OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef MEDIA_BASE_MAC_VIDEOTOOLBOX_GLUE_H_ | |
6 #define MEDIA_BASE_MAC_VIDEOTOOLBOX_GLUE_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "media/base/mac/coremedia_glue.h" | |
12 #include "media/base/media_export.h" | |
13 | |
14 // VideoToolbox API is available in and after OS X 10.9 and iOS 8 (10.8 has | |
15 // support for software encoding, but this class exposes the 10.9 API level). | |
16 // Chromium requires OS X 10.9 or iOS 9. This class is defined to try and load | |
17 // the VideoToolbox library at runtime. If it succeeds, clients can use | |
18 // VideoToolbox via this class. | |
19 // Note that this file is necessary because Chromium still targets OS X 10.6 for | |
20 // deployment. It should be deprecated soon, see crbug.com/579648. | |
21 class MEDIA_EXPORT VideoToolboxGlue { | |
22 public: | |
23 class Loader; | |
24 | |
25 // Returns a glue object if VideoToolbox is supported or null otherwise. | |
26 // Using a glue object allows to avoid expensive atomic operations on every | |
27 // function call. The object has process life duration and must not be | |
28 // deleted. | |
29 static const VideoToolboxGlue* Get(); | |
30 | |
31 // Originally from VTErrors.h | |
32 typedef UInt32 VTEncodeInfoFlags; | |
33 enum { | |
34 kVTEncodeInfo_Asynchronous = 1UL << 0, | |
35 kVTEncodeInfo_FrameDropped = 1UL << 1, | |
36 }; | |
37 | |
38 // Originally from VTCompressionSession.h | |
39 typedef struct OpaqueVTCompressionSession* VTCompressionSessionRef; | |
40 typedef void (*VTCompressionOutputCallback)( | |
41 void* outputCallbackRefCon, | |
42 void* sourceFrameRefCon, | |
43 OSStatus status, | |
44 VTEncodeInfoFlags infoFlags, | |
45 CoreMediaGlue::CMSampleBufferRef sampleBuffer); | |
46 | |
47 // Originally from VTSession.h | |
48 typedef CFTypeRef VTSessionRef; | |
49 | |
50 // Originally from VTCompressionProperties.h | |
51 CFStringRef kVTCompressionPropertyKey_AllowFrameReordering() const; | |
52 CFStringRef kVTCompressionPropertyKey_AverageBitRate() const; | |
53 CFStringRef kVTCompressionPropertyKey_ColorPrimaries() const; | |
54 CFStringRef kVTCompressionPropertyKey_DataRateLimits() const; | |
55 CFStringRef kVTCompressionPropertyKey_ExpectedFrameRate() const; | |
56 CFStringRef kVTCompressionPropertyKey_MaxFrameDelayCount() const; | |
57 CFStringRef kVTCompressionPropertyKey_MaxKeyFrameInterval() const; | |
58 CFStringRef kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration() const; | |
59 CFStringRef kVTCompressionPropertyKey_ProfileLevel() const; | |
60 CFStringRef kVTCompressionPropertyKey_RealTime() const; | |
61 CFStringRef kVTCompressionPropertyKey_TransferFunction() const; | |
62 CFStringRef kVTCompressionPropertyKey_YCbCrMatrix() const; | |
63 | |
64 CFStringRef kVTEncodeFrameOptionKey_ForceKeyFrame() const; | |
65 | |
66 CFStringRef kVTProfileLevel_H264_Baseline_AutoLevel() const; | |
67 CFStringRef kVTProfileLevel_H264_Main_AutoLevel() const; | |
68 CFStringRef kVTProfileLevel_H264_Extended_AutoLevel() const; | |
69 CFStringRef kVTProfileLevel_H264_High_AutoLevel() const; | |
70 | |
71 CFStringRef | |
72 kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder() | |
73 const; | |
74 CFStringRef | |
75 kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder() const; | |
76 | |
77 // Originally from VTCompressionSession.h | |
78 OSStatus VTCompressionSessionCreate( | |
79 CFAllocatorRef allocator, | |
80 int32_t width, | |
81 int32_t height, | |
82 CoreMediaGlue::CMVideoCodecType codecType, | |
83 CFDictionaryRef encoderSpecification, | |
84 CFDictionaryRef sourceImageBufferAttributes, | |
85 CFAllocatorRef compressedDataAllocator, | |
86 VTCompressionOutputCallback outputCallback, | |
87 void* outputCallbackRefCon, | |
88 VTCompressionSessionRef* compressionSessionOut) const; | |
89 OSStatus VTCompressionSessionEncodeFrame( | |
90 VTCompressionSessionRef session, | |
91 CVImageBufferRef imageBuffer, | |
92 CoreMediaGlue::CMTime presentationTimeStamp, | |
93 CoreMediaGlue::CMTime duration, | |
94 CFDictionaryRef frameProperties, | |
95 void* sourceFrameRefCon, | |
96 VTEncodeInfoFlags* infoFlagsOut) const; | |
97 CVPixelBufferPoolRef VTCompressionSessionGetPixelBufferPool( | |
98 VTCompressionSessionRef session) const; | |
99 void VTCompressionSessionInvalidate(VTCompressionSessionRef session) const; | |
100 OSStatus VTCompressionSessionCompleteFrames( | |
101 VTCompressionSessionRef session, | |
102 CoreMediaGlue::CMTime completeUntilPresentationTimeStamp) const; | |
103 | |
104 // Originally from VTSession.h | |
105 OSStatus VTSessionSetProperty(VTSessionRef session, | |
106 CFStringRef propertyKey, | |
107 CFTypeRef propertyValue) const; | |
108 | |
109 private: | |
110 struct Library; | |
111 VideoToolboxGlue(); | |
112 Library* library_; | |
113 DISALLOW_COPY_AND_ASSIGN(VideoToolboxGlue); | |
114 }; | |
115 | |
116 #endif // MEDIA_BASE_MAC_VIDEOTOOLBOX_GLUE_H_ | |
OLD | NEW |