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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 141 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
142 module_process_thread_->RegisterModule(rtp_rtcp); | 142 module_process_thread_->RegisterModule(rtp_rtcp); |
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, kMinSendSidePacketHistorySize); | 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(1); |
152 std::vector<RtpRtcp*>(1, rtp_rtcp_modules_[0])); | |
153 RTC_DCHECK(!send_payload_router_->active()); | 152 RTC_DCHECK(!send_payload_router_->active()); |
154 } else { | 153 } else { |
155 if (vcm_->RegisterReceiveCallback(this) != 0) { | 154 if (vcm_->RegisterReceiveCallback(this) != 0) { |
156 return -1; | 155 return -1; |
157 } | 156 } |
158 vcm_->RegisterFrameTypeCallback(this); | 157 vcm_->RegisterFrameTypeCallback(this); |
159 vcm_->RegisterReceiveStatisticsCallback(this); | 158 vcm_->RegisterReceiveStatisticsCallback(this); |
160 vcm_->RegisterDecoderTimingCallback(this); | 159 vcm_->RegisterDecoderTimingCallback(this); |
161 vcm_->SetRenderDelay(kDefaultRenderDelayMs); | 160 vcm_->SetRenderDelay(kDefaultRenderDelayMs); |
162 } | 161 } |
163 return 0; | 162 return 0; |
164 } | 163 } |
165 | 164 |
166 ViEChannel::~ViEChannel() { | 165 ViEChannel::~ViEChannel() { |
167 UpdateHistograms(); | 166 UpdateHistograms(); |
168 // Make sure we don't get more callbacks from the RTP module. | 167 // Make sure we don't get more callbacks from the RTP module. |
169 module_process_thread_->DeRegisterModule( | 168 module_process_thread_->DeRegisterModule( |
170 vie_receiver_.GetReceiveStatistics()); | 169 vie_receiver_.GetReceiveStatistics()); |
171 if (sender_) { | 170 if (sender_) { |
172 send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>()); | 171 send_payload_router_->SetSendingRtpModules(0); |
173 } | 172 } |
174 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | 173 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) |
175 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 174 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
176 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 175 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
177 module_process_thread_->DeRegisterModule(rtp_rtcp); | 176 module_process_thread_->DeRegisterModule(rtp_rtcp); |
178 delete rtp_rtcp; | 177 delete rtp_rtcp; |
179 } | 178 } |
180 } | 179 } |
181 | 180 |
182 void ViEChannel::UpdateHistograms() { | 181 void ViEChannel::UpdateHistograms() { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 LOG_F(LS_ERROR) << "Incorrect config " | 273 LOG_F(LS_ERROR) << "Incorrect config " |
275 << video_codec.numberOfSimulcastStreams; | 274 << video_codec.numberOfSimulcastStreams; |
276 return -1; | 275 return -1; |
277 } | 276 } |
278 // Update the RTP module with the settings. | 277 // Update the RTP module with the settings. |
279 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been | 278 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been |
280 // set explicitly. | 279 // set explicitly. |
281 // The first layer is always active, so the first module can be checked for | 280 // The first layer is always active, so the first module can be checked for |
282 // sending status. | 281 // sending status. |
283 bool is_sending = rtp_rtcp_modules_[0]->Sending(); | 282 bool is_sending = rtp_rtcp_modules_[0]->Sending(); |
284 bool router_was_active = send_payload_router_->active(); | |
285 send_payload_router_->set_active(false); | 283 send_payload_router_->set_active(false); |
286 send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>()); | 284 send_payload_router_->SetSendingRtpModules(0); |
287 | 285 |
288 std::vector<RtpRtcp*> registered_modules; | 286 std::vector<RtpRtcp*> registered_modules; |
289 std::vector<RtpRtcp*> deregistered_modules; | |
290 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 | 287 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 |
291 ? video_codec.numberOfSimulcastStreams | 288 ? video_codec.numberOfSimulcastStreams |
292 : 1; | 289 : 1; |
293 size_t num_prev_active_modules; | 290 size_t num_prev_active_modules; |
294 { | 291 { |
295 // Cache which modules are active so StartSend can know which ones to start. | 292 // Cache which modules are active so StartSend can know which ones to start. |
296 rtc::CritScope lock(&crit_); | 293 rtc::CritScope lock(&crit_); |
297 num_prev_active_modules = num_active_rtp_rtcp_modules_; | 294 num_prev_active_modules = num_active_rtp_rtcp_modules_; |
298 num_active_rtp_rtcp_modules_ = num_active_modules; | 295 num_active_rtp_rtcp_modules_ = num_active_modules; |
299 } | 296 } |
300 for (size_t i = 0; i < num_active_modules; ++i) | 297 for (size_t i = 0; i < num_active_modules; ++i) |
301 registered_modules.push_back(rtp_rtcp_modules_[i]); | 298 registered_modules.push_back(rtp_rtcp_modules_[i]); |
302 | 299 |
303 for (size_t i = num_active_modules; i < rtp_rtcp_modules_.size(); ++i) | |
304 deregistered_modules.push_back(rtp_rtcp_modules_[i]); | |
305 | |
306 // Disable inactive modules. | |
307 for (RtpRtcp* rtp_rtcp : deregistered_modules) { | |
308 rtp_rtcp->SetSendingStatus(false); | |
309 rtp_rtcp->SetSendingMediaStatus(false); | |
310 } | |
311 | |
312 // Configure active modules. | |
313 for (RtpRtcp* rtp_rtcp : registered_modules) { | |
314 rtp_rtcp->DeRegisterSendPayload(video_codec.plType); | |
315 if (rtp_rtcp->RegisterSendPayload(video_codec) != 0) { | |
316 return -1; | |
317 } | |
318 rtp_rtcp->SetSendingStatus(is_sending); | |
319 rtp_rtcp->SetSendingMediaStatus(is_sending); | |
320 } | |
321 | |
322 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old | 300 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old |
323 // modules can be deleted after this step. | 301 // modules can be deleted after this step. |
324 vie_receiver_.RegisterRtpRtcpModules(registered_modules); | 302 vie_receiver_.RegisterRtpRtcpModules(registered_modules); |
325 | 303 |
326 // Update the packet and payload routers with the sending RtpRtcp modules. | 304 // Update the packet and payload routers with the sending RtpRtcp modules. |
327 send_payload_router_->SetSendingRtpModules(registered_modules); | 305 send_payload_router_->SetSendingRtpModules(num_active_modules); |
328 | 306 |
329 if (router_was_active) | 307 send_payload_router_->set_active(is_sending); |
330 send_payload_router_->set_active(true); | |
331 | 308 |
332 // Deregister previously registered modules. | 309 // Deregister previously registered modules. |
333 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) | 310 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) |
334 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], true); | 311 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], true); |
335 // Register new active modules. | 312 // Register new active modules. |
336 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) | 313 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) |
337 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], true); | 314 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], true); |
338 return 0; | 315 return 0; |
339 } | 316 } |
340 | 317 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
535 SendSideDelayObserver* observer) { | 512 SendSideDelayObserver* observer) { |
536 send_side_delay_observer_.Set(observer); | 513 send_side_delay_observer_.Set(observer); |
537 } | 514 } |
538 | 515 |
539 void ViEChannel::RegisterSendBitrateObserver( | 516 void ViEChannel::RegisterSendBitrateObserver( |
540 BitrateStatisticsObserver* observer) { | 517 BitrateStatisticsObserver* observer) { |
541 send_bitrate_observer_.Set(observer); | 518 send_bitrate_observer_.Set(observer); |
542 } | 519 } |
543 | 520 |
544 int32_t ViEChannel::StartSend() { | 521 int32_t ViEChannel::StartSend() { |
545 rtc::CritScope lock(&crit_); | |
546 | |
547 if (rtp_rtcp_modules_[0]->Sending()) | 522 if (rtp_rtcp_modules_[0]->Sending()) |
548 return -1; | 523 return -1; |
549 | 524 |
550 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) { | 525 if (!sender_) { |
551 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[i]; | 526 rtp_rtcp_modules_[0]->SetSendingStatus(true); |
stefan-webrtc
2016/02/26 14:49:07
Shouldn't we rely on the payload router to do this
pbos-webrtc
2016/02/26 14:58:56
Not on the receiver side. I'm removing this in a l
| |
552 // Only have senders send media. | 527 } else { |
553 rtp_rtcp->SetSendingMediaStatus(sender_); | 528 send_payload_router_->set_active(true); |
554 rtp_rtcp->SetSendingStatus(true); | |
555 } | 529 } |
556 if (sender_) | |
557 send_payload_router_->set_active(true); | |
558 return 0; | 530 return 0; |
559 } | 531 } |
560 | 532 |
561 int32_t ViEChannel::StopSend() { | 533 int32_t ViEChannel::StopSend() { |
562 if (sender_) | 534 if (!rtp_rtcp_modules_[0]->Sending()) |
535 return -1; | |
536 | |
537 if (!sender_) { | |
538 rtp_rtcp_modules_[0]->SetSendingStatus(false); | |
539 } else { | |
563 send_payload_router_->set_active(false); | 540 send_payload_router_->set_active(false); |
564 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
565 rtp_rtcp->SetSendingMediaStatus(false); | |
566 | |
567 if (!rtp_rtcp_modules_[0]->Sending()) { | |
568 return -1; | |
569 } | 541 } |
570 | 542 |
571 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
572 rtp_rtcp->SetSendingStatus(false); | |
573 } | |
574 return 0; | 543 return 0; |
575 } | 544 } |
576 | 545 |
577 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const { | 546 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const { |
578 return rtp_rtcp_modules_; | 547 return rtp_rtcp_modules_; |
579 } | 548 } |
580 | 549 |
581 ViEReceiver* ViEChannel::vie_receiver() { | 550 ViEReceiver* ViEChannel::vie_receiver() { |
582 return &vie_receiver_; | 551 return &vie_receiver_; |
583 } | 552 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 rtc::CritScope lock(&crit_); | 757 rtc::CritScope lock(&crit_); |
789 receive_stats_callback_ = receive_statistics_proxy; | 758 receive_stats_callback_ = receive_statistics_proxy; |
790 } | 759 } |
791 | 760 |
792 void ViEChannel::SetIncomingVideoStream( | 761 void ViEChannel::SetIncomingVideoStream( |
793 IncomingVideoStream* incoming_video_stream) { | 762 IncomingVideoStream* incoming_video_stream) { |
794 rtc::CritScope lock(&crit_); | 763 rtc::CritScope lock(&crit_); |
795 incoming_video_stream_ = incoming_video_stream; | 764 incoming_video_stream_ = incoming_video_stream; |
796 } | 765 } |
797 } // namespace webrtc | 766 } // namespace webrtc |
OLD | NEW |