Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / AVStreams / Component_Switching / sender.h
blob9d40a9f9312fbaa919380c518e0339780b536103
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file sender.h
7 * This application reads data from a file and sends it to s
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/Protocol_Factory.h"
20 /**
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
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 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
46 public:
47 /**
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);
58 private:
59 //// Flowname of the callback.
60 ACE_CString flowname_;
63 /**
64 * @class Sender_StreamEndPoint
66 * @brief Defines a sender stream endpoint.
68 class Sender_StreamEndPoint : public TAO_Client_StreamEndPoint
70 public:
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
77 //// chosen.
78 int set_protocol_object (const char *flowname,
79 TAO_AV_Protocol_Object *object);
81 //// Perform application specific actions before accepting new
82 //// connections.
83 CORBA::Boolean handle_preconnect (AVStreams::flowSpec &flowspec);
85 protected:
86 //// Application callback.
87 Sender_Callback callback_;
90 typedef TAO_AV_Endpoint_Reactive_Strategy_A
91 <Sender_StreamEndPoint,
92 TAO_VDev,
93 AV_Null_MediaCtrl>
94 SENDER_ENDPOINT_STRATEGY;
96 /**
97 * @class Sender
99 * @brief Sender Application.
101 * Class is responsible for streaming (and pacing) data to a
102 * receiver.
104 class Sender
106 public:
107 //// Constructor
108 Sender ();
110 //// Destructor
111 ~Sender ();
113 void shut_down ();
115 //// Method to initialize the various data components.
116 int init (int argc,
117 ACE_TCHAR *argv[]);
119 //// Method to pace and send data from a file.
120 int pace_data ();
122 //// Accessor to the connection manager.
123 Connection_Manager &connection_manager ();
125 private:
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.
136 int frame_count_;
138 //// File from which data is read.
139 ACE_CString filename_;
141 //// File handle of the file read from.
142 FILE *input_file_;
144 //// Rate at which the data will be sent.
145 double frame_rate_;
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_;