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

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: Rebase, again 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
« no previous file with comments | « webrtc/video_engine/vie_channel.h ('k') | webrtc/video_engine/vie_channel_group.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ViEChannel* owner_; 77 ViEChannel* owner_;
78 }; 78 };
79 79
80 ViEChannel::ViEChannel(int32_t channel_id, 80 ViEChannel::ViEChannel(int32_t channel_id,
81 int32_t engine_id, 81 int32_t engine_id,
82 uint32_t number_of_cores, 82 uint32_t number_of_cores,
83 Transport* transport, 83 Transport* transport,
84 ProcessThread* module_process_thread, 84 ProcessThread* module_process_thread,
85 RtcpIntraFrameObserver* intra_frame_observer, 85 RtcpIntraFrameObserver* intra_frame_observer,
86 RtcpBandwidthObserver* bandwidth_observer, 86 RtcpBandwidthObserver* bandwidth_observer,
87 SendTimeObserver* send_time_observer,
87 RemoteBitrateEstimator* remote_bitrate_estimator, 88 RemoteBitrateEstimator* remote_bitrate_estimator,
88 RtcpRttStats* rtt_stats, 89 RtcpRttStats* rtt_stats,
89 PacedSender* paced_sender, 90 PacedSender* paced_sender,
90 PacketRouter* packet_router, 91 PacketRouter* packet_router,
91 size_t max_rtp_streams, 92 size_t max_rtp_streams,
92 bool sender) 93 bool sender)
93 : channel_id_(channel_id), 94 : channel_id_(channel_id),
94 engine_id_(engine_id), 95 engine_id_(engine_id),
95 number_of_cores_(number_of_cores), 96 number_of_cores_(number_of_cores),
96 sender_(sender), 97 sender_(sender),
97 module_process_thread_(module_process_thread), 98 module_process_thread_(module_process_thread),
98 crit_(CriticalSectionWrapper::CreateCriticalSection()), 99 crit_(CriticalSectionWrapper::CreateCriticalSection()),
99 send_payload_router_(new PayloadRouter()), 100 send_payload_router_(new PayloadRouter()),
100 vcm_protection_callback_(new ViEChannelProtectionCallback(this)), 101 vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
101 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(), 102 vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
102 nullptr, 103 nullptr,
103 nullptr)), 104 nullptr)),
104 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this), 105 vie_receiver_(channel_id, vcm_, remote_bitrate_estimator, this),
105 vie_sync_(vcm_), 106 vie_sync_(vcm_),
106 stats_observer_(new ChannelStatsObserver(this)), 107 stats_observer_(new ChannelStatsObserver(this)),
107 vcm_receive_stats_callback_(NULL), 108 vcm_receive_stats_callback_(NULL),
108 incoming_video_stream_(nullptr), 109 incoming_video_stream_(nullptr),
109 codec_observer_(NULL), 110 codec_observer_(NULL),
110 intra_frame_observer_(intra_frame_observer), 111 intra_frame_observer_(intra_frame_observer),
111 rtt_stats_(rtt_stats), 112 rtt_stats_(rtt_stats),
112 paced_sender_(paced_sender), 113 paced_sender_(paced_sender),
113 packet_router_(packet_router), 114 packet_router_(packet_router),
114 bandwidth_observer_(bandwidth_observer), 115 bandwidth_observer_(bandwidth_observer),
116 send_time_observer_(send_time_observer),
115 decoder_reset_(true), 117 decoder_reset_(true),
116 nack_history_size_sender_(kSendSidePacketHistorySize), 118 nack_history_size_sender_(kSendSidePacketHistorySize),
117 max_nack_reordering_threshold_(kMaxPacketAgeToNack), 119 max_nack_reordering_threshold_(kMaxPacketAgeToNack),
118 pre_render_callback_(NULL), 120 pre_render_callback_(NULL),
119 report_block_stats_sender_(new ReportBlockStats()), 121 report_block_stats_sender_(new ReportBlockStats()),
120 rtp_rtcp_modules_( 122 rtp_rtcp_modules_(
121 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_), 123 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_),
122 !sender, 124 !sender,
123 vie_receiver_.GetReceiveStatistics(), 125 vie_receiver_.GetReceiveStatistics(),
124 transport, 126 transport,
125 sender ? intra_frame_observer_ : nullptr, 127 sender ? intra_frame_observer_ : nullptr,
126 sender ? bandwidth_observer_.get() : nullptr, 128 sender ? bandwidth_observer_.get() : nullptr,
129 sender ? send_time_observer_ : nullptr,
127 rtt_stats_, 130 rtt_stats_,
128 &rtcp_packet_type_counter_observer_, 131 &rtcp_packet_type_counter_observer_,
129 remote_bitrate_estimator, 132 remote_bitrate_estimator,
130 paced_sender_, 133 paced_sender_,
134 sender_ ? packet_router_ : nullptr,
131 &send_bitrate_observer_, 135 &send_bitrate_observer_,
132 &send_frame_count_observer_, 136 &send_frame_count_observer_,
133 &send_side_delay_observer_, 137 &send_side_delay_observer_,
134 max_rtp_streams)), 138 max_rtp_streams)),
135 num_active_rtp_rtcp_modules_(1) { 139 num_active_rtp_rtcp_modules_(1) {
136 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); 140 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]);
137 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); 141 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0);
138 } 142 }
139 143
140 int32_t ViEChannel::Init() { 144 int32_t ViEChannel::Init() {
(...skipping 28 matching lines...) Expand all
169 } 173 }
170 174
171 ViEChannel::~ViEChannel() { 175 ViEChannel::~ViEChannel() {
172 UpdateHistograms(); 176 UpdateHistograms();
173 // Make sure we don't get more callbacks from the RTP module. 177 // Make sure we don't get more callbacks from the RTP module.
174 module_process_thread_->DeRegisterModule( 178 module_process_thread_->DeRegisterModule(
175 vie_receiver_.GetReceiveStatistics()); 179 vie_receiver_.GetReceiveStatistics());
176 module_process_thread_->DeRegisterModule(vcm_); 180 module_process_thread_->DeRegisterModule(vcm_);
177 module_process_thread_->DeRegisterModule(&vie_sync_); 181 module_process_thread_->DeRegisterModule(&vie_sync_);
178 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); 182 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>());
183 if (sender_ && packet_router_) {
184 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i)
185 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]);
186 }
179 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { 187 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
180 packet_router_->RemoveRtpModule(rtp_rtcp);
181 module_process_thread_->DeRegisterModule(rtp_rtcp); 188 module_process_thread_->DeRegisterModule(rtp_rtcp);
182 delete rtp_rtcp; 189 delete rtp_rtcp;
183 } 190 }
184 if (decode_thread_) { 191 if (decode_thread_) {
185 StopDecodeThread(); 192 StopDecodeThread();
186 } 193 }
187 // Release modules. 194 // Release modules.
188 VideoCodingModule::Destroy(vcm_); 195 VideoCodingModule::Destroy(vcm_);
189 } 196 }
190 197
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 } 334 }
328 // Update the RTP module with the settings. 335 // Update the RTP module with the settings.
329 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been 336 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been
330 // set explicitly. 337 // set explicitly.
331 // The first layer is always active, so the first module can be checked for 338 // The first layer is always active, so the first module can be checked for
332 // sending status. 339 // sending status.
333 bool is_sending = rtp_rtcp_modules_[0]->Sending(); 340 bool is_sending = rtp_rtcp_modules_[0]->Sending();
334 bool router_was_active = send_payload_router_->active(); 341 bool router_was_active = send_payload_router_->active();
335 send_payload_router_->set_active(false); 342 send_payload_router_->set_active(false);
336 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); 343 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>());
337 for (RtpRtcp* module : rtp_rtcp_modules_)
338 packet_router_->RemoveRtpModule(module);
339 344
340 std::vector<RtpRtcp*> registered_modules; 345 std::vector<RtpRtcp*> registered_modules;
341 std::vector<RtpRtcp*> deregistered_modules; 346 std::vector<RtpRtcp*> deregistered_modules;
342 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 347 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0
343 ? video_codec.numberOfSimulcastStreams 348 ? video_codec.numberOfSimulcastStreams
344 : 1; 349 : 1;
345 size_t num_prev_active_modules; 350 size_t num_prev_active_modules;
346 { 351 {
347 // Cache which modules are active so StartSend can know which ones to start. 352 // Cache which modules are active so StartSend can know which ones to start.
348 CriticalSectionScoped cs(crit_.get()); 353 CriticalSectionScoped cs(crit_.get());
(...skipping 20 matching lines...) Expand all
369 } 374 }
370 rtp_rtcp->SetSendingStatus(is_sending); 375 rtp_rtcp->SetSendingStatus(is_sending);
371 rtp_rtcp->SetSendingMediaStatus(is_sending); 376 rtp_rtcp->SetSendingMediaStatus(is_sending);
372 } 377 }
373 378
374 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old 379 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old
375 // modules can be deleted after this step. 380 // modules can be deleted after this step.
376 vie_receiver_.RegisterRtpRtcpModules(registered_modules); 381 vie_receiver_.RegisterRtpRtcpModules(registered_modules);
377 382
378 // Update the packet and payload routers with the sending RtpRtcp modules. 383 // Update the packet and payload routers with the sending RtpRtcp modules.
379 std::list<RtpRtcp*> active_send_modules; 384 if (sender_) {
380 for (RtpRtcp* rtp_rtcp : registered_modules) { 385 std::list<RtpRtcp*> active_send_modules;
381 packet_router_->AddRtpModule(rtp_rtcp); 386 for (RtpRtcp* rtp_rtcp : registered_modules)
382 active_send_modules.push_back(rtp_rtcp); 387 active_send_modules.push_back(rtp_rtcp);
388 send_payload_router_->SetSendingRtpModules(active_send_modules);
383 } 389 }
384 send_payload_router_->SetSendingRtpModules(active_send_modules);
385 390
386 if (router_was_active) 391 if (router_was_active)
387 send_payload_router_->set_active(true); 392 send_payload_router_->set_active(true);
388 393
389 // Deregister previously registered modules. 394 // Deregister previously registered modules.
390 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) 395 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) {
391 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); 396 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]);
397 if (sender_ && packet_router_)
398 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]);
399 }
392 // Register new active modules. 400 // Register new active modules.
393 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) 401 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) {
394 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); 402 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]);
403 if (sender_ && packet_router_)
404 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]);
405 }
395 return 0; 406 return 0;
396 } 407 }
397 408
398 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { 409 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) {
399 DCHECK(!sender_); 410 DCHECK(!sender_);
400 if (!vie_receiver_.SetReceiveCodec(video_codec)) { 411 if (!vie_receiver_.SetReceiveCodec(video_codec)) {
401 return -1; 412 return -1;
402 } 413 }
403 414
404 if (video_codec.codecType != kVideoCodecRED && 415 if (video_codec.codecType != kVideoCodecRED &&
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( 679 error |= rtp_rtcp->RegisterSendRtpHeaderExtension(
669 kRtpExtensionVideoRotation, id); 680 kRtpExtensionVideoRotation, id);
670 } 681 }
671 return error; 682 return error;
672 } 683 }
673 684
674 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) { 685 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) {
675 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1; 686 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1;
676 } 687 }
677 688
689 int ViEChannel::SetSendTransportSequenceNumber(bool enable, int id) {
690 // Disable any previous registrations of this extension to avoid errors.
691 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
692 rtp_rtcp->DeregisterSendRtpHeaderExtension(
693 kRtpExtensionTransportSequenceNumber);
694 }
695 if (!enable)
696 return 0;
697 // Enable the extension.
698 int error = 0;
699 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) {
700 error |= rtp_rtcp->RegisterSendRtpHeaderExtension(
701 kRtpExtensionTransportSequenceNumber, id);
702 }
703 return error;
704 }
705
706 int ViEChannel::SetReceiveTransportSequenceNumber(bool enable, int id) {
707 return vie_receiver_.SetReceiveTransportSequenceNumber(enable, id) ? 0 : -1;
708 }
709
678 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) { 710 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) {
679 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable); 711 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable);
680 } 712 }
681 713
682 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { 714 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) {
683 DCHECK(paced_sender_ && "No paced sender registered."); 715 DCHECK(paced_sender_ && "No paced sender registered.");
684 paced_sender_->SetStatus(enable); 716 paced_sender_->SetStatus(enable);
685 } 717 }
686 718
687 void ViEChannel::EnableTMMBR(bool enable) { 719 void ViEChannel::EnableTMMBR(bool enable) {
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 return 0; 1146 return 0;
1115 } 1147 }
1116 1148
1117 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules( 1149 std::vector<RtpRtcp*> ViEChannel::CreateRtpRtcpModules(
1118 int32_t id, 1150 int32_t id,
1119 bool receiver_only, 1151 bool receiver_only,
1120 ReceiveStatistics* receive_statistics, 1152 ReceiveStatistics* receive_statistics,
1121 Transport* outgoing_transport, 1153 Transport* outgoing_transport,
1122 RtcpIntraFrameObserver* intra_frame_callback, 1154 RtcpIntraFrameObserver* intra_frame_callback,
1123 RtcpBandwidthObserver* bandwidth_callback, 1155 RtcpBandwidthObserver* bandwidth_callback,
1156 SendTimeObserver* send_time_callback,
1124 RtcpRttStats* rtt_stats, 1157 RtcpRttStats* rtt_stats,
1125 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, 1158 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
1126 RemoteBitrateEstimator* remote_bitrate_estimator, 1159 RemoteBitrateEstimator* remote_bitrate_estimator,
1127 PacedSender* paced_sender, 1160 PacedSender* paced_sender,
1161 PacketRouter* packet_router,
1128 BitrateStatisticsObserver* send_bitrate_observer, 1162 BitrateStatisticsObserver* send_bitrate_observer,
1129 FrameCountObserver* send_frame_count_observer, 1163 FrameCountObserver* send_frame_count_observer,
1130 SendSideDelayObserver* send_side_delay_observer, 1164 SendSideDelayObserver* send_side_delay_observer,
1131 size_t num_modules) { 1165 size_t num_modules) {
1132 DCHECK_GT(num_modules, 0u); 1166 DCHECK_GT(num_modules, 0u);
1133 RtpRtcp::Configuration configuration; 1167 RtpRtcp::Configuration configuration;
1134 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; 1168 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics;
1135 configuration.id = id; 1169 configuration.id = id;
1136 configuration.audio = false; 1170 configuration.audio = false;
1137 configuration.receiver_only = receiver_only; 1171 configuration.receiver_only = receiver_only;
1138 configuration.receive_statistics = receive_statistics; 1172 configuration.receive_statistics = receive_statistics;
1139 configuration.outgoing_transport = outgoing_transport; 1173 configuration.outgoing_transport = outgoing_transport;
1140 configuration.intra_frame_callback = intra_frame_callback; 1174 configuration.intra_frame_callback = intra_frame_callback;
1141 configuration.rtt_stats = rtt_stats; 1175 configuration.rtt_stats = rtt_stats;
1142 configuration.rtcp_packet_type_counter_observer = 1176 configuration.rtcp_packet_type_counter_observer =
1143 rtcp_packet_type_counter_observer; 1177 rtcp_packet_type_counter_observer;
1144 configuration.paced_sender = paced_sender; 1178 configuration.paced_sender = paced_sender;
1179 configuration.packet_router = packet_router;
1145 configuration.send_bitrate_observer = send_bitrate_observer; 1180 configuration.send_bitrate_observer = send_bitrate_observer;
1146 configuration.send_frame_count_observer = send_frame_count_observer; 1181 configuration.send_frame_count_observer = send_frame_count_observer;
1147 configuration.send_side_delay_observer = send_side_delay_observer; 1182 configuration.send_side_delay_observer = send_side_delay_observer;
1148 configuration.bandwidth_callback = bandwidth_callback; 1183 configuration.bandwidth_callback = bandwidth_callback;
1184 configuration.send_time_callback = send_time_callback;
1149 1185
1150 std::vector<RtpRtcp*> modules; 1186 std::vector<RtpRtcp*> modules;
1151 for (size_t i = 0; i < num_modules; ++i) { 1187 for (size_t i = 0; i < num_modules; ++i) {
1152 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); 1188 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration);
1153 rtp_rtcp->SetSendingStatus(false); 1189 rtp_rtcp->SetSendingStatus(false);
1154 rtp_rtcp->SetSendingMediaStatus(false); 1190 rtp_rtcp->SetSendingMediaStatus(false);
1155 rtp_rtcp->SetRTCPStatus(kRtcpCompound); 1191 rtp_rtcp->SetRTCPStatus(kRtcpCompound);
1156 modules.push_back(rtp_rtcp); 1192 modules.push_back(rtp_rtcp);
1157 // Receive statistics and remote bitrate estimator should only be set for 1193 // Receive statistics and remote bitrate estimator should only be set for
1158 // the primary (first) module. 1194 // the primary (first) module.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 CriticalSectionScoped cs(crit_.get()); 1279 CriticalSectionScoped cs(crit_.get());
1244 vcm_receive_stats_callback_ = receive_statistics_proxy; 1280 vcm_receive_stats_callback_ = receive_statistics_proxy;
1245 } 1281 }
1246 1282
1247 void ViEChannel::SetIncomingVideoStream( 1283 void ViEChannel::SetIncomingVideoStream(
1248 IncomingVideoStream* incoming_video_stream) { 1284 IncomingVideoStream* incoming_video_stream) {
1249 CriticalSectionScoped cs(crit_.get()); 1285 CriticalSectionScoped cs(crit_.get());
1250 incoming_video_stream_ = incoming_video_stream; 1286 incoming_video_stream_ = incoming_video_stream;
1251 } 1287 }
1252 } // namespace webrtc 1288 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video_engine/vie_channel.h ('k') | webrtc/video_engine/vie_channel_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698