OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
watk
2015/08/28 21:52:05
s/2013/2015
liberato (no reviews please)
2015/09/04 17:59:47
Done.
| |
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_BASE_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_BASE_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | |
19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
20 #include "media/base/android/media_codec_bridge.h" | 19 #include "media/base/android/media_codec_bridge.h" |
21 #include "media/video/video_decode_accelerator.h" | 20 #include "media/video/video_decode_accelerator.h" |
22 | 21 |
23 namespace gfx { | 22 namespace gfx { |
24 class SurfaceTexture; | 23 class SurfaceTexture; |
25 } | 24 } |
26 | 25 |
27 namespace content { | 26 namespace content { |
28 // A VideoDecodeAccelerator implementation for Android. | 27 // A VideoDecodeAccelerator implementation for Android. |
29 // This class decodes the input encoded stream by using Android's MediaCodec | 28 // This class decodes the input encoded stream by using Android's MediaCodec |
30 // class. http://developer.android.com/reference/android/media/MediaCodec.html | 29 // class. http://developer.android.com/reference/android/media/MediaCodec.html |
watk
2015/08/28 21:52:05
Update this comment?
liberato (no reviews please)
2015/09/04 17:59:47
whoops! thanks!
| |
31 class CONTENT_EXPORT AndroidVideoDecodeAccelerator | 30 class CONTENT_EXPORT AndroidVideoDecodeAcceleratorBase |
32 : public media::VideoDecodeAccelerator { | 31 : public media::VideoDecodeAccelerator { |
33 public: | 32 public: |
34 // Does not take ownership of |client| which must outlive |*this|. | 33 // Does not take ownership of |client| which must outlive |*this|. |
watk
2015/08/28 21:52:05
Comment needs to go down a couple of lines
liberato (no reviews please)
2015/09/04 17:59:47
Done.
| |
35 AndroidVideoDecodeAccelerator( | 34 AndroidVideoDecodeAcceleratorBase( |
36 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, | 35 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, |
37 const base::Callback<bool(void)>& make_context_current); | 36 const base::Callback<bool(void)>& make_context_current); |
38 | 37 |
39 // media::VideoDecodeAccelerator implementation. | 38 // media::VideoDecodeAccelerator implementation. |
40 bool Initialize(media::VideoCodecProfile profile, Client* client) override; | 39 bool Initialize(media::VideoCodecProfile profile, Client* client) override; |
41 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 40 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
42 void AssignPictureBuffers( | 41 void AssignPictureBuffers( |
43 const std::vector<media::PictureBuffer>& buffers) override; | 42 const std::vector<media::PictureBuffer>& buffers) override; |
44 void ReusePictureBuffer(int32 picture_buffer_id) override; | 43 void ReusePictureBuffer(int32 picture_buffer_id) override; |
45 void Flush() override; | 44 void Flush() override; |
46 void Reset() override; | 45 void Reset() override; |
47 void Destroy() override; | 46 void Destroy() override; |
48 bool CanDecodeOnIOThread() override; | 47 bool CanDecodeOnIOThread() override; |
49 | 48 |
50 static media::VideoDecodeAccelerator::SupportedProfiles | 49 static media::VideoDecodeAccelerator::SupportedProfiles |
51 GetSupportedProfiles(); | 50 GetSupportedProfiles(); |
52 | 51 |
52 protected: | |
53 ~AndroidVideoDecodeAcceleratorBase() override; | |
54 | |
55 // Return the number of picture buffers that the implementation would like. | |
56 // TODO(liberato): this isn't used much, and can probably be removed. | |
57 virtual uint32 GetNumPictureBuffers() const = 0; | |
58 | |
59 // Return the GL texture target that the PictureBuffers will use. | |
60 virtual uint32 GetTextureTarget() const = 0; | |
61 | |
62 // Use the provided PictureBuffer to hold the current surface. | |
63 virtual void AssignCurrentSurfaceToPictureBuffer(int32 codec_buffer_index, | |
64 const media::PictureBuffer&) = 0; | |
65 | |
66 // Misc getters for subclasses. | |
67 Client* GetClient() const; | |
68 const gfx::Size& GetSize() const; | |
69 const base::ThreadChecker& ThreadChecker() const; | |
70 gfx::SurfaceTexture* GetSurfaceTexture() const; | |
71 uint32 GetSurfaceTextureId() const; | |
72 gpu::gles2::GLES2Decoder* GetGlDecoder() const; | |
73 media::VideoCodecBridge* GetMediaCodec(); | |
74 | |
53 private: | 75 private: |
54 enum State { | 76 enum State { |
55 NO_ERROR, | 77 NO_ERROR, |
56 ERROR, | 78 ERROR, |
57 }; | 79 }; |
58 | 80 |
59 static const base::TimeDelta kDecodePollDelay; | 81 static const base::TimeDelta kDecodePollDelay; |
60 | 82 |
61 ~AndroidVideoDecodeAccelerator() override; | |
62 | |
63 // Configures |media_codec_| with the given codec parameters from the client. | 83 // Configures |media_codec_| with the given codec parameters from the client. |
64 bool ConfigureMediaCodec(); | 84 bool ConfigureMediaCodec(); |
65 | 85 |
66 // Sends the current picture on the surface to the client. | 86 // Sends the current picture on the surface to the client. |
67 void SendCurrentSurfaceToClient(int32 bitstream_id); | 87 void SendCurrentSurfaceToClient(int32 codec_buffer_index, int32 bitstream_id); |
68 | 88 |
69 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| | 89 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| |
70 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is | 90 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is |
71 // used. | 91 // used. |
72 void DoIOTask(); | 92 void DoIOTask(); |
73 | 93 |
74 // Feeds input data to |media_codec_|. This checks | 94 // Feeds input data to |media_codec_|. This checks |
75 // |pending_bitstream_buffers_| and queues a buffer to |media_codec_|. | 95 // |pending_bitstream_buffers_| and queues a buffer to |media_codec_|. |
76 void QueueInput(); | 96 void QueueInput(); |
77 | 97 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 PendingBitstreamBuffers; | 170 PendingBitstreamBuffers; |
151 PendingBitstreamBuffers pending_bitstream_buffers_; | 171 PendingBitstreamBuffers pending_bitstream_buffers_; |
152 | 172 |
153 // Keeps track of bitstream ids notified to the client with | 173 // Keeps track of bitstream ids notified to the client with |
154 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. | 174 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. |
155 std::list<int32> bitstreams_notified_in_advance_; | 175 std::list<int32> bitstreams_notified_in_advance_; |
156 | 176 |
157 // Owner of the GL context. Used to restore the context state. | 177 // Owner of the GL context. Used to restore the context state. |
158 base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_; | 178 base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_; |
159 | 179 |
160 // Used for copy the texture from |surface_texture_| to picture buffers. | |
161 scoped_ptr<gpu::CopyTextureCHROMIUMResourceManager> copier_; | |
162 | |
163 // Repeating timer responsible for draining pending IO to the codec. | 180 // Repeating timer responsible for draining pending IO to the codec. |
164 base::RepeatingTimer<AndroidVideoDecodeAccelerator> io_timer_; | 181 base::RepeatingTimer<AndroidVideoDecodeAcceleratorBase> io_timer_; |
165 | 182 |
166 // WeakPtrFactory for posting tasks back to |this|. | 183 // WeakPtrFactory for posting tasks back to |this|. |
167 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 184 base::WeakPtrFactory<AndroidVideoDecodeAcceleratorBase> weak_this_factory_; |
168 | 185 |
169 friend class AndroidVideoDecodeAcceleratorTest; | 186 friend class AndroidVideoDecodeAcceleratorTest; |
170 }; | 187 }; |
171 | 188 |
172 } // namespace content | 189 } // namespace content |
173 | 190 |
174 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 191 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_BASE_H_ |
OLD | NEW |