| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 void GetSupportedProfiles( | 94 void GetSupportedProfiles( |
| 92 std::vector<PP_VideoProfileDescription>* pp_profiles); | 95 std::vector<PP_VideoProfileDescription>* pp_profiles); |
| 93 bool IsInitializationValid(const PP_Size& input_size, | 96 bool IsInitializationValid(const PP_Size& input_size, |
| 94 PP_VideoProfile ouput_profile, | 97 PP_VideoProfile ouput_profile, |
| 95 PP_HardwareAcceleration acceleration); | 98 PP_HardwareAcceleration acceleration); |
| 96 bool EnsureGpuChannel(); | 99 bool EnsureGpuChannel(); |
| 97 bool InitializeHardware(media::VideoFrame::Format input_format, | 100 bool InitializeHardware(media::VideoFrame::Format input_format, |
| 98 const gfx::Size& input_visible_size, | 101 const gfx::Size& input_visible_size, |
| 99 media::VideoCodecProfile output_profile, | 102 media::VideoCodecProfile output_profile, |
| 100 uint32_t initial_bitrate); | 103 uint32_t initial_bitrate); |
| 104 bool InitializeSoftware(media::VideoFrame::Format input_format, |
| 105 const gfx::Size& input_visible_size, |
| 106 media::VideoCodecProfile output_profile, |
| 107 uint32_t initial_bitrate); |
| 101 void Close(); | 108 void Close(); |
| 102 void AllocateVideoFrames(); | 109 void AllocateVideoFrames(); |
| 103 void SendGetFramesErrorReply(int32_t error); | 110 void SendGetFramesErrorReply(int32_t error); |
| 104 scoped_refptr<media::VideoFrame> CreateVideoFrame( | 111 scoped_refptr<media::VideoFrame> CreateVideoFrame( |
| 105 uint32_t frame_id, | 112 uint32_t frame_id, |
| 106 const ppapi::host::ReplyMessageContext& reply_context); | 113 const ppapi::host::ReplyMessageContext& reply_context); |
| 107 void FrameReleased(const ppapi::host::ReplyMessageContext& reply_context, | 114 void FrameReleased(const ppapi::host::ReplyMessageContext& reply_context, |
| 108 uint32_t frame_id); | 115 uint32_t frame_id); |
| 109 void NotifyPepperError(int32_t error); | 116 void NotifyPepperError(int32_t error); |
| 110 | 117 |
| 118 // Helper method for VideoEncoderShim. |
| 119 uint8_t* ShmHandleToAddress(int32 buffer_id); |
| 120 |
| 111 // Non-owning pointer. | 121 // Non-owning pointer. |
| 112 RendererPpapiHost* renderer_ppapi_host_; | 122 RendererPpapiHost* renderer_ppapi_host_; |
| 113 | 123 |
| 114 ScopedVector<ShmBuffer> shm_buffers_; | 124 ScopedVector<ShmBuffer> shm_buffers_; |
| 115 | 125 |
| 116 // Buffer manager for shared memory that holds video frames. | 126 // Buffer manager for shared memory that holds video frames. |
| 117 ppapi::MediaStreamBufferManager buffer_manager_; | 127 ppapi::MediaStreamBufferManager buffer_manager_; |
| 118 | 128 |
| 119 scoped_refptr<GpuChannelHost> channel_; | 129 scoped_refptr<GpuChannelHost> channel_; |
| 120 CommandBufferProxyImpl* command_buffer_; | 130 CommandBufferProxyImpl* command_buffer_; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 149 media::VideoFrame::Format media_input_format_; | 159 media::VideoFrame::Format media_input_format_; |
| 150 | 160 |
| 151 base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_; | 161 base::WeakPtrFactory<PepperVideoEncoderHost> weak_ptr_factory_; |
| 152 | 162 |
| 153 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost); | 163 DISALLOW_COPY_AND_ASSIGN(PepperVideoEncoderHost); |
| 154 }; | 164 }; |
| 155 | 165 |
| 156 } // namespace content | 166 } // namespace content |
| 157 | 167 |
| 158 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ | 168 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_ENCODER_HOST_H_ |
| OLD | NEW |