TAO_AV_UDP_Connector Class Reference

#include <UDP.h>

Inheritance diagram for TAO_AV_UDP_Connector:

Inheritance graph
[legend]
Collaboration diagram for TAO_AV_UDP_Connector:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_AV_UDP_Connector (void)
 ~TAO_AV_UDP_Connector (void)
virtual int open (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, TAO_AV_Flow_Protocol_Factory *factory)
virtual int connect (TAO_FlowSpec_Entry *entry, TAO_AV_Transport *&transport, TAO_AV_Core::Flow_Component flow_comp=TAO_AV_Core::TAO_AV_DATA)
virtual int activate_svc_handler (TAO_AV_Flow_Handler *handler)
virtual int close (void)

Protected Attributes

ACE_INET_Addrcontrol_inet_address_
TAO_Base_StreamEndPointendpoint_
TAO_AV_Coreav_core_
TAO_FlowSpec_Entryentry_
TAO_AV_Flow_Protocol_Factoryflow_protocol_factory_
TAO_AV_Core::Flow_Component flow_component_

Constructor & Destructor Documentation

TAO_AV_UDP_Connector::TAO_AV_UDP_Connector void   ) 
 

Definition at line 567 of file UDP.cpp.

00568   : control_inet_address_ (0)
00569 {
00570 }

TAO_AV_UDP_Connector::~TAO_AV_UDP_Connector void   ) 
 

Definition at line 572 of file UDP.cpp.

References TAO_FlowSpec_Entry::control_handler().

00573 {
00574   if (this->flow_component_ == TAO_AV_Core::TAO_AV_CONTROL)
00575     {
00576       delete this->entry_->control_handler ();
00577     }
00578 
00579   if (this->control_inet_address_ != 0)
00580     delete this->control_inet_address_;
00581 }


Member Function Documentation

int TAO_AV_UDP_Connector::activate_svc_handler TAO_AV_Flow_Handler handler  )  [virtual]
 

Definition at line 764 of file UDP.cpp.

References TAO_AV_Flow_Handler::event_handler(), TAO_AV_Core::reactor(), and TAO_AV_Flow_Handler::schedule_timer().

Referenced by connect().

00765 {
00766   ACE_Event_Handler *event_handler = handler->event_handler ();
00767   int result = this->av_core_->reactor ()->register_handler (event_handler,
00768                                                              ACE_Event_Handler::READ_MASK);
00769 
00770   if (this->flow_component_ == TAO_AV_Core::TAO_AV_CONTROL)
00771     handler->schedule_timer ();
00772 
00773   return result;
00774 }

int TAO_AV_UDP_Connector::close void   )  [virtual]
 

Implements TAO_AV_Connector.

Definition at line 777 of file UDP.cpp.

00778 {
00779   return 0;
00780 }

int TAO_AV_UDP_Connector::connect TAO_FlowSpec_Entry entry,
TAO_AV_Transport *&  transport,
TAO_AV_Core::Flow_Component  flow_comp = TAO_AV_Core::TAO_AV_DATA
[virtual]
 

Implements TAO_AV_Connector.

Definition at line 597 of file UDP.cpp.

References ACE_CString, ACE_DEBUG, ACE_NEW_RETURN, activate_svc_handler(), ACE_INET_Addr::addr_to_string(), TAO_FlowSpec_Entry::control_handler(), TAO_FlowSpec_Entry::control_protocol_object(), TAO_AV_Core::get_control_flowname(), ACE_INET_Addr::get_host_name(), TAO_FlowSpec_Entry::get_local_control_addr(), ACE_INET_Addr::get_port_number(), ACE_OS::itoa(), LM_DEBUG, TAO_AV_Flow_Protocol_Factory::make_protocol_object(), TAO_FlowSpec_Entry::protocol_object(), TAO_AV_Flow_Handler::protocol_object(), TAO_Base_StreamEndPoint::set_control_flow_handler(), TAO_Base_StreamEndPoint::set_flow_handler(), TAO_FlowSpec_Entry::set_local_control_addr(), TAO_AV_Flow_Handler::set_remote_address(), TAO_AV_UDP_Connection_Setup::setup(), ACE_OS::strcasecmp(), TAO_debug_level, and TAO_AV_Flow_Handler::transport().

00600 {
00601   ACE_INET_Addr *local_addr = 0;
00602   ACE_INET_Addr *control_inet_addr = 0;
00603 
00604   this->entry_ = entry;
00605   this->flow_component_ = flow_component;
00606 
00607   ACE_INET_Addr *inet_addr;
00608 
00609   if (flow_component == TAO_AV_Core::TAO_AV_CONTROL)
00610     {
00611       this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname());
00612     inet_addr = dynamic_cast<ACE_INET_Addr*> (entry->control_address ());
00613     }
00614   else
00615     {
00616       this->flowname_ = entry->flowname ();
00617       inet_addr = dynamic_cast<ACE_INET_Addr*> (entry->address ());
00618       control_inet_addr = dynamic_cast<ACE_INET_Addr*> (entry->control_address ());
00619     }
00620 
00621   TAO_AV_Flow_Handler *flow_handler = 0;
00622 
00623   // if this is the control flow component, the
00624   //  handler and local address are already set in the flow spec entry
00625   if ((flow_component == TAO_AV_Core::TAO_AV_CONTROL)  &&
00626       (ACE_OS::strcasecmp(this->entry_->flow_protocol_str (), "RTP") == 0) &&
00627       !entry->is_multicast ())
00628     {
00629       flow_handler = this->entry_->control_handler ();
00630       flow_handler->set_remote_address (inet_addr);
00631 
00632       local_addr = dynamic_cast<ACE_INET_Addr*> (this->entry_->get_local_control_addr ());
00633     }
00634   else
00635     {
00636       // this variable is only used for RTP/UDP; RFC 1889 requires an even/odd
00637       //  consecutive port pair
00638       int get_new_port = 1;
00639 
00640       while (get_new_port)
00641         {
00642           // assume the ports will be OK
00643           get_new_port = 0;
00644 
00645           ACE_Addr *addr;
00646           if ((addr = entry->get_peer_addr ()) != 0)
00647             {
00648               local_addr = dynamic_cast<ACE_INET_Addr*> (addr);
00649               char buf [BUFSIZ];
00650               local_addr->addr_to_string (buf, BUFSIZ);
00651             }
00652 
00653           TAO_AV_UDP_Connection_Setup::setup (flow_handler,
00654                                               inet_addr,
00655                                               local_addr,
00656                                               entry->is_multicast (),
00657                                               TAO_AV_UDP_Connection_Setup::CONNECTOR);
00658 
00659           if ((ACE_OS::strcasecmp(this->entry_->flow_protocol_str (), "RTP") == 0) &&
00660               (flow_component == TAO_AV_Core::TAO_AV_DATA) &&
00661               !entry->is_multicast ())
00662             {
00663               if (local_addr->get_port_number ()%2 != 0)
00664                 {
00665                   // RTP port should be even
00666                   delete local_addr;
00667                   delete flow_handler;
00668                   get_new_port = 1;
00669                 }
00670               else
00671                 {
00672                   ACE_INET_Addr *local_control_addr;
00673                   TAO_AV_Flow_Handler *control_flow_handler = 0;
00674 
00675                   if (entry->is_multicast ())
00676                     control_inet_addr =  dynamic_cast<ACE_INET_Addr*> (entry->control_address ()) ;
00677                   else
00678                     {
00679 
00680                       if (local_addr != 0)
00681                         {
00682                           char buf [BUFSIZ];
00683                           ACE_CString addr_str (local_addr->get_host_name ());
00684                           addr_str += ":";
00685                           addr_str += ACE_OS::itoa (local_addr->get_port_number () + 1, buf, 10);
00686                           ACE_NEW_RETURN (local_control_addr,
00687                                           ACE_INET_Addr (addr_str.c_str ()),
00688                                           -1);
00689                           local_control_addr->addr_to_string (buf, BUFSIZ);
00690                         }
00691 
00692 
00693                       if (entry->control_address () == 0)
00694                         ACE_NEW_RETURN (this->control_inet_address_,
00695                                         ACE_INET_Addr ("0"),
00696                                         -1);
00697                       else
00698                         control_inet_address_ = dynamic_cast<ACE_INET_Addr*> (entry->control_address ());
00699                     }
00700 
00701                   TAO_AV_UDP_Connection_Setup::setup (control_flow_handler,
00702                                                       control_inet_addr,
00703                                                       local_control_addr,
00704                                                       entry->is_multicast (),
00705                                                       TAO_AV_UDP_Connection_Setup::CONNECTOR);
00706 
00707                   if (local_control_addr->get_port_number () !=
00708                       local_addr->get_port_number () +1)
00709                     {
00710                       delete local_addr;
00711                       delete flow_handler;
00712                       delete local_control_addr;
00713                       delete control_flow_handler;
00714                       get_new_port = 1;
00715                     }
00716                   else
00717                     {
00718                       this->entry_->set_local_control_addr (local_control_addr);
00719                       this->entry_->control_handler (control_flow_handler);
00720                     }
00721                 }
00722             }
00723         }
00724     }
00725 
00726   TAO_AV_Protocol_Object *object =
00727     this->flow_protocol_factory_->make_protocol_object (this->entry_,
00728                                                         this->endpoint_,
00729                                                         flow_handler,
00730                                                         flow_handler->transport ());
00731 
00732   flow_handler->protocol_object (object);
00733 
00734   if (flow_component == TAO_AV_Core::TAO_AV_DATA)
00735     {
00736       this->endpoint_->set_flow_handler (this->flowname_.c_str (),
00737                                          flow_handler);
00738       this->entry_->protocol_object (object);
00739       entry->set_local_addr (local_addr);
00740       entry->handler (flow_handler);
00741       transport = flow_handler->transport ();
00742     }
00743   else
00744     {
00745       this->endpoint_->set_control_flow_handler (this->flowname_.c_str (),
00746                                                  flow_handler);
00747       this->entry_->control_protocol_object (object);
00748       entry->set_local_control_addr (local_addr);
00749       entry->control_handler (flow_handler);
00750       transport = flow_handler->transport ();
00751     }
00752 
00753   char buf[BUFSIZ];
00754   local_addr->addr_to_string (buf,BUFSIZ);
00755 
00756   if (TAO_debug_level > 0)
00757     ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_CONNECTOR::connect:%s \n",buf));
00758 
00759   // call activate svc handler.
00760   return this->activate_svc_handler (flow_handler);
00761 }

int TAO_AV_UDP_Connector::open TAO_Base_StreamEndPoint endpoint,
TAO_AV_Core av_core,
TAO_AV_Flow_Protocol_Factory factory
[virtual]
 

Implements TAO_AV_Connector.

Definition at line 584 of file UDP.cpp.

References ACE_DEBUG, LM_DEBUG, and TAO_debug_level.

00588 {
00589   if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_Connector::open "));
00590   this->endpoint_ = endpoint;
00591   this->av_core_ = av_core;
00592   this->flow_protocol_factory_ = factory;
00593   return 0;
00594 }


Member Data Documentation

TAO_AV_Core* TAO_AV_UDP_Connector::av_core_ [protected]
 

Definition at line 201 of file UDP.h.

ACE_INET_Addr* TAO_AV_UDP_Connector::control_inet_address_ [protected]
 

Definition at line 199 of file UDP.h.

TAO_Base_StreamEndPoint* TAO_AV_UDP_Connector::endpoint_ [protected]
 

Definition at line 200 of file UDP.h.

TAO_FlowSpec_Entry* TAO_AV_UDP_Connector::entry_ [protected]
 

Definition at line 202 of file UDP.h.

TAO_AV_Core::Flow_Component TAO_AV_UDP_Connector::flow_component_ [protected]
 

Definition at line 204 of file UDP.h.

TAO_AV_Flow_Protocol_Factory* TAO_AV_UDP_Connector::flow_protocol_factory_ [protected]
 

Definition at line 203 of file UDP.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:48:12 2006 for TAO_AV by doxygen 1.3.6