OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ |
6 #define MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/single_thread_task_runner.h" |
15 #include "media/base/bitstream_buffer.h" | 17 #include "media/base/bitstream_buffer.h" |
16 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
17 #include "media/base/video_decoder_config.h" | 19 #include "media/base/video_decoder_config.h" |
18 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
19 | 21 |
20 namespace media { | 22 namespace media { |
21 | 23 |
22 class BitstreamBuffer; | 24 class BitstreamBuffer; |
23 class VideoFrame; | 25 class VideoFrame; |
24 | 26 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Request a change to the encoding parameters. This is only a request, | 142 // Request a change to the encoding parameters. This is only a request, |
141 // fulfilled on a best-effort basis. | 143 // fulfilled on a best-effort basis. |
142 // Parameters: | 144 // Parameters: |
143 // |bitrate| is the requested new bitrate, in bits per second. | 145 // |bitrate| is the requested new bitrate, in bits per second. |
144 // |framerate| is the requested new framerate, in frames per second. | 146 // |framerate| is the requested new framerate, in frames per second. |
145 virtual void RequestEncodingParametersChange(uint32_t bitrate, | 147 virtual void RequestEncodingParametersChange(uint32_t bitrate, |
146 uint32_t framerate) = 0; | 148 uint32_t framerate) = 0; |
147 | 149 |
148 // Destroys the encoder: all pending inputs and outputs are dropped | 150 // Destroys the encoder: all pending inputs and outputs are dropped |
149 // immediately and the component is freed. This call may asynchronously free | 151 // immediately and the component is freed. This call may asynchronously free |
150 // system resources, but its client-visible effects are synchronous. After | 152 // system resources, but its client-visible effects are synchronous. After |
151 // this method returns no more callbacks will be made on the client. Deletes | 153 // this method returns no more callbacks will be made on the client. Deletes |
152 // |this| unconditionally, so make sure to drop all pointers to it! | 154 // |this| unconditionally, so make sure to drop all pointers to it! |
153 virtual void Destroy() = 0; | 155 virtual void Destroy() = 0; |
154 | 156 |
| 157 // Encode tasks include these methods that are used frequently during the |
| 158 // session: Encode(), UseOutputBitstreamBuffer(), |
| 159 // RequestEncodingParametersChange(), Client::BitstreamBufferReady(). |
| 160 // If the Client can support running these on a separate thread, it may |
| 161 // call this method to try to set up the VEA implementation to do so. |
| 162 // |
| 163 // If the VEA can support this as well, return true, otherwise return false. |
| 164 // If true is returned, the client may submit each of these calls on |
| 165 // |encode_task_runner|, and then expect Client::BitstreamBufferReady() to be |
| 166 // called on |encode_task_runner| as well; called on |encode_client|, instead |
| 167 // of |client| provided to Initialize(). |
| 168 // |
| 169 // One application of this is offloading the GPU main thread. This helps |
| 170 // reduce latency and jitter by avoiding the wait. |
| 171 virtual bool TryToSetupEncodeOnSeparateThread( |
| 172 const base::WeakPtr<Client>& encode_client, |
| 173 const scoped_refptr<base::SingleThreadTaskRunner>& encode_task_runner); |
| 174 |
155 protected: | 175 protected: |
156 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which | 176 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which |
157 // will Destroy() it properly by default. | 177 // will Destroy() it properly by default. |
158 virtual ~VideoEncodeAccelerator(); | 178 virtual ~VideoEncodeAccelerator(); |
159 }; | 179 }; |
160 | 180 |
161 } // namespace media | 181 } // namespace media |
162 | 182 |
163 namespace std { | 183 namespace std { |
164 | 184 |
165 // Specialize std::default_delete so that | 185 // Specialize std::default_delete so that |
166 // std::unique_ptr<VideoEncodeAccelerator> uses "Destroy()" instead of trying to | 186 // std::unique_ptr<VideoEncodeAccelerator> uses "Destroy()" instead of trying to |
167 // use the destructor. | 187 // use the destructor. |
168 template <> | 188 template <> |
169 struct MEDIA_EXPORT default_delete<media::VideoEncodeAccelerator> { | 189 struct MEDIA_EXPORT default_delete<media::VideoEncodeAccelerator> { |
170 void operator()(media::VideoEncodeAccelerator* vea) const; | 190 void operator()(media::VideoEncodeAccelerator* vea) const; |
171 }; | 191 }; |
172 | 192 |
173 } // namespace std | 193 } // namespace std |
174 | 194 |
175 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | 195 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ |
OLD | NEW |