Public Member Functions | Protected Attributes

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_

Detailed Description

Definition at line 182 of file UDP.h.


Constructor & Destructor Documentation

TAO_AV_UDP_Connector::TAO_AV_UDP_Connector ( void   ) 

Definition at line 571 of file UDP.cpp.

TAO_AV_UDP_Connector::~TAO_AV_UDP_Connector ( void   ) 

Definition at line 576 of file UDP.cpp.

{
  if (this->flow_component_ == TAO_AV_Core::TAO_AV_CONTROL)
    {
      delete this->entry_->control_handler ();
    }

  if (this->control_inet_address_ != 0)
    delete this->control_inet_address_;
}


Member Function Documentation

int TAO_AV_UDP_Connector::activate_svc_handler ( TAO_AV_Flow_Handler handler  )  [virtual]

Definition at line 773 of file UDP.cpp.

{
  ACE_Event_Handler *event_handler = handler->event_handler ();
  int result = this->av_core_->reactor ()->register_handler (event_handler,
                                                             ACE_Event_Handler::READ_MASK);

  if (this->flow_component_ == TAO_AV_Core::TAO_AV_CONTROL)
    handler->schedule_timer ();

  return result;
}

int TAO_AV_UDP_Connector::close ( void   )  [virtual]

Implements TAO_AV_Connector.

Definition at line 786 of file UDP.cpp.

{
  return 0;
}

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 601 of file UDP.cpp.

{
  ACE_INET_Addr *local_addr = 0;
  ACE_INET_Addr *control_inet_addr = 0;

  this->entry_ = entry;
  this->flow_component_ = flow_component;

  ACE_INET_Addr *inet_addr;

  if (flow_component == TAO_AV_Core::TAO_AV_CONTROL)
    {
      this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname());
    inet_addr = dynamic_cast<ACE_INET_Addr*> (entry->control_address ());
    }
  else
    {
      this->flowname_ = entry->flowname ();
      inet_addr = dynamic_cast<ACE_INET_Addr*> (entry->address ());
      control_inet_addr = dynamic_cast<ACE_INET_Addr*> (entry->control_address ());
    }

  TAO_AV_Flow_Handler *flow_handler = 0;

  // if this is the control flow component, the
  //  handler and local address are already set in the flow spec entry
  if ((flow_component == TAO_AV_Core::TAO_AV_CONTROL)  &&
      (ACE_OS::strcasecmp(this->entry_->flow_protocol_str (), "RTP") == 0) &&
      !entry->is_multicast ())
    {
      flow_handler = this->entry_->control_handler ();
      flow_handler->set_remote_address (inet_addr);

      local_addr = dynamic_cast<ACE_INET_Addr*> (this->entry_->get_local_control_addr ());
    }
  else
    {
      // this variable is only used for RTP/UDP; RFC 1889 requires an even/odd
      //  consecutive port pair
      int get_new_port = 1;

      while (get_new_port)
        {
          // assume the ports will be OK
          get_new_port = 0;

          ACE_Addr *addr;
          if ((addr = entry->get_peer_addr ()) != 0)
            {
              local_addr = dynamic_cast<ACE_INET_Addr*> (addr);
              ACE_TCHAR buf [BUFSIZ];
              local_addr->addr_to_string (buf, BUFSIZ);
            }

          TAO_AV_UDP_Connection_Setup::setup (flow_handler,
                                              inet_addr,
                                              local_addr,
                                              entry->is_multicast (),
                                              TAO_AV_UDP_Connection_Setup::CONNECTOR);

          if ((ACE_OS::strcasecmp(this->entry_->flow_protocol_str (), "RTP") == 0) &&
              (flow_component == TAO_AV_Core::TAO_AV_DATA) &&
              !entry->is_multicast ())
            {
              if (local_addr->get_port_number ()%2 != 0)
                {
                  // RTP port should be even
                  delete local_addr;
                  local_addr = 0;
                  delete flow_handler;
                  get_new_port = 1;
                }
              else
                {
                  ACE_INET_Addr *local_control_addr = 0;
                  TAO_AV_Flow_Handler *control_flow_handler = 0;

                  if (entry->is_multicast ())
                    control_inet_addr =  dynamic_cast<ACE_INET_Addr*> (entry->control_address ()) ;
                  else
                    {

                      if (local_addr != 0)
                        {
                          ACE_TCHAR buf [BUFSIZ];
                          ACE_TString addr_str (ACE_TEXT_CHAR_TO_TCHAR(local_addr->get_host_name ()));
                          addr_str += ACE_TEXT(":");
                          addr_str += ACE_OS::itoa (local_addr->get_port_number () + 1, buf, 10);
                          ACE_NEW_RETURN (local_control_addr,
                                          ACE_INET_Addr (addr_str.c_str ()),
                                          -1);
                          local_control_addr->addr_to_string (buf, BUFSIZ);
                        }


                      if (entry->control_address () == 0)
                        ACE_NEW_RETURN (this->control_inet_address_,
                                        ACE_INET_Addr ("0"),
                                        -1);
                      else
                        control_inet_address_ = dynamic_cast<ACE_INET_Addr*> (entry->control_address ());
                    }

                  TAO_AV_UDP_Connection_Setup::setup (control_flow_handler,
                                                      control_inet_addr,
                                                      local_control_addr,
                                                      entry->is_multicast (),
                                                      TAO_AV_UDP_Connection_Setup::CONNECTOR);

                  if (local_control_addr->get_port_number () !=
                      local_addr->get_port_number () +1)
                    {
                      delete local_addr;
                      local_addr = 0;
                      delete flow_handler;
                      delete local_control_addr;
                      delete control_flow_handler;
                      get_new_port = 1;
                    }
                  else
                    {
                      this->entry_->set_local_control_addr (local_control_addr);
                      this->entry_->control_handler (control_flow_handler);
                    }
                }
            }
        }
    }

  TAO_AV_Protocol_Object *object =
    this->flow_protocol_factory_->make_protocol_object (this->entry_,
                                                        this->endpoint_,
                                                        flow_handler,
                                                        flow_handler->transport ());

  flow_handler->protocol_object (object);

  if (flow_component == TAO_AV_Core::TAO_AV_DATA)
    {
      this->endpoint_->set_flow_handler (this->flowname_.c_str (),
                                         flow_handler);
      this->entry_->protocol_object (object);
      entry->set_local_addr (local_addr);
      entry->handler (flow_handler);
      transport = flow_handler->transport ();
    }
  else
    {
      this->endpoint_->set_control_flow_handler (this->flowname_.c_str (),
                                                 flow_handler);
      this->entry_->control_protocol_object (object);
      entry->set_local_control_addr (local_addr);
      entry->control_handler (flow_handler);
      transport = flow_handler->transport ();
    }

  if (local_addr != 0)
    {
      ACE_TCHAR buf[BUFSIZ];
      local_addr->addr_to_string (buf,BUFSIZ);

      if (TAO_debug_level > 0)
        ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_CONNECTOR::connect:%s\n",buf));
    }

  // call activate svc handler.
  return this->activate_svc_handler (flow_handler);
}

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 588 of file UDP.cpp.

{
  if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_Connector::open "));
  this->endpoint_ = endpoint;
  this->av_core_ = av_core;
  this->flow_protocol_factory_ = factory;
  return 0;
}


Member Data Documentation

Definition at line 201 of file UDP.h.

Definition at line 199 of file UDP.h.

Definition at line 200 of file UDP.h.

Definition at line 202 of file UDP.h.

Definition at line 204 of file UDP.h.

Definition at line 203 of file UDP.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines