Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / media / filters / gpu_video_accelerator_factories.h
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
7
8 #include <vector>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "gpu/command_buffer/common/mailbox.h"
13 #include "media/base/media_export.h"
14 #include "media/video/video_encode_accelerator.h"
15
16 class SkBitmap;
17
18 namespace base {
19 class SingleThreadTaskRunner;
20 class SharedMemory;
21 }
22
23 namespace gfx {
24 class Rect;
25 class Size;
26 }
27
28 namespace media {
29
30 class VideoDecodeAccelerator;
31
32 // Helper interface for specifying factories needed to instantiate a hardware
33 // video accelerator.
34 // Threading model:
35 // * The GpuVideoAcceleratorFactories may be constructed on any thread.
36 // * The GpuVideoAcceleratorFactories has an associated message loop, which may
37 //   be retrieved as |GetMessageLoop()|.
38 // * All calls to the Factories after construction must be made on its message
39 //   loop.
40 class MEDIA_EXPORT GpuVideoAcceleratorFactories
41     : public base::RefCountedThreadSafe<GpuVideoAcceleratorFactories> {
42  public:
43   // Caller owns returned pointer, but should call Destroy() on it (instead of
44   // directly deleting) for proper destruction, as per the
45   // VideoDecodeAccelerator interface.
46   virtual scoped_ptr<VideoDecodeAccelerator> CreateVideoDecodeAccelerator() = 0;
47
48   // Caller owns returned pointer, but should call Destroy() on it (instead of
49   // directly deleting) for proper destruction, as per the
50   // VideoEncodeAccelerator interface.
51   virtual scoped_ptr<VideoEncodeAccelerator> CreateVideoEncodeAccelerator() = 0;
52
53   // Allocate & delete native textures.
54   virtual bool CreateTextures(int32 count,
55                               const gfx::Size& size,
56                               std::vector<uint32>* texture_ids,
57                               std::vector<gpu::Mailbox>* texture_mailboxes,
58                               uint32 texture_target) = 0;
59   virtual void DeleteTexture(uint32 texture_id) = 0;
60
61   virtual void WaitSyncPoint(uint32 sync_point) = 0;
62
63   // Read pixels within |visible_rect| boundaries from a native texture and
64   // store into |pixels| as RGBA.
65   virtual void ReadPixels(uint32 texture_id,
66                           const gfx::Rect& visible_rect,
67                           const SkBitmap& pixels) = 0;
68
69   // Allocate & return a shared memory segment.  Caller is responsible for
70   // Close()ing the returned pointer.
71   virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0;
72
73   // Returns the task runner the video accelerator runs on.
74   virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() = 0;
75
76   // Returns the supported codec profiles of video encode accelerator.
77   virtual std::vector<VideoEncodeAccelerator::SupportedProfile>
78       GetVideoEncodeAcceleratorSupportedProfiles() = 0;
79
80  protected:
81   friend class base::RefCountedThreadSafe<GpuVideoAcceleratorFactories>;
82   virtual ~GpuVideoAcceleratorFactories();
83 };
84
85 }  // namespace media
86
87 #endif  // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_