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 #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 16 matching lines...) Expand all Loading... |
27 VTCompressionSessionRef, | 27 VTCompressionSessionRef, |
28 CVImageBufferRef, | 28 CVImageBufferRef, |
29 CoreMediaGlue::CMTime, | 29 CoreMediaGlue::CMTime, |
30 CoreMediaGlue::CMTime, | 30 CoreMediaGlue::CMTime, |
31 CFDictionaryRef, | 31 CFDictionaryRef, |
32 void*, | 32 void*, |
33 VTEncodeInfoFlags*); | 33 VTEncodeInfoFlags*); |
34 typedef CVPixelBufferPoolRef (*VTCompressionSessionGetPixelBufferPoolMethod)( | 34 typedef CVPixelBufferPoolRef (*VTCompressionSessionGetPixelBufferPoolMethod)( |
35 VTCompressionSessionRef); | 35 VTCompressionSessionRef); |
36 typedef void (*VTCompressionSessionInvalidateMethod)(VTCompressionSessionRef); | 36 typedef void (*VTCompressionSessionInvalidateMethod)(VTCompressionSessionRef); |
| 37 typedef OSStatus (*VTCompressionSessionCompleteFramesMethod)( |
| 38 VTCompressionSessionRef, |
| 39 CoreMediaGlue::CMTime); |
37 typedef OSStatus (*VTSessionSetPropertyMethod)(VTSessionRef, | 40 typedef OSStatus (*VTSessionSetPropertyMethod)(VTSessionRef, |
38 CFStringRef, | 41 CFStringRef, |
39 CFTypeRef); | 42 CFTypeRef); |
40 | 43 |
41 VTCompressionSessionCreateMethod VTCompressionSessionCreate; | 44 VTCompressionSessionCreateMethod VTCompressionSessionCreate; |
42 VTCompressionSessionEncodeFrameMethod VTCompressionSessionEncodeFrame; | 45 VTCompressionSessionEncodeFrameMethod VTCompressionSessionEncodeFrame; |
43 VTCompressionSessionGetPixelBufferPoolMethod | 46 VTCompressionSessionGetPixelBufferPoolMethod |
44 VTCompressionSessionGetPixelBufferPool; | 47 VTCompressionSessionGetPixelBufferPool; |
45 VTCompressionSessionInvalidateMethod VTCompressionSessionInvalidate; | 48 VTCompressionSessionInvalidateMethod VTCompressionSessionInvalidate; |
| 49 VTCompressionSessionCompleteFramesMethod VTCompressionSessionCompleteFrames; |
46 VTSessionSetPropertyMethod VTSessionSetProperty; | 50 VTSessionSetPropertyMethod VTSessionSetProperty; |
47 | 51 |
48 CFStringRef* kVTCompressionPropertyKey_AllowFrameReordering; | 52 CFStringRef* kVTCompressionPropertyKey_AllowFrameReordering; |
49 CFStringRef* kVTCompressionPropertyKey_AverageBitRate; | 53 CFStringRef* kVTCompressionPropertyKey_AverageBitRate; |
50 CFStringRef* kVTCompressionPropertyKey_ColorPrimaries; | 54 CFStringRef* kVTCompressionPropertyKey_ColorPrimaries; |
51 CFStringRef* kVTCompressionPropertyKey_ExpectedFrameRate; | 55 CFStringRef* kVTCompressionPropertyKey_ExpectedFrameRate; |
| 56 CFStringRef* kVTCompressionPropertyKey_MaxFrameDelayCount; |
52 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameInterval; | 57 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameInterval; |
53 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration; | 58 CFStringRef* kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration; |
54 CFStringRef* kVTCompressionPropertyKey_ProfileLevel; | 59 CFStringRef* kVTCompressionPropertyKey_ProfileLevel; |
55 CFStringRef* kVTCompressionPropertyKey_RealTime; | 60 CFStringRef* kVTCompressionPropertyKey_RealTime; |
56 CFStringRef* kVTCompressionPropertyKey_TransferFunction; | 61 CFStringRef* kVTCompressionPropertyKey_TransferFunction; |
57 CFStringRef* kVTCompressionPropertyKey_YCbCrMatrix; | 62 CFStringRef* kVTCompressionPropertyKey_YCbCrMatrix; |
58 CFStringRef* kVTEncodeFrameOptionKey_ForceKeyFrame; | 63 CFStringRef* kVTEncodeFrameOptionKey_ForceKeyFrame; |
59 CFStringRef* kVTProfileLevel_H264_Baseline_AutoLevel; | 64 CFStringRef* kVTProfileLevel_H264_Baseline_AutoLevel; |
60 CFStringRef* kVTProfileLevel_H264_Main_AutoLevel; | 65 CFStringRef* kVTProfileLevel_H264_Main_AutoLevel; |
61 CFStringRef* kVTProfileLevel_H264_Extended_AutoLevel; | 66 CFStringRef* kVTProfileLevel_H264_Extended_AutoLevel; |
(...skipping 17 matching lines...) Expand all Loading... |
79 return; | 84 return; |
80 | 85 |
81 #define LOAD_SYMBOL(SYMBOL) \ | 86 #define LOAD_SYMBOL(SYMBOL) \ |
82 if (!LoadSymbol(#SYMBOL, reinterpret_cast<void**>(&library_.SYMBOL))) \ | 87 if (!LoadSymbol(#SYMBOL, reinterpret_cast<void**>(&library_.SYMBOL))) \ |
83 return; | 88 return; |
84 | 89 |
85 LOAD_SYMBOL(VTCompressionSessionCreate) | 90 LOAD_SYMBOL(VTCompressionSessionCreate) |
86 LOAD_SYMBOL(VTCompressionSessionEncodeFrame) | 91 LOAD_SYMBOL(VTCompressionSessionEncodeFrame) |
87 LOAD_SYMBOL(VTCompressionSessionGetPixelBufferPool) | 92 LOAD_SYMBOL(VTCompressionSessionGetPixelBufferPool) |
88 LOAD_SYMBOL(VTCompressionSessionInvalidate) | 93 LOAD_SYMBOL(VTCompressionSessionInvalidate) |
| 94 LOAD_SYMBOL(VTCompressionSessionCompleteFrames) |
89 LOAD_SYMBOL(VTSessionSetProperty) | 95 LOAD_SYMBOL(VTSessionSetProperty) |
90 | 96 |
91 LOAD_SYMBOL(kVTCompressionPropertyKey_AllowFrameReordering) | 97 LOAD_SYMBOL(kVTCompressionPropertyKey_AllowFrameReordering) |
92 LOAD_SYMBOL(kVTCompressionPropertyKey_AverageBitRate) | 98 LOAD_SYMBOL(kVTCompressionPropertyKey_AverageBitRate) |
93 LOAD_SYMBOL(kVTCompressionPropertyKey_ColorPrimaries) | 99 LOAD_SYMBOL(kVTCompressionPropertyKey_ColorPrimaries) |
94 LOAD_SYMBOL(kVTCompressionPropertyKey_ExpectedFrameRate) | 100 LOAD_SYMBOL(kVTCompressionPropertyKey_ExpectedFrameRate) |
| 101 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxFrameDelayCount) |
95 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameInterval) | 102 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameInterval) |
96 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration) | 103 LOAD_SYMBOL(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration) |
97 LOAD_SYMBOL(kVTCompressionPropertyKey_ProfileLevel) | 104 LOAD_SYMBOL(kVTCompressionPropertyKey_ProfileLevel) |
98 LOAD_SYMBOL(kVTCompressionPropertyKey_RealTime) | 105 LOAD_SYMBOL(kVTCompressionPropertyKey_RealTime) |
99 LOAD_SYMBOL(kVTCompressionPropertyKey_TransferFunction) | 106 LOAD_SYMBOL(kVTCompressionPropertyKey_TransferFunction) |
100 LOAD_SYMBOL(kVTCompressionPropertyKey_YCbCrMatrix) | 107 LOAD_SYMBOL(kVTCompressionPropertyKey_YCbCrMatrix) |
101 LOAD_SYMBOL(kVTEncodeFrameOptionKey_ForceKeyFrame); | 108 LOAD_SYMBOL(kVTEncodeFrameOptionKey_ForceKeyFrame); |
102 LOAD_SYMBOL(kVTProfileLevel_H264_Baseline_AutoLevel) | 109 LOAD_SYMBOL(kVTProfileLevel_H264_Baseline_AutoLevel) |
103 LOAD_SYMBOL(kVTProfileLevel_H264_Main_AutoLevel) | 110 LOAD_SYMBOL(kVTProfileLevel_H264_Main_AutoLevel) |
104 LOAD_SYMBOL(kVTProfileLevel_H264_Extended_AutoLevel) | 111 LOAD_SYMBOL(kVTProfileLevel_H264_Extended_AutoLevel) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 CVPixelBufferPoolRef VideoToolboxGlue::VTCompressionSessionGetPixelBufferPool( | 189 CVPixelBufferPoolRef VideoToolboxGlue::VTCompressionSessionGetPixelBufferPool( |
183 VTCompressionSessionRef session) const { | 190 VTCompressionSessionRef session) const { |
184 return library_->VTCompressionSessionGetPixelBufferPool(session); | 191 return library_->VTCompressionSessionGetPixelBufferPool(session); |
185 } | 192 } |
186 | 193 |
187 void VideoToolboxGlue::VTCompressionSessionInvalidate( | 194 void VideoToolboxGlue::VTCompressionSessionInvalidate( |
188 VTCompressionSessionRef session) const { | 195 VTCompressionSessionRef session) const { |
189 library_->VTCompressionSessionInvalidate(session); | 196 library_->VTCompressionSessionInvalidate(session); |
190 } | 197 } |
191 | 198 |
| 199 OSStatus VideoToolboxGlue::VTCompressionSessionCompleteFrames( |
| 200 VTCompressionSessionRef session, |
| 201 CoreMediaGlue::CMTime completeUntilPresentationTimeStamp) const { |
| 202 return library_->VTCompressionSessionCompleteFrames( |
| 203 session, completeUntilPresentationTimeStamp); |
| 204 } |
| 205 |
192 OSStatus VideoToolboxGlue::VTSessionSetProperty(VTSessionRef session, | 206 OSStatus VideoToolboxGlue::VTSessionSetProperty(VTSessionRef session, |
193 CFStringRef propertyKey, | 207 CFStringRef propertyKey, |
194 CFTypeRef propertyValue) const { | 208 CFTypeRef propertyValue) const { |
195 return library_->VTSessionSetProperty(session, propertyKey, propertyValue); | 209 return library_->VTSessionSetProperty(session, propertyKey, propertyValue); |
196 } | 210 } |
197 | 211 |
198 #define KEY_ACCESSOR(KEY) \ | 212 #define KEY_ACCESSOR(KEY) \ |
199 CFStringRef VideoToolboxGlue::KEY() const { return *library_->KEY; } | 213 CFStringRef VideoToolboxGlue::KEY() const { return *library_->KEY; } |
200 | 214 |
201 KEY_ACCESSOR(kVTCompressionPropertyKey_AllowFrameReordering) | 215 KEY_ACCESSOR(kVTCompressionPropertyKey_AllowFrameReordering) |
202 KEY_ACCESSOR(kVTCompressionPropertyKey_AverageBitRate) | 216 KEY_ACCESSOR(kVTCompressionPropertyKey_AverageBitRate) |
203 KEY_ACCESSOR(kVTCompressionPropertyKey_ColorPrimaries) | 217 KEY_ACCESSOR(kVTCompressionPropertyKey_ColorPrimaries) |
204 KEY_ACCESSOR(kVTCompressionPropertyKey_ExpectedFrameRate) | 218 KEY_ACCESSOR(kVTCompressionPropertyKey_ExpectedFrameRate) |
| 219 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxFrameDelayCount) |
205 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameInterval) | 220 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameInterval) |
206 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration) | 221 KEY_ACCESSOR(kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration) |
207 KEY_ACCESSOR(kVTCompressionPropertyKey_ProfileLevel) | 222 KEY_ACCESSOR(kVTCompressionPropertyKey_ProfileLevel) |
208 KEY_ACCESSOR(kVTCompressionPropertyKey_RealTime) | 223 KEY_ACCESSOR(kVTCompressionPropertyKey_RealTime) |
209 KEY_ACCESSOR(kVTCompressionPropertyKey_TransferFunction) | 224 KEY_ACCESSOR(kVTCompressionPropertyKey_TransferFunction) |
210 KEY_ACCESSOR(kVTCompressionPropertyKey_YCbCrMatrix) | 225 KEY_ACCESSOR(kVTCompressionPropertyKey_YCbCrMatrix) |
211 KEY_ACCESSOR(kVTEncodeFrameOptionKey_ForceKeyFrame) | 226 KEY_ACCESSOR(kVTEncodeFrameOptionKey_ForceKeyFrame) |
212 KEY_ACCESSOR(kVTProfileLevel_H264_Baseline_AutoLevel) | 227 KEY_ACCESSOR(kVTProfileLevel_H264_Baseline_AutoLevel) |
213 KEY_ACCESSOR(kVTProfileLevel_H264_Main_AutoLevel) | 228 KEY_ACCESSOR(kVTProfileLevel_H264_Main_AutoLevel) |
214 KEY_ACCESSOR(kVTProfileLevel_H264_Extended_AutoLevel) | 229 KEY_ACCESSOR(kVTProfileLevel_H264_Extended_AutoLevel) |
215 KEY_ACCESSOR(kVTProfileLevel_H264_High_AutoLevel) | 230 KEY_ACCESSOR(kVTProfileLevel_H264_High_AutoLevel) |
216 KEY_ACCESSOR(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder) | 231 KEY_ACCESSOR(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder) |
217 | 232 |
218 #undef KEY_ACCESSOR | 233 #undef KEY_ACCESSOR |
OLD | NEW |