1 #include "orbsvcs/AV/AVStreams_i.h"
2 #include "orbsvcs/AV/FlowSpec_Entry.h"
3 #include "tao/PortableServer/PortableServer.h"
4 #include "tao/Strategies/advanced_resource.h"
6 #include "ace/Get_Opt.h"
7 #include "ace/INET_Addr.h"
9 const ACE_TCHAR
*ping_ior
= ACE_TEXT ("file://ping.ior");
10 const ACE_TCHAR
*pong_ior
= ACE_TEXT ("file://pong.ior");
11 const ACE_TCHAR
*ping_address
= ACE_TEXT ("localhost:12345");
12 const ACE_TCHAR
*pong_address
= ACE_TEXT ("localhost:23456");
13 const ACE_TCHAR
*protocol
= ACE_TEXT ("UDP");
15 int milliseconds
= 30000;
18 parse_args (int argc
, ACE_TCHAR
*argv
[])
20 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("f:g:s:r:t:p:d"));
23 while ((c
= get_opts ()) != -1)
27 ping_ior
= get_opts
.opt_arg ();
31 pong_ior
= get_opts
.opt_arg ();
35 ping_address
= get_opts
.opt_arg ();
39 pong_address
= get_opts
.opt_arg ();
43 milliseconds
= ACE_OS::atoi (get_opts
.opt_arg ());
47 protocol
= get_opts
.opt_arg ();
56 ACE_ERROR_RETURN ((LM_ERROR
,
70 // Indicates successful parsing of the command line
74 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
78 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
79 parse_args (argc
, argv
);
82 = orb
->resolve_initial_references ("RootPOA");
84 PortableServer::POA_var poa
85 = PortableServer::POA::_narrow (obj
.in ());
87 PortableServer::POAManager_var mgr
88 = poa
->the_POAManager ();
92 TAO_AV_CORE::instance ()->init (orb
.in (),
95 // Connect the two streams and run them...
96 AVStreams::flowSpec
flow_spec (2);
99 ACE_INET_Addr ping_addr
;
100 ping_addr
.set (ping_address
);
101 TAO_Forward_FlowSpec_Entry
ping ("Ping",
105 ACE_TEXT_ALWAYS_CHAR (protocol
),
107 flow_spec
[0] = CORBA::string_dup (ping
.entry_to_string ());
109 ACE_INET_Addr pong_addr
;
110 pong_addr
.set (pong_address
);
111 TAO_Forward_FlowSpec_Entry
pong ("Pong",
115 ACE_TEXT_ALWAYS_CHAR (protocol
),
117 flow_spec
[1] = CORBA::string_dup (pong
.entry_to_string ());
119 TAO_StreamCtrl stream_control_impl
;
121 AVStreams::StreamCtrl_var stream_control
=
122 stream_control_impl
._this ();
124 obj
= orb
->string_to_object (ping_ior
);
125 AVStreams::MMDevice_var ping_sender
=
126 AVStreams::MMDevice::_narrow (obj
.in ());
128 obj
= orb
->string_to_object (pong_ior
);
129 AVStreams::MMDevice_var pong_sender
=
130 AVStreams::MMDevice::_narrow (obj
.in ());
132 AVStreams::streamQoS_var the_qos
=
133 new AVStreams::streamQoS
;
135 stream_control
->bind_devs (pong_sender
.in (),
140 flow_spec
.length (0);
141 stream_control
->start (flow_spec
);
143 ACE_Time_Value
tv (100, 0);
146 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
147 orb
->shutdown (true);
149 // flow_spec.length (0);
150 // stream_control->stop (flow_spec);
152 catch (const CORBA::Exception
& ex
)
154 ex
._tao_print_exception ("Caught exception:");