| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "gpu/config/gpu_info.h" | 17 #include "gpu/config/gpu_info.h" |
| 18 #include "ipc/ipc_listener.h" | 18 #include "ipc/ipc_listener.h" |
| 19 #include "media/video/video_encode_accelerator.h" | 19 #include "media/video/video_encode_accelerator.h" |
| 20 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
| 21 | 21 |
| 22 struct AcceleratedVideoEncoderMsg_Encode_Params; | 22 struct AcceleratedVideoEncoderMsg_Encode_Params; |
| 23 struct AcceleratedVideoEncoderMsg_Encode_Params2; | 23 struct AcceleratedVideoEncoderMsg_Encode_Params2; |
| 24 | 24 |
| 25 namespace base { | 25 namespace base { |
| 26 class SharedMemory; | 26 class SharedMemory; |
| 27 } // namespace base | 27 } // namespace base |
| 28 | 28 |
| 29 namespace gpu { | |
| 30 struct GpuPreferences; | |
| 31 } // namespace gpu | |
| 32 | |
| 33 namespace content { | 29 namespace content { |
| 34 | 30 |
| 35 // This class encapsulates the GPU process view of a VideoEncodeAccelerator, | 31 // This class encapsulates the GPU process view of a VideoEncodeAccelerator, |
| 36 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles | 32 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles |
| 37 // IPC coming in from the renderer and passes it to the underlying VEA. | 33 // IPC coming in from the renderer and passes it to the underlying VEA. |
| 38 class GpuVideoEncodeAccelerator | 34 class GpuVideoEncodeAccelerator |
| 39 : public IPC::Listener, | 35 : public IPC::Listener, |
| 40 public media::VideoEncodeAccelerator::Client, | 36 public media::VideoEncodeAccelerator::Client, |
| 41 public GpuCommandBufferStub::DestructionObserver { | 37 public GpuCommandBufferStub::DestructionObserver { |
| 42 public: | 38 public: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 61 size_t payload_size, | 57 size_t payload_size, |
| 62 bool key_frame) override; | 58 bool key_frame) override; |
| 63 void NotifyError(media::VideoEncodeAccelerator::Error error) override; | 59 void NotifyError(media::VideoEncodeAccelerator::Error error) override; |
| 64 | 60 |
| 65 // GpuCommandBufferStub::DestructionObserver implementation. | 61 // GpuCommandBufferStub::DestructionObserver implementation. |
| 66 void OnWillDestroyStub() override; | 62 void OnWillDestroyStub() override; |
| 67 | 63 |
| 68 // Static query for supported profiles. This query calls the appropriate | 64 // Static query for supported profiles. This query calls the appropriate |
| 69 // platform-specific version. The returned supported profiles vector will | 65 // platform-specific version. The returned supported profiles vector will |
| 70 // not contain duplicates. | 66 // not contain duplicates. |
| 71 static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles( | 67 static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles(); |
| 72 const gpu::GpuPreferences& gpu_preferences); | |
| 73 | 68 |
| 74 private: | 69 private: |
| 75 typedef scoped_ptr<media::VideoEncodeAccelerator>(*CreateVEAFp)(); | 70 typedef scoped_ptr<media::VideoEncodeAccelerator>(*CreateVEAFp)(); |
| 76 | 71 |
| 77 // Return a set of VEA Create function pointers applicable to the current | 72 // Return a set of VEA Create function pointers applicable to the current |
| 78 // platform. | 73 // platform. |
| 79 static std::vector<CreateVEAFp> CreateVEAFps( | 74 static std::vector<CreateVEAFp> CreateVEAFps(); |
| 80 const gpu::GpuPreferences& gpu_preferences); | |
| 81 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
| 82 static scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); | 75 static scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2VEA(); |
| 83 #endif | |
| 84 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 85 static scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); | 76 static scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiVEA(); |
| 86 #endif | |
| 87 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | |
| 88 static scoped_ptr<media::VideoEncodeAccelerator> CreateAndroidVEA(); | 77 static scoped_ptr<media::VideoEncodeAccelerator> CreateAndroidVEA(); |
| 89 #endif | |
| 90 | 78 |
| 91 // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer | 79 // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer |
| 92 // process. | 80 // process. |
| 93 void OnEncode(const AcceleratedVideoEncoderMsg_Encode_Params& params); | 81 void OnEncode(const AcceleratedVideoEncoderMsg_Encode_Params& params); |
| 94 void OnEncode2(const AcceleratedVideoEncoderMsg_Encode_Params2& params); | 82 void OnEncode2(const AcceleratedVideoEncoderMsg_Encode_Params2& params); |
| 95 void OnUseOutputBitstreamBuffer(int32_t buffer_id, | 83 void OnUseOutputBitstreamBuffer(int32_t buffer_id, |
| 96 base::SharedMemoryHandle buffer_handle, | 84 base::SharedMemoryHandle buffer_handle, |
| 97 uint32_t buffer_size); | 85 uint32_t buffer_size); |
| 98 void OnRequestEncodingParametersChange(uint32_t bitrate, uint32_t framerate); | 86 void OnRequestEncodingParametersChange(uint32_t bitrate, uint32_t framerate); |
| 99 | 87 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 125 | 113 |
| 126 // Weak pointer for media::VideoFrames that refer back to |this|. | 114 // Weak pointer for media::VideoFrames that refer back to |this|. |
| 127 base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; | 115 base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; |
| 128 | 116 |
| 129 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator); | 117 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator); |
| 130 }; | 118 }; |
| 131 | 119 |
| 132 } // namespace content | 120 } // namespace content |
| 133 | 121 |
| 134 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ | 122 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ |
| OLD | NEW |