3 FTP_Server_FlowEndPoint::FTP_Server_FlowEndPoint (void)
4 :TAO_FlowConsumer ("Data",FTP_SERVER::instance ()->protocols (),FTP_SERVER::instance ()->format ())
6 AVStreams::protocolSpec
protocols (2);
8 protocols
[0] = CORBA::string_dup ("TCP");
9 protocols
[1] = CORBA::string_dup ("UDP");
12 this->set_protocol_restriction (protocols
);
14 catch (const CORBA::Exception
& ex
)
16 ex
._tao_print_exception (
17 "FTP_Server_FlowEndPoint::FTP_Server_FlowEndPoint");
22 FTP_Server_FlowEndPoint::get_callback (const char *,
23 TAO_AV_Callback
*&callback
)
25 ACE_DEBUG ((LM_DEBUG
,"FTP_Server_StreamEndPoint::get_sfp_callback\n"));
26 ACE_NEW_RETURN (callback
,
33 FTP_Server_Callback::handle_stop (void)
35 ACE_DEBUG ((LM_DEBUG
,"FTP_Server_Callback::stop\n"));
36 ACE_OS::fclose (FTP_SERVER::instance ()->file ());
37 TAO_AV_CORE::instance ()->orb ()->shutdown ();
42 FTP_Server_Callback::receive_frame (ACE_Message_Block
*frame
,
46 ACE_DEBUG ((LM_DEBUG
,"FTP_Server_Callback::receive_frame\n"));
49 int result
= ACE_OS::fwrite (frame
->rd_ptr (),
52 FTP_SERVER::instance ()->file ());
54 ACE_ERROR_RETURN ((LM_ERROR
,"FTP_Server_Flow_Handler::fwrite failed\n"),-1);
55 frame
= frame
->cont ();
61 FTP_Server_Callback::handle_end_stream (void)
63 ACE_DEBUG ((LM_DEBUG
,"FTP_SFP_Callback::end_stream\n"));
64 CORBA::ORB_var orb
= TAO_AV_CORE::instance ()->orb ();
69 // FTP_Server_FDev::FTP_Server_FDev (void)
74 // AVStreams::FlowConsumer_ptr
75 // FTP_Server_FDev::make_consumer (AVStreams::FlowConnection_ptr the_requester,
76 // AVStreams::QoS & the_qos,
77 // CORBA::Boolean_out met_qos,
78 // char *& named_fdev,
81 // ACE_DEBUG ((LM_DEBUG,"FTP_Server_FDev::make_consumer"));
82 // FTP_Server_FlowEndPoint *endpoint;
83 // ACE_NEW_RETURN (endpoint,
84 // FTP_Server_FlowEndPoint,
86 // return endpoint->_this ();
91 reactive_strategy_
.init (TAO_AV_CORE::instance ()->orb (),
92 TAO_AV_CORE::instance ()->poa ());
95 AVStreams::protocolSpec
96 Server::protocols (void)
98 AVStreams::protocolSpec
protocols (2);
100 protocols
[0] = CORBA::string_dup ("TCP");
101 protocols
[1] = CORBA::string_dup ("UDP");
106 Server::format (void)
112 Server::init (int argc
, ACE_TCHAR
*argv
[])
116 PortableServer::POAManager_var mgr
117 = TAO_AV_CORE::instance ()->poa ()->the_POAManager ();
121 int result
= this->parse_args (argc
, argv
);
123 ACE_ERROR_RETURN ((LM_ERROR
,"parse args failed\n"),-1);
124 // Initialize the naming services
126 if (my_naming_client_
.init (TAO_AV_CORE::instance ()->orb ()) != 0)
127 ACE_ERROR_RETURN ((LM_ERROR
,
128 " (%P|%t) Unable to initialize "
129 "the TAO_Naming_Client.\n"),
132 // Register the video mmdevice object with the ORB
133 ACE_NEW_RETURN (this->mmdevice_
,
134 TAO_MMDevice (&this->reactive_strategy_
),
137 ACE_NEW_RETURN (this->fdev_
,
140 this->fdev_
->flowname ("Data");
141 AVStreams::MMDevice_var mmdevice
= this->mmdevice_
->_this ();
142 AVStreams::FDev_var fdev
= this->fdev_
->_this ();
143 mmdevice
->add_fdev (fdev
.in ());
145 // Register the mmdevice with the naming service.
146 CosNaming::Name
server_mmdevice_name (1);
147 server_mmdevice_name
.length (1);
148 server_mmdevice_name
[0].id
= CORBA::string_dup ("Server_MMDevice1");
151 // Register the video control object with the naming server.
152 this->my_naming_client_
->bind (server_mmdevice_name
,
155 catch (const CosNaming::NamingContext::AlreadyBound
&)
157 server_mmdevice_name
[0].id
= CORBA::string_dup ("Server_MMDevice2");
158 this->my_naming_client_
->bind (server_mmdevice_name
,
162 catch (const CORBA::Exception
& ex
)
164 ex
._tao_print_exception ("server::init");
175 TAO_AV_CORE::instance ()->orb ()->run ();
177 catch (const CORBA::Exception
& ex
)
179 ex
._tao_print_exception ("server::init");
186 Server::parse_args (int argc
, ACE_TCHAR
*argv
[])
188 ACE_Get_Opt
opts (argc
, argv
, ACE_TEXT("f:p:"));
191 while ((c
= opts ()) != -1)
196 this->fp_
= ACE_OS::fopen (opts
.opt_arg (),"w");
199 ACE_DEBUG ((LM_DEBUG
,"file opened successfully\n"));
203 this->protocol_
= ACE_OS::strdup (ACE_TEXT_ALWAYS_CHAR (opts
.opt_arg ()));
206 ACE_ERROR_RETURN ((LM_ERROR
,"Usage: server -f filename"),-1);
219 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
221 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
225 CORBA::Object_var obj
226 = orb
->resolve_initial_references ("RootPOA");
228 PortableServer::POA_var poa
229 = PortableServer::POA::_narrow (obj
.in ());
231 TAO_AV_CORE::instance ()->init (orb
.in (),
234 catch (const CORBA::Exception
& ex
)
236 ex
._tao_print_exception ("server::init");
241 result
= FTP_SERVER::instance ()->init (argc
, argv
);
243 ACE_ERROR_RETURN ((LM_ERROR
,"FTP_SERVER::init failed\n"),1);
244 result
= FTP_SERVER::instance ()->run ();
246 ACE_ERROR_RETURN ((LM_ERROR
,"FTP_SERVER::run failed\n"),1);
248 FTP_SERVER::close (); // Explicitly finalize the Unmanaged_Singleton.
253 #if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
254 template ACE_Unmanaged_Singleton
<Server
, ACE_Null_Mutex
> *ACE_Unmanaged_Singleton
<Server
, ACE_Null_Mutex
>::singleton_
;
255 #endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */