diff options
27 files changed, 2614 insertions, 2875 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/24bit.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/24bit.cpp index 6ec8d2bc06d..87931de7f58 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/24bit.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/24bit.cpp @@ -80,10 +80,10 @@ InitColorDither() { int CR, CB, i; - Cr_b_tab = (int *)malloc(256*sizeof(int)); - Cr_g_tab = (int *)malloc(256*sizeof(int)); - Cb_g_tab = (int *)malloc(256*sizeof(int)); - Cb_r_tab = (int *)malloc(256*sizeof(int)); + Cr_b_tab = (int *)ACE_OS::malloc(256*sizeof(int)); + Cr_g_tab = (int *)ACE_OS::malloc(256*sizeof(int)); + Cb_g_tab = (int *)ACE_OS::malloc(256*sizeof(int)); + Cb_r_tab = (int *)ACE_OS::malloc(256*sizeof(int)); for (i=0; i<256; i++) { CB = CR = i; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/2x2.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/2x2.cpp index f12a0e070e5..06bf6ab7fac 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/2x2.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/2x2.cpp @@ -91,7 +91,7 @@ Init2x2Dither() numcodes = l_range * cr_range * cb_range; - dith_a = (unsigned char *) malloc(numcodes*4); + dith_a = (unsigned char *) ACE_OS::malloc(numcodes*4); dith_ca = dith_a; @@ -183,8 +183,8 @@ void RandInit(int h, int w) { int i; - randval_a = (int *) malloc(w*5*sizeof(int)); - randptr_a = (int **) malloc(h*sizeof(int *)); + randval_a = (int *) ACE_OS::malloc(w*5*sizeof(int)); + randptr_a = (int **) ACE_OS::malloc(h*sizeof(int *)); #ifdef NO_LRAND48 for (i=0; i<w*5; i++) { 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 c2f7ee71f77..bc7bfe20e15 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 @@ -29,15 +29,16 @@ Command_Handler::Command_Handler (ACE_HANDLE command_handle) audio_streamctrl_ (0), receiver_ (this), data_host_ (0), - client_sig_handler_ (this) + client_sig_handler_ (this), + notification_handler_ (this) { } Command_Handler::~Command_Handler (void) { - TAO_ORB_Core_instance ()->reactor ()->remove_handler (this, - ACE_Event_Handler::READ_MASK); - ::remove_all_semaphores (); + this->remove_handlers (); + if (ACE_OS::getpid () == CTRpid) + ::remove_all_semaphores (); } int @@ -94,16 +95,6 @@ Command_Handler::init (int argc, 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); -// TAO_CHECK_ENV; - ior = this->orb_manager_.activate (&this->receiver_, TAO_TRY_ENV); TAO_CHECK_ENV; @@ -134,6 +125,11 @@ Command_Handler::init (int argc, "(%P|%t) register_handler for sig_handler failed\n"), -1); + if (TAO_ORB_Core_instance ()->reactor ()->register_handler (&this->notification_handler_, + ACE_Event_Handler::READ_MASK) < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) register_handler for notification handler failed\n"), + -1); } TAO_CATCHANY { @@ -192,23 +188,6 @@ Command_Handler::resolve_audio_reference (void) this->audio_mmdevice_ior_ = (char *)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); -// 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); @@ -308,7 +287,6 @@ Command_Handler::get_handle (void) const int Command_Handler::handle_input (ACE_HANDLE fd) { - // cerr << "(" << getpid () << " Command_Handler::handle_input:busy_ = " << this->busy_ << endl; unsigned char cmd; int val; @@ -393,7 +371,7 @@ Command_Handler::handle_input (ACE_HANDLE fd) } default: fprintf(stderr, "CTR: unexpected command from UI: cmd = %d.\n", cmd); - exit(1); + ACE_OS::exit (1); break; } this->busy_ = 0; @@ -429,7 +407,10 @@ Command_Handler::init_av (void) if (audioSocket >= 0) { if (ABpid > 0) { - kill(ABpid, SIGUSR1); + ACE_DEBUG ((LM_DEBUG,"killing the abprocess\n")); + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (asp[0],&message,BUFSIZ); ABpid = -1; } usleep(10000); @@ -437,13 +418,15 @@ Command_Handler::init_av (void) if (videoSocket >= 0) { if (VBpid > 0) { - kill(VBpid, SIGUSR1); + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (vsp[0],&message,BUFSIZ); VBpid = -1; } usleep(10000); videoSocket = -1; - while ((!VBbufEmpty()) || !VDbufEmpty()) { + while ((!vbuffer->VBbufEmpty()) || !VDbufEmpty()) { while (VDpeekMsg() != NULL) { VDreclaimMsg(VDgetMsg()); } @@ -461,6 +444,7 @@ Command_Handler::init_av (void) af [0]=0; NewCmd(CmdINIT); + i = 0; result = OurCmdRead((char*)&i, 4); result = OurCmdRead(vf, i); @@ -478,7 +462,10 @@ Command_Handler::init_av (void) if (af[0] != 0) { - if (init_audio_channel(af) != 0) + int result; + if ((result =init_audio_channel(af)) > 0) + return result; + else if (result < 0) { audioSocket = -1; shared->totalSamples = 0; @@ -499,7 +486,9 @@ Command_Handler::init_av (void) if (vf[0] != 0) { ACE_DEBUG ((LM_DEBUG,"(%P|%t) Initializing video\n")); - if (this->init_video_channel(vf)) + if (this->init_video_channel(vf) > 0) + return result; + else if (result < 0) { shared->totalFrames = 0; /* disable video channel */ videoSocket = -1; @@ -536,13 +525,6 @@ Command_Handler::init_av (void) set_speed(); if (videoSocket >= 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; @@ -577,7 +559,9 @@ Command_Handler::init_java_av (char *audio_ior, { if (ABpid > 0) { ACE_DEBUG ((LM_DEBUG,"Killing AB Process\n")); - kill(ABpid, SIGUSR1); + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (asp[0],&message,BUFSIZ); ABpid = -1; } usleep(10000); @@ -586,13 +570,15 @@ Command_Handler::init_java_av (char *audio_ior, if (videoSocket >= 0) { if (VBpid > 0) { - kill(VBpid, SIGUSR1); + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (vsp[0],&message,BUFSIZ); VBpid = -1; } usleep(10000); videoSocket = -1; - while ((!VBbufEmpty()) || !VDbufEmpty()) { + while ((!vbuffer->VBbufEmpty()) || !VDbufEmpty()) { while (VDpeekMsg() != NULL) { VDreclaimMsg(VDgetMsg()); } @@ -712,7 +698,7 @@ Command_Handler::init_audio_channel (char *audiofile) para->para.channels = shared->AFPara.channels; para->para.samplesPerSecond = shared->AFPara.samplesPerSecond; para->para.bytesPerSample = shared->AFPara.bytesPerSample; - para->nameLength = strlen(audiofile)+1; + para->nameLength =ACE_OS::strlen (audiofile)+1; para->audiofile.length (strlen(audiofile)); @@ -768,35 +754,43 @@ Command_Handler::init_audio_channel (char *audiofile) { if (ABpid == -1) { - switch (ABpid = fork()) + switch (ABpid = ACE_OS::fork ()) { case -1: - perror("CTR error on forking AB process"); - exit(1); + ACE_OS::perror ("CTR error on forking AB process"); + ACE_OS::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 (realTimeFlag) { + SetRTpriority("AB", -1); + } + ACE_OS::free (vh); + ACE_OS::free (vf); + ACE_OS::free (ah); + ACE_OS::free (audiofile); + vbuffer->VBdeleteBuf(); + VDdeleteBuf(); + if (cmdSocket >= 0) + ACE_OS::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 + } + abuffer->ABprocess(this->audio_data_handle_); + this->remove_handlers (); + // Before shutting down the orb remove all the handlers registered with it. + ACE_DEBUG ((LM_DEBUG,"(%P|%t) Before shutdown")); + this->orb_manager_.orb ()->shutdown (); + ACE_DEBUG ((LM_DEBUG,"(%P|%t) After shutdown")); + return 1; } - ABprocess(this->audio_data_handle_); break; default: - ABflushBuf(0); + abuffer->ABflushBuf(0); break; } } @@ -806,15 +800,20 @@ Command_Handler::init_audio_channel (char *audiofile) 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 (); -// } +int +Command_Handler::remove_handlers (void) +{ + int result; + result = this->client_sig_handler_.remove_handler (); + + if (TAO_ORB_Core_instance ()->reactor ()->remove_handler (&this->notification_handler_, + ACE_Event_Handler::READ_MASK) < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "(%P|%t) remove_handler for notification handler failed\n"), + -1); + return 0; + +} void Command_Handler::set_mmdevice (CORBA::Object_ptr audio_mmdevice, @@ -955,7 +954,7 @@ Command_Handler::init_video_channel (char *videofile) for (i=0;i<shared->patternSize;i++) shared->pattern[i] = reply->pattern [i]; for (i = 1; i < PATTERN_SIZE / shared->patternSize; i ++) { - // memcpy(ptr, shared->pattern, shared->patternSize); + // ACE_OS::memcpy (ptr, shared->pattern, shared->patternSize); for (int j=0; j < shared->patternSize ;j++) ptr [j] = shared->pattern [j]; ptr += shared->patternSize; @@ -973,7 +972,7 @@ Command_Handler::init_video_channel (char *videofile) { fprintf(stderr, "CTR Error: patternSize %d greater than PATTERN_SIZE %d.\n", shared->patternSize, PATTERN_SIZE); - exit(1); + ACE_OS::exit (1); } fprintf(stderr, "Video: %s, %s\n", shared->videoFormat == VIDEO_SIF ? "SIF" : @@ -1018,33 +1017,33 @@ Command_Handler::init_video_channel (char *videofile) shared->videoMaxPktSize >= 0 ? SOCK_STREAM : SOCK_DGRAM, 0, sp) == -1) { - perror("CTR error on open CTR-VB socketpair"); - exit(1); + ACE_OS::perror ("CTR error on open CTR-VB socketpair"); + ACE_OS::exit (1); } if (VBpid == -1) { - switch (VBpid = fork()) + switch (VBpid = ACE_OS::fork ()) { case -1: - perror("CTR error on forking VB process"); - exit(1); + ACE_OS::perror ("CTR error on forking VB process"); + ACE_OS::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); + ACE_OS::free (vh); + ACE_OS::free (videofile); + ACE_OS::free (ah); + ACE_OS::free (af); ::close(sp[0]); //::close (videoSocket); // if (audioSocket >= 0) // ComCloseFd(audioSocket); ::close (audioSocket); - ABdeleteBuf(); + abuffer->ABdeleteBuf(); VDdeleteBuf(); if (cmdSocket >= 0) ::close(cmdSocket); @@ -1055,7 +1054,17 @@ Command_Handler::init_video_channel (char *videofile) if (SetRTpriority("VB", 1)) realTimeFlag = 0; #endif } - VBprocess(sp[1], this->video_data_handle_); + if (vbuffer->VBprocess(sp[1], this->video_data_handle_) == -1) + { + ACE_DEBUG ((LM_DEBUG,"VBprocess exiting as init failed\n")); + ACE_OS::exit (2); + } + else + { + this->remove_handlers (); + this->orb_manager_.orb ()->shutdown (); + return 1; + } break; default: ::close(sp[1]); @@ -1063,13 +1072,13 @@ Command_Handler::init_video_channel (char *videofile) { int bytes, res; /* passing all messages of INIT frame to VB here. */ - char * buf = (char *)malloc(INET_SOCKET_BUFFER_SIZE); + char * buf = (char *)ACE_OS::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); + ACE_OS::perror ("CTR error on ACE_OS::malloc() for INIT frame"); + ACE_OS::exit (1); } while (msgo + msgs < pkts) { // ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reached line %d in %s\n", __LINE__, __FILE__)); @@ -1099,10 +1108,10 @@ Command_Handler::init_video_channel (char *videofile) VideoRead(buf + sizeof(*msg), msgs); bytes = sizeof(*msg) + msgs; - while ((res = write(sp[0], buf, bytes)) == -1) { + while ((res = ACE_OS::write (sp[0], buf, bytes)) == -1) { if (errno == EINTR || errno == ENOBUFS) continue; - perror("CTR error on sending INIT frame to VB"); - exit(1); + ACE_OS::perror ("CTR error on sending INIT frame to VB"); + ACE_OS::exit (1); } if (res < bytes) { fprintf(stderr, "CTR warn: send() res %dB < bytes %dB\n", res, bytes); @@ -1114,9 +1123,10 @@ Command_Handler::init_video_channel (char *videofile) */ } } - read(sp[0], buf, 1); /* read a garbage byte, to sync with VB */ + ACE_OS::read (sp[0], buf, 1); /* read a garbage byte, to sync with VB */ + fprintf (stderr,"(%P|%t) Command process read a garbage bytes\n"); ::close(sp[0]); - free(buf); + ACE_OS::free (buf); } break; } @@ -1138,62 +1148,66 @@ Command_Handler::stat_stream (CORBA::Char_out ch, int Command_Handler::close (void) { - TAO_TRY + TAO_TRY + { + if (CORBA::is_nil (this->audio_control_) == 0) { - if (CORBA::is_nil (this->audio_control_) == 0) - { - // 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. - this->video_control_->close (TAO_TRY_ENV); - TAO_CHECK_ENV; - if (VBpid > 0) { - kill(VBpid, SIGUSR1); - VBpid = -1; - } - 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")); + // one way function call. + this->audio_control_->close (TAO_TRY_ENV); - 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")); + if (ABpid > 0) { + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (asp[0],&message,BUFSIZ); + ABpid = -1; + } + ACE_DEBUG ((LM_DEBUG,"(%P|%t) audio close done \n")); } - TAO_CATCHANY + + if (CORBA::is_nil (this->video_control_) == 0) { - TAO_TRY_ENV.print_exception ("video_control_->close (..)"); - return -1; + // one way function call. + this->video_control_->close (TAO_TRY_ENV); + TAO_CHECK_ENV; + if (VBpid > 0) { + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (vsp[0],&message,BUFSIZ); + VBpid = -1; + } + ACE_DEBUG ((LM_DEBUG,"(%P|%t) video close done \n")); } - 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; + 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 (..)"); + 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; } @@ -1434,7 +1448,7 @@ Command_Handler::play (int auto_exp, shared->nextSample = shared->totalSamples - 1; } - ABflushBuf (shared->nextSample); + abuffer->ABflushBuf (shared->nextSample); para->sn = shared->cmdsn; para->nextSample = shared->nextSample; @@ -1563,12 +1577,12 @@ Command_Handler::play (int auto_exp, else { int skipped = gap * shared->audioPara.samplesPerSecond / 1000000; skipped += shared->config.audioOffset; - ABskipSamples (skipped); + abuffer->ABskipSamples (skipped); Fprintf (stderr, "Live source: skipped %d audio samples\n", skipped); } } else if (stuffsamples) { - ABskipSamples (-stuffsamples); + abuffer->ABskipSamples (-stuffsamples); } if (cmdstarted) start_timer (); @@ -1582,7 +1596,7 @@ Command_Handler::position_action (int operation_tag) { int val; unsigned char tmp = CmdDONE; - CmdRead ((char*)&val, 4); + OurCmdRead ((char*)&val, 4); this->operation_tag_ = operation_tag; this->position_val_ = val; @@ -1663,7 +1677,7 @@ int Command_Handler::volume (void) { - CmdRead((char *)&shared->volumePosition, 4); + OurCmdRead((char *)&shared->volumePosition, 4); if (audioSocket >= 0) { SetAudioGain(); } @@ -1679,7 +1693,7 @@ int Command_Handler::balance (void) { - CmdRead((char *)&shared->balancePosition, 4); + OurCmdRead((char *)&shared->balancePosition, 4); /* unsigned char tmp = CmdDONE; tmp = CmdDONE; @@ -1695,7 +1709,7 @@ Command_Handler::speed (void) ACE_DEBUG ((LM_DEBUG,"COmmand_Handler::speed ()\n")); unsigned char tmp; CORBA::Boolean result; - CmdRead((char *)&shared->speedPosition, 4); + OurCmdRead((char *)&shared->speedPosition, 4); set_speed(); TAO_TRY { @@ -1717,8 +1731,6 @@ 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++) para->sendPattern[i]=shared->sendPattern[i]; @@ -1767,10 +1779,6 @@ int Command_Handler::stop (void) { - /* - ::stop (); - return 0; - */ #ifdef STAT unsigned char preCmd = shared->cmd; #endif @@ -1974,6 +1982,81 @@ Command_Handler::connect_to_audio_server (void) return 0; } +// ======================================== +// Decode_Notification_Handler methods. + +Decode_Notification_Handler::Decode_Notification_Handler (Command_Handler *command_handler) + :command_handler_ (command_handler) +{ +} + +ACE_HANDLE +Decode_Notification_Handler::get_handle (void) const +{ + return vdsp[0]; +} + +int +Decode_Notification_Handler::handle_input (ACE_HANDLE fd) +{ + ACE_DEBUG ((LM_DEBUG,"Decode_Notification_Handler::handle_input \n")); + char message[BUFSIZ]; + int result = + ACE_OS::read (fd,&message,BUFSIZ); + if (result == -1) + ACE_ERROR_RETURN ((LM_ERROR,"Decode_Notification_Handler::handle_input read failed\n"),0); + if (result == 0) + ACE_ERROR_RETURN ((LM_ERROR,"Decode_Notification_Handler::handle_input socket closed\n"),0); + + if (message[0] != DECODED) + ACE_ERROR_RETURN ((LM_ERROR,"Decode_Notification_Handler:: Not a decoded message\n"),0); + + // 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 (0); + return 0; +} + + +// ---------------------------------------------------------------------- +// Client_Sig_Handler methods + void Client_Sig_Handler::PlayAudioOnly(void) { @@ -2021,7 +2104,7 @@ Client_Sig_Handler::PlayAudioOnly(void) shared->audioPara.samplesPerSecond; for (;;) { - size = ABgetSamples(rawBuf, maxSize); + size = abuffer->ABgetSamples(rawBuf, maxSize); csize = AudioConvert(size); AFtime = PlayAudioSamples(nextAFtime, convBuf, csize); nextASSample += size; @@ -2047,9 +2130,6 @@ Client_Sig_Handler::PlayAudioOnly(void) } } -// ---------------------------------------------------------------------- - -// Client_Sig_Handler methods // handles the timeout SIGALRM signal Client_Sig_Handler::Client_Sig_Handler (Command_Handler *command_handler) : command_handler_ (command_handler) @@ -2089,7 +2169,6 @@ 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 (SIGUSR1); this->sig_set.sig_add (SIGUSR2); this->sig_set.sig_add (SIGSEGV); @@ -2102,8 +2181,20 @@ Client_Sig_Handler::register_handler (void) -1); return 0; } -// Called by the ACE_Reactor to extract the fd. +int +Client_Sig_Handler::remove_handler (void) +{ + if (TAO_ORB_Core_instance ()->reactor ()->remove_handler (this, + ACE_Event_Handler::NULL_MASK) == -1) + ACE_DEBUG ((LM_DEBUG,"(%P)remove_handler failed for client_sig handler")); + + if (TAO_ORB_Core_instance ()->reactor ()->remove_handler (sig_set) == -1) + ACE_DEBUG ((LM_DEBUG,"(%P)remove_handler failed for client_sig handler")); + return 0; +} + +// Called by the ACE_Reactor to extract the fd. ACE_HANDLE Client_Sig_Handler::get_handle (void) const { @@ -2151,50 +2242,6 @@ Client_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *) this->TimerHandler (signum); // %% ??!!! 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: - ::default_usr2_handler (signum); - break; case SIGCHLD: // ACE_DEBUG ((LM_DEBUG, "(%P|%t) received signal %S\n", signum)); pid = ACE_OS::wait (&status); @@ -2669,7 +2716,7 @@ Client_Sig_Handler::DisplayPicture(void) shared->config.filterPara : 100); } if (fr == NULL) { - perror("CTR failed to allocate space for fr filter"); + ACE_OS::perror ("CTR failed to allocate space for fr filter"); fbstate = 0; } vr = DoFilter(fr, (double)shared->usecPerFrame); 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 41f437b3ab5..a6ec7b1d646 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 @@ -66,7 +66,9 @@ #include "ace/Acceptor.h" #include "orbsvcs/Naming/Naming_Utils.h" #include "mpeg_shared/ReceiverS.h" - +#include "ace/Get_Opt.h" +#include "ab.h" +#include "vb.h" class Command_Handler; @@ -325,6 +327,9 @@ public: // this will register this sig_handler // with the reactor for SIGCHLD,SIGTERM,SIGINT + int remove_handler (void); + // removes the handlers. + virtual int shutdown (ACE_HANDLE, ACE_Reactor_Mask); // handles the reactor shutdown @@ -360,6 +365,21 @@ private: }; +class Decode_Notification_Handler :public ACE_Event_Handler +{ +public: + Decode_Notification_Handler (Command_Handler *command_handler); + // constructor. + + virtual ACE_HANDLE get_handle (void) const; + // Get the Notification handle. + + virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE); + // called when input events occur. +private: + Command_Handler *command_handler_; +}; + enum Suspended { UNSUSPENDED = 0,INIT=1,STEP=2,POSITION=3 @@ -512,6 +532,9 @@ private: int parse_args (int argc,char **argv); // parses the arguments. + int remove_handlers (void); + // removes all the handlers. + int busy_; // flag to indicate the state of the command handler @@ -582,6 +605,9 @@ private: Client_Sig_Handler client_sig_handler_; // Handler for the signals. + Decode_Notification_Handler notification_handler_; + // handler for the decode signals from VD process. + int argc_; char **argv_; }; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Makefile b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Makefile index 48413d733ea..0d1f562cf3a 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Makefile +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/Makefile @@ -84,14 +84,49 @@ realclean: clean # DO NOT DELETE THIS LINE -- g++dep uses it. # DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. -.obj/24bit.o .obj/24bit.so .shobj/24bit.o .shobj/24bit.so: 24bit.cpp video.h dither.h proto.h -.obj/2x2.o .obj/2x2.so .shobj/2x2.o .shobj/2x2.so: 2x2.cpp video.h dither.h proto.h -.obj/ab.o .obj/ab.so .shobj/ab.o .shobj/ab.so: ab.cpp \ +.obj/24bit.o .obj/24bit.so .shobj/24bit.o .shobj/24bit.so: 24bit.cpp video.h dither.h proto.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/2x2.o .obj/2x2.so .shobj/2x2.o .shobj/2x2.so: 2x2.cpp video.h dither.h proto.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/ab.o .obj/ab.so .shobj/ab.o .shobj/ab.so: ab.cpp ab.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -103,19 +138,67 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h \ - $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h \ + $(ACE_ROOT)/ace/Event_Handler.h \ + $(ACE_ROOT)/ace/Event_Handler.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ + $(ACE_ROOT)/ace/Handle_Set.i \ + $(ACE_ROOT)/ace/Timer_Queue.h \ + $(ACE_ROOT)/ace/Synch.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ + $(ACE_ROOT)/ace/Synch.i \ + $(ACE_ROOT)/ace/Synch_T.h \ + $(ACE_ROOT)/ace/Synch_T.i \ + $(ACE_ROOT)/ace/Thread.h \ + $(ACE_ROOT)/ace/Thread.i \ + $(ACE_ROOT)/ace/Atomic_Op.i \ + $(ACE_ROOT)/ace/Synch_T.cpp \ + $(ACE_ROOT)/ace/Timer_Queue_T.h \ + $(ACE_ROOT)/ace/Free_List.h \ + $(ACE_ROOT)/ace/Free_List.i \ + $(ACE_ROOT)/ace/Free_List.cpp \ + $(ACE_ROOT)/ace/Timer_Queue_T.i \ + $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ + $(ACE_ROOT)/ace/Signal.h \ + $(ACE_ROOT)/ace/Containers.h \ + $(ACE_ROOT)/ace/Containers.i \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ + $(ACE_ROOT)/ace/Malloc.h \ + $(ACE_ROOT)/ace/Malloc.i \ + $(ACE_ROOT)/ace/Malloc_T.h \ + $(ACE_ROOT)/ace/Malloc_T.i \ + $(ACE_ROOT)/ace/Malloc_T.cpp \ + $(ACE_ROOT)/ace/Memory_Pool.h \ + $(ACE_ROOT)/ace/Mem_Map.h \ + $(ACE_ROOT)/ace/Mem_Map.i \ + $(ACE_ROOT)/ace/Memory_Pool.i \ + $(ACE_ROOT)/ace/Signal.i \ + $(ACE_ROOT)/ace/Object_Manager.h \ + $(ACE_ROOT)/ace/Object_Manager.i \ + $(ACE_ROOT)/ace/Managed_Object.h \ + $(ACE_ROOT)/ace/Managed_Object.i \ + $(ACE_ROOT)/ace/Managed_Object.cpp \ + $(ACE_ROOT)/ace/Reactor.i \ + $(ACE_ROOT)/ace/Reactor_Impl.h vb.h .obj/audio.o .obj/audio.so .shobj/audio.o .shobj/audio.so: audio.cpp \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -127,17 +210,37 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h -.obj/decoders.o .obj/decoders.so .shobj/decoders.o .shobj/decoders.so: decoders.cpp decoders.h util.h video.h proto.h +.obj/decoders.o .obj/decoders.so .shobj/decoders.o .shobj/decoders.so: decoders.cpp decoders.h util.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i video.h \ + proto.h .obj/file.o .obj/file.so .shobj/file.o .shobj/file.so: file.cpp video.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -149,19 +252,74 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h -.obj/fs2.o .obj/fs2.so .shobj/fs2.o .shobj/fs2.so: fs2.cpp video.h dither.h fs2.h proto.h -.obj/fs2fast.o .obj/fs2fast.so .shobj/fs2fast.o .shobj/fs2fast.so: fs2fast.cpp video.h proto.h dither.h -.obj/fs4.o .obj/fs4.so .shobj/fs4.o .shobj/fs4.so: fs4.cpp fs4.h video.h proto.h dither.h +.obj/fs2.o .obj/fs2.so .shobj/fs2.o .shobj/fs2.so: fs2.cpp video.h dither.h fs2.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i proto.h +.obj/fs2fast.o .obj/fs2fast.so .shobj/fs2fast.o .shobj/fs2fast.so: fs2fast.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/fs4.o .obj/fs4.so .shobj/fs4.o .shobj/fs4.so: fs4.cpp fs4.h $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i video.h \ + proto.h dither.h .obj/global.o .obj/global.so .shobj/global.o .shobj/global.so: global.cpp \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -173,23 +331,204 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/gray.o .obj/gray.so .shobj/gray.o .shobj/gray.so: gray.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/hybrid.o .obj/hybrid.so .shobj/hybrid.o .shobj/hybrid.so: hybrid.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/hybriderr.o .obj/hybriderr.so .shobj/hybriderr.o .shobj/hybriderr.so: hybriderr.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/info.o .obj/info.so .shobj/info.o .shobj/info.so: info.cpp $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/jrevdct.o .obj/jrevdct.so .shobj/jrevdct.o .shobj/jrevdct.so: jrevdct.cpp video.h proto.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/mb_ordered.o .obj/mb_ordered.so .shobj/mb_ordered.o .shobj/mb_ordered.so: mb_ordered.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/mono.o .obj/mono.so .shobj/mono.o .shobj/mono.so: mono.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/motionvector.o .obj/motionvector.so .shobj/motionvector.o .shobj/motionvector.so: motionvector.cpp video.h proto.h util.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/ordered.o .obj/ordered.so .shobj/ordered.o .shobj/ordered.so: ordered.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/ordered2.o .obj/ordered2.so .shobj/ordered2.o .shobj/ordered2.so: ordered2.cpp video.h proto.h dither.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ $(ACE_ROOT)/ace/Log_Record.i -.obj/gray.o .obj/gray.so .shobj/gray.o .shobj/gray.so: gray.cpp video.h proto.h dither.h -.obj/hybrid.o .obj/hybrid.so .shobj/hybrid.o .shobj/hybrid.so: hybrid.cpp video.h proto.h dither.h -.obj/hybriderr.o .obj/hybriderr.so .shobj/hybriderr.o .shobj/hybriderr.so: hybriderr.cpp video.h proto.h dither.h -.obj/info.o .obj/info.so .shobj/info.o .shobj/info.so: info.cpp -.obj/jrevdct.o .obj/jrevdct.so .shobj/jrevdct.o .shobj/jrevdct.so: jrevdct.cpp video.h proto.h -.obj/mb_ordered.o .obj/mb_ordered.so .shobj/mb_ordered.o .shobj/mb_ordered.so: mb_ordered.cpp video.h proto.h dither.h -.obj/mono.o .obj/mono.so .shobj/mono.o .shobj/mono.so: mono.cpp video.h proto.h dither.h -.obj/motionvector.o .obj/motionvector.so .shobj/motionvector.o .shobj/motionvector.so: motionvector.cpp video.h proto.h util.h -.obj/ordered.o .obj/ordered.so .shobj/ordered.o .shobj/ordered.so: ordered.cpp video.h proto.h dither.h -.obj/ordered2.o .obj/ordered2.so .shobj/ordered2.o .shobj/ordered2.so: ordered2.cpp video.h proto.h dither.h .obj/para.o .obj/para.so .shobj/para.o .shobj/para.so: para.cpp video.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -201,15 +540,16 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h .obj/parseblock.o .obj/parseblock.so .shobj/parseblock.o .shobj/parseblock.so: parseblock.cpp video.h proto.h decoders.h util.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -221,13 +561,15 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ $(ACE_ROOT)/ace/Log_Record.i .obj/prog.o .obj/prog.so .shobj/prog.o .shobj/prog.so: prog.cpp video.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -239,8 +581,10 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h .obj/ui.o .obj/ui.so .shobj/ui.o .shobj/ui.so: ui.cpp \ @@ -248,7 +592,6 @@ realclean: clean $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -260,6 +603,9 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ $(ACE_ROOT)/ace/Log_Record.i \ interface/fb.xbm interface/play.xbm interface/step.xbm \ interface/stop.xbm interface/loop.xbm interface/ff.xbm \ @@ -268,14 +614,49 @@ realclean: clean newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h -.obj/util.o .obj/util.so .shobj/util.o .shobj/util.so: util.cpp video.h proto.h util.h -.obj/util32.o .obj/util32.so .shobj/util32.o .shobj/util32.so: util32.cpp video.h proto.h ui.h -.obj/vb.o .obj/vb.so .shobj/vb.o .shobj/vb.so: vb.cpp \ +.obj/util.o .obj/util.so .shobj/util.o .shobj/util.so: util.cpp video.h proto.h util.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/util32.o .obj/util32.so .shobj/util32.o .shobj/util32.so: util32.cpp video.h proto.h ui.h \ + $(ACE_ROOT)/ace/OS.h \ + $(ACE_ROOT)/ace/inc_user_config.h \ + $(ACE_ROOT)/ace/config.h \ + $(ACE_ROOT)/ace/config-g++-common.h \ + $(ACE_ROOT)/ace/streams.h \ + $(ACE_ROOT)/ace/Basic_Types.h \ + $(ACE_ROOT)/ace/Basic_Types.i \ + $(ACE_ROOT)/ace/OS.i \ + $(ACE_ROOT)/ace/Trace.h \ + $(ACE_ROOT)/ace/Log_Msg.h \ + $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ + $(ACE_ROOT)/ace/ACE.i \ + $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i +.obj/vb.o .obj/vb.so .shobj/vb.o .shobj/vb.so: vb.cpp vb.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -287,19 +668,67 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h \ - $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h \ + $(ACE_ROOT)/ace/Event_Handler.h \ + $(ACE_ROOT)/ace/Event_Handler.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ + $(ACE_ROOT)/ace/Handle_Set.i \ + $(ACE_ROOT)/ace/Timer_Queue.h \ + $(ACE_ROOT)/ace/Synch.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ + $(ACE_ROOT)/ace/Synch.i \ + $(ACE_ROOT)/ace/Synch_T.h \ + $(ACE_ROOT)/ace/Synch_T.i \ + $(ACE_ROOT)/ace/Thread.h \ + $(ACE_ROOT)/ace/Thread.i \ + $(ACE_ROOT)/ace/Atomic_Op.i \ + $(ACE_ROOT)/ace/Synch_T.cpp \ + $(ACE_ROOT)/ace/Timer_Queue_T.h \ + $(ACE_ROOT)/ace/Free_List.h \ + $(ACE_ROOT)/ace/Free_List.i \ + $(ACE_ROOT)/ace/Free_List.cpp \ + $(ACE_ROOT)/ace/Timer_Queue_T.i \ + $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ + $(ACE_ROOT)/ace/Signal.h \ + $(ACE_ROOT)/ace/Containers.h \ + $(ACE_ROOT)/ace/Containers.i \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ + $(ACE_ROOT)/ace/Malloc.h \ + $(ACE_ROOT)/ace/Malloc.i \ + $(ACE_ROOT)/ace/Malloc_T.h \ + $(ACE_ROOT)/ace/Malloc_T.i \ + $(ACE_ROOT)/ace/Malloc_T.cpp \ + $(ACE_ROOT)/ace/Memory_Pool.h \ + $(ACE_ROOT)/ace/Mem_Map.h \ + $(ACE_ROOT)/ace/Mem_Map.i \ + $(ACE_ROOT)/ace/Memory_Pool.i \ + $(ACE_ROOT)/ace/Signal.i \ + $(ACE_ROOT)/ace/Object_Manager.h \ + $(ACE_ROOT)/ace/Object_Manager.i \ + $(ACE_ROOT)/ace/Managed_Object.h \ + $(ACE_ROOT)/ace/Managed_Object.i \ + $(ACE_ROOT)/ace/Managed_Object.cpp \ + $(ACE_ROOT)/ace/Reactor.i \ + $(ACE_ROOT)/ace/Reactor_Impl.h .obj/vd.o .obj/vd.so .shobj/vd.o .shobj/vd.so: vd.cpp \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -311,16 +740,67 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ - global.h dither.h video.h proto.h + global.h dither.h video.h proto.h vb.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h \ + $(ACE_ROOT)/ace/Event_Handler.h \ + $(ACE_ROOT)/ace/Event_Handler.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ + $(ACE_ROOT)/ace/Handle_Set.i \ + $(ACE_ROOT)/ace/Timer_Queue.h \ + $(ACE_ROOT)/ace/Synch.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \ + $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \ + $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \ + $(ACE_ROOT)/ace/Synch.i \ + $(ACE_ROOT)/ace/Synch_T.h \ + $(ACE_ROOT)/ace/Synch_T.i \ + $(ACE_ROOT)/ace/Thread.h \ + $(ACE_ROOT)/ace/Thread.i \ + $(ACE_ROOT)/ace/Atomic_Op.i \ + $(ACE_ROOT)/ace/Synch_T.cpp \ + $(ACE_ROOT)/ace/Timer_Queue_T.h \ + $(ACE_ROOT)/ace/Free_List.h \ + $(ACE_ROOT)/ace/Free_List.i \ + $(ACE_ROOT)/ace/Free_List.cpp \ + $(ACE_ROOT)/ace/Timer_Queue_T.i \ + $(ACE_ROOT)/ace/Timer_Queue_T.cpp \ + $(ACE_ROOT)/ace/Signal.h \ + $(ACE_ROOT)/ace/Containers.h \ + $(ACE_ROOT)/ace/Containers.i \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ + $(ACE_ROOT)/ace/Malloc.h \ + $(ACE_ROOT)/ace/Malloc.i \ + $(ACE_ROOT)/ace/Malloc_T.h \ + $(ACE_ROOT)/ace/Malloc_T.i \ + $(ACE_ROOT)/ace/Malloc_T.cpp \ + $(ACE_ROOT)/ace/Memory_Pool.h \ + $(ACE_ROOT)/ace/Mem_Map.h \ + $(ACE_ROOT)/ace/Mem_Map.i \ + $(ACE_ROOT)/ace/Memory_Pool.i \ + $(ACE_ROOT)/ace/Signal.i \ + $(ACE_ROOT)/ace/Object_Manager.h \ + $(ACE_ROOT)/ace/Object_Manager.i \ + $(ACE_ROOT)/ace/Managed_Object.h \ + $(ACE_ROOT)/ace/Managed_Object.i \ + $(ACE_ROOT)/ace/Managed_Object.cpp \ + $(ACE_ROOT)/ace/Reactor.i \ + $(ACE_ROOT)/ace/Reactor_Impl.h .obj/video.o .obj/video.so .shobj/video.o .shobj/video.so: video.cpp \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -332,14 +812,16 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - decoders.h util.h video.h proto.h global.h ui.h + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i decoders.h \ + util.h video.h proto.h global.h ui.h .obj/vp.o .obj/vp.so .shobj/vp.o .shobj/vp.so: vp.cpp \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -351,18 +833,16 @@ realclean: clean $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ - $(ACE_ROOT)/ace/Log_Record.i \ - newproto.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ + $(ACE_ROOT)/ace/Log_Record.i newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h dither.h video.h proto.h ui.h .obj/Command_Handler.o .obj/Command_Handler.so .shobj/Command_Handler.o .shobj/Command_Handler.so: Command_Handler.cpp Command_Handler.h \ - $(ACE_ROOT)/ace/Reactor.h \ - $(ACE_ROOT)/ace/Handle_Set.h \ - $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/OS.h \ $(ACE_ROOT)/ace/inc_user_config.h \ $(ACE_ROOT)/ace/config.h \ - $(ACE_ROOT)/ace/config-sunos5.5.h \ $(ACE_ROOT)/ace/config-g++-common.h \ $(ACE_ROOT)/ace/streams.h \ $(ACE_ROOT)/ace/Basic_Types.h \ @@ -371,9 +851,15 @@ realclean: clean $(ACE_ROOT)/ace/Trace.h \ $(ACE_ROOT)/ace/Log_Msg.h \ $(ACE_ROOT)/ace/Log_Record.h \ + $(ACE_ROOT)/ace/ACE.h \ $(ACE_ROOT)/ace/ACE.i \ $(ACE_ROOT)/ace/Log_Priority.h \ + $(ACE_ROOT)/ace/SString.h \ + $(ACE_ROOT)/ace/SString.i \ + $(ACE_ROOT)/ace/Malloc_Base.h \ $(ACE_ROOT)/ace/Log_Record.i \ + $(ACE_ROOT)/ace/Reactor.h \ + $(ACE_ROOT)/ace/Handle_Set.h \ $(ACE_ROOT)/ace/Handle_Set.i \ $(ACE_ROOT)/ace/Timer_Queue.h \ $(ACE_ROOT)/ace/Synch.h \ @@ -399,9 +885,10 @@ realclean: clean $(ACE_ROOT)/ace/Signal.h \ $(ACE_ROOT)/ace/Containers.h \ $(ACE_ROOT)/ace/Containers.i \ - $(ACE_ROOT)/ace/Containers.cpp \ + $(ACE_ROOT)/ace/Containers_T.h \ + $(ACE_ROOT)/ace/Containers_T.i \ + $(ACE_ROOT)/ace/Containers_T.cpp \ $(ACE_ROOT)/ace/Malloc.h \ - $(ACE_ROOT)/ace/Malloc_Base.h \ $(ACE_ROOT)/ace/Malloc.i \ $(ACE_ROOT)/ace/Malloc_T.h \ $(ACE_ROOT)/ace/Malloc_T.i \ @@ -421,164 +908,36 @@ realclean: clean $(ACE_ROOT)/ace/ARGV.h \ $(ACE_ROOT)/ace/ARGV.i \ $(TAO_ROOT)/tao/TAO.h \ - $(TAO_ROOT)/tao/corba.h \ - $(TAO_ROOT)/tao/orbconf.h \ - $(ACE_ROOT)/ace/Get_Opt.h \ - $(ACE_ROOT)/ace/Get_Opt.i \ - $(ACE_ROOT)/ace/SOCK_Stream.h \ - $(ACE_ROOT)/ace/SOCK_IO.h \ - $(ACE_ROOT)/ace/SOCK.h \ - $(ACE_ROOT)/ace/Addr.h \ - $(ACE_ROOT)/ace/Addr.i \ - $(ACE_ROOT)/ace/IPC_SAP.h \ - $(ACE_ROOT)/ace/IPC_SAP.i \ - $(ACE_ROOT)/ace/SOCK.i \ - $(ACE_ROOT)/ace/SOCK_IO.i \ - $(ACE_ROOT)/ace/INET_Addr.h \ - $(ACE_ROOT)/ace/INET_Addr.i \ - $(ACE_ROOT)/ace/SOCK_Stream.i \ - $(ACE_ROOT)/ace/Hash_Map_Manager.h \ - $(ACE_ROOT)/ace/Hash_Map_Manager.cpp \ - $(ACE_ROOT)/ace/Service_Config.h \ - $(ACE_ROOT)/ace/Service_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.h \ - $(ACE_ROOT)/ace/Shared_Object.i \ - $(ACE_ROOT)/ace/Service_Object.i \ - $(ACE_ROOT)/ace/SString.h \ - $(ACE_ROOT)/ace/SString.i \ - $(ACE_ROOT)/ace/Service_Config.i \ - $(ACE_ROOT)/ace/Svc_Conf_Tokens.h \ - $(ACE_ROOT)/ace/SOCK_Acceptor.h \ - $(ACE_ROOT)/ace/Time_Value.h \ - $(ACE_ROOT)/ace/SOCK_Acceptor.i \ - $(ACE_ROOT)/ace/SOCK_Connector.h \ - $(ACE_ROOT)/ace/SOCK_Connector.i \ - $(ACE_ROOT)/ace/Strategies.h \ - $(ACE_ROOT)/ace/Strategies_T.h \ - $(ACE_ROOT)/ace/Synch_Options.h \ - $(ACE_ROOT)/ace/Synch_Options.i \ - $(ACE_ROOT)/ace/Strategies_T.i \ - $(ACE_ROOT)/ace/Strategies_T.cpp \ - $(ACE_ROOT)/ace/Service_Repository.h \ - $(ACE_ROOT)/ace/Service_Types.h \ - $(ACE_ROOT)/ace/Service_Types.i \ - $(ACE_ROOT)/ace/Service_Repository.i \ - $(ACE_ROOT)/ace/Thread_Manager.h \ - $(ACE_ROOT)/ace/Thread_Manager.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.h \ - $(ACE_ROOT)/ace/Message_Queue.h \ + $(TAO_ROOT)/tao/corbafwd.h \ + $(ACE_ROOT)/ace/CDR_Stream.h \ $(ACE_ROOT)/ace/Message_Block.h \ $(ACE_ROOT)/ace/Message_Block.i \ - $(ACE_ROOT)/ace/IO_Cntl_Msg.h \ - $(ACE_ROOT)/ace/Message_Queue_T.h \ - $(ACE_ROOT)/ace/Message_Queue_T.i \ - $(ACE_ROOT)/ace/Message_Queue_T.cpp \ - $(ACE_ROOT)/ace/Message_Queue.i \ - $(ACE_ROOT)/ace/WFMO_Reactor.i \ - $(ACE_ROOT)/ace/Strategies.i \ - $(ACE_ROOT)/ace/Connector.h \ - $(ACE_ROOT)/ace/Map_Manager.h \ - $(ACE_ROOT)/ace/Map_Manager.i \ - $(ACE_ROOT)/ace/Map_Manager.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.h \ - $(ACE_ROOT)/ace/Task.h \ - $(ACE_ROOT)/ace/Task.i \ - $(ACE_ROOT)/ace/Task_T.h \ - $(ACE_ROOT)/ace/Task_T.i \ - $(ACE_ROOT)/ace/Task_T.cpp \ - $(ACE_ROOT)/ace/Module.h \ - $(ACE_ROOT)/ace/Module.i \ - $(ACE_ROOT)/ace/Module.cpp \ - $(ACE_ROOT)/ace/Stream_Modules.h \ - $(ACE_ROOT)/ace/Stream_Modules.i \ - $(ACE_ROOT)/ace/Stream_Modules.cpp \ - $(ACE_ROOT)/ace/Dynamic.h \ - $(ACE_ROOT)/ace/Dynamic.i \ - $(ACE_ROOT)/ace/Singleton.h \ - $(ACE_ROOT)/ace/Singleton.i \ - $(ACE_ROOT)/ace/Singleton.cpp \ - $(ACE_ROOT)/ace/Svc_Handler.i \ - $(ACE_ROOT)/ace/Svc_Handler.cpp \ - $(ACE_ROOT)/ace/Connector.i \ - $(ACE_ROOT)/ace/Connector.cpp \ - $(ACE_ROOT)/ace/Acceptor.h \ - $(ACE_ROOT)/ace/Acceptor.i \ - $(ACE_ROOT)/ace/Acceptor.cpp \ - $(TAO_ROOT)/tao/Align.h \ - $(TAO_ROOT)/tao/ORB.h \ + $(ACE_ROOT)/ace/Message_Block_T.h \ + $(ACE_ROOT)/ace/Message_Block_T.i \ + $(ACE_ROOT)/ace/Message_Block_T.cpp \ + $(ACE_ROOT)/ace/CDR_Stream.i \ + $(TAO_ROOT)/tao/try_macros.h \ + $(TAO_ROOT)/tao/orbconf.h \ + $(ACE_ROOT)/ace/CORBA_macros.h \ + $(TAO_ROOT)/tao/POAC.h \ + $(TAO_ROOT)/tao/PolicyC.h \ + $(TAO_ROOT)/tao/Object.h \ + $(TAO_ROOT)/tao/Object.i \ $(TAO_ROOT)/tao/Sequence.h \ + $(TAO_ROOT)/tao/Managed_Types.h \ + $(TAO_ROOT)/tao/ORB.h \ + $(TAO_ROOT)/tao/Exception.h \ + $(TAO_ROOT)/tao/Exception.i \ + $(TAO_ROOT)/tao/ORB.i \ + $(TAO_ROOT)/tao/Managed_Types.i \ $(TAO_ROOT)/tao/Sequence.i \ $(TAO_ROOT)/tao/Sequence_T.h \ $(TAO_ROOT)/tao/Sequence_T.i \ $(TAO_ROOT)/tao/Sequence_T.cpp \ - $(TAO_ROOT)/tao/Object_KeyC.h \ - $(TAO_ROOT)/tao/Object_KeyC.i \ - $(TAO_ROOT)/tao/Union.h \ - $(TAO_ROOT)/tao/ORB.i \ - $(TAO_ROOT)/tao/Exception.h \ - $(TAO_ROOT)/tao/Exception.i \ - $(TAO_ROOT)/tao/Any.h \ - $(TAO_ROOT)/tao/Any.i \ - $(TAO_ROOT)/tao/NVList.h \ - $(TAO_ROOT)/tao/NVList.i \ - $(TAO_ROOT)/tao/Principal.h \ - $(TAO_ROOT)/tao/Request.h \ - $(TAO_ROOT)/tao/Request.i \ - $(TAO_ROOT)/tao/Stub.h \ - $(TAO_ROOT)/tao/Stub.i \ - $(TAO_ROOT)/tao/Object.h \ - $(TAO_ROOT)/tao/Object.i \ - $(TAO_ROOT)/tao/Typecode.h \ - $(TAO_ROOT)/tao/Typecode.i \ - $(TAO_ROOT)/tao/Marshal.h \ - $(TAO_ROOT)/tao/Marshal.i \ - $(TAO_ROOT)/tao/CDR.h \ - $(TAO_ROOT)/tao/CDR.i \ - $(TAO_ROOT)/tao/PolicyC.h \ $(TAO_ROOT)/tao/PolicyC.i \ $(TAO_ROOT)/tao/CurrentC.h \ $(TAO_ROOT)/tao/CurrentC.i \ - $(TAO_ROOT)/tao/POA.h \ - $(TAO_ROOT)/tao/POAC.h \ $(TAO_ROOT)/tao/POAC.i \ - $(TAO_ROOT)/tao/Servant_Base.h \ - $(TAO_ROOT)/tao/POAS.h \ - $(TAO_ROOT)/tao/POA_CORBA.h \ - $(TAO_ROOT)/tao/POAS.i \ - $(TAO_ROOT)/tao/Active_Object_Map.h \ - $(TAO_ROOT)/tao/POA.i \ - $(TAO_ROOT)/tao/poa_macros.h \ - $(TAO_ROOT)/tao/params.h \ - $(TAO_ROOT)/tao/params.i \ - $(TAO_ROOT)/tao/Connect.h \ - $(TAO_ROOT)/tao/Connect.i \ - $(TAO_ROOT)/tao/ORB_Core.h \ - $(TAO_ROOT)/tao/ORB_Core.i \ - $(ACE_ROOT)/ace/Dynamic_Service.h \ - $(ACE_ROOT)/ace/Dynamic_Service.cpp \ - $(TAO_ROOT)/tao/Operation_Table.h \ - $(TAO_ROOT)/tao/debug.h \ - $(TAO_ROOT)/tao/Client_Strategy_Factory.h \ - $(TAO_ROOT)/tao/Server_Strategy_Factory.h \ - $(TAO_ROOT)/tao/default_client.h \ - $(TAO_ROOT)/tao/default_client.i \ - $(TAO_ROOT)/tao/default_server.h \ - $(TAO_ROOT)/tao/ORB_Strategies_T.h \ - $(TAO_ROOT)/tao/ORB_Strategies_T.i \ - $(TAO_ROOT)/tao/ORB_Strategies_T.cpp \ - $(TAO_ROOT)/tao/default_server.i \ - $(TAO_ROOT)/tao/IIOP_Object.h \ - $(TAO_ROOT)/tao/IIOP_Object.i \ - $(TAO_ROOT)/tao/IIOP_ORB.h \ - $(TAO_ROOT)/tao/IIOP_ORB.i \ - $(TAO_ROOT)/tao/IIOP_Interpreter.h \ - $(TAO_ROOT)/tao/GIOP.h \ - $(TAO_ROOT)/tao/GIOP.i \ - $(TAO_ROOT)/tao/Invocation.h \ - $(TAO_ROOT)/tao/Invocation.i \ - $(TAO_ROOT)/tao/Server_Request.h \ - $(TAO_ROOT)/tao/Server_Request.i \ - $(TAO_ROOT)/tao/singletons.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Video_ControlC.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Video_ControlC.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingC.h \ @@ -607,6 +966,8 @@ realclean: clean $(ACE_ROOT)/ace/Process.h \ $(ACE_ROOT)/ace/Process.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/AV/Endpoint_Strategy.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp \ $(TAO_ROOT)/orbsvcs/orbsvcs/Null_MediaCtrlS.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/Null_MediaCtrlC.h \ $(TAO_ROOT)/orbsvcs/orbsvcs/Null_MediaCtrlC.i \ @@ -614,16 +975,43 @@ realclean: clean $(TAO_ROOT)/orbsvcs/orbsvcs/Null_MediaCtrlS_T.i \ $(TAO_ROOT)/orbsvcs/orbsvcs/Null_MediaCtrlS_T.cpp \ $(TAO_ROOT)/orbsvcs/orbsvcs/Null_MediaCtrlS.i \ + $(TAO_ROOT)/orbsvcs/orbsvcs/Trader/Trader.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingC.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingC.i \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.i \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS_T.cpp \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosTradingS.i \ $(ACE_ROOT)/ace/High_Res_Timer.h \ $(ACE_ROOT)/ace/High_Res_Timer.i \ - ctr.cpp \ + $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/Naming_Utils.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/IOR_Multicast.h \ + $(ACE_ROOT)/ace/SOCK_Dgram_Mcast.h \ + $(ACE_ROOT)/ace/SOCK_Dgram_Mcast.i \ + $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/CosNaming_i.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS_T.h \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS_T.i \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS_T.cpp \ + $(TAO_ROOT)/orbsvcs/orbsvcs/CosNamingS.i \ + $(TAO_ROOT)/orbsvcs/orbsvcs/Naming/Entries.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverS.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverC.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverC.i \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverS_T.h \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverS_T.i \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverS_T.cpp \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/ReceiverS.i \ + ab.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/include/common.h \ newproto.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h \ global.h \ - $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h \ $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h \ - $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h \ + vb.h ctr.cpp \ + $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.h # IF YOU PUT ANYTHING HERE IT WILL GO AWAY 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 7cbccea9cc1..2887981ee52 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ab.cpp @@ -25,62 +25,51 @@ * Department of Computer Science and Engineering * email: scen@cse.ogi.edu */ -#include <stdio.h> -#include <errno.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -#include <stdlib.h> -#include <netinet/in.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Intrinsic.h> -#ifdef __svr4__ -#include <stropts.h> -#include <sys/conf.h> -#endif -#include "include/common.h" -#include "newproto.h" -#include "global.h" -#include "mpeg_shared/filters.h" -#include "mpeg_shared/fileio.h" -#include "mpeg_shared/com.h" +extern int asp[2]; +extern void set_exit_routine_tag(int tag); + +#include "ab.h" ACE_RCSID(mpeg_client, ab, "$Id$") -/* magic number -- deviation is considered - caused by clock drift only if rate <= 1/MAX_CLOCK_DRIFT. - */ -#define MAX_CLOCK_DRIFT 50 - -#define max(a,b) ((a)>(b) ? (a) : (b)) -#define min(a,b) ((a)<(b) ? (a) : (b)) - -typedef struct { - int bufsize; /* number of bytes for the buffer pointed by 'buf' */ - char * buf; /* pointer to the data buffer area */ - int bps; /* current byte-per-sample */ - int size; /* number of samples the buffer can hold */ - int samples; /* number of samples in the buffer; */ - int stuff; /* number of stuff samples to be read by ABgetSamples() */ - int ts; /* tail-sample: the next sample to be comsumed by CTR */ - int hs; /* head-sample: the next sample to be expected from the network */ - int tind; /* index of the ts-sample in the buf */ -} ABBuffer; - -static ABBuffer * abuf; -static int sid; -static int exit_tag = 0; -static int savedSocket; - -static void set_silence(char *buf, int samples) +AudioBuffer::AudioBuffer (void) + :temp (0), + bytes (-1), + abuf (0), + sid (-1), + exit_tag (0), + savedSocket (-1), + packet (0), + pkt_data (0), + conn_tag (-1), + fbstate (0), + waketime (0), + pcmdsn (-1), + mode_ (INVALID) +{ +} + +//destructor. +AudioBuffer::~AudioBuffer (void) +{ + if (ACE_Reactor::instance ()->remove_handler (this->handler_,ACE_Event_Handler::READ_MASK) == -1) + ACE_DEBUG ((LM_ERROR,"(%P)remove handler failed for Video_Notification_Handler\n")); + + delete this->handler_; + if (ACE_Reactor::instance ()->remove_handler (this,ACE_Event_Handler::READ_MASK) == -1) + ACE_DEBUG ((LM_ERROR,"(%P)remove handler failed for VideoBuffer\n")); + +} + +void +AudioBuffer::set_silence (char *buf, int samples) { memset(buf, 0xff, samples * shared->audioPara.bytesPerSample); } -void ABinitBuf(int size) /* size in bytes */ +void +AudioBuffer::ABinitBuf (int size) /* size in bytes */ { abuf = (ABBuffer *)creat_shared_mem(size); abuf->bufsize = size - sizeof(*abuf); @@ -88,7 +77,8 @@ void ABinitBuf(int size) /* size in bytes */ sid = creat_semaphore(); } -void ABflushBuf(int nextSample) /* flush the whole buffer */ +void +AudioBuffer::ABflushBuf (int nextSample) /* flush the whole buffer */ { enter_cs(sid); abuf->bps = shared->audioPara.bytesPerSample; @@ -101,12 +91,14 @@ void ABflushBuf(int nextSample) /* flush the whole buffer */ leave_cs(sid); } -int ABcheckSamples(void) /* returns # of samples in ABbuf */ +int +AudioBuffer::ABcheckSamples (void) /* returns # of samples in ABbuf */ { return abuf->samples; } -int ABgetSamples(char * buf, int samples) +int +AudioBuffer::ABgetSamples (char * buf, int samples) /* read at most given number of samples from AB to buf, returns number of sample actually read */ { @@ -125,12 +117,12 @@ int ABgetSamples(char * buf, int samples) /* there may be fewer samples in abuf */ if (as > 0) { int part1 = min(as, abuf->size - abuf->tind); - memcpy(buf, abuf->buf + (abuf->bps * abuf->tind), part1 * abuf->bps); + ACE_OS::memcpy (buf, abuf->buf + (abuf->bps * abuf->tind), part1 * abuf->bps); set_silence(abuf->buf + (abuf->bps * abuf->tind), part1); if (part1 < as) { /* This read cross the boundary of abuf */ - memcpy(buf + (part1 * abuf->bps), - abuf->buf, - (as - part1) * abuf->bps); + ACE_OS::memcpy (buf + (part1 * abuf->bps), + abuf->buf, + (as - part1) * abuf->bps); set_silence(abuf->buf, as - part1); } } @@ -145,7 +137,8 @@ int ABgetSamples(char * buf, int samples) /* if samples < 0; then stuff |samples| silient samples to ABgetSamples(), otherwise wipe out this number of samples from AB */ -int ABskipSamples(int samples) +int +AudioBuffer::ABskipSamples (int samples) { enter_cs(sid); if (samples <= 0) { @@ -160,327 +153,423 @@ int ABskipSamples(int samples) return samples; } -void ABdeleteBuf(void) +void +AudioBuffer::ABdeleteBuf (void) { remove_shared_mem((char *)abuf); } -void ABdeleteSem(void) +void +AudioBuffer::ABdeleteSem (void) { remove_semaphore(sid); } /* SIGUSR1 from CTR is for killing this process, without affecting any other ones. */ -static void exit_on_kill(void) +void +AudioBuffer::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); - VBdeleteBuf(); - exit(0); -} - -static void usr1_handler(int sig) -{ - cerr << "ABprocess got sigusr1\n"; - exit_on_kill (); + vbuffer->VBdeleteBuf(); + ACE_OS::exit (0); } - -static void usr2_handler(int sig) +ACE_HANDLE +AudioBuffer::get_handle (void) const { - Fprintf(stderr, "VB void usr2_handler (supposed for stat).\n"); + return this->dataSocket; } -#define PACKET_SIZE 8192 -#define STARTUP_WAIT 10000000 -#define ACTION_WAIT 5000000 - -void ABprocess(int dataSocket) +int +AudioBuffer::handle_input (ACE_HANDLE fd) { - - AudioPacket * packet; - char * pkt_data; - int conn_tag = shared->audioMaxPktSize; - - /* following are for feedback */ - int fbstate = 0; - unsigned waketime; - int pcmdsn = -1; /* previous cmdsn */ - - exit_tag = 0; - - savedSocket = dataSocket; - - setsignal(SIGUSR1, usr1_handler); - setsignal(SIGUSR2, usr2_handler); - - packet = (AudioPacket *)malloc(PACKET_SIZE); - if (packet == NULL) { - perror("AB failed to allocate mem for packet buffer"); - exit(1); - } - pkt_data = (char *)packet + sizeof(*packet); - - for (;;) { - int len; - int bytes; - if (conn_tag >= 0) { - bytes = sizeof(*packet); - + // ACE_DEBUG ((LM_DEBUG,"handle_input:mode = %d\n",this->mode_)); + int len; + switch (this->mode_) + { + case READ_HEADER: + { + int len; + if (conn_tag >= 0) + { + // ACE_DEBUG ((LM_DEBUG,"non discard mode: ")); + if (bytes < 0) + bytes = sizeof(*packet); + len = ACE_OS::read (dataSocket, (char *)temp, bytes); + } + else + { /* discard mode packet stream, read all bytes */ + // ACE_DEBUG ((LM_DEBUG,"discard mode: ")); + if (bytes < 0) + bytes = PACKET_SIZE; + len = ACE_OS::read (dataSocket, (char *)packet, bytes); + // ACE_DEBUG ((LM_DEBUG,"(%P|%t) ABprocess: got a %d sized packet\n",len)); + } + if (len == -1) + { + if (errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN) + { + return 0; + } + perror("AB ACE_OS::read () audio packet from discard-mode packet stream"); + ACE_Reactor::instance ()->end_event_loop (); + return -1; + } - len = wait_read_bytes(dataSocket, (char *)packet, bytes); - if (exit_tag) exit_on_kill(); - } - else { /* discard mode packet stream, read all bytes */ - bytes = PACKET_SIZE; - len = read(dataSocket, (char *)packet, bytes); - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) ABprocess: got a %d sized packet\n",len)); - if (exit_tag) exit_on_kill(); - if (len == -1) { - if (errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN) { - usleep(10000); - if (exit_tag) exit_on_kill(); - continue; - } - perror("AB read() audio packet from discard-mode packet stream"); - exit(1); - } - } - if (len == 0) { - fprintf(stderr, "Error: AB found dataSocket broken\n"); - exit(1); - } - if (len < sizeof(*packet)) { /* unknown packet */ - fprintf(stderr, "Warn: AB discard len = %d bytes of supposed header.\n", len); - continue; - } + if (len == 0) + { + fprintf(stderr, "Error: AB found dataSocket broken\n"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + // ACE_DEBUG ((LM_DEBUG,"packet: bytes = %d,len = %d\n",bytes,len)); + if (conn_tag >= 0) + { + temp += len; + bytes -= len; + if (bytes == 0) + { + // header reading is done. + this->mode_ = READ_DATA; + bytes = -1; + len = sizeof (*packet); + } + else + return 0; + } + if (len < sizeof (*packet)) + { + fprintf(stderr, "Warn: AB discard len = %d bytes of supposed header.\n", len); + return 0; + } + // process the header. #ifdef NeedByteOrderConversion - packet->dataBytes = ntohl(packet->dataBytes); + packet->dataBytes = ntohl(packet->dataBytes); #endif - // ACE_DEBUG ((LM_DEBUG,"(%P|%t) ABprocess: Received %d sized packet\n",len)); - if (packet->dataBytes <= 0) { - fprintf(stderr, "AB Error: pkt->dataBytes %d, len %d\n", - packet->dataBytes, - len); - exit(1); - } - bytes = packet->dataBytes + sizeof(*packet); + // ACE_DEBUG ((LM_DEBUG,"(%P|%t) ABprocess: Received %d sized packet\n",len)); + if (packet->dataBytes <= 0) + { + fprintf(stderr, "AB Error: pkt->dataBytes %d, len %d\n", + packet->dataBytes, + len); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + bytes = packet->dataBytes + sizeof(*packet); - if (bytes > PACKET_SIZE) { - Fprintf(stderr, "Fatal error: AB packet buf (%dB) too small (%d)\n", - PACKET_SIZE, bytes); - exit(1); - } - if (conn_tag >= 0) { - len = wait_read_bytes(dataSocket, (char *)packet + sizeof(*packet), - bytes - sizeof(*packet)); - if (len <= 0) { - if (len == -1) perror("AB encounter error on wait_read_bytes()"); - else fprintf(stderr, "AB encounter EOF on wait_read_bytes()\n"); + if (bytes > PACKET_SIZE) + { + Fprintf(stderr, "Fatal error: AB packet buf (%dB) too small (%d)\n", + PACKET_SIZE, bytes); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + if (conn_tag > 0) + { + temp = (char *)packet + sizeof(*packet); + bytes = bytes - sizeof(*packet); + ACE_DEBUG ((LM_DEBUG,"(%P) Ready to read the data part of the packet\n")); + break; + } } - } + // fall through and process the header. + case READ_DATA: + { + // code to read the audio packet and buffer it. + if (conn_tag >= 0) + { + len = ACE_OS::read (dataSocket,temp,bytes); + + if (len <= 0) + { + if (len == -1)ACE_OS::perror ("AB encounter error on wait_read_bytes()"); + else fprintf(stderr, "AB encounter EOF on wait_read_bytes()\n"); + } + temp +=len; + bytes -= len; + if (bytes != 0) + return 0; + } + // set the parameters for the header reading. + this->mode_ = READ_HEADER; + bytes = -1; + temp = (char *)packet; #ifdef NeedByteOrderConversion - packet->cmdsn = ntohl(packet->cmdsn); - packet->samplesPerSecond = ntohl(packet->samplesPerSecond); - packet->resend = ntohl(packet->resend); - packet->firstSample = ntohl(packet->firstSample); - packet->samples = ntohl(packet->samples); - packet->actualSamples = ntohl(packet->actualSamples); - /* dataBytes already byte-reordered */ + packet->cmdsn = ntohl(packet->cmdsn); + packet->samplesPerSecond = ntohl(packet->samplesPerSecond); + packet->resend = ntohl(packet->resend); + packet->firstSample = ntohl(packet->firstSample); + packet->samples = ntohl(packet->samples); + packet->actualSamples = ntohl(packet->actualSamples); + /* dataBytes already byte-reordered */ #endif - /* - Fprintf(stderr, "AB got a packet: %d(%d)\n", - packet->firstSample, packet->samples); - */ - /* - if (packet->firstSample % 10240 && !packet->resend) continue; - */ - if (packet->samples * abuf->bps > PACKET_SIZE - sizeof(*packet)) { - fprintf(stderr, "Fatal error: AB has too small packet buffer, %d out of %d\n", - PACKET_SIZE, packet->samples * abuf->bps + sizeof(*packet)); - exit(1); - } + /* + Fprintf(stderr, "AB got a packet: %d(%d)\n", + packet->firstSample, packet->samples); + */ + /* + if (packet->firstSample % 10240 && !packet->resend) continue; + */ + if (packet->samples * abuf->bps > PACKET_SIZE - sizeof(*packet)) { + fprintf(stderr, "Fatal error: AB has too small packet buffer, %d out of %d\n", + PACKET_SIZE, packet->samples * abuf->bps + sizeof(*packet)); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } - if (packet->cmdsn != shared->cmdsn) { /* outdated packet */ - /* - Fprintf(stderr, "AB discarded an outdated packet\n"); - */ - continue; - } - enter_cs(sid); - if (packet->firstSample + packet->samples <= abuf->ts) { - /* all samples too late, discard it */ - abuf->hs = max(abuf->hs, packet->firstSample + packet->samples); - abuf->samples = abuf->hs - abuf->ts; - leave_cs(sid); - /* - Fprintf(stderr, "AB all sample in packet %d(%d) too late\n", - packet->firstSample, packet->samples); - */ - goto feedback_code; - } - if (packet->firstSample >= abuf->ts + abuf->size) { - /* all samples too early, discard the packet */ - abuf->hs = max(abuf->hs, packet->firstSample + packet->samples); - abuf->samples = abuf->hs - abuf->ts; - leave_cs(sid); - /* - Fprintf(stderr, "AB all sample in packet %d(%d) too early\n", - packet->firstSample, packet->samples); - */ - goto feedback_code; - } - - if (packet->samples > packet->actualSamples) { - leave_cs(sid); - fprintf(stderr, "Error: AB interpolation not available yet.\n"); - exit(1); - } - - { - int oldhs = abuf->hs; - int firstSample = max(packet->firstSample, abuf->ts); - int samples = min(packet->samples - - (firstSample - packet->firstSample), - (abuf->ts + abuf->size) - packet->firstSample); - char * data = pkt_data + - (firstSample - packet->firstSample) * abuf->bps; - int dstart = (abuf->tind + (firstSample - abuf->ts)) % abuf->size; - int part1 = min(samples, abuf->size - dstart); - memcpy(abuf->buf + (dstart * abuf->bps), data, part1 * abuf->bps); - if (part1 < samples) { - memcpy(abuf->buf, data + part1 * abuf->bps, - (samples - part1) * abuf->bps); - } - abuf->hs = max(abuf->hs, packet->firstSample + packet->samples); - abuf->samples = abuf->hs - abuf->ts; - dstart =max(oldhs, abuf->ts); + if (packet->cmdsn != shared->cmdsn) { /* outdated packet */ + /* + Fprintf(stderr, "AB discarded an outdated packet\n"); + */ + return 0; + } + enter_cs(sid); + if (packet->firstSample + packet->samples <= abuf->ts) + { + /* all samples too late, discard it */ + abuf->hs = max(abuf->hs, packet->firstSample + packet->samples); + abuf->samples = abuf->hs - abuf->ts; + leave_cs(sid); + /* + Fprintf(stderr, "AB all sample in packet %d(%d) too late\n", + packet->firstSample, packet->samples); + */ + feedback (); + } + else if (packet->firstSample >= abuf->ts + abuf->size) { + /* all samples too early, discard the packet */ + abuf->hs = max(abuf->hs, packet->firstSample + packet->samples); + abuf->samples = abuf->hs - abuf->ts; + leave_cs(sid); + /* + Fprintf(stderr, "AB all sample in packet %d(%d) too early\n", + packet->firstSample, packet->samples); + */ + feedback (); + } + else if (packet->samples > packet->actualSamples) { + leave_cs(sid); + fprintf(stderr, "Error: AB interpolation not available yet.\n"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + else + { + int oldhs = abuf->hs; + int firstSample = max(packet->firstSample, abuf->ts); + int samples = min(packet->samples - + (firstSample - packet->firstSample), + (abuf->ts + abuf->size) - packet->firstSample); + char * data = pkt_data + + (firstSample - packet->firstSample) * abuf->bps; + int dstart = (abuf->tind + (firstSample - abuf->ts)) % abuf->size; + int part1 = min(samples, abuf->size - dstart); + ACE_OS::memcpy (abuf->buf + (dstart * abuf->bps), data, part1 * abuf->bps); + if (part1 < samples) { + memcpy(abuf->buf, data + part1 * abuf->bps, + (samples - part1) * abuf->bps); + } + abuf->hs = max(abuf->hs, packet->firstSample + packet->samples); + abuf->samples = abuf->hs - abuf->ts; + dstart =max(oldhs, abuf->ts); - leave_cs(sid); + leave_cs(sid); - part1 = firstSample - dstart; - if (packet->resend) { - Fprintf(stderr, "AB got resent %d(%d)\n", - packet->firstSample, packet->samples); - } - else if (part1 > 0) { - int res; - AudioFeedBackPara para; - Fprintf(stderr, "AB found gap %d(%d)\n", dstart, part1); - para.cmdsn = htonl(shared->cmdsn); - para.type = htonl(1); - para.data.ap.firstSample = htonl(dstart); - para.data.ap.samples = htonl(part1); - if (conn_tag != 0) { /* packet stream */ - while ((res = write(dataSocket, (char *)¶, sizeof(para))) == -1) - { - if (errno == EINTR) - continue; - if (errno == ENOBUFS) { - perror("AB Warning, resend-req packet discarded for"); - break; - } - perror("AB error, resend-req packet sending failed"); - exit(1); - } - } - else { - res = wait_write_bytes(dataSocket, (char *)¶, sizeof(para)); - if (res == -1) { - perror("AB error, resend-req packet sending failed"); - exit(1); - } - } - if (res < sizeof(para)) { - fprintf(stderr, "AB warn: send() for gap res %dB < sizeof(para) %dB\n", - res, sizeof(para)); - } + part1 = firstSample - dstart; + if (packet->resend) { + Fprintf(stderr, "AB got resent %d(%d)\n", + packet->firstSample, packet->samples); + } + else if (part1 > 0) { + int res; + AudioFeedBackPara para; + Fprintf(stderr, "AB found gap %d(%d)\n", dstart, part1); + para.cmdsn = htonl(shared->cmdsn); + para.type = htonl(1); + para.data.ap.firstSample = htonl(dstart); + para.data.ap.samples = htonl(part1); + // register ourself for the write handler. + int result; + result = ACE_Reactor::instance ()->register_handler (this,ACE_Event_Handler::WRITE_MASK); + if (result != 0) + return result; + this->mode_ = WRITE_FEEDBACK2; + temp = (char *)¶ + bytes = sizeof (para); + } + } } + break; + default: + break; } - - /* following is feedback algorithm */ - - feedback_code: - - if (shared->live || (!shared->config.syncEffective)) continue; - /* + return 0; +} + +int +AudioBuffer::handle_output (ACE_HANDLE fd) +{ + ACE_DEBUG ((LM_DEBUG,"handle_output:mode = %d\n",this->mode_)); + int res; + if ((this->mode_ == WRITE_FEEDBACK1) || (this->mode_ == WRITE_FEEDBACK2)) + { + // send feedback. + + if (conn_tag != 0) + { /* packet stream */ + res = ACE_OS::write (dataSocket, temp, bytes); + if (res == -1) + { + if (errno == ENOBUFS) { + ACE_OS::perror ("AB Warning, resend-req packet discarded for"); + return 0; + } + ACE_OS::perror ("AB error, resend-req packet sending failed"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + } + else + { + res = ACE_OS::write (dataSocket, temp, bytes); + if (res == -1) { + ACE_OS::perror ("AB error, resend-req packet sending failed"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + } + if (res == 0) + { + ACE_DEBUG ((LM_DEBUG,"(%P|%t)AudioBuffer::handle_output:write failed\n")); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + temp += res; + bytes -= res; + if (bytes != 0) + return 0; + else + { + // remove the write handler. + int result; + result = ACE_Reactor::instance ()->remove_handler (this, + ACE_Event_Handler::WRITE_MASK); + if (result != 0) + return result; + + this->mode_ = READ_HEADER; + temp = (char *)packet; + bytes == -1; + } + } + if (this->mode_ == WRITE_FEEDBACK1) + { + // adjust the wakeup time and feedback state. + waketime = get_usec() + STARTUP_WAIT; + fbstate = 1; + } + return 0; +} + +int +AudioBuffer::ABprocess (int socket) +{ + int result; + ACE_DEBUG ((LM_DEBUG,"(%P|%t)AudioBuffer::ABprocess ()\n")); + packet = (AudioPacket *)ACE_OS::malloc(PACKET_SIZE); + if (packet == NULL) { + ACE_OS::perror ("AB failed to allocate mem for packet buffer"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + + this->dataSocket = socket; + ACE_NEW_RETURN (this->handler_, + Audio_Notification_Handler, + -1); + // Register the notification handler with the reactor. + result = ACE_Reactor::instance ()->register_handler (this->handler_, + ACE_Event_Handler::READ_MASK); + if (result != 0) + return result; + + result = ACE_Reactor::instance ()->register_handler (this, + ACE_Event_Handler::READ_MASK); + + if (result != 0) + return result; + + conn_tag = shared->audioMaxPktSize; + exit_tag = 0; + + this->mode_ = READ_HEADER; + pkt_data = (char *)packet + sizeof(*packet); + temp = (char *)packet; + bytes = -1; + return 0; +} + +// following is feedback algorithm. +void +AudioBuffer::feedback (void) +{ + if (shared->live || (!shared->config.syncEffective)) return; + /* fprintf(stderr, "AB fbstate = %d\n", fbstate); */ - switch (fbstate) { - case 0: /* startup init */ - if (pcmdsn != packet->cmdsn) { - fbstate = 0; - pcmdsn = packet->cmdsn; - } - else { - fbstate = 1; - waketime = get_usec() + STARTUP_WAIT; - } + switch (fbstate) { + case 0: /* startup init */ + if (pcmdsn != packet->cmdsn) { + fbstate = 0; + pcmdsn = packet->cmdsn; + } + else { + fbstate = 1; + waketime = get_usec() + STARTUP_WAIT; + } + break; + case 1: /* startup wait */ + if (pcmdsn != packet->cmdsn) { + fbstate = 0; break; - case 1: /* startup wait */ - if (pcmdsn != packet->cmdsn) { - fbstate = 0; - break; - } - if (get_usec() >= waketime) { - fbstate = 2; - } + } + if (get_usec() >= waketime) { + fbstate = 2; + } + break; + case 2: /* monitoring */ + if (pcmdsn != packet->cmdsn) { + fbstate = 0; break; - case 2: /* monitoring */ - if (pcmdsn != packet->cmdsn) { - fbstate = 0; - break; - } - if (abuf->samples < abuf->size >>2 || - abuf->samples > (abuf->size * 3) >> 2) { - /* feedback action needed */ - AudioFeedBackPara para; - int res; - para.data.fb.addsps = 0; - para.data.fb.addSamples = (abuf->size >> 2) - abuf->samples; - - Fprintf(stderr, "AB sends fb: %dsps, %dsamples\n", - para.data.fb.addsps, - para.data.fb.addSamples); - para.cmdsn = htonl(shared->cmdsn); - para.type = htonl(0); - para.data.fb.addsps = htonl(para.data.fb.addsps); - para.data.fb.addSamples = htonl(para.data.fb.addSamples); - if (conn_tag != 0) { - while ((res = write(dataSocket, (char *)¶, sizeof(para))) == -1) - { - if (errno == EINTR) - continue; - if (errno == ENOBUFS) { - perror("AB Warning, fb packet discarded for"); - break; - } - perror("AB error, fb packet sending failed"); - exit(1); - } - } - else { - res = wait_write_bytes(dataSocket, (char *)¶, sizeof(para)); - if (res == -1) { - perror("AB error, fb packet sending failed"); - exit(1); - } - } - if (res < sizeof(para)) { - fprintf(stderr, "AB warn: send() for sync res %dB < sizeof(para) %dB\n", - res, sizeof(para)); - } + } + if (abuf->samples < abuf->size >>2 || + abuf->samples > (abuf->size * 3) >> 2) + { + /* feedback action needed */ + AudioFeedBackPara para; + int res; + para.data.fb.addsps = 0; + para.data.fb.addSamples = (abuf->size >> 2) - abuf->samples; - waketime = get_usec() + STARTUP_WAIT; - fbstate = 1; + Fprintf(stderr, "AB sends fb: %dsps, %dsamples\n", + para.data.fb.addsps, + para.data.fb.addSamples); + para.cmdsn = htonl(shared->cmdsn); + para.type = htonl(0); + para.data.fb.addsps = htonl(para.data.fb.addsps); + para.data.fb.addSamples = htonl(para.data.fb.addSamples); + int result = ACE_Reactor::instance ()->register_handler (this,ACE_Event_Handler::WRITE_MASK); + if (result != 0) + ACE_DEBUG ((LM_DEBUG,"register_hanlder for write failed\n")); + this->mode_ = WRITE_FEEDBACK1; + temp = (char *)¶ + bytes = sizeof (para); + return; } - break; - default: - break; - } + break; + default: + break; } -} +} + +ACE_HANDLE +Audio_Notification_Handler::get_handle (void) const +{ + return asp[1]; +} diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/audio.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/audio.cpp index e981ecc0e71..b99c7d35cba 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/audio.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/audio.cpp @@ -167,7 +167,7 @@ int InitAudioDevice(void) BytesPerUnit(attributes.type) / SampsPerUnit(attributes.type); shared->AFPara.samplesPerSecond = ac->device->playSampleFreq; /* - memcpy(&(shared->AFPara), &(shared->config.audioPara), sizeof(AudioParameter)); + ACE_OS::memcpy (&(shared->AFPara), &(shared->config.audioPara), sizeof(AudioParameter)); */ useAF = 1; fprintf(stderr, "Using default AudioFile.\n"); @@ -188,14 +188,14 @@ int InitAudioDevice(void) afd = open(AUDIO_DEVICE, O_WRONLY | O_NDELAY); if (afd == -1) { fprintf(stderr, "%s", AUDIO_DEVICE); - perror(" can't be opened for write"); + ACE_OS::perror (" can't be opened for write"); return -1; } cfd = open(AUDIO_CONTROL, O_WRONLY | O_NDELAY); if (cfd == -1) { fprintf(stderr, "%s", AUDIO_DEVICE); - perror(" can't be opened for write"); - close(afd); + ACE_OS::perror (" can't be opened for write"); + ACE_OS::close (afd); afd = -1; return -1; } @@ -203,43 +203,43 @@ int InitAudioDevice(void) if (ioctl(cfd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ULAW) < 0) { fprintf(stderr, "%s" AUDIO_DEVICE); - perror("can't be set to u-law"); - close(afd); - close(cfd); + ACE_OS::perror ("can't be set to u-law"); + ACE_OS::close (afd); + ACE_OS::close (cfd); afd = -1; return -1; } if (ioctl(cfd, AUDIO_SET_CHANNELS, 1) < 0) { fprintf(stderr, "%s" AUDIO_DEVICE); - perror("can't be set to have single channel"); - close(afd); - close(cfd); + ACE_OS::perror ("can't be set to have single channel"); + ACE_OS::close (afd); + ACE_OS::close (cfd); afd = -1; return -1; } if (ioctl(cfd, AUDIO_SET_SAMPLE_RATE, 8000) < 0) { fprintf(stderr, "%s" AUDIO_DEVICE); - perror("can't be set to 8000sps"); - close(afd); - close(cfd); + ACE_OS::perror ("can't be set to 8000sps"); + ACE_OS::close (afd); + ACE_OS::close (cfd); afd = -1; return -1; } if (ioctl(cfd, AUDIO_SET_OUTPUT, AUDIO_OUT_SPEAKER | AUDIO_OUT_HEADPHONE)) { fprintf(stderr, "%s" AUDIO_DEVICE); - perror("can't be set output to both internal speaker and headphone"); - close(afd); - close(cfd); + ACE_OS::perror ("can't be set output to both internal speaker and headphone"); + ACE_OS::close (afd); + ACE_OS::close (cfd); afd = -1; return -1; } if(ioctl(cfd, AUDIO_SET_TXBUFSIZE, 1024*64) < 0) { fprintf(stderr, "%s" AUDIO_DEVICE); - perror("can't be set output buffer size to 64K"); - close(afd); - close(cfd); + ACE_OS::perror ("can't be set output buffer size to 64K"); + ACE_OS::close (afd); + ACE_OS::close (cfd); afd = -1; return -1; } @@ -276,7 +276,7 @@ int InitAudioDevice(void) afd = open(AUDIO_DEVICE, O_WRONLY); if (afd == -1) { fprintf(stderr, "%s", AUDIO_DEVICE); - perror(" can't be opened for write"); + ACE_OS::perror (" can't be opened for write"); return -1; } @@ -380,7 +380,7 @@ unsigned int PlayAudioSamples(unsigned int time, char * buf, int size) } } #else - write(afd, buf, size); + ACE_OS::write (afd, buf, size); #endif current_time += size; 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 7e4de09bfa8..5f5ac9e4b87 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ctr.cpp @@ -58,14 +58,21 @@ ACE_RCSID(mpeg_client, ctr, "$Id$") #define SPEEDHIST_SIZE 20 +#if defined max +#undef max +#endif #define max(a,b) (a>b ? a : b) + +#if defined min +#undef min +#endif #define min(a,b) (a<b ? a : b) 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; static int videoSocket = -1; @@ -113,6 +120,12 @@ static int fb_startup = 0; /* Indicate the first feedback action. The first feed feedback action would then adjust server fps linearly adjstep each time */ +AudioBuffer *abuffer; +VideoBuffer *vbuffer; +int asp[2]; +int vsp[2]; +int vdsp[2]; + #define max(a,b) (a>b ? a : b) #define min(a,b) (a<b ? a : b) @@ -127,91 +140,21 @@ OurCmdRead(char *buf, int size) if (size == 0) return 0; if (cmdBytes > 0) { - memcpy(buf, cmdBuffer, size); + ACE_OS::memcpy (buf, cmdBuffer, size); cmdBytes -= size; cmdBuffer += size; return 0; } - while ((val = read(cmdSocket, (buf), (size))) <= 0) + while ((val = ACE_OS::read (cmdSocket, (buf), (size))) <= 0) { if (val == -1 && errno == EINTR) return 1; if (!val) { - perror("CTR error, EOF reached unexpected within CmdRead()"); + ACE_OS::perror ("CTR error, EOF reached unexpected within CmdRead()"); } else { - perror("CTR CmdRead() from UI through CmdSocket"); + ACE_OS::perror ("CTR CmdRead() from UI through CmdSocket"); } - exit(1); - } - return 0; -} - -void CmdRead(char *buf, int size) -{ - int val; - if (size == 0) return; - if (cmdBytes > 0) - { - memcpy(buf, cmdBuffer, size); - cmdBytes -= size; - cmdBuffer += size; - return; - } - while ((val = read(cmdSocket, (buf), (size))) <= 0) - { - if (val == -1 && errno == EINTR) continue; - if (!val) { - perror("CTR error, EOF reached unexpected within CmdRead()"); - } - else { - perror("CTR CmdRead() from UI through CmdSocket"); - } - exit(1); - } - return; -} - -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); - cmdBytes -= size; - cmdBuffer += size; - return 0; - } - - FD_ZERO(&read_mask); - FD_SET(cmdSocket, &read_mask); -#ifdef _HPUX_SOURCE - if (select(nfds, (int *)&read_mask, NULL, NULL, NULL) == -1) -#else - if (select(nfds, &read_mask, NULL, NULL, NULL) == -1) -#endif - { - if (errno == EINTR) - return -1; - perror("CTR CmdReadNW by select"); - exit(1); - } - if ((val = read(cmdSocket, (buf), (size))) < 0) - { - if (errno == EINTR) - return -1; - - perror("CTR CmdReadNW by read"); - exit(1); - } - if (val == 0) - { - fprintf(stderr, "Error: EOF reached unexpectedly within CmdReadNW()."); - exit(1); + ACE_OS::exit (1); } return 0; } @@ -228,8 +171,8 @@ static void CmdWrite(unsigned char * buf, int size) { if (errno == EINTR) continue; - perror("CTR writes to UI through cmdSocket"); - exit(1); + ACE_OS::perror ("CTR writes to UI through cmdSocket"); + ACE_OS::exit (1); } } @@ -242,7 +185,7 @@ static void SocketRead(int s, char *buf, int size) // fprintf (stderr, "SocketRead: videoSocket = %d\n",videoSocket); for (;;) { - val = read(s, ptr, remain); + val = ACE_OS::read (s, ptr, remain); // fprintf(stderr, "CTR got from %sSocket %d of %d.\n",s == videoSocket ? "video" : "audio", val, remain); @@ -255,14 +198,14 @@ static void SocketRead(int s, char *buf, int size) { fprintf(stderr, "CTR error read %sSocket, ret=%d(size=%d)", s == videoSocket ? "video" : "audio", size-remain, size); - perror(""); - exit(1); + ACE_OS::perror (""); + ACE_OS::exit (1); } if (val == 0) { fprintf(stderr, "CTR error read %sSocket, EOF met, ret=%d(size=%d).\n", s == videoSocket ? "video" : "audio", size-remain, size); - exit(1); + ACE_OS::exit (1); } ptr += val; remain -= val; @@ -270,66 +213,23 @@ static void SocketRead(int s, char *buf, int size) { fprintf(stderr, "CTR error read %sSocket, read too much, ret=%d(size=%d).\n", s == videoSocket ? "video" : "audio", size-remain, size); - exit(1); + ACE_OS::exit (1); } if (remain == 0) break; } } -#if 0 -static void SocketRecv(int s, char *buf, int size) -{ int val, remain = size; - char * ptr = buf; - 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; - continue; - } - if (val == -1) - { - fprintf(stderr, "CTR error read %sSocket, ret=%d(size=%d)", - s == videoSocket ? "video" : "audio", size-remain, size); - perror(""); - exit(1); - } - if (val == 0) - { - fprintf(stderr, "CTR error read %sSocket, EOF met, ret=%d(size=%d).\n", - s == videoSocket ? "video" : "audio", size-remain, size); - exit(1); - } - ptr += val; - remain -= val; - if (remain < 0) - { - fprintf(stderr, "CTR error read %sSocket, read too much, ret=%d(size=%d).\n", - s == videoSocket ? "video" : "audio", size-remain, size); - exit(1); - } - if (remain == 0) - break; - } -} -#endif - #define VideoRead(buf, size) SocketRead(videoSocket, buf, size) #define VideoWrite(buf, psize) \ - { int val; while ((val = write(videoSocket, (buf), (psize))) == -1) \ + { int val; while ((val = ACE_OS::write (videoSocket, (buf), (psize))) == -1) \ { if (errno == EINTR) continue; \ - perror("CTR writes to VS through videoSocket");\ - exit(1); \ + ACE_OS::perror ("CTR writes to VS through videoSocket");\ + ACE_OS::exit (1); \ } \ if (val < (int)(psize)) { \ - fprintf(stderr, "CTR bad VideoWrite, size %d, val %d", psize, val); perror(""); }\ + fprintf(stderr, "CTR bad VideoWrite, size %d, val %d", psize, val);ACE_OS::perror (""); }\ } #define AudioRead(buf, size) SocketRead(audioSocket, buf, size) @@ -337,8 +237,8 @@ static void SocketRecv(int s, char *buf, int size) #define AudioWrite(buf, size) \ { while (write(audioSocket, (buf), (size)) == -1) \ { if (errno == EINTR) continue; \ - perror("CTR writes to AS through audioSocket"); \ - exit(1); \ + ACE_OS::perror ("CTR writes to AS through audioSocket"); \ + ACE_OS::exit (1); \ } \ } @@ -469,15 +369,15 @@ static void PlayAudioInit(void) * (double)shared->audioPara.samplesPerSecond / 1000.0); if (rawBuf == NULL) { - if ((rawBuf = (char *)malloc(AUDIO_BUFSIZE)) == NULL) + if ((rawBuf = (char *)ACE_OS::malloc(AUDIO_BUFSIZE)) == NULL) { - perror("CTR fails to allocate rawBuf for audio channel"); - exit(1); + ACE_OS::perror ("CTR fails to allocate rawBuf for audio channel"); + ACE_OS::exit (1); } - if ((workBuf = (char *)malloc(AUDIO_BUFSIZE)) == NULL) + if ((workBuf = (char *)ACE_OS::malloc(AUDIO_BUFSIZE)) == NULL) { - perror("CTR fails to allocate workBuf for audio channel"); - exit(1); + ACE_OS::perror ("CTR fails to allocate workBuf for audio channel"); + ACE_OS::exit (1); } } AudioBufSize = (AUDIO_BUFSIZE / shared->audioPara.bytesPerSample) * @@ -541,7 +441,7 @@ static int PlayAudio(void) ((double)timer_count / shared->pictureRate) * shared->audioPara.samplesPerSecond); int skip_samples = next_sample - nextASSample; - ABskipSamples(skip_samples); + abuffer->ABskipSamples(skip_samples); nextAFtime += (unsigned int)(((double)skip_samples * (double)shared->audioPara.samplesPerSecond) / (double)shared->samplesPerSecond); @@ -571,10 +471,10 @@ static int PlayAudio(void) please reduce value of parameter 'Audio timer interval',\n\ or 'Audio buffered intervals' or Frames per audio play',\n\ and try again.\n"); - exit(1); + ACE_OS::exit (1); } - read_samples = ABgetSamples(ptr, frame_samples); + read_samples = abuffer->ABgetSamples(ptr, frame_samples); /* convert and play to AF */ { @@ -597,7 +497,7 @@ static int PlayAudio(void) break; else { - memcpy(rawBuf, rawBuf + samples * shared->audioPara.bytesPerSample, + ACE_OS::memcpy (rawBuf, rawBuf + samples * shared->audioPara.bytesPerSample, left_samples * shared->audioPara.bytesPerSample); } } @@ -649,7 +549,7 @@ static void start_timer (void) if (shared->nextSample < shared->totalSamples) { int samples = videoSocket >= 0 ? 1200 : 1200; - while (ABcheckSamples() <= samples) + while (abuffer->ABcheckSamples() <= samples) { if (get_duration(val1, get_usec()) >= MAX_WAIT_USEC) { @@ -821,11 +721,6 @@ static void usr1_handler(int sig) } } -static void default_usr2_handler(int sig) -{ - Fprintf(stderr, "CTR warning: void SIGUSR2 handler.\n"); -} - static void compute_sendPattern(void) { char buf[PATTERN_SIZE]; @@ -852,7 +747,7 @@ static void compute_sendPattern(void) ComputeSendPattern(pat, buf, len, f); shared->qosRecomputes ++; - memcpy(shared->sendPattern, buf, PATTERN_SIZE); + ACE_OS::memcpy (shared->sendPattern, buf, PATTERN_SIZE); f = len - f; if (shared->config.verbose) { @@ -868,32 +763,6 @@ static void compute_sendPattern(void) } } -/* 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 - filterPara #int - 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) { @@ -907,26 +776,30 @@ static void on_exit_routine(void) if (audioSocket >= 0) { - write(audioSocket, &tmp, 1); - ComCloseConn(audioSocket); + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (asp[0],&message,BUFSIZ); + // ACE_OS::write (audioSocket, &tmp, 1); + // ComCloseConn(audioSocket); audioSocket = -1; } if (videoSocket >= 0) { - // write(videoSocket, &tmp, 1); + // ACE_OS::write (videoSocket, &tmp, 1); // ComCloseConn(videoSocket); videoSocket = -1; if (VBpid > 0) { - kill(VBpid, SIGUSR1); + char message[BUFSIZ]; + message [0] = EXIT; + ACE_OS::write (vsp[0],&message,BUFSIZ); + // ACE_OS::kill (VBpid, SIGUSR1); VBpid = -1; } } ComCloseClient(); } -#define EXP_PLAN_FILE "experiment_plan" - int CTRmain(int argc, char **argv) { @@ -936,7 +809,6 @@ int CTRmain(int argc, 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)); @@ -978,50 +850,72 @@ int CTRmain(int argc, shared->config.maxSPframes = DEFAULT_maxSPframes; shared->config.audioConn = 0; shared->config.videoConn = 0; - shared->config.verbose = (!getuid()) || getuid() == DEVELOPER_UID; + shared->config.verbose = (!getuid()) || ACE_OS::getuid () == DEVELOPER_UID; + + ACE_NEW_RETURN (vbuffer, + VideoBuffer (), + -1); + + ACE_NEW_RETURN (abuffer, + AudioBuffer (), + -1); /* create all shared buffers: AB-CTR, VB-VD, VD-VP */ - ABinitBuf(AB_BUF_SIZE); - VBinitBuf(VB_BUF_SIZE); + abuffer->ABinitBuf(AB_BUF_SIZE); + vbuffer->VBinitBuf(VB_BUF_SIZE); VDinitBuf(VD_BUF_SIZE); - CTRpid = getpid(); + CTRpid =ACE_OS::getpid (); set_exit_routine_tag(1); + + // create the notification socket pair. + if (ACE_OS::socketpair (AF_UNIX,SOCK_STREAM,0,asp) == -1) + ACE_ERROR_RETURN ((LM_ERROR,"Error in opening notification socket:%p", + "notification socket"),-1); + + // create the notification socket pair. + if (ACE_OS::socketpair (AF_UNIX,SOCK_STREAM,0,vsp) == -1) + ACE_ERROR_RETURN ((LM_ERROR,"Error in opening notification socket:%p", + "notification socket"),-1); + + if (ACE_OS::socketpair (AF_UNIX,SOCK_STREAM,0,vdsp) == -1) + ACE_ERROR_RETURN ((LM_ERROR,"Error in opening notification socket:%p", + "notification socket"),-1); + /* create command socket pair */ if (ACE_OS::socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) { - perror("CTR error on open cmd socketpair"); - exit(1); + ACE_OS::perror ("CTR error on open cmd socketpair"); + ACE_OS::exit (1); } cmdSocket = sv[0]; - cerr << "cmdsocket = " << cmdSocket << endl; /* fork processes: VD, GUI */ - if ((VDpid = fork()) == -1) + if ((VDpid = ACE_OS::fork ()) == -1) { - perror("CTR error on fork VD"); - exit(1); + ACE_OS::perror ("CTR error on fork VD"); + ACE_OS::exit (1); } else if (VDpid == 0) { - ABdeleteBuf(); - close(sv[0]); - close(sv[1]); + abuffer->ABdeleteBuf(); + ACE_OS::close (sv[0]); + ACE_OS::close (sv[1]); if (realTimeFlag >= 3) { if (SetRTpriority("VD", 0)) realTimeFlag = 0; } VDprocess(CTRpid); } - if ((UIpid = fork()) == -1) + if ((UIpid = ACE_OS::fork ()) == -1) { - perror("CTR error on fork UI"); - exit(1); + ACE_OS::perror ("CTR error on fork UI"); + ACE_OS::exit (1); } else if (UIpid == 0) { - VBdeleteBuf(); - ABdeleteBuf(); - close(sv[0]); + vbuffer->VBdeleteBuf(); + abuffer->ABdeleteBuf(); + ACE_OS::close (sv[0]); if (realTimeFlag >= 2) { #ifdef __svr4__ if (SetRTpriority("VB", 0)) realTimeFlag = 0; @@ -1031,8 +925,7 @@ int CTRmain(int argc, } UIprocess(sv[1]); } - close(sv[1]); - // setsignal(SIGUSR1, usr1_handler); + ACE_OS::close (sv[1]); /* initialize Audio device */ if (InitAudioDevice() == 0) @@ -1042,32 +935,30 @@ int CTRmain(int argc, // ComInitClient(VCR_TCP_PORT, VCR_UNIX_PORT, VCR_ATM_PORT); - if ((vh = (char *)malloc(PATH_SIZE)) == NULL) + if ((vh = (char *)ACE_OS::malloc(PATH_SIZE)) == NULL) { - perror("CTR failed to allocate space for vh"); - exit(1); + ACE_OS::perror ("CTR failed to allocate space for vh"); + ACE_OS::exit (1); } - if ((vf = (char *)malloc(PATH_SIZE)) == NULL) + if ((vf = (char *)ACE_OS::malloc(PATH_SIZE)) == NULL) { - perror("CTR failed to allocate space for vf"); - exit(1); + ACE_OS::perror ("CTR failed to allocate space for vf"); + ACE_OS::exit (1); } - if ((ah = (char *)malloc(PATH_SIZE)) == NULL) + if ((ah = (char *)ACE_OS::malloc(PATH_SIZE)) == NULL) { - perror("CTR failed to allocate space for ah"); - exit(1); + ACE_OS::perror ("CTR failed to allocate space for ah"); + ACE_OS::exit (1); } - if ((af = (char *)malloc(PATH_SIZE)) == NULL) + if ((af = (char *)ACE_OS::malloc(PATH_SIZE)) == NULL) { - perror("CTR failed to allocate space for af"); - exit(1); + ACE_OS::perror ("CTR failed to allocate space for af"); + ACE_OS::exit (1); } 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) @@ -1082,36 +973,23 @@ int CTRmain(int argc, "(%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 run the event loop - // TAO_ORB_Core_instance ()->reactor ()->run_event_loop (); - // int result; -// while (1) -// { int result = command_handler.run (); -// cerr << "result " << result << " "; -// // ACE_DEBUG ((LM_DEBUG,"Command_Handler::run result is %s\n",result)); -// if (errno == EINTR) -// { -// cerr << "Interrupted run "; -// continue; -// } -// else -// break; -// } - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Exited the client command handler event loop\n" - "%p\n", - "run_event_loop")); + if (ABpid == 0) + { + ACE_DEBUG ((LM_DEBUG,"(%d) Restarting the ACE_Reactor::instance ()",ACE_OS::getpid ())); + ACE_Reactor::instance ()->run_event_loop (); + } + + if (VBpid == 0) + { + ACE_DEBUG ((LM_DEBUG,"(%d) Restarting the ACE_Reactor::instance ()",ACE_OS::getpid ())); + ACE_Reactor::instance ()->run_event_loop (); + } + + 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/file.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/file.cpp index b73150396aa..7caa4bb8621 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/file.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/file.cpp @@ -75,7 +75,7 @@ void StartLocalServer(void) /* hostname == "" defaults to local host */ static void StartFile(char *hostname, char *filename) { - char *title = (char *)malloc(strlen(hostname) + strlen(filename) + 10); + char *title = (char *)ACE_OS::malloc(strlen(hostname) +ACE_OS::strlen (filename) + 10); char buf[BUFSIZE]; int len; @@ -88,7 +88,7 @@ static void StartFile(char *hostname, char *filename) strncpy(buf, filename, BUFSIZE); buf[BUFSIZE-1] = 0; } - len = strlen(buf); + len =ACE_OS::strlen (buf); if (title == NULL) title = filename; else sprintf(title, "%s:%s", hostname, filename); @@ -100,7 +100,7 @@ static void StartFile(char *hostname, char *filename) else fprintf(stderr, "Error: type of file %s not known (know only .mpeg .mpg, .au).\n", filename); - if (title != filename) free(title); + if (title != filename) ACE_OS::free (title); } static void dismissCB(Widget W, XtPointer closure, XtPointer call_data) diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2.cpp index d5c3bb52e88..b5d07070aa1 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2.cpp @@ -130,8 +130,8 @@ void FS2DitherImage(unsigned char *lum, unsigned char *cr, /* Allocate error arrays. */ if (first) { - cur_row_error = (char *) malloc(cols+2); - next_row_error = (char *) malloc(cols+2); + cur_row_error = (char *) ACE_OS::malloc(cols+2); + next_row_error = (char *) ACE_OS::malloc(cols+2); first = 0; } diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2fast.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2fast.cpp index 616ffd7bcbe..f5eb87c236f 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2fast.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs2fast.cpp @@ -140,12 +140,12 @@ FS2FastDitherImage ( if (first) { first = 0; - yerr1 = (int *) malloc((w+5)*sizeof(int)); - yerr2 = (int *) malloc((w+5)*sizeof(int)); - uerr1 = (int *) malloc((w+5)*sizeof(int)); - uerr2 = (int *) malloc((w+5)*sizeof(int)); - verr1 = (int *) malloc((w+5)*sizeof(int)); - verr2 = (int *) malloc((w+5)*sizeof(int)); + yerr1 = (int *) ACE_OS::malloc((w+5)*sizeof(int)); + yerr2 = (int *) ACE_OS::malloc((w+5)*sizeof(int)); + uerr1 = (int *) ACE_OS::malloc((w+5)*sizeof(int)); + uerr2 = (int *) ACE_OS::malloc((w+5)*sizeof(int)); + verr1 = (int *) ACE_OS::malloc((w+5)*sizeof(int)); + verr2 = (int *) ACE_OS::malloc((w+5)*sizeof(int)); } /* diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs4.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs4.cpp index 800aca3905d..79174685246 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs4.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/fs4.cpp @@ -128,8 +128,8 @@ FS4DitherImage(unsigned char *lum, unsigned char *cr, FS4Dither *chan_index; if (first) { - cur_row_error = (char *) malloc(cols+2); - next_row_error = (char *) malloc(cols+2); + cur_row_error = (char *) ACE_OS::malloc(cols+2); + next_row_error = (char *) ACE_OS::malloc(cols+2); first = 0; } diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybrid.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybrid.cpp index b6e469d38e9..11b969be3a2 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybrid.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybrid.cpp @@ -69,7 +69,7 @@ InitHybridDither() unsigned char *lmark; for (i=0; i<DITH_SIZE; i++) { - lmark = l_darrays[i] = (unsigned char *) malloc(256); + lmark = l_darrays[i] = (unsigned char *) ACE_OS::malloc(256); for (j=0; j<lum_values[0]; j++) { *lmark++ = 0; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybriderr.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybriderr.cpp index 274ef24cd2f..b07d19ea14b 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybriderr.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/hybriderr.cpp @@ -73,7 +73,7 @@ InitHybridErrorDither() for (i=0; i<DITH_SIZE; i++) { - lmark = l_darrays[i] = (unsigned char *) malloc(256); + lmark = l_darrays[i] = (unsigned char *) ACE_OS::malloc(256); for (j=0; j<lum_values[0]; j++) { *lmark++ = 0; @@ -248,8 +248,8 @@ HybridErrorDitherImage (unsigned char *lum, unsigned char *cr, /* If first time called, allocate error arrays. */ if (first) { - cr_row_errs = (int *) malloc((w+5)*sizeof(int)); - cb_row_errs = (int *) malloc((w+5)*sizeof(int)); + cr_row_errs = (int *) ACE_OS::malloc((w+5)*sizeof(int)); + cb_row_errs = (int *) ACE_OS::malloc((w+5)*sizeof(int)); first = 0; } diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mb_ordered.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mb_ordered.cpp index c1a69ad2041..716648959b6 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mb_ordered.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mb_ordered.cpp @@ -67,16 +67,16 @@ InitMBOrderedDither() int i, j, pos; int err_range, threshval; - pos_2_cb = (unsigned char ****) malloc (DITH_SIZE*sizeof(unsigned char ***)); - cb_2_cr = (unsigned char ***) malloc(CB_RANGE*sizeof(unsigned char **)); - cr_2_l = (unsigned char **) malloc(CR_RANGE*sizeof(unsigned char *)); + pos_2_cb = (unsigned char ****) ACE_OS::malloc (DITH_SIZE*sizeof(unsigned char ***)); + cb_2_cr = (unsigned char ***) ACE_OS::malloc(CB_RANGE*sizeof(unsigned char **)); + cr_2_l = (unsigned char **) ACE_OS::malloc(CR_RANGE*sizeof(unsigned char *)); for (pos=0; pos<DITH_SIZE; pos++) { - pos_2_cb[pos] = (unsigned char ***) malloc(256*(sizeof(unsigned char **))); + pos_2_cb[pos] = (unsigned char ***) ACE_OS::malloc(256*(sizeof(unsigned char **))); for (j=0; j<CB_RANGE; j++) { - cb_2_cr[j] = (unsigned char **) malloc(256*(sizeof(unsigned char *))); + cb_2_cr[j] = (unsigned char **) ACE_OS::malloc(256*(sizeof(unsigned char *))); } for (cb_val=0; cb_val<cb_values[0]; cb_val++) { @@ -100,7 +100,7 @@ InitMBOrderedDither() for (cb_rval=0; cb_rval<CB_RANGE; cb_rval++) { for (j=0; j<CR_RANGE; j++) { - cr_2_l[j] = (unsigned char *) malloc(256*(sizeof(unsigned char))); + cr_2_l[j] = (unsigned char *) ACE_OS::malloc(256*(sizeof(unsigned char))); } for (cr_val=0; cr_val < cr_values[0]; cr_val++) { diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mono.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mono.cpp index 27e8c83a592..879de356059 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mono.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/mono.cpp @@ -86,11 +86,11 @@ MonoDitherImage(register unsigned char *lum, unsigned char *cr, register int next2; if(curr == NULL) { - curr = (int *)malloc(sizeof(int) * (w + 2)); + curr = (int *)ACE_OS::malloc(sizeof(int) * (w + 2)); curr += 1; } if(next == NULL) { - next = (int *)malloc(sizeof(int) * (w + 2)); + next = (int *)ACE_OS::malloc(sizeof(int) * (w + 2)); next += 1; } diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered.cpp index 5306f742242..e62806771b2 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered.cpp @@ -65,7 +65,7 @@ InitOrderedDither() unsigned char *lmark, *cmark; for (i=0; i<DITH_SIZE; i++) { - lmark = l_darrays[i] = (unsigned char *) malloc(256); + lmark = l_darrays[i] = (unsigned char *) ACE_OS::malloc(256); for (j=0; j<lum_values[0]; j++) { *lmark++ = 0; @@ -87,7 +87,7 @@ InitOrderedDither() } for (i=0; i<DITH_SIZE; i++) { - cmark = cr_darrays[i] = (unsigned char *) malloc(256); + cmark = cr_darrays[i] = (unsigned char *) ACE_OS::malloc(256); for (j=0; j<cr_values[0]; j++) { *cmark++ = 0; @@ -109,7 +109,7 @@ InitOrderedDither() } for (i=0; i<DITH_SIZE; i++) { - cmark = cb_darrays[i] = (unsigned char *) malloc(256); + cmark = cb_darrays[i] = (unsigned char *) ACE_OS::malloc(256); for (j=0; j<cb_values[0]; j++) { *cmark++ = 0; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered2.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered2.cpp index 5f8adb7da50..c57d2ba21e1 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered2.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ordered2.cpp @@ -67,16 +67,16 @@ InitOrdered2Dither() int i, j, pos; int err_range, threshval; - pos_2_cb = (unsigned char ****) malloc (DITH_SIZE*sizeof(unsigned char ***)); - cb_2_cr = (unsigned char ***) malloc(CB_RANGE*sizeof(unsigned char **)); - cr_2_l = (unsigned char **) malloc(CR_RANGE*sizeof(unsigned char *)); + pos_2_cb = (unsigned char ****) ACE_OS::malloc (DITH_SIZE*sizeof(unsigned char ***)); + cb_2_cr = (unsigned char ***) ACE_OS::malloc(CB_RANGE*sizeof(unsigned char **)); + cr_2_l = (unsigned char **) ACE_OS::malloc(CR_RANGE*sizeof(unsigned char *)); for (pos=0; pos<DITH_SIZE; pos++) { - pos_2_cb[pos] = (unsigned char ***) malloc(256*(sizeof(unsigned char **))); + pos_2_cb[pos] = (unsigned char ***) ACE_OS::malloc(256*(sizeof(unsigned char **))); for (j=0; j<CB_RANGE; j++) { - cb_2_cr[j] = (unsigned char **) malloc(256*(sizeof(unsigned char *))); + cb_2_cr[j] = (unsigned char **) ACE_OS::malloc(256*(sizeof(unsigned char *))); } for (cb_val=0; cb_val<cb_values[0]; cb_val++) { @@ -100,7 +100,7 @@ InitOrdered2Dither() for (cb_rval=0; cb_rval<CB_RANGE; cb_rval++) { for (j=0; j<CR_RANGE; j++) { - cr_2_l[j] = (unsigned char *) malloc(256*(sizeof(unsigned char))); + cr_2_l[j] = (unsigned char *) ACE_OS::malloc(256*(sizeof(unsigned char))); } for (cr_val=0; cr_val < cr_values[0]; cr_val++) { diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/para.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/para.cpp index 40307c30f9b..de3e5a358f5 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/para.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/para.cpp @@ -125,7 +125,7 @@ static void InitBuf(void) goto InitBuf_exit1; } buf[strlen(buf)-1] = 0; - if (strcmp(buf, BANNER)) + if (ACE_OS::strcmp (buf, BANNER)) { fprintf(stderr, "BANNER in %s not expected, use default parameter value\n", PARAMETER_FILE); @@ -153,7 +153,7 @@ static void SaveBuf(void) if (fp == NULL) { fprintf(stderr, "Fail to open %s for saving para", buf); - perror(""); + ACE_OS::perror (""); return; } Fputs(BANNER); @@ -318,13 +318,13 @@ Widget CreateParameterWindow(Widget parent) { fprintf(stderr, "Error in para.c: fewer titles than parameters, %d out of %d.\n", items, ITEMS); - exit(1); + ACE_OS::exit (1); } - item = (XmString *)malloc(sizeof(*item) * items); + item = (XmString *)ACE_OS::malloc(sizeof(*item) * items); if (item == NULL) { - perror("UI allocate parameter list item(XmString)"); - exit(1); + ACE_OS::perror ("UI allocate parameter list item(XmString)"); + ACE_OS::exit (1); } for (i = 0; i < items; i ++) { @@ -343,7 +343,7 @@ Widget CreateParameterWindow(Widget parent) XtManageChild(wparalist); for (i = 0; i < items; i++) XmStringFree(item[i]); - free(item); + ACE_OS::free (item); } XmFontListFree(fontlist); 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 679c8178430..1469e13ac6f 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/prog.cpp @@ -101,17 +101,17 @@ static void InitBuf(void) deletedprog.title[0] = 0; - item = (XmString *)malloc(sizeof(*item) * ITEMS); + item = (XmString *)ACE_OS::malloc(sizeof(*item) * ITEMS); if (item == NULL) { - perror("UI allocate proglist item(XmString)"); - exit(1); + ACE_OS::perror ("UI allocate proglist item(XmString)"); + ACE_OS::exit (1); } - prog = (struct ProgramList *) malloc(sizeof(*prog) * ITEMS); + prog = (struct ProgramList *) ACE_OS::malloc(sizeof(*prog) * ITEMS); if (prog == NULL) { - perror("UI allocate prog"); - exit(1); + ACE_OS::perror ("UI allocate prog"); + ACE_OS::exit (1); } fp = NULL; if (proglistName[0] != 0) { /* file name given in command line */ @@ -120,7 +120,7 @@ static void InitBuf(void) fp = fopen(buf, "r"); if (fp == NULL) { fprintf(stderr,"PROG.C error opening %s:", proglistName); - perror(""); + ACE_OS::perror (""); } } if (fp == NULL) { @@ -149,7 +149,7 @@ static void InitBuf(void) fname = tmpnam(NULL); if (ptr != NULL) { strncpy(fname, ptr, L_tmpnam); - free(ptr); + ACE_OS::free (ptr); } strcpy(buf, fname); fp = tmpfile(); @@ -226,7 +226,7 @@ lemond.cse.ogi.edu\n\ } else { fprintf(stderr, "Warning: failed to read newly created %s:", buf); - perror(""); + ACE_OS::perror (""); } */ } @@ -244,7 +244,7 @@ lemond.cse.ogi.edu\n\ goto InitBuf_exit1; } buf[strlen(buf)-1] = 0; - if (strncmp(buf, BANNER, strlen(BANNER))) + if (strncmp(buf, BANNER,ACE_OS::strlen (BANNER))) { fprintf(stderr, "BANNER in %s not expected\n", fname); fprintf(stderr, " Expected: %s\n", BANNER); @@ -288,7 +288,7 @@ static void SaveBuf(void) if (fp == NULL) { fprintf(stderr, "Fail to open %s for saving programs", buf); - perror(""); + ACE_OS::perror (""); return; } Fputs(BANNER); @@ -309,8 +309,8 @@ static void CmdWrite(char * buf, int size) while (write(cmdSocket, (buf), (size)) == -1) { if (errno == EINTR) continue; - perror("UI write to cmdSocket"); - exit(1); + ACE_OS::perror ("UI write to cmdSocket"); + ACE_OS::exit (1); } } @@ -321,39 +321,39 @@ void StartProgram(char * title, char * vh, char * vf, char * ah, char * af) int len; if (!cmdBusy) { char *str = title; - len = strlen(str); + len =ACE_OS::strlen (str); // if (len > 0 && str[len-1] == 0x0d) str[len - 1] = 0; // str = vh; - // len = strlen(str); + // len =ACE_OS::strlen (str); if (len > 0 && str[len-1] == 0x0d) str[len - 1] = 0; str = vf; - // len = strlen(str); + // len =ACE_OS::strlen (str); // if (len > 0 && str[len-1] == 0x0d) str[len - 1] = 0; // str = ah; - len = strlen(str); + len =ACE_OS::strlen (str); if (len > 0 && str[len-1] == 0x0d) str[len - 1] = 0; str = af; - len = strlen(str); + len =ACE_OS::strlen (str); if (len > 0 && str[len-1] == 0x0d) str[len - 1] = 0; XmTextFieldSetString(titlewidget, title); cmdBusy = 1; CmdWrite(&tmp, 1); -// len = strlen(vh); +// len =ACE_OS::strlen (vh); // CmdWrite((char *)&len, 4); // cerr << "StartProgram: len =" << len; // CmdWrite(vh, len); // cerr << " StartProgram: vh =" << vh << endl; - len = strlen(vf); + len =ACE_OS::strlen (vf); CmdWrite((char *)&len, 4); cerr << "StartProgram: len =" << len; CmdWrite(vf, len); cerr << " StartProgram: vf =" << vf << endl; -// len = strlen(ah); +// len =ACE_OS::strlen (ah); // CmdWrite((char *)&len, 4); // cerr << "StartProgram: len =" << len; // CmdWrite(ah, len); // cerr << " StartProgram: ah =" << ah << endl; - len = strlen(af); + len =ACE_OS::strlen (af); CmdWrite((char *)&len, 4); cerr << "StartProgram: len =" << len; CmdWrite(af, len); @@ -392,7 +392,7 @@ static void modifyprog(struct ProgramList *p) XmListReplaceItemsPos(wproglist, &item, 1, progid+1); XmListSelectPos(wproglist, progid+1, 0); XmStringFree(item); - memcpy(&(prog[progid]), p, sizeof(*p)); + ACE_OS::memcpy (&(prog[progid]), p, sizeof(*p)); SaveBuf(); } @@ -401,7 +401,7 @@ static void insertprog(struct ProgramList *p) XmString item; if (items <= 0 || items >= ITEMS) return; - memcpy((char*)&(prog[items]), (char *)p, sizeof(*p)); + ACE_OS::memcpy ((char*)&(prog[items]), (char *)p, sizeof(*p)); item = (XmString)XmStringCreateLtoR(p->title, XmStringTag); XmListAddItemUnselected(wproglist, item, items+1); XmStringFree(item); @@ -423,9 +423,9 @@ static void deleteCB(Widget w, XtPointer closure, XtPointer call_data) if (items <= 0) { beep(); return; } j = curListPos(); if (j == -1) return; - memcpy(&deletedprog, &prog[j], sizeof(deletedprog)); + ACE_OS::memcpy (&deletedprog, &prog[j], sizeof(deletedprog)); for (i = j+1; i < items; i++) - memcpy(&prog[i-1], &prog[i], sizeof(*prog)); + ACE_OS::memcpy (&prog[i-1], &prog[i], sizeof(*prog)); XmListDeletePos(wproglist, j+1); items --; SaveBuf(); @@ -734,7 +734,7 @@ static void CreateModifyWindow(Widget parent) XtManageChild(wcancel); XtAddCallback (wcancel, XmNactivateCallback, (XtCallbackProc)modifydismissCB, NULL); - titleSize = strlen(LINE1); + titleSize =ACE_OS::strlen (LINE1); n=0; XtSetArg (args[n], XmNleftOffset, 5); n++; @@ -901,7 +901,7 @@ Widget CreateProgramWindow(Widget parent, int cmdSock, int * playflag, Widget fr wproglist = wlist; for (n = 0; n < items; n++) XmStringFree(item[n]); - free(item); + ACE_OS::free (item); n=0; XtSetArg (args[n], XmNtopOffset, 2); n++; 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 08f2ef0d030..734029da118 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/ui.cpp @@ -103,8 +103,8 @@ static void CmdWrite(char * buf, int size) while (ACE_OS::write(cmdSocket, (buf), (size)) == -1) { if (errno == EINTR) continue; - perror("UI write to cmdSocket"); - exit(1); + ACE_OS::perror ("UI write to cmdSocket"); + ACE_OS::exit (1); } // ACE_DEBUG ((LM_DEBUG,"(%P|%t)After writing cmd\n")); } @@ -529,7 +529,7 @@ void UIMinsize(int x, int y) static void exit_callback(Widget w, XtPointer data, XmAnyCallbackStruct *cbs) { - exit(0); + ACE_OS::exit (0); } @@ -778,8 +778,8 @@ static void cmdSocket_callback(Widget w, XtPointer data, XmAnyCallbackStruct *cb while (read(cmdSocket, &cmd, 1) <= 0) { if (errno == EINTR) return; - perror("UI by callback read from CmdSocket"); - exit(1); + ACE_OS::perror ("UI by callback read from CmdSocket"); + ACE_OS::exit (1); } // ACE_DEBUG ((LM_DEBUG,"(%P)cmdSocket_callback:cmd= %d",cmd)); if (cmd == CmdDONE || cmd == CmdFAIL) @@ -824,7 +824,7 @@ static void cmdSocket_callback(Widget w, XtPointer data, XmAnyCallbackStruct *cb char * ptr; if (cmd == CmdVPdisplayFrame) { - read(cmdSocket, (char *)&ptr, sizeof(char *)); + ACE_OS::read (cmdSocket, (char *)&ptr, sizeof(char *)); } VPcommand((int)cmd, ptr); @@ -877,7 +877,7 @@ void UIprocess(int cmdSock) title = vh = vf = vb = ah = af = ab = NULL; for (i = 1; i < argc_share; i++) { - if (strcmp(argv_share[i], "-v") == 0) { + if (ACE_OS::strcmp (argv_share[i], "-v") == 0) { if (argc_share > i + 1) { i ++; vh = argv_share[i]; @@ -885,7 +885,7 @@ void UIprocess(int cmdSock) } else break; } - else if (strcmp(argv_share[i], "-a") == 0) { + else if (ACE_OS::strcmp (argv_share[i], "-a") == 0) { if (argc_share > i + 1) { i ++; ah = argv_share[i]; @@ -893,7 +893,7 @@ void UIprocess(int cmdSock) } else break; } - else if (strcmp(argv_share[i], "-p") == 0) { + else if (ACE_OS::strcmp (argv_share[i], "-p") == 0) { if (argc_share > i + 1) { i ++; title = argv_share[i]; @@ -945,13 +945,13 @@ void UIprocess(int cmdSock) /* form the title */ if (vh != NULL) { - title = (char *)malloc(strlen(vh) + 1); + title = (char *)ACE_OS::malloc(strlen(vh) + 1); if (title != NULL) { strcpy(title, vh); } } else { - title = (char *)malloc(strlen(ah) + 1); + title = (char *)ACE_OS::malloc(strlen(ah) + 1); if (title != NULL) { strcpy(title, ah); } @@ -969,11 +969,6 @@ void UIprocess(int cmdSock) else { vf = vh; vh = ""; - // vb = (char *)malloc(BUFSIZE); -// if (vb != NULL) { -// get_full_path(vf, vb, BUFSIZE); -// vf = vb; -// } } } else vh = vf = ""; @@ -987,11 +982,6 @@ void UIprocess(int cmdSock) else { af = ah; ah = ""; -// ab = (char *)malloc(BUFSIZE); -// if (ab != NULL) { -// get_full_path(af, ab, BUFSIZE); -// af = ab; -// } } } else ah = af = ""; @@ -999,9 +989,9 @@ void UIprocess(int cmdSock) fprintf(stderr, "Init program: title %s, vh %s, vf %s, ah %s, af %s\n", title, vh, vf, ah, af); StartProgram(title, vh, vf, ah, af); - free(title); - if (ab != NULL) free(ab); - if (vb != NULL) free(vb); + ACE_OS::free (title); + if (ab != NULL) ACE_OS::free (ab); + if (vb != NULL) ACE_OS::free (vb); } XtAppMainLoop(App); diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/util.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/util.cpp index c266190b7fd..8fc6ac680b6 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/util.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/util.cpp @@ -110,9 +110,9 @@ correct_underflow() { if (status < 0) { if (!quietFlag) { fprintf (stderr, "\n"); - perror("Unexpected read error."); + ACE_OS::perror ("Unexpected read error."); } - exit(1); + ACE_OS::exit (1); } else if ((status == 0) && (bufLength < 1)) { if (!quietFlag) { @@ -128,7 +128,7 @@ correct_underflow() { if (loopFlag) longjmp(env, 1); DestroyVidStream(curVidStream); */ - exit(0); + ACE_OS::exit (0); } #ifdef UTIL2 curBits = *bitBuffer << bitOffset; @@ -215,7 +215,7 @@ char *get_ext_data () /* Allocate ext data buffer. */ - dataPtr = (char *) malloc(size); + dataPtr = (char *) ACE_OS::malloc(size); /* Initialize marker to keep place in ext data buffer. */ @@ -421,7 +421,7 @@ char *get_extra_bit_info () /* Initialize size of extra bit info buffer and allocate. */ size = EXT_BUF_SIZE; - dataPtr = (char *) malloc(size); + dataPtr = (char *) ACE_OS::malloc(size); /* Reset marker to hold place in buffer. */ 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..0f2ab37c5af 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vb.cpp @@ -25,60 +25,59 @@ * email: scen@cse.ogi.edu */ -#include <stdio.h> -#include <errno.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> -#include <stdlib.h> -#include <netinet/in.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/Intrinsic.h> -#if defined(__svr4__) || defined(IRIX) -#include <stropts.h> -#include <sys/conf.h> -#endif -#include "include/common.h" -#include "newproto.h" -#include "global.h" -#include "mpeg_shared/filters.h" -#include "mpeg_shared/fileio.h" -#include "mpeg_shared/com.h" - -ACE_RCSID(mpeg_client, vb, "$Id$") +extern int vsp[2]; +extern void set_exit_routine_tag(int tag); -/* magic number -- deviation is considered - caused by clock drift only if rate <= 1/MAX_CLOCK_DRIFT. - */ -#define MAX_CLOCK_DRIFT 50 +#include "vb.h" -#define SHCODE 0x000001b3 - -#define max(a,b) ((a)>(b) ? (a) : (b)) +ACE_RCSID(mpeg_client, vb, "$Id$") -static struct block +block ** VideoBuffer::head = 0; +block ** VideoBuffer::tail = 0; +char * VideoBuffer::buf = 0; +int VideoBuffer::bufsize = -1; +int VideoBuffer::sid = -1; +int VideoBuffer::countid = -1; +int VideoBuffer::exit_tag = -1; +int VideoBuffer::conn_tag = -1; +int VideoBuffer::savedSocket = -1; + +//constructor. +VideoBuffer::VideoBuffer (void) + :msg (0), + packet (0), + msgsn (-1), + ptr (0), + ptr1 (0), + tmp_buf (0), + cmdsn (-1), + fb_state (0), + qosRecomputes (0), + f (0), + fa (0), + reach_limit (0), + not_action (1) +#ifdef STAT + ,to_count (1), + gap_msgsn (-1) +#endif { - unsigned shcode; - struct block * next; - int full; -} ** head, ** tail; +} -struct header +// Destructor. +VideoBuffer::~VideoBuffer (void) { - struct block *h, *t; -}; + if (ACE_Reactor::instance ()->remove_handler (this->handler_,ACE_Event_Handler::READ_MASK) == -1) + ACE_DEBUG ((LM_ERROR,"(%P)remove handler failed for Video_Notification_Handler\n")); -static char * buf; -static int bufsize; -static int sid, countid; -static exit_tag = 0; -static int conn_tag; -static int savedSocket; + delete this->handler_; + if (ACE_Reactor::instance ()->remove_handler (this,ACE_Event_Handler::READ_MASK) == -1) + ACE_DEBUG ((LM_ERROR,"(%P)remove handler failed for VideoBuffer\n")); +} -void VBinitBuf(int size) /* size in byte */ +void +VideoBuffer::VBinitBuf (int size) { bufsize = size - sizeof(struct header); buf = creat_shared_mem(size); @@ -94,28 +93,36 @@ void VBinitBuf(int size) (*tail)->shcode = SHCODE; } -char * VBgetBuf(int size) /* block version */ +/* block version */ +char* +VideoBuffer::VBgetBuf (int size) { return 0; } -int VBcheckBuf(int size) /* non-block check, return True/False*/ +/* non-block check, return True/False*/ +int +VideoBuffer::VBcheckBuf (int size) { return 0; } -void VBputMsg(char * msgPtr) +void +VideoBuffer::VBputMsg (char * msgPtr) { } -char * VBgetMsg() /* block version */ +/* block version */ +char * +VideoBuffer::VBgetMsg () { - char *ptr; + char *vb_ptr; #ifdef STAT if (shared->collectStat && *head == *tail) shared->stat.VBemptyTimes ++; #endif + // ACE_DEBUG ((LM_DEBUG,"(%P)waiting for countid\n")); enter_cs(countid); enter_cs(sid); while (*tail != *head && (*tail)->full == 0) @@ -124,21 +131,24 @@ char * VBgetMsg() /* block version */ if (*head == *tail) { fprintf(stderr, "VB: getMsg run out of msg unexpectedly.\n"); - exit(1); + ACE_OS::exit (1); } - ptr = ((char*)*tail)+sizeof(**tail)+sizeof(VideoMessage); + vb_ptr = ((char*)*tail)+sizeof(**tail)+sizeof(VideoMessage); - // fprintf(stderr,"VBgetMsg: buf:%x, msg:%x\n", (int)buf, (int)ptr); + // fprintf(stderr,"VBgetMsg: buf:%x, msg:%x\n", (int)buf, (int)vb_ptr); - return ptr; + return vb_ptr; } -int VBcheckMsg() /* non-block check, return Number of Msgs in buffer */ +/* non-block check, return Number of Msgs in buffer */ +int +VideoBuffer::VBcheckMsg () { return get_semval(countid); } -int VBbufEmpty(void) +int +VideoBuffer::VBbufEmpty (void) { /* Fprintf(stderr, "VB countid %d\n", get_semval(countid)); @@ -146,1663 +156,974 @@ int VBbufEmpty(void) return get_semval(countid) <= 0; } -void VBreclaimMsg(char * msgPtr) +void +VideoBuffer::VBreclaimMsg (char * msgPtr) { enter_cs(sid); *tail = (*tail)->next; leave_cs(sid); } -void VBdeleteBuf(void) +void +VideoBuffer::VBdeleteBuf (void) { - remove_shared_mem(buf - sizeof(struct header)); + remove_shared_mem (buf - sizeof(struct header)); } -void VBdeleteSem(void) + +void +VideoBuffer::VBdeleteSem (void) { remove_semaphore(sid); remove_semaphore(countid); } - -/* SIGUSR1 from CTR is for killing this process, without affecting any other ones. */ -static void exit_on_kill(void) +int +VideoBuffer::VBprocess (int init_socket, int normal_socket) { - ACE_DEBUG ((LM_DEBUG,"(%P|%t) VBProcess killed\n")); - extern void set_exit_routine_tag(int tag); - set_exit_routine_tag(0); - ComCloseConn(savedSocket); - VBdeleteBuf(); - exit(0); -} + this->initSocket = init_socket; + this->normalSocket = normal_socket; + msgsn = -1; + dataSocket = initSocket; + exit_tag = 0; + conn_tag = shared->videoMaxPktSize; + savedSocket = normalSocket; -static void usr1_handler(int sig) -{ - cerr << "VBProcess got sigusr1\n"; - exit_on_kill (); - exit_tag = 1; -} + // ACE_DEBUG ((LM_DEBUG,"VideoBuffer::VBProcess ()\n")); + /* buffer big enough for discard mode packet stream */ + if (conn_tag < 0) + { + tmp_buf = (char *)ACE_OS::malloc(-conn_tag); + if (tmp_buf == NULL) { + fprintf(stderr, "AB failed to allocate %d bytes"); + ACE_OS::perror ("of tmp_buf"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + } + ACE_NEW_RETURN (this->handler_, + Video_Notification_Handler (), + -1); -static void usr2_handler(int sig) -{ - /* - fprintf(stderr, "VB void usr2_handler (supposed for stat).\n"); - */ -} + // Register the notification handler with the reactor. + int result = ACE_Reactor::instance ()->register_handler (this->handler_, + ACE_Event_Handler::READ_MASK); + if (result != 0) + return result; -static int send_feedback(int sock, int addupf, int addf, int advance) -{ - int res; - VideoFeedBackPara para; - para.cmdsn = htonl(shared->cmdsn); - para.addUsecPerFrame = htonl(addupf); - para.addFrames = htonl(addf); - para.needHeader = htonl(shared->needHeader); - shared->needHeader = 0; - para.frameRateLimit1000 = - htonl((long)(shared->frameRateLimit * 1000.0)); - para.sendPatternGops = htonl(shared->sendPatternGops); - memcpy(para.sendPattern, shared->sendPattern, PATTERN_SIZE); - /* - fprintf(stderr, "VB to send a fb packet..."); - */ - if (conn_tag != 0) { /* packet stream */ - while ((res = write(sock, (char *)¶, sizeof(para))) == -1) { - if (errno == EINTR) - continue; - if (errno == ENOBUFS) { - perror("VB Warning, fb packet discarded for"); - return -1; - } - perror("VB error, fb packet sending failed"); - exit(1); - } - } - else { - res = write(sock, (char *)¶, sizeof(para)); - if (res == -1) { - perror("VB error, fb packet sending failed"); - exit(1); - } - } - if (res < sizeof(para)) { - fprintf(stderr, "VB send_feedback() warn: res %dB < sizeof(para) %dB\n", - res, sizeof(para)); - } -#ifdef STAT - { - int i; - if ((i = shared->stat.fbPacketNumber) < MAX_FB_PACKETS) { - shared->stat.fbPackets[i].frameId = shared->nextFrame; - shared->stat.fbPackets[i].addUsecPerFrame = addupf; - shared->stat.fbPackets[i].addFrames = addf; - shared->stat.fbPackets[i].frames = shared->sendPatternGops * - shared->patternSize; - shared->stat.fbPackets[i].framesDropped = shared->framesDropped; - shared->stat.fbPackets[i].frameRateLimit = shared->frameRateLimit; - shared->stat.fbPackets[i].advance = advance; - } - shared->stat.fbPacketNumber ++; - } -#endif - Fprintf(stderr, "VB sent fb pkt frame%d gop%d addf%d addupf%d frate%5.2f.\n", - shared->nextFrame, shared->nextGroup, - addf, addupf, shared->frameRateLimit); + result = ACE_Reactor::instance ()->register_handler (this, + ACE_Event_Handler::READ_MASK); + + if (result != 0) + return result; + + this->state_ = READ_HEADER; + temp = (char *)&msghd; + bytes = sizeof (msghd); return 0; } -static void skip_message(int fd, VideoMessage * msg) +ACE_HANDLE +VideoBuffer::get_handle (void) const { - char buf[1024]; - if (conn_tag >= 0) { - int size = msg->msgSize; - while (size > 0) { - int res; - int bytes = size > 1024 ? 1024 : size; - read_bytes(fd, buf, bytes); - /* - if ((res = read(fd, buf, bytes)) < bytes) { - fprintf(stderr, "VB Error skip_message: try read %dB, got %dB\n", - bytes, res); - } - */ - size -= bytes; - } - } - else { /* discard mode packet stream packet has been read */ - } - if (exit_tag) exit_on_kill(); + if (this->socket_flag_) + return this->normalSocket; + else + return this->initSocket; } -void VBprocess(int initSocket, int normalSocket) +int +VideoBuffer::handle_input (ACE_HANDLE fd) { - VideoMessage * msg, msghd; - VideoPacket * packet; - int len, bsize, msgsn = -1; - int psize, poffset; - char * ptr, *ptr1; - char *tmp_buf = NULL; - int dataSocket = initSocket; - - /* INIT frame is received from CTR through initSocket */ - -#ifdef STAT - int to_count = 1; - int gap_msgsn = -1; + // ACE_DEBUG ((LM_DEBUG,"VideoBuffer::handle_input:state = %d\n",this->state_)); + switch (this->state_) + { + case READ_NEXT_HEADER: + case READ_HEADER: + { + if (conn_tag >= 0) + len = ACE_OS::read (dataSocket,temp,bytes); + else + { + len = ACE_OS::read (dataSocket,tmp_buf,-conn_tag); + // fprintf (stderr,"VB read packet len = %d\n",len); + ACE_OS::memcpy ((char *)&msghd, tmp_buf, sizeof(msghd)); + } + if (len == -1) { + if (errno == EWOULDBLOCK || errno == EAGAIN) { + perror("VB sleep for 10ms"); + usleep(10000); + // set the pointers before going into the next loop. + temp = (char *)&msghd; + bytes = sizeof (msghd); + return 0; + } + ACE_OS::perror ("VB ACE_OS::read () data"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + if (len == 0) { /* EOF, connection closed by peer */ + fprintf(stderr, "Error: VB found dataSocket broken\n"); + for (;;) { + usleep(1000000); + } + } + if (conn_tag >= 0) + { + temp += len; + bytes -= len; + if (bytes != 0) + return 0; + else + len = sizeof (msghd); + } + if (len < sizeof(msghd)) + { + // go back to reading the next header. + temp = (char *)&msghd; + bytes = sizeof (msghd); + fprintf(stderr, "VD warn: PEEK1ed %dB < expected %dB\n",len, sizeof(msghd)); + // continue; + } +#ifdef NeedByteOrderConversion + msghd.packetsn = ntohl(msghd.packetsn); + msghd.packetSize = ntohl(msghd.packetSize); + msghd.msgsn = ntohl(msghd.msgsn); + msghd.msgOffset = ntohl(msghd.msgOffset); + msghd.msgSize = ntohl(msghd.msgSize); #endif - - /* following variables are for feedback */ - int pcmdsn, pcmd; /* to store the cmdsn and cmd of previous frame, - to detect new commands */ - 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 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 */ - int action_time; /* the time when feedback action is taken, used to enforce - action_delay */ - int upf, cupf; /* upf -- currentUPF as carried in all frames, - cupf -- real current UPF, being adjusted by FB */ - double fv; /* current buffer fill level in term of #frames */ - double init_fv; /* init_fv and init_pos record the fv value and position - (frameid or gopid) when fv is very close to med */ - double init_pos; - int high, low, med; /* median, high and low water marks, in term of #frames */ - int period; /* interms of #frames, (high-med, period) defined the max - buffer fill drift which can be assumed as caused by - clock drift */ - Filter * f = NULL; /* buffer fill level filter */ - - int advance, min_advance; /* in microseconds, advance holds the - current target buffer-fill-level as - determined by jitter level - estimate. min_advance sets a absolute - minimun level, no matter how low jitter - level is. - 'advance' does not change when - play-speed changes, but med/high/low - will be updated upon speed change */ - double fav; /* #frames, jitter level output by the filter */ - Filter * fa = NULL; /* jitter filter */ - int reach_limit = 0; /* indicate that the target 'advance' has reached client VB - buffer limit, and can not further increase, even if - jitter increases */ - int not_action = 1; /* indicates entering state=3 is not caused by - feedback action. If not_action = 1 entering state=3 - is caused either by 'start' or speed change, and - the jitter filter needs to be reset */ - - exit_tag = 0; - conn_tag = shared->videoMaxPktSize; - - savedSocket = normalSocket; -#if 0 -#ifdef __svr4__ - - /* On solaris 2.x for i86pc, a datagram socket may not discard the - remaining of a message if recv() fails to read the whole - thing. Following systems are tried but seems doesn't work. So for - this platform, This causes problem with skip_message() defined - above, which tries to discard whole packets by reading only a few - bytes. An alternative here is to allocate a big enough buffer, - read and discard the whole packet, this is less efficient because - of more data copy. - But if we call read(2) instead of recv(), then it works. - */ - if (!conn_tag) { - len = ioctl(dataSocket, I_SRDOPT, RMSGD); /* discard unread part of the message */ - if (len) perror("error message"); - } -#endif + if (this->state_ == READ_NEXT_HEADER) + { +#ifdef STAT + { + int gap = msghd.msgsn - gap_msgsn; + gap = (gap >MSGGAP_MAX) ? MSGGAP_MAX : gap < MSGGAP_MIN ? MSGGAP_MIN : gap; + shared->stat.VBmsgGaps[gap - MSGGAP_MIN] ++; + if (gap >0) gap_msgsn = msghd.msgsn; + } #endif - - setsignal(SIGUSR1, usr1_handler); - setsignal(SIGUSR2, usr2_handler); - - if (conn_tag < 0) { /* buffer big enough for discard mode packet stream */ - tmp_buf = (char *)malloc(-conn_tag); - if (tmp_buf == NULL) { - fprintf(stderr, "AB failed to allocate %d bytes"); - perror("of tmp_buf"); - exit(1); - } - } - - for (;;) - { - // fprintf(stderr, "VB wait for a new packet.\n"); - if (conn_tag >= 0) { - len = wait_read_bytes(dataSocket, (char *)&msghd, sizeof(msghd)); - } - else { /* discard mode packet stream, read all bytes */ - len = read(dataSocket, tmp_buf, -conn_tag); - memcpy((char *)&msghd, tmp_buf, sizeof(msghd)); - } - // ACE_DEBUG ((LM_DEBUG, "(%P|%t) vb: Got a packet of length = %d\n", len)); - if (exit_tag) exit_on_kill(); - if (len == -1) { - if (errno == EWOULDBLOCK || errno == EAGAIN) { - perror("VB sleep for 10ms"); - usleep(10000); - if (exit_tag) exit_on_kill(); - continue; - } - perror("VB read() data"); - exit(1); - } - if (len == 0) { /* EOF, connection closed by peer */ - fprintf(stderr, "Error: VB found dataSocket broken\n"); - for (;;) { - usleep(1000000); - if (exit_tag) exit_on_kill(); - } - } - if (len < sizeof(msghd)) { - fprintf(stderr, "VD warn: PEEK1ed %dB < expected %dB\n", - len, sizeof(msghd)); - continue; - } -#ifdef NeedByteOrderConversion - msghd.packetsn = ntohl(msghd.packetsn); - msghd.packetSize = ntohl(msghd.packetSize); - msghd.msgsn = ntohl(msghd.msgsn); - msghd.msgOffset = ntohl(msghd.msgOffset); - msghd.msgSize = ntohl(msghd.msgSize); + if (msghd.msgsn <= msgsn) + { /* outdated message, wait for next one */ + + fprintf(stderr, "VB discard outdated or dup msgsn %d, pktsn %d\n", + msghd.msgsn, msghd.packetsn); + + this->state_ = SKIP_NEXT_MESSAGE; + bytes = msghd.msgSize; + // skip_message(dataSocket, &msghd); + // continue; + return 0; + } + + if ((msghd.msgsn > msgsn + 1) || (msghd.msgOffset == 0)) + { + /* message out of order, abandon current packet */ + /* + fprintf(stderr, "VB msg out of order for current packet, discard it.\n"); + */ +#ifdef STAT + to_count = 0; #endif - - /* - fprintf(stderr, "VB PEEK1 a msg sn-%d, size-%d, pkt-%d, pktsize-%d\n", - msghd.msgsn, msghd.msgSize, msghd.packetsn, msghd.packetSize); - */ - start_new_packet: + } + else + { + // ACE_DEBUG ((LM_DEBUG,"assigning next msgsn %d\n",msghd.msgsn)); + msgsn = msghd.msgsn; + this->state_ = READ_MESSAGE; + temp = ptr +sizeof (msghd); + bytes = msghd.msgSize; + // make a recursive call as we just have to do a memcpy from the buffer. + this->handle_input (dataSocket); + return 0; + } + } + + // fprintf(stderr, "VB PEEK1 a msg sn-%d, size-%d, pkt-%d, pktsize-%d\n",msghd.msgsn, msghd.msgSize, msghd.packetsn, msghd.packetSize); - #ifdef STAT - if (to_count) { - int gap = msghd.msgsn - gap_msgsn; - gap = (gap >MSGGAP_MAX) ? MSGGAP_MAX : gap < MSGGAP_MIN ? MSGGAP_MIN : gap; - shared->stat.VBmsgGaps[gap - MSGGAP_MIN] ++; - if (gap >0) gap_msgsn = msghd.msgsn; - } - to_count = 1; + if (to_count) { + int gap = msghd.msgsn - gap_msgsn; + gap = (gap >MSGGAP_MAX) ? MSGGAP_MAX : gap < MSGGAP_MIN ? MSGGAP_MIN : gap; + shared->stat.VBmsgGaps[gap - MSGGAP_MIN] ++; + if (gap >0) gap_msgsn = msghd.msgsn; + } + to_count = 1; #endif - if (msghd.msgsn <= msgsn) /* outdated msg */ - { + if (msghd.msgsn <= msgsn) /* outdated msg */ + { + fprintf(stderr, "VB discard outdated msgsn %d, pktsn %d when expecting first %d\n", + msghd.msgsn, msghd.packetsn,msgsn); + this->state_ = SKIP_MESSAGE; + bytes = msghd.msgSize; + // skip_message(dataSocket, &msghd); + // continue; + return 0; + } + else if (msghd.msgOffset != 0) /* not first msg of a packet */ + { - fprintf(stderr, "VB discard outdated msgsn %d, pktsn %d when expecting first\n", - msghd.msgsn, msghd.packetsn); + /* + Fprintf(stderr, "VB discard non-first msg msgsn %d, pktsn %d\n", + msghd.msgsn, msghd.packetsn); + */ + this->state_ = SKIP_MESSAGE; + bytes = msghd.msgSize; + // skip_message(dataSocket, &msghd); + // continue; + return 0; + } + else + { + // ACE_DEBUG ((LM_DEBUG,"assigning msgsn %d\n",msghd.msgsn)); + msgsn = msghd.msgsn; + } - skip_message(dataSocket, &msghd); - continue; - } - else if (msghd.msgOffset != 0) /* not first msg of a packet */ - { - - /* - Fprintf(stderr, "VB discard non-first msg msgsn %d, pktsn %d\n", - msghd.msgsn, msghd.packetsn); - */ - skip_message(dataSocket, &msghd); - continue; - } - else - msgsn = msghd.msgsn; - - /* allocate packet for the incoming msg */ - bsize = msghd.packetSize + sizeof(**head)*2 + sizeof(msghd); - bsize = ((bsize+3)>>2)<<2; - enter_cs(sid); - if (*head >= *tail) - { - if (bufsize - (int)((char*)*head - buf) >= bsize ) - msg =(VideoMessage *)((char*)*head + sizeof(**head)); - else if ((int)((char*)*tail - buf) >= bsize) - { - (*head)->next = (struct block *)buf; - (*head)->full = 0; - *head = (struct block *)buf; - msg = (VideoMessage *)(buf + sizeof(**head)); - *head = (struct block *)buf; - (*head)->shcode = SHCODE; - } - else /* not enough buffer, discard current message */ - { - leave_cs(sid); + /* allocate packet for the incoming msg */ + bsize = msghd.packetSize + sizeof(**head)*2 + sizeof(msghd); + bsize = ((bsize+3)>>2)<<2; + enter_cs(sid); + if (*head >= *tail) + { + if (bufsize - (int)((char*)*head - buf) >= bsize ) + msg =(VideoMessage *)((char*)*head + sizeof(**head)); + else if ((int)((char*)*tail - buf) >= bsize) + { + (*head)->next = (struct block *)buf; + (*head)->full = 0; + *head = (struct block *)buf; + msg = (VideoMessage *)(buf + sizeof(**head)); + *head = (struct block *)buf; + (*head)->shcode = SHCODE; + } + else /* not enough buffer, discard current message */ + { + leave_cs(sid); #ifdef STAT - if (shared->collectStat) - shared->stat.VBdroppedFrames ++; + if (shared->collectStat) + shared->stat.VBdroppedFrames ++; #endif - /* - Fprintf(stderr, "VB not enough space 1, drop msg.sn %d pktsn %d\n", - msghd.msgsn, msghd.packetsn); - */ - - skip_message(dataSocket, &msghd); - continue; - } - } - else /* *head < *tail */ - if ((char*)*tail - (char*)*head >= bsize) - msg = (VideoMessage *)((char*)*head + sizeof(**head)); - else /* not enough buffer, abandon current message */ - { - leave_cs(sid); + /* + Fprintf(stderr, "VB not enough space 1, drop msg.sn %d pktsn %d\n", + msghd.msgsn, msghd.packetsn); + */ + this->state_ = SKIP_MESSAGE; + bytes = msghd.msgSize; + // skip_message(dataSocket, &msghd); + // continue; + return 0; + } + } + else /* *head < *tail */ + if ((char*)*tail - (char*)*head >= bsize) + msg = (VideoMessage *)((char*)*head + sizeof(**head)); + else /* not enough buffer, abandon current message */ + { + leave_cs(sid); #ifdef STAT - if (shared->collectStat) - shared->stat.VBdroppedFrames ++; + if (shared->collectStat) + shared->stat.VBdroppedFrames ++; #endif - /* - Fprintf(stderr, "VB not enough space 1, drop msg.sn %d pktsn %d\n", - msghd.msgsn, msghd.packetsn); - - */ - skip_message(dataSocket, &msghd); - continue; - } - leave_cs(sid); - - // fprintf(stderr, "VB allocated a buffer for comming packet.\n"); - - psize = msghd.packetSize; - poffset = 0; - packet = (VideoPacket *)((char*)msg + sizeof(msghd)); - *(((int*)packet)+(msghd.packetSize>>2)) = 0; - /* clear the last no more than three bytes, for - proper detecting the end of packet by VD */ - ptr = (char*)msg; - for (;;) - { - int bytes; - bytes = sizeof(msghd) + msghd.msgSize; - if (conn_tag >= 0) { - len = bytes; - read_bytes(dataSocket, ptr + sizeof(msghd), bytes - sizeof(msghd)); + /* + Fprintf(stderr, "VB not enough space 1, drop msg.sn %d pktsn %d\n", + msghd.msgsn, msghd.packetsn); + + */ + this->state_ = SKIP_MESSAGE; + bytes = msghd.msgSize; + // skip_message(dataSocket, &msghd); + // continue; + return 0; + } + leave_cs(sid); + + //fprintf(stderr, "VB allocated a buffer for comming packet.\n"); + + psize = msghd.packetSize; + poffset = 0; + packet = (VideoPacket *)((char*)msg + sizeof(msghd)); + *(((int*)packet)+(msghd.packetSize>>2)) = 0; + /* clear the last no more than three bytes, for + proper detecting the end of packet by VD */ + ptr = (char*)msg; + this->state_ = READ_MESSAGE; + temp = ptr +sizeof (msghd); + bytes = msghd.msgSize; } - else { - len = bytes; - memcpy(ptr + sizeof(msghd), tmp_buf + sizeof(msghd), bytes - sizeof(msghd)); - } - if (exit_tag) exit_on_kill(); - if (len == -1) { - perror("VB fails to recv data"); - exit(1); - } - if (len < bytes) { - fprintf(stderr, "VB warn: recv() len %dB < bytes %dB\n", len, bytes); - } - /* because message header is already PEEKed to msghd before recv(), so we can - use info in msghd instead of *(VideoMessage*)ptr */ - if (len != sizeof(msghd)+msghd.msgSize) - /* some of msg contents not successfully received, abandon current packet */ + break; + case SKIP_NEXT_MESSAGE: + case SKIP_MESSAGE: { - /* - fprintf(stderr, "VB got corrupted msg, len=%d, supposed len=%d\n", - len, sizeof(msghd)+msghd.msgSize); - */ - break; + char buffer[BUFSIZ]; + if (conn_tag >= 0) + { + int size = bytes > BUFSIZ ? BUFSIZ : bytes; + int res =ACE_OS::read (dataSocket, buffer, size); + bytes -= res; + + if (bytes != 0) + return 0; + } + if (this->state_ == SKIP_MESSAGE) + this->state_ = READ_HEADER; + else if (this->state_ == SKIP_NEXT_MESSAGE) + this->state_ = READ_NEXT_HEADER; + temp = (char *)&msghd; + bytes = sizeof (msghd); + break; } - poffset += msghd.msgSize; - psize -= msghd.msgSize; - ptr += msghd.msgSize; - - // fprintf(stderr, "VB packet remain size %d\n", psize); - - if (psize == 0) + case READ_MESSAGE: { - /* finished receiving the current packet */ + if (conn_tag >= 0) + { + int val; + val = ACE_OS::read (dataSocket,temp,bytes); + + if (val == -1 && (errno == EINTR || errno == EAGAIN | errno == EWOULDBLOCK)) + { /* interrupted or need to wait, try again */ + if (errno == EAGAIN | errno == EWOULDBLOCK) usleep(10000); + errno = 0; + return 0; + } + if (val == -1) + { + ACE_OS::perror ("Error -- Read from socket"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + if (val == 0) /* EOF encountered */ + { + ACE_DEBUG ((LM_DEBUG, "Error -- EOF reached while trying to read %d bytes.\n")); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + temp += val; + bytes -= val; + if (bytes < 0) /* weird thing is happening */ + { + ACE_DEBUG ((LM_DEBUG, "Error: read too much from socket, %d out of %d bytes.\n")); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + if (bytes != 0) + return 0; + } + else + memcpy(temp, tmp_buf + sizeof(msghd), bytes); + poffset += msghd.msgSize; + psize -= msghd.msgSize; + ptr += msghd.msgSize; + + // fprintf(stderr, "VB packet remain size %d\n", psize); + + if (psize == 0) + { + // ACE_DEBUG ((LM_DEBUG,"finished receiving current packet\n")); + /* finished receiving the current packet */ #ifdef NeedByteOrderConversion - packet->cmd = ntohl(packet->cmd); - packet->cmdsn = ntohl(packet->cmdsn); - packet->sh = ntohl(packet->sh); - packet->gop = ntohl(packet->gop); - packet->frame = ntohl(packet->frame); - packet->display = ntohl(packet->display); - packet->future = ntohl(packet->future); - packet->past = ntohl(packet->past); - packet->currentUPF = ntohl(packet->currentUPF); - packet->dataBytes = ntohl(packet->dataBytes); + packet->cmd = ntohl(packet->cmd); + packet->cmdsn = ntohl(packet->cmdsn); + packet->sh = ntohl(packet->sh); + packet->gop = ntohl(packet->gop); + packet->frame = ntohl(packet->frame); + packet->display = ntohl(packet->display); + packet->future = ntohl(packet->future); + packet->past = ntohl(packet->past); + packet->currentUPF = ntohl(packet->currentUPF); + packet->dataBytes = ntohl(packet->dataBytes); #endif - pcmdsn = packet->cmdsn; - pcmd = packet->cmd; - pfid = packet->frame; - pgop = packet->gop; - shared->VBheadFrame = (pcmd == CmdPLAY) ? pfid : pgop; - - shared->currentUPF = packet->currentUPF; - enter_cs(sid); - (*head)->full = 1; - psize = sizeof(**head) + sizeof(*msg) + msghd.packetSize; - psize = ((psize+3)>>2)<<2; - ptr = (char*)*head + psize; - (*head)->next = (struct block *) ptr; - (*head) = (struct block *)ptr; - (*head)->shcode = SHCODE; - leave_cs(countid); - leave_cs(sid); - - /* VB receives all frame except for the INIT one through normalSocket */ - if (dataSocket != normalSocket) { - /* - Fprintf(stderr, "VB got INIT frame.\n"); - */ - write(initSocket, (char *)&initSocket, 1); /* write a garbage byte */ - close(initSocket); - dataSocket = normalSocket; - } + pcmdsn = packet->cmdsn; + pcmd = packet->cmd; + pfid = packet->frame; + pgop = packet->gop; + shared->VBheadFrame = (pcmd == CmdPLAY) ? pfid : pgop; - /* following is synchronization feedback algorithm */ + shared->currentUPF = packet->currentUPF; + enter_cs(sid); + (*head)->full = 1; + psize = sizeof(**head) + sizeof(*msg) + msghd.packetSize; + psize = ((psize+3)>>2)<<2; + ptr = (char*)*head + psize; + (*head)->next = (struct block *) ptr; + (*head) = (struct block *)ptr; + (*head)->shcode = SHCODE; + leave_cs(countid); + leave_cs(sid); + + /* VB receives all frame except for the INIT one through normalSocket */ + if (dataSocket != normalSocket) + { + this->socket_flag_ = 1; + fprintf(stderr, "VB got INIT frame.\n"); + ACE_OS::write (initSocket, (char *)&initSocket, 1); /* write a garbage byte */ + // ACE_OS::close (initSocket); + // dataSocket = normalSocket; + // int result = ACE_Reactor::instance ()->remove_handler (this,ACE_Event_Handler::READ_MASK); + // if (result != 0) + // ACE_DEBUG ((LM_DEBUG,"remove handler failed for read_mask\n")); + + } - if (shared->config.syncEffective) { - if (state > 1 && state != 4 && (len = shared->qosRecomputes) != qosRecomputes) { - /* QoS feedback packet is sent if at any time send pattern is - recomputed, and sync feedback is not in active state*/ - send_feedback(dataSocket, 0, 0, advance); - qosRecomputes = len; - } - switch (state) { - case 4: /* active */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - if (pcmd == CmdPLAY && shared->usecPerFrame != upf) { - /* jump to state 5 if speed changes */ - state = 5; - break; - } - { - int interval = shared->usecPerFrame; - double val = (double)(pcmd == CmdPLAY ? - pfid - shared->nextFrame : - (pcmd == CmdFF ? - pgop - shared->nextGroup : - shared->nextGroup - pgop)); - fv = DoFilter(f, val); /* get average #frames in the whole client - pipeline, including all stages */ - val = val - fv; - fav = DoFilter(fa, val >= 0.0 ? val : -val); - /* get average #frames jitter in the whole client pipeline */ - - val = fav * interval * 6; - /* convert deviation in frame into microseconds, 6 is a magic number */ - - /* tries to recompute advance (in microseconds), and med/high/low - in adaptation to current jitter level */ - if ((val > advance && !reach_limit) || - (advance > min_advance && val < advance >> 3)) { - advance = (int) max(2 * val, min_advance); - med = advance / interval; - /* - if (pcmd == CmdPLAY) { - if (med < shared->VDframeNumber) { - med = shared->VDframeNumber; - } - } - else - */ - if (med < 2 ) { /* but keep minimum buffer fill level */ - med = 2; - } - if (med > (VB_BUF_SIZE / shared->averageFrameSize) / 2) { - reach_limit = 1; - med = (VB_BUF_SIZE / shared->averageFrameSize) / 2; - Fprintf(stderr, - "VB VSadvance control: VBbuf limit reached, med %d.\n", med); - } - else reach_limit = 0; - high = med + med / 2; - low = med - med / 2; - period = med * MAX_CLOCK_DRIFT; - Fprintf(stderr, - "VB: VS advance control: fav %5.2f, med %d, advance %d at nextFrame %d\n", - fav, med, advance, shared->nextFrame); - } - } - /* record the current time (fid or gopid) if buffer fill level drift - only very little */ - if ((int)fv == med) { - init_fv = fv; - init_pos = pcmd == CmdPLAY ? pfid : pgop; - break; - } - /* - fprintf(stderr, "VB fb: fv %lf\n", fv); - */ - /* try send action if low/high water mark is passed, or qos recomputed */ - /* There is problem here, the deltas of upf are sent, instead of upf - and frame themself. This scheme is not robust in case case feedback - packets are lost, and get resent */ - len = shared->qosRecomputes; - if (fv >= high || fv <= low || len != qosRecomputes) { - int addupf, addf; - int pos = pcmd == CmdPLAY ? pfid : pgop; - int dist = (int)(pcmd == CmdFB ? init_pos - pos : pos - init_pos); - if (fv >= high || fv <= low) { - if (dist < period) { /* try skip or stall */ - addf = (int)(med - fv); - addupf = 0; - } - else { /* try adjust VS clock rate */ - int added = (int)((double)cupf * (fv - (double)med) / (double) dist); - addf = (int)(med - fv); - addupf = added; - cupf += added; - } - state = 6; - } - else { /* fb only recomputed sendpattern, no state change */ - addupf = 0; - addf = 0; - } - - /* tries to send a feedback packet. */ - if (shared->live) { /* no sync feedback with live video */ - qosRecomputes = len; - } - else if (send_feedback(dataSocket, addupf, addf, advance) == -1) { - /* Keep trying action repeatedly if failed to send the action - packet (by keeping in state 4). - An action packet can also be lost in the network */ - state = 4; - } - else { - qosRecomputes = len; - } - if (state == 6) { /* record the time if an action packet is - successfully send, and indicate that an - feedback action leads to state 6, which after - delay sometime leads to state 3. - The action_delay should have been related - to round-trip time. */ - action_time = get_usec(); - action_delay = shared->usecPerFrame * 100; - not_action = 0; - } - } - break; - case 6: /* reset after action */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - if (pcmd == CmdPLAY && shared->usecPerFrame != upf) { - state = 5; - break; - } - /* Jump to transition state 3 only after delay for some - time, when feedback action has been taken, and the - effect has been propogated back to the client */ - if (get_duration(action_time, get_usec()) >= action_delay) { - state = 3; - } - break; - case 5: /* reset after speed change, feedback stays in this - state as long as play speed is changing */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - /* Jump to transition state 3, indicating that the transition - is not caused by feedback action */ - if (shared->currentUPF == shared->usecPerFrame) { - not_action = 1; - state = 3; - } - break; - case 2: /* delay after start, this delay is for avoiding feedback - action during server fast start-up. */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - if (pcmd == CmdPLAY) { - if (pfid - startpos >= delay) { - advance = shared->VStimeAdvance; - state = 3; - } - } - else if (pcmd == CmdFF) { - if (pgop - startpos >= delay) { - advance = shared->VStimeAdvance; - state = 3; - } - } - else { /* CmdFB */ - if (startpos - pgop >= delay) { - advance = shared->VStimeAdvance; - state = 3; - } - } - break; - case 3: /* transient state, entered after start-up delay, - action-delay, or play-speed change */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - /* Initialize both buffer-fill-level and jitter filters */ - if (f == NULL) { - f = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - } - else { - f = ResetFilter(f, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - } - if (fa == NULL) { - fa = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - DoFilter(fa, 0.0); - } - else if (not_action) { /* reset jitter level filter only - if entering this state is not - cause by feedback action */ - fa = ResetFilter(fa, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - } - if (f == NULL || fa == NULL) { - perror("VB failed to allocate space for filters"); - state = 0; - } - else { - init_fv = - DoFilter(f, (double)(pcmd == CmdPLAY ? - pfid - shared->nextFrame : - (pcmd == CmdFF ? - pgop - shared->nextGroup : - shared->nextGroup - pgop))); - init_pos = pcmd == CmdPLAY ? pfid : pgop; - upf = shared->currentUPF; - cupf = upf; - { - int interval = shared->usecPerFrame; - - /* upon speed change, 'advance', in microseconds, will - not change, but med/high/low will be updated. This - may suggest that in the new toolkit version of the - same feedback systems, the buffer-fill level and - jitter is measured directly in microseconds, not in - #frames then converting to microseconds. */ - med = advance / interval; - /* - if (pcmd == CmdPLAY) { - if (med < shared->VDframeNumber) { - med = shared->VDframeNumber; - min_advance = advance = med * interval; - } - } - else - */ - if (med < 2 ) { - med = 2; - advance = med * interval; - min_advance = max(advance, shared->VStimeAdvance); - } - else min_advance = shared->VStimeAdvance; - if (med > (VB_BUF_SIZE / shared->averageFrameSize) / 2) { - reach_limit = 1; - med = (VB_BUF_SIZE / shared->averageFrameSize) / 2; - if (not_action) { - Fprintf(stderr, - "VB start/speed-change: VBbuf limit reached, med %d.\n", med); - } - } - else reach_limit = 0; - } - high = med + med / 2; - low = med - med / 2; - delay = med * (SPEEDUP_INV_SCALE - 1); /* this delay is to avoid - feedback when VS is in - fast-start period */ - period = med * MAX_CLOCK_DRIFT; - if (not_action) { - Fprintf(stderr, - "VB start/speed-change: med %d, advance %d at nextFrame %d\n", - med, advance, shared->nextFrame); - } - state = 4; - } - break; - case 0: /* idle */ - if (pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB) { - cmdsn = pcmdsn; - state = 1; - } - break; - case 1: /* start */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - break; - } - startpos = pcmd == CmdPLAY ? pfid : pgop; - advance = shared->VStimeAdvance; - - /* following from vs.c: - timerAdjust = (VStimeAdvance * SPEEDUP_INV_SCALE) / currentUPF; - */ - med = advance / shared->usecPerFrame; - /* - if (pcmd != CmdPLAY) med /= shared->patternSize; - */ - delay = med * (SPEEDUP_INV_SCALE - 1); /* this delay is to avoid - feedback when VS is in - fast-start period */ - not_action = 1; - state = 2; - break; - default: - fprintf(stderr, "VB: unknown Feedback state %d reached.\n", state); - state = 0; - break; - } - } /* end if (shared->config.syncEffective) */ - else { - state = 0; - } -#ifdef STAT - if (shared->collectStat && packet->cmd != CmdREF) - { - char * val, * val1; - int size; - size = packet->frame; - shared->stat.VBframesReceived[size >>3] |= 1 << (size % 8); - val = (char *)*head; - val1 = (char *)*tail; - if (val >= val1) /* *head >= *tail */ - size = val - val1; - else - size = bufsize - (val1 - val); - shared->stat.VBmaxBytes = max(shared->stat.VBmaxBytes, size); - } -#endif - /* - fprintf(stderr, "VB: Packet(%x, buf:%x)=cmd-%d, cmdsn-%d sh-%d, gop-%d\n", - (int)packet, (int)buf, packet->cmd, packet->cmdsn, packet->sh, packet->gop); - fprintf(stderr, " frame-%d, display-%d, future-%d, past-%d, bytes-%d\n", - packet->frame, packet->display, packet->future, - packet->past, packet->dataBytes); - */ - break; /* got the whole packet, break to the out-most loop for next packet */ - } /* end if (psize == 0) */ - else if (psize < 0) - { - fprintf(stderr, "VB error: received too many msgs for a packet.\n"); - exit(1); - } - - /* try get another message for current packet */ - for (;;) - { - if (conn_tag >= 0) { - len = wait_read_bytes(dataSocket, (char *)&msghd, sizeof(msghd)); - } - else { - len = read(dataSocket, tmp_buf, -conn_tag); - memcpy((char *)&msghd, tmp_buf, sizeof(msghd)); - } - if (exit_tag) exit_on_kill(); - // ACE_DEBUG ((LM_DEBUG, "(%P|%t) vb: Got a packet of length = %d\n", len)); - if (len <= 0) - { - if (errno == EWOULDBLOCK || errno == EAGAIN) { - perror("VB sleep2 for 10ms"); - usleep(10000); - if (exit_tag) exit_on_kill(); - continue; - } - perror("VB recv data(MSG_PEEK)"); - exit(1); - } - if (len < sizeof(msghd)) { - fprintf(stderr, "VD warn: PEEK1ed %dB < expected %dB\n", - len, sizeof(msghd)); - continue; - } -#ifdef NeedByteOrderConversion - msghd.packetsn = ntohl(msghd.packetsn); - msghd.packetSize = ntohl(msghd.packetSize); - msghd.msgsn = ntohl(msghd.msgsn); - msghd.msgOffset = ntohl(msghd.msgOffset); - msghd.msgSize = ntohl(msghd.msgSize); -#endif - /* - fprintf(stderr, "VB PEEK2 a msg: sn-%d, size-%d, pkt-%d, pktsize-%d\n", - msghd.msgsn, msghd.msgSize, msghd.packetsn, msghd.packetSize); - */ -#ifdef STAT - { - int gap = msghd.msgsn - gap_msgsn; - gap = (gap >MSGGAP_MAX) ? MSGGAP_MAX : gap < MSGGAP_MIN ? MSGGAP_MIN : gap; - shared->stat.VBmsgGaps[gap - MSGGAP_MIN] ++; - if (gap >0) gap_msgsn = msghd.msgsn; - } -#endif - if (msghd.msgsn <= msgsn) { /* outdated message, wait for next one */ - /* - fprintf(stderr, "VB discard outdated or dup msgsn %d, pktsn %d\n", - msghd.msgsn, msghd.packetsn); - */ - skip_message(dataSocket, &msghd); - continue; - } - break; /* got a message for current packet */ - } /* end for (;;) */ - - if (msghd.msgsn > msgsn + 1 || msghd.msgOffset == 0) - { - /* message out of order, abandon current packet */ - /* - fprintf(stderr, "VB msg out of order for current packet, discard it.\n"); - */ -#ifdef STAT - to_count = 0; -#endif - goto start_new_packet; - } - else { - msgsn = msghd.msgsn; + /* following is synchronization feedback algorithm */ + this->sync_feedback (); + if (dataSocket != normalSocket) + { + dataSocket = normalSocket; + int result = ACE_Reactor::instance ()->register_handler (this,ACE_Event_Handler::READ_MASK); + if (result != 0) + ACE_DEBUG ((LM_DEBUG,"register handler failed for read_mask after datasocket change\n")); + return -1; + } + // return 0; + break; /* got the whole packet, break to the out-most loop for next packet */ + } /* end if (psize == 0) */ + else if (psize < 0) + { + fprintf(stderr, "VB error: received too many msgs for a packet.\n"); + ACE_Reactor::instance ()->end_event_loop (); + return -1; + } + this->state_ = READ_NEXT_HEADER; + temp = (char *)&msghd; + bytes = sizeof (msghd); + break; } } - } + return 0; } - -void MyVBprocess(int initSocket, int normalSocket) +int +VideoBuffer::handle_output (ACE_HANDLE fd) { - VideoMessage * msg, msghd; - VideoPacket * packet; - int len, bsize, msgsn = -1; - int psize, poffset; - char * ptr, *ptr1; - char *tmp_buf = NULL; - int dataSocket = initSocket; - - /* INIT frame is received from CTR through initSocket */ + if ((this->state_ == WRITE_FEEDBACK1) || (this->state_ == WRITE_FEEDBACK2)) + { + // send the feedback to the server. + VideoFeedBackPara para; + para.cmdsn = htonl(shared->cmdsn); + para.addUsecPerFrame = htonl(fb_addupf); + para.addFrames = htonl(fb_addf); + para.needHeader = htonl(shared->needHeader); + shared->needHeader = 0; + para.frameRateLimit1000 = + htonl((long)(shared->frameRateLimit * 1000.0)); + para.sendPatternGops = htonl(shared->sendPatternGops); + ACE_OS::memcpy (para.sendPattern, shared->sendPattern, PATTERN_SIZE); + + // fprintf(stderr, "VB to send a fb packet..."); + int res; + if (conn_tag != 0) + { /* packet stream */ + if (temp == 0) + { + temp = (char *)¶ + bytes = sizeof (para); + } + res = ACE_OS::write (dataSocket, temp, bytes); + if (res == -1) + { + if (errno == EINTR) + return 0; + if (errno == ENOBUFS) { + perror("VB Warning, fb packet discarded for"); + // Here we should handle the return -1 case! + fb_state = 4; + } + else + { + ACE_OS::perror ("VB error, fb packet sending failed"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + } + else if (res == 0) + { + ACE_OS::perror ("VB error, sending fb,socket closed"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + else + { + temp += res; + bytes -= res; + if (bytes != 0) + return 0; + } + } + else + { + res = ACE_OS::write (dataSocket, (char *)¶, sizeof(para)); + if (res == -1) + { + ACE_OS::perror ("VB error, fb packet sending failed"); + ACE_Reactor::instance ()->end_event_loop (); return -1; + } + if (res < sizeof(para)) + { + fprintf(stderr, "VB send_feedback() warn: res %dB < sizeof(para) %dB\n", + res, sizeof(para)); + } + } + if (errno != ENOBUFS) // fb_state == 4; + qosRecomputes = len; + ACE_Reactor::instance ()->remove_handler (this, + ACE_Event_Handler::WRITE_MASK); + if (this->state_ == WRITE_FEEDBACK2) + { + if (fb_state == 6) + { /* record the time if an action packet is + successfully send, and indicate that an + feedback action leads to state 6, which after + delay sometime leads to state 3. + The action_delay should have been related + to round-trip time. */ + action_time = get_usec(); + action_delay = shared->usecPerFrame * 100; + not_action = 0; + } + } + else if (this->state_ == WRITE_FEEDBACK2) + { + this->feedback_action (); + } #ifdef STAT - int to_count = 1; - int gap_msgsn = -1; -#endif - - /* following variables are for feedback */ - int pcmdsn, pcmd; /* to store the cmdsn and cmd of previous frame, - to detect new commands */ - 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 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 */ - int action_time; /* the time when feedback action is taken, used to enforce - action_delay */ - int upf, cupf; /* upf -- currentUPF as carried in all frames, - cupf -- real current UPF, being adjusted by FB */ - double fv; /* current buffer fill level in term of #frames */ - double init_fv; /* init_fv and init_pos record the fv value and position - (frameid or gopid) when fv is very close to med */ - double init_pos; - int high, low, med; /* median, high and low water marks, in term of #frames */ - int period; /* interms of #frames, (high-med, period) defined the max - buffer fill drift which can be assumed as caused by - clock drift */ - Filter * f = NULL; /* buffer fill level filter */ - - int advance, min_advance; /* in microseconds, advance holds the - current target buffer-fill-level as - determined by jitter level - estimate. min_advance sets a absolute - minimun level, no matter how low jitter - level is. - 'advance' does not change when - play-speed changes, but med/high/low - will be updated upon speed change */ - double fav; /* #frames, jitter level output by the filter */ - Filter * fa = NULL; /* jitter filter */ - int reach_limit = 0; /* indicate that the target 'advance' has reached client VB - buffer limit, and can not further increase, even if - jitter increases */ - int not_action = 1; /* indicates entering state=3 is not caused by - feedback action. If not_action = 1 entering state=3 - is caused either by 'start' or speed change, and - the jitter filter needs to be reset */ - - exit_tag = 0; - conn_tag = shared->videoMaxPktSize; - - savedSocket = normalSocket; -#if 0 -#ifdef __svr4__ - - /* On solaris 2.x for i86pc, a datagram socket may not discard the - remaining of a message if recv() fails to read the whole - thing. Following systems are tried but seems doesn't work. So for - this platform, This causes problem with skip_message() defined - above, which tries to discard whole packets by reading only a few - bytes. An alternative here is to allocate a big enough buffer, - read and discard the whole packet, this is less efficient because - of more data copy. - - But if we call read(2) instead of recv(), then it works. - */ - if (!conn_tag) { - len = ioctl(dataSocket, I_SRDOPT, RMSGD); /* discard unread part of the message */ - if (len) perror("error message"); - } -#endif -#endif - - setsignal(SIGUSR1, usr1_handler); - setsignal(SIGUSR2, usr2_handler); - - if (conn_tag < 0) { /* buffer big enough for discard mode packet stream */ - tmp_buf = (char *)malloc(-conn_tag); - if (tmp_buf == NULL) { - fprintf(stderr, "AB failed to allocate %d bytes"); - perror("of tmp_buf"); - exit(1); - } - } - - for (;;) - { - // fprintf(stderr, "VB wait for a new packet.\n"); - if (conn_tag >= 0) { - len = wait_read_bytes(dataSocket, (char *)&msghd, sizeof(msghd)); - } - else { /* discard mode packet stream, read all bytes */ - len = read(dataSocket, tmp_buf, -conn_tag); - memcpy((char *)&msghd, tmp_buf, sizeof(msghd)); - } - if (exit_tag) exit_on_kill(); - if (len == -1) { - if (errno == EWOULDBLOCK || errno == EAGAIN) { - perror("VB sleep for 10ms"); - usleep(10000); - if (exit_tag) exit_on_kill(); - continue; - } - perror("VB read() data"); - exit(1); - } - if (len == 0) { /* EOF, connection closed by peer */ - fprintf(stderr, "Error: VB found dataSocket broken\n"); - for (;;) { - usleep(1000000); - if (exit_tag) exit_on_kill(); + { + int i; + if ((i = shared->stat.fbPacketNumber) < MAX_FB_PACKETS) { + shared->stat.fbPackets[i].frameId = shared->nextFrame; + shared->stat.fbPackets[i].addUsecPerFrame = addupf; + shared->stat.fbPackets[i].addFrames = addf; + shared->stat.fbPackets[i].frames = shared->sendPatternGops * + shared->patternSize; + shared->stat.fbPackets[i].framesDropped = shared->framesDropped; + shared->stat.fbPackets[i].frameRateLimit = shared->frameRateLimit; + shared->stat.fbPackets[i].advance = advance; + } + shared->stat.fbPacketNumber ++; } - } - if (len < sizeof(msghd)) { - fprintf(stderr, "VD warn: PEEK1ed %dB < expected %dB\n", - len, sizeof(msghd)); - continue; - } -#ifdef NeedByteOrderConversion - msghd.packetsn = ntohl(msghd.packetsn); - msghd.packetSize = ntohl(msghd.packetSize); - msghd.msgsn = ntohl(msghd.msgsn); - msghd.msgOffset = ntohl(msghd.msgOffset); - msghd.msgSize = ntohl(msghd.msgSize); #endif - /* - fprintf(stderr, "VB PEEK1 a msg sn-%d, size-%d, pkt-%d, pktsize-%d\n", - msghd.msgsn, msghd.msgSize, msghd.packetsn, msghd.packetSize); - */ - - - start_new_packet: - - -#ifdef STAT - if (to_count) { - int gap = msghd.msgsn - gap_msgsn; - gap = (gap >MSGGAP_MAX) ? MSGGAP_MAX : gap < MSGGAP_MIN ? MSGGAP_MIN : gap; - shared->stat.VBmsgGaps[gap - MSGGAP_MIN] ++; - if (gap >0) gap_msgsn = msghd.msgsn; - } - to_count = 1; -#endif - if (msghd.msgsn <= msgsn) /* outdated msg */ - { - /* - fprintf(stderr, "VB discard outdated msgsn %d, pktsn %d when expecting first\n", - msghd.msgsn, msghd.packetsn); - */ - skip_message(dataSocket, &msghd); - continue; + // Now return to the reading header position. + this->state_ = READ_HEADER; + temp = (char *)&msghd; + bytes = sizeof (msghd); + int result = ACE_Reactor::instance ()->remove_handler (this, + ACE_Event_Handler::WRITE_MASK); + if (result != 0) + ACE_DEBUG ((LM_DEBUG,"remove_handler failed for write")); } - else if (msghd.msgOffset != 0) /* not first msg of a packet */ + return 0; +} + +int +VideoBuffer::sync_feedback (void) +{ + int result; + if (shared->config.syncEffective) { - /* - Fprintf(stderr, "VB discard non-first msg msgsn %d, pktsn %d\n", - msghd.msgsn, msghd.packetsn); - */ - skip_message(dataSocket, &msghd); - continue; - } - else - msgsn = msghd.msgsn; - - /* allocate packet for the incoming msg */ - bsize = msghd.packetSize + sizeof(**head)*2 + sizeof(msghd); - bsize = ((bsize+3)>>2)<<2; - enter_cs(sid); - if (*head >= *tail) + if (fb_state > 1 && fb_state != 4 && (len = shared->qosRecomputes) != qosRecomputes) + { + /* QoS feedback packet is sent if at any time send pattern is + recomputed, and sync feedback is not in active fb_state*/ + this->state_ = WRITE_FEEDBACK1; + result = ACE_Reactor::instance ()->register_handler (this,ACE_Event_Handler::WRITE_MASK); + if (result != 0) + return result; + fb_addupf = 0; + fb_addf = 0; + fb_advance = advance; + temp = 0; + return 0; + } + this->feedback_action (); + } /* end if (shared->config.syncEffective) */ + else + fb_state = 0; + return 0; +} + +int +VideoBuffer::feedback_action (void) +{ + switch (fb_state) { - if (bufsize - (int)((char*)*head - buf) >= bsize ) - msg =(VideoMessage *)((char*)*head + sizeof(**head)); - else if ((int)((char*)*tail - buf) >= bsize) - { - (*head)->next = (struct block *)buf; - (*head)->full = 0; - *head = (struct block *)buf; - msg = (VideoMessage *)(buf + sizeof(**head)); - *head = (struct block *)buf; - (*head)->shcode = SHCODE; - } - else /* not enough buffer, discard current message */ + case 4: /* active */ + if (pcmdsn != cmdsn) + { + cmdsn = pcmdsn; + if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) + fb_state = 0; + else + fb_state = 1; + break; + } + if (pcmd == CmdPLAY && shared->usecPerFrame != upf) + { + /* jump to fb_state 5 if speed changes */ + fb_state = 5; + break; + } { - leave_cs(sid); -#ifdef STAT - if (shared->collectStat) - shared->stat.VBdroppedFrames ++; -#endif - /* - Fprintf(stderr, "VB not enough space 1, drop msg.sn %d pktsn %d\n", - msghd.msgsn, msghd.packetsn); - */ - skip_message(dataSocket, &msghd); - continue; + int interval = shared->usecPerFrame; + double val = (double)(pcmd == CmdPLAY ? + pfid - shared->nextFrame : + (pcmd == CmdFF ? + pgop - shared->nextGroup : + shared->nextGroup - pgop)); + fv = DoFilter(f, val); /* get average #frames in the whole client + pipeline, including all stages */ + val = val - fv; + fav = DoFilter(fa, val >= 0.0 ? val : -val); + /* get average #frames jitter in the whole client pipeline */ + + val = fav * interval * 6; + /* convert deviation in frame into microseconds, 6 is a magic number */ + + /* tries to recompute advance (in microseconds), and med/high/low + in adaptation to current jitter level */ + if ((val > advance && !reach_limit) || + (advance > min_advance && val < advance >> 3)) { + advance = (int) max(2 * val, min_advance); + med = advance / interval; + /* + if (pcmd == CmdPLAY) { + if (med < shared->VDframeNumber) { + med = shared->VDframeNumber; + } + } + else + */ + if (med < 2 ) { /* but keep minimum buffer fill level */ + med = 2; + } + if (med > (VB_BUF_SIZE / shared->averageFrameSize) / 2) { + reach_limit = 1; + med = (VB_BUF_SIZE / shared->averageFrameSize) / 2; + Fprintf(stderr, + "VB VSadvance control: VBbuf limit reached, med %d.\n", med); + } + else reach_limit = 0; + high = med + med / 2; + low = med - med / 2; + period = med * MAX_CLOCK_DRIFT; + Fprintf(stderr, + "VB: VS advance control: fav %5.2f, med %d, advance %d at nextFrame %d\n", + fav, med, advance, shared->nextFrame); + } } - } - else /* *head < *tail */ - if ((char*)*tail - (char*)*head >= bsize) - msg = (VideoMessage *)((char*)*head + sizeof(**head)); - else /* not enough buffer, abandon current message */ - { - leave_cs(sid); -#ifdef STAT - if (shared->collectStat) - shared->stat.VBdroppedFrames ++; -#endif + /* record the current time (fid or gopid) if buffer fill level drift + only very little */ + if ((int)fv == med) + { + init_fv = fv; + init_pos = pcmd == CmdPLAY ? pfid : pgop; + break; + } /* - Fprintf(stderr, "VB not enough space 1, drop msg.sn %d pktsn %d\n", - msghd.msgsn, msghd.packetsn); + fprintf(stderr, "VB fb: fv %lf\n", fv); */ - skip_message(dataSocket, &msghd); - continue; - } - leave_cs(sid); - /* - fprintf(stderr, "VB allocated a buffer for comming packet.\n"); - */ - psize = msghd.packetSize; - poffset = 0; - packet = (VideoPacket *)((char*)msg + sizeof(msghd)); - *(((int*)packet)+(msghd.packetSize>>2)) = 0; - /* clear the last no more than three bytes, for - proper detecting the end of packet by VD */ - ptr = (char*)msg; - for (;;) - { - int bytes; - bytes = sizeof(msghd) + msghd.msgSize; - if (conn_tag >= 0) { - len = bytes; - read_bytes(dataSocket, ptr + sizeof(msghd), bytes - sizeof(msghd)); + /* try send action if low/high water mark is passed, or qos recomputed */ + /* There is problem here, the deltas of upf are sent, instead of upf + and frame themself. This scheme is not robust in case case feedback + packets are lost, and get resent */ + len = shared->qosRecomputes; + if (fv >= high || fv <= low || len != qosRecomputes) + { + int addupf, addf; + int pos = pcmd == CmdPLAY ? pfid : pgop; + int dist = (int)(pcmd == CmdFB ? init_pos - pos : pos - init_pos); + if (fv >= high || fv <= low) + { + if (dist < period) + { /* try skip or stall */ + addf = (int)(med - fv); + addupf = 0; + } + else + { /* try adjust VS clock rate */ + int added = (int)((double)cupf * (fv - (double)med) / (double) dist); + addf = (int)(med - fv); + addupf = added; + cupf += added; + } + fb_state = 6; + } + else + { /* fb only recomputed sendpattern, no fb_state change */ + addupf = 0; + addf = 0; + } + + /* tries to send a feedback packet. */ + if (shared->live) + /* no sync feedback with live video */ + qosRecomputes = len; + else + { + this->state_ = WRITE_FEEDBACK2; + int result = ACE_Reactor::instance ()->register_handler (this,ACE_Event_Handler::WRITE_MASK); + if (result != 0) + return result; + fb_addupf = addupf; + fb_addf = addf; + fb_advance = advance; + return 0; + } + if (fb_state == 6) + { /* record the time if an action packet is + successfully send, and indicate that an + feedback action leads to fb_state 6, which after + delay sometime leads to fb_state 3. + The action_delay should have been related + to round-trip time. */ + action_time = get_usec(); + action_delay = shared->usecPerFrame * 100; + not_action = 0; + } + } + break; + case 6: /* reset after action */ + if (pcmdsn != cmdsn) + { + cmdsn = pcmdsn; + if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) + fb_state = 0; + else + fb_state = 1; + break; + } + if (pcmd == CmdPLAY && shared->usecPerFrame != upf) + { + fb_state = 5; + break; + } + /* Jump to transition fb_state 3 only after delay for some + time, when feedback action has been taken, and the + effect has been propogated back to the client */ + if (get_duration(action_time, get_usec()) >= action_delay) + fb_state = 3; + break; + case 5: /* reset after speed change, feedback stays in this + fb_state as long as play speed is changing */ + if (pcmdsn != cmdsn) + { + cmdsn = pcmdsn; + if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) + fb_state = 0; + else + fb_state = 1; + break; + } + /* Jump to transition fb_state 3, indicating that the transition + is not caused by feedback action */ + if (shared->currentUPF == shared->usecPerFrame) + { + not_action = 1; + fb_state = 3; + } + break; + case 2: /* delay after start, this delay is for avoiding feedback + action during server fast start-up. */ + if (pcmdsn != cmdsn) { + cmdsn = pcmdsn; + if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { + fb_state = 0; + } + else { + fb_state = 1; + } + break; + } + if (pcmd == CmdPLAY) { + if (pfid - startpos >= delay) { + advance = shared->VStimeAdvance; + fb_state = 3; + } + } + else if (pcmd == CmdFF) { + if (pgop - startpos >= delay) { + advance = shared->VStimeAdvance; + fb_state = 3; + } + } + else { /* CmdFB */ + if (startpos - pgop >= delay) { + advance = shared->VStimeAdvance; + fb_state = 3; + } + } + break; + case 3: /* transient fb_state, entered after start-up delay, + action-delay, or play-speed change */ + if (pcmdsn != cmdsn) { + cmdsn = pcmdsn; + if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { + fb_state = 0; + } + else { + fb_state = 1; + } + break; + } + /* Initialize both buffer-fill-level and jitter filters */ + if (f == NULL) { + f = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ? + shared->config.filterPara : 100); } else { - len = bytes; - memcpy(ptr + sizeof(msghd), tmp_buf + sizeof(msghd), bytes - sizeof(msghd)); + f = ResetFilter(f, shared->config.filterPara >= 1 ? + shared->config.filterPara : 100); } - if (exit_tag) exit_on_kill(); - if (len == -1) { - perror("VB fails to recv data"); - exit(1); + if (fa == NULL) { + fa = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ? + shared->config.filterPara : 100); + DoFilter(fa, 0.0); } - if (len < bytes) { - fprintf(stderr, "VB warn: recv() len %dB < bytes %dB\n", len, bytes); + else if (not_action) { /* reset jitter level filter only + if entering this fb_state is not + cause by feedback action */ + fa = ResetFilter(fa, shared->config.filterPara >= 1 ? + shared->config.filterPara : 100); } - /* because message header is already PEEKed to msghd before recv(), so we can - use info in msghd instead of *(VideoMessage*)ptr */ - if (len != sizeof(msghd)+msghd.msgSize) - /* some of msg contents not successfully received, abandon current packet */ - { - /* - fprintf(stderr, "VB got corrupted msg, len=%d, supposed len=%d\n", - len, sizeof(msghd)+msghd.msgSize); - */ + if (f == NULL || fa == NULL) { + ACE_OS::perror ("VB failed to allocate space for filters"); + fb_state = 0; + } + else { + init_fv = + DoFilter(f, (double)(pcmd == CmdPLAY ? + pfid - shared->nextFrame : + (pcmd == CmdFF ? + pgop - shared->nextGroup : + shared->nextGroup - pgop))); + init_pos = pcmd == CmdPLAY ? pfid : pgop; + upf = shared->currentUPF; + cupf = upf; + { + int interval = shared->usecPerFrame; + + /* upon speed change, 'advance', in microseconds, will + not change, but med/high/low will be updated. This + may suggest that in the new toolkit version of the + same feedback systems, the buffer-fill level and + jitter is measured directly in microseconds, not in + #frames then converting to microseconds. */ + med = advance / interval; + /* + if (pcmd == CmdPLAY) { + if (med < shared->VDframeNumber) { + med = shared->VDframeNumber; + min_advance = advance = med * interval; + } + } + else + */ + if (med < 2 ) { + med = 2; + advance = med * interval; + min_advance = max(advance, shared->VStimeAdvance); + } + else min_advance = shared->VStimeAdvance; + if (med > (VB_BUF_SIZE / shared->averageFrameSize) / 2) { + reach_limit = 1; + med = (VB_BUF_SIZE / shared->averageFrameSize) / 2; + if (not_action) { + Fprintf(stderr, + "VB start/speed-change: VBbuf limit reached, med %d.\n", med); + } + } + else reach_limit = 0; + } + high = med + med / 2; + low = med - med / 2; + delay = med * (SPEEDUP_INV_SCALE - 1); /* this delay is to avoid + feedback when VS is in + fast-start period */ + period = med * MAX_CLOCK_DRIFT; + if (not_action) { + Fprintf(stderr, + "VB start/speed-change: med %d, advance %d at nextFrame %d\n", + med, advance, shared->nextFrame); + } + fb_state = 4; + } + break; + case 0: /* idle */ + if (pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB) { + cmdsn = pcmdsn; + fb_state = 1; + } + break; + case 1: /* start */ + if (pcmdsn != cmdsn) { + cmdsn = pcmdsn; + if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { + fb_state = 0; + } break; } - poffset += msghd.msgSize; - psize -= msghd.msgSize; - ptr += msghd.msgSize; + startpos = pcmd == CmdPLAY ? pfid : pgop; + advance = shared->VStimeAdvance; + + /* following from vs.c: + timerAdjust = (VStimeAdvance * SPEEDUP_INV_SCALE) / currentUPF; + */ + med = advance / shared->usecPerFrame; /* - fprintf(stderr, "VB packet remain size %d\n", psize); + if (pcmd != CmdPLAY) med /= shared->patternSize; */ - if (psize == 0) - { - /* finished receiving the current packet */ -#ifdef NeedByteOrderConversion - packet->cmd = ntohl(packet->cmd); - packet->cmdsn = ntohl(packet->cmdsn); - packet->sh = ntohl(packet->sh); - packet->gop = ntohl(packet->gop); - packet->frame = ntohl(packet->frame); - packet->display = ntohl(packet->display); - packet->future = ntohl(packet->future); - packet->past = ntohl(packet->past); - packet->currentUPF = ntohl(packet->currentUPF); - packet->dataBytes = ntohl(packet->dataBytes); -#endif - pcmdsn = packet->cmdsn; - pcmd = packet->cmd; - pfid = packet->frame; - pgop = packet->gop; - shared->VBheadFrame = (pcmd == CmdPLAY) ? pfid : pgop; - - shared->currentUPF = packet->currentUPF; - enter_cs(sid); - (*head)->full = 1; - psize = sizeof(**head) + sizeof(*msg) + msghd.packetSize; - psize = ((psize+3)>>2)<<2; - ptr = (char*)*head + psize; - (*head)->next = (struct block *) ptr; - (*head) = (struct block *)ptr; - (*head)->shcode = SHCODE; - leave_cs(countid); - leave_cs(sid); - - /* VB receives all frame except for the INIT one through normalSocket */ - if (dataSocket != normalSocket) { - /* - Fprintf(stderr, "VB got INIT frame.\n"); - */ - write(initSocket, (char *)&initSocket, 1); /* write a garbage byte */ - close(initSocket); - dataSocket = normalSocket; - } - - /* following is synchronization feedback algorithm */ - - if (shared->config.syncEffective) { - if (state > 1 && state != 4 && (len = shared->qosRecomputes) != qosRecomputes) { - /* QoS feedback packet is sent if at any time send pattern is - recomputed, and sync feedback is not in active state*/ - send_feedback(dataSocket, 0, 0, advance); - qosRecomputes = len; - } - switch (state) { - case 4: /* active */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - if (pcmd == CmdPLAY && shared->usecPerFrame != upf) { - /* jump to state 5 if speed changes */ - state = 5; - break; - } - { - int interval = shared->usecPerFrame; - double val = (double)(pcmd == CmdPLAY ? - pfid - shared->nextFrame : - (pcmd == CmdFF ? - pgop - shared->nextGroup : - shared->nextGroup - pgop)); - fv = DoFilter(f, val); /* get average #frames in the whole client - pipeline, including all stages */ - val = val - fv; - fav = DoFilter(fa, val >= 0.0 ? val : -val); - /* get average #frames jitter in the whole client pipeline */ - - val = fav * interval * 6; - /* convert deviation in frame into microseconds, 6 is a magic number */ - - /* tries to recompute advance (in microseconds), and med/high/low - in adaptation to current jitter level */ - if ((val > advance && !reach_limit) || - (advance > min_advance && val < advance >> 3)) { - advance = (int) max(2 * val, min_advance); - med = advance / interval; - /* - if (pcmd == CmdPLAY) { - if (med < shared->VDframeNumber) { - med = shared->VDframeNumber; - } - } - else - */ - if (med < 2 ) { /* but keep minimum buffer fill level */ - med = 2; - } - if (med > (VB_BUF_SIZE / shared->averageFrameSize) / 2) { - reach_limit = 1; - med = (VB_BUF_SIZE / shared->averageFrameSize) / 2; - Fprintf(stderr, - "VB VSadvance control: VBbuf limit reached, med %d.\n", med); - } - else reach_limit = 0; - high = med + med / 2; - low = med - med / 2; - period = med * MAX_CLOCK_DRIFT; - Fprintf(stderr, - "VB: VS advance control: fav %5.2f, med %d, advance %d at nextFrame %d\n", - fav, med, advance, shared->nextFrame); - } - } - /* record the current time (fid or gopid) if buffer fill level drift - only very little */ - if ((int)fv == med) { - init_fv = fv; - init_pos = pcmd == CmdPLAY ? pfid : pgop; - break; - } - /* - fprintf(stderr, "VB fb: fv %lf\n", fv); - */ - /* try send action if low/high water mark is passed, or qos recomputed */ - /* There is problem here, the deltas of upf are sent, instead of upf - and frame themself. This scheme is not robust in case case feedback - packets are lost, and get resent */ - len = shared->qosRecomputes; - if (fv >= high || fv <= low || len != qosRecomputes) { - int addupf, addf; - int pos = pcmd == CmdPLAY ? pfid : pgop; - int dist = (int)(pcmd == CmdFB ? init_pos - pos : pos - init_pos); - if (fv >= high || fv <= low) { - if (dist < period) { /* try skip or stall */ - addf = (int)(med - fv); - addupf = 0; - } - else { /* try adjust VS clock rate */ - int added = (int)((double)cupf * (fv - (double)med) / (double) dist); - addf = (int)(med - fv); - addupf = added; - cupf += added; - } - state = 6; - } - else { /* fb only recomputed sendpattern, no state change */ - addupf = 0; - addf = 0; - } - - /* tries to send a feedback packet. */ - if (shared->live) { /* no sync feedback with live video */ - qosRecomputes = len; - } - else if (send_feedback(dataSocket, addupf, addf, advance) == -1) { - /* Keep trying action repeatedly if failed to send the action - packet (by keeping in state 4). - An action packet can also be lost in the network */ - state = 4; - } - else { - qosRecomputes = len; - } - if (state == 6) { /* record the time if an action packet is - successfully send, and indicate that an - feedback action leads to state 6, which after - delay sometime leads to state 3. - The action_delay should have been related - to round-trip time. */ - action_time = get_usec(); - action_delay = shared->usecPerFrame * 100; - not_action = 0; - } - } - break; - case 6: /* reset after action */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - if (pcmd == CmdPLAY && shared->usecPerFrame != upf) { - state = 5; - break; - } - /* Jump to transition state 3 only after delay for some - time, when feedback action has been taken, and the - effect has been propogated back to the client */ - if (get_duration(action_time, get_usec()) >= action_delay) { - state = 3; - } - break; - case 5: /* reset after speed change, feedback stays in this - state as long as play speed is changing */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - /* Jump to transition state 3, indicating that the transition - is not caused by feedback action */ - if (shared->currentUPF == shared->usecPerFrame) { - not_action = 1; - state = 3; - } - break; - case 2: /* delay after start, this delay is for avoiding feedback - action during server fast start-up. */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - if (pcmd == CmdPLAY) { - if (pfid - startpos >= delay) { - advance = shared->VStimeAdvance; - state = 3; - } - } - else if (pcmd == CmdFF) { - if (pgop - startpos >= delay) { - advance = shared->VStimeAdvance; - state = 3; - } - } - else { /* CmdFB */ - if (startpos - pgop >= delay) { - advance = shared->VStimeAdvance; - state = 3; - } - } - break; - case 3: /* transient state, entered after start-up delay, - action-delay, or play-speed change */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - else { - state = 1; - } - break; - } - /* Initialize both buffer-fill-level and jitter filters */ - if (f == NULL) { - f = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - } - else { - f = ResetFilter(f, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - } - if (fa == NULL) { - fa = NewFilter(FILTER_LOWPASS, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - DoFilter(fa, 0.0); - } - else if (not_action) { /* reset jitter level filter only - if entering this state is not - cause by feedback action */ - fa = ResetFilter(fa, shared->config.filterPara >= 1 ? - shared->config.filterPara : 100); - } - if (f == NULL || fa == NULL) { - perror("VB failed to allocate space for filters"); - state = 0; - } - else { - init_fv = - DoFilter(f, (double)(pcmd == CmdPLAY ? - pfid - shared->nextFrame : - (pcmd == CmdFF ? - pgop - shared->nextGroup : - shared->nextGroup - pgop))); - init_pos = pcmd == CmdPLAY ? pfid : pgop; - upf = shared->currentUPF; - cupf = upf; - { - int interval = shared->usecPerFrame; + delay = med * (SPEEDUP_INV_SCALE - 1); /* this delay is to avoid + feedback when VS is in + fast-start period */ + not_action = 1; + fb_state = 2; + break; + default: + fprintf(stderr, "VB: unknown Feedback fb_state %d reached.\n", fb_state); + fb_state = 0; + break; + } +} - /* upon speed change, 'advance', in microseconds, will - not change, but med/high/low will be updated. This - may suggest that in the new toolkit version of the - same feedback systems, the buffer-fill level and - jitter is measured directly in microseconds, not in - #frames then converting to microseconds. */ - med = advance / interval; - /* - if (pcmd == CmdPLAY) { - if (med < shared->VDframeNumber) { - med = shared->VDframeNumber; - min_advance = advance = med * interval; - } - } - else - */ - if (med < 2 ) { - med = 2; - advance = med * interval; - min_advance = max(advance, shared->VStimeAdvance); - } - else min_advance = shared->VStimeAdvance; - if (med > (VB_BUF_SIZE / shared->averageFrameSize) / 2) { - reach_limit = 1; - med = (VB_BUF_SIZE / shared->averageFrameSize) / 2; - if (not_action) { - Fprintf(stderr, - "VB start/speed-change: VBbuf limit reached, med %d.\n", med); - } - } - else reach_limit = 0; - } - high = med + med / 2; - low = med - med / 2; - delay = med * (SPEEDUP_INV_SCALE - 1); /* this delay is to avoid - feedback when VS is in - fast-start period */ - period = med * MAX_CLOCK_DRIFT; - if (not_action) { - Fprintf(stderr, - "VB start/speed-change: med %d, advance %d at nextFrame %d\n", - med, advance, shared->nextFrame); - } - state = 4; - } - break; - case 0: /* idle */ - if (pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB) { - cmdsn = pcmdsn; - state = 1; - } - break; - case 1: /* start */ - if (pcmdsn != cmdsn) { - cmdsn = pcmdsn; - if (!(pcmd == CmdPLAY || pcmd == CmdFF || pcmd == CmdFB)) { - state = 0; - } - break; - } - startpos = pcmd == CmdPLAY ? pfid : pgop; - advance = shared->VStimeAdvance; +ACE_HANDLE +Notification_Handler::get_handle (void) const +{ + return -1; +} - /* following from vs.c: - timerAdjust = (VStimeAdvance * SPEEDUP_INV_SCALE) / currentUPF; - */ - med = advance / shared->usecPerFrame; - /* - if (pcmd != CmdPLAY) med /= shared->patternSize; - */ - delay = med * (SPEEDUP_INV_SCALE - 1); /* this delay is to avoid - feedback when VS is in - fast-start period */ - not_action = 1; - state = 2; - break; - default: - fprintf(stderr, "VB: unknown Feedback state %d reached.\n", state); - state = 0; - break; - } - } /* end if (shared->config.syncEffective) */ - else { - state = 0; - } -#ifdef STAT - if (shared->collectStat && packet->cmd != CmdREF) - { - char * val, * val1; - int size; - size = packet->frame; - shared->stat.VBframesReceived[size >>3] |= 1 << (size % 8); - val = (char *)*head; - val1 = (char *)*tail; - if (val >= val1) /* *head >= *tail */ - size = val - val1; - else - size = bufsize - (val1 - val); - shared->stat.VBmaxBytes = max(shared->stat.VBmaxBytes, size); - } -#endif - /* - fprintf(stderr, "VB: Packet(%x, buf:%x)=cmd-%d, cmdsn-%d sh-%d, gop-%d\n", - (int)packet, (int)buf, packet->cmd, packet->cmdsn, packet->sh, packet->gop); - fprintf(stderr, " frame-%d, display-%d, future-%d, past-%d, bytes-%d\n", - packet->frame, packet->display, packet->future, - packet->past, packet->dataBytes); - */ - break; /* got the whole packet, break to the out-most loop for next packet */ - } /* end if (psize == 0) */ - else if (psize < 0) - { - fprintf(stderr, "VB error: received too many msgs for a packet.\n"); - exit(1); - } +int +Notification_Handler::handle_input (ACE_HANDLE fd) +{ + ACE_DEBUG ((LM_DEBUG,"Notification_Handler::handle_input")); + char message[BUFSIZ]; + message [0] = 0; + // used to indicate that we should exit. + int result = + ACE_OS::read (fd,message,BUFSIZ); + + ACE_DEBUG ((LM_DEBUG,"result:%d,message[0]:%d\n",result,message[0])); + if (result == 0) + { + ACE_DEBUG ((LM_DEBUG,"AB process exiting, notification socket eof while reading\n")); + ACE_Reactor::instance ()->end_event_loop (); + return -1; + } + if (result == -1) + { + ACE_DEBUG ((LM_DEBUG,"AB process exiting, notification socket error while reading\n")); + ACE_Reactor::instance ()->end_event_loop (); + return -1; + } + ACE_DEBUG ((LM_DEBUG," %d %d\n",result,message[0])); - /* try get another message for current packet */ - for (;;) - { - if (conn_tag >= 0) { - len = wait_read_bytes(dataSocket, (char *)&msghd, sizeof(msghd)); - } - else { - len = read(dataSocket, tmp_buf, -conn_tag); - memcpy((char *)&msghd, tmp_buf, sizeof(msghd)); - } - if (exit_tag) exit_on_kill(); - if (len <= 0) - { - if (errno == EWOULDBLOCK || errno == EAGAIN) { - perror("VB sleep2 for 10ms"); - usleep(10000); - if (exit_tag) exit_on_kill(); - continue; - } - perror("VB recv data(MSG_PEEK)"); - exit(1); - } - if (len < sizeof(msghd)) { - fprintf(stderr, "VD warn: PEEK1ed %dB < expected %dB\n", - len, sizeof(msghd)); - continue; - } -#ifdef NeedByteOrderConversion - msghd.packetsn = ntohl(msghd.packetsn); - msghd.packetSize = ntohl(msghd.packetSize); - msghd.msgsn = ntohl(msghd.msgsn); - msghd.msgOffset = ntohl(msghd.msgOffset); - msghd.msgSize = ntohl(msghd.msgSize); -#endif - /* - fprintf(stderr, "VB PEEK2 a msg: sn-%d, size-%d, pkt-%d, pktsize-%d\n", - msghd.msgsn, msghd.msgSize, msghd.packetsn, msghd.packetSize); - */ -#ifdef STAT - { - int gap = msghd.msgsn - gap_msgsn; - gap = (gap >MSGGAP_MAX) ? MSGGAP_MAX : gap < MSGGAP_MIN ? MSGGAP_MIN : gap; - shared->stat.VBmsgGaps[gap - MSGGAP_MIN] ++; - if (gap >0) gap_msgsn = msghd.msgsn; - } -#endif - if (msghd.msgsn <= msgsn) { /* outdated message, wait for next one */ - /* - fprintf(stderr, "VB discard outdated or dup msgsn %d, pktsn %d\n", - msghd.msgsn, msghd.packetsn); - */ - skip_message(dataSocket, &msghd); - continue; - } - break; /* got a message for current packet */ - } /* end for (;;) */ - - if (msghd.msgsn > msgsn + 1 || msghd.msgOffset == 0) - { - /* message out of order, abandon current packet */ - /* - fprintf(stderr, "VB msg out of order for current packet, discard it.\n"); - */ -#ifdef STAT - to_count = 0; -#endif - goto start_new_packet; - } - else { - msgsn = msghd.msgsn; - } + switch (message[0]) + { + case EXIT: + ACE_DEBUG ((LM_DEBUG,"AB process exiting because of exit signal\n")); + set_exit_routine_tag(0); + VideoBuffer::VBdeleteBuf(); + ACE_Reactor::instance ()->end_event_loop (); + return -1; + default: + break; } - } + return 0; +} + +ACE_HANDLE +Video_Notification_Handler::get_handle (void) const +{ + return vsp[1]; } 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 4ae1860f12f..9eb3e6e1c57 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vd.cpp @@ -25,6 +25,8 @@ * email: scen@cse.ogi.edu */ +extern int vdsp[2]; + #include <stdio.h> #include <errno.h> #include <signal.h> @@ -43,6 +45,7 @@ #include "dither.h" #include "video.h" #include "proto.h" +#include "vb.h" ACE_RCSID(mpeg_client, vd, "$Id$") @@ -56,6 +59,7 @@ static int ecountid, ccountid; static int sid; extern VidStream * curVidStream; +extern VideoBuffer *vbuffer; static struct shared_mem_block { @@ -96,7 +100,7 @@ static void put_block(FrameBlock * bptr, int tag) if (shm->sptr > MAX_VDBLOCK_NUM) { fprintf(stderr, "VD weird error: ESTACK full.\n"); - exit(1); + ACE_OS::exit (1); } } else @@ -165,8 +169,8 @@ void VDresizeBuf(int height, int width) if (get_semval(ecountid) < 0) { fprintf(stderr, "Error<weird>: pid %d get (ecountid) = %d < 0\n", - getpid(), get_semval(ecountid)); - exit(1); + ACE_OS::getpid (), get_semval(ecountid)); + ACE_OS::exit (1); } /* fprintf(stderr, "VD before resizeBuf(): get_semval(ecountid) = %d\n", @@ -195,7 +199,7 @@ void VDresizeBuf(int height, int width) { fprintf(stderr, "VD error: VDbuf fails to hold at least 3(three) block.\n"); - exit(1); + ACE_OS::exit (1); } shm->sptr = 0; /* empty stack */ shm->qhead = shm->qtail = 0; /* empty cqueue */ @@ -228,7 +232,7 @@ FrameBlock * VDgetBuf(void) /* block version, return with interrupt */ fprintf(stderr, "VD error: VDgetBuf should not return NULL.\n"); /* fprintf(stderr, "pid %d VDgetBuf() %u, ref %d, ecount %d\n", - getpid(), (unsigned)ptr, ptr->refcount, get_semval(ecountid)); + ACE_OS::getpid (), (unsigned)ptr, ptr->refcount, get_semval(ecountid)); */ return ptr; } @@ -249,7 +253,7 @@ void VDputMsg(FrameBlock * msgPtr) leave_cs(sid); /* fprintf(stderr, "pid %d VDputMsg() %u, ref %d, ccount %d\n", - getpid(), (unsigned)msgPtr, msgPtr->refcount, get_semval(ccountid)); + ACE_OS::getpid (), (unsigned)msgPtr, msgPtr->refcount, get_semval(ccountid)); */ } @@ -264,7 +268,7 @@ FrameBlock * VDgetMsg(void) /* block version, return with interrupt */ fprintf(stderr, "VD error: VDgetMsg should not return NULL.\n"); /* fprintf(stderr, "pid %d VDgetMsg() %u, ref %d, ccount %d\n", - getpid(), (unsigned)ptr, ptr->refcount, get_semval(ccountid)); + ACE_OS::getpid (), (unsigned)ptr, ptr->refcount, get_semval(ccountid)); */ return ptr; } @@ -297,7 +301,7 @@ FrameBlock * VDpeekMsg(void) /* if (ptr != NULL) { fprintf(stderr, "pid %d VDpeekMsg() = %u, ref=%d\n", - getpid(), (unsigned)ptr, ptr->refcount); + ACE_OS::getpid (), (unsigned)ptr, ptr->refcount); } */ return ptr; @@ -310,7 +314,7 @@ void VDreferMsg(FrameBlock * msgPtr) leave_cs(sid); /* fprintf(stderr, "pid %d VDreferMsg() %u, ccount %d\n", - getpid(), (unsigned)msgPtr, get_semval(ccountid)); + ACE_OS::getpid (), (unsigned)msgPtr, get_semval(ccountid)); */ } @@ -329,11 +333,11 @@ void VDreclaimMsg(FrameBlock * msgPtr) leave_cs(sid); /* fprintf(stderr, "pid %d VDreclaimMsg() %u, ref %d, ecount %d\n", - getpid(), (unsigned)msgPtr, ref, get_semval(ecountid)); + ACE_OS::getpid (), (unsigned)msgPtr, ref, get_semval(ecountid)); */ if (ref <= 0) { Fprintf(stderr, "pid %d VDreclaimMsg() %u WEIRD, :ref %d:, ecount %d\n", - getpid(), (unsigned)msgPtr, ref, get_semval(ecountid)); + ACE_OS::getpid (), (unsigned)msgPtr, ref, get_semval(ecountid)); } } @@ -357,7 +361,7 @@ get_more_data(unsigned int *buf_start, int max_length, "Fatel error: vd.c get_more_data() should not be called, bufLength = %d.!\n", *length_ptr); fprintf(stderr, " **** Please report this bug. ****\n"); - // exit(1); + // ACE_OS::exit (1); return 0; } @@ -370,17 +374,8 @@ static void printPacket(VideoPacket *p) p->past, p->dataBytes); } -static void usr1_handler(int sig) -{ - fprintf(stderr, "VD void usr1_handler.\n"); -} - -static void usr2_handler(int sig) -{ - fprintf(stderr, "VD void usr2_handler\n"); -} -void VDprocess(int CTRpid) +void VDprocess (int CTRpid) { FrameBlock * curBlk = NULL; PictImage * curPict = NULL; @@ -391,11 +386,9 @@ void VDprocess(int CTRpid) if (curVidStream == NULL) { fprintf(stderr, "VD: unable to allocat curVidStream.\n"); - exit(1); + ACE_OS::exit (1); } - setsignal(SIGUSR1, usr1_handler); - setsignal(SIGUSR2, usr2_handler); - + for(;;) { int curcmd, curcmdsn; @@ -407,24 +400,21 @@ void VDprocess(int CTRpid) VDreclaimMsg(curBlk); curBlk = NULL; } - p = (VideoPacket*)VBgetMsg(); /* guarranteed to get a Packet */ - - //printPacket(p); - + p = (VideoPacket*)vbuffer->VBgetMsg(); /* guarranteed to get a Packet */ + // printPacket(p); // fprintf(stderr, "VD: got frame %d\n", p->frame); curcmd = shared->cmd; curcmdsn = shared->cmdsn; - if (p->cmdsn != shared->cmdsn || p->cmdsn != curcmdsn) + if (p->cmdsn != shared->cmdsn) { - /* - fprintf(stderr, "VD: frame not for current Cmd, discard it\n"); - + fprintf(stderr, "VD: frame not for current Cmd, discard it:p->cmdsn:%d,shared->cmdsn:%d\n", + p->cmdsn,shared->cmdsn); printPacket(p); */ - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); continue; } if (curcmd == CmdINIT) @@ -477,18 +467,24 @@ void VDprocess(int CTRpid) fprintf(stderr, "VD: unable to decode packet -- future and/or past frame no available.\n"); printPacket(p); - */ + */ if (curcmd == CmdSTEP && curcmdsn == shared->cmdsn) { /* Fprintf(stderr, "VD failed to decode f%d, USR1 to CTR for STEP\n", p->frame); */ - kill(getppid(), SIGUSR1); /* notify CTR anyway if STEP */ + char message[BUFSIZ]; + message [0]= DECODED; + int result = ACE_OS::write (vdsp[1],&message,BUFSIZ); + if (result == -1) + perror ("VD:Decode Notify"); + if (result == 0) + perror ("VD:Socket Closed"); } #ifdef STAT else if (shared->collectStat && curcmd == CmdPLAY) shared->stat.VDnoRef ++; #endif - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); continue; } } @@ -510,7 +506,7 @@ void VDprocess(int CTRpid) (shared->patternSize * shared->sendPatternGops); if (shared->sendPattern[i] == 0) { - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); #ifdef STAT if (shared->collectStat) shared->stat.VDagainstSendPattern ++; @@ -520,7 +516,7 @@ void VDprocess(int CTRpid) } #endif - if (VBcheckMsg() > 0) { /* a frame is to be dropped only if + if (vbuffer->VBcheckMsg() > 0) { /* a frame is to be dropped only if there are more frames in VB */ if (p->past >= 0) { /* 'B' */ if (p->display <= shared->nextFrame) { @@ -551,7 +547,7 @@ void VDprocess(int CTRpid) frameTooLate: if (shared->rtplay) /* too late, drop the frame */ { - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); /* Fprintf(stderr, "VD: frame %d too late, shared->nextFrame %d.\n", p->frame, shared->nextFrame); @@ -562,7 +558,7 @@ void VDprocess(int CTRpid) } else { /* live video */ if (p->display < shared->nextFrame) { - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); /* Fprintf(stderr, "VD live video frame %d too late, nextFrame=%d\n", p->frame, shared->nextFrame); @@ -581,7 +577,7 @@ void VDprocess(int CTRpid) fprintf(stderr, "VD: a frame too late and dropped when FF.\n"); printPacket(p); */ - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); continue; } } @@ -593,7 +589,7 @@ void VDprocess(int CTRpid) fprintf(stderr, "VD: a frame too late and dropped when FB.\n"); printPacket(p); */ - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); continue; } } @@ -749,10 +745,9 @@ void VDprocess(int CTRpid) } else /* decoding failed */ { - /* + fprintf(stderr, "VD error -- tried but failed decoding the packet.\n"); printPacket(p); - */ } end_decode_loop: @@ -760,27 +755,32 @@ void VDprocess(int CTRpid) /* signal CTR for singlular operation: STEP, POSITION, INIT */ if (single_tag && p->cmd != CmdREF && curcmdsn == shared->cmdsn) { - /* - Fprintf(stderr, "VD decoded f%d, USR1 to CTR\n", p->frame); - */ - kill(getppid(), SIGUSR1); + + fprintf(stderr, "VD decoded f%d, USR1 to CTR\n", p->frame); + char message[BUFSIZ]; + message[0]= DECODED; + int result = ACE_OS::write (vdsp[1],&message,BUFSIZ); + if (result == -1) + perror ("VD:Decode Notify"); + if (result == 0) + perror ("VD:Socket Closed"); } - VBreclaimMsg((char*)p); + vbuffer->VBreclaimMsg((char*)p); } } static void InitDitherEnv(void) { - lum_values = (int *) malloc(LUM_RANGE*sizeof(int)); - cr_values = (int *) malloc(CR_RANGE*sizeof(int)); - cb_values = (int *) malloc(CB_RANGE*sizeof(int)); + lum_values = (int *) ACE_OS::malloc(LUM_RANGE*sizeof(int)); + cr_values = (int *) ACE_OS::malloc(CR_RANGE*sizeof(int)); + cb_values = (int *) ACE_OS::malloc(CB_RANGE*sizeof(int)); init_tables(); while (!shared->pixelValid) { usleep(10000); } - memcpy(pixel, shared->pixel, 256); + ACE_OS::memcpy (pixel, shared->pixel, 256); switch (ditherType) { diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.cpp index b96cc8297b5..31666f570e2 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.cpp @@ -606,7 +606,7 @@ VidStream * NewVidStream(void) /* Allocate memory for new structure. */ - new_stream = (VidStream *) malloc(sizeof(VidStream)); + new_stream = (VidStream *) ACE_OS::malloc(sizeof(VidStream)); /* Initialize pointers to extension and user data. */ @@ -687,31 +687,31 @@ DestroyVidStream(VidStream *astream) int i; if (astream->ext_data != NULL) - free(astream->ext_data); + ACE_OS::free (astream->ext_data); if (astream->user_data != NULL) - free(astream->user_data); + ACE_OS::free (astream->user_data); if (astream->group.ext_data != NULL) - free(astream->group.ext_data); + ACE_OS::free (astream->group.ext_data); if (astream->group.user_data != NULL) - free(astream->group.user_data); + ACE_OS::free (astream->group.user_data); if (astream->picture.extra_info != NULL) - free(astream->picture.extra_info); + ACE_OS::free (astream->picture.extra_info); if (astream->picture.ext_data != NULL) - free(astream->picture.ext_data); + ACE_OS::free (astream->picture.ext_data); if (astream->picture.user_data != NULL) - free(astream->picture.user_data); + ACE_OS::free (astream->picture.user_data); if (astream->slice.extra_info != NULL) - free(astream->slice.extra_info); + ACE_OS::free (astream->slice.extra_info); if (astream->buf_start != NULL) - free(astream->buf_start); + ACE_OS::free (astream->buf_start); for (i = 0; i < RING_BUF_SIZE; i++) { if (astream->ring[i] != NULL) { @@ -720,7 +720,7 @@ DestroyVidStream(VidStream *astream) } } - free((char *) astream); + ACE_OS::free ((char *) astream); } @@ -751,10 +751,10 @@ NewPictImage(unsigned int width, unsigned int height) /* Allocate memory space for new structure. */ - new_pi = (PictImage *) malloc(sizeof(PictImage)); - new_pi->luminance = (unsigned char *) malloc(width * height); - new_pi->Cr = (unsigned char *) malloc(width * height / 4); - new_pi->Cb = (unsigned char *) malloc(width * height / 4); + new_pi = (PictImage *) ACE_OS::malloc(sizeof(PictImage)); + new_pi->luminance = (unsigned char *) ACE_OS::malloc(width * height); + new_pi->Cr = (unsigned char *) ACE_OS::malloc(width * height / 4); + new_pi->Cb = (unsigned char *) ACE_OS::malloc(width * height / 4); /* Reset locked flag. */ @@ -786,15 +786,15 @@ void DestroyPictImage(PictImage *apictimage) { if (apictimage->luminance != NULL) { - free(apictimage->luminance); + ACE_OS::free (apictimage->luminance); } if (apictimage->Cr != NULL) { - free(apictimage->Cr); + ACE_OS::free (apictimage->Cr); } if (apictimage->Cb != NULL) { - free(apictimage->Cb); + ACE_OS::free (apictimage->Cb); } - free(apictimage); + ACE_OS::free (apictimage); } @@ -832,8 +832,8 @@ int mpegVidRsrc(char *packet) i = 0; while (curVidStream->ring[i]->locked != 0) if (++i >= RING_BUF_SIZE) { - perror("VD fatal error. Ring buffer full."); - exit(1); + ACE_OS::perror ("VD fatal error. Ring buffer full."); + ACE_OS::exit (1); } curVidStream->current = curVidStream->ring[i]; curVidStream->current->sh = p->sh; @@ -863,7 +863,7 @@ int mpegVidRsrc(char *packet) if (data != SEQ_START_CODE) { fprintf(stderr, "VD error: This is not first packet of the an MPEG stream, data %u.", data); DestroyVidStream(curVidStream); - exit(1); + ACE_OS::exit (1); } } /* Get next 32 bits (size of start codes). */ @@ -1040,7 +1040,7 @@ ParseSeqHead(VidStream *vid_stream) /* If dither type is MBORDERED allocate ditherFlags. */ if (ditherType == MBORDERED_DITHER) { - ditherFlags = (char *) malloc(vid_stream->mb_width*vid_stream->mb_height); + ditherFlags = (char *) ACE_OS::malloc(vid_stream->mb_width*vid_stream->mb_height); } /* Initialize lmaxx, lmaxy, cmaxx, cmaxy. */ @@ -1120,7 +1120,7 @@ ParseSeqHead(VidStream *vid_stream) if (next_bits(32, EXT_START_CODE)) { flush_bits32; if (vid_stream->ext_data != NULL) { - free(vid_stream->ext_data); + ACE_OS::free (vid_stream->ext_data); vid_stream->ext_data = NULL; } vid_stream->ext_data = get_ext_data(); @@ -1130,7 +1130,7 @@ ParseSeqHead(VidStream *vid_stream) if (next_bits(32, USER_START_CODE)) { flush_bits32; if (vid_stream->user_data != NULL) { - free(vid_stream->user_data); + ACE_OS::free (vid_stream->user_data); vid_stream->user_data = NULL; } vid_stream->user_data = get_ext_data(); @@ -1230,7 +1230,7 @@ ParseGOP(VidStream *vid_stream) if (next_bits(32, EXT_START_CODE)) { flush_bits32; if (vid_stream->group.ext_data != NULL) { - free(vid_stream->group.ext_data); + ACE_OS::free (vid_stream->group.ext_data); vid_stream->group.ext_data = NULL; } vid_stream->group.ext_data = get_ext_data(); @@ -1240,7 +1240,7 @@ ParseGOP(VidStream *vid_stream) if (next_bits(32, USER_START_CODE)) { flush_bits32; if (vid_stream->group.user_data != NULL) { - free(vid_stream->group.user_data); + ACE_OS::free (vid_stream->group.user_data); vid_stream->group.user_data = NULL; } vid_stream->group.user_data = get_ext_data(); @@ -1341,7 +1341,7 @@ ParsePicture(VidStream *vid_stream,TimeStamp time_stamp) /* Get extra bit picture info. */ if (vid_stream->picture.extra_info != NULL) { - free(vid_stream->picture.extra_info); + ACE_OS::free (vid_stream->picture.extra_info); vid_stream->picture.extra_info = NULL; } vid_stream->picture.extra_info = get_extra_bit_info(); @@ -1355,7 +1355,7 @@ ParsePicture(VidStream *vid_stream,TimeStamp time_stamp) flush_bits32; if (vid_stream->picture.ext_data != NULL) { - free(vid_stream->picture.ext_data); + ACE_OS::free (vid_stream->picture.ext_data); vid_stream->picture.ext_data = NULL; } vid_stream->picture.ext_data = get_ext_data(); @@ -1366,7 +1366,7 @@ ParsePicture(VidStream *vid_stream,TimeStamp time_stamp) flush_bits32; if (vid_stream->picture.user_data != NULL) { - free(vid_stream->picture.user_data); + ACE_OS::free (vid_stream->picture.user_data); vid_stream->picture.user_data = NULL; } vid_stream->picture.user_data = get_ext_data(); @@ -1417,7 +1417,7 @@ ParseSlice(VidStream *vid_stream) /* Parse off extra bit slice info. */ if (vid_stream->slice.extra_info != NULL) { - free(vid_stream->slice.extra_info); + ACE_OS::free (vid_stream->slice.extra_info); vid_stream->slice.extra_info = NULL; } vid_stream->slice.extra_info = get_extra_bit_info(); @@ -3398,7 +3398,7 @@ ProcessSkippedBFrameMBlocks(VidStream *vid_stream) for (rr = 0; rr < 16; rr++) { - /* memcpy(dest, forw_lum+(rr<<4), 16); */ + /* ACE_OS::memcpy (dest, forw_lum+(rr<<4), 16); */ dest[0] = src[0]; dest[1] = src[1]; dest[2] = src[2]; @@ -3414,7 +3414,7 @@ ProcessSkippedBFrameMBlocks(VidStream *vid_stream) for (rr = 0; rr < 8; rr++) { /* - * memcpy(dest, forw_cr+(rr<<3), 8); memcpy(dest1, forw_cb+(rr<<3), + * ACE_OS::memcpy (dest, forw_cr+(rr<<3), 8); ACE_OS::memcpy (dest1, forw_cb+(rr<<3), * 8); */ @@ -3454,7 +3454,7 @@ ProcessSkippedBFrameMBlocks(VidStream *vid_stream) for (rr = 0; rr < 8; rr++) { /* - * memcpy(dest, back_cr+(rr<<3), 8); memcpy(dest1, back_cb+(rr<<3), + * ACE_OS::memcpy (dest, back_cr+(rr<<3), 8); ACE_OS::memcpy (dest1, back_cb+(rr<<3), * 8); */ diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.h index 9e51780de20..9e2a9336f14 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.h +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/video.h @@ -191,7 +191,7 @@ typedef struct macroblock { /* Block structure. */ -typedef struct block { +typedef struct { short int dct_recon[8][8]; /* Reconstructed dct coeff matrix. */ short int dct_dc_y_past; /* Past lum. dc dct coefficient. */ short int dct_dc_cr_past; /* Past cr dc dct coefficient. */ diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vp.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vp.cpp index ffdc3aac81b..e7e75e08e06 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vp.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_client/vp.cpp @@ -260,7 +260,7 @@ MakeWindow(void) else if (shmemFlag) { fprintf(stderr, "VP unexpected: display is NULL.\n"); - exit(1); + ACE_OS::exit (1); } if(shmemFlag) CompletionType = /*XShmGetEventBase(display) +*/ ShmCompletion; @@ -562,7 +562,7 @@ static void ClearWindow(void) size = win_width * win_height * 4; else size = win_width * win_height; - data = (char *)malloc(size); + data = (char *)ACE_OS::malloc(size); if (data != NULL) { memset(data, 0, size); ximage->data = data; @@ -570,7 +570,7 @@ static void ClearWindow(void) ximage->width, ximage->height); XFlush(display); ximage->data = NULL; - free(data); + ACE_OS::free (data); } } @@ -713,8 +713,8 @@ shmemerror: } if (ximage == NULL) { - perror("VP error: fails to XCreateImage ximage"); - exit(1); + ACE_OS::perror ("VP error: fails to XCreateImage ximage"); + ACE_OS::exit (1); } } #ifdef SH_MEM @@ -884,17 +884,17 @@ static void DisplayInitialization(void) void VPinitWindow(Widget shell, Window monitorWindow, int cmdSock) { cmdSocket = cmdSock; - lum_values = (int *) malloc(LUM_RANGE*sizeof(int)); - cr_values = (int *) malloc(CR_RANGE*sizeof(int)); - cb_values = (int *) malloc(CB_RANGE*sizeof(int)); + lum_values = (int *) ACE_OS::malloc(LUM_RANGE*sizeof(int)); + cr_values = (int *) ACE_OS::malloc(CR_RANGE*sizeof(int)); + cb_values = (int *) ACE_OS::malloc(CB_RANGE*sizeof(int)); DisplayInitialization(); - memcpy(shared->pixel, pixel, 256); + ACE_OS::memcpy (shared->pixel, pixel, 256); shared->pixelValid = 1; - free(lum_values); - free(cr_values); - free(cb_values); + ACE_OS::free (lum_values); + ACE_OS::free (cr_values); + ACE_OS::free (cb_values); #ifdef SH_MEM if (shmemFlag && display != NULL) { |