root/trunk/AudioCodec.h

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

Initial Import

Line 
1 /*      Copyright:      © Copyright 2003 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      File:       AudioToolbox/AudioCodec.h
40
41      Contains:   A component API for encoding/decoding audio data.
42
43      Version:    Technology: Mac OS X
44                  Release:    Mac OS X
45
46      Copyright:  (c) 1985-2002 by Apple Computer, Inc., all rights reserved.
47
48      Bugs?:      For bug reports, consult the following page on
49                  the World Wide Web:
50
51                      http://developer.apple.com/bugreporter/
52
53 */
54 #if !defined(__AudioCodec_h__)
55 #define __AudioCodec_h__
56
57 //=============================================================================
58 //      Includes
59 //=============================================================================
60
61 #include <TargetConditionals.h>
62
63 #if     TARGET_OS_MAC && TARGET_RT_MAC_MACHO
64         #include <CoreServices/CoreServices.h>
65         #include <CoreAudio/CoreAudioTypes.h>
66 #else
67         #include "Components.h"
68         #include "CoreAudioTypes.h"
69 #endif
70
71 #if defined(__cplusplus)
72 extern "C"
73 {
74 #endif
75
76 //=============================================================================
77 //      Theory of Operation
78 //
79 //      AudioCodec components translate audio data from one format to another. There
80 //      are three kinds of AudioCodec components. Decoder components translate data
81 //      that isn't in linear PCM into linear PCM formatted data. Encoder components
82 //      translate linear PCM data into some other format. Unity codecs translates
83 //      between different flavors of the same type (for instance 16 bit signed
84 //      integer linear PCM into 32 bit floating point linear PCM).
85 //
86 //      <how to find AudioCodecs yet to be determined>
87 //
88 //      Once an AudioCodec is found that implements the translation in question,
89 //      it has to be set up to do the translation. This can be done by setting the
90 //      appropriate properties or by calling AudioCodecInitialize. If the translation
91 //      is specified by properties, AudioCodecInitialize still needs to be called
92 //      prior to appending input data or producing output data.
93 //
94 //      AudioCodecInitialize puts the codec into the "initialized" state. In this state,
95 //      the format information for the translation cannot be changed. The codec
96 //      has to be in the initialized state for AudioCodecAppendInputData and
97 //      AudioCodecProduceOutputData to work. They will return kAudioCodecStateError
98 //      if the codec isn't initialized.
99 //
100 //      AudioCodecUninitialize will return the codec to the uninitialized state and
101 //      release any allocated resources. It may then be configured freely. It is not
102 //      necessary to call AudioCodecUninitialize prior to closing the codec.
103 //
104 //      Once in the initialized state, the codec is ready to receive input and produce
105 //      output using the AudioCodecAppendInputData and AudioCodecProduceOutputData
106 //      routines. Input data can be fed into a codec in any size (even byte by byte),
107 //      but output data can only be produced in whole packet sizes. Both routines
108 //      will return the amount of data they consume/produce.
109 //
110 //      AudioCodecProduceOutputData also returns a status code to the caller that
111 //      indicates the result of the operation (success or failure) as well as the
112 //      state of the input buffer.
113 //=============================================================================
114
115 //=============================================================================
116 //      Issues for Discussion
117 //
118 //      -       Finding these guys hasn't been addressed yet. When it is, one must
119 //              keep in mind the fact that multiple codecs may perform the same
120 //              translation so being able to differentiate between them by something
121 //              other than type and subtype is important.
122 //
123 //      -       Should there be standard properties for the important configuration
124 //              things, like bit rate, profile, etc. that aren't covered in an
125 //              AudioStreamBasicDescription? If so what are they and what do they
126 //              look like. If there were standared properties for this stuff, then
127 //              it would be possible to create a standard UI for the majority of
128 //              the codecs out there which would greatly simplify the process of
129 //              creating an AudioCodec component.
130 //
131 //      -       UI for configuring a codec. Because of the way things are layered
132 //              on X, it is highly desireable to not include any UI code in the
133 //              AudioCodec component. But, it is also desireable to allow the codec
134 //              the opportunity to present it's own UI for configuration. In fact,
135 //              this is how QT works with codecs now. AudioUnits have the exact same
136 //              problem, so likely the solution here is similar to the solution
137 //              being worked on for AudioUnits.
138 //
139 //      -       
140 //=============================================================================
141
142 //=============================================================================
143 //      Types specific to AudioCodecs
144 //=============================================================================
145
146 typedef ComponentInstance       AudioCodec;
147 typedef UInt32                          AudioCodecPropertyID;
148
149 struct AudioStreamLoudnessStatistics
150 {
151         Float64 mAveragePerceivedPowerCoefficient;              //      normalized from 0-1
152         Float64 mMaximumPerceivedPowerCoefficient;              //      normalized from 0-1
153         UInt64  mMaximumPerceivedPowerPacketOffset;             //      the packet that contains the maximum coefficient
154         Float32 mPeakAmplitude;                                                 //      the absolute peak sample value
155         UInt32  mReserved;                                                              //      padding
156         UInt64  mPeakAmplitudeSampleOffset;                             //      the sample number of the absolute peak sample
157 };
158 typedef struct AudioStreamLoudnessStatistics    AudioStreamLoudnessStatistics;
159
160 //=============================================================================
161 //      AudioCodec Component Constants
162 //=============================================================================
163
164 enum
165 {
166
167         kAudioDecoderComponentType                                                              = 'adec',
168                 //      A codec that translates data in some other format into linear PCM
169                 //      The component subtype specifies the format ID of the other format
170        
171         kAudioEncoderComponentType                                                              = 'aenc',
172                 //      A codec that translates linear PCM data into some other format
173                 //      The component subtype specifies the format ID of the other format
174        
175         kAudioUnityCodecComponentType                                                   = 'acdc'
176                 //      A codec that translates between different flavors of the same format
177                 //      The component subtype specifies the format ID of this format.
178
179 };
180
181 //=============================================================================
182 //      Standard Codec Properties
183 //
184 //      Used with the AudioCodecXXXXPropertyXXXX family of routines.
185 //=============================================================================
186
187 enum
188 {
189
190         kAudioCodecPropertyNameCFString                                                 = 'lnam',
191                 //      the name of the codec's format as a CFStringRef. The CFStringRef
192                 //      retrieved via this property must be released by the caller.
193                
194         kAudioCodecPropertyManufacturerCFString                                 = 'lmak',
195                 //      the manufacturer of the codec as a CFStringRef. The CFStringRef
196                 //      retrieved via this property must be released by the caller.
197        
198         kAudioCodecPropertyRequiresPacketDescription                    = 'pakd',
199                 //      A UInt32 where a non-zero value indicates that the format the codec implements
200                 //      requires that an AudioStreamPacketDescription array must be supplied with any data
201                 //      in that format. Note that this implies that data must also be handled strictly in
202                 //      packets. For a decoder, this applies to input data. For an encoder, it appies to
203                 //      output data.
204                
205         kAudioCodecPropertyPacketFrameSize                                              = 'pakf',
206                 //      A UInt32 indicating the number of frames of audio data in each
207                 //      packet of data in the codec's format will be. For encoders, this is the
208                 //      input format. For decoders this is the output format.
209                 //      Note that this property can only be queried when the codec is initialized.
210        
211         kAudioCodecPropertyHasVariablePacketByteSizes                   = 'vpk?',
212                 //      A UInt32 where 0 indicates that all packets in the codec's format
213                 //      have the same byte size and 1 indicates that they vary in size (up
214                 //      to the maximum size indicated in kAudioCodecPropertyMaximumPacketByteSize).
215        
216         kAudioCodecPropertyMaximumPacketByteSize                                = 'pakb',
217                 //      A UInt32 indicating the maximum number of bytes a packet of data
218                 //      in the codec's format will be. If the format is constant bit rate,
219                 //      all packets will be this size. If it is variable bit rate, the packets
220                 //      won't ever be any larger than this size.
221                 //      This always refers to the encoded data, so for encoders it refers to the
222                 //      output data and for decoders the input data.
223                 //      Note that this property can only be queried when the codec is initialized.
224        
225         kAudioCodecPropertyCurrentInputFormat                                   = 'ifmt',
226                 //      An AudioStreamBasicDescription describing the format the codec
227                 //      expects it's input data in
228        
229         kAudioCodecPropertySupportedInputFormats                                = 'ifm#',
230                 //      An array of the AudioStreamBasicDescription's the codec supports
231                 //      for input data
232        
233         kAudioCodecPropertyCurrentOutputFormat                                  = 'ofmt',
234                 //      An AudioStreamBasicDescription describing the format the codec
235                 //      provides it's output data in
236        
237         kAudioCodecPropertySupportedOutputFormats                               = 'ofm#',
238                 //      An array of the AudioStreamBasicDescription's the codec supports
239                 //      for output data
240        
241         kAudioCodecPropertyMagicCookie                                                  = 'kuki',
242                 //      An untyped buffer of out of band configuration data the codec
243                 //      requires to process the stream of data correctly. The contents
244                 //      of this data is private to the codec. Not all codecs have magic
245                 //      cookies.
246        
247         kAudioCodecPropertyInputBufferSize                                              = 'tbuf',
248                 //      A UInt32 indicating the maximum input buffering size for the codec
249                 //      in bytes
250        
251         kAudioCodecPropertyUsedInputBufferSize                                  = 'ubuf',
252                 //      A UInt32 indicating the number of bytes in the codec's input
253                 //      buffer that are already in use
254        
255         kAudioCodecPropertyIsInitialized                                                = 'init',
256                 //      A UInt32 where 0 means the codec is uninitialized and anything
257                 //      else means the codec is initialized.
258        
259         kAudioCodecPropertyCurrentTargetBitRate                                 = 'brat',
260                 //      A UInt32 containing the number of bits per second to aim
261                 //      for when encoding data. This property is only relevant to
262                 //      encoders.
263
264         kAudioCodecPropertyAvailableBitRates                                    = 'brt#',
265                 //      An array of UInt32's that indicate the target bit rates
266                 //      supported by the encoder. This property is only relevant to
267                 //      encoders.
268                 //      Deprecated. Replaced with kAudioCodecPropertyAvailableBitRateRange
269
270         kAudioCodecPropertyCurrentInputSampleRate                               = 'cisr',
271                 //      A Float64 containing current input sample rate in Hz.
272                
273         kAudioCodecPropertyCurrentOutputSampleRate                              = 'cosr',
274                 //      A Float64 containing current output sample rate in Hz.
275                
276         kAudioCodecPropertyAvailableInputSampleRates                    = 'aisr',
277                 //      An array of AudioValueRange indicating the valid ranges for the
278                 //      input sample rate of the codec.
279      
280         kAudioCodecPropertyAvailableOutputSampleRates                   = 'aosr',
281                 //      An array of AudioValueRange indicating the valid ranges for the
282                 //      output sample rate of the codec.
283
284         kAudioCodecPropertyQualitySetting                                               = 'srcq',
285                 //      "Some Relative Codec Quality"
286                 //
287                 //      A UInt32 that specifies the relative quality of a codec.
288                 //      (see enum constants below)
289
290         kAudioCodecPropertyCurrentLoudnessStatistics                    = 'loud',
291                 //      An array of AudioStreamLoudnessStatistics structs that provides statistics about
292                 //      the loudness of each channel in the stream of data being processed by the codec.
293                 //      Note that this property can only be queried when the codec is initialized
294                 //      and until data is actually moved through it the values will all be defaults.
295
296         kAudioCodecPropertyAvailableBitRateRange                                = 'abrt',
297                 //      An array of AudioValueRange that indicate the target bit rates
298                 //      supported by the encoder.
299                 //      This property is only relevant to encoders.
300
301         kAudioCodecPropertyApplicableBitRateRange                               = 'brta',
302                 //      An array of AudioValueRange indicating the target bit rates
303                 //      supported by the encoder in its current configuration.
304                 //      This property is only relevant to encoders.
305
306         kAudioCodecPropertyApplicableInputSampleRates                   = 'isra',
307                 //      An array of AudioValueRange indicating the valid ranges for the
308                 //      input sample rate of the codec for the current bit rate.
309
310         kAudioCodecPropertyApplicableOutputSampleRates                  = 'osra',
311                 //      An array of AudioValueRange indicating the valid ranges for the
312                 //      output sample rate of the codec for the current bit rate.
313
314         kAudioCodecPropertyMinimumNumberInputPackets                    = 'mnip',
315                 //      A UInt32 indicating the minimum number of input packets
316                 //      that need to be supplied to the codec. The actual input the
317                 //      codec accepts could be less than this.
318                 //      For most codecs this value will be 1.
319
320         kAudioCodecPropertyMinimumNumberOutputPackets                   = 'mnop',
321                 //      A UInt32 indicating the minimum number of output packets
322                 //      that need to be handled from the codec. The actual output
323                 //      might be less than this.
324                 //      For most codecs this value will be 1.
325
326         kAudioCodecPropertyZeroFramesPadded                                             = 'pad0',
327                 //      A UInt32 indicating the number of zeroes (samples) that were appended
328                 //      to the last packet of input data to mae a complete packet encoding.
329
330         kAudioCodecPropertyAvailableNumberChannels                              = 'cmnc',
331                 //      An array of UInt32 that specifies the number of channels the codec is capable of encoding to.
332                 //      0xFFFFFFFF means any number of channels.
333
334         kAudioCodecPropertyPrimeMethod                                                  = 'prmm',
335                 // a UInt32 specifying priming method.
336                 // see explanation for struct AudioCodecPrimeInfo below along with enum constants
337
338         kAudioCodecPropertyPrimeInfo                                                    = 'prim',
339                 //  A pointer to AudioCodecPrimeInfo
340
341         kAudioCodecDoesSampleRateConversion                                             = 'lmrc',
342                 //      a UInt32 indicating if the codec wants to do a sample rate conversion (if
343                 //      necessary) because it can do it in a way that is meaningful for quality.
344                 //      Value is 1 if true, 0 otherwise.
345                
346         kAudioCodecPropertyInputChannelLayout                                   = 'icl ',
347                 // An AudioChannelLayout that specifies the channel layout that the codec is using for input.
348                 // Settable on encoders.
349        
350         kAudioCodecPropertyOutputChannelLayout                                  = 'ocl ',
351                 // An AudioChannelLayout that specifies the channel layout that the codec is using for output.
352                 // If settable on a encoder, it means the encoder can re-map channels
353
354         kAudioCodecPropertyAvailableInputChannelLayouts                 = 'aicl',
355                 //      An array of AudioChannelLayoutTags that specifies what channel layouts the codec is
356                 //      capable of using on input.
357
358         kAudioCodecPropertyAvailableOutputChannelLayouts                = 'aocl'
359                 //      An array of AudioChannelLayoutTags that specifies what channel layouts the codec is
360                 //      capable of using on output.
361 };
362
363 // constants to be used with kAudioCodecPropertyQualitySetting
364 enum
365 {
366         kAudioCodecQuality_Max                                                          = 0x7F,
367         kAudioCodecQuality_High                                                         = 0x60,
368         kAudioCodecQuality_Medium                                                       = 0x40,
369         kAudioCodecQuality_Low                                                          = 0x20,
370         kAudioCodecQuality_Min                                                          = 0
371 };
372
373 // constants to be used with kAudioCodecPrimeMethod
374 enum
375 {
376         kAudioCodecPrimeMethod_Pre              = 0,    // primes with leading + trailing input frames
377         kAudioCodecPrimeMethod_Normal   = 1,    // only primes with trailing (zero latency)
378                                                                                         // leading frames are assumed to be silence
379         kAudioCodecPrimeMethod_None     = 2             // acts in "latency" mode
380                                                                                         // both leading and trailing frames assumed to be silence
381 };
382
383 typedef struct AudioCodecPrimeInfo {
384         UInt32          leadingFrames;
385         UInt32          trailingFrames;
386 } AudioCodecPrimeInfo;
387
388 //=============================================================================
389 //      Status values returned from the AudioCodecProduceOutputPacket routine
390 //=============================================================================
391
392 enum
393 {
394
395         kAudioCodecProduceOutputPacketFailure                                   = 1,
396                 //      Couldn't complete the request due to an error. It is possible
397                 //      that some output data was produced. This is reflected in the value
398                 //      returned in ioNumberPackets.
399                
400         kAudioCodecProduceOutputPacketSuccess                                   = 2,
401                 //      The number of requested output packets was produced without incident
402                 //      and there isn't any more input data to process
403        
404         kAudioCodecProduceOutputPacketSuccessHasMore                    = 3,
405                 //      The number of requested output packets was produced and there is
406                 //      enough input data to produce at least one more packet of output data
407                
408         kAudioCodecProduceOutputPacketNeedsMoreInputData                = 4,
409                 //      There was insufficient input data to produce the requested
410                 //      number of output packets, The value returned in ioNumberPackets
411                 //      holds the number of output packets produced.
412                
413         kAudioCodecProduceOutputPacketAtEOF                                             = 5
414                 //      The end-of-file marker was hit during the processing. Fewer
415                 //      than the requested number of output packets may have been
416                 //      produced. Check the value returned in ioNumberPackets for the
417                 //      actual number produced. Note that not all formats have EOF
418                 //      markers in them.
419                
420 };
421
422 //=============================================================================
423 //      Selectors for the component routines (preliminary)
424 //=============================================================================
425
426 enum
427 {
428
429         kAudioCodecGetPropertyInfoSelect                                                = 0x0001,
430         kAudioCodecGetPropertySelect                                                    = 0x0002,
431         kAudioCodecSetPropertySelect                                                    = 0x0003,
432         kAudioCodecInitializeSelect                                                             = 0x0004,
433         kAudioCodecUninitializeSelect                                                   = 0x0005,
434         kAudioCodecAppendInputDataSelect                                                = 0x0006,
435         kAudioCodecProduceOutputDataSelect                                              = 0x0007,
436         kAudioCodecResetSelect                                                                  = 0x0008
437        
438 };
439
440 //=============================================================================
441 //      Errors
442 //=============================================================================
443
444 enum
445 {
446         kAudioCodecNoError                                                              = 0,
447         kAudioCodecUnspecifiedError                                             = 'what',
448         kAudioCodecUnknownPropertyError                                 = 'who?',
449         kAudioCodecBadPropertySizeError                                 = '!siz',
450         kAudioCodecIllegalOperationError                                = 'nope',
451         kAudioCodecUnsupportedFormatError                               = '!dat',
452         kAudioCodecStateError                                                   = '!stt',
453         kAudioCodecNotEnoughBufferSpaceError                    = '!buf'
454 };
455
456 //=============================================================================
457 //      Codec Property Management
458 //=============================================================================
459
460 //-----------------------------------------------------------------------------
461 //      AudioCodecGetPropertyInfo
462 //
463 //      Retrieve information about the given property. The outSize argument
464 //      will return the size in bytes of the current value of the property.
465 //      The outWritable argument will return whether or not the property
466 //      in question can be changed.
467 //-----------------------------------------------------------------------------
468        
469 EXTERN_API(ComponentResult)
470 AudioCodecGetPropertyInfo(      AudioCodec                              inCodec,
471                                                         AudioCodecPropertyID    inPropertyID,
472                                                         UInt32*                                 outSize,
473                                                         Boolean*                                outWritable);
474
475 //-----------------------------------------------------------------------------
476 //      AudioCodecGetProperty
477 //
478 //      Retrieve the indicated property data. On input, ioDataSize has the size
479 //      of the data pointed to by outPropertyData. On output, ioDataSize will contain
480 //      the amount written.
481 //-----------------------------------------------------------------------------
482        
483 EXTERN_API(ComponentResult)
484 AudioCodecGetProperty(  AudioCodec                              inCodec,
485                                                 AudioCodecPropertyID    inPropertyID,
486                                                 UInt32*                                 ioPropertyDataSize,
487                                                 void*                                   outPropertyData);
488
489 //-----------------------------------------------------------------------------
490 //      AudioCodecSetProperty
491 //
492 //      Set the indicated property data.
493 //-----------------------------------------------------------------------------
494        
495 EXTERN_API(ComponentResult)
496 AudioCodecSetProperty(  AudioCodec                              inCodec,
497                                                 AudioCodecPropertyID    inPropertyID,
498                                                 UInt32                                  inPropertyDataSize,
499                                                 const void*                             inPropertyData);
500
501 //=============================================================================
502 //      Codec Data Handling Routines
503 //=============================================================================
504
505 //-----------------------------------------------------------------------------
506 //      AudioCodecInitialize
507 //
508 //      This call will allocate any buffers needed and otherwise set the codec
509 //      up to perform the indicated translation. If an argument is NULL, any
510 //      previously set proeprties will be used for preparing the codec for work.
511 //      Note that this routine will also validate the format information as useable.
512 //-----------------------------------------------------------------------------
513        
514 EXTERN_API(ComponentResult)
515 AudioCodecInitialize(   AudioCodec                                                      inCodec,
516                                                 const AudioStreamBasicDescription*      inInputFormat,
517                                                 const AudioStreamBasicDescription*      inOutputFormat,
518                                                 const void*                                                     inMagicCookie,
519                                                 UInt32                                                          inMagicCookieByteSize);
520
521 //-----------------------------------------------------------------------------
522 //      AudioCodecUninitialize
523 //
524 //      This call will move the codec from the initialized state back to the
525 //      uninitialized state. The codec will release any resources it allocated
526 //      or claimed in AudioCodecInitialize.
527 //-----------------------------------------------------------------------------
528        
529 EXTERN_API(ComponentResult)
530 AudioCodecUninitialize(AudioCodec inCodec);
531
532 //-----------------------------------------------------------------------------
533 //      AudioCodecAppendInputData
534 //
535 //      Append as much of the given data to the codec's input buffer as possible
536 //      and return in ioInputDataByteSize the amount of data used. Note that the
537 //      data is copied from the input buffer to the codec's internal buffers.
538 //     
539 //      The inPacketDescription argument is an array of AudioStreamPacketDescription
540 //      structs that describes the packet layout returned in outOutputData. The number
541 //      of elements in this array is indicated on input by ioNumberPackets.
542 //
543 //      Note that inPacketDescription and ioNumberPackets need only be filled out
544 //      if the value of kAudioCodecPropertyRequiresPacketDescription is non-zero.
545 //      Note also in this case that it is an error to supply less than a full packet
546 //      of data at a time.
547 //-----------------------------------------------------------------------------
548        
549 EXTERN_API(ComponentResult)
550 AudioCodecAppendInputData(      AudioCodec                                                      inCodec,
551                                                         const void*                                                     inInputData,
552                                                         UInt32*                                                         ioInputDataByteSize,
553                                                         UInt32*                                                         ioNumberPackets,
554                                                         const AudioStreamPacketDescription*     inPacketDescription);
555
556 //-----------------------------------------------------------------------------
557 //      AudioCodecProduceOutputPackets
558 //
559 //      Produce as many output packets as requested and the amount of input data
560 //      allows for. The outStatus argument returns information about the codec's
561 //      status to allow for proper data management. See the constants above for
562 //      the possible values that can be returned.
563 //     
564 //      The outPacketDescription argument is an array of AudioStreamPacketDescription
565 //      structs that describes the packet layout returned in outOutputData. This
566 //      argument is optional. Pass NULL if this information is not to be returned.
567 //      Note that this information is only provided when the output format isn't
568 //      linear PCM.
569 //
570 //      Note that decoders will always only produce linear PCM data in multiples of
571 //      the number frames in a packet of the encoded format (as returned by
572 //      kAudioCodecPropertyPacketFrameSize). Encoders will consume this many frames
573 //      of linear PCM data to produce a packet of their format.
574 //-----------------------------------------------------------------------------
575        
576 EXTERN_API(ComponentResult)
577 AudioCodecProduceOutputPackets( AudioCodec                                              inCodec,
578                                                                 void*                                                   outOutputData,
579                                                                 UInt32*                                                 ioOutputDataByteSize,
580                                                                 UInt32*                                                 ioNumberPackets,
581                                                                 AudioStreamPacketDescription*   outPacketDescription,
582                                                                 UInt32*                                                 outStatus);
583
584 //-----------------------------------------------------------------------------
585 //      AudioCodecReset
586 //
587 //      Flushes all the data in the codec and clears the input buffer. Note that
588 //      the formats, and magic cookie will be retained so they won't need to be
589 //      set up again to decode the same data.
590 //-----------------------------------------------------------------------------
591        
592 EXTERN_API(ComponentResult)
593 AudioCodecReset(AudioCodec inCodec);
594
595 #if defined(__cplusplus)
596 }
597 #endif
598
599 #endif
Note: See TracBrowser for help on using the browser.