Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / tests / AVStreams / Bidirectional_Flows / sender.h
blob5bbc4cc5e4a5736c7d3775c883053c6d23e44f3f
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 "orbsvcs/Naming/Naming_Client.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 Sender_Callback
23 * @brief Application defined callback object.
25 * AVStreams calls this class when data shows up from a sender.
27 class Sender_Callback : public TAO_AV_Callback
29 public:
30 /// Constructor.
31 Sender_Callback ();
33 // Method that is called when there is data to be received from a
34 // sender.
35 int receive_frame (ACE_Message_Block *frame,
36 TAO_AV_frame_info *frame_info,
37 const ACE_Addr &peer_address);
39 // Called when the sender is done sending data and wants to close
40 // down the connection.
41 // int handle_destroy ();
43 private:
44 /// Keeping a count of the incoming frames.
45 int frame_count_;
48 /**
49 * @class Sender_StreamEndPoint
51 * @brief Defines a sender stream endpoint.
53 class Sender_StreamEndPoint : public TAO_Client_StreamEndPoint
55 public:
56 /// Create the application callback and return its handle to
57 /// AVStreams for further application callbacks.
58 int get_callback (const char *flowname,
59 TAO_AV_Callback *&callback);
61 /// Set protocol object corresponding to the transport protocol
62 /// chosen.
63 int set_protocol_object (const char *flowname,
64 TAO_AV_Protocol_Object *object);
66 protected:
67 /// Application callback.
68 Sender_Callback callback_;
71 typedef TAO_AV_Endpoint_Reactive_Strategy_A
72 <Sender_StreamEndPoint,
73 TAO_VDev,
74 AV_Null_MediaCtrl>
75 SENDER_ENDPOINT_STRATEGY;
77 /**
78 * @class Sender
80 * @brief Sender Application.
82 * Class is responsible for streaming (and pacing) data to a
83 * receiver.
85 class Sender
87 public:
88 /// Constructor
89 Sender ();
91 /// Method to initialize the various data components.
92 int init (int argc,
93 ACE_TCHAR *argv[]);
95 /// Method to pace and send data from a file.
96 int pace_data ();
98 /// Set the protocol object corresponding to the transport protocol chosen.
99 void protocol_object (TAO_AV_Protocol_Object *protocol_object);
101 int eof ();
103 void shutdown ();
105 private:
106 /// Method to parse the command line arguments.
107 int parse_args (int argc, ACE_TCHAR *argv[]);
109 /// Method that binds the sender to the receiver.
110 int bind_to_receiver ();
112 /// The endpoint strategy used by the sender.
113 SENDER_ENDPOINT_STRATEGY endpoint_strategy_;
115 /// The receiver MMDevice that the sender connects to.
116 AVStreams::MMDevice_var receiver_mmdevice_;
118 /// The sender MMDevice.
119 TAO_MMDevice *sender_mmdevice_;
121 /// Stream controller
122 TAO_StreamCtrl *streamctrl_;
124 /// Number of frames sent.
125 int frame_count_;
127 /// File from which data is read.
128 ACE_CString filename_;
130 /// The Naming Service client.
131 TAO_Naming_Client naming_client_;
133 /// File handle of the file read from.
134 FILE *input_file_;
136 /// Selected protocol - default is UDP
137 ACE_CString protocol_;
139 /// Rate at which the data will be sent.
140 int frame_rate_;
142 /// Message block into which data is read from a file and then sent.
143 ACE_Message_Block mb_;
145 /// Protocol object corresponding to the transport protocol selected.
146 TAO_AV_Protocol_Object *protocol_object_;
148 int eof_;