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

Side by Side Diff: media/base/mac/videotoolbox_glue.mm

Issue 1805723002: Reland: H264 HW encode using VideoToolbox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix gyp. Created 4 years, 9 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/base/mac/videotoolbox_glue.h ('k') | media/base/mac/videotoolbox_helpers.h » ('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 #include "media/base/mac/videotoolbox_glue.h" 5 #include "media/base/mac/videotoolbox_glue.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 VTCompressionSessionEncodeFrameMethod VTCompressionSessionEncodeFrame; 46 VTCompressionSessionEncodeFrameMethod VTCompressionSessionEncodeFrame;
47 VTCompressionSessionGetPixelBufferPoolMethod 47 VTCompressionSessionGetPixelBufferPoolMethod
48 VTCompressionSessionGetPixelBufferPool; 48 VTCompressionSessionGetPixelBufferPool;
49 VTCompressionSessionInvalidateMethod VTCompressionSessionInvalidate; 49 VTCompressionSessionInvalidateMethod VTCompressionSessionInvalidate;
50 VTCompressionSessionCompleteFramesMethod VTCompressionSessionCompleteFrames; 50 VTCompressionSessionCompleteFramesMethod VTCompressionSessionCompleteFrames;
51 VTSessionSetPropertyMethod VTSessionSetProperty; 51 VTSessionSetPropertyMethod VTSessionSetProperty;
52 52
53 CFStringRef* kVTCompressionPropertyKey_AllowFrameReordering; 53 CFStringRef* kVTCompressionPropertyKey_AllowFrameReordering;
54 CFStringRef* kVTCompressionPropertyKey_AverageBitRate; 54 CFStringRef* kVTCompressionPropertyKey_AverageBitRate;
55 CFStringRef* kVTCompressionPropertyKey_ColorPrimaries; 55 CFStringRef* kVTCompressionPropertyKey_ColorPrimaries;
56 CFStringRef* kVTCompressionPropertyKey_DataRateLimits;
56 CFStringRef* kVTCompressionPropertyKey_ExpectedFrameRate; 57 CFStringRef* kVTCompressionPropertyKey_ExpectedFrameRate;
57 CFStringRef* kVTCompressionPropertyKey_MaxFrameDelayCount; 58 CFStringRef* kVTCompressionPropertyKey_MaxFrameDelayCount;
58 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameInterval; 59 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameInterval;
59 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration; 60 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration;
60 CFStringRef* kVTCompressionPropertyKey_ProfileLevel; 61 CFStringRef* kVTCompressionPropertyKey_ProfileLevel;
61 CFStringRef* kVTCompressionPropertyKey_RealTime; 62 CFStringRef* kVTCompressionPropertyKey_RealTime;
62 CFStringRef* kVTCompressionPropertyKey_TransferFunction; 63 CFStringRef* kVTCompressionPropertyKey_TransferFunction;
63 CFStringRef* kVTCompressionPropertyKey_YCbCrMatrix; 64 CFStringRef* kVTCompressionPropertyKey_YCbCrMatrix;
64 CFStringRef* kVTEncodeFrameOptionKey_ForceKeyFrame; 65 CFStringRef* kVTEncodeFrameOptionKey_ForceKeyFrame;
65 CFStringRef* kVTProfileLevel_H264_Baseline_AutoLevel; 66 CFStringRef* kVTProfileLevel_H264_Baseline_AutoLevel;
66 CFStringRef* kVTProfileLevel_H264_Main_AutoLevel; 67 CFStringRef* kVTProfileLevel_H264_Main_AutoLevel;
67 CFStringRef* kVTProfileLevel_H264_Extended_AutoLevel; 68 CFStringRef* kVTProfileLevel_H264_Extended_AutoLevel;
68 CFStringRef* kVTProfileLevel_H264_High_AutoLevel; 69 CFStringRef* kVTProfileLevel_H264_High_AutoLevel;
69 CFStringRef* 70 CFStringRef*
70 kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder; 71 kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder;
72 CFStringRef*
73 kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder;
71 }; 74 };
72 75
73 // Lazy-instance responsible for loading VideoToolbox. 76 // Lazy-instance responsible for loading VideoToolbox.
74 class VideoToolboxGlue::Loader { 77 class VideoToolboxGlue::Loader {
75 public: 78 public:
76 Loader() { 79 Loader() {
77 NSBundle* bundle = [NSBundle 80 NSBundle* bundle = [NSBundle
78 bundleWithPath:@"/System/Library/Frameworks/VideoToolbox.framework"]; 81 bundleWithPath:@"/System/Library/Frameworks/VideoToolbox.framework"];
79 const char* path = [[bundle executablePath] fileSystemRepresentation]; 82 const char* path = [[bundle executablePath] fileSystemRepresentation];
80 if (!path) 83 if (!path)
(...skipping 10 matching lines...) Expand all
91 LOAD_SYMBOL(VTCompressionSessionCreate) 94 LOAD_SYMBOL(VTCompressionSessionCreate)
92 LOAD_SYMBOL(VTCompressionSessionEncodeFrame) 95 LOAD_SYMBOL(VTCompressionSessionEncodeFrame)
93 LOAD_SYMBOL(VTCompressionSessionGetPixelBufferPool) 96 LOAD_SYMBOL(VTCompressionSessionGetPixelBufferPool)
94 LOAD_SYMBOL(VTCompressionSessionInvalidate) 97 LOAD_SYMBOL(VTCompressionSessionInvalidate)
95 LOAD_SYMBOL(VTCompressionSessionCompleteFrames) 98 LOAD_SYMBOL(VTCompressionSessionCompleteFrames)
96 LOAD_SYMBOL(VTSessionSetProperty) 99 LOAD_SYMBOL(VTSessionSetProperty)
97 100
98 LOAD_SYMBOL(kVTCompressionPropertyKey_AllowFrameReordering) 101 LOAD_SYMBOL(kVTCompressionPropertyKey_AllowFrameReordering)
99 LOAD_SYMBOL(kVTCompressionPropertyKey_AverageBitRate) 102 LOAD_SYMBOL(kVTCompressionPropertyKey_AverageBitRate)
100 LOAD_SYMBOL(kVTCompressionPropertyKey_ColorPrimaries) 103 LOAD_SYMBOL(kVTCompressionPropertyKey_ColorPrimaries)
104 LOAD_SYMBOL(kVTCompressionPropertyKey_DataRateLimits)
101 LOAD_SYMBOL(kVTCompressionPropertyKey_ExpectedFrameRate) 105 LOAD_SYMBOL(kVTCompressionPropertyKey_ExpectedFrameRate)
102 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxFrameDelayCount) 106 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxFrameDelayCount)
103 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameInterval) 107 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameInterval)
104 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration) 108 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration)
105 LOAD_SYMBOL(kVTCompressionPropertyKey_ProfileLevel) 109 LOAD_SYMBOL(kVTCompressionPropertyKey_ProfileLevel)
106 LOAD_SYMBOL(kVTCompressionPropertyKey_RealTime) 110 LOAD_SYMBOL(kVTCompressionPropertyKey_RealTime)
107 LOAD_SYMBOL(kVTCompressionPropertyKey_TransferFunction) 111 LOAD_SYMBOL(kVTCompressionPropertyKey_TransferFunction)
108 LOAD_SYMBOL(kVTCompressionPropertyKey_YCbCrMatrix) 112 LOAD_SYMBOL(kVTCompressionPropertyKey_YCbCrMatrix)
109 LOAD_SYMBOL(kVTEncodeFrameOptionKey_ForceKeyFrame); 113 LOAD_SYMBOL(kVTEncodeFrameOptionKey_ForceKeyFrame);
110 LOAD_SYMBOL(kVTProfileLevel_H264_Baseline_AutoLevel) 114 LOAD_SYMBOL(kVTProfileLevel_H264_Baseline_AutoLevel)
111 LOAD_SYMBOL(kVTProfileLevel_H264_Main_AutoLevel) 115 LOAD_SYMBOL(kVTProfileLevel_H264_Main_AutoLevel)
112 LOAD_SYMBOL(kVTProfileLevel_H264_Extended_AutoLevel) 116 LOAD_SYMBOL(kVTProfileLevel_H264_Extended_AutoLevel)
113 LOAD_SYMBOL(kVTProfileLevel_H264_High_AutoLevel) 117 LOAD_SYMBOL(kVTProfileLevel_H264_High_AutoLevel)
114 LOAD_SYMBOL( 118 LOAD_SYMBOL(
115 kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder) 119 kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder)
120 LOAD_SYMBOL(
121 kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder)
116 122
117 #undef LOAD_SYMBOL 123 #undef LOAD_SYMBOL
118 124
119 glue_.library_ = &library_; 125 glue_.library_ = &library_;
120 } 126 }
121 127
122 const VideoToolboxGlue* glue() const { 128 const VideoToolboxGlue* glue() const {
123 return (glue_.library_) ? &glue_ : NULL; 129 return (glue_.library_) ? &glue_ : NULL;
124 } 130 }
125 131
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 CFTypeRef propertyValue) const { 215 CFTypeRef propertyValue) const {
210 return library_->VTSessionSetProperty(session, propertyKey, propertyValue); 216 return library_->VTSessionSetProperty(session, propertyKey, propertyValue);
211 } 217 }
212 218
213 #define KEY_ACCESSOR(KEY) \ 219 #define KEY_ACCESSOR(KEY) \
214 CFStringRef VideoToolboxGlue::KEY() const { return *library_->KEY; } 220 CFStringRef VideoToolboxGlue::KEY() const { return *library_->KEY; }
215 221
216 KEY_ACCESSOR(kVTCompressionPropertyKey_AllowFrameReordering) 222 KEY_ACCESSOR(kVTCompressionPropertyKey_AllowFrameReordering)
217 KEY_ACCESSOR(kVTCompressionPropertyKey_AverageBitRate) 223 KEY_ACCESSOR(kVTCompressionPropertyKey_AverageBitRate)
218 KEY_ACCESSOR(kVTCompressionPropertyKey_ColorPrimaries) 224 KEY_ACCESSOR(kVTCompressionPropertyKey_ColorPrimaries)
225 KEY_ACCESSOR(kVTCompressionPropertyKey_DataRateLimits)
219 KEY_ACCESSOR(kVTCompressionPropertyKey_ExpectedFrameRate) 226 KEY_ACCESSOR(kVTCompressionPropertyKey_ExpectedFrameRate)
220 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxFrameDelayCount) 227 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxFrameDelayCount)
221 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameInterval) 228 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameInterval)
222 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration) 229 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration)
223 KEY_ACCESSOR(kVTCompressionPropertyKey_ProfileLevel) 230 KEY_ACCESSOR(kVTCompressionPropertyKey_ProfileLevel)
224 KEY_ACCESSOR(kVTCompressionPropertyKey_RealTime) 231 KEY_ACCESSOR(kVTCompressionPropertyKey_RealTime)
225 KEY_ACCESSOR(kVTCompressionPropertyKey_TransferFunction) 232 KEY_ACCESSOR(kVTCompressionPropertyKey_TransferFunction)
226 KEY_ACCESSOR(kVTCompressionPropertyKey_YCbCrMatrix) 233 KEY_ACCESSOR(kVTCompressionPropertyKey_YCbCrMatrix)
227 KEY_ACCESSOR(kVTEncodeFrameOptionKey_ForceKeyFrame) 234 KEY_ACCESSOR(kVTEncodeFrameOptionKey_ForceKeyFrame)
228 KEY_ACCESSOR(kVTProfileLevel_H264_Baseline_AutoLevel) 235 KEY_ACCESSOR(kVTProfileLevel_H264_Baseline_AutoLevel)
229 KEY_ACCESSOR(kVTProfileLevel_H264_Main_AutoLevel) 236 KEY_ACCESSOR(kVTProfileLevel_H264_Main_AutoLevel)
230 KEY_ACCESSOR(kVTProfileLevel_H264_Extended_AutoLevel) 237 KEY_ACCESSOR(kVTProfileLevel_H264_Extended_AutoLevel)
231 KEY_ACCESSOR(kVTProfileLevel_H264_High_AutoLevel) 238 KEY_ACCESSOR(kVTProfileLevel_H264_High_AutoLevel)
232 KEY_ACCESSOR(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder) 239 KEY_ACCESSOR(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder)
240 KEY_ACCESSOR(
241 kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder)
233 242
234 #undef KEY_ACCESSOR 243 #undef KEY_ACCESSOR
OLDNEW
« no previous file with comments | « media/base/mac/videotoolbox_glue.h ('k') | media/base/mac/videotoolbox_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698