OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 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_PEPPER_VIDEO_DECODER_HOST_H_ | |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | |
7 | |
8 #include <map> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/containers/hash_tables.h" | |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/memory/scoped_vector.h" | |
16 #include "content/common/content_export.h" | |
17 #include "gpu/command_buffer/common/mailbox.h" | |
18 #include "media/video/video_decode_accelerator.h" | |
19 #include "ppapi/c/pp_codecs.h" | |
20 #include "ppapi/host/host_message_context.h" | |
21 #include "ppapi/host/resource_host.h" | |
22 #include "ppapi/proxy/resource_message_params.h" | |
23 // For limits on shm buffer size and number. | |
24 #include "ppapi/proxy/video_decoder_resource.h" | |
dmichael (off chromium)
2014/05/20 22:40:38
Should this go in the body?
bbudge
2014/05/22 18:34:55
Removed this.
| |
25 | |
26 namespace base { | |
27 class SharedMemory; | |
28 } | |
29 | |
30 namespace content { | |
31 | |
32 class PPB_Graphics3D_Impl; | |
33 class RendererPpapiHost; | |
34 class RenderViewImpl; | |
35 | |
36 class CONTENT_EXPORT PepperVideoDecoderHost | |
37 : public ppapi::host::ResourceHost, | |
38 public media::VideoDecodeAccelerator::Client { | |
39 public: | |
40 PepperVideoDecoderHost(RendererPpapiHost* host, | |
41 PP_Instance instance, | |
42 PP_Resource resource); | |
43 virtual ~PepperVideoDecoderHost(); | |
44 | |
45 private: | |
46 struct PendingDecode { | |
47 PendingDecode(uint32_t shm_id, | |
48 const ppapi::host::ReplyMessageContext& reply_context); | |
49 ~PendingDecode(); | |
50 | |
51 uint32_t shm_id; | |
52 ppapi::host::ReplyMessageContext reply_context; | |
53 }; | |
54 | |
55 virtual int32_t OnResourceMessageReceived( | |
56 const IPC::Message& msg, | |
57 ppapi::host::HostMessageContext* context) OVERRIDE; | |
58 | |
59 // media::VideoDecodeAccelerator::Client implementation. | |
60 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | |
61 const gfx::Size& dimensions, | |
62 uint32 texture_target) OVERRIDE; | |
63 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | |
64 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | |
65 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; | |
66 virtual void NotifyFlushDone() OVERRIDE; | |
67 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; | |
68 virtual void NotifyResetDone() OVERRIDE; | |
69 | |
70 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context, | |
71 const ppapi::HostResource& graphics_context, | |
72 PP_VideoProfile profile, | |
73 bool allow_software_fallback); | |
74 int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context, | |
75 uint32_t size, | |
76 uint32_t pending_shm_id); | |
77 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, | |
78 const PP_Size& size, | |
79 const std::vector<uint32_t>& texture_ids); | |
80 int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context, | |
81 uint32_t shm_id, | |
82 uint32_t size); | |
83 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, | |
84 uint32_t picture_id); | |
85 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); | |
86 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); | |
87 | |
88 void RequestTextures(uint32 num_textures, | |
89 const gfx::Size& dimensions, | |
90 uint32 texture_target); | |
91 | |
92 // Non-owning pointer. | |
93 RendererPpapiHost* renderer_ppapi_host_; | |
94 | |
95 scoped_ptr<media::VideoDecodeAccelerator> decoder_; | |
96 | |
97 scoped_refptr<PPB_Graphics3D_Impl> graphics3d_; | |
98 ScopedVector<base::SharedMemory> shm_buffers_; | |
99 | |
100 // Tracks buffers that are in use by the decoder. | |
101 std::vector<uint8_t> shm_buffer_busy_; | |
dmichael (off chromium)
2014/05/20 22:40:38
Why not std::vector<bool>? Better yet, can't you j
bbudge
2014/05/22 18:34:55
I was avoiding vector<bool> because it is slightly
| |
102 // Unique id for Decode calls. | |
103 uint32_t next_decode_id_; | |
104 // Maps decode_id to PendingDecode info. | |
105 typedef base::hash_map<uint32_t, PendingDecode> PendingDecodeMap; | |
106 PendingDecodeMap pending_decodes_; | |
107 | |
108 ppapi::host::ReplyMessageContext flush_reply_context_; | |
109 ppapi::host::ReplyMessageContext reset_reply_context_; | |
110 | |
111 bool initialized_; | |
112 | |
113 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); | |
114 }; | |
115 | |
116 } // namespace content | |
117 | |
118 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | |
OLD | NEW |