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

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

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

Powered by Google App Engine
This is Rietveld 408576698