liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 1 | // 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 Watkins | b0ad6af8 | 2017-09-14 04:09:44 | [diff] [blame^] | 5 | #ifndef MEDIA_GPU_ANDROID_AVDA_SURFACE_BUNDLE_H_ |
| 6 | #define MEDIA_GPU_ANDROID_AVDA_SURFACE_BUNDLE_H_ |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 7 | |
| 8 | #include "base/memory/ref_counted.h" |
liberato | c58e8f82 | 2017-03-10 19:45:48 | [diff] [blame] | 9 | #include "media/base/android/android_overlay.h" |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 10 | #include "media/base/surface_manager.h" |
Chris Watkins | b0ad6af8 | 2017-09-14 04:09:44 | [diff] [blame^] | 11 | #include "media/gpu/android/surface_texture_gl_owner.h" |
liberato | 9432ee0 | 2017-05-03 07:18:11 | [diff] [blame] | 12 | #include "media/gpu/media_gpu_export.h" |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 13 | #include "ui/gl/android/scoped_java_surface.h" |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 14 | |
| 15 | namespace media { |
| 16 | |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 17 | // AVDASurfaceBundle is a Java surface, and the SurfaceTexture or Overlay that |
| 18 | // backs it. |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 19 | // |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 20 | // 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. |
liberato | 9432ee0 | 2017-05-03 07:18:11 | [diff] [blame] | 24 | struct MEDIA_GPU_EXPORT AVDASurfaceBundle |
| 25 | : public base::RefCountedThreadSafe<AVDASurfaceBundle> { |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 26 | public: |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 27 | // Create an empty bundle to be manually populated. |
| 28 | explicit AVDASurfaceBundle(); |
liberato | 9432ee0 | 2017-05-03 07:18:11 | [diff] [blame] | 29 | explicit AVDASurfaceBundle(std::unique_ptr<AndroidOverlay> overlay); |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 30 | explicit AVDASurfaceBundle( |
| 31 | scoped_refptr<SurfaceTextureGLOwner> surface_texture_owner); |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 32 | |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 33 | const base::android::JavaRef<jobject>& GetJavaSurface() const; |
liberato | c58e8f82 | 2017-03-10 19:45:48 | [diff] [blame] | 34 | |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 35 | // The Overlay or SurfaceTexture. |
liberato | c58e8f82 | 2017-03-10 19:45:48 | [diff] [blame] | 36 | std::unique_ptr<AndroidOverlay> overlay; |
liberato | 95c9282 | 2017-05-17 22:36:21 | [diff] [blame] | 37 | scoped_refptr<SurfaceTextureGLOwner> surface_texture; |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 38 | |
Chris Watkins | 70e667e | 2017-05-21 20:03:48 | [diff] [blame] | 39 | // The Java surface for |surface_texture|. |
liberato | c58e8f82 | 2017-03-10 19:45:48 | [diff] [blame] | 40 | gl::ScopedJavaSurface surface_texture_surface; |
| 41 | |
liberato | 5e0962e | 2017-03-08 19:21:36 | [diff] [blame] | 42 | private: |
| 43 | ~AVDASurfaceBundle(); |
| 44 | friend class base::RefCountedThreadSafe<AVDASurfaceBundle>; |
| 45 | |
| 46 | DISALLOW_COPY_AND_ASSIGN(AVDASurfaceBundle); |
| 47 | }; |
| 48 | |
| 49 | } // namespace media |
| 50 | |
Chris Watkins | b0ad6af8 | 2017-09-14 04:09:44 | [diff] [blame^] | 51 | #endif // MEDIA_GPU_ANDROID_AVDA_SURFACE_BUNDLE_H_ |