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_codec.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()), |
| 170 event_log_(nullptr) { |
166 DCHECK(config.send_transport != nullptr); | 171 DCHECK(config.send_transport != nullptr); |
167 | 172 |
168 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 173 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
169 DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 174 DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
170 config.bitrate_config.min_bitrate_bps); | 175 config.bitrate_config.min_bitrate_bps); |
171 if (config.bitrate_config.max_bitrate_bps != -1) { | 176 if (config.bitrate_config.max_bitrate_bps != -1) { |
172 DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 177 DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
173 config.bitrate_config.start_bitrate_bps); | 178 config.bitrate_config.start_bitrate_bps); |
174 } | 179 } |
| 180 if (config.voice_engine) { |
| 181 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine); |
| 182 if (voe_codec) { |
| 183 event_log_ = voe_codec->GetEventLog(); |
| 184 voe_codec->Release(); |
| 185 } |
| 186 } |
175 | 187 |
176 Trace::CreateTrace(); | 188 Trace::CreateTrace(); |
177 module_process_thread_->Start(); | 189 module_process_thread_->Start(); |
178 | 190 |
179 if (config.overuse_callback) { | 191 if (config.overuse_callback) { |
180 overuse_observer_proxy_.reset( | 192 overuse_observer_proxy_.reset( |
181 new CpuOveruseObserverProxy(config.overuse_callback)); | 193 new CpuOveruseObserverProxy(config.overuse_callback)); |
182 } | 194 } |
183 | 195 |
184 SetBitrateControllerConfig(config_.bitrate_config); | 196 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 | 273 // This needs to be taken before send_crit_ as both locks need to be held |
262 // while changing network state. | 274 // while changing network state. |
263 rtc::CritScope lock(&network_enabled_crit_); | 275 rtc::CritScope lock(&network_enabled_crit_); |
264 WriteLockScoped write_lock(*send_crit_); | 276 WriteLockScoped write_lock(*send_crit_); |
265 for (uint32_t ssrc : config.rtp.ssrcs) { | 277 for (uint32_t ssrc : config.rtp.ssrcs) { |
266 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 278 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
267 video_send_ssrcs_[ssrc] = send_stream; | 279 video_send_ssrcs_[ssrc] = send_stream; |
268 } | 280 } |
269 video_send_streams_.insert(send_stream); | 281 video_send_streams_.insert(send_stream); |
270 | 282 |
| 283 if (event_log_) |
| 284 event_log_->LogVideoSendStreamConfig(config); |
| 285 |
271 if (!network_enabled_) | 286 if (!network_enabled_) |
272 send_stream->SignalNetworkState(kNetworkDown); | 287 send_stream->SignalNetworkState(kNetworkDown); |
273 return send_stream; | 288 return send_stream; |
274 } | 289 } |
275 | 290 |
276 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { | 291 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
277 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); | 292 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); |
278 DCHECK(send_stream != nullptr); | 293 DCHECK(send_stream != nullptr); |
279 | 294 |
280 send_stream->Stop(); | 295 send_stream->Stop(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 config.rtp.rtx.begin(); | 342 config.rtp.rtx.begin(); |
328 if (it != config.rtp.rtx.end()) | 343 if (it != config.rtp.rtx.end()) |
329 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 344 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
330 video_receive_streams_.insert(receive_stream); | 345 video_receive_streams_.insert(receive_stream); |
331 | 346 |
332 ConfigureSync(config.sync_group); | 347 ConfigureSync(config.sync_group); |
333 | 348 |
334 if (!network_enabled_) | 349 if (!network_enabled_) |
335 receive_stream->SignalNetworkState(kNetworkDown); | 350 receive_stream->SignalNetworkState(kNetworkDown); |
336 | 351 |
| 352 if (event_log_) |
| 353 event_log_->LogVideoReceiveStreamConfig(config); |
| 354 |
337 return receive_stream; | 355 return receive_stream; |
338 } | 356 } |
339 | 357 |
340 void Call::DestroyVideoReceiveStream( | 358 void Call::DestroyVideoReceiveStream( |
341 webrtc::VideoReceiveStream* receive_stream) { | 359 webrtc::VideoReceiveStream* receive_stream) { |
342 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 360 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
343 DCHECK(receive_stream != nullptr); | 361 DCHECK(receive_stream != nullptr); |
344 VideoReceiveStream* receive_stream_impl = nullptr; | 362 VideoReceiveStream* receive_stream_impl = nullptr; |
345 { | 363 { |
346 WriteLockScoped write_lock(*receive_crit_); | 364 WriteLockScoped write_lock(*receive_crit_); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 const uint8_t* packet, | 506 const uint8_t* packet, |
489 size_t length) { | 507 size_t length) { |
490 // TODO(pbos): Figure out what channel needs it actually. | 508 // TODO(pbos): Figure out what channel needs it actually. |
491 // Do NOT broadcast! Also make sure it's a valid packet. | 509 // Do NOT broadcast! Also make sure it's a valid packet. |
492 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 510 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
493 // there's no receiver of the packet. | 511 // there's no receiver of the packet. |
494 bool rtcp_delivered = false; | 512 bool rtcp_delivered = false; |
495 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 513 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
496 ReadLockScoped read_lock(*receive_crit_); | 514 ReadLockScoped read_lock(*receive_crit_); |
497 for (VideoReceiveStream* stream : video_receive_streams_) { | 515 for (VideoReceiveStream* stream : video_receive_streams_) { |
498 if (stream->DeliverRtcp(packet, length)) | 516 if (stream->DeliverRtcp(packet, length)) { |
499 rtcp_delivered = true; | 517 rtcp_delivered = true; |
| 518 if (event_log_) |
| 519 event_log_->LogRtcpPacket(true, media_type, packet, length); |
| 520 } |
500 } | 521 } |
501 } | 522 } |
502 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 523 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
503 ReadLockScoped read_lock(*send_crit_); | 524 ReadLockScoped read_lock(*send_crit_); |
504 for (VideoSendStream* stream : video_send_streams_) { | 525 for (VideoSendStream* stream : video_send_streams_) { |
505 if (stream->DeliverRtcp(packet, length)) | 526 if (stream->DeliverRtcp(packet, length)) { |
506 rtcp_delivered = true; | 527 rtcp_delivered = true; |
| 528 if (event_log_) |
| 529 event_log_->LogRtcpPacket(false, media_type, packet, length); |
| 530 } |
507 } | 531 } |
508 } | 532 } |
509 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 533 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
510 } | 534 } |
511 | 535 |
512 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 536 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
513 const uint8_t* packet, | 537 const uint8_t* packet, |
514 size_t length) { | 538 size_t length) { |
515 // Minimum RTP header size. | 539 // Minimum RTP header size. |
516 if (length < 12) | 540 if (length < 12) |
517 return DELIVERY_PACKET_ERROR; | 541 return DELIVERY_PACKET_ERROR; |
518 | 542 |
519 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 543 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
520 | 544 |
| 545 // TODO(ivoc): This should be updated once the splitting of the header is done |
| 546 // in the RtcEventLog. |
| 547 if (event_log_) |
| 548 event_log_->LogRtpHeader(true, media_type, packet, 20, length); |
521 ReadLockScoped read_lock(*receive_crit_); | 549 ReadLockScoped read_lock(*receive_crit_); |
522 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 550 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
523 auto it = audio_receive_ssrcs_.find(ssrc); | 551 auto it = audio_receive_ssrcs_.find(ssrc); |
524 if (it != audio_receive_ssrcs_.end()) { | 552 if (it != audio_receive_ssrcs_.end()) { |
525 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK | 553 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK |
526 : DELIVERY_PACKET_ERROR; | 554 : DELIVERY_PACKET_ERROR; |
527 } | 555 } |
528 } | 556 } |
529 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 557 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
530 auto it = video_receive_ssrcs_.find(ssrc); | 558 auto it = video_receive_ssrcs_.find(ssrc); |
531 if (it != video_receive_ssrcs_.end()) { | 559 if (it != video_receive_ssrcs_.end()) { |
532 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK | 560 return it->second->DeliverRtp(packet, length) ? DELIVERY_OK |
533 : DELIVERY_PACKET_ERROR; | 561 : DELIVERY_PACKET_ERROR; |
534 } | 562 } |
535 } | 563 } |
536 return DELIVERY_UNKNOWN_SSRC; | 564 return DELIVERY_UNKNOWN_SSRC; |
537 } | 565 } |
538 | 566 |
539 PacketReceiver::DeliveryStatus Call::DeliverPacket(MediaType media_type, | 567 PacketReceiver::DeliveryStatus Call::DeliverPacket(MediaType media_type, |
540 const uint8_t* packet, | 568 const uint8_t* packet, |
541 size_t length) { | 569 size_t length) { |
542 if (RtpHeaderParser::IsRtcp(packet, length)) | 570 if (RtpHeaderParser::IsRtcp(packet, length)) |
543 return DeliverRtcp(media_type, packet, length); | 571 return DeliverRtcp(media_type, packet, length); |
544 | 572 |
545 return DeliverRtp(media_type, packet, length); | 573 return DeliverRtp(media_type, packet, length); |
546 } | 574 } |
547 | 575 |
548 } // namespace internal | 576 } // namespace internal |
549 } // namespace webrtc | 577 } // namespace webrtc |
OLD | NEW |