summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-20 03:14:52 +0000
committernaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-20 03:14:52 +0000
commit751191ae7ea9286654d8e1f6b671331c4d2ad031 (patch)
treedfddf15900d8970531d38644856a8acbf35274d2
parent8b81392e4fc98631158820965bc0dcc18252a4dd (diff)
downloadATCD-751191ae7ea9286654d8e1f6b671331c4d2ad031.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/TODO8
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h2
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.cpp113
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.h7
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp147
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.h44
6 files changed, 245 insertions, 76 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/TODO b/TAO/orbsvcs/tests/AVStreams/mpeg/source/TODO
index baf96d27125..d6af775f1ba 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/TODO
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/TODO
@@ -10,7 +10,7 @@ Things to do
- Remove kerberos warnings
-- Need to fix the following warnings:
++ Need to fix the following warnings:
"Video_Server.cpp", line 880: Warning: para hides Video_Server::para.
"Video_Server.cpp", line 906: Warning: para hides Video_Server::para.
@@ -19,18 +19,18 @@ Things to do
-- I think I've fixed this! Naga, can you confirm that it doesnt crash
anymore ?
-- Parent-Child relationship
++ Parent-Child relationship
-- parent goes back and listens for new connections
-- child handles this connection
- rttag is enabled with -r
does it work ?
-- rename Mpeg_Server to AV_Server
++ rename Mpeg_Server to AV_Server
- Make #define's into enums in common.h/globals.h
-- Change handle_input to handle_connection in
++ Change handle_input to handle_connection in
Mpeg_Svc_Handler
+ Video_Sig_Handler is in Mpeg_Server -- needs to be moved to Video_Server
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
index 3297b5809c4..c3904f8e115 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
@@ -222,7 +222,7 @@ class Video_Global
int fast_preGroup;
int fast_preHeader;
- enum video_states {INVALID=-1, VIDEO_PLAY=1,VIDEO_FAST};
+ enum video_states {INVALID=-1, VIDEO_PLAY=1,VIDEO_FAST_FORWARD=2,VIDEO_FAST_BACKWARD=3};
video_states state;
// Indicates the state of the Video Server process ie. play, fast forward play
};
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.cpp
index 1cc58e4a4f1..226672c60a1 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.cpp
@@ -34,7 +34,7 @@ PLAYpara Video_Server::para;
// %% maybe put this in some class?
// this sends one frame
int
-play_send (void)
+play_send (int debug)
{
// ACE_DEBUG((LM_DEBUG,"play_send: sending the frame \n"));
@@ -43,14 +43,19 @@ play_send (void)
int curHeader = Video_Timer_Global::timerHeader;
char * sp;
- if (VIDEO_SINGLETON::instance ()->preGroup != curGroup || curFrame != VIDEO_SINGLETON::instance ()->preFrame)
+ if (VIDEO_SINGLETON::instance ()->preGroup != curGroup ||
+ curFrame != VIDEO_SINGLETON::instance ()->preFrame)
{
int sendStatus = -1;
int frameStep = 1;
+ if (debug)
+ cerr << " curgroup = " << curGroup << endl ;
if (curGroup == 0)
{
+
int i = curFrame + 1;
- while (i < VIDEO_SINGLETON::instance ()->firstPatternSize && !VIDEO_SINGLETON::instance ()->firstSendPattern[i])
+ while (i < VIDEO_SINGLETON::instance ()->firstPatternSize &&
+ !VIDEO_SINGLETON::instance ()->firstSendPattern[i])
{
frameStep ++;
i++;
@@ -68,6 +73,9 @@ play_send (void)
}
if (curGroup == 0)
{
+ if (debug)
+ cerr << "first : " <<
+ VIDEO_SINGLETON::instance ()->firstSendPattern[curFrame] << endl;
if (VIDEO_SINGLETON::instance ()->firstSendPattern[curFrame])
sendStatus = 0;
else /* (!VIDEO_SINGLETON::instance ()->firstVIDEO_SINGLETON::instance ()->SendVIDEO_SINGLETON::Instance ()->Pattern[curFrame]) */
@@ -83,6 +91,8 @@ play_send (void)
}
else
sendStatus = -1;
+ if (debug)
+ cerr << "SendStatus = " << sendStatus << endl;
}
}
else if (sp[curFrame]) /* curGroup > 0 */
@@ -231,13 +241,15 @@ Video_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
switch (VIDEO_SINGLETON::instance ()->state)
{
// %% you probably dont need to use instance here
- case VIDEO_SINGLETON::instance ()->VIDEO_PLAY:
+ case Video_Global::VIDEO_PLAY:
play_send ();
break;
- // %% you probably dont need to use instance here
- // %% this should probably be split into VIDEO_FAST_{FORWARD,BACKWARD}
- case VIDEO_SINGLETON::instance ()->VIDEO_FAST:
- // this handles *both* the backward and forward play case!
+ case Video_Global::VIDEO_FAST_FORWARD:
+ // this handles the forward play case!
+ fast_play_send ();
+ break;
+ case Video_Global::VIDEO_FAST_BACKWARD:
+ // this handles the backward play case!
fast_play_send ();
break;
default:
@@ -273,11 +285,12 @@ Video_Data_Handler::handle_input (ACE_HANDLE handle)
switch (VIDEO_SINGLETON::instance ()->state)
{
- case VIDEO_SINGLETON::instance ()->VIDEO_PLAY:
+ case Video_Global::VIDEO_PLAY:
GetFeedBack ();
- play_send (); // simulating the for loop in vs.cpp
+ play_send (); // simulating the for loop in playvideo () in vs.cpp
break;
- case VIDEO_SINGLETON::instance ()->VIDEO_FAST:
+ case Video_Global::VIDEO_FAST_FORWARD:
+ case Video_Global::VIDEO_FAST_BACKWARD:
GetFeedBack ();
fast_play_send (); // simulating the for loop in fast_play
break;
@@ -312,7 +325,7 @@ Video_Control_Handler::handle_input (ACE_HANDLE handle)
return 1;
}
- if (VIDEO_SINGLETON::instance ()->state == VIDEO_SINGLETON::instance ()->VIDEO_PLAY)
+ if (VIDEO_SINGLETON::instance ()->state == Video_Global::VIDEO_PLAY)
{
fprintf (stderr,"Video_Control_Handler::handle_input () \n");
@@ -338,7 +351,7 @@ Video_Control_Handler::handle_input (ACE_HANDLE handle)
#endif
Video_Timer_Global::StopTimer();
- VIDEO_SINGLETON::instance ()->state = VIDEO_SINGLETON::instance ()->INVALID;
+ VIDEO_SINGLETON::instance ()->state = Video_Global::INVALID;
// We need to call the read_cmd of the Video_Server to simulate
// the control going to a switch..
Video_Server::read_cmd ();
@@ -376,7 +389,10 @@ Video_Control_Handler::handle_input (ACE_HANDLE handle)
}
play_send ();// simulating the for loop in vs.cpp
}
- else if (VIDEO_SINGLETON::instance ()->state == VIDEO_SINGLETON::instance ()->VIDEO_FAST)
+ else if ((VIDEO_SINGLETON::instance ()->state ==
+ Video_Global::VIDEO_FAST_FORWARD) ||
+ (VIDEO_SINGLETON::instance ()->state ==
+ Video_Global::VIDEO_FAST_BACKWARD ))
{
result = Video_Server::CmdRead((char *)&VIDEO_SINGLETON::instance ()->cmd, 1);
if (result != 0)
@@ -400,7 +416,7 @@ Video_Control_Handler::handle_input (ACE_HANDLE handle)
VIDEO_SINGLETON::instance ()->cmdsn = ntohl(VIDEO_SINGLETON::instance ()->cmdsn);
#endif
Video_Timer_Global::StopTimer();
- VIDEO_SINGLETON::instance ()->state = VIDEO_SINGLETON::instance ()->INVALID;
+ VIDEO_SINGLETON::instance ()->state = Video_Global::INVALID;
Video_Server::read_cmd ();
return 0;
}
@@ -431,6 +447,7 @@ Video_Server::Video_Server (int ctr_fd,
// send data packets and recieve feedback packets
// from the client
// the reactor_ also gets initialized here
+int
Video_Server::init (int ctr_fd,
int data_fd,
int rttag,
@@ -439,6 +456,7 @@ Video_Server::init (int ctr_fd,
this->reactor_ = ACE_Reactor::instance ();
// %% new the sig handler also here
+ // %% use ACE_NEW_RETURN
this->data_handler_ = new Video_Data_Handler (data_fd);
this->control_handler_ = new Video_Control_Handler (ctr_fd);
this->sig_handler_ = new Video_Sig_Handler ();
@@ -553,7 +571,7 @@ Video_Server::read_cmd (void)
}
fprintf(stderr, "VS got VIDEO_SINGLETON::instance ()->cmd %d\n", VIDEO_SINGLETON::instance ()->cmd);
- VIDEO_SINGLETON::instance ()->state = VIDEO_SINGLETON::instance ()->INVALID;
+ VIDEO_SINGLETON::instance ()->state = Video_Global::INVALID;
switch (VIDEO_SINGLETON::instance ()->cmd)
{
case CmdPOSITION:
@@ -568,18 +586,15 @@ Video_Server::read_cmd (void)
return result;
break;
case CmdFF:
- // %% maybe you dont need instance here ?
- VIDEO_SINGLETON::instance ()->state = VIDEO_SINGLETON::instance ()->VIDEO_FAST;
+ VIDEO_SINGLETON::instance ()->state = Video_Global::VIDEO_FAST_FORWARD;
Video_Server::fast_forward ();
break;
case CmdFB:
- // %% maybe you dont need instance here ?
- VIDEO_SINGLETON::instance ()->state = VIDEO_SINGLETON::instance ()->VIDEO_FAST;
+ VIDEO_SINGLETON::instance ()->state = Video_Global::VIDEO_FAST_BACKWARD;
Video_Server::fast_backward ();
break;
case CmdPLAY:
- // %% maybe you dont need instance here ?
- VIDEO_SINGLETON::instance ()->state = VIDEO_SINGLETON::instance ()->VIDEO_PLAY;
+ VIDEO_SINGLETON::instance ()->state = Video_Global::VIDEO_PLAY;
result = Video_Server::play ();
break;
case CmdCLOSE:
@@ -663,7 +678,7 @@ Video_Server::play (void)
Video_Timer_Global::StartTimer ();
// Sends the first frame of the video...
- result = play_send ();
+ result = play_send (1);
return 0;
}
@@ -877,24 +892,24 @@ int
Video_Server::position (void)
{
int result;
- POSITIONpara para;
+ POSITIONpara pos_para;
/*
fprintf(stderr, "POSITION . . .\n");
*/
- result = CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&pos_para, sizeof(pos_para));
if (result != 0)
return result;
if (VIDEO_SINGLETON::instance ()->live_source) return 0;
#ifdef NeedByteOrderConversion
- para.VIDEO_SINGLETON::instance ()->nextGroup = ntohl(para.VIDEO_SINGLETON::instance ()->nextGroup);
- para.sn = ntohl(para.sn);
+ pos_para.nextGroup = ntohl(pos_para.nextGroup);
+ pos_para.sn = ntohl(pos_para.sn);
#endif
- CheckGroupRange(para.nextGroup);
- VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
- result = SendPacket(VIDEO_SINGLETON::instance ()->numS>1 || para.nextGroup == 0, para.nextGroup, 0, 0);
+ CheckGroupRange(pos_para.nextGroup);
+ VIDEO_SINGLETON::instance ()->cmdsn = pos_para.sn;
+ result = SendPacket(VIDEO_SINGLETON::instance ()->numS>1 || pos_para.nextGroup == 0, pos_para.nextGroup, 0, 0);
Video_Server::read_cmd ();
return result;
}
@@ -903,33 +918,33 @@ int
Video_Server::step_video()
{
int group;
- STEPpara para;
+ STEPpara step_para;
int tag = 0;
int result;
- result = CmdRead((char *)&para, sizeof(para));
+ result = CmdRead((char *)&step_para, sizeof(step_para));
if (result != 0)
return result;
#ifdef NeedByteOrderConversion
- para.sn = ntohl(para.sn);
- para.VIDEO_SINGLETON::instance ()->nextFrame = ntohl(para.VIDEO_SINGLETON::instance ()->nextFrame);
+ step_para.sn = ntohl(step_para.sn);
+ step_para.VIDEO_SINGLETON::instance ()->nextFrame = ntohl(step_para.VIDEO_SINGLETON::instance ()->nextFrame);
#endif
- VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
+ VIDEO_SINGLETON::instance ()->cmdsn = step_para.sn;
if (!VIDEO_SINGLETON::instance ()->live_source) {
- if (para.nextFrame >= VIDEO_SINGLETON::instance ()->numF) /* send SEQ_END */
+ if (step_para.nextFrame >= VIDEO_SINGLETON::instance ()->numF) /* send SEQ_END */
{
tag = 1;
- para.nextFrame --;
+ step_para.nextFrame --;
}
/*
- fprintf(stderr, "STEP . . .frame-%d\n", para.VIDEO_SINGLETON::instance ()->nextFrame);
+ fprintf(stderr, "STEP . . .frame-%d\n", step_para.VIDEO_SINGLETON::instance ()->nextFrame);
*/
- CheckFrameRange(para.nextFrame);
- group = FrameToGroup(&para.nextFrame);
+ CheckFrameRange(step_para.nextFrame);
+ group = FrameToGroup(&step_para.nextFrame);
if (VIDEO_SINGLETON::instance ()->precmd != CmdSTEP && !tag ) {
- result = SendReferences(group, para.nextFrame);
+ result = SendReferences(group, step_para.nextFrame);
if (result < 0 )
return result;
}
@@ -937,10 +952,10 @@ Video_Server::step_video()
if (VIDEO_SINGLETON::instance ()->live_source) StartPlayLiveVideo();
if (VIDEO_SINGLETON::instance ()->live_source) {
- SendPicture(&para.nextFrame);
+ SendPicture(&step_para.nextFrame);
}
else if (VIDEO_SINGLETON::instance ()->video_format == VIDEO_MPEG1) {
- SendPacket(VIDEO_SINGLETON::instance ()->numS>1, group, tag ? VIDEO_SINGLETON::instance ()->numF : para.nextFrame, 0);
+ SendPacket(VIDEO_SINGLETON::instance ()->numS>1, group, tag ? VIDEO_SINGLETON::instance ()->numF : step_para.nextFrame, 0);
}
else {
fprintf(stderr, "VS: wierd1\n");
@@ -1031,3 +1046,15 @@ Video_Server::stat_sent(void)
Video_Server::read_cmd ();
return 0;
}
+
+// Destructor
+Video_Server::~Video_Server ()
+{
+ if (this->data_handler_ != 0)
+ delete this->data_handler_ ;
+ if (this->control_handler_ != 0)
+ delete this->control_handler_ ;
+ if (this->sig_handler_ != 0)
+ delete this->sig_handler_ ;
+}
+
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.h
index 9b2f4bf398c..7683b9e568e 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Video_Server.h
@@ -54,7 +54,7 @@ int send_to_network(int timeToUse);
void StartPlayLiveVideo (void);
void GetFeedBack (void);
int SendPicture (int *frame);
-int play_send (void);
+int play_send (int debug=0);
int fast_play_send (void);
// %% comments
@@ -135,6 +135,10 @@ public:
int rttag,
int max_pkt_size);
// constructor taking the handles
+
+ ~Video_Server ();
+ // Destructor
+
int init (int control_fd,
int data_fd,
int rttag,
@@ -177,7 +181,6 @@ private:
// signal handler for SIGALRM to periodically send the video frames
// to the client
-
};
#endif // MPEG_VIDEO_SERVER_H
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp
index a5a140253b5..00c089894e4 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.cpp
@@ -231,17 +231,125 @@ Mpeg_Svc_Handler::handle_timeout (const ACE_Time_Value &,
return 0;
}
-// Default Constructor
-Mpeg_Server::Mpeg_Server ()
+// AV_Server_Sig_Handler routines
+// Video_Sig_Handler methods
+// handles the timeout SIGALRM signal
+// %% this should *not* register itself,but it should
+// be registered by the Video_Server::run, alongwith
+// the remaining handlers.
+AV_Server_Sig_Handler::AV_Server_Sig_Handler (void)
+{
+}
+
+int
+AV_Server_Sig_Handler::register_handler (void)
+{
+ // Assign the Sig_Handler a dummy I/O descriptor. Note that even
+ // though we open this file "Write Only" we still need to use the
+ // ACE_Event_Handler::NULL_MASK when registering this with the
+ // ACE_Reactor (see below).
+ this->handle_ = ACE_OS::open (ACE_DEV_NULL, O_WRONLY);
+ ACE_ASSERT (this->handle_ != -1);
+
+ // Register signal handler object. Note that NULL_MASK is used to
+ // keep the ACE_Reactor from calling us back on the "/dev/null"
+ // descriptor.
+ if (ACE_Reactor::instance ()->register_handler
+ (this, ACE_Event_Handler::NULL_MASK) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "register_handler"),
+ -1);
+
+ // Create a sigset_t corresponding to the signals we want to catch.
+ ACE_Sig_Set sig_set;
+
+ // sig_set.sig_add (SIGINT);
+ // sig_set.sig_add (SIGQUIT);
+ sig_set.sig_add (SIGCHLD);
+ sig_set.sig_add (SIGBUS);
+ sig_set.sig_add (SIGINT);
+ sig_set.sig_add (SIGTERM);
+
+ // Register the signal handler object to catch the signals.
+ if (ACE_Reactor::instance ()->register_handler (sig_set,
+ this) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "register_handler"),
+ -1);
+
+ return 0;
+}
+// Called by the ACE_Reactor to extract the fd.
+
+ACE_HANDLE
+AV_Server_Sig_Handler::get_handle (void) const
+{
+ return this->handle_;
+}
+
+int
+AV_Server_Sig_Handler::handle_input (ACE_HANDLE)
{
+ ACE_DEBUG ((LM_DEBUG, "(%t) handling asynchonrous input...\n"));
+ return 0;
+}
+int
+AV_Server_Sig_Handler::shutdown (ACE_HANDLE, ACE_Reactor_Mask)
+{
+ ACE_DEBUG ((LM_DEBUG, "(%t) closing down Sig_Handler...\n"));
+ return 0;
+}
+
+// This method handles all the signals that are being caught by this
+// object. In our simple example, we are simply catching SIGALRM,
+// SIGINT, and SIGQUIT. Anything else is logged and ignored.
+//
+// There are several advantages to using this approach. First,
+// the behavior triggered by the signal is handled in the main event
+// loop, rather than in the signal handler. Second, the ACE_Reactor's
+// signal handling mechanism eliminates the need to use global signal
+// handler functions and data.
+
+int
+AV_Server_Sig_Handler::handle_signal (int signum, siginfo_t *, ucontext_t *)
+{
+ // ACE_DEBUG ((LM_DEBUG, "(%t) received signal %S\n", signum));
+
+ switch (signum)
+ {
+ case SIGCHLD:
+ // Handle the timeout
+ AV_Server::clear_child (SIGCHLD);
+ break;
+ case SIGBUS:
+ case SIGINT:
+ case SIGTERM:
+ AV_Server::int_handler (signum);
+ ACE_DEBUG ((LM_DEBUG,
+ "(%t) %S: not handled, returning to program\n",
+ signum));
+ break;
+ }
+ return 0;
+}
+
+
+// AV_Server routines
+
+// Default Constructor
+AV_Server::AV_Server ()
+{
+ this->sh_ = new AV_Server_Sig_Handler ;
}
// Cluttering the code with various signal handlers here.
-// ctrl-c handler
+// ctrl-c handler,Bus error handler,interrupt sig handler
void
-Mpeg_Server::int_handler (int sig)
+AV_Server::int_handler (int sig)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) killed by signal %d",
@@ -250,7 +358,7 @@ Mpeg_Server::int_handler (int sig)
}
void
-Mpeg_Server::on_exit_routine (void)
+AV_Server::on_exit_routine (void)
{
// %% what does the following do
if (Mpeg_Global::parentpid != ACE_OS::getpid ())
@@ -268,11 +376,13 @@ Mpeg_Server::on_exit_routine (void)
// SIGCHLD handler
void
-Mpeg_Server::clear_child (int sig)
+AV_Server::clear_child (int sig)
{
int pid;
int status;
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) Reaping the children"));
// reap the children
while ((pid = ACE_OS::waitpid (-1,
&status,
@@ -316,7 +426,7 @@ Mpeg_Server::clear_child (int sig)
// Parses the command line arguments
int
-Mpeg_Server::parse_args (int argc,
+AV_Server::parse_args (int argc,
char **argv)
{
ACE_Get_Opt get_opts (argc, argv, "rd:s:vamh");
@@ -358,7 +468,7 @@ Mpeg_Server::parse_args (int argc,
// sets the handlers for the various signals
int
-Mpeg_Server::set_signals ()
+AV_Server::set_signals ()
{
setsignal (SIGCHLD, clear_child);
setsignal (SIGPIPE, SIG_IGN);
@@ -372,7 +482,7 @@ Mpeg_Server::set_signals ()
// Initializes the mpeg server
int
-Mpeg_Server::init (int argc,
+AV_Server::init (int argc,
char **argv)
{
int result;
@@ -381,7 +491,14 @@ Mpeg_Server::init (int argc,
if (result < 0)
return result;
- this->set_signals ();
+ // This code has become obsolete with the new AV_Server_Sig_Handler class..
+ // this->set_signals ();
+ // Register the various signal handlers with the reactor.
+ result = this->sh_->register_handler ();
+
+ if (result < 0)
+ return result;
+
Mpeg_Global::parentpid = ACE_OS::getpid ();
::atexit (on_exit_routine);
@@ -425,7 +542,7 @@ Mpeg_Server::init (int argc,
// Runs the mpeg server
int
-Mpeg_Server::run ()
+AV_Server::run ()
{
int result;
this->server_control_addr_.set (VCR_TCP_PORT);
@@ -437,20 +554,22 @@ Mpeg_Server::run ()
ACE_Reactor::instance ()->run_event_loop ();
ACE_DEBUG ((LM_DEBUG,
- "(%P)Mpeg_Server::run () "
+ "(%P)AV_Server::run () "
"came out of the (acceptor) "
"event loop %p\n",
"run_event_loop\n"));
}
-Mpeg_Server::~Mpeg_Server (void)
+AV_Server::~AV_Server (void)
{
+ if (this->sh_ != 0)
+ delete this->sh_;
}
int
main (int argc, char **argv)
{
- Mpeg_Server vcr_server;
+ AV_Server vcr_server;
// parses the arguments, and initializes the server
if (vcr_server.init (argc, argv) < 0)
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.h
index 43467f427cf..5b3b010b4da 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/server/server.h
@@ -93,19 +93,44 @@ private:
Video_Server vs_;
};
-class Mpeg_Server
+class AV_Server_Sig_Handler
+ : public virtual ACE_Event_Handler
+{
+public:
+ AV_Server_Sig_Handler (void);
+
+ virtual ACE_HANDLE get_handle (void) const;
+
+ int register_handler (void);
+ // this will register this sig_handler
+ // with the reactor
+
+ virtual int shutdown (ACE_HANDLE,
+ ACE_Reactor_Mask);
+
+ virtual int handle_input (ACE_HANDLE);
+
+ virtual int handle_signal (ACE_HANDLE signum,
+ siginfo_t * = 0,
+ ucontext_t* = 0);
+private:
+ ACE_HANDLE handle_;
+};
+
+
+class AV_Server
{
// =TITLE
// Defines a class that abstracts the functionality of a mpeg
// video and audio server.
public:
- Mpeg_Server ();
+ AV_Server ();
int init (int argc,
char **argv);
- // Initialize the mpeg_server
+ // Initialize the AV_Server
int run ();
- // Run the Mpeg_Server
+ // Run the AV_Server
static void int_handler (int sig);
static void on_exit_routine (void);
@@ -114,19 +139,14 @@ public:
// we need them to be static
static void init_static (void);
- ~Mpeg_Server ();
+ ~AV_Server ();
private:
Mpeg_Acceptor acceptor_;
// the acceptor
- // %% why is this here ? this should be in video_server
- // if you are newing the other handlers, you should new
- // this one also, and destroy them in the destructor
- // for video_server
- // Video_Sig_Handler vh_;
- // signal handler for SIGALRM to periodically send the video frames
- // to the client
+ AV_Server_Sig_Handler *sh_;
+ // Signal handler for SIGCHLD,SIGINT,SIGTERM,SIGBUS
ACE_INET_Addr server_control_addr_;
// Control (TCP) Address of this server.