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

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

Issue 2649973005: Inform jitter buffer about FlexFEC protection. (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
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
11 #include "webrtc/video/video_receive_stream.h" 11 #include "webrtc/video/video_receive_stream.h"
12 12
13 #include <stdlib.h> 13 #include <stdlib.h>
14 14
15 #include <set> 15 #include <set>
16 #include <string> 16 #include <string>
17 #include <utility> 17 #include <utility>
18 18
19 #include "webrtc/base/checks.h" 19 #include "webrtc/base/checks.h"
20 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
21 #include "webrtc/base/optional.h" 21 #include "webrtc/base/optional.h"
22 #include "webrtc/call/flexfec_receive_stream.h"
22 #include "webrtc/common_video/h264/profile_level_id.h" 23 #include "webrtc/common_video/h264/profile_level_id.h"
23 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 24 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
24 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 25 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
25 #include "webrtc/modules/utility/include/process_thread.h" 26 #include "webrtc/modules/utility/include/process_thread.h"
26 #include "webrtc/modules/video_coding/frame_object.h" 27 #include "webrtc/modules/video_coding/frame_object.h"
27 #include "webrtc/modules/video_coding/include/video_coding.h" 28 #include "webrtc/modules/video_coding/include/video_coding.h"
28 #include "webrtc/modules/video_coding/jitter_estimator.h" 29 #include "webrtc/modules/video_coding/jitter_estimator.h"
29 #include "webrtc/modules/video_coding/timing.h" 30 #include "webrtc/modules/video_coding/timing.h"
30 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h" 31 #include "webrtc/modules/video_coding/utility/ivf_file_writer.h"
31 #include "webrtc/system_wrappers/include/clock.h" 32 #include "webrtc/system_wrappers/include/clock.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 namespace internal { 188 namespace internal {
188 189
189 VideoReceiveStream::VideoReceiveStream( 190 VideoReceiveStream::VideoReceiveStream(
190 int num_cpu_cores, 191 int num_cpu_cores,
191 CongestionController* congestion_controller, 192 CongestionController* congestion_controller,
192 PacketRouter* packet_router, 193 PacketRouter* packet_router,
193 VideoReceiveStream::Config config, 194 VideoReceiveStream::Config config,
194 webrtc::VoiceEngine* voice_engine, 195 webrtc::VoiceEngine* voice_engine,
195 ProcessThread* process_thread, 196 ProcessThread* process_thread,
196 CallStats* call_stats, 197 CallStats* call_stats,
197 VieRemb* remb) 198 VieRemb* remb,
199 FlexfecProtectionMediator* flexfec_protection_mediator)
198 : transport_adapter_(config.rtcp_send_transport), 200 : transport_adapter_(config.rtcp_send_transport),
199 config_(std::move(config)), 201 config_(std::move(config)),
200 num_cpu_cores_(num_cpu_cores), 202 num_cpu_cores_(num_cpu_cores),
201 process_thread_(process_thread), 203 process_thread_(process_thread),
202 clock_(Clock::GetRealTimeClock()), 204 clock_(Clock::GetRealTimeClock()),
203 decode_thread_(DecodeThreadFunction, this, "DecodingThread"), 205 decode_thread_(DecodeThreadFunction, this, "DecodingThread"),
204 congestion_controller_(congestion_controller), 206 congestion_controller_(congestion_controller),
205 call_stats_(call_stats), 207 call_stats_(call_stats),
208 flexfec_protection_mediator_(flexfec_protection_mediator),
206 timing_(new VCMTiming(clock_)), 209 timing_(new VCMTiming(clock_)),
207 video_receiver_(clock_, nullptr, this, timing_.get(), this, this), 210 video_receiver_(clock_, nullptr, this, timing_.get(), this, this),
208 stats_proxy_(&config_, clock_), 211 stats_proxy_(&config_, clock_),
209 rtp_stream_receiver_( 212 rtp_stream_receiver_(
210 &video_receiver_, 213 &video_receiver_,
211 congestion_controller_->GetRemoteBitrateEstimator( 214 congestion_controller_->GetRemoteBitrateEstimator(
212 UseSendSideBwe(config_)), 215 UseSendSideBwe(config_)),
213 &transport_adapter_, 216 &transport_adapter_,
214 call_stats_->rtcp_rtt_stats(), 217 call_stats_->rtcp_rtt_stats(),
215 packet_router, 218 packet_router,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 284 }
282 285
283 bool VideoReceiveStream::OnRecoveredPacket(const uint8_t* packet, 286 bool VideoReceiveStream::OnRecoveredPacket(const uint8_t* packet,
284 size_t length) { 287 size_t length) {
285 return rtp_stream_receiver_.OnRecoveredPacket(packet, length); 288 return rtp_stream_receiver_.OnRecoveredPacket(packet, length);
286 } 289 }
287 290
288 void VideoReceiveStream::Start() { 291 void VideoReceiveStream::Start() {
289 if (decode_thread_.IsRunning()) 292 if (decode_thread_.IsRunning())
290 return; 293 return;
294
295 bool fec_enabled = IsFlexfecEnabled() || IsUlpfecEnabled();
296
291 if (jitter_buffer_experiment_) { 297 if (jitter_buffer_experiment_) {
292 frame_buffer_->Start(); 298 frame_buffer_->Start();
293 call_stats_->RegisterStatsObserver(&rtp_stream_receiver_); 299 call_stats_->RegisterStatsObserver(&rtp_stream_receiver_);
294 300
295 if (rtp_stream_receiver_.IsRetransmissionsEnabled() && 301 if (rtp_stream_receiver_.IsRetransmissionsEnabled() && fec_enabled) {
296 rtp_stream_receiver_.IsUlpfecEnabled()) {
297 frame_buffer_->SetProtectionMode(kProtectionNackFEC); 302 frame_buffer_->SetProtectionMode(kProtectionNackFEC);
298 } 303 }
299 } 304 }
300 transport_adapter_.Enable(); 305 transport_adapter_.Enable();
301 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr; 306 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;
302 if (config_.renderer) { 307 if (config_.renderer) {
303 if (config_.disable_prerenderer_smoothing) { 308 if (config_.disable_prerenderer_smoothing) {
304 renderer = this; 309 renderer = this;
305 } else { 310 } else {
306 incoming_video_stream_.reset( 311 incoming_video_stream_.reset(
307 new IncomingVideoStream(config_.render_delay_ms, this)); 312 new IncomingVideoStream(config_.render_delay_ms, this));
308 renderer = incoming_video_stream_.get(); 313 renderer = incoming_video_stream_.get();
309 } 314 }
310 } 315 }
311 RTC_DCHECK(renderer != nullptr); 316 RTC_DCHECK(renderer != nullptr);
312 317
313 for (const Decoder& decoder : config_.decoders) { 318 for (const Decoder& decoder : config_.decoders) {
314 video_receiver_.RegisterExternalDecoder(decoder.decoder, 319 video_receiver_.RegisterExternalDecoder(decoder.decoder,
315 decoder.payload_type); 320 decoder.payload_type);
316 // TODO(johan): make Decoder.codec_params accessible for RtpStreamReceiver 321 // TODO(johan): make Decoder.codec_params accessible for RtpStreamReceiver
317 // which holds H264SpsPpsTracker 322 // which holds H264SpsPpsTracker
318 VideoCodec codec = CreateDecoderVideoCodec(decoder); 323 VideoCodec codec = CreateDecoderVideoCodec(decoder);
319 RTC_CHECK(rtp_stream_receiver_.AddReceiveCodec(codec)); 324 RTC_CHECK(rtp_stream_receiver_.AddReceiveCodec(codec));
320 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec( 325 RTC_CHECK_EQ(VCM_OK, video_receiver_.RegisterReceiveCodec(
321 &codec, num_cpu_cores_, false)); 326 &codec, num_cpu_cores_, false));
322 } 327 }
323 328
324 video_stream_decoder_.reset(new VideoStreamDecoder( 329 video_stream_decoder_.reset(new VideoStreamDecoder(
325 &video_receiver_, &rtp_stream_receiver_, &rtp_stream_receiver_, 330 &video_receiver_, &rtp_stream_receiver_, &rtp_stream_receiver_,
326 rtp_stream_receiver_.IsRetransmissionsEnabled(), 331 rtp_stream_receiver_.IsRetransmissionsEnabled(), fec_enabled,
327 rtp_stream_receiver_.IsUlpfecEnabled(), &stats_proxy_, renderer, 332 &stats_proxy_, renderer, config_.pre_render_callback));
328 config_.pre_render_callback));
329 // Register the channel to receive stats updates. 333 // Register the channel to receive stats updates.
330 call_stats_->RegisterStatsObserver(video_stream_decoder_.get()); 334 call_stats_->RegisterStatsObserver(video_stream_decoder_.get());
331 // Start the decode thread 335 // Start the decode thread
332 decode_thread_.Start(); 336 decode_thread_.Start();
333 decode_thread_.SetPriority(rtc::kHighestPriority); 337 decode_thread_.SetPriority(rtc::kHighestPriority);
334 rtp_stream_receiver_.StartReceive(); 338 rtp_stream_receiver_.StartReceive();
335 } 339 }
336 340
337 void VideoReceiveStream::Stop() { 341 void VideoReceiveStream::Stop() {
338 rtp_stream_receiver_.StopReceive(); 342 rtp_stream_receiver_.StopReceive();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // Make a keyframe appear as early as possible in the logs, to give actually 487 // Make a keyframe appear as early as possible in the logs, to give actually
484 // decodable output. 488 // decodable output.
485 RequestKeyFrame(); 489 RequestKeyFrame();
486 } 490 }
487 } 491 }
488 492
489 void VideoReceiveStream::RequestKeyFrame() { 493 void VideoReceiveStream::RequestKeyFrame() {
490 rtp_stream_receiver_.RequestKeyFrame(); 494 rtp_stream_receiver_.RequestKeyFrame();
491 } 495 }
492 496
497 bool VideoReceiveStream::IsFlexfecEnabled() const {
498 return flexfec_protection_mediator_->IsProtectedByFlexfec(
499 config_.rtp.remote_ssrc);
500 }
501
502 bool VideoReceiveStream::IsUlpfecEnabled() const {
503 return rtp_stream_receiver_.IsUlpfecEnabled();
504 }
505
493 } // namespace internal 506 } // namespace internal
494 } // namespace webrtc 507 } // namespace webrtc
OLDNEW
« webrtc/video/video_receive_stream.h ('K') | « webrtc/video/video_receive_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698