を使用して、AUGraph の出力を AAC (iOS 5.1) としてエンコードしたいと考えています。グラフの基本トポロジは次のようになります。
inputs --> MixerUnit --> pcm2aac --> aac2pcm --> RemoteIO
PostRenderCallback を介して再生されている AAC でエンコードされたデータを取得し、pcm2aac
UDP を介してサーバー アプリケーションに送信したいと考えています。
私が理解しているように、このユースケースkAudioUnitType_FormatConverter
の頼りになる AudioUnit は ですが、aac2pcm の ASBD 入力プロパティを設定したい場合、AudioUnitSetProperty は -10868 で失敗します (pcm2acc の出力を設定すると、同じエラーで失敗します) )。
AudioComponentDescription converterUnitDescription;
converterUnitDescription.componentType = kAudioUnitType_FormatConverter;
converterUnitDescription.componentSubType = kAudioUnitSubType_AUConverter;
converterUnitDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
converterUnitDescription.componentFlags = 0;
converterUnitDescription.componentFlagsMask = 0;
//...
AUNode pcm2aacNode;
AUNode aac2pcmNode;
//...
result = AUGraphAddNode (
processingGraph,
&converterUnitDescription,
&aac2pcmNode
);
if (noErr != result) {[self printErrorMessage: @"AUGraphNewNode failed for Converter unit" withStatus: result]; return;}
//...
result = AUGraphOpen (processingGraph);
if (noErr != result) {[self printErrorMessage: @"AUGraphOpen" withStatus: result]; return;}
//...
AudioUnit aac2pcmUnit;
AudioUnit pcm2aacUnit;
//...
result = AUGraphNodeInfo (
processingGraph,
aac2pcmNode,
NULL,
&aac2pcmUnit
);
if (noErr != result) {[self printErrorMessage: @"AUGraphNodeInfo (aac2pcm)" withStatus: result]; return;}
//...
NSLog (@"Setting stream format for input aac2pcm bus");
result = AudioUnitSetProperty (aac2pcmUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0,
&aacStreamFormat,
sizeof (aacStreamFormat)
);
if (noErr != result) {[self printErrorMessage: @"AudioUnitSetProperty (input aac2pcm stream format)" withStatus: result];return;}
// returns -10868
どこaacStreamFormat
ですか
memset(&aacStreamFormat, 0, sizeof(aacStreamFormat));/
UInt32 size = sizeof(aacStreamFormat);
aacStreamFormat.mFormatID = kAudioFormatMPEG4AAC;
aacStreamFormat.mChannelsPerFrame = 2;
aacStreamFormat.mFormatFlags = kMPEG4Object_AAC_Main;
aacStreamFormat.mSampleRate = graphSampleRate; //44100
AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &size, &aacStreamFormat);
この種の変換は AUGraph でも可能ですか? または、ライブ変換に他の方法を使用する必要がありますか?