2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-07-31 15:53:44 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* 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 06:47:31 +02:00
|
|
|
#include "modules/video_coding/generic_decoder.h"
|
2017-07-05 16:45:57 -07:00
|
|
|
|
2017-07-06 03:06:50 -07:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/include/video_coding.h"
|
|
|
|
|
#include "modules/video_coding/internal_defines.h"
|
|
|
|
|
#include "rtc_base/checks.h"
|
|
|
|
|
#include "rtc_base/logging.h"
|
|
|
|
|
#include "rtc_base/timeutils.h"
|
|
|
|
|
#include "rtc_base/trace_event.h"
|
|
|
|
|
#include "system_wrappers/include/clock.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
VCMDecodedFrameCallback::VCMDecodedFrameCallback(VCMTiming* timing,
|
2013-01-21 07:42:11 +00:00
|
|
|
Clock* clock)
|
2017-03-14 04:16:20 -07:00
|
|
|
: _clock(clock),
|
2015-12-18 16:01:11 +01:00
|
|
|
_timing(timing),
|
|
|
|
|
_timestampMap(kDecoderFrameMemoryLength),
|
2017-06-19 07:18:55 -07:00
|
|
|
_lastReceivedPictureID(0) {
|
|
|
|
|
ntp_offset_ =
|
|
|
|
|
_clock->CurrentNtpInMilliseconds() - _clock->TimeInMilliseconds();
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
VCMDecodedFrameCallback::~VCMDecodedFrameCallback() {
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-10 14:17:46 +00:00
|
|
|
void VCMDecodedFrameCallback::SetUserReceiveCallback(
|
2015-12-21 04:12:39 -08:00
|
|
|
VCMReceiveCallback* receiveCallback) {
|
2017-03-14 04:16:20 -07:00
|
|
|
RTC_DCHECK(construction_thread_.CalledOnValidThread());
|
|
|
|
|
RTC_DCHECK((!_receiveCallback && receiveCallback) ||
|
|
|
|
|
(_receiveCallback && !receiveCallback));
|
2015-12-21 04:12:39 -08:00
|
|
|
_receiveCallback = receiveCallback;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
VCMReceiveCallback* VCMDecodedFrameCallback::UserReceiveCallback() {
|
2017-03-14 04:16:20 -07:00
|
|
|
// Called on the decode thread via VCMCodecDataBase::GetDecoder.
|
|
|
|
|
// The callback must always have been set before this happens.
|
|
|
|
|
RTC_DCHECK(_receiveCallback);
|
2015-12-21 04:12:39 -08:00
|
|
|
return _receiveCallback;
|
2013-08-12 14:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
2015-05-29 17:21:40 -07:00
|
|
|
int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage) {
|
2015-11-10 14:00:27 +01:00
|
|
|
return Decoded(decodedImage, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
|
|
|
|
|
int64_t decode_time_ms) {
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
Decoded(decodedImage,
|
|
|
|
|
decode_time_ms >= 0 ? rtc::Optional<int32_t>(decode_time_ms)
|
2017-11-16 10:54:49 +01:00
|
|
|
: rtc::nullopt,
|
|
|
|
|
rtc::nullopt);
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
|
|
|
|
|
rtc::Optional<int32_t> decode_time_ms,
|
|
|
|
|
rtc::Optional<uint8_t> qp) {
|
2017-03-14 04:16:20 -07:00
|
|
|
RTC_DCHECK(_receiveCallback) << "Callback must not be null at this point";
|
2015-12-21 04:12:39 -08:00
|
|
|
TRACE_EVENT_INSTANT1("webrtc", "VCMDecodedFrameCallback::Decoded",
|
|
|
|
|
"timestamp", decodedImage.timestamp());
|
|
|
|
|
// TODO(holmer): We should improve this so that we can handle multiple
|
|
|
|
|
// callbacks from one call to Decode().
|
2018-02-21 19:38:59 +00:00
|
|
|
VCMFrameInformation* frameInfo;
|
|
|
|
|
{
|
|
|
|
|
rtc::CritScope cs(&lock_);
|
|
|
|
|
frameInfo = _timestampMap.Pop(decodedImage.timestamp());
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
if (frameInfo == NULL) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Too many frames backed up in the decoder, dropping "
|
|
|
|
|
"this one.";
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
return;
|
2015-12-21 04:12:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int64_t now_ms = _clock->TimeInMilliseconds();
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
if (!decode_time_ms) {
|
2017-11-16 10:54:49 +01:00
|
|
|
decode_time_ms = now_ms - frameInfo->decodeStartTimeMs;
|
2015-12-21 04:12:39 -08:00
|
|
|
}
|
Reland of Add QP sum stats for received streams. (patchset #2 id:300001 of https://codereview.webrtc.org/2680893002/ )
Reason for revert:
Fix the problem.
Original issue's description:
> Revert of Add QP sum stats for received streams. (patchset #10 id:180001 of https://codereview.webrtc.org/2649133005/ )
>
> Reason for revert:
> Breaks downstream build.
>
> Original issue's description:
> > Add QP sum stats for received streams.
> >
> > This is not implemented yet in any of the decoders.
> >
> > BUG=webrtc:6541
> >
> > Review-Url: https://codereview.webrtc.org/2649133005
> > Cr-Commit-Position: refs/heads/master@{#16475}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/ff0e72fd165facac27f0313aa178648782e63bc4
>
> TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,sakal@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6541
>
> Review-Url: https://codereview.webrtc.org/2680893002 .
> Cr-Commit-Position: refs/heads/master@{#16480}
> Committed: https://chromium.googlesource.com/external/webrtc/+/69fb2cca4d54f3df7ceddcd1c3e9b0ad80fa849b
TBR=hta@webrtc.org,hbos@webrtc.org,sprang@webrtc.org,magjed@webrtc.org,stefan@webrtc.org,skvlad@webrtc.org
BUG=webrtc:6541
Review-Url: https://codereview.webrtc.org/2681663005
Cr-Commit-Position: refs/heads/master@{#16511}
2017-02-09 04:53:45 -08:00
|
|
|
_timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms,
|
2015-12-21 04:12:39 -08:00
|
|
|
frameInfo->renderTimeMs);
|
|
|
|
|
|
2017-06-19 07:18:55 -07:00
|
|
|
// Report timing information.
|
2017-08-18 02:51:12 -07:00
|
|
|
if (frameInfo->timing.flags != TimingFrameFlags::kInvalid) {
|
2017-07-06 03:06:50 -07:00
|
|
|
int64_t capture_time_ms = decodedImage.ntp_time_ms() - ntp_offset_;
|
2017-06-19 07:18:55 -07:00
|
|
|
// Convert remote timestamps to local time from ntp timestamps.
|
|
|
|
|
frameInfo->timing.encode_start_ms -= ntp_offset_;
|
|
|
|
|
frameInfo->timing.encode_finish_ms -= ntp_offset_;
|
|
|
|
|
frameInfo->timing.packetization_finish_ms -= ntp_offset_;
|
|
|
|
|
frameInfo->timing.pacer_exit_ms -= ntp_offset_;
|
|
|
|
|
frameInfo->timing.network_timestamp_ms -= ntp_offset_;
|
|
|
|
|
frameInfo->timing.network2_timestamp_ms -= ntp_offset_;
|
2017-07-06 03:06:50 -07:00
|
|
|
|
|
|
|
|
int64_t sender_delta_ms = 0;
|
|
|
|
|
if (decodedImage.ntp_time_ms() < 0) {
|
|
|
|
|
// Sender clock is not estimated yet. Make sure that sender times are all
|
|
|
|
|
// negative to indicate that. Yet they still should be relatively correct.
|
|
|
|
|
sender_delta_ms =
|
|
|
|
|
std::max({capture_time_ms, frameInfo->timing.encode_start_ms,
|
|
|
|
|
frameInfo->timing.encode_finish_ms,
|
|
|
|
|
frameInfo->timing.packetization_finish_ms,
|
|
|
|
|
frameInfo->timing.pacer_exit_ms,
|
|
|
|
|
frameInfo->timing.network_timestamp_ms,
|
|
|
|
|
frameInfo->timing.network2_timestamp_ms}) +
|
|
|
|
|
1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TimingFrameInfo timing_frame_info;
|
|
|
|
|
|
|
|
|
|
timing_frame_info.capture_time_ms = capture_time_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.encode_start_ms =
|
|
|
|
|
frameInfo->timing.encode_start_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.encode_finish_ms =
|
|
|
|
|
frameInfo->timing.encode_finish_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.packetization_finish_ms =
|
|
|
|
|
frameInfo->timing.packetization_finish_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.pacer_exit_ms =
|
|
|
|
|
frameInfo->timing.pacer_exit_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.network_timestamp_ms =
|
|
|
|
|
frameInfo->timing.network_timestamp_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.network2_timestamp_ms =
|
|
|
|
|
frameInfo->timing.network2_timestamp_ms - sender_delta_ms;
|
|
|
|
|
timing_frame_info.receive_start_ms = frameInfo->timing.receive_start_ms;
|
|
|
|
|
timing_frame_info.receive_finish_ms = frameInfo->timing.receive_finish_ms;
|
|
|
|
|
timing_frame_info.decode_start_ms = frameInfo->decodeStartTimeMs;
|
|
|
|
|
timing_frame_info.decode_finish_ms = now_ms;
|
|
|
|
|
timing_frame_info.render_time_ms = frameInfo->renderTimeMs;
|
|
|
|
|
timing_frame_info.rtp_timestamp = decodedImage.timestamp();
|
2017-08-18 02:51:12 -07:00
|
|
|
timing_frame_info.flags = frameInfo->timing.flags;
|
2017-07-06 03:06:50 -07:00
|
|
|
|
|
|
|
|
_timing->SetTimingFrameInfo(timing_frame_info);
|
2017-06-19 07:18:55 -07:00
|
|
|
}
|
|
|
|
|
|
2017-01-30 02:43:18 -08:00
|
|
|
decodedImage.set_timestamp_us(
|
|
|
|
|
frameInfo->renderTimeMs * rtc::kNumMicrosecsPerMillisec);
|
2016-09-30 06:19:08 -07:00
|
|
|
decodedImage.set_rotation(frameInfo->rotation);
|
2017-04-11 10:34:31 -07:00
|
|
|
_receiveCallback->FrameToRender(decodedImage, qp, frameInfo->content_type);
|
2015-12-21 04:12:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t VCMDecodedFrameCallback::ReceivedDecodedReferenceFrame(
|
|
|
|
|
const uint64_t pictureId) {
|
2017-03-14 04:16:20 -07:00
|
|
|
return _receiveCallback->ReceivedDecodedReferenceFrame(pictureId);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
int32_t VCMDecodedFrameCallback::ReceivedDecodedFrame(
|
|
|
|
|
const uint64_t pictureId) {
|
|
|
|
|
_lastReceivedPictureID = pictureId;
|
|
|
|
|
return 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
uint64_t VCMDecodedFrameCallback::LastReceivedPictureID() const {
|
|
|
|
|
return _lastReceivedPictureID;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
void VCMDecodedFrameCallback::OnDecoderImplementationName(
|
|
|
|
|
const char* implementation_name) {
|
2017-03-14 04:16:20 -07:00
|
|
|
_receiveCallback->OnDecoderImplementationName(implementation_name);
|
2015-12-18 16:01:11 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-28 08:52:18 -07:00
|
|
|
void VCMDecodedFrameCallback::Map(uint32_t timestamp,
|
|
|
|
|
VCMFrameInformation* frameInfo) {
|
2018-02-21 19:38:59 +00:00
|
|
|
rtc::CritScope cs(&lock_);
|
2015-09-28 08:52:18 -07:00
|
|
|
_timestampMap.Add(timestamp, frameInfo);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
int32_t VCMDecodedFrameCallback::Pop(uint32_t timestamp) {
|
2018-02-21 19:38:59 +00:00
|
|
|
rtc::CritScope cs(&lock_);
|
|
|
|
|
if (_timestampMap.Pop(timestamp) == NULL) {
|
|
|
|
|
return VCM_GENERAL_ERROR;
|
|
|
|
|
}
|
|
|
|
|
return VCM_OK;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2017-11-13 14:10:02 +01:00
|
|
|
VCMGenericDecoder::VCMGenericDecoder(std::unique_ptr<VideoDecoder> decoder)
|
|
|
|
|
: VCMGenericDecoder(decoder.release(), false /* isExternal */) {}
|
|
|
|
|
|
2015-12-01 17:20:01 +01:00
|
|
|
VCMGenericDecoder::VCMGenericDecoder(VideoDecoder* decoder, bool isExternal)
|
|
|
|
|
: _callback(NULL),
|
|
|
|
|
_frameInfos(),
|
|
|
|
|
_nextFrameInfoIdx(0),
|
2017-07-05 16:45:57 -07:00
|
|
|
decoder_(decoder),
|
2015-12-01 17:20:01 +01:00
|
|
|
_codecType(kVideoCodecUnknown),
|
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
|
|
|
_isExternal(isExternal),
|
2017-07-05 16:45:57 -07:00
|
|
|
_last_keyframe_content_type(VideoContentType::UNSPECIFIED) {
|
|
|
|
|
RTC_DCHECK(decoder_);
|
|
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-07-05 16:45:57 -07:00
|
|
|
VCMGenericDecoder::~VCMGenericDecoder() {
|
|
|
|
|
decoder_->Release();
|
|
|
|
|
if (_isExternal)
|
|
|
|
|
decoder_.release();
|
2017-07-15 11:33:35 -07:00
|
|
|
RTC_DCHECK(_isExternal || decoder_);
|
2017-07-05 16:45:57 -07:00
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-04-02 15:54:38 +00:00
|
|
|
int32_t VCMGenericDecoder::InitDecode(const VideoCodec* settings,
|
2015-12-21 04:12:39 -08:00
|
|
|
int32_t numberOfCores) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "VCMGenericDecoder::InitDecode");
|
|
|
|
|
_codecType = settings->codecType;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-07-05 16:45:57 -07:00
|
|
|
return decoder_->InitDecode(settings, numberOfCores);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 06:03:43 -08:00
|
|
|
int32_t VCMGenericDecoder::Decode(const VCMEncodedFrame& frame, int64_t nowMs) {
|
2018-02-21 19:38:59 +00:00
|
|
|
TRACE_EVENT1("webrtc", "VCMGenericDecoder::Decode", "timestamp",
|
|
|
|
|
frame.EncodedImage()._timeStamp);
|
|
|
|
|
_frameInfos[_nextFrameInfoIdx].decodeStartTimeMs = nowMs;
|
|
|
|
|
_frameInfos[_nextFrameInfoIdx].renderTimeMs = frame.RenderTimeMs();
|
|
|
|
|
_frameInfos[_nextFrameInfoIdx].rotation = frame.rotation();
|
|
|
|
|
_frameInfos[_nextFrameInfoIdx].timing = frame.video_timing();
|
|
|
|
|
// Set correctly only for key frames. Thus, use latest key frame
|
|
|
|
|
// content type. If the corresponding key frame was lost, decode will fail
|
|
|
|
|
// and content type will be ignored.
|
|
|
|
|
if (frame.FrameType() == kVideoFrameKey) {
|
|
|
|
|
_frameInfos[_nextFrameInfoIdx].content_type = frame.contentType();
|
|
|
|
|
_last_keyframe_content_type = frame.contentType();
|
|
|
|
|
} else {
|
|
|
|
|
_frameInfos[_nextFrameInfoIdx].content_type = _last_keyframe_content_type;
|
|
|
|
|
}
|
|
|
|
|
_callback->Map(frame.TimeStamp(), &_frameInfos[_nextFrameInfoIdx]);
|
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
|
|
|
|
2018-02-21 19:38:59 +00:00
|
|
|
_nextFrameInfoIdx = (_nextFrameInfoIdx + 1) % kDecoderFrameMemoryLength;
|
|
|
|
|
int32_t ret = decoder_->Decode(frame.EncodedImage(), frame.MissingFrame(),
|
|
|
|
|
frame.CodecSpecific(), frame.RenderTimeMs());
|
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
|
|
|
|
2018-02-21 19:38:59 +00:00
|
|
|
_callback->OnDecoderImplementationName(decoder_->ImplementationName());
|
2015-12-21 04:12:39 -08:00
|
|
|
if (ret < WEBRTC_VIDEO_CODEC_OK) {
|
2017-11-09 11:09:25 +01:00
|
|
|
RTC_LOG(LS_WARNING) << "Failed to decode frame with timestamp "
|
|
|
|
|
<< frame.TimeStamp() << ", error code: " << ret;
|
2018-02-21 19:38:59 +00:00
|
|
|
_callback->Pop(frame.TimeStamp());
|
|
|
|
|
return ret;
|
|
|
|
|
} else if (ret == WEBRTC_VIDEO_CODEC_NO_OUTPUT ||
|
|
|
|
|
ret == WEBRTC_VIDEO_CODEC_REQUEST_SLI) {
|
|
|
|
|
// No output
|
|
|
|
|
_callback->Pop(frame.TimeStamp());
|
2011-10-10 14:17:46 +00:00
|
|
|
}
|
2018-02-21 19:38:59 +00:00
|
|
|
return ret;
|
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
|
|
|
}
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-01 17:20:01 +01:00
|
|
|
int32_t VCMGenericDecoder::RegisterDecodeCompleteCallback(
|
|
|
|
|
VCMDecodedFrameCallback* callback) {
|
|
|
|
|
_callback = callback;
|
2017-07-05 16:45:57 -07:00
|
|
|
return decoder_->RegisterDecodeCompleteCallback(callback);
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
bool VCMGenericDecoder::PrefersLateDecoding() const {
|
2017-07-05 16:45:57 -07:00
|
|
|
return decoder_->PrefersLateDecoding();
|
2015-12-10 09:27:38 -08:00
|
|
|
}
|
|
|
|
|
|
2015-12-21 04:12:39 -08:00
|
|
|
} // namespace webrtc
|