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

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

Issue 1313913003: Begin refactor of AVDA to support zero-copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: refactored into composable pieces, to see if it looks nicer. Created 5 years, 3 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) 2015 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_IMPL_H_
6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_IMPL_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" 18 #include "content/common/gpu/media/android_video_decode_accelerator.h"
19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
20 #include "media/base/android/media_codec_bridge.h" 20 #include "media/base/android/media_codec_bridge.h"
21 #include "media/video/video_decode_accelerator.h" 21 #include "media/video/video_decode_accelerator.h"
22 22
23 namespace gfx { 23 namespace gfx {
24 class SurfaceTexture; 24 class SurfaceTexture;
25 } 25 }
26 26
27 namespace content { 27 namespace content {
28 // A VideoDecodeAccelerator implementation for Android. 28 // Implementation of a VideoDecodeAccelerator for Android.
29 // This class decodes the input encoded stream by using Android's MediaCodec 29 // This class decodes the input encoded stream by using Android's MediaCodec
30 // class. http://developer.android.com/reference/android/media/MediaCodec.html 30 // class. http://developer.android.com/reference/android/media/MediaCodec.html
31 class CONTENT_EXPORT AndroidVideoDecodeAccelerator 31 // It delegates attaching pictures to PictureBuffers to the BackingStrategy,
32 : public media::VideoDecodeAccelerator { 32 // but otherwise handles the work of transferring data to / from MediaCodec.
33 class CONTENT_EXPORT AndroidVideoDecodeAcceleratorImpl
sandersd (OOO until July 31) 2015/09/04 22:12:52 It seems like this would be better as just Android
liberato (no reviews please) 2015/09/08 19:50:00 it was a forward reference management strategy. i
34 : public AndroidVideoDecodeAccelerator
35 , public AndroidVideoDecodeAccelerator::StateProvider {
33 public: 36 public:
37
34 // Does not take ownership of |client| which must outlive |*this|. 38 // Does not take ownership of |client| which must outlive |*this|.
35 AndroidVideoDecodeAccelerator(
36 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
37 const base::Callback<bool(void)>& make_context_current);
38
39 // 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 // AndroidVideoDecodeAccelerator::StateProvider
51 GetSupportedProfiles(); 50 const gfx::Size& GetSize() const override;
51 const base::ThreadChecker& ThreadChecker() const override;
52 gfx::SurfaceTexture* GetSurfaceTexture() const override;
53 uint32 GetSurfaceTextureId() const override;
54 gpu::gles2::GLES2Decoder* GetGlDecoder() const override;
55 media::VideoCodecBridge* GetMediaCodec() override;
56 void PostError(const ::tracked_objects::Location& from_here,
57 media::VideoDecodeAccelerator::Error error) override;
58
59 protected:
60 AndroidVideoDecodeAcceleratorImpl(
61 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder,
62 const base::Callback<bool(void)>& make_context_current,
63 scoped_refptr<BackingStrategy> strategy);
64 ~AndroidVideoDecodeAcceleratorImpl() override;
52 65
53 private: 66 private:
54 enum State { 67 enum State {
55 NO_ERROR, 68 NO_ERROR,
56 ERROR, 69 ERROR,
57 }; 70 };
58 71
59 static const base::TimeDelta kDecodePollDelay; 72 static const base::TimeDelta kDecodePollDelay;
60 73
61 ~AndroidVideoDecodeAccelerator() override;
62
63 // Configures |media_codec_| with the given codec parameters from the client. 74 // Configures |media_codec_| with the given codec parameters from the client.
64 bool ConfigureMediaCodec(); 75 bool ConfigureMediaCodec();
65 76
66 // Sends the current picture on the surface to the client. 77 // Sends the current picture on the surface to the client.
67 void SendCurrentSurfaceToClient(int32 bitstream_id); 78 void SendCurrentSurfaceToClient(int32 codec_buffer_index, int32 bitstream_id);
68 79
69 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| 80 // 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 81 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is
71 // used. 82 // used.
72 void DoIOTask(); 83 void DoIOTask();
73 84
74 // Feeds input data to |media_codec_|. This checks 85 // Feeds input data to |media_codec_|. This checks
75 // |pending_bitstream_buffers_| and queues a buffer to |media_codec_|. 86 // |pending_bitstream_buffers_| and queues a buffer to |media_codec_|.
76 void QueueInput(); 87 void QueueInput();
77 88
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 PendingBitstreamBuffers; 161 PendingBitstreamBuffers;
151 PendingBitstreamBuffers pending_bitstream_buffers_; 162 PendingBitstreamBuffers pending_bitstream_buffers_;
152 163
153 // Keeps track of bitstream ids notified to the client with 164 // Keeps track of bitstream ids notified to the client with
154 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream. 165 // NotifyEndOfBitstreamBuffer() before getting output from the bitstream.
155 std::list<int32> bitstreams_notified_in_advance_; 166 std::list<int32> bitstreams_notified_in_advance_;
156 167
157 // Owner of the GL context. Used to restore the context state. 168 // Owner of the GL context. Used to restore the context state.
158 base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_; 169 base::WeakPtr<gpu::gles2::GLES2Decoder> gl_decoder_;
159 170
160 // Used for copy the texture from |surface_texture_| to picture buffers. 171 // Repeating timer responsible for draining pending IO to the codec.
161 scoped_ptr<gpu::CopyTextureCHROMIUMResourceManager> copier_; 172 base::RepeatingTimer<AndroidVideoDecodeAcceleratorImpl> io_timer_;
162 173
163 // Repeating timer responsible for draining pending IO to the codec. 174 // Backing strategy that we'll use to connect PictureBuffers to frames.
164 base::RepeatingTimer<AndroidVideoDecodeAccelerator> io_timer_; 175 scoped_refptr<BackingStrategy> strategy_;
165 176
166 // WeakPtrFactory for posting tasks back to |this|. 177 // WeakPtrFactory for posting tasks back to |this|.
167 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; 178 base::WeakPtrFactory<AndroidVideoDecodeAcceleratorImpl> weak_this_factory_;
168 179
169 friend class AndroidVideoDecodeAcceleratorTest; 180 friend class AndroidVideoDecodeAcceleratorTest;
170 }; 181 };
171 182
172 } // namespace content 183 } // namespace content
173 184
174 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ 185 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698