Separate i420 and i444 implementations to separate targets.
This means we can properly declare the dependency between
libjingle_peerconnection_api and video_frame_api. i420
pulls in system_wrappers, which can't be a dependency of
the public API.
Plan:
1) Land this CL + send out PSA
2) Make all direct users of i420_buffer depend on the
new video_frame_api_i420 target
3) Move i420_buffer.cc to the new target
4) Make libjingle_peerconnection_api depend on
video_frame_api, since it no longer contains i420 code
Bug: webrtc:7504
Change-Id: I30d90f2ac7af53748859bbde8aed92386d5501f9
Reviewed-on: https://webrtc-review.googlesource.com/9382
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20656}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index bad3a51..05b8902 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -81,15 +81,16 @@
]
deps = [
- # Basically, don't add stuff here. You might break sensitive downstream
- # targets like pnacl. API should not depend on anything, really. All these
- # should go away, in time.
":optional",
":rtc_stats_api",
+ "audio_codecs:audio_codecs_api",
+
+ # Basically, don't add stuff here. You might break sensitive downstream
+ # targets like pnacl. API should not depend on anything outside of this
+ # file, really. All these should arguably go away in time.
"..:webrtc_common",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved",
- "audio_codecs:audio_codecs_api",
]
# This is needed until bugs.webrtc.org/7504 is removed so this target can
@@ -214,6 +215,8 @@
rtc_source_set("video_frame_api") {
sources = [
+ # TODO(phoglund): move i420 files to video_frame_api_i420 after updating
+ # downstream. See bugs.webrtc.org/7504.
"video/i420_buffer.cc",
"video/i420_buffer.h",
"video/video_content_type.cc",
@@ -245,6 +248,17 @@
}
}
+rtc_source_set("video_frame_api_i420") {
+ sources = [
+ "video/i420_buffer.h",
+ ]
+ deps = [
+ ":video_frame_api",
+ "../rtc_base:rtc_base_approved",
+ "../system_wrappers",
+ ]
+}
+
rtc_source_set("array_view") {
sources = [
"array_view.h",
diff --git a/api/video/video_frame_buffer.cc b/api/video/video_frame_buffer.cc
index b231745..867f249 100644
--- a/api/video/video_frame_buffer.cc
+++ b/api/video/video_frame_buffer.cc
@@ -10,8 +10,6 @@
#include "api/video/video_frame_buffer.h"
-#include "libyuv/convert.h"
-#include "api/video/i420_buffer.h"
#include "rtc_base/checks.h"
namespace webrtc {
@@ -79,15 +77,4 @@
return height();
}
-rtc::scoped_refptr<I420BufferInterface> I444BufferInterface::ToI420() {
- rtc::scoped_refptr<I420Buffer> i420_buffer =
- I420Buffer::Create(width(), height());
- libyuv::I444ToI420(DataY(), StrideY(), DataU(), StrideU(), DataV(), StrideV(),
- i420_buffer->MutableDataY(), i420_buffer->StrideY(),
- i420_buffer->MutableDataU(), i420_buffer->StrideU(),
- i420_buffer->MutableDataV(), i420_buffer->StrideV(),
- width(), height());
- return i420_buffer;
-}
-
} // namespace webrtc
diff --git a/api/video/video_frame_buffer.h b/api/video/video_frame_buffer.h
index e656edd..2be7e0b 100644
--- a/api/video/video_frame_buffer.h
+++ b/api/video/video_frame_buffer.h
@@ -129,8 +129,6 @@
int ChromaWidth() const final;
int ChromaHeight() const final;
- rtc::scoped_refptr<I420BufferInterface> ToI420() final;
-
protected:
~I444BufferInterface() override {}
};
diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn
index c7da8d6..669fa7a 100644
--- a/common_video/BUILD.gn
+++ b/common_video/BUILD.gn
@@ -58,6 +58,7 @@
deps = [
"..:webrtc_common",
"../api:optional",
+ "../api:video_frame_api_i420",
"../media:rtc_h264_profile_id",
"../modules:module_api",
"../rtc_base:rtc_base",
@@ -115,6 +116,7 @@
deps = [
":common_video",
+ "../api:video_frame_api_i420",
"../modules/video_capture:video_capture",
"../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved",
diff --git a/common_video/video_frame_buffer.cc b/common_video/video_frame_buffer.cc
index 9c8955c..88c8ca4 100644
--- a/common_video/video_frame_buffer.cc
+++ b/common_video/video_frame_buffer.cc
@@ -13,6 +13,7 @@
#include <algorithm>
+#include "api/video/i420_buffer.h"
#include "libyuv/convert.h"
#include "libyuv/planar_functions.h"
#include "libyuv/scale.h"
@@ -21,57 +22,7 @@
namespace webrtc {
-WrappedI420Buffer::WrappedI420Buffer(int width,
- int height,
- const uint8_t* y_plane,
- int y_stride,
- const uint8_t* u_plane,
- int u_stride,
- const uint8_t* v_plane,
- int v_stride,
- const rtc::Callback0<void>& no_longer_used)
- : width_(width),
- height_(height),
- y_plane_(y_plane),
- u_plane_(u_plane),
- v_plane_(v_plane),
- y_stride_(y_stride),
- u_stride_(u_stride),
- v_stride_(v_stride),
- no_longer_used_cb_(no_longer_used) {
-}
-
-WrappedI420Buffer::~WrappedI420Buffer() {
- no_longer_used_cb_();
-}
-
-int WrappedI420Buffer::width() const {
- return width_;
-}
-
-int WrappedI420Buffer::height() const {
- return height_;
-}
-
-const uint8_t* WrappedI420Buffer::DataY() const {
- return y_plane_;
-}
-const uint8_t* WrappedI420Buffer::DataU() const {
- return u_plane_;
-}
-const uint8_t* WrappedI420Buffer::DataV() const {
- return v_plane_;
-}
-
-int WrappedI420Buffer::StrideY() const {
- return y_stride_;
-}
-int WrappedI420Buffer::StrideU() const {
- return u_stride_;
-}
-int WrappedI420Buffer::StrideV() const {
- return v_stride_;
-}
+namespace {
// Template to implement a wrapped buffer for a I4??BufferInterface.
template <typename Base>
@@ -163,6 +114,76 @@
const int a_stride_;
};
+class I444BufferBase : public I444BufferInterface {
+ public:
+ rtc::scoped_refptr<I420BufferInterface> ToI420() final;
+};
+
+rtc::scoped_refptr<I420BufferInterface> I444BufferBase::ToI420() {
+ rtc::scoped_refptr<I420Buffer> i420_buffer =
+ I420Buffer::Create(width(), height());
+ libyuv::I444ToI420(DataY(), StrideY(), DataU(), StrideU(), DataV(), StrideV(),
+ i420_buffer->MutableDataY(), i420_buffer->StrideY(),
+ i420_buffer->MutableDataU(), i420_buffer->StrideU(),
+ i420_buffer->MutableDataV(), i420_buffer->StrideV(),
+ width(), height());
+ return i420_buffer;
+}
+
+} // namespace
+
+WrappedI420Buffer::WrappedI420Buffer(int width,
+ int height,
+ const uint8_t* y_plane,
+ int y_stride,
+ const uint8_t* u_plane,
+ int u_stride,
+ const uint8_t* v_plane,
+ int v_stride,
+ const rtc::Callback0<void>& no_longer_used)
+ : width_(width),
+ height_(height),
+ y_plane_(y_plane),
+ u_plane_(u_plane),
+ v_plane_(v_plane),
+ y_stride_(y_stride),
+ u_stride_(u_stride),
+ v_stride_(v_stride),
+ no_longer_used_cb_(no_longer_used) {
+}
+
+WrappedI420Buffer::~WrappedI420Buffer() {
+ no_longer_used_cb_();
+}
+
+int WrappedI420Buffer::width() const {
+ return width_;
+}
+
+int WrappedI420Buffer::height() const {
+ return height_;
+}
+
+const uint8_t* WrappedI420Buffer::DataY() const {
+ return y_plane_;
+}
+const uint8_t* WrappedI420Buffer::DataU() const {
+ return u_plane_;
+}
+const uint8_t* WrappedI420Buffer::DataV() const {
+ return v_plane_;
+}
+
+int WrappedI420Buffer::StrideY() const {
+ return y_stride_;
+}
+int WrappedI420Buffer::StrideU() const {
+ return u_stride_;
+}
+int WrappedI420Buffer::StrideV() const {
+ return v_stride_;
+}
+
rtc::scoped_refptr<I420BufferInterface> WrapI420Buffer(
int width,
int height,
@@ -208,7 +229,7 @@
int v_stride,
const rtc::Callback0<void>& no_longer_used) {
return rtc::scoped_refptr<I444BufferInterface>(
- new rtc::RefCountedObject<WrappedYuvBuffer<I444BufferInterface>>(
+ new rtc::RefCountedObject<WrappedYuvBuffer<I444BufferBase>>(
width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
v_stride, no_longer_used));
}
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index 01d73a4..740ebe5 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -492,7 +492,9 @@
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
}
- deps = []
+ deps = [
+ "../api:video_frame_api_i420",
+ ]
if (is_win) {
sources += [
"peerconnection/client/flagdefs.h",
diff --git a/media/BUILD.gn b/media/BUILD.gn
index 2af6121..5370791 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -135,6 +135,7 @@
defines = []
libs = []
deps = [
+ "../api:video_frame_api_i420",
"../modules/video_coding:video_coding_utility",
]
sources = [
@@ -339,6 +340,7 @@
include_dirs = []
public_deps = []
deps = [
+ "../api:video_frame_api_i420",
"../call:video_stream_api",
"../modules/audio_coding:rent_a_codec",
"../modules/audio_processing:audio_processing",
@@ -440,6 +442,7 @@
defines = []
deps = [
+ "../api:video_frame_api_i420",
"../pc:rtc_pc",
"../test:field_trial",
]
diff --git a/modules/BUILD.gn b/modules/BUILD.gn
index 5d4987e..d534f56 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -37,6 +37,7 @@
"..:webrtc_common",
"../api:optional",
"../api:video_frame_api",
+ "../api:video_frame_api_i420",
"../rtc_base:rtc_base_approved",
"video_coding:codec_globals_headers",
]
diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn
index 5176862..31a4b65 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -28,6 +28,7 @@
deps = [
"..:module_api",
"../..:webrtc_common",
+ "../../api:video_frame_api_i420",
"../../common_video",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers",
@@ -200,6 +201,7 @@
deps = [
":video_capture_internal_impl",
":video_capture_module",
+ "../../api:video_frame_api_i420",
"../../common_video:common_video",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers:system_wrappers",
diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn
index d561bf6..728ed80 100644
--- a/modules/video_coding/BUILD.gn
+++ b/modules/video_coding/BUILD.gn
@@ -99,6 +99,7 @@
"..:module_api",
"../..:webrtc_common",
"../../api:optional",
+ "../../api:video_frame_api_i420",
"../../call:video_stream_api",
"../../common_video",
"../../rtc_base:rtc_base",
@@ -189,6 +190,7 @@
defines = []
deps = [
":video_coding_utility",
+ "../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api",
"../../media:rtc_media_base",
"../../rtc_base:rtc_base_approved",
@@ -229,6 +231,7 @@
deps = [
":video_coding_utility",
"../..:webrtc_common",
+ "../../api:video_frame_api_i420",
"../../common_video:common_video",
"../../rtc_base:rtc_base_approved",
"../../system_wrappers",
@@ -252,6 +255,7 @@
":video_coding_utility",
"..:module_api",
"../..:webrtc_common",
+ "../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api",
"../../common_video:common_video",
"../../rtc_base:rtc_base_approved",
@@ -376,6 +380,7 @@
":video_coding",
":webrtc_vp8",
"../../api:video_frame_api",
+ "../../api:video_frame_api_i420",
"../../common_video:common_video",
"../../rtc_base:rtc_base_approved",
"../../test:test_support",
@@ -409,6 +414,7 @@
":video_coding_utility",
":webrtc_vp8",
"../..:webrtc_common",
+ "../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api",
"../../common_video:common_video",
"../../rtc_base:rtc_base_approved",
@@ -471,6 +477,7 @@
"../../api:mock_video_codec_factory",
"../../api:optional",
"../../api:video_frame_api",
+ "../../api:video_frame_api_i420",
"../../common_video",
"../../media:rtc_audio_video",
"../../media:rtc_media_base",
@@ -586,6 +593,7 @@
"..:module_api",
"../..:webrtc_common",
"../../api:video_frame_api",
+ "../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api",
"../../common_video:common_video",
"../../rtc_base:rtc_base",
diff --git a/test/BUILD.gn b/test/BUILD.gn
index e00bbef..8a1c823 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -61,6 +61,7 @@
deps = [
"..:webrtc_common",
"../api:optional",
+ "../api:video_frame_api_i420",
"../api/video_codecs:video_codecs_api",
"../call:video_stream_api",
"../common_video",
@@ -212,6 +213,7 @@
":video_test_common",
"..:webrtc_common",
"../api:video_frame_api",
+ "../api:video_frame_api_i420",
"../common_video",
"../rtc_base:rtc_base_approved",
"../system_wrappers",
@@ -285,6 +287,7 @@
":fake_audio_device",
":rtp_test_utils",
"../api:video_frame_api",
+ "../api:video_frame_api_i420",
"../call:call_interfaces",
"../common_audio",
"../modules/rtp_rtcp",
@@ -553,6 +556,7 @@
"..:webrtc_common",
"../api:transport_api",
"../api:video_frame_api",
+ "../api:video_frame_api_i420",
"../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory",
"../api/video_codecs:video_codecs_api",
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 8799a84..e75a446 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -57,6 +57,7 @@
"..:webrtc_common",
"../api:optional",
"../api:transport_api",
+ "../api:video_frame_api_i420",
"../api/video_codecs:video_codecs_api",
"../call:bitrate_allocator",
"../call:call_interfaces",
@@ -273,6 +274,7 @@
":video",
"../api:optional",
"../api:video_frame_api",
+ "../api:video_frame_api_i420",
"../api/video_codecs:video_codecs_api",
"../call:call_interfaces",
"../call:mock_rtp_interfaces",