OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "media/base/android/media_drm_bridge_cdm_context.h" | 22 #include "media/base/android/media_drm_bridge_cdm_context.h" |
23 #include "media/base/android/sdk_media_codec_bridge.h" | 23 #include "media/base/android/sdk_media_codec_bridge.h" |
24 #include "media/base/media_keys.h" | 24 #include "media/base/media_keys.h" |
25 #include "media/gpu/avda_state_provider.h" | 25 #include "media/gpu/avda_state_provider.h" |
26 #include "media/gpu/avda_surface_tracker.h" | 26 #include "media/gpu/avda_surface_tracker.h" |
27 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" | 27 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" |
28 #include "media/gpu/media_gpu_export.h" | 28 #include "media/gpu/media_gpu_export.h" |
29 #include "media/video/video_decode_accelerator.h" | 29 #include "media/video/video_decode_accelerator.h" |
30 #include "ui/gl/android/scoped_java_surface.h" | 30 #include "ui/gl/android/scoped_java_surface.h" |
31 | 31 |
32 namespace gfx { | 32 namespace gl { |
33 class SurfaceTexture; | 33 class SurfaceTexture; |
34 } | 34 } |
35 | 35 |
36 namespace media { | 36 namespace media { |
37 | 37 |
38 class SharedMemoryRegion; | 38 class SharedMemoryRegion; |
39 | 39 |
40 // A VideoDecodeAccelerator implementation for Android. | 40 // A VideoDecodeAccelerator implementation for Android. |
41 // This class decodes the input encoded stream by using Android's MediaCodec | 41 // This class decodes the input encoded stream by using Android's MediaCodec |
42 // class. http://developer.android.com/reference/android/media/MediaCodec.html | 42 // class. http://developer.android.com/reference/android/media/MediaCodec.html |
43 // It delegates attaching pictures to PictureBuffers to a BackingStrategy, but | 43 // It delegates attaching pictures to PictureBuffers to a BackingStrategy, but |
44 // otherwise handles the work of transferring data to / from MediaCodec. | 44 // otherwise handles the work of transferring data to / from MediaCodec. |
45 class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator | 45 class MEDIA_GPU_EXPORT AndroidVideoDecodeAccelerator |
46 : public media::VideoDecodeAccelerator, | 46 : public media::VideoDecodeAccelerator, |
47 public AVDAStateProvider { | 47 public AVDAStateProvider { |
48 public: | 48 public: |
49 using OutputBufferMap = std::map<int32_t, media::PictureBuffer>; | 49 using OutputBufferMap = std::map<int32_t, media::PictureBuffer>; |
50 | 50 |
51 // A BackingStrategy is responsible for making a PictureBuffer's texture | 51 // A BackingStrategy is responsible for making a PictureBuffer's texture |
52 // contain the image that a MediaCodec decoder buffer tells it to. | 52 // contain the image that a MediaCodec decoder buffer tells it to. |
53 class BackingStrategy { | 53 class BackingStrategy { |
54 public: | 54 public: |
55 virtual ~BackingStrategy() {} | 55 virtual ~BackingStrategy() {} |
56 | 56 |
57 // Must be called before anything else. If surface_view_id is not equal to | 57 // Must be called before anything else. If surface_view_id is not equal to |
58 // |kNoSurfaceID| it refers to a SurfaceView that the strategy must render | 58 // |kNoSurfaceID| it refers to a SurfaceView that the strategy must render |
59 // to. | 59 // to. |
60 // Returns the Java surface to configure MediaCodec with. | 60 // Returns the Java surface to configure MediaCodec with. |
61 virtual gfx::ScopedJavaSurface Initialize(int surface_view_id) = 0; | 61 virtual gl::ScopedJavaSurface Initialize(int surface_view_id) = 0; |
62 | 62 |
63 // Called before the AVDA does any Destroy() work. This will be | 63 // Called before the AVDA does any Destroy() work. This will be |
64 // the last call that the BackingStrategy receives. | 64 // the last call that the BackingStrategy receives. |
65 virtual void Cleanup(bool have_context, | 65 virtual void Cleanup(bool have_context, |
66 const OutputBufferMap& buffer_map) = 0; | 66 const OutputBufferMap& buffer_map) = 0; |
67 | 67 |
68 // This returns the SurfaceTexture created by Initialize, or nullptr if | 68 // This returns the SurfaceTexture created by Initialize, or nullptr if |
69 // the strategy was initialized with a SurfaceView. | 69 // the strategy was initialized with a SurfaceView. |
70 virtual scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture() const = 0; | 70 virtual scoped_refptr<gl::SurfaceTexture> GetSurfaceTexture() const = 0; |
71 | 71 |
72 // Return the GL texture target that the PictureBuffer textures use. | 72 // Return the GL texture target that the PictureBuffer textures use. |
73 virtual uint32_t GetTextureTarget() const = 0; | 73 virtual uint32_t GetTextureTarget() const = 0; |
74 | 74 |
75 // Return the size to use when requesting picture buffers. | 75 // Return the size to use when requesting picture buffers. |
76 virtual gfx::Size GetPictureBufferSize() const = 0; | 76 virtual gfx::Size GetPictureBufferSize() const = 0; |
77 | 77 |
78 // Make the provided PictureBuffer draw the image that is represented by | 78 // Make the provided PictureBuffer draw the image that is represented by |
79 // the decoded output buffer at codec_buffer_index. | 79 // the decoded output buffer at codec_buffer_index. |
80 virtual void UseCodecBufferForPictureBuffer( | 80 virtual void UseCodecBufferForPictureBuffer( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 CodecConfig(); | 187 CodecConfig(); |
188 | 188 |
189 // Codec type. Used when we configure media codec. | 189 // Codec type. Used when we configure media codec. |
190 media::VideoCodec codec_ = media::kUnknownVideoCodec; | 190 media::VideoCodec codec_ = media::kUnknownVideoCodec; |
191 | 191 |
192 // Whether encryption scheme requires to use protected surface. | 192 // Whether encryption scheme requires to use protected surface. |
193 bool needs_protected_surface_ = false; | 193 bool needs_protected_surface_ = false; |
194 | 194 |
195 // The surface that MediaCodec is configured to output to. It's created by | 195 // The surface that MediaCodec is configured to output to. It's created by |
196 // the backing strategy. | 196 // the backing strategy. |
197 gfx::ScopedJavaSurface surface_; | 197 gl::ScopedJavaSurface surface_; |
198 | 198 |
199 // The MediaCrypto object is used in the MediaCodec.configure() in case of | 199 // The MediaCrypto object is used in the MediaCodec.configure() in case of |
200 // an encrypted stream. | 200 // an encrypted stream. |
201 media::MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto_; | 201 media::MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto_; |
202 | 202 |
203 // Initial coded size. The actual size might change at any time, so this | 203 // Initial coded size. The actual size might change at any time, so this |
204 // is only a hint. | 204 // is only a hint. |
205 gfx::Size initial_expected_coded_size_; | 205 gfx::Size initial_expected_coded_size_; |
206 | 206 |
207 protected: | 207 protected: |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 | 462 |
463 // WeakPtrFactory for posting tasks back to |this|. | 463 // WeakPtrFactory for posting tasks back to |this|. |
464 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 464 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
465 | 465 |
466 friend class AndroidVideoDecodeAcceleratorTest; | 466 friend class AndroidVideoDecodeAcceleratorTest; |
467 }; | 467 }; |
468 | 468 |
469 } // namespace media | 469 } // namespace media |
470 | 470 |
471 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 471 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |