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