Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / pepper / ppb_video_decoder_impl.h
blob094bcff7b43efa3e424b4b4aa32c4ee81fbb6b2d
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.
5 #ifndef CONTENT_RENDERER_PEPPER_PPB_VIDEO_DECODER_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PPB_VIDEO_DECODER_IMPL_H_
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"
19 struct PP_PictureBuffer_Dev;
20 struct PP_VideoBitstreamBuffer_Dev;
22 namespace content {
23 class PPB_Graphics3D_Impl;
25 class 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);
34 // PPB_VideoDecoder_Dev_API implementation.
35 int32_t Decode(const PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
36 scoped_refptr<ppapi::TrackedCallback> callback) override;
37 void AssignPictureBuffers(uint32_t no_of_buffers,
38 const PP_PictureBuffer_Dev* buffers) override;
39 void ReusePictureBuffer(int32_t picture_buffer_id) override;
40 int32_t Flush(scoped_refptr<ppapi::TrackedCallback> callback) override;
41 int32_t Reset(scoped_refptr<ppapi::TrackedCallback> callback) override;
42 void Destroy() override;
44 // media::VideoDecodeAccelerator::Client implementation.
45 void ProvidePictureBuffers(uint32 requested_num_of_buffers,
46 const gfx::Size& dimensions,
47 uint32 texture_target) override;
48 void DismissPictureBuffer(int32 picture_buffer_id) override;
49 void PictureReady(const media::Picture& picture) override;
50 void NotifyError(media::VideoDecodeAccelerator::Error error) override;
51 void NotifyFlushDone() override;
52 void NotifyEndOfBitstreamBuffer(int32 buffer_id) override;
53 void NotifyResetDone() override;
55 private:
56 ~PPB_VideoDecoder_Impl() override;
58 explicit PPB_VideoDecoder_Impl(PP_Instance instance);
59 bool Init(PP_Resource graphics_context,
60 PP_VideoDecoder_Profile profile);
61 // Returns the associated PPP_VideoDecoder_Dev interface to use when
62 // making calls on the plugin. This fetches the interface lazily. For
63 // out-of-process plugins, this means a synchronous message to the plugin,
64 // so it's important to never call this in response to a synchronous
65 // plugin->renderer message (such as the Create message).
66 const PPP_VideoDecoder_Dev* GetPPP();
68 // This is NULL before initialization, and after destruction.
69 // Holds a GpuVideoDecodeAcceleratorHost.
70 scoped_ptr<media::VideoDecodeAccelerator> decoder_;
72 // The interface to use when making calls on the plugin. For the most part,
73 // methods should not use this directly but should call GetPPP() instead.
74 const PPP_VideoDecoder_Dev* ppp_videodecoder_;
76 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl);
79 } // namespace content
81 #endif // CONTENT_RENDERER_PEPPER_PPB_VIDEO_DECODER_IMPL_H_