Intel IP Media Server Home Theater Server User Manual


 
IP Media Server for HMP Demo Guide — July 2005 41
Demo Details
5.5 Event Handling
This section describes how the IP Media Server for HMP demo handles events. It contains the
following topics:
Event Mechanism
Handling Keyboard Input Events
Handling SRL Events
Handling Application Exit Events
TSUsrEvent Structure
5.5.1 Event Mechanism
The IP Media Server demo uses the SRL mechanism to retrieve events. When an event occurs, SRL
calls event handlers automatically. All events are received by the SRL and then passed to the
CallbackHdlr( ) function for handling.
In the initialization phase of the demo, the main( ) function sets up the call-back handler, by calling
PDLsr_enbhdlr( ).
5.5.2 Handling Keyboard Input Events
There is an endless loop {while(0)} in the main( ) function in the Main.cpp file. In that loop, the
application waits forever for a keyboard event by calling the waitForKey( ) function. The event
must be handled immediately and event-specific information should be retrieved before the next
call to waitForKey( ).
5.5.3 Handling SRL Events
When the R4/Global Call event is received, the application performs the following:
1. Get METAEVENT by calling gc_GetMetaEvent( ).
2. Get channel ID through device handle to channel mapping.
3. Get device type through device handle to type mapping.
4. Route meta event to the module specified by device type.
5.5.4 Handling Application Exit Events
Normal application exit events, such as pressing either q or Q, don’t enter the SRL. The main( )
function calls PDLSetApplicationExitPath( ) before initialization. In Linux, this function sets the
signals (SIGINT, SIGTERM, SIGABRT) for making the appropriate exit from the application. In
Windows, this function enables the detection of CTRL_CLOSE_EVENT (closing the window).