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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bandwidth_observer_.get(), | 113 bandwidth_observer_.get(), |
114 transport_feedback_observer_, | 114 transport_feedback_observer_, |
115 rtt_stats_, | 115 rtt_stats_, |
116 &rtcp_packet_type_counter_observer_, | 116 &rtcp_packet_type_counter_observer_, |
117 remote_bitrate_estimator, | 117 remote_bitrate_estimator, |
118 paced_sender_, | 118 paced_sender_, |
119 packet_router_, | 119 packet_router_, |
120 &send_bitrate_observer_, | 120 &send_bitrate_observer_, |
121 &send_frame_count_observer_, | 121 &send_frame_count_observer_, |
122 &send_side_delay_observer_, | 122 &send_side_delay_observer_, |
123 max_rtp_streams)), | 123 max_rtp_streams)) { |
124 num_active_rtp_rtcp_modules_(1) { | |
125 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); | 124 vie_receiver_.SetRtpRtcpModule(rtp_rtcp_modules_[0]); |
126 if (sender_) { | 125 if (sender_) { |
127 RTC_DCHECK(send_payload_router_); | 126 RTC_DCHECK(send_payload_router_); |
128 RTC_DCHECK(!vcm_); | 127 RTC_DCHECK(!vcm_); |
129 } else { | 128 } else { |
130 RTC_DCHECK(!send_payload_router_); | 129 RTC_DCHECK(!send_payload_router_); |
131 RTC_DCHECK(vcm_); | 130 RTC_DCHECK(vcm_); |
132 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); | 131 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); |
133 } | 132 } |
134 } | 133 } |
135 | 134 |
136 int32_t ViEChannel::Init() { | 135 int32_t ViEChannel::Init() { |
137 static const int kDefaultRenderDelayMs = 10; | 136 static const int kDefaultRenderDelayMs = 10; |
138 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); | 137 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); |
139 | 138 |
140 // RTP/RTCP initialization. | 139 // RTP/RTCP initialization. |
141 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 140 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
142 module_process_thread_->RegisterModule(rtp_rtcp); | 141 module_process_thread_->RegisterModule(rtp_rtcp); |
| 142 packet_router_->AddRtpModule(rtp_rtcp); |
| 143 } |
143 | 144 |
144 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); | 145 rtp_rtcp_modules_[0]->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp); |
145 if (paced_sender_) { | 146 if (paced_sender_) { |
146 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 147 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
147 rtp_rtcp->SetStorePacketsStatus(true, kMinSendSidePacketHistorySize); | 148 rtp_rtcp->SetStorePacketsStatus(true, kMinSendSidePacketHistorySize); |
148 } | 149 } |
149 packet_router_->AddRtpModule(rtp_rtcp_modules_[0]); | |
150 if (sender_) { | 150 if (sender_) { |
151 send_payload_router_->SetSendingRtpModules(1); | 151 send_payload_router_->SetSendingRtpModules(1); |
152 RTC_DCHECK(!send_payload_router_->active()); | 152 RTC_DCHECK(!send_payload_router_->active()); |
153 } else { | 153 } else { |
154 if (vcm_->RegisterReceiveCallback(this) != 0) { | 154 if (vcm_->RegisterReceiveCallback(this) != 0) { |
155 return -1; | 155 return -1; |
156 } | 156 } |
157 vcm_->RegisterFrameTypeCallback(this); | 157 vcm_->RegisterFrameTypeCallback(this); |
158 vcm_->RegisterReceiveStatisticsCallback(this); | 158 vcm_->RegisterReceiveStatisticsCallback(this); |
159 vcm_->RegisterDecoderTimingCallback(this); | 159 vcm_->RegisterDecoderTimingCallback(this); |
160 vcm_->SetRenderDelay(kDefaultRenderDelayMs); | 160 vcm_->SetRenderDelay(kDefaultRenderDelayMs); |
161 } | 161 } |
162 return 0; | 162 return 0; |
163 } | 163 } |
164 | 164 |
165 ViEChannel::~ViEChannel() { | 165 ViEChannel::~ViEChannel() { |
166 UpdateHistograms(); | 166 UpdateHistograms(); |
167 // 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. |
168 module_process_thread_->DeRegisterModule( | 168 module_process_thread_->DeRegisterModule( |
169 vie_receiver_.GetReceiveStatistics()); | 169 vie_receiver_.GetReceiveStatistics()); |
170 if (sender_) { | 170 if (sender_) { |
171 send_payload_router_->SetSendingRtpModules(0); | 171 send_payload_router_->SetSendingRtpModules(0); |
172 } | 172 } |
173 for (size_t i = 0; i < num_active_rtp_rtcp_modules_; ++i) | |
174 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); | |
175 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 173 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
| 174 packet_router_->RemoveRtpModule(rtp_rtcp); |
176 module_process_thread_->DeRegisterModule(rtp_rtcp); | 175 module_process_thread_->DeRegisterModule(rtp_rtcp); |
177 delete rtp_rtcp; | 176 delete rtp_rtcp; |
178 } | 177 } |
179 } | 178 } |
180 | 179 |
181 void ViEChannel::UpdateHistograms() { | 180 void ViEChannel::UpdateHistograms() { |
182 if (sender_) { | 181 if (sender_) { |
183 StreamDataCounters rtp; | 182 StreamDataCounters rtp; |
184 StreamDataCounters rtx; | 183 StreamDataCounters rtx; |
185 GetSendStreamDataCounters(&rtp, &rtx); | 184 GetSendStreamDataCounters(&rtp, &rtx); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // The first layer is always active, so the first module can be checked for | 242 // The first layer is always active, so the first module can be checked for |
244 // sending status. | 243 // sending status. |
245 bool is_sending = rtp_rtcp_modules_[0]->Sending(); | 244 bool is_sending = rtp_rtcp_modules_[0]->Sending(); |
246 send_payload_router_->set_active(false); | 245 send_payload_router_->set_active(false); |
247 send_payload_router_->SetSendingRtpModules(0); | 246 send_payload_router_->SetSendingRtpModules(0); |
248 | 247 |
249 std::vector<RtpRtcp*> registered_modules; | 248 std::vector<RtpRtcp*> registered_modules; |
250 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 | 249 size_t num_active_modules = video_codec.numberOfSimulcastStreams > 0 |
251 ? video_codec.numberOfSimulcastStreams | 250 ? video_codec.numberOfSimulcastStreams |
252 : 1; | 251 : 1; |
253 size_t num_prev_active_modules; | |
254 { | |
255 // Cache which modules are active so StartSend can know which ones to start. | |
256 rtc::CritScope lock(&crit_); | |
257 num_prev_active_modules = num_active_rtp_rtcp_modules_; | |
258 num_active_rtp_rtcp_modules_ = num_active_modules; | |
259 } | |
260 for (size_t i = 0; i < num_active_modules; ++i) | 252 for (size_t i = 0; i < num_active_modules; ++i) |
261 registered_modules.push_back(rtp_rtcp_modules_[i]); | 253 registered_modules.push_back(rtp_rtcp_modules_[i]); |
262 | 254 |
263 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old | 255 // |RegisterSimulcastRtpRtcpModules| resets all old weak pointers and old |
264 // modules can be deleted after this step. | 256 // modules can be deleted after this step. |
265 vie_receiver_.RegisterRtpRtcpModules(registered_modules); | 257 vie_receiver_.RegisterRtpRtcpModules(registered_modules); |
266 | 258 |
267 // Update the packet and payload routers with the sending RtpRtcp modules. | 259 // Update the packet and payload routers with the sending RtpRtcp modules. |
268 send_payload_router_->SetSendingRtpModules(num_active_modules); | 260 send_payload_router_->SetSendingRtpModules(num_active_modules); |
269 | 261 |
270 send_payload_router_->set_active(is_sending); | 262 send_payload_router_->set_active(is_sending); |
271 | 263 |
272 // Deregister previously registered modules. | |
273 for (size_t i = num_active_modules; i < num_prev_active_modules; ++i) | |
274 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i]); | |
275 // Register new active modules. | |
276 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) | |
277 packet_router_->AddRtpModule(rtp_rtcp_modules_[i]); | |
278 return 0; | 264 return 0; |
279 } | 265 } |
280 | 266 |
281 void ViEChannel::SetProtectionMode(bool enable_nack, | 267 void ViEChannel::SetProtectionMode(bool enable_nack, |
282 bool enable_fec, | 268 bool enable_fec, |
283 int payload_type_red, | 269 int payload_type_red, |
284 int payload_type_fec) { | 270 int payload_type_fec) { |
285 // Validate payload types. If either RED or FEC payload types are set then | 271 // Validate payload types. If either RED or FEC payload types are set then |
286 // both should be. If FEC is enabled then they both have to be set. | 272 // both should be. If FEC is enabled then they both have to be set. |
287 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { | 273 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 rtc::CritScope lock(&crit_); | 619 rtc::CritScope lock(&crit_); |
634 receive_stats_callback_ = receive_statistics_proxy; | 620 receive_stats_callback_ = receive_statistics_proxy; |
635 } | 621 } |
636 | 622 |
637 void ViEChannel::SetIncomingVideoStream( | 623 void ViEChannel::SetIncomingVideoStream( |
638 IncomingVideoStream* incoming_video_stream) { | 624 IncomingVideoStream* incoming_video_stream) { |
639 rtc::CritScope lock(&crit_); | 625 rtc::CritScope lock(&crit_); |
640 incoming_video_stream_ = incoming_video_stream; | 626 incoming_video_stream_ = incoming_video_stream; |
641 } | 627 } |
642 } // namespace webrtc | 628 } // namespace webrtc |
OLD | NEW |