Chromium Code Reviews| 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 all calls, except Initialize() and Destroy(), that are | |
|
Pawel Osciak
2016/10/25 01:44:05
Could we instead document the complete set of call
emircan
2016/10/25 21:57:51
Sgtm. I moved RequireBitstreamBuffers and NotifyEr
| |
| 158 // used frequently during the encode session. If the Client can support | |
| 159 // running these calls on a separate thread, it may call this method to | |
| 160 // try to set up the VEA implementation to do so. | |
| 161 // | |
| 162 // If the VEA can support this as well, return true, otherwise return false. | |
| 163 // If true is returned, the client may submit each of these calls on | |
| 164 // |encode_task_runner|, and then expect Client methods to be called on | |
| 165 // |encode_task_runner| as well; called on |encode_client|, instead of | |
| 166 // |client| provided to Initialize(). | |
| 167 // | |
| 168 // One application of this is offloading the GPU main thread. This helps | |
| 169 // reduce latency by avoiding the wait and reduces jitter. | |
| 170 virtual bool TryToSetupEncodeOnSeparateThread( | |
|
Pawel Osciak
2016/10/25 01:44:05
Could you add this call to video_encode_accelerato
emircan
2016/10/25 21:57:51
VEAUnittest is not running on Win bots right now.
Pawel Osciak
2016/10/27 01:45:19
The test is currently run on CrOS bots on CrOS dev
emircan
2016/10/27 17:53:30
I added a dummy IO thread where calls run to the t
| |
| 171 const base::WeakPtr<Client>& encode_client, | |
| 172 const scoped_refptr<base::SingleThreadTaskRunner>& encode_task_runner); | |
| 173 | |
| 155 protected: | 174 protected: |
| 156 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which | 175 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which |
| 157 // will Destroy() it properly by default. | 176 // will Destroy() it properly by default. |
| 158 virtual ~VideoEncodeAccelerator(); | 177 virtual ~VideoEncodeAccelerator(); |
| 159 }; | 178 }; |
| 160 | 179 |
| 161 } // namespace media | 180 } // namespace media |
| 162 | 181 |
| 163 namespace std { | 182 namespace std { |
| 164 | 183 |
| 165 // Specialize std::default_delete so that | 184 // Specialize std::default_delete so that |
| 166 // std::unique_ptr<VideoEncodeAccelerator> uses "Destroy()" instead of trying to | 185 // std::unique_ptr<VideoEncodeAccelerator> uses "Destroy()" instead of trying to |
| 167 // use the destructor. | 186 // use the destructor. |
| 168 template <> | 187 template <> |
| 169 struct MEDIA_EXPORT default_delete<media::VideoEncodeAccelerator> { | 188 struct MEDIA_EXPORT default_delete<media::VideoEncodeAccelerator> { |
| 170 void operator()(media::VideoEncodeAccelerator* vea) const; | 189 void operator()(media::VideoEncodeAccelerator* vea) const; |
| 171 }; | 190 }; |
| 172 | 191 |
| 173 } // namespace std | 192 } // namespace std |
| 174 | 193 |
| 175 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ | 194 #endif // MEDIA_VIDEO_VIDEO_ENCODE_ACCELERATOR_H_ |
| OLD | NEW |