OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
13 #include "base/memory/ref_counted.h" | |
14 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
16 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
17 #include "gpu/command_buffer/common/mailbox.h" | |
18 #include "media/video/video_decode_accelerator.h" | 16 #include "media/video/video_decode_accelerator.h" |
19 #include "ppapi/c/pp_codecs.h" | 17 #include "ppapi/c/pp_codecs.h" |
20 #include "ppapi/host/host_message_context.h" | 18 #include "ppapi/host/host_message_context.h" |
21 #include "ppapi/host/resource_host.h" | 19 #include "ppapi/host/resource_host.h" |
22 #include "ppapi/proxy/resource_message_params.h" | 20 #include "ppapi/proxy/resource_message_params.h" |
23 | 21 |
24 namespace base { | 22 namespace base { |
25 class SharedMemory; | 23 class SharedMemory; |
26 } | 24 } |
27 | 25 |
28 namespace content { | 26 namespace content { |
29 | 27 |
30 class PPB_Graphics3D_Impl; | 28 class PPB_Graphics3D_Impl; |
31 class RendererPpapiHost; | 29 class RendererPpapiHost; |
32 class RenderViewImpl; | 30 class RenderViewImpl; |
31 class VideoDecoderShim; | |
33 | 32 |
34 class CONTENT_EXPORT PepperVideoDecoderHost | 33 class CONTENT_EXPORT PepperVideoDecoderHost |
35 : public ppapi::host::ResourceHost, | 34 : public ppapi::host::ResourceHost, |
36 public media::VideoDecodeAccelerator::Client { | 35 public media::VideoDecodeAccelerator::Client { |
37 public: | 36 public: |
38 PepperVideoDecoderHost(RendererPpapiHost* host, | 37 PepperVideoDecoderHost(RendererPpapiHost* host, |
39 PP_Instance instance, | 38 PP_Instance instance, |
40 PP_Resource resource); | 39 PP_Resource resource); |
41 virtual ~PepperVideoDecoderHost(); | 40 virtual ~PepperVideoDecoderHost(); |
42 | 41 |
43 private: | 42 private: |
44 struct PendingDecode { | 43 struct PendingDecode { |
45 PendingDecode(uint32_t shm_id, | 44 PendingDecode(uint32_t shm_id, |
46 const ppapi::host::ReplyMessageContext& reply_context); | 45 const ppapi::host::ReplyMessageContext& reply_context); |
47 ~PendingDecode(); | 46 ~PendingDecode(); |
48 | 47 |
49 const uint32_t shm_id; | 48 const uint32_t shm_id; |
50 const ppapi::host::ReplyMessageContext reply_context; | 49 const ppapi::host::ReplyMessageContext reply_context; |
51 }; | 50 }; |
52 | 51 |
52 friend class VideoDecoderShim; | |
53 | |
53 // ResourceHost implementation. | 54 // ResourceHost implementation. |
54 virtual int32_t OnResourceMessageReceived( | 55 virtual int32_t OnResourceMessageReceived( |
55 const IPC::Message& msg, | 56 const IPC::Message& msg, |
56 ppapi::host::HostMessageContext* context) OVERRIDE; | 57 ppapi::host::HostMessageContext* context) OVERRIDE; |
57 | 58 |
58 // media::VideoDecodeAccelerator::Client implementation. | 59 // media::VideoDecodeAccelerator::Client implementation. |
59 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | 60 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, |
60 const gfx::Size& dimensions, | 61 const gfx::Size& dimensions, |
61 uint32 texture_target) OVERRIDE; | 62 uint32 texture_target) OVERRIDE; |
62 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | 63 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; |
63 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | 64 virtual void PictureReady(const media::Picture& picture) OVERRIDE; |
65 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; | |
66 virtual void NotifyFlushDone() OVERRIDE; | |
67 virtual void NotifyResetDone() OVERRIDE; | |
64 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; | 68 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; |
65 virtual void NotifyFlushDone() OVERRIDE; | |
66 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE; | |
67 virtual void NotifyResetDone() OVERRIDE; | |
68 | 69 |
69 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context, | 70 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context, |
70 const ppapi::HostResource& graphics_context, | 71 const ppapi::HostResource& graphics_context, |
71 PP_VideoProfile profile, | 72 PP_VideoProfile profile, |
72 bool allow_software_fallback); | 73 bool allow_software_fallback); |
73 int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context, | 74 int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context, |
74 uint32_t shm_id, | 75 uint32_t shm_id, |
75 uint32_t shm_size); | 76 uint32_t shm_size); |
76 int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context, | 77 int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context, |
77 uint32_t shm_id, | 78 uint32_t shm_id, |
78 uint32_t size, | 79 uint32_t size, |
79 int32_t decode_id); | 80 int32_t decode_id); |
80 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, | 81 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, |
81 const PP_Size& size, | 82 const PP_Size& size, |
82 const std::vector<uint32_t>& texture_ids); | 83 const std::vector<uint32_t>& texture_ids); |
83 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, | 84 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, |
84 uint32_t picture_id); | 85 uint32_t picture_id); |
85 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); | 86 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); |
86 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); | 87 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); |
87 | 88 |
89 // These methods are needed by VideoDecodeAdapter, to look like a | |
Ami GONE FROM CHROMIUM
2014/06/07 18:26:39
s/Adapter/Shim/
(please make a pass)
bbudge
2014/06/07 21:28:33
Done.
| |
90 // VideoDecodeAccelerator. | |
91 void OnInitializeComplete(int32_t result); | |
92 intptr_t ShmIdToKey(uint32_t shm_id); | |
93 intptr_t ShmHandleToKey(const base::SharedMemoryHandle& handle); | |
94 const uint8_t* ShmHandleToAddress(const base::SharedMemoryHandle& handle); | |
95 void RequestTextures(uint32 requested_num_of_buffers, | |
96 const gfx::Size& dimensions, | |
97 uint32 texture_target, | |
98 const std::vector<gpu::Mailbox>& mailboxes); | |
99 | |
88 // Non-owning pointer. | 100 // Non-owning pointer. |
89 RendererPpapiHost* renderer_ppapi_host_; | 101 RendererPpapiHost* renderer_ppapi_host_; |
90 | 102 |
91 scoped_ptr<media::VideoDecodeAccelerator> decoder_; | 103 scoped_ptr<media::VideoDecodeAccelerator> decoder_; |
92 scoped_refptr<PPB_Graphics3D_Impl> graphics3d_; | |
93 | 104 |
94 // A vector holding our shm buffers, in sync with a similar vector in the | 105 // A vector holding our shm buffers, in sync with a similar vector in the |
95 // resource. We use a buffer's index in these vectors as its id on both sides | 106 // resource. We use a buffer's index in these vectors as its id on both sides |
96 // of the proxy. Only add buffers or update them in place so as not to | 107 // of the proxy. Only add buffers or update them in place so as not to |
97 // invalidate these ids. | 108 // invalidate these ids. |
98 ScopedVector<base::SharedMemory> shm_buffers_; | 109 ScopedVector<base::SharedMemory> shm_buffers_; |
99 // A vector of true/false indicating if a shm buffer is in use by the decoder. | 110 // A vector of true/false indicating if a shm buffer is in use by the decoder. |
100 // This is parallel to |shm_buffers_|. | 111 // This is parallel to |shm_buffers_|. |
101 std::vector<uint8_t> shm_buffer_busy_; | 112 std::vector<uint8_t> shm_buffer_busy_; |
113 // A map of shm handles to memory addresses, to assist VideoDecoderShim. | |
Ami GONE FROM CHROMIUM
2014/06/07 18:26:39
If you didn't need to go from Handle to addr (only
bbudge
2014/06/07 21:28:33
So much better.
Done.
| |
114 // base::SharedMemoryHandle isn't suitable as a key on POSIX. | |
115 typedef base::hash_map<intptr_t, void*> SharedMemoryAddrMap; | |
116 SharedMemoryAddrMap shm_handle_to_memory_map_; | |
102 | 117 |
103 // Maps decode uid to PendingDecode info. | 118 // Maps decode uid to PendingDecode info. |
104 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap; | 119 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap; |
105 PendingDecodeMap pending_decodes_; | 120 PendingDecodeMap pending_decodes_; |
106 | 121 |
107 ppapi::host::ReplyMessageContext flush_reply_context_; | 122 ppapi::host::ReplyMessageContext flush_reply_context_; |
108 ppapi::host::ReplyMessageContext reset_reply_context_; | 123 ppapi::host::ReplyMessageContext reset_reply_context_; |
124 // Only used when in software fallback mode. | |
125 ppapi::host::ReplyMessageContext initialize_reply_context_; | |
109 | 126 |
110 bool initialized_; | 127 bool initialized_; |
111 | 128 |
112 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); | 129 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); |
113 }; | 130 }; |
114 | 131 |
115 } // namespace content | 132 } // namespace content |
116 | 133 |
117 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | 134 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ |
OLD | NEW |