[Live-devel] Streaming a WAV file

Sid Price sidprice at softtools.com
Wed Jul 25 17:09:48 PDT 2012


Hi Ross,

 

Sorry it took so long to get back to this. I reworked the front end of the
WAVAudioFileSource Constructor to cope with the possible variety of
subchunks in the "WAVE" chunck. It is passed below. Unfortunately the sample
WAV file I have is copyright material and I am not comfortable sharing it. I
will search to find a suitable WAV file.

WAVAudioFileSource::WAVAudioFileSource(UsageEnvironment& env, FILE* fid)

  : AudioInputDevice(env, 0, 0, 0, 0)/* set the real parameters later */,

    fFid(fid), fFidIsSeekable(False), fLastPlayTime(0),
fHaveStartedReading(False), fWAVHeaderSize(0), fFileSize(0),

    fScaleFactor(1), fLimitNumBytesToStream(False), fNumBytesToStream(0),
fAudioFormat(WA_UNKNOWN) {

  // Check the WAV file header for validity.

  // Note: The following web pages contain info about the WAV format:

  // http://www.ringthis.com/dev/wave_format.htm

  // http://www.lightlink.com/tjweber/StripWav/Canon.html

  // http://www.wotsit.org/list.asp?al=W

 

  Boolean success = False; // until we learn otherwise

  do {

                int           iStatus = 1;          // 0 means we can
procede after finding "fmt "

 
// 1 means keep going

 
// -1 means error occured

                  {

                                                unsigned int       uiTemp,
uiSubchunkSize ;

                                                //

                                                // Attempt to read "RIFF"

                                                //

                                                if (!get4Bytes(fid, uiTemp))
break;

                                                if (uiTemp != 0x46464952)
break ;

                                                if (!skipBytes(fid, 4))
break;

                                                //

                                                // Attempt to read "WAVE"

                                                //

                                                if (!get4Bytes(fid, uiTemp))
break;

                                                if (uiTemp != 0x45564157)
break ;

                                                //

                                                // Loop until the "fmt "
subchunk is found

                                                //

                                                while(iStatus == 1)

                                                {

                                                                if
(get4Bytes(fid, uiTemp))

                                                                {

 
//

 
// Is it "fmt "?

 
//

 
if (uiTemp != 0x20746d66)

 
{

 
//

 
// Skip this subchunk

 
//

 
if (get4Bytes(fid, uiSubchunkSize))

 
{

 
if (!skipBytes(fid, uiSubchunkSize))

 
{

 
iStatus = -1 ;

 
}

 
}

 
else

 
{

 
iStatus = -1 ;

 
}

 
}

 
else

 
{

 
//

 
// Found the "fmt " subchunk" ... exit loop

 
//

 
break ;

 
}

                                                                }

                                                                else

                                                                {

 
iStatus = -1 ;       // Error give up

                                                                }

                                                }

                  }

                  if(iStatus == -1) break ;
// error in parsing

    //// RIFF Chunk:

    //if (nextc != 'R' || nextc != 'I' || nextc != 'F' || nextc != 'F')
break;

    //if (!skipBytes(fid, 4)) break;

    //if (nextc != 'W' || nextc != 'A' || nextc != 'V' || nextc != 'E')
break;

 

    //// FORMAT Chunk:

    //if (nextc != 'f' || nextc != 'm' || nextc != 't' || nextc != ' ')
break;

    unsigned formatLength;

    if (!get4Bytes(fid, formatLength)) break;

    unsigned short audioFormat;

 

The balance of the method remains the same. The new code simply skips and
subchunk other than "fmt "

 

Sid.

 

From: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] On Behalf Of Ross Finlayson
Sent: Wednesday, June 06, 2012 3:43 AM
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] Streaming a WAV file

 

I am running the OnDemandRTSPServer test application with WAV files and it
seems that the WAV file processing expects the first SubChunk of the file to
always be the "fmt " SubChunk. This is not the case for the files I am
using, they have other SubChunks, e.g. "LIST".

 

What is the best way to get this into the library? Should I implement and
submit my changes to you?

 

Yes, if you can.  (The change will most likely be to the file
"liveMedia/WAVAudioFileSource.cpp".)

 

For future reference, it would also be useful to get an example of a WAV
file like this.  Could you please put one on a web server, and send us the
URL, so we can download it?

 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/ 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120725/b65f6271/attachment-0001.html>


More information about the live-devel mailing list