00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef TAO_AV_RTCP_H
00049 #define TAO_AV_RTCP_H
00050 #include "ace/pre.h"
00051
00052 #include "orbsvcs/AV/RTCP_Channel.h"
00053
00054
00055
00056 #include "orbsvcs/AV/AVStreams_i.h"
00057 #include "orbsvcs/AV/UDP.h"
00058 #include "orbsvcs/AV/RTP.h"
00059 #include "ace/Hash_Map_Manager_T.h"
00060 #include <math.h>
00061 #include <stdlib.h>
00062
00063 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00064
00065 class TAO_AV_RTCP_Callback;
00066
00067
00068
00069
00070
00071
00072 class TAO_AV_Export TAO_AV_RTCP
00073 {
00074 public:
00075 struct rtcphdr
00076 {
00077 ACE_UINT16 rh_flags;
00078 ACE_UINT16 rh_len;
00079 ACE_UINT32 rh_ssrc;
00080 };
00081
00082 struct ntp64
00083 {
00084 ACE_UINT32 upper;
00085 ACE_UINT32 lower;
00086 };
00087
00088 struct md5_string
00089 {
00090 int type;
00091 ACE_Time_Value tv;
00092 pid_t pid;
00093 pid_t pgid;
00094 pid_t ppid;
00095 uid_t uid;
00096 gid_t gid;
00097 };
00098
00099 static void send_report (ACE_Message_Block *mb);
00100
00101 static ACE_UINT32 alloc_srcid (ACE_UINT32 addr);
00102
00103 static double rtcp_interval (int members,
00104 int senders,
00105 double rtcp_bw,
00106 int we_sent,
00107 int packet_size,
00108 int *avg_rtcp_size,
00109 int initial);
00110 };
00111
00112
00113
00114
00115
00116
00117
00118 class TAO_AV_Export TAO_AV_RTCP_Flow_Factory
00119 :public TAO_AV_Flow_Protocol_Factory
00120 {
00121 public:
00122 TAO_AV_RTCP_Flow_Factory (void);
00123 virtual ~TAO_AV_RTCP_Flow_Factory (void);
00124 virtual int init (int argc, char *argv[]);
00125 virtual int match_protocol (const char *flow_string);
00126 virtual TAO_AV_Protocol_Object* make_protocol_object (TAO_FlowSpec_Entry *entry,
00127 TAO_Base_StreamEndPoint *endpoint,
00128 TAO_AV_Flow_Handler *handler,
00129 TAO_AV_Transport *transport);
00130 };
00131
00132 class TAO_AV_Callback;
00133
00134
00135
00136
00137
00138
00139 class TAO_AV_Export TAO_AV_RTCP_Callback : public TAO_AV_Callback
00140 {
00141 public:
00142
00143 TAO_AV_RTCP_Callback (void);
00144
00145
00146 virtual ~TAO_AV_RTCP_Callback (void);
00147
00148
00149 virtual int handle_start (void);
00150
00151
00152 virtual int handle_stop (void);
00153
00154
00155 virtual int handle_timeout (void *arg);
00156
00157
00158 virtual int receive_frame (ACE_Message_Block *frame,
00159 TAO_AV_frame_info *frame_info = 0,
00160 const ACE_Addr &peer_address = ACE_Addr::sap_any);
00161 int send_frame (ACE_Message_Block *frame);
00162
00163 virtual int receive_control_frame (ACE_Message_Block *frame,
00164 const ACE_Addr &peer_address = ACE_Addr::sap_any);
00165
00166
00167
00168 virtual int handle_destroy (void);
00169
00170
00171
00172 virtual void get_timeout (ACE_Time_Value *&tv,
00173 void *&arg);
00174
00175 int send_report(int bye);
00176 void schedule (int ms);
00177 TAO_AV_RTP_State *state (void);
00178 void ts_offset (ACE_UINT32 offset);
00179
00180 protected:
00181 ACE_Hash_Map_Manager<ACE_UINT32, RTCP_Channel_In*, ACE_Null_Mutex> inputs_;
00182 RTCP_Channel_Out output_;
00183 int timeout_;
00184 int timestamp_offset_;
00185 int sdes_count_;
00186
00187 int is_initial_timeout_;
00188 int avg_rtcp_size_;
00189 int packet_size_;
00190 };
00191
00192 class RTP_Packet;
00193
00194
00195
00196
00197
00198
00199 class TAO_AV_Export TAO_AV_RTCP_Object
00200 : public TAO_AV_Protocol_Object
00201 {
00202 public:
00203
00204 TAO_AV_RTCP_Object (TAO_AV_Callback *client_cb,
00205 TAO_AV_RTCP_Callback *&rtcp_cb,
00206 TAO_AV_Transport *transport = 0);
00207
00208
00209 virtual ~TAO_AV_RTCP_Object (void);
00210
00211 virtual int handle_input (void);
00212 virtual int handle_control_input (ACE_Message_Block *frame,
00213 const ACE_Addr &peer_address);
00214 virtual int handle_control_output (ACE_Message_Block *frame);
00215
00216
00217 virtual int set_policies (const TAO_AV_PolicyList &policy_list);
00218
00219
00220 virtual int start (void);
00221 virtual int stop (void);
00222
00223
00224 virtual int send_frame (ACE_Message_Block *frame,
00225 TAO_AV_frame_info *frame_info = 0);
00226
00227
00228 virtual int send_frame (const iovec *iov,
00229 int iovcnt,
00230 TAO_AV_frame_info *frame_info = 0);
00231
00232 virtual int send_frame (const char*buf,
00233 size_t len);
00234
00235
00236 virtual int destroy (void);
00237
00238 void ssrc (ACE_UINT32 ssrc) {this->ssrc_ = ssrc; }
00239 ACE_UINT32 ssrc (void) { return this->ssrc_; }
00240
00241 void ts_offset (ACE_UINT32 ts_offset);
00242
00243
00244 private:
00245 TAO_AV_Callback *client_cb_;
00246 TAO_AV_RTCP_Callback rtcp_cb_;
00247 ACE_UINT32 ssrc_;
00248 };
00249
00250 TAO_END_VERSIONED_NAMESPACE_DECL
00251
00252 ACE_STATIC_SVC_DECLARE (TAO_AV_RTCP_Flow_Factory)
00253 ACE_FACTORY_DECLARE (TAO_AV, TAO_AV_RTCP_Flow_Factory)
00254
00255 #include "ace/post.h"
00256 #endif