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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_), | 125 CreateRtpRtcpModules(ViEModuleId(engine_id_, channel_id_), |
126 !sender, | 126 !sender, |
127 vie_receiver_.GetReceiveStatistics(), | 127 vie_receiver_.GetReceiveStatistics(), |
128 transport, | 128 transport, |
129 sender ? intra_frame_observer_ : nullptr, | 129 sender ? intra_frame_observer_ : nullptr, |
130 sender ? bandwidth_observer_.get() : nullptr, | 130 sender ? bandwidth_observer_.get() : nullptr, |
131 rtt_stats_, | 131 rtt_stats_, |
132 &rtcp_packet_type_counter_observer_, | 132 &rtcp_packet_type_counter_observer_, |
133 remote_bitrate_estimator, | 133 remote_bitrate_estimator, |
134 paced_sender_, | 134 paced_sender_, |
135 sender_ ? packet_router_ : nullptr, | |
135 &send_bitrate_observer_, | 136 &send_bitrate_observer_, |
136 &send_frame_count_observer_, | 137 &send_frame_count_observer_, |
137 &send_side_delay_observer_, | 138 &send_side_delay_observer_, |
138 max_rtp_streams)), | 139 max_rtp_streams)), |
139 num_active_rtp_rtcp_modules_(1) { | 140 num_active_rtp_rtcp_modules_(1) { |
140 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); | 141 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); |
141 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); | 142 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); |
142 } | 143 } |
143 | 144 |
144 int32_t ViEChannel::Init() { | 145 int32_t ViEChannel::Init() { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 } | 195 } |
195 | 196 |
196 ViEChannel::~ViEChannel() { | 197 ViEChannel::~ViEChannel() { |
197 UpdateHistograms(); | 198 UpdateHistograms(); |
198 // Make sure we don't get more callbacks from the RTP module. | 199 // Make sure we don't get more callbacks from the RTP module. |
199 module_process_thread_->DeRegisterModule( | 200 module_process_thread_->DeRegisterModule( |
200 vie_receiver_.GetReceiveStatistics()); | 201 vie_receiver_.GetReceiveStatistics()); |
201 module_process_thread_->DeRegisterModule(vcm_); | 202 module_process_thread_->DeRegisterModule(vcm_); |
202 module_process_thread_->DeRegisterModule(&vie_sync_); | 203 module_process_thread_->DeRegisterModule(&vie_sync_); |
203 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); | 204 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); |
205 if (sender_ && packet_router_) { | |
206 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | |
207 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); | |
208 } | |
204 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 209 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
205 packet_router_->RemoveRtpModule(rtp_rtcp); | |
206 module_process_thread_->DeRegisterModule(rtp_rtcp); | 210 module_process_thread_->DeRegisterModule(rtp_rtcp); |
207 delete rtp_rtcp; | 211 delete rtp_rtcp; |
208 } | 212 } |
209 if (decode_thread_) { | 213 if (decode_thread_) { |
210 StopDecodeThread(); | 214 StopDecodeThread(); |
211 } | 215 } |
212 // Release modules. | 216 // Release modules. |
213 VideoCodingModule::Destroy(vcm_); | 217 VideoCodingModule::Destroy(vcm_); |
214 } | 218 } |
215 | 219 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 } | 356 } |
353 // Update the RTP module with the settings. | 357 // Update the RTP module with the settings. |
354 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been | 358 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been |
355 // set explicitly. | 359 // set explicitly. |
356 // The first layer is always active, so the first module can be checked for | 360 // The first layer is always active, so the first module can be checked for |
357 // sending status. | 361 // sending status. |
358 bool is_sending = rtp_rtcp_modules_[0]->Sending(); | 362 bool is_sending = rtp_rtcp_modules_[0]->Sending(); |
359 bool router_was_active = send_payload_router_->active(); | 363 bool router_was_active = send_payload_router_->active(); |
360 send_payload_router_->set_active(false); | 364 send_payload_router_->set_active(false); |
361 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); | 365 send_payload_router_->SetSendingRtpModules(std::list<RtpRtcp*>()); |
362 for (RtpRtcp* module : rtp_rtcp_modules_) | |
363 packet_router_->RemoveRtpModule(module); | |
364 | 366 |
365 std::vector<RtpRtcp*> registered_modules; | 367 std::vector<RtpRtcp*> registered_modules; |
366 std::vector<RtpRtcp*> deregistered_modules; | 368 std::vector<RtpRtcp*> deregistered_modules; |
367 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 | 369 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 |
368 ? video_codec.numberOfSimulcastStreams | 370 ? video_codec.numberOfSimulcastStreams |
369 : 1; | 371 : 1; |
370 size_t num_prev_active_modules; | 372 size_t num_prev_active_modules; |
371 { | 373 { |
372 // Cache which modules are active so StartSend can know which ones to start. | 374 // Cache which modules are active so StartSend can know which ones to start. |
373 CriticalSectionScoped cs(crit_.get()); | 375 CriticalSectionScoped cs(crit_.get()); |
(...skipping 21 matching lines...) Expand all Loading... | |
395 rtp_rtcp->SetSendingStatus(is_sending); | 397 rtp_rtcp->SetSendingStatus(is_sending); |
396 rtp_rtcp->SetSendingMediaStatus(is_sending); | 398 rtp_rtcp->SetSendingMediaStatus(is_sending); |
397 } | 399 } |
398 | 400 |
399 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old | 401 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old |
400 // modules can be deleted after this step. | 402 // modules can be deleted after this step. |
401 vie_receiver_.RegisterRtpRtcpModules(registered_modules); | 403 vie_receiver_.RegisterRtpRtcpModules(registered_modules); |
402 | 404 |
403 // Update the packet and payload routers with the sending RtpRtcp modules. | 405 // Update the packet and payload routers with the sending RtpRtcp modules. |
404 std::list<RtpRtcp*> active_send_modules; | 406 std::list<RtpRtcp*> active_send_modules; |
405 for (RtpRtcp* rtp_rtcp : registered_modules) { | 407 for (RtpRtcp* rtp_rtcp : registered_modules) |
406 packet_router_->AddRtpModule(rtp_rtcp); | |
407 active_send_modules.push_back(rtp_rtcp); | 408 active_send_modules.push_back(rtp_rtcp); |
408 } | |
409 send_payload_router_->SetSendingRtpModules(active_send_modules); | 409 send_payload_router_->SetSendingRtpModules(active_send_modules); |
stefan-webrtc
2015/07/22 10:49:01
Seems like send_payload_router_ and active_send_mo
sprang_webrtc
2015/07/22 15:11:32
Done.
| |
410 | 410 |
411 if (router_was_active) | 411 if (router_was_active) |
412 send_payload_router_->set_active(true); | 412 send_payload_router_->set_active(true); |
413 | 413 |
414 // Deregister previously registered modules. | 414 // Deregister previously registered modules. |
415 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) | 415 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) { |
416 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); | 416 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); |
417 if (sender_ && packet_router_) | |
418 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); | |
419 } | |
417 // Register new active modules. | 420 // Register new active modules. |
418 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) | 421 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { |
419 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); | 422 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); |
423 if (sender_ && packet_router_) | |
424 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]); | |
425 } | |
420 return 0; | 426 return 0; |
421 } | 427 } |
422 | 428 |
423 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { | 429 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { |
424 DCHECK(!sender_); | 430 DCHECK(!sender_); |
425 if (!vie_receiver_.SetReceiveCodec(video_codec)) { | 431 if (!vie_receiver_.SetReceiveCodec(video_codec)) { |
426 return -1; | 432 return -1; |
427 } | 433 } |
428 | 434 |
429 if (video_codec.codecType != kVideoCodecRED && | 435 if (video_codec.codecType != kVideoCodecRED && |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( | 699 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( |
694 kRtpExtensionVideoRotation, id); | 700 kRtpExtensionVideoRotation, id); |
695 } | 701 } |
696 return error; | 702 return error; |
697 } | 703 } |
698 | 704 |
699 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) { | 705 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) { |
700 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1; | 706 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1; |
701 } | 707 } |
702 | 708 |
709 int ViEChannel::SetSendTransportSequenceNumber(bool enable, int id) { | |
710 // Disable any previous registrations of this extension to avoid errors. | |
711 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
stefan-webrtc
2015/07/22 10:49:01
{}
sprang_webrtc
2015/07/22 15:11:33
Done.
| |
712 rtp_rtcp->DeregisterSendRtpHeaderExtension( | |
713 kRtpExtensionTransportSequenceNumber); | |
714 if (!enable) | |
715 return 0; | |
716 // Enable the extension. | |
717 int error = 0; | |
718 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
719 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( | |
720 kRtpExtensionTransportSequenceNumber, id); | |
721 } | |
722 return error; | |
723 } | |
724 | |
725 int ViEChannel::SetReceiveTransportSequenceNumber(bool enable, int id) { | |
726 return vie_receiver_.SetReceiveTransportSequenceNumber(enable, id) ? 0 : -1; | |
727 } | |
728 | |
703 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) { | 729 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) { |
704 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable); | 730 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable); |
705 } | 731 } |
706 | 732 |
707 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { | 733 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { |
708 DCHECK(paced_sender_ && "No paced sender registered."); | 734 DCHECK(paced_sender_ && "No paced sender registered."); |
709 paced_sender_->SetStatus(enable); | 735 paced_sender_->SetStatus(enable); |
710 } | 736 } |
711 | 737 |
712 void ViEChannel::EnableTMMBR(bool enable) { | 738 void ViEChannel::EnableTMMBR(bool enable) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 int32_t id, | 1169 int32_t id, |
1144 bool receiver_only, | 1170 bool receiver_only, |
1145 ReceiveStatistics* receive_statistics, | 1171 ReceiveStatistics* receive_statistics, |
1146 Transport* outgoing_transport, | 1172 Transport* outgoing_transport, |
1147 RtcpIntraFrameObserver* intra_frame_callback, | 1173 RtcpIntraFrameObserver* intra_frame_callback, |
1148 RtcpBandwidthObserver* bandwidth_callback, | 1174 RtcpBandwidthObserver* bandwidth_callback, |
1149 RtcpRttStats* rtt_stats, | 1175 RtcpRttStats* rtt_stats, |
1150 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, | 1176 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, |
1151 RemoteBitrateEstimator* remote_bitrate_estimator, | 1177 RemoteBitrateEstimator* remote_bitrate_estimator, |
1152 PacedSender* paced_sender, | 1178 PacedSender* paced_sender, |
1179 PacketRouter* packet_router, | |
1153 BitrateStatisticsObserver* send_bitrate_observer, | 1180 BitrateStatisticsObserver* send_bitrate_observer, |
1154 FrameCountObserver* send_frame_count_observer, | 1181 FrameCountObserver* send_frame_count_observer, |
1155 SendSideDelayObserver* send_side_delay_observer, | 1182 SendSideDelayObserver* send_side_delay_observer, |
1156 size_t num_modules) { | 1183 size_t num_modules) { |
1157 DCHECK_GT(num_modules, 0u); | 1184 DCHECK_GT(num_modules, 0u); |
1158 RtpRtcp::Configuration configuration; | 1185 RtpRtcp::Configuration configuration; |
1159 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; | 1186 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; |
1160 configuration.id = id; | 1187 configuration.id = id; |
1161 configuration.audio = false; | 1188 configuration.audio = false; |
1162 configuration.receiver_only = receiver_only; | 1189 configuration.receiver_only = receiver_only; |
1163 configuration.receive_statistics = receive_statistics; | 1190 configuration.receive_statistics = receive_statistics; |
1164 configuration.outgoing_transport = outgoing_transport; | 1191 configuration.outgoing_transport = outgoing_transport; |
1165 configuration.intra_frame_callback = intra_frame_callback; | 1192 configuration.intra_frame_callback = intra_frame_callback; |
1166 configuration.rtt_stats = rtt_stats; | 1193 configuration.rtt_stats = rtt_stats; |
1167 configuration.rtcp_packet_type_counter_observer = | 1194 configuration.rtcp_packet_type_counter_observer = |
1168 rtcp_packet_type_counter_observer; | 1195 rtcp_packet_type_counter_observer; |
1169 configuration.paced_sender = paced_sender; | 1196 configuration.paced_sender = paced_sender; |
1197 configuration.packet_router = packet_router; | |
1170 configuration.send_bitrate_observer = send_bitrate_observer; | 1198 configuration.send_bitrate_observer = send_bitrate_observer; |
1171 configuration.send_frame_count_observer = send_frame_count_observer; | 1199 configuration.send_frame_count_observer = send_frame_count_observer; |
1172 configuration.send_side_delay_observer = send_side_delay_observer; | 1200 configuration.send_side_delay_observer = send_side_delay_observer; |
1173 configuration.bandwidth_callback = bandwidth_callback; | 1201 configuration.bandwidth_callback = bandwidth_callback; |
1174 | 1202 |
1175 std::vector<RtpRtcp*> modules; | 1203 std::vector<RtpRtcp*> modules; |
1176 for (size_t i = 0; i < num_modules; ++i) { | 1204 for (size_t i = 0; i < num_modules; ++i) { |
1177 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); | 1205 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); |
1178 rtp_rtcp->SetSendingStatus(false); | 1206 rtp_rtcp->SetSendingStatus(false); |
1179 rtp_rtcp->SetSendingMediaStatus(false); | 1207 rtp_rtcp->SetSendingMediaStatus(false); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 CriticalSectionScoped cs(crit_.get()); | 1296 CriticalSectionScoped cs(crit_.get()); |
1269 vcm_receive_stats_callback_ = receive_statistics_proxy; | 1297 vcm_receive_stats_callback_ = receive_statistics_proxy; |
1270 } | 1298 } |
1271 | 1299 |
1272 void ViEChannel::SetIncomingVideoStream( | 1300 void ViEChannel::SetIncomingVideoStream( |
1273 IncomingVideoStream* incoming_video_stream) { | 1301 IncomingVideoStream* incoming_video_stream) { |
1274 CriticalSectionScoped cs(crit_.get()); | 1302 CriticalSectionScoped cs(crit_.get()); |
1275 incoming_video_stream_ = incoming_video_stream; | 1303 incoming_video_stream_ = incoming_video_stream; |
1276 } | 1304 } |
1277 } // namespace webrtc | 1305 } // namespace webrtc |
OLD | NEW |