summaryrefslogtreecommitdiffstats
path: root/chromecast
diff options
context:
space:
mode:
authorhalliwell <halliwell@chromium.org>2015-05-21 13:53:35 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-21 20:55:04 +0000
commit16769bfff6b299126da4b533450c89311af978e6 (patch)
treeea7d46170bed3b1c0771a0aa7a67bf7f2e97e6c6 /chromecast
parent1160bd32d83b17e5e97ba20547a634b1bef67cd0 (diff)
downloadchromium_src-16769bfff6b299126da4b533450c89311af978e6.zip
chromium_src-16769bfff6b299126da4b533450c89311af978e6.tar.gz
chromium_src-16769bfff6b299126da4b533450c89311af978e6.tar.bz2
Adds hardware overlay support to Cast
Note: this doesn't mean cast_shell is using overlays quite yet. CmaRenderer still has to set up the VideoFrames correctly for that to happen. But this change makes everything ready for that. BUG=469374 Review URL: https://codereview.chromium.org/1138033006 Cr-Commit-Position: refs/heads/master@{#330980}
Diffstat (limited to 'chromecast')
-rw-r--r--chromecast/browser/cast_browser_main_parts.cc2
-rw-r--r--chromecast/browser/media/cma_message_filter_host.cc168
-rw-r--r--chromecast/chromecast.gyp1
-rw-r--r--chromecast/media/base/cast_media_default.cc29
-rw-r--r--chromecast/media/cma/backend/video_plane.cc54
-rw-r--r--chromecast/media/cma/backend/video_plane.h62
-rw-r--r--chromecast/media/cma/backend/video_plane_fake.cc33
-rw-r--r--chromecast/media/cma/backend/video_plane_fake.h31
-rw-r--r--chromecast/media/cma/backend/video_plane_fake_factory.cc15
-rw-r--r--chromecast/media/media.gyp5
-rw-r--r--chromecast/public/cast_media_shlib.h7
-rw-r--r--chromecast/public/graphics_types.h11
-rw-r--r--chromecast/public/video_plane.h55
13 files changed, 269 insertions, 204 deletions
diff --git a/chromecast/browser/cast_browser_main_parts.cc b/chromecast/browser/cast_browser_main_parts.cc
index 1c4c7fe..b376b69 100644
--- a/chromecast/browser/cast_browser_main_parts.cc
+++ b/chromecast/browser/cast_browser_main_parts.cc
@@ -42,6 +42,7 @@
#include "media/audio/audio_manager.h"
#include "media/audio/audio_manager_factory.h"
#include "media/base/browser_cdm_factory.h"
+#include "ui/compositor/compositor_switches.h"
#if defined(OS_ANDROID)
#include "chromecast/browser/media/cast_media_client_android.h"
@@ -178,6 +179,7 @@ DefaultCommandLineSwitch g_default_switches[] = {
#elif defined(ARCH_CPU_ARM_FAMILY) && !defined(DISABLE_DISPLAY)
// On Linux arm, enable CMA pipeline by default.
{ switches::kEnableCmaMediaPipeline, "" },
+ { switches::kEnableHardwareOverlays, "" },
#endif
#endif // defined(OS_LINUX)
// Needed to fix a bug where the raster thread doesn't get scheduled for a
diff --git a/chromecast/browser/media/cma_message_filter_host.cc b/chromecast/browser/media/cma_message_filter_host.cc
index 7ebc455..2d34dea 100644
--- a/chromecast/browser/media/cma_message_filter_host.cc
+++ b/chromecast/browser/media/cma_message_filter_host.cc
@@ -14,10 +14,12 @@
#include "chromecast/browser/media/media_pipeline_host.h"
#include "chromecast/common/media/cma_messages.h"
#include "chromecast/media/cdm/browser_cdm_cast.h"
-#include "chromecast/media/cma/backend/video_plane.h"
#include "chromecast/media/cma/pipeline/av_pipeline_client.h"
#include "chromecast/media/cma/pipeline/media_pipeline_client.h"
#include "chromecast/media/cma/pipeline/video_pipeline_client.h"
+#include "chromecast/public/cast_media_shlib.h"
+#include "chromecast/public/graphics_types.h"
+#include "chromecast/public/video_plane.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "media/base/bind_to_current_loop.h"
@@ -125,14 +127,172 @@ void SetCdmOnUiThread(
browser_cdm_cast));
}
+// TODO(halliwell): remove this and the NotifyExternalSurface path once
+// VIDEO_HOLE is no longer required.
+void EstimateVideoPlaneRect(const gfx::QuadF& quad,
+ VideoPlane::Transform* transform,
+ RectF* rect) {
+ const gfx::PointF& p0 = quad.p1();
+ const gfx::PointF& p1 = quad.p2();
+ const gfx::PointF& p2 = quad.p3();
+ const gfx::PointF& p3 = quad.p4();
+
+ float det0 = p0.x() * p1.y() - p1.x() * p0.y();
+ float det1 = p1.x() * p2.y() - p2.x() * p1.y();
+ float det2 = p2.x() * p3.y() - p3.x() * p2.y();
+ float det3 = p3.x() * p0.y() - p0.x() * p3.y();
+
+ // Calculate the area of the quad (i.e. moment 0 of the polygon).
+ // Note: the area can here be either positive or negative
+ // depending on whether the quad is clock wise or counter clock wise.
+ float area = 0.5 * (det0 + det1 + det2 + det3);
+ if (area == 0.0) {
+ // Empty rectangle in that case.
+ *transform = VideoPlane::TRANSFORM_NONE;
+ *rect = RectF(p0.x(), p0.y(), 0.0, 0.0);
+ return;
+ }
+
+ // Calculate the center of gravity of the polygon
+ // (i.e. moment 1 of the polygon).
+ float cx = (1.0 / (6.0 * area)) *
+ ((p0.x() + p1.x()) * det0 +
+ (p1.x() + p2.x()) * det1 +
+ (p2.x() + p3.x()) * det2 +
+ (p3.x() + p0.x()) * det3);
+ float cy = (1.0 / (6.0 * area)) *
+ ((p0.y() + p1.y()) * det0 +
+ (p1.y() + p2.y()) * det1 +
+ (p2.y() + p3.y()) * det2 +
+ (p3.y() + p0.y()) * det3);
+
+ // For numerical stability, subtract the center of gravity now instead of
+ // later doing:
+ // mxx -= cx * cx;
+ // myy -= cy * cy;
+ // mxy -= cx * cy;
+ // to get the centered 2nd moments.
+ gfx::PointF p0c(p0.x() - cx, p0.y() - cy);
+ gfx::PointF p1c(p1.x() - cx, p1.y() - cy);
+ gfx::PointF p2c(p2.x() - cx, p2.y() - cy);
+ gfx::PointF p3c(p3.x() - cx, p3.y() - cy);
+
+ // Calculate the second moments of the polygon.
+ float det0c = p0c.x() * p1c.y() - p1c.x() * p0c.y();
+ float det1c = p1c.x() * p2c.y() - p2c.x() * p1c.y();
+ float det2c = p2c.x() * p3c.y() - p3c.x() * p2c.y();
+ float det3c = p3c.x() * p0c.y() - p0c.x() * p3c.y();
+ float mxx = (1.0 / (12.0 * area)) *
+ ((p0c.x() * p0c.x() + p0c.x() * p1c.x() + p1c.x() * p1c.x()) * det0c +
+ (p1c.x() * p1c.x() + p1c.x() * p2c.x() + p2c.x() * p2c.x()) * det1c +
+ (p2c.x() * p2c.x() + p2c.x() * p3c.x() + p3c.x() * p3c.x()) * det2c +
+ (p3c.x() * p3c.x() + p3c.x() * p0c.x() + p0c.x() * p0c.x()) * det3c);
+ float myy = (1.0 / (12.0 * area)) *
+ ((p0c.y() * p0c.y() + p0c.y() * p1c.y() + p1c.y() * p1c.y()) * det0c +
+ (p1c.y() * p1c.y() + p1c.y() * p2c.y() + p2c.y() * p2c.y()) * det1c +
+ (p2c.y() * p2c.y() + p2c.y() * p3c.y() + p3c.y() * p3c.y()) * det2c +
+ (p3c.y() * p3c.y() + p3c.y() * p0c.y() + p0c.y() * p0c.y()) * det3c);
+
+ // Remark: the 2nd moments of a rotated & centered rectangle are given by:
+ // mxx = (1/12) * (h^2 * s^2 + w^2 * c^2)
+ // myy = (1/12) * (h^2 * c^2 + w^2 * s^2)
+ // mxy = (1/12) * (w^2 - h^2) * c * s
+ // where w = width of the original rectangle,
+ // h = height of the original rectangle,
+ // c = cos(teta) with teta the angle of the rotation,
+ // s = sin(teta)
+ //
+ // For reference, mxy can be calculated from the quad using:
+ // float mxy = (1.0 / (24.0 * area)) *
+ // ((2.0 * p0c.x() * p0c.y() + p0c.x() * p1c.y() + p1c.x() * p0c.y() +
+ // 2.0 * p1c.x() * p1c.y()) * det0c +
+ // (2.0 * p1c.x() * p1c.y() + p1c.x() * p2c.y() + p2c.x() * p1c.y() +
+ // 2.0 * p2c.x() * p2c.y()) * det1c +
+ // (2.0 * p2c.x() * p2c.y() + p2c.x() * p3c.y() + p3c.x() * p2c.y() +
+ // 2.0 * p3c.x() * p3c.y()) * det2c +
+ // (2.0 * p3c.x() * p3c.y() + p3c.x() * p0c.y() + p0c.x() * p3c.y() +
+ // 2.0 * p0c.x() * p0c.y()) * det3c);
+
+ // The rotation is assumed to be 0, 90, 180 or 270 degrees, so mxy = 0.0
+ // Using this assumption: mxx = (1/12) h^2 or (1/12) w^2 depending on the
+ // rotation. Same for myy.
+ if (mxx < 0 || myy < 0) {
+ // mxx and myy should be positive, only numerical errors can lead to a
+ // negative value.
+ LOG(WARNING) << "Numerical errors: " << mxx << " " << myy;
+ *transform = VideoPlane::TRANSFORM_NONE;
+ *rect = RectF(p0.x(), p0.y(), 0.0, 0.0);
+ return;
+ }
+ float size_x = sqrt(12.0 * mxx);
+ float size_y = sqrt(12.0 * myy);
+
+ // Estimate the parameters of the rotation since teta can only be known
+ // modulo 90 degrees. In previous equations, you can always swap w and h
+ // and subtract 90 degrees to teta to get the exact same second moment.
+ int idx_best = -1;
+ float err_best = 0.0;
+
+ // First, estimate the rotation angle assuming
+ // dist(p0,p1) is equal to |size_x|,
+ // dist(p0,p3) is equal to |size_y|.
+ gfx::PointF r1(size_x, 0);
+ gfx::PointF r2(size_x, size_y);
+ gfx::PointF r3(0, size_y);
+ for (int k = 0; k < 4; k++) {
+ float cur_err =
+ fabs((p1.x() - p0.x()) - r1.x()) + fabs((p1.y() - p0.y()) - r1.y()) +
+ fabs((p2.x() - p0.x()) - r2.x()) + fabs((p2.y() - p0.y()) - r2.y()) +
+ fabs((p3.x() - p0.x()) - r3.x()) + fabs((p3.y() - p0.y()) - r3.y());
+ if (idx_best < 0 || cur_err < err_best) {
+ idx_best = k;
+ err_best = cur_err;
+ }
+ // 90 degree rotation.
+ r1 = gfx::PointF(-r1.y(), r1.x());
+ r2 = gfx::PointF(-r2.y(), r2.x());
+ r3 = gfx::PointF(-r3.y(), r3.x());
+ }
+
+ // Then, estimate the rotation angle assuming:
+ // dist(p0,p1) is equal to |size_y|,
+ // dist(p0,p3) is equal to |size_x|.
+ r1 = gfx::PointF(size_y, 0);
+ r2 = gfx::PointF(size_y, size_x);
+ r3 = gfx::PointF(0, size_x);
+ for (int k = 0; k < 4; k++) {
+ float cur_err =
+ fabs((p1.x() - p0.x()) - r1.x()) + fabs((p1.y() - p0.y()) - r1.y()) +
+ fabs((p2.x() - p0.x()) - r2.x()) + fabs((p2.y() - p0.y()) - r2.y()) +
+ fabs((p3.x() - p0.x()) - r3.x()) + fabs((p3.y() - p0.y()) - r3.y());
+ if (idx_best < 0 || cur_err < err_best) {
+ idx_best = k;
+ err_best = cur_err;
+ }
+ // 90 degree rotation.
+ r1 = gfx::PointF(-r1.y(), r1.x());
+ r2 = gfx::PointF(-r2.y(), r2.x());
+ r3 = gfx::PointF(-r3.y(), r3.x());
+ }
+
+ *transform = static_cast<VideoPlane::Transform>(idx_best);
+ *rect = RectF(cx - size_x / 2.0, cy - size_y / 2.0, size_x, size_y);
+}
+
void UpdateVideoSurfaceHost(int surface_id, const gfx::QuadF& quad) {
// Currently supports only one video plane.
CHECK_EQ(surface_id, 0);
- VideoPlane* video_plane = GetVideoPlane();
+ // Convert quad into rect + transform
+ VideoPlane::Transform transform = VideoPlane::TRANSFORM_NONE;
+ RectF rect(0, 0, 0, 0);
+ EstimateVideoPlaneRect(quad, &transform, &rect);
+
+ VideoPlane* video_plane = CastMediaShlib::GetVideoPlane();
video_plane->SetGeometry(
- quad,
- VideoPlane::COORDINATE_TYPE_GRAPHICS_PLANE);
+ rect,
+ VideoPlane::COORDINATE_TYPE_GRAPHICS_PLANE,
+ transform);
}
} // namespace
diff --git a/chromecast/chromecast.gyp b/chromecast/chromecast.gyp
index 6bcb71f..d0da332 100644
--- a/chromecast/chromecast.gyp
+++ b/chromecast/chromecast.gyp
@@ -47,6 +47,7 @@
'public/osd_plane.h',
'public/osd_plane_shlib.h',
'public/osd_surface.h',
+ 'public/video_plane.h',
],
},
# TODO(gunsch): Remove this fake target once it's either added or no
diff --git a/chromecast/media/base/cast_media_default.cc b/chromecast/media/base/cast_media_default.cc
index 0cc03d3..0c17712 100644
--- a/chromecast/media/base/cast_media_default.cc
+++ b/chromecast/media/base/cast_media_default.cc
@@ -3,14 +3,43 @@
// found in the LICENSE file.
#include "chromecast/public/cast_media_shlib.h"
+#include "chromecast/public/graphics_types.h"
+#include "chromecast/public/video_plane.h"
namespace chromecast {
namespace media {
+namespace {
+
+class DefaultVideoPlane : public VideoPlane {
+ public:
+ ~DefaultVideoPlane() override {}
+
+ Size GetScreenResolution() override {
+ return Size(1920, 1080);
+ }
+
+ void SetGeometry(const RectF& display_rect,
+ CoordinateType coordinate_type,
+ Transform transform) override {}
+
+ void OnScreenResolutionChanged(const Size& screen_res) override {}
+};
+
+DefaultVideoPlane* g_video_plane = nullptr;
+
+} // namespace
void CastMediaShlib::Initialize(const std::vector<std::string>& argv) {
+ g_video_plane = new DefaultVideoPlane();
}
void CastMediaShlib::Finalize() {
+ delete g_video_plane;
+ g_video_plane = nullptr;
+}
+
+VideoPlane* CastMediaShlib::GetVideoPlane() {
+ return g_video_plane;
}
} // namespace media
diff --git a/chromecast/media/cma/backend/video_plane.cc b/chromecast/media/cma/backend/video_plane.cc
deleted file mode 100644
index 5d8097f..0000000
--- a/chromecast/media/cma/backend/video_plane.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromecast/media/cma/backend/video_plane.h"
-
-#include "base/memory/singleton.h"
-
-namespace chromecast {
-namespace media {
-
-VideoPlane::VideoPlane() {
-}
-
-VideoPlane::~VideoPlane() {
-}
-
-class VideoPlaneRegistry {
- public:
- static VideoPlaneRegistry* GetInstance() {
- return Singleton<VideoPlaneRegistry>::get();
- }
-
- VideoPlane* GetVideoPlane();
-
- private:
- friend struct DefaultSingletonTraits<VideoPlaneRegistry>;
- friend class Singleton<VideoPlaneRegistry>;
-
- VideoPlaneRegistry();
- virtual ~VideoPlaneRegistry();
-
- scoped_ptr<VideoPlane> video_plane_;
-
- DISALLOW_COPY_AND_ASSIGN(VideoPlaneRegistry);
-};
-
-VideoPlaneRegistry::VideoPlaneRegistry() :
- video_plane_(CreateVideoPlane()) {
-}
-
-VideoPlaneRegistry::~VideoPlaneRegistry() {
-}
-
-VideoPlane* VideoPlaneRegistry::GetVideoPlane() {
- return video_plane_.get();
-}
-
-VideoPlane* GetVideoPlane() {
- return VideoPlaneRegistry::GetInstance()->GetVideoPlane();
-}
-
-} // namespace media
-} // namespace chromecast
diff --git a/chromecast/media/cma/backend/video_plane.h b/chromecast/media/cma/backend/video_plane.h
deleted file mode 100644
index a5f864c..0000000
--- a/chromecast/media/cma/backend/video_plane.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
-#define CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
-
-#include "base/macros.h"
-#include "base/memory/scoped_ptr.h"
-
-namespace gfx {
-class QuadF;
-class Size;
-}
-
-namespace chromecast {
-namespace media {
-
-class VideoPlane {
- public:
- enum CoordinateType {
- // Graphics plane as coordinate type.
- COORDINATE_TYPE_GRAPHICS_PLANE = 0,
- // Output display screen as coordinate type.
- COORDINATE_TYPE_SCREEN_RESOLUTION = 1,
- };
-
- VideoPlane();
- virtual ~VideoPlane();
-
- // Gets output screen resolution.
- virtual gfx::Size GetScreenResolution() = 0;
-
- // Updates the video plane geometry.
- // |quad.p1()| corresponds to the top left of the original video,
- // |quad.p2()| to the top right of the original video,
- // and so on.
- // Depending on the underlying hardware, the exact geometry
- // might not be honored.
- // |coordinate_type| indicates what coordinate type |quad| refers to.
- virtual void SetGeometry(const gfx::QuadF& quad,
- CoordinateType coordinate_type) = 0;
-
- // Should be invoked whenever screen resolution changes (e.g. when a device is
- // plugged into a new HDMI port and a new HDMI EDID is received).
- // VideoPlane should reposition itself according to the new screen resolution.
- virtual void OnScreenResolutionChanged(const gfx::Size& screen_res) = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(VideoPlane);
-};
-
-// Factory to create a VideoPlane.
-scoped_ptr<VideoPlane> CreateVideoPlane();
-
-// Global accessor to the video plane.
-VideoPlane* GetVideoPlane();
-
-} // namespace media
-} // namespace chromecast
-
-#endif // CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_H_
diff --git a/chromecast/media/cma/backend/video_plane_fake.cc b/chromecast/media/cma/backend/video_plane_fake.cc
deleted file mode 100644
index 73fa39e..0000000
--- a/chromecast/media/cma/backend/video_plane_fake.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromecast/media/cma/backend/video_plane_fake.h"
-
-#include "base/logging.h"
-#include "ui/gfx/geometry/quad_f.h"
-#include "ui/gfx/geometry/size.h"
-
-namespace chromecast {
-namespace media {
-
-VideoPlaneFake::VideoPlaneFake() {
-}
-
-VideoPlaneFake::~VideoPlaneFake() {
-}
-
-gfx::Size VideoPlaneFake::GetScreenResolution() {
- return gfx::Size(1920, 1080);
-}
-
-void VideoPlaneFake::SetGeometry(const gfx::QuadF& quad,
- CoordinateType coordinate_type) {
- // Nothing to be done.
-}
-
-void VideoPlaneFake::OnScreenResolutionChanged(const gfx::Size& screen_res) {
-}
-
-} // namespace media
-} // namespace chromecast
diff --git a/chromecast/media/cma/backend/video_plane_fake.h b/chromecast/media/cma/backend/video_plane_fake.h
deleted file mode 100644
index 5fe04e6..0000000
--- a/chromecast/media/cma/backend/video_plane_fake.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
-#define CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
-
-#include "base/macros.h"
-#include "chromecast/media/cma/backend/video_plane.h"
-
-namespace chromecast {
-namespace media {
-
-class VideoPlaneFake : public VideoPlane {
- public:
- VideoPlaneFake();
- ~VideoPlaneFake() override;
-
- // VideoPlane implementation.
- gfx::Size GetScreenResolution() override;
- void SetGeometry(const gfx::QuadF& quad,
- CoordinateType coordinate_type) override;
- void OnScreenResolutionChanged(const gfx::Size& screen_res) override;
-
- DISALLOW_COPY_AND_ASSIGN(VideoPlaneFake);
-};
-
-} // namespace media
-} // namespace chromecast
-
-#endif // CHROMECAST_MEDIA_CMA_BACKEND_VIDEO_PLANE_FAKE_H_
diff --git a/chromecast/media/cma/backend/video_plane_fake_factory.cc b/chromecast/media/cma/backend/video_plane_fake_factory.cc
deleted file mode 100644
index 310c8bc..0000000
--- a/chromecast/media/cma/backend/video_plane_fake_factory.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chromecast/media/cma/backend/video_plane_fake.h"
-
-namespace chromecast {
-namespace media {
-
-scoped_ptr<VideoPlane> CreateVideoPlane() {
- return make_scoped_ptr(new VideoPlaneFake());
-}
-
-} // namespace media
-} // namespace chromecast
diff --git a/chromecast/media/media.gyp b/chromecast/media/media.gyp
index 125e278..7dbfd90 100644
--- a/chromecast/media/media.gyp
+++ b/chromecast/media/media.gyp
@@ -128,10 +128,6 @@
'cma/backend/media_pipeline_device_params.h',
'cma/backend/video_pipeline_device.cc',
'cma/backend/video_pipeline_device.h',
- 'cma/backend/video_plane.cc',
- 'cma/backend/video_plane.h',
- 'cma/backend/video_plane_fake.cc',
- 'cma/backend/video_plane_fake.h',
],
'conditions': [
['chromecast_branding=="Chrome"', {
@@ -141,7 +137,6 @@
}, {
'sources': [
'cma/backend/media_pipeline_device_fake_factory.cc',
- 'cma/backend/video_plane_fake_factory.cc',
],
}],
],
diff --git a/chromecast/public/cast_media_shlib.h b/chromecast/public/cast_media_shlib.h
index 6f2d60d..8b776da 100644
--- a/chromecast/public/cast_media_shlib.h
+++ b/chromecast/public/cast_media_shlib.h
@@ -13,6 +13,8 @@
namespace chromecast {
namespace media {
+class VideoPlane;
+
// Provides access to platform-specific media systems and hardware resources.
// In cast_shell, all usage is from the browser process. An implementation is
// assumed to be in an uninitialized state initially. When uninitialized, no
@@ -32,6 +34,11 @@ class CHROMECAST_EXPORT CastMediaShlib {
// state. The implementation must release all media-related hardware
// resources.
static void Finalize();
+
+ // Gets the VideoPlane instance for managing the hardware video plane.
+ // While an implementation is in an initialized state, this function may be
+ // called at any time. The VideoPlane object must be destroyed in Finalize.
+ static VideoPlane* GetVideoPlane();
};
} // namespace media
diff --git a/chromecast/public/graphics_types.h b/chromecast/public/graphics_types.h
index 09ac12b..841dc00 100644
--- a/chromecast/public/graphics_types.h
+++ b/chromecast/public/graphics_types.h
@@ -18,6 +18,17 @@ struct Rect {
int height;
};
+struct RectF {
+ RectF(float w, float h) : x(0), y(0), width(w), height(h) {}
+ RectF(float arg_x, float arg_y, float w, float h)
+ : x(arg_x), y(arg_y), width(w), height(h) {}
+
+ float x;
+ float y;
+ float width;
+ float height;
+};
+
struct Size {
Size(int w, int h) : width(w), height(h) {}
diff --git a/chromecast/public/video_plane.h b/chromecast/public/video_plane.h
new file mode 100644
index 0000000..890e7a0
--- /dev/null
+++ b/chromecast/public/video_plane.h
@@ -0,0 +1,55 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMECAST_PUBLIC_VIDEO_PLANE_H_
+#define CHROMECAST_PUBLIC_VIDEO_PLANE_H_
+
+namespace chromecast {
+struct RectF;
+struct Size;
+
+namespace media {
+
+class VideoPlane {
+ public:
+ // List of possible hardware transforms that can be applied to video.
+ // Rotations are anticlockwise.
+ enum Transform {
+ TRANSFORM_NONE,
+ ROTATE_90,
+ ROTATE_180,
+ ROTATE_270,
+ FLIP_HORIZONTAL,
+ FLIP_VERTICAL,
+ };
+
+ enum CoordinateType {
+ // Graphics plane as coordinate type.
+ COORDINATE_TYPE_GRAPHICS_PLANE = 0,
+ // Output display screen as coordinate type.
+ COORDINATE_TYPE_SCREEN_RESOLUTION = 1,
+ };
+
+ virtual ~VideoPlane() {}
+
+ // Gets output screen resolution.
+ virtual Size GetScreenResolution() = 0;
+
+ // Updates the video plane geometry.
+ // |display_rect| specifies the rectangle that the video should occupy.
+ // |coordinate_type| gives the coordinate space of |display_rect|.
+ // |transform| specifies how the video should be transformed within that
+ // rectangle.
+ virtual void SetGeometry(const RectF& display_rect,
+ CoordinateType coordinate_type,
+ Transform transform) = 0;
+
+ // Notifies VideoPlane that screen resolution has changed.
+ virtual void OnScreenResolutionChanged(const Size& screen_res) = 0;
+};
+
+} // namespace media
+} // namespace chromecast
+
+#endif // CHROMECAST_PUBLIC_VIDEO_PLANE_H_