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.
5 #ifndef MEDIA_BASE_MAC_COREMEDIA_GLUE_H_
6 #define MEDIA_BASE_MAC_COREMEDIA_GLUE_H_
8 #include <CoreVideo/CoreVideo.h>
10 #include "base/basictypes.h"
11 #include "media/base/media_export.h"
13 // CoreMedia API is only introduced in Mac OS X > 10.6, the (potential) linking
14 // with it has to happen in runtime. If it succeeds, subsequent clients can use
15 // CoreMedia via the class declared in this file, where the original naming has
16 // been kept as much as possible.
17 class MEDIA_EXPORT CoreMediaGlue
{
19 // Originally from CMTime.h
20 typedef int64_t CMTimeValue
;
21 typedef int32_t CMTimeScale
;
22 typedef int64_t CMTimeEpoch
;
23 typedef uint32_t CMTimeFlags
;
26 CMTimeScale timescale
;
31 // Originally from CMBlockBuffer.h
32 typedef uint32_t CMBlockBufferFlags
;
33 typedef struct OpaqueCMBlockBuffer
* CMBlockBufferRef
;
36 void* (*AllocateBlock
)(void*, size_t);
37 void (*FreeBlock
)(void*, void*, size_t);
39 } CMBlockBufferCustomBlockSource
;
41 // Originally from CMFormatDescription.h.
42 typedef const struct opaqueCMFormatDescription
* CMFormatDescriptionRef
;
43 typedef CMFormatDescriptionRef CMVideoFormatDescriptionRef
;
44 typedef FourCharCode CMVideoCodecType
;
50 kCMPixelFormat_422YpCbCr8_yuvs
= 'yuvs',
53 kCMVideoCodecType_JPEG_OpenDML
= 'dmb1',
54 kCMVideoCodecType_H264
= 'avc1',
57 // Originally from CMFormatDescriptionBridge.h
59 kCMFormatDescriptionBridgeError_InvalidParameter
= -12712,
62 // Originally from CMSampleBuffer.h.
63 typedef struct OpaqueCMSampleBuffer
* CMSampleBufferRef
;
65 // Originally from CMTime.h.
66 static CMTime
CMTimeMake(int64_t value
, int32_t timescale
);
68 // Originally from CMBlockBuffer.h
69 static OSStatus
CMBlockBufferCreateContiguous(
70 CFAllocatorRef structureAllocator
,
71 CMBlockBufferRef sourceBuffer
,
72 CFAllocatorRef blockAllocator
,
73 const CMBlockBufferCustomBlockSource
* customBlockSource
,
76 CMBlockBufferFlags flags
,
77 CMBlockBufferRef
* newBBufOut
);
78 static size_t CMBlockBufferGetDataLength(CMBlockBufferRef theBuffer
);
79 static OSStatus
CMBlockBufferGetDataPointer(CMBlockBufferRef theBuffer
,
81 size_t* lengthAtOffset
,
84 static Boolean
CMBlockBufferIsRangeContiguous(CMBlockBufferRef theBuffer
,
88 // Originally from CMSampleBuffer.h.
89 static CMBlockBufferRef
CMSampleBufferGetDataBuffer(CMSampleBufferRef sbuf
);
90 static CMFormatDescriptionRef
CMSampleBufferGetFormatDescription(
91 CMSampleBufferRef sbuf
);
92 static CVImageBufferRef
CMSampleBufferGetImageBuffer(
93 CMSampleBufferRef buffer
);
94 static CFArrayRef
CMSampleBufferGetSampleAttachmentsArray(
95 CMSampleBufferRef sbuf
,
96 Boolean createIfNecessary
);
97 static CFStringRef
kCMSampleAttachmentKey_NotSync();
99 // Originally from CMFormatDescription.h.
100 static FourCharCode
CMFormatDescriptionGetMediaSubType(
101 CMFormatDescriptionRef desc
);
102 static CMVideoDimensions
CMVideoFormatDescriptionGetDimensions(
103 CMVideoFormatDescriptionRef videoDesc
);
104 static OSStatus
CMVideoFormatDescriptionGetH264ParameterSetAtIndex(
105 CMFormatDescriptionRef videoDesc
,
106 size_t parameterSetIndex
,
107 const uint8_t** parameterSetPointerOut
,
108 size_t* parameterSetSizeOut
,
109 size_t* parameterSetCountOut
,
110 int* NALUnitHeaderLengthOut
)
111 /*__OSX_AVAILABLE_STARTING(__MAC_10_9,__IPHONE_7_0)*/;
114 DISALLOW_IMPLICIT_CONSTRUCTORS(CoreMediaGlue
);
117 #endif // MEDIA_BASE_MAC_COREMEDIA_GLUE_H_