blob: 9f1aa46fcebb16aec298ab1740bab2eb3ef94207 [file] [log] [blame]
[email protected]7ace8ad2011-08-06 03:23:581// Copyright (c) 2011 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
[email protected]9a578392011-12-07 18:59:275#ifndef PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_
6#define PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_
[email protected]7ace8ad2011-08-06 03:23:587
8#include <map>
9#include <vector>
10
11#include "base/basictypes.h"
12#include "base/compiler_specific.h"
13#include "ppapi/c/dev/ppb_video_decoder_dev.h"
[email protected]7f8b26b2011-08-18 15:41:0114#include "ppapi/shared_impl/resource.h"
[email protected]614888b2012-01-05 06:18:1215#include "ppapi/shared_impl/tracked_callback.h"
[email protected]7ace8ad2011-08-06 03:23:5816#include "ppapi/thunk/ppb_video_decoder_api.h"
17
18namespace gpu {
19namespace gles2 {
20class GLES2Implementation;
21} // namespace gles2
22} // namespace gpu
23
24namespace ppapi {
[email protected]7ace8ad2011-08-06 03:23:5825
26// Implements the logic to set and run callbacks for various video decoder
27// events. Both the proxy and the renderer implementation share this code.
[email protected]9a578392011-12-07 18:59:2728class PPAPI_SHARED_EXPORT PPB_VideoDecoder_Shared
[email protected]614888b2012-01-05 06:18:1229 : public Resource,
30 NON_EXPORTED_BASE(public thunk::PPB_VideoDecoder_API) {
[email protected]7ace8ad2011-08-06 03:23:5831 public:
[email protected]614888b2012-01-05 06:18:1232 explicit PPB_VideoDecoder_Shared(PP_Instance instance);
33 explicit PPB_VideoDecoder_Shared(const HostResource& host_resource);
[email protected]9a578392011-12-07 18:59:2734 virtual ~PPB_VideoDecoder_Shared();
[email protected]7ace8ad2011-08-06 03:23:5835
[email protected]614888b2012-01-05 06:18:1236 // Resource overrides.
37 virtual thunk::PPB_VideoDecoder_API* AsPPB_VideoDecoder_API() OVERRIDE;
38
[email protected]7ace8ad2011-08-06 03:23:5839 // PPB_VideoDecoder_API implementation.
40 virtual void Destroy() OVERRIDE;
41
[email protected]7ace8ad2011-08-06 03:23:5842 protected:
[email protected]d527cdd82011-08-12 22:50:1943 bool SetFlushCallback(PP_CompletionCallback callback);
44 bool SetResetCallback(PP_CompletionCallback callback);
45 bool SetBitstreamBufferCallback(
[email protected]7ace8ad2011-08-06 03:23:5846 int32 bitstream_buffer_id, PP_CompletionCallback callback);
47
48 void RunFlushCallback(int32 result);
49 void RunResetCallback(int32 result);
50 void RunBitstreamBufferCallback(int32 bitstream_buffer_id, int32 result);
51
52 // Tell command buffer to process all commands it has received so far.
53 void FlushCommandBuffer();
54
[email protected]1b2ec22e2011-08-30 00:48:3355 // Initialize the underlying decoder.
56 void InitCommon(PP_Resource graphics_context,
57 gpu::gles2::GLES2Implementation* gles2_impl);
[email protected]7ace8ad2011-08-06 03:23:5858
[email protected]7ace8ad2011-08-06 03:23:5859 private:
60 // Key: bitstream_buffer_id, value: callback to run when bitstream decode is
61 // done.
[email protected]614888b2012-01-05 06:18:1262 typedef std::map<int32, scoped_refptr<TrackedCallback> > CallbackById;
[email protected]7ace8ad2011-08-06 03:23:5863
[email protected]614888b2012-01-05 06:18:1264 scoped_refptr<TrackedCallback> flush_callback_;
65 scoped_refptr<TrackedCallback> reset_callback_;
[email protected]7ace8ad2011-08-06 03:23:5866 CallbackById bitstream_buffer_callbacks_;
67
[email protected]88cc78182011-12-01 06:47:0968 // The resource ID of the underlying Graphics3D object being used. Used only
[email protected]7ace8ad2011-08-06 03:23:5869 // for reference counting to keep it alive for the lifetime of |*this|.
[email protected]1b2ec22e2011-08-30 00:48:3370 PP_Resource graphics_context_;
[email protected]7ace8ad2011-08-06 03:23:5871
[email protected]88cc78182011-12-01 06:47:0972 // Reference to the GLES2Implementation owned by |graphics_context_|.
73 // Graphics3D is guaranteed to be alive for the lifetime of this class.
74 // In the out-of-process case, Graphics3D's gles2_impl() exists in the plugin
[email protected]7ace8ad2011-08-06 03:23:5875 // process only, so gles2_impl_ is NULL in that case.
76 gpu::gles2::GLES2Implementation* gles2_impl_;
77
[email protected]9a578392011-12-07 18:59:2778 DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Shared);
[email protected]7ace8ad2011-08-06 03:23:5879};
80
81} // namespace ppapi
82
[email protected]9a578392011-12-07 18:59:2783#endif // PPAPI_SHARED_IMPL_PPB_VIDEO_DECODER_SHARED_H_