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.
5 #ifndef MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
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"
14 class MessageLoopProxy;
22 // Helper interface for specifying factories needed to instantiate a hardware
24 class MEDIA_EXPORT GpuVideoAcceleratorFactories
25 : public base::RefCountedThreadSafe<GpuVideoAcceleratorFactories> {
27 // Caller owns returned pointer.
28 virtual scoped_ptr<VideoDecodeAccelerator> CreateVideoDecodeAccelerator(
29 VideoCodecProfile profile,
30 VideoDecodeAccelerator::Client* client) = 0;
32 // Caller owns returned pointer.
33 virtual scoped_ptr<VideoEncodeAccelerator> CreateVideoEncodeAccelerator(
34 VideoEncodeAccelerator::Client* client) = 0;
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;
44 virtual void WaitSyncPoint(uint32 sync_point) = 0;
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;
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;
55 // Returns the message loop the video accelerator runs on.
56 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0;
58 // Abort any outstanding factory operations and error any future
59 // attempts at factory operations
60 virtual void Abort() = 0;
62 // Returns true if Abort() has been called.
63 virtual bool IsAborted() = 0;
66 friend class base::RefCountedThreadSafe<GpuVideoAcceleratorFactories>;
67 virtual ~GpuVideoAcceleratorFactories();
72 #endif // MEDIA_FILTERS_GPU_VIDEO_ACCELERATOR_FACTORIES_H_