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 20 matching lines...) Expand all Loading... |
394 } | 396 } |
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 if (sender_) { |
405 for (RtpRtcp* rtp_rtcp : registered_modules) { | 407 std::list<RtpRtcp*> active_send_modules; |
406 packet_router_->AddRtpModule(rtp_rtcp); | 408 for (RtpRtcp* rtp_rtcp : registered_modules) |
407 active_send_modules.push_back(rtp_rtcp); | 409 active_send_modules.push_back(rtp_rtcp); |
| 410 send_payload_router_->SetSendingRtpModules(active_send_modules); |
408 } | 411 } |
409 send_payload_router_->SetSendingRtpModules(active_send_modules); | |
410 | 412 |
411 if (router_was_active) | 413 if (router_was_active) |
412 send_payload_router_->set_active(true); | 414 send_payload_router_->set_active(true); |
413 | 415 |
414 // Deregister previously registered modules. | 416 // Deregister previously registered modules. |
415 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) | 417 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) { |
416 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); | 418 module_process_thread_->DeRegisterModule(rtp_rtcp_modules_[i]); |
| 419 if (sender_ && packet_router_) |
| 420 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); |
| 421 } |
417 // Register new active modules. | 422 // Register new active modules. |
418 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) | 423 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { |
419 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); | 424 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); |
| 425 if (sender_ && packet_router_) |
| 426 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]); |
| 427 } |
420 return 0; | 428 return 0; |
421 } | 429 } |
422 | 430 |
423 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { | 431 int32_t ViEChannel::SetReceiveCodec(const VideoCodec& video_codec) { |
424 DCHECK(!sender_); | 432 DCHECK(!sender_); |
425 if (!vie_receiver_.SetReceiveCodec(video_codec)) { | 433 if (!vie_receiver_.SetReceiveCodec(video_codec)) { |
426 return -1; | 434 return -1; |
427 } | 435 } |
428 | 436 |
429 if (video_codec.codecType != kVideoCodecRED && | 437 if (video_codec.codecType != kVideoCodecRED && |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( | 701 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( |
694 kRtpExtensionVideoRotation, id); | 702 kRtpExtensionVideoRotation, id); |
695 } | 703 } |
696 return error; | 704 return error; |
697 } | 705 } |
698 | 706 |
699 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) { | 707 int ViEChannel::SetReceiveVideoRotationStatus(bool enable, int id) { |
700 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1; | 708 return vie_receiver_.SetReceiveVideoRotationStatus(enable, id) ? 0 : -1; |
701 } | 709 } |
702 | 710 |
| 711 int ViEChannel::SetSendTransportSequenceNumber(bool enable, int id) { |
| 712 // Disable any previous registrations of this extension to avoid errors. |
| 713 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 714 rtp_rtcp->DeregisterSendRtpHeaderExtension( |
| 715 kRtpExtensionTransportSequenceNumber); |
| 716 } |
| 717 if (!enable) |
| 718 return 0; |
| 719 // Enable the extension. |
| 720 int error = 0; |
| 721 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 722 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( |
| 723 kRtpExtensionTransportSequenceNumber, id); |
| 724 } |
| 725 return error; |
| 726 } |
| 727 |
| 728 int ViEChannel::SetReceiveTransportSequenceNumber(bool enable, int id) { |
| 729 return vie_receiver_.SetReceiveTransportSequenceNumber(enable, id) ? 0 : -1; |
| 730 } |
| 731 |
703 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) { | 732 void ViEChannel::SetRtcpXrRrtrStatus(bool enable) { |
704 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable); | 733 rtp_rtcp_modules_[0]->SetRtcpXrRrtrStatus(enable); |
705 } | 734 } |
706 | 735 |
707 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { | 736 void ViEChannel::SetTransmissionSmoothingStatus(bool enable) { |
708 DCHECK(paced_sender_ && "No paced sender registered."); | 737 DCHECK(paced_sender_ && "No paced sender registered."); |
709 paced_sender_->SetStatus(enable); | 738 paced_sender_->SetStatus(enable); |
710 } | 739 } |
711 | 740 |
712 void ViEChannel::EnableTMMBR(bool enable) { | 741 void ViEChannel::EnableTMMBR(bool enable) { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 int32_t id, | 1172 int32_t id, |
1144 bool receiver_only, | 1173 bool receiver_only, |
1145 ReceiveStatistics* receive_statistics, | 1174 ReceiveStatistics* receive_statistics, |
1146 Transport* outgoing_transport, | 1175 Transport* outgoing_transport, |
1147 RtcpIntraFrameObserver* intra_frame_callback, | 1176 RtcpIntraFrameObserver* intra_frame_callback, |
1148 RtcpBandwidthObserver* bandwidth_callback, | 1177 RtcpBandwidthObserver* bandwidth_callback, |
1149 RtcpRttStats* rtt_stats, | 1178 RtcpRttStats* rtt_stats, |
1150 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, | 1179 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer, |
1151 RemoteBitrateEstimator* remote_bitrate_estimator, | 1180 RemoteBitrateEstimator* remote_bitrate_estimator, |
1152 PacedSender* paced_sender, | 1181 PacedSender* paced_sender, |
| 1182 PacketRouter* packet_router, |
1153 BitrateStatisticsObserver* send_bitrate_observer, | 1183 BitrateStatisticsObserver* send_bitrate_observer, |
1154 FrameCountObserver* send_frame_count_observer, | 1184 FrameCountObserver* send_frame_count_observer, |
1155 SendSideDelayObserver* send_side_delay_observer, | 1185 SendSideDelayObserver* send_side_delay_observer, |
1156 size_t num_modules) { | 1186 size_t num_modules) { |
1157 DCHECK_GT(num_modules, 0u); | 1187 DCHECK_GT(num_modules, 0u); |
1158 RtpRtcp::Configuration configuration; | 1188 RtpRtcp::Configuration configuration; |
1159 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; | 1189 ReceiveStatistics* null_receive_statistics = configuration.receive_statistics; |
1160 configuration.id = id; | 1190 configuration.id = id; |
1161 configuration.audio = false; | 1191 configuration.audio = false; |
1162 configuration.receiver_only = receiver_only; | 1192 configuration.receiver_only = receiver_only; |
1163 configuration.receive_statistics = receive_statistics; | 1193 configuration.receive_statistics = receive_statistics; |
1164 configuration.outgoing_transport = outgoing_transport; | 1194 configuration.outgoing_transport = outgoing_transport; |
1165 configuration.intra_frame_callback = intra_frame_callback; | 1195 configuration.intra_frame_callback = intra_frame_callback; |
1166 configuration.rtt_stats = rtt_stats; | 1196 configuration.rtt_stats = rtt_stats; |
1167 configuration.rtcp_packet_type_counter_observer = | 1197 configuration.rtcp_packet_type_counter_observer = |
1168 rtcp_packet_type_counter_observer; | 1198 rtcp_packet_type_counter_observer; |
1169 configuration.paced_sender = paced_sender; | 1199 configuration.paced_sender = paced_sender; |
| 1200 configuration.packet_router = packet_router; |
1170 configuration.send_bitrate_observer = send_bitrate_observer; | 1201 configuration.send_bitrate_observer = send_bitrate_observer; |
1171 configuration.send_frame_count_observer = send_frame_count_observer; | 1202 configuration.send_frame_count_observer = send_frame_count_observer; |
1172 configuration.send_side_delay_observer = send_side_delay_observer; | 1203 configuration.send_side_delay_observer = send_side_delay_observer; |
1173 configuration.bandwidth_callback = bandwidth_callback; | 1204 configuration.bandwidth_callback = bandwidth_callback; |
1174 | 1205 |
1175 std::vector<RtpRtcp*> modules; | 1206 std::vector<RtpRtcp*> modules; |
1176 for (size_t i = 0; i < num_modules; ++i) { | 1207 for (size_t i = 0; i < num_modules; ++i) { |
1177 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); | 1208 RtpRtcp* rtp_rtcp = RtpRtcp::CreateRtpRtcp(configuration); |
1178 rtp_rtcp->SetSendingStatus(false); | 1209 rtp_rtcp->SetSendingStatus(false); |
1179 rtp_rtcp->SetSendingMediaStatus(false); | 1210 rtp_rtcp->SetSendingMediaStatus(false); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1268 CriticalSectionScoped cs(crit_.get()); | 1299 CriticalSectionScoped cs(crit_.get()); |
1269 vcm_receive_stats_callback_ = receive_statistics_proxy; | 1300 vcm_receive_stats_callback_ = receive_statistics_proxy; |
1270 } | 1301 } |
1271 | 1302 |
1272 void ViEChannel::SetIncomingVideoStream( | 1303 void ViEChannel::SetIncomingVideoStream( |
1273 IncomingVideoStream* incoming_video_stream) { | 1304 IncomingVideoStream* incoming_video_stream) { |
1274 CriticalSectionScoped cs(crit_.get()); | 1305 CriticalSectionScoped cs(crit_.get()); |
1275 incoming_video_stream_ = incoming_video_stream; | 1306 incoming_video_stream_ = incoming_video_stream; |
1276 } | 1307 } |
1277 } // namespace webrtc | 1308 } // namespace webrtc |
OLD | NEW |