| 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> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/optional.h" |
| 16 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
| 17 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 19 #include "gpu/command_buffer/service/gpu_preferences.h" | 20 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 20 #include "media/base/android/media_drm_bridge_cdm_context.h" | 21 #include "media/base/android/media_drm_bridge_cdm_context.h" |
| 21 #include "media/base/android/sdk_media_codec_bridge.h" | 22 #include "media/base/android/sdk_media_codec_bridge.h" |
| 22 #include "media/base/media_keys.h" | 23 #include "media/base/media_keys.h" |
| 23 #include "media/gpu/avda_codec_allocator.h" | 24 #include "media/gpu/avda_codec_allocator.h" |
| 24 #include "media/gpu/avda_picture_buffer_manager.h" | 25 #include "media/gpu/avda_picture_buffer_manager.h" |
| 25 #include "media/gpu/avda_state_provider.h" | 26 #include "media/gpu/avda_state_provider.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 | 51 |
| 51 ~AndroidVideoDecodeAccelerator() override; | 52 ~AndroidVideoDecodeAccelerator() override; |
| 52 | 53 |
| 53 // VideoDecodeAccelerator implementation: | 54 // VideoDecodeAccelerator implementation: |
| 54 bool Initialize(const Config& config, Client* client) override; | 55 bool Initialize(const Config& config, Client* client) override; |
| 55 void Decode(const BitstreamBuffer& bitstream_buffer) override; | 56 void Decode(const BitstreamBuffer& bitstream_buffer) override; |
| 56 void AssignPictureBuffers(const std::vector<PictureBuffer>& buffers) override; | 57 void AssignPictureBuffers(const std::vector<PictureBuffer>& buffers) override; |
| 57 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 58 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
| 58 void Flush() override; | 59 void Flush() override; |
| 59 void Reset() override; | 60 void Reset() override; |
| 61 void SetSurface(int32_t surface_id) override; |
| 60 void Destroy() override; | 62 void Destroy() override; |
| 61 bool TryToSetupDecodeOnSeparateThread( | 63 bool TryToSetupDecodeOnSeparateThread( |
| 62 const base::WeakPtr<Client>& decode_client, | 64 const base::WeakPtr<Client>& decode_client, |
| 63 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) | 65 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
| 64 override; | 66 override; |
| 65 | 67 |
| 66 // AVDAStateProvider implementation: | 68 // AVDAStateProvider implementation: |
| 67 const gfx::Size& GetSize() const override; | 69 const gfx::Size& GetSize() const override; |
| 68 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; | 70 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; |
| 69 void PostError(const ::tracked_objects::Location& from_here, | 71 void PostError(const ::tracked_objects::Location& from_here, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 272 |
| 271 // Registered to be called when surfaces are being destroyed. If |surface_id| | 273 // Registered to be called when surfaces are being destroyed. If |surface_id| |
| 272 // is our surface, we should release the MediaCodec before returning from | 274 // is our surface, we should release the MediaCodec before returning from |
| 273 // this. | 275 // this. |
| 274 void OnDestroyingSurface(int surface_id); | 276 void OnDestroyingSurface(int surface_id); |
| 275 | 277 |
| 276 // Indicates if MediaCodec should not be used for software decoding since we | 278 // Indicates if MediaCodec should not be used for software decoding since we |
| 277 // have safer versions elsewhere. | 279 // have safer versions elsewhere. |
| 278 bool IsMediaCodecSoftwareDecodingForbidden() const; | 280 bool IsMediaCodecSoftwareDecodingForbidden() const; |
| 279 | 281 |
| 282 // On platforms which support seamless surface changes, this will reinitialize |
| 283 // the picture buffer manager with the new surface. This function reads and |
| 284 // clears the surface id from |pending_surface_id_|. It will issue a decode |
| 285 // error if the surface change fails. Returns false on failure. |
| 286 bool UpdateSurface(); |
| 287 |
| 280 // Used to DCHECK that we are called on the correct thread. | 288 // Used to DCHECK that we are called on the correct thread. |
| 281 base::ThreadChecker thread_checker_; | 289 base::ThreadChecker thread_checker_; |
| 282 | 290 |
| 283 // To expose client callbacks from VideoDecodeAccelerator. | 291 // To expose client callbacks from VideoDecodeAccelerator. |
| 284 Client* client_; | 292 Client* client_; |
| 285 | 293 |
| 286 // Callback to set the correct gl context. | 294 // Callback to set the correct gl context. |
| 287 MakeGLContextCurrentCallback make_context_current_cb_; | 295 MakeGLContextCurrentCallback make_context_current_cb_; |
| 288 | 296 |
| 289 // Callback to get the GLES2Decoder instance. | 297 // Callback to get the GLES2Decoder instance. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 384 |
| 377 // Indicates if ResetCodecState() should be called upon the next call to | 385 // Indicates if ResetCodecState() should be called upon the next call to |
| 378 // Decode(). Allows us to avoid trashing the last few frames of a playback | 386 // Decode(). Allows us to avoid trashing the last few frames of a playback |
| 379 // when the EOS buffer is received. | 387 // when the EOS buffer is received. |
| 380 bool codec_needs_reset_; | 388 bool codec_needs_reset_; |
| 381 | 389 |
| 382 // True if surface creation and |picture_buffer_manager_| initialization has | 390 // True if surface creation and |picture_buffer_manager_| initialization has |
| 383 // been defered until the first Decode() call. | 391 // been defered until the first Decode() call. |
| 384 bool defer_surface_creation_; | 392 bool defer_surface_creation_; |
| 385 | 393 |
| 394 // Has a value if a SetSurface() call has occurred and a new surface should be |
| 395 // switched to when possible. Cleared during OnDestroyingSurface() and if all |
| 396 // pictures have been rendered in DequeueOutput(). |
| 397 int32_t surface_id_; |
| 398 base::Optional<int32_t> pending_surface_id_; |
| 399 |
| 386 // Copy of the VDA::Config we were given. | 400 // Copy of the VDA::Config we were given. |
| 387 Config config_; | 401 Config config_; |
| 388 | 402 |
| 389 OnDestroyingSurfaceCallback on_destroying_surface_cb_; | 403 OnDestroyingSurfaceCallback on_destroying_surface_cb_; |
| 390 | 404 |
| 391 // WeakPtrFactory for posting tasks back to |this|. | 405 // WeakPtrFactory for posting tasks back to |this|. |
| 392 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 406 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
| 393 | 407 |
| 394 friend class AndroidVideoDecodeAcceleratorTest; | 408 friend class AndroidVideoDecodeAcceleratorTest; |
| 395 }; | 409 }; |
| 396 | 410 |
| 397 } // namespace media | 411 } // namespace media |
| 398 | 412 |
| 399 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 413 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |