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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 void SetBitrateConfig( | 87 void SetBitrateConfig( |
88 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; | 88 const webrtc::Call::Config::BitrateConfig& bitrate_config) override; |
89 void SignalNetworkState(NetworkState state) override; | 89 void SignalNetworkState(NetworkState state) override; |
90 | 90 |
91 void OnSentPacket(const rtc::SentPacket& sent_packet) override; | 91 void OnSentPacket(const rtc::SentPacket& sent_packet) override; |
92 | 92 |
93 // Implements BitrateObserver. | 93 // Implements BitrateObserver. |
94 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, | 94 void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss, |
95 int64_t rtt_ms) override; | 95 int64_t rtt_ms) override; |
96 | 96 |
97 webrtc::RtcEventLog* RtcEventLog() override { return event_log_.get(); } | |
98 | |
97 private: | 99 private: |
98 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, | 100 DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet, |
99 size_t length); | 101 size_t length); |
100 DeliveryStatus DeliverRtp(MediaType media_type, | 102 DeliveryStatus DeliverRtp(MediaType media_type, |
101 const uint8_t* packet, | 103 const uint8_t* packet, |
102 size_t length, | 104 size_t length, |
103 const PacketTime& packet_time); | 105 const PacketTime& packet_time); |
104 | 106 |
105 void ConfigureSync(const std::string& sync_group) | 107 void ConfigureSync(const std::string& sync_group) |
106 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); | 108 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 GUARDED_BY(receive_crit_); | 143 GUARDED_BY(receive_crit_); |
142 | 144 |
143 rtc::scoped_ptr<RWLockWrapper> send_crit_; | 145 rtc::scoped_ptr<RWLockWrapper> send_crit_; |
144 // Audio and Video send streams are owned by the client that creates them. | 146 // Audio and Video send streams are owned by the client that creates them. |
145 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); | 147 std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_); |
146 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); | 148 std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_); |
147 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); | 149 std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_); |
148 | 150 |
149 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; | 151 VideoSendStream::RtpStateMap suspended_video_send_ssrcs_; |
150 | 152 |
151 RtcEventLog* event_log_ = nullptr; | 153 rtc::scoped_ptr<webrtc::RtcEventLog> event_log_ = RtcEventLog::Create(); |
the sun
2016/03/03 09:25:13
Is there a thread checker in RtcEventLog::Create()
stefan-webrtc
2016/03/03 10:08:25
Use std::unique_ptr. I'd also prefer if you create
ivoc
2016/03/10 13:15:36
Done.
ivoc
2016/03/10 13:15:36
I moved the initialization to the initializer list
| |
152 | 154 |
153 // The following members are only accessed (exclusively) from one thread and | 155 // The following members are only accessed (exclusively) from one thread and |
154 // from the destructor, and therefore doesn't need any explicit | 156 // from the destructor, and therefore doesn't need any explicit |
155 // synchronization. | 157 // synchronization. |
156 int64_t received_video_bytes_; | 158 int64_t received_video_bytes_; |
157 int64_t received_audio_bytes_; | 159 int64_t received_audio_bytes_; |
158 int64_t received_rtcp_bytes_; | 160 int64_t received_rtcp_bytes_; |
159 int64_t first_rtp_packet_received_ms_; | 161 int64_t first_rtp_packet_received_ms_; |
160 int64_t last_rtp_packet_received_ms_; | 162 int64_t last_rtp_packet_received_ms_; |
161 int64_t first_packet_sent_ms_; | 163 int64_t first_packet_sent_ms_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 remb_(clock_), | 205 remb_(clock_), |
204 congestion_controller_(new CongestionController(clock_, this, &remb_)) { | 206 congestion_controller_(new CongestionController(clock_, this, &remb_)) { |
205 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 207 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
206 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); | 208 RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0); |
207 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, | 209 RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps, |
208 config.bitrate_config.min_bitrate_bps); | 210 config.bitrate_config.min_bitrate_bps); |
209 if (config.bitrate_config.max_bitrate_bps != -1) { | 211 if (config.bitrate_config.max_bitrate_bps != -1) { |
210 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, | 212 RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps, |
211 config.bitrate_config.start_bitrate_bps); | 213 config.bitrate_config.start_bitrate_bps); |
212 } | 214 } |
213 if (config.audio_state.get()) { | |
214 ScopedVoEInterface<VoECodec> voe_codec(voice_engine()); | |
215 event_log_ = voe_codec->GetEventLog(); | |
216 } | |
217 | 215 |
218 Trace::CreateTrace(); | 216 Trace::CreateTrace(); |
219 call_stats_->RegisterStatsObserver(congestion_controller_.get()); | 217 call_stats_->RegisterStatsObserver(congestion_controller_.get()); |
220 | 218 |
221 congestion_controller_->SetBweBitrates( | 219 congestion_controller_->SetBweBitrates( |
222 config_.bitrate_config.min_bitrate_bps, | 220 config_.bitrate_config.min_bitrate_bps, |
223 config_.bitrate_config.start_bitrate_bps, | 221 config_.bitrate_config.start_bitrate_bps, |
224 config_.bitrate_config.max_bitrate_bps); | 222 config_.bitrate_config.max_bitrate_bps); |
225 congestion_controller_->GetBitrateController()->SetEventLog(event_log_); | 223 congestion_controller_->GetBitrateController()->SetEventLog(event_log_.get()); |
the sun
2016/03/03 09:25:12
Could we pass the log* in the CongestionController
stefan-webrtc
2016/03/03 10:08:25
That would be nicer.
ivoc
2016/03/10 13:15:36
Good point, done.
| |
226 | 224 |
227 module_process_thread_->Start(); | 225 module_process_thread_->Start(); |
228 module_process_thread_->RegisterModule(call_stats_.get()); | 226 module_process_thread_->RegisterModule(call_stats_.get()); |
229 module_process_thread_->RegisterModule(congestion_controller_.get()); | 227 module_process_thread_->RegisterModule(congestion_controller_.get()); |
230 pacer_thread_->RegisterModule(congestion_controller_->pacer()); | 228 pacer_thread_->RegisterModule(congestion_controller_->pacer()); |
231 pacer_thread_->RegisterModule( | 229 pacer_thread_->RegisterModule( |
232 congestion_controller_->GetRemoteBitrateEstimator(true)); | 230 congestion_controller_->GetRemoteBitrateEstimator(true)); |
233 pacer_thread_->Start(); | 231 pacer_thread_->Start(); |
234 } | 232 } |
235 | 233 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 } | 342 } |
345 delete audio_send_stream; | 343 delete audio_send_stream; |
346 } | 344 } |
347 | 345 |
348 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( | 346 webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream( |
349 const webrtc::AudioReceiveStream::Config& config) { | 347 const webrtc::AudioReceiveStream::Config& config) { |
350 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); | 348 TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream"); |
351 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 349 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
352 AudioReceiveStream* receive_stream = new AudioReceiveStream( | 350 AudioReceiveStream* receive_stream = new AudioReceiveStream( |
353 congestion_controller_.get(), config, config_.audio_state); | 351 congestion_controller_.get(), config, config_.audio_state); |
352 receive_stream->SetRtcEventLog(event_log_.get()); | |
stefan-webrtc
2016/03/03 10:08:25
Isn't it possible to pass this via the constructor
ivoc
2016/03/10 13:15:36
Done.
| |
354 { | 353 { |
355 WriteLockScoped write_lock(*receive_crit_); | 354 WriteLockScoped write_lock(*receive_crit_); |
356 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == | 355 RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) == |
357 audio_receive_ssrcs_.end()); | 356 audio_receive_ssrcs_.end()); |
358 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; | 357 audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream; |
359 ConfigureSync(config.sync_group); | 358 ConfigureSync(config.sync_group); |
360 } | 359 } |
361 return receive_stream; | 360 return receive_stream; |
362 } | 361 } |
363 | 362 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 if (!network_enabled_) | 399 if (!network_enabled_) |
401 send_stream->SignalNetworkState(kNetworkDown); | 400 send_stream->SignalNetworkState(kNetworkDown); |
402 | 401 |
403 WriteLockScoped write_lock(*send_crit_); | 402 WriteLockScoped write_lock(*send_crit_); |
404 for (uint32_t ssrc : config.rtp.ssrcs) { | 403 for (uint32_t ssrc : config.rtp.ssrcs) { |
405 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); | 404 RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end()); |
406 video_send_ssrcs_[ssrc] = send_stream; | 405 video_send_ssrcs_[ssrc] = send_stream; |
407 } | 406 } |
408 video_send_streams_.insert(send_stream); | 407 video_send_streams_.insert(send_stream); |
409 | 408 |
410 if (event_log_) | 409 event_log_->LogVideoSendStreamConfig(config); |
411 event_log_->LogVideoSendStreamConfig(config); | |
412 | 410 |
413 return send_stream; | 411 return send_stream; |
414 } | 412 } |
415 | 413 |
416 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { | 414 void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) { |
417 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); | 415 TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream"); |
418 RTC_DCHECK(send_stream != nullptr); | 416 RTC_DCHECK(send_stream != nullptr); |
419 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 417 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
420 | 418 |
421 send_stream->Stop(); | 419 send_stream->Stop(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 config.rtp.rtx.begin(); | 462 config.rtp.rtx.begin(); |
465 if (it != config.rtp.rtx.end()) | 463 if (it != config.rtp.rtx.end()) |
466 video_receive_ssrcs_[it->second.ssrc] = receive_stream; | 464 video_receive_ssrcs_[it->second.ssrc] = receive_stream; |
467 video_receive_streams_.insert(receive_stream); | 465 video_receive_streams_.insert(receive_stream); |
468 | 466 |
469 ConfigureSync(config.sync_group); | 467 ConfigureSync(config.sync_group); |
470 | 468 |
471 if (!network_enabled_) | 469 if (!network_enabled_) |
472 receive_stream->SignalNetworkState(kNetworkDown); | 470 receive_stream->SignalNetworkState(kNetworkDown); |
473 | 471 |
474 if (event_log_) | 472 event_log_->LogVideoReceiveStreamConfig(config); |
475 event_log_->LogVideoReceiveStreamConfig(config); | |
476 | 473 |
477 return receive_stream; | 474 return receive_stream; |
478 } | 475 } |
479 | 476 |
480 void Call::DestroyVideoReceiveStream( | 477 void Call::DestroyVideoReceiveStream( |
481 webrtc::VideoReceiveStream* receive_stream) { | 478 webrtc::VideoReceiveStream* receive_stream) { |
482 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); | 479 TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream"); |
483 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); | 480 RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread()); |
484 RTC_DCHECK(receive_stream != nullptr); | 481 RTC_DCHECK(receive_stream != nullptr); |
485 VideoReceiveStream* receive_stream_impl = nullptr; | 482 VideoReceiveStream* receive_stream_impl = nullptr; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 // Do NOT broadcast! Also make sure it's a valid packet. | 662 // Do NOT broadcast! Also make sure it's a valid packet. |
666 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that | 663 // Return DELIVERY_UNKNOWN_SSRC if it can be determined that |
667 // there's no receiver of the packet. | 664 // there's no receiver of the packet. |
668 received_rtcp_bytes_ += length; | 665 received_rtcp_bytes_ += length; |
669 bool rtcp_delivered = false; | 666 bool rtcp_delivered = false; |
670 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 667 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
671 ReadLockScoped read_lock(*receive_crit_); | 668 ReadLockScoped read_lock(*receive_crit_); |
672 for (VideoReceiveStream* stream : video_receive_streams_) { | 669 for (VideoReceiveStream* stream : video_receive_streams_) { |
673 if (stream->DeliverRtcp(packet, length)) { | 670 if (stream->DeliverRtcp(packet, length)) { |
674 rtcp_delivered = true; | 671 rtcp_delivered = true; |
675 if (event_log_) | 672 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); |
676 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, | |
677 length); | |
678 } | 673 } |
679 } | 674 } |
680 } | 675 } |
681 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 676 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
682 ReadLockScoped read_lock(*send_crit_); | 677 ReadLockScoped read_lock(*send_crit_); |
683 for (VideoSendStream* stream : video_send_streams_) { | 678 for (VideoSendStream* stream : video_send_streams_) { |
684 if (stream->DeliverRtcp(packet, length)) { | 679 if (stream->DeliverRtcp(packet, length)) { |
685 rtcp_delivered = true; | 680 rtcp_delivered = true; |
686 if (event_log_) | 681 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length); |
687 event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, | |
688 length); | |
689 } | 682 } |
690 } | 683 } |
691 } | 684 } |
692 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 685 return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
693 } | 686 } |
694 | 687 |
695 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, | 688 PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type, |
696 const uint8_t* packet, | 689 const uint8_t* packet, |
697 size_t length, | 690 size_t length, |
698 const PacketTime& packet_time) { | 691 const PacketTime& packet_time) { |
699 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); | 692 TRACE_EVENT0("webrtc", "Call::DeliverRtp"); |
700 // Minimum RTP header size. | 693 // Minimum RTP header size. |
701 if (length < 12) | 694 if (length < 12) |
702 return DELIVERY_PACKET_ERROR; | 695 return DELIVERY_PACKET_ERROR; |
703 | 696 |
704 last_rtp_packet_received_ms_ = clock_->TimeInMilliseconds(); | 697 last_rtp_packet_received_ms_ = clock_->TimeInMilliseconds(); |
705 if (first_rtp_packet_received_ms_ == -1) | 698 if (first_rtp_packet_received_ms_ == -1) |
706 first_rtp_packet_received_ms_ = last_rtp_packet_received_ms_; | 699 first_rtp_packet_received_ms_ = last_rtp_packet_received_ms_; |
707 | 700 |
708 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); | 701 uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]); |
709 ReadLockScoped read_lock(*receive_crit_); | 702 ReadLockScoped read_lock(*receive_crit_); |
710 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { | 703 if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) { |
711 auto it = audio_receive_ssrcs_.find(ssrc); | 704 auto it = audio_receive_ssrcs_.find(ssrc); |
712 if (it != audio_receive_ssrcs_.end()) { | 705 if (it != audio_receive_ssrcs_.end()) { |
713 received_audio_bytes_ += length; | 706 received_audio_bytes_ += length; |
714 auto status = it->second->DeliverRtp(packet, length, packet_time) | 707 auto status = it->second->DeliverRtp(packet, length, packet_time) |
715 ? DELIVERY_OK | 708 ? DELIVERY_OK |
716 : DELIVERY_PACKET_ERROR; | 709 : DELIVERY_PACKET_ERROR; |
717 if (status == DELIVERY_OK && event_log_) | 710 if (status == DELIVERY_OK) |
718 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 711 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
719 return status; | 712 return status; |
720 } | 713 } |
721 } | 714 } |
722 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { | 715 if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) { |
723 auto it = video_receive_ssrcs_.find(ssrc); | 716 auto it = video_receive_ssrcs_.find(ssrc); |
724 if (it != video_receive_ssrcs_.end()) { | 717 if (it != video_receive_ssrcs_.end()) { |
725 received_video_bytes_ += length; | 718 received_video_bytes_ += length; |
726 auto status = it->second->DeliverRtp(packet, length, packet_time) | 719 auto status = it->second->DeliverRtp(packet, length, packet_time) |
727 ? DELIVERY_OK | 720 ? DELIVERY_OK |
728 : DELIVERY_PACKET_ERROR; | 721 : DELIVERY_PACKET_ERROR; |
729 if (status == DELIVERY_OK && event_log_) | 722 if (status == DELIVERY_OK) |
730 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); | 723 event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length); |
731 return status; | 724 return status; |
732 } | 725 } |
733 } | 726 } |
734 return DELIVERY_UNKNOWN_SSRC; | 727 return DELIVERY_UNKNOWN_SSRC; |
735 } | 728 } |
736 | 729 |
737 PacketReceiver::DeliveryStatus Call::DeliverPacket( | 730 PacketReceiver::DeliveryStatus Call::DeliverPacket( |
738 MediaType media_type, | 731 MediaType media_type, |
739 const uint8_t* packet, | 732 const uint8_t* packet, |
740 size_t length, | 733 size_t length, |
741 const PacketTime& packet_time) { | 734 const PacketTime& packet_time) { |
742 // TODO(solenberg): Tests call this function on a network thread, libjingle | 735 // TODO(solenberg): Tests call this function on a network thread, libjingle |
743 // calls on the worker thread. We should move towards always using a network | 736 // calls on the worker thread. We should move towards always using a network |
744 // thread. Then this check can be enabled. | 737 // thread. Then this check can be enabled. |
745 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); | 738 // RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread()); |
746 if (RtpHeaderParser::IsRtcp(packet, length)) | 739 if (RtpHeaderParser::IsRtcp(packet, length)) |
747 return DeliverRtcp(media_type, packet, length); | 740 return DeliverRtcp(media_type, packet, length); |
748 | 741 |
749 return DeliverRtp(media_type, packet, length, packet_time); | 742 return DeliverRtp(media_type, packet, length, packet_time); |
750 } | 743 } |
751 | 744 |
752 } // namespace internal | 745 } // namespace internal |
753 } // namespace webrtc | 746 } // namespace webrtc |
OLD | NEW |