Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: content/renderer/pepper/pepper_video_decoder_host.h

Issue 311853005: Implement software fallback for PPB_VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
40 namespace content {
41 class SoftwareDecoder;
42 }
43
44 namespace base {
45
46 template <class T>
47 struct DefaultDeleter;
48
49 // Specialize DefaultDeleter so that scoped_ptr<content::SoftwareDecoder>
50 // always uses "Destroy()" instead of trying to use the destructor.
51 template <>
52 struct DefaultDeleter<content::SoftwareDecoder> {
53 public:
54 void operator()(void* software_decoder) const;
55 };
dmichael (off chromium) 2014/06/03 22:27:46 I think in this case, I think you could just make
56
57 } // namespace base
58
28 namespace content { 59 namespace content {
29 60
30 class PPB_Graphics3D_Impl; 61 class PPB_Graphics3D_Impl;
31 class RendererPpapiHost; 62 class RendererPpapiHost;
32 class RenderViewImpl; 63 class RenderViewImpl;
33 64
34 class CONTENT_EXPORT PepperVideoDecoderHost 65 class CONTENT_EXPORT PepperVideoDecoderHost
35 : public ppapi::host::ResourceHost, 66 : public ppapi::host::ResourceHost,
36 public media::VideoDecodeAccelerator::Client { 67 public media::VideoDecodeAccelerator::Client {
37 public: 68 public:
38 PepperVideoDecoderHost(RendererPpapiHost* host, 69 PepperVideoDecoderHost(RendererPpapiHost* host,
39 PP_Instance instance, 70 PP_Instance instance,
40 PP_Resource resource); 71 PP_Resource resource);
41 virtual ~PepperVideoDecoderHost(); 72 virtual ~PepperVideoDecoderHost();
42 73
43 private: 74 private:
44 struct PendingDecode { 75 struct PendingDecode {
45 PendingDecode(uint32_t shm_id, 76 PendingDecode(uint32_t shm_id,
46 const ppapi::host::ReplyMessageContext& reply_context); 77 const ppapi::host::ReplyMessageContext& reply_context);
47 ~PendingDecode(); 78 ~PendingDecode();
48 79
49 const uint32_t shm_id; 80 const uint32_t shm_id;
50 const ppapi::host::ReplyMessageContext reply_context; 81 const ppapi::host::ReplyMessageContext reply_context;
51 }; 82 };
52 83
84 friend class SoftwareDecoder;
85
53 // ResourceHost implementation. 86 // ResourceHost implementation.
54 virtual int32_t OnResourceMessageReceived( 87 virtual int32_t OnResourceMessageReceived(
55 const IPC::Message& msg, 88 const IPC::Message& msg,
56 ppapi::host::HostMessageContext* context) OVERRIDE; 89 ppapi::host::HostMessageContext* context) OVERRIDE;
57 90
58 // media::VideoDecodeAccelerator::Client implementation. 91 // media::VideoDecodeAccelerator::Client implementation.
59 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers, 92 virtual void ProvidePictureBuffers(uint32 requested_num_of_buffers,
60 const gfx::Size& dimensions, 93 const gfx::Size& dimensions,
61 uint32 texture_target) OVERRIDE; 94 uint32 texture_target) OVERRIDE;
62 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE; 95 virtual void DismissPictureBuffer(int32 picture_buffer_id) OVERRIDE;
63 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 96 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
97 virtual void NotifyEndOfBitstreamBuffer(int32 bitstream_buffer_id) OVERRIDE;
98 virtual void NotifyFlushDone() OVERRIDE;
99 virtual void NotifyResetDone() OVERRIDE;
64 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; 100 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 101
69 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context, 102 int32_t OnHostMsgInitialize(ppapi::host::HostMessageContext* context,
70 const ppapi::HostResource& graphics_context, 103 const ppapi::HostResource& graphics_context,
71 PP_VideoProfile profile, 104 PP_VideoProfile profile,
72 bool allow_software_fallback); 105 bool allow_software_fallback);
73 int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context, 106 int32_t OnHostMsgGetShm(ppapi::host::HostMessageContext* context,
74 uint32_t shm_id, 107 uint32_t shm_id,
75 uint32_t shm_size); 108 uint32_t shm_size);
76 int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context, 109 int32_t OnHostMsgDecode(ppapi::host::HostMessageContext* context,
77 uint32_t shm_id, 110 uint32_t shm_id,
78 uint32_t size, 111 uint32_t size,
79 int32_t decode_id); 112 int32_t decode_id);
80 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context, 113 int32_t OnHostMsgAssignTextures(ppapi::host::HostMessageContext* context,
81 const PP_Size& size, 114 const PP_Size& size,
82 const std::vector<uint32_t>& texture_ids); 115 const std::vector<uint32_t>& texture_ids);
83 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context, 116 int32_t OnHostMsgRecyclePicture(ppapi::host::HostMessageContext* context,
84 uint32_t picture_id); 117 uint32_t picture_id);
85 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context); 118 int32_t OnHostMsgFlush(ppapi::host::HostMessageContext* context);
86 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context); 119 int32_t OnHostMsgReset(ppapi::host::HostMessageContext* context);
87 120
121 void OnInitializeComplete(int32_t result);
122 void RequestTextures(uint32 requested_num_of_buffers,
123 const gfx::Size& dimensions,
124 uint32 texture_target,
125 const std::vector<gpu::Mailbox>& mailboxes);
126 void NotifyError(int32_t pp_error);
127
88 // Non-owning pointer. 128 // Non-owning pointer.
89 RendererPpapiHost* renderer_ppapi_host_; 129 RendererPpapiHost* renderer_ppapi_host_;
90 130
91 scoped_ptr<media::VideoDecodeAccelerator> decoder_; 131 scoped_ptr<media::VideoDecodeAccelerator> decoder_;
92 scoped_refptr<PPB_Graphics3D_Impl> graphics3d_;
bbudge 2014/06/03 20:16:07 This isn't necessary, since the resource keeps the
93 132
94 // A vector holding our shm buffers, in sync with a similar vector in the 133 // 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 134 // 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 135 // of the proxy. Only add buffers or update them in place so as not to
97 // invalidate these ids. 136 // invalidate these ids.
98 ScopedVector<base::SharedMemory> shm_buffers_; 137 ScopedVector<base::SharedMemory> shm_buffers_;
99 // A vector of true/false indicating if a shm buffer is in use by the decoder. 138 // A vector of true/false indicating if a shm buffer is in use by the decoder.
100 // This is parallel to |shm_buffers_|. 139 // This is parallel to |shm_buffers_|.
101 std::vector<uint8_t> shm_buffer_busy_; 140 std::vector<uint8_t> shm_buffer_busy_;
102 141
103 // Maps decode uid to PendingDecode info. 142 // Maps decode uid to PendingDecode info.
104 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap; 143 typedef base::hash_map<int32_t, PendingDecode> PendingDecodeMap;
105 PendingDecodeMap pending_decodes_; 144 PendingDecodeMap pending_decodes_;
106 145
107 ppapi::host::ReplyMessageContext flush_reply_context_; 146 ppapi::host::ReplyMessageContext flush_reply_context_;
108 ppapi::host::ReplyMessageContext reset_reply_context_; 147 ppapi::host::ReplyMessageContext reset_reply_context_;
109 148
149 // These are only used when in software fallback mode.
150 scoped_ptr<SoftwareDecoder> software_decoder_;
151 ppapi::host::ReplyMessageContext initialize_reply_context_;
152
110 bool initialized_; 153 bool initialized_;
111 154
112 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost); 155 DISALLOW_COPY_AND_ASSIGN(PepperVideoDecoderHost);
113 }; 156 };
114 157
115 } // namespace content 158 } // namespace content
116 159
117 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_ 160 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_DECODER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698