I'm writing a core audio decoders wrapper plugin for GStreamer. This
involves allowing to use the existing QT decoders within a GStreamer
pipeline.
I currently have it working with mp3 and somewhat with QDM2, but
it's failing miserably with AAC.
The first time I call AudioConverterFillComplexBuffer() it returns
'!pkd' (kAudioConverterErr_RequiresPacketDescriptionsError). The
problem is that I am giving that function a table of
AudioStreamPacketDescription, so I can't figure out what's wrong here.
I have been looking for documentation on what that error really means
(apart from the obvious "you haven't given a packet description) but
couldn't find any documentation whatsoever.
Below follows the relevant part of my plugin so you can see how I'm
using AudioConverter.
Since this is a GStreamer plugin, we get the data (in this case AAC
packets) without having any knowledge of where it comes from, so
there's no way to use the QuickTime API that requires giving a file.
This reduces drastically the number of examples I can base myself on
(well ... basically no examples).
I would appreciate any hints as to why ACFCB would return that error
code, or any hints on what would be wrong in that code.
/* Create an AudioConverter */
status = AudioConverterNew (&macosx->indesc,
&macosx->outdesc, &macosx->aconv);
if (status != noErr) {
GST_WARNING_OBJECT (macosx,
"Error when calling AudioConverterNew() : %" GST_FOURCC_FORMAT,
QT_FOURCC_ARGS (status));
goto beach;
}
/* if we have codec_data, give it to the converter ! */
if (codec_data) {
oserr = AudioConverterSetProperty (macosx->aconv,
kAudioConverterDecompressionMagicCookie,
GST_BUFFER_SIZE (codec_data), GST_BUFFER_DATA (codec_data));
if (oserr != noErr) {
GST_WARNING_OBJECT (macosx, "Error setting extra codec data !");
goto beach;
}
}
/* Ask AudioConverter to give us data ! */
status = AudioConverterFillComplexBuffer (macosx->aconv,
(AudioConverterComplexInputDataProc) process_buffer_cb,
macosx, &outsamples, macosx->bufferlist, aspd);
g_free (aspd);
if ((status != noErr) && (status != 42)) {
if (status < 0)
GST_WARNING_OBJECT (macosx,
"Error in AudioConverterFillComplexBuffer() : %d", status);
else
GST_WARNING_OBJECT (macosx,
"Error in AudioConverterFillComplexBuffer() : %" GST_FOURCC_FORMAT,
QT_FOURCC_ARGS (status));
ret = GST_FLOW_ERROR;
goto beach;
}
/* 4. Create buffer and copy data in it */
ret = gst_pad_alloc_buffer (macosx->srcpad, macosx->cur_offset,
realbytes, GST_PAD_CAPS (macosx->srcpad), &outbuf);
if (ret != GST_FLOW_OK)
goto beach;
/* copy data from bufferlist to output buffer */
g_memmove (GST_BUFFER_DATA (outbuf),
macosx->bufferlist->mBuffers[0].mData, realbytes);
}