| 1 |
/* Copyright: © Copyright 2005 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 |
ACBaseCodec.h |
|---|
| 40 |
|
|---|
| 41 |
=============================================================================*/ |
|---|
| 42 |
#if !defined(__ACBaseCodec_h__) |
|---|
| 43 |
#define __ACBaseCodec_h__ |
|---|
| 44 |
|
|---|
| 45 |
//============================================================================= |
|---|
| 46 |
// Includes |
|---|
| 47 |
//============================================================================= |
|---|
| 48 |
|
|---|
| 49 |
#include "ACCodec.h" |
|---|
| 50 |
#include "CAStreamBasicDescription.h" |
|---|
| 51 |
#include <vector> |
|---|
| 52 |
#include "GetCodecBundle.h" |
|---|
| 53 |
|
|---|
| 54 |
//============================================================================= |
|---|
| 55 |
// ACBaseCodec |
|---|
| 56 |
// |
|---|
| 57 |
// An abstract subclass of ACCodec that implements all the nuts and bolts |
|---|
| 58 |
// of the ACCodec interface, except for buffer handling. This class does |
|---|
| 59 |
// the proper dispatching of property requests and manages the list of |
|---|
| 60 |
// input and output formats. |
|---|
| 61 |
//============================================================================= |
|---|
| 62 |
|
|---|
| 63 |
class ACBaseCodec |
|---|
| 64 |
: |
|---|
| 65 |
public ACCodec |
|---|
| 66 |
{ |
|---|
| 67 |
|
|---|
| 68 |
// Construction/Destruction |
|---|
| 69 |
public: |
|---|
| 70 |
ACBaseCodec(); |
|---|
| 71 |
virtual ~ACBaseCodec(); |
|---|
| 72 |
|
|---|
| 73 |
// Property Management |
|---|
| 74 |
public: |
|---|
| 75 |
virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable); |
|---|
| 76 |
virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData); |
|---|
| 77 |
virtual void SetProperty(AudioCodecPropertyID inPropertyID, UInt32 inPropertyDataSize, const void* inPropertyData); |
|---|
| 78 |
|
|---|
| 79 |
// Data Handling |
|---|
| 80 |
public: |
|---|
| 81 |
bool IsInitialized() const { return mIsInitialized; } |
|---|
| 82 |
virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize); |
|---|
| 83 |
virtual void Uninitialize(); |
|---|
| 84 |
virtual void Reset(); |
|---|
| 85 |
virtual UInt32 GetInputBufferByteSize() const = 0; |
|---|
| 86 |
virtual UInt32 GetUsedInputBufferByteSize() const = 0; |
|---|
| 87 |
|
|---|
| 88 |
protected: |
|---|
| 89 |
virtual void ReallocateInputBuffer(UInt32 inInputBufferByteSize) = 0; |
|---|
| 90 |
|
|---|
| 91 |
bool mIsInitialized; |
|---|
| 92 |
|
|---|
| 93 |
// Format Management |
|---|
| 94 |
public: |
|---|
| 95 |
UInt32 GetNumberSupportedInputFormats() const; |
|---|
| 96 |
void GetSupportedInputFormats(AudioStreamBasicDescription* outInputFormats, UInt32& ioNumberInputFormats) const; |
|---|
| 97 |
|
|---|
| 98 |
void GetCurrentInputFormat(AudioStreamBasicDescription& outInputFormat); |
|---|
| 99 |
virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat); |
|---|
| 100 |
|
|---|
| 101 |
UInt32 GetNumberSupportedOutputFormats() const; |
|---|
| 102 |
void GetSupportedOutputFormats(AudioStreamBasicDescription* outOutputFormats, UInt32& ioNumberOutputFormats) const; |
|---|
| 103 |
|
|---|
| 104 |
void GetCurrentOutputFormat(AudioStreamBasicDescription& outOutputFormat); |
|---|
| 105 |
virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat); |
|---|
| 106 |
|
|---|
| 107 |
virtual UInt32 GetMagicCookieByteSize() const; |
|---|
| 108 |
virtual void GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const; |
|---|
| 109 |
virtual void SetMagicCookie(const void* outMagicCookieData, UInt32 inMagicCookieDataByteSize); |
|---|
| 110 |
|
|---|
| 111 |
protected: |
|---|
| 112 |
void AddInputFormat(const AudioStreamBasicDescription& inInputFormat); |
|---|
| 113 |
void AddOutputFormat(const AudioStreamBasicDescription& inOutputFormat); |
|---|
| 114 |
|
|---|
| 115 |
typedef std::vector<CAStreamBasicDescription> FormatList; |
|---|
| 116 |
|
|---|
| 117 |
FormatList mInputFormatList; |
|---|
| 118 |
CAStreamBasicDescription mInputFormat; |
|---|
| 119 |
|
|---|
| 120 |
FormatList mOutputFormatList; |
|---|
| 121 |
CAStreamBasicDescription mOutputFormat; |
|---|
| 122 |
|
|---|
| 123 |
}; |
|---|
| 124 |
|
|---|
| 125 |
#endif |
|---|