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

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

Issue 1247293002: Add support for transport wide sequence numbers (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moved SendTimeHistory, comment Created 5 years, 4 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
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }; 79 };
80 80
81 ViEChannel::ViEChannel(int32_t channel_id, 81 ViEChannel::ViEChannel(int32_t channel_id,
82 int32_t engine_id, 82 int32_t engine_id,
83 uint32_t number_of_cores, 83 uint32_t number_of_cores,
84 const Config& config, 84 const Config& config,
85 Transport* transport, 85 Transport* transport,
86 ProcessThread* module_process_thread, 86 ProcessThread* module_process_thread,
87 RtcpIntraFrameObserver* intra_frame_observer, 87 RtcpIntraFrameObserver* intra_frame_observer,
88 RtcpBandwidthObserver* bandwidth_observer, 88 RtcpBandwidthObserver* bandwidth_observer,
89 SendTimeObserver* send_time_observer,
89 RemoteBitrateEstimator* remote_bitrate_estimator, 90 RemoteBitrateEstimator* remote_bitrate_estimator,
90 RtcpRttStats* rtt_stats, 91 RtcpRttStats* rtt_stats,
91 PacedSender* paced_sender, 92 PacedSender* paced_sender,
92 PacketRouter* packet_router, 93 PacketRouter* packet_router,
93 size_t max_rtp_streams, 94 size_t max_rtp_streams,
94 bool sender, 95 bool sender,
95 bool disable_default_encoder) 96 bool disable_default_encoder)
96 : channel_id_(channel_id), 97 : channel_id_(channel_id),
97 engine_id_(engine_id), 98 engine_id_(engine_id),
98 number_of_cores_(number_of_cores), 99 number_of_cores_(number_of_cores),
99 sender_(sender), 100 sender_(sender),
100 module_process_thread_(module_process_thread), 101 module_process_thread_(module_process_thread),
101 crit_(CriticalSectionWrapper::CreateCriticalSection()), 102 crit_(CriticalSectionWrapper::CreateCriticalSection()),
102 send_payload_router_(new PayloadRouter()), 103 send_payload_router_(new PayloadRouter()),
103 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), 104 vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
104 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), 105 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
105 nullptr, 106 nullptr,
106 nullptr)), 107 nullptr)),
107 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this), 108 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this),
108 vie_sync_(vcm_), 109 vie_sync_(vcm_),
109 stats_observer_(new ChannelStatsObserver(this)), 110 stats_observer_(new ChannelStatsObserver(this)),
110 vcm_receive_stats_callback_(NULL), 111 vcm_receive_stats_callback_(NULL),
111 incoming_video_stream_(nullptr), 112 incoming_video_stream_(nullptr),
112 codec_observer_(NULL), 113 codec_observer_(NULL),
113 intra_frame_observer_(intra_frame_observer), 114 intra_frame_observer_(intra_frame_observer),
114 rtt_stats_(rtt_stats), 115 rtt_stats_(rtt_stats),
115 paced_sender_(paced_sender), 116 paced_sender_(paced_sender),
116 packet_router_(packet_router), 117 packet_router_(packet_router),
117 bandwidth_observer_(bandwidth_observer), 118 bandwidth_observer_(bandwidth_observer),
119 send_time_observer_(send_time_observer),
118 decoder_reset_(true), 120 decoder_reset_(true),
119 disable_default_encoder_(disable_default_encoder), 121 disable_default_encoder_(disable_default_encoder),
120 nack_history_size_sender_(kSendSidePacketHistorySize), 122 nack_history_size_sender_(kSendSidePacketHistorySize),
121 max_nack_reordering_threshold_(kMaxPacketAgeToNack), 123 max_nack_reordering_threshold_(kMaxPacketAgeToNack),
122 pre_render_callback_(NULL), 124 pre_render_callback_(NULL),
123 report_block_stats_sender_(new ReportBlockStats()), 125 report_block_stats_sender_(new ReportBlockStats()),
124 rtp_rtcp_modules_( 126 rtp_rtcp_modules_(
125 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_), 127 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_),
126 !sender, 128 !sender,
127 vie_receiver_.GetReceiveStatistics(), 129 vie_receiver_.GetReceiveStatistics(),
128 transport, 130 transport,
129 sender ? intra_frame_observer_ : nullptr, 131 sender ? intra_frame_observer_ : nullptr,
130 sender ? bandwidth_observer_.get() : nullptr, 132 sender ? bandwidth_observer_.get() : nullptr,
133 sender ? send_time_observer_ : nullptr,
131 rtt_stats_, 134 rtt_stats_,
132 &rtcp_packet_type_counter_observer_, 135 &rtcp_packet_type_counter_observer_,
133 remote_bitrate_estimator, 136 remote_bitrate_estimator,
134 paced_sender_, 137 paced_sender_,
138 sender_ ? packet_router_ : nullptr,
135 &send_bitrate_observer_, 139 &send_bitrate_observer_,
136 &send_frame_count_observer_, 140 &send_frame_count_observer_,
137 &send_side_delay_observer_, 141 &send_side_delay_observer_,
138 max_rtp_streams)), 142 max_rtp_streams)),
139 num_active_rtp_rtcp_modules_(1) { 143 num_active_rtp_rtcp_modules_(1) {
140 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); 144 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]);
141 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); 145 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0);
142 } 146 }
143 147
144 int32_t ViEChannel::Init() { 148 int32_t ViEChannel::Init() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 198 }
195 199
196 ViEChannel::~ViEChannel() { 200 ViEChannel::~ViEChannel() {
197 UpdateHistograms(); 201 UpdateHistograms();
198 // Make sure we don't get more callbacks from the RTP module. 202 // Make sure we don't get more callbacks from the RTP module.
199 module_process_thread_->DeRegisterModule( 203 module_process_thread_->DeRegisterModule(
200 vie_receiver_.GetReceiveStatistics()); 204 vie_receiver_.GetReceiveStatistics());
201 module_process_thread_->DeRegisterModule(vcm_); 205 module_process_thread_->DeRegisterModule(vcm_);
202 module_process_thread_->DeRegisterModule(&vie_sync_); 206 module_process_thread_->DeRegisterModule(&vie_sync_);
203 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); 207 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>());
208 if (sender_ && packet_router_) {
209 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i)
210 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]);
211 }
204 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 212 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
205 packet_router_->RemoveRtpModule(rtp_rtcp);
206 module_process_thread_->DeRegisterModule(rtp_rtcp); 213 module_process_thread_->DeRegisterModule(rtp_rtcp);
207 delete rtp_rtcp; 214 delete rtp_rtcp;
208 } 215 }
209 if (decode_thread_) { 216 if (decode_thread_) {
210 StopDecodeThread(); 217 StopDecodeThread();
211 } 218 }
212 // Release modules. 219 // Release modules.
213 VideoCodingModule::Destroy(vcm_); 220 VideoCodingModule::Destroy(vcm_);
214 } 221 }
215 222
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } 359 }
353 // Update the RTP module with the settings. 360 // Update the RTP module with the settings.
354 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been 361 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been
355 // set explicitly. 362 // set explicitly.
356 // The first layer is always active, so the first module can be checked for 363 // The first layer is always active, so the first module can be checked for
357 // sending status. 364 // sending status.
358 bool is_sending = rtp_rtcp_modules_[0]->Sending(); 365 bool is_sending = rtp_rtcp_modules_[0]->Sending();
359 bool router_was_active = send_payload_router_->active(); 366 bool router_was_active = send_payload_router_->active();
360 send_payload_router_->set_active(false); 367 send_payload_router_->set_active(false);
361 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); 368 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>());
362 for (RtpRtcp* module : rtp_rtcp_modules_)
363 packet_router_->RemoveRtpModule(module);
364 369
365 std::vector<RtpRtcp*> registered_modules; 370 std::vector<RtpRtcp*> registered_modules;
366 std::vector<RtpRtcp*> deregistered_modules; 371 std::vector<RtpRtcp*> deregistered_modules;
367 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 372 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0
368 ? video_codec.numberOfSimulcastStreams 373 ? video_codec.numberOfSimulcastStreams
369 : 1; 374 : 1;
370 size_t num_prev_active_modules; 375 size_t num_prev_active_modules;
371 { 376 {
372 // Cache which modules are active so StartSend can know which ones to start. 377 // Cache which modules are active so StartSend can know which ones to start.
373 CriticalSectionScoped cs(crit_.get()); 378 CriticalSectionScoped cs(crit_.get());
(...skipping 20 matching lines...) Expand all
394 } 399 }
395 rtp_rtcp->SetSendingStatus(is_sending); 400 rtp_rtcp->SetSendingStatus(is_sending);
396 rtp_rtcp->SetSendingMediaStatus(is_sending); 401 rtp_rtcp->SetSendingMediaStatus(is_sending);
397 } 402 }
398 403
399 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old 404 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old
400 // modules can be deleted after this step. 405 // modules can be deleted after this step.
401 vie_receiver_.RegisterRtpRtcpModules(registered_modules); 406 vie_receiver_.RegisterRtpRtcpModules(registered_modules);
402 407
403 // Update the packet and payload routers with the sending RtpRtcp modules. 408 // Update the packet and payload routers with the sending RtpRtcp modules.
404 std::list<RtpRtcp*> active_send_modules; 409 if (sender_) {
405 for (RtpRtcp* rtp_rtcp : registered_modules) { 410 std::list<RtpRtcp*> active_send_modules;
406 packet_router_->AddRtpModule(rtp_rtcp); 411 for (RtpRtcp* rtp_rtcp : registered_modules)
407 active_send_modules.push_back(rtp_rtcp); 412 active_send_modules.push_back(rtp_rtcp);
413 send_payload_router_->SetSendingRtpModules(active_send_modules);
408 } 414 }
409 send_payload_router_->SetSendingRtpModules(active_send_modules);
410 415
411 if (router_was_active) 416 if (router_was_active)
412 send_payload_router_->set_active(true); 417 send_payload_router_->set_active(true);
413 418
414 // Deregister previously registered modules. 419 // Deregister previously registered modules.
415 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) 420 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) {
416 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); 421 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]);
422 if (sender_ && packet_router_)
423 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]);
424 }
417 // Register new active modules. 425 // Register new active modules.
418 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) 426 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) {
419 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); 427 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]);
428 if (sender_ && packet_router_)
429 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]);
430 }
420 return 0; 431 return 0;
421 } 432 }
422 433
423 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { 434 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) {
424 DCHECK(!sender_); 435 DCHECK(!sender_);
425 if (!vie_receiver_.SetReceiveCodec(video_codec)) { 436 if (!vie_receiver_.SetReceiveCodec(video_codec)) {
426 return -1; 437 return -1;
427 } 438 }
428 439
429 if (video_codec.codecType != kVideoCodecRED && 440 if (video_codec.codecType != kVideoCodecRED &&
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( 704 error |= rtp_rtcp->RegisterSendRtpHeaderExtension(
694 kRtpExtensionVideoRotation, id); 705 kRtpExtensionVideoRotation, id);
695 } 706 }
696 return error; 707 return error;
697 } 708 }
698 709
699 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) { 710 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) {
700 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1; 711 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1;
701 } 712 }
702 713
714 int ViEChannel::SetSendTransportSequenceNumber(bool enable, int id) {
715 // Disable any previous registrations of this extension to avoid errors.
716 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
717 rtp_rtcp->DeregisterSendRtpHeaderExtension(
718 kRtpExtensionTransportSequenceNumber);
719 }
720 if (!enable)
721 return 0;
722 // Enable the extension.
723 int error = 0;
724 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
725 error |= rtp_rtcp->RegisterSendRtpHeaderExtension(
726 kRtpExtensionTransportSequenceNumber, id);
727 }
728 return error;
729 }
730
731 int ViEChannel::SetReceiveTransportSequenceNumber(bool enable, int id) {
732 return vie_receiver_.SetReceiveTransportSequenceNumber(enable, id) ? 0 : -1;
733 }
734
703 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) { 735 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) {
704 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable); 736 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable);
705 } 737 }
706 738
707 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { 739 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) {
708 DCHECK(paced_sender_ && "No paced sender registered."); 740 DCHECK(paced_sender_ && "No paced sender registered.");
709 paced_sender_->SetStatus(enable); 741 paced_sender_->SetStatus(enable);
710 } 742 }
711 743
712 void ViEChannel::EnableTMMBR(bool enable) { 744 void ViEChannel::EnableTMMBR(bool enable) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 return 0; 1171 return 0;
1140 } 1172 }
1141 1173
1142 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules( 1174 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules(
1143 int32_t id, 1175 int32_t id,
1144 bool receiver_only, 1176 bool receiver_only,
1145 ReceiveStatistics* receive_statistics, 1177 ReceiveStatistics* receive_statistics,
1146 Transport* outgoing_transport, 1178 Transport* outgoing_transport,
1147 RtcpIntraFrameObserver* intra_frame_callback, 1179 RtcpIntraFrameObserver* intra_frame_callback,
1148 RtcpBandwidthObserver* bandwidth_callback, 1180 RtcpBandwidthObserver* bandwidth_callback,
1181 SendTimeObserver* send_time_callback,
1149 RtcpRttStats* rtt_stats, 1182 RtcpRttStats* rtt_stats,
1150 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, 1183 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
1151 RemoteBitrateEstimator* remote_bitrate_estimator, 1184 RemoteBitrateEstimator* remote_bitrate_estimator,
1152 PacedSender* paced_sender, 1185 PacedSender* paced_sender,
1186 PacketRouter* packet_router,
1153 BitrateStatisticsObserver* send_bitrate_observer, 1187 BitrateStatisticsObserver* send_bitrate_observer,
1154 FrameCountObserver* send_frame_count_observer, 1188 FrameCountObserver* send_frame_count_observer,
1155 SendSideDelayObserver* send_side_delay_observer, 1189 SendSideDelayObserver* send_side_delay_observer,
1156 size_t num_modules) { 1190 size_t num_modules) {
1157 DCHECK_GT(num_modules, 0u); 1191 DCHECK_GT(num_modules, 0u);
1158 RtpRtcp::Configuration configuration; 1192 RtpRtcp::Configuration configuration;
1159 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; 1193 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics;
1160 configuration.id = id; 1194 configuration.id = id;
1161 configuration.audio = false; 1195 configuration.audio = false;
1162 configuration.receiver_only = receiver_only; 1196 configuration.receiver_only = receiver_only;
1163 configuration.receive_statistics = receive_statistics; 1197 configuration.receive_statistics = receive_statistics;
1164 configuration.outgoing_transport = outgoing_transport; 1198 configuration.outgoing_transport = outgoing_transport;
1165 configuration.intra_frame_callback = intra_frame_callback; 1199 configuration.intra_frame_callback = intra_frame_callback;
1166 configuration.rtt_stats = rtt_stats; 1200 configuration.rtt_stats = rtt_stats;
1167 configuration.rtcp_packet_type_counter_observer = 1201 configuration.rtcp_packet_type_counter_observer =
1168 rtcp_packet_type_counter_observer; 1202 rtcp_packet_type_counter_observer;
1169 configuration.paced_sender = paced_sender; 1203 configuration.paced_sender = paced_sender;
1204 configuration.packet_router = packet_router;
1170 configuration.send_bitrate_observer = send_bitrate_observer; 1205 configuration.send_bitrate_observer = send_bitrate_observer;
1171 configuration.send_frame_count_observer = send_frame_count_observer; 1206 configuration.send_frame_count_observer = send_frame_count_observer;
1172 configuration.send_side_delay_observer = send_side_delay_observer; 1207 configuration.send_side_delay_observer = send_side_delay_observer;
1173 configuration.bandwidth_callback = bandwidth_callback; 1208 configuration.bandwidth_callback = bandwidth_callback;
1209 configuration.send_time_callback = send_time_callback;
1174 1210
1175 std::vector<RtpRtcp*> modules; 1211 std::vector<RtpRtcp*> modules;
1176 for (size_t i = 0; i < num_modules; ++i) { 1212 for (size_t i = 0; i < num_modules; ++i) {
1177 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); 1213 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration);
1178 rtp_rtcp->SetSendingStatus(false); 1214 rtp_rtcp->SetSendingStatus(false);
1179 rtp_rtcp->SetSendingMediaStatus(false); 1215 rtp_rtcp->SetSendingMediaStatus(false);
1180 rtp_rtcp->SetRTCPStatus(kRtcpCompound); 1216 rtp_rtcp->SetRTCPStatus(kRtcpCompound);
1181 modules.push_back(rtp_rtcp); 1217 modules.push_back(rtp_rtcp);
1182 // Receive statistics and remote bitrate estimator should only be set for 1218 // Receive statistics and remote bitrate estimator should only be set for
1183 // the primary (first) module. 1219 // the primary (first) module.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 CriticalSectionScoped cs(crit_.get()); 1304 CriticalSectionScoped cs(crit_.get());
1269 vcm_receive_stats_callback_ = receive_statistics_proxy; 1305 vcm_receive_stats_callback_ = receive_statistics_proxy;
1270 } 1306 }
1271 1307
1272 void ViEChannel::SetIncomingVideoStream( 1308 void ViEChannel::SetIncomingVideoStream(
1273 IncomingVideoStream* incoming_video_stream) { 1309 IncomingVideoStream* incoming_video_stream) {
1274 CriticalSectionScoped cs(crit_.get()); 1310 CriticalSectionScoped cs(crit_.get());
1275 incoming_video_stream_ = incoming_video_stream; 1311 incoming_video_stream_ = incoming_video_stream;
1276 } 1312 }
1277 } // namespace webrtc 1313 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698