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 3// found in the LICENSE file. 4 5#ifndef CONTENT_RENDERER_PEPPER_PPB_VIDEO_DECODER_IMPL_H_ 6#define CONTENT_RENDERER_PEPPER_PPB_VIDEO_DECODER_IMPL_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "base/memory/ref_counted.h" 11#include "media/video/video_decode_accelerator.h" 12#include "ppapi/c/dev/pp_video_dev.h" 13#include "ppapi/c/dev/ppp_video_decoder_dev.h" 14#include "ppapi/c/pp_var.h" 15#include "ppapi/shared_impl/ppb_video_decoder_shared.h" 16#include "ppapi/shared_impl/resource.h" 17#include "ppapi/thunk/ppb_video_decoder_dev_api.h" 18 19struct PP_PictureBuffer_Dev; 20struct PP_VideoBitstreamBuffer_Dev; 21 22namespace content { 23class PPB_Graphics3D_Impl; 24 25class PPB_VideoDecoder_Impl : public ppapi::PPB_VideoDecoder_Shared, 26 public media::VideoDecodeAccelerator::Client { 27 public: 28 // See PPB_VideoDecoder_Dev::Create. Returns 0 on failure to create & 29 // initialize. 30 static PP_Resource Create(PP_Instance instance, 31 PP_Resource graphics_context, 32 PP_VideoDecoder_Profile profile); 33 34 // PPB_VideoDecoder_Dev_API implementation. 35 virtual int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer, 36 scoped_refptr<ppapi::TrackedCallback> callback) 37 OVERRIDE; 38 virtual void AssignPictureBuffers(uint32_t no_of_buffers, 39 const PP_PictureBuffer_Dev* buffers) 40 OVERRIDE; 41 virtual void ReusePictureBuffer(int32_t picture_buffer_id) OVERRIDE; 42 virtual int32_t Flush(scoped_refptr<ppapi::TrackedCallback> callback) 43 OVERRIDE; 44 virtual int32_t Reset(scoped_refptr<ppapi::TrackedCallback> callback) 45 OVERRIDE; 46 virtual void Destroy() OVERRIDE; 47 48 // media::VideoDecodeAccelerator::Client implementation. 49 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, 50 const gfx::Size& dimensions, 51 uint32 texture_target) OVERRIDE; 52 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; 53 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 54 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; 55 virtual void NotifyFlushDone() OVERRIDE; 56 virtual void NotifyEndOfBitstreamBuffer(int32 buffer_id) OVERRIDE; 57 virtual void NotifyResetDone() OVERRIDE; 58 59 private: 60 virtual ~PPB_VideoDecoder_Impl(); 61 62 explicit PPB_VideoDecoder_Impl(PP_Instance instance); 63 bool Init(PP_Resource graphics_context, 64 PP_VideoDecoder_Profile profile); 65 66 // This is NULL before initialization, and after destruction. 67 // Holds a GpuVideoDecodeAcceleratorHost. 68 scoped_ptr<media::VideoDecodeAccelerator> decoder_; 69 70 // Reference to the plugin requesting this interface. 71 const PPP_VideoDecoder_Dev* ppp_videodecoder_; 72 73 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl); 74}; 75 76} // namespace content 77 78#endif // CONTENT_RENDERER_PEPPER_PPB_VIDEO_DECODER_IMPL_H_ 79