OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... | |
25 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 25 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
26 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 26 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
27 #include "webrtc/modules/video_render/include/video_render.h" | 27 #include "webrtc/modules/video_render/include/video_render.h" |
28 #include "webrtc/system_wrappers/interface/cpu_info.h" | 28 #include "webrtc/system_wrappers/interface/cpu_info.h" |
29 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" | 29 #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
30 #include "webrtc/system_wrappers/interface/logging.h" | 30 #include "webrtc/system_wrappers/interface/logging.h" |
31 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" | 31 #include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" |
32 #include "webrtc/system_wrappers/interface/trace.h" | 32 #include "webrtc/system_wrappers/interface/trace.h" |
33 #include "webrtc/system_wrappers/interface/trace_event.h" | 33 #include "webrtc/system_wrappers/interface/trace_event.h" |
34 #include "webrtc/video/audio_receive_stream.h" | 34 #include "webrtc/video/audio_receive_stream.h" |
35 #include "webrtc/video/rtc_event_log.h" | |
35 #include "webrtc/video/video_receive_stream.h" | 36 #include "webrtc/video/video_receive_stream.h" |
36 #include "webrtc/video/video_send_stream.h" | 37 #include "webrtc/video/video_send_stream.h" |
38 #include "webrtc/voice_engine/include/voe_base.h" | |
37 | 39 |
38 namespace webrtc { | 40 namespace webrtc { |
39 | 41 |
40 const int Call::Config::kDefaultStartBitrateBps = 300000; | 42 const int Call::Config::kDefaultStartBitrateBps = 300000; |
41 | 43 |
42 namespace internal { | 44 namespace internal { |
43 | 45 |
44 class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver { | 46 class CpuOveruseObserverProxy : public webrtc::CpuOveruseObserver { |
45 public: | 47 public: |
46 explicit CpuOveruseObserverProxy(LoadObserver* overuse_callback) | 48 explicit CpuOveruseObserverProxy(LoadObserver* overuse_callback) |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 GUARDED_BY(receive_crit_); | 138 GUARDED_BY(receive_crit_); |
137 | 139 |
138 rtc::scoped_ptr<RWLockWrapper> send_crit_; | 140 rtc::scoped_ptr<RWLockWrapper> send_crit_; |
139 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 141 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
140 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 142 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
141 | 143 |
142 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_; | 144 rtc::scoped_ptr<CpuOveruseObserverProxy> overuse_observer_proxy_; |
143 | 145 |
144 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 146 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
145 | 147 |
148 RtcEventLog* event_log_; | |
149 | |
146 DISALLOW_COPY_AND_ASSIGN(Call); | 150 DISALLOW_COPY_AND_ASSIGN(Call); |
147 }; | 151 }; |
148 } // namespace internal | 152 } // namespace internal |
149 | 153 |
150 Call* Call::Create(const Call::Config& config) { | 154 Call* Call::Create(const Call::Config& config) { |
151 return new internal::Call(config); | 155 return new internal::Call(config); |
152 } | 156 } |
153 | 157 |
154 namespace internal { | 158 namespace internal { |
155 | 159 |
156 Call::Call(const Call::Config& config) | 160 Call::Call(const Call::Config& config) |
157 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 161 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
158 module_process_thread_(ProcessThread::Create()), | 162 module_process_thread_(ProcessThread::Create()), |
159 channel_group_(new ChannelGroup(module_process_thread_.get())), | 163 channel_group_(new ChannelGroup(module_process_thread_.get())), |
160 next_channel_id_(0), | 164 next_channel_id_(0), |
161 config_(config), | 165 config_(config), |
162 network_enabled_(true), | 166 network_enabled_(true), |
163 transport_adapter_(nullptr), | 167 transport_adapter_(nullptr), |
164 receive_crit_(RWLockWrapper::CreateRWLock()), | 168 receive_crit_(RWLockWrapper::CreateRWLock()), |
165 send_crit_(RWLockWrapper::CreateRWLock()) { | 169 send_crit_(RWLockWrapper::CreateRWLock()) { |
166 DCHECK(config.send_transport != nullptr); | 170 DCHECK(config.send_transport != nullptr); |
167 | 171 |
168 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 172 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
169 DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 173 DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
170 config.bitrate_config.min_bitrate_bps); | 174 config.bitrate_config.min_bitrate_bps); |
171 if (config.bitrate_config.max_bitrate_bps != -1) { | 175 if (config.bitrate_config.max_bitrate_bps != -1) { |
172 DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 176 DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
173 config.bitrate_config.start_bitrate_bps); | 177 config.bitrate_config.start_bitrate_bps); |
174 } | 178 } |
179 if (config.voice_engine) { | |
180 VoEBase* voe_base = VoEBase::GetInterface(config.voice_engine); | |
181 event_log_ = voe_base->GetEventLog(); | |
182 voe_base->Release(); | |
terelius
2015/07/30 12:34:43
I don't understand what 'sub-API' means in the doc
ivoc
2015/07/30 15:10:23
Good point on null pointer, I added a check.
Abo
| |
183 } | |
175 | 184 |
176 Trace::CreateTrace(); | 185 Trace::CreateTrace(); |
177 module_process_thread_->Start(); | 186 module_process_thread_->Start(); |
178 | 187 |
179 if (config.overuse_callback) { | 188 if (config.overuse_callback) { |
180 overuse_observer_proxy_.reset( | 189 overuse_observer_proxy_.reset( |
181 new CpuOveruseObserverProxy(config.overuse_callback)); | 190 new CpuOveruseObserverProxy(config.overuse_callback)); |
182 } | 191 } |
183 | 192 |
184 SetBitrateControllerConfig(config_.bitrate_config); | 193 SetBitrateControllerConfig(config_.bitrate_config); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 // This needs to be taken before send_crit_ as both locks need to be held | 270 // This needs to be taken before send_crit_ as both locks need to be held |
262 // while changing network state. | 271 // while changing network state. |
263 rtc::CritScope lock(&network_enabled_crit_); | 272 rtc::CritScope lock(&network_enabled_crit_); |
264 WriteLockScoped write_lock(*send_crit_); | 273 WriteLockScoped write_lock(*send_crit_); |
265 for (uint32_t ssrc : config.rtp.ssrcs) { | 274 for (uint32_t ssrc : config.rtp.ssrcs) { |
266 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 275 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
267 video_send_ssrcs_[ssrc] = send_stream; | 276 video_send_ssrcs_[ssrc] = send_stream; |
268 } | 277 } |
269 video_send_streams_.insert(send_stream); | 278 video_send_streams_.insert(send_stream); |
270 | 279 |
280 if (event_log_) | |
281 event_log_->LogVideoSendStreamConfig(config); | |
282 | |
271 if (!network_enabled_) | 283 if (!network_enabled_) |
272 send_stream->SignalNetworkState(kNetworkDown); | 284 send_stream->SignalNetworkState(kNetworkDown); |
273 return send_stream; | 285 return send_stream; |
274 } | 286 } |
275 | 287 |
276 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { | 288 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
277 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); | 289 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); |
278 DCHECK(send_stream != nullptr); | 290 DCHECK(send_stream != nullptr); |
279 | 291 |
280 send_stream->Stop(); | 292 send_stream->Stop(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 config.rtp.rtx.begin(); | 339 config.rtp.rtx.begin(); |
328 if (it != config.rtp.rtx.end()) | 340 if (it != config.rtp.rtx.end()) |
329 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 341 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
330 video_receive_streams_.insert(receive_stream); | 342 video_receive_streams_.insert(receive_stream); |
331 | 343 |
332 ConfigureSync(config.sync_group); | 344 ConfigureSync(config.sync_group); |
333 | 345 |
334 if (!network_enabled_) | 346 if (!network_enabled_) |
335 receive_stream->SignalNetworkState(kNetworkDown); | 347 receive_stream->SignalNetworkState(kNetworkDown); |
336 | 348 |
349 if (event_log_) | |
350 event_log_->LogVideoReceiveStreamConfig(config); | |
351 | |
337 return receive_stream; | 352 return receive_stream; |
338 } | 353 } |
339 | 354 |
340 void Call::DestroyVideoReceiveStream( | 355 void Call::DestroyVideoReceiveStream( |
341 webrtc::VideoReceiveStream* receive_stream) { | 356 webrtc::VideoReceiveStream* receive_stream) { |
342 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 357 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
343 DCHECK(receive_stream != nullptr); | 358 DCHECK(receive_stream != nullptr); |
344 VideoReceiveStream* receive_stream_impl = nullptr; | 359 VideoReceiveStream* receive_stream_impl = nullptr; |
345 { | 360 { |
346 WriteLockScoped write_lock(*receive_crit_); | 361 WriteLockScoped write_lock(*receive_crit_); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
488 const uint8_t* packet, | 503 const uint8_t* packet, |
489 size_t length) { | 504 size_t length) { |
490 // TODO(pbos): Figure out what channel needs it actually. | 505 // TODO(pbos): Figure out what channel needs it actually. |
491 // Do NOT broadcast! Also make sure it's a valid packet. | 506 // Do NOT broadcast! Also make sure it's a valid packet. |
492 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 507 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
493 // there's no receiver of the packet. | 508 // there's no receiver of the packet. |
494 bool rtcp_delivered = false; | 509 bool rtcp_delivered = false; |
495 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 510 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
496 ReadLockScoped read_lock(*receive_crit_); | 511 ReadLockScoped read_lock(*receive_crit_); |
497 for (VideoReceiveStream* stream : video_receive_streams_) { | 512 for (VideoReceiveStream* stream : video_receive_streams_) { |
498 if (stream->DeliverRtcp(packet, length)) | 513 if (stream->DeliverRtcp(packet, length)) { |
499 rtcp_delivered = true; | 514 rtcp_delivered = true; |
515 if (event_log_) | |
516 event_log_->LogRtcpPacket(true, media_type, packet, length); | |
517 } | |
500 } | 518 } |
501 } | 519 } |
502 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 520 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
503 ReadLockScoped read_lock(*send_crit_); | 521 ReadLockScoped read_lock(*send_crit_); |
504 for (VideoSendStream* stream : video_send_streams_) { | 522 for (VideoSendStream* stream : video_send_streams_) { |
505 if (stream->DeliverRtcp(packet, length)) | 523 if (stream->DeliverRtcp(packet, length)) { |
506 rtcp_delivered = true; | 524 rtcp_delivered = true; |
525 if (event_log_) | |
526 event_log_->LogRtcpPacket(false, media_type, packet, length); | |
527 } | |
507 } | 528 } |
508 } | 529 } |
509 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 530 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
510 } | 531 } |
511 | 532 |
512 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 533 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
513 const uint8_t* packet, | 534 const uint8_t* packet, |
514 size_t length) { | 535 size_t length) { |
515 // Minimum RTP header size. | 536 // Minimum RTP header size. |
516 if (length < 12) | 537 if (length < 12) |
517 return DELIVERY_PACKET_ERROR; | 538 return DELIVERY_PACKET_ERROR; |
518 | 539 |
519 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 540 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
520 | 541 |
542 // TODO(ivoc): This should be updated once the splitting of the header is done | |
543 // in the RtcEventLog. | |
544 if (event_log_) | |
545 event_log_->LogRtpHeader(true, media_type, packet, 20, length); | |
521 ReadLockScoped read_lock(*receive_crit_); | 546 ReadLockScoped read_lock(*receive_crit_); |
522 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 547 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
523 auto it = audio_receive_ssrcs_.find(ssrc); | 548 auto it = audio_receive_ssrcs_.find(ssrc); |
524 if (it != audio_receive_ssrcs_.end()) { | 549 if (it != audio_receive_ssrcs_.end()) { |
525 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK | 550 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK |
526 : DELIVERY_PACKET_ERROR; | 551 : DELIVERY_PACKET_ERROR; |
527 } | 552 } |
528 } | 553 } |
529 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 554 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
530 auto it = video_receive_ssrcs_.find(ssrc); | 555 auto it = video_receive_ssrcs_.find(ssrc); |
531 if (it != video_receive_ssrcs_.end()) { | 556 if (it != video_receive_ssrcs_.end()) { |
532 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK | 557 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK |
533 : DELIVERY_PACKET_ERROR; | 558 : DELIVERY_PACKET_ERROR; |
534 } | 559 } |
535 } | 560 } |
536 return DELIVERY_UNKNOWN_SSRC; | 561 return DELIVERY_UNKNOWN_SSRC; |
537 } | 562 } |
538 | 563 |
539 PacketReceiver::DeliveryStatus Call::DeliverPacket(MediaType media_type, | 564 PacketReceiver::DeliveryStatus Call::DeliverPacket(MediaType media_type, |
540 const uint8_t* packet, | 565 const uint8_t* packet, |
541 size_t length) { | 566 size_t length) { |
542 if (RtpHeaderParser::IsRtcp(packet, length)) | 567 if (RtpHeaderParser::IsRtcp(packet, length)) |
543 return DeliverRtcp(media_type, packet, length); | 568 return DeliverRtcp(media_type, packet, length); |
544 | 569 |
545 return DeliverRtp(media_type, packet, length); | 570 return DeliverRtp(media_type, packet, length); |
546 } | 571 } |
547 | 572 |
548 } // namespace internal | 573 } // namespace internal |
549 } // namespace webrtc | 574 } // namespace webrtc |
OLD | NEW |