00001
00002
00003 #include "orbsvcs/AV/AV_Core.h"
00004 #include "orbsvcs/AV/FlowSpec_Entry.h"
00005 #include "orbsvcs/AV/Transport.h"
00006 #include "orbsvcs/AV/Protocol_Factory.h"
00007 #include "orbsvcs/AV/UDP.h"
00008 #include "orbsvcs/AV/TCP.h"
00009 #include "orbsvcs/AV/RTP.h"
00010 #include "orbsvcs/AV/RTCP.h"
00011 #include "orbsvcs/AV/sfp.h"
00012 #include "orbsvcs/AV/default_resource.h"
00013
00014 #if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
00015 #include "orbsvcs/AV/QoS_UDP.h"
00016 #endif
00017
00018 #if defined (ACE_HAS_SCTP)
00019 #include "orbsvcs/AV/SCTP_SEQ.h"
00020 #endif // ACE_HAS_SCTP
00021
00022 #include "tao/debug.h"
00023 #include "tao/ORB_Core.h"
00024
00025 #include "ace/Dynamic_Service.h"
00026
00027 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029
00030
00031
00032
00033 TAO_AV_Core::TAO_AV_Core (void)
00034 :connector_registry_ (0),
00035 acceptor_registry_ (0)
00036 {
00037 ACE_NEW (this->connector_registry_,
00038 TAO_AV_Connector_Registry
00039 );
00040 ACE_NEW (this->acceptor_registry_,
00041 TAO_AV_Acceptor_Registry
00042 );
00043 }
00044
00045 TAO_AV_Core::~TAO_AV_Core (void)
00046 {
00047 delete this->connector_registry_;
00048 delete this->acceptor_registry_;
00049
00050 TAO_AV_TransportFactorySetItor transport_iter =
00051 this->transport_factories_.begin();
00052
00053 while (transport_iter != this->transport_factories_.end())
00054 {
00055 if ((*transport_iter)->factory()->ref_count != 1)
00056 {
00057 delete (*transport_iter)->factory();
00058 }
00059 delete (*transport_iter);
00060 transport_iter++;
00061 }
00062
00063 TAO_AV_Flow_ProtocolFactorySetItor flow_iter =
00064 this->flow_protocol_factories_.begin();
00065
00066 while (flow_iter != this->flow_protocol_factories_.end())
00067 {
00068 if ((*flow_iter)->factory()->ref_count != 1)
00069 {
00070 delete (*flow_iter)->factory();
00071 }
00072 delete (*flow_iter);
00073
00074 flow_iter++;
00075 }
00076 }
00077
00078 CORBA::ORB_ptr
00079 TAO_AV_Core::orb (void)
00080 {
00081 return this->orb_.in ();
00082 }
00083
00084 void
00085 TAO_AV_Core::orb (CORBA::ORB_ptr orb)
00086 {
00087 this->orb_ = orb;
00088 }
00089
00090 PortableServer::POA_ptr
00091 TAO_AV_Core::poa (void)
00092 {
00093 return this->poa_.in ();
00094 }
00095
00096 void
00097 TAO_AV_Core::poa (PortableServer::POA_ptr poa)
00098 {
00099 this->poa_ = poa;
00100 }
00101
00102 TAO_AV_Connector_Registry*
00103 TAO_AV_Core::connector_registry (void)
00104 {
00105 return this->connector_registry_;
00106 }
00107
00108 TAO_AV_Acceptor_Registry*
00109 TAO_AV_Core::acceptor_registry (void)
00110 {
00111 return this->acceptor_registry_;
00112 }
00113
00114 TAO_AV_TransportFactorySet *
00115 TAO_AV_Core::transport_factories (void)
00116 {
00117 return &this->transport_factories_;
00118 }
00119
00120 TAO_AV_Flow_ProtocolFactorySet*
00121 TAO_AV_Core::flow_protocol_factories (void)
00122 {
00123 return &this->flow_protocol_factories_;
00124 }
00125
00126 int
00127 TAO_AV_Core::stop_run (void)
00128 {
00129 this->stop_run_ = 1;
00130 return 0;
00131 }
00132
00133 int
00134 TAO_AV_Core::run (void)
00135 {
00136 this->stop_run_ = 0;
00137 while (!this->stop_run_ && this->orb_->work_pending ())
00138 this->orb_->perform_work ();
00139 return 0;
00140 }
00141
00142 void
00143 TAO_AV_Core::reactor (ACE_Reactor *r)
00144 {
00145 this->reactor_ = r;
00146 }
00147
00148 ACE_Reactor *
00149 TAO_AV_Core::reactor (void)
00150 {
00151 return this->reactor_;
00152 }
00153
00154
00155 int
00156 TAO_AV_Core::init (CORBA::ORB_ptr orb,
00157 PortableServer::POA_ptr poa)
00158 {
00159 if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_Core::init "));
00160 this->orb_ = CORBA::ORB::_duplicate (orb);
00161 this->poa_ = PortableServer::POA::_duplicate (poa);
00162 this->reactor (this->orb_->orb_core ()->reactor ());
00163 this->init_transport_factories ();
00164 this->init_flow_protocol_factories ();
00165 return 0;
00166 }
00167
00168 int
00169 TAO_AV_Core::init_forward_flows (TAO_Base_StreamEndPoint *endpoint,
00170 TAO_AV_FlowSpecSet &flow_spec_set,
00171 TAO_AV_Core::EndPoint direction,
00172 AVStreams::flowSpec &flow_spec)
00173 {
00174 if (TAO_debug_level > 0)
00175 ACE_DEBUG ((LM_DEBUG,
00176 "TAO_AV_Core::init_forward_flows\n"));
00177
00178 TAO_AV_FlowSpecSet address_flow_set;
00179 TAO_AV_FlowSpecSet flow_set;
00180 TAO_AV_FlowSpecSetItor end = flow_spec_set.end ();
00181 for (TAO_AV_FlowSpecSetItor start = flow_spec_set.begin ();
00182 start != end; ++start)
00183 {
00184 TAO_FlowSpec_Entry *entry = (*start);
00185 switch (direction)
00186 {
00187 case TAO_AV_Core::TAO_AV_ENDPOINT_B:
00188 {
00189 switch (entry->direction ())
00190 {
00191 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00192 {
00193 entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER);
00194 break;
00195 }
00196 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00197 {
00198 entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER);
00199 break;
00200 }
00201 }
00202 break;
00203 }
00204 case TAO_AV_Core::TAO_AV_ENDPOINT_A:
00205 {
00206 switch (entry->direction ())
00207 {
00208 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00209 entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER);
00210 break;
00211 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00212 entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER);
00213 break;
00214 }
00215 break;
00216 }
00217 default:
00218 break;
00219 }
00220 ACE_Addr *address = entry->address ();
00221 if (address != 0)
00222 {
00223 if (TAO_debug_level > 0)
00224 ACE_DEBUG ((LM_DEBUG,
00225 "address given for flow %s\n",
00226 entry->flowname ()));
00227
00228 address_flow_set.insert (entry);
00229 }
00230 else
00231 flow_set.insert (entry);
00232 }
00233
00234
00235 int result = -1;
00236 switch (direction)
00237 {
00238 case TAO_AV_Core::TAO_AV_ENDPOINT_A:
00239 if (address_flow_set.size () > 0)
00240 {
00241 result = this->acceptor_registry_->open (endpoint,
00242 this,
00243 address_flow_set);
00244 if (result < 0)
00245 ACE_ERROR_RETURN ((LM_ERROR,
00246 "TAO_AV_Core::init_forward_flows::acceptor_registry::open failed\n"),
00247 -1);
00248 TAO_AV_FlowSpecSetItor end = address_flow_set.end ();
00249 for (TAO_AV_FlowSpecSetItor start = address_flow_set.begin ();
00250 start != end; ++start)
00251 {
00252 TAO_FlowSpec_Entry *entry = (*start);
00253 switch (entry->direction ())
00254 {
00255 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00256 {
00257 if (entry->handler () != 0)
00258 {
00259
00260 #if defined ACE_HAS_RAPI || defined (ACE_HAS_WINSOCK2_GQOS)
00261
00262 ACE_Event_Handler *event_handler = entry->handler ()->event_handler ();
00263
00264 if (event_handler->reactor () != 0)
00265 {
00266 result = event_handler->reactor ()->remove_handler (event_handler,
00267 ACE_Event_Handler::READ_MASK);
00268
00269 if (result < 0)
00270 if (TAO_debug_level > 0)
00271 ACE_DEBUG ((LM_DEBUG,
00272 "TAO_AV_Core::init_forward_flows: remove_handler failed\n"));
00273 }
00274 #endif //ACE_HAS_RAPI || ACE_HAS_WINSOCK2_GQOS
00275 }
00276 }
00277 default:
00278 break;
00279 }
00280
00281
00282 if (flow_spec_set.find (entry) < 0)
00283 {
00284
00285 flow_spec_set.insert (entry);
00286
00287
00288
00289 }
00290 }
00291 }
00292 break;
00293 case TAO_AV_Core::TAO_AV_ENDPOINT_B:
00294 {
00295 if (address_flow_set.size () > 0)
00296 {
00297 ACE_DEBUG ((LM_DEBUG,
00298 "(%N,%l) This connector registry is called\n"));
00299
00300 result = this->connector_registry_->open (endpoint,
00301 this,
00302 address_flow_set);
00303 if (result == -1)
00304 ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Core::init_Forward_flows: connector_registry open failed\n"),-1);
00305 TAO_AV_FlowSpecSetItor end = address_flow_set.end ();
00306 for (TAO_AV_FlowSpecSetItor start = address_flow_set.begin ();
00307 start != end; ++start)
00308 {
00309 TAO_FlowSpec_Entry *entry = (*start);
00310 switch (entry->direction ())
00311 {
00312 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00313 {
00314 if (entry->handler () != 0)
00315 {
00316
00317
00318 ACE_Event_Handler *event_handler = entry->handler ()->event_handler ();
00319 result = event_handler->reactor ()->remove_handler (event_handler,
00320 ACE_Event_Handler::READ_MASK);
00321 if (result < 0)
00322 if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_Core::init_forward_flows: remove_handler failed\n"));
00323 }
00324 }
00325 default:
00326 break;
00327 }
00328
00329
00330 if (flow_spec_set.find (entry) < 0)
00331 {
00332
00333 flow_spec_set.insert (entry);
00334 }
00335 }
00336 }
00337 if (flow_set.size () > 0)
00338 {
00339
00340
00341
00342
00343 TAO_AV_FlowSpecSetItor end = flow_set.end ();
00344 TAO_AV_FlowSpecSetItor start = flow_set.begin ();
00345 for (; start != end; ++start)
00346 {
00347 TAO_FlowSpec_Entry *entry = *start;
00348 if (entry->get_peer_addr () != 0)
00349 {
00350 entry->address (entry->get_peer_addr (), false);
00351 }
00352 }
00353
00354 result = this->acceptor_registry_->open (endpoint,
00355 this,
00356 flow_set);
00357 if (result == -1)
00358 ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Core::init_Forward_flows: Acceptor_registry open failed\n"),-1);
00359 end = address_flow_set.end ();
00360 start = address_flow_set.begin ();
00361 for (; start != end; ++start)
00362 {
00363 TAO_FlowSpec_Entry *entry = (*start);
00364 switch (entry->direction ())
00365 {
00366 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00367 {
00368 if (entry->handler () != 0)
00369 {
00370
00371 ACE_Event_Handler *event_handler = entry->handler ()->event_handler ();
00372 result = event_handler->reactor ()->remove_handler (event_handler,
00373 ACE_Event_Handler::READ_MASK);
00374 if (result < 0)
00375 if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_AV_Core::init_forward_flows: remove_handler failed\n"));
00376 }
00377 }
00378 default:
00379 break;
00380 }
00381
00382
00383 if (flow_spec_set.find (entry) < 0)
00384 {
00385
00386 flow_spec_set.insert (entry);
00387 }
00388 }
00389 }
00390
00391 AVStreams::flowSpec new_flowspec (static_cast<CORBA::ULong> (flow_spec_set.size ()));
00392 int i=0;
00393 TAO_AV_FlowSpecSetItor connect_end = address_flow_set.end ();
00394 TAO_AV_FlowSpecSetItor connect = address_flow_set.begin ();
00395 for (;connect != connect_end; ++connect)
00396 {
00397 ACE_Addr *local_addr;
00398 ACE_Addr *local_control_addr;
00399 local_addr = (*connect)->get_local_addr ();
00400 local_control_addr = (*connect)->get_local_control_addr ();
00401 if (local_addr != 0)
00402 {
00403 TAO_Reverse_FlowSpec_Entry entry ((*connect)->flowname (),
00404 (*connect)->direction_str (),
00405 (*connect)->format (),
00406 (*connect)->flow_protocol_str (),
00407 (*connect)->carrier_protocol_str (),
00408 local_addr,
00409 local_control_addr);
00410
00411
00412
00413
00414
00415
00416
00417 int len = new_flowspec.length ();
00418 if (i == len)
00419 new_flowspec.length (len+1);
00420 new_flowspec [i++] = entry.entry_to_string ();
00421 if (TAO_debug_level > 0)
00422 ACE_DEBUG ((LM_DEBUG, "reverse Flow Spec Is %s\n", entry.entry_to_string ()));
00423 }
00424 }
00425 connect_end = flow_set.end ();
00426 for (connect = flow_set.begin ();
00427 connect != connect_end; ++connect)
00428 {
00429 ACE_Addr *local_addr;
00430 ACE_Addr *local_control_addr;
00431 local_addr = (*connect)->get_local_addr ();
00432 local_control_addr = (*connect)->get_local_control_addr ();
00433 if (local_addr != 0)
00434 {
00435 TAO_Reverse_FlowSpec_Entry entry ((*connect)->flowname (),
00436 (*connect)->direction_str (),
00437 (*connect)->format (),
00438 (*connect)->flow_protocol_str (),
00439 (*connect)->carrier_protocol_str (),
00440 local_addr,
00441 local_control_addr);
00442
00443 int len = new_flowspec.length ();
00444 if (i == len)
00445 new_flowspec.length (len+1);
00446 new_flowspec [i++] = entry.entry_to_string ();
00447 }
00448 }
00449
00450
00451 int index = new_flowspec.length ();
00452 flow_spec.length (index);
00453 for (i = 0; i < index; i++)
00454 {
00455 flow_spec [i] = new_flowspec [i];
00456 }
00457 }
00458 break;
00459 default:
00460 break;
00461 }
00462 return 0;
00463 }
00464
00465 int
00466 TAO_AV_Core::init_reverse_flows (TAO_Base_StreamEndPoint *endpoint,
00467 TAO_AV_FlowSpecSet &forward_flow_spec_set,
00468 TAO_AV_FlowSpecSet &reverse_flow_spec_set,
00469 TAO_AV_Core::EndPoint direction)
00470 {
00471 if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Core::init_reverse_flows\n"));
00472 TAO_AV_FlowSpecSet acceptor_flow_set;
00473 TAO_AV_FlowSpecSet connector_flow_set;
00474 TAO_AV_FlowSpecSetItor end = reverse_flow_spec_set.end ();
00475 TAO_AV_FlowSpecSetItor start = reverse_flow_spec_set.begin ();
00476 for (;start != end; ++start)
00477 {
00478 TAO_FlowSpec_Entry *entry = (*start);
00479 ACE_Addr *address = entry->address ();
00480 switch (direction)
00481 {
00482 case TAO_AV_Core::TAO_AV_ENDPOINT_B:
00483 {
00484 switch (entry->direction ())
00485 {
00486 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00487 entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER);
00488 break;
00489 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00490 entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER);
00491 break;
00492 }
00493 break;
00494 }
00495 case TAO_AV_Core::TAO_AV_ENDPOINT_A:
00496 {
00497 switch (entry->direction ())
00498 {
00499 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00500 entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER);
00501 break;
00502 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00503 entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER);
00504 break;
00505 }
00506 break;
00507 }
00508 default: break;
00509 }
00510
00511 if (address != 0)
00512 {
00513 if (this->get_acceptor (entry->flowname ())!= 0)
00514 {
00515 ACE_Addr *address = entry->address ();
00516 TAO_FlowSpec_Entry *forward_entry =
00517 this->get_flow_spec_entry (forward_flow_spec_set,
00518 entry->flowname ());
00519 if (forward_entry != 0)
00520 forward_entry->set_peer_addr (address);
00521 }
00522 else
00523 connector_flow_set.insert (entry);
00524 }
00525 }
00526 int result = -1;
00527 switch (direction)
00528 {
00529
00530 case TAO_AV_Core::TAO_AV_ENDPOINT_A:
00531 {
00532 result = this->connector_registry_->open (endpoint,
00533 this,
00534 connector_flow_set);
00535 }
00536 break;
00537 default:
00538 break;
00539 }
00540 if (result == -1)
00541 ACE_ERROR_RETURN ((LM_ERROR,"acceptor_registry::open"),-1);
00542 return 0;
00543 }
00544
00545 TAO_FlowSpec_Entry *
00546 TAO_AV_Core::get_flow_spec_entry (TAO_AV_FlowSpecSet &flow_spec_set,
00547 const char *flowname)
00548 {
00549 TAO_AV_FlowSpecSetItor end = flow_spec_set.end ();
00550 TAO_AV_FlowSpecSetItor begin = flow_spec_set.begin ();
00551 for (;
00552 begin != end;
00553 ++begin)
00554 {
00555 if (ACE_OS::strcmp ((*begin)->flowname (),flowname) == 0)
00556 return (*begin);
00557 }
00558 return 0;
00559 }
00560
00561 TAO_AV_Acceptor*
00562 TAO_AV_Core::get_acceptor (const char *flowname)
00563 {
00564
00565 try
00566 {
00567
00568 TAO_AV_AcceptorSetItor acceptor = this->acceptor_registry_->begin ();
00569
00570 TAO_AV_AcceptorSetItor end =
00571 this->acceptor_registry_->end ();
00572
00573 for (;acceptor != end; ++acceptor)
00574 {
00575 if (ACE_OS::strcmp ((*acceptor)->flowname (),flowname) == 0)
00576 return *acceptor;
00577 }
00578 }
00579 catch (const CORBA::Exception& ex)
00580 {
00581 ex._tao_print_exception ("TAO_AV_Core::get_acceptor");
00582 }
00583 return 0;
00584 }
00585
00586 int
00587 TAO_AV_Core::remove_acceptor (const char *flowname)
00588 {
00589
00590 try
00591 {
00592
00593 TAO_AV_AcceptorSetItor acceptor = this->acceptor_registry_->begin ();
00594
00595 TAO_AV_AcceptorSetItor end =
00596 this->acceptor_registry_->end ();
00597
00598 for (;acceptor != end; ++acceptor)
00599 {
00600 if (ACE_OS::strcmp ((*acceptor)->flowname (),flowname) == 0)
00601 {
00602 this->acceptor_registry_->close (*acceptor);
00603 return 0;
00604 }
00605 }
00606 }
00607 catch (const CORBA::Exception& ex)
00608 {
00609 ex._tao_print_exception ("TAO_AV_Core::get_acceptor");
00610 }
00611 return -1;
00612 }
00613
00614 TAO_AV_Connector*
00615 TAO_AV_Core::get_connector (const char *flowname)
00616 {
00617 TAO_AV_ConnectorSetItor connector =
00618 this->connector_registry_->begin ();
00619 TAO_AV_ConnectorSetItor end =
00620 this->connector_registry_->end ();
00621
00622 for (;connector != end; ++connector)
00623 {
00624 if (ACE_OS::strcmp ((*connector)->flowname (),flowname) == 0)
00625 return *connector;
00626 }
00627 return 0;
00628 }
00629
00630 int
00631 TAO_AV_Core::remove_connector (const char *flowname)
00632 {
00633 TAO_AV_ConnectorSetItor connector =
00634 this->connector_registry_->begin ();
00635 TAO_AV_ConnectorSetItor end =
00636 this->connector_registry_->end ();
00637
00638 for (;connector != end; ++connector)
00639 {
00640 if (ACE_OS::strcmp ((*connector)->flowname (),flowname) == 0)
00641 {
00642 this->connector_registry_->close (*connector);
00643 return 0;
00644 }
00645 }
00646 return -1;
00647 }
00648
00649 TAO_AV_Flow_Protocol_Factory *
00650 TAO_AV_Core::get_flow_protocol_factory(const char *flow_protocol)
00651 {
00652 if (flow_protocol == 0)
00653 return 0;
00654
00655 for (TAO_AV_Flow_ProtocolFactorySetItor control_flow_factory =
00656 this->flow_protocol_factories_.begin ();
00657 control_flow_factory !=
00658 this->flow_protocol_factories_.end ();
00659 ++control_flow_factory)
00660 {
00661 if ((*control_flow_factory)->factory ()->match_protocol (flow_protocol))
00662 {
00663 return (*control_flow_factory)->factory ();
00664 }
00665 }
00666
00667
00668 return 0;
00669 }
00670
00671 TAO_AV_Transport_Factory *
00672 TAO_AV_Core::get_transport_factory(const char *transport_protocol)
00673 {
00674 if (transport_protocol == 0)
00675 return 0;
00676
00677 for (TAO_AV_TransportFactorySetItor transport_factory =
00678 this->transport_factories_.begin ();
00679 transport_factory != this->transport_factories_.end ();
00680 ++transport_factory)
00681 {
00682 if ((*transport_factory)->factory ()->match_protocol (transport_protocol))
00683 {
00684 return (*transport_factory)->factory ();
00685 }
00686 }
00687
00688
00689 return 0;
00690 }
00691
00692 int
00693 TAO_AV_Core::load_default_transport_factories (void)
00694 {
00695 const char *udp_factory_str = "UDP_Factory";
00696 const char *tcp_factory_str = "TCP_Factory";
00697
00698 TAO_AV_Transport_Factory *udp_factory = 0;
00699 TAO_AV_Transport_Item *udp_item = 0;
00700
00701 udp_factory =
00702 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (udp_factory_str);
00703 if (udp_factory == 0)
00704 {
00705 if (TAO_debug_level)
00706 ACE_ERROR ((LM_WARNING,
00707 "(%P|%t) WARNING - No %s found in Service Repository."
00708 " Using default instance.\n",
00709 "UDP Factory"));
00710
00711 ACE_NEW_RETURN (udp_factory,
00712 TAO_AV_UDP_Factory,
00713 -1);
00714 }
00715 else udp_factory->ref_count = 1;
00716
00717 ACE_NEW_RETURN (udp_item, TAO_AV_Transport_Item ("UDP_Factory"), -1);
00718 udp_item->factory (udp_factory);
00719
00720 this->transport_factories_.insert (udp_item);
00721
00722 TAO_AV_Transport_Factory *tcp_factory = 0;
00723 TAO_AV_Transport_Item *tcp_item = 0;
00724
00725 tcp_factory =
00726 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (tcp_factory_str);
00727 if (tcp_factory == 0)
00728 {
00729 if (TAO_debug_level)
00730 ACE_ERROR ((LM_WARNING,
00731 "(%P|%t) WARNING - No %s found in Service Repository."
00732 " Using default instance.\n",
00733 "TCP Factory"));
00734
00735 ACE_NEW_RETURN (tcp_factory,
00736 TAO_AV_TCP_Factory,
00737 -1);
00738 }
00739 else tcp_factory->ref_count = 1;
00740
00741 ACE_NEW_RETURN (tcp_item, TAO_AV_Transport_Item ("TCP_Factory"), -1);
00742 tcp_item->factory (tcp_factory);
00743
00744 this->transport_factories_.insert (tcp_item);
00745
00746 #if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
00747 const char *udp_qos_factory_str = "UDP_QoS_Factory";
00748
00749 TAO_AV_Transport_Factory *udp_qos_factory = 0;
00750 TAO_AV_Transport_Item *udp_qos_item = 0;
00751
00752 udp_qos_factory =
00753 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (udp_qos_factory_str);
00754 if (udp_qos_factory == 0)
00755 {
00756 if (TAO_debug_level)
00757 ACE_ERROR ((LM_WARNING,
00758 "(%P|%t) WARNING - No %s found in Service Repository."
00759 " Using default instance.\n",
00760 "UDP QoS Factory"));
00761
00762 ACE_NEW_RETURN (udp_qos_factory,
00763 TAO_AV_UDP_QoS_Factory,
00764 -1);
00765 }
00766 else udp_qos_factory->ref_count = 1;
00767
00768 ACE_NEW_RETURN (udp_qos_item,
00769 TAO_AV_Transport_Item ("UDP_QoS_Factory"),
00770 -1);
00771
00772 udp_qos_item->factory (udp_qos_factory);
00773
00774 this->transport_factories_.insert (udp_qos_item);
00775 #endif
00776
00777 #if defined ACE_HAS_SCTP
00778 const char *sctp_seq_factory_str = "SCTP_SEQ_Factory";
00779
00780 TAO_AV_Transport_Factory *sctp_seq_factory = 0;
00781 TAO_AV_Transport_Item *sctp_seq_item = 0;
00782
00783 sctp_seq_factory =
00784 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (sctp_seq_factory_str);
00785 if (sctp_seq_factory == 0)
00786 {
00787 if (TAO_debug_level)
00788 ACE_ERROR ((LM_WARNING,
00789 "(%P|%t) WARNING - No %s found in Service Repository."
00790 " Using default instance.\n",
00791 "SCTP SEQ Factory"));
00792
00793 ACE_NEW_RETURN (sctp_seq_factory,
00794 TAO_AV_SCTP_SEQ_Factory,
00795 -1);
00796 }
00797 else sctp_seq_factory->ref_count = 1;
00798
00799 ACE_NEW_RETURN (sctp_seq_item,
00800 TAO_AV_Transport_Item ("SCTP_SEQ_Factory"),
00801 -1);
00802
00803 sctp_seq_item->factory (sctp_seq_factory);
00804
00805 this->transport_factories_.insert (sctp_seq_item);
00806 #endif
00807
00808 return 0;
00809 }
00810
00811 int
00812 TAO_AV_Core::init_transport_factories (void)
00813 {
00814 TAO_AV_TransportFactorySetItor end = this->transport_factories_.end ();
00815 TAO_AV_TransportFactorySetItor factory = this->transport_factories_.begin ();
00816
00817
00818 if (factory == end)
00819 {
00820 if (TAO_debug_level > 0)
00821 ACE_DEBUG ((LM_DEBUG,
00822 "Loading default transport protocols\n"));
00823 this->load_default_transport_factories ();
00824 }
00825 else
00826 {
00827 for (; factory != end; factory++)
00828 {
00829 const ACE_CString &name = (*factory)->name ();
00830 if (TAO_debug_level > 0)
00831 ACE_DEBUG ((LM_DEBUG,
00832 "%s \n",
00833 name.c_str ()));
00834
00835 (*factory)->factory (
00836 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (name.c_str ()));
00837 if ((*factory)->factory () == 0)
00838 {
00839 ACE_ERROR_RETURN ((LM_ERROR,
00840 ACE_TEXT ("TAO (%P|%t) Unable to load ")
00841 ACE_TEXT ("protocol <%s>, %p\n"),
00842 name.c_str (), ""),
00843 -1);
00844 }
00845 (*factory)->factory ()->ref_count = 1;
00846
00847 if (TAO_debug_level > 0)
00848 {
00849 ACE_DEBUG ((LM_DEBUG,
00850 ACE_TEXT ("TAO (%P|%t) Loaded protocol <%s>\n"),
00851 name.c_str ()));
00852 }
00853 }
00854 }
00855
00856 return 0;
00857 }
00858
00859 int
00860 TAO_AV_Core::load_default_flow_protocol_factories (void)
00861 {
00862 const char *udp_flow = "UDP_Flow_Factory";
00863 const char *tcp_flow = "TCP_Flow_Factory";
00864 const char *rtp_flow = "RTP_Flow_Factory";
00865 const char *rtcp_flow = "RTCP_Flow_Factory";
00866 const char *sfp_flow = "SFP_Flow_Factory";
00867
00868 TAO_AV_Flow_Protocol_Factory *udp_flow_factory = 0;
00869 TAO_AV_Flow_Protocol_Item *udp_item = 0;
00870
00871 udp_flow_factory =
00872 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (udp_flow);
00873 if (udp_flow_factory == 0)
00874 {
00875 if (TAO_debug_level)
00876 ACE_ERROR ((LM_WARNING,
00877 "(%P|%t) WARNING - No %s found in Service Repository."
00878 " Using default instance.\n",
00879 "UDP Flow Factory"));
00880
00881 ACE_NEW_RETURN (udp_flow_factory,
00882 TAO_AV_UDP_Flow_Factory,
00883 -1);
00884 }
00885 else udp_flow_factory->ref_count = 1;
00886
00887 ACE_NEW_RETURN (udp_item, TAO_AV_Flow_Protocol_Item ("UDP_Flow_Factory"), -1);
00888 udp_item->factory (udp_flow_factory);
00889
00890 this->flow_protocol_factories_.insert (udp_item);
00891
00892 #if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
00893
00894 const char *udp_qos_flow = "UDP_QoS_Flow_Factory";
00895 TAO_AV_Flow_Protocol_Factory *udp_qos_flow_factory = 0;
00896 TAO_AV_Flow_Protocol_Item *udp_qos_flow_item = 0;
00897
00898 udp_qos_flow_factory =
00899 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (udp_qos_flow);
00900 if (udp_qos_flow_factory == 0)
00901 {
00902 if (TAO_debug_level)
00903 ACE_ERROR ((LM_WARNING,
00904 "(%P|%t) WARNING - No %s found in Service Repository."
00905 " Using default instance.\n",
00906 "UDP QoS Flow Factory"));
00907
00908 ACE_NEW_RETURN (udp_qos_flow_factory,
00909 TAO_AV_UDP_QoS_Flow_Factory,
00910 -1);
00911 }
00912 else udp_qos_flow_factory->ref_count = 1;
00913
00914 ACE_NEW_RETURN (udp_qos_flow_item, TAO_AV_Flow_Protocol_Item ("UDP_QoS_Flow_Factory"), -1);
00915 udp_qos_flow_item->factory (udp_qos_flow_factory);
00916
00917 this->flow_protocol_factories_.insert (udp_qos_flow_item);
00918
00919 #endif
00920
00921 #if defined ACE_HAS_SCTP
00922
00923 const char *sctp_seq_flow = "SCTP_SEQ_Flow_Factory";
00924 TAO_AV_Flow_Protocol_Factory *sctp_seq_flow_factory = 0;
00925 TAO_AV_Flow_Protocol_Item *sctp_seq_flow_item = 0;
00926
00927 sctp_seq_flow_factory =
00928 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (sctp_seq_flow);
00929 if (sctp_seq_flow_factory == 0)
00930 {
00931 if (TAO_debug_level)
00932 ACE_ERROR ((LM_WARNING,
00933 "(%P|%t) WARNING - No %s found in Service Repository."
00934 " Using default instance.\n",
00935 "SCTP SEQ Flow Factory"));
00936
00937 ACE_NEW_RETURN (sctp_seq_flow_factory,
00938 TAO_AV_SCTP_SEQ_Flow_Factory,
00939 -1);
00940 }
00941 else sctp_seq_flow_factory->ref_count = 1;
00942
00943 ACE_NEW_RETURN (sctp_seq_flow_item, TAO_AV_Flow_Protocol_Item ("SCTP_SEQ_Flow_Factory"), -1);
00944 sctp_seq_flow_item->factory (sctp_seq_flow_factory);
00945
00946 this->flow_protocol_factories_.insert (sctp_seq_flow_item);
00947
00948 #endif
00949
00950 TAO_AV_Flow_Protocol_Factory *tcp_flow_factory = 0;
00951 TAO_AV_Flow_Protocol_Item *tcp_item = 0;
00952
00953 tcp_flow_factory =
00954 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (tcp_flow);
00955 if (tcp_flow_factory == 0)
00956 {
00957 if (TAO_debug_level)
00958 ACE_ERROR ((LM_WARNING,
00959 "(%P|%t) WARNING - No %s found in Service Repository."
00960 " Using default instance.\n",
00961 "TCP Flow Factory"));
00962
00963 ACE_NEW_RETURN (tcp_flow_factory,
00964 TAO_AV_TCP_Flow_Factory,
00965 -1);
00966 }
00967 else tcp_flow_factory->ref_count = 1;
00968
00969 ACE_NEW_RETURN (tcp_item, TAO_AV_Flow_Protocol_Item ("TCP_Flow_Factory"), -1);
00970 tcp_item->factory (tcp_flow_factory);
00971
00972 this->flow_protocol_factories_.insert (tcp_item);
00973
00974 TAO_AV_Flow_Protocol_Factory *rtp_flow_factory = 0;
00975 TAO_AV_Flow_Protocol_Item *rtp_item = 0;
00976
00977 rtp_flow_factory =
00978 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (rtp_flow);
00979 if (rtp_flow_factory == 0)
00980 {
00981 if (TAO_debug_level)
00982 ACE_ERROR ((LM_WARNING,
00983 "(%P|%t) WARNING - No %s found in Service Repository."
00984 " Using default instance.\n",
00985 "RTP Flow Factory"));
00986
00987 ACE_NEW_RETURN (rtp_flow_factory,
00988 TAO_AV_RTP_Flow_Factory,
00989 -1);
00990 }
00991 else rtp_flow_factory->ref_count = 1;
00992
00993 ACE_NEW_RETURN (rtp_item, TAO_AV_Flow_Protocol_Item ("RTP_Flow_Factory"), -1);
00994 rtp_item->factory (rtp_flow_factory);
00995
00996 this->flow_protocol_factories_.insert (rtp_item);
00997
00998 TAO_AV_Flow_Protocol_Factory *rtcp_flow_factory = 0;
00999 TAO_AV_Flow_Protocol_Item *rtcp_item = 0;
01000
01001 rtcp_flow_factory =
01002 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (rtcp_flow);
01003 if (rtcp_flow_factory == 0)
01004 {
01005 if (TAO_debug_level)
01006 ACE_ERROR ((LM_WARNING,
01007 "(%P|%t) WARNING - No %s found in Service Repository."
01008 " Using default instance.\n",
01009 "RTCP Flow Factory"));
01010
01011 ACE_NEW_RETURN (rtcp_flow_factory,
01012 TAO_AV_RTCP_Flow_Factory,
01013 -1);
01014 }
01015 else rtcp_flow_factory->ref_count = 1;
01016
01017 ACE_NEW_RETURN (rtcp_item, TAO_AV_Flow_Protocol_Item ("RTCP_Flow_Factory"), -1);
01018 rtcp_item->factory (rtcp_flow_factory);
01019
01020 this->flow_protocol_factories_.insert (rtcp_item);
01021
01022 TAO_AV_Flow_Protocol_Factory *sfp_flow_factory = 0;
01023 TAO_AV_Flow_Protocol_Item *sfp_item = 0;
01024
01025 sfp_flow_factory =
01026 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (sfp_flow);
01027 if (sfp_flow_factory == 0)
01028 {
01029 if (TAO_debug_level)
01030 ACE_ERROR ((LM_WARNING,
01031 "(%P|%t) WARNING - No %s found in Service Repository."
01032 " Using default instance.\n",
01033 "SFP Flow Factory"));
01034
01035 ACE_NEW_RETURN (sfp_flow_factory,
01036 TAO_AV_SFP_Factory,
01037 -1);
01038 }
01039 else sfp_flow_factory->ref_count = 1;
01040
01041 ACE_NEW_RETURN (sfp_item, TAO_AV_Flow_Protocol_Item ("SFP_Flow_Factory"), -1);
01042 sfp_item->factory (sfp_flow_factory);
01043
01044 this->flow_protocol_factories_.insert (sfp_item);
01045
01046 return 0;
01047 }
01048
01049 int
01050 TAO_AV_Core::init_flow_protocol_factories (void)
01051 {
01052 TAO_AV_Flow_ProtocolFactorySetItor end = this->flow_protocol_factories_.end ();
01053 TAO_AV_Flow_ProtocolFactorySetItor factory = this->flow_protocol_factories_.begin ();
01054
01055 if (factory == end)
01056 {
01057 ACE_DEBUG ((LM_DEBUG,
01058 "Loading default flow protocol factories\n"));
01059
01060 this->load_default_flow_protocol_factories ();
01061 }
01062 else
01063 {
01064 for (; factory != end; factory++)
01065 {
01066 const ACE_CString &name = (*factory)->name ();
01067 if (TAO_debug_level > 0)
01068 ACE_DEBUG ((LM_DEBUG,
01069 "%s \n",
01070 name.c_str ()));
01071
01072 (*factory)->factory (
01073 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (name.c_str ()));
01074 if ((*factory)->factory () == 0)
01075 {
01076 ACE_ERROR_RETURN ((LM_ERROR,
01077 ACE_TEXT ("TAO (%P|%t) Unable to load ")
01078 ACE_TEXT ("protocol <%s>, %p\n"),
01079 name.c_str (), ""),
01080 -1);
01081 }
01082
01083 (*factory)->factory ()->ref_count = 1;
01084
01085 if (TAO_debug_level > 0)
01086 {
01087 ACE_DEBUG ((LM_DEBUG,
01088 ACE_TEXT ("TAO (%P|%t) Loaded protocol <%s>\n"),
01089 name.c_str ()));
01090 }
01091 }
01092 }
01093
01094 return 0;
01095 }
01096
01097
01098 int
01099 TAO_AV_Core::deactivate_servant (PortableServer::Servant servant)
01100 {
01101
01102
01103
01104
01105 try
01106 {
01107 PortableServer::POA_var poa = servant->_default_POA ();
01108
01109 PortableServer::ObjectId_var id = poa->servant_to_id (servant);
01110
01111 poa->deactivate_object (id.in ());
01112 }
01113 catch (const CORBA::Exception& ex)
01114 {
01115 ex._tao_print_exception ("deactivate_servant");
01116 return -1;
01117 }
01118 return 0;
01119 }
01120
01121
01122 char *
01123 TAO_AV_Core::get_flowname (const char *flow_spec_entry_str)
01124 {
01125 ACE_CString flow_spec_entry (flow_spec_entry_str);
01126 ACE_CString::size_type slash_pos = flow_spec_entry.find ('\\');
01127 ACE_CString flow_name;
01128 if (slash_pos != flow_spec_entry.npos)
01129 flow_name = flow_spec_entry.substring (0, slash_pos);
01130 else
01131 flow_name = flow_spec_entry_str;
01132 return CORBA::string_dup (flow_name.c_str ());
01133 }
01134
01135 ACE_CString
01136 TAO_AV_Core::get_control_flowname(const char *flowname)
01137 {
01138 ACE_CString control_flowname;
01139 control_flowname = "c_";
01140 control_flowname = control_flowname + flowname;
01141
01142 return flowname;
01143 }
01144
01145 #if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
01146 template ACE_Singleton<TAO_AV_Core, ACE_Null_Mutex> *ACE_Singleton<TAO_AV_Core, ACE_Null_Mutex>::singleton_;
01147 #endif
01148
01149 TAO_END_VERSIONED_NAMESPACE_DECL