3 //=============================================================================
7 * This application reads data from a file and sends it to s
10 * @author Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
12 //=============================================================================
15 #include "Connection_Manager.h"
16 #include "orbsvcs/AV/AVStreams_i.h"
17 #include "orbsvcs/AV/Endpoint_Strategy.h"
18 #include "orbsvcs/AV/Protocol_Factory.h"
21 * @class Signal_Handler
23 * This class Handles the SIGINT signal through the Reactor.
24 * Useful to gracefully release the process
26 class Signal_Handler
: public ACE_Event_Handler
31 /// Override this method to implement graceful shutdown.
32 int handle_signal(int signum
, siginfo_t
*,ucontext_t
*);
37 * @class Sender_Callback
39 * @brief Defines a class for the sender application callback.
41 * This class overrides the methods of the TAO_AV_Callback so the
42 * AVStreams can make upcalls to the application.
44 class Sender_Callback
: public TAO_AV_Callback
48 * Called when the sender has finished reading the file and wants
49 * to close down the connection. Also called when the distributer
50 * tears down the connection when it switches to a new sender.
52 int handle_destroy ();
54 /// Accessor methods for the flowname of the callback
55 ACE_CString
&flowname ();
56 void flowname (const ACE_CString
&flowname
);
59 //// Flowname of the callback.
60 ACE_CString flowname_
;
64 * @class Sender_StreamEndPoint
66 * @brief Defines a sender stream endpoint.
68 class Sender_StreamEndPoint
: public TAO_Client_StreamEndPoint
71 //// Create the application callback and return its handle to
72 //// AVStreams for further application callbacks.
73 int get_callback (const char *flowname
,
74 TAO_AV_Callback
*&callback
);
76 //// Set protocol object corresponding to the transport protocol
78 int set_protocol_object (const char *flowname
,
79 TAO_AV_Protocol_Object
*object
);
81 //// Perform application specific actions before accepting new
83 CORBA::Boolean
handle_preconnect (AVStreams::flowSpec
&flowspec
);
86 //// Application callback.
87 Sender_Callback callback_
;
90 typedef TAO_AV_Endpoint_Reactive_Strategy_A
91 <Sender_StreamEndPoint
,
94 SENDER_ENDPOINT_STRATEGY
;
99 * @brief Sender Application.
101 * Class is responsible for streaming (and pacing) data to a
115 //// Method to initialize the various data components.
119 //// Method to pace and send data from a file.
122 //// Accessor to the connection manager.
123 Connection_Manager
&connection_manager ();
126 //// Method to parse the command line arguments.
127 int parse_args (int argc
, ACE_TCHAR
*argv
[]);
129 //// The endpoint strategy used by the sender.
130 SENDER_ENDPOINT_STRATEGY endpoint_strategy_
;
132 //// The sender MMDevice.
133 TAO_MMDevice
*sender_mmdevice_
;
135 //// Number of frames sent.
138 //// File from which data is read.
139 ACE_CString filename_
;
141 //// File handle of the file read from.
144 //// Rate at which the data will be sent.
147 //// Message block into which data is read from a file and then sent.
148 ACE_Message_Block mb_
;
150 //// Name of this sender.
151 ACE_CString sender_name_
;
153 //// Connection manager.
154 Connection_Manager connection_manager_
;
156 //// Reference to the signal handler.
157 Signal_Handler signal_handler_
;