Error decoding an mp3 stream
Louis Latreille <[email protected]> Sat, 15 Mar 2014 18:25:10 +0000
| Newsgroups | gmane.comp.audio.mad.devel |
|---|---|
| Message-ID | <[email protected]> |
--_6f8fd6db-2991-44d7-9d8b-192b8298ffb6_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello everyone=2C
I have an issue with the mad_decoder.=20
I am currently developing a media server using live555 to stream the data=
=2C and libmad to decode the stream received. Currently=2C I am able to rec=
eive the stream perfectly into a file=2C and it is fully playable through a=
player (i.e. windows media player). Though=2C I want to play it with my ow=
n program=2C so I need to decode the stream received. I tried including the=
minimad test program into my projet with live555=2C but I am getting the e=
rror : decoding error 0x0101 (lost synchronization) at byte offset 0. Here =
is the function where the mad_decoder is called:
void SoundSink::afterGettingFrame(unsigned frameSize=2C unsigned numTruncat=
edBytes=2C struct timeval presentationTime){ if (numTruncatedBytes > 0) { =
envir() << "FileSink::afterGettingFrame(): The input frame data was too =
large for our buffer size (" << fBufferSize << "). " << num=
TruncatedBytes << " bytes of trailing data was dropped! Correct this by in=
creasing the \"bufferSize\" parameter in the \"createNew()\" call to at lea=
st " << fBufferSize + numTruncatedBytes << "\n"=3B } addData(f=
Buffer=2C frameSize=2C presentationTime)=3B
if (fOutFid =3D=3D NULL || fflush(fOutFid) =3D=3D EOF) { // The output=
file has closed. Handle this the same way as if the input source had clos=
ed: if (fSource !=3D NULL) fSource->stopGettingFrames()=3B onSourceCl=
osure()=3B return=3B }
if (fPerFrameFileNameBuffer !=3D NULL) { if (fOutFid !=3D NULL) { fclo=
se(fOutFid)=3B fOutFid =3D NULL=3B } }
decode((const unsigned char *)"test.mp3"=2C frameSize)=3B //mad_decoder =
continuePlaying()=3B}
In this function I give the decode function (same as in minimad.c) the mp3 =
file that receives the stream=2C and the frameSize given by live555 API=2C =
which is usually at 1045.
static int decode(unsigned char const *start=2C unsigned long length){ str=
uct buffer buffer=3B struct mad_decoder decoder=3B int result=3B /* init=
ialize our private message structure */
buffer.start =3D start=3B buffer.length =3D length=3B /* configure inp=
ut=2C output=2C and error functions */
mad_decoder_init(&decoder=2C &buffer=2C input=2C 0 /* header */=2C 0 =
/* filter */=2C output=2C error=2C 0 /* message */)=3B
/* start decoding */ result =3D mad_decoder_run(&decoder=2C MAD_DECODER_=
MODE_SYNC)=3B /* release the decoder */
mad_decoder_finish(&decoder)=3B
return result=3B}
The mad_decoder goes directly into the error function=2C and outputs nothin=
g due to the error 0x0101
Any help would be greatly useful=2C
Louis
=
--_6f8fd6db-2991-44d7-9d8b-192b8298ffb6_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 12pt=3B
font-family:Calibri
}
--></style></head>
<body class=3D'hmmessage'><div dir=3D'ltr'>Hello everyone=2C<div><br></div>=
<div>I have an issue with the mad_decoder. =3B</div><div><br></div><div=
>I am currently developing a media server using live555 to stream the data=
=2C and libmad to decode the stream received. Currently=2C I am able to rec=
eive the stream perfectly into a file=2C and it is fully playable through a=
player (i.e. windows media player). Though=2C I want to play it with my ow=
n program=2C so I need to decode the stream received. I tried including the=
minimad test program into my projet with live555=2C but I am getting the e=
rror : decoding error 0x0101 (lost synchronization) at byte offset 0. Here =
is the function where the mad_decoder is called:</div><div><br></div><div><=
div>void SoundSink::afterGettingFrame(unsigned frameSize=2C unsigned numTru=
ncatedBytes=2C struct timeval presentationTime)</div><div>{</div><div><span=
class=3D"Apple-tab-span" style=3D"white-space:pre"> </span> if (numTruncat=
edBytes >=3B 0) {</div><div> =3B  =3B envir() <=3B<=3B "FileS=
ink::afterGettingFrame(): The input frame data was too large for our buffer=
size ("</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"=
> </span>  =3B  =3B<=3B<=3B fBufferSize <=3B<=3B ").  =
=3B"</div><div> =3B  =3B  =3B  =3B  =3B  =3B <=3B=
<=3B numTruncatedBytes <=3B<=3B " bytes of trailing data was dropped!=
 =3BCorrect this by increasing the \"bufferSize\" parameter in the \"c=
reateNew()\" call to at least "</div><div> =3B  =3B  =3B  =
=3B  =3B  =3B <=3B<=3B fBufferSize + numTruncatedBytes <=3B&l=
t=3B "\n"=3B</div><div> =3B }</div><div> =3B addData(fBuffer=2C fra=
meSize=2C presentationTime)=3B</div><div><br></div><div> =3B if (fOutFi=
d =3D=3D NULL || fflush(fOutFid) =3D=3D EOF) {</div><div> =3B  =3B =
// The output file has closed.  =3BHandle this the same way as if the i=
nput source had closed:</div><div> =3B  =3B if (fSource !=3D NULL) =
fSource->=3BstopGettingFrames()=3B</div><div> =3B  =3B onSourceCl=
osure()=3B</div><div> =3B  =3B return=3B</div><div> =3B }</div>=
<div><br></div><div> =3B if (fPerFrameFileNameBuffer !=3D NULL) {</div>=
<div> =3B  =3B if (fOutFid !=3D NULL) { fclose(fOutFid)=3B fOutFid =
=3D NULL=3B }</div><div> =3B }</div><div><br></div><div><span class=3D"=
Apple-tab-span" style=3D"white-space:pre"> </span>decode((const unsigned ch=
ar *)"test.mp3"=2C frameSize)=3B //mad_decoder</div><div> =3B  =3B =
continuePlaying()=3B</div><div>}</div></div><div><br></div><div>In this fun=
ction I give the decode function (same as in minimad.c) the mp3 file that r=
eceives the stream=2C and the frameSize given by live555 API=2C which is us=
ually at 1045.</div><div><br></div><div><div>static int decode(unsigned cha=
r const *start=2C unsigned long length)</div><div>{</div><div> =3B stru=
ct buffer buffer=3B</div><div> =3B struct mad_decoder decoder=3B</div><=
div> =3B int result=3B</div><div> =3B /* initialize our private mes=
sage structure */</div><div><br></div><div> =3B buffer.start  =3B=
=3D start=3B</div><div> =3B buffer.length =3D length=3B</div><div> =
=3B /* configure input=2C output=2C and error functions */</div><div><br></=
div><div> =3B mad_decoder_init(&=3Bdecoder=2C &=3Bbuffer=2C</div>=
<div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span> &nb=
sp=3B input=2C 0 /* header */=2C 0 /* filter */=2C output=2C</div><div><spa=
n class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>  =3B err=
or=2C 0 /* message */)=3B</div><div><br></div><div> =3B /* start decodi=
ng */</div><div> =3B result =3D mad_decoder_run(&=3Bdecoder=2C MAD_D=
ECODER_MODE_SYNC)=3B</div><div> =3B /* release the decoder */</div><div=
><br></div><div> =3B mad_decoder_finish(&=3Bdecoder)=3B</div><div><b=
r></div><div> =3B return result=3B</div><div>}</div></div><div><br></di=
v><div>The mad_decoder goes directly into the error function=2C and outputs=
nothing due to the error 0x0101</div><div><br></div><div>Any help would be=
greatly useful=2C</div><div><br></div><div>Louis</div><div><br></div> =
</div></body>
</html>=
--_6f8fd6db-2991-44d7-9d8b-192b8298ffb6_--