2013-09-14 00:25:28 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "common_types.h" // NOLINT(build/include)
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
2018-02-21 15:56:05 +01:00
|
|
|
#include "modules/utility/include/process_thread.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/encoded_frame.h"
|
|
|
|
|
#include "modules/video_coding/include/video_codec_interface.h"
|
|
|
|
|
#include "modules/video_coding/jitter_buffer.h"
|
|
|
|
|
#include "modules/video_coding/packet.h"
|
|
|
|
|
#include "modules/video_coding/video_coding_impl.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
2018-02-21 15:56:05 +01:00
|
|
|
#include "rtc_base/location.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/logging.h"
|
|
|
|
|
#include "rtc_base/trace_event.h"
|
|
|
|
|
#include "system_wrappers/include/clock.h"
|
2013-09-14 00:25:28 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace vcm {
|
|
|
|
|
|
2016-03-12 03:30:23 -08:00
|
|
|
VideoReceiver::VideoReceiver(Clock* clock,
|
|
|
|
|
EventFactory* event_factory,
|
2016-04-15 01:24:14 -07:00
|
|
|
EncodedImageCallback* pre_decode_image_callback,
|
2016-12-15 07:10:57 -08:00
|
|
|
VCMTiming* timing,
|
2016-03-12 03:30:23 -08:00
|
|
|
NackSender* nack_sender,
|
|
|
|
|
KeyFrameRequestSender* keyframe_request_sender)
|
2014-04-11 14:08:35 +00:00
|
|
|
: clock_(clock),
|
2016-12-15 07:10:57 -08:00
|
|
|
_timing(timing),
|
|
|
|
|
_receiver(_timing,
|
2016-03-12 03:30:23 -08:00
|
|
|
clock_,
|
|
|
|
|
event_factory,
|
|
|
|
|
nack_sender,
|
|
|
|
|
keyframe_request_sender),
|
2016-12-15 07:10:57 -08:00
|
|
|
_decodedFrameCallback(_timing, clock_),
|
2016-04-15 01:24:14 -07:00
|
|
|
_frameTypeCallback(nullptr),
|
|
|
|
|
_receiveStatsCallback(nullptr),
|
|
|
|
|
_packetRequestCallback(nullptr),
|
2013-09-14 00:25:28 +00:00
|
|
|
_scheduleKeyRequest(false),
|
2016-02-02 15:40:04 +01:00
|
|
|
drop_frames_until_keyframe_(false),
|
2013-09-14 00:25:28 +00:00
|
|
|
max_nack_list_size_(0),
|
2018-02-20 16:09:48 +01:00
|
|
|
_codecDataBase(),
|
2016-04-15 01:24:14 -07:00
|
|
|
pre_decode_image_callback_(pre_decode_image_callback),
|
2013-09-14 00:25:28 +00:00
|
|
|
_receiveStatsTimer(1000, clock_),
|
|
|
|
|
_retransmissionTimer(10, clock_),
|
2018-02-21 15:56:05 +01:00
|
|
|
_keyRequestTimer(500, clock_) {
|
|
|
|
|
decoder_thread_checker_.DetachFromThread();
|
|
|
|
|
module_thread_checker_.DetachFromThread();
|
|
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
VideoReceiver::~VideoReceiver() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2016-02-25 04:50:01 -08:00
|
|
|
void VideoReceiver::Process() {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
2013-09-14 00:25:28 +00:00
|
|
|
// Receive-side statistics
|
2017-02-22 05:30:39 -08:00
|
|
|
|
|
|
|
|
// TODO(philipel): Remove this if block when we know what to do with
|
|
|
|
|
// ReceiveStatisticsProxy::QualitySample.
|
2013-09-14 00:25:28 +00:00
|
|
|
if (_receiveStatsTimer.TimeUntilProcess() == 0) {
|
|
|
|
|
_receiveStatsTimer.Processed();
|
2016-04-15 01:24:14 -07:00
|
|
|
if (_receiveStatsCallback != nullptr) {
|
2017-02-22 05:30:39 -08:00
|
|
|
_receiveStatsCallback->OnReceiveRatesUpdated(0, 0);
|
2013-10-23 23:59:45 +00:00
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Key frame requests
|
|
|
|
|
if (_keyRequestTimer.TimeUntilProcess() == 0) {
|
|
|
|
|
_keyRequestTimer.Processed();
|
2018-02-21 15:56:05 +01:00
|
|
|
bool request_key_frame = _frameTypeCallback != nullptr;
|
|
|
|
|
if (request_key_frame) {
|
2016-04-15 01:24:14 -07:00
|
|
|
rtc::CritScope cs(&process_crit_);
|
2018-02-21 15:56:05 +01:00
|
|
|
request_key_frame = _scheduleKeyRequest;
|
2014-01-29 10:27:51 +00:00
|
|
|
}
|
2016-02-25 04:50:01 -08:00
|
|
|
if (request_key_frame)
|
|
|
|
|
RequestKeyFrame();
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Packet retransmission requests
|
|
|
|
|
// TODO(holmer): Add API for changing Process interval and make sure it's
|
|
|
|
|
// disabled when NACK is off.
|
|
|
|
|
if (_retransmissionTimer.TimeUntilProcess() == 0) {
|
|
|
|
|
_retransmissionTimer.Processed();
|
2018-02-21 15:56:05 +01:00
|
|
|
bool callback_registered = _packetRequestCallback != nullptr;
|
|
|
|
|
uint16_t length = max_nack_list_size_;
|
2014-01-29 10:27:51 +00:00
|
|
|
if (callback_registered && length > 0) {
|
2015-06-03 15:03:35 -07:00
|
|
|
// Collect sequence numbers from the default receiver.
|
|
|
|
|
bool request_key_frame = false;
|
|
|
|
|
std::vector<uint16_t> nackList = _receiver.NackList(&request_key_frame);
|
|
|
|
|
int32_t ret = VCM_OK;
|
|
|
|
|
if (request_key_frame) {
|
|
|
|
|
ret = RequestKeyFrame();
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
2015-06-03 15:03:35 -07:00
|
|
|
if (ret == VCM_OK && !nackList.empty()) {
|
Revert of Deliver video frames on Android, on the decode thread. (patchset #7 id:120001 of https://codereview.webrtc.org/2764573002/ )
Reason for revert:
Breaks Chrome FYI Android bots.
See:
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus9%29/builds/20418
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus6%29/builds/14724
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus5%29/builds/20133
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28K%20Nexus5%29/builds/15111
Original issue's description:
> Deliver video frames on Android, on the decode thread.
>
> VideoCoding
> * Adding a method for polling for frames on Android only until the capture implementation takes care of this (longer term plan).
>
> CodecDatabase
> * Add an accessor for the current decoder
> * Use std::unique_ptr<> for ownership.
> * Remove "Release()" and "ReleaseDecoder()". Instead just delete.
> * Remove |friend| relationship between CodecDatabase and VCMGenericDecoder.
>
> VCMDecodedFrameCallback
> * DCHECKs for thread correctness.
> * Remove |lock_| now that a threading model has been established and verified.
>
> VCMGenericDecoder
> * All methods now have thread checks.
> * Variable access associated with thread checkers.
>
> VideoReceiver
> * Added two notification methods, DecoderThreadStarting() and DecoderThreadStopped()
> * Allows us to establish a period when the decoder thread is not running and it is safe to modify variables such as callbacks, that are only read when the decoder thread is running.
> * Allows us to DCHECK thread guarantees.
> * Allows synchronizing callbacks from the module process thread and have them only active while the decoder thread is running.
> * The above, allows us to establish two modes for the thread, single-threaded-mutable and multi-threaded-const.
> * Using that knowledge, we can remove |receive_crit_| as well as locking for a number of member variables.
>
> MediaCodecVideoDecoder
> * Removed frame polling code from this class, since this is now done from the root thread function in VideoReceiveStream.
>
> VideoReceiveStream
> * On Android: Polls for decoded frames every 10ms (same interval as previously in MediaCodecVideoDecoder)
> * [Un]Registers the |video_receiver_| with the module thread only around the time the decoder thread is started/stopped.
> * Notifies the receiver of start/stop events of the decoder thread.
> * Changed the decoder thread to use the new PlatformThread callback type.
>
> BUG=webrtc:7361, 695438
>
> Review-Url: https://codereview.webrtc.org/2764573002
> Cr-Commit-Position: refs/heads/master@{#17527}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e3aa88bbd5accadec73fa7e38584dfbf6aabe8a9
TBR=sakal@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7361, 695438
Review-Url: https://codereview.webrtc.org/2792033003
Cr-Commit-Position: refs/heads/master@{#17530}
2017-04-04 07:16:21 -07:00
|
|
|
rtc::CritScope cs(&process_crit_);
|
2016-04-15 01:24:14 -07:00
|
|
|
if (_packetRequestCallback != nullptr) {
|
2015-06-03 15:03:35 -07:00
|
|
|
_packetRequestCallback->ResendPackets(&nackList[0], nackList.size());
|
2014-01-29 10:27:51 +00:00
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
void VideoReceiver::ProcessThreadAttached(ProcessThread* process_thread) {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
if (process_thread) {
|
|
|
|
|
is_attached_to_process_thread_ = true;
|
|
|
|
|
RTC_DCHECK(!process_thread_ || process_thread_ == process_thread);
|
|
|
|
|
process_thread_ = process_thread;
|
|
|
|
|
} else {
|
|
|
|
|
is_attached_to_process_thread_ = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t VideoReceiver::TimeUntilNextProcess() {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t timeUntilNextProcess = _receiveStatsTimer.TimeUntilProcess();
|
2014-11-24 09:06:48 +00:00
|
|
|
if (_receiver.NackMode() != kNoNack) {
|
2013-09-14 00:25:28 +00:00
|
|
|
// We need a Process call more often if we are relying on
|
|
|
|
|
// retransmissions
|
|
|
|
|
timeUntilNextProcess =
|
|
|
|
|
VCM_MIN(timeUntilNextProcess, _retransmissionTimer.TimeUntilProcess());
|
|
|
|
|
}
|
|
|
|
|
timeUntilNextProcess =
|
|
|
|
|
VCM_MIN(timeUntilNextProcess, _keyRequestTimer.TimeUntilProcess());
|
|
|
|
|
|
|
|
|
|
return timeUntilNextProcess;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-12 21:51:21 +00:00
|
|
|
int32_t VideoReceiver::SetReceiveChannelParameters(int64_t rtt) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
2013-09-14 00:25:28 +00:00
|
|
|
_receiver.UpdateRtt(rtt);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Enable or disable a video protection method.
|
|
|
|
|
// Note: This API should be deprecated, as it does not offer a distinction
|
2017-03-20 10:43:23 -07:00
|
|
|
// between the protection method and decoding with or without errors.
|
2013-09-14 00:25:28 +00:00
|
|
|
int32_t VideoReceiver::SetVideoProtection(VCMVideoProtection videoProtection,
|
|
|
|
|
bool enable) {
|
|
|
|
|
// By default, do not decode with errors.
|
|
|
|
|
_receiver.SetDecodeErrorMode(kNoErrors);
|
|
|
|
|
switch (videoProtection) {
|
2015-07-14 09:36:34 -07:00
|
|
|
case kProtectionNack: {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(enable);
|
2015-07-14 09:36:34 -07:00
|
|
|
_receiver.SetNackMode(kNack, -1, -1);
|
2013-09-14 00:25:28 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case kProtectionNackFEC: {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(enable);
|
2016-05-09 12:14:29 +02:00
|
|
|
_receiver.SetNackMode(kNack,
|
|
|
|
|
media_optimization::kLowRttNackMs,
|
|
|
|
|
media_optimization::kMaxRttDelayThreshold);
|
2015-07-14 09:36:34 -07:00
|
|
|
_receiver.SetDecodeErrorMode(kNoErrors);
|
2013-09-14 00:25:28 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case kProtectionFEC:
|
2015-03-12 10:39:24 +00:00
|
|
|
case kProtectionNone:
|
2015-07-14 09:36:34 -07:00
|
|
|
// No receiver-side protection.
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(enable);
|
2015-07-14 09:36:34 -07:00
|
|
|
_receiver.SetNackMode(kNoNack, -1, -1);
|
|
|
|
|
_receiver.SetDecodeErrorMode(kWithErrors);
|
2015-03-12 10:39:24 +00:00
|
|
|
break;
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register a receive callback. Will be called whenever there is a new frame
|
|
|
|
|
// ready for rendering.
|
|
|
|
|
int32_t VideoReceiver::RegisterReceiveCallback(
|
|
|
|
|
VCMReceiveCallback* receiveCallback) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
|
|
|
|
// This value is set before the decoder thread starts and unset after
|
|
|
|
|
// the decoder thread has been stopped.
|
2013-09-14 00:25:28 +00:00
|
|
|
_decodedFrameCallback.SetUserReceiveCallback(receiveCallback);
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t VideoReceiver::RegisterReceiveStatisticsCallback(
|
|
|
|
|
VCMReceiveStatisticsCallback* receiveStats) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning() && !is_attached_to_process_thread_);
|
|
|
|
|
// |_receiver| is used on both the decoder and module threads.
|
|
|
|
|
// However, since we make sure that we never do anything on the module thread
|
|
|
|
|
// when the decoder thread is not running, we don't need a lock for the
|
|
|
|
|
// |_receiver| or |_receiveStatsCallback| here.
|
2014-12-19 15:45:03 +00:00
|
|
|
_receiver.RegisterStatsCallback(receiveStats);
|
2013-09-14 00:25:28 +00:00
|
|
|
_receiveStatsCallback = receiveStats;
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-10 09:27:38 -08:00
|
|
|
// Register an externally defined decoder object.
|
2015-11-27 14:09:07 +01:00
|
|
|
void VideoReceiver::RegisterExternalDecoder(VideoDecoder* externalDecoder,
|
2015-12-10 09:27:38 -08:00
|
|
|
uint8_t payloadType) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
2016-04-15 01:24:14 -07:00
|
|
|
if (externalDecoder == nullptr) {
|
2015-11-27 14:09:07 +01:00
|
|
|
RTC_CHECK(_codecDataBase.DeregisterExternalDecoder(payloadType));
|
2015-11-27 15:23:12 +01:00
|
|
|
return;
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
2015-12-10 09:27:38 -08:00
|
|
|
_codecDataBase.RegisterExternalDecoder(externalDecoder, payloadType);
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register a frame type request callback.
|
|
|
|
|
int32_t VideoReceiver::RegisterFrameTypeCallback(
|
|
|
|
|
VCMFrameTypeCallback* frameTypeCallback) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning() && !is_attached_to_process_thread_);
|
|
|
|
|
// This callback is used on the module thread, but since we don't get
|
|
|
|
|
// callbacks on the module thread while the decoder thread isn't running
|
|
|
|
|
// (and this function must not be called when the decoder is running),
|
|
|
|
|
// we don't need a lock here.
|
2013-09-14 00:25:28 +00:00
|
|
|
_frameTypeCallback = frameTypeCallback;
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t VideoReceiver::RegisterPacketRequestCallback(
|
|
|
|
|
VCMPacketRequestCallback* callback) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning() && !is_attached_to_process_thread_);
|
|
|
|
|
// This callback is used on the module thread, but since we don't get
|
|
|
|
|
// callbacks on the module thread while the decoder thread isn't running
|
|
|
|
|
// (and this function must not be called when the decoder is running),
|
|
|
|
|
// we don't need a lock here.
|
2013-09-14 00:25:28 +00:00
|
|
|
_packetRequestCallback = callback;
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-17 13:22:43 +00:00
|
|
|
void VideoReceiver::TriggerDecoderShutdown() {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(IsDecoderThreadRunning());
|
2015-02-17 13:22:43 +00:00
|
|
|
_receiver.TriggerDecoderShutdown();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
void VideoReceiver::DecoderThreadStarting() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
|
|
|
|
if (process_thread_ && !is_attached_to_process_thread_) {
|
|
|
|
|
process_thread_->RegisterModule(this, RTC_FROM_HERE);
|
|
|
|
|
}
|
|
|
|
|
#if RTC_DCHECK_IS_ON
|
|
|
|
|
decoder_thread_is_running_ = true;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoReceiver::DecoderThreadStopped() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(IsDecoderThreadRunning());
|
|
|
|
|
if (process_thread_ && is_attached_to_process_thread_) {
|
|
|
|
|
process_thread_->DeRegisterModule(this);
|
|
|
|
|
}
|
|
|
|
|
#if RTC_DCHECK_IS_ON
|
|
|
|
|
decoder_thread_is_running_ = false;
|
|
|
|
|
decoder_thread_checker_.DetachFromThread();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-14 00:25:28 +00:00
|
|
|
// Decode next frame, blocking.
|
|
|
|
|
// Should be called as often as possible to get the most out of the decoder.
|
|
|
|
|
int32_t VideoReceiver::Decode(uint16_t maxWaitTimeMs) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
|
|
|
|
|
VCMEncodedFrame* frame = _receiver.FrameForDecoding(
|
|
|
|
|
maxWaitTimeMs, _codecDataBase.PrefersLateDecoding());
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
if (!frame)
|
2013-09-14 00:25:28 +00:00
|
|
|
return VCM_FRAME_NOT_READY;
|
|
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
bool drop_frame = false;
|
2016-02-02 15:40:04 +01:00
|
|
|
{
|
2016-04-15 01:24:14 -07:00
|
|
|
rtc::CritScope cs(&process_crit_);
|
2016-02-02 15:40:04 +01:00
|
|
|
if (drop_frames_until_keyframe_) {
|
|
|
|
|
// Still getting delta frames, schedule another keyframe request as if
|
|
|
|
|
// decode failed.
|
|
|
|
|
if (frame->FrameType() != kVideoFrameKey) {
|
2018-02-21 15:56:05 +01:00
|
|
|
drop_frame = true;
|
2016-02-02 15:40:04 +01:00
|
|
|
_scheduleKeyRequest = true;
|
2018-02-21 15:56:05 +01:00
|
|
|
// TODO(tommi): Consider if we could instead post a task to the module
|
|
|
|
|
// thread and call RequestKeyFrame directly. Here we call WakeUp so that
|
|
|
|
|
// TimeUntilNextProcess() gets called straight away.
|
|
|
|
|
process_thread_->WakeUp(this);
|
|
|
|
|
} else {
|
|
|
|
|
drop_frames_until_keyframe_ = false;
|
2016-02-02 15:40:04 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
if (drop_frame) {
|
|
|
|
|
_receiver.ReleaseFrame(frame);
|
|
|
|
|
return VCM_FRAME_NOT_READY;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
if (pre_decode_image_callback_) {
|
|
|
|
|
EncodedImage encoded_image(frame->EncodedImage());
|
|
|
|
|
int qp = -1;
|
|
|
|
|
if (qp_parser_.GetQp(*frame, &qp)) {
|
|
|
|
|
encoded_image.qp_ = qp;
|
2013-11-26 11:41:59 +00:00
|
|
|
}
|
2016-11-04 11:39:29 -07:00
|
|
|
pre_decode_image_callback_->OnEncodedImage(encoded_image,
|
|
|
|
|
frame->CodecSpecific(), nullptr);
|
2015-12-18 16:01:11 +01:00
|
|
|
}
|
2013-11-26 11:41:59 +00:00
|
|
|
|
2016-04-15 01:24:14 -07:00
|
|
|
// If this frame was too late, we should adjust the delay accordingly
|
2016-12-15 07:10:57 -08:00
|
|
|
_timing->UpdateCurrentDelay(frame->RenderTimeMs(),
|
|
|
|
|
clock_->TimeInMilliseconds());
|
2016-04-07 15:36:45 -07:00
|
|
|
|
|
|
|
|
if (first_frame_received_()) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_INFO) << "Received first "
|
|
|
|
|
<< (frame->Complete() ? "complete" : "incomplete")
|
|
|
|
|
<< " decodable video frame";
|
2016-04-07 15:36:45 -07:00
|
|
|
}
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
const int32_t ret = Decode(*frame);
|
|
|
|
|
_receiver.ReleaseFrame(frame);
|
|
|
|
|
return ret;
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
2017-02-22 05:30:39 -08:00
|
|
|
// Used for the new jitter buffer.
|
2016-11-15 00:57:57 -08:00
|
|
|
// TODO(philipel): Clean up among the Decode functions as we replace
|
|
|
|
|
// VCMEncodedFrame with FrameObject.
|
|
|
|
|
int32_t VideoReceiver::Decode(const webrtc::VCMEncodedFrame* frame) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
|
2016-11-28 08:49:07 -08:00
|
|
|
if (pre_decode_image_callback_) {
|
|
|
|
|
EncodedImage encoded_image(frame->EncodedImage());
|
|
|
|
|
int qp = -1;
|
|
|
|
|
if (qp_parser_.GetQp(*frame, &qp)) {
|
|
|
|
|
encoded_image.qp_ = qp;
|
|
|
|
|
}
|
|
|
|
|
pre_decode_image_callback_->OnEncodedImage(encoded_image,
|
|
|
|
|
frame->CodecSpecific(), nullptr);
|
|
|
|
|
}
|
2016-11-15 00:57:57 -08:00
|
|
|
return Decode(*frame);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 19:37:14 +00:00
|
|
|
int32_t VideoReceiver::RequestKeyFrame() {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
|
|
|
|
|
|
|
|
|
// Since we deregister from the module thread when the decoder thread isn't
|
|
|
|
|
// running, we should get no calls here if decoding isn't being done.
|
|
|
|
|
RTC_DCHECK(IsDecoderThreadRunning());
|
|
|
|
|
|
2013-09-14 00:25:28 +00:00
|
|
|
TRACE_EVENT0("webrtc", "RequestKeyFrame");
|
2016-04-15 01:24:14 -07:00
|
|
|
if (_frameTypeCallback != nullptr) {
|
2013-09-14 00:25:28 +00:00
|
|
|
const int32_t ret = _frameTypeCallback->RequestKeyFrame();
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2018-02-21 15:56:05 +01:00
|
|
|
rtc::CritScope cs(&process_crit_);
|
2013-09-14 00:25:28 +00:00
|
|
|
_scheduleKeyRequest = false;
|
|
|
|
|
} else {
|
|
|
|
|
return VCM_MISSING_CALLBACK;
|
|
|
|
|
}
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Must be called from inside the receive side critical section.
|
|
|
|
|
int32_t VideoReceiver::Decode(const VCMEncodedFrame& frame) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&decoder_thread_checker_);
|
2017-03-03 07:21:18 -08:00
|
|
|
TRACE_EVENT0("webrtc", "VideoReceiver::Decode");
|
2013-09-14 00:25:28 +00:00
|
|
|
// Change decoder if payload type has changed
|
2017-03-14 04:16:20 -07:00
|
|
|
VCMGenericDecoder* decoder =
|
|
|
|
|
_codecDataBase.GetDecoder(frame, &_decodedFrameCallback);
|
|
|
|
|
if (decoder == nullptr) {
|
2013-09-14 00:25:28 +00:00
|
|
|
return VCM_NO_CODEC_REGISTERED;
|
|
|
|
|
}
|
Reland of quest keyframes more frequently on stream start/decoding error. (patchset #1 id:1 of https://codereview.chromium.org/2995153002/ )
Reason for revert:
iOS workaround.
Original issue's description:
> Revert of quest keyframes more frequently on stream start/decoding error. (patchset #2 id:170001 of https://codereview.webrtc.org/2996823002/ )
>
> Reason for revert:
> Causes iOS H264 calls received in the background to have increased delay before being able to decode stream from sender due to not having a keyframe.
>
> Original issue's description:
> > Reland of quest keyframes more frequently on stream start/decoding error. (patchset #1 id:1 of https://codereview.chromium.org/2994043002/ )
> >
> > Reason for revert:
> > Create fix CL.
> >
> > Original issue's description:
> > > Revert of Request keyframes more frequently on stream start/decoding error. (patchset #1 id:1 of https://codereview.webrtc.org/2993793002/ )
> > >
> > > Reason for revert:
> > > Broke downstream test that was waiting for 5 keyframes to be received within 10 seconds. Maybe the issue is that "stats_callback_->OnCompleteFrame(frame->num_references == 0, ..." was changed to "frame->is_keyframe()"?
> > >
> > > Original issue's description:
> > > > Request keyframes more frequently on stream start/decoding error.
> > > >
> > > > In this CL:
> > > > - Added FrameObject::is_keyframe() convinience function.
> > > > - Moved logic to request keyframes on decoding error from VideoReceived to
> > > > VideoReceiveStream.
> > > > - Added keyframe_required as a parameter to FrameBuffer::NextFrame.
> > > >
> > > > BUG=webrtc:8074
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2993793002
> > > > Cr-Commit-Position: refs/heads/master@{#19280}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/26b48043581735eed6e36b95fae6f5b1bcf8cfb5
> > >
> > > TBR=terelius@webrtc.org,stefan@webrtc.org,noahric@chromium.org,philipel@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:8074
> > >
> > > Review-Url: https://codereview.webrtc.org/2994043002
> > > Cr-Commit-Position: refs/heads/master@{#19295}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/77a983185f57628cd5955bd2c0a1bf71c30439bb
> >
> > TBR=terelius@webrtc.org,stefan@webrtc.org,noahric@chromium.org,deadbeef@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > BUG=webrtc:8074
> >
> > Review-Url: https://codereview.webrtc.org/2996823002
> > Cr-Commit-Position: refs/heads/master@{#19324}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/628ac5964e32e66083a6ab14dceac6cb2cabe345
>
> TBR=terelius@webrtc.org,stefan@webrtc.org,noahric@chromium.org,deadbeef@webrtc.org,philipel@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:8074
>
> Review-Url: https://codereview.webrtc.org/2995153002
> Cr-Commit-Position: refs/heads/master@{#19392}
> Committed: https://chromium.googlesource.com/external/webrtc/+/53959fcc2ba580e7c87231708e5b4af7906f6836
TBR=terelius@webrtc.org,stefan@webrtc.org,noahric@chromium.org,deadbeef@webrtc.org,tkchin@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
BUG=webrtc:8074
Review-Url: https://codereview.webrtc.org/2996153003
Cr-Commit-Position: refs/heads/master@{#19410}
2017-08-18 04:55:02 -07:00
|
|
|
return decoder->Decode(frame, clock_->TimeInMilliseconds());
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register possible receive codecs, can be called multiple times
|
|
|
|
|
int32_t VideoReceiver::RegisterReceiveCodec(const VideoCodec* receiveCodec,
|
|
|
|
|
int32_t numberOfCores,
|
|
|
|
|
bool requireKeyFrame) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
2016-04-15 01:24:14 -07:00
|
|
|
if (receiveCodec == nullptr) {
|
2013-09-14 00:25:28 +00:00
|
|
|
return VCM_PARAMETER_ERROR;
|
|
|
|
|
}
|
2015-12-21 04:12:39 -08:00
|
|
|
if (!_codecDataBase.RegisterReceiveCodec(receiveCodec, numberOfCores,
|
|
|
|
|
requireKeyFrame)) {
|
2013-09-14 00:25:28 +00:00
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Incoming packet from network parsed and ready for decode, non blocking.
|
|
|
|
|
int32_t VideoReceiver::IncomingPacket(const uint8_t* incomingPayload,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t payloadLength,
|
2013-09-14 00:25:28 +00:00
|
|
|
const WebRtcRTPHeader& rtpInfo) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
2013-09-14 00:25:28 +00:00
|
|
|
if (rtpInfo.frameType == kVideoFrameKey) {
|
2015-12-21 04:12:39 -08:00
|
|
|
TRACE_EVENT1("webrtc", "VCM::PacketKeyFrame", "seqnum",
|
2013-09-14 00:25:28 +00:00
|
|
|
rtpInfo.header.sequenceNumber);
|
|
|
|
|
}
|
2016-04-15 01:24:14 -07:00
|
|
|
if (incomingPayload == nullptr) {
|
2013-09-14 00:25:28 +00:00
|
|
|
// The jitter buffer doesn't handle non-zero payload lengths for packets
|
|
|
|
|
// without payload.
|
|
|
|
|
// TODO(holmer): We should fix this in the jitter buffer.
|
|
|
|
|
payloadLength = 0;
|
|
|
|
|
}
|
|
|
|
|
const VCMPacket packet(incomingPayload, payloadLength, rtpInfo);
|
2016-06-28 11:11:28 +02:00
|
|
|
int32_t ret = _receiver.InsertPacket(packet);
|
2016-04-15 01:24:14 -07:00
|
|
|
|
2013-09-14 00:25:28 +00:00
|
|
|
// TODO(holmer): Investigate if this somehow should use the key frame
|
|
|
|
|
// request scheduling to throttle the requests.
|
|
|
|
|
if (ret == VCM_FLUSH_INDICATOR) {
|
2016-02-02 15:40:04 +01:00
|
|
|
{
|
2016-04-15 01:24:14 -07:00
|
|
|
rtc::CritScope cs(&process_crit_);
|
2016-02-02 15:40:04 +01:00
|
|
|
drop_frames_until_keyframe_ = true;
|
|
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
RequestKeyFrame();
|
|
|
|
|
} else if (ret < 0) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Minimum playout delay (used for lip-sync). This is the minimum delay required
|
|
|
|
|
// to sync with audio. Not included in VideoCodingModule::Delay()
|
|
|
|
|
// Defaults to 0 ms.
|
|
|
|
|
int32_t VideoReceiver::SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
2016-12-15 07:10:57 -08:00
|
|
|
_timing->set_min_playout_delay(minPlayoutDelayMs);
|
2013-09-14 00:25:28 +00:00
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The estimated delay caused by rendering, defaults to
|
|
|
|
|
// kDefaultRenderDelayMs = 10 ms
|
|
|
|
|
int32_t VideoReceiver::SetRenderDelay(uint32_t timeMS) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
2016-12-15 07:10:57 -08:00
|
|
|
_timing->set_render_delay(timeMS);
|
2013-09-14 00:25:28 +00:00
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Current video delay
|
2015-12-21 04:12:39 -08:00
|
|
|
int32_t VideoReceiver::Delay() const {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&module_thread_checker_);
|
2016-12-15 07:10:57 -08:00
|
|
|
return _timing->TargetVideoDelay();
|
2015-12-21 04:12:39 -08:00
|
|
|
}
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
// Only used by VCMRobustnessTest.
|
2013-09-14 00:25:28 +00:00
|
|
|
int VideoReceiver::SetReceiverRobustnessMode(
|
2017-03-20 10:43:23 -07:00
|
|
|
VideoCodingModule::ReceiverRobustness robustnessMode,
|
2013-09-14 00:25:28 +00:00
|
|
|
VCMDecodeErrorMode decode_error_mode) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
2013-09-14 00:25:28 +00:00
|
|
|
switch (robustnessMode) {
|
|
|
|
|
case VideoCodingModule::kNone:
|
|
|
|
|
_receiver.SetNackMode(kNoNack, -1, -1);
|
|
|
|
|
break;
|
|
|
|
|
case VideoCodingModule::kHardNack:
|
|
|
|
|
// Always wait for retransmissions (except when decoding with errors).
|
|
|
|
|
_receiver.SetNackMode(kNack, -1, -1);
|
|
|
|
|
break;
|
2017-03-20 10:43:23 -07:00
|
|
|
default:
|
|
|
|
|
RTC_NOTREACHED();
|
|
|
|
|
return VCM_PARAMETER_ERROR;
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
_receiver.SetDecodeErrorMode(decode_error_mode);
|
|
|
|
|
return VCM_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoReceiver::SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
2013-09-14 00:25:28 +00:00
|
|
|
_receiver.SetDecodeErrorMode(decode_error_mode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VideoReceiver::SetNackSettings(size_t max_nack_list_size,
|
|
|
|
|
int max_packet_age_to_nack,
|
|
|
|
|
int max_incomplete_time_ms) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
Revert of Deliver video frames on Android, on the decode thread. (patchset #7 id:120001 of https://codereview.webrtc.org/2764573002/ )
Reason for revert:
Breaks Chrome FYI Android bots.
See:
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus9%29/builds/20418
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus6%29/builds/14724
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus5%29/builds/20133
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28K%20Nexus5%29/builds/15111
Original issue's description:
> Deliver video frames on Android, on the decode thread.
>
> VideoCoding
> * Adding a method for polling for frames on Android only until the capture implementation takes care of this (longer term plan).
>
> CodecDatabase
> * Add an accessor for the current decoder
> * Use std::unique_ptr<> for ownership.
> * Remove "Release()" and "ReleaseDecoder()". Instead just delete.
> * Remove |friend| relationship between CodecDatabase and VCMGenericDecoder.
>
> VCMDecodedFrameCallback
> * DCHECKs for thread correctness.
> * Remove |lock_| now that a threading model has been established and verified.
>
> VCMGenericDecoder
> * All methods now have thread checks.
> * Variable access associated with thread checkers.
>
> VideoReceiver
> * Added two notification methods, DecoderThreadStarting() and DecoderThreadStopped()
> * Allows us to establish a period when the decoder thread is not running and it is safe to modify variables such as callbacks, that are only read when the decoder thread is running.
> * Allows us to DCHECK thread guarantees.
> * Allows synchronizing callbacks from the module process thread and have them only active while the decoder thread is running.
> * The above, allows us to establish two modes for the thread, single-threaded-mutable and multi-threaded-const.
> * Using that knowledge, we can remove |receive_crit_| as well as locking for a number of member variables.
>
> MediaCodecVideoDecoder
> * Removed frame polling code from this class, since this is now done from the root thread function in VideoReceiveStream.
>
> VideoReceiveStream
> * On Android: Polls for decoded frames every 10ms (same interval as previously in MediaCodecVideoDecoder)
> * [Un]Registers the |video_receiver_| with the module thread only around the time the decoder thread is started/stopped.
> * Notifies the receiver of start/stop events of the decoder thread.
> * Changed the decoder thread to use the new PlatformThread callback type.
>
> BUG=webrtc:7361, 695438
>
> Review-Url: https://codereview.webrtc.org/2764573002
> Cr-Commit-Position: refs/heads/master@{#17527}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e3aa88bbd5accadec73fa7e38584dfbf6aabe8a9
TBR=sakal@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7361, 695438
Review-Url: https://codereview.webrtc.org/2792033003
Cr-Commit-Position: refs/heads/master@{#17530}
2017-04-04 07:16:21 -07:00
|
|
|
if (max_nack_list_size != 0) {
|
2013-09-14 00:25:28 +00:00
|
|
|
max_nack_list_size_ = max_nack_list_size;
|
Revert of Deliver video frames on Android, on the decode thread. (patchset #7 id:120001 of https://codereview.webrtc.org/2764573002/ )
Reason for revert:
Breaks Chrome FYI Android bots.
See:
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus9%29/builds/20418
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus6%29/builds/14724
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus5%29/builds/20133
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28K%20Nexus5%29/builds/15111
Original issue's description:
> Deliver video frames on Android, on the decode thread.
>
> VideoCoding
> * Adding a method for polling for frames on Android only until the capture implementation takes care of this (longer term plan).
>
> CodecDatabase
> * Add an accessor for the current decoder
> * Use std::unique_ptr<> for ownership.
> * Remove "Release()" and "ReleaseDecoder()". Instead just delete.
> * Remove |friend| relationship between CodecDatabase and VCMGenericDecoder.
>
> VCMDecodedFrameCallback
> * DCHECKs for thread correctness.
> * Remove |lock_| now that a threading model has been established and verified.
>
> VCMGenericDecoder
> * All methods now have thread checks.
> * Variable access associated with thread checkers.
>
> VideoReceiver
> * Added two notification methods, DecoderThreadStarting() and DecoderThreadStopped()
> * Allows us to establish a period when the decoder thread is not running and it is safe to modify variables such as callbacks, that are only read when the decoder thread is running.
> * Allows us to DCHECK thread guarantees.
> * Allows synchronizing callbacks from the module process thread and have them only active while the decoder thread is running.
> * The above, allows us to establish two modes for the thread, single-threaded-mutable and multi-threaded-const.
> * Using that knowledge, we can remove |receive_crit_| as well as locking for a number of member variables.
>
> MediaCodecVideoDecoder
> * Removed frame polling code from this class, since this is now done from the root thread function in VideoReceiveStream.
>
> VideoReceiveStream
> * On Android: Polls for decoded frames every 10ms (same interval as previously in MediaCodecVideoDecoder)
> * [Un]Registers the |video_receiver_| with the module thread only around the time the decoder thread is started/stopped.
> * Notifies the receiver of start/stop events of the decoder thread.
> * Changed the decoder thread to use the new PlatformThread callback type.
>
> BUG=webrtc:7361, 695438
>
> Review-Url: https://codereview.webrtc.org/2764573002
> Cr-Commit-Position: refs/heads/master@{#17527}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e3aa88bbd5accadec73fa7e38584dfbf6aabe8a9
TBR=sakal@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7361, 695438
Review-Url: https://codereview.webrtc.org/2792033003
Cr-Commit-Position: refs/heads/master@{#17530}
2017-04-04 07:16:21 -07:00
|
|
|
}
|
2015-12-21 04:12:39 -08:00
|
|
|
_receiver.SetNackSettings(max_nack_list_size, max_packet_age_to_nack,
|
|
|
|
|
max_incomplete_time_ms);
|
2013-09-14 00:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int VideoReceiver::SetMinReceiverDelay(int desired_delay_ms) {
|
2018-02-21 15:56:05 +01:00
|
|
|
RTC_DCHECK_RUN_ON(&construction_thread_checker_);
|
|
|
|
|
RTC_DCHECK(!IsDecoderThreadRunning());
|
|
|
|
|
// TODO(tommi): Is the method only used by tests? Maybe could be offered
|
|
|
|
|
// via a test only subclass?
|
|
|
|
|
// Info from Stefan: If it is indeed only used by tests I think it's just that
|
|
|
|
|
// it hasn't been cleaned up when the calling code was cleaned up.
|
2013-09-14 00:25:28 +00:00
|
|
|
return _receiver.SetMinReceiverDelay(desired_delay_ms);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
bool VideoReceiver::IsDecoderThreadRunning() {
|
|
|
|
|
#if RTC_DCHECK_IS_ON
|
|
|
|
|
return decoder_thread_is_running_;
|
|
|
|
|
#else
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-14 00:25:28 +00:00
|
|
|
} // namespace vcm
|
|
|
|
|
} // namespace webrtc
|