Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: media/gpu/v4l2_video_encode_accelerator.h

Issue 1939683002: Test X11 header pollution (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/gpu/v4l2_video_decode_accelerator.cc ('k') | media/gpu/v4l2_video_encode_accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ 5 #ifndef MEDIA_GPU_V4L2_VIDEO_ENCODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ 6 #define MEDIA_GPU_V4L2_VIDEO_ENCODE_ACCELERATOR_H_
7 7
8 #include <linux/videodev2.h> 8 #include <linux/videodev2.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include <list> 12 #include <list>
13 #include <memory> 13 #include <memory>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/files/scoped_file.h" 16 #include "base/files/scoped_file.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/linked_ptr.h" 18 #include "base/memory/linked_ptr.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "content/common/content_export.h" 22 #include "media/gpu/media_gpu_export.h"
23 #include "content/common/gpu/media/v4l2_device.h" 23 #include "media/gpu/v4l2_device.h"
24 #include "content/common/gpu/media/v4l2_image_processor.h" 24 #include "media/gpu/v4l2_image_processor.h"
25 #include "media/video/video_encode_accelerator.h" 25 #include "media/video/video_encode_accelerator.h"
26 #include "ui/gfx/geometry/size.h" 26 #include "ui/gfx/geometry/size.h"
27 27
28 namespace media { 28 namespace media {
29 29
30 class BitstreamBuffer; 30 class BitstreamBuffer;
31 31
32 } // namespace media 32 } // namespace media
33 33
34 namespace content { 34 namespace media {
35 35
36 // This class handles video encode acceleration by interfacing with a V4L2 36 // This class handles video encode acceleration by interfacing with a V4L2
37 // device exposed by the codec hardware driver. The threading model of this 37 // device exposed by the codec hardware driver. The threading model of this
38 // class is the same as in the V4L2VideoDecodeAccelerator (from which class this 38 // class is the same as in the V4L2VideoDecodeAccelerator (from which class this
39 // was designed). 39 // was designed).
40 // This class may try to instantiate and use a V4L2ImageProcessor for input 40 // This class may try to instantiate and use a V4L2ImageProcessor for input
41 // format conversion, if the input format requested via Initialize() is not 41 // format conversion, if the input format requested via Initialize() is not
42 // accepted by the hardware codec. 42 // accepted by the hardware codec.
43 class CONTENT_EXPORT V4L2VideoEncodeAccelerator 43 class MEDIA_GPU_EXPORT V4L2VideoEncodeAccelerator
44 : public media::VideoEncodeAccelerator { 44 : public media::VideoEncodeAccelerator {
45 public: 45 public:
46 explicit V4L2VideoEncodeAccelerator(const scoped_refptr<V4L2Device>& device); 46 explicit V4L2VideoEncodeAccelerator(const scoped_refptr<V4L2Device>& device);
47 ~V4L2VideoEncodeAccelerator() override; 47 ~V4L2VideoEncodeAccelerator() override;
48 48
49 // media::VideoEncodeAccelerator implementation. 49 // media::VideoEncodeAccelerator implementation.
50 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles() 50 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles()
51 override; 51 override;
52 bool Initialize(media::VideoPixelFormat format, 52 bool Initialize(media::VideoPixelFormat format,
53 const gfx::Size& input_visible_size, 53 const gfx::Size& input_visible_size,
54 media::VideoCodecProfile output_profile, 54 media::VideoCodecProfile output_profile,
55 uint32_t initial_bitrate, 55 uint32_t initial_bitrate,
56 Client* client) override; 56 Client* client) override;
57 void Encode(const scoped_refptr<media::VideoFrame>& frame, 57 void Encode(const scoped_refptr<media::VideoFrame>& frame,
58 bool force_keyframe) override; 58 bool force_keyframe) override;
59 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) 59 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override;
60 override;
61 void RequestEncodingParametersChange(uint32_t bitrate, 60 void RequestEncodingParametersChange(uint32_t bitrate,
62 uint32_t framerate) override; 61 uint32_t framerate) override;
63 void Destroy() override; 62 void Destroy() override;
64 63
65 private: 64 private:
66 // Auto-destroy reference for BitstreamBuffer, for tracking buffers passed to 65 // Auto-destroy reference for BitstreamBuffer, for tracking buffers passed to
67 // this instance. 66 // this instance.
68 struct BitstreamBufferRef; 67 struct BitstreamBufferRef;
69 68
70 // Record for codec input buffers. 69 // Record for codec input buffers.
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 bool output_streamon_; 254 bool output_streamon_;
256 // Output buffers enqueued to device. 255 // Output buffers enqueued to device.
257 int output_buffer_queued_count_; 256 int output_buffer_queued_count_;
258 // Output buffers ready to use; LIFO since we don't care about ordering. 257 // Output buffers ready to use; LIFO since we don't care about ordering.
259 std::vector<int> free_output_buffers_; 258 std::vector<int> free_output_buffers_;
260 // Mapping of int index to output buffer record. 259 // Mapping of int index to output buffer record.
261 std::vector<OutputRecord> output_buffer_map_; 260 std::vector<OutputRecord> output_buffer_map_;
262 261
263 // Bitstream buffers ready to be used to return encoded output, as a LIFO 262 // Bitstream buffers ready to be used to return encoded output, as a LIFO
264 // since we don't care about ordering. 263 // since we don't care about ordering.
265 std::vector<linked_ptr<BitstreamBufferRef> > encoder_output_queue_; 264 std::vector<linked_ptr<BitstreamBufferRef>> encoder_output_queue_;
266 265
267 // Image processor, if one is in use. 266 // Image processor, if one is in use.
268 std::unique_ptr<V4L2ImageProcessor> image_processor_; 267 std::unique_ptr<V4L2ImageProcessor> image_processor_;
269 // Indexes of free image processor output buffers. Only accessed on child 268 // Indexes of free image processor output buffers. Only accessed on child
270 // thread. 269 // thread.
271 std::vector<int> free_image_processor_output_buffers_; 270 std::vector<int> free_image_processor_output_buffers_;
272 // Video frames ready to be processed. Only accessed on child thread. 271 // Video frames ready to be processed. Only accessed on child thread.
273 std::queue<ImageProcessorInputRecord> image_processor_input_queue_; 272 std::queue<ImageProcessorInputRecord> image_processor_input_queue_;
274 // Mapping of int index to fds of image processor output buffer. 273 // Mapping of int index to fds of image processor output buffer.
275 std::vector<std::vector<base::ScopedFD>> image_processor_output_buffer_map_; 274 std::vector<std::vector<base::ScopedFD>> image_processor_output_buffer_map_;
(...skipping 15 matching lines...) Expand all
291 // WeakPtr<> pointing to |this| for use in posting tasks from the 290 // WeakPtr<> pointing to |this| for use in posting tasks from the
292 // image_processor_ back to the child thread. 291 // image_processor_ back to the child thread.
293 // Tasks posted onto encoder and poll threads can use base::Unretained(this), 292 // Tasks posted onto encoder and poll threads can use base::Unretained(this),
294 // as both threads will not outlive this object. 293 // as both threads will not outlive this object.
295 base::WeakPtr<V4L2VideoEncodeAccelerator> weak_this_; 294 base::WeakPtr<V4L2VideoEncodeAccelerator> weak_this_;
296 base::WeakPtrFactory<V4L2VideoEncodeAccelerator> weak_this_ptr_factory_; 295 base::WeakPtrFactory<V4L2VideoEncodeAccelerator> weak_this_ptr_factory_;
297 296
298 DISALLOW_COPY_AND_ASSIGN(V4L2VideoEncodeAccelerator); 297 DISALLOW_COPY_AND_ASSIGN(V4L2VideoEncodeAccelerator);
299 }; 298 };
300 299
301 } // namespace content 300 } // namespace media
302 301
303 #endif // CONTENT_COMMON_GPU_MEDIA_V4L2_VIDEO_ENCODE_ACCELERATOR_H_ 302 #endif // MEDIA_GPU_V4L2_VIDEO_ENCODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « media/gpu/v4l2_video_decode_accelerator.cc ('k') | media/gpu/v4l2_video_encode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698