[Live-devel] interactive support

Ross Finlayson finlayson at live555.com
Thu Sep 29 02:54:12 PDT 2005


>Sorry if this was asked before, I checked the archive
>without success, but I would like to know if LiveMedia
>library has already support for interactive control ?
>By this I mean I want to be able to start a function
>anytime during the runtime of my program by pressing a
>key on the keyboard.

Yes, there are two possible ways to do this.

The most general (but most complicated) way is to write a new 
"TaskScheduler" subclass, that implements a new event loop, and use 
this instead of "BasicTaskScheduler".

A much simpler (but less general) way is to use the "watchVariable" 
feature of "TaskScheduler::doEventLoop()".  E,g.

replace
         env->taskScheduler().doEventLoop();
with
         char watchVariable; // make this a global variable
         ...
         while (1) {
                 watchVariable = 0;
                 env->taskScheduler().doEventLoop(&watchVariable);
                 switch (watchVariable) {
                         case 'a': {
                                 // handle the pressing of key 'a'
                                 break;
                         }
                         case 'b': {
                                 // hande the pressing of key 'b'
                                 break;
                         }
                         // etc.
                 }
         }

Then, elsewhere in your program, do
         if (/* key 'a' is pressed*/) {
                 watchVariable = 'a';
         }
etc.


	Ross Finlayson
	Live Networks, Inc. (LIVE555.COM)
	<http://www.live555.com/>



More information about the live-devel mailing list