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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 // This class encapsulates the GPU process view of a VideoEncodeAccelerator, | 26 // This class encapsulates the GPU process view of a VideoEncodeAccelerator, |
27 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles | 27 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles |
28 // IPC coming in from the renderer and passes it to the underlying VEA. | 28 // IPC coming in from the renderer and passes it to the underlying VEA. |
29 class GpuVideoEncodeAccelerator | 29 class GpuVideoEncodeAccelerator |
30 : public IPC::Listener, | 30 : public IPC::Listener, |
31 public media::VideoEncodeAccelerator::Client, | 31 public media::VideoEncodeAccelerator::Client, |
32 public GpuCommandBufferStub::DestructionObserver { | 32 public GpuCommandBufferStub::DestructionObserver { |
33 public: | 33 public: |
34 typedef base::Callback<scoped_ptr<media::VideoEncodeAccelerator>(void)> | |
Pawel Osciak
2014/12/31 07:56:00
private please.
henryhsu
2014/12/31 08:47:53
Done.
| |
35 CreateVEACb; | |
36 | |
34 GpuVideoEncodeAccelerator(int32 host_route_id, GpuCommandBufferStub* stub); | 37 GpuVideoEncodeAccelerator(int32 host_route_id, GpuCommandBufferStub* stub); |
35 ~GpuVideoEncodeAccelerator() override; | 38 ~GpuVideoEncodeAccelerator() override; |
36 | 39 |
37 // Initialize this accelerator with the given parameters and send | 40 // Initialize this accelerator with the given parameters and send |
38 // |init_done_msg| when complete. | 41 // |init_done_msg| when complete. |
39 void Initialize(media::VideoFrame::Format input_format, | 42 void Initialize(media::VideoFrame::Format input_format, |
40 const gfx::Size& input_visible_size, | 43 const gfx::Size& input_visible_size, |
41 media::VideoCodecProfile output_profile, | 44 media::VideoCodecProfile output_profile, |
42 uint32 initial_bitrate, | 45 uint32 initial_bitrate, |
43 IPC::Message* init_done_msg); | 46 IPC::Message* init_done_msg); |
44 | 47 |
45 // IPC::Listener implementation | 48 // IPC::Listener implementation |
46 bool OnMessageReceived(const IPC::Message& message) override; | 49 bool OnMessageReceived(const IPC::Message& message) override; |
47 | 50 |
48 // media::VideoEncodeAccelerator::Client implementation. | 51 // media::VideoEncodeAccelerator::Client implementation. |
49 void RequireBitstreamBuffers(unsigned int input_count, | 52 void RequireBitstreamBuffers(unsigned int input_count, |
50 const gfx::Size& input_coded_size, | 53 const gfx::Size& input_coded_size, |
51 size_t output_buffer_size) override; | 54 size_t output_buffer_size) override; |
52 void BitstreamBufferReady(int32 bitstream_buffer_id, | 55 void BitstreamBufferReady(int32 bitstream_buffer_id, |
53 size_t payload_size, | 56 size_t payload_size, |
54 bool key_frame) override; | 57 bool key_frame) override; |
55 void NotifyError(media::VideoEncodeAccelerator::Error error) override; | 58 void NotifyError(media::VideoEncodeAccelerator::Error error) override; |
56 | 59 |
57 // GpuCommandBufferStub::DestructionObserver implementation. | 60 // GpuCommandBufferStub::DestructionObserver implementation. |
58 void OnWillDestroyStub() override; | 61 void OnWillDestroyStub() override; |
59 | 62 |
60 // Static query for supported profiles. This query calls the appropriate | 63 // Static query for supported profiles. This query calls the appropriate |
61 // platform-specific version. | 64 // platform-specific version. |
62 static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> | 65 static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> |
63 GetSupportedProfiles(); | 66 GetSupportedProfiles(); |
64 static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> | 67 static std::vector<gpu::VideoEncodeAcceleratorSupportedProfile> |
65 ConvertMediaToGpuProfiles(const std::vector< | 68 ConvertMediaToGpuProfiles(const std::vector< |
66 media::VideoEncodeAccelerator::SupportedProfile>& media_profiles); | 69 media::VideoEncodeAccelerator::SupportedProfile>& media_profiles); |
67 | 70 |
68 private: | 71 private: |
69 // Create the appropriate platform-specific VEA. | 72 // Create the appropriate platform-specific VEA callback functions. |
Pawel Osciak
2014/12/31 07:56:00
Same comments as in gvda.h please.
henryhsu
2014/12/31 08:47:53
Done.
| |
70 static scoped_ptr<media::VideoEncodeAccelerator> CreateEncoder(); | 73 static std::vector<CreateVEACb> CreateEncoderCbs(); |
74 // Create V4L2 VEA. | |
75 static scoped_ptr<media::VideoEncodeAccelerator> CreateV4L2Encoder(); | |
76 // Create vaapi VEA on x86 CrOS. | |
77 static scoped_ptr<media::VideoEncodeAccelerator> CreateVaapiEncoder(); | |
78 // Create Android VEA. | |
79 static scoped_ptr<media::VideoEncodeAccelerator> CreateAndroidEncoder(); | |
71 | 80 |
72 // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer | 81 // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer |
73 // process. | 82 // process. |
74 void OnEncode(int32 frame_id, | 83 void OnEncode(int32 frame_id, |
75 base::SharedMemoryHandle buffer_handle, | 84 base::SharedMemoryHandle buffer_handle, |
76 uint32 buffer_size, | 85 uint32 buffer_size, |
77 bool force_keyframe); | 86 bool force_keyframe); |
78 void OnUseOutputBitstreamBuffer(int32 buffer_id, | 87 void OnUseOutputBitstreamBuffer(int32 buffer_id, |
79 base::SharedMemoryHandle buffer_handle, | 88 base::SharedMemoryHandle buffer_handle, |
80 uint32 buffer_size); | 89 uint32 buffer_size); |
(...skipping 27 matching lines...) Expand all Loading... | |
108 | 117 |
109 // Weak pointer for media::VideoFrames that refer back to |this|. | 118 // Weak pointer for media::VideoFrames that refer back to |this|. |
110 base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; | 119 base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; |
111 | 120 |
112 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator); | 121 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator); |
113 }; | 122 }; |
114 | 123 |
115 } // namespace content | 124 } // namespace content |
116 | 125 |
117 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ | 126 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ |
OLD | NEW |