Public Member Functions | Protected Attributes

TAO_AV_UDP_Acceptor Class Reference

#include <UDP.h>

Inheritance diagram for TAO_AV_UDP_Acceptor:
Inheritance graph
[legend]
Collaboration diagram for TAO_AV_UDP_Acceptor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_AV_UDP_Acceptor (void)
virtual ~TAO_AV_UDP_Acceptor (void)
virtual int open (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, TAO_FlowSpec_Entry *entry, TAO_AV_Flow_Protocol_Factory *factory, TAO_AV_Core::Flow_Component flow_comp=TAO_AV_Core::TAO_AV_DATA)
virtual int open_default (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, TAO_FlowSpec_Entry *entry, TAO_AV_Flow_Protocol_Factory *factory, TAO_AV_Core::Flow_Component flow_comp=TAO_AV_Core::TAO_AV_DATA)
virtual int open_i (ACE_INET_Addr *address, int is_default_open)
virtual int close (void)
virtual int activate_svc_handler (TAO_AV_Flow_Handler *handler)

Protected Attributes

ACE_INET_Addraddress_
ACE_INET_Addrcontrol_inet_address_
TAO_Base_StreamEndPointendpoint_
TAO_FlowSpec_Entryentry_
TAO_AV_Flow_Protocol_Factoryflow_protocol_factory_
TAO_AV_Core::Flow_Component flow_component_

Detailed Description

Definition at line 141 of file UDP.h.


Constructor & Destructor Documentation

TAO_AV_UDP_Acceptor::TAO_AV_UDP_Acceptor ( void   ) 

Definition at line 325 of file UDP.cpp.

TAO_AV_UDP_Acceptor::~TAO_AV_UDP_Acceptor ( void   )  [virtual]

Definition at line 331 of file UDP.cpp.

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

  delete this->address_;
  delete this->control_inet_address_;
}


Member Function Documentation

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

Definition at line 341 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_Acceptor::close ( void   )  [virtual]

Implements TAO_AV_Acceptor.

Definition at line 563 of file UDP.cpp.

{
  return 0;
}

int TAO_AV_UDP_Acceptor::open ( TAO_Base_StreamEndPoint endpoint,
TAO_AV_Core av_core,
TAO_FlowSpec_Entry entry,
TAO_AV_Flow_Protocol_Factory factory,
TAO_AV_Core::Flow_Component  flow_comp = TAO_AV_Core::TAO_AV_DATA 
) [virtual]

Implements TAO_AV_Acceptor.

Definition at line 354 of file UDP.cpp.

{
  if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_UDP_Acceptor::open\n"));
  this->av_core_ = av_core;
  this->endpoint_ = endpoint;
  this->entry_ = entry;
  this->flow_component_ = flow_comp;
  this->flow_protocol_factory_ = factory;
  ACE_INET_Addr *inet_addr;
  if (flow_comp == TAO_AV_Core::TAO_AV_CONTROL)
    {
      this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname ());
      inet_addr = (ACE_INET_Addr *) entry->control_address ();
    }
  else
    {
      this->flowname_ = entry->flowname ();
      inet_addr = (ACE_INET_Addr *) entry->address ();
    }

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

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

  int result = this->open_i (inet_addr, 0);

  if (result < 0)
    return result;
  return 0;
}

int TAO_AV_UDP_Acceptor::open_default ( TAO_Base_StreamEndPoint endpoint,
TAO_AV_Core av_core,
TAO_FlowSpec_Entry entry,
TAO_AV_Flow_Protocol_Factory factory,
TAO_AV_Core::Flow_Component  flow_comp = TAO_AV_Core::TAO_AV_DATA 
) [virtual]

Implements TAO_AV_Acceptor.

Definition at line 397 of file UDP.cpp.

{
  this->av_core_ = av_core;
  this->endpoint_ = endpoint;
  this->entry_ = entry;
  this->flow_component_ = flow_comp;
  this->flow_protocol_factory_ = factory;
  if (flow_comp == TAO_AV_Core::TAO_AV_CONTROL)
    {
      this->flowname_ = TAO_AV_Core::get_control_flowname (entry->flowname ());
    }
  else
    {
      this->flowname_ = entry->flowname ();
      ACE_NEW_RETURN (this->address_,
                    ACE_INET_Addr ("0"),
                    -1);
    }

  int result = this->open_i (this->address_, 1);
  if (result < 0)
    return result;

  return 0;
}

int TAO_AV_UDP_Acceptor::open_i ( ACE_INET_Addr address,
int  is_default_open 
) [virtual]

Definition at line 428 of file UDP.cpp.

{
  int result = -1;
  ACE_INET_Addr *local_addr = 0;

  TAO_AV_Flow_Handler *flow_handler = 0;

  // if using a default address and this is the control flow component, the
  //  handler and local address are already set in the flow spec entry
  if (is_default_addr &&
      (this->flow_component_ == TAO_AV_Core::TAO_AV_CONTROL)  &&
      (ACE_OS::strcasecmp(this->entry_->flow_protocol_str (), "RTP") == 0))
    {
      flow_handler = this->entry_->control_handler ();

      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;

          result = TAO_AV_UDP_Connection_Setup::setup (flow_handler,
                                                       inet_addr,
                                                       local_addr,
                                                       this->entry_->is_multicast (),
                                                       TAO_AV_UDP_Connection_Setup::ACCEPTOR);

        if (result < 0)
          {
             ACE_DEBUG((LM_DEBUG,"(%N,%l) Error during connection setup: %d\n", result));
          }

          local_addr->set (local_addr->get_port_number (),
                           local_addr->get_host_name ());

          if (is_default_addr)
            {
              if ((ACE_OS::strcasecmp(this->entry_->flow_protocol_str (), "RTP") == 0) &&
                  (this->flow_component_ == TAO_AV_Core::TAO_AV_DATA))
                {
                  if (is_default_addr && 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;

                      ACE_NEW_RETURN (this->control_inet_address_,
                                      ACE_INET_Addr ("0"),
                                      -1);

                      TAO_AV_UDP_Connection_Setup::setup(control_flow_handler,
                                                         this->control_inet_address_,
                                                         local_control_addr,
                                                         this->entry_->is_multicast (),
                                                         TAO_AV_UDP_Connection_Setup::ACCEPTOR);

                      if (local_control_addr->get_port_number () !=
                          local_addr->get_port_number () +1)
                        {
                          delete this->control_inet_address_;
                          delete local_addr;
                          local_addr = 0;
                          delete flow_handler;
                          delete local_control_addr;
                          delete control_flow_handler;
                          get_new_port = 1;
                        }
                      else
                        {
                          this->entry_->control_address (this->control_inet_address_);
                          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 (this->flow_component_ == TAO_AV_Core::TAO_AV_DATA)
    {
      this->endpoint_->set_flow_handler (this->flowname_.c_str (),flow_handler);

      this->entry_->protocol_object (object);
      this->entry_->set_local_addr (local_addr);
      this->entry_->handler (flow_handler);
      //this->entry_->address (inet_addr);
      this->entry_->address (local_addr);
    }
  else
    {
      this->endpoint_->set_control_flow_handler (this->flowname_.c_str (),flow_handler);

      this->entry_->control_protocol_object (object);
      this->entry_->set_local_control_addr (local_addr);
      this->entry_->control_handler (flow_handler);
    }

  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_ACCEPTOR::open:%s\n",
                    buf));
    }

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


Member Data Documentation

Reimplemented from TAO_AV_Acceptor.

Definition at line 168 of file UDP.h.

Definition at line 169 of file UDP.h.

Definition at line 170 of file UDP.h.

Definition at line 171 of file UDP.h.

Definition at line 173 of file UDP.h.

Definition at line 172 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