OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ENCODER_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "media/video/video_encode_accelerator.h" | 12 #include "media/video/video_encode_accelerator.h" |
13 #include "ppapi/c/pp_codecs.h" | 13 #include "ppapi/c/pp_codecs.h" |
14 #include "ppapi/c/ppb_video_frame.h" | 14 #include "ppapi/c/ppb_video_frame.h" |
15 #include "ppapi/host/host_message_context.h" | 15 #include "ppapi/host/host_message_context.h" |
16 #include "ppapi/host/resource_host.h" | 16 #include "ppapi/host/resource_host.h" |
17 #include "ppapi/proxy/resource_message_params.h" | 17 #include "ppapi/proxy/resource_message_params.h" |
18 #include "ppapi/shared_impl/media_stream_buffer_manager.h" | 18 #include "ppapi/shared_impl/media_stream_buffer_manager.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 class GpuVideoAcceleratorFactories; | 21 class GpuVideoAcceleratorFactories; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 class CommandBufferProxyImpl; | 26 class CommandBufferProxyImpl; |
27 class GpuChannelHost; | 27 class GpuChannelHost; |
28 class RendererPpapiHost; | 28 class RendererPpapiHost; |
| 29 class VideoEncoderShim; |
29 | 30 |
30 class CONTENT_EXPORT PepperVideoEncoderHost | 31 class CONTENT_EXPORT PepperVideoEncoderHost |
31 : public ppapi::host::ResourceHost, | 32 : public ppapi::host::ResourceHost, |
32 public media::VideoEncodeAccelerator::Client, | 33 public media::VideoEncodeAccelerator::Client, |
33 public ppapi::MediaStreamBufferManager::Delegate { | 34 public ppapi::MediaStreamBufferManager::Delegate { |
34 public: | 35 public: |
35 PepperVideoEncoderHost(RendererPpapiHost* host, | 36 PepperVideoEncoderHost(RendererPpapiHost* host, |
36 PP_Instance instance, | 37 PP_Instance instance, |
37 PP_Resource resource); | 38 PP_Resource resource); |
38 ~PepperVideoEncoderHost() override; | 39 ~PepperVideoEncoderHost() override; |
39 | 40 |
40 private: | 41 private: |
| 42 friend class VideoEncoderShim; |
| 43 |
41 // Shared memory buffers. | 44 // Shared memory buffers. |
42 struct ShmBuffer { | 45 struct ShmBuffer { |
43 ShmBuffer(uint32_t id, scoped_ptr<base::SharedMemory> shm); | 46 ShmBuffer(uint32_t id, scoped_ptr<base::SharedMemory> shm); |
44 ~ShmBuffer(); | 47 ~ShmBuffer(); |
45 | 48 |
46 media::BitstreamBuffer ToBitstreamBuffer(); | 49 media::BitstreamBuffer ToBitstreamBuffer(); |
47 | 50 |
48 // Index of the buffer in the ScopedVector. Buffers have the same id in | 51 // Index of the buffer in the ScopedVector. Buffers have the same id in |
49 // the plugin and the host. | 52 // the plugin and the host. |
50 uint32_t id; | 53 uint32_t id; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 void Close(); | 104 void Close(); |
102 void AllocateVideoFrames(); | 105 void AllocateVideoFrames(); |
103 void SendGetFramesErrorReply(int32_t error); | 106 void SendGetFramesErrorReply(int32_t error); |
104 scoped_refptr<media::VideoFrame> CreateVideoFrame( | 107 scoped_refptr<media::VideoFrame> CreateVideoFrame( |
105 uint32_t frame_id, | 108 uint32_t frame_id, |
106 const ppapi::host::ReplyMessageContext& reply_context); | 109 const ppapi::host::ReplyMessageContext& reply_context); |
107 void FrameReleased(const ppapi::host::ReplyMessageContext& reply_context, | 110 void FrameReleased(const ppapi::host::ReplyMessageContext& reply_context, |
108 uint32_t frame_id); | 111 uint32_t frame_id); |
109 void NotifyPepperError(int32_t error); | 112 void NotifyPepperError(int32_t error); |
110 | 113 |
| 114 // Helper method for VideoEncoderShim. |
| 115 uint8_t* ShmHandleToAddress(int32 buffer_id); |
| 116 |
111 // Non-owning pointer. | 117 // Non-owning pointer. |
112 RendererPpapiHost* renderer_ppapi_host_; | 118 RendererPpapiHost* renderer_ppapi_host_; |
113 | 119 |
114 ScopedVector<ShmBuffer> shm_buffers_; | 120 ScopedVector<ShmBuffer> shm_buffers_; |
115 | 121 |
116 // Buffer manager for shared memory that holds video frames. | 122 // Buffer manager for shared memory that holds video frames. |
117 ppapi::MediaStreamBufferManager buffer_manager_; | 123 ppapi::MediaStreamBufferManager buffer_manager_; |
118 | 124 |
119 scoped_refptr<GpuChannelHost> channel_; | 125 scoped_refptr<GpuChannelHost> channel_; |
120 CommandBufferProxyImpl* command_buffer_; | 126 CommandBufferProxyImpl* command_buffer_; |
(...skipping 28 matching lines...) Expand all Loading... |
149 media::VideoFrame::Format media_input_format_; | 155 media::VideoFrame::Format media_input_format_; |
150 | 156 |
151 base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_; | 157 base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_; |
152 | 158 |
153 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost); | 159 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost); |
154 }; | 160 }; |
155 | 161 |
156 } // namespace content | 162 } // namespace content |
157 | 163 |
158 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ | 164 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ |
OLD | NEW |