root/trunk/AudioCodecComponentGlue.c

Revision 1, 11.6 kB (checked in by gbooker, 2 years ago)

Initial Import

Line 
1 /*      Copyright:      © Copyright 2004 Apple Computer, Inc. All rights reserved.
2
3         Disclaimer:     IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
4                         ("Apple") in consideration of your agreement to the following terms, and your
5                         use, installation, modification or redistribution of this Apple software
6                         constitutes acceptance of these terms.  If you do not agree with these terms,
7                         please do not use, install, modify or redistribute this Apple software.
8
9                         In consideration of your agreement to abide by the following terms, and subject
10                         to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
11                         copyrights in this original Apple software (the "Apple Software"), to use,
12                         reproduce, modify and redistribute the Apple Software, with or without
13                         modifications, in source and/or binary forms; provided that if you redistribute
14                         the Apple Software in its entirety and without modifications, you must retain
15                         this notice and the following text and disclaimers in all such redistributions of
16                         the Apple Software.  Neither the name, trademarks, service marks or logos of
17                         Apple Computer, Inc. may be used to endorse or promote products derived from the
18                         Apple Software without specific prior written permission from Apple.  Except as
19                         expressly stated in this notice, no other rights or licenses, express or implied,
20                         are granted by Apple herein, including but not limited to any patent rights that
21                         may be infringed by your derivative works or by other works in which the Apple
22                         Software may be incorporated.
23
24                         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
25                         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26                         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27                         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28                         COMBINATION WITH YOUR PRODUCTS.
29
30                         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31                         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32                         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33                         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34                         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35                         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36                         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38 /*=============================================================================
39         AudioCodecComponentGlue.c
40
41 =============================================================================*/
42
43 //=============================================================================
44 //      Includes
45 //=============================================================================
46
47 #include "AudioCodec.h"
48 #include "ACCodecDispatchTypes.h"
49
50 #if     !TARGET_OS_MAC || !TARGET_RT_MAC_MACHO
51         #include <MixedMode.h>
52         #if MP_SUPPORT
53                 #include "MPMixedModeSupport.h"
54         #endif
55 #endif
56
57 DEFINE_API(ComponentResult)
58 AudioCodecGetPropertyInfo(      AudioCodec                              inCodec,
59                                                         AudioCodecPropertyID    inPropertyID,
60                                                         UInt32*                                 outSize,
61                                                         Boolean*                                outWritable)
62 {
63         AudioCodecGetPropertyInfoGluePB myAudioCodecGetPropertyInfoGluePB;
64         myAudioCodecGetPropertyInfoGluePB.componentFlags = 0;
65         myAudioCodecGetPropertyInfoGluePB.componentParamSize = 12;
66         myAudioCodecGetPropertyInfoGluePB.componentWhat = kAudioCodecGetPropertyInfoSelect;
67        
68         #if     !TARGET_OS_WIN32
69                 myAudioCodecGetPropertyInfoGluePB.inCodec = inCodec;
70         #endif
71        
72         myAudioCodecGetPropertyInfoGluePB.outWritable = outWritable;
73         myAudioCodecGetPropertyInfoGluePB.outSize = outSize;
74         myAudioCodecGetPropertyInfoGluePB.inPropertyID = inPropertyID;
75
76         #if TARGET_API_MAC_OS8
77                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecGetPropertyInfoGluePB);
78         #elif TARGET_API_MAC_OSX
79                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecGetPropertyInfoGluePB);
80         #else
81                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecGetPropertyInfoGluePB);
82         #endif
83 }
84
85 DEFINE_API(ComponentResult)
86 AudioCodecGetProperty(  AudioCodec                              inCodec,
87                                                 AudioCodecPropertyID    inPropertyID,
88                                                 UInt32*                                 ioPropertyDataSize,
89                                                 void*                                   outPropertyData)
90 {
91         AudioCodecGetPropertyGluePB myAudioCodecGetPropertyGluePB;
92         myAudioCodecGetPropertyGluePB.componentFlags = 0;
93         myAudioCodecGetPropertyGluePB.componentParamSize = 12;
94         myAudioCodecGetPropertyGluePB.componentWhat = kAudioCodecGetPropertySelect;
95        
96         #if     !TARGET_OS_WIN32
97                 myAudioCodecGetPropertyGluePB.inCodec = inCodec;
98         #endif
99        
100         myAudioCodecGetPropertyGluePB.outPropertyData = outPropertyData;
101         myAudioCodecGetPropertyGluePB.ioPropertyDataSize = ioPropertyDataSize;
102         myAudioCodecGetPropertyGluePB.inPropertyID = inPropertyID;
103
104         #if TARGET_API_MAC_OS8
105                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecGetPropertyGluePB);
106         #elif TARGET_API_MAC_OSX
107                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecGetPropertyGluePB);
108         #else
109                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecGetPropertyGluePB);
110         #endif
111 }
112
113 DEFINE_API(ComponentResult)
114 AudioCodecSetProperty(  AudioCodec                              inCodec,
115                                                 AudioCodecPropertyID    inPropertyID,
116                                                 UInt32                                  inPropertyDataSize,
117                                                 const void*                             inPropertyData)
118 {
119         AudioCodecSetPropertyGluePB myAudioCodecSetPropertyGluePB;
120         myAudioCodecSetPropertyGluePB.componentFlags = 0;
121         myAudioCodecSetPropertyGluePB.componentParamSize = 12;
122         myAudioCodecSetPropertyGluePB.componentWhat = kAudioCodecSetPropertySelect;
123        
124         #if     !TARGET_OS_WIN32
125                 myAudioCodecSetPropertyGluePB.inCodec = inCodec;
126         #endif
127        
128         myAudioCodecSetPropertyGluePB.inPropertyData = inPropertyData;
129         myAudioCodecSetPropertyGluePB.inPropertyDataSize = inPropertyDataSize;
130         myAudioCodecSetPropertyGluePB.inPropertyID = inPropertyID;
131
132         #if TARGET_API_MAC_OS8
133                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecSetPropertyGluePB);
134         #elif TARGET_API_MAC_OSX
135                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecSetPropertyGluePB);
136         #else
137                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecSetPropertyGluePB);
138         #endif
139 }
140
141 DEFINE_API(ComponentResult)
142 AudioCodecInitialize(   AudioCodec                                                      inCodec,
143                                                 const AudioStreamBasicDescription*      inInputFormat,
144                                                 const AudioStreamBasicDescription*      inOutputFormat,
145                                                 const void*                                                     inMagicCookie,
146                                                 UInt32                                                          inMagicCookieByteSize)
147 {
148         AudioCodecInitializeGluePB myAudioCodecInitializeGluePB;
149         myAudioCodecInitializeGluePB.componentFlags = 0;
150         myAudioCodecInitializeGluePB.componentParamSize = 16;
151         myAudioCodecInitializeGluePB.componentWhat = kAudioCodecInitializeSelect;
152        
153         #if     !TARGET_OS_WIN32
154                 myAudioCodecInitializeGluePB.inCodec = inCodec;
155         #endif
156        
157         myAudioCodecInitializeGluePB.inMagicCookieByteSize = inMagicCookieByteSize;
158         myAudioCodecInitializeGluePB.inMagicCookie = inMagicCookie;
159         myAudioCodecInitializeGluePB.inOutputFormat = inOutputFormat;
160         myAudioCodecInitializeGluePB.inInputFormat = inInputFormat;
161
162         #if TARGET_API_MAC_OS8
163                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecInitializeGluePB);
164         #elif TARGET_API_MAC_OSX
165                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecInitializeGluePB);
166         #else
167                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecInitializeGluePB);
168         #endif
169 }
170
171 DEFINE_API(ComponentResult)
172 AudioCodecUninitialize(AudioCodec inCodec)
173 {
174         AudioCodecUninitializeGluePB myAudioCodecUninitializeGluePB;
175         myAudioCodecUninitializeGluePB.componentFlags = 0;
176         myAudioCodecUninitializeGluePB.componentParamSize = 0;
177         myAudioCodecUninitializeGluePB.componentWhat = kAudioCodecUninitializeSelect;
178        
179         #if     !TARGET_OS_WIN32
180                 myAudioCodecUninitializeGluePB.inCodec = inCodec;
181         #endif
182
183         #if TARGET_API_MAC_OS8
184                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecUninitializeGluePB);
185         #elif TARGET_API_MAC_OSX
186                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecUninitializeGluePB);
187         #else
188                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecUninitializeGluePB);
189         #endif
190 }
191
192 DEFINE_API(ComponentResult)
193 AudioCodecAppendInputData(      AudioCodec                                                      inCodec,
194                                                         const void*                                                     inInputData,
195                                                         UInt32*                                                         ioInputDataByteSize,
196                                                         UInt32*                                                         ioNumberPackets,
197                                                         const AudioStreamPacketDescription*     inPacketDescription)
198 {
199         AudioCodecAppendInputDataGluePB myAudioCodecAppendInputDataGluePB;
200         myAudioCodecAppendInputDataGluePB.componentFlags = 0;
201         myAudioCodecAppendInputDataGluePB.componentParamSize = 16;
202         myAudioCodecAppendInputDataGluePB.componentWhat = kAudioCodecAppendInputDataSelect;
203        
204         #if     !TARGET_OS_WIN32
205                 myAudioCodecAppendInputDataGluePB.inCodec = inCodec;
206         #endif
207        
208         myAudioCodecAppendInputDataGluePB.inPacketDescription = inPacketDescription;
209         myAudioCodecAppendInputDataGluePB.ioNumberPackets = ioNumberPackets;
210         myAudioCodecAppendInputDataGluePB.ioInputDataByteSize = ioInputDataByteSize;
211         myAudioCodecAppendInputDataGluePB.inInputData = inInputData;
212
213         #if TARGET_API_MAC_OS8
214                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecAppendInputDataGluePB);
215         #elif TARGET_API_MAC_OSX
216                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecAppendInputDataGluePB);
217         #else
218                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecAppendInputDataGluePB);
219         #endif
220 }
221
222 DEFINE_API(ComponentResult)
223 AudioCodecProduceOutputPackets( AudioCodec                                              inCodec,
224                                                                 void*                                                   outOutputData,
225                                                                 UInt32*                                                 ioOutputDataByteSize,
226                                                                 UInt32*                                                 ioNumberPackets,
227                                                                 AudioStreamPacketDescription*   outPacketDescription,
228                                                                 UInt32*                                                 outStatus)
229 {
230         AudioCodecProduceOutputPacketsGluePB myAudioCodecProduceOutputPacketsGluePB;
231         myAudioCodecProduceOutputPacketsGluePB.componentFlags = 0;
232         myAudioCodecProduceOutputPacketsGluePB.componentParamSize = 20;
233         myAudioCodecProduceOutputPacketsGluePB.componentWhat = kAudioCodecProduceOutputDataSelect;
234        
235         #if     !TARGET_OS_WIN32
236                 myAudioCodecProduceOutputPacketsGluePB.inCodec = inCodec;
237         #endif
238        
239         myAudioCodecProduceOutputPacketsGluePB.outStatus = outStatus;
240         myAudioCodecProduceOutputPacketsGluePB.outPacketDescription = outPacketDescription;
241         myAudioCodecProduceOutputPacketsGluePB.ioNumberPackets = ioNumberPackets;
242         myAudioCodecProduceOutputPacketsGluePB.ioOutputDataByteSize = ioOutputDataByteSize;
243         myAudioCodecProduceOutputPacketsGluePB.outOutputData = outOutputData;
244
245         #if TARGET_API_MAC_OS8
246                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecProduceOutputPacketsGluePB);
247         #elif TARGET_API_MAC_OSX
248                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecProduceOutputPacketsGluePB);
249         #else
250                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecProduceOutputPacketsGluePB);
251         #endif
252 }
253
254 DEFINE_API(ComponentResult)
255 AudioCodecReset(AudioCodec inCodec)
256 {
257         AudioCodecResetGluePB myAudioCodecResetGluePB;
258         myAudioCodecResetGluePB.componentFlags = 0;
259         myAudioCodecResetGluePB.componentParamSize = 0;
260         myAudioCodecResetGluePB.componentWhat = kAudioCodecResetSelect;
261        
262         #if     !TARGET_OS_WIN32
263                 myAudioCodecResetGluePB.inCodec = inCodec;
264         #endif
265
266         #if TARGET_API_MAC_OS8
267                 return (ComponentResult)CallUniversalProc(CallComponentUPP, 0x000000F0, &myAudioCodecResetGluePB);
268         #elif TARGET_API_MAC_OSX
269                 return (ComponentResult)CallComponentDispatch((ComponentParameters*)&myAudioCodecResetGluePB);
270         #else
271                 return (ComponentResult)CallComponent(inCodec, (ComponentParameters*)&myAudioCodecResetGluePB);
272         #endif
273 }
Note: See TracBrowser for help on using the browser.