Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: media/video/video_decode_accelerator.h

Issue 1745903002: Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "ui/gl/gl_image.h"
19 20
20 typedef unsigned int GLenum; 21 typedef unsigned int GLenum;
21 22
23 namespace base {
24 class SingleThreadTaskRunner;
25 }
26
22 namespace media { 27 namespace media {
23 28
24 // Video decoder interface. 29 // Video decoder interface.
25 // This interface is extended by the various components that ultimately 30 // This interface is extended by the various components that ultimately
26 // implement the backend of PPB_VideoDecoder_Dev. 31 // implement the backend of PPB_VideoDecoder_Dev.
27 class MEDIA_EXPORT VideoDecodeAccelerator { 32 class MEDIA_EXPORT VideoDecodeAccelerator {
28 public: 33 public:
29 // Specification of a decoding profile supported by an decoder. 34 // Specification of a decoding profile supported by an decoder.
30 // |max_resolution| and |min_resolution| are inclusive. 35 // |max_resolution| and |min_resolution| are inclusive.
31 struct MEDIA_EXPORT SupportedProfile { 36 struct MEDIA_EXPORT SupportedProfile {
32 SupportedProfile(); 37 SupportedProfile();
33 ~SupportedProfile(); 38 ~SupportedProfile();
34 VideoCodecProfile profile; 39 VideoCodecProfile profile;
35 gfx::Size max_resolution; 40 gfx::Size max_resolution;
36 gfx::Size min_resolution; 41 gfx::Size min_resolution;
37 bool encrypted_only; 42 bool encrypted_only;
38 }; 43 };
39 using SupportedProfiles = std::vector<SupportedProfile>; 44 using SupportedProfiles = std::vector<SupportedProfile>;
40 45
41 using MakeContextCurrentCallback = base::Callback<bool(void)>;
42 using BindImageCallback = base::Callback<
43 void(uint32_t, uint32_t, scoped_refptr<gl::GLImage>, bool)>;
44
45 struct MEDIA_EXPORT Capabilities { 46 struct MEDIA_EXPORT Capabilities {
46 Capabilities(); 47 Capabilities();
47 Capabilities(const Capabilities& other); 48 Capabilities(const Capabilities& other);
48 ~Capabilities(); 49 ~Capabilities();
49 50
50 std::string AsHumanReadableString() const; 51 std::string AsHumanReadableString() const;
51 52
52 // Flags that can be associated with a VDA. 53 // Flags that can be associated with a VDA.
53 enum Flags { 54 enum Flags {
54 NO_FLAGS = 0, 55 NO_FLAGS = 0,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // "seek". 223 // "seek".
223 virtual void Reset() = 0; 224 virtual void Reset() = 0;
224 225
225 // Destroys the decoder: all pending inputs are dropped immediately and the 226 // Destroys the decoder: all pending inputs are dropped immediately and the
226 // component is freed. This call may asynchornously free system resources, 227 // component is freed. This call may asynchornously free system resources,
227 // but its client-visible effects are synchronous. After this method returns 228 // but its client-visible effects are synchronous. After this method returns
228 // no more callbacks will be made on the client. Deletes |this| 229 // no more callbacks will be made on the client. Deletes |this|
229 // unconditionally, so make sure to drop all pointers to it! 230 // unconditionally, so make sure to drop all pointers to it!
230 virtual void Destroy() = 0; 231 virtual void Destroy() = 0;
231 232
232 // GPU PROCESS ONLY. Implementations of this interface in the 233 // TO BE CALLED IN THE SAME PROCESS AS THE VDA IMPLEMENTATION ONLY.
233 // content/common/gpu/media should implement this, and implementations in 234 //
234 // other processes should not override the default implementation. 235 // A decode "task" is a sequence that includes a Decode() call from Client,
235 // 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
236 // thread. Otherwise they will run on the GPU child thread. The purpose of 237 // after use, and the resulting output Picture(s).
237 // running Decode on the IO thread is to reduce decode latency. Note Decode 238 //
238 // 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,
239 // 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.
240 // the first time so it can be cleared. 241 // If the VDA can support this as well, return true, otherwise return false.
241 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);
242 266
243 // Windows creates a BGRA texture. 267 // Windows creates a BGRA texture.
244 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 268 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691
245 virtual GLenum GetSurfaceInternalFormat() const; 269 virtual GLenum GetSurfaceInternalFormat() const;
246 270
247 protected: 271 protected:
248 // 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
249 // will Destroy() it properly by default. 273 // will Destroy() it properly by default.
250 virtual ~VideoDecodeAccelerator(); 274 virtual ~VideoDecodeAccelerator();
251 }; 275 };
252 276
253 } // namespace media 277 } // namespace media
254 278
255 namespace std { 279 namespace std {
256 280
257 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> 281 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator>
258 // uses "Destroy()" instead of trying to use the destructor. 282 // uses "Destroy()" instead of trying to use the destructor.
259 template <> 283 template <>
260 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { 284 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> {
261 void operator()(media::VideoDecodeAccelerator* vda) const; 285 void operator()(media::VideoDecodeAccelerator* vda) const;
262 }; 286 };
263 287
264 } // namespace std 288 } // namespace std
265 289
266 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ 290 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698