diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/AV')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp | 1793 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h | 891 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.cpp | 392 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.h | 160 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp | 631 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.h | 222 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/README | 28 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/sfp.cpp | 918 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/sfp.h | 197 |
9 files changed, 0 insertions, 5232 deletions
diff --git a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp deleted file mode 100644 index 456673e2aec..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp +++ /dev/null @@ -1,1793 +0,0 @@ - // $Id$ - -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// AVStreams_i.cpp -// -// = AUTHOR -// Sumedh Mungee <sumedh@cs.wustl.edu> -// Nagarajan Surendran <naga@cs.wustl.edu> -// -// -// ============================================================================ - -#include "AVStreams_i.h" -#include "orbsvcs/Trader/Trader.h" - -ACE_RCSID(AV, AVStreams_i, "$Id$") - -// ---------------------------------------------------------------------- -// AV_Null_MediaCtrl -// ---------------------------------------------------------------------- -AV_Null_MediaCtrl::AV_Null_MediaCtrl (void) -{ -} - - -// ---------------------------------------------------------------------- -// TAO_Basic_StreamCtrl -// ---------------------------------------------------------------------- - -// Constructor -TAO_Basic_StreamCtrl::TAO_Basic_StreamCtrl (void) - :flow_count_ (0) -{ -} - -TAO_Basic_StreamCtrl::~TAO_Basic_StreamCtrl (void) -{ -} - -// Stop the transfer of data of the stream -// Empty the_spec means apply operation to all flows -void -TAO_Basic_StreamCtrl::stop (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - if (CORBA::is_nil (this->stream_endpoint_a_.in ())) - return; - - // Make the upcall into the application - this->stream_endpoint_a_->stop (the_spec, env); -} - -// Start the transfer of data in the stream. -// Empty the_spec means apply operation to all flows -void -TAO_Basic_StreamCtrl::start (const AVStreams::flowSpec &flow_spec, - CORBA::Environment &env) -{ - if (CORBA::is_nil (this->stream_endpoint_a_.in ())) - return; - - // Make the upcall into the application - this->stream_endpoint_a_->start (flow_spec, env); -} - -// Tears down the stream. This will close the connection, and delete -// the streamendpoint and vdev associated with this stream -// Empty the_spec means apply operation to all flows -void -TAO_Basic_StreamCtrl::destroy (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - if (CORBA::is_nil (this->stream_endpoint_a_.in ())) - return; - - // Make the upcall into the application - this->stream_endpoint_a_->destroy (the_spec, env); -} - -// Changes the QoS associated with the stream -// Empty the_spec means apply operation to all flows -CORBA::Boolean -TAO_Basic_StreamCtrl::modify_QoS (AVStreams::streamQoS &new_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (new_qos); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); - return 0; -} - -// Used by StreamEndPoint and VDev to inform StreamCtrl of events. -// E.g., loss of flow, reestablishment of flow, etc.. -void -TAO_Basic_StreamCtrl::push_event (const struct CosPropertyService::Property & the_event, - CORBA::Environment &env) -{ - ACE_DEBUG ((LM_DEBUG, - "\n(%P|%t) Recieved event \"")); - ACE_UNUSED_ARG (the_event); - ACE_UNUSED_ARG (env); -} - -// @@ Need to throw not-supported exception here -void -TAO_Basic_StreamCtrl::set_FPStatus (const AVStreams::flowSpec &the_spec, - const char *fp_name, - const CORBA::Any &fp_settings, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (fp_name); - ACE_UNUSED_ARG (fp_settings); - ACE_UNUSED_ARG (env); -} - -// @@ Need to throw not-supported exception here -CORBA::Object_ptr -TAO_Basic_StreamCtrl::get_flow_connection (const char *flow_name, - CORBA::Environment &) -{ - TAO_String_Hash_Key flow_name_key (flow_name); - FlowConnection_Map::ENTRY *flow_connection_entry = 0; - if (this->flow_map_.find (flow_name_key,flow_connection_entry) == 0) - return flow_connection_entry->int_id_; - return 0; -} - -// @@ Need to throw not-supported exception here -void -TAO_Basic_StreamCtrl::set_flow_connection (const char *flow_name, - CORBA::Object_ptr flow_connection, - CORBA::Environment &env) -{ - // add the flowname and the flowconnection to the hashtable. - this->flows_ [this->flow_count_++] = CORBA::string_dup (flow_name); - TAO_String_Hash_Key flow_name_key (flow_name); - if (this->flow_map_.bind (flow_name_key,flow_connection) != 0) - TAO_THROW_ENV (AVStreams::noSuchFlow (),env);// is this right? -} - -// ---------------------------------------------------------------------- -// TAO_StreamCtrl -// ---------------------------------------------------------------------- - -TAO_StreamCtrl::TAO_StreamCtrl (void) -{ -} - -TAO_StreamCtrl::~TAO_StreamCtrl (void) -{ -} - -// request the two MMDevices to create vdev and stream endpoints. save -// the references returned. - -// The interaction diagram for this method is on page 13 of the spec -CORBA::Boolean -TAO_StreamCtrl::bind_devs (AVStreams::MMDevice_ptr a_party, - AVStreams::MMDevice_ptr b_party, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env) -{ - // do a Qos Translation from application level Qos to Network level Qos?? - - // Check to see if we have non-nil parties to bind! - if (CORBA::is_nil (a_party) || - CORBA::is_nil (b_party)) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) TAO_StreamCtrl::bind_devs: " - "a_party or b_party is null" - "Multicast not supported in this implementation!\n"), - 1); - - // Request a_party to create the endpoint and vdev - CORBA::Boolean met_qos; - CORBA::String_var named_vdev; - - this->stream_endpoint_a_ = - a_party-> create_A (this->_this (env), - this->vdev_a_.out (), - the_qos, - met_qos, - named_vdev.inout (), - the_flows, - env); - TAO_CHECK_ENV_RETURN (env, 1); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) TAO_StreamCtrl::create_A: succeeded\n")); - - // Request b_party to create the endpoint and vdev - - this->stream_endpoint_b_ = - b_party-> create_B (this->_this (env), - this->vdev_b_.out (), - the_qos, - met_qos, - named_vdev.inout (), - the_flows, - env); - TAO_CHECK_ENV_RETURN (env, 1); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) TAO_StreamCtrl::create_B: succeeded\n")); - - ACE_DEBUG ((LM_DEBUG, - "\n(%P|%t)stream_endpoint_b_ = %s", - TAO_ORB_Core_instance ()->orb ()->object_to_string (this->stream_endpoint_b_.in (), - env))); - TAO_CHECK_ENV_RETURN (env, 1); - - // Tell the 2 VDev's about one another - this->vdev_a_->set_peer (this->_this (env), - this->vdev_b_.in (), - the_qos, - the_flows, - env); - - TAO_CHECK_ENV_RETURN (env, 1); - - this->vdev_b_->set_peer (this->_this (env), - this->vdev_a_.in (), - the_qos, - the_flows, - env); - - TAO_CHECK_ENV_RETURN (env, 1); - - - // Now connect the streams together. This will - // establish the connection - this->stream_endpoint_a_->connect (this->stream_endpoint_b_.in (), - the_qos, - the_flows, - env); - TAO_CHECK_ENV_RETURN (env, 1); - return 0; -} - -// Used to establish a connection between two endpoints -// directly, i.e. without a MMDevice -CORBA::Boolean -TAO_StreamCtrl::bind (AVStreams::StreamEndPoint_A_ptr sep_a, - AVStreams::StreamEndPoint_B_ptr sep_b, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env) -{ - this->stream_endpoint_a_ = sep_a; - this->stream_endpoint_b_ = sep_b; - - TAO_TRY - { - if (CORBA::is_nil (sep_a) || - CORBA::is_nil (sep_b)) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) TAO_StreamCtrl::bind:" - "a_party or b_party null!"), - 1); - - // since its full profile we do the viable stream setup algorithm. - // get the flows for the A streamendpoint. - if (the_flows.length () == 0) - { - // the flows spec is empty and hence we do a exhaustive match. - AVStreams::flowSpec *a_flows = 0,*b_flows = 0; - AVStreams::FlowEndPoint_seq a_feps,b_feps; - CORBA::Any_ptr flows_any; - flows_any = sep_a->get_property_value ("Flows",TAO_TRY_ENV); - TAO_CHECK_ENV; - *flows_any >>= a_flows; - flows_any = sep_b->get_property_value ("Flows",TAO_TRY_ENV); - TAO_CHECK_ENV; - *flows_any >>= b_flows; - u_int i; - for (i=0;i<a_flows->length ();i++) - { - // get the flowendpoint references. - CORBA::Object_ptr fep_obj; - fep_obj = sep_a->get_fep ((*a_flows)[i], - TAO_TRY_ENV); - TAO_CHECK_ENV; - AVStreams::FlowEndPoint_ptr fep; - fep = AVStreams::FlowEndPoint::_narrow (fep_obj, - TAO_TRY_ENV); - TAO_CHECK_ENV; - a_feps [i] = fep; - } - // get the flowendpoints for streamendpoint_b - for (i=0;i<b_flows->length ();i++) - { - // get the flowendpoint references. - CORBA::Object_ptr fep_obj; - fep_obj = sep_b->get_fep ((*b_flows)[i], - TAO_TRY_ENV); - TAO_CHECK_ENV; - AVStreams::FlowEndPoint_ptr fep; - fep = AVStreams::FlowEndPoint::_narrow (fep_obj, - TAO_TRY_ENV); - TAO_CHECK_ENV; - b_feps [i] = fep; - } - // Now go thru the list of flow endpoint and match them. - // uses the first match policy. - for (i=0;i<a_feps.length ();i++) - { - for (u_int j=0;j<b_feps.length ();j++) - { - AVStreams::FlowEndPoint_ptr fep_a = - AVStreams::FlowEndPoint::_narrow (a_feps [i],TAO_TRY_ENV); - TAO_CHECK_ENV; - AVStreams::FlowEndPoint_ptr fep_b = - AVStreams::FlowEndPoint::_narrow (b_feps [j],TAO_TRY_ENV); - - if (fep_b->get_connected_fep () != 0) - { - if (fep_a->is_fep_compatible (fep_b, - TAO_TRY_ENV) == 1) - { - // assume that flow names are same so that we - // can use either of them. - CORBA::Object_ptr flow_connection_obj; - AVStreams::FlowConnection_ptr flow_connection; - if ((flow_connection_obj - = this->get_flow_connection ((*a_flows)[i],TAO_TRY_ENV))!= 0) - { - flow_connection = AVStreams::FlowConnection::_narrow (flow_connection_obj,TAO_TRY_ENV); - TAO_CHECK_ENV; - } - else - { - TAO_FlowConnection *flowConnection; - ACE_NEW_RETURN (flowConnection,TAO_FlowConnection,0); - flow_connection = flowConnection->_this (TAO_TRY_ENV); - TAO_CHECK_ENV; - } - // make sure that a_feps is flow_producer and b_feps is flow_consumer - // There should be a way to find which flow endpoint is producer and which is consumer. - AVStreams::FlowProducer_ptr producer = - AVStreams::FlowProducer::_narrow (fep_a,TAO_TRY_ENV); - TAO_CHECK_ENV; - AVStreams::FlowConsumer_ptr consumer = - AVStreams::FlowConsumer::_narrow (fep_b,TAO_TRY_ENV); - TAO_CHECK_ENV; - // what should be passed to QoS? - flow_connection->connect (producer,consumer,the_qos [0],env); - fep_a->set_peer (flow_connection,fep_b,the_qos[0],env); - fep_b->set_peer (flow_connection,fep_a,the_qos[0],env); - } - } - } - } - } - else - { - // since the flow spec is not empty we need to query for the - // flows mentioned on both the A and B sides. - // not implemented yet. - } - } - TAO_CATCHANY - { - // error was thrown because one of the streamendpoints is light profile. - // Now connect the streams together - this->stream_endpoint_a_->connect (this->stream_endpoint_b_.in (), - the_qos, - the_flows, - env); - TAO_CHECK_ENV_RETURN (env, 1); - } - TAO_ENDTRY; - return 0; -} - -void -TAO_StreamCtrl::unbind (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -void -TAO_StreamCtrl::unbind_party (AVStreams::StreamEndPoint_ptr the_ep, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); -} - -// ---------------------------------------------------------------------- -// TAO_Base_StreamEndPoint -// ---------------------------------------------------------------------- - -TAO_Base_StreamEndPoint::~TAO_Base_StreamEndPoint (void) -{ -} - -int TAO_Base_StreamEndPoint::handle_close (void) -{ - // This method should not be defined, but EGCS complains endlessly - // about it. - return -1; -} - -// ---------------------------------------------------------------------- -// TAO_StreamEndPoint -// ---------------------------------------------------------------------- - -// constructor. -TAO_StreamEndPoint::TAO_StreamEndPoint (void) - :flow_count_ (1) -{ - // this->handle_open (); -} - -// Stop the physical flow of data on the stream -// Empty the_spec --> apply to all flows -void -TAO_StreamEndPoint::stop (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - // Make the upcall into the app - this->handle_stop (the_spec, env); -} - -// Start the physical flow of data on the stream -// Empty the_spec --> apply to all flows -void -TAO_StreamEndPoint::start (const AVStreams::flowSpec &flow_spec, - CORBA::Environment &env) -{ - // Make the upcall into the app - this->handle_start (flow_spec, env); -} - -// Close the connection -void -TAO_StreamEndPoint::destroy (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - // Make the upcall into the app - this->handle_destroy (the_spec, env); -} - -// Called by streamctrl, requesting us to call request_connection -// on the responder (to initiate a connection) -CORBA::Boolean -TAO_Server_StreamEndPoint::connect (AVStreams::StreamEndPoint_ptr responder, - AVStreams::streamQoS &qos_spec, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &) -{ - ACE_UNUSED_ARG (responder); - ACE_UNUSED_ARG (qos_spec); - ACE_UNUSED_ARG (the_spec); - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Calling TAO_Server_StreamEndPoint::connect" - " is not compatible with the spec!" - "\n"), - 0); -} - -// Called by our peer endpoint, requesting us to establish -// a connection -CORBA::Boolean -TAO_StreamEndPoint::request_connection (AVStreams::StreamEndPoint_ptr initiator, - CORBA::Boolean is_mcast, - AVStreams::streamQoS &qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &) -{ - ACE_UNUSED_ARG (initiator); - ACE_UNUSED_ARG (is_mcast); - ACE_UNUSED_ARG (qos); - - ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) TAO_StreamEndPoint::request_connection called")); - ACE_DEBUG ((LM_DEBUG, - "\n(%P|%t) TAO_StreamEndPoint::request_connection: " - "flowspec has length = %d" - "and the strings are:", - the_spec.length ())); - for (u_int i = 0; i < the_spec.length (); i++) - ACE_DEBUG ((LM_DEBUG, - the_spec [i])); - - return 0; -} - -// @@ Need to throw not-supported exception here -CORBA::Boolean -TAO_StreamEndPoint::modify_QoS (AVStreams::streamQoS &new_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (new_qos); - ACE_UNUSED_ARG (the_flows); - ACE_UNUSED_ARG (env); - return 0; -} - -// @@ Need to throw not-supported exception here -CORBA::Boolean -TAO_StreamEndPoint::set_protocol_restriction (const AVStreams::protocolSpec &the_pspec, - CORBA::Environment &env) -{ - CORBA::Any protocol_restriction_any; - - protocol_restriction_any <<= the_pspec; - this->define_property ("ProtocolRestriction", - protocol_restriction_any, - env); - TAO_CHECK_ENV_RETURN (env,0); - return 1; -} - -void -TAO_StreamEndPoint::disconnect (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); -} - -// @@ Need to throw not-supported exception here -void -TAO_StreamEndPoint::set_FPStatus (const AVStreams::flowSpec &the_spec, - const char *fp_name, - const CORBA::Any &fp_settings, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (fp_name); - ACE_UNUSED_ARG (fp_settings); - ACE_UNUSED_ARG (env); -} - -CORBA::Object_ptr -TAO_StreamEndPoint::get_fep (const char *flow_name, - CORBA::Environment &) -{ - TAO_String_Hash_Key fep_name_key (flow_name); - FlowEndPoint_Map::ENTRY *fep_entry = 0; - if (this->fep_map_.find (fep_name_key,fep_entry) == 0) - return fep_entry->int_id_; - return 0; -} - -char * -TAO_StreamEndPoint::add_fep (CORBA::Object_ptr the_fep, - CORBA::Environment &env) -{ - char *flow_name = 0; - ACE_NEW_RETURN (flow_name,char [BUFSIZ],0); - CORBA::Any_ptr flow_name_any; - AVStreams::FlowEndPoint_ptr fep = - AVStreams::FlowEndPoint::_narrow (the_fep,env); - TAO_CHECK_ENV_RETURN (env,0); - TAO_TRY - { - flow_name_any = fep->get_property_value ("FlowName",TAO_TRY_ENV); - TAO_CHECK_ENV; - - *flow_name_any >>= flow_name; - } - TAO_CATCHANY - { - // exception implies the flow name is not defined and is system generated. - ACE_OS::sprintf (flow_name,"flow%d",flow_num_++); - } - // Add it to the sequence of flowNames supported. - // put the flowname and the flowendpoint in a hashtable. - TAO_String_Hash_Key fep_name_key (flow_name); - if (this->fep_map_.bind (fep_name_key,the_fep) != 0) - TAO_THROW_ENV_RETURN (AVStreams::streamOpFailed (),env,0); - - // increment the flow count. - this->flow_count_++; - this->flows_.length (this->flow_count_); - this->flows_ [this->flow_count_-1] = flow_name; - // define/modify the "Flows" property. - CORBA::Any flows_any; - flows_any <<= this->flows_; - this->define_property ("Flows", - flows_any, - env); - TAO_CHECK_ENV_PRINT_RETURN (env,"TAO_StreamEndPoint::add_fep",0); - TAO_ENDTRY; - return flow_name; -} - -void -TAO_StreamEndPoint::remove_fep (const char *flow_name, - CORBA::Environment &env) -{ - TAO_String_Hash_Key fep_name_key (flow_name); - CORBA::Object_ptr fep_entry = 0; - // Remove the fep from the hash table. - if (this->fep_map_.unbind (fep_name_key,fep_entry)!= 0) - TAO_THROW_ENV (AVStreams::streamOpFailed (),env); - // redefine the "Flows" property - AVStreams::flowSpec new_flows (this->flows_.length ()); - for (u_int i=0,j=0 ; i <this->flows_.length (); i++) - if (ACE_OS::strcmp (flow_name,this->flows_[i]) != 0) - new_flows[j++] = this->flows_[i]; - - CORBA::Any flows; - flows <<= new_flows; - this->flows_ = new_flows; - this->define_property ("Flows", - flows, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_StreamEndPoint::remove_fep"); - return; -} - -// @@ Need to throw not-supported exception here -void -TAO_StreamEndPoint::set_negotiator (AVStreams::Negotiator_ptr new_negotiator, - CORBA::Environment &env) -{ - CORBA::Any negotiator; - negotiator <<= new_negotiator; - this->define_property ("Negotiator", - negotiator, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_StreamEndPoint::set_negotiator"); - return; -} - -// Sets the public key used for this streamendpoint. -void -TAO_StreamEndPoint::set_key (const char *flow_name, - const AVStreams::key & the_key, - CORBA::Environment &env) -{ - CORBA::Any PublicKey; - PublicKey <<= the_key; - char PublicKey_property [BUFSIZ]; - ACE_OS::sprintf (PublicKey_property,"%s_PublicKey",flow_name); - this->define_property (PublicKey_property, - PublicKey, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_StreamEndPoint::set_key"); - return; -} - -// Set the source id. -void -TAO_StreamEndPoint::set_source_id (CORBA::Long source_id, - CORBA::Environment &) -{ - this->source_id_ = source_id; -} - -TAO_StreamEndPoint::~TAO_StreamEndPoint (void) -{ - //this->handle_close (); -} - -// ---------------------------------------------------------------------- -// TAO_Client_StreamEndPoint -// ---------------------------------------------------------------------- - -TAO_Client_StreamEndPoint::TAO_Client_StreamEndPoint (void) -{ - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) TAO_Client_StreamEndPoint::TAO_Client_StreamEndPoint: created\n")); -} - -CORBA::Boolean -TAO_Client_StreamEndPoint::connect (AVStreams::StreamEndPoint_ptr responder, - AVStreams::streamQoS &qos_spec, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - AVStreams::flowSpec flow_spec (the_spec); - this->handle_preconnect (flow_spec); - - // Use the base class implementation of connect - responder->request_connection (this->_this (env), - 0, - qos_spec, - flow_spec, - env); - - TAO_CHECK_ENV_RETURN (env,0); - - // Make the upcall to the app - return this->handle_postconnect (flow_spec); - - -} - - -// @@ Need to throw not-supported exception here -CORBA::Boolean -TAO_Client_StreamEndPoint::multiconnect (AVStreams::streamQoS &the_qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); - return 0; -} - -// Multicast is not supported yet. -CORBA::Boolean -TAO_Client_StreamEndPoint::connect_leaf (AVStreams::StreamEndPoint_B_ptr the_ep, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (the_flows); - ACE_UNUSED_ARG (env); - return 0; -} - -// Multicast not supported yet. -void -TAO_Client_StreamEndPoint::disconnect_leaf (AVStreams::StreamEndPoint_B_ptr the_ep, - const AVStreams::flowSpec &theSpec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (theSpec); - ACE_UNUSED_ARG (env); -} - -TAO_Client_StreamEndPoint::~TAO_Client_StreamEndPoint (void) -{ -} - -// ---------------------------------------------------------------------- -// TAO_Server_StreamEndPoint -// ---------------------------------------------------------------------- - -TAO_Server_StreamEndPoint::TAO_Server_StreamEndPoint (void) -{ - ACE_DEBUG ((LM_DEBUG, - "\n(%P|%t) TAO_Server_StreamEndPoint::TAO_Server_StreamEndPoint: created")); -} - -CORBA::Boolean -TAO_Server_StreamEndPoint::request_connection (AVStreams::StreamEndPoint_ptr initiator, - CORBA::Boolean is_mcast, - AVStreams::streamQoS &qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env) - -{ - // Use the base class implementation of request_connection - TAO_StreamEndPoint::request_connection (initiator, - is_mcast, - qos, - the_spec, - env); - - TAO_CHECK_ENV_RETURN (env,0); - // Make the upcall to the app - return this->handle_connection_requested (the_spec, - env); - -} -CORBA::Boolean -TAO_Server_StreamEndPoint::multiconnect (AVStreams::streamQoS &the_qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); - return 0; -} - -TAO_Server_StreamEndPoint::~TAO_Server_StreamEndPoint (void) -{ -} - -// ---------------------------------------------------------------------- -// TAO_VDev -// ---------------------------------------------------------------------- - -TAO_VDev::TAO_VDev (void) -{ - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) TAO_VDev::TAO_VDev: created\n")); -} - -// StreamCtrl will call this to give us a reference to itself, and to -// our peer vdev.. -CORBA::Boolean -TAO_VDev::set_peer (AVStreams::StreamCtrl_ptr the_ctrl, - AVStreams::VDev_ptr the_peer_dev, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (the_spec); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) TAO_VDev::set_peer: called")); - - CORBA::String_var ior = TAO_ORB_Core_instance ()->orb ()->object_to_string (the_peer_dev, - env); - - TAO_CHECK_ENV_RETURN (env, - 0); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) TAO_VDev::set_peer: my peer is %s\n", - ior.in ())); - - CORBA::Any anyval; - anyval <<= ior.in (); - this->define_property ("Related_VDev", - anyval, - env); - - TAO_CHECK_ENV_RETURN (env, - 0); - - this->streamctrl_ = the_ctrl; - this->peer_ = the_peer_dev; - - CORBA::Any_ptr anyptr; - CORBA::String media_ctrl_ior; - anyptr = this->peer_->get_property_value ("Related_MediaCtrl", - env); - TAO_CHECK_ENV_RETURN (env,1); - - if (anyptr != 0) - { - *anyptr >>= media_ctrl_ior; - ACE_DEBUG ((LM_DEBUG,"(%P|%t)The Media Control IOR is %s\n", - media_ctrl_ior)); - } - CORBA::Object_ptr media_ctrl_obj = - TAO_ORB_Core_instance ()->orb ()->string_to_object - (media_ctrl_ior,env); - TAO_CHECK_ENV_RETURN (env, 0); - - CORBA::Boolean result = - this->set_media_ctrl (media_ctrl_obj,env); - TAO_CHECK_ENV_RETURN (env,0); - - return result; -} - -CORBA::Boolean -TAO_VDev::set_media_ctrl (CORBA::Object_ptr media_ctrl, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (media_ctrl); - ACE_UNUSED_ARG (env); - return 1; -} - -// Multicast is not supported yet. -CORBA::Boolean -TAO_VDev::set_Mcast_peer (AVStreams::StreamCtrl_ptr the_ctrl, - AVStreams::MCastConfigIf_ptr a_mcastconfigif, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_ctrl); - ACE_UNUSED_ARG (a_mcastconfigif); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); - return 0; -} - -// applications should override this to handle configuration changes. -void -TAO_VDev::configure (const CosPropertyService::Property &the_config_mesg, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_config_mesg); - ACE_UNUSED_ARG (env); -} - -// sets the media format used for the flowname as a property. -void -TAO_VDev::set_format (const char *flowName, - const char *format_name, - CORBA::Environment &env) -{ - if (flowName == 0 || format_name == 0) - ACE_ERROR ((LM_ERROR,"TAO_VDev::set_format: flowName or format_name is null\n")); - char format_property [BUFSIZ]; - ACE_OS::sprintf (format_property,"%s_currFormat",flowName); - CORBA::Any format; - format <<= format_name; - this->define_property (format_property, - format, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"set_format"); - return; -} - -// sets the device parameters for the flowname as a property. -void -TAO_VDev::set_dev_params (const char *flowName, - const CosPropertyService::Properties &new_params, - CORBA::Environment &env) -{ - if (flowName == 0) - ACE_ERROR ((LM_ERROR,"TAO_VDev::set_dev_params:flowName is null\n")); - char devParams_property[BUFSIZ]; - ACE_OS::sprintf (devParams_property,"%s_devParams",flowName); - CORBA::Any devParams; - devParams <<= new_params; - this->define_property (devParams_property, - devParams, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_VDev::set_dev_params"); - return; -} - -// QoS Modification should be handled by the application currently. -CORBA::Boolean -TAO_VDev::modify_QoS (AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); - return 0; -} - -TAO_VDev::~TAO_VDev (void) -{ -} - -// ---------------------------------------------------------------------- -// TAO_MMDevice -// ---------------------------------------------------------------------- - - -TAO_MMDevice::TAO_MMDevice (TAO_AV_Endpoint_Strategy *endpoint_strategy) - : endpoint_strategy_ (endpoint_strategy) -{ -} - -// create a streamctrl which is colocated with me, use that streamctrl -// to bind the peer_device with me. -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, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (is_met); - TAO_StreamCtrl *stream_ctrl; - ACE_NEW_RETURN (stream_ctrl, - TAO_StreamCtrl, - 0); - stream_ctrl->bind_devs (peer_device, - AVStreams::MMDevice::_duplicate (this->_this (env)), - the_qos, - the_spec, - env); - TAO_CHECK_ENV_PRINT_RETURN (env,"TAO_MMDevice::bind",0); - return stream_ctrl->_this (env); -} - -// Multicast is not supported yet. -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, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (first_peer); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (is_met); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (env); - return 0; -} - -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, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_requester); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (met_qos); - ACE_UNUSED_ARG (named_vdev); - ACE_UNUSED_ARG (the_spec); - // In full profile application can override this to use FDevs. - AVStreams::StreamEndPoint_A_ptr ptr; - if (this->endpoint_strategy_->create_A (ptr, - the_vdev, - env) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Error in create_A\n"), - 0); - - TAO_CHECK_ENV_RETURN (env, 0); - - return ptr; -} - - -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, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_requester); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (met_qos); - ACE_UNUSED_ARG (named_vdev); - ACE_UNUSED_ARG (the_spec); - - // In full profile application can override this to use FDevs. - AVStreams::StreamEndPoint_B_ptr ptr; - if (this->endpoint_strategy_->create_B (ptr, - the_vdev, - env) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Error in create_B\n"), - 0); - - TAO_CHECK_ENV_RETURN (env, 0); - - return ptr; -} - -// destroys the streamendpoint and the Vdev. -void -TAO_MMDevice::destroy (AVStreams::StreamEndPoint_ptr the_ep, - const char *vdev_name, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (vdev_name); - ACE_UNUSED_ARG (env); -} - -// Adds the fdev object to the MMDevice. -char * -TAO_MMDevice::add_fdev (CORBA::Object_ptr the_fdev, - CORBA::Environment &env) -{ - char *flow_name = 0; - ACE_NEW_RETURN (flow_name,char [BUFSIZ],0); - CORBA::Any_ptr flow_name_any; - AVStreams::FDev_ptr fdev = - AVStreams::FDev::_narrow (the_fdev,env); - TAO_CHECK_ENV_RETURN (env,0); - TAO_TRY - { - flow_name_any = fdev->get_property_value ("Flow",TAO_TRY_ENV); - TAO_CHECK_ENV; - *flow_name_any >>= flow_name; - } - TAO_CATCHANY - { - // exception implies the flow name is not defined and is system generated. - ACE_OS::sprintf (flow_name,"flow%d",flow_num_++); - } - // Add it to the sequence of flowNames supported. - // put the flowname and the fdev in a hashtable. - TAO_String_Hash_Key fdev_name_key (flow_name); - if (this->fdev_map_.bind (fdev_name_key,the_fdev) != 0) - TAO_THROW_ENV_RETURN (AVStreams::streamOpFailed (),env,0); - - // increment the flow count. - this->flow_count_++; - this->flows_.length (this->flow_count_); - this->flows_ [this->flow_count_-1] = flow_name; - // define/modify the "Flows" property. - CORBA::Any flows_any; - flows_any <<= this->flows_; - this->define_property ("Flows", - flows_any, - env); - TAO_CHECK_ENV_PRINT_RETURN(env,"TAO_MMDevice::add_fdev",0); - TAO_ENDTRY; - return flow_name; -} - -// Gets the FDev object associated with this flow. -CORBA::Object_ptr -TAO_MMDevice::get_fdev (const char *flow_name, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - - TAO_String_Hash_Key fdev_name_key (flow_name); - FDev_Map::ENTRY *fdev_entry = 0; - if (this->fdev_map_.find (fdev_name_key,fdev_entry) == 0) - return fdev_entry->int_id_; - return 0; -} - -// Removes the fdev from this MMDevice. -void -TAO_MMDevice::remove_fdev (const char *flow_name, - CORBA::Environment &env) -{ - TAO_String_Hash_Key fdev_name_key (flow_name); - CORBA::Object_ptr fdev_entry = 0; - // Remove the fep from the hash table. - if (this->fdev_map_.unbind (flow_name,fdev_entry)!= 0) - TAO_THROW_ENV (AVStreams::streamOpFailed (),env); - - AVStreams::flowSpec new_flows (this->flows_.length ()); - for (u_int i=0,j=0 ; i <this->flows_.length (); i++) - if (ACE_OS::strcmp (flow_name,this->flows_[i]) != 0) - new_flows[j++] = this->flows_[i]; - - CORBA::Any flows; - flows <<= new_flows; - this->flows_ = new_flows; - this->define_property ("Flows", - flows, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_MMDevice::remove_fdev"); - return; -} - -// destructor. -TAO_MMDevice::~TAO_MMDevice (void) -{ -} - -//------------------------------------------------------------------ -// TAO_FlowConnection -//------------------------------------------------------------------ - -// default constructor. -TAO_FlowConnection::TAO_FlowConnection (void) - :producer_ (0), - consumer_ (0), - fp_name_ (0) -{ -} - -// stop this flow. -void -TAO_FlowConnection::stop (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -// start this flow. -void -TAO_FlowConnection::start (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -// destroy this flow. -void -TAO_FlowConnection::destroy (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -// modify the QoS for this flow. -CORBA::Boolean -TAO_FlowConnection::modify_QoS (AVStreams::QoS & new_qos, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (new_qos); - ACE_UNUSED_ARG (env); - return 0; -} - -// use the specified flow protocol for this flow. -CORBA::Boolean -TAO_FlowConnection::use_flow_protocol (const char * fp_name, - const CORBA::Any & fp_settings, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (fp_settings); - ACE_UNUSED_ARG (env); - this->fp_name_ = (char *)fp_name; - return 1; -} - -void -TAO_FlowConnection::push_event (const AVStreams::streamEvent & the_event, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_event); - ACE_UNUSED_ARG (env); -} - -CORBA::Boolean -TAO_FlowConnection::connect_devs (AVStreams::FDev_ptr a_party, - AVStreams::FDev_ptr b_party, - AVStreams::QoS & the_qos, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (a_party); - ACE_UNUSED_ARG (b_party); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (env); - return 0; -} - -// connect the producer and the consumer -CORBA::Boolean -TAO_FlowConnection::connect (AVStreams::FlowProducer_ptr flow_producer, - AVStreams::FlowConsumer_ptr flow_consumer, - AVStreams::QoS & the_qos, - CORBA::Environment &env) -{ - this->producer_ = flow_producer; - this->consumer_ = flow_consumer; - - this->producer_->set_peer (this->_this (env), - this->consumer_, - the_qos, - env); - TAO_CHECK_ENV_RETURN (env,0); - - this->consumer_->set_peer (this->_this (env), - this->producer_, - the_qos, - env); - TAO_CHECK_ENV_RETURN (env,0); - - char *consumer_address = - this->consumer_->go_to_listen (the_qos, - 0,// false for is_mcast - this->producer_, - this->fp_name_, - env); - - TAO_CHECK_ENV_RETURN (env,0); - this->producer_->connect_to_peer (the_qos, - consumer_address, - this->fp_name_, - env); - TAO_CHECK_ENV_RETURN (env,0); - return 1; -} - - -CORBA::Boolean -TAO_FlowConnection::disconnect (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - return 0; -} - -CORBA::Boolean -TAO_FlowConnection::add_producer (AVStreams::FlowProducer_ptr flow_producer, - AVStreams::QoS & the_qos, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (env); - this->producer_ = flow_producer; - return 1; -} - -CORBA::Boolean -TAO_FlowConnection::add_consumer (AVStreams::FlowConsumer_ptr flow_consumer, - AVStreams::QoS & the_qos, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (env); - this->consumer_ = flow_consumer; - return 1; -} - -CORBA::Boolean -TAO_FlowConnection::drop (AVStreams::FlowEndPoint_ptr target, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (target); - ACE_UNUSED_ARG (env); - return 0; -} - -// ----------------------------------------------------------------- -// TAO_FlowEndPoint -// ----------------------------------------------------------------- - -//default constructor. -TAO_FlowEndPoint::TAO_FlowEndPoint (void) - :related_sep_ (0), - related_flow_connection_ (0) -{ -} - -// used by one flowconnection so that multiple connections cant use -// the same flowendpoint. -CORBA::Boolean -TAO_FlowEndPoint::lock (CORBA::Environment &env) -{ - // lock the current flowendpoint - ACE_UNUSED_ARG (env); - return 0; -} - -// unlocks the flowendpoint ,becomes free to be used in another flow. -void -TAO_FlowEndPoint::unlock (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -// The start,stop and destroy are to be handled by the application. -void -TAO_FlowEndPoint::stop (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -void -TAO_FlowEndPoint::start (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -void -TAO_FlowEndPoint::destroy (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); -} - -AVStreams::StreamEndPoint_ptr -TAO_FlowEndPoint::related_sep (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - return this->related_sep_; -} - -void -TAO_FlowEndPoint::related_sep (AVStreams::StreamEndPoint_ptr related_sep, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - this->related_sep_ = related_sep; -} - -AVStreams::FlowConnection_ptr -TAO_FlowEndPoint::related_flow_connection (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - return this->related_flow_connection_; -} - -void -TAO_FlowEndPoint::related_flow_connection (AVStreams::FlowConnection_ptr related_flow_connection, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - this->related_flow_connection_ = related_flow_connection; -} - -// returns the connected peer for this flow -AVStreams::FlowEndPoint_ptr -TAO_FlowEndPoint::get_connected_fep (CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - return this->peer_fep_; -} - -CORBA::Boolean -TAO_FlowEndPoint::use_flow_protocol (const char * fp_name, - const CORBA::Any & fp_settings, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (fp_settings); - // Define the property called FlowProtocol - CORBA::Any flowname_property; - flowname_property <<= fp_name; - this->define_property ("FlowProtocol", - flowname_property, - env); - TAO_CHECK_ENV_RETURN (env,0); - return 1; -} - -void -TAO_FlowEndPoint::set_format (const char * format, - CORBA::Environment &env) -{ - // make this a property so that is_fep_compatible can query this and - // check if 2 flowendpoints are compatible. - CORBA::Any format_val; - format_val <<= format; - this->define_property ("Format", - format_val, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_FlowEndPoint::set_format"); -} - -void -TAO_FlowEndPoint::set_dev_params (const CosPropertyService::Properties & new_settings, - CORBA::Environment &env) -{ - CORBA::Any DevParams_property; - DevParams_property <<= new_settings; - this->define_property ("DevParams", - DevParams_property, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_FlowEndPoint::set_dev_params"); - -} - -void -TAO_FlowEndPoint::set_protocol_restriction (const AVStreams::protocolSpec & the_spec, - CORBA::Environment &env) -{ - CORBA::Any AvailableProtocols_property; - AvailableProtocols_property <<= the_spec; - this->define_property ("AvailableProtocols", - AvailableProtocols_property, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_FlowEndPoint::set_protocol_restriction"); - -} - -CORBA::Boolean -TAO_FlowEndPoint::is_fep_compatible (AVStreams::FlowEndPoint_ptr peer_fep, - CORBA::Environment &env) -{ - // check whether the passed flowendpoint is compatible with this flowendpoint. - // should we check for the availableFormats and choose one format. - // get my format value - CORBA::Any_ptr format_ptr; - CORBA::String my_format,peer_format; - format_ptr = this->get_property_value ("Format", - env); - TAO_CHECK_ENV_PRINT_RETURN (env,"TAO_FlowEndPoint::is_fep_compatible",0); - if (format_ptr != 0) - *format_ptr >>= my_format; - else - // property is not defined - ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) TAO_FlowEndPoint::is_fep_compatible"),0); - - // get my peer's format value - - format_ptr = peer_fep->get_property_value ("Format", - env); - TAO_CHECK_ENV_PRINT_RETURN (env,"TAO_FlowEndPoint::is_fep_compatible",0); - if (format_ptr != 0) - *format_ptr >>= peer_format; - else - // property is not defined - ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) TAO_FlowEndPoint::is_fep_compatible"),0); - - // can we use strcmp?? - if (ACE_OS::strcmp (my_format,peer_format) != 0) - return 0; - // since formats are same, check for a common protocol - CORBA::Any* AvailableProtocols_ptr; - AVStreams::protocolSpec *my_protocolSpec,*peer_protocolSpec; - - AvailableProtocols_ptr = this->get_property_value ("AvailableProtocols", - env); - TAO_CHECK_ENV_PRINT_RETURN (env,"TAO_FlowEndPoint::is_fep_compatible",0); - if (AvailableProtocols_ptr != 0) - *AvailableProtocols_ptr >>= my_protocolSpec; - else - ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) TAO_FlowEndPoint::is_fep_compatible"),0); - - AvailableProtocols_ptr = peer_fep->get_property_value ("AvailableProtocols", - env); - TAO_CHECK_ENV_PRINT_RETURN (env,"TAO_FlowEndPoint::AvailableProtocols",0); - if (AvailableProtocols_ptr != 0) - *AvailableProtocols_ptr >>= peer_protocolSpec; - - return 1; -} - -CORBA::Boolean -TAO_FlowEndPoint::set_peer (AVStreams::FlowConnection_ptr the_fc, - AVStreams::FlowEndPoint_ptr the_peer_fep, - AVStreams::QoS & the_qos, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_fc); - ACE_UNUSED_ARG (the_peer_fep); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (env); - - this->peer_fep_ = the_peer_fep; - return 1; -} - -CORBA::Boolean -TAO_FlowEndPoint::set_Mcast_peer (AVStreams::FlowConnection_ptr the_fc, - AVStreams::MCastConfigIf_ptr a_mcastconfigif, - AVStreams::QoS & the_qos, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_fc); - ACE_UNUSED_ARG (a_mcastconfigif); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (env); - return 0; -} - -// ------------------------------------------------------------ -// TAO_FlowProducer class -// ------------------------------------------------------------ - -//default constructor -TAO_FlowProducer::TAO_FlowProducer (void) -{ -} - -CORBA::Boolean -TAO_FlowProducer::connect_to_peer (AVStreams::QoS & the_qos, - const char * address, - const char * use_flow_protocol, - CORBA::Environment &env) -{ - // Right now since the A/V framework doesnt bother about the - // protocols we leave it to the application to handle the connection - // to its peer. When A/V Streams implements common protocol - // interaction like UDP and TCP this will be handled by the - // framework. - - return this->handle_connect_to_peer (the_qos,address,use_flow_protocol,env); -} - -CORBA::Boolean -TAO_FlowProducer::handle_connect_to_peer (AVStreams::QoS & the_qos, - const char * address, - const char * use_flow_protocol, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (address); - ACE_UNUSED_ARG (use_flow_protocol); - ACE_UNUSED_ARG (env); - return 0; -} - - -// multicast is currently not supported -char * -TAO_FlowProducer::connect_mcast (AVStreams::QoS & the_qos, - CORBA::Boolean_out is_met, - const char * address, - const char * use_flow_protocol, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (is_met); - ACE_UNUSED_ARG (address); - ACE_UNUSED_ARG (use_flow_protocol); - ACE_UNUSED_ARG (env); - return 0; -} - -// gets the reverse channel for feedback. -char * -TAO_FlowProducer::get_rev_channel (const char * pcol_name, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (pcol_name); - ACE_UNUSED_ARG (env); - return 0; -} - -// sets the key for this flow. -void -TAO_FlowProducer::set_key (const AVStreams::key & the_key, - CORBA::Environment &env) -{ - CORBA::Any anyval; - anyval <<= the_key; - this->define_property ("PublicKey", - anyval, - env); - TAO_CHECK_ENV_PRINT_RETURN_VOID (env,"TAO_FlowProducer::set_key"); -} - -// source id to be used to distinguish this source from others. -void -TAO_FlowProducer::set_source_id (CORBA::Long source_id, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (env); - this->source_id_ = source_id; -} - -// ------------------------------------------------------------ -// TAO_FlowConsumer -// ------------------------------------------------------------ - - -// default constructor. -TAO_FlowConsumer::TAO_FlowConsumer (void) -{ -} - -char * -TAO_FlowConsumer::go_to_listen (AVStreams::QoS & the_qos, - CORBA::Boolean is_mcast, - AVStreams::FlowProducer_ptr peer, - char *& flowProtocol, - CORBA::Environment &env) -{ - return this->handle_go_to_listen (the_qos,is_mcast,peer,flowProtocol,env); -} - -char * -TAO_FlowConsumer::handle_go_to_listen (AVStreams::QoS & the_qos, - CORBA::Boolean is_mcast, - AVStreams::FlowProducer_ptr peer, - char *& flowProtocol, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (is_mcast); - ACE_UNUSED_ARG (peer); - ACE_UNUSED_ARG (flowProtocol); - ACE_UNUSED_ARG (env); - - return 0; -} - -// ------------------------------------------------------------ -// TAO_FDev -// ------------------------------------------------------------ - -// default constructor -TAO_FDev::TAO_FDev (void) - :producer_ (0), - consumer_ (0) -{ -} - -AVStreams::FlowProducer_ptr -TAO_FDev::create_producer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env) -{ - // call the bridge method. - this->producer_ = this->make_producer (the_requester, - the_qos, - met_qos, - named_fdev, - env); - return this->producer_; -} - -// hook for the applications to override the creation process. -AVStreams::FlowProducer_ptr -TAO_FDev::make_producer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_requester); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (met_qos); - ACE_UNUSED_ARG (named_fdev); - - // memory leak?? - TAO_FlowProducer *producer; - ACE_NEW_RETURN (producer, - TAO_FlowProducer, - 0); - return producer->_this (env); -} - -// hook for the applications to override the consumer creation. -AVStreams::FlowConsumer_ptr -TAO_FDev::make_consumer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_requester); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (met_qos); - ACE_UNUSED_ARG (named_fdev); - - // memory leak?? - TAO_FlowConsumer *consumer; - ACE_NEW_RETURN (consumer, - TAO_FlowConsumer, - 0); - return consumer->_this (env); -} - -AVStreams::FlowConsumer_ptr -TAO_FDev::create_consumer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env) -{ - this->consumer_ = this->make_consumer (the_requester, - the_qos, - met_qos, - named_fdev, - env); - return this->consumer_; -} - -// not implemented yet. -AVStreams::FlowConnection_ptr -TAO_FDev::bind (AVStreams::FDev_ptr peer_device, - AVStreams::QoS & the_qos, - CORBA::Boolean_out is_met, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (peer_device); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (is_met); - ACE_UNUSED_ARG (env); - return 0; -} - -// multicast is not supported yet. -AVStreams::FlowConnection_ptr -TAO_FDev::bind_mcast (AVStreams::FDev_ptr first_peer, - AVStreams::QoS & the_qos, - CORBA::Boolean_out is_met, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (first_peer); - ACE_UNUSED_ARG (the_qos); - ACE_UNUSED_ARG (is_met); - ACE_UNUSED_ARG (env); - return 0; -} - -void -TAO_FDev::destroy (AVStreams::FlowEndPoint_ptr the_ep, - const char * fdev_name, - CORBA::Environment &env) -{ - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (fdev_name); - ACE_UNUSED_ARG (env); -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Hash_Map_Entry<TAO_String_Hash_Key,CORBA::Object_ptr>; -template class ACE_Hash_Map_Manager<TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex>; -template class ACE_Hash_Map_Manager_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator<TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator<TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex>; -template class ACE_Hash_Map_Reverse_Iterator_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Hash_Map_Entry<TAO_String_Hash_Key,CORBA::Object_ptr> -#pragma instantiate ACE_Hash_Map_Manager<TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator<TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator<TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<TAO_String_Hash_Key, CORBA::Object_ptr, ACE_Hash<TAO_String_Hash_Key>, ACE_Equal_To<TAO_String_Hash_Key>, ACE_Null_Mutex> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h deleted file mode 100644 index 007dec183ed..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h +++ /dev/null @@ -1,891 +0,0 @@ -/* -*- C++ -*- */ - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// AVStreams_i.h -// -// = AUTHOR -// Sumedh Mungee <sumedh@cs.wustl.edu> -// Nagarajan Surendran <naga@cs.wustl.edu> -// -// -// ============================================================================ - -#ifndef AVSTREAMS_I_H -#define AVSTREAMS_I_H - -#include "orbsvcs/orbsvcs_export.h" -#include "orbsvcs/CosPropertyServiceS.h" -#include "orbsvcs/AVStreamsS.h" -#include "orbsvcs/Property/CosPropertyService_i.h" -#include "ace/Process.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -#pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -#include "orbsvcs/CosNamingC.h" -#include "orbsvcs/AV/Endpoint_Strategy.h" -#include "orbsvcs/Null_MediaCtrlS.h" - -#include "orbsvcs/Trader/Trader.h" -// for the Hash_Map helper classes. -class TAO_ORBSVCS_Export AV_Null_MediaCtrl : public virtual POA_Null_MediaCtrl -{ - public: - AV_Null_MediaCtrl (void); -}; - - -class TAO_ORBSVCS_Export TAO_Basic_StreamCtrl - : public virtual POA_AVStreams::Basic_StreamCtrl, - public virtual TAO_PropertySet - // = DESCRIPTION - // Base class for StreamCtrl, implements basic stream start - // and stop functionality -{ - public: - TAO_Basic_StreamCtrl (void); - // Default Constructor - - virtual void stop (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Stop the transfer of data of the stream - // Empty the_spec means apply operation to all flows - - virtual void start (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Start the transfer of data in the stream. - // Empty the_spec means apply operation to all flows - - virtual void destroy (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Tears down the stream. This will close the connection, and delete - // the streamendpoint and vdev associated with this stream - // Empty the_spec means apply operation to all flows - - virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &new_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Changes the QoS associated with the stream - // Empty the_spec means apply operation to all flows - - virtual void push_event (const struct CosPropertyService::Property & the_event, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used by StreamEndPoint and VDev to inform StreamCtrl of events. - // E.g., loss of flow, reestablishment of flow, etc.. - - virtual void set_FPStatus (const AVStreams::flowSpec &the_spec, - const char *fp_name, - const CORBA::Any &fp_settings, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to control the flow protocol parameters. - - virtual CORBA::Object_ptr get_flow_connection (const char *flow_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not implemented in the light profile, will raise the notsupported - // exception - - virtual void set_flow_connection (const char *flow_name, - CORBA::Object_ptr flow_connection, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not implemented in the light profile, will raise the notsupported - // exception - - virtual ~TAO_Basic_StreamCtrl (void); - // Destructor - - protected: - - AVStreams::VDev_var vdev_a_; - AVStreams::VDev_var vdev_b_; - // The Virtual Devices for this stream - - AVStreams::StreamEndPoint_A_var stream_endpoint_a_; - AVStreams::StreamEndPoint_B_var stream_endpoint_b_; - // The Endpoints for this stream - - typedef ACE_Hash_Map_Manager <TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex> FlowConnection_Map; - FlowConnection_Map flow_map_; - // Hash table for the flow names and its corresponding flowconnection object reference. - AVStreams::FlowConnection_seq flowConnections_; - - u_int flow_count_; - AVStreams::flowSpec flows_; - //sequence of flow names. -}; - -class TAO_ORBSVCS_Export TAO_StreamCtrl - : public virtual POA_AVStreams::StreamCtrl, - public virtual TAO_Basic_StreamCtrl -// = DESCRIPTION -// Implementation the A/V StreamCtrl class. this class -// is used to control the stream. It should be subclassed -// by applications that want to provide more control features. -{ -public: - TAO_StreamCtrl (void); - // Default Constructor - - virtual CORBA::Boolean bind_devs (AVStreams::MMDevice_ptr a_party, - AVStreams::MMDevice_ptr b_party, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Establish a stream between a_party and b_party, - // with qos the_qos, and for the flows in the_flows - // if the_flows is empty, bind all the flows - // Causes a connection to be established between the StreamEndpoints. - // Returns success/failure - - virtual CORBA::Boolean bind (AVStreams::StreamEndPoint_A_ptr a_party, - AVStreams::StreamEndPoint_B_ptr b_party, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Establish a connection between two streamendpoints. This can - // be used if the streamendpoints have been created independent of - // a MMDevice - - virtual void unbind_party (AVStreams::StreamEndPoint_ptr the_ep, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Unbind the_ep from the stream. Empty the_spec means apply to all flows. - - virtual void unbind (CORBA::Environment &env = CORBA::Environment::default_environment ()); - // unbind the stream. Same effect as Basic_StreamCtrl::destroy () - - virtual ~TAO_StreamCtrl (void); - // Destructor - -}; - - -class TAO_ORBSVCS_Export TAO_Base_StreamEndPoint -// = DESCRIPTION -// Base class for the A/V StreamEndPoint class. this class -// is used to control the stream. It should be subclassed -// by applications that want to provide more control features. -{ -public: - virtual ~TAO_Base_StreamEndPoint (void); - - virtual int handle_open (void) = 0; - // called when streamendpoint is instantiated - - virtual int handle_close (void) = 0; - // called when streamendpoint is being destructed - - virtual int handle_stop (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()) = 0; - // Application needs to define this - - virtual int handle_start (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()) = 0; - // Application needs to define this - - - virtual int handle_destroy (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()) = 0; - // Application needs to define this -}; - -class TAO_ORBSVCS_Export TAO_Client_Base_StreamEndPoint - : public virtual TAO_Base_StreamEndPoint -{ -public: - virtual CORBA::Boolean handle_preconnect (AVStreams::flowSpec &the_spec) = 0; - // Application needs to define this - - virtual CORBA::Boolean handle_postconnect (AVStreams::flowSpec &the_spec) = 0; - // Application needs to define this -}; - -class TAO_ORBSVCS_Export TAO_Server_Base_StreamEndPoint - : public virtual TAO_Base_StreamEndPoint -{ -public: - virtual CORBA::Boolean handle_connection_requested (AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()) = 0; - // Application needs to define this -}; - -class TAO_ORBSVCS_Export TAO_StreamEndPoint - : public virtual POA_AVStreams::StreamEndPoint, // The POA class - public virtual TAO_Base_StreamEndPoint, - public virtual TAO_PropertySet -{ - // = DESCRIPTION - // The Stream EndPoint. Used to implement one endpoint of a stream - // that implements the transport layer. -public: - TAO_StreamEndPoint (void); - // Constructor - - virtual void stop (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Stop the stream. Empty the_spec means, for all the flows - - virtual void start (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Start the stream, Empty the_spec means, for all the flows - - virtual void destroy (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Destroy the stream, Empty the_spec means, for all the flows - - - virtual CORBA::Boolean connect (AVStreams::StreamEndPoint_ptr responder, - AVStreams::streamQoS &qos_spec, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()) = 0; - // Called by StreamCtrl. responder is the peer to connect to - - virtual CORBA::Boolean request_connection (AVStreams::StreamEndPoint_ptr initiator, - CORBA::Boolean is_mcast, - AVStreams::streamQoS &qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called by the peer StreamEndPoint. The flow_spec indicates the - // flows (which contain transport addresses etc.) - - virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &new_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Change the transport qos on a stream - - virtual CORBA::Boolean set_protocol_restriction (const AVStreams::protocolSpec &the_pspec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to restrict the set of protocols - - virtual void disconnect (const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // disconnect the flows - - virtual void set_FPStatus (const AVStreams::flowSpec &the_spec, - const char *fp_name, - const CORBA::Any &fp_settings, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to control the flow - - virtual CORBA::Object_ptr get_fep (const char *flow_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not implemented in the light profile, throws notsupported - - virtual char * add_fep (CORBA::Object_ptr the_fep, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not implemented in the light profile, throws notsupported - - virtual void remove_fep (const char *fep_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not implemented in the light profile, throws notsupported - - virtual void set_negotiator (AVStreams::Negotiator_ptr new_negotiator, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to "attach" a negotiator to the endpoint - - virtual void set_key (const char *flow_name, - const AVStreams::key & the_key, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used for public key encryption. - - virtual void set_source_id (CORBA::Long source_id, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to set a unique id for packets sent by this streamendpoint - - virtual ~TAO_StreamEndPoint (void); - // Destructor - -private: - u_int flow_count_; - // Count of the number of flows in this streamendpoint, used to - // generate unique names for the flows. - u_int flow_num_; - // current flow number used for system generation of flow names. - typedef ACE_Hash_Map_Manager <TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex> - FlowEndPoint_Map; - FlowEndPoint_Map fep_map_; - // hash table for the flownames and its corresponding flowEndpoint - // reference. - AVStreams::flowSpec flows_; - // sequence of supported flow names. - CORBA::Long source_id_; - // source id used for multicast. -}; - -class TAO_ORBSVCS_Export TAO_Client_StreamEndPoint : - public virtual POA_AVStreams::StreamEndPoint_A, - public virtual TAO_StreamEndPoint, - public virtual TAO_Client_Base_StreamEndPoint -{ - // = DESCRIPTION - // The "A" side of a streamendpoint -public: - TAO_Client_StreamEndPoint (void); - // Constructor - - virtual CORBA::Boolean connect (AVStreams::StreamEndPoint_ptr responder, - AVStreams::streamQoS &qos_spec, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called by StreamCtrl. responder is the peer to connect to - - virtual CORBA::Boolean multiconnect (AVStreams::streamQoS &the_qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used for ATM-style multicast - - virtual CORBA::Boolean connect_leaf (AVStreams::StreamEndPoint_B_ptr the_ep, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_flows, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used for ATM-style multicast - - virtual void disconnect_leaf (AVStreams::StreamEndPoint_B_ptr the_ep, - const AVStreams::flowSpec &theSpec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to remove a multicast leaf - - virtual ~TAO_Client_StreamEndPoint (void); - // Destructor - -}; - -class TAO_ORBSVCS_Export TAO_Server_StreamEndPoint : - public virtual POA_AVStreams::StreamEndPoint_B, - public virtual TAO_StreamEndPoint, - public virtual TAO_Server_Base_StreamEndPoint // Abstract interface -{ - // = DESCRIPTION - // The "B" side of a streamendpoint -public: - TAO_Server_StreamEndPoint (void); - // Constructor - - virtual CORBA::Boolean connect (AVStreams::StreamEndPoint_ptr responder, - AVStreams::streamQoS &qos_spec, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - - virtual CORBA::Boolean request_connection (AVStreams::StreamEndPoint_ptr initiator, - CORBA::Boolean is_mcast, - AVStreams::streamQoS &qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called by the peer StreamEndPoint. The flow_spec indicates the - // flows (which contain transport addresses etc.) - - virtual CORBA::Boolean multiconnect (AVStreams::streamQoS &the_qos, - AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used for internet-style multicast - - virtual ~TAO_Server_StreamEndPoint (void); - // Destructor -}; - -class TAO_ORBSVCS_Export TAO_VDev - :public virtual TAO_PropertySet, - public virtual POA_AVStreams::VDev -// = DESCRIPTION -// Implements the VDev interface. One of these is created per connection, -// and represents device-specific parameters -{ - public: - TAO_VDev (void); - // Default Constructor - - virtual CORBA::Boolean set_peer (AVStreams::StreamCtrl_ptr the_ctrl, - AVStreams::VDev_ptr the_peer_dev, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called to tell the vdev who the streamctrl, peer vdev is - - virtual CORBA::Boolean set_Mcast_peer (AVStreams::StreamCtrl_ptr the_ctrl, - AVStreams::MCastConfigIf_ptr a_mcastconfigif, - AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to set the streamctrl and multicast device - - virtual void configure (const CosPropertyService::Property &the_config_mesg, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called by the peer VDev to configure the device (catch all) - - virtual void set_format (const char *flowName, - const char *format_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to set a format on a flowname - - virtual void set_dev_params (const char *flowName, - const CosPropertyService::Properties &new_params, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Used to set device parameters - - virtual CORBA::Boolean modify_QoS (AVStreams::streamQoS &the_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called to change QoS of the device - - virtual ~TAO_VDev (void); - // Destructor - - protected: - virtual CORBA::Boolean set_media_ctrl (CORBA::Object_ptr media_ctrl, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // hook called after set_peer is done to set the media ctrl of the peer vdev. - private: - AVStreams::StreamCtrl_var streamctrl_; - // My stream controller - - AVStreams::VDev_var peer_; - // My peer -}; - -class TAO_AV_Endpoint_Strategy; - -class TAO_ORBSVCS_Export TAO_MMDevice - : public TAO_PropertySet, - public POA_AVStreams::MMDevice -// = DESCRIPTION -// Implements a factory to create Endpoints and VDevs -{ - protected: - - TAO_AV_Endpoint_Strategy *endpoint_strategy_; - - public: - - TAO_MMDevice (TAO_AV_Endpoint_Strategy *endpoint_strategy_); - // Constructor - - virtual AVStreams::StreamCtrl_ptr bind (AVStreams::MMDevice_ptr peer_device, - AVStreams::streamQoS &the_qos, - CORBA::Boolean_out is_met, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Can be used to request the MMDevice to create a new StreamCtrl, - // and call bind_devs on it - - 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, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // 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, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // 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, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Called by StreamCtrl to create a "B" type streamandpoint and vdev - - virtual void destroy (AVStreams::StreamEndPoint_ptr the_ep, - const char *vdev_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Remove the StreamEndPoint and the related vdev - - virtual char * add_fdev (CORBA::Object_ptr the_fdev, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not supported in the light profile, raises notsupported - - virtual CORBA::Object_ptr get_fdev (const char *flow_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not supported in the light profile, raises notsupported - - virtual void remove_fdev (const char *flow_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Not supported in the light profile, raises notsupported - - virtual ~TAO_MMDevice (void); - // Destructor - -private: - u_int flow_count_; - // Count of the number of flows in this MMDevice , used to - // generate unique names for the flows. - u_int flow_num_; - // current flow number used for system generation of flow names. - typedef ACE_Hash_Map_Manager <TAO_String_Hash_Key,CORBA::Object_ptr,ACE_Null_Mutex> - FDev_Map; - FDev_Map fdev_map_; - // hash table for the flownames and its corresponding flowEndpoint - // reference. - AVStreams::flowSpec flows_; - // sequence of supported flow names. -}; - -class TAO_FlowConsumer; -class TAO_FlowProducer; - -class TAO_ORBSVCS_Export TAO_FlowConnection : public TAO_PropertySet, - public POA_AVStreams::FlowConnection -{ - // =TITLE - // Class to manage a flow connection. - // - // =Description - // This class currently supports only one producer and one - // consumer per flow. -public: - TAO_FlowConnection (void); - // default constructor. - - virtual void stop (CORBA::Environment &env = CORBA::Environment::default_environment ()); - // stop this flow. - - virtual void start (CORBA::Environment &env = CORBA::Environment::default_environment ()); - // start this flow. - - virtual void destroy (CORBA::Environment &env = CORBA::Environment::default_environment ()); - // destroy this flow. - - virtual CORBA::Boolean modify_QoS (AVStreams::QoS & new_qos, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // modify the QoS for this flow. - - virtual CORBA::Boolean use_flow_protocol (const char * fp_name, - const CORBA::Any & fp_settings, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // use the specified flow protocol for this flow. - - virtual void push_event (const AVStreams::streamEvent & the_event, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - - // pushes an event , to be handled by the application. - - virtual CORBA::Boolean connect_devs (AVStreams::FDev_ptr a_party, - AVStreams::FDev_ptr b_party, - AVStreams::QoS & the_qos, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // connect 2 Flow Devices. - - virtual CORBA::Boolean connect (AVStreams::FlowProducer_ptr flow_producer, - AVStreams::FlowConsumer_ptr flow_consumer, - AVStreams::QoS & the_qos, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // Connect a flow producer and consumer under this flow connection. - - virtual CORBA::Boolean disconnect (CORBA::Environment &env = CORBA::Environment::default_environment ()); - // disconnect this flow connection. - - virtual CORBA::Boolean add_producer (AVStreams::FlowProducer_ptr flow_producer, - AVStreams::QoS & the_qos, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // adds the producer to this flow connection. - - virtual CORBA::Boolean add_consumer (AVStreams::FlowConsumer_ptr flow_consumer, - AVStreams::QoS & the_qos, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // adds a consumer to this flow connection. - - virtual CORBA::Boolean drop (AVStreams::FlowEndPoint_ptr target, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // drops a flow endpoint from the flow. - -private: - AVStreams::FlowProducer *producer_; - // The producer of this flow. - AVStreams::FlowConsumer *consumer_; - // The consumer of this flow - char * fp_name_; - // name of the flow protocol to be used. -}; - -class TAO_ORBSVCS_Export TAO_FlowEndPoint : - public virtual POA_AVStreams::FlowEndPoint, - public virtual TAO_PropertySet -{ - // = DESCRIPTION - // This class is used per flow e.g video flow and an audio flow - // to encapuslate the transport details. - - public: - - TAO_FlowEndPoint (void); - //default constructor. - - virtual CORBA::Boolean lock (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // lock the flow endpoint for a particular flow. - - virtual void unlock (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // unlock the flow endpoint for subsequent use. - - virtual void stop (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // stop this flow, to be overridden by the application. - - virtual void start (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // start this flow, to be overridden by the application. - - virtual void destroy (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // destroy this flow. - - virtual AVStreams::StreamEndPoint_ptr related_sep - (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // get method for the related streamendpoint under which this - // flowendpoint is. - - virtual void related_sep (AVStreams::StreamEndPoint_ptr related_sep, - CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // set method for the related streamendpoint under which this - // flowendpoint is. - - virtual AVStreams::FlowConnection_ptr related_flow_connection(CORBA::Environment &env = - CORBA::Environment::default_environment ()); - - // accessor for the related flow connection attribute. - - virtual void related_flow_connection (AVStreams::FlowConnection_ptr related_flow_connection, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // set method for the related flow connection attribute. - - virtual AVStreams::FlowEndPoint_ptr get_connected_fep - (CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // returns the other flowendpoint to which this is connected. - - virtual CORBA::Boolean use_flow_protocol (const char * fp_name, - const CORBA::Any & fp_settings, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - /// use the specified flow protocol. - - virtual void set_format (const char * format, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // sets the data format. - - virtual void set_dev_params (const CosPropertyService::Properties & new_settings, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // sets the device parameters. - - virtual void set_protocol_restriction (const AVStreams::protocolSpec & the_spec, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // sets the list of protocols to be used. - - virtual CORBA::Boolean is_fep_compatible (AVStreams::FlowEndPoint_ptr fep, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // checks whether the passed flowendpoint is compatible with this. - - virtual CORBA::Boolean set_peer (AVStreams::FlowConnection_ptr the_fc, - AVStreams::FlowEndPoint_ptr the_peer_fep, - AVStreams::QoS & the_qos, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - //sets the peer flowendpoint. - - virtual CORBA::Boolean set_Mcast_peer (AVStreams::FlowConnection_ptr the_fc, - AVStreams::MCastConfigIf_ptr a_mcastconfigif, - AVStreams::QoS & the_qos, - CORBA::Environment &env = - CORBA::Environment::default_environment ()); - ///sets the multicast peer flowendpoint, not implemented. -private: - AVStreams::StreamEndPoint_ptr related_sep_; - // The related streamendpoint. - AVStreams::FlowConnection_ptr related_flow_connection_; - // The related flow connection reference - AVStreams::FlowEndPoint_ptr peer_fep_; - // The peer flowendpoint reference. -}; - -class TAO_ORBSVCS_Export TAO_FlowProducer: - public virtual POA_AVStreams::FlowProducer, - public virtual TAO_FlowEndPoint -{ - public: - TAO_FlowProducer (void); - // default constructor - - virtual CORBA::Boolean connect_to_peer (AVStreams::QoS & the_qos, - const char * address, - const char * use_flow_protocol, - CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // connect to the peer endpoint. - - virtual CORBA::Boolean handle_connect_to_peer (AVStreams::QoS & the_qos, - const char * address, - const char * use_flow_protocol, - CORBA::Environment &env = - CORBA::Environment::default_environment ()); - - // hook method to be overridden by the application to handle the connection request. - - virtual char * connect_mcast (AVStreams::QoS & the_qos, - CORBA::Boolean_out is_met, - const char * address, - const char * use_flow_protocol, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - - // connect to the multicast address, not implemented. - - virtual char * get_rev_channel (const char * pcol_name, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // get the reverse channel, to be used for feedback for protocols like UDP. - - virtual void set_key (const AVStreams::key & the_key, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // sets the public key to be used for encryption of the data. - - virtual void set_source_id (CORBA::Long source_id, - CORBA::Environment &env = - CORBA::Environment::default_environment - ()); - // sets the source id of this flow producer so that it can be used - // to distinguish this producer from others in the multicast case. - - private: - CORBA::Long source_id_; - // source id of this producer. -}; - -class TAO_ORBSVCS_Export TAO_FlowConsumer : - public virtual POA_AVStreams::FlowConsumer, - public virtual TAO_FlowEndPoint -{ - public: - TAO_FlowConsumer (void); - // default constructor. - - virtual char * go_to_listen (AVStreams::QoS & the_qos, - CORBA::Boolean is_mcast, - AVStreams::FlowProducer_ptr peer, - char *& flowProtocol, - CORBA::Environment &env = - CORBA::Environment::default_environment - ()); - - // listen request from the peer. - - virtual char * handle_go_to_listen (AVStreams::QoS & the_qos, - CORBA::Boolean is_mcast, - AVStreams::FlowProducer_ptr peer, - char *& flowProtocol, - CORBA::Environment &env = - CORBA::Environment::default_environment - ()); - // applications should override this method. - -}; - -class TAO_ORBSVCS_Export TAO_FDev : - public virtual POA_AVStreams::FDev, - public virtual TAO_PropertySet -{ - public: - TAO_FDev (void); - // default constructor - - AVStreams::FlowProducer_ptr create_producer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // create a flow producer object. - - virtual AVStreams::FlowProducer_ptr make_producer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // bridge method for the application to override the producer object - // creation. Default implementation creates a TAO_FlowProducer. - - virtual AVStreams::FlowConsumer_ptr create_consumer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // create a flow consumer object. - - virtual AVStreams::FlowConsumer_ptr make_consumer (AVStreams::FlowConnection_ptr the_requester, - AVStreams::QoS & the_qos, - CORBA::Boolean_out met_qos, - char *& named_fdev, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // bridge method for the application to override the consumer object - // creation. Default implementation creates a TAO_FlowConsumer. - - virtual AVStreams::FlowConnection_ptr bind (AVStreams::FDev_ptr peer_device, - AVStreams::QoS & the_qos, - CORBA::Boolean_out is_met, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // bind this FDev with another FDev. - - virtual AVStreams::FlowConnection_ptr bind_mcast (AVStreams::FDev_ptr first_peer, - AVStreams::QoS & the_qos, - CORBA::Boolean_out is_met, - CORBA::Environment &env = CORBA::Environment::default_environment ()); - // multicast bind is not implemented yet. - - virtual void destroy (AVStreams::FlowEndPoint_ptr the_ep, - const char * fdev_name, - CORBA::Environment &env = - CORBA::Environment::default_environment ()); - // destroys this FDev. - - private: - AVStreams::FlowProducer_ptr producer_; - AVStreams::FlowConsumer_ptr consumer_; - // references to the created producers and consumers. -}; - -class TAO_ORBSVCS_Export TAO_MediaControl - :public virtual POA_AVStreams::MediaControl -{ - // = TITLE - // Abstract Mediacontrol class. - // - // = DESCRIPTION - // The following are to be handled by the specialized media control for the specific - // media like camera,speaker. - public: - TAO_MediaControl (void); - // default constructor - - virtual AVStreams::Position get_media_position (AVStreams::PositionOrigin an_origin, - AVStreams::PositionKey a_key, - CORBA::Environment &env = CORBA::Environment::default_environment ()) =0; - - virtual void set_media_position (const AVStreams::Position & a_position, - CORBA::Environment &env = CORBA::Environment::default_environment ()) =0; - - virtual void start (const AVStreams::Position & a_position, - CORBA::Environment &env = CORBA::Environment::default_environment ()) =0; - - virtual void pause (const AVStreams::Position & a_position, - CORBA::Environment &env = CORBA::Environment::default_environment ()) =0; - - virtual void resume (const AVStreams::Position & a_position, - CORBA::Environment &env = CORBA::Environment::default_environment ()) =0; - - virtual void stop (const AVStreams::Position & a_position, - CORBA::Environment &env = CORBA::Environment::default_environment ()) = 0; - -}; - -#endif /* AVSTREAMS_I_H */ diff --git a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.cpp b/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.cpp deleted file mode 100644 index 654098b048a..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.cpp +++ /dev/null @@ -1,392 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// Endpoint_Strategy.cpp -// -// = AUTHOR -// Sumedh Mungee <sumedh@cs.wustl.edu> -// -// -// ============================================================================ - -#include "orbsvcs/AV/Endpoint_Strategy.h" - -ACE_RCSID(AV, Endpoint_Strategy, "$Id$") - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Strategy -// ---------------------------------------------------------------------- - -// Constructor -TAO_AV_Endpoint_Strategy::TAO_AV_Endpoint_Strategy (void) -{ -} - -// Destructor. -TAO_AV_Endpoint_Strategy::~TAO_AV_Endpoint_Strategy (void) -{ -// if (CORBA::is_nil (this->stream_endpoint_a_) == 0) -// CORBA::release (this->stream_endpoint_a_); - -// if (CORBA::is_nil (this->stream_endpoint_b_) == 0) -// CORBA::release (this->stream_endpoint_b_); - -// if (CORBA::is_nil (this->stream_endpoint_b_) == 0) -// CORBA::release (this->vdev_); - -} - -// The base class defines the "failure" case, so that unless the -// subclasses override this, the call will fail. This is done so that -// subclasses need only define the calls that they want to support, -// and the remaining calls will fail automagically -int -TAO_AV_Endpoint_Strategy::create_A (AVStreams::StreamEndPoint_A_ptr & /* stream_endpoint */, - AVStreams::VDev_ptr & /* vdev */, - CORBA::Environment &) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Error creating A endpoint\n"), - -1); -} - -// The base class defines the "failure" case, so that unless the -// subclasses override this, the call will fail. This is done so that -// subclasses need only define the calls that they want to support, -// and the remaining calls will fail automagically -int -TAO_AV_Endpoint_Strategy::create_B (AVStreams::StreamEndPoint_B_ptr & /* stream_endpoint */, - AVStreams::VDev_ptr & /*vdev */, - CORBA::Environment &) -{ - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Error creating B endpoint\n"), - -1); -} - - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Process_Strategy -// ---------------------------------------------------------------------- - -// Constructor -TAO_AV_Endpoint_Process_Strategy::TAO_AV_Endpoint_Process_Strategy (ACE_Process_Options *process_options) - : process_options_ (process_options), - pid_ (-1) -{ - ACE_OS::hostname (this->host_, - sizeof this->host_); -} - -// Destructor. -TAO_AV_Endpoint_Process_Strategy::~TAO_AV_Endpoint_Process_Strategy (void) -{ -} - -// Spawns the process, and waits for it to finish booting. -// Then uses bind_to_naming_service, get_stream_endpoint, and get_vdev -// to get the object references to the various objects created in the -// child -int -TAO_AV_Endpoint_Process_Strategy::activate (void) -{ - ACE_Process process; - - // Create a new process to contain this endpoint - this->pid_ = process.spawn (*this->process_options_); - - // Process creation failed - if (this->pid_ == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) ACE_Process:: spawn failed: %p\n", - "spawn"), - -1); - - // Create a unique semaphore name, using my hostname, and pid. - char sem_str [BUFSIZ]; - - // create a unique semaphore name - ACE_OS::sprintf (sem_str, - "%s:%s:%ld", - "TAO_AV_Process_Semaphore", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) semaphore is %s\n", - sem_str)); - // Create the semaphore - ACE_Process_Semaphore semaphore (0, // 0 means that the - // semaphore is locked initially - sem_str); - - // wait until the child finishes booting - while (1) - { - if (semaphore.acquire () == -1) - { - // See if my child process is still alive -- if not, return an error - if (ACE_OS::kill (this->pid_, - 0) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Process_Strategy: Process being waited on died unexpectedly.\n"), - -1); - // if we were not interrupted due to a EINTR, break - if (errno != EINTR) - break; - } - else - break; - } - - // The job of the semaphore is done, remove it. - if (semaphore.remove () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) semaphore remove failed: %p\n", - "remove"), - -1); - - TAO_TRY - { - // Get ourselves a Naming service - this->bind_to_naming_service (TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Get the stream endpoint created by the child from the naming service - this->get_stream_endpoint (TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Get the Vdev created by the child from the naming service - this->get_vdev (TAO_TRY_ENV); - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("TAO_Endpoint_Process_Strategy::activate"); - return -1; - } - TAO_ENDTRY; - - return 0; -} - -// Get ourselves a Naming service reference -int -TAO_AV_Endpoint_Process_Strategy::bind_to_naming_service (CORBA::Environment &env) -{ - if (CORBA::is_nil (this->naming_context_.in ()) == 0) - return 0; - - CORBA::Object_var naming_obj = - TAO_ORB_Core_instance ()->orb ()->resolve_initial_references ("NameService"); - - if (CORBA::is_nil (naming_obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to resolve the Name Service.\n"), - -1); - this->naming_context_ = - CosNaming::NamingContext::_narrow (naming_obj.in (), - env); - TAO_CHECK_ENV_RETURN (env, -1); - - return 0; -} - -// Get the VDev created in the child process from the namingservice -int -TAO_AV_Endpoint_Process_Strategy::get_vdev (CORBA::Environment &env) -{ - char vdev_name [BUFSIZ]; - ACE_OS::sprintf (vdev_name, - "%s:%s:%d", - "VDev", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",vdev_name)); - - // Create the name - CosNaming::Name VDev_Name (1); - VDev_Name.length (1); - VDev_Name [0].id = CORBA::string_dup (vdev_name); - - // Get the CORBA::Object - CORBA::Object_var vdev = - this->naming_context_->resolve (VDev_Name, - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Narrow it - this->vdev_ = - AVStreams::VDev::_narrow (vdev.in (), - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Check if valid - if (CORBA::is_nil (this->vdev_)) - ACE_ERROR_RETURN ((LM_ERROR, - " could not resolve Stream_Endpoint_B in Naming service <%s>\n"), - -1); - return 0; -} - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Process_Strategy_A -// ---------------------------------------------------------------------- - -// Constructor -TAO_AV_Endpoint_Process_Strategy_A::TAO_AV_Endpoint_Process_Strategy_A (ACE_Process_Options *process_options) - : TAO_AV_Endpoint_Process_Strategy (process_options) -{ -} - -// Destructor -TAO_AV_Endpoint_Process_Strategy_A::~TAO_AV_Endpoint_Process_Strategy_A (void) -{ -} - -// the "A" type endpoint creator -int -TAO_AV_Endpoint_Process_Strategy_A::create_A (AVStreams::StreamEndPoint_A_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &) -{ - // use the baseclass activate - if (this->activate () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) TAO_AV_Endpoint_Process_Strategy: Error in activate ()\n"), - -1); - - // return the object references - stream_endpoint = this->stream_endpoint_a_; - vdev = this->vdev_; - return 0; - -} - -// Gets the stream endpoint object reference from the naming service -int -TAO_AV_Endpoint_Process_Strategy_A::get_stream_endpoint (CORBA::Environment &env) -{ - char stream_endpoint_name[BUFSIZ]; - ACE_OS::sprintf (stream_endpoint_name, - "%s:%s:%d", - "Stream_Endpoint_A", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",stream_endpoint_name)); - - // Create the name - CosNaming::Name Stream_Endpoint_A_Name (1); - - Stream_Endpoint_A_Name.length (1); - Stream_Endpoint_A_Name [0].id = CORBA::string_dup (stream_endpoint_name); - - // Get the CORBA::Object - CORBA::Object_var stream_endpoint_a = - this->naming_context_->resolve (Stream_Endpoint_A_Name, - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Narrow the reference - this->stream_endpoint_a_ = - AVStreams::StreamEndPoint_A::_narrow (stream_endpoint_a.in (), - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Check for validity - if (CORBA::is_nil (this->stream_endpoint_a_)) - ACE_ERROR_RETURN ((LM_ERROR, - " could not resolve Stream_Endpoint_A in Naming service <%s>\n"), - -1); - return 0; -} - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Process_Strategy_B -// ---------------------------------------------------------------------- - -// Constructor -TAO_AV_Endpoint_Process_Strategy_B::TAO_AV_Endpoint_Process_Strategy_B (ACE_Process_Options *process_options) - : TAO_AV_Endpoint_Process_Strategy (process_options) -{ -} - -// Destructor -TAO_AV_Endpoint_Process_Strategy_B::~TAO_AV_Endpoint_Process_Strategy_B (void) -{ -} - -// Creates and returns a "B" type endpoint -int -TAO_AV_Endpoint_Process_Strategy_B::create_B (AVStreams::StreamEndPoint_B_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &) -{ - TAO_TRY - { - if (this->activate () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) TAO_AV_Endpoint_Process_Strategy: Error in activate ()\n"), - -1); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Process_Strategy_B::create_B ()\n: stream_endpoint is:%s\n", - TAO_ORB_Core_instance ()->orb ()->object_to_string (this->stream_endpoint_b_, - TAO_TRY_ENV))); - TAO_CHECK_ENV; - stream_endpoint = this->stream_endpoint_b_; - vdev = this->vdev_; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("TAO_AV_Endpoint_Process_Strategy_B::create_B\n"); - return -1; - } - TAO_ENDTRY; - return 0; -} - -// Gets the B type stream_endpoint from the Naming service -int -TAO_AV_Endpoint_Process_Strategy_B::get_stream_endpoint (CORBA::Environment &env) -{ - char stream_endpoint_name[BUFSIZ]; - ACE_OS::sprintf (stream_endpoint_name, - "%s:%s:%d", - "Stream_Endpoint_B", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",stream_endpoint_name)); - - // Create the name - CosNaming::Name Stream_Endpoint_B_Name (1); - - Stream_Endpoint_B_Name.length (1); - Stream_Endpoint_B_Name [0].id = CORBA::string_dup (stream_endpoint_name); - - // Get the CORBA::Object reference - CORBA::Object_var stream_endpoint_b = - this->naming_context_->resolve (Stream_Endpoint_B_Name, - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Narrow the reference - this->stream_endpoint_b_ = - AVStreams::StreamEndPoint_B::_narrow (stream_endpoint_b.in (), - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // Check for validity - if (CORBA::is_nil (this->stream_endpoint_b_)) - ACE_ERROR_RETURN ((LM_ERROR, - " could not resolve Stream_Endpoint_B in Naming service <%s>\n"), - -1); - return 0; -} diff --git a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.h b/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.h deleted file mode 100644 index d964036148a..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy.h +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- C++ -*- */ - -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// cos -// -// = FILENAME -// Endpoint_Strategy.h -// -// = AUTHOR -// Sumedh Mungee <sumedh@cs.wustl.edu> -// -// -// ============================================================================ - -#ifndef TAO_AV_ENDPOINT_STRATEGY_H -#define TAO_AV_ENDPOINT_STRATEGY_H - -#include "orbsvcs/AV/AVStreams_i.h" -#include "tao/TAO.h" - -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Strategy -// = DESCRIPTION -// Base class to define various endpoint strategies -// used by the MMDevice to create the Endpoint and Vdev -{ -public: - TAO_AV_Endpoint_Strategy (void); - // Constructor - - virtual ~TAO_AV_Endpoint_Strategy (void); - // Destructor - - virtual int create_A (AVStreams::StreamEndPoint_A_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env); - // Called by the MMDevice, when it needs to create an A type endpoint - - virtual int create_B (AVStreams::StreamEndPoint_B_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env); - // Called by the MMDevice, when it needs to create an B type endpoint - - protected: - AVStreams::StreamEndPoint_A_ptr stream_endpoint_a_; - // The "A" stream endpoint - - AVStreams::StreamEndPoint_B_ptr stream_endpoint_b_; - // The "B" stream endpoint - - AVStreams::VDev_ptr vdev_; - // The vdev - -}; - -// ---------------------------------------------------------------------- - -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Process_Strategy - : public TAO_AV_Endpoint_Strategy -// = DESCRIPTION -// Process-based strategy for creating endpoints -// Abstract base class. -{ - public: - TAO_AV_Endpoint_Process_Strategy (ACE_Process_Options *process_options); - // Constructor. The process_options contain the name and arguments - // for the process to be created - - virtual ~TAO_AV_Endpoint_Process_Strategy (void); - // Destructor. - - virtual int activate (void); - // creates a new child process, and waits on a semaphore - // until the child process has finished creating the endpoints - - protected: - virtual int bind_to_naming_service (CORBA::Environment &env); - // Bind to the naming service - - virtual int get_stream_endpoint (CORBA::Environment &env) = 0; - // Get the object reference for the newly created stream - // endpoint (which will be in the child process) - // Subclasses will define the functionality for this - - virtual int get_vdev (CORBA::Environment &env); - // Get the Vdev object reference for the newly created - // endpoint - - CosNaming::NamingContext_var naming_context_; - // Naming context - - ACE_Process_Options *process_options_; - // Name and arguments for the process to be created - - char host_[MAXHOSTNAMELEN]; - // name of this host used for resolving unique names. - - pid_t pid_; - // My child's process id. -}; - - -// ---------------------------------------------------------------------- - -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Process_Strategy_A - : public TAO_AV_Endpoint_Process_Strategy -// = DESCRIPTION -// Process-based strategy to create "A" type endpoints -{ - public: - TAO_AV_Endpoint_Process_Strategy_A (ACE_Process_Options *process_options); - // Constructor - - virtual ~TAO_AV_Endpoint_Process_Strategy_A (void); - // Destructor. - - protected: - virtual int create_A (AVStreams::StreamEndPoint_A_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env); - // Creates an "A" type stream endpoint, and a vdev - - virtual int get_stream_endpoint (CORBA::Environment &env); - // Gets the "A" type stream endpoint from the child process - -}; - -// ---------------------------------------------------------------------- - -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Process_Strategy_B - : public TAO_AV_Endpoint_Process_Strategy -// = DESCRIPTION -// Process-based strategy to create "B" type endpoints -{ - public: - TAO_AV_Endpoint_Process_Strategy_B (ACE_Process_Options *process_options); - // Constructor - - virtual ~TAO_AV_Endpoint_Process_Strategy_B (void); - // Destructor. - - protected: - virtual int create_B (AVStreams::StreamEndPoint_B_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env); - // Creates a "B" type stream endpoint, and a vdev - - - virtual int get_stream_endpoint (CORBA::Environment &env); - // Gets the object reference of the "B" type streamendpoint. - -}; - -// Include the templates here. -#include "Endpoint_Strategy_T.h" - -#endif /* TAO_AV_ENDPOINT_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp b/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp deleted file mode 100644 index 5d262e6f616..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp +++ /dev/null @@ -1,631 +0,0 @@ -// $Id$ - -#ifndef TAO_AV_ENDPOINT_STRATEGY_T_C -#define TAO_AV_ENDPOINT_STRATEGY_T_C - -#include "Endpoint_Strategy_T.h" - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Reactive_Strategy -// ---------------------------------------------------------------------- - -// Constructor -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Endpoint_Reactive_Strategy (TAO_ORB_Manager *orb_manager) - : orb_manager_ (orb_manager) -{ -} - -template <class T_StreamEndpoint, class T_VDev, class T_MediaCtrl> -TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Endpoint_Reactive_Strategy (void) -{ -} - -// Create, activate the objects with the POA -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate (void) -{ - TAO_TRY - { - this->activate_stream_endpoint (TAO_TRY_ENV); - TAO_CHECK_ENV; - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Reactive_Strategy::activated stream_endpoint\n")); - - this->activate_vdev (TAO_TRY_ENV); - TAO_CHECK_ENV; - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Reactive_Strategy::activated vdev\n")); - - this->activate_mediactrl (TAO_TRY_ENV); - TAO_CHECK_ENV; - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Reactive_Strategy::activated mediactrl\n")); - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("TAO_Endpoint_Reactive_Strategy::activate"); - return -1; - } - TAO_ENDTRY; - return 0; -} - -// Activate VDev into the POA -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate_vdev (CORBA::Environment &env) -{ - // Bridge pattern. Allow subclasses to override this behavior - T_VDev *vdev = 0; - if (this->make_vdev (vdev) == -1) - return -1; - - // Put the object in the POA - CORBA::String_var vdev_ior = this->orb_manager_->activate (vdev, - env); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Reactive_Strategy::activate_vdev, vdev ior is:%s\n", - vdev_ior. in ())); - - // Save the object reference, so that create_A can return it - this->vdev_ = vdev->_this (env); - TAO_CHECK_ENV_RETURN (env, -1); - - - return 0; -} - -// Activate the media_controller -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate_mediactrl (CORBA::Environment &env) -{ - // Bridge pattern. Subclasses can override this - T_MediaCtrl *media_ctrl = 0; - if (this->make_mediactrl (media_ctrl) == -1) - return -1; - - // Put the object in the POA - CORBA::String_var mediactrl_ior = this->orb_manager_->activate (media_ctrl, - env); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Reactive_Strategy::activate_mediactrl , media_ctrl ior is :%s\n", - mediactrl_ior.in ())); - - - // Associate the media controller object reference with the vdev, as per the OMG spec - CORBA::Any anyval; - anyval <<= this->orb_manager_->orb ()->object_to_string (media_ctrl->_this (env), - env); - TAO_CHECK_ENV_RETURN (env, -1); - - this->vdev_->define_property ("Related_MediaCtrl", - anyval, - env); - - TAO_CHECK_ENV_RETURN (env, -1); - - return 0; -} - -// Bridge method -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_stream_endpoint (T_StreamEndpoint *&stream_endpoint) -{ - ACE_NEW_RETURN (stream_endpoint, - T_StreamEndpoint, - - -1); - return 0; -} - -// Bridge method -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_vdev (T_VDev *&vdev) -{ - ACE_NEW_RETURN (vdev, - T_VDev, - -1); - return 0; -} - -// Bridge method -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_mediactrl (T_MediaCtrl *&media_ctrl) -{ - ACE_NEW_RETURN (media_ctrl, - T_MediaCtrl, - -1); - return 0; -} - - -// ---------------------------------------------------------------------- - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Reactive_Strategy_A -// ---------------------------------------------------------------------- -// Constructor -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Endpoint_Reactive_Strategy_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Endpoint_Reactive_Strategy_A (TAO_ORB_Manager *orb_manager) - : TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl> (orb_manager) -{ -} - -// Destructor -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Endpoint_Reactive_Strategy_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Endpoint_Reactive_Strategy_A (void) -{ -} - -// Creates an "A" type streamendpoint, and a vdev and returns the -// object references -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy_A<T_StreamEndpoint, T_VDev, T_MediaCtrl>::create_A (AVStreams::StreamEndPoint_A_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env) -{ - if (this->activate () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) TAO_AV_Endpoint_Reactive_Strategy_A: Error in activate ()\n"), - -1); - - stream_endpoint = this->stream_endpoint_a_; - vdev = this->vdev_; - return 0; - -} - -// Put the stream_endpoint into the POA -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate_stream_endpoint (CORBA::Environment &env) -{ - T_StreamEndpoint *stream_endpoint_a = 0; - - // Use the bridge method - if (this->make_stream_endpoint (stream_endpoint_a) == -1) - return -1; - - CORBA::String_var stream_endpoint_ior = this->orb_manager_->activate (stream_endpoint_a, - env); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"TAO_AV_Endpoint_Reactive_Strategy_A::activate_stream_endpoint,Stream Endpoint ior is : %s\n",stream_endpoint_ior.in ())); - - // Save the object references, so that create_a can return them - this->stream_endpoint_a_ = stream_endpoint_a->_this (env); - TAO_CHECK_ENV_RETURN (env, -1); - - return 0; -} - -// ---------------------------------------------------------------------- -// TAO_AV_Endpoint_Reactive_Strategy_B -// ---------------------------------------------------------------------- - -// Constructor -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Endpoint_Reactive_Strategy_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Endpoint_Reactive_Strategy_B (TAO_ORB_Manager *orb_manager) - : TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl> (orb_manager) -{ -} - -// Destructor -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Endpoint_Reactive_Strategy_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Endpoint_Reactive_Strategy_B (void) -{ -} - -// Activate stream_endpoint -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate_stream_endpoint (CORBA::Environment &env) -{ - T_StreamEndpoint *stream_endpoint_b = 0; - - if (this->make_stream_endpoint (stream_endpoint_b) == -1) - return -1; - CORBA::String_var stream_endpoint_ior = this->orb_manager_->activate (stream_endpoint_b, - env); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"TAO_AV_Endpoint_Reactive_Strategy_B::activate_stream_endpoint,Stream Endpoint ior is : %s\n",stream_endpoint_ior.in ())); - - this->stream_endpoint_b_ = stream_endpoint_b->_this (env); - TAO_CHECK_ENV_RETURN (env, -1); - - return 0; -} - -// Returns a "B" type stream_endpoint and a vdev -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Endpoint_Reactive_Strategy_B<T_StreamEndpoint, T_VDev, T_MediaCtrl>::create_B (AVStreams::StreamEndPoint_B_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env) -{ - if (this->activate () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) TAO_AV_Endpoint_Reactive_Strategy_B: Error in activate ()\n"), - -1); - - stream_endpoint = this->stream_endpoint_b_; - vdev = this->vdev_; - return 0; - -} - -// ---------------------------------------------------------------------- -// TAO_AV_Child_Process -// ---------------------------------------------------------------------- - -// Constructor -template <class T_StreamEndpoint_B, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process <T_StreamEndpoint_B, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process () - : stream_endpoint_name_ (0), - pid_ (-1) -{ - this->pid_ = ACE_OS::getpid (); - if (this->pid_ == 0) - ACE_ERROR ((LM_ERROR,"getpid () failed\n")); - ACE_OS::hostname (this->host_, - sizeof this->host_); -} - -// Initializes the ORB, activates the objects, and release the semaphore -template <class T_StreamEndpoint_B, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint_B, T_VDev, T_MediaCtrl>::init (int argc, char **argv) -{ - TAO_TRY - { - // create the objects and activate them in the poa - this->activate_objects (argc, - argv, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Get ourselves a naming_service object reference - this->bind_to_naming_service (TAO_TRY_ENV); - TAO_CHECK_ENV; - - // Register the vdev with the naming service - this->register_vdev (TAO_TRY_ENV); - TAO_CHECK_ENV; - - // register the stream_endpoing with the naming_service - this->register_stream_endpoint (TAO_TRY_ENV); - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("TAO_Child_Process"); - return -1; - } - TAO_ENDTRY; - - // release the semaphore the parent is waiting on - if (this->release_semaphore () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Error releasing semaphores\n"), - -1); - - return 0; -} - -// initializes the orb, and activates the objects -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate_objects (int argc, - char **argv, - CORBA::Environment &env) -{ - // initialize the orb - this->orb_manager_.init (argc, - argv, - env); - TAO_CHECK_ENV_RETURN (env, -1); - - // bridge method to make a new stream endpoint - if (this->make_stream_endpoint (this->stream_endpoint_) == -1) - return -1; - - // bridge method to make a new vdev - if (this->make_vdev (this->vdev_) == -1) - return -1; - - // bridge method to make a new media controller - if (this->make_mediactrl (this->media_ctrl_) == -1) - return -1; - - // activate the stream_endpoint - CORBA::String_var stream_endpoint_ior = this->orb_manager_.activate (this->stream_endpoint_, - env); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,stream_endpoint_ior :%s\n",stream_endpoint_ior.in ())); - - // activate the vdev - CORBA::String_var vdev_ior = this->orb_manager_.activate (this->vdev_, - env); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects, vdev ior is :%s\n",vdev_ior.in ())); - - // activate the media controller - CORBA::String_var media_ctrl_ior = this->orb_manager_.activate (this->media_ctrl_, - env); - - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,media_ctrl_ior is: %s\n",media_ctrl_ior.in ())); - - return 0; - -} - -// Bind to the namingservice -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::bind_to_naming_service (CORBA::Environment &env) -{ - CORBA::Object_var naming_obj = - this->orb_manager_.orb ()->resolve_initial_references ("NameService"); - if (CORBA::is_nil (naming_obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to resolve the Name Service.\n"), - -1); - // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); - this->naming_context_ = - CosNaming::NamingContext::_narrow (naming_obj.in (), - env); - TAO_CHECK_ENV_RETURN (env, - -1); - - return 0; -} - -// register the vdev with the naming service -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::register_vdev (CORBA::Environment &env) -{ - char vdev_name [BUFSIZ]; - ACE_OS::sprintf (vdev_name, - "%s:%s:%d", - "VDev", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",vdev_name)); - // create the name - this->vdev_name_.length (1); - this->vdev_name_ [0].id = CORBA::string_dup (vdev_name); - - // make the media controller a property of the vdev - CORBA::Any media_ctrl_property; - media_ctrl_property <<= this->orb_manager_.orb ()->object_to_string (this->media_ctrl_->_this (env), - env); - this->vdev_->define_property ("Related_MediaCtrl", - media_ctrl_property, - env); - TAO_CHECK_ENV_RETURN (env,-1); - - // Register the vdev with the naming server. - this->naming_context_->bind (this->vdev_name_, - this->vdev_->_this (env), - env); - - // If the object was already there, replace the older reference - // with this one - if (env.exception () != 0) - { - env.clear (); - this->naming_context_->rebind (this->vdev_name_, - this->vdev_->_this (env), - env); - TAO_CHECK_ENV_RETURN (env, -1); - } - - return 0; -} - -// run the orb event look -template <class T_StreamEndpoint_B, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint_B, T_VDev, T_MediaCtrl>::run (ACE_Time_Value *tv) -{ - int result; - TAO_TRY - { - result = this->orb_manager_.run (TAO_TRY_ENV,tv); - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("orb_manager_.run ()"); - return -1; - } - TAO_ENDTRY; - return result; -} - -// release the semaphore the parent is waiting on -template <class T_StreamEndpoint_B, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint_B, T_VDev, T_MediaCtrl>::release_semaphore () -{ - char sem_str [BUFSIZ]; - - sprintf (sem_str, - "%s:%s:%d", - "TAO_AV_Process_Semaphore", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) semaphore is %s\n", - sem_str)); - - // Release the lock on which the server is waiting - ACE_Process_Semaphore semaphore (0, // 0 means that the semaphore is - // initially locked - sem_str); - - if (semaphore.release () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%P|%t) Error releasing semaphore %s: %p\n", - sem_str, - "semaphore.release ()"), - -1); - - return 0; -} - -// register the stream_endpoint with the naming service -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::register_stream_endpoint (CORBA::Environment &env) -{ - // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); - // Create a name for the video control object - // subclasses can define their own name for the streamendpoint - // Register the stream endpoint object with the naming server. - this->naming_context_->bind (this->stream_endpoint_name_, - this->stream_endpoint_->_this (env), - env); - - // if the name was already there, replace the reference with the new one - if (env.exception () != 0) - { - env.clear (); - this->naming_context_->rebind (this->stream_endpoint_name_, - this->stream_endpoint_->_this (env), - env); - TAO_CHECK_ENV_RETURN (env, -1); - } - - return 0; -} - -// Bridge method to make a new stream_endpoint -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_stream_endpoint (T_StreamEndpoint *&stream_endpoint) -{ - ACE_NEW_RETURN (stream_endpoint, - T_StreamEndpoint, - -1); - return 0; -} - -// Bridge method to make a new vdev -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_vdev (T_VDev *&vdev) -{ - ACE_NEW_RETURN (vdev, - T_VDev, - -1); - return 0; -} - -// Bridge method to make a new media controller -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -int -TAO_AV_Child_Process<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_mediactrl (T_MediaCtrl *&media_ctrl) -{ - ACE_DEBUG ((LM_DEBUG,"(%P|%t) TAO_AV_Child_Process::make_mediactrl ()\n")); - ACE_NEW_RETURN (media_ctrl, - T_MediaCtrl, - -1); - return 0; -} - -// %% its not clear whether we should be deleting the objects, since -// if the application overrides the make_mediactrl methods etc., -// then, we may not own these objects. -// For now, we dont delete the objects, since they exist for the -// lifetime of the process anyway -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process () -{ - // Remove the names from the naming service - if (CORBA::is_nil (this->naming_context_.in ()) == 0) - return; - TAO_TRY - { - this->naming_context_->unbind (this->stream_endpoint_name_, - TAO_TRY_ENV); - TAO_CHECK_ENV; - - this->naming_context_->unbind (this->vdev_name_, - TAO_TRY_ENV); - TAO_CHECK_ENV; - } - TAO_CATCHANY - { - TAO_TRY_ENV.print_exception ("TAO_Endpoint_Process_Strategy::activate"); - } - TAO_ENDTRY; - -// if (this->stream_endpoint_ != 0) -// delete this->stream_endpoint_; -// if (this->vdev_ != 0) -// delete this->vdev_; -// if (this->media_ctrl_ != 0) -// delete this->media_ctrl_; -} - -// ---------------------------------------------------------------------- -// TAO_AV_Child_Process_A -// ---------------------------------------------------------------------- - -// Define the name of the stream_endpoint, as used to register with -// the naming service -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process_A () -{ - char stream_endpoint_name[BUFSIZ]; - ACE_OS::sprintf (stream_endpoint_name, - "%s:%s:%d", - "Stream_Endpoint_A", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",stream_endpoint_name)); - this->stream_endpoint_name_.length (1); - this->stream_endpoint_name_ [0].id = CORBA::string_dup (stream_endpoint_name); -} - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process_A () -{ -} - -// ---------------------------------------------------------------------- -// TAO_AV_Child_Process_B -// ---------------------------------------------------------------------- - -// Define the name of the stream_endpoint, as used to register with -// the naming service -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process_B () -{ - char stream_endpoint_name[BUFSIZ]; - ACE_OS::sprintf (stream_endpoint_name, - "%s:%s:%d", - "Stream_Endpoint_B", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",stream_endpoint_name)); - this->stream_endpoint_name_.length (1); - this->stream_endpoint_name_ [0].id = CORBA::string_dup (stream_endpoint_name); -} - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process_B () -{ -} - -#endif /* TAO_AV_ENDPOINT_STRATEGY_T_C */ diff --git a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.h b/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.h deleted file mode 100644 index 8483ce20a34..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.h +++ /dev/null @@ -1,222 +0,0 @@ -// $Id$ - -#ifndef TAO_AV_ENDPOINT_STRATEGY_T_H -#define TAO_AV_ENDPOINT_STRATEGY_T_H - -#include "Endpoint_Strategy.h" - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Reactive_Strategy - : public TAO_AV_Endpoint_Strategy -// = DESCRIPTION -// Reactive strategy base class -{ - protected: - TAO_AV_Endpoint_Reactive_Strategy (TAO_ORB_Manager *orb_manager); - // Constructor - - virtual ~TAO_AV_Endpoint_Reactive_Strategy (void); - // Destructor. - - virtual int activate (void); - // creates and activates the streamendpoint, vdev, and mediacontrol - - virtual int activate_stream_endpoint (CORBA::Environment &env) = 0; - // activates the stream_endpoint with the POA - - virtual int activate_vdev (CORBA::Environment &env); - // activates the vdev with the POA - - virtual int activate_mediactrl (CORBA::Environment &env); - // activates the media controller with the POA - - virtual int make_vdev (T_VDev *&vdev); - // Bridge method to create a vdev, a la Acceptor. Applications - // can override this - - virtual int make_stream_endpoint (T_StreamEndpoint *&stream_endpoint); - // Bridge method to create a stream_endpoint, a la Acceptor. Applications - // can override this - - virtual int make_mediactrl (T_MediaCtrl *&media_ctrl); - // Bridge method to create a media_ctrl, a la Acceptor. Applications - // can override this - - TAO_ORB_Manager *orb_manager_; - // ORB manager, used to activate the objects - -}; -// ---------------------------------------------------------------------- - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Reactive_Strategy_A - : public TAO_AV_Endpoint_Reactive_Strategy<T_StreamEndpoint, T_VDev , T_MediaCtrl> -// = DESCRIPTION -// Reactive strategy -{ - public: - TAO_AV_Endpoint_Reactive_Strategy_A (TAO_ORB_Manager *orb_manager); - // Constructor - - virtual ~TAO_AV_Endpoint_Reactive_Strategy_A (void); - // Destructor. - - virtual int activate_stream_endpoint (CORBA::Environment &env); - // Overrides the base class stream_endpoint activator, to activate - // an "A" type endpoint - - virtual int create_A (AVStreams::StreamEndPoint_A_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env); - // Called by the MMDevice, when it needs to create an A type endpoint - - -}; - -// ---------------------------------------------------------------------- -template <class T_StreamEndpoint, class T_Vdev , class T_MediaCtrl> -class TAO_ORBSVCS_Export TAO_AV_Endpoint_Reactive_Strategy_B - : public TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_Vdev, T_MediaCtrl> -// = DESCRIPTION -// Reactive strategy -{ - public: - TAO_AV_Endpoint_Reactive_Strategy_B (TAO_ORB_Manager *); - // Constructor. - - virtual ~TAO_AV_Endpoint_Reactive_Strategy_B (void); - // Destructor. - - virtual int activate_stream_endpoint (CORBA::Environment &env); - // Overrides the base class stream_endpoint activator, to activate - // a "B" type endpoint - - virtual int create_B (AVStreams::StreamEndPoint_B_ptr &stream_endpoint, - AVStreams::VDev_ptr &vdev, - CORBA::Environment &env); - // Called by the MMDevice, when it needs to create a B type endpoint -}; - -// ---------------------------------------------------------------------- - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -class TAO_ORBSVCS_Export TAO_AV_Child_Process -// = DESCRIPTION -// Helper class for the child process created in TAO_AV_Endpoint_Process_Strategy -{ -public: - TAO_AV_Child_Process (); - // Constructor - - virtual ~TAO_AV_Child_Process (); - // Destructor - - int init (int argc, char **argv); - // Initializes the ORB, creates and activates the - // T_StreamEndpoint, T_VDev, T_MediaCtrl in the POA - - int run (ACE_Time_Value *tv = 0); - // runs the ORB event loop - - protected: - int activate_objects (int argc, - char **argv, - CORBA::Environment &env); - // Creates the objects and inserts them into the Naming - // Service, so the parent can pick the IOR's and - // return them to the client - - - int bind_to_naming_service (CORBA::Environment &env); - // Binds to the naming service - - int register_vdev (CORBA::Environment &env); - // Registers vdev with the naming service - - int register_stream_endpoint (CORBA::Environment &env); - // Registers stream_endpoint with the naming service - - int release_semaphore (); - // Releases the semaphore on which the parent is waiting on - - virtual int make_vdev (T_VDev *&vdev); - // Bridge method to create a vdev, a la Acceptor. Applications - // can override this - - virtual int make_stream_endpoint (T_StreamEndpoint *&stream_endpoint); - // Bridge method to create a stream_endpoint, a la Acceptor. Applications - // can override this - - virtual int make_mediactrl (T_MediaCtrl *&media_ctrl); - // Bridge method to create a media_ctrl, a la Acceptor. Applications - // can override this - - TAO_ORB_Manager orb_manager_; - // The ORB Manager - - CosNaming::NamingContext_var naming_context_; - // The root Naming Context of the TAO naming service - - CosNaming::Name vdev_name_; - // Name of the vdev - - CosNaming::Name stream_endpoint_name_; - // Name of the stream_endpoint - - T_StreamEndpoint *stream_endpoint_; - // The stream endpoint member - - T_VDev *vdev_; - // The virtual device - - T_MediaCtrl *media_ctrl_; - // Media controller - - pid_t pid_; - // pid of this process - - char host_[MAXHOSTNAMELEN]; - // Name of the host. -}; - -// ---------------------------------------------------------------------- - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -class TAO_ORBSVCS_Export TAO_AV_Child_Process_A - : public TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl> -// = DESCRIPTION -// Helper class for the child process created in TAO_AV_Child_Process -{ -public: - TAO_AV_Child_Process_A (void); - // Constructor. - - virtual ~TAO_AV_Child_Process_A (void); - // Destructor. -}; - -// ---------------------------------------------------------------------- - -template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -class TAO_ORBSVCS_Export TAO_AV_Child_Process_B - : public TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl> -// = DESCRIPTION -// Helper class for the child process created in TAO_AV_Child_Process -{ -public: - TAO_AV_Child_Process_B (void); - // Constructor. - - virtual ~TAO_AV_Child_Process_B (void); - // Destructor. -}; - -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "Endpoint_Strategy_T.cpp" -#endif /*ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Endpoint_Strategy_T.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ - -#endif /* TAO_AV_ENDPOINT_STRATEGY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/AV/README b/TAO/orbsvcs/orbsvcs/AV/README deleted file mode 100644 index ffe6958a6db..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/README +++ /dev/null @@ -1,28 +0,0 @@ -// $Id$ - -TAO Audio/Video Streaming service ---------------------------------- - - -This is a prototype implementation of the CORBA "Control and -Management of A/V streams" specification, that defines various -interfaces for controlling multimedia streams. - -This directory contains the following files - -AVStreams_i.{h,cpp}: Implementation of the A/V handshake specification, as well - as base classes for the various interfaces defined in the spec. - -Endpoint_Strategy.{h,cpp}: Implementation of various multimedia endpoint activation strategies. - -A complete distributed audio/video streaming application that -illustrates the use of the various components defined above is -available in the following directory: - -TAO/orbsvcs/tests/AVStreams/mpeg/source/ - - -Sumedh Mungee <sumedh@cs.wustl.edu> -Nagarajan Surendran <naga@cs.wustl.edu> -Alexander Arulanthu <alex@cs.wustl.edu> - diff --git a/TAO/orbsvcs/orbsvcs/AV/sfp.cpp b/TAO/orbsvcs/orbsvcs/AV/sfp.cpp deleted file mode 100644 index e76f24f87b7..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/sfp.cpp +++ /dev/null @@ -1,918 +0,0 @@ -#include "orbsvcs/AV/sfp.h" -#include "ace/ARGV.h" - -// $Id$ - -// constructor. -SFP::SFP (CORBA::ORB_ptr orb, - ACE_Reactor* reactor, - ACE_Time_Value timeout1, - ACE_Time_Value timeout2, - SFP_Callback *callback) - :orb_ (orb), - reactor_ (reactor), - encoder_ (0), - decoder_ (0), - timeout1_ (timeout1), - timeout2_ (timeout2), - start_tries_ (10), - startReply_tries_ (10), - callback_ (callback), - sequence_num_ (0) -{ - -} - -void -SFP::set_cdr_length (void) -{ - CORBA::ULong bodylen = encoder_->total_length (); - char* buf = ACE_const_cast(char*,encoder_->buffer ()); - buf += 4; -#if !defined (TAO_ENABLE_SWAP_ON_WRITE) - *ACE_reinterpret_cast(CORBA::ULong*,buf) = bodylen; -#else - if (!encoder_->do_byte_swap ()) - { - *ACE_reinterpret_cast(CORBA::ULong*, buf) = bodylen; - } - else - { - CDR::swap_4 (ACE_reinterpret_cast(char*,&bodylen), buf); - } -#endif -} - -// Copies length bytes from the given message into the -// CDR buffer. Returns 0 on success, -1 on failure -int -SFP::create_cdr_buffer (char *message, - size_t length) -{ - if (this->decoder_) - delete this->decoder_; - - ACE_NEW_RETURN (this->decoder_, - TAO_InputCDR (message, - length), - -1); - - ACE_OS::memcpy (this->decoder_->rd_ptr (), - message, - length); - - return 0; -} - -// Start the active end of the stream. -int -SFP::start_stream (const char *receiver_addr) -{ - // @@we have to do ACE_NTOHS for all the network-byte ordered fields. - int result; - ACE_INET_Addr sender; - result = this->connect_to_receiver (receiver_addr); - if (result < 0) - return result; - while (this->start_tries_ > 0) - { - if ((result = this->send_start ()) != 0) - return result; - char magic_number [4]; - // Timed recv. - ssize_t n =this->dgram_.recv (magic_number, - sizeof(magic_number), - sender, - MSG_PEEK, - &this->timeout1_); - ACE_DEBUG ((LM_DEBUG,"n = %d\n",n)); - if (n == -1) - { - if (errno == ETIME) - { - ACE_DEBUG ((LM_DEBUG,"Timed out in reading StartReply")); - this->start_tries_ --; - continue; - } - else - ACE_ERROR_RETURN ((LM_ERROR,"dgram recv error:%p","recv"),-1); - } - else if (n==0) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::start_stream -peek"),-1); - // successful receive of dgram. - ACE_DEBUG ((LM_DEBUG,"StartReply received")); - // check if its startreply message. - char *magic_string = this->magic_number_to_string (magic_number); - if (ACE_OS::strcmp (magic_string,TAO_SFP_STARTREPLY_MAGIC_NUMBER) == 0) - { - ACE_DEBUG ((LM_DEBUG,"(%P|%t)StartReply message received\n")); - flowProtocol::StartReply start_reply; - n = this->dgram_.recv ((char *)&start_reply, - sizeof (start_reply), - sender); - if (n != sizeof (start_reply)) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input-StartReply\n"),0); - // check for SFP version difference.?? - // Call the application back. - this->state_ = REPLY_RECEIVED; - } - // register the data handler. - result = this->register_dgram_handler (); - return result; - } - return 0; -} - -// Start the passive end of the stream. -int -SFP::start_stream (const char *local_addr,int Credit) -{ - int result; - ACE_INET_Addr sender; - - this->state_ = PASSIVE_START; - ACE_INET_Addr myaddr (local_addr); - result = this->dgram_.open (myaddr); - - if (result != 0) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::passive start- open failed\n"),-1); - - char magic_number[4]; - // Timed recv. - ssize_t n =this->dgram_.recv (magic_number, - sizeof(magic_number), - sender, - MSG_PEEK, - &this->timeout2_); - if ((n == -1) && (errno == ETIME)) - { - ACE_ERROR_RETURN ((LM_ERROR,"Timedout in reading Start"),-1); - } - else if (n==0) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::start_stream -peek"),-1); - - ACE_DEBUG ((LM_DEBUG,"Start received:")); - char *magic_string = this->magic_number_to_string (magic_number); - if (ACE_OS::strcmp (magic_string,TAO_SFP_START_MAGIC_NUMBER) == 0) - { - // Read the start message. - flowProtocol::Start start; - n = this->dgram_.recv ((char *)&start, - sizeof (start), - sender); - if (n != sizeof (start)) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input - Start\n"),0); - else - ACE_DEBUG ((LM_DEBUG,"Start message consumed\n")); - this->state_ = START_RECEIVED; - this->receiver_inet_addr_.set (sender); - // Now send a startReply message back. - result = this->send_startReply (); - if (result != 0) - return result; - // Now we register a timeout handler until we receive a data - // frame. - result = this->reactor_->schedule_timer (this, - 0, - this->timeout1_); - if (result == -1) - ACE_ERROR_RETURN ((LM_ERROR,"schedule_timer failed\n"),result); - - // register the data handler. - result = this->register_dgram_handler (); - return result; - } - - else - { - ACE_ERROR_RETURN ((LM_ERROR,"Invalid messaged received"),-1); - } - return 0; -} - -// Sends the ACE_Message_Block data as a frame, fragmenting if necessary. -int -SFP::send_simple_frame (ACE_Message_Block *frame) -{ - // Currently there is no fragmentation handled, just a simple - // frame. - - ACE_Message_Block *mb; - ACE_NEW_RETURN (mb, - ACE_Message_Block, - -1); - if (this->credit_ > 0) - { - // if we have enough credit then we send. - // Currently no fragmentation. - int length = frame->length (); - - if (length > ACE_MAX_DGRAM_SIZE) - ACE_ERROR_RETURN ((LM_ERROR,"sfp doesn't support fragmentation yet"),-1); - - flowProtocol::frameHeader frame_header; - - // The magic_number and flags are to be sent in network-byte order. - frame_header.magic_number [0] = ACE_HTONS ('='); - frame_header.magic_number [1] = ACE_HTONS ('S'); - frame_header.magic_number [2] = ACE_HTONS ('F'); - frame_header.magic_number [3] = ACE_HTONS ('P'); - - // set the byte order and no fragments. - frame_header.flags = 0; - frame_header.flags |= TAO_ENCAP_BYTE_ORDER; - - frame_header.flags = ACE_HTONS (frame_header.flags); - //set the size of the message block. - int len = sizeof(frame_header.magic_number)+sizeof - (frame_header.flags); - mb->size (len); - - mb->rd_ptr ((char *)&frame_header); - mb->wr_ptr ((char *)&frame_header+len); - if (this->encoder_ != 0) - delete this->encoder_; - ACE_NEW_RETURN (this->encoder_, - TAO_OutputCDR, - -1); - - frame_header.message_type = flowProtocol::SimpleFrame; - frame_header.message_size = frame->length (); - this->encoder_->write_octet (frame_header.message_type); - this->encoder_->write_ulong (frame_header.message_size); - - // This is a good maximum, because Dgrams cannot be longer than - // 64K and the usual size for a CDR fragment is 512 bytes. - // @@ TODO In the future we may need to allocate some memory - // from the heap. - const int TAO_WRITEV_MAX = 128; - iovec iov[TAO_WRITEV_MAX]; - - iov[0].iov_base = mb->rd_ptr (); - iov[0].iov_len = mb->length (); - ACE_DEBUG ((LM_DEBUG,"length: %d ",mb->length ())); - int iovcnt = 1; - for (const ACE_Message_Block* b = this->encoder_->begin (); - b != this->encoder_->end () && iovcnt < TAO_WRITEV_MAX; - b = b->cont ()) - { - iov[iovcnt].iov_base = b->rd_ptr (); - iov[iovcnt].iov_len = b->length (); - ACE_DEBUG ((LM_DEBUG,"length: %d ",b->length ())); - iovcnt++; - } - iov[iovcnt].iov_base = frame->rd_ptr (); - iov[iovcnt].iov_len = frame->length (); - ACE_DEBUG ((LM_DEBUG,"length: %d ",frame->length ())); - ssize_t n = this->dgram_.send (iov, - iovcnt, - this->receiver_inet_addr_); - if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "send_simple_frame (%t) send failed %p\n", ""),-1); - else if (n == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "send_simple_Frame (%t) EOF on send \n"),-1); - } - return 0; -} - -// This is used to send large frames with fragmentation.This is not -// complete yet. -int -SFP::send_frame (ACE_Message_Block *frame) -{ - ACE_Message_Block *mb; - ACE_NEW_RETURN (mb, - ACE_Message_Block, - -1); - if (this->credit_ > 0) - { - // if we have enough credit then we send. - // Do fragmentation if necessary. - int length = frame->length (); - - int total_length = 0; - ACE_Message_Block *temp = frame; - while (temp != 0) - { - total_length += temp->length (); - temp = temp->next (); - } - flowProtocol::frameHeader frame_header; - - // The magic_number and flags are to be sent in network-byte order. - frame_header.magic_number [0] = ACE_HTONS ('='); - frame_header.magic_number [1] = ACE_HTONS ('S'); - frame_header.magic_number [2] = ACE_HTONS ('F'); - frame_header.magic_number [3] = ACE_HTONS ('P'); - // sizeof (frameHeader) may have to be replaced with more - // accurate size??. - if (total_length > (ACE_MAX_DGRAM_SIZE- sizeof (flowProtocol::frameHeader))) - { - // If the message size is not okay including the headers i.e it - // cannot fit in a dgram. - - // set the byte order and no fragments. - frame_header.flags = 0; - frame_header.flags |= TAO_ENCAP_BYTE_ORDER; - // set the fragments bit. - frame_header.flags |= 2; - - frame_header.flags = ACE_HTONS (frame_header.flags); - - // first fragment will have size to be - //set the size of the message block. - int len = sizeof(frame_header.magic_number)+sizeof - (frame_header.flags); - mb->size (len); - - mb->rd_ptr ((char *)&frame_header); - mb->wr_ptr ((char *)&frame_header+len); - if (this->encoder_ != 0) - delete this->encoder_; - ACE_NEW_RETURN (this->encoder_, - TAO_OutputCDR, - -1); - - - // This is a good maximum, because Dgrams cannot be longer than - // 64K and the usual size for a CDR fragment is 512 bytes. - // @@ TODO In the future we may need to allocate some memory - // from the heap. - int message_len = 0; - const int TAO_WRITEV_MAX = 128; - iovec iov[TAO_WRITEV_MAX]; - - iov[0].iov_base = mb->rd_ptr (); - iov[0].iov_len = mb->length (); - int header_len = mb->length ()+2* sizeof(CORBA::ULong); - message_len += header_len; - ACE_DEBUG ((LM_DEBUG,"length: %d ",mb->length ())); - int iovcnt = 2; - ACE_Message_Block *mb = frame; - int prev_len; - while (mb != 0) - { - prev_len = message_len; - message_len += mb->length (); - if (message_len > ACE_MAX_DGRAM_SIZE) - { - // get only the length that we can accomodate. - int current_len = ACE_MAX_DGRAM_SIZE - prev_len; - if (current_len < mb->length ()) - { - // The above condition is an assertion. - iov [iovcnt].iov_base = mb->rd_ptr (); - iov [iovcnt].iov_len = current_len; - message_len += current_len; - mb->rd_ptr (current_len); - iovcnt++; - } - break; - } - else - { - // we can accomodate this message block - iov [iovcnt].iov_base = mb->rd_ptr (); - iov [iovcnt].iov_len = mb->length (); - message_len += mb->length (); - iovcnt++; - mb = mb->next (); - } - } - frame_header.message_type = flowProtocol::SimpleFrame; - frame_header.message_size = message_len - header_len; - this->encoder_->write_octet (frame_header.message_type); - this->encoder_->write_ulong (frame_header.message_size); - - // THe header will be only in the first cdr fragment. - iov[1].iov_base = this->encoder_->begin ()->rd_ptr (); - iov[1].iov_len = this->encoder_->begin ()->length (); - - // send the fragment 0. - ssize_t n = this->dgram_.send (iov, - iovcnt, - this->receiver_inet_addr_); - if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "send_frame (%t) fragment 0 send failed %p\n", ""),-1); - else if (n == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "send_Frame (%t) EOF on send \n"),-1); - - int frag_number = 0; - // If there is any more data send those as fragments. - while (mb != 0) - { - flowProtocol::fragment frag; - - // The magic_number and flags are to be sent in network-byte order. - frag.magic_number [0] = ACE_HTONS ('F'); - frag.magic_number [1] = ACE_HTONS ('R'); - frag.magic_number [2] = ACE_HTONS ('A'); - frag.magic_number [3] = ACE_HTONS ('G'); - - ACE_Message_Block *magic_block; - ACE_NEW_RETURN (magic_block, - ACE_Message_Block, - -1); - magic_block->size (5);// magic_number+flags size. - magic_block->rd_ptr ((char *)&frag); - magic_block->wr_ptr (5); - - iov [0].iov_base = magic_block->rd_ptr (); - iov [0].iov_len = magic_block->length (); - - int header_len = 5 + 4 *sizeof (CORBA::ULong); - message_len = header_len; - // 5 for magic_number+flags and 4 ulongs in the fragment header. - iovcnt = 2;// 1 is for the frag header. - while (mb != 0) - { - prev_len = message_len; - message_len += mb->length (); - if (message_len > ACE_MAX_DGRAM_SIZE) - { - // get only the length that we can accomodate. - int current_len = ACE_MAX_DGRAM_SIZE - prev_len; - if (current_len < mb->length ()) - { - // The above condition is an assertion. - iov [iovcnt].iov_base = mb->rd_ptr (); - iov [iovcnt].iov_len = current_len; - mb->rd_ptr (current_len); - message_len += current_len; - iovcnt++; - } - break; - } - else - { - // we can accomodate this message block - iov [iovcnt].iov_base = mb->rd_ptr (); - iov [iovcnt].iov_len = mb->length (); - message_len += mb->length (); - iovcnt++; - mb = mb->next (); - } - } - // send this fragment. - // set the more fragments flag - if ((mb != 0) && (mb->length () != 0)) - frag.flags = ACE_HTONS (2); - else - break; - if (this->encoder_ != 0) - delete this->encoder_; - ACE_NEW_RETURN (this->encoder_, - TAO_OutputCDR, - -1); - frag.frag_number = frag_number++; - frag.sequence_num = this->sequence_num_; - frag.frag_sz = message_len - header_len; - frag.source_id = 0; - this->encoder_->write_ulong (frag.frag_number); - this->encoder_->write_ulong (frag.sequence_num); - this->encoder_->write_ulong (frag.frag_sz); - this->encoder_->write_ulong (frag.source_id); - - // THe header will be only in the first cdr fragment. - iov[1].iov_base = this->encoder_->begin ()->rd_ptr (); - iov[1].iov_len = this->encoder_->begin ()->length (); - - // send the fragment now. - ssize_t n = this->dgram_.send (iov, - iovcnt, - this->receiver_inet_addr_); - if (n == -1) - { - ACE_DEBUG ((LM_DEBUG, - "SFP::send_frame (%t) send failed %p\n", "")); - return -1; - } - else if (n == 0) - { - ACE_DEBUG ((LM_DEBUG, - "SFP::send_frame (%t) EOF on send \n")); - return -1; - } - } - } - } - return 0; -} - - -// creates a connected dgram. -int -SFP::connect_to_receiver (const char *receiver_addr) -{ - this->receiver_addr_ = ACE_OS::strdup (receiver_addr); - // Get the local UDP address - if (this->dgram_.open (ACE_Addr::sap_any) == -1) - ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) datagram open failed %p\n"),1); - - // set the socket buffer sizes to 64k. - int sndbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; - int rcvbufsize = ACE_DEFAULT_MAX_SOCKET_BUFSIZ; - - if (this->dgram_.set_option (SOL_SOCKET, - SO_SNDBUF, - (void *) &sndbufsize, - sizeof (sndbufsize)) == -1 - && errno != ENOTSUP) - return -1; - else if (this->dgram_.set_option (SOL_SOCKET, - SO_RCVBUF, - (void *) &rcvbufsize, - sizeof (rcvbufsize)) == -1 - && errno != ENOTSUP) - return -1; - - this->receiver_inet_addr_.set (receiver_addr); - if (ACE_OS::connect (this->dgram_.get_handle (),(sockaddr *) this->receiver_inet_addr_.get_addr (), - this->receiver_inet_addr_.get_size ()) == -1) - ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) datagram connect failed %p\n"),-1); - return 0; -} - -// sends all the ACE_Message_Blocks in the current CDR stream. -int -SFP::send_cdr_buffer (void) -{ - // This is a good maximum, because Dgrams cannot be longer than - // 64K and the usual size for a CDR fragment is 512 bytes. - // @@ TODO In the future we may need to allocate some memory - // from the heap. - const int TAO_WRITEV_MAX = 128; - iovec iov[TAO_WRITEV_MAX]; - - int iovcnt = 0; - for (const ACE_Message_Block* b = this->encoder_->begin (); - b != this->encoder_->end () && iovcnt < TAO_WRITEV_MAX; - b = b->cont ()) - { - iov[iovcnt].iov_base = b->rd_ptr (); - iov[iovcnt].iov_len = b->length (); - iovcnt++; - } - // send the message. - ssize_t n = this->dgram_.send (iov, - iovcnt, - this->receiver_inet_addr_); - if (n == -1) - { - ACE_DEBUG ((LM_DEBUG, - "SFP::send_cdr_buffer (%t) send failed %p\n", "")); - return -1; - } - else if (n == 0) - { - ACE_DEBUG ((LM_DEBUG, - "SFP::send_cdr_buffer (%t) EOF on send \n")); - return -1; - } - return 0; -} - -int -SFP::send_start (void) -{ - int result; - // Start message is in network byte order. - // construct the start message - flowProtocol::Start start; - - // copy the magic number into the message - start.magic_number [0] = ACE_HTONS ('='); - start.magic_number [1] = ACE_HTONS ('S'); - start.magic_number [2] = ACE_HTONS ('T'); - start.magic_number [3] = ACE_HTONS ('A'); - - // put the version number into the field - start.major_version = ACE_HTONS (TAO_SFP_MAJOR_VERSION); - start.minor_version = ACE_HTONS (TAO_SFP_MINOR_VERSION); - - // flags field is all zeroes - start.flags = ACE_HTONS (0); - - this->state_ = ACTIVE_START; - - // Now send the network byte ordered start message. - int n = this->dgram_.send ((char *)&start, - sizeof (start), - this->receiver_inet_addr_); - if (n!= sizeof (start)) - ACE_ERROR_RETURN ((LM_ERROR,"start send failed\n"),-1); - - ACE_DEBUG ((LM_DEBUG," Start sent\n")); -// // non-interval timer. -// result = this->reactor_->schedule_timer (this, -// 0, -// this->timeout1_); -// if (result != 0) -// return result; - - return 0; -} - -int -SFP::send_startReply (void) -{ - int result; - - flowProtocol::StartReply start_reply; - - // copy the magic number into the message - start_reply.magic_number [0] = ACE_HTONS ('='); - start_reply.magic_number [1] = ACE_HTONS ('S'); - start_reply.magic_number [2] = ACE_HTONS ('T'); - start_reply.magic_number [3] = ACE_HTONS ('R'); - - start_reply.flags = ACE_HTONS (0); - - // Now send the network byte ordered start message. - int n = this->dgram_.send ((char *)&start_reply, - sizeof (start_reply), - this->receiver_inet_addr_); - if (n!= sizeof (start_reply)) - ACE_ERROR_RETURN ((LM_ERROR,"startreply send failed\n"),-1); - - ACE_DEBUG ((LM_DEBUG," startReply sent\n")); - return 0; -} - -int -SFP::handle_timeout (const ACE_Time_Value &tv, - const void *arg) -{ - int result; - // Handle the timeout for timeout1 and timeout2. - switch (this->state_) - { - case ACTIVE_START: - case PASSIVE_START: - // Timingout for Start Messages. - ACE_DEBUG ((LM_DEBUG,"Invalid state in handle_timeout\n")); - break; - case START_RECEIVED: - // we need to reduce the startreply_tries and also reschedule - // the timer. - if (this->startReply_tries_ --) - { - ACE_DEBUG ((LM_DEBUG,"Timed out on receiving Data Frame\n")); - // send startreply. - result = this->send_startReply (); - if (result != 0) - ACE_ERROR_RETURN ((LM_ERROR,"Error in sending startreply"),0); - this->reactor_->schedule_timer (this, - 0, - this->timeout1_); - } - else - { - this->end_stream (); - } - } - return 0; -} - -// Handle_input is called when data arrives on the dgram -// socket. Currently both the receiver and sender side input is -// handled in this same handle_input (). -int -SFP::handle_input (ACE_HANDLE fd) -{ - flowProtocol::MsgType msg_type; - ACE_INET_Addr sender; - char magic_number[4]; - ssize_t n =this->dgram_.recv (magic_number, - sizeof(magic_number), - sender, - MSG_PEEK); - if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input -peek"),-1); - else if (n==0) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input -peek"),0); - - // convert from network byte order to host order. - - magic_number [0] = ACE_NTOHS (magic_number [0]); - magic_number [1] = ACE_NTOHS (magic_number [1]); - magic_number [2] = ACE_NTOHS (magic_number [2]); - magic_number [3] = ACE_NTOHS (magic_number [3]); - - char *magic_string = this->magic_number_to_string (magic_number); - - if (ACE_OS::strcmp (magic_string,TAO_SFP_START_MAGIC_NUMBER) == 0) - { - ACE_DEBUG ((LM_DEBUG,"(%P|%t)Start message received\n")); - msg_type = flowProtocol::start; - } - else if (ACE_OS::strcmp (magic_string,TAO_SFP_STARTREPLY_MAGIC_NUMBER) == 0) - { - ACE_DEBUG ((LM_DEBUG,"(%P|%t)StartReply message received\n")); - msg_type = flowProtocol::startReply; - } - else if (ACE_OS::strcmp (magic_string,TAO_SFP_MAGIC_NUMBER) == 0) - { - ACE_DEBUG ((LM_DEBUG,"(%P|%t) frameHeader received\n")); - msg_type = flowProtocol::SimpleFrame; - } - else if (ACE_OS::strcmp (magic_string,TAO_SFP_FRAGMENT_MAGIC_NUMBER) == 0) - { - ACE_DEBUG ((LM_DEBUG,"(%P|%t) fragment Header received\n")); - msg_type = flowProtocol::Fragment; - } - else if (ACE_OS::strcmp (magic_string,TAO_SFP_CREDIT_MAGIC_NUMBER) == 0) - { - ACE_DEBUG ((LM_DEBUG,"(%P|%t) credit message received\n")); - msg_type = flowProtocol::Credit; - } - switch (this->state_) - { - case ACTIVE_START: - // Check if we received a StartReply back. - ACE_DEBUG ((LM_DEBUG,"Unexpected message while StartReply expected\n")); - break; - case PASSIVE_START: - // Check if we received a Start from the Sender. - ACE_DEBUG ((LM_DEBUG,"Unexpected message while Start expected\n")); - break; - case START_RECEIVED: - // In this state we check for credit frames. - switch (msg_type) - { - case flowProtocol::Credit: - { - flowProtocol::credit credit; - n = this->dgram_.recv ((char *)&credit, - sizeof (credit), - sender); - if (n != sizeof (credit)) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input - Credit\n"),0); - this->credit_ += credit.cred_num; - break; - } - case flowProtocol::start: - // consume the retransmitted start message. - { - flowProtocol::Start start; - n = this->dgram_.recv ((char *)&start, - sizeof (start), - sender); - if (n != sizeof (start)) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input - Start\n"),0); - else - ACE_DEBUG ((LM_DEBUG,"Start message consumed\n")); - // ACE_DEBUG ((LM_DEBUG,"Unexpected message while - // Credit expected\n")); - break; - } - case flowProtocol::SimpleFrame: - { - ACE_Message_Block * mb =this->read_simple_frame (); - this->callback_->receive_frame (mb); - } - } - break; - case REPLY_RECEIVED: - // In this state we check for Data frames. - switch (msg_type) - { - case flowProtocol::startReply: - { - flowProtocol::StartReply start_reply; - n = this->dgram_.recv ((char *)&start_reply, - sizeof (start_reply), - sender); - if (n != sizeof (start_reply)) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input-StartReply\n"),0); - else - ACE_DEBUG ((LM_DEBUG,"start reply consumed\n")); - } - } - } - return 0; -} - -char * -SFP::magic_number_to_string (char *magic_number) -{ - char *buf; - ACE_NEW_RETURN (buf, - char [5], - 0); - for (int i=0;i<4;i++) - { - buf [i] = magic_number [i]; - ACE_DEBUG ((LM_DEBUG,"%c ",buf [i])); - } - buf[i] = 0; - return buf; -} - -int -SFP::end_stream (void) -{ - ACE_DEBUG ((LM_DEBUG,"SFP - ending the stream\n")); - int result = this->reactor_->remove_handler (this, - ACE_Event_Handler::READ_MASK); - return result; -} - -int -SFP::register_dgram_handler (void) -{ - int result; - result = this->reactor_->register_handler (this, - ACE_Event_Handler::READ_MASK); - return result; -} - -ACE_HANDLE -SFP::get_handle (void) const -{ - return this->dgram_.get_handle (); -} - -ACE_Message_Block * -SFP::read_simple_frame (void) -{ - ACE_DEBUG ((LM_DEBUG,"Reading simple frame\n")); - // Check to see what the length of the message is. - - flowProtocol::frameHeader frame_header; - char *buf; - ssize_t firstlen =sizeof (frame_header.magic_number)+sizeof (frame_header.flags); - ssize_t buflen =firstlen+2*sizeof (CORBA::ULong)+3;// hack to ensure - // that buffer is aligned for CDR. - - ACE_DEBUG ((LM_DEBUG,"firstlen = %d,buflen =%d\n",firstlen,buflen)); - ACE_NEW_RETURN (buf, - char [buflen], - 0); - - ACE_INET_Addr sender; - - buf +=3; - ssize_t n =this->dgram_.recv (buf, - buflen, - sender, - MSG_PEEK); - if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input -peek"),0); - else if (n==0) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input -peek"),0); - for (int i=0;i<4;i++) - ACE_DEBUG ((LM_DEBUG,"%c ",buf[i])); - //skip the magic_number.. - buf += 4 ; - - // Get the byte order from the flags. - - int byte_order = buf[0]; - ACE_DEBUG ((LM_DEBUG,"byte_order = %d\n",byte_order)); - // move past the flags. - buf += 1; - // CORBA::ULong *header = (CORBA::ULong *) (buf+firstlen); - // ACE_DEBUG ((LM_DEBUG,"first ulong = %d, second ulong = %d",*(CORBA::ULong*)(buf+firstlen), - // *(CORBA::ULong *)(buf+firstlen+sizeof (CORBA::ULong)))); - - // ACE_DEBUG ((LM_DEBUG,"first ulong = %d, second ulong = %d",header [0],header[1])); - - - ACE_Message_Block mb (buf,buflen-firstlen+CDR::MAX_ALIGNMENT); - CDR::mb_align (&mb); - mb.wr_ptr (buflen-firstlen); - ACE_DEBUG ((LM_DEBUG,"mb len = %d\n",mb.length ())); - TAO_InputCDR cdr (&mb,byte_order); - cdr.read_octet (frame_header.message_type); - cdr.read_ulong (frame_header.message_size); - - ACE_DEBUG ((LM_DEBUG,"message_type = %d, message_size = %d", - frame_header.message_type,frame_header.message_size)); - - char *message; - int message_len = buflen+frame_header.message_size; - ACE_NEW_RETURN (message, - char [message_len], - 0); - - ACE_DEBUG ((LM_DEBUG,"message_len = %d\n",message_len)); - n = this->dgram_.recv (message,message_len,sender); - if (n == -1) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input -peek"),0); - else if (n==0) - ACE_ERROR_RETURN ((LM_ERROR,"SFP::handle_input -peek"),0); - - ACE_Message_Block *message_block; - ACE_NEW_RETURN (message_block, - ACE_Message_Block (message+buflen, - message_len-buflen), - 0); - message_block->wr_ptr (message_len-buflen); - ACE_DEBUG ((LM_DEBUG,"messageblock length: ",message_block ->length ())); - return message_block; -} diff --git a/TAO/orbsvcs/orbsvcs/AV/sfp.h b/TAO/orbsvcs/orbsvcs/AV/sfp.h deleted file mode 100644 index 2dfa734a1c5..00000000000 --- a/TAO/orbsvcs/orbsvcs/AV/sfp.h +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// AVStreams. -// -// = FILENAME -// sfp.h -// -// = AUTHOR -// Nagarajan Surendran <naga@cs.wustl.edu> -// -// ============================================================================ - -#if !defined (TAO_AV_SFP_H) -#define TAO_AV_SFP_H - -#include "ace/SOCK_Dgram.h" -#include "orbsvcs/sfpC.h" - -// default arguments to pass to use for the ORB -const char *TAO_SFP_ORB_ARGUMENTS = "-ORBobjrefstyle URL"; - -// SFP magic numbers -const char *TAO_SFP_MAGIC_NUMBER = "=SFP"; -const char *TAO_SFP_FRAGMENT_MAGIC_NUMBER = "FRAG"; -const char *TAO_SFP_START_MAGIC_NUMBER = "=STA"; -const char *TAO_SFP_CREDIT_MAGIC_NUMBER = "=CRE"; -const char *TAO_SFP_STARTREPLY_MAGIC_NUMBER = "=STR"; - -// SFP version 1.0 -const unsigned char TAO_SFP_MAJOR_VERSION = 1; -const unsigned char TAO_SFP_MINOR_VERSION = 0; - -// lengths of various SFP headers -const unsigned char TAO_SFP_FRAME_HEADER_LEN = 12; - -class TAO_ORBSVCS_Export SFP_Callback - // =TITLE - // Callback interface for SFP. - // - // =Description - // Application should create a callback object which they - // register with the SFP. The SFP implementation notifies the - // applicationn of any changes in the stream status like stream - // established, stream ended. -{ -public: - virtual int start_failed (void) = 0; - // This is called for both active and passive start. - - virtual int stream_established (void) = 0; - // This is a callback for both active and passive stream - // establshment. - - virtual int receive_frame (ACE_Message_Block *frame) =0; -}; - -class TAO_ORBSVCS_Export SFP :public virtual ACE_Event_Handler - // = TITLE - // SFP implementation on UDP. - // - // = Description - // This implements the methods to send and receive data octet - // streams using the Simple Flow Protocol. - -{ -public: - enum State - { - ACTIVE_START, - PASSIVE_START, - TIMEDOUT_T1, - TIMEDOUT_T2, - REPLY_RECEIVED, - START_RECEIVED - }; - - SFP (CORBA::ORB_ptr orb, - ACE_Reactor* reactor, - ACE_Time_Value timeout1, - ACE_Time_Value timeout2, - SFP_Callback *callback); - // constructor. - - virtual int start_stream (const char *receiver_addr); - // Actively start the stream by trying to connect to the UDP - // receiver_addr in host:port format. - - virtual int start_stream (const char *local_addr,int credit_); - // Passive start. - - virtual int send_simple_frame (ACE_Message_Block *frame); - // sends a single frame over UDP. - - virtual int send_frame (ACE_Message_Block *frame); - // This will send a larger frame fragmenting if necessary. - - virtual ACE_Message_Block* read_simple_frame (void); - // receives a single frame from the network. - - virtual int end_stream (void); - // terminates the stream. - - virtual int handle_input (ACE_HANDLE fd); - // Callback when event happens on the dgram socket. - - virtual int handle_timeout (const ACE_Time_Value&, const void*); - // Used for timeout for the number of tries for starting a stream. - - virtual ACE_HANDLE get_handle (void) const; -private: - - int create_cdr_buffer (char *message, - size_t length); - // Helper - copies length bytes from the given message into the CDR - // buffer. Returns 0 on success, -1 on failure - - //// ACE_Message_Block *create_message_block (void); - void set_cdr_length (void); - // Helper method - copies the buffer in encoder_ - // into a new ACE_Message_Block and returns it. - // Returns 0 on failure - - void create_local_dgram (void); - // Create the local dgram endpoint. - - int connect_to_receiver (const char *receiver_addr); - // Creates a connected dgram with the receiver addr. - - int send_start (void); - // sends the start message to the receiver. - - int send_startReply (void); - // sends the StartReply message to the receiver. - - int send_cdr_buffer (void); - // sends the encoders cdr buffer using iovecs. - - char *magic_number_to_string (char *magic_number); - // appends a 0 to the end of the magic number. - - int register_dgram_handler (void); - // registers the dgram socket with the reactor. - - CORBA::ORB_ptr orb_; - // ORB reference. - - ACE_Reactor* reactor_; - // Used for registering the dgram handler. - - TAO_OutputCDR *encoder_; - // Use the TAO CDR encoder to encode everything - - TAO_InputCDR *decoder_; - // Use the TAO CDR encoder to encode everything - - ACE_SOCK_Dgram dgram_; - // Connection Oriented Dgram. - - int start_tries_; - // Number of tries to send a Start message. - - int startReply_tries_; - // Number of tries to send a StartReply message. - - CORBA::ULong credit_; - // Credit on the number of frames. - - ACE_Time_Value timeout1_; - // Timeout used for Start on Sender side and also for Credit on - // receiver side. - - ACE_Time_Value timeout2_; - // Timeout used for StartReply on the receiver side and also for - // CREDIT on the sender side. - - State state_; - // State variable. - // @@We can use the state pattern here. - - const char *receiver_addr_; - // The address of the receiver to which we're connected to. - - ACE_INET_Addr receiver_inet_addr_; - // INET addr of the receiver. - - SFP_Callback *callback_; - // Application Callback Object. - - int sequence_num_; - // sequence number of the packet. -}; - -#endif /* !defined (TAO_SFP_H) */ |