| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // AVDAStateProvider implementation: | 69 // AVDAStateProvider implementation: |
| 70 const gfx::Size& GetSize() const override; | 70 const gfx::Size& GetSize() const override; |
| 71 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; | 71 base::WeakPtr<gpu::gles2::GLES2Decoder> GetGlDecoder() const override; |
| 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; | |
| 80 void OnSurfaceDestroyed() override; | |
| 81 void OnCodecConfigured( | 79 void OnCodecConfigured( |
| 80 scoped_refptr<CodecConfig> codec_config, |
| 82 std::unique_ptr<VideoCodecBridge> media_codec) override; | 81 std::unique_ptr<VideoCodecBridge> media_codec) override; |
| 83 | 82 |
| 84 private: | 83 private: |
| 85 friend class AVDAManager; | 84 friend class AVDAManager; |
| 86 | 85 |
| 87 // 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. |
| 88 enum State { | 87 enum State { |
| 89 NO_ERROR, | 88 NO_ERROR, |
| 90 ERROR, | 89 ERROR, |
| 91 // We have requested a surface, but haven't allocated it yet. When the | 90 // We have requested a surface, but haven't allocated it yet. When the |
| (...skipping 18 matching lines...) Expand all Loading... |
| 110 }; | 109 }; |
| 111 | 110 |
| 112 // Entry point for configuring / reconfiguring a codec with a new surface. | 111 // Entry point for configuring / reconfiguring a codec with a new surface. |
| 113 // Start surface creation by trying to allocate the surface id. Will either | 112 // Start surface creation by trying to allocate the surface id. Will either |
| 114 // InitializePictureBufferManager if the surface is available immediately, or | 113 // InitializePictureBufferManager if the surface is available immediately, or |
| 115 // will wait for OnSurfaceAvailable to do it. This will transition |state_| | 114 // will wait for OnSurfaceAvailable to do it. This will transition |state_| |
| 116 // to WAITING_FOR_SURFACE or WAITING_FOR_CODEC, as needed (or NO_ERROR if it | 115 // to WAITING_FOR_SURFACE or WAITING_FOR_CODEC, as needed (or NO_ERROR if it |
| 117 // gets the surface and the codec without waiting). | 116 // gets the surface and the codec without waiting). |
| 118 void StartSurfaceCreation(); | 117 void StartSurfaceCreation(); |
| 119 | 118 |
| 119 // Called by AndroidOverlay when a surface becomes available. |
| 120 void OnSurfaceAvailable(); |
| 121 |
| 122 // Called by AndroidOverlay when a surface is lost or initialization failed. |
| 123 void OnSurfaceDestroyed(); |
| 124 |
| 120 // Initialize of the picture buffer manager to use the current surface, once | 125 // Initialize of the picture buffer manager to use the current surface, once |
| 121 // it is available. This is not normally called directly, but rather via | 126 // it is available. This is not normally called directly, but rather via |
| 122 // StartSurfaceCreation. If we have a media codec already, then this will | 127 // StartSurfaceCreation. If we have a media codec already, then this will |
| 123 // attempt to setSurface the new surface. Otherwise, it will start codec | 128 // attempt to setSurface the new surface. Otherwise, it will start codec |
| 124 // config using the new surface. In that case, there might not be a codec | 129 // config using the new surface. In that case, there might not be a codec |
| 125 // ready even if this succeeds, but async config will be started. If | 130 // ready even if this succeeds, but async config will be started. If |
| 126 // setSurface fails, this will not replace the codec. On failure, this will | 131 // setSurface fails, this will not replace the codec. On failure, this will |
| 127 // transition |state_| to ERROR. | 132 // transition |state_| to ERROR. |
| 128 void InitializePictureBufferManager(); | 133 void InitializePictureBufferManager(); |
| 129 | 134 |
| 130 // A part of destruction process that is sometimes postponed after the drain. | 135 // A part of destruction process that is sometimes postponed after the drain. |
| 131 void ActualDestroy(); | 136 void ActualDestroy(); |
| 132 | 137 |
| 133 // Configures |media_codec_| with the given codec parameters from the client. | 138 // Configures |media_codec_| with the given codec parameters from the client. |
| 134 // This configuration will (probably) not be complete before this call | 139 // This configuration will (probably) not be complete before this call |
| 135 // returns. Multiple calls before completion will be ignored. |state_| | 140 // returns. Multiple calls before completion will be ignored. |state_| |
| 136 // must be NO_ERROR or WAITING_FOR_CODEC. Note that, once you call this, | 141 // must be NO_ERROR or WAITING_FOR_CODEC. Note that, once you call this, |
| 137 // you should be careful to avoid modifying members of |codec_config_| until | 142 // you should be careful to avoid modifying members of |codec_config_| until |
| 138 // |state_| is no longer WAITING_FOR_CODEC. | 143 // |state_| is no longer WAITING_FOR_CODEC. |
| 139 void ConfigureMediaCodecAsynchronously(); | 144 void ConfigureMediaCodecAsynchronously(); |
| 140 | 145 |
| 141 // Like ConfigureMediaCodecAsynchronously, but synchronous. Will NotifyError | 146 // Like ConfigureMediaCodecAsynchronously, but synchronous. Will NotifyError |
| 142 // on failure. Since all configuration is done synchronously, there is no | 147 // on failure. Since all configuration is done synchronously, there is no |
| 143 // concern with modifying |codec_config_| after this returns. | 148 // concern with modifying |codec_config_| after this returns. |
| 144 void ConfigureMediaCodecSynchronously(); | 149 void ConfigureMediaCodecSynchronously(); |
| 145 | 150 |
| 146 // Instantiate a media codec using |codec_config|. | |
| 147 // This may be called on any thread. | |
| 148 static std::unique_ptr<VideoCodecBridge> ConfigureMediaCodecOnAnyThread( | |
| 149 scoped_refptr<CodecConfig> codec_config); | |
| 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); |
| 159 | 159 |
| 160 // Feeds buffers in |pending_bitstream_records_| to |media_codec_|. Returns | 160 // Feeds buffers in |pending_bitstream_records_| to |media_codec_|. Returns |
| (...skipping 201 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 |