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 Call : public webrtc::Call, public PacketReceiver { | 46 class Call : public webrtc::Call, public PacketReceiver { |
45 public: | 47 public: |
46 explicit Call(const Call::Config& config); | 48 explicit Call(const Call::Config& config); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 GUARDED_BY(receive_crit_); | 115 GUARDED_BY(receive_crit_); |
114 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ | 116 std::map<std::string, AudioReceiveStream*> sync_stream_mapping_ |
115 GUARDED_BY(receive_crit_); | 117 GUARDED_BY(receive_crit_); |
116 | 118 |
117 rtc::scoped_ptr<RWLockWrapper> send_crit_; | 119 rtc::scoped_ptr<RWLockWrapper> send_crit_; |
118 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 120 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
119 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 121 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
120 | 122 |
121 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 123 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
122 | 124 |
| 125 RtcEventLog* event_log_; |
| 126 |
123 DISALLOW_COPY_AND_ASSIGN(Call); | 127 DISALLOW_COPY_AND_ASSIGN(Call); |
124 }; | 128 }; |
125 } // namespace internal | 129 } // namespace internal |
126 | 130 |
127 Call* Call::Create(const Call::Config& config) { | 131 Call* Call::Create(const Call::Config& config) { |
128 return new internal::Call(config); | 132 return new internal::Call(config); |
129 } | 133 } |
130 | 134 |
131 namespace internal { | 135 namespace internal { |
132 | 136 |
133 Call::Call(const Call::Config& config) | 137 Call::Call(const Call::Config& config) |
134 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), | 138 : num_cpu_cores_(CpuInfo::DetectNumberOfCores()), |
135 module_process_thread_(ProcessThread::Create()), | 139 module_process_thread_(ProcessThread::Create()), |
136 channel_group_(new ChannelGroup(module_process_thread_.get())), | 140 channel_group_(new ChannelGroup(module_process_thread_.get())), |
137 next_channel_id_(0), | 141 next_channel_id_(0), |
138 config_(config), | 142 config_(config), |
139 network_enabled_(true), | 143 network_enabled_(true), |
140 receive_crit_(RWLockWrapper::CreateRWLock()), | 144 receive_crit_(RWLockWrapper::CreateRWLock()), |
141 send_crit_(RWLockWrapper::CreateRWLock()) { | 145 send_crit_(RWLockWrapper::CreateRWLock()), |
| 146 event_log_(nullptr) { |
142 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 147 DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
143 DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 148 DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
144 config.bitrate_config.min_bitrate_bps); | 149 config.bitrate_config.min_bitrate_bps); |
145 if (config.bitrate_config.max_bitrate_bps != -1) { | 150 if (config.bitrate_config.max_bitrate_bps != -1) { |
146 DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 151 DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
147 config.bitrate_config.start_bitrate_bps); | 152 config.bitrate_config.start_bitrate_bps); |
148 } | 153 } |
| 154 if (config.voice_engine) { |
| 155 VoECodec* voe_codec = VoECodec::GetInterface(config.voice_engine); |
| 156 if (voe_codec) { |
| 157 event_log_ = voe_codec->GetEventLog(); |
| 158 voe_codec->Release(); |
| 159 } |
| 160 } |
149 | 161 |
150 Trace::CreateTrace(); | 162 Trace::CreateTrace(); |
151 module_process_thread_->Start(); | 163 module_process_thread_->Start(); |
152 | 164 |
153 SetBitrateControllerConfig(config_.bitrate_config); | 165 SetBitrateControllerConfig(config_.bitrate_config); |
154 } | 166 } |
155 | 167 |
156 Call::~Call() { | 168 Call::~Call() { |
157 CHECK_EQ(0u, video_send_ssrcs_.size()); | 169 CHECK_EQ(0u, video_send_ssrcs_.size()); |
158 CHECK_EQ(0u, video_send_streams_.size()); | 170 CHECK_EQ(0u, video_send_streams_.size()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // This needs to be taken before send_crit_ as both locks need to be held | 241 // This needs to be taken before send_crit_ as both locks need to be held |
230 // while changing network state. | 242 // while changing network state. |
231 rtc::CritScope lock(&network_enabled_crit_); | 243 rtc::CritScope lock(&network_enabled_crit_); |
232 WriteLockScoped write_lock(*send_crit_); | 244 WriteLockScoped write_lock(*send_crit_); |
233 for (uint32_t ssrc : config.rtp.ssrcs) { | 245 for (uint32_t ssrc : config.rtp.ssrcs) { |
234 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 246 DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
235 video_send_ssrcs_[ssrc] = send_stream; | 247 video_send_ssrcs_[ssrc] = send_stream; |
236 } | 248 } |
237 video_send_streams_.insert(send_stream); | 249 video_send_streams_.insert(send_stream); |
238 | 250 |
| 251 if (event_log_) |
| 252 event_log_->LogVideoSendStreamConfig(config); |
| 253 |
239 if (!network_enabled_) | 254 if (!network_enabled_) |
240 send_stream->SignalNetworkState(kNetworkDown); | 255 send_stream->SignalNetworkState(kNetworkDown); |
241 return send_stream; | 256 return send_stream; |
242 } | 257 } |
243 | 258 |
244 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { | 259 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
245 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); | 260 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); |
246 DCHECK(send_stream != nullptr); | 261 DCHECK(send_stream != nullptr); |
247 | 262 |
248 send_stream->Stop(); | 263 send_stream->Stop(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 config.rtp.rtx.begin(); | 310 config.rtp.rtx.begin(); |
296 if (it != config.rtp.rtx.end()) | 311 if (it != config.rtp.rtx.end()) |
297 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 312 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
298 video_receive_streams_.insert(receive_stream); | 313 video_receive_streams_.insert(receive_stream); |
299 | 314 |
300 ConfigureSync(config.sync_group); | 315 ConfigureSync(config.sync_group); |
301 | 316 |
302 if (!network_enabled_) | 317 if (!network_enabled_) |
303 receive_stream->SignalNetworkState(kNetworkDown); | 318 receive_stream->SignalNetworkState(kNetworkDown); |
304 | 319 |
| 320 if (event_log_) |
| 321 event_log_->LogVideoReceiveStreamConfig(config); |
| 322 |
305 return receive_stream; | 323 return receive_stream; |
306 } | 324 } |
307 | 325 |
308 void Call::DestroyVideoReceiveStream( | 326 void Call::DestroyVideoReceiveStream( |
309 webrtc::VideoReceiveStream* receive_stream) { | 327 webrtc::VideoReceiveStream* receive_stream) { |
310 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 328 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
311 DCHECK(receive_stream != nullptr); | 329 DCHECK(receive_stream != nullptr); |
312 VideoReceiveStream* receive_stream_impl = nullptr; | 330 VideoReceiveStream* receive_stream_impl = nullptr; |
313 { | 331 { |
314 WriteLockScoped write_lock(*receive_crit_); | 332 WriteLockScoped write_lock(*receive_crit_); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 const uint8_t* packet, | 474 const uint8_t* packet, |
457 size_t length) { | 475 size_t length) { |
458 // TODO(pbos): Figure out what channel needs it actually. | 476 // TODO(pbos): Figure out what channel needs it actually. |
459 // Do NOT broadcast! Also make sure it's a valid packet. | 477 // Do NOT broadcast! Also make sure it's a valid packet. |
460 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 478 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
461 // there's no receiver of the packet. | 479 // there's no receiver of the packet. |
462 bool rtcp_delivered = false; | 480 bool rtcp_delivered = false; |
463 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 481 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
464 ReadLockScoped read_lock(*receive_crit_); | 482 ReadLockScoped read_lock(*receive_crit_); |
465 for (VideoReceiveStream* stream : video_receive_streams_) { | 483 for (VideoReceiveStream* stream : video_receive_streams_) { |
466 if (stream->DeliverRtcp(packet, length)) | 484 if (stream->DeliverRtcp(packet, length)) { |
467 rtcp_delivered = true; | 485 rtcp_delivered = true; |
| 486 if (event_log_) |
| 487 event_log_->LogRtcpPacket(true, media_type, packet, length); |
| 488 } |
468 } | 489 } |
469 } | 490 } |
470 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 491 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
471 ReadLockScoped read_lock(*send_crit_); | 492 ReadLockScoped read_lock(*send_crit_); |
472 for (VideoSendStream* stream : video_send_streams_) { | 493 for (VideoSendStream* stream : video_send_streams_) { |
473 if (stream->DeliverRtcp(packet, length)) | 494 if (stream->DeliverRtcp(packet, length)) { |
474 rtcp_delivered = true; | 495 rtcp_delivered = true; |
| 496 if (event_log_) |
| 497 event_log_->LogRtcpPacket(false, media_type, packet, length); |
| 498 } |
475 } | 499 } |
476 } | 500 } |
477 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 501 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
478 } | 502 } |
479 | 503 |
480 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 504 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
481 const uint8_t* packet, | 505 const uint8_t* packet, |
482 size_t length, | 506 size_t length, |
483 const PacketTime& packet_time) { | 507 const PacketTime& packet_time) { |
484 // Minimum RTP header size. | 508 // Minimum RTP header size. |
485 if (length < 12) | 509 if (length < 12) |
486 return DELIVERY_PACKET_ERROR; | 510 return DELIVERY_PACKET_ERROR; |
487 | 511 |
488 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 512 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
489 | 513 |
490 ReadLockScoped read_lock(*receive_crit_); | 514 ReadLockScoped read_lock(*receive_crit_); |
491 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 515 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
492 auto it = audio_receive_ssrcs_.find(ssrc); | 516 auto it = audio_receive_ssrcs_.find(ssrc); |
493 if (it != audio_receive_ssrcs_.end()) { | 517 if (it != audio_receive_ssrcs_.end()) { |
494 return it->second->DeliverRtp(packet, length, packet_time) | 518 auto status = it->second->DeliverRtp(packet, length, packet_time) |
495 ? DELIVERY_OK | 519 ? DELIVERY_OK |
496 : DELIVERY_PACKET_ERROR; | 520 : DELIVERY_PACKET_ERROR; |
| 521 if (status == DELIVERY_OK && event_log_) |
| 522 event_log_->LogRtpHeader(true, media_type, packet, length); |
| 523 return status; |
497 } | 524 } |
498 } | 525 } |
499 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 526 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
500 auto it = video_receive_ssrcs_.find(ssrc); | 527 auto it = video_receive_ssrcs_.find(ssrc); |
501 if (it != video_receive_ssrcs_.end()) { | 528 if (it != video_receive_ssrcs_.end()) { |
502 return it->second->DeliverRtp(packet, length, packet_time) | 529 auto status = it->second->DeliverRtp(packet, length, packet_time) |
503 ? DELIVERY_OK | 530 ? DELIVERY_OK |
504 : DELIVERY_PACKET_ERROR; | 531 : DELIVERY_PACKET_ERROR; |
| 532 if (status == DELIVERY_OK && event_log_) |
| 533 event_log_->LogRtpHeader(true, media_type, packet, length); |
| 534 return status; |
505 } | 535 } |
506 } | 536 } |
507 return DELIVERY_UNKNOWN_SSRC; | 537 return DELIVERY_UNKNOWN_SSRC; |
508 } | 538 } |
509 | 539 |
510 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 540 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
511 MediaType media_type, | 541 MediaType media_type, |
512 const uint8_t* packet, | 542 const uint8_t* packet, |
513 size_t length, | 543 size_t length, |
514 const PacketTime& packet_time) { | 544 const PacketTime& packet_time) { |
515 if (RtpHeaderParser::IsRtcp(packet, length)) | 545 if (RtpHeaderParser::IsRtcp(packet, length)) |
516 return DeliverRtcp(media_type, packet, length); | 546 return DeliverRtcp(media_type, packet, length); |
517 | 547 |
518 return DeliverRtp(media_type, packet, length, packet_time); | 548 return DeliverRtp(media_type, packet, length, packet_time); |
519 } | 549 } |
520 | 550 |
521 } // namespace internal | 551 } // namespace internal |
522 } // namespace webrtc | 552 } // namespace webrtc |
OLD | NEW |