[Live-devel] Implementing FramedSource
Ken Seo
ken.seo at gmail.com
Tue Apr 8 16:38:24 PDT 2008
Hi, Ross,
** Sorry I pressed wrong button and email was sent accidently, please
disregard the first email.
Thank you for your reply,
if "doGetNextFrame()" returns immediately, I'm not quite sure how it
would work, the following is my understanding of RTP cycle,
RTSPServer
- upon start playing - calls GetNextFrame() -> calls doGetNextFrame()
-> calls afterGetting() -> sends packets all that -> calls
GetNextFrame()
So, in the cycle above, once doGetNextFrame() returns without
scheduling afterGetting(), then the cycle stops there. Also,
doGetNextFrame() should be called only by "GetNextFrame()" which takes
many parameters and has some initialization steps.
So, from your explanation "Later, when a frame becomes available, this
will be triggered as an event that can get handled within the event
loop.", once I have a sample, how should I *handle* that in the event
loop?, I can create a callback function or a watch variable to get
notified, but, I'm not exactly sure what to do with it, should I
manually call "doGetNextFrame()"?
Here is what I tried, my doGetNextFrame() is empty.
void QueueSource::doGetNextFrame()
{
}
And I have a function in my FramedSource that gets invoked when a
sample arrives,
HRESULT ReceivedSample(IMediaSample *pSample)
{
...
fMaxSize = bufSize;
fFrameSize = frameSize;
fNumTruncatedBytes = (frameSize <= bufSize) ? 0 : (frameSize - bufSize);
fPresentationTime.tv_sec = tv.tv_sec;
fPresentationTime.tv_usec = tv.tv_usec;
fDurationInMicroseconds = (unsigned) ((pEnd - pStart) / 10);
memcpy(fTo, ptr, frameSize);
nextTask() =
envir().taskScheduler().scheduleDelayedTask(0,
(TaskFunc*)FramedSource::afterGetting, this);
//clean up
}
However, I'm getting AccessViolation, when afterGetting is called
00000001()
ken.exe!FramedSource::afterGetting(FramedSource * source=0x010668a8)
Line 118 + 0x31 bytes C++
ken.exe!AlarmHandler::handleTimeout() Line 34 + 0x11 bytes C++
ken.exe!DelayQueue::handleAlarm() Line 179 + 0xf bytes C++
ken.exe!BasicTaskScheduler::SingleStep(unsigned int
maxDelayTime=0x00000000) Line 99 C++
ken.exe!BasicTaskScheduler0::doEventLoop(char *
watchVariable=0x00000000) Line 76 + 0x11 bytes C++
ken.exe!wmain(int argc=0x00000001, wchar_t * * argv=0x00b0ac58,
wchar_t * * envp=0x00b0cf00) Line 79 + 0x25 bytes C++
ken.exe!__tmainCRTStartup() Line 583 + 0x19 bytes C
ken.exe!wmainCRTStartup() Line 403 C
kernel32.dll!7c816fd7()
[Frames below may be incorrect and/or missing, no symbols loaded for
kernel32.dll]
Any suggestions or ideas are greatly appreciated,
Best Regards,
Ken S.
On Tue, Apr 8, 2008 at 7:28 PM, Ken Seo <ken.seo at gmail.com> wrote:
> Hi, Ross,
>
> Thank you for your reply,
>
> if "doGetNextFrame()" returns immediately, I'm not quite sure how it
> would work, the following is my understanding of RTP cycle,
>
> RTSPServer
> - upon start playing - calls GetNextFrame() -> calls doGetNextFrame()
> -> calls afterGetting() -> sends packets all that -> calls
> GetNextFrame()
>
> So, in the cycle above, once doGetNextFrame() returns without
> scheduling afterGetting(), then the cycle stops there. Also,
> doGetNextFrame() should be called only by "GetNextFrame()" which takes
> many parameters and has some initialization steps.
>
> So, from your explanation "Later, when a frame becomes available, this
>
> will be triggered as an event that can get handled within the event
> loop.", once I have a sample, how should I *handle* that in the event
> loop?, I can create a callback function or a watch variable to get
> notified, but, I'm not exactly sure what to do with it, should I
> manually call "doGetNextFrame()"?
>
> Here is what I tried, my doGetNextFrame() is empty.
>
> void QueueSource::doGetNextFrame()
> {
> }
>
> And I have a function that gets invoked when a sample arrives,
>
> HRESULT ReceivedSample(IMediaSample *pSample)
> {
>
>
>
>
> On Fri, Apr 4, 2008 at 5:17 PM, Ross Finlayson <finlayson at live555.com> wrote:
> > >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
> >
> > No, it should *not* be blocking until the next frame is available,
> > because if you block, you'll be starving out any other events that
> > need to be handled. Instead, if no frame is immediately available,
> > "doGetNextFrame()" should return. Later, when a frame becomes
> > available, this will be triggered as an event that can get handled
> > within the event loop.
> >
> > You can use the "watchVariable" parameter to "doEventLoop()" for this
> > purpose (e.g., have your separate queue-filling thread set the
> > 'watchVariable' when a new frame becomes available. (See the FAQ for
> > more information.)
> > --
> >
> > Ross Finlayson
> > Live Networks, Inc.
> > http://www.live555.com/
> > _______________________________________________
> > live-devel mailing list
> > live-devel at lists.live555.com
> > http://lists.live555.com/mailman/listinfo/live-devel
> >
>
More information about the live-devel
mailing list