| 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" | 16 #include "gpu/command_buffer/common/mailbox.h" |
| 17 #include "media/base/video_decoder.h" |
| 18 #include "media/video/video_decode_accelerator.h" | 18 #include "media/video/video_decode_accelerator.h" |
| 19 #include "ppapi/c/pp_codecs.h" | 19 #include "ppapi/c/pp_codecs.h" |
| 20 #include "ppapi/host/host_message_context.h" | 20 #include "ppapi/host/host_message_context.h" |
| 21 #include "ppapi/host/resource_host.h" | 21 #include "ppapi/host/resource_host.h" |
| 22 #include "ppapi/proxy/resource_message_params.h" | 22 #include "ppapi/proxy/resource_message_params.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class SharedMemory; | 25 class SharedMemory; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace gpu { |
| 29 namespace gles2 { |
| 30 class GLES2Interface; |
| 31 } |
| 32 } |
| 33 |
| 34 namespace webkit { |
| 35 namespace gpu { |
| 36 class ContextProviderWebContext; |
| 37 } |
| 38 } |
| 39 |
| 28 namespace content { | 40 namespace content { |
| 29 | 41 |
| 30 class PPB_Graphics3D_Impl; | 42 class PPB_Graphics3D_Impl; |
| 31 class RendererPpapiHost; | 43 class RendererPpapiHost; |
| 32 class RenderViewImpl; | 44 class RenderViewImpl; |
| 45 class SoftwareDecoder; |
| 33 | 46 |
| 34 class CONTENT_EXPORT PepperVideoDecoderHost | 47 class CONTENT_EXPORT PepperVideoDecoderHost |
| 35 : public ppapi::host::ResourceHost, | 48 : public ppapi::host::ResourceHost, |
| 36 public media::VideoDecodeAccelerator::Client { | 49 public media::VideoDecodeAccelerator::Client { |
| 37 public: | 50 public: |
| 38 PepperVideoDecoderHost(RendererPpapiHost* host, | 51 PepperVideoDecoderHost(RendererPpapiHost* host, |
| 39 PP_Instance instance, | 52 PP_Instance instance, |
| 40 PP_Resource resource); | 53 PP_Resource resource); |
| 41 virtual ~PepperVideoDecoderHost(); | 54 virtual ~PepperVideoDecoderHost(); |
| 42 | 55 |
| 43 private: | 56 private: |
| 44 struct PendingDecode { | 57 struct PendingDecode { |
| 45 PendingDecode(uint32_t shm_id, | 58 PendingDecode(uint32_t shm_id, |
| 46 const ppapi::host::ReplyMessageContext& reply_context); | 59 const ppapi::host::ReplyMessageContext& reply_context); |
| 47 ~PendingDecode(); | 60 ~PendingDecode(); |
| 48 | 61 |
| 49 const uint32_t shm_id; | 62 const uint32_t shm_id; |
| 50 const ppapi::host::ReplyMessageContext reply_context; | 63 const ppapi::host::ReplyMessageContext reply_context; |
| 51 }; | 64 }; |
| 52 | 65 |
| 66 friend class SoftwareDecoder; |
| 67 |
| 53 // ResourceHost implementation. | 68 // ResourceHost implementation. |
| 54 virtual int32_t OnResourceMessageReceived( | 69 virtual int32_t OnResourceMessageReceived( |
| 55 const IPC::Message& msg, | 70 const IPC::Message& msg, |
| 56 ppapi::host::HostMessageContext* context) OVERRIDE; | 71 ppapi::host::HostMessageContext* context) OVERRIDE; |
| 57 | 72 |
| 58 // media::VideoDecodeAccelerator::Client implementation. | 73 // media::VideoDecodeAccelerator::Client implementation. |
| 59 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | 74 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, |
| 60 const gfx::Size& dimensions, | 75 const gfx::Size& dimensions, |
| 61 uint32 texture_target) OVERRIDE; | 76 uint32 texture_target) OVERRIDE; |
| 62 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | 77 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 78 uint32_t size, | 93 uint32_t size, |
| 79 int32_t decode_id); | 94 int32_t decode_id); |
| 80 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, | 95 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, |
| 81 const PP_Size& size, | 96 const PP_Size& size, |
| 82 const std::vector<uint32_t>& texture_ids); | 97 const std::vector<uint32_t>& texture_ids); |
| 83 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, | 98 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, |
| 84 uint32_t picture_id); | 99 uint32_t picture_id); |
| 85 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); | 100 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); |
| 86 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); | 101 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); |
| 87 | 102 |
| 103 // Software decoder callbacks. |
| 104 void OnInitializeComplete(media::PipelineStatus pipeline_status); |
| 105 |
| 106 void RequestTextures(uint32 requested_num_of_buffers, |
| 107 const gfx::Size& dimensions, |
| 108 uint32 texture_target, |
| 109 const std::vector<gpu::Mailbox>& mailboxes); |
| 110 |
| 88 // Non-owning pointer. | 111 // Non-owning pointer. |
| 89 RendererPpapiHost* renderer_ppapi_host_; | 112 RendererPpapiHost* renderer_ppapi_host_; |
| 90 | 113 |
| 91 scoped_ptr<media::VideoDecodeAccelerator> decoder_; | 114 scoped_ptr<media::VideoDecodeAccelerator> decoder_; |
| 92 scoped_refptr<PPB_Graphics3D_Impl> graphics3d_; | 115 scoped_refptr<PPB_Graphics3D_Impl> graphics3d_; |
| 93 | 116 |
| 94 // A vector holding our shm buffers, in sync with a similar vector in the | 117 // 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 | 118 // 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 | 119 // of the proxy. Only add buffers or update them in place so as not to |
| 97 // invalidate these ids. | 120 // invalidate these ids. |
| 98 ScopedVector<base::SharedMemory> shm_buffers_; | 121 ScopedVector<base::SharedMemory> shm_buffers_; |
| 99 // A vector of true/false indicating if a shm buffer is in use by the decoder. | 122 // A vector of true/false indicating if a shm buffer is in use by the decoder. |
| 100 // This is parallel to |shm_buffers_|. | 123 // This is parallel to |shm_buffers_|. |
| 101 std::vector<uint8_t> shm_buffer_busy_; | 124 std::vector<uint8_t> shm_buffer_busy_; |
| 102 | 125 |
| 103 // Maps decode uid to PendingDecode info. | 126 // Maps decode uid to PendingDecode info. |
| 104 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap; | 127 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap; |
| 105 PendingDecodeMap pending_decodes_; | 128 PendingDecodeMap pending_decodes_; |
| 106 | 129 |
| 107 ppapi::host::ReplyMessageContext flush_reply_context_; | 130 ppapi::host::ReplyMessageContext flush_reply_context_; |
| 108 ppapi::host::ReplyMessageContext reset_reply_context_; | 131 ppapi::host::ReplyMessageContext reset_reply_context_; |
| 109 | 132 |
| 133 // These are only used when in software fallback mode. |
| 134 scoped_ptr<SoftwareDecoder> software_decoder_; |
| 135 ppapi::host::ReplyMessageContext initialize_reply_context_; |
| 136 |
| 110 bool initialized_; | 137 bool initialized_; |
| 111 | 138 |
| 112 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); | 139 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); |
| 113 }; | 140 }; |
| 114 | 141 |
| 115 } // namespace content | 142 } // namespace content |
| 116 | 143 |
| 117 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | 144 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ |
| OLD | NEW |