2015-05-19 23:09:35 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-11-15 06:30:54 -08:00
|
|
|
#include "webrtc/media/engine/videoencodersoftwarefallbackwrapper.h"
|
|
|
|
|
|
|
|
|
|
#include <utility>
|
2015-05-19 23:09:35 +02:00
|
|
|
|
2017-01-10 07:44:26 -08:00
|
|
|
#include "webrtc/api/video/i420_buffer.h"
|
2017-03-08 05:42:26 -08:00
|
|
|
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h"
|
2016-11-16 16:41:30 +01:00
|
|
|
#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
|
2016-09-01 00:21:16 -07:00
|
|
|
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
2015-11-18 22:00:21 +01:00
|
|
|
#include "webrtc/modules/video_coding/include/video_error_codes.h"
|
2017-07-06 19:44:34 +02:00
|
|
|
#include "webrtc/rtc_base/checks.h"
|
2016-09-30 22:29:43 -07:00
|
|
|
#include "webrtc/test/gtest.h"
|
2015-05-19 23:09:35 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-10-21 23:54:51 -07:00
|
|
|
const int kWidth = 320;
|
|
|
|
|
const int kHeight = 240;
|
2015-05-19 23:09:35 +02:00
|
|
|
const size_t kMaxPayloadSize = 800;
|
|
|
|
|
|
|
|
|
|
class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test {
|
|
|
|
|
protected:
|
|
|
|
|
VideoEncoderSoftwareFallbackWrapperTest()
|
Reland of Stop using hardcoded payload types for video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2513633002/ )
Reason for revert:
The WebRtcBrowserTest.NegotiateUnsupportedVideoCodec test has been fixed in Chromium with the following change:
function removeVideoCodec(offerSdp) {
- offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n',
- 'a=rtpmap:100 XVP8/90000\r\n');
+ offerSdp = offerSdp.replace(/a=rtpmap:(\d+)\ VP8\/90000\r\n/,
+ 'a=rtpmap:$1 XVP8/90000\r\n');
return offerSdp;
}
Original issue's description:
> Revert of Stop using hardcoded payload types for video codecs (patchset #6 id:210001 of https://codereview.webrtc.org/2493133002/ )
>
> Reason for revert:
> Breaks chromium.fyi test:
> WebRtcBrowserTest.NegotiateUnsupportedVideoCodec
>
> Original issue's description:
> > Stop using hardcoded payload types for video codecs
> >
> > This CL stops using hardcoded payload types for different video codecs
> > and will dynamically assign them payload types incrementally from 96 to
> > 127 instead.
> >
> > This CL:
> > * Replaces 'std::vector<VideoCodec> DefaultVideoCodecList()' in
> > webrtcvideoengine2.cc with an explicit WebRtcVideoEncoderFactory for
> > internally supported software codecs instead. The purpose is to
> > streamline the payload type assignment in webrtcvideoengine2.cc which
> > will now have two encoder factories of the same
> > WebRtcVideoEncoderFactory type; one internal and one external.
> > * Removes webrtc::VideoEncoder::EncoderType and use cricket::VideoCodec
> > instead.
> > * Removes 'static VideoEncoder* Create(EncoderType codec_type)' and
> > moves the create function to the internal encoder factory instead.
> > * Removes video_encoder.cc. webrtc::VideoEncoder is now just an
> > interface without any static functions.
> > * The function GetSupportedCodecs in webrtcvideoengine2.cc unifies
> > the internal and external codecs and assigns them payload types
> > incrementally from 96 to 127.
> > * Updates webrtcvideoengine2_unittest.cc and removes assumptions about
> > what payload types will be used.
> >
> > BUG=webrtc:6677,webrtc:6705
> > R=hta@webrtc.org, ossu@webrtc.org, stefan@webrtc.org
> >
> > Committed: https://crrev.com/42043b95872b51321f508bf255d804ce3dff366b
> > Cr-Commit-Position: refs/heads/master@{#15135}
>
> TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6677,webrtc:6705
>
> Committed: https://crrev.com/eacbaea920797ff751ca83050d140821f5055591
> Cr-Commit-Position: refs/heads/master@{#15140}
TBR=hta@webrtc.org,stefan@webrtc.org,ossu@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6677,webrtc:6705
Review-Url: https://codereview.webrtc.org/2511933002
Cr-Commit-Position: refs/heads/master@{#15148}
2016-11-18 01:34:11 -08:00
|
|
|
: fallback_wrapper_(cricket::VideoCodec("VP8"), &fake_encoder_) {}
|
2015-05-19 23:09:35 +02:00
|
|
|
|
|
|
|
|
class CountingFakeEncoder : public VideoEncoder {
|
|
|
|
|
public:
|
|
|
|
|
int32_t InitEncode(const VideoCodec* codec_settings,
|
|
|
|
|
int32_t number_of_cores,
|
|
|
|
|
size_t max_payload_size) override {
|
|
|
|
|
++init_encode_count_;
|
|
|
|
|
return init_encode_return_code_;
|
|
|
|
|
}
|
2015-05-29 17:21:40 -07:00
|
|
|
int32_t Encode(const VideoFrame& frame,
|
2015-05-19 23:09:35 +02:00
|
|
|
const CodecSpecificInfo* codec_specific_info,
|
2015-10-19 02:39:06 -07:00
|
|
|
const std::vector<FrameType>* frame_types) override {
|
2015-05-19 23:09:35 +02:00
|
|
|
++encode_count_;
|
2016-09-01 00:21:16 -07:00
|
|
|
if (encode_complete_callback_ &&
|
|
|
|
|
encode_return_code_ == WEBRTC_VIDEO_CODEC_OK) {
|
|
|
|
|
CodecSpecificInfo info;
|
|
|
|
|
info.codec_name = ImplementationName();
|
|
|
|
|
encode_complete_callback_->OnEncodedImage(EncodedImage(), &info,
|
|
|
|
|
nullptr);
|
|
|
|
|
}
|
2015-10-21 23:54:51 -07:00
|
|
|
return encode_return_code_;
|
2015-05-19 23:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t RegisterEncodeCompleteCallback(
|
|
|
|
|
EncodedImageCallback* callback) override {
|
|
|
|
|
encode_complete_callback_ = callback;
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t Release() override {
|
|
|
|
|
++release_count_;
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t SetChannelParameters(uint32_t packet_loss, int64_t rtt) override {
|
|
|
|
|
++set_channel_parameters_count_;
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 16:41:30 +01:00
|
|
|
int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
|
|
|
|
|
uint32_t framerate) override {
|
2015-05-19 23:09:35 +02:00
|
|
|
++set_rates_count_;
|
|
|
|
|
return WEBRTC_VIDEO_CODEC_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-05 11:08:03 +02:00
|
|
|
bool SupportsNativeHandle() const override {
|
|
|
|
|
++supports_native_handle_count_;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
const char* ImplementationName() const override {
|
|
|
|
|
return "fake-encoder";
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-19 23:09:35 +02:00
|
|
|
int init_encode_count_ = 0;
|
|
|
|
|
int32_t init_encode_return_code_ = WEBRTC_VIDEO_CODEC_OK;
|
2015-10-21 23:54:51 -07:00
|
|
|
int32_t encode_return_code_ = WEBRTC_VIDEO_CODEC_OK;
|
2015-05-19 23:09:35 +02:00
|
|
|
int encode_count_ = 0;
|
|
|
|
|
EncodedImageCallback* encode_complete_callback_ = nullptr;
|
|
|
|
|
int release_count_ = 0;
|
|
|
|
|
int set_channel_parameters_count_ = 0;
|
|
|
|
|
int set_rates_count_ = 0;
|
2015-06-05 11:08:03 +02:00
|
|
|
mutable int supports_native_handle_count_ = 0;
|
2015-05-19 23:09:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class FakeEncodedImageCallback : public EncodedImageCallback {
|
|
|
|
|
public:
|
2016-08-02 17:46:41 -07:00
|
|
|
Result OnEncodedImage(
|
|
|
|
|
const EncodedImage& encoded_image,
|
|
|
|
|
const CodecSpecificInfo* codec_specific_info,
|
|
|
|
|
const RTPFragmentationHeader* fragmentation) override {
|
|
|
|
|
++callback_count_;
|
2016-09-01 00:21:16 -07:00
|
|
|
last_codec_name_ = codec_specific_info->codec_name;
|
2016-08-02 17:46:41 -07:00
|
|
|
return Result(Result::OK, callback_count_);
|
2015-05-19 23:09:35 +02:00
|
|
|
}
|
|
|
|
|
int callback_count_ = 0;
|
2016-09-01 00:21:16 -07:00
|
|
|
std::string last_codec_name_;
|
2015-05-19 23:09:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void UtilizeFallbackEncoder();
|
2015-10-21 23:54:51 -07:00
|
|
|
void FallbackFromEncodeRequest();
|
|
|
|
|
void EncodeFrame();
|
2016-09-01 00:21:16 -07:00
|
|
|
void CheckLastEncoderName(const char* expected_name) {
|
|
|
|
|
EXPECT_STREQ(expected_name, callback_.last_codec_name_.c_str());
|
|
|
|
|
}
|
2015-05-19 23:09:35 +02:00
|
|
|
|
|
|
|
|
FakeEncodedImageCallback callback_;
|
|
|
|
|
CountingFakeEncoder fake_encoder_;
|
|
|
|
|
VideoEncoderSoftwareFallbackWrapper fallback_wrapper_;
|
|
|
|
|
VideoCodec codec_ = {};
|
Reland of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #1 id:1 of https://codereview.webrtc.org/2354223002/ )
Reason for revert:
Downstream application now fixed.
Original issue's description:
> Revert of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #14 id:260001 of https://codereview.webrtc.org/2278883002/ )
>
> Reason for revert:
> Broke downstream application.
>
> Original issue's description:
> > Move MutableDataY{,U,V} methods to I420Buffer only.
> >
> > Deleted from the VideoFrameBuffer base class.
> >
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/5539ef6c03c273f39fadae41ace47fdc11ac6d60
> > Cr-Commit-Position: refs/heads/master@{#14317}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/776870a2599b8f43ad56987f9031690e3ccecde8
> Cr-Commit-Position: refs/heads/master@{#14325}
TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2372483002
Cr-Commit-Position: refs/heads/master@{#14389}
2016-09-27 00:17:25 -07:00
|
|
|
std::unique_ptr<VideoFrame> frame_;
|
2016-11-16 16:41:30 +01:00
|
|
|
std::unique_ptr<SimulcastRateAllocator> rate_allocator_;
|
2015-05-19 23:09:35 +02:00
|
|
|
};
|
|
|
|
|
|
2015-10-21 23:54:51 -07:00
|
|
|
void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() {
|
2017-06-14 11:28:08 +02:00
|
|
|
rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(kWidth, kHeight);
|
2017-01-10 07:44:26 -08:00
|
|
|
I420Buffer::SetBlack(buffer);
|
2016-09-21 03:52:16 -07:00
|
|
|
std::vector<FrameType> types(1, kVideoFrameKey);
|
Reland of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #1 id:1 of https://codereview.webrtc.org/2354223002/ )
Reason for revert:
Downstream application now fixed.
Original issue's description:
> Revert of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #14 id:260001 of https://codereview.webrtc.org/2278883002/ )
>
> Reason for revert:
> Broke downstream application.
>
> Original issue's description:
> > Move MutableDataY{,U,V} methods to I420Buffer only.
> >
> > Deleted from the VideoFrameBuffer base class.
> >
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/5539ef6c03c273f39fadae41ace47fdc11ac6d60
> > Cr-Commit-Position: refs/heads/master@{#14317}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/776870a2599b8f43ad56987f9031690e3ccecde8
> Cr-Commit-Position: refs/heads/master@{#14325}
TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2372483002
Cr-Commit-Position: refs/heads/master@{#14389}
2016-09-27 00:17:25 -07:00
|
|
|
|
|
|
|
|
frame_.reset(new VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0));
|
2015-10-21 23:54:51 -07:00
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
Reland of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #1 id:1 of https://codereview.webrtc.org/2354223002/ )
Reason for revert:
Downstream application now fixed.
Original issue's description:
> Revert of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #14 id:260001 of https://codereview.webrtc.org/2278883002/ )
>
> Reason for revert:
> Broke downstream application.
>
> Original issue's description:
> > Move MutableDataY{,U,V} methods to I420Buffer only.
> >
> > Deleted from the VideoFrameBuffer base class.
> >
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/5539ef6c03c273f39fadae41ace47fdc11ac6d60
> > Cr-Commit-Position: refs/heads/master@{#14317}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/776870a2599b8f43ad56987f9031690e3ccecde8
> Cr-Commit-Position: refs/heads/master@{#14325}
TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2372483002
Cr-Commit-Position: refs/heads/master@{#14389}
2016-09-27 00:17:25 -07:00
|
|
|
fallback_wrapper_.Encode(*frame_, nullptr, &types));
|
2015-10-21 23:54:51 -07:00
|
|
|
}
|
|
|
|
|
|
2015-05-19 23:09:35 +02:00
|
|
|
void VideoEncoderSoftwareFallbackWrapperTest::UtilizeFallbackEncoder() {
|
|
|
|
|
fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_);
|
|
|
|
|
EXPECT_EQ(&callback_, fake_encoder_.encode_complete_callback_);
|
|
|
|
|
|
|
|
|
|
// Register with failing fake encoder. Should succeed with VP8 fallback.
|
|
|
|
|
codec_.codecType = kVideoCodecVP8;
|
|
|
|
|
codec_.maxFramerate = 30;
|
|
|
|
|
codec_.width = kWidth;
|
|
|
|
|
codec_.height = kHeight;
|
2016-11-16 16:41:30 +01:00
|
|
|
codec_.VP8()->numberOfTemporalLayers = 1;
|
|
|
|
|
std::unique_ptr<TemporalLayersFactory> tl_factory(
|
|
|
|
|
new TemporalLayersFactory());
|
|
|
|
|
codec_.VP8()->tl_factory = tl_factory.get();
|
|
|
|
|
rate_allocator_.reset(
|
|
|
|
|
new SimulcastRateAllocator(codec_, std::move(tl_factory)));
|
|
|
|
|
|
2015-05-19 23:09:35 +02:00
|
|
|
fake_encoder_.init_encode_return_code_ = WEBRTC_VIDEO_CODEC_ERROR;
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
|
|
|
fallback_wrapper_.InitEncode(&codec_, 2, kMaxPayloadSize));
|
2016-11-16 16:41:30 +01:00
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
|
|
|
fallback_wrapper_.SetRateAllocation(
|
|
|
|
|
rate_allocator_->GetAllocation(300000, 30), 30));
|
2015-05-19 23:09:35 +02:00
|
|
|
|
2015-10-21 23:54:51 -07:00
|
|
|
int callback_count = callback_.callback_count_;
|
|
|
|
|
int encode_count = fake_encoder_.encode_count_;
|
|
|
|
|
EncodeFrame();
|
|
|
|
|
EXPECT_EQ(encode_count, fake_encoder_.encode_count_);
|
|
|
|
|
EXPECT_EQ(callback_count + 1, callback_.callback_count_);
|
|
|
|
|
}
|
2015-05-19 23:09:35 +02:00
|
|
|
|
2015-10-21 23:54:51 -07:00
|
|
|
void VideoEncoderSoftwareFallbackWrapperTest::FallbackFromEncodeRequest() {
|
|
|
|
|
fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_);
|
|
|
|
|
codec_.codecType = kVideoCodecVP8;
|
|
|
|
|
codec_.maxFramerate = 30;
|
|
|
|
|
codec_.width = kWidth;
|
|
|
|
|
codec_.height = kHeight;
|
2016-11-16 16:41:30 +01:00
|
|
|
codec_.VP8()->numberOfTemporalLayers = 1;
|
|
|
|
|
std::unique_ptr<TemporalLayersFactory> tl_factory(
|
|
|
|
|
new TemporalLayersFactory());
|
|
|
|
|
codec_.VP8()->tl_factory = tl_factory.get();
|
|
|
|
|
rate_allocator_.reset(
|
|
|
|
|
new SimulcastRateAllocator(codec_, std::move(tl_factory)));
|
2015-10-21 23:54:51 -07:00
|
|
|
fallback_wrapper_.InitEncode(&codec_, 2, kMaxPayloadSize);
|
2016-11-16 16:41:30 +01:00
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
|
|
|
|
fallback_wrapper_.SetRateAllocation(
|
|
|
|
|
rate_allocator_->GetAllocation(300000, 30), 30));
|
2015-10-21 23:54:51 -07:00
|
|
|
EXPECT_EQ(1, fake_encoder_.init_encode_count_);
|
|
|
|
|
|
|
|
|
|
// Have the non-fallback encoder request a software fallback.
|
|
|
|
|
fake_encoder_.encode_return_code_ = WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
|
|
|
|
|
int callback_count = callback_.callback_count_;
|
|
|
|
|
int encode_count = fake_encoder_.encode_count_;
|
|
|
|
|
EncodeFrame();
|
|
|
|
|
// Single encode request, which returned failure.
|
|
|
|
|
EXPECT_EQ(encode_count + 1, fake_encoder_.encode_count_);
|
|
|
|
|
EXPECT_EQ(callback_count + 1, callback_.callback_count_);
|
2015-05-19 23:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest, InitializesEncoder) {
|
|
|
|
|
VideoCodec codec = {};
|
|
|
|
|
fallback_wrapper_.InitEncode(&codec, 2, kMaxPayloadSize);
|
|
|
|
|
EXPECT_EQ(1, fake_encoder_.init_encode_count_);
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-21 23:54:51 -07:00
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest, EncodeRequestsFallback) {
|
|
|
|
|
FallbackFromEncodeRequest();
|
|
|
|
|
// After fallback, further encodes shouldn't hit the fake encoder.
|
|
|
|
|
int encode_count = fake_encoder_.encode_count_;
|
|
|
|
|
EncodeFrame();
|
|
|
|
|
EXPECT_EQ(encode_count, fake_encoder_.encode_count_);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-19 23:09:35 +02:00
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest, CanUtilizeFallbackEncoder) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
2015-10-21 23:54:51 -07:00
|
|
|
InternalEncoderReleasedDuringFallback) {
|
|
|
|
|
EXPECT_EQ(0, fake_encoder_.release_count_);
|
2015-05-19 23:09:35 +02:00
|
|
|
UtilizeFallbackEncoder();
|
2015-10-21 23:54:51 -07:00
|
|
|
EXPECT_EQ(1, fake_encoder_.release_count_);
|
2015-05-19 23:09:35 +02:00
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
2015-10-21 23:54:51 -07:00
|
|
|
// No extra release when the fallback is released.
|
|
|
|
|
EXPECT_EQ(1, fake_encoder_.release_count_);
|
2015-05-19 23:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
InternalEncoderNotEncodingDuringFallback) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
2015-10-21 23:54:51 -07:00
|
|
|
int encode_count = fake_encoder_.encode_count_;
|
|
|
|
|
EncodeFrame();
|
|
|
|
|
EXPECT_EQ(encode_count, fake_encoder_.encode_count_);
|
2015-05-19 23:09:35 +02:00
|
|
|
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
CanRegisterCallbackWhileUsingFallbackEncoder) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
|
|
|
|
// Registering an encode-complete callback should still work when fallback
|
|
|
|
|
// encoder is being used.
|
|
|
|
|
FakeEncodedImageCallback callback2;
|
|
|
|
|
fallback_wrapper_.RegisterEncodeCompleteCallback(&callback2);
|
|
|
|
|
EXPECT_EQ(&callback2, fake_encoder_.encode_complete_callback_);
|
|
|
|
|
|
|
|
|
|
// Encoding a frame using the fallback should arrive at the new callback.
|
2015-10-23 15:58:18 +02:00
|
|
|
std::vector<FrameType> types(1, kVideoFrameKey);
|
Reland of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #1 id:1 of https://codereview.webrtc.org/2354223002/ )
Reason for revert:
Downstream application now fixed.
Original issue's description:
> Revert of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #14 id:260001 of https://codereview.webrtc.org/2278883002/ )
>
> Reason for revert:
> Broke downstream application.
>
> Original issue's description:
> > Move MutableDataY{,U,V} methods to I420Buffer only.
> >
> > Deleted from the VideoFrameBuffer base class.
> >
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/5539ef6c03c273f39fadae41ace47fdc11ac6d60
> > Cr-Commit-Position: refs/heads/master@{#14317}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/776870a2599b8f43ad56987f9031690e3ccecde8
> Cr-Commit-Position: refs/heads/master@{#14325}
TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2372483002
Cr-Commit-Position: refs/heads/master@{#14389}
2016-09-27 00:17:25 -07:00
|
|
|
frame_->set_timestamp(frame_->timestamp() + 1000);
|
2015-05-19 23:09:35 +02:00
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
|
Reland of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #1 id:1 of https://codereview.webrtc.org/2354223002/ )
Reason for revert:
Downstream application now fixed.
Original issue's description:
> Revert of Move MutableDataY{,U,V} methods to I420Buffer only. (patchset #14 id:260001 of https://codereview.webrtc.org/2278883002/ )
>
> Reason for revert:
> Broke downstream application.
>
> Original issue's description:
> > Move MutableDataY{,U,V} methods to I420Buffer only.
> >
> > Deleted from the VideoFrameBuffer base class.
> >
> > BUG=webrtc:5921
> >
> > Committed: https://crrev.com/5539ef6c03c273f39fadae41ace47fdc11ac6d60
> > Cr-Commit-Position: refs/heads/master@{#14317}
>
> TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:5921
>
> Committed: https://crrev.com/776870a2599b8f43ad56987f9031690e3ccecde8
> Cr-Commit-Position: refs/heads/master@{#14325}
TBR=perkj@webrtc.org,magjed@webrtc.org,pthatcher@webrtc.org,honghaiz@webrtc.org,stefan@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:5921
Review-Url: https://codereview.webrtc.org/2372483002
Cr-Commit-Position: refs/heads/master@{#14389}
2016-09-27 00:17:25 -07:00
|
|
|
fallback_wrapper_.Encode(*frame_, nullptr, &types));
|
2015-05-19 23:09:35 +02:00
|
|
|
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
SetChannelParametersForwardedDuringFallback) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
|
|
|
|
EXPECT_EQ(0, fake_encoder_.set_channel_parameters_count_);
|
|
|
|
|
fallback_wrapper_.SetChannelParameters(1, 1);
|
|
|
|
|
EXPECT_EQ(1, fake_encoder_.set_channel_parameters_count_);
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
SetRatesForwardedDuringFallback) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
|
|
|
|
EXPECT_EQ(1, fake_encoder_.set_rates_count_);
|
2016-11-16 16:41:30 +01:00
|
|
|
fallback_wrapper_.SetRateAllocation(BitrateAllocation(), 1);
|
2015-05-19 23:09:35 +02:00
|
|
|
EXPECT_EQ(2, fake_encoder_.set_rates_count_);
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-05 11:08:03 +02:00
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
SupportsNativeHandleForwardedWithoutFallback) {
|
|
|
|
|
fallback_wrapper_.SupportsNativeHandle();
|
|
|
|
|
EXPECT_EQ(1, fake_encoder_.supports_native_handle_count_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
SupportsNativeHandleNotForwardedDuringFallback) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
|
|
|
|
fallback_wrapper_.SupportsNativeHandle();
|
|
|
|
|
EXPECT_EQ(0, fake_encoder_.supports_native_handle_count_);
|
|
|
|
|
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release());
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-01 00:21:16 -07:00
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest, ReportsImplementationName) {
|
|
|
|
|
VideoCodec codec = {};
|
|
|
|
|
fallback_wrapper_.RegisterEncodeCompleteCallback(&callback_);
|
|
|
|
|
fallback_wrapper_.InitEncode(&codec, 2, kMaxPayloadSize);
|
|
|
|
|
EncodeFrame();
|
|
|
|
|
CheckLastEncoderName("fake-encoder");
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-18 16:01:11 +01:00
|
|
|
TEST_F(VideoEncoderSoftwareFallbackWrapperTest,
|
|
|
|
|
ReportsFallbackImplementationName) {
|
|
|
|
|
UtilizeFallbackEncoder();
|
|
|
|
|
// Hard coded expected value since libvpx is the software implementation name
|
|
|
|
|
// for VP8. Change accordingly if the underlying implementation does.
|
2016-09-01 00:21:16 -07:00
|
|
|
CheckLastEncoderName("libvpx");
|
2015-12-18 16:01:11 +01:00
|
|
|
}
|
|
|
|
|
|
2015-05-19 23:09:35 +02:00
|
|
|
} // namespace webrtc
|