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)
00323 ACE_DEBUG ((LM_DEBUG,
00324 "TAO_AV_Core::init_forward_flows: remove_handler failed\n"));
00325 }
00326 }
00327 default:
00328 break;
00329 }
00330
00331
00332 if (flow_spec_set.find (entry) < 0)
00333 {
00334
00335 flow_spec_set.insert (entry);
00336 }
00337 }
00338 }
00339 if (flow_set.size () > 0)
00340 {
00341
00342
00343
00344
00345 TAO_AV_FlowSpecSetItor end = flow_set.end ();
00346 TAO_AV_FlowSpecSetItor start = flow_set.begin ();
00347 for (; start != end; ++start)
00348 {
00349 TAO_FlowSpec_Entry *entry = *start;
00350 if (entry->get_peer_addr () != 0)
00351 {
00352 entry->address (entry->get_peer_addr (), false);
00353 }
00354 }
00355
00356 result = this->acceptor_registry_->open (endpoint,
00357 this,
00358 flow_set);
00359 if (result == -1)
00360 ACE_ERROR_RETURN ((LM_ERROR,"TAO_AV_Core::init_Forward_flows: Acceptor_registry open failed\n"),-1);
00361 end = address_flow_set.end ();
00362 start = address_flow_set.begin ();
00363 for (; start != end; ++start)
00364 {
00365 TAO_FlowSpec_Entry *entry = (*start);
00366 switch (entry->direction ())
00367 {
00368 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00369 {
00370 if (entry->handler () != 0)
00371 {
00372
00373 ACE_Event_Handler *event_handler = entry->handler ()->event_handler ();
00374 result = event_handler->reactor ()->remove_handler (event_handler,
00375 ACE_Event_Handler::READ_MASK);
00376 if (result < 0)
00377 if (TAO_debug_level > 0)
00378 ACE_DEBUG ((LM_DEBUG,
00379 "TAO_AV_Core::init_forward_flows: remove_handler failed\n"));
00380 }
00381 }
00382 default:
00383 break;
00384 }
00385
00386
00387 if (flow_spec_set.find (entry) < 0)
00388 {
00389
00390 flow_spec_set.insert (entry);
00391 }
00392 }
00393 }
00394
00395 AVStreams::flowSpec new_flowspec (static_cast<CORBA::ULong> (flow_spec_set.size ()));
00396 int i=0;
00397 TAO_AV_FlowSpecSetItor connect_end = address_flow_set.end ();
00398 TAO_AV_FlowSpecSetItor connect = address_flow_set.begin ();
00399 for (;connect != connect_end; ++connect)
00400 {
00401 ACE_Addr *local_addr;
00402 ACE_Addr *local_control_addr;
00403 local_addr = (*connect)->get_local_addr ();
00404 local_control_addr = (*connect)->get_local_control_addr ();
00405 if (local_addr != 0)
00406 {
00407 TAO_Reverse_FlowSpec_Entry entry ((*connect)->flowname (),
00408 (*connect)->direction_str (),
00409 (*connect)->format (),
00410 (*connect)->flow_protocol_str (),
00411 (*connect)->carrier_protocol_str (),
00412 local_addr,
00413 local_control_addr);
00414
00415
00416
00417
00418
00419
00420
00421 int len = new_flowspec.length ();
00422 if (i == len)
00423 new_flowspec.length (len+1);
00424 new_flowspec [i++] = entry.entry_to_string ();
00425 if (TAO_debug_level > 0)
00426 ACE_DEBUG ((LM_DEBUG, "reverse Flow Spec Is %s\n", entry.entry_to_string ()));
00427 }
00428 }
00429 connect_end = flow_set.end ();
00430 for (connect = flow_set.begin ();
00431 connect != connect_end; ++connect)
00432 {
00433 ACE_Addr *local_addr;
00434 ACE_Addr *local_control_addr;
00435 local_addr = (*connect)->get_local_addr ();
00436 local_control_addr = (*connect)->get_local_control_addr ();
00437 if (local_addr != 0)
00438 {
00439 TAO_Reverse_FlowSpec_Entry entry ((*connect)->flowname (),
00440 (*connect)->direction_str (),
00441 (*connect)->format (),
00442 (*connect)->flow_protocol_str (),
00443 (*connect)->carrier_protocol_str (),
00444 local_addr,
00445 local_control_addr);
00446
00447 int len = new_flowspec.length ();
00448 if (i == len)
00449 new_flowspec.length (len+1);
00450 new_flowspec [i++] = entry.entry_to_string ();
00451 }
00452 }
00453
00454
00455 int index = new_flowspec.length ();
00456 flow_spec.length (index);
00457 for (i = 0; i < index; i++)
00458 {
00459 flow_spec [i] = new_flowspec [i];
00460 }
00461 }
00462 break;
00463 default:
00464 break;
00465 }
00466 return 0;
00467 }
00468
00469 int
00470 TAO_AV_Core::init_reverse_flows (TAO_Base_StreamEndPoint *endpoint,
00471 TAO_AV_FlowSpecSet &forward_flow_spec_set,
00472 TAO_AV_FlowSpecSet &reverse_flow_spec_set,
00473 TAO_AV_Core::EndPoint direction)
00474 {
00475 if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Core::init_reverse_flows\n"));
00476 TAO_AV_FlowSpecSet acceptor_flow_set;
00477 TAO_AV_FlowSpecSet connector_flow_set;
00478 TAO_AV_FlowSpecSetItor end = reverse_flow_spec_set.end ();
00479 TAO_AV_FlowSpecSetItor start = reverse_flow_spec_set.begin ();
00480 for (;start != end; ++start)
00481 {
00482 TAO_FlowSpec_Entry *entry = (*start);
00483 ACE_Addr *address = entry->address ();
00484 switch (direction)
00485 {
00486 case TAO_AV_Core::TAO_AV_ENDPOINT_B:
00487 {
00488 switch (entry->direction ())
00489 {
00490 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00491 entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER);
00492 break;
00493 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00494 entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER);
00495 break;
00496 }
00497 break;
00498 }
00499 case TAO_AV_Core::TAO_AV_ENDPOINT_A:
00500 {
00501 switch (entry->direction ())
00502 {
00503 case TAO_FlowSpec_Entry::TAO_AV_DIR_IN:
00504 entry->role (TAO_FlowSpec_Entry::TAO_AV_PRODUCER);
00505 break;
00506 case TAO_FlowSpec_Entry::TAO_AV_DIR_OUT:
00507 entry->role (TAO_FlowSpec_Entry::TAO_AV_CONSUMER);
00508 break;
00509 }
00510 break;
00511 }
00512 default: break;
00513 }
00514
00515 if (address != 0)
00516 {
00517 if (this->get_acceptor (entry->flowname ())!= 0)
00518 {
00519 ACE_Addr *address = entry->address ();
00520 TAO_FlowSpec_Entry *forward_entry =
00521 this->get_flow_spec_entry (forward_flow_spec_set,
00522 entry->flowname ());
00523 if (forward_entry != 0)
00524 forward_entry->set_peer_addr (address);
00525 }
00526 else
00527 connector_flow_set.insert (entry);
00528 }
00529 }
00530 int result = -1;
00531 switch (direction)
00532 {
00533
00534 case TAO_AV_Core::TAO_AV_ENDPOINT_A:
00535 {
00536 result = this->connector_registry_->open (endpoint,
00537 this,
00538 connector_flow_set);
00539 }
00540 break;
00541 default:
00542 break;
00543 }
00544 if (result == -1)
00545 ACE_ERROR_RETURN ((LM_ERROR,"acceptor_registry::open"),-1);
00546 return 0;
00547 }
00548
00549 TAO_FlowSpec_Entry *
00550 TAO_AV_Core::get_flow_spec_entry (TAO_AV_FlowSpecSet &flow_spec_set,
00551 const char *flowname)
00552 {
00553 TAO_AV_FlowSpecSetItor end = flow_spec_set.end ();
00554 TAO_AV_FlowSpecSetItor begin = flow_spec_set.begin ();
00555 for (;
00556 begin != end;
00557 ++begin)
00558 {
00559 if (ACE_OS::strcmp ((*begin)->flowname (),flowname) == 0)
00560 return (*begin);
00561 }
00562 return 0;
00563 }
00564
00565 TAO_AV_Acceptor*
00566 TAO_AV_Core::get_acceptor (const char *flowname)
00567 {
00568
00569 try
00570 {
00571
00572 TAO_AV_AcceptorSetItor acceptor = this->acceptor_registry_->begin ();
00573
00574 TAO_AV_AcceptorSetItor end =
00575 this->acceptor_registry_->end ();
00576
00577 for (;acceptor != end; ++acceptor)
00578 {
00579 if (ACE_OS::strcmp ((*acceptor)->flowname (),flowname) == 0)
00580 return *acceptor;
00581 }
00582 }
00583 catch (const CORBA::Exception& ex)
00584 {
00585 ex._tao_print_exception ("TAO_AV_Core::get_acceptor");
00586 }
00587 return 0;
00588 }
00589
00590 int
00591 TAO_AV_Core::remove_acceptor (const char *flowname)
00592 {
00593
00594 try
00595 {
00596
00597 TAO_AV_AcceptorSetItor acceptor = this->acceptor_registry_->begin ();
00598
00599 TAO_AV_AcceptorSetItor end =
00600 this->acceptor_registry_->end ();
00601
00602 for (;acceptor != end; ++acceptor)
00603 {
00604 if (ACE_OS::strcmp ((*acceptor)->flowname (),flowname) == 0)
00605 {
00606 this->acceptor_registry_->close (*acceptor);
00607 return 0;
00608 }
00609 }
00610 }
00611 catch (const CORBA::Exception& ex)
00612 {
00613 ex._tao_print_exception ("TAO_AV_Core::get_acceptor");
00614 }
00615 return -1;
00616 }
00617
00618 TAO_AV_Connector*
00619 TAO_AV_Core::get_connector (const char *flowname)
00620 {
00621 TAO_AV_ConnectorSetItor connector =
00622 this->connector_registry_->begin ();
00623 TAO_AV_ConnectorSetItor end =
00624 this->connector_registry_->end ();
00625
00626 for (;connector != end; ++connector)
00627 {
00628 if (ACE_OS::strcmp ((*connector)->flowname (),flowname) == 0)
00629 return *connector;
00630 }
00631 return 0;
00632 }
00633
00634 int
00635 TAO_AV_Core::remove_connector (const char *flowname)
00636 {
00637 TAO_AV_ConnectorSetItor connector =
00638 this->connector_registry_->begin ();
00639 TAO_AV_ConnectorSetItor end =
00640 this->connector_registry_->end ();
00641
00642 for (;connector != end; ++connector)
00643 {
00644 if (ACE_OS::strcmp ((*connector)->flowname (),flowname) == 0)
00645 {
00646 this->connector_registry_->close (*connector);
00647 return 0;
00648 }
00649 }
00650 return -1;
00651 }
00652
00653 TAO_AV_Flow_Protocol_Factory *
00654 TAO_AV_Core::get_flow_protocol_factory(const char *flow_protocol)
00655 {
00656 if (flow_protocol == 0)
00657 return 0;
00658
00659 for (TAO_AV_Flow_ProtocolFactorySetItor control_flow_factory =
00660 this->flow_protocol_factories_.begin ();
00661 control_flow_factory !=
00662 this->flow_protocol_factories_.end ();
00663 ++control_flow_factory)
00664 {
00665 if ((*control_flow_factory)->factory ()->match_protocol (flow_protocol))
00666 {
00667 return (*control_flow_factory)->factory ();
00668 }
00669 }
00670
00671
00672 return 0;
00673 }
00674
00675 TAO_AV_Transport_Factory *
00676 TAO_AV_Core::get_transport_factory(const char *transport_protocol)
00677 {
00678 if (transport_protocol == 0)
00679 return 0;
00680
00681 for (TAO_AV_TransportFactorySetItor transport_factory =
00682 this->transport_factories_.begin ();
00683 transport_factory != this->transport_factories_.end ();
00684 ++transport_factory)
00685 {
00686 if ((*transport_factory)->factory ()->match_protocol (transport_protocol))
00687 {
00688 return (*transport_factory)->factory ();
00689 }
00690 }
00691
00692
00693 return 0;
00694 }
00695
00696 int
00697 TAO_AV_Core::load_default_transport_factories (void)
00698 {
00699 const char *udp_factory_str = "UDP_Factory";
00700 const char *tcp_factory_str = "TCP_Factory";
00701
00702 TAO_AV_Transport_Factory *udp_factory = 0;
00703 TAO_AV_Transport_Item *udp_item = 0;
00704
00705 udp_factory =
00706 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (udp_factory_str);
00707 if (udp_factory == 0)
00708 {
00709 if (TAO_debug_level)
00710 ACE_ERROR ((LM_WARNING,
00711 "(%P|%t) WARNING - No %s found in Service Repository."
00712 " Using default instance.\n",
00713 "UDP Factory"));
00714
00715 ACE_NEW_RETURN (udp_factory,
00716 TAO_AV_UDP_Factory,
00717 -1);
00718 }
00719 else udp_factory->ref_count = 1;
00720
00721 ACE_NEW_RETURN (udp_item, TAO_AV_Transport_Item ("UDP_Factory"), -1);
00722 udp_item->factory (udp_factory);
00723
00724 this->transport_factories_.insert (udp_item);
00725
00726 TAO_AV_Transport_Factory *tcp_factory = 0;
00727 TAO_AV_Transport_Item *tcp_item = 0;
00728
00729 tcp_factory =
00730 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (tcp_factory_str);
00731 if (tcp_factory == 0)
00732 {
00733 if (TAO_debug_level)
00734 ACE_ERROR ((LM_WARNING,
00735 "(%P|%t) WARNING - No %s found in Service Repository."
00736 " Using default instance.\n",
00737 "TCP Factory"));
00738
00739 ACE_NEW_RETURN (tcp_factory,
00740 TAO_AV_TCP_Factory,
00741 -1);
00742 }
00743 else tcp_factory->ref_count = 1;
00744
00745 ACE_NEW_RETURN (tcp_item, TAO_AV_Transport_Item ("TCP_Factory"), -1);
00746 tcp_item->factory (tcp_factory);
00747
00748 this->transport_factories_.insert (tcp_item);
00749
00750 #if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
00751 const char *udp_qos_factory_str = "UDP_QoS_Factory";
00752
00753 TAO_AV_Transport_Factory *udp_qos_factory = 0;
00754 TAO_AV_Transport_Item *udp_qos_item = 0;
00755
00756 udp_qos_factory =
00757 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (udp_qos_factory_str);
00758 if (udp_qos_factory == 0)
00759 {
00760 if (TAO_debug_level)
00761 ACE_ERROR ((LM_WARNING,
00762 "(%P|%t) WARNING - No %s found in Service Repository."
00763 " Using default instance.\n",
00764 "UDP QoS Factory"));
00765
00766 ACE_NEW_RETURN (udp_qos_factory,
00767 TAO_AV_UDP_QoS_Factory,
00768 -1);
00769 }
00770 else udp_qos_factory->ref_count = 1;
00771
00772 ACE_NEW_RETURN (udp_qos_item,
00773 TAO_AV_Transport_Item ("UDP_QoS_Factory"),
00774 -1);
00775
00776 udp_qos_item->factory (udp_qos_factory);
00777
00778 this->transport_factories_.insert (udp_qos_item);
00779 #endif
00780
00781 #if defined ACE_HAS_SCTP
00782 const char *sctp_seq_factory_str = "SCTP_SEQ_Factory";
00783
00784 TAO_AV_Transport_Factory *sctp_seq_factory = 0;
00785 TAO_AV_Transport_Item *sctp_seq_item = 0;
00786
00787 sctp_seq_factory =
00788 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (sctp_seq_factory_str);
00789 if (sctp_seq_factory == 0)
00790 {
00791 if (TAO_debug_level)
00792 ACE_ERROR ((LM_WARNING,
00793 "(%P|%t) WARNING - No %s found in Service Repository."
00794 " Using default instance.\n",
00795 "SCTP SEQ Factory"));
00796
00797 ACE_NEW_RETURN (sctp_seq_factory,
00798 TAO_AV_SCTP_SEQ_Factory,
00799 -1);
00800 }
00801 else sctp_seq_factory->ref_count = 1;
00802
00803 ACE_NEW_RETURN (sctp_seq_item,
00804 TAO_AV_Transport_Item ("SCTP_SEQ_Factory"),
00805 -1);
00806
00807 sctp_seq_item->factory (sctp_seq_factory);
00808
00809 this->transport_factories_.insert (sctp_seq_item);
00810 #endif
00811
00812 return 0;
00813 }
00814
00815 int
00816 TAO_AV_Core::init_transport_factories (void)
00817 {
00818 TAO_AV_TransportFactorySetItor end = this->transport_factories_.end ();
00819 TAO_AV_TransportFactorySetItor factory = this->transport_factories_.begin ();
00820
00821
00822 if (factory == end)
00823 {
00824 if (TAO_debug_level > 0)
00825 ACE_DEBUG ((LM_DEBUG,
00826 "Loading default transport protocols\n"));
00827 this->load_default_transport_factories ();
00828 }
00829 else
00830 {
00831 for (; factory != end; factory++)
00832 {
00833 const ACE_CString &name = (*factory)->name ();
00834 if (TAO_debug_level > 0)
00835 ACE_DEBUG ((LM_DEBUG,
00836 "%s\n",
00837 name.c_str ()));
00838
00839 (*factory)->factory (
00840 ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (name.c_str ()));
00841 if ((*factory)->factory () == 0)
00842 {
00843 ACE_ERROR_RETURN ((LM_ERROR,
00844 ACE_TEXT ("TAO (%P|%t) Unable to load ")
00845 ACE_TEXT ("protocol <%s>, %p\n"),
00846 name.c_str (), ""),
00847 -1);
00848 }
00849 (*factory)->factory ()->ref_count = 1;
00850
00851 if (TAO_debug_level > 0)
00852 {
00853 ACE_DEBUG ((LM_DEBUG,
00854 ACE_TEXT ("TAO (%P|%t) Loaded protocol <%s>\n"),
00855 name.c_str ()));
00856 }
00857 }
00858 }
00859
00860 return 0;
00861 }
00862
00863 int
00864 TAO_AV_Core::load_default_flow_protocol_factories (void)
00865 {
00866 const char *udp_flow = "UDP_Flow_Factory";
00867 const char *tcp_flow = "TCP_Flow_Factory";
00868 const char *rtp_flow = "RTP_Flow_Factory";
00869 const char *rtcp_flow = "RTCP_Flow_Factory";
00870 const char *sfp_flow = "SFP_Flow_Factory";
00871
00872 TAO_AV_Flow_Protocol_Factory *udp_flow_factory = 0;
00873 TAO_AV_Flow_Protocol_Item *udp_item = 0;
00874
00875 udp_flow_factory =
00876 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (udp_flow);
00877 if (udp_flow_factory == 0)
00878 {
00879 if (TAO_debug_level)
00880 ACE_ERROR ((LM_WARNING,
00881 "(%P|%t) WARNING - No %s found in Service Repository."
00882 " Using default instance.\n",
00883 "UDP Flow Factory"));
00884
00885 ACE_NEW_RETURN (udp_flow_factory,
00886 TAO_AV_UDP_Flow_Factory,
00887 -1);
00888 }
00889 else udp_flow_factory->ref_count = 1;
00890
00891 ACE_NEW_RETURN (udp_item, TAO_AV_Flow_Protocol_Item ("UDP_Flow_Factory"), -1);
00892 udp_item->factory (udp_flow_factory);
00893
00894 this->flow_protocol_factories_.insert (udp_item);
00895
00896 #if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
00897
00898 const char *udp_qos_flow = "UDP_QoS_Flow_Factory";
00899 TAO_AV_Flow_Protocol_Factory *udp_qos_flow_factory = 0;
00900 TAO_AV_Flow_Protocol_Item *udp_qos_flow_item = 0;
00901
00902 udp_qos_flow_factory =
00903 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (udp_qos_flow);
00904 if (udp_qos_flow_factory == 0)
00905 {
00906 if (TAO_debug_level)
00907 ACE_ERROR ((LM_WARNING,
00908 "(%P|%t) WARNING - No %s found in Service Repository."
00909 " Using default instance.\n",
00910 "UDP QoS Flow Factory"));
00911
00912 ACE_NEW_RETURN (udp_qos_flow_factory,
00913 TAO_AV_UDP_QoS_Flow_Factory,
00914 -1);
00915 }
00916 else udp_qos_flow_factory->ref_count = 1;
00917
00918 ACE_NEW_RETURN (udp_qos_flow_item, TAO_AV_Flow_Protocol_Item ("UDP_QoS_Flow_Factory"), -1);
00919 udp_qos_flow_item->factory (udp_qos_flow_factory);
00920
00921 this->flow_protocol_factories_.insert (udp_qos_flow_item);
00922
00923 #endif
00924
00925 #if defined ACE_HAS_SCTP
00926
00927 const char *sctp_seq_flow = "SCTP_SEQ_Flow_Factory";
00928 TAO_AV_Flow_Protocol_Factory *sctp_seq_flow_factory = 0;
00929 TAO_AV_Flow_Protocol_Item *sctp_seq_flow_item = 0;
00930
00931 sctp_seq_flow_factory =
00932 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (sctp_seq_flow);
00933 if (sctp_seq_flow_factory == 0)
00934 {
00935 if (TAO_debug_level)
00936 ACE_ERROR ((LM_WARNING,
00937 "(%P|%t) WARNING - No %s found in Service Repository."
00938 " Using default instance.\n",
00939 "SCTP SEQ Flow Factory"));
00940
00941 ACE_NEW_RETURN (sctp_seq_flow_factory,
00942 TAO_AV_SCTP_SEQ_Flow_Factory,
00943 -1);
00944 }
00945 else sctp_seq_flow_factory->ref_count = 1;
00946
00947 ACE_NEW_RETURN (sctp_seq_flow_item, TAO_AV_Flow_Protocol_Item ("SCTP_SEQ_Flow_Factory"), -1);
00948 sctp_seq_flow_item->factory (sctp_seq_flow_factory);
00949
00950 this->flow_protocol_factories_.insert (sctp_seq_flow_item);
00951
00952 #endif
00953
00954 TAO_AV_Flow_Protocol_Factory *tcp_flow_factory = 0;
00955 TAO_AV_Flow_Protocol_Item *tcp_item = 0;
00956
00957 tcp_flow_factory =
00958 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (tcp_flow);
00959 if (tcp_flow_factory == 0)
00960 {
00961 if (TAO_debug_level)
00962 ACE_ERROR ((LM_WARNING,
00963 "(%P|%t) WARNING - No %s found in Service Repository."
00964 " Using default instance.\n",
00965 "TCP Flow Factory"));
00966
00967 ACE_NEW_RETURN (tcp_flow_factory,
00968 TAO_AV_TCP_Flow_Factory,
00969 -1);
00970 }
00971 else tcp_flow_factory->ref_count = 1;
00972
00973 ACE_NEW_RETURN (tcp_item, TAO_AV_Flow_Protocol_Item ("TCP_Flow_Factory"), -1);
00974 tcp_item->factory (tcp_flow_factory);
00975
00976 this->flow_protocol_factories_.insert (tcp_item);
00977
00978 TAO_AV_Flow_Protocol_Factory *rtp_flow_factory = 0;
00979 TAO_AV_Flow_Protocol_Item *rtp_item = 0;
00980
00981 rtp_flow_factory =
00982 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (rtp_flow);
00983 if (rtp_flow_factory == 0)
00984 {
00985 if (TAO_debug_level)
00986 ACE_ERROR ((LM_WARNING,
00987 "(%P|%t) WARNING - No %s found in Service Repository."
00988 " Using default instance.\n",
00989 "RTP Flow Factory"));
00990
00991 ACE_NEW_RETURN (rtp_flow_factory,
00992 TAO_AV_RTP_Flow_Factory,
00993 -1);
00994 }
00995 else rtp_flow_factory->ref_count = 1;
00996
00997 ACE_NEW_RETURN (rtp_item, TAO_AV_Flow_Protocol_Item ("RTP_Flow_Factory"), -1);
00998 rtp_item->factory (rtp_flow_factory);
00999
01000 this->flow_protocol_factories_.insert (rtp_item);
01001
01002 TAO_AV_Flow_Protocol_Factory *rtcp_flow_factory = 0;
01003 TAO_AV_Flow_Protocol_Item *rtcp_item = 0;
01004
01005 rtcp_flow_factory =
01006 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (rtcp_flow);
01007 if (rtcp_flow_factory == 0)
01008 {
01009 if (TAO_debug_level)
01010 ACE_ERROR ((LM_WARNING,
01011 "(%P|%t) WARNING - No %s found in Service Repository."
01012 " Using default instance.\n",
01013 "RTCP Flow Factory"));
01014
01015 ACE_NEW_RETURN (rtcp_flow_factory,
01016 TAO_AV_RTCP_Flow_Factory,
01017 -1);
01018 }
01019 else rtcp_flow_factory->ref_count = 1;
01020
01021 ACE_NEW_RETURN (rtcp_item, TAO_AV_Flow_Protocol_Item ("RTCP_Flow_Factory"), -1);
01022 rtcp_item->factory (rtcp_flow_factory);
01023
01024 this->flow_protocol_factories_.insert (rtcp_item);
01025
01026 TAO_AV_Flow_Protocol_Factory *sfp_flow_factory = 0;
01027 TAO_AV_Flow_Protocol_Item *sfp_item = 0;
01028
01029 sfp_flow_factory =
01030 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (sfp_flow);
01031 if (sfp_flow_factory == 0)
01032 {
01033 if (TAO_debug_level)
01034 ACE_ERROR ((LM_WARNING,
01035 "(%P|%t) WARNING - No %s found in Service Repository."
01036 " Using default instance.\n",
01037 "SFP Flow Factory"));
01038
01039 ACE_NEW_RETURN (sfp_flow_factory,
01040 TAO_AV_SFP_Factory,
01041 -1);
01042 }
01043 else sfp_flow_factory->ref_count = 1;
01044
01045 ACE_NEW_RETURN (sfp_item, TAO_AV_Flow_Protocol_Item ("SFP_Flow_Factory"), -1);
01046 sfp_item->factory (sfp_flow_factory);
01047
01048 this->flow_protocol_factories_.insert (sfp_item);
01049
01050 return 0;
01051 }
01052
01053 int
01054 TAO_AV_Core::init_flow_protocol_factories (void)
01055 {
01056 TAO_AV_Flow_ProtocolFactorySetItor end = this->flow_protocol_factories_.end ();
01057 TAO_AV_Flow_ProtocolFactorySetItor factory = this->flow_protocol_factories_.begin ();
01058
01059 if (factory == end)
01060 {
01061 ACE_DEBUG ((LM_DEBUG,
01062 "Loading default flow protocol factories\n"));
01063
01064 this->load_default_flow_protocol_factories ();
01065 }
01066 else
01067 {
01068 for (; factory != end; factory++)
01069 {
01070 const ACE_CString &name = (*factory)->name ();
01071 if (TAO_debug_level > 0)
01072 ACE_DEBUG ((LM_DEBUG,
01073 "%s\n",
01074 name.c_str ()));
01075
01076 (*factory)->factory (
01077 ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (name.c_str ()));
01078 if ((*factory)->factory () == 0)
01079 {
01080 ACE_ERROR_RETURN ((LM_ERROR,
01081 ACE_TEXT ("TAO (%P|%t) Unable to load ")
01082 ACE_TEXT ("protocol <%s>, %p\n"),
01083 name.c_str (), ""),
01084 -1);
01085 }
01086
01087 (*factory)->factory ()->ref_count = 1;
01088
01089 if (TAO_debug_level > 0)
01090 {
01091 ACE_DEBUG ((LM_DEBUG,
01092 ACE_TEXT ("TAO (%P|%t) Loaded protocol <%s>\n"),
01093 name.c_str ()));
01094 }
01095 }
01096 }
01097
01098 return 0;
01099 }
01100
01101
01102 int
01103 TAO_AV_Core::deactivate_servant (PortableServer::Servant servant)
01104 {
01105
01106
01107
01108
01109 try
01110 {
01111 PortableServer::POA_var poa = servant->_default_POA ();
01112
01113 PortableServer::ObjectId_var id = poa->servant_to_id (servant);
01114
01115 poa->deactivate_object (id.in ());
01116 }
01117 catch (const CORBA::Exception& ex)
01118 {
01119 ex._tao_print_exception ("deactivate_servant");
01120 return -1;
01121 }
01122 return 0;
01123 }
01124
01125
01126 char *
01127 TAO_AV_Core::get_flowname (const char *flow_spec_entry_str)
01128 {
01129 ACE_CString flow_spec_entry (flow_spec_entry_str);
01130 ACE_CString::size_type slash_pos = flow_spec_entry.find ('\\');
01131 ACE_CString flow_name;
01132 if (slash_pos != flow_spec_entry.npos)
01133 flow_name = flow_spec_entry.substring (0, slash_pos);
01134 else
01135 flow_name = flow_spec_entry_str;
01136 return CORBA::string_dup (flow_name.c_str ());
01137 }
01138
01139 ACE_CString
01140 TAO_AV_Core::get_control_flowname(const char *flowname)
01141 {
01142 ACE_CString control_flowname;
01143 control_flowname = "c_";
01144 control_flowname = control_flowname + flowname;
01145
01146 return flowname;
01147 }
01148
01149 #if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
01150 template ACE_Singleton<TAO_AV_Core, ACE_Null_Mutex> *ACE_Singleton<TAO_AV_Core, ACE_Null_Mutex>::singleton_;
01151 #endif
01152
01153 TAO_END_VERSIONED_NAMESPACE_DECL