Chromium Code Reviews| 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_) |
| 515 vcm_->RegisterPacketRequestCallback(nullptr); | |
|
stefan-webrtc
2016/02/04 10:46:14
Canw e move this down to line 522?
pbos-webrtc
2016/02/04 14:04:20
Merged below things with this one.
| |
| 514 if (paced_sender_ == nullptr) { | 516 if (paced_sender_ == nullptr) { |
|
stefan-webrtc
2016/02/04 10:46:14
Should always be nullptr for a receiver, right? Sh
pbos-webrtc
2016/02/04 14:04:20
Merged with above !sender_ check.
| |
| 515 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 517 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 516 rtp_rtcp->SetStorePacketsStatus(false, 0); | 518 rtp_rtcp->SetStorePacketsStatus(false, 0); |
| 517 } | 519 } |
| 518 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); | 520 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); |
| 519 // When NACK is off, allow decoding with errors. Otherwise, the video | 521 if (!sender_) { |
| 520 // will freeze, and will only recover with a complete key frame. | 522 // When NACK is off, allow decoding with errors. Otherwise, the video |
| 521 vcm_->SetDecodeErrorMode(kWithErrors); | 523 // will freeze, and will only recover with a complete key frame. |
| 524 vcm_->SetDecodeErrorMode(kWithErrors); | |
| 525 } | |
| 522 } | 526 } |
| 523 } | 527 } |
| 524 | 528 |
| 525 bool ViEChannel::IsSendingFecEnabled() { | 529 bool ViEChannel::IsSendingFecEnabled() { |
| 526 bool fec_enabled = false; | 530 bool fec_enabled = false; |
| 527 uint8_t pltype_red = 0; | 531 uint8_t pltype_red = 0; |
| 528 uint8_t pltype_fec = 0; | 532 uint8_t pltype_fec = 0; |
| 529 | 533 |
| 530 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 534 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 531 rtp_rtcp->GenericFECStatus(&fec_enabled, &pltype_red, &pltype_fec); | 535 rtp_rtcp->GenericFECStatus(&fec_enabled, &pltype_red, &pltype_fec); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 873 } | 877 } |
| 874 | 878 |
| 875 int32_t ViEChannel::StartSend() { | 879 int32_t ViEChannel::StartSend() { |
| 876 rtc::CritScope lock(&crit_); | 880 rtc::CritScope lock(&crit_); |
| 877 | 881 |
| 878 if (rtp_rtcp_modules_[0]->Sending()) | 882 if (rtp_rtcp_modules_[0]->Sending()) |
| 879 return -1; | 883 return -1; |
| 880 | 884 |
| 881 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) { | 885 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) { |
| 882 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[i]; | 886 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[i]; |
| 883 rtp_rtcp->SetSendingMediaStatus(true); | 887 rtp_rtcp->SetSendingMediaStatus(true); |
|
stefan-webrtc
2016/02/04 10:46:14
Should we set this to true only for the senders?
pbos-webrtc
2016/02/04 14:04:20
Done.
| |
| 884 rtp_rtcp->SetSendingStatus(true); | 888 rtp_rtcp->SetSendingStatus(true); |
| 885 } | 889 } |
| 886 send_payload_router_->set_active(true); | 890 if (sender_) |
| 891 send_payload_router_->set_active(true); | |
| 887 return 0; | 892 return 0; |
| 888 } | 893 } |
| 889 | 894 |
| 890 int32_t ViEChannel::StopSend() { | 895 int32_t ViEChannel::StopSend() { |
| 891 send_payload_router_->set_active(false); | 896 if (sender_) |
| 897 send_payload_router_->set_active(false); | |
| 892 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 898 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 893 rtp_rtcp->SetSendingMediaStatus(false); | 899 rtp_rtcp->SetSendingMediaStatus(false); |
| 894 | 900 |
| 895 if (!rtp_rtcp_modules_[0]->Sending()) { | 901 if (!rtp_rtcp_modules_[0]->Sending()) { |
| 896 return -1; | 902 return -1; |
| 897 } | 903 } |
| 898 | 904 |
| 899 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 905 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 900 rtp_rtcp->SetSendingStatus(false); | 906 rtp_rtcp->SetSendingStatus(false); |
| 901 } | 907 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 935 int32_t ViEChannel::SetMTU(uint16_t mtu) { | 941 int32_t ViEChannel::SetMTU(uint16_t mtu) { |
| 936 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 942 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
| 937 rtp_rtcp->SetMaxTransferUnit(mtu); | 943 rtp_rtcp->SetMaxTransferUnit(mtu); |
| 938 return 0; | 944 return 0; |
| 939 } | 945 } |
| 940 | 946 |
| 941 RtpRtcp* ViEChannel::rtp_rtcp() { | 947 RtpRtcp* ViEChannel::rtp_rtcp() { |
| 942 return rtp_rtcp_modules_[0]; | 948 return rtp_rtcp_modules_[0]; |
| 943 } | 949 } |
| 944 | 950 |
| 945 rtc::scoped_refptr<PayloadRouter> ViEChannel::send_payload_router() { | |
| 946 return send_payload_router_; | |
| 947 } | |
| 948 | |
| 949 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { | 951 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { |
| 950 return vcm_protection_callback_.get(); | 952 return vcm_protection_callback_.get(); |
| 951 } | 953 } |
| 952 | 954 |
| 953 CallStatsObserver* ViEChannel::GetStatsObserver() { | 955 CallStatsObserver* ViEChannel::GetStatsObserver() { |
| 954 return stats_observer_.get(); | 956 return stats_observer_.get(); |
| 955 } | 957 } |
| 956 | 958 |
| 957 // Do not acquire the lock of |vcm_| in this function. Decode callback won't | 959 // Do not acquire the lock of |vcm_| in this function. Decode callback won't |
| 958 // necessarily be called from the decoding thread. The decoding thread may have | 960 // 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... | |
| 1033 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, | 1035 int32_t ViEChannel::ResendPackets(const uint16_t* sequence_numbers, |
| 1034 uint16_t length) { | 1036 uint16_t length) { |
| 1035 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); | 1037 return rtp_rtcp_modules_[0]->SendNACK(sequence_numbers, length); |
| 1036 } | 1038 } |
| 1037 | 1039 |
| 1038 bool ViEChannel::ChannelDecodeThreadFunction(void* obj) { | 1040 bool ViEChannel::ChannelDecodeThreadFunction(void* obj) { |
| 1039 return static_cast<ViEChannel*>(obj)->ChannelDecodeProcess(); | 1041 return static_cast<ViEChannel*>(obj)->ChannelDecodeProcess(); |
| 1040 } | 1042 } |
| 1041 | 1043 |
| 1042 bool ViEChannel::ChannelDecodeProcess() { | 1044 bool ViEChannel::ChannelDecodeProcess() { |
| 1045 RTC_DCHECK(!sender_); | |
| 1043 vcm_->Decode(kMaxDecodeWaitTimeMs); | 1046 vcm_->Decode(kMaxDecodeWaitTimeMs); |
| 1044 return true; | 1047 return true; |
| 1045 } | 1048 } |
| 1046 | 1049 |
| 1047 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 1050 void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 1048 vcm_->SetReceiveChannelParameters(max_rtt_ms); | 1051 if (!sender_) |
| 1052 vcm_->SetReceiveChannelParameters(max_rtt_ms); | |
| 1049 | 1053 |
| 1050 rtc::CritScope lock(&crit_); | 1054 rtc::CritScope lock(&crit_); |
| 1051 if (time_of_first_rtt_ms_ == -1) | 1055 if (time_of_first_rtt_ms_ == -1) |
| 1052 time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); | 1056 time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds(); |
| 1053 rtt_sum_ms_ += avg_rtt_ms; | 1057 rtt_sum_ms_ += avg_rtt_ms; |
| 1054 last_rtt_ms_ = avg_rtt_ms; | 1058 last_rtt_ms_ = avg_rtt_ms; |
| 1055 ++num_rtts_; | 1059 ++num_rtts_; |
| 1056 } | 1060 } |
| 1057 | 1061 |
| 1058 int ViEChannel::ProtectionRequest(const FecProtectionParams* delta_fec_params, | 1062 int ViEChannel::ProtectionRequest(const FecProtectionParams* delta_fec_params, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 void ViEChannel::StartDecodeThread() { | 1136 void ViEChannel::StartDecodeThread() { |
| 1133 RTC_DCHECK(!sender_); | 1137 RTC_DCHECK(!sender_); |
| 1134 if (decode_thread_.IsRunning()) | 1138 if (decode_thread_.IsRunning()) |
| 1135 return; | 1139 return; |
| 1136 // Start the decode thread | 1140 // Start the decode thread |
| 1137 decode_thread_.Start(); | 1141 decode_thread_.Start(); |
| 1138 decode_thread_.SetPriority(rtc::kHighestPriority); | 1142 decode_thread_.SetPriority(rtc::kHighestPriority); |
| 1139 } | 1143 } |
| 1140 | 1144 |
| 1141 void ViEChannel::StopDecodeThread() { | 1145 void ViEChannel::StopDecodeThread() { |
| 1146 RTC_DCHECK(!sender_); | |
| 1142 vcm_->TriggerDecoderShutdown(); | 1147 vcm_->TriggerDecoderShutdown(); |
| 1143 | 1148 |
| 1144 decode_thread_.Stop(); | 1149 decode_thread_.Stop(); |
| 1145 } | 1150 } |
| 1146 | 1151 |
| 1147 int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, | 1152 int32_t ViEChannel::SetVoiceChannel(int32_t ve_channel_id, |
| 1148 VoEVideoSync* ve_sync_interface) { | 1153 VoEVideoSync* ve_sync_interface) { |
| 1154 RTC_DCHECK(!sender_); | |
| 1149 return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, | 1155 return vie_sync_.ConfigureSync(ve_channel_id, ve_sync_interface, |
| 1150 rtp_rtcp_modules_[0], | 1156 rtp_rtcp_modules_[0], |
| 1151 vie_receiver_.GetRtpReceiver()); | 1157 vie_receiver_.GetRtpReceiver()); |
| 1152 } | 1158 } |
| 1153 | 1159 |
| 1154 int32_t ViEChannel::VoiceChannel() { | 1160 int32_t ViEChannel::VoiceChannel() { |
| 1161 RTC_DCHECK(!sender_); | |
| 1155 return vie_sync_.VoiceChannel(); | 1162 return vie_sync_.VoiceChannel(); |
| 1156 } | 1163 } |
| 1157 | 1164 |
| 1158 void ViEChannel::RegisterPreRenderCallback( | 1165 void ViEChannel::RegisterPreRenderCallback( |
| 1159 I420FrameCallback* pre_render_callback) { | 1166 I420FrameCallback* pre_render_callback) { |
| 1160 rtc::CritScope lock(&crit_); | 1167 rtc::CritScope lock(&crit_); |
| 1161 pre_render_callback_ = pre_render_callback; | 1168 pre_render_callback_ = pre_render_callback; |
| 1162 } | 1169 } |
| 1163 | 1170 |
| 1164 void ViEChannel::RegisterPreDecodeImageCallback( | 1171 void ViEChannel::RegisterPreDecodeImageCallback( |
| 1165 EncodedImageCallback* pre_decode_callback) { | 1172 EncodedImageCallback* pre_decode_callback) { |
| 1173 RTC_DCHECK(!sender_); | |
| 1166 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); | 1174 vcm_->RegisterPreDecodeImageCallback(pre_decode_callback); |
| 1167 } | 1175 } |
| 1168 | 1176 |
| 1169 // TODO(pbos): Remove OnInitializeDecoder which is called from the RTP module, | 1177 // TODO(pbos): Remove OnInitializeDecoder which is called from the RTP module, |
| 1170 // any decoder resetting should be handled internally within the VCM. | 1178 // any decoder resetting should be handled internally within the VCM. |
| 1171 int32_t ViEChannel::OnInitializeDecoder( | 1179 int32_t ViEChannel::OnInitializeDecoder( |
| 1172 const int8_t payload_type, | 1180 const int8_t payload_type, |
| 1173 const char payload_name[RTP_PAYLOAD_NAME_SIZE], | 1181 const char payload_name[RTP_PAYLOAD_NAME_SIZE], |
| 1174 const int frequency, | 1182 const int frequency, |
| 1175 const size_t channels, | 1183 const size_t channels, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1197 rtc::CritScope lock(&crit_); | 1205 rtc::CritScope lock(&crit_); |
| 1198 receive_stats_callback_ = receive_statistics_proxy; | 1206 receive_stats_callback_ = receive_statistics_proxy; |
| 1199 } | 1207 } |
| 1200 | 1208 |
| 1201 void ViEChannel::SetIncomingVideoStream( | 1209 void ViEChannel::SetIncomingVideoStream( |
| 1202 IncomingVideoStream* incoming_video_stream) { | 1210 IncomingVideoStream* incoming_video_stream) { |
| 1203 rtc::CritScope lock(&crit_); | 1211 rtc::CritScope lock(&crit_); |
| 1204 incoming_video_stream_ = incoming_video_stream; | 1212 incoming_video_stream_ = incoming_video_stream; |
| 1205 } | 1213 } |
| 1206 } // namespace webrtc | 1214 } // namespace webrtc |
| OLD | NEW |