| 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 <memory> | 12 #include <memory> |
| 13 #include <queue> | 13 #include <queue> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "base/timer/timer.h" | 19 #include "base/timer/timer.h" |
| 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 21 #include "gpu/command_buffer/service/gpu_preferences.h" | 21 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 22 #include "media/base/android/media_drm_bridge_cdm_context.h" | 22 #include "media/base/android/media_drm_bridge_cdm_context.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/gpu/avda_state_provider.h" | 25 #include "media/gpu/avda_state_provider.h" |
| 26 #include "media/gpu/avda_surface_tracker.h" |
| 26 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" | 27 #include "media/gpu/gpu_video_decode_accelerator_helpers.h" |
| 27 #include "media/gpu/media_gpu_export.h" | 28 #include "media/gpu/media_gpu_export.h" |
| 28 #include "media/video/video_decode_accelerator.h" | 29 #include "media/video/video_decode_accelerator.h" |
| 29 #include "ui/gl/android/scoped_java_surface.h" | 30 #include "ui/gl/android/scoped_java_surface.h" |
| 30 | 31 |
| 31 namespace gfx { | 32 namespace gfx { |
| 32 class SurfaceTexture; | 33 class SurfaceTexture; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace media { | 36 namespace media { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 158 |
| 158 // 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. |
| 159 enum State { | 160 enum State { |
| 160 NO_ERROR, | 161 NO_ERROR, |
| 161 ERROR, | 162 ERROR, |
| 162 // Set when we are asynchronously constructing the codec. Will transition | 163 // Set when we are asynchronously constructing the codec. Will transition |
| 163 // to NO_ERROR or ERROR depending on success. | 164 // to NO_ERROR or ERROR depending on success. |
| 164 WAITING_FOR_CODEC, | 165 WAITING_FOR_CODEC, |
| 165 // Set when we have a codec, but it doesn't yet have a key. | 166 // Set when we have a codec, but it doesn't yet have a key. |
| 166 WAITING_FOR_KEY, | 167 WAITING_FOR_KEY, |
| 168 // The output surface was destroyed. We must not configure a new MediaCodec |
| 169 // with the destroyed surface. |
| 170 SURFACE_DESTROYED, |
| 167 }; | 171 }; |
| 168 | 172 |
| 169 enum DrainType { | 173 enum DrainType { |
| 170 DRAIN_TYPE_NONE, | 174 DRAIN_TYPE_NONE, |
| 171 DRAIN_FOR_FLUSH, | 175 DRAIN_FOR_FLUSH, |
| 172 DRAIN_FOR_RESET, | 176 DRAIN_FOR_RESET, |
| 173 DRAIN_FOR_DESTROY, | 177 DRAIN_FOR_DESTROY, |
| 174 }; | 178 }; |
| 175 | 179 |
| 176 // Configuration info for MediaCodec. | 180 // Configuration info for MediaCodec. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 // itself depends on the |drain_type_|. | 315 // itself depends on the |drain_type_|. |
| 312 void OnDrainCompleted(); | 316 void OnDrainCompleted(); |
| 313 | 317 |
| 314 // Resets MediaCodec and buffers/containers used for storing output. These | 318 // Resets MediaCodec and buffers/containers used for storing output. These |
| 315 // components need to be reset upon EOS to decode a later stream. Input state | 319 // components need to be reset upon EOS to decode a later stream. Input state |
| 316 // (e.g. queued BitstreamBuffers) is not reset, as input following an EOS | 320 // (e.g. queued BitstreamBuffers) is not reset, as input following an EOS |
| 317 // is still valid and should be processed. Upon competion calls |done_cb| that | 321 // is still valid and should be processed. Upon competion calls |done_cb| that |
| 318 // can be a null callback. | 322 // can be a null callback. |
| 319 void ResetCodecState(const base::Closure& done_cb); | 323 void ResetCodecState(const base::Closure& done_cb); |
| 320 | 324 |
| 325 // Registered to be called when surfaces are being destroyed. If |surface_id| |
| 326 // is our surface, we should release the MediaCodec before returning from |
| 327 // this. |
| 328 void OnDestroyingSurface(int surface_id); |
| 329 |
| 321 // Return true if and only if we should use deferred rendering. | 330 // Return true if and only if we should use deferred rendering. |
| 322 static bool UseDeferredRenderingStrategy( | 331 static bool UseDeferredRenderingStrategy( |
| 323 const gpu::GpuPreferences& gpu_preferences); | 332 const gpu::GpuPreferences& gpu_preferences); |
| 324 | 333 |
| 325 // Used to DCHECK that we are called on the correct thread. | 334 // Used to DCHECK that we are called on the correct thread. |
| 326 base::ThreadChecker thread_checker_; | 335 base::ThreadChecker thread_checker_; |
| 327 | 336 |
| 328 // To expose client callbacks from VideoDecodeAccelerator. | 337 // To expose client callbacks from VideoDecodeAccelerator. |
| 329 Client* client_; | 338 Client* client_; |
| 330 | 339 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 // from being sent after a reset. | 418 // from being sent after a reset. |
| 410 int error_sequence_token_; | 419 int error_sequence_token_; |
| 411 | 420 |
| 412 // PostError will defer sending an error if and only if this is true. | 421 // PostError will defer sending an error if and only if this is true. |
| 413 bool defer_errors_; | 422 bool defer_errors_; |
| 414 | 423 |
| 415 // True if and only if VDA initialization is deferred, and we have not yet | 424 // True if and only if VDA initialization is deferred, and we have not yet |
| 416 // called NotifyInitializationComplete. | 425 // called NotifyInitializationComplete. |
| 417 bool deferred_initialization_pending_; | 426 bool deferred_initialization_pending_; |
| 418 | 427 |
| 428 int surface_id_; |
| 429 |
| 430 OnDestroyingSurfaceCallback on_destroying_surface_cb_; |
| 431 |
| 419 // WeakPtrFactory for posting tasks back to |this|. | 432 // WeakPtrFactory for posting tasks back to |this|. |
| 420 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 433 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
| 421 | 434 |
| 422 friend class AndroidVideoDecodeAcceleratorTest; | 435 friend class AndroidVideoDecodeAcceleratorTest; |
| 423 }; | 436 }; |
| 424 | 437 |
| 425 } // namespace media | 438 } // namespace media |
| 426 | 439 |
| 427 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 440 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |