diff options
author | tiago.vignatti@intel.com <tiago.vignatti@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 06:47:51 +0000 |
---|---|---|
committer | tiago.vignatti@intel.com <tiago.vignatti@intel.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 06:47:51 +0000 |
commit | 5e658c28c9e8bc343a689a73a45ca372c861924d (patch) | |
tree | 9a75a802285a7f9da8e1a5a329110337668f26d2 /media/ozone | |
parent | e416a9b047cc72abcaf4b6b2753cf09d88143306 (diff) | |
download | chromium_src-5e658c28c9e8bc343a689a73a45ca372c861924d.zip chromium_src-5e658c28c9e8bc343a689a73a45ca372c861924d.tar.gz chromium_src-5e658c28c9e8bc343a689a73a45ca372c861924d.tar.bz2 |
media: Add MediaOzonePlatform support
This CL adds MediaOzonePlatform, a new Ozone component for abstracting media
and related. In particular it adds CreateVideoDecodeAccelerator method so Ozone
implementations can use that for abstracting video decoding acceleration (i.e.
GPU based video decoding). Eventually MediaOzonePlatform will be used as well
for many windowing systems abstractions related to media, e.g. video encode,
audio, etc. We will add support for these others as needed.
Media platform is called and created on demand whenever a video playback is set
to play. Different than ui::OzonePlatform methods, the one added in here is
non-pure virtual so the implementations can decide themselves whether a video
implementation is actually wanted, based on its hardware capabilities.
This work is aimed at internal implementations like Ozone-DRI, Ozone-test but
also for externals like Ozone-Wayland. Different targets like Chromium Browser,
Chrome OS, ChromeCast and others can now take advantage of it.
BUG=380884
TEST=manually on Ozone-Wayland, using:
$ export GYP_DEFINES='chromeos=0 use_ozone=1 proprietary_codecs=1 ffmpeg_branding=Chrome'
$ ninja -j16 -C out/Release content
and to run:
~/git/chromium/src/out/Debug$ ./chrome --no-sandbox --user-data-dir=/tmp/chrome --ignore-gpu-blacklist ../../third_party/WebKit/PerformanceTests/resources/bear-1280x720.mp4 --vmodule=*/ozone/ui*=3 --v=0
additionally, in Release builds you can start chrome with --disable-accelerated-video-decode to compare the results.
Review URL: https://codereview.chromium.org/269673005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276552 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/ozone')
-rw-r--r-- | media/ozone/media_ozone_platform.cc | 93 | ||||
-rw-r--r-- | media/ozone/media_ozone_platform.h | 47 |
2 files changed, 140 insertions, 0 deletions
diff --git a/media/ozone/media_ozone_platform.cc b/media/ozone/media_ozone_platform.cc new file mode 100644 index 0000000..804de375 --- /dev/null +++ b/media/ozone/media_ozone_platform.cc @@ -0,0 +1,93 @@ +// 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 "media/ozone/media_ozone_platform.h" + +#include "base/debug/trace_event.h" +#include "base/logging.h" +#include "ui/ozone/platform_object.h" +#include "ui/ozone/platform_selection.h" + +namespace media { + +namespace { + +class MediaOzonePlatformStub : public MediaOzonePlatform { + public: + MediaOzonePlatformStub() {} + + virtual ~MediaOzonePlatformStub() {} + + private: + DISALLOW_COPY_AND_ASSIGN(MediaOzonePlatformStub); +}; + +} // namespace + +// The following statics are just convenient stubs, declared by the +// generate_constructor_list.py script. They should be removed once the +// internal Ozone platforms decide to actually implement their media specifics. +MediaOzonePlatform* CreateMediaOzonePlatformCaca() { + return new MediaOzonePlatformStub; +} + +MediaOzonePlatform* CreateMediaOzonePlatformDri() { + return new MediaOzonePlatformStub; +} + +MediaOzonePlatform* CreateMediaOzonePlatformEgltest() { + return new MediaOzonePlatformStub; +} + +MediaOzonePlatform* CreateMediaOzonePlatformGbm() { + return new MediaOzonePlatformStub; +} + +MediaOzonePlatform* CreateMediaOzonePlatformTest() { + return new MediaOzonePlatformStub; +} + +MediaOzonePlatform::MediaOzonePlatform() { + CHECK(!instance_) << "There should only be a single MediaOzonePlatform."; + instance_ = this; +} + +MediaOzonePlatform::~MediaOzonePlatform() { + CHECK_EQ(instance_, this); + instance_ = NULL; +} + +// static +MediaOzonePlatform* MediaOzonePlatform::GetInstance() { + if (!instance_) + CreateInstance(); + return instance_; +} + +VideoDecodeAccelerator* MediaOzonePlatform::CreateVideoDecodeAccelerator( + const base::Callback<bool(void)>& make_context_current) { + NOTIMPLEMENTED(); + return NULL; +} + +// static +void MediaOzonePlatform::CreateInstance() { + if (instance_) + return; + + TRACE_EVENT1("ozone", + "MediaOzonePlatform::Initialize", + "platform", + ui::GetOzonePlatformName()); + scoped_ptr<MediaOzonePlatform> platform = + ui::PlatformObject<MediaOzonePlatform>::Create(); + + // TODO(spang): Currently need to leak this object. + CHECK_EQ(instance_, platform.release()); +} + +// static +MediaOzonePlatform* MediaOzonePlatform::instance_; + +} // namespace media diff --git a/media/ozone/media_ozone_platform.h b/media/ozone/media_ozone_platform.h new file mode 100644 index 0000000..c59775d --- /dev/null +++ b/media/ozone/media_ozone_platform.h @@ -0,0 +1,47 @@ +// 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 MEDIA_OZONE_MEDIA_OZONE_PLATFORM_H_ +#define MEDIA_OZONE_MEDIA_OZONE_PLATFORM_H_ + +#include "base/callback.h" +#include "media/base/media_export.h" + +namespace media { + +class VideoDecodeAccelerator; + +// Class for Ozone platform media implementations. Note that the base class for +// Ozone platform is at ui/ozone. +// +// Ozone platforms must override this class and implement the virtual +// GetFooFactoryOzone() methods to provide implementations of the +// various ozone interfaces. +class MEDIA_EXPORT MediaOzonePlatform { + public: + MediaOzonePlatform(); + virtual ~MediaOzonePlatform(); + + // Besides get the global instance, initializes the subsystems/resources + // necessary for media also. + static MediaOzonePlatform* GetInstance(); + + // Factory getters to override in subclasses. The returned objects will be + // injected into the appropriate layer at startup. Subclasses should not + // inject these objects themselves. Ownership is retained by + // MediaOzonePlatform. + virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator( + const base::Callback<bool(void)>& make_context_current); + + private: + static void CreateInstance(); + + static MediaOzonePlatform* instance_; + + DISALLOW_COPY_AND_ASSIGN(MediaOzonePlatform); +}; + +} // namespace media + +#endif // MEDIA_OZONE_MEDIA_OZONE_PLATFORM_H_ |