forked from FMXExpress/ios-object-pascal-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iOSapi.MediaToolbox.pas
123 lines (103 loc) · 3.87 KB
/
iOSapi.MediaToolbox.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{ *********************************************************** }
{ }
{ CodeGear Delphi Runtime Library }
{ }
{ Copyright(c) 2012-2014 Embarcadero Technologies, Inc. }
{ }
{ *********************************************************** }
//
// Delphi-Objective-C Bridge
// Interfaces for Cocoa framework MediaToolbox
//
unit iOSapi.MediaToolbox;
interface
uses
Macapi.CoreFoundation,
Macapi.CoreServices,
Macapi.Dispatch,
Macapi.Foundation,
Macapi.Mach,
Macapi.ObjCRuntime,
Macapi.ObjectiveC,
Macapi.QuartzCore,
iOSapi.CocoaTypes,
iOSapi.CoreAudio,
iOSapi.CoreMedia,
iOSapi.Foundation;
const
kMTAudioProcessingTapCreationFlag_PreEffects = (1 shl 0);
kMTAudioProcessingTapCreationFlag_PostEffects = (1 shl 1);
kMTAudioProcessingTapFlag_StartOfStream = (1 shl 8);
kMTAudioProcessingTapFlag_EndOfStream = (1 shl 9);
kMTAudioProcessingTapCallbacksVersion_0 = 0;
type
// ===== Framework typedefs =====
{$M+}
MTAudioProcessingTapRef = Pointer;
CFTypeID = LongWord;
MTAudioProcessingTapCreationFlags = LongWord;
MTAudioProcessingTapFlags = LongWord;
MTAudioProcessingTapInitCallback = procedure(param1: MTAudioProcessingTapRef;
param2: Pointer; param3: Pointer); cdecl;
MTAudioProcessingTapFinalizeCallback = procedure
(param1: MTAudioProcessingTapRef); cdecl;
CMItemCount = LongInt;
MTAudioProcessingTapPrepareCallback = procedure
(param1: MTAudioProcessingTapRef; param2: CMItemCount;
param3: Pointer); cdecl;
MTAudioProcessingTapUnprepareCallback = procedure
(param1: MTAudioProcessingTapRef); cdecl;
MTAudioProcessingTapProcessCallback = procedure
(param1: MTAudioProcessingTapRef; param2: CMItemCount;
param3: MTAudioProcessingTapFlags; param4: Pointer; param5: PLongInt;
param6: PLongWord); cdecl;
MTAudioProcessingTapCallbacks = record
version: Integer;
clientInfo: Pointer;
init: MTAudioProcessingTapInitCallback;
finalize: MTAudioProcessingTapFinalizeCallback;
prepare: MTAudioProcessingTapPrepareCallback;
unprepare: MTAudioProcessingTapUnprepareCallback;
process: MTAudioProcessingTapProcessCallback;
end;
PMTAudioProcessingTapCallbacks = ^MTAudioProcessingTapCallbacks;
CFAllocatorRef = Pointer;
OSStatus = Int32;
FourCharCode = UInt32;
CMMediaType = FourCharCode;
CFStringRef = Pointer;
// ===== External functions =====
const
libMediaToolbox =
'/System/Library/Frameworks/MediaToolbox.framework/MediaToolbox';
function MTAudioProcessingTapGetTypeID: CFTypeID; cdecl;
external libMediaToolbox name _PU + 'MTAudioProcessingTapGetTypeID';
function MTAudioProcessingTapCreate(allocator: CFAllocatorRef;
callbacks: Pointer; flags: MTAudioProcessingTapCreationFlags; tapOut: Pointer)
: OSStatus; cdecl; external libMediaToolbox name _PU +
'MTAudioProcessingTapCreate';
function MTAudioProcessingTapGetStorage(tap: MTAudioProcessingTapRef): Pointer;
cdecl; external libMediaToolbox name _PU + 'MTAudioProcessingTapGetStorage';
function MTAudioProcessingTapGetSourceAudio(tap: MTAudioProcessingTapRef;
numberFrames: CMItemCount; bufferListInOut: Pointer; flagsOut: PLongWord;
timeRangeOut: Pointer; numberFramesOut: PLongInt): OSStatus; cdecl;
external libMediaToolbox name _PU + 'MTAudioProcessingTapGetSourceAudio';
function MTCopyLocalizedNameForMediaType(mediaType: CMMediaType): CFStringRef;
cdecl; external libMediaToolbox name _PU + 'MTCopyLocalizedNameForMediaType';
function MTCopyLocalizedNameForMediaSubType(mediaType: CMMediaType;
mediaSubType: FourCharCode): CFStringRef; cdecl;
external libMediaToolbox name _PU + 'MTCopyLocalizedNameForMediaSubType';
implementation
{$IF defined(IOS) and NOT defined(CPUARM)}
uses
Posix.Dlfcn;
var
MediaToolboxModule: THandle;
{$ENDIF IOS}
{$IF defined(IOS) and NOT defined(CPUARM)}
initialization
MediaToolboxModule := dlopen(MarshaledAString(libMediaToolbox), RTLD_LAZY);
finalization
dlclose(MediaToolboxModule);
{$ENDIF IOS}
end.