[Live-devel] Implementing FramedSource
Ken Seo
ken.seo at gmail.com
Fri Apr 4 08:44:42 PDT 2008
Hi,
I'm trying to implement a FramedSource which will get next frames from
a Queue. From my digging so far, "doGetNextFrame()" should be blocking
until the next frame is available, so my current implementation looks
like,
void QueueSource::doGetNextFrame()
{
//CAutoLock cAutolock(&m_Lock);
SampleData* sampleData = NULL;
while(true)
{
sampleData = m_pMediaSampleQueue->Pop();
if (sampleData == NULL) continue;
if (sampleData->endOfStream)
{
handleClosure(this);
return;
}
if (IsBadReadPtr(sampleData->pSample, sizeof(UCHAR))) continue;
break;
}
printf("sample: %d\n", sampleData->sampleSize);
fMaxSize = sampleData->maxSize;
fFrameSize = sampleData->sampleSize;
fNumTruncatedBytes = sampleData->numTruncatedBytes;
fPresentationTime.tv_sec = sampleData->presentationTime.tv_sec;
fPresentationTime.tv_usec = sampleData->presentationTime.tv_usec;
fDurationInMicroseconds = sampleData->durationInMicroseconds;
memcpy(fTo, sampleData->pSample, fFrameSize);
delete sampleData;
afterGetting(this);
//nextTask() = envir().taskScheduler().scheduleDelayedTask(0,
(TaskFunc*)FramedSource::afterGetting, this);
}
And there will be another thread filling the Queue, (this shouldn't
interfere with with live555's single threaded model),
But it seems to me that this implementation too expensive (cpu
intensive) and I do experience jitters in streaming (a lot). And if I
make non-blocking (without loop) then no samples retrieved,
Considering, live555 is single threaded, how else do I implement
blocking ?? and who's responsible to call GetNextFrame()?
Regards,
Ken Seo
More information about the live-devel
mailing list