| 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 CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_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 <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
| 20 #include "content/common/gpu/media/avda_state_provider.h" | 20 #include "content/common/gpu/media/avda_state_provider.h" |
| 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 22 #include "media/base/android/media_drm_bridge.h" |
| 22 #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" |
| 23 #include "media/video/video_decode_accelerator.h" | 25 #include "media/video/video_decode_accelerator.h" |
| 24 | 26 |
| 25 namespace gfx { | 27 namespace gfx { |
| 26 class SurfaceTexture; | 28 class SurfaceTexture; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| 30 | 32 |
| 31 // A VideoDecodeAccelerator implementation for Android. | 33 // A VideoDecodeAccelerator implementation for Android. |
| 32 // This class decodes the input encoded stream by using Android's MediaCodec | 34 // This class decodes the input encoded stream by using Android's MediaCodec |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 bool QueueInput(); | 149 bool QueueInput(); |
| 148 | 150 |
| 149 // Dequeues output from |media_codec_| and feeds the decoded frame to the | 151 // Dequeues output from |media_codec_| and feeds the decoded frame to the |
| 150 // client. Returns a hint about whether calling again might produce | 152 // client. Returns a hint about whether calling again might produce |
| 151 // more output. | 153 // more output. |
| 152 bool DequeueOutput(); | 154 bool DequeueOutput(); |
| 153 | 155 |
| 154 // Requests picture buffers from the client. | 156 // Requests picture buffers from the client. |
| 155 void RequestPictureBuffers(); | 157 void RequestPictureBuffers(); |
| 156 | 158 |
| 159 // This callback is called after CDM obtained a MediaCrypto object. |
| 160 void OnMediaCryptoReady(media::MediaDrmBridge::JavaObjectPtr media_crypto, |
| 161 bool needs_protected_surface); |
| 162 |
| 163 // This callback is called when a new key is added to CDM. |
| 164 void OnKeyAdded(); |
| 165 |
| 157 // Notifies the client of the CDM setting result. | 166 // Notifies the client of the CDM setting result. |
| 158 void NotifyCdmAttached(bool success); | 167 void NotifyCdmAttached(bool success); |
| 159 | 168 |
| 160 // Notifies the client about the availability of a picture. | 169 // Notifies the client about the availability of a picture. |
| 161 void NotifyPictureReady(const media::Picture& picture); | 170 void NotifyPictureReady(const media::Picture& picture); |
| 162 | 171 |
| 163 // Notifies the client that the input buffer identifed by input_buffer_id has | 172 // Notifies the client that the input buffer identifed by input_buffer_id has |
| 164 // been processed. | 173 // been processed. |
| 165 void NotifyEndOfBitstreamBuffer(int input_buffer_id); | 174 void NotifyEndOfBitstreamBuffer(int input_buffer_id); |
| 166 | 175 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 195 | 204 |
| 196 // Callback to set the correct gl context. | 205 // Callback to set the correct gl context. |
| 197 base::Callback<bool(void)> make_context_current_; | 206 base::Callback<bool(void)> make_context_current_; |
| 198 | 207 |
| 199 // Codec type. Used when we configure media codec. | 208 // Codec type. Used when we configure media codec. |
| 200 media::VideoCodec codec_; | 209 media::VideoCodec codec_; |
| 201 | 210 |
| 202 // Whether the stream is encrypted. | 211 // Whether the stream is encrypted. |
| 203 bool is_encrypted_; | 212 bool is_encrypted_; |
| 204 | 213 |
| 214 // Whether encryption scheme requires to use protected surface. |
| 215 bool needs_protected_surface_; |
| 216 |
| 205 // The current state of this class. For now, this is used only for setting | 217 // The current state of this class. For now, this is used only for setting |
| 206 // error state. | 218 // error state. |
| 207 State state_; | 219 State state_; |
| 208 | 220 |
| 209 // This map maintains the picture buffers passed to the client for decoding. | 221 // This map maintains the picture buffers passed to the client for decoding. |
| 210 // The key is the picture buffer id. | 222 // The key is the picture buffer id. |
| 211 OutputBufferMap output_picture_buffers_; | 223 OutputBufferMap output_picture_buffers_; |
| 212 | 224 |
| 213 // This keeps the free picture buffer ids which can be used for sending | 225 // This keeps the free picture buffer ids which can be used for sending |
| 214 // decoded frames to the client. | 226 // decoded frames to the client. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // Backing strategy that we'll use to connect PictureBuffers to frames. | 269 // Backing strategy that we'll use to connect PictureBuffers to frames. |
| 258 scoped_ptr<BackingStrategy> strategy_; | 270 scoped_ptr<BackingStrategy> strategy_; |
| 259 | 271 |
| 260 // Helper class that manages asynchronous OnFrameAvailable callbacks. | 272 // Helper class that manages asynchronous OnFrameAvailable callbacks. |
| 261 class OnFrameAvailableHandler; | 273 class OnFrameAvailableHandler; |
| 262 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; | 274 scoped_refptr<OnFrameAvailableHandler> on_frame_available_handler_; |
| 263 | 275 |
| 264 // Time at which we last did useful work on io_timer_. | 276 // Time at which we last did useful work on io_timer_. |
| 265 base::TimeTicks most_recent_work_; | 277 base::TimeTicks most_recent_work_; |
| 266 | 278 |
| 279 // CDM related stuff. |
| 280 |
| 281 // Holds a ref-count to the CDM. |
| 282 scoped_refptr<media::MediaKeys> cdm_; |
| 283 |
| 284 // MediaDrmBridge requires registration/unregistration of the player, this |
| 285 // registration id is used for this. |
| 286 int cdm_registration_id_; |
| 287 |
| 288 // The MediaCrypto object is used in the MediaCodec.configure() in case of |
| 289 // an encrypted stream. |
| 290 media::MediaDrmBridge::JavaObjectPtr media_crypto_; |
| 291 |
| 267 // WeakPtrFactory for posting tasks back to |this|. | 292 // WeakPtrFactory for posting tasks back to |this|. |
| 268 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 293 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
| 269 | 294 |
| 270 friend class AndroidVideoDecodeAcceleratorTest; | 295 friend class AndroidVideoDecodeAcceleratorTest; |
| 271 }; | 296 }; |
| 272 | 297 |
| 273 } // namespace content | 298 } // namespace content |
| 274 | 299 |
| 275 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 300 #endif // CONTENT_COMMON_GPU_MEDIA_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |