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

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

Issue 2638423003: Revert of Make the new jitter buffer the default jitter buffer. (Closed)
Patch Set: Created 3 years, 11 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/video_stream_decoder.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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 packet_router, 216 packet_router,
217 remb, 217 remb,
218 &config_, 218 &config_,
219 &stats_proxy_, 219 &stats_proxy_,
220 process_thread_, 220 process_thread_,
221 congestion_controller_->GetRetransmissionRateLimiter(), 221 congestion_controller_->GetRetransmissionRateLimiter(),
222 this, // NackSender 222 this, // NackSender
223 this, // KeyFrameRequestSender 223 this, // KeyFrameRequestSender
224 this, // OnCompleteFrameCallback 224 this, // OnCompleteFrameCallback
225 timing_.get()), 225 timing_.get()),
226 rtp_stream_sync_(&video_receiver_, &rtp_stream_receiver_) { 226 rtp_stream_sync_(&video_receiver_, &rtp_stream_receiver_),
227 jitter_buffer_experiment_(
228 field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") ==
229 "Enabled") {
227 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); 230 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
228 231
229 RTC_DCHECK(process_thread_); 232 RTC_DCHECK(process_thread_);
230 RTC_DCHECK(congestion_controller_); 233 RTC_DCHECK(congestion_controller_);
231 RTC_DCHECK(call_stats_); 234 RTC_DCHECK(call_stats_);
232 235
233 RTC_DCHECK(!config_.decoders.empty()); 236 RTC_DCHECK(!config_.decoders.empty());
234 std::set<int> decoder_payload_types; 237 std::set<int> decoder_payload_types;
235 for (const Decoder& decoder : config_.decoders) { 238 for (const Decoder& decoder : config_.decoders) {
236 RTC_CHECK(decoder.decoder); 239 RTC_CHECK(decoder.decoder);
237 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == 240 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) ==
238 decoder_payload_types.end()) 241 decoder_payload_types.end())
239 << "Duplicate payload type (" << decoder.payload_type 242 << "Duplicate payload type (" << decoder.payload_type
240 << ") for different decoders."; 243 << ") for different decoders.";
241 decoder_payload_types.insert(decoder.payload_type); 244 decoder_payload_types.insert(decoder.payload_type);
242 } 245 }
243 246
244 video_receiver_.SetRenderDelay(config.render_delay_ms); 247 video_receiver_.SetRenderDelay(config.render_delay_ms);
245 248
246 jitter_estimator_.reset(new VCMJitterEstimator(clock_)); 249 if (jitter_buffer_experiment_) {
247 frame_buffer_.reset(new video_coding::FrameBuffer( 250 jitter_estimator_.reset(new VCMJitterEstimator(clock_));
248 clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); 251 frame_buffer_.reset(new video_coding::FrameBuffer(
252 clock_, jitter_estimator_.get(), timing_.get()));
253 }
249 254
250 process_thread_->RegisterModule(&video_receiver_); 255 process_thread_->RegisterModule(&video_receiver_);
251 process_thread_->RegisterModule(&rtp_stream_sync_); 256 process_thread_->RegisterModule(&rtp_stream_sync_);
252 } 257 }
253 258
254 VideoReceiveStream::~VideoReceiveStream() { 259 VideoReceiveStream::~VideoReceiveStream() {
255 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); 260 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
256 Stop(); 261 Stop();
257 262
258 process_thread_->DeRegisterModule(&rtp_stream_sync_); 263 process_thread_->DeRegisterModule(&rtp_stream_sync_);
(...skipping 19 matching lines...) Expand all
278 } 283 }
279 284
280 bool VideoReceiveStream::OnRecoveredPacket(const uint8_t* packet, 285 bool VideoReceiveStream::OnRecoveredPacket(const uint8_t* packet,
281 size_t length) { 286 size_t length) {
282 return rtp_stream_receiver_.OnRecoveredPacket(packet, length); 287 return rtp_stream_receiver_.OnRecoveredPacket(packet, length);
283 } 288 }
284 289
285 void VideoReceiveStream::Start() { 290 void VideoReceiveStream::Start() {
286 if (decode_thread_.IsRunning()) 291 if (decode_thread_.IsRunning())
287 return; 292 return;
293 if (jitter_buffer_experiment_) {
294 frame_buffer_->Start();
295 call_stats_->RegisterStatsObserver(&rtp_stream_receiver_);
288 296
289 frame_buffer_->Start(); 297 if (rtp_stream_receiver_.IsRetransmissionsEnabled() &&
290 call_stats_->RegisterStatsObserver(&rtp_stream_receiver_); 298 rtp_stream_receiver_.IsUlpfecEnabled()) {
291 299 frame_buffer_->SetProtectionMode(kProtectionNackFEC);
292 if (rtp_stream_receiver_.IsRetransmissionsEnabled() && 300 }
293 rtp_stream_receiver_.IsUlpfecEnabled()) {
294 frame_buffer_->SetProtectionMode(kProtectionNackFEC);
295 } 301 }
296
297 transport_adapter_.Enable(); 302 transport_adapter_.Enable();
298 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr; 303 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;
299 if (config_.renderer) { 304 if (config_.renderer) {
300 if (config_.disable_prerenderer_smoothing) { 305 if (config_.disable_prerenderer_smoothing) {
301 renderer = this; 306 renderer = this;
302 } else { 307 } else {
303 incoming_video_stream_.reset( 308 incoming_video_stream_.reset(
304 new IncomingVideoStream(config_.render_delay_ms, this)); 309 new IncomingVideoStream(config_.render_delay_ms, this));
305 renderer = incoming_video_stream_.get(); 310 renderer = incoming_video_stream_.get();
306 } 311 }
(...skipping 24 matching lines...) Expand all
331 rtp_stream_receiver_.StartReceive(); 336 rtp_stream_receiver_.StartReceive();
332 } 337 }
333 338
334 void VideoReceiveStream::Stop() { 339 void VideoReceiveStream::Stop() {
335 rtp_stream_receiver_.StopReceive(); 340 rtp_stream_receiver_.StopReceive();
336 // TriggerDecoderShutdown will release any waiting decoder thread and make it 341 // TriggerDecoderShutdown will release any waiting decoder thread and make it
337 // stop immediately, instead of waiting for a timeout. Needs to be called 342 // stop immediately, instead of waiting for a timeout. Needs to be called
338 // before joining the decoder thread thread. 343 // before joining the decoder thread thread.
339 video_receiver_.TriggerDecoderShutdown(); 344 video_receiver_.TriggerDecoderShutdown();
340 345
341 frame_buffer_->Stop(); 346 if (jitter_buffer_experiment_) {
342 call_stats_->DeregisterStatsObserver(&rtp_stream_receiver_); 347 frame_buffer_->Stop();
348 call_stats_->DeregisterStatsObserver(&rtp_stream_receiver_);
349 }
343 350
344 if (decode_thread_.IsRunning()) { 351 if (decode_thread_.IsRunning()) {
345 decode_thread_.Stop(); 352 decode_thread_.Stop();
346 // Deregister external decoders so they are no longer running during 353 // Deregister external decoders so they are no longer running during
347 // destruction. This effectively stops the VCM since the decoder thread is 354 // destruction. This effectively stops the VCM since the decoder thread is
348 // stopped, the VCM is deregistered and no asynchronous decoder threads are 355 // stopped, the VCM is deregistered and no asynchronous decoder threads are
349 // running. 356 // running.
350 for (const Decoder& decoder : config_.decoders) 357 for (const Decoder& decoder : config_.decoders)
351 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); 358 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type);
352 } 359 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 435
429 return Result(Result::OK, encoded_image._timeStamp); 436 return Result(Result::OK, encoded_image._timeStamp);
430 } 437 }
431 438
432 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) { 439 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) {
433 static_cast<VideoReceiveStream*>(ptr)->Decode(); 440 static_cast<VideoReceiveStream*>(ptr)->Decode();
434 return true; 441 return true;
435 } 442 }
436 443
437 void VideoReceiveStream::Decode() { 444 void VideoReceiveStream::Decode() {
438 static const int kMaxWaitForFrameMs = 3000; 445 static const int kMaxDecodeWaitTimeMs = 50;
439 std::unique_ptr<video_coding::FrameObject> frame; 446 if (jitter_buffer_experiment_) {
440 video_coding::FrameBuffer::ReturnReason res = 447 static const int kMaxWaitForFrameMs = 3000;
441 frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame); 448 std::unique_ptr<video_coding::FrameObject> frame;
449 video_coding::FrameBuffer::ReturnReason res =
450 frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame);
442 451
443 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) 452 if (res == video_coding::FrameBuffer::ReturnReason::kStopped)
444 return; 453 return;
445 454
446 if (frame) { 455 if (frame) {
447 if (video_receiver_.Decode(frame.get()) == VCM_OK) 456 if (video_receiver_.Decode(frame.get()) == VCM_OK)
448 rtp_stream_receiver_.FrameDecoded(frame->picture_id); 457 rtp_stream_receiver_.FrameDecoded(frame->picture_id);
458 } else {
459 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
460 << " ms, requesting keyframe.";
461 RequestKeyFrame();
462 }
449 } else { 463 } else {
450 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs 464 video_receiver_.Decode(kMaxDecodeWaitTimeMs);
451 << " ms, requesting keyframe.";
452 RequestKeyFrame();
453 } 465 }
454 } 466 }
455 467
456 void VideoReceiveStream::SendNack( 468 void VideoReceiveStream::SendNack(
457 const std::vector<uint16_t>& sequence_numbers) { 469 const std::vector<uint16_t>& sequence_numbers) {
458 rtp_stream_receiver_.RequestPacketRetransmit(sequence_numbers); 470 rtp_stream_receiver_.RequestPacketRetransmit(sequence_numbers);
459 } 471 }
460 472
461 void VideoReceiveStream::EnableEncodedFrameRecording(rtc::PlatformFile file, 473 void VideoReceiveStream::EnableEncodedFrameRecording(rtc::PlatformFile file,
462 size_t byte_limit) { 474 size_t byte_limit) {
(...skipping 12 matching lines...) Expand all
475 RequestKeyFrame(); 487 RequestKeyFrame();
476 } 488 }
477 } 489 }
478 490
479 void VideoReceiveStream::RequestKeyFrame() { 491 void VideoReceiveStream::RequestKeyFrame() {
480 rtp_stream_receiver_.RequestKeyFrame(); 492 rtp_stream_receiver_.RequestKeyFrame();
481 } 493 }
482 494
483 } // namespace internal 495 } // namespace internal
484 } // namespace webrtc 496 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | webrtc/video/video_stream_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698