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

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

Issue 1839193003: Reland: Introduce GpuVideoDecodeAcceleratorFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // "seek". 224 // "seek".
224 virtual void Reset() = 0; 225 virtual void Reset() = 0;
225 226
226 // Destroys the decoder: all pending inputs are dropped immediately and the 227 // Destroys the decoder: all pending inputs are dropped immediately and the
227 // component is freed. This call may asynchornously free system resources, 228 // component is freed. This call may asynchornously free system resources,
228 // but its client-visible effects are synchronous. After this method returns 229 // but its client-visible effects are synchronous. After this method returns
229 // no more callbacks will be made on the client. Deletes |this| 230 // no more callbacks will be made on the client. Deletes |this|
230 // unconditionally, so make sure to drop all pointers to it! 231 // unconditionally, so make sure to drop all pointers to it!
231 virtual void Destroy() = 0; 232 virtual void Destroy() = 0;
232 233
233 // GPU PROCESS ONLY. Implementations of this interface in the 234 // TO BE CALLED IN THE SAME PROCESS AS THE VDA IMPLEMENTATION ONLY.
234 // content/common/gpu/media should implement this, and implementations in 235 //
235 // other processes should not override the default implementation. 236 // A decode "task" is a sequence that includes a Decode() call from Client,
236 // Returns true if VDA::Decode and VDA::Client callbacks can run on the IO 237 // as well as corresponding callbacks to return the input BitstreamBuffer
237 // thread. Otherwise they will run on the GPU child thread. The purpose of 238 // after use, and the resulting output Picture(s).
238 // running Decode on the IO thread is to reduce decode latency. Note Decode 239 //
239 // should return as soon as possible and not block on the IO thread. Also, 240 // If the Client can support running these three calls on a separate thread,
240 // PictureReady should be run on the child thread if a picture is delivered 241 // it may call this method to try to set up the VDA implementation to do so.
241 // the first time so it can be cleared. 242 // If the VDA can support this as well, return true, otherwise return false.
242 virtual bool CanDecodeOnIOThread(); 243 // If true is returned, the client may submit each Decode() call (but no other
244 // calls) on |decode_task_runner|, and should then expect that
245 // NotifyEndOfBitstreamBuffer() and PictureReady() callbacks may come on
246 // |decode_task_runner| as well, called on |decode_client|, instead of client
247 // provided to Initialize().
248 //
249 // This method may be called at any time.
250 //
251 // NOTE 1: some callbacks may still have to come on the main thread and the
252 // Client should handle both callbacks coming on main and |decode_task_runner|
253 // thread.
254 //
255 // NOTE 2: VDA implementations of Decode() must return as soon as possible and
256 // never block, as |decode_task_runner| may be a latency critical thread
257 // (such as the GPU IO thread).
258 //
259 // One application of this is offloading the GPU Child thread. In general,
260 // calls to VDA in GPU process have to be done on the GPU Child thread, as
261 // they may require GL context to be current. However, some VDAs may be able
262 // to run decode operations without GL context, which helps reduce latency and
263 // offloads the GPU Child thread.
264 virtual bool TryToSetupDecodeOnSeparateThread(
265 const base::WeakPtr<Client>& decode_client,
266 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner);
243 267
244 // Windows creates a BGRA texture. 268 // Windows creates a BGRA texture.
245 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691 269 // TODO(dshwang): after moving to D3D11, remove this. crbug.com/438691
246 virtual GLenum GetSurfaceInternalFormat() const; 270 virtual GLenum GetSurfaceInternalFormat() const;
247 271
248 protected: 272 protected:
249 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which 273 // Do not delete directly; use Destroy() or own it with a scoped_ptr, which
250 // will Destroy() it properly by default. 274 // will Destroy() it properly by default.
251 virtual ~VideoDecodeAccelerator(); 275 virtual ~VideoDecodeAccelerator();
252 }; 276 };
253 277
254 } // namespace media 278 } // namespace media
255 279
256 namespace std { 280 namespace std {
257 281
258 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator> 282 // Specialize std::default_delete so that scoped_ptr<VideoDecodeAccelerator>
259 // uses "Destroy()" instead of trying to use the destructor. 283 // uses "Destroy()" instead of trying to use the destructor.
260 template <> 284 template <>
261 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { 285 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> {
262 void operator()(media::VideoDecodeAccelerator* vda) const; 286 void operator()(media::VideoDecodeAccelerator* vda) const;
263 }; 287 };
264 288
265 } // namespace std 289 } // namespace std
266 290
267 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ 291 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698