Helper class for the child process created in TAO_AV_Endpoint_Process_Strategy. More...
#include <Endpoint_Strategy_T.h>
Public Member Functions | |
TAO_AV_Child_Process () | |
Constructor. | |
virtual | ~TAO_AV_Child_Process () |
Destructor. | |
int | init (int argc, ACE_TCHAR **argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) |
int | run (ACE_Time_Value *tv=0) |
runs the ORB event loop | |
Protected Member Functions | |
int | activate_objects (int argc, ACE_TCHAR **argv) |
char * | activate_with_poa (PortableServer::Servant servant) |
activate the servant with the poa | |
int | unbind_names (void) |
Removes the vdev and streamendpoint names from the naming service. | |
int | bind_to_naming_service (void) |
Binds to the naming service. | |
int | register_vdev (void) |
Registers vdev with the naming service. | |
int | register_stream_endpoint (void) |
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) |
virtual int | make_stream_endpoint (T_StreamEndpoint *&stream_endpoint) |
virtual int | make_mediactrl (T_MediaCtrl *&media_ctrl) |
Protected Attributes | |
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. | |
CORBA::Object_var | vdev_obj_ |
Virtual device CORBA object reference. | |
T_MediaCtrl * | media_ctrl_ |
Media controller. | |
CORBA::Object_var | media_ctrl_obj_ |
pid_t | pid_ |
pid of this process | |
char | host_ [MAXHOSTNAMELEN] |
Name of the host. | |
CORBA::ORB_ptr | orb_ |
PortableServer::POA_ptr | poa_ |
Helper class for the child process created in TAO_AV_Endpoint_Process_Strategy.
Definition at line 150 of file Endpoint_Strategy_T.h.
TAO_AV_Child_Process< T_StreamEndpoint_B, T_VDev, T_MediaCtrl >::TAO_AV_Child_Process | ( | ) |
Constructor.
Definition at line 341 of file Endpoint_Strategy_T.cpp.
: stream_endpoint_name_ (0), pid_ (-1), stream_endpoint_(0), vdev_ (0), media_ctrl_ (0) { this->pid_ = ACE_OS::getpid (); if (this->pid_ == 0) ACE_ERROR ((LM_ERROR,"getpid () failed\n")); ACE_OS::hostname (this->host_, sizeof this->host_); }
TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::~TAO_AV_Child_Process | ( | ) | [virtual] |
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::activate_objects | ( | int | argc, | |
ACE_TCHAR ** | argv | |||
) | [protected] |
Creates the objects and inserts them into the Naming Service, so the parent can pick the IOR's and return them to the client
Definition at line 417 of file Endpoint_Strategy_T.cpp.
{ try { // 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->activate_with_poa (this->stream_endpoint_); if (TAO_debug_level > 0) 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->activate_with_poa (this->vdev_); if (TAO_debug_level > 0) 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->activate_with_poa (this->media_ctrl_); if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,media_ctrl_ior is: %s\n",media_ctrl_ior.in ())); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("TAO_AV_Child_Process::init "); return -1; } return 0; }
char * TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::activate_with_poa | ( | PortableServer::Servant | servant | ) | [protected] |
activate the servant with the poa
Definition at line 399 of file Endpoint_Strategy_T.cpp.
{ PortableServer::ObjectId_var id = this->poa_->activate_object (servant); CORBA::Object_var obj = this->poa_->id_to_reference (id.in ()); CORBA::String_var str = this->orb_->object_to_string (obj.in ()); return str._retn (); }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::bind_to_naming_service | ( | void | ) | [protected] |
Binds to the naming service.
Definition at line 462 of file Endpoint_Strategy_T.cpp.
{ try { CORBA::Object_var naming_obj = this->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); // if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); this->naming_context_ = CosNaming::NamingContext::_narrow (naming_obj.in ()); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_AV_Child_Process::bind_to_naming_service"); return -1; } return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint_B, T_VDev, T_MediaCtrl >::init | ( | int | argc, | |
ACE_TCHAR ** | argv, | |||
CORBA::ORB_ptr | orb, | |||
PortableServer::POA_ptr | poa | |||
) |
Initializes the ORB, creates and activates the T_StreamEndpoint, T_VDev, T_MediaCtrl in the POA
Definition at line 358 of file Endpoint_Strategy_T.cpp.
{ try { this->orb_ = orb; this->poa_ = poa; // create the objects and activate them in the poa this->activate_objects (argc, argv); // Get ourselves a naming_service object reference this->bind_to_naming_service (); // Register the vdev with the naming service this->register_vdev (); // register the stream_endpoing with the naming_service this->register_stream_endpoint (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("TAO_Child_Process"); return -1; } // 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; }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::make_mediactrl | ( | T_MediaCtrl *& | media_ctrl | ) | [protected, virtual] |
Bridge method to create a media_ctrl, a la Acceptor. Applications can override this
Definition at line 649 of file Endpoint_Strategy_T.cpp.
{ if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"(%P|%t) TAO_AV_Child_Process::make_mediactrl ()\n")); ACE_NEW_RETURN (media_ctrl, T_MediaCtrl, -1); return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::make_stream_endpoint | ( | T_StreamEndpoint *& | stream_endpoint | ) | [protected, virtual] |
Bridge method to create a stream_endpoint, a la Acceptor. Applications can override this
Definition at line 627 of file Endpoint_Strategy_T.cpp.
{ ACE_NEW_RETURN (stream_endpoint, T_StreamEndpoint, -1); return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::make_vdev | ( | T_VDev *& | vdev | ) | [protected, virtual] |
Bridge method to create a vdev, a la Acceptor. Applications can override this
Definition at line 638 of file Endpoint_Strategy_T.cpp.
{ ACE_NEW_RETURN (vdev, T_VDev, -1); return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::register_stream_endpoint | ( | void | ) | [protected] |
Registers stream_endpoint with the naming service.
Definition at line 596 of file Endpoint_Strategy_T.cpp.
{ CORBA::Object_ptr stream_endpoint_obj = CORBA::Object::_nil (); try { stream_endpoint_obj = this->stream_endpoint_->_this (); // 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_, stream_endpoint_obj); } catch (const CosNaming::NamingContext::AlreadyBound& ) { // if the name was already there, replace the reference with the new one this->naming_context_->rebind (this->stream_endpoint_name_, stream_endpoint_obj); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_Endpoint_Reactive_Strategy::activate"); return -1; } return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::register_vdev | ( | void | ) | [protected] |
Registers vdev with the naming service.
Definition at line 488 of file Endpoint_Strategy_T.cpp.
{ try { char vdev_name [BUFSIZ]; ACE_OS::sprintf (vdev_name, "%s:%s:%ld", "VDev", this->host_, static_cast<long> (this->pid_)); if (TAO_debug_level > 0) 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_obj_ = this->media_ctrl_->_this (); this->vdev_->define_property ("Related_MediaCtrl", media_ctrl_obj_.in()); vdev_obj_ = this->vdev_->_this (); try { // Register the vdev with the naming server. this->naming_context_->bind (this->vdev_name_, vdev_obj_.in()); } catch (const CosNaming::NamingContext::AlreadyBound& ) { // If the object was already there, replace the older reference // with this one this->naming_context_->rebind (this->vdev_name_, vdev_obj_.in()); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_AV_Child_Process::register_vdev"); return -1; } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_AV_Child_Process::register_vdev"); return -1; } return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint_B, T_VDev, T_MediaCtrl >::release_semaphore | ( | ) | [protected] |
Releases the semaphore on which the parent is waiting on.
Definition at line 563 of file Endpoint_Strategy_T.cpp.
{ char sem_str [BUFSIZ]; long pid = this->pid_; ACE_OS::sprintf (sem_str, "%s:%s:%ld", "TAO_AV_Process_Semaphore", this->host_, pid); if (TAO_debug_level > 0) 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; }
int TAO_AV_Child_Process< T_StreamEndpoint_B, T_VDev, T_MediaCtrl >::run | ( | ACE_Time_Value * | tv = 0 |
) |
runs the ORB event loop
Definition at line 546 of file Endpoint_Strategy_T.cpp.
{ try { this->orb_->run (tv); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("orb.run ()"); return -1; } return 0; }
int TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::unbind_names | ( | void | ) | [protected] |
Removes the vdev and streamendpoint names from the naming service.
Definition at line 661 of file Endpoint_Strategy_T.cpp.
{ // Remove the names from the naming service try { if (CORBA::is_nil (this->naming_context_.in ()) == 0) return 0; this->naming_context_->unbind (this->stream_endpoint_name_); this->naming_context_->unbind (this->vdev_name_); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_Endpoint_Process_Strategy::activate"); return -1; } return 0; }
char TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::host_[MAXHOSTNAMELEN] [protected] |
Name of the host.
Definition at line 234 of file Endpoint_Strategy_T.h.
T_MediaCtrl* TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::media_ctrl_ [protected] |
Media controller.
Definition at line 225 of file Endpoint_Strategy_T.h.
CORBA::Object_var TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::media_ctrl_obj_ [protected] |
Definition at line 228 of file Endpoint_Strategy_T.h.
CosNaming::NamingContext_var TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::naming_context_ [protected] |
The root Naming Context of the TAO naming service.
Definition at line 207 of file Endpoint_Strategy_T.h.
CORBA::ORB_ptr TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::orb_ [protected] |
Definition at line 236 of file Endpoint_Strategy_T.h.
pid_t TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::pid_ [protected] |
pid of this process
Definition at line 231 of file Endpoint_Strategy_T.h.
PortableServer::POA_ptr TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::poa_ [protected] |
Definition at line 238 of file Endpoint_Strategy_T.h.
T_StreamEndpoint* TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::stream_endpoint_ [protected] |
The stream endpoint member.
Definition at line 216 of file Endpoint_Strategy_T.h.
CosNaming::Name TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::stream_endpoint_name_ [protected] |
Name of the stream_endpoint.
Definition at line 213 of file Endpoint_Strategy_T.h.
T_VDev* TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::vdev_ [protected] |
The virtual device.
Definition at line 219 of file Endpoint_Strategy_T.h.
CosNaming::Name TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::vdev_name_ [protected] |
Name of the vdev.
Definition at line 210 of file Endpoint_Strategy_T.h.
CORBA::Object_var TAO_AV_Child_Process< T_StreamEndpoint, T_VDev, T_MediaCtrl >::vdev_obj_ [protected] |
Virtual device CORBA object reference.
Definition at line 222 of file Endpoint_Strategy_T.h.