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

Side by Side Diff: content/common/gpu/media/vt_video_encode_accelerator.h

Issue 1636083003: H264 HW encode using VideoToolbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_H_
7
8 #include "base/mac/scoped_cftyperef.h"
9 #include "content/common/content_export.h"
10 #include "media/base/mac/videotoolbox_glue.h"
11 #include "media/video/video_encode_accelerator.h"
12
13 namespace content {
14
15 // VideoToolbox.framework implementation of the VideoEncodeAccelerator
16 // interface for MacOSX.
17 class CONTENT_EXPORT VTVideoEncodeAccelerator
18 : public media::VideoEncodeAccelerator {
19 public:
20 VTVideoEncodeAccelerator();
21 ~VTVideoEncodeAccelerator() override;
22
23 // media::VideoEncodeAccelerator implementation.
24 media::VideoEncodeAccelerator::SupportedProfiles GetSupportedProfiles()
25 override;
26 bool Initialize(media::VideoPixelFormat format,
27 const gfx::Size& input_visible_size,
28 media::VideoCodecProfile output_profile,
29 uint32_t initial_bitrate,
30 Client* client) override;
31 void Encode(const scoped_refptr<media::VideoFrame>& frame,
32 bool force_keyframe) override;
33 void UseOutputBitstreamBuffer(const media::BitstreamBuffer& buffer) override;
34 void RequestEncodingParametersChange(uint32_t bitrate,
35 uint32_t framerate) override;
36 void Destroy() override;
37
38 // Holds output buffers coming from the client ready to be filled.
39 struct BitstreamBufferRef;
40
41 private:
42 typedef CoreMediaGlue::CMSampleBufferRef CMSampleBufferRef;
mcasas 2016/02/03 20:01:31 using CMSampleBufferRef = CoreMediaGlue::CMSampleB
emircan 2016/02/04 05:18:52 Done.
43 typedef VideoToolboxGlue::VTCompressionSessionRef VTCompressionSessionRef;
44 typedef VideoToolboxGlue::VTEncodeInfoFlags VTEncodeInfoFlags;
45
46 // Compression session callback function to handle compressed frames.
47 static void CompressionCallback(void* encoder_opaque,
48 void* request_opaque,
49 OSStatus status,
50 VTEncodeInfoFlags info,
51 CMSampleBufferRef sbuf);
52
53 // Reset the encoder's compression session by destroying the existing one
54 // using DestroyCompressionSession() and creating a new one. The new session
55 // is configured using ConfigureCompressionSession().
56 bool ResetCompressionSession();
57
58 // Configure the current compression session using current encoder settings.
59 void ConfigureCompressionSession();
60
61 // Destroy the current compression session if any. Blocks until all pending
62 // frames have been flushed out (similar to EmitFrames without doing any
63 // encoding work).
64 void DestroyCompressionSession();
65
66 // VideoToolboxGlue provides access to VideoToolbox at runtime.
67 const VideoToolboxGlue* const videotoolbox_glue_;
68 base::ScopedCFTypeRef<VTCompressionSessionRef> compression_session_;
69
70 // Initial parameters given by media::VideoEncodeAccelerator::Initialize()
71 uint32_t bitrate_;
72 gfx::Size input_visible_size_;
73
74 // Bitstream buffers ready to be used to return encoded output, as a LIFO
75 // since we don't care about ordering.
76 std::deque<scoped_ptr<BitstreamBufferRef>> encoder_output_queue_;
77
78 // Our original calling task runner for the child thread.
79 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
mcasas 2016/02/03 20:01:31 nit: s/child_task_runner_/callback_task_runner_/ ?
emircan 2016/02/04 05:18:52 callback might be confusing since there are callba
80
81 // To expose client callbacks from VideoEncodeAccelerator.
82 // NOTE: all calls to these objects *MUST* be executed on
83 // child_task_runner_.
mcasas 2016/02/03 20:01:31 |child_task_runner_|
emircan 2016/02/04 05:18:52 Done.
84 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
85 base::WeakPtr<Client> client_;
86
87 // Thread checker to enforce that this object is used on a specific thread.
88 base::ThreadChecker thread_checker_;
89
90 DISALLOW_COPY_AND_ASSIGN(VTVideoEncodeAccelerator);
91 };
92
93 } // namespace content
94
95 #endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_ENCODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698