From ceecea4559894d680daa689eef3677a612c9e7ec Mon Sep 17 00:00:00 2001 From: magjed Date: Mon, 28 Nov 2016 07:20:21 -0800 Subject: [PATCH] Pass selected cricket::VideoCodec down to internal H264 encoder Pass the selected cricket::VideoCodec to H264EncoderImpl::H264EncoderImpl. The cricket::VideoCodec contains relevant information for H264 about selected profile and packetization mode. BUG=chromium:600254,webrtc:6402, webrtc:6337 Review-Url: https://codereview.webrtc.org/2474993002 Cr-Commit-Position: refs/heads/master@{#15270} --- webrtc/media/engine/internalencoderfactory.cc | 2 +- webrtc/modules/BUILD.gn | 1 + webrtc/modules/video_coding/DEPS | 1 + webrtc/modules/video_coding/codecs/h264/h264.cc | 2 +- .../modules/video_coding/codecs/h264/include/h264.h | 13 ++----------- .../codecs/test/videoprocessor_integrationtest.cc | 2 +- webrtc/video/BUILD.gn | 2 ++ webrtc/video/end_to_end_tests.cc | 6 ++++-- webrtc/video/video_quality_test.cc | 2 +- 9 files changed, 14 insertions(+), 17 deletions(-) diff --git a/webrtc/media/engine/internalencoderfactory.cc b/webrtc/media/engine/internalencoderfactory.cc index db30b668d2..e714e5a5d8 100644 --- a/webrtc/media/engine/internalencoderfactory.cc +++ b/webrtc/media/engine/internalencoderfactory.cc @@ -69,7 +69,7 @@ webrtc::VideoEncoder* InternalEncoderFactory::CreateVideoEncoder( .value_or(webrtc::kVideoCodecUnknown); switch (codec_type) { case webrtc::kVideoCodecH264: - return webrtc::H264Encoder::Create(); + return webrtc::H264Encoder::Create(codec); case webrtc::kVideoCodecVP8: return webrtc::VP8Encoder::Create(); case webrtc::kVideoCodecVP9: diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index 3846c6379f..1708c15988 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -66,6 +66,7 @@ if (rtc_include_tests) { deps = [ "..:webrtc_common", "../common_video", + "../media:rtc_media_base", "../modules/audio_coding", "../modules/audio_coding:audio_format_conversion", "../modules/rtp_rtcp", diff --git a/webrtc/modules/video_coding/DEPS b/webrtc/modules/video_coding/DEPS index 512a0d8277..d8e3c22cd6 100644 --- a/webrtc/modules/video_coding/DEPS +++ b/webrtc/modules/video_coding/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+vpx", "+webrtc/base", "+webrtc/common_video", + "+webrtc/media/base", "+webrtc/system_wrappers", "+webrtc/tools", ] diff --git a/webrtc/modules/video_coding/codecs/h264/h264.cc b/webrtc/modules/video_coding/codecs/h264/h264.cc index bbff225d1c..f03a83d781 100644 --- a/webrtc/modules/video_coding/codecs/h264/h264.cc +++ b/webrtc/modules/video_coding/codecs/h264/h264.cc @@ -44,7 +44,7 @@ bool IsH264CodecSupported() { #endif } -H264Encoder* H264Encoder::Create() { +H264Encoder* H264Encoder::Create(const cricket::VideoCodec& codec) { RTC_DCHECK(H264Encoder::IsSupported()); #if defined(WEBRTC_USE_H264) RTC_CHECK(g_rtc_use_h264); diff --git a/webrtc/modules/video_coding/codecs/h264/include/h264.h b/webrtc/modules/video_coding/codecs/h264/include/h264.h index 467845de8f..2d92473ab5 100644 --- a/webrtc/modules/video_coding/codecs/h264/include/h264.h +++ b/webrtc/modules/video_coding/codecs/h264/include/h264.h @@ -12,16 +12,7 @@ #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_H_ #define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_INCLUDE_H264_H_ -#if defined(WEBRTC_IOS) || defined(WEBRTC_MAC) - -#include -#if defined(WEBRTC_IOS) || \ - defined(__MAC_10_8) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_8 -#define WEBRTC_VIDEO_TOOLBOX_SUPPORTED 1 -#endif - -#endif // defined(WEBRTC_IOS) || defined(WEBRTC_MAC) - +#include "webrtc/media/base/codec.h" #include "webrtc/modules/video_coding/include/video_codec_interface.h" namespace webrtc { @@ -34,7 +25,7 @@ void DisableRtcUseH264(); class H264Encoder : public VideoEncoder { public: - static H264Encoder* Create(); + static H264Encoder* Create(const cricket::VideoCodec& codec); // If H.264 is supported (any implementation). static bool IsSupported(); diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc index 45d915bd59..dc0011d31f 100644 --- a/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc +++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.cc @@ -155,7 +155,7 @@ class VideoProcessorIntegrationTest : public testing::Test { void SetUpCodecConfig() { if (codec_type_ == kVideoCodecH264) { - encoder_ = H264Encoder::Create(); + encoder_ = H264Encoder::Create(cricket::VideoCodec("H264")); decoder_ = H264Decoder::Create(); VideoCodingModule::Codec(kVideoCodecH264, &codec_settings_); } else if (codec_type_ == kVideoCodecVP8) { diff --git a/webrtc/video/BUILD.gn b/webrtc/video/BUILD.gn index aa6730e3f5..8a99fbf9bd 100644 --- a/webrtc/video/BUILD.gn +++ b/webrtc/video/BUILD.gn @@ -83,6 +83,7 @@ if (rtc_include_tests) { "video_quality_test.h", ] deps = [ + "../media:rtc_media_base", "../system_wrappers", "//testing/gtest", ] @@ -162,6 +163,7 @@ if (rtc_include_tests) { ] deps = [ ":video", + "../media:rtc_media_base", "//testing/gmock", "//testing/gtest", ] diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc index e406d0fab2..e88977abdd 100644 --- a/webrtc/video/end_to_end_tests.cc +++ b/webrtc/video/end_to_end_tests.cc @@ -374,13 +374,15 @@ TEST_F(EndToEndTest, SendsAndReceivesVP9VideoRotation90) { #if defined(WEBRTC_USE_H264) TEST_F(EndToEndTest, SendsAndReceivesH264) { - CodecObserver test(500, kVideoRotation_0, "H264", H264Encoder::Create(), + CodecObserver test(500, kVideoRotation_0, "H264", + H264Encoder::Create(cricket::VideoCodec("H264")), H264Decoder::Create()); RunBaseTest(&test); } TEST_F(EndToEndTest, SendsAndReceivesH264VideoRotation90) { - CodecObserver test(5, kVideoRotation_90, "H264", H264Encoder::Create(), + CodecObserver test(5, kVideoRotation_90, "H264", + H264Encoder::Create(cricket::VideoCodec("H264")), H264Decoder::Create()); RunBaseTest(&test); } diff --git a/webrtc/video/video_quality_test.cc b/webrtc/video/video_quality_test.cc index 42f24046b2..f7a63aea41 100644 --- a/webrtc/video/video_quality_test.cc +++ b/webrtc/video/video_quality_test.cc @@ -1009,7 +1009,7 @@ void VideoQualityTest::SetupVideo(Transport* send_transport, int payload_type; if (params_.video.codec == "H264") { - video_encoder_.reset(H264Encoder::Create()); + video_encoder_.reset(H264Encoder::Create(cricket::VideoCodec("H264"))); payload_type = kPayloadTypeH264; } else if (params_.video.codec == "VP8") { video_encoder_.reset(VP8Encoder::Create());