Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: webrtc/video/video_receive_stream.cc

Issue 1917363005: Rename ViEReceiver and move ownership to VideoReceiveStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Add back dtoe since needed b/c ChannelStatsObserver declaration in cc Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | webrtc/video/vie_channel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 config_(config), 158 config_(config),
159 process_thread_(process_thread), 159 process_thread_(process_thread),
160 clock_(Clock::GetRealTimeClock()), 160 clock_(Clock::GetRealTimeClock()),
161 decode_thread_(DecodeThreadFunction, this, "DecodingThread"), 161 decode_thread_(DecodeThreadFunction, this, "DecodingThread"),
162 congestion_controller_(congestion_controller), 162 congestion_controller_(congestion_controller),
163 call_stats_(call_stats), 163 call_stats_(call_stats),
164 remb_(remb), 164 remb_(remb),
165 video_receiver_(clock_, nullptr, this, this, this), 165 video_receiver_(clock_, nullptr, this, this, this),
166 incoming_video_stream_(0, config.disable_prerenderer_smoothing), 166 incoming_video_stream_(0, config.disable_prerenderer_smoothing),
167 stats_proxy_(config_, clock_), 167 stats_proxy_(config_, clock_),
168 vie_channel_(&transport_adapter_, 168 rtp_stream_receiver_(&video_receiver_,
169 process_thread, 169 congestion_controller_->GetRemoteBitrateEstimator(
170 &video_receiver_, 170 UseSendSideBwe(config_)),
171 congestion_controller_->GetRemoteBitrateEstimator( 171 &transport_adapter_,
172 UseSendSideBwe(config_)), 172 call_stats_->rtcp_rtt_stats(),
173 call_stats_->rtcp_rtt_stats(), 173 congestion_controller_->pacer(),
174 congestion_controller_->pacer(), 174 congestion_controller_->packet_router()),
175 congestion_controller_->packet_router()), 175 vie_channel_(&video_receiver_,
176 vie_receiver_(vie_channel_.vie_receiver()), 176 &rtp_stream_receiver_),
177 vie_sync_(&video_receiver_), 177 vie_sync_(&video_receiver_),
178 rtp_rtcp_(vie_channel_.rtp_rtcp()) { 178 rtp_rtcp_(vie_channel_.rtp_rtcp()) {
179 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); 179 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
180 180
181 RTC_DCHECK(process_thread_); 181 RTC_DCHECK(process_thread_);
182 RTC_DCHECK(congestion_controller_); 182 RTC_DCHECK(congestion_controller_);
183 RTC_DCHECK(call_stats_); 183 RTC_DCHECK(call_stats_);
184 RTC_DCHECK(remb_); 184 RTC_DCHECK(remb_);
185 RTC_CHECK(vie_channel_.Init() == 0); 185 RTC_CHECK(vie_channel_.Init() == 0);
186 186
(...skipping 12 matching lines...) Expand all
199 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? 199 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams?
200 RTC_DCHECK(config_.rtp.local_ssrc != 0); 200 RTC_DCHECK(config_.rtp.local_ssrc != 0);
201 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); 201 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc);
202 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc); 202 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc);
203 203
204 // TODO(pbos): Support multiple RTX, per video payload. 204 // TODO(pbos): Support multiple RTX, per video payload.
205 for (const auto& kv : config_.rtp.rtx) { 205 for (const auto& kv : config_.rtp.rtx) {
206 RTC_DCHECK(kv.second.ssrc != 0); 206 RTC_DCHECK(kv.second.ssrc != 0);
207 RTC_DCHECK(kv.second.payload_type != 0); 207 RTC_DCHECK(kv.second.payload_type != 0);
208 208
209 vie_receiver_->SetRtxSsrc(kv.second.ssrc); 209 rtp_stream_receiver_.SetRtxSsrc(kv.second.ssrc);
210 vie_receiver_->SetRtxPayloadType(kv.second.payload_type, kv.first); 210 rtp_stream_receiver_.SetRtxPayloadType(kv.second.payload_type, kv.first);
211 } 211 }
212 // TODO(holmer): When Chrome no longer depends on this being false by default, 212 // TODO(holmer): When Chrome no longer depends on this being false by default,
213 // always use the mapping and remove this whole codepath. 213 // always use the mapping and remove this whole codepath.
214 vie_receiver_->SetUseRtxPayloadMappingOnRestore( 214 rtp_stream_receiver_.SetUseRtxPayloadMappingOnRestore(
215 config_.rtp.use_rtx_payload_mapping_on_restore); 215 config_.rtp.use_rtx_payload_mapping_on_restore);
216 216
217 if (config_.rtp.remb) { 217 if (config_.rtp.remb) {
218 rtp_rtcp_->SetREMBStatus(true); 218 rtp_rtcp_->SetREMBStatus(true);
219 remb_->AddReceiveChannel(rtp_rtcp_); 219 remb_->AddReceiveChannel(rtp_rtcp_);
220 } 220 }
221 221
222 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { 222 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
223 const std::string& extension = config_.rtp.extensions[i].name; 223 const std::string& extension = config_.rtp.extensions[i].name;
224 int id = config_.rtp.extensions[i].id; 224 int id = config_.rtp.extensions[i].id;
225 // One-byte-extension local identifiers are in the range 1-14 inclusive. 225 // One-byte-extension local identifiers are in the range 1-14 inclusive.
226 RTC_DCHECK_GE(id, 1); 226 RTC_DCHECK_GE(id, 1);
227 RTC_DCHECK_LE(id, 14); 227 RTC_DCHECK_LE(id, 14);
228 vie_receiver_->EnableReceiveRtpHeaderExtension(extension, id); 228 rtp_stream_receiver_.EnableReceiveRtpHeaderExtension(extension, id);
229 } 229 }
230 230
231 if (config_.rtp.fec.ulpfec_payload_type != -1) { 231 if (config_.rtp.fec.ulpfec_payload_type != -1) {
232 // ULPFEC without RED doesn't make sense. 232 // ULPFEC without RED doesn't make sense.
233 RTC_DCHECK(config_.rtp.fec.red_payload_type != -1); 233 RTC_DCHECK(config_.rtp.fec.red_payload_type != -1);
234 VideoCodec codec; 234 VideoCodec codec;
235 memset(&codec, 0, sizeof(codec)); 235 memset(&codec, 0, sizeof(codec));
236 codec.codecType = kVideoCodecULPFEC; 236 codec.codecType = kVideoCodecULPFEC;
237 strncpy(codec.plName, "ulpfec", sizeof(codec.plName)); 237 strncpy(codec.plName, "ulpfec", sizeof(codec.plName));
238 codec.plType = config_.rtp.fec.ulpfec_payload_type; 238 codec.plType = config_.rtp.fec.ulpfec_payload_type;
239 RTC_CHECK(vie_receiver_->SetReceiveCodec(codec)); 239 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec));
240 } 240 }
241 if (config_.rtp.fec.red_payload_type != -1) { 241 if (config_.rtp.fec.red_payload_type != -1) {
242 VideoCodec codec; 242 VideoCodec codec;
243 memset(&codec, 0, sizeof(codec)); 243 memset(&codec, 0, sizeof(codec));
244 codec.codecType = kVideoCodecRED; 244 codec.codecType = kVideoCodecRED;
245 strncpy(codec.plName, "red", sizeof(codec.plName)); 245 strncpy(codec.plName, "red", sizeof(codec.plName));
246 codec.plType = config_.rtp.fec.red_payload_type; 246 codec.plType = config_.rtp.fec.red_payload_type;
247 RTC_CHECK(vie_receiver_->SetReceiveCodec(codec)); 247 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec));
248 if (config_.rtp.fec.red_rtx_payload_type != -1) { 248 if (config_.rtp.fec.red_rtx_payload_type != -1) {
249 vie_receiver_->SetRtxPayloadType(config_.rtp.fec.red_rtx_payload_type, 249 rtp_stream_receiver_.SetRtxPayloadType(
250 config_.rtp.fec.red_payload_type); 250 config_.rtp.fec.red_rtx_payload_type,
251 config_.rtp.fec.red_payload_type);
251 } 252 }
252 } 253 }
253 254
254 if (config.rtp.rtcp_xr.receiver_reference_time_report) 255 if (config.rtp.rtcp_xr.receiver_reference_time_report)
255 rtp_rtcp_->SetRtcpXrRrtrStatus(true); 256 rtp_rtcp_->SetRtcpXrRrtrStatus(true);
256 257
257 vie_channel_.RegisterReceiveStatisticsProxy(&stats_proxy_); 258 vie_channel_.RegisterReceiveStatisticsProxy(&stats_proxy_);
258 vie_receiver_->GetReceiveStatistics()->RegisterRtpStatisticsCallback( 259 rtp_stream_receiver_.GetReceiveStatistics()->RegisterRtpStatisticsCallback(
259 &stats_proxy_); 260 &stats_proxy_);
260 vie_receiver_->GetReceiveStatistics()->RegisterRtcpStatisticsCallback( 261 rtp_stream_receiver_.GetReceiveStatistics()->RegisterRtcpStatisticsCallback(
261 &stats_proxy_); 262 &stats_proxy_);
262 // Stats callback for CNAME changes. 263 // Stats callback for CNAME changes.
263 rtp_rtcp_->RegisterRtcpStatisticsCallback(&stats_proxy_); 264 rtp_rtcp_->RegisterRtcpStatisticsCallback(&stats_proxy_);
264 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); 265 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_);
265 266
266 RTC_DCHECK(!config_.decoders.empty()); 267 RTC_DCHECK(!config_.decoders.empty());
267 std::set<int> decoder_payload_types; 268 std::set<int> decoder_payload_types;
268 for (const Decoder& decoder : config_.decoders) { 269 for (const Decoder& decoder : config_.decoders) {
269 RTC_CHECK(decoder.decoder); 270 RTC_CHECK(decoder.decoder);
270 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == 271 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) ==
271 decoder_payload_types.end()) 272 decoder_payload_types.end())
272 << "Duplicate payload type (" << decoder.payload_type 273 << "Duplicate payload type (" << decoder.payload_type
273 << ") for different decoders."; 274 << ") for different decoders.";
274 decoder_payload_types.insert(decoder.payload_type); 275 decoder_payload_types.insert(decoder.payload_type);
275 video_receiver_.RegisterExternalDecoder(decoder.decoder, 276 video_receiver_.RegisterExternalDecoder(decoder.decoder,
276 decoder.payload_type); 277 decoder.payload_type);
277 278
278 VideoCodec codec = CreateDecoderVideoCodec(decoder); 279 VideoCodec codec = CreateDecoderVideoCodec(decoder);
279 280
280 RTC_CHECK(vie_receiver_->SetReceiveCodec(codec)); 281 RTC_CHECK(rtp_stream_receiver_.SetReceiveCodec(codec));
281 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( 282 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec(
282 &codec, num_cpu_cores, false)); 283 &codec, num_cpu_cores, false));
283 } 284 }
284 285
285 video_receiver_.SetRenderDelay(config.render_delay_ms); 286 video_receiver_.SetRenderDelay(config.render_delay_ms);
286 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); 287 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms);
287 incoming_video_stream_.SetExternalCallback(this); 288 incoming_video_stream_.SetExternalCallback(this);
288 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); 289 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_);
289 vie_channel_.RegisterPreRenderCallback(this); 290 vie_channel_.RegisterPreRenderCallback(this);
290 291
292 process_thread_->RegisterModule(rtp_stream_receiver_.GetReceiveStatistics());
293 process_thread_->RegisterModule(rtp_stream_receiver_.rtp_rtcp());
291 process_thread_->RegisterModule(&video_receiver_); 294 process_thread_->RegisterModule(&video_receiver_);
292 process_thread_->RegisterModule(&vie_sync_); 295 process_thread_->RegisterModule(&vie_sync_);
293 } 296 }
294 297
295 VideoReceiveStream::~VideoReceiveStream() { 298 VideoReceiveStream::~VideoReceiveStream() {
296 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); 299 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
297 Stop(); 300 Stop();
298 301
299 process_thread_->DeRegisterModule(&vie_sync_); 302 process_thread_->DeRegisterModule(&vie_sync_);
300 process_thread_->DeRegisterModule(&video_receiver_); 303 process_thread_->DeRegisterModule(&video_receiver_);
304 process_thread_->DeRegisterModule(rtp_stream_receiver_.rtp_rtcp());
305 process_thread_->DeRegisterModule(
306 rtp_stream_receiver_.GetReceiveStatistics());
301 307
302 // Deregister external decoders so that they are no longer running during 308 // Deregister external decoders so that they are no longer running during
303 // destruction. This effectively stops the VCM since the decoder thread is 309 // destruction. This effectively stops the VCM since the decoder thread is
304 // stopped, the VCM is deregistered and no asynchronous decoder threads are 310 // stopped, the VCM is deregistered and no asynchronous decoder threads are
305 // running. 311 // running.
306 for (const Decoder& decoder : config_.decoders) 312 for (const Decoder& decoder : config_.decoders)
307 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); 313 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type);
308 314
309 vie_channel_.RegisterPreRenderCallback(nullptr); 315 vie_channel_.RegisterPreRenderCallback(nullptr);
310 316
311 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); 317 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver());
312 rtp_rtcp_->SetREMBStatus(false); 318 rtp_rtcp_->SetREMBStatus(false);
313 remb_->RemoveReceiveChannel(rtp_rtcp_); 319 remb_->RemoveReceiveChannel(rtp_rtcp_);
314 320
315 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) 321 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_))
316 ->RemoveStream(vie_receiver_->GetRemoteSsrc()); 322 ->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc());
317 } 323 }
318 324
319 void VideoReceiveStream::Start() { 325 void VideoReceiveStream::Start() {
320 if (decode_thread_.IsRunning()) 326 if (decode_thread_.IsRunning())
321 return; 327 return;
322 transport_adapter_.Enable(); 328 transport_adapter_.Enable();
323 incoming_video_stream_.Start(); 329 incoming_video_stream_.Start();
324 // Start the decode thread 330 // Start the decode thread
325 decode_thread_.Start(); 331 decode_thread_.Start();
326 decode_thread_.SetPriority(rtc::kHighestPriority); 332 decode_thread_.SetPriority(rtc::kHighestPriority);
327 vie_receiver_->StartReceive(); 333 rtp_stream_receiver_.StartReceive();
328 } 334 }
329 335
330 void VideoReceiveStream::Stop() { 336 void VideoReceiveStream::Stop() {
331 incoming_video_stream_.Stop(); 337 incoming_video_stream_.Stop();
332 vie_receiver_->StopReceive(); 338 rtp_stream_receiver_.StopReceive();
333 video_receiver_.TriggerDecoderShutdown(); 339 video_receiver_.TriggerDecoderShutdown();
334 decode_thread_.Stop(); 340 decode_thread_.Stop();
335 transport_adapter_.Disable(); 341 transport_adapter_.Disable();
336 } 342 }
337 343
338 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine, 344 void VideoReceiveStream::SetSyncChannel(VoiceEngine* voice_engine,
339 int audio_channel_id) { 345 int audio_channel_id) {
340 if (voice_engine && audio_channel_id != -1) { 346 if (voice_engine && audio_channel_id != -1) {
341 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine); 347 VoEVideoSync* voe_sync_interface = VoEVideoSync::GetInterface(voice_engine);
342 vie_sync_.ConfigureSync(audio_channel_id, voe_sync_interface, rtp_rtcp_, 348 vie_sync_.ConfigureSync(audio_channel_id, voe_sync_interface, rtp_rtcp_,
343 vie_receiver_->GetRtpReceiver()); 349 rtp_stream_receiver_.GetRtpReceiver());
344 voe_sync_interface->Release(); 350 voe_sync_interface->Release();
345 return; 351 return;
346 } 352 }
347 vie_sync_.ConfigureSync(-1, nullptr, rtp_rtcp_, 353 vie_sync_.ConfigureSync(-1, nullptr, rtp_rtcp_,
348 vie_receiver_->GetRtpReceiver()); 354 rtp_stream_receiver_.GetRtpReceiver());
349 } 355 }
350 356
351 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { 357 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const {
352 return stats_proxy_.GetStats(); 358 return stats_proxy_.GetStats();
353 } 359 }
354 360
355 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { 361 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
356 return vie_receiver_->DeliverRtcp(packet, length); 362 return rtp_stream_receiver_.DeliverRtcp(packet, length);
357 } 363 }
358 364
359 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, 365 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet,
360 size_t length, 366 size_t length,
361 const PacketTime& packet_time) { 367 const PacketTime& packet_time) {
362 return vie_receiver_->DeliverRtp(packet, length, packet_time); 368 return rtp_stream_receiver_.DeliverRtp(packet, length, packet_time);
363 } 369 }
364 370
365 void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) { 371 void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) {
366 stats_proxy_.OnDecodedFrame(); 372 stats_proxy_.OnDecodedFrame();
367 373
368 // Post processing is not supported if the frame is backed by a texture. 374 // Post processing is not supported if the frame is backed by a texture.
369 if (!video_frame->video_frame_buffer()->native_handle()) { 375 if (!video_frame->video_frame_buffer()->native_handle()) {
370 if (config_.pre_render_callback) 376 if (config_.pre_render_callback)
371 config_.pre_render_callback->FrameCallback(video_frame); 377 config_.pre_render_callback->FrameCallback(video_frame);
372 } 378 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 const std::vector<uint16_t>& sequence_numbers) { 440 const std::vector<uint16_t>& sequence_numbers) {
435 rtp_rtcp_->SendNack(sequence_numbers); 441 rtp_rtcp_->SendNack(sequence_numbers);
436 } 442 }
437 443
438 void VideoReceiveStream::RequestKeyFrame() { 444 void VideoReceiveStream::RequestKeyFrame() {
439 rtp_rtcp_->RequestKeyFrame(); 445 rtp_rtcp_->RequestKeyFrame();
440 } 446 }
441 447
442 } // namespace internal 448 } // namespace internal
443 } // namespace webrtc 449 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | webrtc/video/vie_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698