TAO_MMDevice Class Reference

Implements a factory to create Endpoints and VDevs. More...

#include <AVStreams_i.h>

Collaboration diagram for TAO_MMDevice:

Collaboration graph
[legend]
List of all members.

Public Types

 MMDEVICE_A = 0
 MMDEVICE_B = 1
enum  MMDevice_Type { MMDEVICE_A = 0, MMDEVICE_B = 1 }
 Constructor. More...

Public Member Functions

 TAO_MMDevice (TAO_AV_Endpoint_Strategy *endpoint_strategy_)
virtual AVStreams::StreamEndPoint_ptr create_A_B (MMDevice_Type type, AVStreams::StreamCtrl_ptr the_requester, AVStreams::VDev_out the_vdev, AVStreams::streamQoS &the_qos, CORBA::Boolean_out met_qos, char *&named_vdev, const AVStreams::flowSpec &the_spec)
virtual AVStreams::StreamCtrl_ptr bind (AVStreams::MMDevice_ptr peer_device, AVStreams::streamQoS &the_qos, CORBA::Boolean_out is_met, const AVStreams::flowSpec &the_spec)
virtual AVStreams::StreamCtrl_ptr bind_mcast (AVStreams::MMDevice_ptr first_peer, AVStreams::streamQoS &the_qos, CORBA::Boolean_out is_met, const AVStreams::flowSpec &the_spec)
 Multicast bind.
virtual AVStreams::StreamEndPoint_A_ptr create_A (AVStreams::StreamCtrl_ptr the_requester, AVStreams::VDev_out the_vdev, AVStreams::streamQoS &the_qos, CORBA::Boolean_out met_qos, char *&named_vdev, const AVStreams::flowSpec &the_spec)
 Called by StreamCtrl to create a "A" type streamandpoint and vdev.
virtual AVStreams::StreamEndPoint_B_ptr create_B (AVStreams::StreamCtrl_ptr the_requester, AVStreams::VDev_out the_vdev, AVStreams::streamQoS &the_qos, CORBA::Boolean_out met_qos, char *&named_vdev, const AVStreams::flowSpec &the_spec)
 Called by StreamCtrl to create a "B" type streamandpoint and vdev.
virtual void destroy (AVStreams::StreamEndPoint_ptr the_ep, const char *vdev_name)
 Remove the StreamEndPoint and the related vdev.
virtual char * add_fdev (CORBA::Object_ptr the_fdev)
 Not supported in the light profile, raises notsupported.
virtual CORBA::Object_ptr get_fdev (const char *flow_name)
 Not supported in the light profile, raises notsupported.
virtual void remove_fdev (const char *flow_name)
 Not supported in the light profile, raises notsupported.
virtual ~TAO_MMDevice (void)
 Destructor.

Protected Types

typedef ACE_Hash_Map_Manager<
ACE_CString, AVStreams::FDev_var,
ACE_Null_Mutex
FDev_Map
typedef ACE_Hash_Map_Iterator<
ACE_CString, AVStreams::FDev_var,
ACE_Null_Mutex
FDev_Map_Iterator
typedef ACE_Hash_Map_Entry<
ACE_CString, AVStreams::FDev_var > 
FDev_Map_Entry

Protected Member Functions

char * add_fdev_i (AVStreams::FDev_ptr fdev)
 Helper method to implement add_fdev().

Protected Attributes

TAO_AV_Endpoint_Strategyendpoint_strategy_
u_int flow_count_
u_int flow_num_
 current flow number used for system generation of flow names.
FDev_Map fdev_map_
AVStreams::flowSpec flows_
 sequence of supported flow names.
TAO_StreamCtrlstream_ctrl_

Detailed Description

Implements a factory to create Endpoints and VDevs.

Definition at line 700 of file AVStreams_i.h.


Member Typedef Documentation

typedef ACE_Hash_Map_Manager<ACE_CString,AVStreams::FDev_var,ACE_Null_Mutex> TAO_MMDevice::FDev_Map [protected]

Definition at line 779 of file AVStreams_i.h.

typedef ACE_Hash_Map_Entry<ACE_CString,AVStreams::FDev_var> TAO_MMDevice::FDev_Map_Entry [protected]

Definition at line 781 of file AVStreams_i.h.

typedef ACE_Hash_Map_Iterator<ACE_CString,AVStreams::FDev_var,ACE_Null_Mutex> TAO_MMDevice::FDev_Map_Iterator [protected]

Definition at line 780 of file AVStreams_i.h.


Member Enumeration Documentation

enum TAO_MMDevice::MMDevice_Type

Constructor.

Enumerator:
MMDEVICE_A 
MMDEVICE_B 

Definition at line 708 of file AVStreams_i.h.

00708 {MMDEVICE_A = 0,MMDEVICE_B = 1};


Constructor & Destructor Documentation

TAO_MMDevice::TAO_MMDevice ( TAO_AV_Endpoint_Strategy endpoint_strategy_  ) 

Definition at line 2928 of file AVStreams_i.cpp.

02929   : endpoint_strategy_ (endpoint_strategy),
02930     flow_count_ (0),
02931     flow_num_ (0),
02932     stream_ctrl_ (0)
02933 {
02934 }

TAO_MMDevice::~TAO_MMDevice ( void   )  [virtual]

Destructor.

Definition at line 3341 of file AVStreams_i.cpp.

References stream_ctrl_.

03342 {
03343   delete this->stream_ctrl_;
03344 }


Member Function Documentation

char * TAO_MMDevice::add_fdev ( CORBA::Object_ptr  the_fdev  )  [virtual]

Not supported in the light profile, raises notsupported.

Definition at line 3246 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), add_fdev_i(), flow_count_, flows_, CORBA::is_nil(), and CORBA::string_dup().

03247 {
03248   CORBA::String_var flow_name;
03249   AVStreams::FDev_var fdev;
03250   try
03251     {
03252       CORBA::Any_ptr flow_name_any;
03253       fdev = AVStreams::FDev::_narrow (fdev_obj);
03254 
03255       if (CORBA::is_nil (fdev.in ()))
03256           return 0;
03257 
03258 
03259       flow_name_any = fdev->get_property_value ("Flow");
03260 
03261       const char *tmp;
03262       *flow_name_any >>= tmp;
03263       flow_name = CORBA::string_dup (tmp);
03264     }
03265   catch (const CORBA::Exception&)
03266     {
03267       flow_name =
03268         this->add_fdev_i (fdev.in ());
03269     }
03270 
03271 
03272   // Add it to the sequence of flowNames supported.
03273   // put the flowname and the fdev in a hashtable.
03274   ACE_CString fdev_name_key ( flow_name.in () );
03275 
03276 
03277   if ( (this->fdev_map_.bind (fdev_name_key, fdev )) != 0)
03278     throw AVStreams::streamOpFailed ();
03279   // increment the flow count.
03280   this->flow_count_++;
03281   this->flows_.length (this->flow_count_);
03282   this->flows_ [this->flow_count_-1] = flow_name;
03283   // define/modify the "Flows" property.
03284   CORBA::Any flows_any;
03285   flows_any <<= this->flows_;
03286   try
03287     {
03288       this->define_property ("Flows",
03289                              flows_any);
03290     }
03291   catch (const CORBA::Exception& ex)
03292     {
03293       ex._tao_print_exception ("TAO_MMDevice::add_fdev");
03294       return 0;
03295     }
03296   return flow_name._retn ();
03297 }

char * TAO_MMDevice::add_fdev_i ( AVStreams::FDev_ptr  fdev  )  [protected]

Helper method to implement add_fdev().

Definition at line 3219 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_NEW_RETURN, flow_num_, and ACE_OS::sprintf().

Referenced by add_fdev().

03220 {
03221   char* tmp;
03222   ACE_NEW_RETURN (tmp,
03223                   char[64],
03224                   0);
03225   CORBA::String_var flow_name = tmp;
03226 
03227   try
03228     {
03229       // exception implies the flow name is not defined and is system
03230       // generated.
03231       ACE_OS::sprintf (tmp, "flow%d", flow_num_++);
03232       CORBA::Any flowname_any;
03233       flowname_any <<= flow_name.in ();
03234       fdev->define_property ("Flow", flowname_any);
03235     }
03236   catch (const CORBA::Exception& ex)
03237     {
03238       ex._tao_print_exception ("TAO_MMDevice::add_fdev");
03239       return 0;
03240     }
03241   return flow_name._retn ();
03242 }

AVStreams::StreamCtrl_ptr TAO_MMDevice::bind ( AVStreams::MMDevice_ptr  peer_device,
AVStreams::streamQoS the_qos,
CORBA::Boolean_out  is_met,
const AVStreams::flowSpec the_spec 
) [virtual]

Can be used to request the MMDevice to create a new StreamCtrl, and call bind_devs on it

Definition at line 2939 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_NEW_RETURN, TAO_StreamCtrl::bind_devs(), and stream_ctrl_.

02943 {
02944   AVStreams::StreamCtrl_ptr streamctrl (AVStreams::StreamCtrl::_nil ());
02945   try
02946     {
02947       ACE_UNUSED_ARG (is_met);
02948       ACE_NEW_RETURN (this->stream_ctrl_,
02949                       TAO_StreamCtrl,
02950                       0);
02951       AVStreams::MMDevice_var mmdevice = this->_this ();
02952       this->stream_ctrl_->bind_devs (peer_device,
02953                                      mmdevice.in (),
02954                                      the_qos,
02955                                      the_spec);
02956       streamctrl = this->stream_ctrl_->_this ();
02957     }
02958   catch (const CORBA::Exception& ex)
02959     {
02960       ex._tao_print_exception ("TAO_MMDevice::bind");
02961       return streamctrl;
02962     }
02963   return streamctrl;
02964 }

AVStreams::StreamCtrl_ptr TAO_MMDevice::bind_mcast ( AVStreams::MMDevice_ptr  first_peer,
AVStreams::streamQoS the_qos,
CORBA::Boolean_out  is_met,
const AVStreams::flowSpec the_spec 
) [virtual]

Multicast bind.

Definition at line 2968 of file AVStreams_i.cpp.

02972 {
02973   ACE_UNUSED_ARG (first_peer);
02974   ACE_UNUSED_ARG (the_qos);
02975   ACE_UNUSED_ARG (is_met);
02976   ACE_UNUSED_ARG (the_spec);
02977 
02978   return 0;
02979 }

AVStreams::StreamEndPoint_A_ptr TAO_MMDevice::create_A ( AVStreams::StreamCtrl_ptr  the_requester,
AVStreams::VDev_out  the_vdev,
AVStreams::streamQoS the_qos,
CORBA::Boolean_out  met_qos,
char *&  named_vdev,
const AVStreams::flowSpec the_spec 
) [virtual]

Called by StreamCtrl to create a "A" type streamandpoint and vdev.

Definition at line 3152 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ASSERT, create_A_B(), CORBA::is_nil(), and MMDEVICE_A.

03158 {
03159   AVStreams::StreamEndPoint_A_ptr sep_a = 0;
03160   AVStreams::StreamEndPoint_var sep;
03161   try
03162     {
03163       sep = this->create_A_B (MMDEVICE_A, streamctrl, the_vdev, stream_qos, met_qos, named_vdev, flow_spec);
03164       sep_a = AVStreams::StreamEndPoint_A::_narrow (sep.in());
03165 
03166       ACE_ASSERT( !CORBA::is_nil( sep_a ) );
03167     }
03168   catch (const CORBA::Exception& ex)
03169     {
03170       ex._tao_print_exception ("TAO_MMDevice::create_A");
03171       return sep_a;
03172     }
03173 
03174   return sep_a;
03175 }

AVStreams::StreamEndPoint_ptr TAO_MMDevice::create_A_B ( MMDevice_Type  type,
AVStreams::StreamCtrl_ptr  the_requester,
AVStreams::VDev_out  the_vdev,
AVStreams::streamQoS the_qos,
CORBA::Boolean_out  met_qos,
char *&  named_vdev,
const AVStreams::flowSpec the_spec 
) [virtual]

Definition at line 2982 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_DEBUG, ACE_ERROR_RETURN, ACE_NEW_RETURN, fdev_map_, ACE_Hash_Map_Manager_Ex< EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK >::find(), TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), LM_DEBUG, LM_ERROR, MMDEVICE_A, MMDEVICE_B, ACE_OS::printf(), TAO_FlowSpec_Entry::TAO_AV_DIR_IN, TAO_FlowSpec_Entry::TAO_AV_DIR_OUT, and TAO_debug_level.

Referenced by create_A(), and create_B().

02989 {
02990   AVStreams::StreamEndPoint_A_ptr sep_a (AVStreams::StreamEndPoint_A::_nil ());
02991   AVStreams::StreamEndPoint_B_ptr sep_b (AVStreams::StreamEndPoint_B::_nil ());
02992   AVStreams::StreamEndPoint_ptr sep (AVStreams::StreamEndPoint::_nil ());
02993   try
02994     {
02995       switch (type)
02996         {
02997         case MMDEVICE_A:
02998           {
02999             if (this->endpoint_strategy_->create_A (sep_a,
03000                                                     the_vdev) == -1)
03001               ACE_ERROR_RETURN ((LM_ERROR,
03002                                  "TAO_MMDevice::create_A_B (%P|%t) - "
03003                                  "error in create_A\n"),
03004                                 0);
03005             sep = sep_a;
03006           }
03007           break;
03008         case MMDEVICE_B:
03009           {
03010             if (this->endpoint_strategy_->create_B (sep_b,
03011                                                     the_vdev) == -1)
03012               ACE_ERROR_RETURN ((LM_ERROR,
03013                                  "TAO_MMDevice::create_A_B (%P|%t) - "
03014                                  "error in create_B\n"),
03015                                 0);
03016             sep = sep_b;
03017           }
03018           break;
03019         default:
03020           break;
03021         }
03022       if (this->fdev_map_.current_size () > 0)
03023         {
03024           TAO_AV_QoS qos (the_qos);
03025           // create flowendpoints from the FDevs.
03026           for (u_int i=0;i<flow_spec.length ();i++)
03027             {
03028               TAO_Forward_FlowSpec_Entry forward_entry;
03029               forward_entry.parse (flow_spec[i]);
03030               ACE_CString flow_key (forward_entry.flowname ());
03031               AVStreams::FDev_var flow_dev;
03032               AVStreams::FlowConnection_var flowconnection;
03033               try
03034                 {
03035                   // Get the flowconnection for this flow.
03036                   //static int blah = 0; if(blah == 1){blah=0; abort();}else{blah=1;}
03037                   CORBA::Object_var flowconnection_obj =
03038                     streamctrl->get_flow_connection (forward_entry.flowname ());
03039                   ACE_OS::printf("successfully called get_flow_connection\n");
03040                   if (!CORBA::is_nil (flowconnection_obj.in ()))
03041                     {
03042                       flowconnection = AVStreams::FlowConnection::_narrow (flowconnection_obj.in ());
03043                     }
03044                 }
03045               catch (const AVStreams::noSuchFlow&)
03046                 {
03047                           TAO_FlowConnection *flowConnection;
03048                           ACE_NEW_RETURN (flowConnection,
03049                                           TAO_FlowConnection,
03050                                           0);
03051                           flowconnection = flowConnection->_this ();
03052                           streamctrl->set_flow_connection (forward_entry.flowname(),
03053                                                      flowconnection.in ());
03054                 }
03055               catch (const CORBA::Exception& ex)
03056                 {
03057                   //if (TAO_debug_level >= 0)
03058                     ex._tao_print_exception (
03059                       "TAO_MMDevice::create_a::get_flow_connection");
03060                 }
03061 
03062               int result = this->fdev_map_.find (flow_key, flow_dev);
03063               if (result < 0)
03064                 ACE_ERROR_RETURN ((LM_ERROR, "(%N,%l) fdev_map::find failed\n"), 0);
03065 
03066               CORBA::String_var named_fdev;
03067               AVStreams::FlowEndPoint_var flow_endpoint;
03068               AVStreams::QoS flow_qos;
03069               result = qos.get_flow_qos (forward_entry.flowname (), flow_qos);
03070               if (result < 0)
03071                 if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "(%N,%l) get_flow_qos failed for %s\n", forward_entry.flowname ()));
03072               switch (forward_entry.direction ())
03073                 {
03074                 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
03075                   {
03076                     switch (type)
03077                       {
03078                       case MMDEVICE_A:
03079                         {
03080                           // In implies flow is from A to B and
03081                           // hence A is the producer for this flow and B is the consumer for this flow.
03082                           // We have to create a producer from the FDev for this flow.
03083                           flow_endpoint =
03084                             flow_dev->create_producer (flowconnection.in (),
03085                                                        flow_qos,
03086                                                        met_qos,
03087                                                        named_fdev.inout ());
03088                         }
03089                         break;
03090                       case MMDEVICE_B:
03091                         {
03092                           flow_endpoint =
03093                             flow_dev->create_consumer (flowconnection.in (),
03094                                                        flow_qos,
03095                                                        met_qos,
03096                                                        named_fdev.inout ());
03097                         }
03098                         break;
03099                       }
03100                   }
03101                   break;
03102                 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
03103                   {
03104                     switch (type)
03105                       {
03106                       case MMDEVICE_A:
03107                         {
03108                           // OUT implies flow is from B to A and
03109                           // hence B is the producer for this flow and A is the consumer for this flow.
03110                           // We have to create a consumer from the FDev for this flow.
03111                           flow_endpoint =
03112                             flow_dev->create_consumer (flowconnection.in (),
03113                                                        flow_qos,
03114                                                        met_qos,
03115                                                        named_fdev.inout ());
03116                         }
03117                         break;
03118                       case MMDEVICE_B:
03119                         {
03120                           // In implies flow is from A to B and
03121                           // hence A is the producer for this flow and B is the consumer for this flow.
03122                           // We have to create a producer from the FDev for this flow.
03123                           flow_endpoint =
03124                             flow_dev->create_producer (flowconnection.in (),
03125                                                        flow_qos,
03126                                                        met_qos,
03127                                                        named_fdev.inout ());
03128                         }
03129                         break;
03130                       }
03131                   }
03132                   break;
03133                 default:
03134                   break;
03135                 }
03136               CORBA::Any flowname_any;
03137               flowname_any <<= forward_entry.flowname ();
03138               flow_endpoint->define_property ("FlowName", flowname_any);
03139               sep->add_fep (flow_endpoint.in ());
03140             }
03141         }
03142     }
03143   catch (const CORBA::Exception& ex)
03144     {
03145       ex._tao_print_exception ("TAO_MMDevice::create_A");
03146       return sep;
03147     }
03148   return sep;
03149 }

AVStreams::StreamEndPoint_B_ptr TAO_MMDevice::create_B ( AVStreams::StreamCtrl_ptr  the_requester,
AVStreams::VDev_out  the_vdev,
AVStreams::streamQoS the_qos,
CORBA::Boolean_out  met_qos,
char *&  named_vdev,
const AVStreams::flowSpec the_spec 
) [virtual]

Called by StreamCtrl to create a "B" type streamandpoint and vdev.

Definition at line 3179 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), ACE_ASSERT, create_A_B(), CORBA::is_nil(), and MMDEVICE_B.

03185 {
03186   AVStreams::StreamEndPoint_B_ptr sep_b = AVStreams::StreamEndPoint_B::_nil ();
03187   AVStreams::StreamEndPoint_var sep;
03188 
03189   try
03190     {
03191       sep = this->create_A_B (MMDEVICE_B, streamctrl, the_vdev, stream_qos, met_qos, named_vdev, flow_spec);
03192       sep_b = AVStreams::StreamEndPoint_B::_narrow (sep.in());
03193 
03194       ACE_ASSERT ( !CORBA::is_nil( sep_b ) );
03195     }
03196   catch (const CORBA::Exception& ex)
03197     {
03198       ex._tao_print_exception ("TAO_MMDevice::create_B");
03199       return sep_b;
03200     }
03201   return sep_b;
03202 }

void TAO_MMDevice::destroy ( AVStreams::StreamEndPoint_ptr  the_ep,
const char *  vdev_name 
) [virtual]

Remove the StreamEndPoint and the related vdev.

Definition at line 3207 of file AVStreams_i.cpp.

References ACE_DEBUG, TAO_AV_Core::deactivate_servant(), LM_DEBUG, and TAO_debug_level.

03209 {
03210   // Remove self from POA.  Because of reference counting, the POA
03211   // will automatically delete the servant when all pending requests
03212   // on this servant are complete.
03213   int result = TAO_AV_Core::deactivate_servant (this);
03214   if (result < 0)
03215     if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "TAO_MMDevice::destroy failed\n"));
03216 }

CORBA::Object_ptr TAO_MMDevice::get_fdev ( const char *  flow_name  )  [virtual]

Not supported in the light profile, raises notsupported.

Definition at line 3301 of file AVStreams_i.cpp.

03302 {
03303 
03304   ACE_CString fdev_name_key (flow_name);
03305   AVStreams::FDev_var fdev_entry;
03306   if (this->fdev_map_.find (fdev_name_key, fdev_entry) == 0)
03307     return fdev_entry._retn() ;
03308   return 0;
03309 }

void TAO_MMDevice::remove_fdev ( const char *  flow_name  )  [virtual]

Not supported in the light profile, raises notsupported.

Definition at line 3313 of file AVStreams_i.cpp.

References CORBA::Exception::_tao_print_exception(), flows_, and ACE_OS::strcmp().

03314 {
03315   try
03316     {
03317       ACE_CString fdev_name_key (flow_name);
03318       AVStreams::FDev_var fdev_entry;
03319       // Remove the fep from the hash table.
03320       if (this->fdev_map_.unbind (fdev_name_key, fdev_entry)!= 0)
03321         throw AVStreams::streamOpFailed ();
03322 
03323       AVStreams::flowSpec new_flows (this->flows_.length ());
03324       for (u_int i=0, j=0 ; i <this->flows_.length (); i++)
03325         if (ACE_OS::strcmp (flow_name, this->flows_[i]) != 0)
03326           new_flows[j++] = this->flows_[i];
03327 
03328       CORBA::Any flows;
03329       flows <<= new_flows;
03330       this->flows_ = new_flows;
03331       this->define_property ("Flows",
03332                              flows);
03333     }
03334   catch (const CORBA::Exception& ex)
03335     {
03336       ex._tao_print_exception ("TAO_MMDevice::remove_fdev");
03337     }
03338 }


Member Data Documentation

TAO_AV_Endpoint_Strategy* TAO_MMDevice::endpoint_strategy_ [protected]

Definition at line 770 of file AVStreams_i.h.

FDev_Map TAO_MMDevice::fdev_map_ [protected]

hash table for the flownames and its corresponding flowEndpoint reference.

Definition at line 785 of file AVStreams_i.h.

Referenced by create_A_B().

u_int TAO_MMDevice::flow_count_ [protected]

Count of the number of flows in this MMDevice , used to generate unique names for the flows.

Definition at line 774 of file AVStreams_i.h.

Referenced by add_fdev().

u_int TAO_MMDevice::flow_num_ [protected]

current flow number used for system generation of flow names.

Definition at line 777 of file AVStreams_i.h.

Referenced by add_fdev_i().

AVStreams::flowSpec TAO_MMDevice::flows_ [protected]

sequence of supported flow names.

Definition at line 788 of file AVStreams_i.h.

Referenced by add_fdev(), and remove_fdev().

TAO_StreamCtrl* TAO_MMDevice::stream_ctrl_ [protected]

Definition at line 790 of file AVStreams_i.h.

Referenced by bind(), and ~TAO_MMDevice().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:48:10 2010 for TAO_AV by  doxygen 1.4.7