| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <queue> | 9 #include <queue> |
| 10 | 10 |
| 11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/common/gpu/media/h264_dpb.h" | 14 #include "content/common/gpu/media/h264_dpb.h" |
| 15 #include "content/common/gpu/media/va_surface.h" | 15 #include "content/common/gpu/media/va_surface.h" |
| 16 #include "content/common/gpu/media/vaapi_wrapper.h" | 16 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 17 #include "media/filters/h264_bitstream_buffer.h" | 17 #include "media/filters/h264_bitstream_buffer.h" |
| 18 #include "media/video/video_encode_accelerator.h" | 18 #include "media/video/video_encode_accelerator.h" |
| 19 | 19 |
| 20 namespace gfx { |
| 21 class GLContext; |
| 22 }; // namespace gfx |
| 23 |
| 20 namespace content { | 24 namespace content { |
| 21 | 25 |
| 22 // A VideoEncodeAccelerator implementation that uses VA-API | 26 // A VideoEncodeAccelerator implementation that uses VA-API |
| 23 // (http://www.freedesktop.org/wiki/Software/vaapi) for HW-accelerated | 27 // (http://www.freedesktop.org/wiki/Software/vaapi) for HW-accelerated |
| 24 // video encode. | 28 // video encode. |
| 25 class CONTENT_EXPORT VaapiVideoEncodeAccelerator | 29 class CONTENT_EXPORT VaapiVideoEncodeAccelerator |
| 26 : public media::VideoEncodeAccelerator { | 30 : public media::VideoEncodeAccelerator { |
| 27 public: | 31 public: |
| 28 explicit VaapiVideoEncodeAccelerator(Display* x_display); | 32 explicit VaapiVideoEncodeAccelerator( |
| 33 gfx::GLContext* gl_context, |
| 34 const base::Callback<bool(void)>& make_context_current); |
| 29 virtual ~VaapiVideoEncodeAccelerator(); | 35 virtual ~VaapiVideoEncodeAccelerator(); |
| 30 | 36 |
| 31 // media::VideoEncodeAccelerator implementation. | 37 // media::VideoEncodeAccelerator implementation. |
| 32 virtual bool Initialize(media::VideoFrame::Format format, | 38 virtual bool Initialize(media::VideoFrame::Format format, |
| 33 const gfx::Size& input_visible_size, | 39 const gfx::Size& input_visible_size, |
| 34 media::VideoCodecProfile output_profile, | 40 media::VideoCodecProfile output_profile, |
| 35 uint32 initial_bitrate, | 41 uint32 initial_bitrate, |
| 36 Client* client) OVERRIDE; | 42 Client* client) OVERRIDE; |
| 37 virtual void Encode(const scoped_refptr<media::VideoFrame>& frame, | 43 virtual void Encode(const scoped_refptr<media::VideoFrame>& frame, |
| 38 bool force_keyframe) OVERRIDE; | 44 bool force_keyframe) OVERRIDE; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 unsigned int idr_period_; | 178 unsigned int idr_period_; |
| 173 // I frame period. | 179 // I frame period. |
| 174 unsigned int i_period_; | 180 unsigned int i_period_; |
| 175 // IP period, i.e. how often do we need to have either an I or a P frame in | 181 // IP period, i.e. how often do we need to have either an I or a P frame in |
| 176 // the stream. Period of 1 means we can have no B frames. | 182 // the stream. Period of 1 means we can have no B frames. |
| 177 unsigned int ip_period_; | 183 unsigned int ip_period_; |
| 178 | 184 |
| 179 // Size in bytes required for input bitstream buffers. | 185 // Size in bytes required for input bitstream buffers. |
| 180 size_t output_buffer_byte_size_; | 186 size_t output_buffer_byte_size_; |
| 181 | 187 |
| 182 Display* x_display_; | 188 base::Callback<bool(void)> make_context_current_; |
| 189 |
| 190 gfx::GLContext* gl_context_; |
| 183 | 191 |
| 184 // All of the members below must be accessed on the encoder_thread_, | 192 // All of the members below must be accessed on the encoder_thread_, |
| 185 // while it is running. | 193 // while it is running. |
| 186 | 194 |
| 187 // Encoder state. Encode tasks will only run in kEncoding state. | 195 // Encoder state. Encode tasks will only run in kEncoding state. |
| 188 State state_; | 196 State state_; |
| 189 | 197 |
| 190 // frame_num to be used for the next frame. | 198 // frame_num to be used for the next frame. |
| 191 unsigned int frame_num_; | 199 unsigned int frame_num_; |
| 192 // frame_num of the previous IDR. | 200 // frame_num of the previous IDR. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // thread (it's a member of this class). | 263 // thread (it's a member of this class). |
| 256 base::WeakPtr<VaapiVideoEncodeAccelerator> weak_this_; | 264 base::WeakPtr<VaapiVideoEncodeAccelerator> weak_this_; |
| 257 base::WeakPtrFactory<VaapiVideoEncodeAccelerator> weak_this_ptr_factory_; | 265 base::WeakPtrFactory<VaapiVideoEncodeAccelerator> weak_this_ptr_factory_; |
| 258 | 266 |
| 259 DISALLOW_COPY_AND_ASSIGN(VaapiVideoEncodeAccelerator); | 267 DISALLOW_COPY_AND_ASSIGN(VaapiVideoEncodeAccelerator); |
| 260 }; | 268 }; |
| 261 | 269 |
| 262 } // namespace content | 270 } // namespace content |
| 263 | 271 |
| 264 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ | 272 #endif // CONTENT_COMMON_GPU_MEDIA_VAAPI_VIDEO_ENCODE_ACCELERATOR_H_ |
| OLD | NEW |