OLD | NEW |
| (Empty) |
1 // Copyright 2013 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_COREMEDIA_GLUE_H_ | |
6 #define MEDIA_BASE_MAC_COREMEDIA_GLUE_H_ | |
7 | |
8 #include <CoreVideo/CoreVideo.h> | |
9 #include <stddef.h> | |
10 #include <stdint.h> | |
11 | |
12 #include "base/macros.h" | |
13 #include "media/base/media_export.h" | |
14 | |
15 // CoreMedia API is only introduced in Mac OS X > 10.6, the (potential) linking | |
16 // with it has to happen in runtime. If it succeeds, subsequent clients can use | |
17 // CoreMedia via the class declared in this file, where the original naming has | |
18 // been kept as much as possible. | |
19 class MEDIA_EXPORT CoreMediaGlue { | |
20 public: | |
21 // Originally from CMTime.h | |
22 typedef int64_t CMTimeValue; | |
23 typedef int32_t CMTimeScale; | |
24 typedef int64_t CMTimeEpoch; | |
25 typedef uint32_t CMTimeFlags; | |
26 typedef struct { | |
27 CMTimeValue value; | |
28 CMTimeScale timescale; | |
29 CMTimeFlags flags; | |
30 CMTimeEpoch epoch; | |
31 } CMTime; | |
32 | |
33 // Originally from CMBlockBuffer.h | |
34 typedef uint32_t CMBlockBufferFlags; | |
35 typedef struct OpaqueCMBlockBuffer* CMBlockBufferRef; | |
36 typedef struct { | |
37 uint32_t version; | |
38 void* (*AllocateBlock)(void*, size_t); | |
39 void (*FreeBlock)(void*, void*, size_t); | |
40 void* refCon; | |
41 } CMBlockBufferCustomBlockSource; | |
42 | |
43 // Originally from CMFormatDescription.h. | |
44 typedef const struct opaqueCMFormatDescription* CMFormatDescriptionRef; | |
45 typedef CMFormatDescriptionRef CMVideoFormatDescriptionRef; | |
46 typedef FourCharCode CMVideoCodecType; | |
47 typedef struct { | |
48 int32_t width; | |
49 int32_t height; | |
50 } CMVideoDimensions; | |
51 enum { | |
52 kCMPixelFormat_422YpCbCr8_yuvs = 'yuvs', | |
53 }; | |
54 enum { | |
55 kCMVideoCodecType_JPEG = 'jpeg', | |
56 kCMVideoCodecType_JPEG_OpenDML = 'dmb1', | |
57 kCMVideoCodecType_H264 = 'avc1', | |
58 }; | |
59 | |
60 // Originally from CMFormatDescriptionBridge.h | |
61 enum { | |
62 kCMFormatDescriptionBridgeError_InvalidParameter = -12712, | |
63 }; | |
64 | |
65 // Originally from CMSampleBuffer.h. | |
66 typedef struct OpaqueCMSampleBuffer* CMSampleBufferRef; | |
67 | |
68 // Originally from CMTime.h. | |
69 static CMTime CMTimeMake(int64_t value, int32_t timescale); | |
70 | |
71 // Originally from CMBlockBuffer.h | |
72 static OSStatus CMBlockBufferCreateContiguous( | |
73 CFAllocatorRef structureAllocator, | |
74 CMBlockBufferRef sourceBuffer, | |
75 CFAllocatorRef blockAllocator, | |
76 const CMBlockBufferCustomBlockSource* customBlockSource, | |
77 size_t offsetToData, | |
78 size_t dataLength, | |
79 CMBlockBufferFlags flags, | |
80 CMBlockBufferRef* newBBufOut); | |
81 static size_t CMBlockBufferGetDataLength(CMBlockBufferRef theBuffer); | |
82 static OSStatus CMBlockBufferGetDataPointer(CMBlockBufferRef theBuffer, | |
83 size_t offset, | |
84 size_t* lengthAtOffset, | |
85 size_t* totalLength, | |
86 char** dataPointer); | |
87 static Boolean CMBlockBufferIsRangeContiguous(CMBlockBufferRef theBuffer, | |
88 size_t offset, | |
89 size_t length); | |
90 | |
91 // Originally from CMSampleBuffer.h. | |
92 static CMBlockBufferRef CMSampleBufferGetDataBuffer(CMSampleBufferRef sbuf); | |
93 static CMFormatDescriptionRef CMSampleBufferGetFormatDescription( | |
94 CMSampleBufferRef sbuf); | |
95 static CVImageBufferRef CMSampleBufferGetImageBuffer( | |
96 CMSampleBufferRef buffer); | |
97 static CFArrayRef CMSampleBufferGetSampleAttachmentsArray( | |
98 CMSampleBufferRef sbuf, | |
99 Boolean createIfNecessary); | |
100 static CFStringRef kCMSampleAttachmentKey_NotSync(); | |
101 static CMTime CMSampleBufferGetPresentationTimeStamp(CMSampleBufferRef sbuf); | |
102 | |
103 // Originally from CMFormatDescription.h. | |
104 static FourCharCode CMFormatDescriptionGetMediaSubType( | |
105 CMFormatDescriptionRef desc); | |
106 static CMVideoDimensions CMVideoFormatDescriptionGetDimensions( | |
107 CMVideoFormatDescriptionRef videoDesc); | |
108 static OSStatus CMVideoFormatDescriptionGetH264ParameterSetAtIndex( | |
109 CMFormatDescriptionRef videoDesc, | |
110 size_t parameterSetIndex, | |
111 const uint8_t** parameterSetPointerOut, | |
112 size_t* parameterSetSizeOut, | |
113 size_t* parameterSetCountOut, | |
114 int* NALUnitHeaderLengthOut) | |
115 /*__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)*/; | |
116 | |
117 private: | |
118 DISALLOW_IMPLICIT_CONSTRUCTORS(CoreMediaGlue); | |
119 }; | |
120 | |
121 #endif // MEDIA_BASE_MAC_COREMEDIA_GLUE_H_ | |
OLD | NEW |