[Live-devel] Non Blocking doGetNextFrame

Drew Ostheimer d_osthei at ece.concordia.ca
Fri Mar 31 13:52:52 PST 2006


Hello Ross,

I have done what you said and it has brought my CPU usage to well below 20%
which is where I am looking for it to be. However I have some problems with
the stream and the way it is displayed after being streamed. The video is
far from fluid, seems like packets are being delivered in bundles. Here is
how I modified my code to do what you suggested:

Inside my RtspServer class, where doEventLoop is located, I did this
modification:

while (true) {
	watchVariable = 0;
	env->taskScheduler().doEventLoop(&watchVariable);
	//for(int i = 0; i < numberOfFramers; i++)
	framer[0]->doGetNextFrame();
}

Where watchVariable is a private data value inside the class. I also have
function: 

void RtspServer:setWatchVariable() {
	watchVariable = 'a';	
}

Which is called from my FramedSource thread. Essentially my buffer signals
the receiving thread whenever data is located in the buffer, therefore
inside my run function of the FramedSource I have this:

while (true) {
	wait();
	server->setWatchVariable();
}

Where wait is calling pThread wait and the setWatchVariable is the function
defined above. Also I modified my doGetNextFrame function as follows:

if (!isCurrentlyAwaitingData())
	return;

pkt = (AVPacket*)(getInputBuffer()->getNextFrame(this));
if (pkt == NULL)
	return;
deliverFrame();	


Not sure why it is not running like it did before with my infinite loop in
the doGetNextFrame. Hopefully you can help. THANKS again for everything you
have done, nice to see people are out there to help others.

______________________________________
Drew Ostheimer
 
Computer Engineering Undergraduate Student,
Concordia University,
Montreal Canada.
 
Quote: "I've seen recently on a software package: Requires
Windows 2000 or better. So I installed Linux."
______________________________________

-----Original Message-----
From: live-devel-bounces at ns.live555.com
[mailto:live-devel-bounces at ns.live555.com] On Behalf Of Ross Finlayson
Sent: Friday, March 31, 2006 2:29 PM
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] Non Blocking doGetNextFrame


>The queue is designed such that if nothing is present it will return 
>null. In all the classes implementing filter, we have a wait() call 
>to our pthread wrapper class. Where the problem occurs is live is 
>not using our threading model and therefore this design will not work.

That's correct

>  How we did set it up was to just not call our start() and allow 
> live to take care of everything with a simple:
>
>while(pkt != null)
>             pkt = buffer->getPacket();
>deliverFrame();
>
>within the doGetNextFrame. As you can see this is a serious polling
problem.

Yes.  Note that - because the "LIVE555 Streaming Media" code has a 
single-threaded, event-based execution model, data reads should not 
be done synchronously.  Instead, data reads should be done 
asynchronously, using the event loop.  I.e., the arrival of new data 
needs to be (somehow) signalled as an event, and handled within the event
loop.

Probably the simplest way to do this is using the "watchVariable" 
feature of "doEventLoop()".  See 
<http://lists.live555.com/pipermail/live-devel/2005-September/003276.html>. 
Your separate thread - that delivers incoming data to your buffer - 
should set the global "watchVariable" whenever it delivers 
data.  Then, modify your call to "doEventLoop()" - as shown in the 
example - to handle the setting of this watch variable.  (I.e., what 
you're doing here is modifying the event loop to include testing of 
the watch variable.)

One way to handle the watch variable 'event' is to just call
         yourSource->doGetNextFrame();

Your "doGetNextFrame()" would then look something like:

void YourSource::doGetNextFrame() {
         if (!isCurrentlyAwaitingData()) return; // noone is awaiting data

         if (/*no data is available on your queue*/) return;

         // Get data from your queue, and deliver it to the client
         // (see "DeviceSource.cpp")

         // After delivering the data, switch to another task, and inform
         // the reader that he has data:
         nextTask()
                 = 
envir().taskScheduler().scheduleDelayedTask(0, 
(TaskFunc*)afterGetting, this);
}


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

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.4/299 - Release Date: 3/31/2006
 



More information about the live-devel mailing list