blob: 9f62ce6cba6c1582c7304ff1a1781335ae3b8415 [file] [log] [blame]
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Yves Gerey3e707812018-11-28 16:47:49 +010011#include <stddef.h>
12#include <cstdint>
13#include <vector>
14
15#include "api/rtp_headers.h"
16#include "api/video_codecs/video_codec.h"
17#include "api/video_codecs/video_decoder.h"
Yves Gerey3e707812018-11-28 16:47:49 +010018#include "modules/include/module_common_types.h"
Tommifbf3bce2018-02-21 15:56:05 +010019#include "modules/utility/include/process_thread.h"
Yves Gerey3e707812018-11-28 16:47:49 +010020#include "modules/video_coding/decoder_database.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "modules/video_coding/encoded_frame.h"
Yves Gerey3e707812018-11-28 16:47:49 +010022#include "modules/video_coding/generic_decoder.h"
23#include "modules/video_coding/include/video_coding.h"
24#include "modules/video_coding/include/video_coding_defines.h"
25#include "modules/video_coding/internal_defines.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "modules/video_coding/jitter_buffer.h"
Yves Gerey3e707812018-11-28 16:47:49 +010027#include "modules/video_coding/media_opt_util.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "modules/video_coding/packet.h"
Yves Gerey3e707812018-11-28 16:47:49 +010029#include "modules/video_coding/receiver.h"
30#include "modules/video_coding/timing.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020031#include "modules/video_coding/video_coding_impl.h"
32#include "rtc_base/checks.h"
Steve Anton10542f22019-01-11 09:11:00 -080033#include "rtc_base/critical_section.h"
Tommifbf3bce2018-02-21 15:56:05 +010034#include "rtc_base/location.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020035#include "rtc_base/logging.h"
Steve Anton10542f22019-01-11 09:11:00 -080036#include "rtc_base/one_time_event.h"
Yves Gerey3e707812018-11-28 16:47:49 +010037#include "rtc_base/thread_checker.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020038#include "rtc_base/trace_event.h"
39#include "system_wrappers/include/clock.h"
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000040
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000041namespace webrtc {
42namespace vcm {
43
Niels Möllerdb64d992019-03-29 14:30:53 +010044VideoReceiver::VideoReceiver(Clock* clock, VCMTiming* timing)
stefan@webrtc.org34c5da62014-04-11 14:08:35 +000045 : clock_(clock),
philipel721d4022016-12-15 07:10:57 -080046 _timing(timing),
Niels Möllerdb64d992019-03-29 14:30:53 +010047 _receiver(_timing, clock_),
philipel721d4022016-12-15 07:10:57 -080048 _decodedFrameCallback(_timing, clock_),
sprang3911c262016-04-15 01:24:14 -070049 _frameTypeCallback(nullptr),
sprang3911c262016-04-15 01:24:14 -070050 _packetRequestCallback(nullptr),
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000051 _scheduleKeyRequest(false),
Peter Boströmed3277b2016-02-02 15:40:04 +010052 drop_frames_until_keyframe_(false),
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000053 max_nack_list_size_(0),
Niels Möllerf9063782018-02-20 16:09:48 +010054 _codecDataBase(),
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000055 _receiveStatsTimer(1000, clock_),
56 _retransmissionTimer(10, clock_),
Tommifbf3bce2018-02-21 15:56:05 +010057 _keyRequestTimer(500, clock_) {
Sebastian Janssonc01367d2019-04-08 15:20:44 +020058 decoder_thread_checker_.Detach();
59 module_thread_checker_.Detach();
Tommifbf3bce2018-02-21 15:56:05 +010060}
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000061
Tommifbf3bce2018-02-21 15:56:05 +010062VideoReceiver::~VideoReceiver() {
63 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
64}
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000065
pbosa26ac922016-02-25 04:50:01 -080066void VideoReceiver::Process() {
Tommifbf3bce2018-02-21 15:56:05 +010067 RTC_DCHECK_RUN_ON(&module_thread_checker_);
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000068 // Receive-side statistics
philipela45102f2017-02-22 05:30:39 -080069
70 // TODO(philipel): Remove this if block when we know what to do with
71 // ReceiveStatisticsProxy::QualitySample.
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000072 if (_receiveStatsTimer.TimeUntilProcess() == 0) {
73 _receiveStatsTimer.Processed();
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000074 }
75
76 // Key frame requests
77 if (_keyRequestTimer.TimeUntilProcess() == 0) {
78 _keyRequestTimer.Processed();
Tommifbf3bce2018-02-21 15:56:05 +010079 bool request_key_frame = _frameTypeCallback != nullptr;
80 if (request_key_frame) {
sprang3911c262016-04-15 01:24:14 -070081 rtc::CritScope cs(&process_crit_);
Tommifbf3bce2018-02-21 15:56:05 +010082 request_key_frame = _scheduleKeyRequest;
stefan@webrtc.orgf7c6e742014-01-29 10:27:51 +000083 }
pbosa26ac922016-02-25 04:50:01 -080084 if (request_key_frame)
85 RequestKeyFrame();
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +000086 }
87
88 // Packet retransmission requests
89 // TODO(holmer): Add API for changing Process interval and make sure it's
90 // disabled when NACK is off.
91 if (_retransmissionTimer.TimeUntilProcess() == 0) {
92 _retransmissionTimer.Processed();
Tommifbf3bce2018-02-21 15:56:05 +010093 bool callback_registered = _packetRequestCallback != nullptr;
94 uint16_t length = max_nack_list_size_;
stefan@webrtc.orgf7c6e742014-01-29 10:27:51 +000095 if (callback_registered && length > 0) {
Wan-Teh Changb1825a42015-06-03 15:03:35 -070096 // Collect sequence numbers from the default receiver.
97 bool request_key_frame = false;
98 std::vector<uint16_t> nackList = _receiver.NackList(&request_key_frame);
99 int32_t ret = VCM_OK;
100 if (request_key_frame) {
101 ret = RequestKeyFrame();
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000102 }
Wan-Teh Changb1825a42015-06-03 15:03:35 -0700103 if (ret == VCM_OK && !nackList.empty()) {
guidouc3372582017-04-04 07:16:21 -0700104 rtc::CritScope cs(&process_crit_);
sprang3911c262016-04-15 01:24:14 -0700105 if (_packetRequestCallback != nullptr) {
Wan-Teh Changb1825a42015-06-03 15:03:35 -0700106 _packetRequestCallback->ResendPackets(&nackList[0], nackList.size());
stefan@webrtc.orgf7c6e742014-01-29 10:27:51 +0000107 }
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000108 }
109 }
110 }
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000111}
112
Tommifbf3bce2018-02-21 15:56:05 +0100113void VideoReceiver::ProcessThreadAttached(ProcessThread* process_thread) {
114 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
115 if (process_thread) {
116 is_attached_to_process_thread_ = true;
117 RTC_DCHECK(!process_thread_ || process_thread_ == process_thread);
118 process_thread_ = process_thread;
119 } else {
120 is_attached_to_process_thread_ = false;
121 }
122}
123
pkasting@chromium.org0b1534c2014-12-15 22:09:40 +0000124int64_t VideoReceiver::TimeUntilNextProcess() {
Tommifbf3bce2018-02-21 15:56:05 +0100125 RTC_DCHECK_RUN_ON(&module_thread_checker_);
pkasting@chromium.org0b1534c2014-12-15 22:09:40 +0000126 int64_t timeUntilNextProcess = _receiveStatsTimer.TimeUntilProcess();
Niels Möller691f62c2019-04-11 15:27:17 +0200127 // We need a Process call more often if we are relying on
128 // retransmissions
129 timeUntilNextProcess =
130 VCM_MIN(timeUntilNextProcess, _retransmissionTimer.TimeUntilProcess());
131
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000132 timeUntilNextProcess =
133 VCM_MIN(timeUntilNextProcess, _keyRequestTimer.TimeUntilProcess());
134
135 return timeUntilNextProcess;
136}
137
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000138// Register a receive callback. Will be called whenever there is a new frame
139// ready for rendering.
140int32_t VideoReceiver::RegisterReceiveCallback(
141 VCMReceiveCallback* receiveCallback) {
Tommifbf3bce2018-02-21 15:56:05 +0100142 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
143 RTC_DCHECK(!IsDecoderThreadRunning());
144 // This value is set before the decoder thread starts and unset after
145 // the decoder thread has been stopped.
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000146 _decodedFrameCallback.SetUserReceiveCallback(receiveCallback);
147 return VCM_OK;
148}
149
perkj796cfaf2015-12-10 09:27:38 -0800150// Register an externally defined decoder object.
Peter Boström795dbe42015-11-27 14:09:07 +0100151void VideoReceiver::RegisterExternalDecoder(VideoDecoder* externalDecoder,
perkj796cfaf2015-12-10 09:27:38 -0800152 uint8_t payloadType) {
Tommifbf3bce2018-02-21 15:56:05 +0100153 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
154 RTC_DCHECK(!IsDecoderThreadRunning());
sprang3911c262016-04-15 01:24:14 -0700155 if (externalDecoder == nullptr) {
Peter Boström795dbe42015-11-27 14:09:07 +0100156 RTC_CHECK(_codecDataBase.DeregisterExternalDecoder(payloadType));
Peter Boström395c7c62015-11-27 15:23:12 +0100157 return;
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000158 }
perkj796cfaf2015-12-10 09:27:38 -0800159 _codecDataBase.RegisterExternalDecoder(externalDecoder, payloadType);
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000160}
161
162// Register a frame type request callback.
163int32_t VideoReceiver::RegisterFrameTypeCallback(
164 VCMFrameTypeCallback* frameTypeCallback) {
Tommifbf3bce2018-02-21 15:56:05 +0100165 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
166 RTC_DCHECK(!IsDecoderThreadRunning() && !is_attached_to_process_thread_);
167 // This callback is used on the module thread, but since we don't get
168 // callbacks on the module thread while the decoder thread isn't running
169 // (and this function must not be called when the decoder is running),
170 // we don't need a lock here.
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000171 _frameTypeCallback = frameTypeCallback;
172 return VCM_OK;
173}
174
175int32_t VideoReceiver::RegisterPacketRequestCallback(
176 VCMPacketRequestCallback* callback) {
Tommifbf3bce2018-02-21 15:56:05 +0100177 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
178 RTC_DCHECK(!IsDecoderThreadRunning() && !is_attached_to_process_thread_);
179 // This callback is used on the module thread, but since we don't get
180 // callbacks on the module thread while the decoder thread isn't running
181 // (and this function must not be called when the decoder is running),
182 // we don't need a lock here.
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000183 _packetRequestCallback = callback;
184 return VCM_OK;
185}
186
pbos@webrtc.org4dd40d62015-02-17 13:22:43 +0000187void VideoReceiver::TriggerDecoderShutdown() {
Tommifbf3bce2018-02-21 15:56:05 +0100188 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
189 RTC_DCHECK(IsDecoderThreadRunning());
pbos@webrtc.org4dd40d62015-02-17 13:22:43 +0000190 _receiver.TriggerDecoderShutdown();
191}
192
Tommifbf3bce2018-02-21 15:56:05 +0100193void VideoReceiver::DecoderThreadStarting() {
194 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
195 RTC_DCHECK(!IsDecoderThreadRunning());
196 if (process_thread_ && !is_attached_to_process_thread_) {
197 process_thread_->RegisterModule(this, RTC_FROM_HERE);
198 }
199#if RTC_DCHECK_IS_ON
200 decoder_thread_is_running_ = true;
201#endif
202}
203
204void VideoReceiver::DecoderThreadStopped() {
205 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
206 RTC_DCHECK(IsDecoderThreadRunning());
207 if (process_thread_ && is_attached_to_process_thread_) {
208 process_thread_->DeRegisterModule(this);
209 }
210#if RTC_DCHECK_IS_ON
211 decoder_thread_is_running_ = false;
Sebastian Janssonc01367d2019-04-08 15:20:44 +0200212 decoder_thread_checker_.Detach();
Tommifbf3bce2018-02-21 15:56:05 +0100213#endif
214}
215
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000216// Decode next frame, blocking.
217// Should be called as often as possible to get the most out of the decoder.
218int32_t VideoReceiver::Decode(uint16_t maxWaitTimeMs) {
Tommifbf3bce2018-02-21 15:56:05 +0100219 RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
220 VCMEncodedFrame* frame = _receiver.FrameForDecoding(
221 maxWaitTimeMs, _codecDataBase.PrefersLateDecoding());
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000222
Peter Boströmb7d9a972015-12-18 16:01:11 +0100223 if (!frame)
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000224 return VCM_FRAME_NOT_READY;
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000225
Tommifbf3bce2018-02-21 15:56:05 +0100226 bool drop_frame = false;
Peter Boströmed3277b2016-02-02 15:40:04 +0100227 {
sprang3911c262016-04-15 01:24:14 -0700228 rtc::CritScope cs(&process_crit_);
Peter Boströmed3277b2016-02-02 15:40:04 +0100229 if (drop_frames_until_keyframe_) {
230 // Still getting delta frames, schedule another keyframe request as if
231 // decode failed.
Niels Möller8f7ce222019-03-21 15:43:58 +0100232 if (frame->FrameType() != VideoFrameType::kVideoFrameKey) {
Tommifbf3bce2018-02-21 15:56:05 +0100233 drop_frame = true;
Peter Boströmed3277b2016-02-02 15:40:04 +0100234 _scheduleKeyRequest = true;
Tommifbf3bce2018-02-21 15:56:05 +0100235 // TODO(tommi): Consider if we could instead post a task to the module
236 // thread and call RequestKeyFrame directly. Here we call WakeUp so that
237 // TimeUntilNextProcess() gets called straight away.
238 process_thread_->WakeUp(this);
239 } else {
240 drop_frames_until_keyframe_ = false;
Peter Boströmed3277b2016-02-02 15:40:04 +0100241 }
Peter Boströmed3277b2016-02-02 15:40:04 +0100242 }
243 }
Peter Boströmb7d9a972015-12-18 16:01:11 +0100244
Tommifbf3bce2018-02-21 15:56:05 +0100245 if (drop_frame) {
246 _receiver.ReleaseFrame(frame);
247 return VCM_FRAME_NOT_READY;
248 }
249
sprang3911c262016-04-15 01:24:14 -0700250 // If this frame was too late, we should adjust the delay accordingly
philipel721d4022016-12-15 07:10:57 -0800251 _timing->UpdateCurrentDelay(frame->RenderTimeMs(),
252 clock_->TimeInMilliseconds());
skvlad98bb6642016-04-07 15:36:45 -0700253
254 if (first_frame_received_()) {
Mirko Bonadei675513b2017-11-09 11:09:25 +0100255 RTC_LOG(LS_INFO) << "Received first "
256 << (frame->Complete() ? "complete" : "incomplete")
257 << " decodable video frame";
skvlad98bb6642016-04-07 15:36:45 -0700258 }
259
Peter Boströmb7d9a972015-12-18 16:01:11 +0100260 const int32_t ret = Decode(*frame);
261 _receiver.ReleaseFrame(frame);
262 return ret;
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000263}
264
philipela45102f2017-02-22 05:30:39 -0800265// Used for the new jitter buffer.
philipelfd5a20f2016-11-15 00:57:57 -0800266// TODO(philipel): Clean up among the Decode functions as we replace
267// VCMEncodedFrame with FrameObject.
268int32_t VideoReceiver::Decode(const webrtc::VCMEncodedFrame* frame) {
Tommifbf3bce2018-02-21 15:56:05 +0100269 RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
philipelfd5a20f2016-11-15 00:57:57 -0800270 return Decode(*frame);
271}
272
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000273int32_t VideoReceiver::RequestKeyFrame() {
Tommifbf3bce2018-02-21 15:56:05 +0100274 RTC_DCHECK_RUN_ON(&module_thread_checker_);
275
276 // Since we deregister from the module thread when the decoder thread isn't
277 // running, we should get no calls here if decoding isn't being done.
278 RTC_DCHECK(IsDecoderThreadRunning());
279
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000280 TRACE_EVENT0("webrtc", "RequestKeyFrame");
sprang3911c262016-04-15 01:24:14 -0700281 if (_frameTypeCallback != nullptr) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000282 const int32_t ret = _frameTypeCallback->RequestKeyFrame();
283 if (ret < 0) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000284 return ret;
285 }
Tommifbf3bce2018-02-21 15:56:05 +0100286 rtc::CritScope cs(&process_crit_);
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000287 _scheduleKeyRequest = false;
288 } else {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000289 return VCM_MISSING_CALLBACK;
290 }
291 return VCM_OK;
292}
293
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000294// Must be called from inside the receive side critical section.
295int32_t VideoReceiver::Decode(const VCMEncodedFrame& frame) {
Tommifbf3bce2018-02-21 15:56:05 +0100296 RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
tommidb23ea62017-03-03 07:21:18 -0800297 TRACE_EVENT0("webrtc", "VideoReceiver::Decode");
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000298 // Change decoder if payload type has changed
tommid0a71ba2017-03-14 04:16:20 -0700299 VCMGenericDecoder* decoder =
300 _codecDataBase.GetDecoder(frame, &_decodedFrameCallback);
301 if (decoder == nullptr) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000302 return VCM_NO_CODEC_REGISTERED;
303 }
philipel3042c2d2017-08-18 04:55:02 -0700304 return decoder->Decode(frame, clock_->TimeInMilliseconds());
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000305}
306
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000307// Register possible receive codecs, can be called multiple times
308int32_t VideoReceiver::RegisterReceiveCodec(const VideoCodec* receiveCodec,
309 int32_t numberOfCores,
310 bool requireKeyFrame) {
Tommifbf3bce2018-02-21 15:56:05 +0100311 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
312 RTC_DCHECK(!IsDecoderThreadRunning());
sprang3911c262016-04-15 01:24:14 -0700313 if (receiveCodec == nullptr) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000314 return VCM_PARAMETER_ERROR;
315 }
philipel9d3ab612015-12-21 04:12:39 -0800316 if (!_codecDataBase.RegisterReceiveCodec(receiveCodec, numberOfCores,
317 requireKeyFrame)) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000318 return -1;
319 }
320 return 0;
321}
322
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000323// Incoming packet from network parsed and ready for decode, non blocking.
324int32_t VideoReceiver::IncomingPacket(const uint8_t* incomingPayload,
pkasting@chromium.org4591fbd2014-11-20 22:28:14 +0000325 size_t payloadLength,
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000326 const WebRtcRTPHeader& rtpInfo) {
Tommifbf3bce2018-02-21 15:56:05 +0100327 RTC_DCHECK_RUN_ON(&module_thread_checker_);
Niels Möller8f7ce222019-03-21 15:43:58 +0100328 if (rtpInfo.frameType == VideoFrameType::kVideoFrameKey) {
philipel9d3ab612015-12-21 04:12:39 -0800329 TRACE_EVENT1("webrtc", "VCM::PacketKeyFrame", "seqnum",
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000330 rtpInfo.header.sequenceNumber);
331 }
sprang3911c262016-04-15 01:24:14 -0700332 if (incomingPayload == nullptr) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000333 // The jitter buffer doesn't handle non-zero payload lengths for packets
334 // without payload.
335 // TODO(holmer): We should fix this in the jitter buffer.
336 payloadLength = 0;
337 }
Niels Möller075e7fd2019-03-12 12:29:22 +0100338 const VCMPacket packet(incomingPayload, payloadLength, rtpInfo.header,
339 rtpInfo.video_header(), rtpInfo.frameType,
340 rtpInfo.ntp_time_ms);
Johan Ahlers95348f72016-06-28 11:11:28 +0200341 int32_t ret = _receiver.InsertPacket(packet);
sprang3911c262016-04-15 01:24:14 -0700342
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000343 // TODO(holmer): Investigate if this somehow should use the key frame
344 // request scheduling to throttle the requests.
345 if (ret == VCM_FLUSH_INDICATOR) {
Peter Boströmed3277b2016-02-02 15:40:04 +0100346 {
sprang3911c262016-04-15 01:24:14 -0700347 rtc::CritScope cs(&process_crit_);
Peter Boströmed3277b2016-02-02 15:40:04 +0100348 drop_frames_until_keyframe_ = true;
349 }
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000350 RequestKeyFrame();
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000351 } else if (ret < 0) {
352 return ret;
353 }
354 return VCM_OK;
355}
356
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000357void VideoReceiver::SetNackSettings(size_t max_nack_list_size,
358 int max_packet_age_to_nack,
359 int max_incomplete_time_ms) {
Tommifbf3bce2018-02-21 15:56:05 +0100360 RTC_DCHECK_RUN_ON(&construction_thread_checker_);
361 RTC_DCHECK(!IsDecoderThreadRunning());
guidouc3372582017-04-04 07:16:21 -0700362 if (max_nack_list_size != 0) {
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000363 max_nack_list_size_ = max_nack_list_size;
guidouc3372582017-04-04 07:16:21 -0700364 }
philipel9d3ab612015-12-21 04:12:39 -0800365 _receiver.SetNackSettings(max_nack_list_size, max_packet_age_to_nack,
366 max_incomplete_time_ms);
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000367}
368
Tommifbf3bce2018-02-21 15:56:05 +0100369bool VideoReceiver::IsDecoderThreadRunning() {
370#if RTC_DCHECK_IS_ON
371 return decoder_thread_is_running_;
372#else
373 return true;
374#endif
375}
376
andresp@webrtc.orgf7eb75b2013-09-14 00:25:28 +0000377} // namespace vcm
378} // namespace webrtc