RTCP.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /**
00004  * Copyright (c) 1993-1994 The Regents of the University of California.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 3. All advertising materials mentioning features or use of this software
00016  *    must display the following acknowledgement:
00017  *      This product includes software developed by the University of
00018  *      California, Berkeley and the Network Research Group at
00019  *      Lawrence Berkeley Laboratory.
00020  * 4. Neither the name of the University nor of the Laboratory may be used
00021  *    to endorse or promote products derived from this software without
00022  *    specific prior written permission.
00023  *
00024  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00025  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00027  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00028  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00029  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00030  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00031  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00033  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00034  * SUCH DAMAGE.
00035  */
00036 
00037 //=============================================================================
00038 /**
00039  *  @file   RTCP.h
00040  *
00041  *  $Id: RTCP.h 71526 2006-03-14 06:14:35Z jtc $
00042  *
00043  *  @author Nagarajan Surendran <naga@cs.wustl.edu>
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 // FUZZ: disable check_for_math_include
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  * @class TAO_AV_RTCP
00069  * @brief Encapsulate the header format for the Real Time Control
00070  *        Protocol (RTCP)
00071  */
00072 class TAO_AV_Export TAO_AV_RTCP
00073 {
00074 public:
00075   struct rtcphdr
00076   {
00077     ACE_UINT16 rh_flags;        /* T:2 P:1 CNT:5 PT:8 */
00078     ACE_UINT16 rh_len;  /* length of message (in bytes) */
00079     ACE_UINT32 rh_ssrc; /* synchronization src id */
00080   };
00081 
00082   struct ntp64
00083   {
00084     ACE_UINT32 upper;   /* more significant 32 bits */
00085     ACE_UINT32 lower;   /* less significant 32 bits */
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  * @class TAO_AV_RTCP_Flow_Factory
00116  * @brief
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  * @class TAO_AV_RTCP_Callback
00137  * @brief TAO_AV_Callback for RTCP protocol
00138  */
00139 class TAO_AV_Export TAO_AV_RTCP_Callback : public TAO_AV_Callback
00140 {
00141 public:
00142   /// RTCP callback.
00143   TAO_AV_RTCP_Callback (void);
00144 
00145   /// virtual destructor.
00146   virtual ~TAO_AV_RTCP_Callback (void);
00147 
00148   /// Called during Streamctrl->start.
00149   virtual int handle_start (void);
00150 
00151   /// Called during Streamctrl->stop.
00152   virtual int handle_stop (void);
00153 
00154   /// Called during timeout for Flow Producers.
00155   virtual int handle_timeout (void *arg);
00156 
00157   /// Called when a frame arrives for a FlowConsumer.
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   /// Called during Streamctrl->destroy i.e tear_down  of the stream
00167   /// @@coryan:Call it handle_destroy or handle_close.
00168   virtual int handle_destroy (void);
00169 
00170   /// Called to get the timeout. If tv is 0 then the framework stop
00171   /// calling this.
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  * @class TAO_AV_RTCP_Object
00197  * @brief TAO_AV_Protocol_Object for RTCP protocol
00198  */
00199 class TAO_AV_Export TAO_AV_RTCP_Object
00200   : public TAO_AV_Protocol_Object
00201 {
00202 public:
00203   /// constructor.
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   /// Destructor
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   /// set/get policies.
00217   virtual int set_policies (const TAO_AV_PolicyList &policy_list);
00218 
00219   /// start/stop the flow.
00220   virtual int start (void);
00221   virtual int stop (void);
00222 
00223   /// send a data frame.
00224   virtual int send_frame (ACE_Message_Block *frame,
00225                           TAO_AV_frame_info *frame_info = 0);
00226 
00227   /// send a frame in iovecs.
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   /// end the stream.
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 /* TAO_AV_RTCP_H */

Generated on Tue Feb 2 17:47:49 2010 for TAO_AV by  doxygen 1.4.7