Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / orbsvcs / tests / AVStreams / Latency / control.cpp
blob183dca390a0c3925f50ed85f0bca9ad3f77408c7
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"
5 #include "tao/debug.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;
17 int
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"));
21 int c;
23 while ((c = get_opts ()) != -1)
24 switch (c)
26 case 'f':
27 ping_ior = get_opts.opt_arg ();
28 break;
30 case 'g':
31 pong_ior = get_opts.opt_arg ();
32 break;
34 case 'r':
35 ping_address = get_opts.opt_arg ();
36 break;
38 case 's':
39 pong_address = get_opts.opt_arg ();
40 break;
42 case 't':
43 milliseconds = ACE_OS::atoi (get_opts.opt_arg ());
44 break;
46 case 'p':
47 protocol = get_opts.opt_arg ();
48 break;
50 case 'd':
51 TAO_debug_level++;
52 break;
54 case '?':
55 default:
56 ACE_ERROR_RETURN ((LM_ERROR,
57 "usage: %s "
58 "-f <ping_ior> "
59 "-g <ping_ior> "
60 "-s <ping_address> "
61 "-r <pong_address> "
62 "-t <milliseconds> "
63 "-p protocols "
64 "\n",
65 argv [0]),
66 -1);
70 // Indicates successful parsing of the command line
71 return 0;
74 int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
76 try
78 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
79 parse_args (argc, argv);
81 CORBA::Object_var obj
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 ();
90 mgr->activate ();
92 TAO_AV_CORE::instance ()->init (orb.in (),
93 poa.in ());
95 // Connect the two streams and run them...
96 AVStreams::flowSpec flow_spec (2);
97 flow_spec.length (2);
99 ACE_INET_Addr ping_addr;
100 ping_addr.set (ping_address);
101 TAO_Forward_FlowSpec_Entry ping ("Ping",
102 "IN",
103 "UNS:ping",
105 ACE_TEXT_ALWAYS_CHAR (protocol),
106 &ping_addr);
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",
112 "OUT",
113 "UNS:pong",
115 ACE_TEXT_ALWAYS_CHAR (protocol),
116 &pong_addr);
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 (),
136 ping_sender.in (),
137 the_qos.inout (),
138 flow_spec);
140 flow_spec.length (0);
141 stream_control->start (flow_spec);
143 ACE_Time_Value tv (100, 0);
144 orb->run (tv);
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:");
155 return 1;
158 return 0;