Move call of stat's OnPreDecode to VideoReceiveStream::Decode
This is a preparation for deleting VideoReceiveStream::OnEncodedImage and VideoReceiveStream::EnableEncodedFrameRecording. Bug: webrtc:9106 Change-Id: Id5444f74e4b4d2003e548a9916e7acfe3b978144 Reviewed-on: https://webrtc-review.googlesource.com/102580 Reviewed-by: Åsa Persson <asapersson@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24913}
This commit is contained in:
@ -839,18 +839,13 @@ void ReceiveStatisticsProxy::OnDiscardedPacketsUpdated(int discarded_packets) {
|
||||
stats_.discarded_packets = discarded_packets;
|
||||
}
|
||||
|
||||
void ReceiveStatisticsProxy::OnPreDecode(
|
||||
const EncodedImage& encoded_image,
|
||||
const CodecSpecificInfo* codec_specific_info) {
|
||||
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
|
||||
RTC_DCHECK_RUN_ON(&decode_thread_);
|
||||
if (!codec_specific_info || encoded_image.qp_ == -1) {
|
||||
return;
|
||||
}
|
||||
rtc::CritScope lock(&crit_);
|
||||
last_codec_type_ = codec_specific_info->codecType;
|
||||
if (last_codec_type_ == kVideoCodecVP8) {
|
||||
qp_counters_.vp8.Add(encoded_image.qp_);
|
||||
qp_sample_.Add(encoded_image.qp_);
|
||||
last_codec_type_ = codec_type;
|
||||
if (last_codec_type_ == kVideoCodecVP8 && qp != -1) {
|
||||
qp_counters_.vp8.Add(qp);
|
||||
qp_sample_.Add(qp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -62,8 +62,7 @@ class ReceiveStatisticsProxy : public VCMReceiveStatisticsCallback,
|
||||
void OnDecoderImplementationName(const char* implementation_name);
|
||||
void OnIncomingRate(unsigned int framerate, unsigned int bitrate_bps);
|
||||
|
||||
void OnPreDecode(const EncodedImage& encoded_image,
|
||||
const CodecSpecificInfo* codec_specific_info);
|
||||
void OnPreDecode(VideoCodecType codec_type, int qp);
|
||||
|
||||
void OnUniqueFramesCounted(int num_unique_frames);
|
||||
|
||||
|
||||
@ -578,13 +578,9 @@ TEST_F(ReceiveStatisticsProxyTest, RtpToNtpFrequencyOffsetHistogramIsUpdated) {
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsUpdated) {
|
||||
const int kQp = 22;
|
||||
EncodedImage encoded_image;
|
||||
encoded_image.qp_ = kQp;
|
||||
CodecSpecificInfo codec_info;
|
||||
codec_info.codecType = kVideoCodecVP8;
|
||||
|
||||
for (int i = 0; i < kMinRequiredSamples; ++i)
|
||||
statistics_proxy_->OnPreDecode(encoded_image, &codec_info);
|
||||
statistics_proxy_->OnPreDecode(kVideoCodecVP8, kQp);
|
||||
|
||||
statistics_proxy_.reset();
|
||||
EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp"));
|
||||
@ -592,25 +588,18 @@ TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsUpdated) {
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsNotUpdatedForTooFewSamples) {
|
||||
EncodedImage encoded_image;
|
||||
encoded_image.qp_ = 22;
|
||||
CodecSpecificInfo codec_info;
|
||||
codec_info.codecType = kVideoCodecVP8;
|
||||
const int kQp = 22;
|
||||
|
||||
for (int i = 0; i < kMinRequiredSamples - 1; ++i)
|
||||
statistics_proxy_->OnPreDecode(encoded_image, &codec_info);
|
||||
statistics_proxy_->OnPreDecode(kVideoCodecVP8, kQp);
|
||||
|
||||
statistics_proxy_.reset();
|
||||
EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp"));
|
||||
}
|
||||
|
||||
TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsNotUpdatedIfNoQpValue) {
|
||||
EncodedImage encoded_image;
|
||||
CodecSpecificInfo codec_info;
|
||||
codec_info.codecType = kVideoCodecVP8;
|
||||
|
||||
for (int i = 0; i < kMinRequiredSamples; ++i)
|
||||
statistics_proxy_->OnPreDecode(encoded_image, &codec_info);
|
||||
statistics_proxy_->OnPreDecode(kVideoCodecVP8, -1);
|
||||
|
||||
statistics_proxy_.reset();
|
||||
EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp"));
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#include "modules/video_coding/jitter_estimator.h"
|
||||
#include "modules/video_coding/timing.h"
|
||||
#include "modules/video_coding/utility/ivf_file_writer.h"
|
||||
#include "modules/video_coding/utility/vp8_header_parser.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/location.h"
|
||||
#include "rtc_base/logging.h"
|
||||
@ -366,7 +367,6 @@ EncodedImageCallback::Result VideoReceiveStream::OnEncodedImage(
|
||||
const EncodedImage& encoded_image,
|
||||
const CodecSpecificInfo* codec_specific_info,
|
||||
const RTPFragmentationHeader* fragmentation) {
|
||||
stats_proxy_.OnPreDecode(encoded_image, codec_specific_info);
|
||||
{
|
||||
rtc::CritScope lock(&ivf_writer_lock_);
|
||||
if (ivf_writer_.get()) {
|
||||
@ -458,6 +458,16 @@ bool VideoReceiveStream::Decode() {
|
||||
if (frame) {
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
RTC_DCHECK_EQ(res, video_coding::FrameBuffer::ReturnReason::kFrameFound);
|
||||
|
||||
// Current OnPreDecode only cares about QP for VP8.
|
||||
int qp = -1;
|
||||
if (frame->CodecSpecific()->codecType == kVideoCodecVP8) {
|
||||
if (!vp8::GetQp(frame->Buffer(), frame->Length(), &qp)) {
|
||||
RTC_LOG(LS_WARNING) << "Failed to extract QP from VP8 video frame";
|
||||
}
|
||||
}
|
||||
stats_proxy_.OnPreDecode(frame->CodecSpecific()->codecType, qp);
|
||||
|
||||
int decode_result = video_receiver_.Decode(frame.get());
|
||||
if (decode_result == WEBRTC_VIDEO_CODEC_OK ||
|
||||
decode_result == WEBRTC_VIDEO_CODEC_OK_REQUEST_KEYFRAME) {
|
||||
|
||||
Reference in New Issue
Block a user