Hello everyone,
I have an issue with the mad_decoder.
I am currently developing a media server using live555 to stream the data, and libmad to decode the stream received. Currently, I am able to receive the stream perfectly into a file, and it is fully playable through a player (i.e. windows media player). Though, I want to play it with my own program, so I need to decode the stream received. I tried including the minimad test program into my projet with live555, but I am getting the error : decoding error 0x0101 (lost synchronization) at byte offset 0. Here is the function where the mad_decoder is called:
void SoundSink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime){ if (numTruncatedBytes > 0) { envir() << "FileSink::afterGettingFrame(): The input frame data was too large for our buffer size (" << fBufferSize << "). " << numTruncatedBytes << " bytes of trailing data was dropped! Correct this by increasing the \"bufferSize\" parameter in the \"createNew()\" call to at least " << fBufferSize + numTruncatedBytes << "\n"; } addData(fBuffer, frameSize, presentationTime);
if (fOutFid == NULL || fflush(fOutFid) == EOF) { // The output file has closed. Handle this the same way as if the input source had closed: if (fSource != NULL) fSource->stopGettingFrames(); onSourceClosure(); return; }
if (fPerFrameFileNameBuffer != NULL) { if (fOutFid != NULL) { fclose(fOutFid); fOutFid = NULL; } }
decode((const unsigned char *)"test.mp3", frameSize); //mad_decoder continuePlaying();}
In this function I give the decode function (same as in minimad.c) the mp3 file that receives the stream, and the frameSize given by live555 API, which is usually at 1045.
static int decode(unsigned char const *start, unsigned long length){ struct buffer buffer; struct mad_decoder decoder; int result; /* initialize our private message structure */
buffer.start = start; buffer.length = length; /* configure input, output, and error functions */
mad_decoder_init(&decoder, &buffer, input, 0 /* header */, 0 /* filter */, output, error, 0 /* message */);
/* start decoding */ result = mad_decoder_run(&decoder, MAD_DECODER_MODE_SYNC); /* release the decoder */
mad_decoder_finish(&decoder);
return result;}
The mad_decoder goes directly into the error function, and outputs nothing due to the error 0x0101
Any help would be greatly useful,
Louis