| 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" | |
| 17 #include "gpu/config/gpu_info.h" | 16 #include "gpu/config/gpu_info.h" |
| 17 #include "gpu/ipc/service/gpu_command_buffer_stub.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 { | 29 namespace gpu { |
| 30 struct GpuPreferences; | 30 struct GpuPreferences; |
| 31 } // namespace gpu | 31 } // namespace gpu |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 | 34 |
| 35 // This class encapsulates the GPU process view of a VideoEncodeAccelerator, | 35 // This class encapsulates the GPU process view of a VideoEncodeAccelerator, |
| 36 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles | 36 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles |
| 37 // 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. |
| 38 class GpuVideoEncodeAccelerator | 38 class GpuVideoEncodeAccelerator |
| 39 : public IPC::Listener, | 39 : public IPC::Listener, |
| 40 public media::VideoEncodeAccelerator::Client, | 40 public media::VideoEncodeAccelerator::Client, |
| 41 public GpuCommandBufferStub::DestructionObserver { | 41 public gpu::GpuCommandBufferStub::DestructionObserver { |
| 42 public: | 42 public: |
| 43 GpuVideoEncodeAccelerator(int32_t host_route_id, GpuCommandBufferStub* stub); | 43 GpuVideoEncodeAccelerator(int32_t host_route_id, |
| 44 gpu::GpuCommandBufferStub* stub); |
| 44 ~GpuVideoEncodeAccelerator() override; | 45 ~GpuVideoEncodeAccelerator() override; |
| 45 | 46 |
| 46 // Initialize this accelerator with the given parameters and send | 47 // Initialize this accelerator with the given parameters and send |
| 47 // |init_done_msg| when complete. | 48 // |init_done_msg| when complete. |
| 48 bool Initialize(media::VideoPixelFormat input_format, | 49 bool Initialize(media::VideoPixelFormat input_format, |
| 49 const gfx::Size& input_visible_size, | 50 const gfx::Size& input_visible_size, |
| 50 media::VideoCodecProfile output_profile, | 51 media::VideoCodecProfile output_profile, |
| 51 uint32_t initial_bitrate); | 52 uint32_t initial_bitrate); |
| 52 | 53 |
| 53 // IPC::Listener implementation | 54 // IPC::Listener implementation |
| 54 bool OnMessageReceived(const IPC::Message& message) override; | 55 bool OnMessageReceived(const IPC::Message& message) override; |
| 55 | 56 |
| 56 // media::VideoEncodeAccelerator::Client implementation. | 57 // media::VideoEncodeAccelerator::Client implementation. |
| 57 void RequireBitstreamBuffers(unsigned int input_count, | 58 void RequireBitstreamBuffers(unsigned int input_count, |
| 58 const gfx::Size& input_coded_size, | 59 const gfx::Size& input_coded_size, |
| 59 size_t output_buffer_size) override; | 60 size_t output_buffer_size) override; |
| 60 void BitstreamBufferReady(int32_t bitstream_buffer_id, | 61 void BitstreamBufferReady(int32_t bitstream_buffer_id, |
| 61 size_t payload_size, | 62 size_t payload_size, |
| 62 bool key_frame) override; | 63 bool key_frame) override; |
| 63 void NotifyError(media::VideoEncodeAccelerator::Error error) override; | 64 void NotifyError(media::VideoEncodeAccelerator::Error error) override; |
| 64 | 65 |
| 65 // GpuCommandBufferStub::DestructionObserver implementation. | 66 // gpu::GpuCommandBufferStub::DestructionObserver implementation. |
| 66 void OnWillDestroyStub() override; | 67 void OnWillDestroyStub() override; |
| 67 | 68 |
| 68 // Static query for supported profiles. This query calls the appropriate | 69 // Static query for supported profiles. This query calls the appropriate |
| 69 // platform-specific version. The returned supported profiles vector will | 70 // platform-specific version. The returned supported profiles vector will |
| 70 // not contain duplicates. | 71 // not contain duplicates. |
| 71 static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles( | 72 static gpu::VideoEncodeAcceleratorSupportedProfiles GetSupportedProfiles( |
| 72 const gpu::GpuPreferences& gpu_preferences); | 73 const gpu::GpuPreferences& gpu_preferences); |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 typedef scoped_ptr<media::VideoEncodeAccelerator>(*CreateVEAFp)(); | 76 typedef scoped_ptr<media::VideoEncodeAccelerator>(*CreateVEAFp)(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 | 103 |
| 103 void OnDestroy(); | 104 void OnDestroy(); |
| 104 | 105 |
| 105 void EncodeFrameFinished(int32_t frame_id, | 106 void EncodeFrameFinished(int32_t frame_id, |
| 106 scoped_ptr<base::SharedMemory> shm); | 107 scoped_ptr<base::SharedMemory> shm); |
| 107 void Send(IPC::Message* message); | 108 void Send(IPC::Message* message); |
| 108 | 109 |
| 109 // Route ID to communicate with the host. | 110 // Route ID to communicate with the host. |
| 110 const uint32_t host_route_id_; | 111 const uint32_t host_route_id_; |
| 111 | 112 |
| 112 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is | 113 // Unowned pointer to the underlying gpu::GpuCommandBufferStub. |this| is |
| 113 // registered as a DestuctionObserver of |stub_| and will self-delete when | 114 // registered as a DestuctionObserver of |stub_| and will self-delete when |
| 114 // |stub_| is destroyed. | 115 // |stub_| is destroyed. |
| 115 GpuCommandBufferStub* const stub_; | 116 gpu::GpuCommandBufferStub* const stub_; |
| 116 | 117 |
| 117 // Owned pointer to the underlying VideoEncodeAccelerator. | 118 // Owned pointer to the underlying VideoEncodeAccelerator. |
| 118 scoped_ptr<media::VideoEncodeAccelerator> encoder_; | 119 scoped_ptr<media::VideoEncodeAccelerator> encoder_; |
| 119 base::Callback<bool(void)> make_context_current_; | 120 base::Callback<bool(void)> make_context_current_; |
| 120 | 121 |
| 121 // Video encoding parameters. | 122 // Video encoding parameters. |
| 122 media::VideoPixelFormat input_format_; | 123 media::VideoPixelFormat input_format_; |
| 123 gfx::Size input_visible_size_; | 124 gfx::Size input_visible_size_; |
| 124 gfx::Size input_coded_size_; | 125 gfx::Size input_coded_size_; |
| 125 size_t output_buffer_size_; | 126 size_t output_buffer_size_; |
| 126 | 127 |
| 127 // Weak pointer for media::VideoFrames that refer back to |this|. | 128 // Weak pointer for media::VideoFrames that refer back to |this|. |
| 128 base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; | 129 base::WeakPtrFactory<GpuVideoEncodeAccelerator> weak_this_factory_; |
| 129 | 130 |
| 130 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator); | 131 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator); |
| 131 }; | 132 }; |
| 132 | 133 |
| 133 } // namespace content | 134 } // namespace content |
| 134 | 135 |
| 135 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ | 136 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_ |
| OLD | NEW |