Chromium Code Reviews| 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 | |
| 24 namespace base { | |
| 25 class SharedMemory; | |
| 26 } | |
| 27 | |
| 28 namespace content { | |
| 29 | |
| 30 class PPB_Graphics3D_Impl; | |
| 31 class RendererPpapiHost; | |
| 32 class RenderViewImpl; | |
| 33 | |
| 34 class CONTENT_EXPORT PepperVideoDecoderHost | |
| 35 : public ppapi::host::ResourceHost, | |
| 36 public media::VideoDecodeAccelerator::Client { | |
| 37 public: | |
| 38 PepperVideoDecoderHost(RendererPpapiHost* host, | |
| 39 PP_Instance instance, | |
| 40 PP_Resource resource); | |
| 41 virtual ~PepperVideoDecoderHost(); | |
| 42 | |
| 43 private: | |
| 44 struct PendingDecode { | |
| 45 PendingDecode(uint32_t shm_id, | |
| 46 const ppapi::host::ReplyMessageContext& reply_context); | |
| 47 ~PendingDecode(); | |
| 48 | |
| 49 const uint32_t shm_id; | |
| 50 const ppapi::host::ReplyMessageContext reply_context; | |
| 51 }; | |
| 52 | |
| 53 // ResourceHost implementation. | |
| 54 virtual int32_t OnResourceMessageReceived( | |
| 55 const IPC::Message& msg, | |
| 56 ppapi::host::HostMessageContext* context) OVERRIDE; | |
| 57 | |
| 58 // media::VideoDecodeAccelerator::Client implementation. | |
| 59 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, | |
| 60 const gfx::Size& dimensions, | |
| 61 uint32 texture_target) OVERRIDE; | |
| 62 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; | |
| 63 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | |
| 64 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 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context, | |
| 70 const ppapi::HostResource& graphics_context, | |
| 71 PP_VideoProfile profile, | |
| 72 bool allow_software_fallback); | |
| 73 int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context, | |
| 74 uint32_t shm_id, | |
| 75 uint32_t shm_size); | |
| 76 int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context, | |
| 77 uint32_t shm_id, | |
| 78 uint32_t size); | |
| 79 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, | |
| 80 const PP_Size& size, | |
| 81 const std::vector<uint32_t>& texture_ids); | |
| 82 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, | |
| 83 uint32_t picture_id); | |
| 84 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); | |
| 85 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); | |
| 86 | |
| 87 // Non-owning pointer. | |
| 88 RendererPpapiHost* renderer_ppapi_host_; | |
| 89 | |
| 90 scoped_ptr<media::VideoDecodeAccelerator> decoder_; | |
| 91 scoped_refptr<PPB_Graphics3D_Impl> graphics3d_; | |
| 92 | |
| 93 // A vector holding our shm buffers, in sync with a similar vector in the | |
| 94 // resource. We use a buffer's index in these vectors as its id on both sides | |
| 95 // of the proxy. Only add buffers or update them in place so as not to | |
| 96 // invalidate these ids. | |
| 97 ScopedVector<base::SharedMemory> shm_buffers_; | |
| 98 // A vector of values indicating if a shm buffer is in use by the decoder. | |
|
Ami GONE FROM CHROMIUM
2014/05/29 02:31:36
s/values/true\/false/ ?
bbudge
2014/05/29 12:07:38
Done.
| |
| 99 // This is parallel to |shm_buffers_|. | |
| 100 std::vector<uint8_t> shm_buffer_busy_; | |
| 101 | |
| 102 // Number of Decode calls made, mod 2^32, to serve as a uid for each decode. | |
|
Ami GONE FROM CHROMIUM
2014/05/29 02:31:36
s/32/31/
bbudge
2014/05/29 12:07:38
Done.
| |
| 103 // The resource counts decodes in unison. | |
| 104 int32_t num_decodes_; | |
| 105 // Maps decode uid to PendingDecode info. | |
| 106 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap; | |
| 107 PendingDecodeMap pending_decodes_; | |
| 108 | |
| 109 ppapi::host::ReplyMessageContext flush_reply_context_; | |
| 110 ppapi::host::ReplyMessageContext reset_reply_context_; | |
| 111 | |
| 112 bool initialized_; | |
| 113 | |
| 114 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); | |
| 115 }; | |
| 116 | |
| 117 } // namespace content | |
| 118 | |
| 119 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ | |
| OLD | NEW |