[Live-devel] Slow devices

Martin Morissette martin.morissette at gmail.com
Tue May 3 22:57:09 PDT 2005


Hi Ross, 

I've been experiencing a few problems lately and I was wondering if
you could hint me in on a solution. Whenever I stream data from a slow
device, I get weird frames on the client side. On some version of
Quicktime the stream will display GREEN frames and others it will
display old (previously received) frames. Does it matter to the
library if the delay to get a new frame from a device varies (i.e.
sometime getting a new frame will take 30ms, other times it will take
150ms)? Does it matter if the call to fill fTo is blocking
(encoder->encodeFrame(fTo) in doGetNextFrame)? If so, is there another
solution? The FramedSource is actually a custom class that grabs data
from a firewire camera. Here is the code of my MpegSource.

MpegSource::MpegSource(UsageEnvironment& env, ImageSource* tdBuffer) :
FramedSource(env)
{
   Config* config = Config::getInstance();
   int divider = atoi(config->getString("streaming.divider", "1").c_str());

   encoder = new MpegEncoder(tdBuffer,500, divider);
   fMaxSize = tdBuffer->getBufferSize();
   active = true;
}


void MpegSource::doGetNextFrame()
{
  
   actualSize = encoder->encodeFrame(fTo);
   deliverFrame();
//   delayedTaskTime = 0;

   if (!active) {
     handleClosure(this);
     return;
   }

}

void MpegSource::deliverFrame()
{
   if(actualSize > fMaxSize)
   {
      fNumTruncatedBytes = actualSize - fMaxSize;
      fFrameSize = fMaxSize;
   }
   else
   {
      fNumTruncatedBytes = 0;
      fFrameSize = actualSize;
   }
   
   fPresentationTime = actualTime;
   
   // After delivering the data, switch to another task, and inform
   // the reader that he has data:
   nextTask() = envir().taskScheduler().scheduleDelayedTask(0,
(TaskFunc*)afterGetting, this);
   
}

Thank you
Martin



More information about the live-devel mailing list