Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / AVStreams / Component_Switching / distributer.h
blobe4c61ab7f7b9be0cf1ed1c379f52cdd6c15aa5ac
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file distributer.h
7 * Process to receive data from the sender and send it to the
8 * receiver.
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"
20 /**
21 * @class Signal_Handler
22 TITLE
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
28 public:
29 Signal_Handler ();
31 /// Override this method to implement graceful shutdown.
32 int handle_signal(int signum, siginfo_t*,ucontext_t*);
36 /**
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
45 public:
46 //// Constructor.
47 Distributer_Receiver_Callback ();
49 /// Method that is called when there is data to be received from a
50 /// sender.
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);
63 private:
64 //// Count of the frames passing through us.
65 int frame_count_;
67 //// Flowname of the flow.
68 ACE_CString flowname_;
71 /**
72 * @class Distributer_Sender_Callback
74 * @brief Defines a class for the distributer application callback
75 * for receiving data.
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
82 public:
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);
91 private:
92 ACE_CString flowname_;
95 /**
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
104 public:
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);
117 private:
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
129 public:
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
136 //// chosen.
137 int set_protocol_object (const char *flowname,
138 TAO_AV_Protocol_Object *object);
140 protected:
141 //// Application callback.
142 Distributer_Sender_Callback callback_;
145 typedef TAO_AV_Endpoint_Reactive_Strategy_A
146 <Distributer_Sender_StreamEndPoint,
147 TAO_VDev,
148 AV_Null_MediaCtrl>
149 SENDER_ENDPOINT_STRATEGY;
151 typedef TAO_AV_Endpoint_Reactive_Strategy_B
152 <Distributer_Receiver_StreamEndPoint,
153 TAO_VDev,
154 AV_Null_MediaCtrl>
155 RECEIVER_ENDPOINT_STRATEGY;
158 * @class Distributer
160 * @brief Distributer Application.
162 * The distributer is the intermediate receiver that receives
163 * data from the sender and forwards to a receiver.
165 class Distributer
167 public:
168 //// Constructor
169 Distributer ();
171 //// Destructor.
172 ~Distributer ();
174 //// Initialize data components.
175 int init (int argc,
176 ACE_TCHAR **argv);
178 //// Parse args.
179 int parse_args (int argc,
180 ACE_TCHAR **argv);
182 /// Flag to know when we are done.
183 bool done () const;
184 void done (bool);
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
196 void shut_down ();
198 protected:
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_;
217 //// Our name.
218 ACE_CString distributer_name_;
220 //// Flag to know when we are done.
221 bool done_;
223 //// Number of active streams. When a stream is disconnected this
224 //// count is decremented.
225 int stream_count_;
227 //// Reference to the signal handler.
228 Signal_Handler signal_handler_;