3 //=============================================================================
7 * Process to receive data from the sender and send it to the
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/Policy.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 Signal_Handler (void);
33 /// Override this method to implement graceful shutdown.
34 int handle_signal(int signum
, siginfo_t
*,ucontext_t
*);
40 * @class Distributer_Receiver_Callback
42 * @brief Application defined callback object.
44 * AVStreams calls this class when data shows up from a sender.
46 class Distributer_Receiver_Callback
: public TAO_AV_Callback
51 Distributer_Receiver_Callback (void);
53 /// Method that is called when there is data to be received from a
55 int receive_frame (ACE_Message_Block
*frame
,
56 TAO_AV_frame_info
*frame_info
,
57 const ACE_Addr
&peer_address
);
59 /// Called when the sender is done sending data and wants to close
60 /// down the connection.
61 int handle_destroy (void);
63 /// Accessor methods for the flowname of the callback.
64 ACE_CString
&flowname (void);
65 void flowname (const ACE_CString
&flowname
);
68 //// Count of the frames passing through us.
71 //// Flowname of the flow.
72 ACE_CString flowname_
;
76 * @class Distributer_Sender_Callback
78 * @brief Defines a class for the distributer application callback
81 * This class overrides the methods of the TAO_AV_Callback so the
82 * AVStreams can make upcalls to the application.
84 class Distributer_Sender_Callback
: public TAO_AV_Callback
89 //// Called when the sender has finished reading the file and wants
90 //// to close down the connection.
91 int handle_destroy (void);
93 /// Accessor methods for the flowname of the callback.
94 ACE_CString
&flowname (void);
95 void flowname (const ACE_CString
&flowname
);
99 ACE_CString flowname_
;
104 * @class Distributer_Receiver_StreamEndPoint
106 * @brief Application defined stream endpoint object.
108 * AVStreams calls this class during connection setup.
110 class Distributer_Receiver_StreamEndPoint
: public TAO_Server_StreamEndPoint
113 /// Create a receiver application callback.
114 int get_callback (const char *flowname
,
115 TAO_AV_Callback
*&callback
);
117 //// Store the reference to the protocol object corresponding
118 //// to the transport
119 int set_protocol_object (const char *,
120 TAO_AV_Protocol_Object
*object
);
122 //// Called when a sender makes a connection request.
123 virtual CORBA::Boolean
handle_connection_requested (AVStreams::flowSpec
&the_spec
);
126 //// Receiver application callback.
127 Distributer_Receiver_Callback callback_
;
131 * @class Distributer_Sender_StreamEndPoint
133 * @brief / Defines a sender stream endpoint.
135 class Distributer_Sender_StreamEndPoint
: public TAO_Client_StreamEndPoint
138 //// Create the application callback and return its handle to
139 //// AVStreams for further application callbacks.
140 int get_callback (const char *flowname
,
141 TAO_AV_Callback
*&callback
);
143 //// Set protocol object corresponding to the transport protocol
145 int set_protocol_object (const char *flowname
,
146 TAO_AV_Protocol_Object
*object
);
149 //// Application callback.
150 Distributer_Sender_Callback callback_
;
153 typedef TAO_AV_Endpoint_Reactive_Strategy_A
154 <Distributer_Sender_StreamEndPoint
,
157 SENDER_ENDPOINT_STRATEGY
;
159 typedef TAO_AV_Endpoint_Reactive_Strategy_B
160 <Distributer_Receiver_StreamEndPoint
,
163 RECEIVER_ENDPOINT_STRATEGY
;
168 * @brief Distributer Application.
170 * The distributer is the intermediate receiver that receives
171 * data from the sender and forwards to a receiver.
182 //// Initialize data components.
187 int parse_args (int argc
,
190 /// Flag to know when we are done.
191 bool done (void) const;
194 //// Accessor to connection manager.
195 Connection_Manager
&connection_manager (void);
197 //// Called when stream created
198 void stream_created (void);
200 //// Called when stream destroyed
201 void stream_destroyed (void);
203 ////Unbind the sender and receiver from the Naming Service
204 void shut_down (void);
207 //// Connection manager.
208 Connection_Manager connection_manager_
;
210 //// The sender endpoint strategy.
211 SENDER_ENDPOINT_STRATEGY sender_endpoint_strategy_
;
213 //// The receiver endpoint strategy.
214 RECEIVER_ENDPOINT_STRATEGY receiver_endpoint_strategy_
;
216 //// The distributer receiver multimedia device
217 TAO_MMDevice
* distributer_receiver_mmdevice_
;
219 //// The distributer receiver multimedia device
220 TAO_MMDevice
* distributer_sender_mmdevice_
;
222 //// The name of the sender to connect to.
223 ACE_CString sender_name_
;
226 ACE_CString distributer_name_
;
228 //// Flag to know when we are done.
231 //// Number of active streams. When a stream is disconnected this
232 //// count is decremented.
235 //// Reference to the signal handler.
236 Signal_Handler signal_handler_
;