2 #ifndef RECORDING_DEVICE_H
3 #define RECORDING_DEVICE_H
5 #include "ace/FILE_Addr.h"
6 #include "ace/Event_Handler.h"
7 #include "ace/Log_Msg.h"
8 #include "ace/Reactor.h"
9 #include "ace/Semaphore.h"
19 // Initialize the semaphore so that we don't block on the
20 // first call to wait_for_activity().
23 virtual ~RecordingDevice ()
27 virtual const ACE_TCHAR
*get_name () const
29 return ACE_TEXT ("UNKNOWN");
32 virtual int init (int, ACE_TCHAR
*[])
37 // Answer the incoming call
38 virtual int answer_call () = 0;
40 // Fetch some form of caller identification at the hardware level.
41 virtual CallerId
*retrieve_callerId () = 0;
43 // Fetch the message at the location specified by 'addr' and play
45 virtual int play_message (ACE_FILE_Addr
&addr
) = 0;
47 // Record data from our physical device into the file at the
48 // specified address. Return the number of bytes recorded.
49 virtual MessageType
*record_message (ACE_FILE_Addr
&addr
) = 0;
51 // Release the RecordingDevice to accept another incoming call
52 virtual void release ()
54 this->release_semaphore ();
57 // Get the handler of the device so that wait_for_activity() can
58 // wait for data to arrive.
59 virtual ACE_Event_Handler
*get_handler () const
64 virtual RecordingDevice
*wait_for_activity ()
66 // Block on a semaphore until it says we're ready to do
69 ACE_TEXT ("Waiting for semaphore\n")));
70 this->acquire_semaphore ();
72 // Use the reactor to wait for activity on our handle
75 ACE_Event_Handler
*handler
= this->get_handler ();
77 ACE_TEXT ("Handler is %@\n"),
80 reactor
.register_handler (this->get_handler (),
81 ACE_Event_Handler::READ_MASK
);
83 reactor
.handle_events ();
84 // Error-check this...
86 // Leave the semaphore locked so that we'll block until
87 // recording_complete() is invoked.
93 void acquire_semaphore ()
95 this->semaphore_
.acquire ();
98 void release_semaphore ()
100 // Reset the semaphore so that wait_for_activity() will
102 ACE_DEBUG ((LM_DEBUG
,
103 ACE_TEXT ("Releasing semaphore\n")));
104 this->semaphore_
.release ();
108 ACE_Semaphore semaphore_
;
111 #include "RecordingDevice_Text.h"
112 #include "RecordingDevice_USRVM.h"
113 #include "RecordingDevice_QC.h"
115 #include "RecordingDeviceFactory.h"
117 #endif /* RECORDING_DEVICE_H */