| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 sent_video_rate_bps, sent_nack_rate_bps, | 73 sent_video_rate_bps, sent_nack_rate_bps, |
| 74 sent_fec_rate_bps); | 74 sent_fec_rate_bps); |
| 75 } | 75 } |
| 76 private: | 76 private: |
| 77 ViEChannel* owner_; | 77 ViEChannel* owner_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 ViEChannel::ViEChannel(uint32_t number_of_cores, | 80 ViEChannel::ViEChannel(uint32_t number_of_cores, |
| 81 Transport* transport, | 81 Transport* transport, |
| 82 ProcessThread* module_process_thread, | 82 ProcessThread* module_process_thread, |
| 83 PayloadRouter* send_payload_router, |
| 84 VideoCodingModule* vcm, |
| 83 RtcpIntraFrameObserver* intra_frame_observer, | 85 RtcpIntraFrameObserver* intra_frame_observer, |
| 84 RtcpBandwidthObserver* bandwidth_observer, | 86 RtcpBandwidthObserver* bandwidth_observer, |
| 85 TransportFeedbackObserver* transport_feedback_observer, | 87 TransportFeedbackObserver* transport_feedback_observer, |
| 86 RemoteBitrateEstimator* remote_bitrate_estimator, | 88 RemoteBitrateEstimator* remote_bitrate_estimator, |
| 87 RtcpRttStats* rtt_stats, | 89 RtcpRttStats* rtt_stats, |
| 88 PacedSender* paced_sender, | 90 PacedSender* paced_sender, |
| 89 PacketRouter* packet_router, | 91 PacketRouter* packet_router, |
| 90 size_t max_rtp_streams, | 92 size_t max_rtp_streams, |
| 91 bool sender) | 93 bool sender) |
| 92 : number_of_cores_(number_of_cores), | 94 : number_of_cores_(number_of_cores), |
| 93 sender_(sender), | 95 sender_(sender), |
| 94 module_process_thread_(module_process_thread), | 96 module_process_thread_(module_process_thread), |
| 95 send_payload_router_(new PayloadRouter()), | 97 send_payload_router_(send_payload_router), |
| 96 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), | 98 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), |
| 97 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), | 99 vcm_(vcm), |
| 98 nullptr, | |
| 99 nullptr)), | |
| 100 vie_receiver_(vcm_, remote_bitrate_estimator, this), | 100 vie_receiver_(vcm_, remote_bitrate_estimator, this), |
| 101 vie_sync_(vcm_), | 101 vie_sync_(vcm_), |
| 102 stats_observer_(new ChannelStatsObserver(this)), | 102 stats_observer_(new ChannelStatsObserver(this)), |
| 103 receive_stats_callback_(nullptr), | 103 receive_stats_callback_(nullptr), |
| 104 incoming_video_stream_(nullptr), | 104 incoming_video_stream_(nullptr), |
| 105 intra_frame_observer_(intra_frame_observer), | 105 intra_frame_observer_(intra_frame_observer), |
| 106 rtt_stats_(rtt_stats), | 106 rtt_stats_(rtt_stats), |
| 107 paced_sender_(paced_sender), | 107 paced_sender_(paced_sender), |
| 108 packet_router_(packet_router), | 108 packet_router_(packet_router), |
| 109 bandwidth_observer_(bandwidth_observer), | 109 bandwidth_observer_(bandwidth_observer), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 128 &rtcp_packet_type_counter_observer_, | 128 &rtcp_packet_type_counter_observer_, |
| 129 remote_bitrate_estimator, | 129 remote_bitrate_estimator, |
| 130 paced_sender_, | 130 paced_sender_, |
| 131 packet_router_, | 131 packet_router_, |
| 132 &send_bitrate_observer_, | 132 &send_bitrate_observer_, |
| 133 &send_frame_count_observer_, | 133 &send_frame_count_observer_, |
| 134 &send_side_delay_observer_, | 134 &send_side_delay_observer_, |
| 135 max_rtp_streams)), | 135 max_rtp_streams)), |
| 136 num_active_rtp_rtcp_modules_(1) { | 136 num_active_rtp_rtcp_modules_(1) { |
| 137 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); | 137 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); |
| 138 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); | 138 if (sender_) { |
| 139 RTC_DCHECK(send_payload_router_); |
| 140 RTC_DCHECK(!vcm_); |
| 141 } else { |
| 142 RTC_DCHECK(!send_payload_router_); |
| 143 RTC_DCHECK(vcm_); |
| 144 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); |
| 145 } |
| 139 } | 146 } |
| 140 | 147 |
| 141 int32_t ViEChannel::Init() { | 148 int32_t ViEChannel::Init() { |
| 142 static const int kDefaultRenderDelayMs = 10; | 149 static const int kDefaultRenderDelayMs = 10; |
| 143 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); | 150 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); |
| 144 | 151 |
| 145 // RTP/RTCP initialization. | 152 // RTP/RTCP initialization. |
| 146 module_process_thread_->RegisterModule(rtp_rtcp_modules_[0]); | 153 module_process_thread_->RegisterModule(rtp_rtcp_modules_[0]); |
| 147 | 154 |
| 148 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); | 155 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); |
| 149 if (paced_sender_) { | 156 if (paced_sender_) { |
| 150 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 157 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 151 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); | 158 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); |
| 152 } | 159 } |
| 153 packet_router_->AddRtpModule(rtp_rtcp_modules_[0], sender_); | 160 packet_router_->AddRtpModule(rtp_rtcp_modules_[0], sender_); |
| 154 if (sender_) { | 161 if (sender_) { |
| 155 std::list<RtpRtcp*> send_rtp_modules(1, rtp_rtcp_modules_[0]); | 162 std::list<RtpRtcp*> send_rtp_modules(1, rtp_rtcp_modules_[0]); |
| 156 send_payload_router_->SetSendingRtpModules(send_rtp_modules); | 163 send_payload_router_->SetSendingRtpModules(send_rtp_modules); |
| 157 RTC_DCHECK(!send_payload_router_->active()); | 164 RTC_DCHECK(!send_payload_router_->active()); |
| 165 } else { |
| 166 if (vcm_->RegisterReceiveCallback(this) != 0) { |
| 167 return -1; |
| 168 } |
| 169 vcm_->RegisterFrameTypeCallback(this); |
| 170 vcm_->RegisterReceiveStatisticsCallback(this); |
| 171 vcm_->RegisterDecoderTimingCallback(this); |
| 172 vcm_->SetRenderDelay(kDefaultRenderDelayMs); |
| 173 module_process_thread_->RegisterModule(&vie_sync_); |
| 158 } | 174 } |
| 159 if (vcm_->RegisterReceiveCallback(this) != 0) { | |
| 160 return -1; | |
| 161 } | |
| 162 vcm_->RegisterFrameTypeCallback(this); | |
| 163 vcm_->RegisterReceiveStatisticsCallback(this); | |
| 164 vcm_->RegisterDecoderTimingCallback(this); | |
| 165 vcm_->SetRenderDelay(kDefaultRenderDelayMs); | |
| 166 | |
| 167 module_process_thread_->RegisterModule(vcm_); | |
| 168 module_process_thread_->RegisterModule(&vie_sync_); | |
| 169 | |
| 170 return 0; | 175 return 0; |
| 171 } | 176 } |
| 172 | 177 |
| 173 ViEChannel::~ViEChannel() { | 178 ViEChannel::~ViEChannel() { |
| 174 UpdateHistograms(); | 179 UpdateHistograms(); |
| 175 // Make sure we don't get more callbacks from the RTP module. | 180 // Make sure we don't get more callbacks from the RTP module. |
| 176 module_process_thread_->DeRegisterModule( | 181 module_process_thread_->DeRegisterModule( |
| 177 vie_receiver_.GetReceiveStatistics()); | 182 vie_receiver_.GetReceiveStatistics()); |
| 178 module_process_thread_->DeRegisterModule(vcm_); | 183 if (sender_) { |
| 179 module_process_thread_->DeRegisterModule(&vie_sync_); | 184 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); |
| 180 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); | 185 } else { |
| 186 module_process_thread_->DeRegisterModule(&vie_sync_); |
| 187 } |
| 181 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | 188 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) |
| 182 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 189 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
| 183 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 190 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 184 module_process_thread_->DeRegisterModule(rtp_rtcp); | 191 module_process_thread_->DeRegisterModule(rtp_rtcp); |
| 185 delete rtp_rtcp; | 192 delete rtp_rtcp; |
| 186 } | 193 } |
| 187 if (!sender_) | 194 if (!sender_) |
| 188 StopDecodeThread(); | 195 StopDecodeThread(); |
| 189 // Release modules. | |
| 190 VideoCodingModule::Destroy(vcm_); | |
| 191 } | 196 } |
| 192 | 197 |
| 193 void ViEChannel::UpdateHistograms() { | 198 void ViEChannel::UpdateHistograms() { |
| 194 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 199 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
| 195 | 200 |
| 196 { | 201 { |
| 197 rtc::CritScope lock(&crit_); | 202 rtc::CritScope lock(&crit_); |
| 198 int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000; | 203 int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000; |
| 199 if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 && | 204 if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 && |
| 200 elapsed_sec > metrics::kMinRunTimeInSeconds) { | 205 elapsed_sec > metrics::kMinRunTimeInSeconds) { |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 439 } |
| 435 | 440 |
| 436 int32_t ViEChannel::ReceiveCodecStatistics(uint32_t* num_key_frames, | 441 int32_t ViEChannel::ReceiveCodecStatistics(uint32_t* num_key_frames, |
| 437 uint32_t* num_delta_frames) { | 442 uint32_t* num_delta_frames) { |
| 438 rtc::CritScope lock(&crit_); | 443 rtc::CritScope lock(&crit_); |
| 439 *num_key_frames = receive_frame_counts_.key_frames; | 444 *num_key_frames = receive_frame_counts_.key_frames; |
| 440 *num_delta_frames = receive_frame_counts_.delta_frames; | 445 *num_delta_frames = receive_frame_counts_.delta_frames; |
| 441 return 0; | 446 return 0; |
| 442 } | 447 } |
| 443 | 448 |
| 444 uint32_t ViEChannel::DiscardedPackets() const { | |
| 445 return vcm_->DiscardedPackets(); | |
| 446 } | |
| 447 | |
| 448 int ViEChannel::ReceiveDelay() const { | |
| 449 return vcm_->Delay(); | |
| 450 } | |
| 451 | |
| 452 void ViEChannel::SetExpectedRenderDelay(int delay_ms) { | 449 void ViEChannel::SetExpectedRenderDelay(int delay_ms) { |
| 450 RTC_DCHECK(!sender_); |
| 453 vcm_->SetRenderDelay(delay_ms); | 451 vcm_->SetRenderDelay(delay_ms); |
| 454 } | 452 } |
| 455 | 453 |
| 456 void ViEChannel::SetRTCPMode(const RtcpMode rtcp_mode) { | 454 void ViEChannel::SetRTCPMode(const RtcpMode rtcp_mode) { |
| 457 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 455 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 458 rtp_rtcp->SetRTCPStatus(rtcp_mode); | 456 rtp_rtcp->SetRTCPStatus(rtcp_mode); |
| 459 } | 457 } |
| 460 | 458 |
| 461 void ViEChannel::SetProtectionMode(bool enable_nack, | 459 void ViEChannel::SetProtectionMode(bool enable_nack, |
| 462 bool enable_fec, | 460 bool enable_fec, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 476 payload_type_fec = 0; | 474 payload_type_fec = 0; |
| 477 } | 475 } |
| 478 | 476 |
| 479 VCMVideoProtection protection_method; | 477 VCMVideoProtection protection_method; |
| 480 if (enable_nack) { | 478 if (enable_nack) { |
| 481 protection_method = enable_fec ? kProtectionNackFEC : kProtectionNack; | 479 protection_method = enable_fec ? kProtectionNackFEC : kProtectionNack; |
| 482 } else { | 480 } else { |
| 483 protection_method = kProtectionNone; | 481 protection_method = kProtectionNone; |
| 484 } | 482 } |
| 485 | 483 |
| 486 vcm_->SetVideoProtection(protection_method, true); | 484 if (!sender_) |
| 485 vcm_->SetVideoProtection(protection_method, true); |
| 487 | 486 |
| 488 // Set NACK. | 487 // Set NACK. |
| 489 ProcessNACKRequest(enable_nack); | 488 ProcessNACKRequest(enable_nack); |
| 490 | 489 |
| 491 // Set FEC. | 490 // Set FEC. |
| 492 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 491 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 493 rtp_rtcp->SetGenericFECStatus(enable_fec, | 492 rtp_rtcp->SetGenericFECStatus(enable_fec, |
| 494 static_cast<uint8_t>(payload_type_red), | 493 static_cast<uint8_t>(payload_type_red), |
| 495 static_cast<uint8_t>(payload_type_fec)); | 494 static_cast<uint8_t>(payload_type_fec)); |
| 496 } | 495 } |
| 497 } | 496 } |
| 498 | 497 |
| 499 void ViEChannel::ProcessNACKRequest(const bool enable) { | 498 void ViEChannel::ProcessNACKRequest(const bool enable) { |
| 500 if (enable) { | 499 if (enable) { |
| 501 // Turn on NACK. | 500 // Turn on NACK. |
| 502 if (rtp_rtcp_modules_[0]->RTCP() == RtcpMode::kOff) | 501 if (rtp_rtcp_modules_[0]->RTCP() == RtcpMode::kOff) |
| 503 return; | 502 return; |
| 504 vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_); | 503 vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_); |
| 505 | 504 |
| 506 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 505 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 507 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); | 506 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); |
| 508 | 507 |
| 509 vcm_->RegisterPacketRequestCallback(this); | 508 if (!sender_) { |
| 510 // Don't introduce errors when NACK is enabled. | 509 vcm_->RegisterPacketRequestCallback(this); |
| 511 vcm_->SetDecodeErrorMode(kNoErrors); | 510 // Don't introduce errors when NACK is enabled. |
| 511 vcm_->SetDecodeErrorMode(kNoErrors); |
| 512 } |
| 512 } else { | 513 } else { |
| 513 vcm_->RegisterPacketRequestCallback(NULL); | 514 if (!sender_) { |
| 514 if (paced_sender_ == nullptr) { | 515 vcm_->RegisterPacketRequestCallback(nullptr); |
| 515 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 516 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 516 rtp_rtcp->SetStorePacketsStatus(false, 0); | 517 rtp_rtcp->SetStorePacketsStatus(false, 0); |
| 518 // When NACK is off, allow decoding with errors. Otherwise, the video |
| 519 // will freeze, and will only recover with a complete key frame. |
| 520 vcm_->SetDecodeErrorMode(kWithErrors); |
| 517 } | 521 } |
| 518 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); | 522 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); |
| 519 // When NACK is off, allow decoding with errors. Otherwise, the video | |
| 520 // will freeze, and will only recover with a complete key frame. | |
| 521 vcm_->SetDecodeErrorMode(kWithErrors); | |
| 522 } | 523 } |
| 523 } | 524 } |
| 524 | 525 |
| 525 bool ViEChannel::IsSendingFecEnabled() { | 526 bool ViEChannel::IsSendingFecEnabled() { |
| 526 bool fec_enabled = false; | 527 bool fec_enabled = false; |
| 527 uint8_t pltype_red = 0; | 528 uint8_t pltype_red = 0; |
| 528 uint8_t pltype_fec = 0; | 529 uint8_t pltype_fec = 0; |
| 529 | 530 |
| 530 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 531 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 531 rtp_rtcp->GenericFECStatus(&fec_enabled, &pltype_red, &pltype_fec); | 532 rtp_rtcp->GenericFECStatus(&fec_enabled, &pltype_red, &pltype_fec); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 } | 874 } |
| 874 | 875 |
| 875 int32_t ViEChannel::StartSend() { | 876 int32_t ViEChannel::StartSend() { |
| 876 rtc::CritScope lock(&crit_); | 877 rtc::CritScope lock(&crit_); |
| 877 | 878 |
| 878 if (rtp_rtcp_modules_[0]->Sending()) | 879 if (rtp_rtcp_modules_[0]->Sending()) |
| 879 return -1; | 880 return -1; |
| 880 | 881 |
| 881 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) { | 882 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) { |
| 882 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[i]; | 883 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[i]; |
| 883 rtp_rtcp->SetSendingMediaStatus(true); | 884 // Only have senders send media. |
| 885 rtp_rtcp->SetSendingMediaStatus(sender_); |
| 884 rtp_rtcp->SetSendingStatus(true); | 886 rtp_rtcp->SetSendingStatus(true); |
| 885 } | 887 } |
| 886 send_payload_router_->set_active(true); | 888 if (sender_) |
| 889 send_payload_router_->set_active(true); |
| 887 return 0; | 890 return 0; |
| 888 } | 891 } |
| 889 | 892 |
| 890 int32_t ViEChannel::StopSend() { | 893 int32_t ViEChannel::StopSend() { |
| 891 send_payload_router_->set_active(false); | 894 if (sender_) |
| 895 send_payload_router_->set_active(false); |
| 892 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 896 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 893 rtp_rtcp->SetSendingMediaStatus(false); | 897 rtp_rtcp->SetSendingMediaStatus(false); |
| 894 | 898 |
| 895 if (!rtp_rtcp_modules_[0]->Sending()) { | 899 if (!rtp_rtcp_modules_[0]->Sending()) { |
| 896 return -1; | 900 return -1; |
| 897 } | 901 } |
| 898 | 902 |
| 899 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 903 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 900 rtp_rtcp->SetSendingStatus(false); | 904 rtp_rtcp->SetSendingStatus(false); |
| 901 } | 905 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 int32_t ViEChannel::SetMTU(uint16_t mtu) { | 937 int32_t ViEChannel::SetMTU(uint16_t mtu) { |
| 934 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 938 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 935 rtp_rtcp->SetMaxTransferUnit(mtu); | 939 rtp_rtcp->SetMaxTransferUnit(mtu); |
| 936 return 0; | 940 return 0; |
| 937 } | 941 } |
| 938 | 942 |
| 939 RtpRtcp* ViEChannel::rtp_rtcp() { | 943 RtpRtcp* ViEChannel::rtp_rtcp() { |
| 940 return rtp_rtcp_modules_[0]; | 944 return rtp_rtcp_modules_[0]; |
| 941 } | 945 } |
| 942 | 946 |
| 943 rtc::scoped_refptr<PayloadRouter> ViEChannel::send_payload_router() { | |
| 944 return send_payload_router_; | |
| 945 } | |
| 946 | |
| 947 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { | 947 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { |
| 948 return vcm_protection_callback_.get(); | 948 return vcm_protection_callback_.get(); |
| 949 } | 949 } |
| 950 | 950 |
| 951 CallStatsObserver* ViEChannel::GetStatsObserver() { | 951 CallStatsObserver* ViEChannel::GetStatsObserver() { |
| 952 return stats_observer_.get(); | 952 return stats_observer_.get(); |
| 953 } | 953 } |
| 954 | 954 |
| 955 // Do not acquire the lock of |vcm_| in this function. Decode callback won't | 955 // Do not acquire the lock of |vcm_| in this function. Decode callback won't |
| 956 // necessarily be called from the decoding thread. The decoding thread may have | 956 // necessarily be called from the decoding thread. The decoding thread may have |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, | 1031 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, |
| 1032 uint16_t length) { | 1032 uint16_t length) { |
| 1033 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); | 1033 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 bool ViEChannel::ChannelDecodeThreadFunction(void* obj) { | 1036 bool ViEChannel::ChannelDecodeThreadFunction(void* obj) { |
| 1037 return static_cast<ViEChannel*>(obj)->ChannelDecodeProcess(); | 1037 return static_cast<ViEChannel*>(obj)->ChannelDecodeProcess(); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 bool ViEChannel::ChannelDecodeProcess() { | 1040 bool ViEChannel::ChannelDecodeProcess() { |
| 1041 RTC_DCHECK(!sender_); |
| 1041 vcm_->Decode(kMaxDecodeWaitTimeMs); | 1042 vcm_->Decode(kMaxDecodeWaitTimeMs); |
| 1042 return true; | 1043 return true; |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 1046 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 1046 vcm_->SetReceiveChannelParameters(max_rtt_ms); | 1047 if (!sender_) |
| 1048 vcm_->SetReceiveChannelParameters(max_rtt_ms); |
| 1047 | 1049 |
| 1048 rtc::CritScope lock(&crit_); | 1050 rtc::CritScope lock(&crit_); |
| 1049 if (time_of_first_rtt_ms_ == -1) | 1051 if (time_of_first_rtt_ms_ == -1) |
| 1050 time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 1052 time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
| 1051 rtt_sum_ms_ += avg_rtt_ms; | 1053 rtt_sum_ms_ += avg_rtt_ms; |
| 1052 last_rtt_ms_ = avg_rtt_ms; | 1054 last_rtt_ms_ = avg_rtt_ms; |
| 1053 ++num_rtts_; | 1055 ++num_rtts_; |
| 1054 } | 1056 } |
| 1055 | 1057 |
| 1056 int ViEChannel::ProtectionRequest(const FecProtectionParams* delta_fec_params, | 1058 int ViEChannel::ProtectionRequest(const FecProtectionParams* delta_fec_params, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 void ViEChannel::StartDecodeThread() { | 1132 void ViEChannel::StartDecodeThread() { |
| 1131 RTC_DCHECK(!sender_); | 1133 RTC_DCHECK(!sender_); |
| 1132 if (decode_thread_.IsRunning()) | 1134 if (decode_thread_.IsRunning()) |
| 1133 return; | 1135 return; |
| 1134 // Start the decode thread | 1136 // Start the decode thread |
| 1135 decode_thread_.Start(); | 1137 decode_thread_.Start(); |
| 1136 decode_thread_.SetPriority(rtc::kHighestPriority); | 1138 decode_thread_.SetPriority(rtc::kHighestPriority); |
| 1137 } | 1139 } |
| 1138 | 1140 |
| 1139 void ViEChannel::StopDecodeThread() { | 1141 void ViEChannel::StopDecodeThread() { |
| 1142 RTC_DCHECK(!sender_); |
| 1140 vcm_->TriggerDecoderShutdown(); | 1143 vcm_->TriggerDecoderShutdown(); |
| 1141 | 1144 |
| 1142 decode_thread_.Stop(); | 1145 decode_thread_.Stop(); |
| 1143 } | 1146 } |
| 1144 | 1147 |
| 1145 int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, | 1148 int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, |
| 1146 VoEVideoSync* ve_sync_interface) { | 1149 VoEVideoSync* ve_sync_interface) { |
| 1150 RTC_DCHECK(!sender_); |
| 1147 return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, | 1151 return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, |
| 1148 rtp_rtcp_modules_[0], | 1152 rtp_rtcp_modules_[0], |
| 1149 vie_receiver_.GetRtpReceiver()); | 1153 vie_receiver_.GetRtpReceiver()); |
| 1150 } | 1154 } |
| 1151 | 1155 |
| 1152 int32_t ViEChannel::VoiceChannel() { | 1156 int32_t ViEChannel::VoiceChannel() { |
| 1157 RTC_DCHECK(!sender_); |
| 1153 return vie_sync_.VoiceChannel(); | 1158 return vie_sync_.VoiceChannel(); |
| 1154 } | 1159 } |
| 1155 | 1160 |
| 1156 void ViEChannel::RegisterPreRenderCallback( | 1161 void ViEChannel::RegisterPreRenderCallback( |
| 1157 I420FrameCallback* pre_render_callback) { | 1162 I420FrameCallback* pre_render_callback) { |
| 1158 rtc::CritScope lock(&crit_); | 1163 rtc::CritScope lock(&crit_); |
| 1159 pre_render_callback_ = pre_render_callback; | 1164 pre_render_callback_ = pre_render_callback; |
| 1160 } | 1165 } |
| 1161 | 1166 |
| 1162 void ViEChannel::RegisterPreDecodeImageCallback( | 1167 void ViEChannel::RegisterPreDecodeImageCallback( |
| 1163 EncodedImageCallback* pre_decode_callback) { | 1168 EncodedImageCallback* pre_decode_callback) { |
| 1169 RTC_DCHECK(!sender_); |
| 1164 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); | 1170 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); |
| 1165 } | 1171 } |
| 1166 | 1172 |
| 1167 // TODO(pbos): Remove as soon as audio can handle a changing payload type | 1173 // TODO(pbos): Remove as soon as audio can handle a changing payload type |
| 1168 // without this callback. | 1174 // without this callback. |
| 1169 int32_t ViEChannel::OnInitializeDecoder( | 1175 int32_t ViEChannel::OnInitializeDecoder( |
| 1170 const int8_t payload_type, | 1176 const int8_t payload_type, |
| 1171 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 1177 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 1172 const int frequency, | 1178 const int frequency, |
| 1173 const size_t channels, | 1179 const size_t channels, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1192 rtc::CritScope lock(&crit_); | 1198 rtc::CritScope lock(&crit_); |
| 1193 receive_stats_callback_ = receive_statistics_proxy; | 1199 receive_stats_callback_ = receive_statistics_proxy; |
| 1194 } | 1200 } |
| 1195 | 1201 |
| 1196 void ViEChannel::SetIncomingVideoStream( | 1202 void ViEChannel::SetIncomingVideoStream( |
| 1197 IncomingVideoStream* incoming_video_stream) { | 1203 IncomingVideoStream* incoming_video_stream) { |
| 1198 rtc::CritScope lock(&crit_); | 1204 rtc::CritScope lock(&crit_); |
| 1199 incoming_video_stream_ = incoming_video_stream; | 1205 incoming_video_stream_ = incoming_video_stream; |
| 1200 } | 1206 } |
| 1201 } // namespace webrtc | 1207 } // namespace webrtc |
| OLD | NEW |