Hey folks,

Here's what I have:

- An iPhone app that reads audio input and writes to audio output

- One of these threads runs a DynamicRTSPServer session which runs a 
WAVAudioFileServerMediaSubsession

- When I run this session with a wav file, WAVAudioFileSource::doReadFromFile() 
 is called, and the
  samples are read out of this wav file and I can send it to another app which 
is acting as a live555 client.
  Works great.

- Now, getting back to the iOS audio:   A function gets called when the audio 
output hardware wants samples.
  I write these samples to a circular buffer, which can be read from other 
threads.

- In fact, WAVAudioFileSource::doReadFromFile()  is being called right now 
since I already have the setup
  working for a .wav file.  All I want to do is write the samples to fTo:


> void WAVAudioFileSource::doReadFromFile() {
>   // Try to read as many bytes as will fit in the buffer provided (or 
> "fPreferredFrameSize" if less)                                                
>    
>   if (fLimitNumBytesToStream && fNumBytesToStream < fMaxSize) {
>     fMaxSize = fNumBytesToStream;
>   }
>   if (fPreferredFrameSize < fMaxSize) {
>     fMaxSize = fPreferredFrameSize;
>   }
>   unsigned bytesPerSample = (fNumChannels*fBitsPerSample)/8;
>   if (bytesPerSample == 0) bytesPerSample = 1; // because we can't read less 
> than a byte at a time                                                     
> 
>   // For 'trick play', read one sample at a time; otherwise (normal case) 
> read samples in bulk:                                                        
>   unsigned bytesToRead = fScaleFactor == 1 ? fMaxSize - 
> fMaxSize%bytesPerSample : bytesPerSample;
>   unsigned numBytesRead;
>   while (1) { // loop for 'trick play' only                                   
>                                                                          
>     if (readFromFilesSynchronously || fFidIsSeekable) {
>       numBytesRead = fread(fTo, 1, bytesToRead, fFid);
>    } else {
>       // For non-seekable files (e.g., pipes), call "read()" rather than 
> "fread()", to ensure that the read doesn't block:                             
>       numBytesRead = read(fileno(fFid), fTo, bytesToRead);
>     }
> 
> 

I think if I change this line to copy samples out of the ring buffer to fTo I 
would  be able to spoof the wav file
reader into using these samples instead of the ones from the file.

> numBytesRead = fread(fTo, 1, bytesToRead, fFid);

Then ultimately, if this works,  think I could make a new subclass 
WaveAudioIOSInputSource to do the job.

Preliminary experiments have been a bit frustrating, and I think it has 
something to do with the fTo variable.

Any hints on how to proceed on this?

Thanks,

- Nick













_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to