blob: b22367267274a5601aee95e8912c9708680705d7 [file] [log] [blame]
liberato5e0962e2017-03-08 19:21:361// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Chris Watkinsb0ad6af82017-09-14 04:09:445#ifndef MEDIA_GPU_ANDROID_AVDA_SURFACE_BUNDLE_H_
6#define MEDIA_GPU_ANDROID_AVDA_SURFACE_BUNDLE_H_
liberato5e0962e2017-03-08 19:21:367
8#include "base/memory/ref_counted.h"
liberatoc58e8f822017-03-10 19:45:489#include "media/base/android/android_overlay.h"
liberato5e0962e2017-03-08 19:21:3610#include "media/base/surface_manager.h"
Chris Watkinsb0ad6af82017-09-14 04:09:4411#include "media/gpu/android/surface_texture_gl_owner.h"
liberato9432ee02017-05-03 07:18:1112#include "media/gpu/media_gpu_export.h"
liberato5e0962e2017-03-08 19:21:3613#include "ui/gl/android/scoped_java_surface.h"
liberato5e0962e2017-03-08 19:21:3614
15namespace media {
16
Chris Watkins70e667e2017-05-21 20:03:4817// AVDASurfaceBundle is a Java surface, and the SurfaceTexture or Overlay that
18// backs it.
liberato5e0962e2017-03-08 19:21:3619//
Chris Watkins70e667e2017-05-21 20:03:4820// Once a MediaCodec is configured with an output surface, the corresponding
21// AVDASurfaceBundle should be kept alive as long as the codec to prevent
22// crashes due to the codec losing its output surface.
23// TODO(watk): Remove AVDA from the name.
liberato9432ee02017-05-03 07:18:1124struct MEDIA_GPU_EXPORT AVDASurfaceBundle
25 : public base::RefCountedThreadSafe<AVDASurfaceBundle> {
liberato5e0962e2017-03-08 19:21:3626 public:
Chris Watkins70e667e2017-05-21 20:03:4827 // Create an empty bundle to be manually populated.
28 explicit AVDASurfaceBundle();
liberato9432ee02017-05-03 07:18:1129 explicit AVDASurfaceBundle(std::unique_ptr<AndroidOverlay> overlay);
Chris Watkins70e667e2017-05-21 20:03:4830 explicit AVDASurfaceBundle(
31 scoped_refptr<SurfaceTextureGLOwner> surface_texture_owner);
liberato5e0962e2017-03-08 19:21:3632
Chris Watkins70e667e2017-05-21 20:03:4833 const base::android::JavaRef<jobject>& GetJavaSurface() const;
liberatoc58e8f822017-03-10 19:45:4834
Chris Watkins70e667e2017-05-21 20:03:4835 // The Overlay or SurfaceTexture.
liberatoc58e8f822017-03-10 19:45:4836 std::unique_ptr<AndroidOverlay> overlay;
liberato95c92822017-05-17 22:36:2137 scoped_refptr<SurfaceTextureGLOwner> surface_texture;
liberato5e0962e2017-03-08 19:21:3638
Chris Watkins70e667e2017-05-21 20:03:4839 // The Java surface for |surface_texture|.
liberatoc58e8f822017-03-10 19:45:4840 gl::ScopedJavaSurface surface_texture_surface;
41
liberato5e0962e2017-03-08 19:21:3642 private:
43 ~AVDASurfaceBundle();
44 friend class base::RefCountedThreadSafe<AVDASurfaceBundle>;
45
46 DISALLOW_COPY_AND_ASSIGN(AVDASurfaceBundle);
47};
48
49} // namespace media
50
Chris Watkinsb0ad6af82017-09-14 04:09:4451#endif // MEDIA_GPU_ANDROID_AVDA_SURFACE_BUNDLE_H_