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 method to be called on | |
Pawel Osciak
2016/10/27 01:45:19
s/Client method/Client::BitstreamBufferReady()/
emircan
2016/10/27 17:53:30
Done.
| |
166 // |encode_task_runner| as well; called on |encode_client|, instead of | |
167 // |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 // TODO(emircan): Add this method to video_encode_accelerator_unittest. | |
172 virtual bool TryToSetupEncodeOnSeparateThread( | |
173 const base::WeakPtr<Client>& encode_client, | |
174 const scoped_refptr<base::SingleThreadTaskRunner>& encode_task_runner); | |
175 | |
155 protected: | 176 protected: |
156 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which | 177 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which |
157 // will Destroy() it properly by default. | 178 // will Destroy() it properly by default. |
158 virtual ~VideoEncodeAccelerator(); | 179 virtual ~VideoEncodeAccelerator(); |
159 }; | 180 }; |
160 | 181 |
161 } // namespace media | 182 } // namespace media |
162 | 183 |
163 namespace std { | 184 namespace std { |
164 | 185 |
165 // Specialize std::default_delete so that | 186 // Specialize std::default_delete so that |
166 // std::unique_ptr<VideoEncodeAccelerator> uses "Destroy()" instead of trying to | 187 // std::unique_ptr<VideoEncodeAccelerator> uses "Destroy()" instead of trying to |
167 // use the destructor. | 188 // use the destructor. |
168 template <> | 189 template <> |
169 struct MEDIA_EXPORT default_delete<media::VideoEncodeAccelerator> { | 190 struct MEDIA_EXPORT default_delete<media::VideoEncodeAccelerator> { |
170 void operator()(media::VideoEncodeAccelerator* vea) const; | 191 void operator()(media::VideoEncodeAccelerator* vea) const; |
171 }; | 192 }; |
172 | 193 |
173 } // namespace std | 194 } // namespace std |
174 | 195 |
175 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | 196 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ |
OLD | NEW |