Make sure WebRTC works without libvpx VP9 support.

Wires up existing libvpx_build_vp9==0 GYP flag into WebRTC and makes VP9
optional. Change is GYP only for now since libvpx's GN files build VP9
unconditionally.

BUG=webrtc:5884
R=kjellander@webrtc.org

Review URL: https://codereview.webrtc.org/1970343002 .

Cr-Commit-Position: refs/heads/master@{#12741}
This commit is contained in:
Peter Boström 2016-05-14 02:03:18 +02:00
parent dae07bae82
commit 1299615838
14 changed files with 110 additions and 9 deletions

View File

@ -102,6 +102,7 @@
'build_libjpeg%': 1,
'build_libsrtp%': 1,
'build_libvpx%': 1,
'libvpx_build_vp9%': 1,
'build_libyuv%': 1,
'build_openmax_dl%': 1,
'build_opus%': 1,
@ -447,6 +448,11 @@
'WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE',
],
}],
['libvpx_build_vp9==0', {
'defines': [
'RTC_DISABLE_VP9',
],
}],
], # conditions
'direct_dependent_settings': {
'conditions': [

View File

@ -29,6 +29,7 @@
#include "webrtc/media/engine/webrtcvoiceengine.h"
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
#include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h"
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
#include "webrtc/system_wrappers/include/field_trial.h"
#include "webrtc/video_decoder.h"
#include "webrtc/video_encoder.h"
@ -159,7 +160,8 @@ bool CodecIsInternallySupported(const std::string& codec_name) {
return true;
}
if (CodecNamesEq(codec_name, kVp9CodecName)) {
return true;
return webrtc::VP9Encoder::IsSupported() &&
webrtc::VP9Decoder::IsSupported();
}
if (CodecNamesEq(codec_name, kH264CodecName)) {
return webrtc::H264Encoder::IsSupported() &&

View File

@ -150,6 +150,21 @@ class WebRtcVideoEngine2Test : public ::testing::Test {
std::map<int, int> default_apt_rtx_types_;
};
TEST_F(WebRtcVideoEngine2Test, AnnouncesVp9AccordingToBuildFlags) {
bool claims_vp9_support = false;
for (const cricket::VideoCodec& codec : engine_.codecs()) {
if (codec.name == "VP9") {
claims_vp9_support = true;
break;
}
}
#if defined(RTC_DISABLE_VP9)
EXPECT_FALSE(claims_vp9_support);
#else
EXPECT_TRUE(claims_vp9_support);
#endif // defined(RTC_DISABLE_VP9)
}
TEST_F(WebRtcVideoEngine2Test, DefaultRtxCodecHasAssociatedPayloadTypeSet) {
std::vector<VideoCodec> engine_codecs = engine_.codecs();
for (size_t i = 0; i < engine_codecs.size(); ++i) {
@ -414,6 +429,7 @@ TEST_F(WebRtcVideoEngine2Test, DisablesFullEncoderTimeForNonExternalEncoders) {
TestExtendedEncoderOveruse(false);
}
#if !defined(RTC_DISABLE_VP9)
TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) {
cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
encoder_factory.AddSupportedVideoCodecType(webrtc::kVideoCodecVP9, "VP9");
@ -426,6 +442,7 @@ TEST_F(WebRtcVideoEngine2Test, CanConstructDecoderForVp9EncoderFactory) {
EXPECT_TRUE(
channel->AddRecvStream(cricket::StreamParams::CreateLegacy(kSsrc)));
}
#endif // !defined(RTC_DISABLE_VP9)
TEST_F(WebRtcVideoEngine2Test, PropagatesInputFrameTimestamp) {
cricket::FakeWebRtcVideoEncoderFactory encoder_factory;

View File

@ -63,7 +63,6 @@
'<(webrtc_root)/common.gyp:webrtc_common',
'<(webrtc_root)/common_video/common_video.gyp:common_video',
'<(webrtc_root)/modules/video_coding/codecs/vp8/vp8.gyp:webrtc_vp8',
'<(webrtc_root)/modules/video_coding/codecs/vp9/vp9.gyp:webrtc_vp9',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers',
'<(webrtc_root)/test/metrics.gyp:metrics',
'<(webrtc_root)/test/test.gyp:test_support',
@ -363,7 +362,6 @@
'video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc',
'video_coding/codecs/vp8/simulcast_unittest.cc',
'video_coding/codecs/vp8/simulcast_unittest.h',
'video_coding/codecs/vp9/screenshare_layers_unittest.cc',
'video_coding/include/mock/mock_vcm_callbacks.h',
'video_coding/decoding_state_unittest.cc',
'video_coding/histogram_unittest.cc',
@ -390,6 +388,11 @@
'video_processing/test/video_processing_unittest.h',
],
'conditions': [
['libvpx_build_vp9==1', {
'sources': [
'video_coding/codecs/vp9/screenshare_layers_unittest.cc',
],
}],
['enable_bwe_test_logging==1', {
'defines': [ 'BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1' ],
}, {

View File

@ -626,6 +626,7 @@ TEST_F(VideoProcessorIntegrationTest, Process0PercentPacketLossH264) {
// Fails on iOS. See webrtc:4755.
#if !defined(WEBRTC_IOS)
#if !defined(RTC_DISABLE_VP9)
// VP9: Run with no packet loss and fixed bitrate. Quality should be very high.
// One key frame (first frame only) in sequence. Setting |key_frame_interval|
// to -1 below means no periodic key frames in test.
@ -780,6 +781,8 @@ TEST_F(VideoProcessorIntegrationTest, ProcessNoLossSpatialResizeFrameDropVP9) {
// TODO(marpan): Add temporal layer test for VP9, once changes are in
// vp9 wrapper for this.
#endif // !defined(RTC_DISABLE_VP9)
// VP8: Run with no packet loss and fixed bitrate. Quality should be very high.
// One key frame (first frame only) in sequence. Setting |key_frame_interval|
// to -1 below means no periodic key frames in test.

View File

@ -18,6 +18,7 @@ namespace webrtc {
class VP9Encoder : public VideoEncoder {
public:
static bool IsSupported();
static VP9Encoder* Create();
virtual ~VP9Encoder() {}
@ -25,6 +26,7 @@ class VP9Encoder : public VideoEncoder {
class VP9Decoder : public VideoDecoder {
public:
static bool IsSupported();
static VP9Decoder* Create();
virtual ~VP9Decoder() {}

View File

@ -20,6 +20,21 @@
'<(libvpx_dir)/libvpx.gyp:libvpx',
],
}],
['libvpx_build_vp9==1', {
'sources': [
'screenshare_layers.cc',
'screenshare_layers.h',
'vp9_frame_buffer_pool.cc',
'vp9_frame_buffer_pool.h',
'vp9_impl.cc',
'vp9_impl.h',
],
}, {
'sources': [
'vp9_noop.cc',
],
}
],
],
'dependencies': [
'<(webrtc_root)/common_video/common_video.gyp:common_video',
@ -28,12 +43,6 @@
],
'sources': [
'include/vp9.h',
'screenshare_layers.cc',
'screenshare_layers.h',
'vp9_frame_buffer_pool.cc',
'vp9_frame_buffer_pool.h',
'vp9_impl.cc',
'vp9_impl.h',
],
},
],

View File

@ -47,6 +47,10 @@ int GetCpuSpeed(int width, int height) {
#endif
}
bool VP9Encoder::IsSupported() {
return true;
}
VP9Encoder* VP9Encoder::Create() {
return new VP9EncoderImpl();
}
@ -823,6 +827,10 @@ const char* VP9EncoderImpl::ImplementationName() const {
return "libvpx";
}
bool VP9Decoder::IsSupported() {
return true;
}
VP9Decoder* VP9Decoder::Create() {
return new VP9DecoderImpl();
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2016 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.
*
*/
#if !defined(RTC_DISABLE_VP9)
#error
#endif // !defined(RTC_DISABLE_VP9)
#include "webrtc/base/checks.h"
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
namespace webrtc {
bool VP9Encoder::IsSupported() {
return false;
}
VP9Encoder* VP9Encoder::Create() {
RTC_NOTREACHED();
return nullptr;
}
bool VP9Decoder::IsSupported() {
return false;
}
VP9Decoder* VP9Decoder::Create() {
RTC_NOTREACHED();
return nullptr;
}
} // namespace webrtc

View File

@ -333,6 +333,7 @@ TEST_F(EndToEndTest, SendsAndReceivesVP8Rotation90) {
RunBaseTest(&test);
}
#if !defined(RTC_DISABLE_VP9)
TEST_F(EndToEndTest, SendsAndReceivesVP9) {
CodecObserver test(500, kVideoRotation_0, "VP9",
VideoEncoder::Create(VideoEncoder::kVp9),
@ -346,6 +347,7 @@ TEST_F(EndToEndTest, SendsAndReceivesVP9VideoRotation90) {
VP9Decoder::Create());
RunBaseTest(&test);
}
#endif // !defined(RTC_DISABLE_VP9)
#if defined(WEBRTC_END_TO_END_H264_TESTS)

View File

@ -56,6 +56,7 @@ class FullStackTest : public VideoQualityTest {
// logs // bool
// };
#if !defined(RTC_DISABLE_VP9)
TEST_F(FullStackTest, ForemanCifWithoutPacketLossVp9) {
ForemanCifWithoutPacketLoss("VP9");
}
@ -63,6 +64,7 @@ TEST_F(FullStackTest, ForemanCifWithoutPacketLossVp9) {
TEST_F(FullStackTest, ForemanCifPlr5Vp9) {
ForemanCifPlr5("VP9");
}
#endif // !defined(RTC_DISABLE_VP9)
TEST_F(FullStackTest, ParisQcifWithoutPacketLoss) {
VideoQualityTest::Params paris_qcif = {
@ -200,6 +202,7 @@ TEST_F(FullStackTest, ScreenshareSlidesVP8_2TL_VeryLossyNet) {
RunTest(screenshare);
}
#if !defined(RTC_DISABLE_VP9)
TEST_F(FullStackTest, ScreenshareSlidesVP9_2SL) {
VideoQualityTest::Params screenshare = {
{1850, 1110, 5, 50000, 200000, 2000000, "VP9", 1, 0, 400000},
@ -211,4 +214,5 @@ TEST_F(FullStackTest, ScreenshareSlidesVP9_2SL) {
{std::vector<VideoStream>(), 0, 2, 1}};
RunTest(screenshare);
}
#endif // !defined(RTC_DISABLE_VP9)
} // namespace webrtc

View File

@ -25,6 +25,7 @@ VideoDecoder* VideoDecoder::Create(VideoDecoder::DecoderType codec_type) {
case kVp8:
return VP8Decoder::Create();
case kVp9:
RTC_DCHECK(VP9Decoder::IsSupported());
return VP9Decoder::Create();
case kUnsupportedCodec:
LOG(LS_ERROR) << "Creating NullVideoDecoder for unsupported codec.";

View File

@ -25,6 +25,7 @@ VideoEncoder* VideoEncoder::Create(VideoEncoder::EncoderType codec_type) {
case kVp8:
return VP8Encoder::Create();
case kVp9:
RTC_DCHECK(VP9Encoder::IsSupported());
return VP9Encoder::Create();
case kUnsupportedCodec:
RTC_NOTREACHED();

View File

@ -479,10 +479,12 @@ TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp8WithNackEnabled) {
RunBaseTest(&test);
}
#if !defined(RTC_DISABLE_VP9)
TEST_F(VideoSendStreamTest, DoesUtilizeRedForVp9WithNackEnabled) {
FecObserver test(false, true, true, "VP9");
RunBaseTest(&test);
}
#endif // !defined(RTC_DISABLE_VP9)
void VideoSendStreamTest::TestNackRetransmission(
uint32_t retransmit_ssrc,
@ -1886,6 +1888,7 @@ TEST_F(VideoSendStreamTest, ReportsSentResolution) {
RunBaseTest(&test);
}
#if !defined(RTC_DISABLE_VP9)
class Vp9HeaderObserver : public test::SendTest {
public:
Vp9HeaderObserver()
@ -2293,5 +2296,6 @@ TEST_F(VideoSendStreamTest, Vp9FlexModeRefCount) {
RunBaseTest(&test);
}
#endif // !defined(RTC_DISABLE_VP9)
} // namespace webrtc