blob: bcdcbf76868eb42e329454a97a209cb165d6803a [file] [log] [blame]
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
pbos@webrtc.org3f45c2e2013-08-05 16:22:53 +000011#include <assert.h>
12#include <string.h>
13
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +000014#include <map>
15#include <vector>
16
pbos@webrtc.org24e20892013-10-28 16:32:01 +000017#include "webrtc/call.h"
stefan@webrtc.org47f0c412013-12-04 10:24:26 +000018#include "webrtc/common.h"
pbos@webrtc.orgd05597a2013-12-05 12:11:47 +000019#include "webrtc/config.h"
pbos@webrtc.org24e20892013-10-28 16:32:01 +000020#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +000021#include "webrtc/system_wrappers/interface/critical_section_wrapper.h"
pbos@webrtc.org24e20892013-10-28 16:32:01 +000022#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h"
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +000023#include "webrtc/system_wrappers/interface/scoped_ptr.h"
24#include "webrtc/system_wrappers/interface/trace.h"
pbos@webrtc.org24e20892013-10-28 16:32:01 +000025#include "webrtc/video/video_receive_stream.h"
26#include "webrtc/video/video_send_stream.h"
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +000027#include "webrtc/video_engine/include/vie_base.h"
28#include "webrtc/video_engine/include/vie_codec.h"
29#include "webrtc/video_engine/include/vie_rtp_rtcp.h"
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +000030
31namespace webrtc {
pbos@webrtc.orgd05597a2013-12-05 12:11:47 +000032const char* RtpExtension::kTOffset = "urn:ietf:params:rtp-hdrext:toffset";
33const char* RtpExtension::kAbsSendTime =
34 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
pbos@webrtc.org24e20892013-10-28 16:32:01 +000035namespace internal {
asapersson@webrtc.org8ef65482014-01-31 10:05:07 +000036
37class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver {
38 public:
39 CpuOveruseObserverProxy(OveruseCallback* overuse_callback)
40 : crit_(CriticalSectionWrapper::CreateCriticalSection()),
41 overuse_callback_(overuse_callback) {
42 assert(overuse_callback != NULL);
43 }
44
45 virtual ~CpuOveruseObserverProxy() {}
46
47 virtual void OveruseDetected() OVERRIDE {
48 CriticalSectionScoped cs(crit_.get());
49 overuse_callback_->OnOveruse();
50 }
51
52 virtual void NormalUsage() OVERRIDE {
53 CriticalSectionScoped cs(crit_.get());
54 overuse_callback_->OnNormalUse();
55 }
56
57 private:
58 scoped_ptr<CriticalSectionWrapper> crit_;
59 OveruseCallback* overuse_callback_;
60};
61
pbos@webrtc.org24e20892013-10-28 16:32:01 +000062class Call : public webrtc::Call, public PacketReceiver {
63 public:
64 Call(webrtc::VideoEngine* video_engine, const Call::Config& config);
65 virtual ~Call();
66
67 virtual PacketReceiver* Receiver() OVERRIDE;
pbos@webrtc.org24e20892013-10-28 16:32:01 +000068
69 virtual VideoSendStream::Config GetDefaultSendConfig() OVERRIDE;
70
pbos@webrtc.org964d78e2013-11-20 10:40:25 +000071 virtual VideoSendStream* CreateVideoSendStream(
pbos@webrtc.org24e20892013-10-28 16:32:01 +000072 const VideoSendStream::Config& config) OVERRIDE;
73
pbos@webrtc.org12a93e02013-11-21 13:49:43 +000074 virtual void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream)
75 OVERRIDE;
pbos@webrtc.org24e20892013-10-28 16:32:01 +000076
77 virtual VideoReceiveStream::Config GetDefaultReceiveConfig() OVERRIDE;
78
pbos@webrtc.org964d78e2013-11-20 10:40:25 +000079 virtual VideoReceiveStream* CreateVideoReceiveStream(
pbos@webrtc.org24e20892013-10-28 16:32:01 +000080 const VideoReceiveStream::Config& config) OVERRIDE;
81
pbos@webrtc.org12a93e02013-11-21 13:49:43 +000082 virtual void DestroyVideoReceiveStream(
pbos@webrtc.org24e20892013-10-28 16:32:01 +000083 webrtc::VideoReceiveStream* receive_stream) OVERRIDE;
84
85 virtual uint32_t SendBitrateEstimate() OVERRIDE;
86 virtual uint32_t ReceiveBitrateEstimate() OVERRIDE;
87
88 virtual bool DeliverPacket(const uint8_t* packet, size_t length) OVERRIDE;
89
90 private:
91 bool DeliverRtcp(const uint8_t* packet, size_t length);
92 bool DeliverRtp(const RTPHeader& header,
93 const uint8_t* packet,
94 size_t length);
95
96 Call::Config config_;
97
98 std::map<uint32_t, VideoReceiveStream*> receive_ssrcs_;
99 scoped_ptr<RWLockWrapper> receive_lock_;
100
101 std::map<uint32_t, VideoSendStream*> send_ssrcs_;
102 scoped_ptr<RWLockWrapper> send_lock_;
103
104 scoped_ptr<RtpHeaderParser> rtp_header_parser_;
105
asapersson@webrtc.org8ef65482014-01-31 10:05:07 +0000106 scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_;
107
mflodman@webrtc.orgdadfc9e2013-12-13 09:40:45 +0000108 VideoEngine* video_engine_;
pbos@webrtc.org24e20892013-10-28 16:32:01 +0000109 ViERTP_RTCP* rtp_rtcp_;
110 ViECodec* codec_;
mflodman@webrtc.orgdadfc9e2013-12-13 09:40:45 +0000111 ViEBase* base_;
112 int base_channel_id_;
pbos@webrtc.org24e20892013-10-28 16:32:01 +0000113
114 DISALLOW_COPY_AND_ASSIGN(Call);
115};
pbos@webrtc.orgd05597a2013-12-05 12:11:47 +0000116} // namespace internal
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +0000117
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000118class TraceDispatcher : public TraceCallback {
119 public:
120 TraceDispatcher()
pbos@webrtc.orga370f242014-01-27 09:11:10 +0000121 : lock_(CriticalSectionWrapper::CreateCriticalSection()),
122 filter_(kTraceNone) {
123 Trace::CreateTrace();
124 VideoEngine::SetTraceCallback(this);
125 VideoEngine::SetTraceFilter(kTraceNone);
126 }
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000127
pbos@webrtc.orga6063fd2013-10-02 16:22:18 +0000128 ~TraceDispatcher() {
pbos@webrtc.orga370f242014-01-27 09:11:10 +0000129 Trace::ReturnTrace();
130 VideoEngine::SetTraceCallback(NULL);
pbos@webrtc.orga6063fd2013-10-02 16:22:18 +0000131 }
132
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000133 virtual void Print(TraceLevel level,
134 const char* message,
135 int length) OVERRIDE {
pbos@webrtc.orga370f242014-01-27 09:11:10 +0000136 CriticalSectionScoped crit(lock_.get());
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000137 for (std::map<Call*, Call::Config*>::iterator it = callbacks_.begin();
138 it != callbacks_.end();
139 ++it) {
140 if ((level & it->second->trace_filter) != kTraceNone)
141 it->second->trace_callback->Print(level, message, length);
142 }
143 }
144
145 void RegisterCallback(Call* call, Call::Config* config) {
146 if (config->trace_callback == NULL)
147 return;
148
pbos@webrtc.orga370f242014-01-27 09:11:10 +0000149 CriticalSectionScoped crit(lock_.get());
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000150 callbacks_[call] = config;
151
pbos@webrtc.orga6063fd2013-10-02 16:22:18 +0000152 filter_ |= config->trace_filter;
pbos@webrtc.orga6063fd2013-10-02 16:22:18 +0000153 VideoEngine::SetTraceFilter(filter_);
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000154 }
155
156 void DeregisterCallback(Call* call) {
pbos@webrtc.orga370f242014-01-27 09:11:10 +0000157 CriticalSectionScoped crit(lock_.get());
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000158 callbacks_.erase(call);
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000159
160 filter_ = kTraceNone;
161 for (std::map<Call*, Call::Config*>::iterator it = callbacks_.begin();
162 it != callbacks_.end();
163 ++it) {
164 filter_ |= it->second->trace_filter;
165 }
166
167 VideoEngine::SetTraceFilter(filter_);
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000168 }
169
170 private:
pbos@webrtc.orga370f242014-01-27 09:11:10 +0000171 scoped_ptr<CriticalSectionWrapper> lock_;
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000172 unsigned int filter_;
173 std::map<Call*, Call::Config*> callbacks_;
174};
175
176namespace internal {
pbos@webrtc.org24e20892013-10-28 16:32:01 +0000177TraceDispatcher* global_trace_dispatcher = NULL;
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000178} // internal
179
stefan@webrtc.org47f0c412013-12-04 10:24:26 +0000180void CreateTraceDispatcher() {
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000181 if (internal::global_trace_dispatcher == NULL) {
182 TraceDispatcher* dispatcher = new TraceDispatcher();
183 // TODO(pbos): Atomic compare and exchange.
184 if (internal::global_trace_dispatcher == NULL) {
185 internal::global_trace_dispatcher = dispatcher;
186 } else {
187 delete dispatcher;
188 }
189 }
stefan@webrtc.org47f0c412013-12-04 10:24:26 +0000190}
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000191
stefan@webrtc.org47f0c412013-12-04 10:24:26 +0000192Call* Call::Create(const Call::Config& config) {
193 CreateTraceDispatcher();
194
pbos@webrtc.orgc71929d2014-01-24 09:30:53 +0000195 VideoEngine* video_engine = config.webrtc_config != NULL
196 ? VideoEngine::Create(*config.webrtc_config)
197 : VideoEngine::Create();
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +0000198 assert(video_engine != NULL);
199
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000200 return new internal::Call(video_engine, config);
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +0000201}
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +0000202
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000203namespace internal {
204
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000205Call::Call(webrtc::VideoEngine* video_engine, const Call::Config& config)
mflodman@webrtc.orgbf76ae22013-07-23 11:35:00 +0000206 : config_(config),
pbos@webrtc.org63988b22013-06-10 13:48:26 +0000207 receive_lock_(RWLockWrapper::CreateRWLock()),
208 send_lock_(RWLockWrapper::CreateRWLock()),
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000209 rtp_header_parser_(RtpHeaderParser::Create()),
mflodman@webrtc.orgdadfc9e2013-12-13 09:40:45 +0000210 video_engine_(video_engine),
211 base_channel_id_(-1) {
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000212 assert(video_engine != NULL);
mflodman@webrtc.orgbf76ae22013-07-23 11:35:00 +0000213 assert(config.send_transport != NULL);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000214
asapersson@webrtc.org8ef65482014-01-31 10:05:07 +0000215 if (config.overuse_callback) {
216 overuse_observer_proxy_.reset(
217 new CpuOveruseObserverProxy(config.overuse_callback));
218 }
219
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000220 global_trace_dispatcher->RegisterCallback(this, &config_);
221
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000222 rtp_rtcp_ = ViERTP_RTCP::GetInterface(video_engine_);
223 assert(rtp_rtcp_ != NULL);
224
225 codec_ = ViECodec::GetInterface(video_engine_);
226 assert(codec_ != NULL);
mflodman@webrtc.orgdadfc9e2013-12-13 09:40:45 +0000227
228 // As a workaround for non-existing calls in the old API, create a base
229 // channel used as default channel when creating send and receive streams.
230 base_ = ViEBase::GetInterface(video_engine_);
231 assert(base_ != NULL);
232
233 base_->CreateChannel(base_channel_id_);
234 assert(base_channel_id_ != -1);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000235}
236
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000237Call::~Call() {
pbos@webrtc.orgb5d2d162013-10-02 13:36:09 +0000238 global_trace_dispatcher->DeregisterCallback(this);
mflodman@webrtc.orgdadfc9e2013-12-13 09:40:45 +0000239 base_->DeleteChannel(base_channel_id_);
240 base_->Release();
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000241 codec_->Release();
pbos@webrtc.orgc2014fd2013-08-14 13:52:52 +0000242 rtp_rtcp_->Release();
243 webrtc::VideoEngine::Delete(video_engine_);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000244}
245
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000246PacketReceiver* Call::Receiver() { return this; }
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000247
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000248VideoSendStream::Config Call::GetDefaultSendConfig() {
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +0000249 VideoSendStream::Config config;
pbos@webrtc.org6f1c3ef2013-06-05 11:33:21 +0000250 return config;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000251}
252
pbos@webrtc.org964d78e2013-11-20 10:40:25 +0000253VideoSendStream* Call::CreateVideoSendStream(
254 const VideoSendStream::Config& config) {
pbos@webrtc.org63988b22013-06-10 13:48:26 +0000255 assert(config.rtp.ssrcs.size() > 0);
pbos@webrtc.org63988b22013-06-10 13:48:26 +0000256
asapersson@webrtc.org8ef65482014-01-31 10:05:07 +0000257 VideoSendStream* send_stream = new VideoSendStream(
258 config_.send_transport,
259 overuse_observer_proxy_.get(),
260 video_engine_,
261 config,
262 base_channel_id_);
pbos@webrtc.org63988b22013-06-10 13:48:26 +0000263
264 WriteLockScoped write_lock(*send_lock_);
265 for (size_t i = 0; i < config.rtp.ssrcs.size(); ++i) {
266 assert(send_ssrcs_.find(config.rtp.ssrcs[i]) == send_ssrcs_.end());
267 send_ssrcs_[config.rtp.ssrcs[i]] = send_stream;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000268 }
269 return send_stream;
270}
271
pbos@webrtc.org12a93e02013-11-21 13:49:43 +0000272void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
pbos@webrtc.org00208582013-09-05 12:38:54 +0000273 assert(send_stream != NULL);
274
275 VideoSendStream* send_stream_impl = NULL;
276 {
277 WriteLockScoped write_lock(*send_lock_);
278 for (std::map<uint32_t, VideoSendStream*>::iterator it =
279 send_ssrcs_.begin();
280 it != send_ssrcs_.end();
281 ++it) {
282 if (it->second == static_cast<VideoSendStream*>(send_stream)) {
283 send_stream_impl = it->second;
284 send_ssrcs_.erase(it);
285 break;
286 }
287 }
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000288 }
pbos@webrtc.org00208582013-09-05 12:38:54 +0000289
290 assert(send_stream_impl != NULL);
291 delete send_stream_impl;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000292}
293
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000294VideoReceiveStream::Config Call::GetDefaultReceiveConfig() {
mflodman@webrtc.org7ff40892013-12-13 16:36:28 +0000295 VideoReceiveStream::Config config;
296 config.rtp.remb = true;
297 return config;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000298}
299
pbos@webrtc.org964d78e2013-11-20 10:40:25 +0000300VideoReceiveStream* Call::CreateVideoReceiveStream(
pbos@webrtc.orgc1797062013-08-23 09:19:30 +0000301 const VideoReceiveStream::Config& config) {
mflodman@webrtc.orgdadfc9e2013-12-13 09:40:45 +0000302 VideoReceiveStream* receive_stream =
303 new VideoReceiveStream(video_engine_,
304 config,
305 config_.send_transport,
306 config_.voice_engine,
307 base_channel_id_);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000308
pbos@webrtc.org63988b22013-06-10 13:48:26 +0000309 WriteLockScoped write_lock(*receive_lock_);
pbos@webrtc.org4b50db12013-12-03 10:13:04 +0000310 assert(receive_ssrcs_.find(config.rtp.remote_ssrc) == receive_ssrcs_.end());
311 receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
pbos@webrtc.orgc71929d2014-01-24 09:30:53 +0000312 // TODO(pbos): Configure different RTX payloads per receive payload.
313 VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it =
314 config.rtp.rtx.begin();
315 if (it != config.rtp.rtx.end())
316 receive_ssrcs_[it->second.ssrc] = receive_stream;
317
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000318 return receive_stream;
319}
320
pbos@webrtc.org12a93e02013-11-21 13:49:43 +0000321void Call::DestroyVideoReceiveStream(
322 webrtc::VideoReceiveStream* receive_stream) {
pbos@webrtc.org00208582013-09-05 12:38:54 +0000323 assert(receive_stream != NULL);
324
325 VideoReceiveStream* receive_stream_impl = NULL;
326 {
327 WriteLockScoped write_lock(*receive_lock_);
pbos@webrtc.orgc71929d2014-01-24 09:30:53 +0000328 // Remove all ssrcs pointing to a receive stream. As RTX retransmits on a
329 // separate SSRC there can be either one or two.
330 std::map<uint32_t, VideoReceiveStream*>::iterator it =
331 receive_ssrcs_.begin();
332 while (it != receive_ssrcs_.end()) {
pbos@webrtc.org00208582013-09-05 12:38:54 +0000333 if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) {
solenberg@webrtc.org2bb7ad52014-01-29 11:21:58 +0000334 assert(receive_stream_impl == NULL ||
335 receive_stream_impl == it->second);
pbos@webrtc.org00208582013-09-05 12:38:54 +0000336 receive_stream_impl = it->second;
pbos@webrtc.orgc71929d2014-01-24 09:30:53 +0000337 receive_ssrcs_.erase(it++);
338 } else {
339 ++it;
pbos@webrtc.org00208582013-09-05 12:38:54 +0000340 }
341 }
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000342 }
pbos@webrtc.org00208582013-09-05 12:38:54 +0000343
344 assert(receive_stream_impl != NULL);
345 delete receive_stream_impl;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000346}
347
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000348uint32_t Call::SendBitrateEstimate() {
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000349 // TODO(pbos): Return send-bitrate estimate
350 return 0;
351}
352
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000353uint32_t Call::ReceiveBitrateEstimate() {
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000354 // TODO(pbos): Return receive-bitrate estimate
355 return 0;
356}
357
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000358bool Call::DeliverRtcp(const uint8_t* packet, size_t length) {
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000359 // TODO(pbos): Figure out what channel needs it actually.
360 // Do NOT broadcast! Also make sure it's a valid packet.
361 bool rtcp_delivered = false;
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000362 {
363 ReadLockScoped read_lock(*receive_lock_);
364 for (std::map<uint32_t, VideoReceiveStream*>::iterator it =
365 receive_ssrcs_.begin();
366 it != receive_ssrcs_.end();
367 ++it) {
pbos@webrtc.org00112522013-09-20 11:56:26 +0000368 if (it->second->DeliverRtcp(packet, length))
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000369 rtcp_delivered = true;
pbos@webrtc.orgce851092013-08-05 12:01:36 +0000370 }
371 }
372
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000373 {
374 ReadLockScoped read_lock(*send_lock_);
375 for (std::map<uint32_t, VideoSendStream*>::iterator it =
376 send_ssrcs_.begin();
377 it != send_ssrcs_.end();
378 ++it) {
pbos@webrtc.org00112522013-09-20 11:56:26 +0000379 if (it->second->DeliverRtcp(packet, length))
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000380 rtcp_delivered = true;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000381 }
382 }
383 return rtcp_delivered;
384}
385
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000386bool Call::DeliverRtp(const RTPHeader& header,
387 const uint8_t* packet,
388 size_t length) {
solenberg@webrtc.org2bb7ad52014-01-29 11:21:58 +0000389 ReadLockScoped read_lock(*receive_lock_);
390 std::map<uint32_t, VideoReceiveStream*>::iterator it =
391 receive_ssrcs_.find(header.ssrc);
392 if (it == receive_ssrcs_.end()) {
393 // TODO(pbos): Log some warning, SSRC without receiver.
394 return false;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000395 }
solenberg@webrtc.org2bb7ad52014-01-29 11:21:58 +0000396 return it->second->DeliverRtp(static_cast<const uint8_t*>(packet), length);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000397}
398
pbos@webrtc.orgbf6d5722013-09-09 15:04:25 +0000399bool Call::DeliverPacket(const uint8_t* packet, size_t length) {
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000400 // TODO(pbos): ExtensionMap if there are extensions.
401 if (RtpHeaderParser::IsRtcp(packet, static_cast<int>(length)))
402 return DeliverRtcp(packet, length);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000403
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000404 RTPHeader rtp_header;
405 if (!rtp_header_parser_->Parse(packet, static_cast<int>(length), &rtp_header))
406 return false;
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000407
pbos@webrtc.org78ab5112013-08-05 12:49:22 +0000408 return DeliverRtp(rtp_header, packet, length);
pbos@webrtc.org2a9108f2013-05-16 12:08:03 +0000409}
410
411} // namespace internal
412} // namespace webrtc