| 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]); | 149 packet_router_->AddRtpModule(rtp_rtcp_modules_[0]); |
| 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]); | 174 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 LOG_F(LS_ERROR) << "Incorrect config " | 236 LOG_F(LS_ERROR) << "Incorrect config " |
| 238 << video_codec.numberOfSimulcastStreams; | 237 << video_codec.numberOfSimulcastStreams; |
| 239 return -1; | 238 return -1; |
| 240 } | 239 } |
| 241 // Update the RTP module with the settings. | 240 // Update the RTP module with the settings. |
| 242 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been | 241 // Stop and Start the RTP module -> trigger new SSRC, if an SSRC hasn't been |
| 243 // set explicitly. | 242 // set explicitly. |
| 244 // The first layer is always active, so the first module can be checked for | 243 // The first layer is always active, so the first module can be checked for |
| 245 // sending status. | 244 // sending status. |
| 246 bool is_sending = rtp_rtcp_modules_[0]->Sending(); | 245 bool is_sending = rtp_rtcp_modules_[0]->Sending(); |
| 247 bool router_was_active = send_payload_router_->active(); | |
| 248 send_payload_router_->set_active(false); | 246 send_payload_router_->set_active(false); |
| 249 send_payload_router_->SetSendingRtpModules(std::vector<RtpRtcp*>()); | 247 send_payload_router_->SetSendingRtpModules(0); |
| 250 | 248 |
| 251 std::vector<RtpRtcp*> registered_modules; | 249 std::vector<RtpRtcp*> registered_modules; |
| 252 std::vector<RtpRtcp*> deregistered_modules; | |
| 253 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 | 250 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 |
| 254 ? video_codec.numberOfSimulcastStreams | 251 ? video_codec.numberOfSimulcastStreams |
| 255 : 1; | 252 : 1; |
| 256 size_t num_prev_active_modules; | 253 size_t num_prev_active_modules; |
| 257 { | 254 { |
| 258 // Cache which modules are active so StartSend can know which ones to start. | 255 // Cache which modules are active so StartSend can know which ones to start. |
| 259 rtc::CritScope lock(&crit_); | 256 rtc::CritScope lock(&crit_); |
| 260 num_prev_active_modules = num_active_rtp_rtcp_modules_; | 257 num_prev_active_modules = num_active_rtp_rtcp_modules_; |
| 261 num_active_rtp_rtcp_modules_ = num_active_modules; | 258 num_active_rtp_rtcp_modules_ = num_active_modules; |
| 262 } | 259 } |
| 263 for (size_t i = 0; i < num_active_modules; ++i) | 260 for (size_t i = 0; i < num_active_modules; ++i) |
| 264 registered_modules.push_back(rtp_rtcp_modules_[i]); | 261 registered_modules.push_back(rtp_rtcp_modules_[i]); |
| 265 | 262 |
| 266 for (size_t i = num_active_modules; i < rtp_rtcp_modules_.size(); ++i) | |
| 267 deregistered_modules.push_back(rtp_rtcp_modules_[i]); | |
| 268 | |
| 269 // Disable inactive modules. | |
| 270 for (RtpRtcp* rtp_rtcp : deregistered_modules) { | |
| 271 rtp_rtcp->SetSendingStatus(false); | |
| 272 rtp_rtcp->SetSendingMediaStatus(false); | |
| 273 } | |
| 274 | |
| 275 // Configure active modules. | |
| 276 for (RtpRtcp* rtp_rtcp : registered_modules) { | |
| 277 rtp_rtcp->DeRegisterSendPayload(video_codec.plType); | |
| 278 if (rtp_rtcp->RegisterSendPayload(video_codec) != 0) { | |
| 279 return -1; | |
| 280 } | |
| 281 rtp_rtcp->SetSendingStatus(is_sending); | |
| 282 rtp_rtcp->SetSendingMediaStatus(is_sending); | |
| 283 } | |
| 284 | |
| 285 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old | 263 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old |
| 286 // modules can be deleted after this step. | 264 // modules can be deleted after this step. |
| 287 vie_receiver_.RegisterRtpRtcpModules(registered_modules); | 265 vie_receiver_.RegisterRtpRtcpModules(registered_modules); |
| 288 | 266 |
| 289 // Update the packet and payload routers with the sending RtpRtcp modules. | 267 // Update the packet and payload routers with the sending RtpRtcp modules. |
| 290 send_payload_router_->SetSendingRtpModules(registered_modules); | 268 send_payload_router_->SetSendingRtpModules(num_active_modules); |
| 291 | 269 |
| 292 if (router_was_active) | 270 send_payload_router_->set_active(is_sending); |
| 293 send_payload_router_->set_active(true); | |
| 294 | 271 |
| 295 // Deregister previously registered modules. | 272 // Deregister previously registered modules. |
| 296 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) | 273 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) |
| 297 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); | 274 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); |
| 298 // Register new active modules. | 275 // Register new active modules. |
| 299 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) | 276 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) |
| 300 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]); | 277 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]); |
| 301 return 0; | 278 return 0; |
| 302 } | 279 } |
| 303 | 280 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 SendSideDelayObserver* observer) { | 453 SendSideDelayObserver* observer) { |
| 477 send_side_delay_observer_.Set(observer); | 454 send_side_delay_observer_.Set(observer); |
| 478 } | 455 } |
| 479 | 456 |
| 480 void ViEChannel::RegisterSendBitrateObserver( | 457 void ViEChannel::RegisterSendBitrateObserver( |
| 481 BitrateStatisticsObserver* observer) { | 458 BitrateStatisticsObserver* observer) { |
| 482 send_bitrate_observer_.Set(observer); | 459 send_bitrate_observer_.Set(observer); |
| 483 } | 460 } |
| 484 | 461 |
| 485 int32_t ViEChannel::StartSend() { | 462 int32_t ViEChannel::StartSend() { |
| 486 rtc::CritScope lock(&crit_); | |
| 487 | |
| 488 if (rtp_rtcp_modules_[0]->Sending()) | 463 if (rtp_rtcp_modules_[0]->Sending()) |
| 489 return -1; | 464 return -1; |
| 490 | 465 |
| 491 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) { | 466 if (!sender_) { |
| 492 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[i]; | 467 rtp_rtcp_modules_[0]->SetSendingStatus(true); |
| 493 // Only have senders send media. | 468 } else { |
| 494 rtp_rtcp->SetSendingMediaStatus(sender_); | 469 send_payload_router_->set_active(true); |
| 495 rtp_rtcp->SetSendingStatus(true); | |
| 496 } | 470 } |
| 497 if (sender_) | |
| 498 send_payload_router_->set_active(true); | |
| 499 return 0; | 471 return 0; |
| 500 } | 472 } |
| 501 | 473 |
| 502 int32_t ViEChannel::StopSend() { | 474 int32_t ViEChannel::StopSend() { |
| 503 if (sender_) | 475 if (!rtp_rtcp_modules_[0]->Sending()) |
| 476 return -1; |
| 477 |
| 478 if (!sender_) { |
| 479 rtp_rtcp_modules_[0]->SetSendingStatus(false); |
| 480 } else { |
| 504 send_payload_router_->set_active(false); | 481 send_payload_router_->set_active(false); |
| 505 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
| 506 rtp_rtcp->SetSendingMediaStatus(false); | |
| 507 | |
| 508 if (!rtp_rtcp_modules_[0]->Sending()) { | |
| 509 return -1; | |
| 510 } | 482 } |
| 511 | 483 |
| 512 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
| 513 rtp_rtcp->SetSendingStatus(false); | |
| 514 } | |
| 515 return 0; | 484 return 0; |
| 516 } | 485 } |
| 517 | 486 |
| 518 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const { | 487 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const { |
| 519 return rtp_rtcp_modules_; | 488 return rtp_rtcp_modules_; |
| 520 } | 489 } |
| 521 | 490 |
| 522 ViEReceiver* ViEChannel::vie_receiver() { | 491 ViEReceiver* ViEChannel::vie_receiver() { |
| 523 return &vie_receiver_; | 492 return &vie_receiver_; |
| 524 } | 493 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 rtc::CritScope lock(&crit_); | 698 rtc::CritScope lock(&crit_); |
| 730 receive_stats_callback_ = receive_statistics_proxy; | 699 receive_stats_callback_ = receive_statistics_proxy; |
| 731 } | 700 } |
| 732 | 701 |
| 733 void ViEChannel::SetIncomingVideoStream( | 702 void ViEChannel::SetIncomingVideoStream( |
| 734 IncomingVideoStream* incoming_video_stream) { | 703 IncomingVideoStream* incoming_video_stream) { |
| 735 rtc::CritScope lock(&crit_); | 704 rtc::CritScope lock(&crit_); |
| 736 incoming_video_stream_ = incoming_video_stream; | 705 incoming_video_stream_ = incoming_video_stream; |
| 737 } | 706 } |
| 738 } // namespace webrtc | 707 } // namespace webrtc |
| OLD | NEW |