| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // Notifies the client about the error and sets |state_| to |ERROR|. If we're | 71 // Notifies the client about the error and sets |state_| to |ERROR|. If we're |
| 72 // in the middle of Initialize, we guarantee that Initialize will return | 72 // in the middle of Initialize, we guarantee that Initialize will return |
| 73 // failure. If deferred init is pending, then we'll fail deferred init. | 73 // failure. If deferred init is pending, then we'll fail deferred init. |
| 74 // Otherwise, we'll signal errors normally. | 74 // Otherwise, we'll signal errors normally. |
| 75 void NotifyError(Error error) override; | 75 void NotifyError(Error error) override; |
| 76 | 76 |
| 77 // AVDACodecAllocatorClient implementation: | 77 // AVDACodecAllocatorClient implementation: |
| 78 void OnSurfaceAvailable(bool success) override; | 78 void OnSurfaceAvailable(bool success) override; |
| 79 void OnSurfaceDestroyed() override; | 79 void OnSurfaceDestroyed() override; |
| 80 void OnCodecConfigured( | 80 void OnCodecConfigured( |
| 81 std::unique_ptr<VideoCodecBridge> media_codec) override; | 81 std::unique_ptr<MediaCodecBridge> media_codec) override; |
| 82 | 82 |
| 83 private: | 83 private: |
| 84 friend class AVDAManager; | 84 friend class AVDAManager; |
| 85 | 85 |
| 86 // TODO(timav): evaluate the need for more states in the AVDA state machine. | 86 // TODO(timav): evaluate the need for more states in the AVDA state machine. |
| 87 enum State { | 87 enum State { |
| 88 NO_ERROR, | 88 NO_ERROR, |
| 89 ERROR, | 89 ERROR, |
| 90 // Initial state, before we've initialized the CDM, allocated the surface, | 90 // Initial state, before we've initialized the CDM, allocated the surface, |
| 91 // and started codec allocation. From here, we'll transition either to | 91 // and started codec allocation. From here, we'll transition either to |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // |state_| is no longer WAITING_FOR_CODEC. | 130 // |state_| is no longer WAITING_FOR_CODEC. |
| 131 void ConfigureMediaCodecAsynchronously(); | 131 void ConfigureMediaCodecAsynchronously(); |
| 132 | 132 |
| 133 // Like ConfigureMediaCodecAsynchronously, but synchronous. Will NotifyError | 133 // Like ConfigureMediaCodecAsynchronously, but synchronous. Will NotifyError |
| 134 // on failure. Since all configuration is done synchronously, there is no | 134 // on failure. Since all configuration is done synchronously, there is no |
| 135 // concern with modifying |codec_config_| after this returns. | 135 // concern with modifying |codec_config_| after this returns. |
| 136 void ConfigureMediaCodecSynchronously(); | 136 void ConfigureMediaCodecSynchronously(); |
| 137 | 137 |
| 138 // Instantiate a media codec using |codec_config|. | 138 // Instantiate a media codec using |codec_config|. |
| 139 // This may be called on any thread. | 139 // This may be called on any thread. |
| 140 static std::unique_ptr<VideoCodecBridge> ConfigureMediaCodecOnAnyThread( | 140 static std::unique_ptr<MediaCodecBridge> ConfigureMediaCodecOnAnyThread( |
| 141 scoped_refptr<CodecConfig> codec_config); | 141 scoped_refptr<CodecConfig> codec_config); |
| 142 | 142 |
| 143 // Sends the decoded frame specified by |codec_buffer_index| to the client. | 143 // Sends the decoded frame specified by |codec_buffer_index| to the client. |
| 144 void SendDecodedFrameToClient(int32_t codec_buffer_index, | 144 void SendDecodedFrameToClient(int32_t codec_buffer_index, |
| 145 int32_t bitstream_id); | 145 int32_t bitstream_id); |
| 146 | 146 |
| 147 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| | 147 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| |
| 148 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is | 148 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is |
| 149 // used. | 149 // used. |
| 150 void DoIOTask(bool start_timer); | 150 void DoIOTask(bool start_timer); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 State state_; | 249 State state_; |
| 250 | 250 |
| 251 // The assigned picture buffers by picture buffer id. | 251 // The assigned picture buffers by picture buffer id. |
| 252 AVDAPictureBufferManager::PictureBufferMap output_picture_buffers_; | 252 AVDAPictureBufferManager::PictureBufferMap output_picture_buffers_; |
| 253 | 253 |
| 254 // This keeps the free picture buffer ids which can be used for sending | 254 // This keeps the free picture buffer ids which can be used for sending |
| 255 // decoded frames to the client. | 255 // decoded frames to the client. |
| 256 std::queue<int32_t> free_picture_ids_; | 256 std::queue<int32_t> free_picture_ids_; |
| 257 | 257 |
| 258 // The low-level decoder which Android SDK provides. | 258 // The low-level decoder which Android SDK provides. |
| 259 std::unique_ptr<VideoCodecBridge> media_codec_; | 259 std::unique_ptr<MediaCodecBridge> media_codec_; |
| 260 | 260 |
| 261 // Set to true after requesting picture buffers to the client. | 261 // Set to true after requesting picture buffers to the client. |
| 262 bool picturebuffers_requested_; | 262 bool picturebuffers_requested_; |
| 263 | 263 |
| 264 // The resolution of the stream. | 264 // The resolution of the stream. |
| 265 gfx::Size size_; | 265 gfx::Size size_; |
| 266 | 266 |
| 267 // Handy structure to remember a BitstreamBuffer and also its shared memory, | 267 // Handy structure to remember a BitstreamBuffer and also its shared memory, |
| 268 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory | 268 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory |
| 269 // handle open. | 269 // handle open. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 352 |
| 353 // WeakPtrFactory for posting tasks back to |this|. | 353 // WeakPtrFactory for posting tasks back to |this|. |
| 354 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 354 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
| 355 | 355 |
| 356 friend class AndroidVideoDecodeAcceleratorTest; | 356 friend class AndroidVideoDecodeAcceleratorTest; |
| 357 }; | 357 }; |
| 358 | 358 |
| 359 } // namespace media | 359 } // namespace media |
| 360 | 360 |
| 361 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 361 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |