[Live-devel] LiveMedia for multiply thread streaming server

Greg Bothe greg1 at netrats.cc
Mon Sep 6 23:12:49 PDT 2004


I wrote an application that is multi-threaded but that also uses the Live
Media library.  My application had to be multi-threaded due to the APIs
already designed in the system along with using ACE, CORBA, asynchronous
messaging, etc.  It was extremely tedious to work around, but it works.

What I had to do was schedule a live media timer that fires every 100 ms or
so.  This timer checks a queue which contains commands such as adding,
removing, or changing streams.  The calling thread that queues the command
blocks on a condition variable waiting for the queued command to be processed.
 Once the command has been processed, the error code is put into the structure
that was used to queue the command.  The live media timer then signals the
condition variable and the calling thread resumes and picks up the error code.

It's actually a little more work than the above, but you get the idea.  It's a
little disgusting, but it works okay for my application.  100 ms is quick
enough response time for adding/deleting streams and 100 ms timer is nothing
compared to all the timers going off for all the streams the application is
handling.

This is the only way I could safely get the Live Media code to work with my
threads.  I tried many different things, but all resulted in unreliable
behavior.  You can only access the live media library from a single thread,
end of story.  If you even try to schedule a timer from another thread, you
will run into instability.  I'm curious if anyone else has found a better
solution.

A thread-aware version of the live media library would certainly make things
easier, but I can't complain since the library saved me a ton of time and effort.

---

Greg Bothe


---------- Original Message -----------
From: Zhongming Yang <omitofu2004 at yahoo.com.cn>
To: live-devel at ns.live.com
Sent: Sun, 5 Sep 2004 18:00:31 +0800 (CST)
Subject: [Live-devel] LiveMedia for multiply thread streaming server

> hi, 
> I'd like to thank the stuff of live media. I have
> written a rtsp client application with live media. It
> works fine,except for a little problem while handling
> mpeg2 stream.
> 
> today, I'd like to write a streaming server that
> supports rstp protocol. It likes that live media is
> not thread-safed. Is there a method for streaming
> multiply source with live media.
------- End of Original Message -------



More information about the live-devel mailing list