using find modules/video_coding/ -name "*.h" -o -name "*.cc" | grep -v android | xargs tools_webrtc/iwyu/apply-include-cleaner followed by tools_webrtc/gn_check_autofix.py -C out/Default/ and git cl format H264 changes led to link failures so were reverted. Manual changes required: * added I420Buffer to test/testsupport/frame_reader.h * modules/video_coding/codecs/vp8/libvpx_vp8_encoder.cc -- added VP8 constants * modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc -- added uncompressed header parser * modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc -- added vpx_encoder for VPX_DL_REALTIME * modules/video_coding/video_receiver2_unittest.cc -- added video_coding_defines.h * modules/video_coding/generic_decoder.cc -- same * modules/video_coding/generic_decoder_unittest.cc -- same * modules/video_coding/deprecated/jitter_buffer_unittest.cc -- added video_coding/encoded_frame.h * media/engine/simulcast_encoder_adapter_unittest.cc -- added video_error_codes * modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc -- same * modules/video_coding/video_receiver2_unittest.cc -- same * rtc_tools/video_replay.cc -- same * test/video_codec_tester_unittest.cc -- same * rtc_tools/video_encoder/video_encoder.cc -- same * modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h -- moved around includes * rtc_tools/DEPS: allowed include from video_coding:video_codec_interface * modules/video_coding/codecs/av1/libaom_av1_encoder.cc -- expand full aom path Additional changes resulting from moving VP9 defines and feedback. BUG=webrtc:42226242 Change-Id: If7040e1cab93cf587f25ee8492604a7f7af9a573 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/381860 Commit-Queue: Philipp Hancke <phancke@meta.com> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#44345}
87 lines
2.7 KiB
C++
87 lines
2.7 KiB
C++
/*
|
|
* Copyright (c) 2022 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.
|
|
*/
|
|
|
|
#include "modules/video_coding/decoder_database.h"
|
|
|
|
#include <memory>
|
|
#include <utility>
|
|
|
|
#include "api/test/mock_video_decoder.h"
|
|
#include "api/video/video_codec_type.h"
|
|
#include "api/video_codecs/video_decoder.h"
|
|
#include "test/gmock.h"
|
|
#include "test/gtest.h"
|
|
|
|
namespace webrtc {
|
|
namespace {
|
|
|
|
using ::testing::NiceMock;
|
|
|
|
// Test registering and unregistering an external decoder instance.
|
|
TEST(VCMDecoderDatabaseTest, RegisterExternalDecoder) {
|
|
VCMDecoderDatabase db;
|
|
constexpr int kPayloadType = 1;
|
|
ASSERT_FALSE(db.IsExternalDecoderRegistered(kPayloadType));
|
|
|
|
auto decoder = std::make_unique<NiceMock<MockVideoDecoder>>();
|
|
bool decoder_deleted = false;
|
|
EXPECT_CALL(*decoder, Destruct).WillOnce([&decoder_deleted] {
|
|
decoder_deleted = true;
|
|
});
|
|
|
|
db.RegisterExternalDecoder(kPayloadType, std::move(decoder));
|
|
EXPECT_TRUE(db.IsExternalDecoderRegistered(kPayloadType));
|
|
db.DeregisterExternalDecoder(kPayloadType);
|
|
EXPECT_TRUE(decoder_deleted);
|
|
EXPECT_FALSE(db.IsExternalDecoderRegistered(kPayloadType));
|
|
}
|
|
|
|
TEST(VCMDecoderDatabaseTest, RegisterReceiveCodec) {
|
|
VCMDecoderDatabase db;
|
|
constexpr int kPayloadType = 1;
|
|
ASSERT_FALSE(db.DeregisterReceiveCodec(kPayloadType));
|
|
|
|
VideoDecoder::Settings settings;
|
|
settings.set_codec_type(kVideoCodecVP8);
|
|
settings.set_max_render_resolution({10, 10});
|
|
settings.set_number_of_cores(4);
|
|
db.RegisterReceiveCodec(kPayloadType, settings);
|
|
|
|
EXPECT_TRUE(db.DeregisterReceiveCodec(kPayloadType));
|
|
}
|
|
|
|
TEST(VCMDecoderDatabaseTest, DeregisterReceiveCodecs) {
|
|
VCMDecoderDatabase db;
|
|
constexpr int kPayloadType1 = 1;
|
|
constexpr int kPayloadType2 = 2;
|
|
ASSERT_FALSE(db.DeregisterReceiveCodec(kPayloadType1));
|
|
ASSERT_FALSE(db.DeregisterReceiveCodec(kPayloadType2));
|
|
|
|
VideoDecoder::Settings settings1;
|
|
settings1.set_codec_type(kVideoCodecVP8);
|
|
settings1.set_max_render_resolution({10, 10});
|
|
settings1.set_number_of_cores(4);
|
|
|
|
VideoDecoder::Settings settings2 = settings1;
|
|
settings2.set_codec_type(kVideoCodecVP9);
|
|
|
|
db.RegisterReceiveCodec(kPayloadType1, settings1);
|
|
db.RegisterReceiveCodec(kPayloadType2, settings2);
|
|
|
|
db.DeregisterReceiveCodecs();
|
|
|
|
// All receive codecs must have been removed.
|
|
EXPECT_FALSE(db.DeregisterReceiveCodec(kPayloadType1));
|
|
EXPECT_FALSE(db.DeregisterReceiveCodec(kPayloadType2));
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace webrtc
|