| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 18 matching lines...) Expand all Loading... |
| 29 #include "webrtc/modules/video_processing/include/video_processing.h" | 29 #include "webrtc/modules/video_processing/include/video_processing.h" |
| 30 #include "webrtc/modules/video_render/video_render_defines.h" | 30 #include "webrtc/modules/video_render/video_render_defines.h" |
| 31 #include "webrtc/system_wrappers/include/metrics.h" | 31 #include "webrtc/system_wrappers/include/metrics.h" |
| 32 #include "webrtc/video/call_stats.h" | 32 #include "webrtc/video/call_stats.h" |
| 33 #include "webrtc/video/payload_router.h" | 33 #include "webrtc/video/payload_router.h" |
| 34 #include "webrtc/video/receive_statistics_proxy.h" | 34 #include "webrtc/video/receive_statistics_proxy.h" |
| 35 #include "webrtc/video/report_block_stats.h" | 35 #include "webrtc/video/report_block_stats.h" |
| 36 | 36 |
| 37 namespace webrtc { | 37 namespace webrtc { |
| 38 | 38 |
| 39 const int kMaxDecodeWaitTimeMs = 50; | |
| 40 static const int kMaxTargetDelayMs = 10000; | 39 static const int kMaxTargetDelayMs = 10000; |
| 41 const int kMinSendSidePacketHistorySize = 600; | 40 const int kMinSendSidePacketHistorySize = 600; |
| 42 const int kMaxPacketAgeToNack = 450; | 41 const int kMaxPacketAgeToNack = 450; |
| 43 const int kMaxNackListSize = 250; | 42 const int kMaxNackListSize = 250; |
| 44 | 43 |
| 45 // Helper class receiving statistics callbacks. | 44 // Helper class receiving statistics callbacks. |
| 46 class ChannelStatsObserver : public CallStatsObserver { | 45 class ChannelStatsObserver : public CallStatsObserver { |
| 47 public: | 46 public: |
| 48 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} | 47 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} |
| 49 virtual ~ChannelStatsObserver() {} | 48 virtual ~ChannelStatsObserver() {} |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 vie_sync_(vcm_), | 98 vie_sync_(vcm_), |
| 100 stats_observer_(new ChannelStatsObserver(this)), | 99 stats_observer_(new ChannelStatsObserver(this)), |
| 101 receive_stats_callback_(nullptr), | 100 receive_stats_callback_(nullptr), |
| 102 incoming_video_stream_(nullptr), | 101 incoming_video_stream_(nullptr), |
| 103 intra_frame_observer_(intra_frame_observer), | 102 intra_frame_observer_(intra_frame_observer), |
| 104 rtt_stats_(rtt_stats), | 103 rtt_stats_(rtt_stats), |
| 105 paced_sender_(paced_sender), | 104 paced_sender_(paced_sender), |
| 106 packet_router_(packet_router), | 105 packet_router_(packet_router), |
| 107 bandwidth_observer_(bandwidth_observer), | 106 bandwidth_observer_(bandwidth_observer), |
| 108 transport_feedback_observer_(transport_feedback_observer), | 107 transport_feedback_observer_(transport_feedback_observer), |
| 109 decode_thread_(ChannelDecodeThreadFunction, this, "DecodingThread"), | |
| 110 nack_history_size_sender_(kMinSendSidePacketHistorySize), | 108 nack_history_size_sender_(kMinSendSidePacketHistorySize), |
| 111 max_nack_reordering_threshold_(kMaxPacketAgeToNack), | 109 max_nack_reordering_threshold_(kMaxPacketAgeToNack), |
| 112 pre_render_callback_(NULL), | 110 pre_render_callback_(NULL), |
| 113 report_block_stats_sender_(new ReportBlockStats()), | 111 report_block_stats_sender_(new ReportBlockStats()), |
| 114 time_of_first_rtt_ms_(-1), | 112 time_of_first_rtt_ms_(-1), |
| 115 rtt_sum_ms_(0), | 113 rtt_sum_ms_(0), |
| 116 last_rtt_ms_(0), | 114 last_rtt_ms_(0), |
| 117 num_rtts_(0), | 115 num_rtts_(0), |
| 118 rtp_rtcp_modules_( | 116 rtp_rtcp_modules_( |
| 119 CreateRtpRtcpModules(!sender, | 117 CreateRtpRtcpModules(!sender, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); | 180 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); |
| 183 } else { | 181 } else { |
| 184 module_process_thread_->DeRegisterModule(&vie_sync_); | 182 module_process_thread_->DeRegisterModule(&vie_sync_); |
| 185 } | 183 } |
| 186 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | 184 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) |
| 187 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 185 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
| 188 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 186 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 189 module_process_thread_->DeRegisterModule(rtp_rtcp); | 187 module_process_thread_->DeRegisterModule(rtp_rtcp); |
| 190 delete rtp_rtcp; | 188 delete rtp_rtcp; |
| 191 } | 189 } |
| 192 if (!sender_) | |
| 193 StopDecodeThread(); | |
| 194 } | 190 } |
| 195 | 191 |
| 196 void ViEChannel::UpdateHistograms() { | 192 void ViEChannel::UpdateHistograms() { |
| 197 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 193 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
| 198 | 194 |
| 199 { | 195 { |
| 200 rtc::CritScope lock(&crit_); | 196 rtc::CritScope lock(&crit_); |
| 201 int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000; | 197 int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000; |
| 202 if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 && | 198 if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 && |
| 203 elapsed_sec > metrics::kMinRunTimeInSeconds) { | 199 elapsed_sec > metrics::kMinRunTimeInSeconds) { |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 if (!rtp_rtcp_modules_[0]->Sending()) { | 806 if (!rtp_rtcp_modules_[0]->Sending()) { |
| 811 return -1; | 807 return -1; |
| 812 } | 808 } |
| 813 | 809 |
| 814 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 810 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 815 rtp_rtcp->SetSendingStatus(false); | 811 rtp_rtcp->SetSendingStatus(false); |
| 816 } | 812 } |
| 817 return 0; | 813 return 0; |
| 818 } | 814 } |
| 819 | 815 |
| 820 bool ViEChannel::Sending() { | |
| 821 return rtp_rtcp_modules_[0]->Sending(); | |
| 822 } | |
| 823 | |
| 824 void ViEChannel::StartReceive() { | |
| 825 if (!sender_) | |
| 826 StartDecodeThread(); | |
| 827 vie_receiver_.StartReceive(); | |
| 828 } | |
| 829 | |
| 830 void ViEChannel::StopReceive() { | |
| 831 vie_receiver_.StopReceive(); | |
| 832 if (!sender_) | |
| 833 StopDecodeThread(); | |
| 834 } | |
| 835 | |
| 836 int32_t ViEChannel::SetMTU(uint16_t mtu) { | 816 int32_t ViEChannel::SetMTU(uint16_t mtu) { |
| 837 RTC_DCHECK(sender_); | 817 RTC_DCHECK(sender_); |
| 838 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 818 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 839 rtp_rtcp->SetMaxTransferUnit(mtu); | 819 rtp_rtcp->SetMaxTransferUnit(mtu); |
| 840 return 0; | 820 return 0; |
| 841 } | 821 } |
| 842 | 822 |
| 843 RtpRtcp* ViEChannel::rtp_rtcp() { | 823 RtpRtcp* ViEChannel::rtp_rtcp() { |
| 844 return rtp_rtcp_modules_[0]; | 824 return rtp_rtcp_modules_[0]; |
| 845 } | 825 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 const uint64_t picture_id) { | 910 const uint64_t picture_id) { |
| 931 return rtp_rtcp_modules_[0]->SendRTCPSliceLossIndication( | 911 return rtp_rtcp_modules_[0]->SendRTCPSliceLossIndication( |
| 932 static_cast<uint8_t>(picture_id)); | 912 static_cast<uint8_t>(picture_id)); |
| 933 } | 913 } |
| 934 | 914 |
| 935 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, | 915 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, |
| 936 uint16_t length) { | 916 uint16_t length) { |
| 937 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); | 917 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); |
| 938 } | 918 } |
| 939 | 919 |
| 940 bool ViEChannel::ChannelDecodeThreadFunction(void* obj) { | |
| 941 return static_cast<ViEChannel*>(obj)->ChannelDecodeProcess(); | |
| 942 } | |
| 943 | |
| 944 bool ViEChannel::ChannelDecodeProcess() { | |
| 945 RTC_DCHECK(!sender_); | |
| 946 vcm_->Decode(kMaxDecodeWaitTimeMs); | |
| 947 return true; | |
| 948 } | |
| 949 | |
| 950 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 920 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 951 if (!sender_) | 921 if (!sender_) |
| 952 vcm_->SetReceiveChannelParameters(max_rtt_ms); | 922 vcm_->SetReceiveChannelParameters(max_rtt_ms); |
| 953 | 923 |
| 954 rtc::CritScope lock(&crit_); | 924 rtc::CritScope lock(&crit_); |
| 955 if (time_of_first_rtt_ms_ == -1) | 925 if (time_of_first_rtt_ms_ == -1) |
| 956 time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 926 time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
| 957 rtt_sum_ms_ += avg_rtt_ms; | 927 rtt_sum_ms_ += avg_rtt_ms; |
| 958 last_rtt_ms_ = avg_rtt_ms; | 928 last_rtt_ms_ = avg_rtt_ms; |
| 959 ++num_rtts_; | 929 ++num_rtts_; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); | 996 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound); |
| 1027 modules.push_back(rtp_rtcp); | 997 modules.push_back(rtp_rtcp); |
| 1028 // Receive statistics and remote bitrate estimator should only be set for | 998 // Receive statistics and remote bitrate estimator should only be set for |
| 1029 // the primary (first) module. | 999 // the primary (first) module. |
| 1030 configuration.receive_statistics = null_receive_statistics; | 1000 configuration.receive_statistics = null_receive_statistics; |
| 1031 configuration.remote_bitrate_estimator = nullptr; | 1001 configuration.remote_bitrate_estimator = nullptr; |
| 1032 } | 1002 } |
| 1033 return modules; | 1003 return modules; |
| 1034 } | 1004 } |
| 1035 | 1005 |
| 1036 void ViEChannel::StartDecodeThread() { | |
| 1037 RTC_DCHECK(!sender_); | |
| 1038 if (decode_thread_.IsRunning()) | |
| 1039 return; | |
| 1040 // Start the decode thread | |
| 1041 decode_thread_.Start(); | |
| 1042 decode_thread_.SetPriority(rtc::kHighestPriority); | |
| 1043 } | |
| 1044 | |
| 1045 void ViEChannel::StopDecodeThread() { | |
| 1046 RTC_DCHECK(!sender_); | |
| 1047 vcm_->TriggerDecoderShutdown(); | |
| 1048 | |
| 1049 decode_thread_.Stop(); | |
| 1050 } | |
| 1051 | |
| 1052 int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, | 1006 int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, |
| 1053 VoEVideoSync* ve_sync_interface) { | 1007 VoEVideoSync* ve_sync_interface) { |
| 1054 RTC_DCHECK(!sender_); | 1008 RTC_DCHECK(!sender_); |
| 1055 return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, | 1009 return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, |
| 1056 rtp_rtcp_modules_[0], | 1010 rtp_rtcp_modules_[0], |
| 1057 vie_receiver_.GetRtpReceiver()); | 1011 vie_receiver_.GetRtpReceiver()); |
| 1058 } | 1012 } |
| 1059 | 1013 |
| 1060 int32_t ViEChannel::VoiceChannel() { | 1014 int32_t ViEChannel::VoiceChannel() { |
| 1061 RTC_DCHECK(!sender_); | 1015 RTC_DCHECK(!sender_); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 rtc::CritScope lock(&crit_); | 1051 rtc::CritScope lock(&crit_); |
| 1098 receive_stats_callback_ = receive_statistics_proxy; | 1052 receive_stats_callback_ = receive_statistics_proxy; |
| 1099 } | 1053 } |
| 1100 | 1054 |
| 1101 void ViEChannel::SetIncomingVideoStream( | 1055 void ViEChannel::SetIncomingVideoStream( |
| 1102 IncomingVideoStream* incoming_video_stream) { | 1056 IncomingVideoStream* incoming_video_stream) { |
| 1103 rtc::CritScope lock(&crit_); | 1057 rtc::CritScope lock(&crit_); |
| 1104 incoming_video_stream_ = incoming_video_stream; | 1058 incoming_video_stream_ = incoming_video_stream; |
| 1105 } | 1059 } |
| 1106 } // namespace webrtc | 1060 } // namespace webrtc |
| OLD | NEW |