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 /// Override this method to implement graceful shutdown.
32 int handle_signal(int signum
, siginfo_t
*,ucontext_t
*);
37 * @class Distributer_Receiver_Callback
39 * @brief Application defined callback object.
41 * AVStreams calls this class when data shows up from a sender.
43 class Distributer_Receiver_Callback
: public TAO_AV_Callback
47 Distributer_Receiver_Callback ();
49 /// Method that is called when there is data to be received from a
51 int receive_frame (ACE_Message_Block
*frame
,
52 TAO_AV_frame_info
*frame_info
,
53 const ACE_Addr
&peer_address
);
55 /// Called when the sender is done sending data and wants to close
56 /// down the connection.
57 int handle_destroy ();
59 /// Accessor methods for the flowname of the callback.
60 ACE_CString
&flowname ();
61 void flowname (const ACE_CString
&flowname
);
64 //// Count of the frames passing through us.
67 //// Flowname of the flow.
68 ACE_CString flowname_
;
72 * @class Distributer_Sender_Callback
74 * @brief Defines a class for the distributer application callback
77 * This class overrides the methods of the TAO_AV_Callback so the
78 * AVStreams can make upcalls to the application.
80 class Distributer_Sender_Callback
: public TAO_AV_Callback
83 //// Called when the sender has finished reading the file and wants
84 //// to close down the connection.
85 int handle_destroy ();
87 /// Accessor methods for the flowname of the callback.
88 ACE_CString
&flowname ();
89 void flowname (const ACE_CString
&flowname
);
92 ACE_CString flowname_
;
96 * @class Distributer_Receiver_StreamEndPoint
98 * @brief Application defined stream endpoint object.
100 * AVStreams calls this class during connection setup.
102 class Distributer_Receiver_StreamEndPoint
: public TAO_Server_StreamEndPoint
105 /// Create a receiver application callback.
106 int get_callback (const char *flowname
,
107 TAO_AV_Callback
*&callback
);
109 //// Store the reference to the protocol object corresponding
110 //// to the transport
111 int set_protocol_object (const char *,
112 TAO_AV_Protocol_Object
*object
);
114 //// Called when a sender makes a connection request.
115 virtual CORBA::Boolean
handle_connection_requested (AVStreams::flowSpec
&the_spec
);
118 //// Receiver application callback.
119 Distributer_Receiver_Callback callback_
;
123 * @class Distributer_Sender_StreamEndPoint
125 * @brief / Defines a sender stream endpoint.
127 class Distributer_Sender_StreamEndPoint
: public TAO_Client_StreamEndPoint
130 //// Create the application callback and return its handle to
131 //// AVStreams for further application callbacks.
132 int get_callback (const char *flowname
,
133 TAO_AV_Callback
*&callback
);
135 //// Set protocol object corresponding to the transport protocol
137 int set_protocol_object (const char *flowname
,
138 TAO_AV_Protocol_Object
*object
);
141 //// Application callback.
142 Distributer_Sender_Callback callback_
;
145 typedef TAO_AV_Endpoint_Reactive_Strategy_A
146 <Distributer_Sender_StreamEndPoint
,
149 SENDER_ENDPOINT_STRATEGY
;
151 typedef TAO_AV_Endpoint_Reactive_Strategy_B
152 <Distributer_Receiver_StreamEndPoint
,
155 RECEIVER_ENDPOINT_STRATEGY
;
160 * @brief Distributer Application.
162 * The distributer is the intermediate receiver that receives
163 * data from the sender and forwards to a receiver.
174 //// Initialize data components.
179 int parse_args (int argc
,
182 /// Flag to know when we are done.
186 //// Accessor to connection manager.
187 Connection_Manager
&connection_manager ();
189 //// Called when stream created
190 void stream_created ();
192 //// Called when stream destroyed
193 void stream_destroyed ();
195 ////Unbind the sender and receiver from the Naming Service
199 //// Connection manager.
200 Connection_Manager connection_manager_
;
202 //// The sender endpoint strategy.
203 SENDER_ENDPOINT_STRATEGY sender_endpoint_strategy_
;
205 //// The receiver endpoint strategy.
206 RECEIVER_ENDPOINT_STRATEGY receiver_endpoint_strategy_
;
208 //// The distributer receiver multimedia device
209 TAO_MMDevice
* distributer_receiver_mmdevice_
;
211 //// The distributer receiver multimedia device
212 TAO_MMDevice
* distributer_sender_mmdevice_
;
214 //// The name of the sender to connect to.
215 ACE_CString sender_name_
;
218 ACE_CString distributer_name_
;
220 //// Flag to know when we are done.
223 //// Number of active streams. When a stream is disconnected this
224 //// count is decremented.
227 //// Reference to the signal handler.
228 Signal_Handler signal_handler_
;