| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 13 #include "media/base/bitstream_buffer.h" | 15 #include "media/base/bitstream_buffer.h" |
| 14 #include "media/base/surface_manager.h" | 16 #include "media/base/surface_manager.h" |
| 15 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
| 16 #include "media/video/picture.h" | 18 #include "media/video/picture.h" |
| 17 #include "ui/gfx/geometry/size.h" | 19 #include "ui/gfx/geometry/size.h" |
| 18 | 20 |
| 19 typedef unsigned int GLenum; | 21 typedef unsigned int GLenum; |
| 20 | 22 |
| 23 namespace base { |
| 24 class SingleThreadTaskRunner; |
| 25 } |
| 26 |
| 21 namespace media { | 27 namespace media { |
| 22 | 28 |
| 23 // Video decoder interface. | 29 // Video decoder interface. |
| 24 // This interface is extended by the various components that ultimately | 30 // This interface is extended by the various components that ultimately |
| 25 // implement the backend of PPB_VideoDecoder_Dev. | 31 // implement the backend of PPB_VideoDecoder_Dev. |
| 26 class MEDIA_EXPORT VideoDecodeAccelerator { | 32 class MEDIA_EXPORT VideoDecodeAccelerator { |
| 27 public: | 33 public: |
| 28 // Specification of a decoding profile supported by an decoder. | 34 // Specification of a decoding profile supported by an decoder. |
| 29 // |max_resolution| and |min_resolution| are inclusive. | 35 // |max_resolution| and |min_resolution| are inclusive. |
| 30 struct MEDIA_EXPORT SupportedProfile { | 36 struct MEDIA_EXPORT SupportedProfile { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // "seek". | 223 // "seek". |
| 218 virtual void Reset() = 0; | 224 virtual void Reset() = 0; |
| 219 | 225 |
| 220 // Destroys the decoder: all pending inputs are dropped immediately and the | 226 // Destroys the decoder: all pending inputs are dropped immediately and the |
| 221 // component is freed. This call may asynchornously free system resources, | 227 // component is freed. This call may asynchornously free system resources, |
| 222 // but its client-visible effects are synchronous. After this method returns | 228 // but its client-visible effects are synchronous. After this method returns |
| 223 // no more callbacks will be made on the client. Deletes |this| | 229 // no more callbacks will be made on the client. Deletes |this| |
| 224 // unconditionally, so make sure to drop all pointers to it! | 230 // unconditionally, so make sure to drop all pointers to it! |
| 225 virtual void Destroy() = 0; | 231 virtual void Destroy() = 0; |
| 226 | 232 |
| 227 // GPU PROCESS ONLY. Implementations of this interface in the | 233 // TO BE CALLED IN THE SAME PROCESS AS THE VDA IMPLEMENTATION ONLY. |
| 228 // content/common/gpu/media should implement this, and implementations in | 234 // |
| 229 // other processes should not override the default implementation. | 235 // A decode "task" is a sequence that includes a Decode() call from Client, |
| 230 // Returns true if VDA::Decode and VDA::Client callbacks can run on the IO | 236 // as well as corresponding callbacks to return the input BitstreamBuffer |
| 231 // thread. Otherwise they will run on the GPU child thread. The purpose of | 237 // after use, and the resulting output Picture(s). |
| 232 // running Decode on the IO thread is to reduce decode latency. Note Decode | 238 // |
| 233 // should return as soon as possible and not block on the IO thread. Also, | 239 // If the Client can support running these three calls on a separate thread, |
| 234 // PictureReady should be run on the child thread if a picture is delivered | 240 // it may call this method to try to set up the VDA implementation to do so. |
| 235 // the first time so it can be cleared. | 241 // If the VDA can support this as well, return true, otherwise return false. |
| 236 virtual bool CanDecodeOnIOThread(); | 242 // If true is returned, the client may submit each Decode() call (but no other |
| 243 // calls) on |decode_task_runner|, and should then expect that |
| 244 // NotifyEndOfBitstreamBuffer() and PictureReady() callbacks may come on |
| 245 // |decode_task_runner| as well, called on |decode_client|, instead of client |
| 246 // provided to Initialize(). |
| 247 // |
| 248 // This method may be called at any time. |
| 249 // |
| 250 // NOTE 1: some callbacks may still have to come on the main thread and the |
| 251 // Client should handle both callbacks coming on main and |decode_task_runner| |
| 252 // thread. |
| 253 // |
| 254 // NOTE 2: VDA implementations of Decode() must return as soon as possible and |
| 255 // never block, as |decode_task_runner| may be a latency critical thread |
| 256 // (such as the GPU IO thread). |
| 257 // |
| 258 // One application of this is offloading the GPU Child thread. In general, |
| 259 // calls to VDA in GPU process have to be done on the GPU Child thread, as |
| 260 // they may require GL context to be current. However, some VDAs may be able |
| 261 // to run decode operations without GL context, which helps reduce latency and |
| 262 // offloads the GPU Child thread. |
| 263 virtual bool TryToSetupDecodeOnSeparateThread( |
| 264 const base::WeakPtr<Client>& decode_client, |
| 265 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner); |
| 237 | 266 |
| 238 // Windows creates a BGRA texture. | 267 // Windows creates a BGRA texture. |
| 239 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 | 268 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 |
| 240 virtual GLenum GetSurfaceInternalFormat() const; | 269 virtual GLenum GetSurfaceInternalFormat() const; |
| 241 | 270 |
| 242 protected: | 271 protected: |
| 243 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which | 272 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which |
| 244 // will Destroy() it properly by default. | 273 // will Destroy() it properly by default. |
| 245 virtual ~VideoDecodeAccelerator(); | 274 virtual ~VideoDecodeAccelerator(); |
| 246 }; | 275 }; |
| 247 | 276 |
| 248 } // namespace media | 277 } // namespace media |
| 249 | 278 |
| 250 namespace std { | 279 namespace std { |
| 251 | 280 |
| 252 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> | 281 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> |
| 253 // uses "Destroy()" instead of trying to use the destructor. | 282 // uses "Destroy()" instead of trying to use the destructor. |
| 254 template <> | 283 template <> |
| 255 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { | 284 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { |
| 256 void operator()(media::VideoDecodeAccelerator* vda) const; | 285 void operator()(media::VideoDecodeAccelerator* vda) const; |
| 257 }; | 286 }; |
| 258 | 287 |
| 259 } // namespace std | 288 } // namespace std |
| 260 | 289 |
| 261 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 290 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |