AVStreams_i.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   AVStreams_i.h
00006  *
00007  *  $Id: AVStreams_i.h 77001 2007-02-12 07:54:49Z johnnyw $
00008  *
00009  *  @author Sumedh Mungee <sumedh@cs.wustl.edu>
00010  *  @author Nagarajan Surendran <naga@cs.wustl.edu>
00011  */
00012 //=============================================================================
00013 
00014 #ifndef AVSTREAMS_I_H
00015 #define AVSTREAMS_I_H
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "orbsvcs/AV/AV_Core.h"
00019 
00020 #include "orbsvcs/AV/AV_export.h"
00021 #include "orbsvcs/CosPropertyS.h"
00022 #include "orbsvcs/AVStreamsS.h"
00023 #include "orbsvcs/Property/CosPropertyService_i.h"
00024 #include "orbsvcs/CosNamingC.h"
00025 #include "orbsvcs/AV/AV_Core.h"
00026 #include "orbsvcs/AV/Endpoint_Strategy.h"
00027 #include "orbsvcs/Null_MediaCtrlS.h"
00028 #include "orbsvcs/AV/FlowSpec_Entry.h"
00029 
00030 #include "ace/OS.h"
00031 #include "ace/SOCK_Dgram_Mcast.h"
00032 #include "ace/ATM_Addr.h"
00033 #include "ace/Containers_T.h"
00034 #include "ace/Process.h"
00035 #include "ace/SOCK_CODgram.h"
00036 #include "ace/SOCK_Connector.h"
00037 #include "ace/Connector.h"
00038 #include "ace/Acceptor.h"
00039 #include "ace/SOCK_Stream.h"
00040 #include "ace/Svc_Handler.h"
00041 #include "ace/SOCK_Acceptor.h"
00042 
00043 #define FLOWSPEC_MAX 5
00044 // for the Hash_Map helper classes.
00045 
00046 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00047 
00048 typedef ACE_Hash_Map_Manager <ACE_CString,AVStreams::FlowEndPoint_var,ACE_Null_Mutex>  FlowEndPoint_Map;
00049 typedef ACE_Hash_Map_Entry <ACE_CString,AVStreams::FlowEndPoint_var> FlowEndPoint_Map_Entry;
00050 typedef ACE_Hash_Map_Iterator <ACE_CString,AVStreams::FlowEndPoint_var,ACE_Null_Mutex>  FlowEndPoint_Map_Iterator;
00051 
00052 typedef ACE_Hash_Map_Manager <ACE_CString,TAO_AV_Flow_Handler*,ACE_Null_Mutex>  Flow_Handler_Map;
00053 typedef ACE_Hash_Map_Entry <ACE_CString,TAO_AV_Flow_Handler*> Flow_Handler_Map_Entry;
00054 typedef ACE_Hash_Map_Iterator <ACE_CString,TAO_AV_Flow_Handler*,ACE_Null_Mutex>  Flow_Handler_Map_Iterator;
00055 
00056 
00057 
00058 class TAO_AV_Export AV_Null_MediaCtrl
00059   : public virtual POA_Null_MediaCtrl
00060 {
00061 public:
00062   AV_Null_MediaCtrl (void);
00063 
00064 protected:
00065 
00066   virtual ~AV_Null_MediaCtrl (void);
00067 
00068 };
00069 
00070 /**
00071  * @class TAO_Basic_StreamCtrl
00072  * @brief Base class for StreamCtrl, implements basic stream start
00073  *        and stop functionality.
00074  */
00075 class TAO_AV_Export TAO_Basic_StreamCtrl
00076   : public virtual POA_AVStreams::Basic_StreamCtrl,
00077     public virtual TAO_PropertySet
00078 {
00079 
00080 public:
00081   /// Default Constructor
00082   TAO_Basic_StreamCtrl (void);
00083 
00084   /// Stop the transfer of data of the stream
00085   /// Empty the_spec means apply operation to all flows
00086   virtual void stop (const AVStreams::flowSpec &the_spec);
00087 
00088   /// Start the transfer of data in the stream.
00089   /// Empty the_spec means apply operation to all flows
00090   virtual void start (const AVStreams::flowSpec &the_spec);
00091 
00092   /**
00093    * Tears down the stream. This will close the connection, and delete
00094    * the streamendpoint and vdev associated with this stream
00095    * Empty the_spec means apply operation to all flows
00096    */
00097   virtual void destroy (const AVStreams::flowSpec &the_spec);
00098 
00099   /// Changes the QoS associated with the stream
00100   /// Empty the_spec means apply operation to all flows
00101   virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &new_qos,
00102                                      const AVStreams::flowSpec &the_spec);
00103 
00104   /// Used by StreamEndPoint and VDev to inform StreamCtrl of events.
00105   /// E.g., loss of flow, reestablishment of flow, etc..
00106   virtual void push_event (const struct CosPropertyService::Property & the_event);
00107 
00108   /// Used to control the flow protocol parameters.
00109   virtual void set_FPStatus (const AVStreams::flowSpec &the_spec,
00110                              const char *fp_name,
00111                              const CORBA::Any &fp_settings);
00112 
00113   /// Not implemented in the light profile, will raise the notsupported
00114   /// exception
00115   virtual CORBA::Object_ptr get_flow_connection (const char *flow_name);
00116 
00117   /// Not implemented in the light profile, will raise the notsupported
00118   /// exception
00119   virtual void set_flow_connection (const char *flow_name,
00120                                     CORBA::Object_ptr flow_connection);
00121 
00122 protected:
00123 
00124   /// Destructor.
00125   virtual ~TAO_Basic_StreamCtrl (void);
00126 
00127 
00128   /// The Virtual Devices for this stream
00129   AVStreams::VDev_var vdev_a_;
00130   AVStreams::VDev_var vdev_b_;
00131 
00132   /// The Endpoints for this stream
00133   AVStreams::StreamEndPoint_A_var sep_a_;
00134   AVStreams::StreamEndPoint_B_var sep_b_;
00135 
00136   /// Hash table for the flow names and its corresponding flowconnection object reference.
00137   typedef ACE_Hash_Map_Manager <ACE_CString,AVStreams::FlowConnection_var,ACE_Null_Mutex> FlowConnection_Map;
00138   typedef ACE_Hash_Map_Iterator <ACE_CString,AVStreams::FlowConnection_var,ACE_Null_Mutex> FlowConnection_Map_Iterator;
00139   typedef ACE_Hash_Map_Entry <ACE_CString,AVStreams::FlowConnection_var> FlowConnection_Map_Entry;
00140   FlowConnection_Map flow_connection_map_;
00141   AVStreams::FlowConnection_seq flowConnections_;
00142 
00143   ///sequence of flow names.
00144   u_int flow_count_;
00145   AVStreams::flowSpec flows_;
00146 };
00147 
00148 class TAO_AV_Export TAO_Negotiator
00149   : public POA_AVStreams::Negotiator
00150 {
00151 public:
00152   virtual CORBA::Boolean negotiate (AVStreams::Negotiator_ptr remote_negotiator,
00153                                     const AVStreams::streamQoS &qos_spec);
00154 };
00155 
00156 class TAO_MCastConfigIf;
00157 
00158 class TAO_AV_Export MMDevice_Map_Hash_Key
00159 {
00160 public:
00161   /// default constructor.
00162   MMDevice_Map_Hash_Key (void);
00163 
00164   /// constructor.
00165   MMDevice_Map_Hash_Key (AVStreams::MMDevice_ptr mmdevice);
00166 
00167   /// copy constructor.
00168   MMDevice_Map_Hash_Key (const MMDevice_Map_Hash_Key&);
00169 
00170   /// destructor.
00171   ~MMDevice_Map_Hash_Key (void);
00172 
00173   /// operator== needed by  ACE_Hash_Map_Manager.
00174   bool operator == (const MMDevice_Map_Hash_Key &hash_key) const;
00175 
00176   /// operator== needed by  ACE_Hash_Map_Manager.
00177   friend bool operator < (const MMDevice_Map_Hash_Key &left,
00178                           const MMDevice_Map_Hash_Key &right);
00179 
00180   /// hash function for this mmdevice.
00181   u_long hash (void) const;
00182 
00183   static const int hash_maximum_;
00184 protected:
00185   AVStreams::MMDevice_ptr mmdevice_;
00186 };
00187 
00188 /**
00189  * @class TAO_StreamCtrl
00190  * @brief Implementation the A/V StreamCtrl class. this class
00191  *        is used to control the stream. It should be subclassed
00192  *        by applications that want to provide more control features.
00193  */
00194 class TAO_AV_Export TAO_StreamCtrl
00195   : public virtual POA_AVStreams::StreamCtrl,
00196     public virtual TAO_Basic_StreamCtrl
00197 {
00198 
00199 public:
00200 
00201   /// Default Constructor
00202   TAO_StreamCtrl (void);
00203 
00204   /// virtual destructor.
00205   virtual ~TAO_StreamCtrl (void);
00206 
00207   /// Stop the transfer of data of the stream
00208   /// Empty the_spec means apply operation to all flows
00209   virtual void stop (const AVStreams::flowSpec &the_spec);
00210 
00211   /// Start the transfer of data in the stream.
00212   /// Empty the_spec means apply operation to all flows
00213   virtual void start (const AVStreams::flowSpec &the_spec);
00214 
00215   /**
00216    * Tears down the stream. This will close the connection, and delete
00217    * the streamendpoint and vdev associated with this stream
00218    * Empty the_spec means apply operation to all flows
00219    */
00220   virtual void destroy (const AVStreams::flowSpec &the_spec);
00221 
00222   /**
00223    * Establish a stream between a_party and b_party,
00224    * with qos the_qos, and for the flows in the_flows
00225    * if the_flows is empty, bind all the flows
00226    * Causes a connection to be established between the StreamEndpoints.
00227    * Returns success/failure
00228    */
00229   virtual CORBA::Boolean bind_devs (AVStreams::MMDevice_ptr a_party,
00230                                     AVStreams::MMDevice_ptr b_party,
00231                                     AVStreams::streamQoS& the_qos,
00232                                     const AVStreams::flowSpec& the_flows);
00233 
00234   /**
00235    * Establish a connection between two streamendpoints. This can
00236    * be used if the streamendpoints have been created independent of
00237    * a MMDevice
00238    */
00239   virtual CORBA::Boolean bind (AVStreams::StreamEndPoint_A_ptr a_party,
00240                                AVStreams::StreamEndPoint_B_ptr b_party,
00241                                AVStreams::streamQoS &the_qos,
00242                                const AVStreams::flowSpec &the_flows);
00243 
00244   virtual void unbind_dev (AVStreams::MMDevice_ptr dev,
00245                            const AVStreams::flowSpec & the_spec);
00246 
00247   /// Unbind the_ep from the stream. Empty the_spec means apply to all flows.
00248   virtual void unbind_party (AVStreams::StreamEndPoint_ptr the_ep,
00249                              const AVStreams::flowSpec &the_spec);
00250 
00251   /// unbind the stream. Same effect as Basic_StreamCtrl::destroy ()
00252   virtual void unbind (void);
00253 
00254   virtual AVStreams::VDev_ptr get_related_vdev (AVStreams::MMDevice_ptr adev,
00255                                                 AVStreams::StreamEndPoint_out sep);
00256 
00257   /// Changes the QoS associated with the stream
00258   /// Empty the_spec means apply operation to all flows
00259   virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &new_qos,
00260                                      const AVStreams::flowSpec &the_spec);
00261 
00262 protected:
00263 
00264   struct MMDevice_Map_Entry
00265   {
00266     AVStreams::StreamEndPoint_var sep_;
00267     AVStreams::VDev_var vdev_;
00268     AVStreams::flowSpec flowspec_;
00269     AVStreams::streamQoS qos_;
00270   };
00271 
00272   typedef ACE_Hash_Map_Manager <MMDevice_Map_Hash_Key,MMDevice_Map_Entry,ACE_Null_Mutex> MMDevice_Map;
00273   typedef ACE_Hash_Map_Iterator <MMDevice_Map_Hash_Key,MMDevice_Map_Entry,ACE_Null_Mutex> MMDevice_Map_Iterator;
00274 
00275   MMDevice_Map mmdevice_a_map_;
00276   MMDevice_Map mmdevice_b_map_;
00277   TAO_MCastConfigIf *mcastconfigif_;
00278   AVStreams::MCastConfigIf_var mcastconfigif_ptr_;
00279   AVStreams::StreamCtrl_var streamctrl_;
00280   CORBA::ULong source_id_;
00281 };
00282 
00283 class TAO_AV_Export TAO_MCastConfigIf
00284   : public virtual POA_AVStreams::MCastConfigIf,
00285     public virtual TAO_PropertySet
00286 {
00287 public:
00288 
00289   enum Peer_Interface {VDEV = 0, FLOWENDPOINT=1};
00290   struct Peer_Info
00291   {
00292     AVStreams::VDev_var peer_;
00293     AVStreams::FlowEndPoint_var fep_;
00294     AVStreams::streamQoS qos_;
00295     AVStreams::flowSpec flow_spec_;
00296     Peer_Interface interface_;
00297   };
00298 
00299   /// Default constructor.
00300   TAO_MCastConfigIf (void);
00301 
00302   /// Dtor
00303   ~TAO_MCastConfigIf (void);
00304 
00305   virtual CORBA::Boolean set_peer (CORBA::Object_ptr peer,
00306                                    AVStreams::streamQoS & the_qos,
00307                                    const AVStreams::flowSpec & the_spec);
00308 
00309   virtual void configure (const CosPropertyService::Property & a_configuration);
00310 
00311   virtual void set_initial_configuration (const CosPropertyService::Properties & initial);
00312 
00313   virtual void set_format (const char * flowName,
00314                            const char * format_name);
00315 
00316   virtual void set_dev_params (const char * flowName,
00317                                const CosPropertyService::Properties & new_params)
00318 ;
00319 
00320 protected:
00321   /// checks whether the flowname is  in the flow_spec.
00322   int in_flowSpec (const AVStreams::flowSpec& flow_spec, const char *flow_name);
00323 
00324   /// Multicast socket.
00325   ACE_SOCK_Dgram_Mcast sock_mcast_;
00326 
00327   /// Initial configuration to be distributed to all B parties when they join.
00328   CosPropertyService::Properties initial_configuration_;
00329 
00330   ACE_DLList<Peer_Info> peer_list_;
00331   ACE_DLList_Iterator<Peer_Info> peer_list_iterator_;
00332 };
00333 
00334 /**
00335  * @class TAO_AV_QoS
00336  * @brief Class for getting and setting the QoS characteristics of
00337  *        an AV Stream.
00338  */
00339 class TAO_AV_Export TAO_AV_QoS
00340 {
00341 public:
00342   /// constructor.
00343   TAO_AV_QoS (void);
00344 
00345   /// constructor taking a stream qos parameter.
00346   TAO_AV_QoS (AVStreams::streamQoS &stream_qos);
00347 
00348   /// sets the maps with the QoS paramter.
00349   int set (AVStreams::streamQoS &stream_qos);
00350 
00351   /// gets the flow_qos.
00352   int get_flow_qos (const char *flowname,AVStreams::QoS &flow_qos);
00353 
00354   /// converts the application level QoS to Network-level QoS.
00355   int convert (AVStreams::streamQoS &network_qos);
00356 
00357 
00358 protected:
00359   /// Stream Qos.
00360   AVStreams::streamQoS stream_qos_;
00361 
00362   ACE_Hash_Map_Manager<ACE_CString,AVStreams::QoS,ACE_Null_Mutex> qos_map_;
00363 };
00364 
00365 
00366 // Forward declarations.
00367 class TAO_AV_TCP_Flow_Handler;
00368 class TAO_AV_UDP_Flow_Handler;
00369 class TAO_AV_UDP_MCast_Flow_Handler;
00370 class TAO_AV_Protocol_Object;
00371 class TAO_AV_Callback;
00372 class TAO_AV_SourceManager;
00373 class TAO_AV_Source;
00374 class TAO_AV_RTP_State;
00375 class TAO_AV_Flow_Handler;
00376 
00377 /**
00378  * @class TAO_Base_StreamEndPoint
00379  *
00380  * Base class for the A/V StreamEndPoint class. this class
00381  * is used to control the stream. It should be subclassed
00382  * by applications that want to provide more control features.
00383  */
00384 class TAO_AV_Export TAO_Base_StreamEndPoint
00385   :public virtual TAO_PropertySet
00386 {
00387 
00388   // @@Naga: Rename this class to TAO_Base_EndPoint since both stream and flowendpoints derive from it.
00389 public:
00390   TAO_Base_StreamEndPoint (void);
00391   virtual ~TAO_Base_StreamEndPoint (void);
00392 
00393   /// called when streamendpoint is instantiated
00394   virtual int handle_open (void);
00395 
00396   /// called when streamendpoint is being destructed
00397   virtual int handle_close (void);
00398 
00399   /// Application needs to define this
00400   virtual int handle_stop (const AVStreams::flowSpec &the_spec);
00401 
00402   /// Application needs to define this
00403   virtual int handle_start (const AVStreams::flowSpec &the_spec);
00404 
00405   /// Application needs to define this
00406   virtual int handle_destroy (const AVStreams::flowSpec &the_spec);
00407 
00408   /// Application needs to define this
00409   virtual CORBA::Boolean handle_preconnect (AVStreams::flowSpec &the_spec);
00410 
00411   /// Application needs to define this
00412   virtual CORBA::Boolean handle_postconnect (AVStreams::flowSpec &the_spec);
00413 
00414   /// Application needs to define this
00415   virtual CORBA::Boolean handle_connection_requested (AVStreams::flowSpec &the_spec);
00416 
00417   virtual int get_callback (const char *flowname,
00418                             TAO_AV_Callback *&callback);
00419 
00420   virtual int get_control_callback (const char *flowname,
00421                                     TAO_AV_Callback *&callback);
00422 
00423   virtual int set_protocol_object (const char *flowname,
00424                                    TAO_AV_Protocol_Object *object);
00425 
00426   virtual void set_flow_handler (const char *flowname,
00427                                  TAO_AV_Flow_Handler *handler);
00428 
00429   virtual void set_control_flow_handler (const char *flowname,
00430                                          TAO_AV_Flow_Handler *handler);
00431 
00432   TAO_AV_QoS &qos (void);
00433 
00434   void protocol_object_set (void);
00435   int is_protocol_object_set (void);
00436 
00437 protected:
00438 
00439   TAO_AV_QoS qos_;
00440   Flow_Handler_Map flow_handler_map_;
00441   Flow_Handler_Map control_flow_handler_map_;
00442   int protocol_object_set_;
00443 };
00444 
00445 // Forward declarations.
00446 class TAO_AV_Acceptor;
00447 class TAO_AV_Connector;
00448 class TAO_Forward_FlowSpec_Entry;
00449 class TAO_Reverse_FlowSpec_Entry;
00450 
00451 /**
00452  * @class TAO_StreamEndPoint
00453  * @brief The Stream EndPoint. Used to implement one endpoint of a stream
00454  *        that implements the transport layer.
00455  */
00456 class TAO_AV_Export TAO_StreamEndPoint
00457   : public virtual POA_AVStreams::StreamEndPoint,
00458     public virtual TAO_Base_StreamEndPoint
00459 {
00460 
00461 public:
00462   /// Constructor
00463   TAO_StreamEndPoint (void);
00464 
00465    /// Stop the stream. Empty the_spec means, for all the flows
00466   virtual void stop (const AVStreams::flowSpec &the_spec);
00467 
00468   /// Start the stream, Empty the_spec means, for all the flows
00469   virtual void start (const AVStreams::flowSpec &the_spec);
00470 
00471   /// Destroy the stream, Empty the_spec means, for all the flows
00472   virtual void destroy (const AVStreams::flowSpec &the_spec);
00473 
00474   /// Called by StreamCtrl. responder is the peer to connect to
00475   virtual CORBA::Boolean connect (AVStreams::StreamEndPoint_ptr responder,
00476                                   AVStreams::streamQoS& qos_spec,
00477                                   const AVStreams::flowSpec& the_spec);
00478 
00479   /// Called by the peer StreamEndPoint. The flow_spec indicates the
00480   /// flows (which contain transport addresses etc.)
00481   virtual CORBA::Boolean request_connection (AVStreams::StreamEndPoint_ptr initiator,
00482                                              CORBA::Boolean is_mcast,
00483                                              AVStreams::streamQoS &qos,
00484                                              AVStreams::flowSpec &the_spec);
00485 
00486   /// Change the transport qos on a stream
00487   virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &new_qos,
00488                                      const AVStreams::flowSpec &the_flows);
00489 
00490   virtual int change_qos (AVStreams::streamQoS &new_qos,
00491                           const AVStreams::flowSpec &the_flows);
00492 
00493   /// Used to restrict the set of protocols
00494   virtual CORBA::Boolean set_protocol_restriction (const AVStreams::protocolSpec &the_pspec);
00495 
00496   /// disconnect the flows
00497   virtual void disconnect (const AVStreams::flowSpec &the_spec);
00498 
00499   /// Used to control the flow
00500   virtual void set_FPStatus (const AVStreams::flowSpec &the_spec,
00501                              const char *fp_name,
00502                              const CORBA::Any &fp_settings);
00503 
00504   /// Not implemented in the light profile, throws notsupported
00505   virtual CORBA::Object_ptr get_fep (const char *flow_name);
00506 
00507   /// Not implemented in the light profile, throws notsupported
00508   virtual char * add_fep (CORBA::Object_ptr the_fep);
00509 
00510   /// Not implemented in the light profile, throws notsupported
00511   virtual void remove_fep (const char *fep_name);
00512 
00513   /// Used to "attach" a negotiator to the endpoint
00514   virtual void set_negotiator (AVStreams::Negotiator_ptr new_negotiator);
00515 
00516   /// Used for public key encryption.
00517   virtual void set_key (const char *flow_name,
00518                         const AVStreams::key & the_key);
00519 
00520   /// Used to set a unique id for packets sent by this streamendpoint
00521   virtual void set_source_id (CORBA::Long source_id);
00522 
00523   /// Destructor
00524   virtual ~TAO_StreamEndPoint (void);
00525 
00526   CORBA::Boolean multiconnect (AVStreams::streamQoS &the_qos,
00527                                AVStreams::flowSpec &the_spec);
00528 
00529 protected:
00530   /// Helper methods to implement add_fep()
00531   char* add_fep_i (AVStreams::FlowEndPoint_ptr fep);
00532   char* add_fep_i_add_property (AVStreams::FlowEndPoint_ptr fep);
00533 
00534   /// translate from application level to network level qos.
00535   int translate_qos (const AVStreams::streamQoS& application_qos,
00536                      AVStreams::streamQoS& network_qos);
00537 
00538   /// Count of the number of flows in this streamendpoint, used to
00539   /// generate unique names for the flows.
00540   u_int flow_count_;
00541 
00542   /// current flow number used for system generation of flow names.
00543   u_int flow_num_;
00544 
00545   /// hash table for the flownames and its corresponding flowEndpoint reference.
00546   FlowEndPoint_Map fep_map_;
00547 
00548   /// sequence of supported flow names.
00549   AVStreams::flowSpec flows_;
00550 
00551   /// source id used for multicast.
00552   CORBA::Long source_id_;
00553 
00554   /// our local negotiator for QoS.
00555   AVStreams::Negotiator_var negotiator_;
00556 
00557   /// Our available list of protocols.
00558   AVStreams::protocolSpec protocols_;
00559 
00560   /// Chosen protocol for this streamendpoint based on availableprotocols property.
00561   CORBA::String_var protocol_;
00562 
00563   /// Key used for encryption.
00564   AVStreams::key key_;
00565 
00566 ///   TAO_Forward_FlowSpec_Entry forward_entries_ [FLOWSPEC_MAX];
00567 ///   TAO_Reverse_FlowSpec_Entry reverse_entries_ [FLOWSPEC_MAX];
00568   u_short mcast_port_;
00569   ACE_CString mcast_addr_;
00570   ACE_Hash_Map_Manager <ACE_CString, TAO_FlowSpec_Entry*,ACE_Null_Mutex> mcast_entry_map_;
00571   TAO_AV_FlowSpecSet forward_flow_spec_set;
00572   TAO_AV_FlowSpecSet reverse_flow_spec_set;
00573   AVStreams::StreamEndPoint_var peer_sep_;
00574   AVStreams::SFPStatus *sfp_status_;
00575   AVStreams::StreamCtrl_var streamctrl_;
00576 };
00577 
00578 /**
00579  * @class TAO_StreamEndPoint_A
00580  * @brief  The "A" side of a streamendpoint
00581  */
00582 class TAO_AV_Export TAO_StreamEndPoint_A :
00583   public virtual POA_AVStreams::StreamEndPoint_A,
00584   public virtual TAO_StreamEndPoint
00585 {
00586 
00587 public:
00588   /// Constructor
00589   TAO_StreamEndPoint_A (void);
00590 
00591   /// Used for ATM-style multicast
00592   virtual CORBA::Boolean multiconnect (AVStreams::streamQoS &the_qos,
00593                                        AVStreams::flowSpec &the_spec);
00594 
00595   /// Used for ATM-style multicast
00596   virtual CORBA::Boolean connect_leaf (AVStreams::StreamEndPoint_B_ptr the_ep,
00597                                        AVStreams::streamQoS &the_qos,
00598                                        const AVStreams::flowSpec &the_flows);
00599 
00600   /// Used to remove a multicast leaf
00601   virtual void disconnect_leaf (AVStreams::StreamEndPoint_B_ptr the_ep,
00602                                 const AVStreams::flowSpec &theSpec);
00603 
00604   /// Destructor
00605   virtual ~TAO_StreamEndPoint_A (void);
00606 
00607 };
00608 
00609 // For backward compatibility.
00610 #define TAO_Client_StreamEndPoint TAO_StreamEndPoint_A
00611 #define TAO_Server_StreamEndPoint TAO_StreamEndPoint_B
00612 
00613 /**
00614  * @class TAO_StreamEndPoint_B
00615  * @brief The "B" side of a streamendpoint
00616  */
00617 class TAO_AV_Export TAO_StreamEndPoint_B :
00618   public virtual POA_AVStreams::StreamEndPoint_B,
00619   public virtual TAO_StreamEndPoint
00620 {
00621   // = DESCRIPTION
00622   //     The "B" side of a streamendpoint
00623 public:
00624   /// Constructor
00625   TAO_StreamEndPoint_B (void);
00626 
00627   /// Used for internet-style multicast
00628   virtual CORBA::Boolean multiconnect (AVStreams::streamQoS &the_qos,
00629                                        AVStreams::flowSpec &the_spec);
00630 
00631   /// Destructor
00632   virtual ~TAO_StreamEndPoint_B (void);
00633 };
00634 
00635 /**
00636  * @class TAO_VDev
00637  * @brief Implements the VDev interface. One of these is created per
00638  *        connection, and represents device-specific parameters.
00639  */
00640 class TAO_AV_Export TAO_VDev
00641   :public virtual TAO_PropertySet,
00642    public virtual POA_AVStreams::VDev
00643 {
00644 
00645 public:
00646   /// Default Constructor
00647   TAO_VDev (void);
00648 
00649   /// Called to tell the vdev who the streamctrl, peer vdev is
00650   virtual CORBA::Boolean set_peer (AVStreams::StreamCtrl_ptr the_ctrl,
00651                                    AVStreams::VDev_ptr the_peer_dev,
00652                                    AVStreams::streamQoS &the_qos,
00653                                    const AVStreams::flowSpec &the_spec);
00654 
00655   /// Used to set the streamctrl and multicast device
00656   virtual CORBA::Boolean set_Mcast_peer (AVStreams::StreamCtrl_ptr the_ctrl,
00657                                          AVStreams::MCastConfigIf_ptr a_mcastconfigif,
00658                                          AVStreams::streamQoS &the_qos,
00659                                          const AVStreams::flowSpec &the_spec);
00660 
00661   /// Called by the peer VDev to configure the device (catch all)
00662   virtual void configure (const CosPropertyService::Property &the_config_mesg);
00663 
00664   /// Used to set a format on a flowname
00665   virtual void set_format (const char *flowName,
00666                            const char *format_name);
00667 
00668   /// Used to set device parameters
00669   virtual void set_dev_params (const char *flowName,
00670                                const CosPropertyService::Properties &new_params);
00671 
00672   /// Called to change QoS of the device
00673   virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &the_qos,
00674                                      const AVStreams::flowSpec &the_spec);
00675 
00676 protected:
00677   /// Destructor for a servant should be protected or private.
00678   /// Use _remove_ref() to delete this servant.
00679   virtual ~TAO_VDev (void);
00680 
00681   /// hook called after set_peer is done to set the media ctrl of the peer vdev.
00682   virtual CORBA::Boolean set_media_ctrl (CORBA::Object_ptr media_ctrl);
00683 
00684   /// My stream controller
00685   AVStreams::StreamCtrl_var streamctrl_;
00686 
00687   /// My peer
00688   AVStreams::VDev_var peer_;
00689 
00690   /// The multicast VDev peer.
00691   AVStreams::MCastConfigIf_var mcast_peer_;
00692 };
00693 
00694 class TAO_AV_Endpoint_Strategy;
00695 
00696 /**
00697  * @class TAO_MMDevice
00698  * @brief Implements a factory to create Endpoints and VDevs
00699  */
00700 class TAO_AV_Export TAO_MMDevice
00701   :public virtual POA_AVStreams::MMDevice,
00702    public virtual TAO_PropertySet
00703 {
00704 
00705 public:
00706 
00707   /// Constructor
00708   enum MMDevice_Type {MMDEVICE_A = 0,MMDEVICE_B = 1};
00709   TAO_MMDevice (TAO_AV_Endpoint_Strategy *endpoint_strategy_);
00710 
00711   virtual AVStreams::StreamEndPoint_ptr create_A_B (MMDevice_Type type,
00712                                                     AVStreams::StreamCtrl_ptr the_requester,
00713                                                      AVStreams::VDev_out the_vdev,
00714                                                      AVStreams::streamQoS &the_qos,
00715                                                      CORBA::Boolean_out met_qos,
00716                                                      char *&named_vdev,
00717                                                      const AVStreams::flowSpec &the_spec);
00718 
00719   /// Can be used to request the MMDevice to create a new StreamCtrl,
00720   /// and call bind_devs on it
00721   virtual AVStreams::StreamCtrl_ptr  bind (AVStreams::MMDevice_ptr peer_device,
00722                                            AVStreams::streamQoS &the_qos,
00723                                            CORBA::Boolean_out is_met,
00724                                            const AVStreams::flowSpec &the_spec);
00725 
00726   /// Multicast bind
00727   virtual AVStreams::StreamCtrl_ptr  bind_mcast (AVStreams::MMDevice_ptr first_peer,
00728                                                  AVStreams::streamQoS &the_qos,
00729                                                  CORBA::Boolean_out is_met,
00730                                                  const AVStreams::flowSpec &the_spec);
00731 
00732   /// Called by StreamCtrl to create a "A" type streamandpoint and vdev
00733   virtual AVStreams::StreamEndPoint_A_ptr  create_A (AVStreams::StreamCtrl_ptr the_requester,
00734                                                      AVStreams::VDev_out the_vdev,
00735                                                      AVStreams::streamQoS &the_qos,
00736                                                      CORBA::Boolean_out met_qos,
00737                                                      char *&named_vdev,
00738                                                      const AVStreams::flowSpec &the_spec);
00739 
00740   /// Called by StreamCtrl to create a "B" type streamandpoint and vdev
00741   virtual AVStreams::StreamEndPoint_B_ptr  create_B (AVStreams::StreamCtrl_ptr the_requester,
00742                                                      AVStreams::VDev_out the_vdev,
00743                                                      AVStreams::streamQoS &the_qos,
00744                                                      CORBA::Boolean_out met_qos,
00745                                                      char *&named_vdev,
00746                                                      const AVStreams::flowSpec &the_spec);
00747 
00748   /// Remove the StreamEndPoint and the related vdev
00749   virtual void destroy (AVStreams::StreamEndPoint_ptr the_ep,
00750                         const char *vdev_name);
00751 
00752   /// Not supported in the light profile, raises notsupported
00753   virtual char * add_fdev (CORBA::Object_ptr the_fdev);
00754 
00755   /// Not supported in the light profile, raises notsupported
00756   virtual CORBA::Object_ptr get_fdev (const char *flow_name);
00757 
00758   /// Not supported in the light profile, raises notsupported
00759   virtual void remove_fdev (const char *flow_name);
00760 
00761   /// Destructor
00762   virtual ~TAO_MMDevice (void);
00763 
00764 protected:
00765   /// Helper method to implement add_fdev()
00766   char* add_fdev_i (AVStreams::FDev_ptr fdev);
00767 
00768 protected:
00769 
00770   TAO_AV_Endpoint_Strategy *endpoint_strategy_;
00771 
00772   /// Count of the number of flows in this MMDevice , used to
00773   /// generate unique names for the flows.
00774   u_int flow_count_;
00775 
00776   /// current flow number used for system generation of flow names.
00777   u_int flow_num_;
00778 
00779   typedef ACE_Hash_Map_Manager <ACE_CString,AVStreams::FDev_var,ACE_Null_Mutex> FDev_Map;
00780   typedef ACE_Hash_Map_Iterator <ACE_CString,AVStreams::FDev_var,ACE_Null_Mutex> FDev_Map_Iterator;
00781   typedef ACE_Hash_Map_Entry <ACE_CString,AVStreams::FDev_var> FDev_Map_Entry;
00782 
00783   /// hash table for the flownames and its corresponding flowEndpoint
00784   /// reference.
00785   FDev_Map fdev_map_;
00786 
00787   /// sequence of supported flow names.
00788   AVStreams::flowSpec flows_;
00789 
00790   TAO_StreamCtrl *stream_ctrl_;
00791 };
00792 
00793 class TAO_FlowConsumer;
00794 class TAO_FlowProducer;
00795 
00796 /**
00797  * @class TAO_FlowConnection
00798  * @brief This class currently supports only one producer and one
00799  *        consumer per flow.
00800  */
00801 class TAO_AV_Export TAO_FlowConnection
00802  : public virtual POA_AVStreams::FlowConnection,
00803    public virtual TAO_PropertySet
00804 {
00805 
00806 public:
00807   /// default constructor.
00808   TAO_FlowConnection (void);
00809 
00810   /// stop this flow.
00811   virtual void stop (void);
00812 
00813   /// start this flow.
00814   virtual void start (void);
00815 
00816   /// destroy this flow.
00817   virtual void destroy (void);
00818 
00819   /// modify the QoS for this flow.
00820   virtual CORBA::Boolean modify_QoS (AVStreams::QoS & new_qos);
00821 
00822   /// use the specified flow protocol for this flow.
00823   virtual CORBA::Boolean use_flow_protocol (const char * fp_name,
00824                                             const CORBA::Any & fp_settings);
00825 
00826   /// pushes an event , to be handled by the application.
00827   virtual void push_event (const AVStreams::streamEvent & the_event);
00828 
00829 
00830   /// connect 2 Flow Devices.
00831   virtual CORBA::Boolean connect_devs (AVStreams::FDev_ptr a_party,
00832                                        AVStreams::FDev_ptr b_party,
00833                                        AVStreams::QoS & the_qos);
00834 
00835   /// Connect a flow producer and consumer under this flow connection.
00836   virtual CORBA::Boolean connect (AVStreams::FlowProducer_ptr flow_producer,
00837                                   AVStreams::FlowConsumer_ptr flow_consumer,
00838                                   AVStreams::QoS & the_qos);
00839 
00840   /// disconnect this flow connection.
00841   virtual CORBA::Boolean disconnect (void);
00842 
00843   /// adds the producer to this flow connection.
00844   virtual CORBA::Boolean add_producer (AVStreams::FlowProducer_ptr flow_producer,
00845                                        AVStreams::QoS & the_qos);
00846 
00847   /// adds a consumer to this flow connection.
00848   virtual CORBA::Boolean add_consumer (AVStreams::FlowConsumer_ptr flow_consumer,
00849                                        AVStreams::QoS & the_qos);
00850 
00851   /// drops a flow endpoint from the flow.
00852   virtual CORBA::Boolean drop (AVStreams::FlowEndPoint_ptr target);
00853 
00854   int set_mcast_addr (ACE_CString addr,u_short port);
00855   void set_protocol (const char *protocol);
00856 protected:
00857   typedef ACE_Unbounded_Set<AVStreams::FlowProducer_ptr> FlowProducer_Set;
00858   typedef ACE_Unbounded_Set_Iterator<AVStreams::FlowProducer_ptr> FlowProducer_SetItor;
00859   typedef ACE_Unbounded_Set<AVStreams::FlowConsumer_ptr> FlowConsumer_Set;
00860   typedef ACE_Unbounded_Set_Iterator<AVStreams::FlowConsumer_ptr> FlowConsumer_SetItor;
00861 
00862   /// The multicast address returned by the producer.
00863   FlowProducer_Set flow_producer_set_;
00864   FlowConsumer_Set flow_consumer_set_;
00865   CORBA::String_var fp_name_;
00866   CORBA::Any fp_settings_;
00867   CORBA::String_var producer_address_;
00868 
00869   /// IP Multicasting is used.
00870   int ip_multicast_;
00871   TAO_MCastConfigIf *mcastconfigif_i_;
00872   AVStreams::MCastConfigIf_var mcastconfigif_;
00873   u_short mcast_port_;
00874   ACE_CString mcast_addr_;
00875   CORBA::String_var protocol_;
00876 };
00877 
00878 /**
00879  * @class TAO_FlowEndPoint
00880  * @brief This class is used per flow e.g video flow and an audio flow
00881  *        to encapsulate the transport details.
00882  */
00883 class TAO_AV_Export TAO_FlowEndPoint :
00884   public virtual POA_AVStreams::FlowEndPoint,
00885   public virtual TAO_Base_StreamEndPoint
00886 {
00887 
00888 public:
00889 
00890   ///default constructor.
00891   TAO_FlowEndPoint (void);
00892 
00893   TAO_FlowEndPoint (const char *flowname,
00894                     AVStreams::protocolSpec &protocols,
00895                     const char *format);
00896 
00897   int open (const char *flowname,
00898             AVStreams::protocolSpec &protocols,
00899             const char *format);
00900 
00901   int set_flowname (const char *flowname);
00902 
00903   virtual void set_flow_handler (const char *flowname,
00904                                  TAO_AV_Flow_Handler *handler);
00905 
00906   virtual int set_protocol_object (const char *flowname,
00907                                    TAO_AV_Protocol_Object *object);
00908 
00909   /// lock the flow endpoint for a particular flow.
00910   virtual CORBA::Boolean lock (void);
00911 
00912   /// unlock the flow endpoint for subsequent use.
00913   virtual void unlock (void);
00914 
00915 
00916   /// destroy this flow.
00917   virtual void destroy (void);
00918 
00919   /// get method for the related streamendpoint under which this
00920   /// flowendpoint is.
00921   virtual AVStreams::StreamEndPoint_ptr related_sep(void);
00922 
00923   /// set method for the related streamendpoint under which this
00924   /// flowendpoint is.
00925   virtual void related_sep (AVStreams::StreamEndPoint_ptr related_sep);
00926 
00927   virtual AVStreams::FlowConnection_ptr related_flow_connection(void);
00928 
00929   // accessor for the related flow connection attribute.
00930 
00931   /// set method for the related flow connection attribute.
00932   virtual void related_flow_connection (AVStreams::FlowConnection_ptr related_flow_connection);
00933 
00934   /// returns the other flowendpoint to which this is connected.
00935   virtual AVStreams::FlowEndPoint_ptr get_connected_fep (void);
00936 
00937   //// use the specified flow protocol.
00938   virtual CORBA::Boolean use_flow_protocol (const char * fp_name,
00939                                             const CORBA::Any & fp_settings);
00940 
00941   /// sets the data format.
00942   virtual void set_format (const char * format);
00943 
00944   /// sets the device parameters.
00945   virtual void set_dev_params (const CosPropertyService::Properties & new_settings);
00946 
00947   /// sets the list of protocols to be used.
00948   virtual void set_protocol_restriction (const AVStreams::protocolSpec & the_spec);
00949 
00950   /// checks whether the passed flowendpoint is compatible with this.
00951   virtual CORBA::Boolean is_fep_compatible (AVStreams::FlowEndPoint_ptr fep);
00952 
00953   /// sets the peer flowendpoint.
00954   virtual CORBA::Boolean set_peer (AVStreams::FlowConnection_ptr the_fc,
00955                                    AVStreams::FlowEndPoint_ptr the_peer_fep,
00956                                    AVStreams::QoS & the_qos);
00957 
00958   /// sets the multicast peer flowendpoint, not implemented.
00959   virtual CORBA::Boolean set_Mcast_peer (AVStreams::FlowConnection_ptr the_fc,
00960                                          AVStreams::MCastConfigIf_ptr a_mcastconfigif,
00961                                          AVStreams::QoS & the_qos);
00962 
00963 
00964   /**
00965    * This should be implemented in both the FlowProducer and consumer and hence is
00966    * pure virtual since we need to know the role of the flowendpoint to create appropriate
00967    * protocol objects. eg. in SFP to create Producer Object/ Consumer Object.
00968    */
00969   virtual CORBA::Boolean connect_to_peer (AVStreams::QoS & the_qos,
00970                                           const char * address,
00971                                           const char * use_flow_protocol)
00972     = 0;
00973 
00974   /// connect to the peer endpoint.
00975   virtual CORBA::Boolean connect_to_peer_i (TAO_FlowSpec_Entry::Role role,
00976                                             AVStreams::QoS & the_qos,
00977                                             const char * address,
00978                                             const char * use_flow_protocol);
00979 
00980   /**
00981    * This should be implemented in both the FlowProducer and consumer and hence is
00982    * pure virtual since we need to know the role of the flowendpoint to create appropriate
00983    * protocol objects. eg. in SFP to create Producer Object/ Consumer Object.
00984    */
00985   virtual char * go_to_listen (AVStreams::QoS & the_qos,
00986                                CORBA::Boolean is_mcast,
00987                                AVStreams::FlowEndPoint_ptr peer,
00988                                char *& flowProtocol)
00989     = 0;
00990 
00991   /// listen request from the peer.
00992   virtual char * go_to_listen_i (TAO_FlowSpec_Entry::Role role,
00993                                  AVStreams::QoS & the_qos,
00994                                  CORBA::Boolean is_mcast,
00995                                  AVStreams::FlowEndPoint_ptr peer,
00996                                  char *& flowProtocol);
00997 
00998 
00999 protected:
01000   /// The related streamendpoint.
01001   AVStreams::StreamEndPoint_var related_sep_;
01002 
01003   /// The related flow connection reference
01004   AVStreams::FlowConnection_var related_flow_connection_;
01005 
01006   /// The peer flowendpoint reference.
01007   AVStreams::FlowEndPoint_var peer_fep_;
01008 
01009   /// Available protocols for this flowendpoint.
01010   AVStreams::protocolSpec protocols_;
01011 
01012   /// Address information for the protocols.
01013   AVStreams::protocolSpec protocol_addresses_;
01014 
01015   /// The multicast peer endpoint.
01016   AVStreams::MCastConfigIf_var mcast_peer_;
01017 
01018   /// Lock.
01019   CORBA::Boolean lock_;
01020 
01021   CORBA::String_var format_;
01022   CORBA::String_var flowname_;
01023   CosPropertyService::Properties dev_params_;
01024   TAO_AV_FlowSpecSet flow_spec_set_;
01025   CORBA::String_var reverse_channel_;
01026 };
01027 
01028 class TAO_AV_Export TAO_FlowProducer:
01029   public virtual POA_AVStreams::FlowProducer,
01030   public virtual TAO_FlowEndPoint
01031 {
01032 public:
01033   /// default constructor
01034   TAO_FlowProducer (void);
01035 
01036   TAO_FlowProducer (const char *flowname,
01037                     AVStreams::protocolSpec protocols,
01038                     const char *format);
01039 
01040   /**
01041    * get the reverse channel, to be used for feedback for protocols like UDP.
01042    * @@Naga: In the spec this is defined in the TAO_FlowProducer but it seems more reasonable for this
01043    * to be in a FlowEndPoint since any of the flowendpoints can be made to listen. So in the case of
01044    * UDP if the producer is listening and the consumer connects (logically) then the producer needs to
01045    * know the reverse channel on its peer fep to send data to.
01046    */
01047   virtual char * get_rev_channel (const char * pcol_name);
01048 
01049   /// stop this flow, to be overridden by the application.
01050   virtual void stop (void);
01051 
01052   /// start this flow, to be overridden by the application.
01053   virtual void start (void);
01054 
01055   virtual char * go_to_listen (AVStreams::QoS & the_qos,
01056                                CORBA::Boolean is_mcast,
01057                                AVStreams::FlowEndPoint_ptr peer,
01058                                char *& flowProtocol);
01059 
01060   virtual CORBA::Boolean connect_to_peer (AVStreams::QoS & the_qos,
01061                                           const char * address,
01062                                           const char * use_flow_protocol);
01063 
01064   /// connect to the multicast address, not implemented.
01065   virtual char * connect_mcast (AVStreams::QoS & the_qos,
01066                                 CORBA::Boolean_out is_met,
01067                                 const char * address,
01068                                 const char * use_flow_protocol);
01069 
01070 
01071 
01072   /// sets the public key  to be used for encryption of the data.
01073   virtual void set_key (const AVStreams::key & the_key);
01074 
01075   /// sets the source id of this flow producer so that it can be used
01076   /// to distinguish this producer from others in the multicast case.
01077   virtual void set_source_id (CORBA::Long source_id);
01078 
01079 protected:
01080   /// source id of this producer.
01081   CORBA::Long source_id_;
01082   CORBA::String_var peer_address_;
01083 };
01084 
01085 class TAO_AV_Export TAO_FlowConsumer :
01086   public virtual POA_AVStreams::FlowConsumer,
01087   public virtual TAO_FlowEndPoint
01088 {
01089 public:
01090   /// default constructor.
01091   TAO_FlowConsumer (void);
01092 
01093   TAO_FlowConsumer (const char *flowname,
01094                     AVStreams::protocolSpec protocols,
01095                     const char *format);
01096 
01097   /// stop this flow, to be overridden by the application.
01098   virtual void stop (void);
01099 
01100   /// start this flow, to be overridden by the application.
01101   virtual void start (void);
01102 
01103   virtual char * go_to_listen (AVStreams::QoS & the_qos,
01104                                CORBA::Boolean is_mcast,
01105                                AVStreams::FlowEndPoint_ptr peer,
01106                                char *& flowProtocol);
01107 
01108   virtual CORBA::Boolean connect_to_peer (AVStreams::QoS & the_qos,
01109                                           const char * address,
01110                                           const char * use_flow_protocol);
01111 };
01112 
01113 /**
01114  * @class TAO_MediaControl
01115  * @brief Abstract Mediacontrol class.
01116  *        The following are to be handled by the specialized media control
01117  *        for the specific media like camera, speaker.
01118  */
01119 class TAO_AV_Export TAO_MediaControl
01120   :public virtual POA_AVStreams::MediaControl
01121 {
01122 
01123 public:
01124   /// default constructor
01125   TAO_MediaControl (void);
01126 
01127   virtual AVStreams::Position get_media_position (AVStreams::PositionOrigin an_origin,
01128                                                   AVStreams::PositionKey a_key)
01129     =0;
01130 
01131   virtual void set_media_position (const AVStreams::Position & a_position)
01132     =0;
01133 
01134   virtual void start (const AVStreams::Position & a_position)
01135     =0;
01136 
01137   virtual void pause (const AVStreams::Position & a_position)
01138     =0;
01139 
01140   virtual void resume (const AVStreams::Position & a_position)
01141     =0;
01142 
01143   virtual void stop (const AVStreams::Position & a_position)
01144     =0;
01145 
01146 };
01147 
01148 TAO_END_VERSIONED_NAMESPACE_DECL
01149 
01150 #include "orbsvcs/AV/Transport.h"
01151 
01152 #if defined (__ACE_INLINE__)
01153 #include "tao/debug.h"
01154 #include "orbsvcs/AV/AVStreams_i.inl"
01155 #endif /* __ACE_INLINE__ */
01156 
01157 #include "orbsvcs/AV/Flows_T.h"
01158 
01159 #include /**/ "ace/post.h"
01160 #endif /* AVSTREAMS_I_H */

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