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 25 matching lines...) Expand all Loading... |
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 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, 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. |
(...skipping 12 matching lines...) Expand all Loading... |
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( |
81 int32_t codec_buffer_index, | 81 int32_t codec_buffer_index, |
82 const media::PictureBuffer& picture_buffer) = 0; | 82 const PictureBuffer& picture_buffer) = 0; |
83 | 83 |
84 // Notify strategy that a picture buffer has been assigned. | 84 // Notify strategy that a picture buffer has been assigned. |
85 virtual void AssignOnePictureBuffer( | 85 virtual void AssignOnePictureBuffer(const PictureBuffer& picture_buffer, |
86 const media::PictureBuffer& picture_buffer, | 86 bool have_context) {} |
87 bool have_context) {} | |
88 | 87 |
89 // Notify strategy that a picture buffer has been reused. | 88 // Notify strategy that a picture buffer has been reused. |
90 virtual void ReuseOnePictureBuffer( | 89 virtual void ReuseOnePictureBuffer(const PictureBuffer& picture_buffer) {} |
91 const media::PictureBuffer& picture_buffer) {} | |
92 | 90 |
93 // Release MediaCodec buffers. | 91 // Release MediaCodec buffers. |
94 virtual void ReleaseCodecBuffers( | 92 virtual void ReleaseCodecBuffers( |
95 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) {} | 93 const AndroidVideoDecodeAccelerator::OutputBufferMap& buffers) {} |
96 | 94 |
97 // Attempts to free up codec output buffers by rendering early. | 95 // Attempts to free up codec output buffers by rendering early. |
98 virtual void MaybeRenderEarly() {} | 96 virtual void MaybeRenderEarly() {} |
99 | 97 |
100 // Notify strategy that we have a new android MediaCodec instance. This | 98 // Notify strategy that we have a new android MediaCodec instance. This |
101 // happens when we're starting up or re-configuring mid-stream. Any | 99 // happens when we're starting up or re-configuring mid-stream. Any |
102 // previously provided codec should no longer be referenced. | 100 // previously provided codec should no longer be referenced. |
103 virtual void CodecChanged(media::VideoCodecBridge* codec) = 0; | 101 virtual void CodecChanged(VideoCodecBridge* codec) = 0; |
104 | 102 |
105 // Notify the strategy that a frame is available. This callback can happen | 103 // Notify the strategy that a frame is available. This callback can happen |
106 // on any thread at any time. | 104 // on any thread at any time. |
107 virtual void OnFrameAvailable() = 0; | 105 virtual void OnFrameAvailable() = 0; |
108 | 106 |
109 // Whether the pictures produced by this backing strategy are overlayable. | 107 // Whether the pictures produced by this backing strategy are overlayable. |
110 virtual bool ArePicturesOverlayable() = 0; | 108 virtual bool ArePicturesOverlayable() = 0; |
111 | 109 |
112 // Size may have changed due to resolution change since the last time this | 110 // Size may have changed due to resolution change since the last time this |
113 // PictureBuffer was used. Update the size of the picture buffer to | 111 // PictureBuffer was used. Update the size of the picture buffer to |
114 // |new_size| and also update any size-dependent state (e.g. size of | 112 // |new_size| and also update any size-dependent state (e.g. size of |
115 // associated texture). Callers should set the correct GL context prior to | 113 // associated texture). Callers should set the correct GL context prior to |
116 // calling. | 114 // calling. |
117 virtual void UpdatePictureBufferSize(media::PictureBuffer* picture_buffer, | 115 virtual void UpdatePictureBufferSize(PictureBuffer* picture_buffer, |
118 const gfx::Size& new_size) = 0; | 116 const gfx::Size& new_size) = 0; |
119 }; | 117 }; |
120 | 118 |
121 AndroidVideoDecodeAccelerator( | 119 AndroidVideoDecodeAccelerator( |
122 const MakeGLContextCurrentCallback& make_context_current_cb, | 120 const MakeGLContextCurrentCallback& make_context_current_cb, |
123 const GetGLES2DecoderCallback& get_gles2_decoder_cb); | 121 const GetGLES2DecoderCallback& get_gles2_decoder_cb); |
124 | 122 |
125 ~AndroidVideoDecodeAccelerator() override; | 123 ~AndroidVideoDecodeAccelerator() override; |
126 | 124 |
127 // media::VideoDecodeAccelerator implementation: | 125 // VideoDecodeAccelerator implementation: |
128 bool Initialize(const Config& config, Client* client) override; | 126 bool Initialize(const Config& config, Client* client) override; |
129 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 127 void Decode(const BitstreamBuffer& bitstream_buffer) override; |
130 void AssignPictureBuffers( | 128 void AssignPictureBuffers(const std::vector<PictureBuffer>& buffers) override; |
131 const std::vector<media::PictureBuffer>& buffers) override; | |
132 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 129 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
133 void Flush() override; | 130 void Flush() override; |
134 void Reset() override; | 131 void Reset() override; |
135 void Destroy() override; | 132 void Destroy() override; |
136 bool TryToSetupDecodeOnSeparateThread( | 133 bool TryToSetupDecodeOnSeparateThread( |
137 const base::WeakPtr<Client>& decode_client, | 134 const base::WeakPtr<Client>& decode_client, |
138 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) | 135 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
139 override; | 136 override; |
140 | 137 |
141 // AVDAStateProvider implementation: | 138 // AVDAStateProvider implementation: |
142 const gfx::Size& GetSize() const override; | 139 const gfx::Size& GetSize() const override; |
143 const base::ThreadChecker& ThreadChecker() const override; | 140 const base::ThreadChecker& ThreadChecker() const override; |
144 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; | 141 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; |
145 gpu::gles2::TextureRef* GetTextureForPicture( | 142 gpu::gles2::TextureRef* GetTextureForPicture( |
146 const media::PictureBuffer& picture_buffer) override; | 143 const PictureBuffer& picture_buffer) override; |
147 scoped_refptr<gl::SurfaceTexture> CreateAttachedSurfaceTexture( | 144 scoped_refptr<gl::SurfaceTexture> CreateAttachedSurfaceTexture( |
148 GLuint* service_id) override; | 145 GLuint* service_id) override; |
149 void PostError(const ::tracked_objects::Location& from_here, | 146 void PostError(const ::tracked_objects::Location& from_here, |
150 media::VideoDecodeAccelerator::Error error) override; | 147 VideoDecodeAccelerator::Error error) override; |
151 | 148 |
152 static media::VideoDecodeAccelerator::Capabilities GetCapabilities( | 149 static VideoDecodeAccelerator::Capabilities GetCapabilities( |
153 const gpu::GpuPreferences& gpu_preferences); | 150 const gpu::GpuPreferences& gpu_preferences); |
154 | 151 |
155 // Notifies about SurfaceTexture::OnFrameAvailable. This can happen on any | 152 // Notifies about SurfaceTexture::OnFrameAvailable. This can happen on any |
156 // thread at any time! | 153 // thread at any time! |
157 void OnFrameAvailable(); | 154 void OnFrameAvailable(); |
158 | 155 |
159 private: | 156 private: |
160 friend class AVDATimerManager; | 157 friend class AVDATimerManager; |
161 | 158 |
162 // TODO(timav): evaluate the need for more states in the AVDA state machine. | 159 // TODO(timav): evaluate the need for more states in the AVDA state machine. |
(...skipping 19 matching lines...) Expand all Loading... |
182 | 179 |
183 // Configuration info for MediaCodec. | 180 // Configuration info for MediaCodec. |
184 // This is used to shuttle configuration info between threads without needing | 181 // This is used to shuttle configuration info between threads without needing |
185 // to worry about the lifetime of the AVDA instance. All of these should not | 182 // to worry about the lifetime of the AVDA instance. All of these should not |
186 // be modified while |state_| is WAITING_FOR_CODEC. | 183 // be modified while |state_| is WAITING_FOR_CODEC. |
187 class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> { | 184 class CodecConfig : public base::RefCountedThreadSafe<CodecConfig> { |
188 public: | 185 public: |
189 CodecConfig(); | 186 CodecConfig(); |
190 | 187 |
191 // Codec type. Used when we configure media codec. | 188 // Codec type. Used when we configure media codec. |
192 media::VideoCodec codec_ = media::kUnknownVideoCodec; | 189 VideoCodec codec_ = kUnknownVideoCodec; |
193 | 190 |
194 // Whether encryption scheme requires to use protected surface. | 191 // Whether encryption scheme requires to use protected surface. |
195 bool needs_protected_surface_ = false; | 192 bool needs_protected_surface_ = false; |
196 | 193 |
197 // The surface that MediaCodec is configured to output to. It's created by | 194 // The surface that MediaCodec is configured to output to. It's created by |
198 // the backing strategy. | 195 // the backing strategy. |
199 gl::ScopedJavaSurface surface_; | 196 gl::ScopedJavaSurface surface_; |
200 | 197 |
201 // The MediaCrypto object is used in the MediaCodec.configure() in case of | 198 // The MediaCrypto object is used in the MediaCodec.configure() in case of |
202 // an encrypted stream. | 199 // an encrypted stream. |
203 media::MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto_; | 200 MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto_; |
204 | 201 |
205 // Initial coded size. The actual size might change at any time, so this | 202 // Initial coded size. The actual size might change at any time, so this |
206 // is only a hint. | 203 // is only a hint. |
207 gfx::Size initial_expected_coded_size_; | 204 gfx::Size initial_expected_coded_size_; |
208 | 205 |
209 protected: | 206 protected: |
210 friend class base::RefCountedThreadSafe<CodecConfig>; | 207 friend class base::RefCountedThreadSafe<CodecConfig>; |
211 virtual ~CodecConfig(); | 208 virtual ~CodecConfig(); |
212 | 209 |
213 private: | 210 private: |
(...skipping 24 matching lines...) Expand all Loading... |
238 void ConfigureMediaCodecAsynchronously(); | 235 void ConfigureMediaCodecAsynchronously(); |
239 | 236 |
240 // Like ConfigureMediaCodecAsynchronously, but synchronous. Returns true if | 237 // Like ConfigureMediaCodecAsynchronously, but synchronous. Returns true if |
241 // and only if |media_codec_| is non-null. Since all configuration is done | 238 // and only if |media_codec_| is non-null. Since all configuration is done |
242 // synchronously, there is no concern with modifying |codec_config_| after | 239 // synchronously, there is no concern with modifying |codec_config_| after |
243 // this returns. | 240 // this returns. |
244 bool ConfigureMediaCodecSynchronously(); | 241 bool ConfigureMediaCodecSynchronously(); |
245 | 242 |
246 // Instantiate a media codec using |codec_config|. | 243 // Instantiate a media codec using |codec_config|. |
247 // This may be called on any thread. | 244 // This may be called on any thread. |
248 static std::unique_ptr<media::VideoCodecBridge> | 245 static std::unique_ptr<VideoCodecBridge> ConfigureMediaCodecOnAnyThread( |
249 ConfigureMediaCodecOnAnyThread(scoped_refptr<CodecConfig> codec_config); | 246 scoped_refptr<CodecConfig> codec_config); |
250 | 247 |
251 // Called on the main thread to update |media_codec_| and complete codec | 248 // Called on the main thread to update |media_codec_| and complete codec |
252 // configuration. |media_codec| will be null if configuration failed. | 249 // configuration. |media_codec| will be null if configuration failed. |
253 void OnCodecConfigured(std::unique_ptr<media::VideoCodecBridge> media_codec); | 250 void OnCodecConfigured(std::unique_ptr<VideoCodecBridge> media_codec); |
254 | 251 |
255 // Sends the decoded frame specified by |codec_buffer_index| to the client. | 252 // Sends the decoded frame specified by |codec_buffer_index| to the client. |
256 void SendDecodedFrameToClient(int32_t codec_buffer_index, | 253 void SendDecodedFrameToClient(int32_t codec_buffer_index, |
257 int32_t bitstream_id); | 254 int32_t bitstream_id); |
258 | 255 |
259 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| | 256 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| |
260 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is | 257 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is |
261 // used. | 258 // used. |
262 void DoIOTask(bool start_timer); | 259 void DoIOTask(bool start_timer); |
263 | 260 |
264 // Feeds input data to |media_codec_|. This checks | 261 // Feeds input data to |media_codec_|. This checks |
265 // |pending_bitstream_buffers_| and queues a buffer to |media_codec_|. | 262 // |pending_bitstream_buffers_| and queues a buffer to |media_codec_|. |
266 // Returns true if any input was processed. | 263 // Returns true if any input was processed. |
267 bool QueueInput(); | 264 bool QueueInput(); |
268 | 265 |
269 // Dequeues output from |media_codec_| and feeds the decoded frame to the | 266 // Dequeues output from |media_codec_| and feeds the decoded frame to the |
270 // client. Returns a hint about whether calling again might produce | 267 // client. Returns a hint about whether calling again might produce |
271 // more output. | 268 // more output. |
272 bool DequeueOutput(); | 269 bool DequeueOutput(); |
273 | 270 |
274 // Requests picture buffers from the client. | 271 // Requests picture buffers from the client. |
275 void RequestPictureBuffers(); | 272 void RequestPictureBuffers(); |
276 | 273 |
277 // Decode the content in the |bitstream_buffer|. Note that a | 274 // Decode the content in the |bitstream_buffer|. Note that a |
278 // |bitstream_buffer| of id as -1 indicates a flush command. | 275 // |bitstream_buffer| of id as -1 indicates a flush command. |
279 void DecodeBuffer(const media::BitstreamBuffer& bitstream_buffer); | 276 void DecodeBuffer(const BitstreamBuffer& bitstream_buffer); |
280 | 277 |
281 // Called during Initialize() for encrypted streams to set up the CDM. | 278 // Called during Initialize() for encrypted streams to set up the CDM. |
282 void InitializeCdm(); | 279 void InitializeCdm(); |
283 | 280 |
284 // Called after the CDM obtains a MediaCrypto object. | 281 // Called after the CDM obtains a MediaCrypto object. |
285 void OnMediaCryptoReady( | 282 void OnMediaCryptoReady(MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto, |
286 media::MediaDrmBridgeCdmContext::JavaObjectPtr media_crypto, | 283 bool needs_protected_surface); |
287 bool needs_protected_surface); | |
288 | 284 |
289 // Called when a new key is added to the CDM. | 285 // Called when a new key is added to the CDM. |
290 void OnKeyAdded(); | 286 void OnKeyAdded(); |
291 | 287 |
292 // Notifies the client of the result of deferred initialization. | 288 // Notifies the client of the result of deferred initialization. |
293 void NotifyInitializationComplete(bool success); | 289 void NotifyInitializationComplete(bool success); |
294 | 290 |
295 // Notifies the client about the availability of a picture. | 291 // Notifies the client about the availability of a picture. |
296 void NotifyPictureReady(const media::Picture& picture); | 292 void NotifyPictureReady(const Picture& picture); |
297 | 293 |
298 // Notifies the client that the input buffer identifed by input_buffer_id has | 294 // Notifies the client that the input buffer identifed by input_buffer_id has |
299 // been processed. | 295 // been processed. |
300 void NotifyEndOfBitstreamBuffer(int input_buffer_id); | 296 void NotifyEndOfBitstreamBuffer(int input_buffer_id); |
301 | 297 |
302 // Notifies the client that the decoder was flushed. | 298 // Notifies the client that the decoder was flushed. |
303 void NotifyFlushDone(); | 299 void NotifyFlushDone(); |
304 | 300 |
305 // Notifies the client that the decoder was reset. | 301 // Notifies the client that the decoder was reset. |
306 void NotifyResetDone(); | 302 void NotifyResetDone(); |
307 | 303 |
308 // Notifies about decoding errors. | 304 // Notifies about decoding errors. |
309 // Note: you probably don't want to call this directly. Use PostError or | 305 // Note: you probably don't want to call this directly. Use PostError or |
310 // RETURN_ON_FAILURE, since we can defer error reporting to keep the pipeline | 306 // RETURN_ON_FAILURE, since we can defer error reporting to keep the pipeline |
311 // from breaking. NotifyError will do so immediately, PostError may wait. | 307 // from breaking. NotifyError will do so immediately, PostError may wait. |
312 // |token| has to match |error_sequence_token_|, or else it's assumed to be | 308 // |token| has to match |error_sequence_token_|, or else it's assumed to be |
313 // from a post that's prior to a previous reset, and ignored. | 309 // from a post that's prior to a previous reset, and ignored. |
314 void NotifyError(media::VideoDecodeAccelerator::Error error, int token); | 310 void NotifyError(VideoDecodeAccelerator::Error error, int token); |
315 | 311 |
316 // Start or stop our work-polling timer based on whether we did any work, and | 312 // Start or stop our work-polling timer based on whether we did any work, and |
317 // how long it has been since we've done work. Calling this with true will | 313 // how long it has been since we've done work. Calling this with true will |
318 // start the timer. Calling it with false may stop the timer. | 314 // start the timer. Calling it with false may stop the timer. |
319 void ManageTimer(bool did_work); | 315 void ManageTimer(bool did_work); |
320 | 316 |
321 // Start the MediaCodec drain process by adding end_of_stream() buffer to the | 317 // Start the MediaCodec drain process by adding end_of_stream() buffer to the |
322 // encoded buffers queue. When we receive EOS from the output buffer the drain | 318 // encoded buffers queue. When we receive EOS from the output buffer the drain |
323 // process completes and we perform the action depending on the |drain_type|. | 319 // process completes and we perform the action depending on the |drain_type|. |
324 void StartCodecDrain(DrainType drain_type); | 320 void StartCodecDrain(DrainType drain_type); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 362 |
367 // This map maintains the picture buffers passed to the client for decoding. | 363 // This map maintains the picture buffers passed to the client for decoding. |
368 // The key is the picture buffer id. | 364 // The key is the picture buffer id. |
369 OutputBufferMap output_picture_buffers_; | 365 OutputBufferMap output_picture_buffers_; |
370 | 366 |
371 // This keeps the free picture buffer ids which can be used for sending | 367 // This keeps the free picture buffer ids which can be used for sending |
372 // decoded frames to the client. | 368 // decoded frames to the client. |
373 std::queue<int32_t> free_picture_ids_; | 369 std::queue<int32_t> free_picture_ids_; |
374 | 370 |
375 // The low-level decoder which Android SDK provides. | 371 // The low-level decoder which Android SDK provides. |
376 std::unique_ptr<media::VideoCodecBridge> media_codec_; | 372 std::unique_ptr<VideoCodecBridge> media_codec_; |
377 | 373 |
378 // Set to true after requesting picture buffers to the client. | 374 // Set to true after requesting picture buffers to the client. |
379 bool picturebuffers_requested_; | 375 bool picturebuffers_requested_; |
380 | 376 |
381 // The resolution of the stream. | 377 // The resolution of the stream. |
382 gfx::Size size_; | 378 gfx::Size size_; |
383 | 379 |
384 // Handy structure to remember a BitstreamBuffer and also its shared memory, | 380 // Handy structure to remember a BitstreamBuffer and also its shared memory, |
385 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory | 381 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory |
386 // handle open. | 382 // handle open. |
387 struct BitstreamRecord { | 383 struct BitstreamRecord { |
388 BitstreamRecord(const media::BitstreamBuffer&); | 384 BitstreamRecord(const BitstreamBuffer&); |
389 BitstreamRecord(BitstreamRecord&& other); | 385 BitstreamRecord(BitstreamRecord&& other); |
390 ~BitstreamRecord(); | 386 ~BitstreamRecord(); |
391 | 387 |
392 media::BitstreamBuffer buffer; | 388 BitstreamBuffer buffer; |
393 | 389 |
394 // |memory| is not mapped, and may be null if buffer has no data. | 390 // |memory| is not mapped, and may be null if buffer has no data. |
395 std::unique_ptr<SharedMemoryRegion> memory; | 391 std::unique_ptr<SharedMemoryRegion> memory; |
396 }; | 392 }; |
397 | 393 |
398 // Encoded bitstream buffers to be passed to media codec, queued until an | 394 // Encoded bitstream buffers to be passed to media codec, queued until an |
399 // input buffer is available. | 395 // input buffer is available. |
400 std::queue<BitstreamRecord> pending_bitstream_records_; | 396 std::queue<BitstreamRecord> pending_bitstream_records_; |
401 | 397 |
402 // A map of presentation timestamp to bitstream buffer id for the bitstream | 398 // A map of presentation timestamp to bitstream buffer id for the bitstream |
(...skipping 14 matching lines...) Expand all Loading... |
417 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; | 413 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; |
418 | 414 |
419 // Time at which we last did useful work on io_timer_. | 415 // Time at which we last did useful work on io_timer_. |
420 base::TimeTicks most_recent_work_; | 416 base::TimeTicks most_recent_work_; |
421 | 417 |
422 // Type of a drain request. We need to distinguish between DRAIN_FOR_FLUSH | 418 // Type of a drain request. We need to distinguish between DRAIN_FOR_FLUSH |
423 // and other types, see IsDrainingForResetOrDestroy(). | 419 // and other types, see IsDrainingForResetOrDestroy(). |
424 DrainType drain_type_; | 420 DrainType drain_type_; |
425 | 421 |
426 // Holds a ref-count to the CDM to avoid using the CDM after it's destroyed. | 422 // Holds a ref-count to the CDM to avoid using the CDM after it's destroyed. |
427 scoped_refptr<media::MediaKeys> cdm_for_reference_holding_only_; | 423 scoped_refptr<MediaKeys> cdm_for_reference_holding_only_; |
428 | 424 |
429 media::MediaDrmBridgeCdmContext* media_drm_bridge_cdm_context_; | 425 MediaDrmBridgeCdmContext* media_drm_bridge_cdm_context_; |
430 | 426 |
431 // MediaDrmBridge requires registration/unregistration of the player, this | 427 // MediaDrmBridge requires registration/unregistration of the player, this |
432 // registration id is used for this. | 428 // registration id is used for this. |
433 int cdm_registration_id_; | 429 int cdm_registration_id_; |
434 | 430 |
435 // Configuration that we use for MediaCodec. | 431 // Configuration that we use for MediaCodec. |
436 // Do not update any of its members while |state_| is WAITING_FOR_CODEC. | 432 // Do not update any of its members while |state_| is WAITING_FOR_CODEC. |
437 scoped_refptr<CodecConfig> codec_config_; | 433 scoped_refptr<CodecConfig> codec_config_; |
438 | 434 |
439 // Index of the dequeued and filled buffer that we keep trying to enqueue. | 435 // Index of the dequeued and filled buffer that we keep trying to enqueue. |
(...skipping 23 matching lines...) Expand all Loading... |
463 | 459 |
464 // WeakPtrFactory for posting tasks back to |this|. | 460 // WeakPtrFactory for posting tasks back to |this|. |
465 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 461 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
466 | 462 |
467 friend class AndroidVideoDecodeAcceleratorTest; | 463 friend class AndroidVideoDecodeAcceleratorTest; |
468 }; | 464 }; |
469 | 465 |
470 } // namespace media | 466 } // namespace media |
471 | 467 |
472 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 468 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |