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