| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Notifies the client about the error and sets |state_| to |ERROR|. If we're | 72 // Notifies the client about the error and sets |state_| to |ERROR|. If we're |
| 73 // in the middle of Initialize, we guarantee that Initialize will return | 73 // in the middle of Initialize, we guarantee that Initialize will return |
| 74 // failure. If deferred init is pending, then we'll fail deferred init. | 74 // failure. If deferred init is pending, then we'll fail deferred init. |
| 75 // Otherwise, we'll signal errors normally. | 75 // Otherwise, we'll signal errors normally. |
| 76 void NotifyError(Error error) override; | 76 void NotifyError(Error error) override; |
| 77 | 77 |
| 78 // AVDACodecAllocatorClient implementation: | 78 // AVDACodecAllocatorClient implementation: |
| 79 void OnSurfaceAvailable(bool success) override; | 79 void OnSurfaceAvailable(bool success) override; |
| 80 void OnSurfaceDestroyed() override; | 80 void OnSurfaceDestroyed() override; |
| 81 void OnCodecConfigured( | 81 void OnCodecConfigured( |
| 82 std::unique_ptr<VideoCodecBridge> media_codec) override; | 82 std::unique_ptr<MediaCodecBridge> media_codec) override; |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 friend class AVDAManager; | 85 friend class AVDAManager; |
| 86 | 86 |
| 87 // TODO(timav): evaluate the need for more states in the AVDA state machine. | 87 // TODO(timav): evaluate the need for more states in the AVDA state machine. |
| 88 enum State { | 88 enum State { |
| 89 NO_ERROR, | 89 NO_ERROR, |
| 90 ERROR, | 90 ERROR, |
| 91 // We have requested a surface, but haven't allocated it yet. When the | 91 // We have requested a surface, but haven't allocated it yet. When the |
| 92 // surface arrives, we'll transition to WAITING_FOR_CODEC, NO_ERROR, or | 92 // surface arrives, we'll transition to WAITING_FOR_CODEC, NO_ERROR, or |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // |state_| is no longer WAITING_FOR_CODEC. | 138 // |state_| is no longer WAITING_FOR_CODEC. |
| 139 void ConfigureMediaCodecAsynchronously(); | 139 void ConfigureMediaCodecAsynchronously(); |
| 140 | 140 |
| 141 // Like ConfigureMediaCodecAsynchronously, but synchronous. Will NotifyError | 141 // Like ConfigureMediaCodecAsynchronously, but synchronous. Will NotifyError |
| 142 // on failure. Since all configuration is done synchronously, there is no | 142 // on failure. Since all configuration is done synchronously, there is no |
| 143 // concern with modifying |codec_config_| after this returns. | 143 // concern with modifying |codec_config_| after this returns. |
| 144 void ConfigureMediaCodecSynchronously(); | 144 void ConfigureMediaCodecSynchronously(); |
| 145 | 145 |
| 146 // Instantiate a media codec using |codec_config|. | 146 // Instantiate a media codec using |codec_config|. |
| 147 // This may be called on any thread. | 147 // This may be called on any thread. |
| 148 static std::unique_ptr<VideoCodecBridge> ConfigureMediaCodecOnAnyThread( | 148 static std::unique_ptr<MediaCodecBridge> ConfigureMediaCodecOnAnyThread( |
| 149 scoped_refptr<CodecConfig> codec_config); | 149 scoped_refptr<CodecConfig> codec_config); |
| 150 | 150 |
| 151 // Sends the decoded frame specified by |codec_buffer_index| to the client. | 151 // Sends the decoded frame specified by |codec_buffer_index| to the client. |
| 152 void SendDecodedFrameToClient(int32_t codec_buffer_index, | 152 void SendDecodedFrameToClient(int32_t codec_buffer_index, |
| 153 int32_t bitstream_id); | 153 int32_t bitstream_id); |
| 154 | 154 |
| 155 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| | 155 // Does pending IO tasks if any. Once this is called, it polls |media_codec_| |
| 156 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is | 156 // until it finishes pending tasks. For the polling, |kDecodePollDelay| is |
| 157 // used. | 157 // used. |
| 158 void DoIOTask(bool start_timer); | 158 void DoIOTask(bool start_timer); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 State state_; | 259 State state_; |
| 260 | 260 |
| 261 // The assigned picture buffers by picture buffer id. | 261 // The assigned picture buffers by picture buffer id. |
| 262 AVDAPictureBufferManager::PictureBufferMap output_picture_buffers_; | 262 AVDAPictureBufferManager::PictureBufferMap output_picture_buffers_; |
| 263 | 263 |
| 264 // This keeps the free picture buffer ids which can be used for sending | 264 // This keeps the free picture buffer ids which can be used for sending |
| 265 // decoded frames to the client. | 265 // decoded frames to the client. |
| 266 std::queue<int32_t> free_picture_ids_; | 266 std::queue<int32_t> free_picture_ids_; |
| 267 | 267 |
| 268 // The low-level decoder which Android SDK provides. | 268 // The low-level decoder which Android SDK provides. |
| 269 std::unique_ptr<VideoCodecBridge> media_codec_; | 269 std::unique_ptr<MediaCodecBridge> media_codec_; |
| 270 | 270 |
| 271 // Set to true after requesting picture buffers to the client. | 271 // Set to true after requesting picture buffers to the client. |
| 272 bool picturebuffers_requested_; | 272 bool picturebuffers_requested_; |
| 273 | 273 |
| 274 // The resolution of the stream. | 274 // The resolution of the stream. |
| 275 gfx::Size size_; | 275 gfx::Size size_; |
| 276 | 276 |
| 277 // Handy structure to remember a BitstreamBuffer and also its shared memory, | 277 // Handy structure to remember a BitstreamBuffer and also its shared memory, |
| 278 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory | 278 // if any. The goal is to prevent leaving a BitstreamBuffer's shared memory |
| 279 // handle open. | 279 // handle open. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 // WeakPtrFactory for posting tasks back to |this|. | 363 // WeakPtrFactory for posting tasks back to |this|. |
| 364 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; | 364 base::WeakPtrFactory<AndroidVideoDecodeAccelerator> weak_this_factory_; |
| 365 | 365 |
| 366 friend class AndroidVideoDecodeAcceleratorTest; | 366 friend class AndroidVideoDecodeAcceleratorTest; |
| 367 }; | 367 }; |
| 368 | 368 |
| 369 } // namespace media | 369 } // namespace media |
| 370 | 370 |
| 371 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ | 371 #endif // MEDIA_GPU_ANDROID_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |