Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: webrtc/video/vie_channel.cc

Issue 1721713002: Keep disabled RtpRtcp modules registered. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/vie_channel.h ('k') | webrtc/video/vie_encoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 #include "webrtc/modules/video_coding/include/video_coding.h" 28 #include "webrtc/modules/video_coding/include/video_coding.h"
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 35
36 namespace webrtc { 36 namespace webrtc {
37 37
38 const int kMinSendSidePacketHistorySize = 600; 38 static const int kMinSendSidePacketHistorySize = 600;
39 const int kMaxPacketAgeToNack = 450; 39 static const int kMaxPacketAgeToNack = 450;
40 const int kMaxNackListSize = 250; 40 static const int kMaxNackListSize = 250;
41 41
42 // Helper class receiving statistics callbacks. 42 // Helper class receiving statistics callbacks.
43 class ChannelStatsObserver : public CallStatsObserver { 43 class ChannelStatsObserver : public CallStatsObserver {
44 public: 44 public:
45 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} 45 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {}
46 virtual ~ChannelStatsObserver() {} 46 virtual ~ChannelStatsObserver() {}
47 47
48 // Implements StatsObserver. 48 // Implements StatsObserver.
49 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 49 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
50 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 50 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 vie_receiver_(vcm_, remote_bitrate_estimator, this), 95 vie_receiver_(vcm_, remote_bitrate_estimator, this),
96 stats_observer_(new ChannelStatsObserver(this)), 96 stats_observer_(new ChannelStatsObserver(this)),
97 receive_stats_callback_(nullptr), 97 receive_stats_callback_(nullptr),
98 incoming_video_stream_(nullptr), 98 incoming_video_stream_(nullptr),
99 intra_frame_observer_(intra_frame_observer), 99 intra_frame_observer_(intra_frame_observer),
100 rtt_stats_(rtt_stats), 100 rtt_stats_(rtt_stats),
101 paced_sender_(paced_sender), 101 paced_sender_(paced_sender),
102 packet_router_(packet_router), 102 packet_router_(packet_router),
103 bandwidth_observer_(bandwidth_observer), 103 bandwidth_observer_(bandwidth_observer),
104 transport_feedback_observer_(transport_feedback_observer), 104 transport_feedback_observer_(transport_feedback_observer),
105 nack_history_size_sender_(kMinSendSidePacketHistorySize),
106 max_nack_reordering_threshold_(kMaxPacketAgeToNack), 105 max_nack_reordering_threshold_(kMaxPacketAgeToNack),
107 pre_render_callback_(NULL), 106 pre_render_callback_(NULL),
108 last_rtt_ms_(0), 107 last_rtt_ms_(0),
109 rtp_rtcp_modules_( 108 rtp_rtcp_modules_(
110 CreateRtpRtcpModules(!sender, 109 CreateRtpRtcpModules(!sender,
111 vie_receiver_.GetReceiveStatistics(), 110 vie_receiver_.GetReceiveStatistics(),
112 transport, 111 transport,
113 intra_frame_observer_, 112 intra_frame_observer_,
114 bandwidth_observer_.get(), 113 bandwidth_observer_.get(),
115 transport_feedback_observer_, 114 transport_feedback_observer_,
(...skipping 16 matching lines...) Expand all
132 RTC_DCHECK(vcm_); 131 RTC_DCHECK(vcm_);
133 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); 132 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0);
134 } 133 }
135 } 134 }
136 135
137 int32_t ViEChannel::Init() { 136 int32_t ViEChannel::Init() {
138 static const int kDefaultRenderDelayMs = 10; 137 static const int kDefaultRenderDelayMs = 10;
139 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); 138 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics());
140 139
141 // RTP/RTCP initialization. 140 // RTP/RTCP initialization.
142 module_process_thread_->RegisterModule(rtp_rtcp_modules_[0]); 141 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
142 module_process_thread_->RegisterModule(rtp_rtcp);
stefan-webrtc 2016/02/24 14:17:16 Should these be deregistered too?
pbos-webrtc 2016/02/24 14:44:25 They are deregistered in the destructor.
143 143
144 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); 144 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
145 if (paced_sender_) { 145 if (paced_sender_) {
146 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 146 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
147 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); 147 rtp_rtcp->SetStorePacketsStatus(true, kMinSendSidePacketHistorySize);
148 } 148 }
149 packet_router_->AddRtpModule(rtp_rtcp_modules_[0], sender_); 149 packet_router_->AddRtpModule(rtp_rtcp_modules_[0], sender_);
150 if (sender_) { 150 if (sender_) {
151 send_payload_router_->SetSendingRtpModules( 151 send_payload_router_->SetSendingRtpModules(
152 std::vector<RtpRtcp*>(1, rtp_rtcp_modules_[0])); 152 std::vector<RtpRtcp*>(1, rtp_rtcp_modules_[0]));
153 RTC_DCHECK(!send_payload_router_->active()); 153 RTC_DCHECK(!send_payload_router_->active());
154 } else { 154 } else {
155 if (vcm_->RegisterReceiveCallback(this) != 0) { 155 if (vcm_->RegisterReceiveCallback(this) != 0) {
156 return -1; 156 return -1;
157 } 157 }
(...skipping 11 matching lines...) Expand all
169 module_process_thread_->DeRegisterModule( 169 module_process_thread_->DeRegisterModule(
170 vie_receiver_.GetReceiveStatistics()); 170 vie_receiver_.GetReceiveStatistics());
171 if (sender_) { 171 if (sender_) {
172 send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>()); 172 send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>());
173 } 173 }
174 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) 174 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i)
175 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); 175 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_);
176 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 176 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
177 module_process_thread_->DeRegisterModule(rtp_rtcp); 177 module_process_thread_->DeRegisterModule(rtp_rtcp);
178 delete rtp_rtcp; 178 delete rtp_rtcp;
179 } 179 }
stefan-webrtc 2016/02/24 15:04:38 You may want to deregister these before deregister
pbos-webrtc 2016/02/24 15:12:27 Not sure what implications that have since RTP mod
180 } 180 }
181 181
182 void ViEChannel::UpdateHistograms() { 182 void ViEChannel::UpdateHistograms() {
183 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds(); 183 int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds();
184 184
185 if (sender_) { 185 if (sender_) {
186 RtcpPacketTypeCounter rtcp_counter; 186 RtcpPacketTypeCounter rtcp_counter;
187 GetSendRtcpPacketTypeCounter(&rtcp_counter); 187 GetSendRtcpPacketTypeCounter(&rtcp_counter);
188 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000; 188 int64_t elapsed_sec = rtcp_counter.TimeSinceFirstPacketInMs(now) / 1000;
189 if (elapsed_sec > metrics::kMinRunTimeInSeconds) { 189 if (elapsed_sec > metrics::kMinRunTimeInSeconds) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // modules can be deleted after this step. 359 // modules can be deleted after this step.
360 vie_receiver_.RegisterRtpRtcpModules(registered_modules); 360 vie_receiver_.RegisterRtpRtcpModules(registered_modules);
361 361
362 // Update the packet and payload routers with the sending RtpRtcp modules. 362 // Update the packet and payload routers with the sending RtpRtcp modules.
363 send_payload_router_->SetSendingRtpModules(registered_modules); 363 send_payload_router_->SetSendingRtpModules(registered_modules);
364 364
365 if (router_was_active) 365 if (router_was_active)
366 send_payload_router_->set_active(true); 366 send_payload_router_->set_active(true);
367 367
368 // Deregister previously registered modules. 368 // Deregister previously registered modules.
369 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) { 369 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i)
370 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); 370 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], true);
371 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_);
372 }
373 // Register new active modules. 371 // Register new active modules.
374 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { 372 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i)
375 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); 373 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], true);
376 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], sender_);
377 }
378 return 0; 374 return 0;
379 } 375 }
380 376
381 void ViEChannel::SetProtectionMode(bool enable_nack, 377 void ViEChannel::SetProtectionMode(bool enable_nack,
382 bool enable_fec, 378 bool enable_fec,
383 int payload_type_red, 379 int payload_type_red,
384 int payload_type_fec) { 380 int payload_type_fec) {
385 // Validate payload types. If either RED or FEC payload types are set then 381 // Validate payload types. If either RED or FEC payload types are set then
386 // both should be. If FEC is enabled then they both have to be set. 382 // both should be. If FEC is enabled then they both have to be set.
387 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { 383 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 416 }
421 417
422 void ViEChannel::ProcessNACKRequest(const bool enable) { 418 void ViEChannel::ProcessNACKRequest(const bool enable) {
423 if (enable) { 419 if (enable) {
424 // Turn on NACK. 420 // Turn on NACK.
425 if (rtp_rtcp_modules_[0]->RTCP() == RtcpMode::kOff) 421 if (rtp_rtcp_modules_[0]->RTCP() == RtcpMode::kOff)
426 return; 422 return;
427 vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_); 423 vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_);
428 424
429 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 425 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
430 rtp_rtcp->SetStorePacketsStatus(true, nack_history_size_sender_); 426 rtp_rtcp->SetStorePacketsStatus(true, kMinSendSidePacketHistorySize);
431 427
432 if (!sender_) { 428 if (!sender_) {
433 vcm_->RegisterPacketRequestCallback(this); 429 vcm_->RegisterPacketRequestCallback(this);
434 // Don't introduce errors when NACK is enabled. 430 // Don't introduce errors when NACK is enabled.
435 vcm_->SetDecodeErrorMode(kNoErrors); 431 vcm_->SetDecodeErrorMode(kNoErrors);
436 } 432 }
437 } else { 433 } else {
438 if (!sender_) { 434 if (!sender_) {
439 vcm_->RegisterPacketRequestCallback(nullptr); 435 vcm_->RegisterPacketRequestCallback(nullptr);
440 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) 436 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_)
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 rtc::CritScope lock(&crit_); 842 rtc::CritScope lock(&crit_);
847 receive_stats_callback_ = receive_statistics_proxy; 843 receive_stats_callback_ = receive_statistics_proxy;
848 } 844 }
849 845
850 void ViEChannel::SetIncomingVideoStream( 846 void ViEChannel::SetIncomingVideoStream(
851 IncomingVideoStream* incoming_video_stream) { 847 IncomingVideoStream* incoming_video_stream) {
852 rtc::CritScope lock(&crit_); 848 rtc::CritScope lock(&crit_);
853 incoming_video_stream_ = incoming_video_stream; 849 incoming_video_stream_ = incoming_video_stream;
854 } 850 }
855 } // namespace webrtc 851 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/vie_channel.h ('k') | webrtc/video/vie_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698