- add sources.
[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 "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/video/video_decode_accelerator.h"
11 #include "media/video/video_encode_accelerator.h"
12
13 namespace base {
14 class MessageLoopProxy;
15 class SharedMemory;
16 }
17
18 class SkBitmap;
19
20 namespace media {
21
22 // Helper interface for specifying factories needed to instantiate a hardware
23 // video accelerator.
24 class MEDIA_EXPORT GpuVideoAcceleratorFactories
25     : public base::RefCountedThreadSafe<GpuVideoAcceleratorFactories> {
26  public:
27   // Caller owns returned pointer.
28   virtual scoped_ptr<VideoDecodeAccelerator> CreateVideoDecodeAccelerator(
29       VideoCodecProfile profile,
30       VideoDecodeAccelerator::Client* client) = 0;
31
32   // Caller owns returned pointer.
33   virtual scoped_ptr<VideoEncodeAccelerator> CreateVideoEncodeAccelerator(
34       VideoEncodeAccelerator::Client* client) = 0;
35
36   // Allocate & delete native textures.
37   virtual uint32 CreateTextures(int32 count,
38                                 const gfx::Size& size,
39                                 std::vector<uint32>* texture_ids,
40                                 std::vector<gpu::Mailbox>* texture_mailboxes,
41                                 uint32 texture_target) = 0;
42   virtual void DeleteTexture(uint32 texture_id) = 0;
43
44   virtual void WaitSyncPoint(uint32 sync_point) = 0;
45
46   // Read pixels from a native texture and store into |pixels| as RGBA.
47   virtual void ReadPixels(uint32 texture_id,
48                           const gfx::Size& size,
49                           const SkBitmap& pixels) = 0;
50
51   // Allocate & return a shared memory segment.  Caller is responsible for
52   // Close()ing the returned pointer.
53   virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0;
54
55   // Returns the message loop the video accelerator runs on.
56   virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0;
57
58   // Abort any outstanding factory operations and error any future
59   // attempts at factory operations
60   virtual void Abort() = 0;
61
62   // Returns true if Abort() has been called.
63   virtual bool IsAborted() = 0;
64
65  protected:
66   friend class base::RefCountedThreadSafe<GpuVideoAcceleratorFactories>;
67   virtual ~GpuVideoAcceleratorFactories();
68 };
69
70 }  // namespace media
71
72 #endif  // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_