Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.h

Issue 1639963002: AndroidVideoDecodeAccelerator can now render to a SurfaceView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <map> 11 #include <map>
12 #include <queue> 12 #include <queue>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "base/timer/timer.h" 18 #include "base/timer/timer.h"
19 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
20 #include "content/common/gpu/media/avda_state_provider.h" 20 #include "content/common/gpu/media/avda_state_provider.h"
21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
22 #include "media/base/android/media_drm_bridge.h" 22 #include "media/base/android/media_drm_bridge.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/video/video_decode_accelerator.h" 25 #include "media/video/video_decode_accelerator.h"
26 #include "ui/gl/android/scoped_java_surface.h"
26 27
27 namespace gfx { 28 namespace gfx {
28 class SurfaceTexture; 29 class SurfaceTexture;
29 } 30 }
30 31
31 namespace content { 32 namespace content {
32 33
33 // A VideoDecodeAccelerator implementation for Android. 34 // A VideoDecodeAccelerator implementation for Android.
34 // This class decodes the input encoded stream by using Android's MediaCodec 35 // This class decodes the input encoded stream by using Android's MediaCodec
35 // class. http://developer.android.com/reference/android/media/MediaCodec.html 36 // class. http://developer.android.com/reference/android/media/MediaCodec.html
36 // It delegates attaching pictures to PictureBuffers to a BackingStrategy, but 37 // It delegates attaching pictures to PictureBuffers to a BackingStrategy, but
37 // otherwise handles the work of transferring data to / from MediaCodec. 38 // otherwise handles the work of transferring data to / from MediaCodec.
38 class CONTENT_EXPORT AndroidVideoDecodeAccelerator 39 class CONTENT_EXPORT AndroidVideoDecodeAccelerator
39 : public media::VideoDecodeAccelerator, 40 : public media::VideoDecodeAccelerator,
40 public AVDAStateProvider { 41 public AVDAStateProvider {
41 public: 42 public:
42 typedef std::map<int32_t, media::PictureBuffer> OutputBufferMap; 43 typedef std::map<int32_t, media::PictureBuffer> OutputBufferMap;
43 44
44 // A BackingStrategy is responsible for making a PictureBuffer's texture 45 // A BackingStrategy is responsible for making a PictureBuffer's texture
45 // contain the image that a MediaCodec decoder buffer tells it to. 46 // contain the image that a MediaCodec decoder buffer tells it to.
46 class BackingStrategy { 47 class BackingStrategy {
47 public: 48 public:
48 virtual ~BackingStrategy() {} 49 virtual ~BackingStrategy() {}
49 50
50 // Called after the state provider is given, but before any other 51 // Called before anything else. |surface_texture| will be null if the
51 // calls to the BackingStrategy. 52 // MediaCodec will be configured with a SurfaceView instead of a
52 virtual void Initialize(AVDAStateProvider* provider) = 0; 53 // SurfaceTexture.
54 virtual void Initialize(
55 AVDAStateProvider* provider,
56 scoped_refptr<gfx::SurfaceTexture> surface_texture) = 0;
53 57
54 // Called before the AVDA does any Destroy() work. This will be 58 // Called before the AVDA does any Destroy() work. This will be
55 // the last call that the BackingStrategy receives. 59 // the last call that the BackingStrategy receives.
56 virtual void Cleanup(bool have_context, 60 virtual void Cleanup(bool have_context,
57 const OutputBufferMap& buffer_map) = 0; 61 const OutputBufferMap& buffer_map) = 0;
58 62
59 // Return the GL texture target that the PictureBuffer textures use. 63 // Return the GL texture target that the PictureBuffer textures use.
60 virtual uint32_t GetTextureTarget() const = 0; 64 virtual uint32_t GetTextureTarget() const = 0;
61 65
62 // Create and return a surface texture for the MediaCodec to use.
63 virtual scoped_refptr<gfx::SurfaceTexture> CreateSurfaceTexture() = 0;
64
65 // Make the provided PictureBuffer draw the image that is represented by 66 // Make the provided PictureBuffer draw the image that is represented by
66 // the decoded output buffer at codec_buffer_index. 67 // the decoded output buffer at codec_buffer_index.
67 virtual void UseCodecBufferForPictureBuffer( 68 virtual void UseCodecBufferForPictureBuffer(
68 int32_t codec_buffer_index, 69 int32_t codec_buffer_index,
69 const media::PictureBuffer& picture_buffer) = 0; 70 const media::PictureBuffer& picture_buffer) = 0;
70 71
71 // Notify strategy that a picture buffer has been assigned. 72 // Notify strategy that a picture buffer has been assigned.
72 virtual void AssignOnePictureBuffer( 73 virtual void AssignOnePictureBuffer(
73 const media::PictureBuffer& picture_buffer) {} 74 const media::PictureBuffer& picture_buffer) {}
74 75
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 std::queue<int32_t> free_picture_ids_; 235 std::queue<int32_t> free_picture_ids_;
235 236
236 // Picture buffer ids which have been dismissed and not yet re-assigned. Used 237 // Picture buffer ids which have been dismissed and not yet re-assigned. Used
237 // to ignore ReusePictureBuffer calls that were in flight when the 238 // to ignore ReusePictureBuffer calls that were in flight when the
238 // DismissPictureBuffer call was made. 239 // DismissPictureBuffer call was made.
239 std::set<int32_t> dismissed_picture_ids_; 240 std::set<int32_t> dismissed_picture_ids_;
240 241
241 // The low-level decoder which Android SDK provides. 242 // The low-level decoder which Android SDK provides.
242 scoped_ptr<media::VideoCodecBridge> media_codec_; 243 scoped_ptr<media::VideoCodecBridge> media_codec_;
243 244
244 // A container of texture. Used to set a texture to |media_codec_|. 245 // A container of texture. Used to set a texture to |media_codec_|. This may
246 // be null if we're rendering to a SurfaceView instead.
245 scoped_refptr<gfx::SurfaceTexture> surface_texture_; 247 scoped_refptr<gfx::SurfaceTexture> surface_texture_;
246 248
249 // An Android SurfaceView to render to. This may be empty if we're
250 // rendering to a SurfaceTexture instead.
251 gfx::ScopedJavaSurface surface_view_;
252
247 // Set to true after requesting picture buffers to the client. 253 // Set to true after requesting picture buffers to the client.
248 bool picturebuffers_requested_; 254 bool picturebuffers_requested_;
249 255
250 // The resolution of the stream. 256 // The resolution of the stream.
251 gfx::Size size_; 257 gfx::Size size_;
252 258
253 // Encoded bitstream buffers to be passed to media codec, queued until an 259 // Encoded bitstream buffers to be passed to media codec, queued until an
254 // input buffer is available, along with the time when they were first 260 // input buffer is available, along with the time when they were first
255 // enqueued. 261 // enqueued.
256 typedef std::queue<std::pair<media::BitstreamBuffer, base::Time> > 262 typedef std::queue<std::pair<media::BitstreamBuffer, base::Time> >
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 308
303 // WeakPtrFactory for posting tasks back to |this|. 309 // WeakPtrFactory for posting tasks back to |this|.
304 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; 310 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_;
305 311
306 friend class AndroidVideoDecodeAcceleratorTest; 312 friend class AndroidVideoDecodeAcceleratorTest;
307 }; 313 };
308 314
309 } // namespace content 315 } // namespace content
310 316
311 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 317 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698