summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/AVStreams/benchmark
diff options
context:
space:
mode:
authorsumedh <sumedh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-17 01:05:39 +0000
committersumedh <sumedh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-17 01:05:39 +0000
commit1e40008ace84affbbfc5e597fe255feeb17e00b0 (patch)
tree4154c4765be338ccdcef55e0eaab6e1f6c2cf56b /TAO/orbsvcs/tests/AVStreams/benchmark
parent5f3f7f2dabf798adf1057ac8483894c75dcd2148 (diff)
downloadATCD-1e40008ace84affbbfc5e597fe255feeb17e00b0.tar.gz
CVS:
CVS:
Diffstat (limited to 'TAO/orbsvcs/tests/AVStreams/benchmark')
-rw-r--r--TAO/orbsvcs/tests/AVStreams/benchmark/Makefile56
-rw-r--r--TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp231
-rw-r--r--TAO/orbsvcs/tests/AVStreams/benchmark/client.h88
3 files changed, 375 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/Makefile b/TAO/orbsvcs/tests/AVStreams/benchmark/Makefile
new file mode 100644
index 00000000000..fc2b77cbf65
--- /dev/null
+++ b/TAO/orbsvcs/tests/AVStreams/benchmark/Makefile
@@ -0,0 +1,56 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Top-level Makefile for the AVStreams demo of the TAO ORB
+#
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+LDLIBS = -lorbsvcs -lTAO
+
+SERVER_OBJS = server.o
+CLIENT_OBJS = client.o
+
+BIN = server client
+BUILD = $(BIN)
+VLDLIBS = $(LDLIBS:%=%$(VAR))
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
+#include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+
+ifndef TAO_ROOT
+TAO_ROOT = $(ACE_ROOT)/TAO
+endif
+
+DCFLAGS = -g
+LDFLAGS += -L$(TAO_ROOT)/orbsvcs/orbsvcs -L$(TAO_ROOT)/tao
+CPPFLAGS += -I$(TAO_ROOT)/orbsvcs -I$(TAO_ROOT) -I$(TAO_ROOT)/tao/compat $(TSS_ORB_FLAG) \
+ -DTAO_HAS_DYNAMIC_PROPERTY_BUG
+
+server:$(addprefix $(VDIR),$(SERVER_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
+client:$(addprefix $(VDIR),$(CLIENT_OBJS))
+ $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK)
+
+realclean: clean
+ -/bin/rm -rf
+
+
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+
+
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp b/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp
new file mode 100644
index 00000000000..75450e1f29e
--- /dev/null
+++ b/TAO/orbsvcs/tests/AVStreams/benchmark/client.cpp
@@ -0,0 +1,231 @@
+
+// $Id$
+
+#include "client.h"
+
+Client_StreamEndPoint::Client_StreamEndPoint (void)
+{
+}
+
+
+int
+Client_StreamEndPoint::handle_open (void)
+{
+ return 0;
+}
+
+int
+Client_StreamEndPoint::handle_close (void)
+{
+ return 0;
+}
+
+// called by the framework before calling connect. Here we create our
+// flow spec which is nothing but hostname::port_number of the
+// datagram.
+CORBA::Boolean
+Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec)
+{
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t) handle_preconnect called\n"));
+ return 0;
+}
+
+// called by the A/V framework after calling connect. Passes the
+// server streamendpoints' flowspec which we use to connect our
+// datagram socket.
+CORBA::Boolean
+Client_StreamEndPoint::handle_postconnect (AVStreams::flowSpec& server_spec)
+{
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t) handle_postconnect called \n"));
+ return 0;
+}
+
+int
+Client_StreamEndPoint::handle_start (const AVStreams::flowSpec &the_spec,
+ CORBA::Environment &env)
+
+{
+ return -1;
+}
+
+int
+Client_StreamEndPoint::handle_stop (const AVStreams::flowSpec &the_spec,
+ CORBA::Environment &env)
+
+{
+ return -1;
+}
+
+int
+Client_StreamEndPoint::handle_destroy (const AVStreams::flowSpec &the_spec,
+ CORBA::Environment &env)
+
+{
+ return -1;
+}
+
+// ----------------------------------------------------------------------
+Client::Client (int argc, char **argv, ACE_Barrier *barrier)
+ : reactive_strategy_ (&orb_manager_),
+ client_mmdevice_ (&reactive_strategy_),
+ argc_ (argc),
+ argv_ (argv),
+ barrier_ (barrier)
+{
+}
+
+int
+Client::svc (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) Thread created\n"));
+ TAO_TRY
+ {
+ this->orb_manager_.init (this->argc_,
+ this->argv_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("Client");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ if (this->bind_to_server () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) Error binding to the naming service\n"),
+ -1);
+
+ // wait for the other clients to finish binding
+ this->barrier_->wait ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) All threads finished, starting tests.\n"));
+ return 0;
+}
+
+int
+Client::bind_to_server (void)
+{
+ TAO_TRY
+ {
+ 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);
+ CosNaming::NamingContext_var naming_context =
+ CosNaming::NamingContext::_narrow (naming_obj.in (),
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ CosNaming::Name server_mmdevice_name (1);
+
+ server_mmdevice_name.length (1);
+ server_mmdevice_name [0].id = CORBA::string_dup ("Bench_Server_MMDevice");
+ CORBA::Object_var server_mmdevice_obj =
+ naming_context->resolve (server_mmdevice_name,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ this->server_mmdevice_ =
+ AVStreams::MMDevice::_narrow (server_mmdevice_obj.in (),
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (this->server_mmdevice_.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " could not resolve Server_Mmdevice in Naming service <%s>\n"),
+ -1);
+ }
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("Command_Handler::resolve_reference");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) MMDevice successfully resolved.\n"));
+ return 0;
+}
+
+int
+Client::establish_stream (void)
+{
+
+ AVStreams::streamQoS_var the_qos (new AVStreams::streamQoS);
+ AVStreams::flowSpec_var the_flows (new AVStreams::flowSpec);
+ // Bind the client and server mmdevices.
+
+ TAO_TRY
+ {
+ this->streamctrl_.bind_devs
+ (this->client_mmdevice_._this (TAO_TRY_ENV),
+ this->server_mmdevice_.in (),
+ the_qos.inout (),
+ the_flows.in (),
+ TAO_TRY_ENV);
+
+ TAO_CHECK_ENV;
+ }
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("streamctrl.bind_devs:");
+ return -1;
+ }
+ TAO_ENDTRY;
+
+ return 0;
+}
+
+// ----------------------------------------------------------------------
+
+int
+main (int argc, char **argv)
+{
+ ACE_Get_Opt opts (argc, argv, "t:");
+ int thread_count = 0;
+
+ int c;
+ while ((c = opts ()) != -1)
+ switch (c)
+ {
+ case 'n':
+ thread_count = (u_int) ACE_OS::atoi (opts.optarg);
+ continue;
+ default:
+ ACE_DEBUG ((LM_DEBUG, "Usage: %s -n number_of_threads\n"));
+ }
+
+ ACE_Barrier *barrier;
+ ACE_NEW_RETURN (barrier,
+ ACE_Barrier (thread_count + 1),
+ -1);
+ for (int i = 0; i < thread_count; i++)
+ {
+ Client *client;
+ ACE_NEW_RETURN (client,
+ Client (argc,
+ argv,
+ barrier),
+ -1);
+
+ if (client->activate (THR_BOUND) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) Error in activate: %p",
+ "activate"),
+ -1);
+ }
+
+ // wait for all the threads to finish starting up
+ barrier->wait ();
+ ACE_DEBUG ((LM_DEBUG,
+ "(%t) All threads started, waiting for test completion\n"));
+
+ ACE_Thread_Manager::instance ()->wait ();
+
+
+}
diff --git a/TAO/orbsvcs/tests/AVStreams/benchmark/client.h b/TAO/orbsvcs/tests/AVStreams/benchmark/client.h
new file mode 100644
index 00000000000..36074fa5d7d
--- /dev/null
+++ b/TAO/orbsvcs/tests/AVStreams/benchmark/client.h
@@ -0,0 +1,88 @@
+
+// $Id$
+
+#if !defined (TAO_AV_BENCH_H)
+#define TAO_AV_BENCH_H
+
+#include "ace/Reactor.h"
+#include "ace/Event_Handler.h"
+#include "ace/ARGV.h"
+#include "tao/TAO.h"
+#include "orbsvcs/CosNamingC.h"
+#include "ace/SOCK_Dgram.h"
+#include "ace/SOCK_Connector.h"
+#include "orbsvcs/AV/AVStreams_i.h"
+#include "ace/Synch.h"
+
+
+class Client_StreamEndPoint
+ : public virtual TAO_Client_StreamEndPoint
+{
+ // = TITLE
+ // Defines a client StreamEndpoint class
+ // = DESCRIPTION
+ // Makes use of a connected dgram to receive data from the server
+ // side stream endpoint.
+public:
+ Client_StreamEndPoint (void);
+
+ virtual int handle_open (void);
+ // called when streamendpoint is instantiated
+
+ virtual int handle_close (void);
+ // called when streamendpoint is being destructed
+
+ virtual CORBA::Boolean handle_preconnect (AVStreams::flowSpec &the_spec);
+ // called before connecting
+
+ virtual CORBA::Boolean handle_postconnect (AVStreams::flowSpec &the_spec);
+ // called after connecting
+
+ virtual int handle_start (const AVStreams::flowSpec &the_spec,
+ CORBA::Environment &env) ;
+
+ virtual int handle_stop (const AVStreams::flowSpec &the_spec,
+ CORBA::Environment &env) ;
+
+ virtual int handle_destroy (const AVStreams::flowSpec &the_spec,
+ CORBA::Environment &env);
+
+};
+
+
+class Client : public ACE_Task<ACE_SYNCH>
+// one of these per client thread
+{
+public:
+ Client (int argc, char **argv, ACE_Barrier *barrier);
+
+ virtual int svc (void);
+
+private:
+
+ int bind_to_server (void);
+
+ int establish_stream (void);
+
+
+ TAO_ORB_Manager orb_manager_;
+
+ TAO_AV_Endpoint_Reactive_Strategy_A<Client_StreamEndPoint, TAO_VDev,
+ AV_Null_MediaCtrl> reactive_strategy_;
+
+ AVStreams::MMDevice_var server_mmdevice_;
+
+ TAO_MMDevice client_mmdevice_;
+
+ TAO_StreamCtrl streamctrl_;
+ // Video stream controller
+
+ int argc_;
+
+ char **argv_;
+
+ ACE_Barrier *barrier_;
+
+};
+
+#endif /* TAO_AV_BENCH_H */