Pass SDP video parameters to encoder.
Bug: webrtc:11265 Change-Id: I4f3373793de697e9d89c22ba2d9be4bfe571beea Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167201 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30359}
This commit is contained in:

committed by
Commit Bot

parent
7aa2edf936
commit
897776e36c
@ -243,7 +243,8 @@ int SimulcastEncoderAdapter::InitEncode(
|
||||
RTC_DCHECK_LT(highest_resolution_stream_index, number_of_streams);
|
||||
|
||||
const SdpVideoFormat format(
|
||||
codec_.codecType == webrtc::kVideoCodecVP8 ? "VP8" : "H264");
|
||||
codec_.codecType == webrtc::kVideoCodecVP8 ? "VP8" : "H264",
|
||||
video_format_.parameters);
|
||||
|
||||
for (int i = 0; i < number_of_streams; ++i) {
|
||||
// If an existing encoder instance exists, reuse it.
|
||||
|
@ -196,6 +196,7 @@ class MockVideoEncoder : public VideoEncoder {
|
||||
explicit MockVideoEncoder(MockVideoEncoderFactory* factory)
|
||||
: factory_(factory),
|
||||
scaling_settings_(VideoEncoder::ScalingSettings::kOff),
|
||||
video_format_("unknown"),
|
||||
callback_(nullptr) {}
|
||||
|
||||
MOCK_METHOD1(SetFecControllerOverride,
|
||||
@ -298,8 +299,14 @@ class MockVideoEncoder : public VideoEncoder {
|
||||
supports_simulcast_ = supports_simulcast;
|
||||
}
|
||||
|
||||
void set_video_format(const SdpVideoFormat& video_format) {
|
||||
video_format_ = video_format;
|
||||
}
|
||||
|
||||
bool supports_simulcast() const { return supports_simulcast_; }
|
||||
|
||||
SdpVideoFormat video_format() const { return video_format_; }
|
||||
|
||||
private:
|
||||
MockVideoEncoderFactory* const factory_;
|
||||
bool supports_native_handle_ = false;
|
||||
@ -313,6 +320,7 @@ class MockVideoEncoder : public VideoEncoder {
|
||||
VideoEncoder::RateControlParameters last_set_rates_;
|
||||
FramerateFractions fps_allocation_;
|
||||
bool supports_simulcast_ = false;
|
||||
SdpVideoFormat video_format_;
|
||||
|
||||
VideoCodec codec_;
|
||||
EncodedImageCallback* callback_;
|
||||
@ -337,6 +345,7 @@ std::unique_ptr<VideoEncoder> MockVideoEncoderFactory::CreateVideoEncoder(
|
||||
encoder->set_requested_resolution_alignment(
|
||||
requested_resolution_alignments_[encoders_.size()]);
|
||||
encoder->set_supports_simulcast(supports_simulcast_);
|
||||
encoder->set_video_format(format);
|
||||
encoders_.push_back(encoder.get());
|
||||
return encoder;
|
||||
}
|
||||
@ -369,16 +378,19 @@ void MockVideoEncoderFactory::set_init_encode_return_value(int32_t value) {
|
||||
|
||||
class TestSimulcastEncoderAdapterFakeHelper {
|
||||
public:
|
||||
explicit TestSimulcastEncoderAdapterFakeHelper(bool use_fallback_factory)
|
||||
explicit TestSimulcastEncoderAdapterFakeHelper(
|
||||
bool use_fallback_factory,
|
||||
const SdpVideoFormat& video_format)
|
||||
: primary_factory_(new MockVideoEncoderFactory()),
|
||||
fallback_factory_(use_fallback_factory ? new MockVideoEncoderFactory()
|
||||
: nullptr) {}
|
||||
: nullptr),
|
||||
video_format_(video_format) {}
|
||||
|
||||
// Can only be called once as the SimulcastEncoderAdapter will take the
|
||||
// ownership of |factory_|.
|
||||
VideoEncoder* CreateMockEncoderAdapter() {
|
||||
return new SimulcastEncoderAdapter(
|
||||
primary_factory_.get(), fallback_factory_.get(), SdpVideoFormat("VP8"));
|
||||
return new SimulcastEncoderAdapter(primary_factory_.get(),
|
||||
fallback_factory_.get(), video_format_);
|
||||
}
|
||||
|
||||
MockVideoEncoderFactory* factory() { return primary_factory_.get(); }
|
||||
@ -389,6 +401,7 @@ class TestSimulcastEncoderAdapterFakeHelper {
|
||||
private:
|
||||
std::unique_ptr<MockVideoEncoderFactory> primary_factory_;
|
||||
std::unique_ptr<MockVideoEncoderFactory> fallback_factory_;
|
||||
SdpVideoFormat video_format_;
|
||||
};
|
||||
|
||||
static const int kTestTemporalLayerProfile[3] = {3, 2, 1};
|
||||
@ -410,7 +423,7 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
|
||||
|
||||
void SetUp() override {
|
||||
helper_ = std::make_unique<TestSimulcastEncoderAdapterFakeHelper>(
|
||||
use_fallback_factory_);
|
||||
use_fallback_factory_, SdpVideoFormat("VP8", sdp_video_parameters_));
|
||||
adapter_.reset(helper_->CreateMockEncoderAdapter());
|
||||
last_encoded_image_width_ = -1;
|
||||
last_encoded_image_height_ = -1;
|
||||
@ -528,6 +541,7 @@ class TestSimulcastEncoderAdapterFake : public ::testing::Test,
|
||||
int last_encoded_image_simulcast_index_;
|
||||
std::unique_ptr<SimulcastRateAllocator> rate_allocator_;
|
||||
bool use_fallback_factory_;
|
||||
SdpVideoFormat::Parameters sdp_video_parameters_;
|
||||
};
|
||||
|
||||
TEST_F(TestSimulcastEncoderAdapterFake, InitEncode) {
|
||||
@ -1323,6 +1337,16 @@ TEST_F(TestSimulcastEncoderAdapterFake, SupportsSimulcast) {
|
||||
EXPECT_EQ(0, adapter_->Encode(input_frame, &frame_types));
|
||||
}
|
||||
|
||||
TEST_F(TestSimulcastEncoderAdapterFake, PassesSdpVideoFormatToEncoder) {
|
||||
sdp_video_parameters_ = {{"test_param", "test_value"}};
|
||||
SetUp();
|
||||
SetupCodec();
|
||||
std::vector<MockVideoEncoder*> encoders = helper_->factory()->encoders();
|
||||
ASSERT_GT(encoders.size(), 0u);
|
||||
EXPECT_EQ(encoders[0]->video_format(),
|
||||
SdpVideoFormat("VP8", sdp_video_parameters_));
|
||||
}
|
||||
|
||||
TEST_F(TestSimulcastEncoderAdapterFake, SupportsFallback) {
|
||||
// Enable support for fallback encoder factory and re-setup.
|
||||
use_fallback_factory_ = true;
|
||||
|
Reference in New Issue
Block a user