summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryamuna <yamuna@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-09 21:42:51 +0000
committeryamuna <yamuna@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-09 21:42:51 +0000
commit89620cff8eb3cdf0d07fd3b07f81fce975dc6f48 (patch)
tree37e0cdd677bd4dd4053fc7682a24ef89a51f8025
parent674803c4bd77c7a78835eb3af4d1f5ed808c3f93 (diff)
downloadATCD-89620cff8eb3cdf0d07fd3b07f81fce975dc6f48.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/client/vcr.cpp35
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.cpp1277
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.h359
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp3
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp2164
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp18
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp11
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp2
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp10
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h3
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Control_i.cpp5
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile9
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl8
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp32
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl1
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/as.cpp2
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp116
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp29
18 files changed, 1180 insertions, 2904 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/client/vcr.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/client/vcr.cpp
index 37010ba0bc8..d231869cbc8 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/client/vcr.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/client/vcr.cpp
@@ -82,6 +82,8 @@
ACE_RCSID(client, vcr, "$Id$")
static int mainPid;
+int orig_argc;
+char **orig_argv;
static time_t start_time;
/*
@@ -108,8 +110,8 @@ usage(char *s) /* program name */
fprintf(stderr, " [-dither ordered|ordered2|fs4|fs2|fs2fast|hybrid|\n");
fprintf(stderr, " hybrid2|2x2|gray|color|mono|threshold]\n");
fprintf(stderr, " [X-window options]\n");
- fprintf(stderr, " [-v [host_name:]video_file_name]\n");
- fprintf(stderr, " [-a [host_name:]audio_file_name]\n");
+ fprintf(stderr, " [-v video_file_name]\n");
+ fprintf(stderr, " [-a audio_file_name]\n");
fprintf(stderr, " [-p movie_file_name]\n");
fprintf(stderr, " [-l movie_list_file_name]\n");
@@ -236,6 +238,9 @@ int main(int argc, char ** argv)
argc_share = argc;
argv_share = argv;
+
+ orig_argc = argc;
+ orig_argv = argv;
mark = 1;
argc--;
@@ -249,18 +254,18 @@ int main(int argc, char ** argv)
shmemFlag = 0;
#endif
- if (getenv("DISPLAY")!= NULL)
- {
- char * disp = getenv("DISPLAY");
- if (strncmp(disp, "anquetil:0", 10) == 0 ||
- strncmp(disp, "helix:0", 7) == 0 ||
- strncmp(disp, "hinault:0", 9) == 0 ||
- strncmp(disp, "lemond:0", 8) == 0 ||
- strncmp(disp, "indurain:0", 10) == 0)
- ditherType = ORDERED_DITHER;
- else
- ditherType = ORDERED_DITHER;
- }
+// if (getenv("DISPLAY")!= NULL)
+// {
+// char * disp = getenv("DISPLAY");
+// if (strncmp(disp, "anquetil:0", 10) == 0 ||
+// strncmp(disp, "helix:0", 7) == 0 ||
+// strncmp(disp, "hinault:0", 9) == 0 ||
+// strncmp(disp, "lemond:0", 8) == 0 ||
+// strncmp(disp, "indurain:0", 10) == 0)
+// ditherType = ORDERED_DITHER;
+// else
+// ditherType = ORDERED_DITHER;
+// }
while (argc) {
if (strcmp(argv[mark], "-rt") == 0) {
@@ -472,7 +477,7 @@ int main(int argc, char ** argv)
mainPid = getpid();
- CTRmain(argc,argv);
+ CTRmain(orig_argc,orig_argv);
return 0;
}
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.cpp
index 9520abf4045..0ef14d67c8d 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.cpp
@@ -5,49 +5,32 @@
ACE_RCSID(mpeg_client, Command_Handler, "$Id$")
-#define JAVA_CONTROL_PORT 6676
-
-Gui_Acceptor::Gui_Acceptor (Command_Handler *handler)
- :command_handler_ (handler)
-{
-}
-
-int
-Gui_Acceptor::make_svc_handler (Command_Handler *&handler)
-{
- handler = this->command_handler_;
- return 0;
-}
-
-Command_Handler::Command_Handler (void)
- :busy_ (0),
- audio_mmdevice_ior_ (0),
- video_data_handle_ (-1),
- audio_data_handle_ (-1),
- command_handle_ (-1),
- video_control_ (0),
- video_reactive_strategy_ (&orb_manager_,this),
- video_client_mmdevice_ (&video_reactive_strategy_),
- audio_control_ (0),
- audio_reactive_strategy_ (&orb_manager_,this),
- audio_client_mmdevice_ (&audio_reactive_strategy_),
- acceptor_ (this)
-{
-}
+ static int temp_argc = 5;
+static char *temp_argv [] = {"Command_Handler",
+ "-ORBobjrefstyle",
+ "url",
+ "-ORBport",
+ "0"
+ };
Command_Handler::Command_Handler (ACE_HANDLE command_handle)
- :busy_ (0),
+ :command_suspended_ (UNSUSPENDED),
+ busy_ (0),
audio_mmdevice_ior_ (0),
video_data_handle_ (-1),
audio_data_handle_ (-1),
command_handle_ (command_handle),
video_control_ (0),
- video_reactive_strategy_ (&orb_manager_,this),
- video_client_mmdevice_ (&video_reactive_strategy_),
+ video_reactive_strategy_ (0),
+ video_client_mmdevice_ (0),
+ video_streamctrl_ (0),
audio_control_ (0),
- audio_reactive_strategy_ (&orb_manager_,this),
- audio_client_mmdevice_ (&audio_reactive_strategy_),
- acceptor_ (this)
+ audio_reactive_strategy_ (0),
+ audio_client_mmdevice_ (0),
+ audio_streamctrl_ (0),
+ receiver_ (this),
+ data_host_ (0),
+ client_sig_handler_ (this)
{
}
@@ -58,39 +41,99 @@ Command_Handler::~Command_Handler (void)
::remove_all_semaphores ();
}
+int
+Command_Handler::parse_args (int argc,char **argv)
+{
+ ACE_Get_Opt get_opts (argc,argv,"h:");
+ int c;
+
+ while ((c= get_opts ()) != -1)
+ switch (c)
+ {
+ case 'h':
+ this->data_host_ = ACE_OS::strdup (get_opts.optarg);
+ ACE_DEBUG ((LM_DEBUG,"data_host is %s\n",this->data_host_));
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,"Unknown argument %c\n",c),-1);
+ }
+ return 0;
+}
+
+TAO_ORB_Manager *
+Command_Handler::orb_manager (void)
+{
+ return &this->orb_manager_;
+}
+
+void
+Command_Handler::wait_for_display (Suspended reason)
+{
+ this->command_suspended_ = reason;
+ TAO_ORB_Core_instance ()->reactor ()->suspend_handler (this->command_handle_);
+}
+
// initialize the command handler.
int
Command_Handler::init (int argc,
char *argv[])
{
+ this->argc_ = temp_argc;
+ this->argv_ = temp_argv;
+
+ // Increase the debug_level so that we can see the output
+ this->parse_args (argc, argv);
+ TAO_debug_level++;
+ CORBA::String_var ior;
TAO_TRY
{
- this->orb_manager_.init_child_poa (argc,
- argv,
+ this->orb_manager_.init_child_poa (this->argc_,
+ this->argv_,
"child_poa",
TAO_TRY_ENV);
TAO_CHECK_ENV;
// activate the client video mmdevice under the child poa.
- this->orb_manager_.activate_under_child_poa ("Video_Client_MMDevice",
- &this->video_client_mmdevice_,
- TAO_TRY_ENV);
- TAO_CHECK_ENV;
- // activate the client audio mmdevice under the child poa.
- this->orb_manager_.activate_under_child_poa ("Audio_Client_MMDevice",
- &this->audio_client_mmdevice_,
- TAO_TRY_ENV);
+// this->orb_manager_.activate_under_child_poa ("Video_Client_MMDevice",
+// &this->video_client_mmdevice_,
+// TAO_TRY_ENV);
+// TAO_CHECK_ENV;
+// // activate the client audio mmdevice under the child poa.
+// this->orb_manager_.activate_under_child_poa ("Audio_Client_MMDevice",
+// &this->audio_client_mmdevice_,
+// TAO_TRY_ENV);
+// TAO_CHECK_ENV;
+
+ ior = this->orb_manager_.activate (&this->receiver_,
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
// Initialize the naming services
- if (my_name_client_.init (orb_manager_.orb (),
- argc,
- argv) != 0)
+ if (my_name_client_.init (orb_manager_.orb ()) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize "
"the TAO_Naming_Client. \n"),
-1);
-
+
+ char receiver_file[BUFSIZ];
+
+ ACE_OS::sprintf (receiver_file,
+ "/tmp/receiver_ior.%d",
+ getuid ());
+ // print the ior of the receiver to a file
+ FILE *fp = ACE_OS::fopen (receiver_file,"w");
+ if (fp != 0)
+ {
+ ACE_OS::fprintf (fp,"%s",ior.in ());
+ ACE_OS::fclose (fp);
+ }
+ // initialize the client signal handler.
+ if (this->client_sig_handler_.register_handler () < 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t) register_handler for sig_handler failed\n"),
+ -1);
+
}
TAO_CATCHANY
{
@@ -105,13 +148,6 @@ Command_Handler::init (int argc,
int
Command_Handler::run (void)
{
- ACE_INET_Addr acceptor_addr (JAVA_CONTROL_PORT);
-
- if (this->acceptor_.open (acceptor_addr,
- TAO_ORB_Core_instance ()->reactor ()) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "acceptor open"), -1);
- }
TAO_TRY
{
this->orb_manager_.run (TAO_TRY_ENV);
@@ -125,31 +161,6 @@ Command_Handler::run (void)
TAO_ENDTRY;
}
-int
-Command_Handler::open (void *)
-{
- // Java Gui connects to us
- ACE_DEBUG ((LM_DEBUG,"(%P|%t) Command_Handler::open ()\n"));
-
- javaSocket = this->peer ().get_handle ();
-
- ACE_DEBUG ((LM_DEBUG, "open, javaSocket: %d\n", javaSocket));
-
- if (TAO_ORB_Core_instance ()->reactor ()->register_handler (this->peer ().get_handle (),
- this,
- ACE_Event_Handler::READ_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) Unable to register handler in open ()"),-1);
- return 0;
-}
-
-int
-Command_Handler::close (u_long)
-{
- ACE_DEBUG ((LM_DEBUG,
- "(%P|%t)Command_Handler::close called \n"));
- return 0;
-}
-
int
Command_Handler::handle_timeout (const ACE_Time_Value &,
@@ -175,28 +186,34 @@ Command_Handler::resolve_audio_reference (void)
this->audio_server_mmdevice_ = AVStreams::MMDevice::_narrow (mmdevice_obj.in (),
TAO_TRY_ENV);
}
- delete this->audio_mmdevice_ior_;
this->audio_mmdevice_ior_ = 0;
return 0;
}
- 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;
+// 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);
+// CORBA::String_var naming_ior =
+// this->orb_manager_.orb ()->object_to_string (naming_obj,
+// TAO_TRY_ENV);
+// TAO_CHECK_ENV;
+
+// if (TAO_debug_level)
+// ACE_DEBUG ((LM_DEBUG,"Naming service is :%s\n",naming_ior.in ()));
+// CosNaming::NamingContext_var naming_context =
+// CosNaming::NamingContext::_narrow (naming_obj.in (),
+// TAO_TRY_ENV);
+// TAO_CHECK_ENV;
CosNaming::Name audio_server_mmdevice_name (1);
audio_server_mmdevice_name.length (1);
audio_server_mmdevice_name [0].id = CORBA::string_dup ("Audio_Server_MMDevice");
CORBA::Object_var audio_server_mmdevice_obj =
- naming_context->resolve (audio_server_mmdevice_name,
- TAO_TRY_ENV);
+ this->my_name_client_->resolve (audio_server_mmdevice_name,
+ TAO_TRY_ENV);
TAO_CHECK_ENV;
this->audio_server_mmdevice_ =
@@ -206,8 +223,13 @@ Command_Handler::resolve_audio_reference (void)
if (CORBA::is_nil (this->audio_server_mmdevice_.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
- " could not resolve Audio_Server_Mmdevice in Naming service <%s>\n"),
+ " could not resolve Audio_Server_Mmdevice in Naming service\n"),
-1);
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Audio_MMDevice successfully resolved: %s\n",
+ this->orb_manager_.orb ()->object_to_string (this->audio_server_mmdevice_,
+ TAO_TRY_ENV)));
+ TAO_CHECK_ENV;
+
}
TAO_CATCHANY
{
@@ -216,7 +238,6 @@ Command_Handler::resolve_audio_reference (void)
}
TAO_ENDTRY;
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) MMDevice successfully resolved.\n"));
return 0;
}
@@ -230,7 +251,7 @@ Command_Handler::resolve_video_reference (void)
video_server_mmdevice_name.length (1);
video_server_mmdevice_name [0].id = CORBA::string_dup ("Video_Server_MMDevice");
CORBA::Object_var video_server_mmdevice_obj =
- my_name_client_->resolve (video_server_mmdevice_name,
+ this->my_name_client_->resolve (video_server_mmdevice_name,
TAO_TRY_ENV);
TAO_CHECK_ENV;
@@ -241,8 +262,13 @@ Command_Handler::resolve_video_reference (void)
if (CORBA::is_nil (this->video_server_mmdevice_.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
- " could not resolve Video_Server_Mmdevice in Naming service <%s>\n"),
+ " could not resolve Video_Server_Mmdevice in Naming service\n"),
-1);
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Video_MMDevice successfully resolved: %s\n",
+ this->orb_manager_.orb ()->object_to_string (this->video_server_mmdevice_,
+ TAO_TRY_ENV)));
+ TAO_CHECK_ENV;
+
}
TAO_CATCHANY
{
@@ -261,18 +287,17 @@ Command_Handler::get_handle (void) const
return this->command_handle_;
}
-
-// handle the command sent to us by the GUI process
+// handle the command sent to us by the GUI process
// this is a reactor callback method
int
Command_Handler::handle_input (ACE_HANDLE fd)
{
- cerr << "(" << getpid () << " Command_Handler::handle_input:busy_ = " << this->busy_ << endl;
+ // cerr << "(" << getpid () << " Command_Handler::handle_input:busy_ = " << this->busy_ << endl;
unsigned char cmd;
int val;
- ACE_DEBUG ((LM_DEBUG, "handle_input, fd: %d\n", fd));
-
+ // ACE_DEBUG ((LM_DEBUG, "handle_input, fd: %d\n", fd));
+
if (!(this->busy_))
{
// Weird hack coming up:
@@ -280,46 +305,29 @@ Command_Handler::handle_input (ACE_HANDLE fd)
{
val = OurCmdRead ((char*)&cmd, 1);
this->busy_ = 1;
- ::TimerProcessing ();
-
+ this->client_sig_handler_.TimerProcessing ();
}
- else
- val = javaCmdRead ((char*) &cmd, 1);
-
- ACE_DEBUG ((LM_DEBUG, "val: %d, cmd: %d\n", val, cmd));
- // if we get an interrupt while reading we go back to the event loop
+ // ACE_DEBUG ((LM_DEBUG, "val: %d, cmd: %d\n", val, cmd));
+ // if we get an interrupt while reading we go back to the event loop
if (val == 1)
{
this->busy_ = 0;
- return -1;
- }
+ return 0;
+ }
- FILE * fp = NULL; /* file pointer for experiment plan */
- usr1_flag = 0;
-
- fprintf(stderr, "CTR: cmd received - %d\n", cmd);
+ // fprintf(stderr, "CTR: cmd received - %d\n", cmd);
TAO_TRY
{
switch (cmd)
{
- case CmdJINIT:
- ACE_DEBUG ((LM_DEBUG,"(%P|%t) command_handler:CmdJINIT received from GUI\n"));
- if (this->init_java_av (fd) == -1)
- {
- ACE_DEBUG ((LM_DEBUG,"(%P|%t) init_java_av failed\n"));
- }
- break;
case CmdINIT:
ACE_DEBUG ((LM_DEBUG,"(%P|%t) command_handler:CmdINIT received\n"));
if (this->init_av () == -1)
{
- ACE_DEBUG ((LM_DEBUG,"(%P|%t) init_av failed\n"));
- // TAO_ORB_Core_instance ()->orb ()->shutdown ();
- //return -1;
+ this->busy_ = 0;
+ ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) init_av failed\n"),0);
}
// cerr << "init_av done\n";
- // automatic experiment code zapped :-)
- fp = NULL;
break;
case CmdSTOP:
this->stop();
@@ -334,10 +342,12 @@ Command_Handler::handle_input (ACE_HANDLE fd)
this->step ();
break;
case CmdPLAY:
- // automatic experiment code zapped :-)
- if (this->play (fp != NULL,
+ if (this->play (0,
TAO_TRY_ENV) < 0)
- ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t)play failed\n"),-1);
+ {
+ this->busy_ = 0;
+ ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t)play failed\n"),0);
+ }
TAO_CHECK_ENV;
break;
case CmdPOSITION:
@@ -376,15 +386,14 @@ Command_Handler::handle_input (ACE_HANDLE fd)
TAO_CATCHANY
{
TAO_TRY_ENV.print_exception ("Command_Handler::handle_input ()");
- return -1;
+ return 0;
}
TAO_ENDTRY;
- // cerr << "returning from Command_Handler::handle_input \n";
}
- return -1;
+ return 0;
}
-int
+int
Command_Handler::init_av (void)
{
cerr << "inside init_av \n";
@@ -396,71 +405,53 @@ Command_Handler::init_av (void)
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
// this may have to be taken care of afterwards.
unsigned char tmp = CmdCLOSE;
- int result =
+ int result =
this->stop_playing();
if (result < 0)
return result;
-
+
if (audioSocket >= 0)
- {
- if (ABpid > 0) {
- kill(ABpid, SIGUSR1);
- ABpid = -1;
- }
- usleep(10000);
- }
-
- if (videoSocket >= 0)
- {
- if (VBpid > 0) {
- kill(VBpid, SIGUSR1);
- VBpid = -1;
- }
- usleep(10000);
- this->close ();
- videoSocket = -1;
- while ((!VBbufEmpty()) || !VDbufEmpty()) {
- while (VDpeekMsg() != NULL) {
- VDreclaimMsg(VDgetMsg());
- }
- usleep(10000);
- }
- usleep(10000);
- }
+ {
+ if (ABpid > 0) {
+ kill(ABpid, SIGUSR1);
+ ABpid = -1;
+ }
+ usleep(10000);
+ }
+ if (videoSocket >= 0)
+ {
+ if (VBpid > 0) {
+ kill(VBpid, SIGUSR1);
+ VBpid = -1;
+ }
+ usleep(10000);
+
+ videoSocket = -1;
+ while ((!VBbufEmpty()) || !VDbufEmpty()) {
+ while (VDpeekMsg() != NULL) {
+ VDreclaimMsg(VDgetMsg());
+ }
+ usleep(10000);
+ }
+ usleep(10000);
+ }
}
+ this->close ();
int result;
/* read in video/audio files */
// set the vf and af to 0 , very important.
-
- vh [0] = 0;
vf [0]= 0;
- ah [0] = 0;
af [0]=0;
-
+
NewCmd(CmdINIT);
i = 0;
- // cerr << "cmdsocket = " << cmdSocket << endl;
-// result = OurCmdRead((char*)&i, 4);
-// cerr << " " <<i << " ";
-// result = OurCmdRead(vh, i);
-// vh[i] = 0;
-// cerr << vh << "\n";
result = OurCmdRead((char*)&i, 4);
- // cerr << i << " ";
result = OurCmdRead(vf, i);
vf[i] = 0;
- // cerr << vf << "\n";
-// result = OurCmdRead((char*)&i, 4);
-// cerr << i << " ";
-// result = OurCmdRead(ah, i);
-// ah[i] = 0;
-// cerr << ah << endl;
result = OurCmdRead((char*)&i, 4);
- // cerr << i << " ";
result = OurCmdRead(af, i);
af[i] = 0;
- // cerr << af << endl;
/*
fprintf(stderr, "INIT: vh-%s, vf-%s, ah-%s, af-%s\n", vh, vf, ah, af);
*/
@@ -468,16 +459,16 @@ Command_Handler::init_av (void)
shared->live = 0;
shared->audioMaxPktSize = !shared->config.audioConn;
shared->videoMaxPktSize = !shared->config.videoConn;
-
+
if (af[0] != 0)
{
- if (init_audio_channel(ah, af))
+ if (init_audio_channel(af) != 0)
{
audioSocket = -1;
shared->totalSamples = 0;
}
else
- {
+ {
ACE_DEBUG ((LM_DEBUG,"(%P|%t) Initialized audio\n"));
shared->nextSample = 0;
if (shared->config.maxSPS < shared->audioPara.samplesPerSecond)
@@ -492,7 +483,7 @@ Command_Handler::init_av (void)
if (vf[0] != 0)
{
ACE_DEBUG ((LM_DEBUG,"(%P|%t) Initializing video\n"));
- if (this->init_video_channel(vh, vf))
+ if (this->init_video_channel(vf))
{
shared->totalFrames = 0; /* disable video channel */
videoSocket = -1;
@@ -528,45 +519,54 @@ Command_Handler::init_av (void)
unsigned char tmp = CmdDONE;
set_speed();
if (videoSocket >= 0)
- wait_display();
- CmdWrite(&tmp, 1);
- if (videoSocket < 0)
- {
- tmp = CmdVPclearScreen;
- CmdWrite(&tmp, 1);
- }
- return 0;
+ this->wait_for_display (INIT);
+// CmdWrite(&tmp, 1);
+// if (videoSocket < 0)
+// {
+// tmp = CmdVPclearScreen;
+// CmdWrite(&tmp, 1);
+// }
+// return 0;
}
cerr << "returning from init_av \n";
return 0;
}
-int
-Command_Handler::init_java_av (ACE_HANDLE fd)
-{
- cerr << "inside init_av \n";
+int
+Command_Handler::init_java_av (char *audio_ior,
+ char *video_ior,
+ char *audio_file,
+ char *video_file)
+{
+ if (audio_file != 0)
+ ACE_DEBUG ((LM_DEBUG,"%s\n",audio_file));
+ if (video_file != 0)
+ ACE_DEBUG ((LM_DEBUG,"%s\n",video_file));
int j;
+ this->audio_mmdevice_ior_ = audio_ior;
+ this->video_mmdevice_ior_ = video_ior;
/* try to stop and close previous playing */
if (audioSocket >= 0 || videoSocket >= 0)
{
- // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
// this may have to be taken care of afterwards.
unsigned char tmp = CmdCLOSE;
- int result =
+ int result =
this->stop_playing();
if (result < 0)
- return result;
-
+ ACE_ERROR_RETURN ((LM_ERROR,"stop_playing failed\n"),result);
+
if (audioSocket >= 0)
{
if (ABpid > 0) {
+ ACE_DEBUG ((LM_DEBUG,"Killing AB Process\n"));
kill(ABpid, SIGUSR1);
ABpid = -1;
}
usleep(10000);
}
-
+
if (videoSocket >= 0)
{
if (VBpid > 0) {
@@ -574,7 +574,7 @@ Command_Handler::init_java_av (ACE_HANDLE fd)
VBpid = -1;
}
usleep(10000);
- this->close ();
+
videoSocket = -1;
while ((!VBbufEmpty()) || !VDbufEmpty()) {
while (VDpeekMsg() != NULL) {
@@ -585,55 +585,24 @@ Command_Handler::init_java_av (ACE_HANDLE fd)
usleep(10000);
}
}
+ this->close ();
int result;
- /* read in video/audio files */
- // set the vf and af to 0 , very important.
-
- vh [0] = 0;
- vf [0]= 0;
- ah [0] = 0;
- af [0]=0;
-
NewCmd(CmdINIT);
- unsigned char i = 0;
- result = javaCmdRead((char*)&i, 1);
-
- ACE_DEBUG ((LM_DEBUG, "ior len = %d\n", i));
- ACE_NEW_RETURN (this->audio_mmdevice_ior_,
- char [i],
- -1);
- result = javaCmdRead (this->audio_mmdevice_ior_,i);
- //result = ACE::read_n (fd, this->audio_mmdevice_ior_, i);
-
- result = javaCmdRead ((char *) &i, 1);
- //result = ACE::read_n (fd, (char*)&i, 1);
- ACE_DEBUG ((LM_DEBUG, "movie name len = %d\n", i));
-
- result = javaCmdRead (af, i);
- //result = ACE::read_n (fd, af, i);
- // af[i] = 0;
-
- ACE_DEBUG ((LM_DEBUG, "Java init: Ior %s; movie name: %s\n",
- this->audio_mmdevice_ior_, af));
-
- /*
- fprintf(stderr, "INIT: vh-%s, vf-%s, ah-%s, af-%s\n", vh, vf, ah, af);
- */
shared->live = 0;
shared->audioMaxPktSize = !shared->config.audioConn;
shared->videoMaxPktSize = !shared->config.videoConn;
-
- if (af[0] != 0)
+
+ if (audio_file!= 0)
{
- if (init_audio_channel(ah, af))
+ if (init_audio_channel(audio_file))
{
audioSocket = -1;
shared->totalSamples = 0;
}
else
- {
+ {
ACE_DEBUG ((LM_DEBUG,"(%P|%t) Initialized audio\n"));
shared->nextSample = 0;
if (shared->config.maxSPS < shared->audioPara.samplesPerSecond)
@@ -645,10 +614,10 @@ Command_Handler::init_java_av (ACE_HANDLE fd)
shared->totalSamples = 0;
audioSocket = -1;
}
- if (vf[0] != 0)
+ if (video_file!= 0)
{
ACE_DEBUG ((LM_DEBUG,"(%P|%t) Initializing video\n"));
- if (this->init_video_channel(vh, vf))
+ if (this->init_video_channel(video_file))
{
shared->totalFrames = 0; /* disable video channel */
videoSocket = -1;
@@ -674,9 +643,9 @@ Command_Handler::init_java_av (ACE_HANDLE fd)
{
unsigned char tmp = CmdFAIL;
CmdWrite(&tmp, 1);
- /*
- fprintf(stderr, "CTR initialization failed.\n");
- */
+
+ fprintf(stderr, "CTR initialization failed.\n");
+
return -1;
}
else
@@ -684,7 +653,7 @@ Command_Handler::init_java_av (ACE_HANDLE fd)
unsigned char tmp = CmdDONE;
set_speed();
if (videoSocket >= 0)
- wait_display();
+ this->wait_for_display (INIT);
CmdWrite(&tmp, 1);
if (videoSocket < 0)
{
@@ -699,7 +668,7 @@ Command_Handler::init_java_av (ACE_HANDLE fd)
int
-Command_Handler::init_audio_channel (char *phostname, char *audiofile)
+Command_Handler::init_audio_channel (char *audiofile)
{
ACE_DEBUG ((LM_DEBUG,"(%P|%t) init_audio_channel called\n"));
this->audio_data_handle_ = -1;
@@ -710,19 +679,17 @@ Command_Handler::init_audio_channel (char *phostname, char *audiofile)
return -1;
}
- if (this->connect_to_audio_server(phostname,
- &audioSocket,
- &this->audio_data_handle_,
- &shared->audioMaxPktSize) == -1)
+ if (this->connect_to_audio_server() == -1)
return -1;
-
+
+ shared->audioMaxPktSize = -INET_SOCKET_BUFFER_SIZE;
/* Initialize with AS */
{
Audio_Control::INITaudioPara_var para (new
Audio_Control::INITaudioPara);
Audio_Control::INITaudioReply_var reply (new Audio_Control::INITaudioReply);
-
+
para->sn = shared->cmdsn;
para->version = VERSION;
para->para.encodeType = shared->AFPara.encodeType;
@@ -773,60 +740,86 @@ Command_Handler::init_audio_channel (char *phostname, char *audiofile)
shared->audioPara.samplesPerSecond = reply->para.samplesPerSecond;
shared->audioPara.bytesPerSample = reply->para.bytesPerSample;
shared->totalSamples = reply->totalSamples;
-
+
fprintf(stderr, "Audio: samples %d, sps %d, bps %d\n",
shared->totalSamples, shared->AFPara.samplesPerSecond,
shared->AFPara.bytesPerSample);
-
+
SetAudioParameter(&shared->audioPara);
}
-
+
/* create AB */
{
- switch (ABpid = fork())
- {
- case -1:
- perror("CTR error on forking AB process");
- exit(1);
- break;
- case 0:
- if (realTimeFlag) {
- SetRTpriority("AB", -1);
- }
- free(vh);
- free(vf);
- free(ah);
- free(audiofile);
- VBdeleteBuf();
- VDdeleteBuf();
- if (cmdSocket >= 0)
- ::close(cmdSocket);
- if (realTimeFlag >= 2) {
+ if (ABpid == -1)
+ {
+ switch (ABpid = fork())
+ {
+ case -1:
+ perror("CTR error on forking AB process");
+ exit(1);
+ break;
+ case 0:
+ if (realTimeFlag) {
+ SetRTpriority("AB", -1);
+ }
+ free(vh);
+ free(vf);
+ free(ah);
+ free(audiofile);
+ VBdeleteBuf();
+ VDdeleteBuf();
+ if (cmdSocket >= 0)
+ ::close(cmdSocket);
+ if (realTimeFlag >= 2) {
#ifdef __svr4__
- if (SetRTpriority("AB", 0)) realTimeFlag = 0;
+ if (SetRTpriority("AB", 0)) realTimeFlag = 0;
#elif defined(_HPUX_SOURCE)
- if (SetRTpriority("AB", 1)) realTimeFlag = 0;
+ if (SetRTpriority("AB", 1)) realTimeFlag = 0;
#endif
- }
- ABprocess(this->audio_data_handle_);
- break;
- default:
- ABflushBuf(0);
- break;
- }
+ }
+ ABprocess(this->audio_data_handle_);
+ break;
+ default:
+ ABflushBuf(0);
+ break;
+ }
+ }
}
}
+ ACE_DEBUG ((LM_DEBUG,"(%P) Init_audio_channel done\n"));
return 0;
}
+// void
+// Command_Handler::stop_timer (void)
+// {
+// ACE_Time_Value tv;
+// this->timer_.stop ();
+// this->timer_.elapsed_time (tv);
+// // tv.dump ();
+// // this->timer_.dump ();
+// }
+
void
-Command_Handler::stop_timer (void)
+Command_Handler::set_audio_mmdevice (CORBA::Object_ptr audio_mmdevice,
+ const char *audio_file)
{
- ACE_Time_Value tv;
- this->timer_.stop ();
- this->timer_.elapsed_time (tv);
- tv.dump ();
- // this->timer_.dump ();
+ CORBA::String audio_mmdevice_ior;
+ TAO_TRY
+ {
+ audio_mmdevice_ior =
+ this->orb_manager_.orb ()->object_to_string (audio_mmdevice,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,"audio_mmdevice ior is %s\n",audio_mmdevice_ior));
+ }
+ TAO_CATCHANY
+ {
+ ACE_ERROR ((LM_ERROR,"set_audio_mmdevice failed\n"));
+ }
+ TAO_ENDTRY;
+ this->init_java_av (audio_mmdevice_ior,0,(char *)audio_file,0);
+ return;
}
void
@@ -855,18 +848,23 @@ Command_Handler::set_audio_control (Audio_Control_ptr audio_control)
this->audio_control_ = audio_control;
}
+char*
+Command_Handler::get_data_host (void)
+{
+ return this->data_host_;
+}
+
int
-Command_Handler::init_video_channel (char *phostname, char *videofile)
-{
+Command_Handler::init_video_channel (char *videofile)
+{
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n",__LINE__, __FILE__,
fprintf (stderr," File Name is %s\n",videofile);
- if (this->connect_to_video_server (phostname,
- &videoSocket,
- &this->video_data_handle_,
- &shared->videoMaxPktSize) == -1)
+ if (this->connect_to_video_server () == -1)
return -1;
+ // set the max_pkt size for video ?? very minimum
+ shared->videoMaxPktSize = -INET_SOCKET_BUFFER_SIZE;
/* Initialize with VS */
{
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
@@ -879,7 +877,7 @@ Command_Handler::init_video_channel (char *phostname, char *videofile)
para->version = VERSION;
para->videofile.length (strlen(videofile));
- // string to sequence <char>
+ // string to sequence <char>
for (int i=0;i<para->videofile.length ();i++)
para->videofile [i] = videofile [i];
@@ -916,9 +914,9 @@ Command_Handler::init_video_channel (char *phostname, char *videofile)
shared->firstGopFrames = reply->firstGopFrames;
shared->patternSize = reply->pattern.length ();
if (shared->patternSize == 0) {
-
+
Fprintf(stderr, "CTR warning: patternsize %d\n", shared->patternSize);
-
+
shared->patternSize = 1;
shared->pattern[0] = 'I';
shared->pattern[1] = 0;
@@ -958,7 +956,7 @@ Command_Handler::init_video_channel (char *phostname, char *videofile)
shared->videoFormat == VIDEO_MPEG1 ? "MPEG1" :
shared->videoFormat == VIDEO_MPEG2 ? "MPEG2" : "UNKOWN format",
reply->live ? "live source" : "stored source");
-
+
fprintf(stderr, "Video: numS-%d, numG-%d, numF-%d, aveFrameSize-%d\n",
reply->totalHeaders, reply->totalGroups, reply->totalFrames,
reply->averageFrameSize);
@@ -979,128 +977,132 @@ Command_Handler::init_video_channel (char *phostname, char *videofile)
"Error: totalFrames %d > MAX_FRAMES %d, needs change and recompile.\n",
reply->totalFrames, MAX_FRAMES);
ComCloseConn(this->video_data_handle_);
- ComCloseConn(videoSocket);
+ // ComCloseConn(videoSocket);
videoSocket = -1;
return -1;
}
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
-
+
/* create VB, and put INIT frame to VB*/
{
- int sp[2]; /* sp[0] is for CTR and sp[1] is for VB */
-
- /* create command socket pair for sending INIT frame to VB, the pipe
- should be discard/non-discard in consistent with videoSocket*/
- if (socketpair(AF_UNIX,
- shared->videoMaxPktSize >= 0 ? SOCK_STREAM :
- SOCK_DGRAM, 0, sp) == -1)
- {
- perror("CTR error on open CTR-VB socketpair");
- exit(1);
- }
-
- switch (VBpid = fork())
+ int sp[2]; /* sp[0] is for CTR and sp[1] is for VB */
+
+ /* create command socket pair for sending INIT frame to VB, the pipe
+ should be discard/non-discard in consistent with videoSocket*/
+ if (socketpair(AF_UNIX,
+ shared->videoMaxPktSize >= 0 ? SOCK_STREAM :
+ SOCK_DGRAM, 0, sp) == -1)
+ {
+ perror("CTR error on open CTR-VB socketpair");
+ exit(1);
+ }
+
+ if (VBpid == -1)
{
- case -1:
- perror("CTR error on forking VB process");
- exit(1);
- break;
- case 0:
- // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
- if (realTimeFlag) {
- SetRTpriority("VB", -1);
- }
- free(vh);
- free(videofile);
- free(ah);
- free(af);
- ::close(sp[0]);
- //::close (videoSocket);
- // if (audioSocket >= 0)
- // ComCloseFd(audioSocket);
- ::close (audioSocket);
- ABdeleteBuf();
- VDdeleteBuf();
- if (cmdSocket >= 0)
- ::close(cmdSocket);
- if (realTimeFlag >= 2) {
+ switch (VBpid = fork())
+ {
+ case -1:
+ perror("CTR error on forking VB process");
+ exit(1);
+ break;
+ case 0:
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
+ if (realTimeFlag) {
+ SetRTpriority("VB", -1);
+ }
+ free(vh);
+ free(videofile);
+ free(ah);
+ free(af);
+ ::close(sp[0]);
+ //::close (videoSocket);
+ // if (audioSocket >= 0)
+ // ComCloseFd(audioSocket);
+ ::close (audioSocket);
+ ABdeleteBuf();
+ VDdeleteBuf();
+ if (cmdSocket >= 0)
+ ::close(cmdSocket);
+ if (realTimeFlag >= 2) {
#ifdef __svr4__
- if (SetRTpriority("VB", 0)) realTimeFlag = 0;
+ if (SetRTpriority("VB", 0)) realTimeFlag = 0;
#elif defined(_HPUX_SOURCE)
- if (SetRTpriority("VB", 1)) realTimeFlag = 0;
+ if (SetRTpriority("VB", 1)) realTimeFlag = 0;
#endif
- }
- VBprocess(sp[1], this->video_data_handle_);
- break;
- default:
- ::close(sp[1]);
- // ::close(dataSocket);
- {
- int bytes, res;
- /* passing all messages of INIT frame to VB here. */
- char * buf = (char *)malloc(INET_SOCKET_BUFFER_SIZE);
- VideoMessage *msg = (VideoMessage *)buf;
- int pkts = 1, msgo = 0, msgs = 0;
-
- if (buf == NULL) {
- perror("CTR error on malloc() for INIT frame");
- exit(1);
- }
- while (msgo + msgs < pkts) {
- // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
- // cerr << "expecting a packet of size " << sizeof (*msg) << endl;
-
- VideoRead(buf, sizeof(*msg));
- //~~ we need to read the first frame from the
- // data socket instead of control socket.
- // SocketRecv(dataSocket, buf, size);
- // ACE_DEBUG ((LM_DEBUG,"packetsn = %d,msgsn = %d\n",msg->packetsn,msg->msgsn));
- pkts = ntohl(msg->packetSize);
- msgo = ntohl(msg->msgOffset);
- msgs = ntohl(msg->msgSize);
- if (shared->videoMaxPktSize >= 0) { /* non-discard mode */
- // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
- write_bytes(sp[0], buf, sizeof(*msg));
- bytes = msgs;
- while (bytes > 0) {
- int size = min(bytes, INET_SOCKET_BUFFER_SIZE);
- VideoRead(buf, size);
- write_bytes(sp[0], buf, size);
- bytes -= size;
- }
}
- else {
- // cerr << "expecting a packet of size " << msgs << endl;
-
- VideoRead(buf + sizeof(*msg), msgs);
- bytes = sizeof(*msg) + msgs;
- while ((res = write(sp[0], buf, bytes)) == -1) {
- if (errno == EINTR || errno == ENOBUFS) continue;
- perror("CTR error on sending INIT frame to VB");
+ VBprocess(sp[1], this->video_data_handle_);
+ break;
+ default:
+ ::close(sp[1]);
+ // ::close(dataSocket);
+ {
+ int bytes, res;
+ /* passing all messages of INIT frame to VB here. */
+ char * buf = (char *)malloc(INET_SOCKET_BUFFER_SIZE);
+ VideoMessage *msg = (VideoMessage *)buf;
+ int pkts = 1, msgo = 0, msgs = 0;
+
+ if (buf == NULL) {
+ perror("CTR error on malloc() for INIT frame");
exit(1);
}
- if (res < bytes) {
- fprintf(stderr, "CTR warn: send() res %dB < bytes %dB\n", res, bytes);
+ while (msgo + msgs < pkts) {
+ // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
+ // cerr << "expecting a packet of size " << sizeof (*msg) << endl;
+
+ VideoRead(buf, sizeof(*msg));
+ //~~ we need to read the first frame from the
+ // data socket instead of control socket.
+ // SocketRecv(dataSocket, buf, size);
+ // ACE_DEBUG ((LM_DEBUG,"packetsn = %d,msgsn = %d\n",msg->packetsn,msg->msgsn));
+ pkts = ntohl(msg->packetSize);
+ msgo = ntohl(msg->msgOffset);
+ msgs = ntohl(msg->msgSize);
+ if (shared->videoMaxPktSize >= 0) { /* non-discard mode */
+ // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
+ write_bytes(sp[0], buf, sizeof(*msg));
+ bytes = msgs;
+ while (bytes > 0) {
+ int size = min(bytes, INET_SOCKET_BUFFER_SIZE);
+ VideoRead(buf, size);
+ write_bytes(sp[0], buf, size);
+ bytes -= size;
+ }
+ }
+ else {
+ // cerr << "expecting a packet of size " << msgs << endl;
+
+ VideoRead(buf + sizeof(*msg), msgs);
+ bytes = sizeof(*msg) + msgs;
+ while ((res = write(sp[0], buf, bytes)) == -1) {
+ if (errno == EINTR || errno == ENOBUFS) continue;
+ perror("CTR error on sending INIT frame to VB");
+ exit(1);
+ }
+ if (res < bytes) {
+ fprintf(stderr, "CTR warn: send() res %dB < bytes %dB\n", res, bytes);
+ }
+ /*
+ Fprintf(stderr,
+ "CTR transferred INIT frame to VB: pkts %d, msgo %d, msgs %d\n",
+ pkts, msgo, msgs);
+ */
+ }
}
- /*
- Fprintf(stderr,
- "CTR transferred INIT frame to VB: pkts %d, msgo %d, msgs %d\n",
- pkts, msgo, msgs);
- */
+ read(sp[0], buf, 1); /* read a garbage byte, to sync with VB */
+ ::close(sp[0]);
+ free(buf);
}
+ break;
}
- read(sp[0], buf, 1); /* read a garbage byte, to sync with VB */
- ::close(sp[0]);
- free(buf);
- }
- break;
}
}
}
return 0;
}
-int
+
+int
Command_Handler::stat_stream (CORBA::Char_out ch,
CORBA::Long_out size)
{
@@ -1108,7 +1110,7 @@ Command_Handler::stat_stream (CORBA::Char_out ch,
}
-int
+int
Command_Handler::close (void)
{
TAO_TRY
@@ -1117,16 +1119,15 @@ Command_Handler::close (void)
{
// one way function call.
this->audio_control_->close (TAO_TRY_ENV);
-
+
TAO_CHECK_ENV;
if (ABpid > 0) {
kill(ABpid, SIGUSR1);
ABpid = -1;
}
-
ACE_DEBUG ((LM_DEBUG,"(%P|%t) audio close done \n"));
}
-
+
if (CORBA::is_nil (this->video_control_) == 0)
{
// one way function call.
@@ -1138,27 +1139,49 @@ Command_Handler::close (void)
}
ACE_DEBUG ((LM_DEBUG,"(%P|%t) video close done \n"));
}
+ this->orb_manager_.child_poa ()->destroy (1,0,TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t)destroy childpoa done\n"));
+
+ this->orb_manager_.init_child_poa (argc_,
+ argv_,
+ "child_poa",
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,"(%P)New child poa initialized\n"));
}
TAO_CATCHANY
{
- // TAO_TRY_ENV.print_exception ("video_control_->close (..)");
+ TAO_TRY_ENV.print_exception ("video_control_->close (..)");
return -1;
}
TAO_ENDTRY;
+ delete this->audio_reactive_strategy_;
+ ACE_DEBUG ((LM_DEBUG,"(%P)%N,%l"));
+ delete this->audio_client_mmdevice_;
+ ACE_DEBUG ((LM_DEBUG,"(%P)%N,%l"));
+ // delete this->audio_streamctrl_;
+ ACE_DEBUG ((LM_DEBUG,"(%P)%N,%l"));
+ delete this->video_reactive_strategy_;
+ ACE_DEBUG ((LM_DEBUG,"(%P)%N,%l"));
+ delete this->video_client_mmdevice_;
+ ACE_DEBUG ((LM_DEBUG,"(%P)%N,%l"));
+ // delete this->video_streamctrl_;
+ ACE_DEBUG ((LM_DEBUG,"(%P)%N,%l"));
return 0;
}
-int
+int
Command_Handler::stat_sent (void)
{
return 0;
}
-int
+int
Command_Handler::fast_forward (void)
-
+
{
// CORBA call
unsigned char tmp;
@@ -1181,12 +1204,12 @@ Command_Handler::fast_forward (void)
shared->patternSize;
shared->usecPerFrame = (int)(1000000.0 / (float)shared->config.ffFPS) *
shared->patternSize;
-
+
shared->VStimeAdvance =
max(shared->config.VStimeAdvance, DEFAULT_VStimeAdvance) * 1000;
if (shared->VStimeAdvance < shared->usecPerFrame)
shared->VStimeAdvance = shared->usecPerFrame;
-
+
para->VStimeAdvance = shared->VStimeAdvance;
para->sn = shared->cmdsn;
para->nextGroup = shared->nextGroup;
@@ -1218,9 +1241,9 @@ Command_Handler::fast_forward (void)
}
-int
+int
Command_Handler::fast_backward (void)
-
+
{
unsigned char tmp;
Video_Control::FBpara_var para (new Video_Control::FBpara);
@@ -1280,9 +1303,9 @@ Command_Handler::fast_backward (void)
}
-int
+int
Command_Handler::step (void)
-
+
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Command_Handler::step ()\n"));
@@ -1299,7 +1322,7 @@ Command_Handler::step (void)
CORBA::Boolean result;
result = this->video_control_->step (para.in (),
TAO_TRY_ENV);
- ACE_DEBUG ((LM_DEBUG,"(%P|%t) step done \n"));
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t) step done \n"));
TAO_CHECK_ENV;
if (result == (0))
return -1;
@@ -1313,10 +1336,10 @@ Command_Handler::step (void)
/*
fprintf(stderr, "CTR: STEP . . . frame-%d\n", para.nextFrame);
*/
- ::wait_display ();
+ this->wait_for_display (STEP);
}
- unsigned char tmp = CmdDONE;
- CmdWrite(&tmp, 1);
+// unsigned char tmp = CmdDONE;
+// CmdWrite(&tmp, 1);
return 0;
}
@@ -1330,10 +1353,10 @@ Command_Handler::play (int auto_exp,
unsigned char tmp;
int cmdstarted = 0;
int stuffsamples = 0;
-
- this->timer_.start ();
+
+ // this->timer_.start ();
fprintf (stderr, "CTR: PLAY . . .\n");
-
+
this->stop_playing ();
if (!shared->live && !shared->config.rt && videoSocket >= 0) {
@@ -1344,7 +1367,7 @@ Command_Handler::play (int auto_exp,
else {
rtplay = 1;
}
-
+
if (shared->live) {
rtplay = 1;
shared->nextFrame = 0;
@@ -1352,7 +1375,7 @@ Command_Handler::play (int auto_exp,
}
shared->rtplay = rtplay;
-
+
if (shared->nextFrame < 0)
shared->nextFrame = 0;
else if (shared->nextFrame >= shared->totalFrames)
@@ -1360,8 +1383,8 @@ Command_Handler::play (int auto_exp,
shared->nextFrame = shared->totalFrames - 1;
}
- // ACE_DEBUG ((LM_DEBUG,"(%P|%t) nextsample=%d,totalsamples=%d",
- // shared->nextSample,shared->totalSamples));
+ // ACE_DEBUG ((LM_DEBUG,"(%P|%t) nextFrame=%d,totalFrames=%d",
+ // shared->nextFrame,shared->totalFrames));
if (audioSocket >= 0 && shared->nextSample < shared->totalSamples && rtplay)
{
// ACE_DEBUG ((LM_DEBUG,"(%P|%t) %s,%d\n",__FILE__,__LINE__));
@@ -1387,14 +1410,14 @@ Command_Handler::play (int auto_exp,
}
ABflushBuf (shared->nextSample);
-
+
para->sn = shared->cmdsn;
para->nextSample = shared->nextSample;
para->samplesPerSecond = shared->samplesPerSecond;
para->samplesPerPacket = 1024 / shared->audioPara.bytesPerSample;
para->ABsamples = AB_BUF_SIZE / shared->audioPara.bytesPerSample;
para->spslimit = 32000;
-
+
startTime = get_usec ();
// CORBA call.
@@ -1409,7 +1432,7 @@ Command_Handler::play (int auto_exp,
if (videoSocket >= 0 && shared->nextFrame < shared->totalFrames)
{
Video_Control::PLAYpara_var para (new Video_Control::PLAYpara);
-
+
if (cmdstarted == 0)
{
NewCmd (CmdPLAY);
@@ -1441,7 +1464,7 @@ Command_Handler::play (int auto_exp,
max (shared->config.VStimeAdvance, DEFAULT_VStimeAdvance) * 1000;
if (shared->VStimeAdvance < shared->usecPerFrame)
shared->VStimeAdvance = shared->usecPerFrame;
-
+
para->VStimeAdvance = shared->VStimeAdvance;
para->sn = shared->cmdsn;
para->nextFrame = shared->nextFrame;
@@ -1458,14 +1481,14 @@ Command_Handler::play (int auto_exp,
compute_sendPattern ();
para->sendPatternGops = shared->sendPatternGops;
// memcpy (para->sendPattern, shared->sendPattern, PATTERN_SIZE);
-
+
// Sequence of chars
para->sendPattern.length (PATTERN_SIZE);
for (int i=0; i<PATTERN_SIZE ; i++)
para->sendPattern [i] = shared->sendPattern [i];
-
+
startTime = get_usec ();
// CORBA call
result =this->video_control_->play (para,
@@ -1474,7 +1497,7 @@ Command_Handler::play (int auto_exp,
if (result == 0)
return -1;
TAO_CHECK_ENV_RETURN (env,-1);
- // ACE_DEBUG ((LM_DEBUG,"(%P|%t)Reached line %d in %s",__LINE__,__FILE__));
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t)Reached line %d in %s",__LINE__,__FILE__));
if (shared->config.qosEffective) {
/*
fprintf (stderr, "CTR start FeedBack with init frameRateLimit %lf\n",
@@ -1495,17 +1518,17 @@ Command_Handler::play (int auto_exp,
(double)max (shared->patternSize * shared->sendPatternGops, 5);
/* adjust step for current play speed, in percentage against
'maxfr' */
-
+
fbstate = 1;
fb_startup = 1;
-
- /*
+
+
fprintf (stderr, "CTR init frate: %lf minupf %d, shared->upf %d\n",
frate, minupf, shared->usecPerFrame);
- */
+
}
}
-
+
if (shared->live && (videoSocket >= 0) && (audioSocket >= 0)) {
int gap = get_duration (ats, vts);
if (gap < 0 || gap >= 5000000) {
@@ -1536,6 +1559,9 @@ Command_Handler::position_action (int operation_tag)
unsigned char tmp = CmdDONE;
CmdRead ((char*)&val, 4);
+ this->operation_tag_ = operation_tag;
+ this->position_val_ = val;
+
// ACE_DEBUG ((LM_DEBUG,"(%P|%t) position_action called\n"));
if (shared->live) {
beep();
@@ -1576,41 +1602,41 @@ Command_Handler::position_action (int operation_tag)
}
TAO_ENDTRY;
if (operation_tag) /* release or LOOPrewind */
- wait_display();
+ this->wait_for_display (POSITION);
}
- if (operation_tag && audioSocket >= 0) /* needs to adjust audio position */
- {
+// if (operation_tag && audioSocket >= 0) /* needs to adjust audio position */
+// {
- shared->nextSample = (int)((double)shared->audioPara.samplesPerSecond *
- ((double)shared->nextFrame / shared->pictureRate));
- // ACE_DEBUG ((LM_DEBUG,"shared->nextsample = %d\n",shared->nextSample));
- }
+// shared->nextSample = (int)((double)shared->audioPara.samplesPerSecond *
+// ((double)shared->nextFrame / shared->pictureRate));
+// // ACE_DEBUG ((LM_DEBUG,"shared->nextsample = %d\n",shared->nextSample));
+// }
}
- else if (audioSocket >= 0)
- shared->nextSample = (shared->totalSamples-1) * val / POSITION_RANGE;
+// else if (audioSocket >= 0)
+// shared->nextSample = (shared->totalSamples-1) * val / POSITION_RANGE;
}
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
+// tmp = CmdDONE;
+// CmdWrite(&tmp, 1);
return 0;
}
int
Command_Handler::position (void)
-
+
{
return this->position_action (0);
}
int
Command_Handler::position_release (void)
-
+
{
return this->position_action (1);
}
int
Command_Handler::volume (void)
-
+
{
CmdRead((char *)&shared->volumePosition, 4);
if (audioSocket >= 0) {
@@ -1626,7 +1652,7 @@ Command_Handler::volume (void)
int
Command_Handler::balance (void)
-
+
{
CmdRead((char *)&shared->balancePosition, 4);
/*
@@ -1637,10 +1663,11 @@ Command_Handler::balance (void)
return 0;
}
-int
+int
Command_Handler::speed (void)
-
+
{
+ ACE_DEBUG ((LM_DEBUG,"COmmand_Handler::speed ()\n"));
unsigned char tmp;
CORBA::Boolean result;
CmdRead((char *)&shared->speedPosition, 4);
@@ -1649,7 +1676,7 @@ Command_Handler::speed (void)
{
if (!shared->live && shared->cmd == CmdPLAY)
{
- if (videoSocket >= 0)
+ if (videoSocket >= 0)
{
Video_Control::SPEEDpara_var para (new Video_Control::SPEEDpara);
para->sn = shared->cmdsn;
@@ -1665,7 +1692,7 @@ Command_Handler::speed (void)
}
compute_sendPattern();
para->sendPatternGops = shared->sendPatternGops;
-
+
// memcpy(para.sendPattern, shared->sendPattern, PATTERN_SIZE);
para->sendPattern.length (PATTERN_SIZE);
for (int i=0; i< PATTERN_SIZE ; i++)
@@ -1706,14 +1733,14 @@ Command_Handler::speed (void)
return -1;
}
TAO_ENDTRY;
-
+
return 0;
}
-int
+int
Command_Handler::stop (void)
-
+
{
/*
::stop ();
@@ -1732,7 +1759,7 @@ Command_Handler::stop (void)
shared->pictureRate * displayedFrames / shared->nextFrame);
}
unsigned char tmp = CmdDONE;
- // ACE_DEBUG ((LM_DEBUG,"(%P|%t) command_handler::Stop cmdone sent\n"));
+ // ACE_DEBUG ((LM_DEBUG,"(%P|%t) command_handler::Stop :nextFrame=%d\n",shared->nextFrame));
CmdWrite(&tmp, 1);
return 0;
@@ -1742,7 +1769,7 @@ int
Command_Handler::stop_playing (void)
{
unsigned char precmd = shared->cmd;
-
+
TAO_TRY
{
if (precmd == CmdFF || precmd == CmdFB || precmd == CmdPLAY)
@@ -1750,9 +1777,9 @@ Command_Handler::stop_playing (void)
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
unsigned char tmp = CmdSTOP;
NewCmd(CmdSTOP);
-
+
/* notify AS and/or VS */
- if ((CORBA::is_nil (this->audio_control_) == 0)
+ if ((CORBA::is_nil (this->audio_control_) == 0)
&& precmd == CmdPLAY
&& rtplay)
{
@@ -1778,10 +1805,10 @@ Command_Handler::stop_playing (void)
TAO_CHECK_ENV;
}
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__));
-
+
/* stop timer and sleep for a while */
// cerr << "stopping timer" << endl;
- stop_timer();
+ this->client_sig_handler_.stop_timer ();
usleep(100000);
/* purge VDbuf and audio channel from AS*/
@@ -1793,9 +1820,9 @@ Command_Handler::stop_playing (void)
Fprintf(stderr, "CTR: VDbuf purged.\n");
*/
fbstate = 0;
-
+
}
-
+
/* adjust some info */
if (precmd == CmdPLAY && videoSocket >= 0)
shared->nextFrame = shared->currentFrame+1;
@@ -1809,19 +1836,18 @@ Command_Handler::stop_playing (void)
return -1;
}
TAO_ENDTRY;
-
+
}
// connects and handshakes with the server
int
-Command_Handler::connect_to_video_server (char *address,
- int *ctr_fd,
- int *data_fd,
- int *max_pkt_size)
+Command_Handler::connect_to_video_server (void)
{
// set the pointers to the correct values
- *max_pkt_size = -INET_SOCKET_BUFFER_SIZE;
+ // *max_pkt_size = -INET_SOCKET_BUFFER_SIZE;
// initialize the command handler , ORB
+ TAO_TRY
+ {
if (this->resolve_video_reference () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) command_handler: resolve_video_reference returned -1"),
@@ -1830,10 +1856,24 @@ Command_Handler::connect_to_video_server (char *address,
AVStreams::flowSpec_var the_flows (new AVStreams::flowSpec);
// Bind the client and server mmdevices.
- TAO_TRY
- {
- this->video_streamctrl_.bind_devs
- (this->video_client_mmdevice_._this (TAO_TRY_ENV),
+ ACE_NEW_RETURN (this->video_reactive_strategy_,
+ Video_Endpoint_Reactive_Strategy_A (&this->orb_manager_,
+ this),
+ -1);
+ ACE_NEW_RETURN (this->video_client_mmdevice_,
+ TAO_MMDevice (this->video_reactive_strategy_),
+ -1);
+
+ this->orb_manager_.activate_under_child_poa ("Video_Client_MMDevice",
+ this->video_client_mmdevice_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ ACE_NEW_RETURN (this->video_streamctrl_,
+ TAO_StreamCtrl,
+ -1);
+ this->video_streamctrl_->bind_devs
+ (this->video_client_mmdevice_->_this (TAO_TRY_ENV),
this->video_server_mmdevice_.in (),
the_qos.inout (),
the_flows.in (),
@@ -1854,14 +1894,14 @@ Command_Handler::connect_to_video_server (char *address,
// connects and handshakes with the server
int
-Command_Handler::connect_to_audio_server (char *address,
- int *ctr_fd,
- int *data_fd,
- int *max_pkt_size)
+Command_Handler::connect_to_audio_server (void)
{
// // set the pointers to the correct values
- *max_pkt_size = -INET_SOCKET_BUFFER_SIZE;
+ // *max_pkt_size = -INET_SOCKET_BUFFER_SIZE;
+
+ TAO_TRY
+ {
if (this->resolve_audio_reference () == -1)
ACE_ERROR_RETURN ((LM_ERROR,
@@ -1870,11 +1910,28 @@ Command_Handler::connect_to_audio_server (char *address,
AVStreams::streamQoS_var the_qos (new AVStreams::streamQoS);
AVStreams::flowSpec_var the_flows (new AVStreams::flowSpec);
+ ACE_NEW_RETURN (this->audio_reactive_strategy_,
+ Audio_Endpoint_Reactive_Strategy_A (&this->orb_manager_,
+ this),
+ -1);
+
+ ACE_NEW_RETURN (this->audio_client_mmdevice_,
+ TAO_MMDevice (this->audio_reactive_strategy_),
+ -1);
+
+ // activate the client audio mmdevice under the child poa.
+ this->orb_manager_.activate_under_child_poa ("Audio_Client_MMDevice",
+ this->audio_client_mmdevice_,
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ ACE_NEW_RETURN (this->audio_streamctrl_,
+ TAO_StreamCtrl,
+ -1);
+
// Bind the client and server mmdevices.
- TAO_TRY
- {
- this->audio_streamctrl_.bind_devs
- (this->audio_client_mmdevice_._this (TAO_TRY_ENV),
+ this->audio_streamctrl_->bind_devs
+ (this->audio_client_mmdevice_->_this (TAO_TRY_ENV),
this->audio_server_mmdevice_.in (),
the_qos.inout (),
the_flows.in (),
@@ -1898,7 +1955,7 @@ Client_Sig_Handler::PlayAudioOnly(void)
int maxSize;
int size, csize; /* all in samples */
unsigned int AFtime;
-
+
if (audioFirst)
{
audioFirst = 0;
@@ -1907,7 +1964,7 @@ Client_Sig_Handler::PlayAudioOnly(void)
else
if ((int)(nextAFtime - GetAudioTime()) >= bufferedSamples)
return;
-
+
if (timer_on >4)
{
// ~~we may need to uncomment this ??
@@ -1923,7 +1980,7 @@ Client_Sig_Handler::PlayAudioOnly(void)
*/
loopBack();
}
-
+
return;
}
if (nextASSample >= shared->totalSamples)
@@ -1995,10 +2052,10 @@ Client_Sig_Handler::register_handler (void)
// Register signal handler object. Note that NULL_MASK is used to
// keep the ACE_Reactor from calling us back on the "/dev/null"
// descriptor.
- if (TAO_ORB_Core_instance ()->reactor ()->register_handler
+ if (TAO_ORB_Core_instance ()->reactor ()->register_handler
(this, ACE_Event_Handler::NULL_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
"register_handler"),
-1);
@@ -2006,16 +2063,16 @@ Client_Sig_Handler::register_handler (void)
this->sig_set.sig_add (SIGINT);
this->sig_set.sig_add (SIGQUIT);
- this->sig_set.sig_add (SIGALRM);
+ this->sig_set.sig_add (SIGALRM);
this->sig_set.sig_add (SIGUSR1);
- this->sig_set.sig_add (SIGUSR2);
+ this->sig_set.sig_add (SIGUSR2);
this->sig_set.sig_add (SIGSEGV);
// Register the signal handler object to catch the signals.
- if (TAO_ORB_Core_instance ()->reactor ()->register_handler (sig_set,
+ if (TAO_ORB_Core_instance ()->reactor ()->register_handler (sig_set,
this) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
"register_handler"),
-1);
return 0;
@@ -2028,14 +2085,14 @@ Client_Sig_Handler::get_handle (void) const
return this->handle_;
}
-int
+int
Client_Sig_Handler::handle_input (ACE_HANDLE)
{
ACE_DEBUG ((LM_DEBUG, "(%t) handling asynchonrous input...\n"));
return 0;
}
-int
+int
Client_Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask)
{
ACE_DEBUG ((LM_DEBUG, "(%t) closing down Sig_Handler...\n"));
@@ -2046,11 +2103,11 @@ Client_Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask)
// object. In our simple example, we are simply catching SIGALRM,
// SIGINT, and SIGQUIT. Anything else is logged and ignored.
//
-// There are several advantages to using this approach. First,
+// There are several advantages to using this approach. First,
// the behavior triggered by the signal is handled in the main event
-// loop, rather than in the signal handler. Second, the ACE_Reactor's
-// signal handling mechanism eliminates the need to use global signal
-// handler functions and data.
+// loop, rather than in the signal handler. Second, the ACE_Reactor's
+// signal handling mechanism eliminates the need to use global signal
+// handler functions and data.
int
Client_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
@@ -2070,6 +2127,44 @@ Client_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
// %% ??!!!
break;
case SIGUSR1:
+ // Resume the command handler.
+ if (this->command_handler_->command_suspended_ != UNSUSPENDED)
+ {
+ unsigned char tmp;
+ switch (this->command_handler_->command_suspended_)
+ {
+ case INIT:
+ tmp = CmdDONE;
+ CmdWrite(&tmp, 1);
+ if (videoSocket < 0)
+ {
+ tmp = CmdVPclearScreen;
+ CmdWrite(&tmp, 1);
+ }
+ break;
+ case STEP:
+ tmp = CmdDONE;
+ CmdWrite(&tmp, 1);
+ break;
+ case POSITION:
+ if (this->command_handler_->operation_tag_ && audioSocket >= 0) /* needs to adjust audio position */
+ {
+
+ shared->nextSample = (int)((double)shared->audioPara.samplesPerSecond *
+ ((double)shared->nextFrame / shared->pictureRate));
+ // ACE_DEBUG ((LM_DEBUG,"shared->nextsample = %d\n",shared->nextSample));
+ }
+ if (audioSocket >= 0)
+ shared->nextSample = (shared->totalSamples-1) * (this->command_handler_->position_val_) / POSITION_RANGE;
+ tmp = CmdDONE;
+ CmdWrite(&tmp, 1);
+ break;
+ default:
+ ACE_DEBUG ((LM_DEBUG,"INVALID STATE for command suspension\n"));
+ break;
+ }
+ TAO_ORB_Core_instance ()->reactor ()->resume_handler (this->command_handler_->get_handle ());
+ }
::usr1_handler (signum);
break;
case SIGUSR2:
@@ -2085,9 +2180,9 @@ Client_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
TAO_ORB_Core_instance ()->reactor ()->remove_handler (this->sig_set);
TAO_ORB_Core_instance ()->orb ()->shutdown ();
return 0;
- default:
- ACE_DEBUG ((LM_DEBUG,
- "(%t) %S: not handled, returning to program\n",
+ default:
+ ACE_DEBUG ((LM_DEBUG,
+ "(%t) %S: not handled, returning to program\n",
signum));
return 0;
}
@@ -2144,7 +2239,7 @@ Client_Sig_Handler::TimerHandler(int sig)
}
timerCount += timer_signals_skip + 1;
timer_signals_skip = 0;
-
+
if (shared->live ) {
if (audioSocket <= 0) { /* video only */
unsigned t = shared->VBheadFrame - startVSA;
@@ -2156,38 +2251,41 @@ Client_Sig_Handler::TimerHandler(int sig)
}
}
}
+ double frames_per_group =
+ (double)shared->totalFrames/shared->totalGroups;
+ long nextframe = shared->nextGroup * frames_per_group;
+
if (audioSocket > 0)
{
// ACE_DEBUG ((LM_DEBUG,"(%P|%t) Adjusting audio nextsample value\n"));
- double frames_per_group =
- (double)shared->totalFrames/shared->totalGroups;
- long nextframe = shared->nextGroup * frames_per_group;
shared->nextSample = (int)((double)shared->audioPara.samplesPerSecond *
((double)nextframe / shared->pictureRate));
-
+
/* audio involved, TimerProcessing() will adjust the rate automatically */
}
+ if ((shared->cmd == CmdFF) || (shared->cmd == CmdFB))
+ shared->nextFrame = shared->nextGroup * frames_per_group;
}
void
Client_Sig_Handler::stop_timer(void)
{
struct itimerval val;
-
+
if (!timer_on)
return;
-
+
timer_on = 0;
-
+
// setsignal(SIGALRM, SIG_IGN);
-
+
val.it_interval.tv_sec = val.it_value.tv_sec = 0;
val.it_interval.tv_usec = val.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &val, NULL);
-
+
fprintf(stderr, "CTR: timer stopped.\n");
-
- this->command_handler_->stop_timer ();
+
+ // this->command_handler_->stop_timer ();
/*
usleep(200000);
*/
@@ -2196,26 +2294,27 @@ Client_Sig_Handler::stop_timer(void)
void
Client_Sig_Handler::DisplayPicture(void)
{
+ // ACE_DEBUG ((LM_DEBUG,"inside DisplayPicture\n"));
int toDisplay = 1;
int count = timerCount;
-
+
if ((shared->cmd != CmdPLAY &&
shared->cmd != CmdFF &&
shared->cmd != CmdFB) ||
lastCount == count)
- return;
+ ACE_ERROR ((LM_ERROR,"Returning from first if in DisplayPicture\n"));
if (timer_on >4) /* 4 is a magic number */
{
this->stop_timer();
-
+
// stop both the audio and video.
this->command_handler_->stop ();
-
+
/* tries to rewind and play again */
if (shared->cmd == CmdPLAY && shared->loopBack)
loopBack();
-
- return;
+
+ ACE_ERROR ((LM_ERROR,"Returning because timer_on > 4\n"));
}
/*
Fprintf(stderr, "CTR in diplayPicture().\n");
@@ -2262,16 +2361,19 @@ Client_Sig_Handler::DisplayPicture(void)
for (;;)
{
buf = VDpeekMsg();
-
+
if (buf == NULL) {
+ // ACE_DEBUG ((LM_DEBUG,"Null buffer "));
goto loop_end;
}
-
+
switch (shared->cmd)
{
+ // ACE_DEBUG ((LM_DEBUG,"nextFrame = %d,nextGroup\n",shared->nextFrame,shared->nextGroup));
int position;
case CmdPLAY:
position = shared->nextFrame;
+ // ACE_DEBUG ((LM_DEBUG,"nextFrame = %d,nextGroup\n",shared->nextFrame,shared->nextGroup));
/*
Fprintf(stderr, "CTR PLAY: buf->display %d, position %d\n",
buf->display, position);
@@ -2324,6 +2426,7 @@ Client_Sig_Handler::DisplayPicture(void)
{ /* display it */
buf = VDgetMsg();
shared->nextFrame = buf->display;
+ // ACE_DEBUG ((LM_DEBUG,"nextFrame = %d\n",shared->nextFrame));
goto display_picture;
}
else if (buf->gop > position)
@@ -2349,6 +2452,7 @@ Client_Sig_Handler::DisplayPicture(void)
{ /* display it */
buf = VDgetMsg();
shared->nextFrame = buf->display;
+ // ACE_DEBUG ((LM_DEBUG,"nextFrame = %d\n",shared->nextFrame));
goto display_picture;
}
else if (buf->gop < position)
@@ -2389,7 +2493,7 @@ Client_Sig_Handler::DisplayPicture(void)
loop_end:;
}
}
-
+
if (shared->cmd == CmdPLAY)
{
shared->nextFrame += rtplay ? count - lastCount : 1;
@@ -2398,7 +2502,7 @@ Client_Sig_Handler::DisplayPicture(void)
timer_on ++;
shared->nextFrame = shared->totalFrames;
}
-
+
/* following is frameRate feedback algorithm */
if (fbstate && toDisplay && rtplay) {
static Filter *fr = NULL; /* frame-rate filter */
@@ -2415,7 +2519,7 @@ Client_Sig_Handler::DisplayPicture(void)
static double vr; /* filtered frame-rate value, in microseconds/frame */
double r, nr;
int t = get_usec();
-
+
switch (fbstate) {
case 3: /* working, monitoring */
{
@@ -2440,11 +2544,11 @@ Client_Sig_Handler::DisplayPicture(void)
vr = DoFilter(fr, (double)interval);
}
pretime = t;
-
+
r = minupf / vr; /* convert the display fps to percentage of maxfr */
-
+
nr = 0; /* This variable contains the newly computed server frame rate */
-
+
/* let nr oscillate around 1.5 ~ 2.5 */
if (min(frate, maxrate) - r >= 3.0 * adjstep) {
/* pipeline is considered overloaded if server fps is more than 3 adjsteps
@@ -2559,7 +2663,7 @@ Client_Sig_Handler::DisplayPicture(void)
}
}
/* end of frame rate control algorithm */
-
+
}
else if (shared->cmd == CmdFF)
{
@@ -2582,7 +2686,7 @@ Client_Sig_Handler::DisplayPicture(void)
lastCount = count;
}
-void
+void
Client_Sig_Handler::TimerProcessing (void)
{
// cerr << "Timerprocessing signal went off\n";
@@ -2638,22 +2742,19 @@ Client_Sig_Handler::TimerProcessing (void)
}
if (videoSocket >= 0 &&
(shared->cmd == CmdPLAY || shared->cmd == CmdFF || shared->cmd == CmdFB)) {
+ // cerr << "Timerprocessing signal-handler done\n";
DisplayPicture();
}
- // cerr << "Timerprocessing signal-handler done\n";
+
}
// -----------------------------------------------------------
// Audio_Client_StreamEndPoint methods
-Audio_Client_StreamEndPoint::Audio_Client_StreamEndPoint (void)
- : command_handler_ (0)
-{
-}
-
-
-Audio_Client_StreamEndPoint::Audio_Client_StreamEndPoint (Command_Handler *command_handler)
- :command_handler_ (command_handler)
+Audio_Client_StreamEndPoint::Audio_Client_StreamEndPoint (Command_Handler *command_handler,
+ char *host)
+ :command_handler_ (command_handler),
+ host_ (host)
{
}
@@ -2678,7 +2779,7 @@ Audio_Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec)
ACE_DEBUG ((LM_DEBUG,"(%P|%t) handle_preconnect called\n"));
CORBA::UShort server_port;
ACE_INET_Addr local_addr;
-
+
// Get the local UDP address
if (this->dgram_.open (ACE_Addr::sap_any) == -1)
ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) datagram open failed %p\n"),0);
@@ -2702,15 +2803,15 @@ Audio_Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec)
if (this->dgram_.get_local_addr (local_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t)datagram get local addr failed %p"),-1);
- // form a string
+ // form a string
char client_address_string [BUFSIZ];
::sprintf (client_address_string,
"%s:%d",
- local_addr.get_host_name (),
+ this->host_ == 0 ? local_addr.get_host_name ():this->host_,
local_addr.get_port_number ());
the_spec.length (1);
the_spec [0] = CORBA::string_dup (client_address_string);
-
+
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) client flow spec is %s\n",
client_address_string));
@@ -2740,7 +2841,7 @@ Audio_Client_StreamEndPoint::handle_postconnect (AVStreams::flowSpec& server_spe
int
Audio_Client_StreamEndPoint::handle_start (const AVStreams::flowSpec &the_spec,
- CORBA::Environment &env)
+ CORBA::Environment &env)
{
return -1;
@@ -2748,7 +2849,7 @@ Audio_Client_StreamEndPoint::handle_start (const AVStreams::flowSpec &the_spec,
int
Audio_Client_StreamEndPoint::handle_stop (const AVStreams::flowSpec &the_spec,
- CORBA::Environment &env)
+ CORBA::Environment &env)
{
return -1;
@@ -2756,7 +2857,7 @@ Audio_Client_StreamEndPoint::handle_stop (const AVStreams::flowSpec &the_spec,
int
Audio_Client_StreamEndPoint::handle_destroy (const AVStreams::flowSpec &the_spec,
- CORBA::Environment &env)
+ CORBA::Environment &env)
{
return -1;
@@ -2771,14 +2872,10 @@ Audio_Client_StreamEndPoint::get_handle (void)
// -----------------------------------------------------------
// Video_Client_StreamEndPoint methods
-Video_Client_StreamEndPoint::Video_Client_StreamEndPoint (void)
- : command_handler_ (0)
-{
-}
-
-
-Video_Client_StreamEndPoint::Video_Client_StreamEndPoint (Command_Handler *command_handler)
- :command_handler_ (command_handler)
+Video_Client_StreamEndPoint::Video_Client_StreamEndPoint (Command_Handler *command_handler,
+ char *host)
+ :command_handler_ (command_handler),
+ host_ (host)
{
}
@@ -2800,7 +2897,7 @@ Video_Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec)
ACE_DEBUG ((LM_DEBUG,"(%P|%t) handle_preconnect called\n"));
CORBA::UShort server_port;
ACE_INET_Addr local_addr;
-
+
// Get the local UDP address
if (this->dgram_.open (ACE_Addr::sap_any) == -1)
ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t) datagram open failed %p\n"),0);
@@ -2824,15 +2921,15 @@ Video_Client_StreamEndPoint::handle_preconnect (AVStreams::flowSpec &the_spec)
if (this->dgram_.get_local_addr (local_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,"(%P|%t)datagram get local addr failed %p"),-1);
- // form a string
+ // form a string
char client_address_string [BUFSIZ];
::sprintf (client_address_string,
"%s:%d",
- local_addr.get_host_name (),
+ this->host_ == 0 ?local_addr.get_host_name ():this->host_,
local_addr.get_port_number ());
the_spec.length (1);
the_spec [0] = CORBA::string_dup (client_address_string);
-
+
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) client flow spec is %s\n",
client_address_string));
@@ -2859,7 +2956,7 @@ Video_Client_StreamEndPoint::handle_postconnect (AVStreams::flowSpec& server_spe
int
Video_Client_StreamEndPoint::handle_start (const AVStreams::flowSpec &the_spec,
- CORBA::Environment &env)
+ CORBA::Environment &env)
{
return -1;
@@ -2867,7 +2964,7 @@ Video_Client_StreamEndPoint::handle_start (const AVStreams::flowSpec &the_spec,
int
Video_Client_StreamEndPoint::handle_stop (const AVStreams::flowSpec &the_spec,
- CORBA::Environment &env)
+ CORBA::Environment &env)
{
return -1;
@@ -2875,7 +2972,7 @@ Video_Client_StreamEndPoint::handle_stop (const AVStreams::flowSpec &the_spec,
int
Video_Client_StreamEndPoint::handle_destroy (const AVStreams::flowSpec &the_spec,
- CORBA::Environment &env)
+ CORBA::Environment &env)
{
return -1;
@@ -2896,7 +2993,7 @@ Video_Client_VDev::Video_Client_VDev (void)
{
}
-
+
Video_Client_VDev::Video_Client_VDev (Command_Handler *command_handler)
:video_control_ (0),
command_handler_ (command_handler)
@@ -2927,7 +3024,7 @@ Audio_Client_VDev::Audio_Client_VDev (void)
{
}
-
+
Audio_Client_VDev::Audio_Client_VDev (Command_Handler *command_handler)
:audio_control_ (0),
command_handler_ (command_handler)
@@ -2959,22 +3056,30 @@ Video_Endpoint_Reactive_Strategy_A::Video_Endpoint_Reactive_Strategy_A (TAO_ORB_
{
}
+Video_Endpoint_Reactive_Strategy_A::~Video_Endpoint_Reactive_Strategy_A (void)
+{
+ // delete this->vdev_;
+ // delete this->endpoint_;
+}
+
int
Video_Endpoint_Reactive_Strategy_A::make_vdev (Video_Client_VDev *&vdev)
{
- ACE_NEW_RETURN (vdev,
+ ACE_NEW_RETURN (this->vdev_,
Video_Client_VDev (this->command_handler_),
-1);
+ vdev = this->vdev_;
return 0;
}
int
Video_Endpoint_Reactive_Strategy_A::make_stream_endpoint (Video_Client_StreamEndPoint *&endpoint)
{
- ACE_NEW_RETURN (endpoint,
- Video_Client_StreamEndPoint (this->command_handler_),
+ ACE_NEW_RETURN (this->endpoint_,
+ Video_Client_StreamEndPoint (this->command_handler_,
+ this->command_handler_->get_data_host ()),
-1);
-
+ endpoint = this->endpoint_;
return 0;
}
@@ -2988,21 +3093,45 @@ Audio_Endpoint_Reactive_Strategy_A::Audio_Endpoint_Reactive_Strategy_A (TAO_ORB_
{
}
+Audio_Endpoint_Reactive_Strategy_A::~Audio_Endpoint_Reactive_Strategy_A (void)
+{
+ // delete this->vdev_;
+ // delete this->endpoint_;
+}
+
int
Audio_Endpoint_Reactive_Strategy_A::make_vdev (Audio_Client_VDev *&vdev)
{
- ACE_NEW_RETURN (vdev,
+ ACE_NEW_RETURN (this->vdev_,
Audio_Client_VDev (this->command_handler_),
-1);
+ vdev = this->vdev_;
return 0;
}
int
Audio_Endpoint_Reactive_Strategy_A::make_stream_endpoint (Audio_Client_StreamEndPoint *&endpoint)
{
- ACE_NEW_RETURN (endpoint,
- Audio_Client_StreamEndPoint (this->command_handler_),
+ ACE_NEW_RETURN (this->endpoint_,
+ Audio_Client_StreamEndPoint (this->command_handler_,
+ this->command_handler_->get_data_host ()),
-1);
-
+ endpoint = this->endpoint_;
return 0;
}
+
+//--------------------------------------------------------------------------------
+
+Receiver_i::Receiver_i (Command_Handler *handler)
+ :command_handler_ (handler)
+{
+}
+
+void
+Receiver_i::push_audio_mmdevice (CORBA::Object_ptr mmdevice,
+ const char *audio_file,
+ CORBA::Environment&)
+{
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t)Receiver_i::push_audio_mmdevice"));
+ this->command_handler_->set_audio_mmdevice (mmdevice,audio_file);
+}
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.h
index 23e14ad95df..a972440bc29 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Command_Handler.h
@@ -2,22 +2,22 @@
/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology
* P.O.Box 91000-1000, Portland, OR 97291, USA;
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of O.G.I. not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. O.G.I. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of O.G.I. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. O.G.I. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
- *
- * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ *
+ * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Shanwei Cen
@@ -30,7 +30,7 @@
//
// = LIBRARY
// mpeg_client
-//
+//
// = FILENAME
// Command_Handler.h
//
@@ -41,7 +41,7 @@
// = AUTHORS
// Sumedh Mungee (sumedh@cs.wustl.edu)
// Nagarajan Surendran (naga@cs.wustl.edu)
-//
+//
// ============================================================================
@@ -61,20 +61,26 @@
#include "ace/High_Res_Timer.h"
#include "ace/Acceptor.h"
#include "orbsvcs/Naming/Naming_Utils.h"
-
+#include "mpeg_shared/ReceiverS.h"
class Command_Handler;
-class Gui_Acceptor
-:public ACE_Acceptor <Command_Handler, ACE_SOCK_ACCEPTOR>
+
+class Receiver_i
+ :public POA_Receiver
{
-public:
- Gui_Acceptor (Command_Handler *);
+ public:
+ Receiver_i (Command_Handler *handler);
+ // constructor.
- virtual int make_svc_handler (Command_Handler *&sh);
-private:
+ void push_audio_mmdevice (CORBA::Object_ptr mmdevice,
+ const char* audio_file,
+ CORBA::Environment&);
+
+ private:
Command_Handler *command_handler_;
+ // Reference to command handler.
};
class Video_Client_StreamEndPoint
@@ -86,9 +92,8 @@ class Video_Client_StreamEndPoint
// Makes use of a connected dgram to receive data from the server
// side stream endpoint.
public:
- Video_Client_StreamEndPoint (void);
-
- Video_Client_StreamEndPoint (Command_Handler *command_handler);
+ Video_Client_StreamEndPoint (Command_Handler *command_handler =0,
+ char *host =0);
// constructor
virtual int handle_open (void);
@@ -102,23 +107,28 @@ public:
virtual CORBA::Boolean handle_postconnect (AVStreams::flowSpec &the_spec);
// called after connecting
-
- virtual int handle_start (const AVStreams::flowSpec &the_spec,
+
+ 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,
+
+ virtual int handle_destroy (const AVStreams::flowSpec &the_spec,
CORBA::Environment &env);
-
+
virtual ACE_HANDLE get_handle (void);
// gets the underlying socket descriptor from the SOCK_Dgram
private:
ACE_SOCK_Dgram dgram_;
// The datagram used for streaming.
+
Command_Handler *command_handler_;
+ // Reference to the command handler
+
+ char *host_;
+ // host interface to bind to.
};
class Audio_Client_StreamEndPoint
@@ -129,9 +139,8 @@ class Audio_Client_StreamEndPoint
// = DESCRIPTION
// Uses a connected dgram to receive data from the audio server.
public:
- Audio_Client_StreamEndPoint (void);
-
- Audio_Client_StreamEndPoint (Command_Handler *command_handler);
+ Audio_Client_StreamEndPoint (Command_Handler *command_handler = 0,
+ char *host = 0);
// constructor
virtual int handle_open (void);
@@ -145,23 +154,28 @@ public:
virtual CORBA::Boolean handle_postconnect (AVStreams::flowSpec &the_spec);
// called after connecting
-
- virtual int handle_start (const AVStreams::flowSpec &the_spec,
+
+ 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,
+
+ virtual int handle_destroy (const AVStreams::flowSpec &the_spec,
CORBA::Environment &env);
-
+
virtual ACE_HANDLE get_handle (void);
// gets the underlying socket descriptor from the SOCK_Dgram
private:
ACE_SOCK_Dgram dgram_;
// The datagram used for streaming.
+
Command_Handler *command_handler_;
+ // Reference to the command handler.
+
+ char *host_;
+ // host interface to bind to.
};
@@ -214,8 +228,8 @@ private:
// pointer to the command handler object
};
-class Video_Endpoint_Reactive_Strategy_A
- : public TAO_AV_Endpoint_Reactive_Strategy_A<Video_Client_StreamEndPoint,Video_Client_VDev,AV_Null_MediaCtrl>
+class Video_Endpoint_Reactive_Strategy_A
+ : public TAO_AV_Endpoint_Reactive_Strategy_A<Video_Client_StreamEndPoint,Video_Client_VDev,AV_Null_MediaCtrl>
{
// = TITLE
// Implementation of the Reactive Strategy for the client
@@ -229,6 +243,9 @@ public:
Command_Handler *command_handler);
// constructor . The orb manager is needed for the TAO_AV_Endpoint_Reactive_Strategy_A.
+ virtual ~Video_Endpoint_Reactive_Strategy_A (void);
+ // destructor.
+
virtual int make_vdev (Video_Client_VDev *&vdev);
// hook to make our Vdev with the pointer to command handler.
virtual int make_stream_endpoint (Video_Client_StreamEndPoint *& endpoint);
@@ -237,10 +254,15 @@ private:
Command_Handler *command_handler_;
// pointer to command handler object
+ Video_Client_VDev *vdev_;
+ // reference to the created vdev .
+
+ Video_Client_StreamEndPoint *endpoint_;
+ // reference to the created streamendpoint.
};
-class Audio_Endpoint_Reactive_Strategy_A
- : public TAO_AV_Endpoint_Reactive_Strategy_A<Audio_Client_StreamEndPoint,Audio_Client_VDev,AV_Null_MediaCtrl>
+class Audio_Endpoint_Reactive_Strategy_A
+ : public TAO_AV_Endpoint_Reactive_Strategy_A<Audio_Client_StreamEndPoint,Audio_Client_VDev,AV_Null_MediaCtrl>
{
// = TITLE
// Implementation of the Reactive Strategy for the client audio
@@ -254,19 +276,92 @@ public:
Command_Handler *command_handler);
// constructor . The orb manager is needed for the TAO_AV_Endpoint_Reactive_Strategy_A.
+ ~Audio_Endpoint_Reactive_Strategy_A (void);
+ // Destructor.
+
virtual int make_vdev (Audio_Client_VDev *&vdev);
// hook to make our Vdev with the pointer to command handler.
+
virtual int make_stream_endpoint (Audio_Client_StreamEndPoint *& endpoint);
// hook to make our streamendpoint taking a command handler pointer
+
private:
Command_Handler *command_handler_;
// pointer to command handler object
+ Audio_Client_VDev *vdev_;
+ // reference to the vdev that was created.
+
+ Audio_Client_StreamEndPoint *endpoint_;
+ //reference to the created streamendpoint.
+
};
-
-class Command_Handler
- : public virtual ACE_Event_Handler,
- public virtual ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
+
+class Client_Sig_Handler
+ : public virtual ACE_Event_Handler
+ // = TITLE
+ // Defines the signal handler class for the client timer processing
+ //
+ // = DESCRIPTION
+ // Checks if the video is ready and refreshes the display and
+ // also plays the audio packets in the timer processing.
+{
+public:
+ Client_Sig_Handler (Command_Handler *command_handler);
+ // We need the command handler to call close ()
+
+ ~Client_Sig_Handler (void);
+ // Destructor
+
+ virtual ACE_HANDLE get_handle (void) const;
+
+ int register_handler (void);
+ // this will register this sig_handler
+ // with the reactor for SIGCHLD,SIGTERM,SIGINT
+
+ virtual int shutdown (ACE_HANDLE,
+ ACE_Reactor_Mask);
+ // handles the reactor shutdown
+
+ virtual int handle_input (ACE_HANDLE);
+ // handle input on the dummy handle.
+
+ virtual int handle_signal (ACE_HANDLE signum,
+ siginfo_t * = 0,
+ ucontext_t* = 0);
+ // handles SIGALRM
+
+ void TimerHandler (int signum);
+
+ void stop_timer (void);
+
+ void DisplayPicture (void);
+ // display the picture.
+
+ void TimerProcessing (void);
+
+ void PlayAudioOnly (void);
+
+private:
+ ACE_HANDLE handle_;
+ // dummy handle for the sig handler.
+
+ ACE_Sig_Set sig_set;
+ // the signal set
+
+ Command_Handler *command_handler_;
+ // We need the command handler to call close ()
+
+};
+
+enum Suspended
+{
+ UNSUSPENDED = 0,INIT=1,STEP=2,POSITION=3
+};
+
+class Command_Handler
+ : public virtual ACE_Event_Handler
+ // public virtual ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
{
// = TITLE
// Defines the event handler class for the client commands
@@ -277,10 +372,16 @@ class Command_Handler
public:
- Command_Handler (void);
- // Default constructor
+ int command_suspended_;
+ // flag to indicate whether the GUI handler has been suspended.
- Command_Handler (ACE_HANDLE command_handle);
+ int operation_tag_;
+ // operation tag for release/press for position.
+
+ int position_val_;
+ // value of the position button.
+
+ Command_Handler (ACE_HANDLE command_handle = ACE_INVALID_HANDLE);
// Construct this handler with a control (UNIX) handle
~Command_Handler (void);
@@ -292,20 +393,22 @@ public:
int run (void);
// Run the ORB event loop
- virtual int open (void *);
- // Perform the work of the SVC_HANDLER. Called by the acceptor
- // when a new connection shows up
+ int handle_timeout (const ACE_Time_Value &,
+ const void *arg);
+ // handle the timeout
+ // void stop_timer (void);
+ // stop the internal timer
- virtual int close (u_long);
- // Called if ACE_Svc_Handler is closed down unexpectedly.
+ void wait_for_display (Suspended reason);
+ // suspends the gui socket handler in the reactor.
- int handle_timeout (const ACE_Time_Value &,
- const void *arg);
- // handle the timeout
+ TAO_ORB_Manager *orb_manager (void);
+ // returns the orbmanager reference
- void stop_timer (void);
- // stop the internal timer
+ void set_audio_mmdevice (CORBA::Object_ptr audio_mmdevice,
+ const char *audio_file);
+ // sets the audio mmdevice object ptr.
void set_video_data_handle (ACE_HANDLE data_fd);
// sets the data handle (UDP) of the command handler
@@ -323,6 +426,9 @@ public:
// Gets the video control reference thru the property service from
// the video server virtual device
+ char *get_data_host (void);
+ // gets the data interface to be used.
+
int resolve_video_reference (void);
// Resolve the video control reference.
@@ -334,42 +440,45 @@ public:
virtual ACE_HANDLE get_handle (void) const;
// Returns the handle used by the event_handler.
-
+
int init_av (void);
// Initialize both the audio and video
-
- int init_java_av (ACE_HANDLE fd);
+
+ int init_java_av (char *audio_ior,
+ char *video_ior,
+ char *audio_file,
+ char *video_file);
// initialize both the audio and video reading the iors from java GUI thru a socket.
- int init_video_channel (char *phostname,char *videofile);
+ int init_video_channel (char *videofile);
// Initializes the video channel by bind the client and server video
// mmdevices together and gets the video control object.
- int init_audio_channel (char *phostname,char *videofile);
+ int init_audio_channel (char *videofile);
// Initializes the audio channel by bind the client and server audio
// mmdevices together and gets the video control object.
int stat_stream (CORBA::Char_out ch,CORBA::Long_out size) ;
- // statistics of this stream.
+ // statistics of this stream.
int close (void) ;
// close the audio and video connections
int stat_sent (void) ;
-
+
int fast_forward (void);
int fast_backward (void);
-
+
int step (void);
-
+
int play (int flag,
- CORBA::Environment& env);
-
+ CORBA::Environment& env);
+
int position_action (int operation_tag);
int position (void);
-
+
int position_release (void);
int volume (void);
@@ -377,34 +486,33 @@ public:
int balance (void);
int speed (void);
-
+
int stop (void);
int stop_playing (void);
- int connect_to_video_server (char *address,
- int *ctr_fd,
- int *data_fd,
- int *max_pkt_size);
+ int connect_to_video_server (void);
// resolves the server video mmdevice and binds the local and server
// mmdevices together.
- int connect_to_audio_server (char *address,
- int *ctr_fd,
- int *data_fd,
- int *max_pkt_size);
+ int connect_to_audio_server (void);
// resolves the server video mmdevice and binds the local and server
// mmdevices together.
private:
+
+ int parse_args (int argc,char **argv);
+ // parses the arguments.
+
int busy_;
// flag to indicate the state of the command handler
- char *audio_mmdevice_ior_;
+ CORBA::String_var audio_mmdevice_ior_;
+ CORBA::String_var video_mmdevice_ior_;
ACE_SOCK_Dgram video_dgram_;
// UDP socket on which to send/recv data
-
+
ACE_SOCK_Dgram audio_dgram_;
// Audio UDP socket
@@ -422,21 +530,21 @@ private:
TAO_Naming_Client my_name_client_;
// A Name_Client used to resolve the video_server_mmdevice
-
+
Video_Control_ptr video_control_;
// Video Control CORBA object
AVStreams::MMDevice_var video_server_mmdevice_;
// The video server multimedia device
- Video_Endpoint_Reactive_Strategy_A video_reactive_strategy_;
+ Video_Endpoint_Reactive_Strategy_A *video_reactive_strategy_;
// Strategy for creating stream endpoints
- TAO_MMDevice video_client_mmdevice_;
+ TAO_MMDevice *video_client_mmdevice_;
// The video client multimedia device
- TAO_StreamCtrl video_streamctrl_;
- // Video stream controller
+ TAO_StreamCtrl *video_streamctrl_;
+ // Video stream controller
Audio_Control_ptr audio_control_;
// Audio Control CORBA object
@@ -444,77 +552,32 @@ private:
AVStreams::MMDevice_var audio_server_mmdevice_;
// The audio server multimedia device
- Audio_Endpoint_Reactive_Strategy_A audio_reactive_strategy_;
+ Audio_Endpoint_Reactive_Strategy_A *audio_reactive_strategy_;
// Strategy for creating stream endpoints
- TAO_MMDevice audio_client_mmdevice_;
+ TAO_MMDevice *audio_client_mmdevice_;
// The audio client multimedia device
- TAO_StreamCtrl audio_streamctrl_;
+ TAO_StreamCtrl *audio_streamctrl_;
// audio stream controller
- ACE_High_Res_Timer timer_;
+ // ACE_High_Res_Timer timer_;
// timer to record the time taken for the play sequence.
- Gui_Acceptor acceptor_;
-};
-
-
-class Client_Sig_Handler
- : public virtual ACE_Event_Handler
- // = TITLE
- // Defines the signal handler class for the client timer processing
- //
- // = DESCRIPTION
- // Checks if the video is ready and refreshes the display and
- // also plays the audio packets in the timer processing.
-{
-public:
- Client_Sig_Handler (Command_Handler *command_handler);
- // We need the command handler to call close ()
-
- ~Client_Sig_Handler (void);
- // Destructor
-
- virtual ACE_HANDLE get_handle (void) const;
-
- int register_handler (void);
- // this will register this sig_handler
- // with the reactor for SIGCHLD,SIGTERM,SIGINT
-
- virtual int shutdown (ACE_HANDLE,
- ACE_Reactor_Mask);
- // handles the reactor shutdown
-
- virtual int handle_input (ACE_HANDLE);
- // handle input on the dummy handle.
-
- virtual int handle_signal (ACE_HANDLE signum,
- siginfo_t * = 0,
- ucontext_t* = 0);
- // handles SIGALRM
-
- void TimerHandler (int signum);
-
- void stop_timer (void);
-
- void DisplayPicture (void);
- // display the picture.
-
- void TimerProcessing (void);
+ Receiver_i receiver_;
+ // Receive object,called by the agent to give the mmdevice object
+ // reference.
- void PlayAudioOnly (void);
+ char *data_host_;
+ // interface name to bind to for data transfer.
-private:
- ACE_HANDLE handle_;
- // dummy handle for the sig handler.
+ Client_Sig_Handler client_sig_handler_;
+ // Handler for the signals.
- ACE_Sig_Set sig_set;
- // the signal set
+ int argc_;
+ char **argv_;
+};
- Command_Handler *command_handler_;
- // We need the command handler to call close ()
-};
#endif /* AV_COMMAND_HANDLER_H */
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp
index af4b88884b3..7cbccea9cc1 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp
@@ -1,3 +1,4 @@
+
/* $Id$ */
/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology
@@ -176,7 +177,7 @@ static void exit_on_kill(void)
ACE_DEBUG ((LM_DEBUG,"(%P|%t) ABprocess killed \n"));
extern void set_exit_routine_tag(int tag);
set_exit_routine_tag(0);
- ComCloseConn(savedSocket);
+ // ComCloseConn(savedSocket);
VBdeleteBuf();
exit(0);
}
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp
index cc347311657..e6c168ecac9 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp
@@ -2,22 +2,22 @@
/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology
* P.O.Box 91000-1000, Portland, OR 97291, USA;
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of O.G.I. not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. O.G.I. makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of O.G.I. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. O.G.I. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
- *
- * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
- * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ *
+ * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+ * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Shanwei Cen
@@ -64,6 +64,7 @@ ACE_RCSID(mpeg_client, ctr, "$Id$")
static int usr1_flag = 0;
static int rtplay = 1;
static int cmdSocket = -1;
+static int writeSocket = -1;
static int javaSocket = -1;
static int CTRpid = -1, VBpid = -1, VDpid = -1, UIpid = -1;
static int ABpid = -1;
@@ -145,32 +146,6 @@ OurCmdRead(char *buf, int size)
return 0;
}
-int
-javaCmdRead(char *buf, int size)
-{
- int val;
- if (size == 0) return 0;
- if (cmdBytes > 0)
- {
- memcpy(buf, cmdBuffer, size);
- cmdBytes -= size;
- cmdBuffer += size;
- return 0;
- }
- while ((val = read(javaSocket, (buf), (size))) <= 0)
- {
- if (val == -1 && errno == EINTR) return 1;
- if (!val) {
- perror("CTR error, EOF reached unexpected within CmdRead()");
- }
- else {
- perror("CTR CmdRead() from UI through CmdSocket");
- }
- exit(1);
- }
- return 0;
-}
-
void CmdRead(char *buf, int size)
{
int val;
@@ -201,9 +176,9 @@ static int CmdReadNW(char *buf, int size)
struct fd_set read_mask;
int nfds = cmdSocket+1;
int val;
-
+
if (size == 0) return 0;
-
+
if (cmdBytes > 0)
{
memcpy(buf, cmdBuffer, size);
@@ -211,7 +186,7 @@ static int CmdReadNW(char *buf, int size)
cmdBuffer += size;
return 0;
}
-
+
FD_ZERO(&read_mask);
FD_SET(cmdSocket, &read_mask);
#ifdef _HPUX_SOURCE
@@ -229,7 +204,7 @@ static int CmdReadNW(char *buf, int size)
{
if (errno == EINTR)
return -1;
-
+
perror("CTR CmdReadNW by read");
exit(1);
}
@@ -248,8 +223,8 @@ static void CmdWrite(unsigned char * buf, int size)
cmdAcks --;
return;
}
-
- while (write(cmdSocket, buf, size) == -1)
+
+ while (ACE_OS::write(cmdSocket, buf, size) == -1)
{
if (errno == EINTR)
continue;
@@ -268,9 +243,9 @@ static void SocketRead(int s, char *buf, int size)
for (;;)
{
val = read(s, ptr, remain);
-
+
// fprintf(stderr, "CTR got from %sSocket %d of %d.\n",s == videoSocket ? "video" : "audio", val, remain);
-
+
if (val == -1 && errno == EINTR)
{
errno = 0;
@@ -373,457 +348,6 @@ static void timer_speed(void);
static void wait_display(void);
static void stop_playing();
-static int InitVideoChannel(char * phostname, char * vf)
-{
- int dataSocket = -1;
-
- if (ComOpenConnPair(phostname, &videoSocket,
- &dataSocket, &shared->videoMaxPktSize) == -1) {
- return -1;
- }
-
- /* Initialize with VS */
- {
- INITvideoPara para;
- INITvideoReply reply;
- unsigned char tmp;
- tmp = CmdINITvideo;
- VideoWrite(&tmp, 1);
-
- para.sn = htonl(shared->cmdsn);
- para.version = htonl(VERSION);
- para.nameLength = htonl(strlen(vf)+1);
-
- VideoWrite(&para, sizeof(para));
- VideoWrite(vf, strlen(vf)+1);
- /*
- fprintf(stderr, "InitCommand to VSwritten.\n");
- */
- /*
- VideoRead((char*)&tmp, 1);
- */
- errno = 0;
- if (read(videoSocket, (char*)&tmp, 1) <= 0) {
- if (errno) {
- perror("CTR error read first byte from videoSocket");
- }
- else {
- fprintf(stderr, "CTR error: videoSocket closed by VS.\n");
- }
- ComCloseConn(dataSocket);
- ComCloseConn(videoSocket);
- videoSocket = -1;
- return -1;
- }
- if (tmp == CmdFAIL)
- {
- char errmsg[128];
- read_string(videoSocket, errmsg, 128);
- fprintf(stderr, "CTR failed to connect to VS: %s.\n", errmsg);
- ComCloseConn(dataSocket);
- ComCloseConn(videoSocket);
- videoSocket = -1;
- return -1;
- }
- else
- {
- VideoRead((char*)&reply, sizeof(reply));
-#ifdef NeedByteOrderConversion
- reply.live = ntohl(reply.live);
- reply.format = ntohl(reply.format);
- reply.totalHeaders = ntohl(reply.totalHeaders);
- reply.totalGroups = ntohl(reply.totalGroups);
- reply.totalFrames = ntohl(reply.totalFrames);
- reply.horizontalSize = ntohl(reply.horizontalSize);
- reply.verticalSize = ntohl(reply.verticalSize);
- reply.pelAspectRatio = ntohl(reply.pelAspectRatio);
- reply.pictureRate1000 = ntohl(reply.pictureRate1000);
- reply.vbvBufferSize = ntohl(reply.vbvBufferSize);
- reply.sizeIFrame = ntohl(reply.sizeIFrame);
- reply.sizePFrame = ntohl(reply.sizePFrame);
- reply.sizeBFrame = ntohl(reply.sizeBFrame);
- reply.sizeSystemHeader = ntohl(reply.sizeSystemHeader);
- reply.sizeGop = ntohl(reply.sizeGop);
- reply.averageFrameSize = ntohl(reply.averageFrameSize);
- reply.firstGopFrames = ntohl(reply.firstGopFrames);
- reply.patternSize = ntohl(reply.patternSize);
-#endif
- shared->live += reply.live;
- shared->videoFormat = reply.format;
- shared->totalHeaders = reply.totalHeaders;
- shared->totalFrames = reply.totalFrames;
- shared->totalGroups = reply.totalGroups;
- shared->averageFrameSize = reply.averageFrameSize;
- shared->horizontalSize = reply.horizontalSize;
- shared->verticalSize = reply.verticalSize;
- shared->pelAspectRatio = reply.pelAspectRatio;
- shared->pictureRate = ((double)reply.pictureRate1000) / 1000.0;
- shared->vbvBufferSize = reply.vbvBufferSize;
- shared->firstGopFrames = reply.firstGopFrames;
- shared->patternSize = strlen(reply.pattern);
- if (shared->patternSize == 0) {
-
- Fprintf(stderr, "CTR warning: patternsize %d\n", shared->patternSize);
-
- shared->patternSize = 1;
- shared->pattern[0] = 'I';
- shared->pattern[1] = 0;
- shared->IframeGap = 1;
- }
- else if (shared->patternSize < PATTERN_SIZE)
- {
- int i;
- char * ptr = shared->pattern + shared->patternSize;
- strncpy(shared->pattern, reply.pattern, shared->patternSize);
- for (i = 1; i < PATTERN_SIZE / shared->patternSize; i ++) {
- memcpy(ptr, shared->pattern, shared->patternSize);
- ptr += shared->patternSize;
- }
- shared->IframeGap = 1;
- while (shared->IframeGap < shared->patternSize)
- {
- if (shared->pattern[shared->IframeGap] == 'I')
- break;
- else
- shared->IframeGap ++;
- }
- }
- else
- {
- fprintf(stderr, "CTR Error: patternSize %d greater than PATTERN_SIZE %d.\n",
- shared->patternSize, PATTERN_SIZE);
- exit(1);
- }
- fprintf(stderr, "Video: %s, %s\n",
- shared->videoFormat == VIDEO_SIF ? "SIF" :
- shared->videoFormat == VIDEO_JPEG ? "JPEG" :
- shared->videoFormat == VIDEO_MPEG1 ? "MPEG1" :
- shared->videoFormat == VIDEO_MPEG2 ? "MPEG2" : "UNKOWN format",
- reply.live ? "live source" : "stored source");
-
- fprintf(stderr, "Video: numS-%d, numG-%d, numF-%d, aveFrameSize-%d\n",
- reply.totalHeaders, reply.totalGroups, reply.totalFrames,
- reply.averageFrameSize);
- fprintf(stderr, "Video: maxS-%d, maxG-%d, maxI-%d, maxP-%d, maxB-%d\n",
- reply.sizeSystemHeader, reply.sizeGop,
- reply.sizeIFrame, reply.sizePFrame, reply.sizeBFrame);
- fprintf(stderr,
- "Video: SHinfo: hsize-%d, vsize-%d, pelAspect-%d, rate-%f, vbv-%d.\n",
- reply.horizontalSize, reply.verticalSize, reply.pelAspectRatio,
- shared->pictureRate, reply.vbvBufferSize);
- shared->pattern[shared->patternSize] = 0;
- fprintf(stderr, "Video: firstGopFrames %d, pattern: %s, IframeGap %d\n",
- reply.firstGopFrames, reply.pattern, shared->IframeGap);
- shared->pattern[shared->patternSize] = 'I';
- if (reply.totalFrames > MAX_FRAMES && (!shared->live))
- {
- fprintf(stderr,
- "Error: totalFrames %d > MAX_FRAMES %d, needs change and recompile.\n",
- reply.totalFrames, MAX_FRAMES);
- ComCloseConn(dataSocket);
- ComCloseConn(videoSocket);
- videoSocket = -1;
- return -1;
- }
-
- }
-
- /* create VB, and put INIT frame to VB*/
- {
- int sp[2]; /* sp[0] is for CTR and sp[1] is for VB */
-
- /* create command socket pair for sending INIT frame to VB, the pipe
- should be discard/non-discard in consistent with videoSocket*/
- if (socketpair(AF_UNIX,
- shared->videoMaxPktSize >= 0 ? SOCK_STREAM :
- SOCK_DGRAM, 0, sp) == -1)
- {
- perror("CTR error on open CTR-VB socketpair");
- exit(1);
- }
-
- switch (VBpid = fork())
- {
- case -1:
- perror("CTR error on forking VB process");
- exit(1);
- break;
- case 0:
- if (realTimeFlag) {
- SetRTpriority("VB", -1);
- }
- free(vh);
- free(vf);
- free(ah);
- free(af);
- close(sp[0]);
- ComCloseFd(videoSocket);
- if (audioSocket >= 0)
- ComCloseFd(audioSocket);
- ABdeleteBuf();
- VDdeleteBuf();
- if (cmdSocket >= 0)
- close(cmdSocket);
- if (realTimeFlag >= 2) {
-#ifdef __svr4__
- if (SetRTpriority("VB", 0)) realTimeFlag = 0;
-#elif defined(_HPUX_SOURCE)
- if (SetRTpriority("VB", 1)) realTimeFlag = 0;
-#endif
- }
- VBprocess(sp[1], dataSocket);
- break;
- default:
- close(sp[1]);
- ComCloseFd(dataSocket);
- {
- int bytes, res;
- /* passing all messages of INIT frame to VB here. */
- char * buf = (char *)malloc(INET_SOCKET_BUFFER_SIZE);
- VideoMessage *msg = (VideoMessage *)buf;
- int pkts = 1, msgo = 0, msgs = 0;
-
- if (buf == NULL) {
- perror("CTR error on malloc() for INIT frame");
- exit(1);
- }
- while (msgo + msgs < pkts) {
- VideoRead(buf, sizeof(*msg));
- pkts = ntohl(msg->packetSize);
- msgo = ntohl(msg->msgOffset);
- msgs = ntohl(msg->msgSize);
- if (shared->videoMaxPktSize >= 0) { /* non-discard mode */
- write_bytes(sp[0], buf, sizeof(*msg));
- bytes = msgs;
- while (bytes > 0) {
- int size = min(bytes, INET_SOCKET_BUFFER_SIZE);
- VideoRead(buf, size);
- write_bytes(sp[0], buf, size);
- bytes -= size;
- }
- }
- else {
- VideoRead(buf + sizeof(*msg), msgs);
- bytes = sizeof(*msg) + msgs;
- while ((res = write(sp[0], buf, bytes)) == -1) {
- if (errno == EINTR || errno == ENOBUFS) continue;
- perror("CTR error on sending INIT frame to VB");
- exit(1);
- }
- if (res < bytes) {
- fprintf(stderr, "CTR warn: send() res %dB < bytes %dB\n", res, bytes);
- }
- /*
- Fprintf(stderr,
- "CTR transferred INIT frame to VB: pkts %d, msgo %d, msgs %d\n",
- pkts, msgo, msgs);
- */
- }
- }
- read(sp[0], buf, 1); /* read a garbage byte, to sync with VB */
- close(sp[0]);
- free(buf);
- }
- break;
- }
- }
- }
-#ifdef STAT
- if (shared->config.collectFrameInfo && (!shared->live))
- {
- int i;
- int count = 0;
- char ch;
- char buf[100];
- FILE *fp;
-
- for (;;)
- {
- sprintf(buf, "struct.%d", count++);
- if (access(buf, 0))
- break;
- if (count > 10000)
- {
- fprintf(stderr, "CTR generating struct file, weired thing happened.\n");
- exit(1);
- }
- }
- fprintf(stderr, "MPEG info collected to %s. . .", buf);
- fp = fopen(buf, "w");
- if (fp == NULL)
- {
- fprintf(stderr, "CTR failed to open %s for write.\n", buf);
- perror("");
- exit(1);
- }
- {
- time_t val = time(NULL);
- get_hostname(buf, 100);
- buf[99] = 0;
- fprintf(fp, "ClientHost: %s\n", buf);
- fprintf(fp, "Date: %s\n", ctime(&val));
- }
- fprintf(fp, "VideoHost: %s\nVideoFile: %s\n", vh, vf);
- fprintf(fp, "AudioHost: %s\nAudioFile: %s\n\n", ah, af);
- fprintf(fp, "TotalFrames: %d\nTotalGroups: %d\n",
- shared->totalFrames, shared->totalGroups);
- fprintf(fp, "TotalHeaders: %d\n", shared->totalHeaders);
- fprintf(fp, "PictureRate: %f\nPictureSize: %d x %d\n",
- shared->pictureRate, shared->horizontalSize, shared->verticalSize);
- fprintf(fp, "AverageFrameSize: %d\n", shared->averageFrameSize);
- shared->pattern[shared->patternSize] = 0;
- fprintf(fp, "Pattern(%d frames): %s\n\n", shared->patternSize, shared->pattern);
- shared->pattern[shared->patternSize] = 'I';
- {
- fprintf(fp, "FrameInfo:\n ");
- for (i = 0; i < 10; i++)
- fprintf(fp, " %-6d", i);
- fprintf(fp, "\n ----------------------------------------------------");
- ch = CmdSTATstream;
- VideoWrite(&ch, 1);
- for (i = 0; i < shared->totalFrames; i++)
- {
- short size;
- VideoRead(&ch, 1);
- VideoRead((char*)&size, 2);
- size = ntohs(size);
- if (i % 10 == 0)
- fprintf(fp, "\n%4d: ", i / 10);
- fprintf(fp, "%c%-6d", ch, (int)size);
- }
- }
- }
-#endif
- return 0;
-}
-
-static int InitAudioChannel(char * phostname, char * af)
-{
- // ACE_DEBUG ((LM_DEBUG,"(%P|%t) InitAudioChannel called\n"));
- int dataSocket = -1;
-
- if (!hasAudioDevice)
- {
- fprintf(stderr, "CTR warning: Audio device not available, Audio ignored.\n");
- return -1;
- }
-
- if (ComOpenConnPair(phostname, &audioSocket,
- &dataSocket, &shared->audioMaxPktSize) == -1) {
- return -1;
- }
-
- /* Initialize with AS */
- {
- INITaudioPara para;
- INITaudioReply reply;
- unsigned char tmp;
- // tmp = CmdINITaudio;
- // AudioWrite(&tmp, 1);
- para.sn = htonl(shared->cmdsn);
- para.version = htonl(VERSION);
- para.para.encodeType = htonl(shared->AFPara.encodeType);
- para.para.channels = htonl(shared->AFPara.channels);
- para.para.samplesPerSecond = htonl(shared->AFPara.samplesPerSecond);
- para.para.bytesPerSample = htonl(shared->AFPara.bytesPerSample);
- para.nameLength = htonl(strlen(af)+1);
- /*
- fprintf(stderr, "AF Audio para: encode %d, ch %d, sps %d, bps %d.\n",
- para.para.encodeType, para.para.channels,
- para.para.samplesPerSecond, para.para.bytesPerSample);
- */
- AudioWrite(&para, sizeof(para));
- AudioWrite(af, strlen(af)+1);
- /*
- fprintf(stderr, "CTR: InitCommand to AS written.\n");
- */
- /*
- AudioRead((char*)&tmp, 1);
- */
- errno = 0;
- if (read(audioSocket, (char*)&tmp, 1) <= 0) {
- if (errno) {
- perror("CTR error read first byte from audioSocket");
- }
- else {
- fprintf(stderr, "CTR error: audioSocket closed by AS.\n");
- }
- ComCloseConn(audioSocket);
- ComCloseConn(dataSocket);
- videoSocket = -1;
- return -1;
- }
- if (tmp == CmdFAIL)
- {
- char errmsg[128];
- read_string(audioSocket, errmsg, 128);
- fprintf(stderr, "CTR failed to connect to AS: %s\n", errmsg);
- ComCloseConn(audioSocket);
- ComCloseConn(dataSocket);
- audioSocket = -1;
- return -1;
- }
- else
- {
- int flag = 1;
- AudioRead((char*)&reply, sizeof(reply));
- shared->live += ntohl(reply.live);
- shared->audioFormat = ntohl(reply.format);
- shared->audioPara.encodeType = ntohl(reply.para.encodeType);
- shared->audioPara.channels = ntohl(reply.para.channels);
- shared->audioPara.samplesPerSecond = ntohl(reply.para.samplesPerSecond);
- shared->audioPara.bytesPerSample = ntohl(reply.para.bytesPerSample);
- shared->totalSamples = ntohl(reply.totalSamples);
-
- fprintf(stderr, "Audio: samples %d, sps %d, bps %d\n",
- shared->totalSamples, shared->AFPara.samplesPerSecond,
- shared->AFPara.bytesPerSample);
-
- SetAudioParameter(&shared->audioPara);
- }
-
- /* create AB */
- {
- switch (ABpid = fork())
- {
- case -1:
- perror("CTR error on forking AB process");
- exit(1);
- break;
- case 0:
- if (realTimeFlag) {
- SetRTpriority("AB", -1);
- }
- free(vh);
- free(vf);
- free(ah);
- free(af);
- ComCloseFd(audioSocket);
- if (videoSocket >= 0)
- ComCloseFd(videoSocket);
- VBdeleteBuf();
- VDdeleteBuf();
- if (cmdSocket >= 0)
- close(cmdSocket);
- if (realTimeFlag >= 2) {
-#ifdef __svr4__
- if (SetRTpriority("AB", 0)) realTimeFlag = 0;
-#elif defined(_HPUX_SOURCE)
- if (SetRTpriority("AB", 1)) realTimeFlag = 0;
-#endif
- }
- ABprocess(dataSocket);
- break;
- default:
- ComCloseFd(dataSocket);
- ABflushBuf(0);
- break;
- }
- }
- }
- return 0;
-}
-
static void set_speed(void)
{
int val;
@@ -898,870 +422,14 @@ static void set_speed(void)
}
}
-static void init()
-{
- int i, j;
-
- /* try to stop and close previous playing */
- if (audioSocket >= 0 || videoSocket >= 0)
- {
- unsigned char tmp = CmdCLOSE;
- stop_playing();
-
- if (audioSocket >= 0)
- {
- if (ABpid > 0) {
- kill(ABpid, SIGUSR1);
- ABpid = -1;
- }
- usleep(10000);
- AudioWrite(&tmp, 1);
- ComCloseConn(audioSocket);
- audioSocket = -1;
- }
-
- if (videoSocket >= 0)
- {
- if (VBpid > 0) {
- kill(VBpid, SIGUSR1);
- VBpid = -1;
- }
- usleep(10000);
- VideoWrite(&tmp, 1);
- ComCloseConn(videoSocket);
- videoSocket = -1;
- while ((!VBbufEmpty()) || !VDbufEmpty()) {
- while (VDpeekMsg() != NULL) {
- VDreclaimMsg(VDgetMsg());
- }
- usleep(10000);
- }
- usleep(10000);
- }
- }
-
- /* read in video/audio files */
- NewCmd(CmdINIT);
- CmdRead((char*)&i, 4);
- CmdRead(vh, i);
- vh[i] = 0;
- CmdRead((char*)&i, 4);
- CmdRead(vf, i);
- vf[i] = 0;
- CmdRead((char*)&i, 4);
- CmdRead(ah, i);
- ah[i] = 0;
- CmdRead((char*)&i, 4);
- CmdRead(af, i);
- af[i] = 0;
- /*
- fprintf(stderr, "INIT: vh-%s, vf-%s, ah-%s, af-%s\n", vh, vf, ah, af);
- */
-
- shared->live = 0;
- shared->audioMaxPktSize = !shared->config.audioConn;
- shared->videoMaxPktSize = !shared->config.videoConn;
-
- if (af[0] != 0)
- {
- if (InitAudioChannel(ah, af))
- {
- audioSocket = -1;
- shared->totalSamples = 0;
- }
- else
- {
- shared->nextSample = 0;
- if (shared->config.maxSPS < shared->audioPara.samplesPerSecond)
- shared->config.maxSPS < shared->audioPara.samplesPerSecond;
- }
- }
- else
- {
- shared->totalSamples = 0;
- audioSocket = -1;
- }
- if (vf[0] != 0)
- {
- if (InitVideoChannel(vh, vf))
- {
- shared->totalFrames = 0; /* disable video channel */
- videoSocket = -1;
- }
- else
- {
- shared->nextFrame = 1;
- shared->nextGroup = 0;
- shared->currentFrame = shared->currentGroup = shared->currentDisplay = 0;
- if (shared->config.maxFPS < shared->framesPerSecond)
- shared->config.maxFPS = shared->framesPerSecond;
- }
- }
- else
- {
- videoSocket = -1;
- shared->totalFrames = 0; /* disable video channel */
- }
- if (audioSocket < 0 && videoSocket < 0) /* none of video/audio channels is setup */
- {
- unsigned char tmp = CmdFAIL;
- CmdWrite(&tmp, 1);
- /*
- fprintf(stderr, "CTR initialization failed.\n");
- */
- return;
- }
- else
- {
- unsigned char tmp = CmdDONE;
- set_speed();
- if (videoSocket >= 0)
- wait_display();
- CmdWrite(&tmp, 1);
- if (videoSocket < 0)
- {
- tmp = CmdVPclearScreen;
- CmdWrite(&tmp, 1);
- }
- return;
- }
-}
-
-static void stop(void)
-{
-#ifdef STAT
- unsigned char preCmd = shared->cmd;
-#endif
- unsigned char tmp = CmdDONE;
- /*
- fprintf(stderr, "CTR: STOP . . .\n");
- */
- stop_playing();
-
- if (shared->live && videoSocket >= 0) {
- Fprintf(stderr, "CTR live video stat: average disp frame rate: %5.2f fps\n",
- shared->pictureRate * displayedFrames / shared->nextFrame);
- }
- CmdWrite(&tmp, 1);
-
-#ifdef STAT
- if (shared->collectStat && preCmd == CmdPLAY && videoSocket >= 0)
- {
- int i;
- int count = 0;
- char ch;
- char buf[100];
- FILE *fp;
-
- for (;;)
- {
- sprintf(buf, "stat.%02d", count++);
- if (access(buf, 0))
- break;
- if (count > 10000)
- {
- fprintf(stderr, "CTR generating stat file, weired thing happened.\n");
- exit(1);
- }
- }
- fprintf(stderr, "Statistics is being collected to file %s. . .", buf);
- fp = fopen(buf, "w");
- if (fp == NULL)
- {
- fprintf(stderr, "CTR failed to open %s for write.\n", buf);
- perror("");
- exit(1);
- }
- {
- time_t val = time(NULL);
- get_hostname(buf, 100);
- buf[99] = 0;
- fprintf(fp, "ClientHost: %s\n", buf);
- fprintf(fp, "Date: %s\n", ctime(&val));
- }
- fprintf(fp, "VideoHost: %s\nVideoFile: %s\n", vh, vf);
- fprintf(fp, "AudioHost: %s\nAudioFile: %s\n\n", ah, af);
- fprintf(fp, "TotalFrames: %d\nTotalGroups: %d\n",
- shared->totalFrames, shared->totalGroups);
- fprintf(fp, "TotalHeaders: %d\n", shared->totalHeaders);
- fprintf(fp, "PictureRate: %f\nPictureSize: %d x %d\n",
- shared->pictureRate, shared->horizontalSize, shared->verticalSize);
- fprintf(fp, "AverageFrameSize: %d\n", shared->averageFrameSize);
- shared->pattern[shared->patternSize] = 0;
- fprintf(fp, "Pattern(%d frames): %s\n", shared->patternSize, shared->pattern);
- shared->pattern[shared->patternSize] = 'I';
-
- fprintf(fp, "\nStartPlayRoundTripDelay: %d (millisec)\n",
- shared->playRoundTripDelay);
- fprintf(fp, "VBmaxBytes: %d\nVBdroppedFrames: %d\n",
- shared->stat.VBmaxBytes, shared->stat.VBdroppedFrames);
- fprintf(fp, "VBemptyTimes: %d\nVDlastFrameDecoded: %d\n",
- shared->stat.VBemptyTimes, shared->stat.VDlastFrameDecoded);
-
- fprintf(fp, "\nVDframesDroppedWithoutReference: %d\n",
- shared->stat.VDnoRef);
- fprintf(fp, "VDframesDroppedAgainstSendPattern: %d\n",
- shared->stat.VDagainstSendPattern);
- fprintf(fp, "VDIframesDroppedTooLate: %d\n",
- shared->stat.VDtooLateI);
- fprintf(fp, "VDPframesDroppedTooLate: %d\n",
- shared->stat.VDtooLateP);
- fprintf(fp, "VDBframesDroppedTooLate: %d\n",
- shared->stat.VDtooLateB);
-
- fprintf(fp, "CTRframesDisplayedOnTime: %d\n", shared->stat.CTRdispOnTime);
- fprintf(fp, "CTRframesDisplayedLate: %d\n", shared->stat.CTRdispLate);
- fprintf(fp, "CTRframesDroppedOutOrder: %d\n", shared->stat.CTRdropOutOrder);
- fprintf(fp, "CTRframesDroppedLate: %d\n", shared->stat.CTRdropLate);
-
- fprintf(fp,
-"\nSpeedChangeHistory:\n(frameId, UPF, FPS, frameRateLimit, frames, dropped):\n");
- for (i = 0; i < min(speedPtr, SPEEDHIST_SIZE); i ++)
- fprintf(fp, "%-4d %-6d %6.2f %6.2f %-4d %d\n",
- speedHistory[i].frameId, speedHistory[i].usecPerFrame,
- 1000000.0 / (double)speedHistory[i].usecPerFrame,
- speedHistory[i].frameRateLimit,
- speedHistory[i].frames, speedHistory[i].framesDropped);
- if (speedPtr > SPEEDHIST_SIZE)
- fprintf(fp, "Actual speed change times: %d (>%d)\n",
- speedPtr, SPEEDHIST_SIZE);
-
- fprintf(fp, "\nVDbufferFillLevel:\n(frames, times):\n");
- for (i = 0; i < MAX_VDQUEUE_SIZE; i ++) {
- if (shared->stat.VDqueue[i]) {
- fprintf(fp, "%-6d %d\n", i, shared->stat.VDqueue[i]);
- }
- }
-
- fprintf(fp, "\nVBmessageGap:\n(width, times):\n");
- {
- for (i = 0; i <= MSGGAP_MAX - MSGGAP_MIN; i ++) {
- if (shared->stat.VBmsgGaps[i]) {
- fprintf(fp, "%-6d %d\n", i + MSGGAP_MIN, shared->stat.VBmsgGaps[i]);
- }
- }
- }
-
- if (shared->stat.fbPacketNumber > 0)
- {
- fprintf(fp,
-"\nFeedbackPackets:\n(fId,addUPF,addf,rateLimit,frames,fdropped,advance):\n");
- for (i = 0; i < min(shared->stat.fbPacketNumber, MAX_FB_PACKETS); i++)
- fprintf(fp, "%-6d %-6d %-6d %6.2f %4d %4d %d\n",
- shared->stat.fbPackets[i].frameId,
- shared->stat.fbPackets[i].addUsecPerFrame,
- shared->stat.fbPackets[i].addFrames,
- shared->stat.fbPackets[i].frameRateLimit,
- shared->stat.fbPackets[i].frames,
- shared->stat.fbPackets[i].framesDropped,
- shared->stat.fbPackets[i].advance);
- if (shared->stat.fbPacketNumber > MAX_FB_PACKETS)
- fprintf(fp, "Actual # of FB packets: %d\n", shared->stat.fbPacketNumber);
- }
-
- ch = CmdSTATsent;
- VideoWrite(&ch, 1);
- fprintf(fp, "\n\nVSFramesSent:\n ");
- for (i = 0; i < 8; i++)
- fprintf(fp, "%-10d", i * 10);
- fprintf(fp, "\n -----------------------------------------------------");
- count = 0;
- for (i = 0; i < (shared->totalFrames + 7)/8; i ++)
- {
- int j;
- VideoRead(&ch, 1);
- if (i % 10 == 0)
- fprintf(fp, "\n%5d: ", i * 8);
- for (j = 0; j < 8; j++)
- {
- if (ch & (1 << j))
- {
- count ++;
- fputc('x', fp);
- }
- else
- fputc('-', fp);
- }
- }
- fprintf(fp, "\nVSTotalFramesSent: %d\n", count);
- fprintf(fp, "\nVBFramesReceived:\n ");
- for (i = 0; i < 8; i++)
- fprintf(fp, "%-10d", i * 10);
- fprintf(fp, "\n -----------------------------------------------------");
- count = 0;
- for (i = 0; i < (shared->totalFrames + 7)/8; i ++)
- {
- int j;
- if (i % 10 == 0)
- fprintf(fp, "\n%5d: ", i * 8);
- for (j = 0; j < 8; j++)
- {
- if (shared->stat.VBframesReceived[i] & (1 << j))
- {
- count ++;
- fputc('x', fp);
- }
- else
- fputc('-', fp);
- }
- }
- fprintf(fp, "\nVBTotalFramesReceived: %d\n", count);
- fprintf(fp, "\nVDFramesDecoded:\n ");
- for (i = 0; i < 8; i++)
- fprintf(fp, "%-10d", i * 10);
- fprintf(fp, "\n -----------------------------------------------------");
- count = 0;
- for (i = 0; i < (shared->totalFrames + 7)/8; i ++)
- {
- int j;
- if (i % 10 == 0)
- fprintf(fp, "\n%5d: ", i * 8);
- for (j = 0; j < 8; j++)
- {
- if (shared->stat.VDframesDecoded[i] & (1 << j))
- {
- count ++;
- fputc('x', fp);
- }
- else
- fputc('-', fp);
- }
- }
- fprintf(fp, "\nVDTotalFramesDecoded: %d\n", count);
- fprintf(fp, "\nVPFramesDisplayed:\n ");
- for (i = 0; i < 8; i++)
- fprintf(fp, "%-10d", i * 10);
- fprintf(fp, "\n -----------------------------------------------------");
- count = 0;
- for (i = 0; i < (shared->totalFrames + 7)/8; i ++)
- {
- int j;
- if (i % 10 == 0)
- fprintf(fp, "\n%5d: ", i * 8);
- for (j = 0; j < 8; j++)
- {
- if (shared->stat.VPframesDisplayed[i] & (1 << j))
- {
- count ++;
- fputc('x', fp);
- }
- else
- fputc('-', fp);
- }
- }
- fprintf(fp, "\nVPTotalFramesDisplayed: %d\n", count);
-
- fprintf(fp, "\nVBBufferFillLevelHistory:\n ");
- for (i = 0; i < 10; i ++)
- fprintf(fp, "%-7d", i);
- fprintf(fp, "\n -----------------------------------------------------");
- for (i = 0; i < shared->totalFrames; i++)
- {
- if (i % 10 == 0)
- fprintf(fp, "\n%5d: ", i / 10);
- if (shared->stat.VBfillLevel[i] == SHRT_MIN)
- fprintf(fp, "x ");
- else
- fprintf(fp, "%-7d", shared->stat.VBfillLevel[i]);
- }
- fprintf(fp, "\nHistoryEnd\n");
- fclose(fp);
- fprintf(stderr, "Statistics collecting done.\n");
- }
-#endif
-
- return;
-}
-
-static void ff(void)
-{
- unsigned char tmp;
- FFpara para;
- /*
- fprintf(stderr, "CTR: FF . . .\n");
- */
- if (shared->live) {
- beep();
- }
- else {
- stop_playing();
- if (shared->nextGroup < 0)
- shared->nextGroup = 0;
- if (videoSocket >= 0 && shared->nextGroup < shared->totalGroups)
- {
- NewCmd(CmdFF);
- shared->needHeader = 0;
- shared->framesPerSecond = shared->config.ffFPS /
- shared->patternSize;
- shared->usecPerFrame = (int)(1000000.0 / (float)shared->config.ffFPS) *
- shared->patternSize;
-
- shared->VStimeAdvance =
- max(shared->config.VStimeAdvance, DEFAULT_VStimeAdvance) * 1000;
- if (shared->VStimeAdvance < shared->usecPerFrame)
- shared->VStimeAdvance = shared->usecPerFrame;
-
- para.VStimeAdvance = htonl(shared->VStimeAdvance);
- para.sn = htonl(shared->cmdsn);
- para.nextGroup = htonl(shared->nextGroup);
- para.usecPerFrame = htonl(shared->usecPerFrame);
- para.framesPerSecond = htonl(shared->framesPerSecond);
- tmp = CmdFF;
- startTime = get_usec();
- VideoWrite(&tmp, 1);
- VideoWrite(&para, sizeof(para));
- start_timer();
- }
- }
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- return;
-}
-
-static void fb(void)
-{
- unsigned char tmp;
- FFpara para;
- /*
- fprintf(stderr, "CTR: FB . . .\n");
- */
- if (shared->live) {
- beep();
- }
- else {
- stop_playing();
- if (shared->nextGroup >= shared->totalGroups)
- shared->nextGroup = shared->totalGroups - 1;
- if (videoSocket >= 0 && shared->nextGroup >= 0)
- {
- NewCmd(CmdFB);
- shared->needHeader = 0;
- shared->framesPerSecond = shared->config.fbFPS /
- shared->patternSize;
- shared->usecPerFrame = (int)(1000000.0 / (float)shared->config.fbFPS) *
- shared->patternSize;
-
- shared->VStimeAdvance =
- max(shared->config.VStimeAdvance, DEFAULT_VStimeAdvance) * 1000;
- if (shared->VStimeAdvance < shared->usecPerFrame)
- shared->VStimeAdvance = shared->usecPerFrame;
-
- para.VStimeAdvance = htonl(shared->VStimeAdvance);
- para.sn = htonl(shared->cmdsn);
- para.nextGroup = htonl(shared->nextGroup);
- para.usecPerFrame = htonl(shared->usecPerFrame);
- para.framesPerSecond = htonl(shared->framesPerSecond);
- tmp = CmdFB;
- startTime = get_usec();
- VideoWrite(&tmp, 1);
- VideoWrite(&para, sizeof(para));
- start_timer();
- }
- }
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- return;
-}
-
-static void step()
-{
- unsigned char tmp;
- STEPpara para;
- stop_playing();
- NewCmd(CmdSTEP);
- if (videoSocket >= 0 && shared->nextFrame <= shared->totalFrames)
- { /* when shared->nextFrame == shared->totalFrame, it will force VS to send a ENDSEQ,
- to let VD give out the remaining frame in its ring[] buffer */
- para.sn = htonl(shared->cmdsn);
- para.nextFrame = htonl(shared->nextFrame);
- /*
- fprintf(stderr, "CTR: STEP . . . frame-%d\n", para.nextFrame);
- */
- tmp = CmdSTEP;
- VideoWrite(&tmp, 1);
- VideoWrite(&para, sizeof(para));
- wait_display();
- }
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- return;
-}
-
-static void play(int auto_exp)
-{
- unsigned char tmp;
- unsigned ats, vts;
- int cmdstarted = 0;
- int stuffsamples = 0;
- /*
- fprintf(stderr, "CTR: PLAY . . .\n");
- */
- stop_playing();
-
- if (!shared->live && !shared->config.rt && videoSocket >= 0) {
- /* rtplay turned off only when video avaible and not want RT play */
- rtplay = 0;
- fprintf(stderr, "VCR is not playing at in realtime mode, audio disabled\n");
- }
- else {
- rtplay = 1;
- }
-
- if (shared->live) {
- rtplay = 1;
- shared->nextFrame = 0;
- shared->nextSample = 0;
- }
-
- shared->rtplay = rtplay;
-
- if (shared->nextFrame < 0)
- shared->nextFrame = 0;
- else if (shared->nextFrame >= shared->totalFrames)
- shared->nextFrame = shared->totalFrames - 1;
-
- if (audioSocket >= 0 && shared->nextSample < shared->totalSamples && rtplay)
- {
- PLAYaudioPara para;
- if (cmdstarted == 0)
- {
- NewCmd(CmdPLAY);
- if (!auto_exp) set_speed();
- cmdstarted = 1;
- }
-
- if (videoSocket >= 0 && rtplay && !shared->live) {
- /* video channel also active, recompute nextSample */
- shared->nextSample =(int) ((double)shared->audioPara.samplesPerSecond *
- ((double)shared->nextFrame / shared->pictureRate));
- shared->nextSample += shared->config.audioOffset;
- if (shared->nextSample < 0) {
- stuffsamples = (- shared->nextSample);
- shared->nextSample = 0;
- }
- else if (shared->nextSample >= shared->totalSamples)
- shared->nextSample = shared->totalSamples - 1;
- }
-
- ABflushBuf(shared->nextSample);
-
- para.sn = htonl(shared->cmdsn);
- para.nextSample = htonl(shared->nextSample);
- para.samplesPerSecond = htonl(shared->samplesPerSecond);
- para.samplesPerPacket = htonl(1024 / shared->audioPara.bytesPerSample);
- para.ABsamples = htonl(AB_BUF_SIZE / shared->audioPara.bytesPerSample);
- para.spslimit = htonl(32000);
-
- startTime = get_usec();
- tmp = CmdPLAY;
- AudioWrite(&tmp, 1);
- AudioWrite(&para, sizeof(para));
- read_int(audioSocket, (int *)&ats);
- }
-
- if (videoSocket >= 0 && shared->nextFrame < shared->totalFrames)
- {
- PLAYpara para;
- if (cmdstarted == 0)
- {
- NewCmd(CmdPLAY);
- if (!auto_exp) set_speed();
- cmdstarted = 1;
- }
- shared->VBheadFrame = -1;
- shared->needHeader = 0;
- {
- int i = shared->config.maxSPframes;
- i = (int) ((double)i * (1000000.0 / (double)shared->usecPerFrame) /
- shared->pictureRate);
- shared->sendPatternGops = max(min(i, PATTERN_SIZE) / shared->patternSize, 1);
- }
- cmdstarted = 1;
-#ifdef STAT
- shared->collectStat = (shared->config.collectStat && (!shared->live));
- if (shared->collectStat)
- {
- int i;
- memset(&(shared->stat), 0, sizeof(shared->stat));
- shared->stat.VDlastFrameDecoded = (unsigned)-1;
- for (i = 0; i < MAX_FRAMES; i++)
- shared->stat.VBfillLevel[i] = SHRT_MIN;
- speedPtr = 0;
- }
-#endif
- shared->VStimeAdvance =
- max(shared->config.VStimeAdvance, DEFAULT_VStimeAdvance) * 1000;
- if (shared->VStimeAdvance < shared->usecPerFrame)
- shared->VStimeAdvance = shared->usecPerFrame;
-
- para.VStimeAdvance = htonl(shared->VStimeAdvance);
- para.sn = htonl(shared->cmdsn);
- para.nextFrame = htonl(shared->nextFrame);
- para.usecPerFrame = htonl(shared->usecPerFrame);
- para.framesPerSecond = htonl(shared->framesPerSecond);
- para.collectStat = htonl(shared->collectStat);
- frate = shared->config.frameRateLimit;
- if (frate <= 0.0) {
- frate = 1.0;
- }
- shared->frameRateLimit = frate;
- para.frameRateLimit1000 =
- htonl((long)(shared->frameRateLimit * 1000.0));
- compute_sendPattern();
- para.sendPatternGops = htonl(shared->sendPatternGops);
- memcpy(para.sendPattern, shared->sendPattern, PATTERN_SIZE);
- startTime = get_usec();
- tmp = CmdPLAY;
- VideoWrite(&tmp, 1);
- VideoWrite(&para, sizeof(para));
- read_int(videoSocket, (int *)&vts);
-
- if (shared->config.qosEffective) {
- /*
- fprintf(stderr, "CTR start FeedBack with init frameRateLimit %lf\n",
- frate);
- */
- maxfr = frate; /* max frame rate all the time during one playback */
- minupf = (int) (1000000.0 / maxfr); /* min usec-per-frame all the time
- during one playback */
- maxrate = (double)minupf / (double)max(shared->usecPerFrame, minupf);
- /* this is current max frame rate in percentage against 'maxfr',
- current max frame rate is the lower of 'maxfr' and play speed */
- frate = 1.0; /* current sending frame rate, in percentage against 'maxfr'
- This value is set with init value as 1.0, so that if current
- speed is lower than frameRateLimit, no frames are dropped,
- then when play speed increases frame rate will increase
- accordingly until frames are dropped*/
- adjstep = ((double)minupf / (double)shared->usecPerFrame) /
- (double)max(shared->patternSize * shared->sendPatternGops, 5);
- /* adjust step for current play speed, in percentage against
- 'maxfr' */
-
- fbstate = 1;
- fb_startup = 1;
-
- /*
- fprintf(stderr, "CTR init frate: %lf minupf %d, shared->upf %d\n",
- frate, minupf, shared->usecPerFrame);
- */
- }
- }
-
- if (shared->live && (videoSocket >= 0) && (audioSocket >= 0)) {
- int gap = get_duration(ats, vts);
- if (gap < 0 || gap >= 5000000) {
- Fprintf(stderr, "Error for live source: ats %u, vts %u, gap %d\n",
- ats, vts, gap);
- }
- else {
- int skipped = gap * shared->audioPara.samplesPerSecond / 1000000;
- skipped += shared->config.audioOffset;
- ABskipSamples(skipped);
- Fprintf(stderr, "Live source: skipped %d audio samples\n", skipped);
- }
- }
- else if (stuffsamples) {
- ABskipSamples(-stuffsamples);
- }
- if (cmdstarted)
- start_timer();
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- return;
-}
-
-static void position_action(int operation_tag)
-{
- int val;
- unsigned char tmp = CmdDONE;
- CmdRead((char*)&val, 4);
- if (shared->live) {
- beep();
- }
- else {
- shared->locationPosition = val;
- stop_playing();
- NewCmd(CmdPOSITION);
- if (videoSocket >= 0)
- {
- int gop = shared->nextGroup;
- POSITIONpara para;
- shared->nextGroup = ((shared->totalGroups-1) * val) / POSITION_RANGE;
- /*
- fprintf(stderr, "CTR: POSITION%s %d (nextGop %d). . .\n",
- operation_tag ? "_released" : "", val, shared->nextGroup);
- */
- if (gop != shared->nextGroup || operation_tag)
- {
- shared->nextFrame = ((shared->totalFrames-1) * val) / POSITION_RANGE;
- para.sn = htonl(shared->cmdsn);
- para.nextGroup = htonl(shared->nextGroup);
- tmp = CmdPOSITION;
- VideoWrite(&tmp, 1);
- VideoWrite(&para, sizeof(para));
- if (operation_tag) /* release or LOOPrewind */
- wait_display();
- }
- if (operation_tag && audioSocket >= 0) /* needs to adjust audio position */
- {
- shared->nextSample = (int)((double)shared->audioPara.samplesPerSecond *
- ((double)shared->nextFrame / shared->pictureRate));
- }
- }
- else if (audioSocket >= 0)
- shared->nextSample = (shared->totalSamples-1) * val / POSITION_RANGE;
- }
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- return;
-}
-
-static void position()
-{
- position_action(0);
-}
-
-static void position_release()
-{
- position_action(1);
-}
-
-static void volume()
-{
- CmdRead((char *)&shared->volumePosition, 4);
- if (audioSocket >= 0) {
- SetAudioGain();
- }
- /*
- unsigned char tmp = CmdDONE;
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- */
- return;
-}
-
-static void balance()
-{
- CmdRead((char *)&shared->balancePosition, 4);
- /*
- unsigned char tmp = CmdDONE;
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- */
- return;
-}
-
-static void speed(void)
-{
- unsigned char tmp;
- CmdRead((char *)&shared->speedPosition, 4);
- set_speed();
- if (!shared->live && shared->cmd == CmdPLAY)
- {
- if (videoSocket >= 0) {
- SPEEDpara para;
- para.sn = htonl(shared->cmdsn);
- para.usecPerFrame = htonl(shared->usecPerFrame);
- para.framesPerSecond = htonl(shared->framesPerSecond);
- para.frameRateLimit1000 =
- htonl((long)(shared->frameRateLimit * 1000.0));
- {
- int i = shared->config.maxSPframes;
- i = (int) ((double)i * (1000000.0 / (double)shared->usecPerFrame) /
- shared->pictureRate);
- shared->sendPatternGops = max(min(i, PATTERN_SIZE) / shared->patternSize, 1);
- }
- compute_sendPattern();
- para.sendPatternGops = htonl(shared->sendPatternGops);
- memcpy(para.sendPattern, shared->sendPattern, PATTERN_SIZE);
- tmp = CmdSPEED;
- VideoWrite(&tmp, 1);
- VideoWrite(&para, sizeof(para));
- if (fbstate) {
- maxrate = (double)minupf / (double)max(shared->usecPerFrame, minupf);
- adjstep = ((double)minupf / (double)shared->usecPerFrame) /
- (double)max(shared->patternSize * shared->sendPatternGops, 5);
- fbstate = 1;
- }
- }
- if (audioSocket >= 0) {
- SPEEDaudioPara para;
- para.sn = htonl(shared->cmdsn);
- para.samplesPerSecond = htonl(shared->samplesPerSecond);
- para.samplesPerPacket = htonl(1024 / shared->audioPara.bytesPerSample);
- para.spslimit = htonl(32000);
- tmp = CmdSPEED;
- AudioWrite(&tmp, 1);
- AudioWrite(&para, sizeof(para));
- }
- /*
- timer_speed();
- */
- }
- /*
- tmp = CmdDONE;
- CmdWrite(&tmp, 1);
- */
- return;
-}
-
-static int timer_on = 0;
+static int timer_on = 0;
static int timer_signals_skip = 0;
-static int timerCount = 0;
-static int lastCount = 0;
-static int timerUPF;
-static int wait_usr2 = 0;
+static int timerCount = 0;
+static int lastCount = 0;
+static int timerUPF;
+static int wait_usr2 = 0;
static int last_disp_fid = 0;
-static void stop_playing(void)
-{
- unsigned char precmd = shared->cmd;
-
- if (precmd == CmdFF || precmd == CmdFB || precmd == CmdPLAY)
- {
-
- unsigned char tmp = CmdSTOP;
- NewCmd(CmdSTOP);
-
- /* notify AS and/or VS */
- if (audioSocket >= 0 && precmd == CmdPLAY && rtplay)
- {
- int cmdsn = htonl(shared->cmdsn);
- AudioWrite(&tmp, 1);
- AudioWrite(&cmdsn, 4);
- }
- if (videoSocket >= 0)
- {
- // CORBA call
- int cmdsn = htonl(shared->cmdsn);
- VideoWrite(&tmp, 1);
- VideoWrite(&cmdsn, 4);
- }
-
- /* stop timer and sleep for a while */
- stop_timer();
- usleep(100000);
-
- /* purge VDbuf and audio channel from AS*/
- if (videoSocket >= 0)
- {
- while (VDpeekMsg() != NULL)
- VDreclaimMsg(VDgetMsg());
- /*
- Fprintf(stderr, "CTR: VDbuf purged.\n");
- */
- fbstate = 0;
-
- }
-
- /* adjust some info */
- if (precmd == CmdPLAY && videoSocket >= 0)
- shared->nextFrame = shared->currentFrame+1;
- else
- shared->nextGroup = shared->currentGroup + 1;
- }
-}
-
static void loopBack(void)
{
static char loopBackCmd[7] = {CmdSTOP, CmdPOSITIONrelease,
@@ -1770,457 +438,9 @@ static void loopBack(void)
cmdBytes = 7;
cmdAcks = 3;
}
-
-void TimerHandler(int sig)
-{
- int currentUPF = shared->currentUPF;
- /*
- Fprintf(stderr, "CTR in TimerHandler.\n");
- */
- if (videoSocket >= 0 && shared->cmd == CmdPLAY && currentUPF != timerUPF)
- {
- struct itimerval val;
- {
- val.it_interval.tv_sec = val.it_value.tv_sec = currentUPF / 1000000;
- val.it_interval.tv_usec = val.it_value.tv_usec = currentUPF % 1000000;
- setitimer(ITIMER_REAL, &val, NULL);
- /*
- fprintf(stderr, "CTR: timer speed changed to %d upf.\n", shared->currentUPF);
- */
- }
- timerUPF = currentUPF;
-#ifdef STAT
- if (shared->collectStat && speedPtr < SPEEDHIST_SIZE)
- {
- speedHistory[speedPtr].frameId = shared->nextFrame;
- speedHistory[speedPtr].usecPerFrame = timerUPF;
- speedHistory[speedPtr].frameRateLimit = shared->frameRateLimit;
- speedHistory[speedPtr].frames = shared->sendPatternGops * shared->patternSize;
- speedHistory[speedPtr].framesDropped = shared->framesDropped;
- }
- speedPtr ++;
-#endif
- }
- /*
- fprintf(stderr, "+\n");
- */
- if (!timerCount) {
- int addedVSwat;
- if (shared->cmd == CmdPLAY) {
- addedVSwat = shared->usecPerFrame * (shared->VBheadFrame - shared->nextFrame);
- }
- else if (shared->cmd == CmdFF) {
- addedVSwat = shared->usecPerFrame * (shared->VBheadFrame - shared->nextGroup);
- }
- else { /* shared->cmd == CmdFB */
- addedVSwat = shared->usecPerFrame * (shared->nextGroup - shared->VBheadFrame);
- }
- shared->VStimeAdvance += addedVSwat;
- }
- timerCount += timer_signals_skip + 1;
- timer_signals_skip = 0;
-
- if (shared->live ) {
- if (audioSocket <= 0) { /* video only */
- unsigned t = shared->VBheadFrame - startVSA;
- if (timerCount < t) {
- /*
- Fprintf(stderr, "CTR: (av) timerCount %d, t %d\n", timerCount, t);
- */
- timerCount = t;
- }
- }
- /* audio involved, TimerProcessing() will adjust the rate automatically */
- }
-}
-
-static void DisplayPicture(void)
-{
- int toDisplay = 1;
- int count = timerCount;
-
- if ((shared->cmd != CmdPLAY &&
- shared->cmd != CmdFF &&
- shared->cmd != CmdFB) ||
- lastCount == count)
- return;
- if (timer_on >4) /* 4 is a magic number */
- {
- stop_timer();
-
- /* tries to rewind and play again */
- if (shared->cmd == CmdPLAY && shared->loopBack)
- loopBack();
-
- return;
- }
- /*
- Fprintf(stderr, "CTR in diplayPicture().\n");
- */
- {
- int i, j;
- FrameBlock *buf, *next;
-#if 0
- if (shared->cmd == CmdPLAY && rtplay &&
- (i = shared->nextFrame - shared->firstGopFrames) > 0) {
- j = (i / shared->patternSize) % shared->sendPatternGops;
- i %= shared->patternSize;
- if (shared->pattern[i] != 'B') {
- while (i > 0) {
- if (shared->pattern[--i] != 'B') break;
- }
- }
- toDisplay = (shared->sendPattern + j * shared->patternSize)[i];
- }
- else if (shared->cmd != CmdPLAY) {
- if (last_disp_fid != shared->nextGroup) toDisplay = 1;
- else toDisplay = 0;
- }
- if (toDisplay)
-#endif
- {
- if (shared->cmd == CmdPLAY && !rtplay) { /* if play with best effort */
- while (VDcheckMsg() <= 0) /* keep sleeping for 10 millisec until a decoded
- frame show up in VD buffer */
- usleep(10000);
- }
-#ifdef STAT
- if (shared->collectStat)
- {
- shared->stat.VBfillLevel[shared->nextFrame] =
- shared->VBheadFrame - shared->nextFrame;
- i = VDcheckMsg();
- if (i < 0) i = 0;
- else if (i >= MAX_VDQUEUE_SIZE) i = MAX_VDQUEUE_SIZE - 1;
- shared->stat.VDqueue[i] ++;
- }
-#endif
- toDisplay = 0;
- for (;;)
- {
- buf = VDpeekMsg();
-
- if (buf == NULL) {
- goto loop_end;
- }
-
- switch (shared->cmd)
- {
- int position;
- case CmdPLAY:
- position = shared->nextFrame;
- /*
- Fprintf(stderr, "CTR PLAY: buf->display %d, position %d\n",
- buf->display, position);
- */
- if (buf->display == position)
- { /* display it */
- buf = VDgetMsg();
- shared->nextGroup = buf->gop + 1;
-#ifdef STAT
- shared->stat.CTRdispOnTime ++;
-#endif
- goto display_picture;
- }
- else if (buf->display > position)
- { /* too early, wait for future display */
- goto loop_end;
- }
- else /* this picture too late */
- {
- // this line gets the buffer or dequeues from the shared memory queue
- buf = VDgetMsg();
- if (((next = VDpeekMsg()) == NULL || next->display > position) &&
- buf->display > last_disp_fid) {
-#ifdef STAT
- shared->stat.CTRdispLate ++;
-#endif
- /* buf is the last one, or next too to early, display it anyway */
- goto display_picture;
- }
- else /* next not too early, discard buf */
- {
-#ifdef STAT
- if (buf->display < last_disp_fid)
- shared->stat.CTRdropOutOrder ++;
- else
- shared->stat.CTRdropLate ++;
-#endif
- /*
- Fprintf(stderr, "CTR drops frame display=%d, shared->nextFrame=%d\n",
- buf->display, shared->nextFrame);
- */
- VDreclaimMsg(buf);
- continue;
- }
- }
- break;
- case CmdFF:
- position = shared->nextGroup;
- if (buf->gop == position)
- { /* display it */
- buf = VDgetMsg();
- shared->nextFrame = buf->display;
- goto display_picture;
- }
- else if (buf->gop > position)
- { /* hold it for future display */
- goto loop_end;
- }
- else /* discard late picture */
- {
- buf = VDgetMsg();
- if ((next = VDpeekMsg()) == NULL || next->gop > position)
- /* buf is the last one, or next too to early, display it anyway */
- goto display_picture;
- else /* next not too early, discard buf */
- {
- VDreclaimMsg(buf);
- continue;
- }
- }
- break;
- case CmdFB:
- position = shared->nextGroup;
- if (buf->gop == position)
- { /* display it */
- buf = VDgetMsg();
- shared->nextFrame = buf->display;
- goto display_picture;
- }
- else if (buf->gop < position)
- { /* hold it for future display */
- goto loop_end;
- }
- else /* discard late picture */
- {
- buf = VDgetMsg();
- if ((next = VDpeekMsg()) == NULL || next->gop < position)
- /* buf is the last one, or next too to early, display it anyway */
- goto display_picture;
- else /* next not too early, discard buf */
- {
- VDreclaimMsg(buf);
- continue;
- }
- }
- break;
- default:
- goto loop_end;
- }
- }
- display_picture:
- toDisplay = 1;
- if (shared->cmd == CmdPLAY) last_disp_fid = buf->display;
- else last_disp_fid = buf->gop;
-#ifdef STAT
- if (shared->live) displayedFrames ++;
- if (shared->collectStat)
- shared->stat.VPframesDisplayed[buf->display >> 3] |= 1 << (buf->display % 8);
-#endif
- {
- unsigned char tmp = CmdVPdisplayFrame;
- CmdWrite(&tmp, 1);
- }
- CmdWrite((unsigned char *)&buf, sizeof(char *));
- loop_end:;
- }
- }
-
- if (shared->cmd == CmdPLAY)
- {
- shared->nextFrame += rtplay ? count - lastCount : 1;
- if (shared->nextFrame >= shared->totalFrames)
- {
- timer_on ++;
- shared->nextFrame = shared->totalFrames;
- }
-
- /* following is frameRate feedback algorithm */
- if (fbstate && toDisplay && rtplay) {
- static Filter *fr = NULL; /* frame-rate filter */
- static int start; /* feedback action time, in microseconds */
- static int delay; /* time to delay after each action, and to charge
- the filter after action-delay */
- static int pretime; /* time of previous frame, in microseconds */
- static int throw_outlier = 0;
- /* tag to throw away outlier. In case there are outliers, this
- tag is flipped by the algorithm, so that If there are two
- consecutive sample deviating very much from the filtered mean
- value, the second is not considered outlier. This may mean
- that the frame rate has dropped significantly. */
- static double vr; /* filtered frame-rate value, in microseconds/frame */
- double r, nr;
- int t = get_usec();
-
- switch (fbstate) {
- case 3: /* working, monitoring */
- {
- int interval = get_duration(pretime, t);
- if (throw_outlier) {
- if (interval >> 2 >= vr) {
- /* at least four times the filtered mean value to be
- considered outlier */
- /* In case an outlier is detected and thrown away, then
- the following sample will never be classified as an
- outlier, and the current time is recorded */
- throw_outlier = 0;
- pretime = t;
- Fprintf(stderr, "CTR detected a gap %d (vr = %d) us\n",
- interval, (int)vr);
- break;
- }
- }
- else {
- throw_outlier = 1;
- }
- vr = DoFilter(fr, (double)interval);
- }
- pretime = t;
-
- r = minupf / vr; /* convert the display fps to percentage of maxfr */
-
- nr = 0; /* This variable contains the newly computed server frame rate */
-
- /* let nr oscillate around 1.5 ~ 2.5 */
- if (min(frate, maxrate) - r >= 3.0 * adjstep) {
- /* pipeline is considered overloaded if server fps is more than 3 adjsteps
- higher than display fps */
- nr = min(frate, maxrate) - adjstep; /* slow down server frame rate
- one step */
- if (fb_startup) { /* startup feedback action: jump set the server fps
- to a value close to actually measure display
- frame rate */
- fb_startup = 0;
- while (nr >= r + 2.5 * adjstep) {
- nr -= adjstep;
- }
- }
- }
- else if (frate - r <= 0.5 * adjstep && frate < maxrate) {
- /* pipeline load is considered too light if the server frame rate
- is less than 0.5fps higher than display frame rate, while the server
- fps is no maximum yet. The server fps then is stepped up. */
- nr = min(frate + adjstep, maxrate);
- }
- if (nr > 0) { /* nr = 0 if not feedback action needs to be taken */
- shared->frameRateLimit = maxfr * nr;
- compute_sendPattern();
- /*
- fprintf(stderr,
- "CTR adjust frameRate to %lf, vr=%lf minupf=%d, r=%lf, frate=%lf, nr=%lf\n",
- shared->frameRateLimit, vr, minupf, r, frate, nr);
- */
- frate = nr; /* remember new server frame rate */
- shared->qosRecomputes ++;
- start = t; /* remember the action time */
- /* delay for some time before restarts, to let feedback take effect */
- delay = shared->usecPerFrame * (shared->VBheadFrame - shared->nextFrame) +
- shared->playRoundTripDelay;
- if (delay < 0) delay = shared->usecPerFrame;
- fbstate = 4;
- }
- break;
- case 4: /* delay and reset after action*/
- if (get_duration(start, t) >= delay) {
- /*
- fprintf(stderr,
- "CTR VB from s2 to s3, vr %lf, frate %lf, maxrate %lf, step %lf\n",
- vr, frate, maxrate, adjstep);
- */
- fr = ResetFilter(fr, shared->config.filterPara >= 1 ?
- shared->config.filterPara : 100);
- delay = shared->usecPerFrame *
- max(shared->sendPatternGops * shared->patternSize,
- shared->config.filterPara);
- /* charge filter for time */
- start = pretime = t;
- throw_outlier = 0;
- fbstate = 2;
- }
- break;
- case 2: /* charge the filter */
- {
- int interval = get_duration(pretime, t);
- if (throw_outlier) {
- if (interval >> 2 >= vr) { /* at least four times the previous average */
- throw_outlier = 0;
- pretime = t;
- Fprintf(stderr, "CTR detected a gap %d (vr = %d) us\n",
- interval, (int)vr);
- break;
- }
- }
- else {
- throw_outlier = 1;
- }
- vr = DoFilter(fr, (double)interval);
- }
- pretime = t;
- if (get_duration(start, t) >= delay) {
- /*
- fprintf(stderr,
- "CTR VB from s2 to s3, vr %lf, frate %lf, maxrate %lf, step %lf\n",
- vr, frate, maxrate, adjstep);
- */
- fbstate = 3;
- }
- break;
- case 1: /* start or speed change, wait until speed data consistant */
- if (shared->currentUPF == shared->usecPerFrame) {
- if (fr == NULL) {
- fr = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ?
- shared->config.filterPara : 100);
- }
- else {
- fr = ResetFilter(fr, shared->config.filterPara >= 1 ?
- shared->config.filterPara : 100);
- }
- if (fr == NULL) {
- perror("CTR failed to allocate space for fr filter");
- fbstate = 0;
- }
- vr = DoFilter(fr, (double)shared->usecPerFrame);
- delay = shared->usecPerFrame *
- shared->sendPatternGops * shared->patternSize;
- /* charge filter for some time */
- pretime = start = t;
- throw_outlier = 0;
- fbstate = 2;
- }
- break;
- default:
- fprintf(stderr, "CTR error: unknown feedback state: %d\n", fbstate);
- fbstate = 1;
- break;
- }
- }
- /* end of frame rate control algorithm */
-
- }
- else if (shared->cmd == CmdFF)
- {
- shared->nextGroup += count - lastCount;
- if (shared->nextGroup >= shared->totalGroups)
- {
- timer_on ++;
- shared->nextGroup = shared->totalGroups - 1;
- }
- }
- else
- {
- shared->nextGroup -= count - lastCount;
- if (shared->nextGroup < 0)
- {
- timer_on ++;
- shared->nextGroup = 0;
- }
- }
- lastCount = count;
-}
-
+
#define AUDIO_BUFSIZE 2048
-
+
static int audioCount = 0;
static int audioFirst = 0;
static int needAudioSkip = 0;
@@ -2231,7 +451,7 @@ static int forward, forwardDelta;
static int audioForward, framesPerAudioPlay;
static int AudioBufSize;
static char * rawBuf = NULL, * workBuf = NULL, * convBuf = NULL;
-
+
static void PlayAudioInit(void)
{
audioCount = -1;
@@ -2262,98 +482,28 @@ static void PlayAudioInit(void)
}
AudioBufSize = (AUDIO_BUFSIZE / shared->audioPara.bytesPerSample) *
shared->audioPara.bytesPerSample;
-
+
StartAudioPlaySession();
}
-
+
/* input the number of samples in the raw buffer,
returns the numberof samples in theconverted buffer */
static int AudioConvert(int len)
{
int convLen;
-
+
if (shared->samplesPerSecond == shared->audioPara.samplesPerSecond)
{
convBuf = rawBuf;
return len;
}
-
+
convBuf = workBuf;
convLen = len * shared->audioPara.samplesPerSecond / shared->samplesPerSecond;
AudioInterpolate(rawBuf, len, convBuf, convLen);
return convLen;
}
-
-static void PlayAudioOnly(void)
-{
- int maxSize;
- int size, csize; /* all in samples */
- unsigned int AFtime;
-
- if (audioFirst)
- {
- audioFirst = 0;
- nextAFtime = GetAudioTime() + audioForward;
- }
- else
- if ((int)(nextAFtime - GetAudioTime()) >= bufferedSamples)
- return;
-
- if (timer_on >4)
- {
- // ~~we may need to uncomment this ??
- stop_timer();
-
- /* tries to rewind and play again */
- if (shared->loopBack)
- {
- /*
- fprintf(stderr, "CTR: trying loopBack().\n");
- */
- loopBack();
- }
-
- return;
- }
- if (nextASSample >= shared->totalSamples)
- {
- timer_on ++;
- return;
- }
- if (shared->samplesPerSecond >= shared->audioPara.samplesPerSecond)
- maxSize = (AudioBufSize/shared->audioPara.bytesPerSample);
- else
- maxSize = ((AudioBufSize/shared->audioPara.bytesPerSample) *
- shared->samplesPerSecond) /
- shared->audioPara.samplesPerSecond;
- for (;;)
- {
- size = ABgetSamples(rawBuf, maxSize);
- csize = AudioConvert(size);
- AFtime = PlayAudioSamples(nextAFtime, convBuf, csize);
- nextASSample += size;
- shared->nextSample += size;
- nextAFtime += csize;
- if ((int)(nextAFtime - AFtime) < 0)
- nextAFtime = AFtime;
- if (nextASSample >= shared->totalSamples)
- {
- timer_on ++;
- break;
- }
- /*
- Fprintf(stderr, "CTR: nextAFtime:%d, AFtime:%d, bufferedSamples:%d\n",
- nextAFtime, AFtime, bufferedSamples);
- */
- if ((int)(nextAFtime - AFtime) >= bufferedSamples)
- break;
- }
- {
- unsigned char tmp = CmdVPaudioPosition;
- CmdWrite(&tmp, 1);
- }
-}
-
+
/* returns: 0 - no forward calculated , 1 - forward calculated */
static int PlayAudio(void)
{
@@ -2381,9 +531,9 @@ static int PlayAudio(void)
*/
return 0;
}
-
+
audioCount = i;
-
+
if (needAudioSkip)
{
/* return if not enough skip can be done */
@@ -2398,7 +548,7 @@ static int PlayAudio(void)
nextASSample += skip_samples;
needAudioSkip = 0;
}
-
+
/* read current block, convert, put to AF, and update nextAFtime */
{
int frame_samples = (int)(startSample +
@@ -2423,9 +573,9 @@ static int PlayAudio(void)
and try again.\n");
exit(1);
}
-
+
read_samples = ABgetSamples(ptr, frame_samples);
-
+
/* convert and play to AF */
{
int maxSamples;
@@ -2452,7 +602,7 @@ static int PlayAudio(void)
}
}
}
-
+
/* possible bugs in AF some times cause PlayAudioSample() to return 0 */
forward = curAFtime ? (oldAFtime - curAFtime) : audioForward;
/*
@@ -2475,80 +625,21 @@ static int PlayAudio(void)
}
return 1;
}
-
-
-void TimerProcessing(void)
-{
- // cerr << "Timerprocessing signal went off\n";
- if (audioSocket >= 0 && shared->cmd == CmdPLAY)
- {
- if (videoSocket < 0)
- PlayAudioOnly();
- else if (rtplay)
- {
- // cerr << "TimerProcessing: calling PlayAudio ()\n";
- int res = PlayAudio();
- /* and also tries to sync audio and video */
- if (res)
- {
- int jit;
- res = forward - audioForward;
- jit = (res>0 ? res : -res);
- jit = (int)(((double)jit / (double)shared->samplesPerSecond) * 1000000.0);
- if (res < -audioForward/2) /* needs to speedup the clock */
- {
- struct itimerval val;
- getitimer(ITIMER_REAL, &val);
- if ((int)val.it_value.tv_usec > jit)
- val.it_value.tv_usec -= jit;
- else
- {
- timer_signals_skip ++;
- val.it_value.tv_usec = 2;
- }
- setitimer(ITIMER_REAL, &val, NULL);
- }
- else if (res > audioForward) /* needs to slow down the clock */
- {
- struct itimerval val;
- /*
- val.it_interval.tv_sec = val.it_value.tv_sec = 0;
- val.it_interval.tv_usec = val.it_value.tv_usec = 0;
- */
- getitimer(ITIMER_REAL, &val);
- val.it_value.tv_usec += (jit % 1000000);
- val.it_value.tv_sec += (jit / 1000000);
- setitimer(ITIMER_REAL, &val, NULL);
- }
- /*
- if (res < -audioForward || res > audioForward)
- */
- if (res < -16000 || res > 16000)
- {
- Fprintf(stderr, "Audio forward jit %d samples\n", res);
- }
- }
- }
- }
- if (videoSocket >= 0 &&
- (shared->cmd == CmdPLAY || shared->cmd == CmdFF || shared->cmd == CmdFB)) {
- DisplayPicture();
- }
- // cerr << "Timerprocessing signal-handler done\n";
-}
-
+
+
+
#define MAX_WAIT_USEC 10000000
-
+
static void start_timer (void)
{
struct itimerval val;
-
+
if (audioSocket >= 0 && shared->cmd == CmdPLAY && rtplay)
{
// ACE_DEBUG ((LM_DEBUG,"calling playaudioinit ()\n"));
PlayAudioInit();
}
-
+
/* sleep for a while to wait for decoding the first picture
and/or audio stream ready */
{
@@ -2587,9 +678,9 @@ static void start_timer (void)
}
val1 = get_duration(val1, get_usec()) / 1000;
shared->playRoundTripDelay = val1;
-
+
Fprintf(stderr, "CTR: estimated play round trip delay: %d millisec.\n", val1);
-
+
/*
if (shared->collectStat)
{
@@ -2601,9 +692,9 @@ static void start_timer (void)
timer_signals_skip = 0;
timerCount = 0;
lastCount = 0;
-
+
if (shared->live) {
-
+
/* delay for shared->config.VStimeAdvance milliseconds, adjustable delay */
if (shared->config.VStimeAdvance > 0) {
Fprintf(stderr, "CTR adds %d millisec of latency\n",
@@ -2618,7 +709,7 @@ static void start_timer (void)
Fprintf(stderr, "CTR: startVSA %d\n", startVSA);
*/
}
-
+
if (shared->cmd == CmdPLAY && rtplay) {
wait_usr2 = 0;
}
@@ -2651,48 +742,12 @@ static void start_timer (void)
// setsignal(SIGALRM, TimerHandler);
setitimer(ITIMER_REAL, &val, NULL);
}
-
-static void stop_timer(void)
-{
-// struct itimerval val;
-
-// if (!timer_on)
-// return;
-
-// timer_on = 0;
-
-// // setsignal(SIGALRM, SIG_IGN);
-
-// val.it_interval.tv_sec = val.it_value.tv_sec = 0;
-// val.it_interval.tv_usec = val.it_value.tv_usec = 0;
-// setitimer(ITIMER_REAL, &val, NULL);
-
-// fprintf(stderr, "CTR: timer stopped.\n");
-
-// /*
-// usleep(200000);
-// */
-}
-
-static void timer_speed()
-{
- /*
- struct itimerval val;
- if (timer_on && videoSocket >= 0 &&
- (shared->cmd == CmdPLAY || shared->cmd == CmdFF || shared->cmd == CmdFB))
- {
- fprintf(stderr, "CTR: timer speed changed to %d upf.\n", shared->usecPerFrame);
- val.it_interval.tv_sec = val.it_value.tv_sec = shared->usecPerFrame / 1000000;
- val.it_interval.tv_usec = val.it_value.tv_usec = shared->usecPerFrame % 1000000;
- setitimer(ITIMER_REAL, &val, NULL);
- }
- */
-}
-
+
+
static void wait_display(void)
{
if (!usr1_flag) {
- if (shared->cmd == CmdINIT) usleep(5000000);// XXX hack to make the client wait until the server gets a chance.
+ if (shared->cmd == CmdINIT) sleep(10);// XXX hack to make the client wait until the server gets a chance.
else usleep(800000);
}
if (!usr1_flag)
@@ -2706,7 +761,7 @@ static void wait_display(void)
}
usr1_flag = 0;
}
-
+
static void usr1_handler(int sig)
{
FrameBlock *buf;
@@ -2715,7 +770,7 @@ static void usr1_handler(int sig)
Fprintf(stderr, "CTR got USR1 for displaying single frame.\n");
*/
usr1_flag = 1;
-
+
if (shared->cmd == CmdINIT) { /* Initialize display window */
tmp = CmdVPinitScreen;
CmdWrite(&tmp, 1);
@@ -2745,7 +800,7 @@ static void usr1_handler(int sig)
*/
buf = NULL;
}
-
+
if (buf != NULL) {
if (shared->cmd == CmdSTEP)
{
@@ -2765,12 +820,12 @@ static void usr1_handler(int sig)
shared->nextFrame ++;
}
}
-
+
static void default_usr2_handler(int sig)
{
Fprintf(stderr, "CTR warning: void SIGUSR2 handler.\n");
}
-
+
static void compute_sendPattern(void)
{
char buf[PATTERN_SIZE];
@@ -2778,7 +833,7 @@ static void compute_sendPattern(void)
char * pat = shared->pattern;
int len = shared->patternSize * shared->sendPatternGops;
int f;
-
+
if (limit <= 0)
limit = 1.0;
if (rtplay) {
@@ -2793,12 +848,12 @@ static void compute_sendPattern(void)
f = len;
else if (f <= 1)
f = 1;
-
+
ComputeSendPattern(pat, buf, len, f);
shared->qosRecomputes ++;
-
+
memcpy(shared->sendPattern, buf, PATTERN_SIZE);
-
+
f = len - f;
if (shared->config.verbose) {
fprintf(stderr, "speed %dupf, %d frames dropped, frames %d:\nsend pattern:",
@@ -2812,18 +867,18 @@ static void compute_sendPattern(void)
fputc('\n', stderr);
}
}
-
+
/* about automatic experiment plan by software developers or specific users:
to be able to conduct experiment plan, the user need to have a uid defined
by DEVELOPER_UID in "../include/common.h", and he/she needs to prepare a file
EXP_PLAN_FILE, with following format:
-
+
{Delay #seconds |
Expriment } *
EndExpriment
-
+
An experiment command is followed by one or more of following parameters:
-
+
playSpeed #float
frameRateLimit #float
maxSPframes #int
@@ -2831,15 +886,15 @@ static void compute_sendPattern(void)
collectStat 0/1
qosEffective 0/1
syncEffective 0/1
-
+
and the parameter is terminated by an empty line.
-
+
The automatic experiment plan file is opened after init() and experiment
setting read just before calling play(). The Player will be terminated
after all experiments are done.
-
+
*/
-
+
static void on_exit_routine(void)
{
// ACE_DEBUG ((LM_DEBUG,
@@ -2847,16 +902,16 @@ static void on_exit_routine(void)
// __FILE__,
// __LINE__));
unsigned char tmp = CmdCLOSE;
-
+
if (getpid() != CTRpid) return;
-
+
if (audioSocket >= 0)
{
write(audioSocket, &tmp, 1);
ComCloseConn(audioSocket);
audioSocket = -1;
}
-
+
if (videoSocket >= 0)
{
// write(videoSocket, &tmp, 1);
@@ -2869,20 +924,20 @@ static void on_exit_routine(void)
}
ComCloseClient();
}
-
+
#define EXP_PLAN_FILE "experiment_plan"
-
+
int CTRmain(int argc,
char **argv)
{
int sv[2];
extern void set_exit_routine_tag(int tag);
-
+
FILE * fp = NULL; /* file pointer for experiment plan */
-
+
set_exit_routine_tag(0);
// setsignal(SIGUSR2, default_usr2_handler);
-
+
/* allocate shared data structure and initialize it */
shared = (SharedData *) creat_shared_mem(sizeof(*shared));
shared->cmd = 0;
@@ -2894,9 +949,9 @@ int CTRmain(int argc,
shared->locationPosition = 0;
shared->speedPosition = 0;
shared->qosRecomputes = 0;
-
+
shared->pixelValid = 0;
-
+
shared->config.rt = 1;
shared->config.maxFPS = DEFAULT_maxFPS;
shared->config.maxSPS = DEFAULT_maxSPS;
@@ -2924,17 +979,17 @@ int CTRmain(int argc,
shared->config.audioConn = 0;
shared->config.videoConn = 0;
shared->config.verbose = (!getuid()) || getuid() == DEVELOPER_UID;
-
+
/* create all shared buffers: AB-CTR, VB-VD, VD-VP */
ABinitBuf(AB_BUF_SIZE);
VBinitBuf(VB_BUF_SIZE);
VDinitBuf(VD_BUF_SIZE);
-
+
CTRpid = getpid();
set_exit_routine_tag(1);
-
+
/* create command socket pair */
- if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)
+ if (ACE_OS::socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1)
{
perror("CTR error on open cmd socketpair");
exit(1);
@@ -2942,7 +997,7 @@ int CTRmain(int argc,
cmdSocket = sv[0];
cerr << "cmdsocket = " << cmdSocket << endl;
/* fork processes: VD, GUI */
-
+
if ((VDpid = fork()) == -1)
{
perror("CTR error on fork VD");
@@ -2957,7 +1012,7 @@ int CTRmain(int argc,
}
VDprocess(CTRpid);
}
-
+
if ((UIpid = fork()) == -1)
{
perror("CTR error on fork UI");
@@ -2978,15 +1033,15 @@ int CTRmain(int argc,
}
close(sv[1]);
// setsignal(SIGUSR1, usr1_handler);
-
+
/* initialize Audio device */
if (InitAudioDevice() == 0)
hasAudioDevice = 1;
else
hasAudioDevice = 0;
-
+
// ComInitClient(VCR_TCP_PORT, VCR_UNIX_PORT, VCR_ATM_PORT);
-
+
if ((vh = (char *)malloc(PATH_SIZE)) == NULL)
{
perror("CTR failed to allocate space for vh");
@@ -3010,41 +1065,40 @@ int CTRmain(int argc,
if (realTimeFlag) {
if (SetRTpriority("CTR", 4)) realTimeFlag = 0;
}
-
+
// atexit(on_exit_routine);
-
+
// instantiate our command handler
Command_Handler command_handler (cmdSocket);
if (command_handler.init (argc,argv) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) command_handler: init returned -1"),
-1);
-
+
// .. and register it with the reactor.
if (TAO_ORB_Core_instance ()->reactor ()->register_handler (&command_handler,
ACE_Event_Handler::READ_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) register_handler for command_handler failed\n"),
-1);
-
- // and now instantiate the sig_handler
- Client_Sig_Handler client_sig_handler (&command_handler);
-
- // .. and ask it to register itself with the reactor
- if (client_sig_handler.register_handler () < 0)
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%P|%t) register_handler for sig_handler failed\n"),
- -1);
-
+
+// // and now instantiate the sig_handler
+// Client_Sig_Handler client_sig_handler (&command_handler);
+
+// // .. and ask it to register itself with the reactor
+// if (client_sig_handler.register_handler () < 0)
+// ACE_ERROR_RETURN ((LM_ERROR,
+// "(%P|%t) register_handler for sig_handler failed\n"),
+// -1);
+
// and run the event loop
// TAO_ORB_Core_instance ()->reactor ()->run_event_loop ();
command_handler.run ();
-
- ACE_DEBUG ((LM_DEBUG,
+
+ ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Exited the client command handler event loop\n"
"%p\n",
"run_event_loop"));
-
+
return 0;
}
-
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp
index 396d6aacc03..679c8178430 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp
@@ -295,9 +295,9 @@ static void SaveBuf(void)
for (i = 0; i < items; i++)
{
Fputs(prog[i].title);
- Fputs(prog[i].vh);
+ // Fputs(prog[i].vh);
Fputs(prog[i].vf);
- Fputs(prog[i].ah);
+ // Fputs(prog[i].ah);
Fputs(prog[i].af);
}
fclose(fp);
@@ -504,15 +504,15 @@ static void modifyCB(Widget w, XtPointer closure, XtPointer call_data)
strcat(buf, LINE1);
strcat(buf, prog[i].title);
strcat(buf, "\n");
- strcat(buf, LINE2);
- strcat(buf, prog[i].vh);
- strcat(buf, "\n");
+ // strcat(buf, LINE2);
+ // strcat(buf, prog[i].vh);
+ // strcat(buf, "\n");
strcat(buf, LINE3);
strcat(buf, prog[i].vf);
strcat(buf, "\n");
- strcat(buf, LINE4);
- strcat(buf, prog[i].ah);
- strcat(buf, "\n");
+ // strcat(buf, LINE4);
+ // strcat(buf, prog[i].ah);
+ // strcat(buf, "\n");
strcat(buf, LINE5);
strcat(buf, prog[i].af);
strcat(buf, "\n\n");
@@ -538,7 +538,7 @@ static void playCB(Widget w, XtPointer closure, XtPointer call_data)
if (i >= items || i < 0)
return;
cerr << "PlayCB\n";
- cerr << prog[i].title << " " << prog[i].vh << " " <<prog[i].vf << " " << prog[i].ah << " " << prog[i].af << endl;
+ cerr << prog[i].title << " " << " " <<prog[i].vf << " " << " " << prog[i].af << endl;
StartProgram(prog[i].title, prog[i].vh, prog[i].vf, prog[i].ah, prog[i].af);
}
}
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp
index 182349e2835..08f2ef0d030 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp
@@ -39,6 +39,7 @@ ftp from geom.umn.edu; email: software@geom.umn.edu. */
#include "include/common.h"
#include "newproto.h"
#include "global.h"
+#include "ace/OS.h"
ACE_RCSID(mpeg_client, ui, "$Id$")
@@ -98,12 +99,14 @@ static void infoclose_callback(Widget, XtPointer, XmAnyCallbackStruct *);
static void CmdWrite(char * buf, int size)
{
- while (write(cmdSocket, (buf), (size)) == -1)
+ // ACE_DEBUG ((LM_DEBUG,"(%P|%t)before writing cmd\n"));
+ while (ACE_OS::write(cmdSocket, (buf), (size)) == -1)
{
if (errno == EINTR) continue;
perror("UI write to cmdSocket");
exit(1);
}
+ // ACE_DEBUG ((LM_DEBUG,"(%P|%t)After writing cmd\n"));
}
/*****************************************************************************
@@ -130,9 +133,9 @@ static void UICreate()
int n, depth;
static String fallbacks[] = {
- "*Foreground: gray20",
+ "*Foreground: black",
"*BorderWidth: 0",
- "*Background: gray70",
+ "*Background: lavender",
"*XmToggleButton.selectColor: yellow",
"*XmToggleButton.indicatorSize: 16",
"*XmToggleButtonGadget.selectColor: yellow",
@@ -652,6 +655,7 @@ static void step_callback(Widget w, XtPointer data, XmAnyCallbackStruct *cbs)
static void play_callback(Widget w, XtPointer data, XmAnyCallbackStruct *cbs)
{
+ ACE_DEBUG ((LM_DEBUG,"(%P)play_callback:cmdbusy= %d,playtag=%d\n",cmdBusy,playtag));
if (playtag && !cmdBusy)
{
char cmd = CmdPLAY;
@@ -777,6 +781,7 @@ static void cmdSocket_callback(Widget w, XtPointer data, XmAnyCallbackStruct *cb
perror("UI by callback read from CmdSocket");
exit(1);
}
+ // ACE_DEBUG ((LM_DEBUG,"(%P)cmdSocket_callback:cmd= %d",cmd));
if (cmd == CmdDONE || cmd == CmdFAIL)
{
cmdBusy = 0;
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp
index 372c4fef3c5..9b9c0ea6445 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp
@@ -297,7 +297,7 @@ void VBprocess(int initSocket, int normalSocket)
int pfid, pgop; /* frame-id of gopid of previous frame */
int cmdsn = -1; /* cmdsn of previous command */
int state = 0; /* state of the control law/regulator */
- int startpos; /* gopid or frameid when the regulator is in 'start' state 1 */
+ int startposnnn; /* gopid or frameid when the regulator is in 'start' state 1 */
int delay; /* #frames to delay after 'start' */
int qosRecomputes = 0; /* indicate if qos has been recomputed recently */
int action_delay; /* microseconds to delay after feedback action */
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp
index 8119bfb8ab3..4ae1860f12f 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp
@@ -409,7 +409,7 @@ void VDprocess(int CTRpid)
}
p = (VideoPacket*)VBgetMsg(); /* guarranteed to get a Packet */
- // printPacket(p);
+ //printPacket(p);
// fprintf(stderr, "VD: got frame %d\n", p->frame);
@@ -647,10 +647,10 @@ void VDprocess(int CTRpid)
if (!mpegVidRsrc((char*)p)) /* successfully decoded */
{
curPict = curVidStream->current;
- /*
- fprintf(stderr, "VD successfully decodes a frame.\n");
- printPacket(p);
- */
+
+ // fprintf(stderr, "VD successfully decodes a frame.\n");
+ // printPacket(p);
+
if (curcmd == CmdPLAY && shared->rtplay)
{
if ((curVidStream->picture.code_type == I_TYPE) ||
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
index 139f5e853c8..74f74cfb5d5 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
@@ -156,6 +156,8 @@ public:
ACE_SOCK_CODgram dgram;
// the UDP data socket
+ char *data_host;
+ // name of the host to bind to.
int live_source;
int video_format;
@@ -342,6 +344,7 @@ public:
public:
+ char *data_host;
enum audio_state {AUDIO_WAITING = 0,AUDIO_PLAY =1};
audio_state state;
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Control_i.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Control_i.cpp
index a4eba5fb757..5db371090c1 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Control_i.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Control_i.cpp
@@ -144,6 +144,11 @@ Video_Control_i::set_peer (char * &peer,
client_data_addr.get_host_addr (),
client_data_addr.get_port_number ()));
+ char temp_addr [BUFSIZ];
+ if (VIDEO_SINGLETON::instance ()->data_host != 0)
+ ACE_OS::sprintf (temp_addr,"%s:%d",VIDEO_SINGLETON::instance ()->data_host,0);
+ else
+ ACE_OS::sprintf (temp_addr,":%d",0);
if (VIDEO_SINGLETON::instance ()->dgram.open (client_data_addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile
index 181c94427e2..bfbe88374ef 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile
@@ -13,6 +13,10 @@ ifndef TAO_ROOT
TAO_ROOT = $(ACE_ROOT)/TAO
endif
+#TAO_IDLFLAGS = -Wb,export_macro=TAO_ORBSVCS_Export -Wb,export_include=orbsvcs_export.h
+
+IDL_FILES = Video_ControlS Video_ControlC Audio_ControlS Audio_ControlC ReceiverS ReceiverC
+
# On non-Windows environment, we should at least define
# the export_include IDL flag.
FILES = $(IDL_FILES)
@@ -20,11 +24,6 @@ FILES = $(IDL_FILES)
DEFS = $(addsuffix .h,$(FILES))
LSRC = $(addsuffix .cpp,$(FILES))
-
-#TAO_IDLFLAGS = -Wb,export_macro=TAO_ORBSVCS_Export -Wb,export_include=orbsvcs_export.h
-
-IDL_FILES = Video_ControlS Video_ControlC Audio_ControlS Audio_ControlC
-
FILES += com fileio filters routine sendpt
LDFLAGS += -L$(TAO_ROOT)/tao
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl
new file mode 100644
index 00000000000..2694255c141
--- /dev/null
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl
@@ -0,0 +1,8 @@
+/* _*_C++_*_ */
+
+// $Id$
+interface Receiver
+{
+ void push_audio_mmdevice (in Object mmdevice,
+ in string audio_file);
+};
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp
index 8a08d2beda1..3dd8e8c226f 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.cpp
@@ -13,6 +13,7 @@ TAO_Video_Repository::TAO_Video_Repository (const char* file_name)
num_movies_ (0),
lastchanged_ (0)
{
+ cout<<"The movie file is "<<filename_<<endl;
}
TAO_Video_Repository::~TAO_Video_Repository (void)
@@ -27,32 +28,34 @@ TAO_Video_Repository::evalDP (const char* name,
CORBA::Environment& _env)
TAO_THROW_SPEC ((CosTradingDynamic::DPEvalFailure))
{
+ ACE_DEBUG ((LM_DEBUG,"TAO_Video_Repository::evalDP:%s\n",name));
CORBA::Any* return_value = 0;
ACE_NEW_RETURN (return_value, CORBA::Any, 0);
-
+
struct stat file_stat;
if (ACE_OS::stat (this->filename_, &file_stat) == 0)
- {
+ {
if (this->lastchanged_ < file_stat.st_mtime)
{
FILE* file = ACE_OS::fopen (this->filename_, "r");
-
+
if (file != 0)
{
// Read the file into a buffer
ACE_Read_Buffer read_file (file, 1);
- char* database = read_file.read (EOF, '\n', '%');
+ char* database = read_file.read (EOF, '\n', '%');
// Parse the file into a sequence and insert it into an
// Any (i.e., this->return_)
TAO_Video_Repository::parse_file (database,
read_file.replaced ());
-
+
ACE_Allocator* alloc = ACE_Allocator::instance ();
alloc->free (database);
this->lastchanged_ = file_stat.st_mtime;
}
+ else cout<<"The movie_database.txt file does not exist"<<endl;
}
TAO_VR::Movie_Info* movie_info = 0;
@@ -62,9 +65,13 @@ TAO_Video_Repository::evalDP (const char* name,
this->movie_info_,
0),
0);
-
+
(*return_value) <<= movie_info;
}
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG,"TAO_Video_Repository::evalDP::stat failed\n"));
+ }
return return_value;
}
@@ -78,7 +85,7 @@ TAO_Video_Repository::parse_file (const char* database, int num_lines)
char* current = (char *) database;
ACE_DEBUG ((LM_DEBUG, "Recomputing the movie stats.\n"));
-
+
TAO_VR::Movie_Info::freebuf (this->movie_info_);
this->movie_info_ = TAO_VR::Movie_Info::allocbuf (num_lines);
@@ -89,21 +96,21 @@ TAO_Video_Repository::parse_file (const char* database, int num_lines)
while (current != 0)
{
TAO_VR::Movie& movie = this->movie_info_[i];
-
+
movie.name_ = (const char*) current;
movie.filename_ = (const char*) ACE_OS::strtok (0, delim);
movie.description_ = (const char*) ACE_OS::strtok (0, delim);
-
+
ACE_DEBUG ((LM_DEBUG,
"Movie Name: %s\nFile Name: %s\nDescription: %s\n",
(const char *) movie.name_,
(const char *) movie.filename_,
(const char *) movie.description_));
-
+
// From the actual movie file, extract the techincal information.
TAO_Video_Repository::
obtain_movie_info (movie.filename_, movie);
-
+
current = ACE_OS::strtok (0, delim);
i++;
}
@@ -122,7 +129,7 @@ export_properties (TAO_Property_Exporter& prop_exporter)
CosTradingDynamic::DynamicProp* dp_struct =
this->construct_dynamic_prop (MOVIE_INFO,
TAO_VR::_tc_Movie_Info,
- extra_info);
+ extra_info);
prop_exporter.add_dynamic_property (MOVIE_INFO, dp_struct);
}
@@ -143,4 +150,3 @@ define_properties (CosTradingRepos::ServiceTypeRepository::PropStructSeq& prop_s
return 1;
}
-
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl
index ce42c089959..f53cfd88d73 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/Video_Repository.idl
@@ -20,6 +20,7 @@ module TAO_VR
string name_;
string filename_;
string description_;
+ // string video_filename_;
// string movie_format_;
// unsigned long filesize_;
// unsigned long duration_;
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/as.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/as.cpp
index 0ed1e6d5a13..f839b67c17f 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/as.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/as.cpp
@@ -45,7 +45,7 @@ Audio_Child_Process::init (int argc,
int
Audio_Child_Process::make_mediactrl (Audio_Control_i *& media_ctrl)
{
- ACE_DEBUG ((LM_DEBUG,"(%P|%t) Video_Child_Process::make_mediactrl ()\n"));
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t) Audio_Child_Process::make_mediactrl ()\n"));
media_ctrl = AUDIO_CONTROL_I::instance ();
return 0;
}
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp
index 5f90c59db4e..6837ab74a34 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/augmented_server.cpp
@@ -20,14 +20,14 @@ AV_Audio_MMDevice (TAO_AV_Endpoint_Process_Strategy *endpoint_strategy)
{
}
-AVStreams::StreamEndPoint_B_ptr
+AVStreams::StreamEndPoint_B_ptr
AV_Audio_MMDevice::
-create_B (AVStreams::StreamCtrl_ptr the_requester,
- AVStreams::VDev_out the_vdev,
- AVStreams::streamQoS &the_qos,
- CORBA::Boolean_out met_qos,
- char *&named_vdev,
- const AVStreams::flowSpec &the_spec,
+create_B (AVStreams::StreamCtrl_ptr the_requester,
+ AVStreams::VDev_out the_vdev,
+ AVStreams::streamQoS &the_qos,
+ CORBA::Boolean_out met_qos,
+ char *&named_vdev,
+ const AVStreams::flowSpec &the_spec,
CORBA::Environment &env)
{
ACE_DEBUG ((LM_DEBUG,"(%P|%t) Audio_MMDevice::create_B called \n"));
@@ -114,23 +114,23 @@ AV_Server_Sig_Handler::register_handler (void)
if (TAO_ORB_Core_instance ()->reactor ()->register_handler
(this, ACE_Event_Handler::NULL_MASK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
"register_handler"),
-1);
// handles these signals.
// this->sig_set.fill_set ();
- this->sig_set.sig_add (SIGCHLD);
- this->sig_set.sig_add (SIGBUS);
- this->sig_set.sig_add (SIGINT);
+ this->sig_set.sig_add (SIGCHLD);
+ this->sig_set.sig_add (SIGBUS);
+ this->sig_set.sig_add (SIGINT);
this->sig_set.sig_add (SIGTERM);
// Register the signal handler object to catch the signals. if
- if (TAO_ORB_Core_instance ()->reactor ()->register_handler
+ if (TAO_ORB_Core_instance ()->reactor ()->register_handler
(this->sig_set, this) == -1)
- ACE_ERROR_RETURN ((LM_ERROR,
- "%p\n",
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
"register_handler"),
-1);
return 0;
@@ -143,14 +143,14 @@ AV_Server_Sig_Handler::get_handle (void) const
return this->handle_;
}
-int
+int
AV_Server_Sig_Handler::handle_input (ACE_HANDLE)
{
ACE_DEBUG ((LM_DEBUG, "(%t) handling asynchonrous input...\n"));
return 0;
}
-int
+int
AV_Server_Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask)
{
ACE_DEBUG ((LM_DEBUG, "(%t) closing down Sig_Handler...\n"));
@@ -158,7 +158,7 @@ AV_Server_Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask)
}
// This method handles all the signals that are being caught by this
-// object.
+// object.
int
AV_Server_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
@@ -192,11 +192,11 @@ AV_Server_Sig_Handler::clear_child (int sig)
{
int pid;
int status;
-
+
// ACE_DEBUG ((LM_DEBUG,"(%P|%t) AV_Server: Reaping the children\n"));
// reap the children
- while ((pid = ACE_OS::waitpid (-1,
- &status,
+ while ((pid = ACE_OS::waitpid (-1,
+ &status,
WNOHANG)) > 0)
{
if (pid == AV_Server::current_pid_)
@@ -208,10 +208,10 @@ AV_Server_Sig_Handler::clear_child (int sig)
// decrement the count of number of active children
Mpeg_Global::session_num --;
-
- if (status == 0)
+
+ if (status == 0)
continue;
-
+
// ACE_DEBUG ((LM_DEBUG, "(%P|%t) AV_Server: child %d (status %d)\n", pid, status));
}
return;
@@ -228,27 +228,27 @@ AV_Server_Sig_Handler::remove_names (void)
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;
-
+
// Unregister the video_mmdevice with the naming service.
-
+
CosNaming::Name video_server_mmdevice_name (1);
video_server_mmdevice_name.length (1);
video_server_mmdevice_name [0].id = CORBA::string_dup ("Video_Server_MMDevice");
-
+
// Register the video control object with the naming server.
naming_context->unbind (video_server_mmdevice_name,
TAO_TRY_ENV);
// Unregister the audio_mmdevice with the naming service.
-
+
CosNaming::Name audio_server_mmdevice_name (1);
audio_server_mmdevice_name.length (1);
audio_server_mmdevice_name [0].id = CORBA::string_dup ("Audio_Server_MMDevice");
-
+
// Register the audio control object with the naming server.
naming_context->unbind (audio_server_mmdevice_name,
TAO_TRY_ENV);
@@ -272,7 +272,7 @@ AV_Server_Sig_Handler::int_handler (int sig)
this->remove_names ();
TAO_ORB_Core_instance ()->orb ()->shutdown ();
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
"(%P|%t) AV server killed by signal %d\n",
sig));
}
@@ -302,13 +302,13 @@ void
AV_Server::on_exit_routine (void)
{
// %% what does the following do
- if (Mpeg_Global::parentpid != ACE_OS::getpid ())
+ if (Mpeg_Global::parentpid != ACE_OS::getpid ())
{
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Process is exiting\n"));
return;
}
-
+
// %% what does the following do
if (Mpeg_Global::live_audio > 1)
ExitLiveAudio ();
@@ -359,7 +359,7 @@ AV_Server::parse_args (int argc,
return 0;
}
-
+
// Initializes the mpeg server
int
AV_Server::init (int argc,
@@ -375,11 +375,11 @@ AV_Server::init (int argc,
env);
TAO_CHECK_ENV_RETURN (env,
-1);
-
- CORBA::ORB_var orb =
+
+ CORBA::ORB_var orb =
this->orb_manager_.orb ();
- PortableServer::POA_var child_poa =
+ PortableServer::POA_var child_poa =
this->orb_manager_.child_poa ();
result = this->parse_args (argc, argv);
@@ -387,8 +387,8 @@ AV_Server::init (int argc,
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Error parsing arguments"),
-1);
-
- // Resolve the Naming service reference.
+
+ // Resolve the Naming service reference.
/*
CORBA::Object_var naming_obj = orb->resolve_initial_references ("NameService");
if (CORBA::is_nil (naming_obj.in ()))
@@ -401,7 +401,7 @@ AV_Server::init (int argc,
env);
TAO_CHECK_ENV_RETURN (env,-1);
*/
-
+
// Register the video mmdevice object with the ORB
ACE_NEW_RETURN (this->video_mmdevice_,
TAO_MMDevice (&this->video_process_strategy_),
@@ -418,12 +418,12 @@ AV_Server::init (int argc,
CosNaming::Name video_server_mmdevice_name (1);
video_server_mmdevice_name.length (1);
video_server_mmdevice_name [0].id = CORBA::string_dup ("Video_Server_MMDevice");
-
+
// Register the video control object with the naming server.
this->naming_context_->bind (video_server_mmdevice_name,
this->video_mmdevice_->_this (env),
env);
-
+
if (env.exception () != 0)
{
env.clear ();
@@ -432,13 +432,13 @@ AV_Server::init (int argc,
env);
TAO_CHECK_ENV_RETURN (env,-1);
}
-
- */
+
+ */
// Register the audio mmdevice object with the ORB
ACE_NEW_RETURN (this->audio_mmdevice_,
AV_Audio_MMDevice (&this->audio_process_strategy_),
-1);
-
+
// create the audio server mmdevice with the naming service pointer.
this->orb_manager_.activate_under_child_poa ("Audio_Server_MMDevice",
this->audio_mmdevice_,
@@ -451,7 +451,7 @@ AV_Server::init (int argc,
CosNaming::Name audio_server_mmdevice_name (1);
audio_server_mmdevice_name.length (1);
audio_server_mmdevice_name [0].id = CORBA::string_dup ("Audio_Server_MMDevice");
-
+
// Register the audio control object with the naming server.
this->naming_context_->bind (audio_server_mmdevice_name,
this->audio_mmdevice_->_this (env),
@@ -466,16 +466,16 @@ AV_Server::init (int argc,
TAO_CHECK_ENV_RETURN (env,-1);
}
- */
+ */
// Invoke this once, passing in an object for each trading service
- // service type.
+ // service type.
if (this->resolve_trader (env) != -1)
{
// Invoke this for each offer.
this->export_properties (env);
TAO_CHECK_ENV_RETURN (env, -1);
}
-
+
// Register the various signal handlers with the reactor.
result = this->signal_handler_.register_handler ();
@@ -501,7 +501,7 @@ AV_Server::run (CORBA::Environment& env){
"event loop %p\n",
"run_event_loop"));
return 0;
-
+
}
void
@@ -509,11 +509,11 @@ AV_Server::export_properties (CORBA::Environment& _env)
{
CORBA::Object_ptr object_ptr = this->audio_mmdevice_->_this (_env);
TAO_CHECK_ENV_RETURN_VOID (_env);
-
+
CosPropertyService::PropertySet_ptr prop_set =
CosPropertyService::PropertySet::_narrow (object_ptr, _env);
TAO_CHECK_ENV_RETURN_VOID (_env);
-
+
// Instantiate the property exporter helper class.
TAO_Property_Exporter prop_exporter (this->trader_, prop_set);
@@ -541,14 +541,14 @@ AV_Server::resolve_trader (CORBA::Environment& _env)
ACE_DEBUG ((LM_ERROR, "Bootstrap to the Lookup interface.\n"));
CORBA::Object_var trading_obj =
this->orb_manager_.orb ()->resolve_initial_references ("TradingService");
-
+
if (CORBA::is_nil (trading_obj.in ()))
{
ACE_ERROR ((LM_ERROR,
" (%P|%t) Unable to bootstrap to the Trading Service.\n"));
return -1;
}
-
+
// Narrow the lookup interface.
ACE_DEBUG ((LM_DEBUG, "Narrowing the lookup interface.\n"));
this->trader_ = CosTrading::Lookup::_narrow (trading_obj.in (), _env);
@@ -570,7 +570,7 @@ AV_Server::~AV_Server (void)
delete this->video_mmdevice_;
if (this->audio_mmdevice_ != 0)
delete this->audio_mmdevice_;
-
+
}
void
@@ -582,7 +582,7 @@ AV_Server::shutdown (void) const
{
CosTrading::Register_var reg = this->trader_->register_if (TAO_TRY_ENV);
TAO_CHECK_ENV;
-
+
ACE_DEBUG ((LM_DEBUG, "Withdrawing offer...\n"));
reg->withdraw (this->offer_id_.in (), TAO_TRY_ENV);
TAO_CHECK_ENV;
@@ -616,6 +616,6 @@ main (int argc, char **argv)
return -1;
}
TAO_ENDTRY;
-
+
return 0;
}
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp
index 2105d2b6fa7..dbbd61250cd 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp
@@ -231,7 +231,7 @@ AV_Server_Sig_Handler::int_handler (int sig)
AV_Server_Sig_Handler::~AV_Server_Sig_Handler (void)
{
- TAO_ORB_Core_instance ()->reactor ()->remove_handler (this->sig_set);
+ // TAO_ORB_Core_instance ()->reactor ()->remove_handler (this->sig_set);
}
// AV_Server routines
@@ -337,9 +337,7 @@ AV_Server::init (int argc,
-1);
// Initialize the naming services
- if (my_name_client_.init (this->orb_manager_.orb (),
- argc,
- argv) != 0)
+ if (my_name_client_.init (this->orb_manager_.orb ()) != 0)
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Unable to initialize "
"the TAO_Naming_Client. \n"),
@@ -351,9 +349,11 @@ AV_Server::init (int argc,
-1);
// create the video server mmdevice with the naming service pointer.
- this->orb_manager_.activate_under_child_poa ("Video_Server_MMDevice",
- this->video_mmdevice_,
- env);
+ CORBA::String_var video_mmdevice_ior = this->orb_manager_.activate_under_child_poa ("Video_Server_MMDevice",
+ this->video_mmdevice_,
+ env);
+ ACE_DEBUG ((LM_DEBUG,"(%P|%t) video_mmdevice_ior is :%s\n",video_mmdevice_ior.in ()));
+
TAO_CHECK_ENV_RETURN (env,-1);
// Register the video_mmdevice with the naming service.
@@ -382,9 +382,10 @@ AV_Server::init (int argc,
-1);
// create the audio server mmdevice with the naming service pointer.
- this->orb_manager_.activate_under_child_poa ("Audio_Server_MMDevice",
- this->audio_mmdevice_,
- env);
+ CORBA::String_var audio_mmdevice_ior = this->orb_manager_.activate_under_child_poa ("Audio_Server_MMDevice",
+ this->audio_mmdevice_,
+ env);
+ ACE_DEBUG ((LM_DEBUG,"Audio MMDevice ior is: %s\n",audio_mmdevice_ior.in ()));
TAO_CHECK_ENV_RETURN (env,-1);
// Register the audio_mmdevice with the naming service.
@@ -441,12 +442,8 @@ AV_Server::~AV_Server (void)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) AV_Server: Removing handlers from the Reactor\n"));
-
- if (this->video_mmdevice_ != 0)
- delete this->video_mmdevice_;
- if (this->audio_mmdevice_ != 0)
- delete this->audio_mmdevice_;
-
+ delete this->video_mmdevice_;
+ delete this->audio_mmdevice_;
}
int