diff options
Diffstat (limited to 'TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared')
16 files changed, 0 insertions, 4447 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Audio_Control.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Audio_Control.idl deleted file mode 100644 index 0719e784c3b..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Audio_Control.idl +++ /dev/null @@ -1,78 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -interface Audio_Control -{ - typedef sequence<char> my_seq_char; - - struct AudioParameter - { - long encodeType; - long channels; - long samplesPerSecond; - long bytesPerSample; - }; - - - /* CmdINITaudio parameter of fixed structure of 3 integers and a AudioPara, - replys with CmdINITaudio followed by reply or CmdFAIL followed by a string */ - struct INITaudioPara - { - long sn; - long version; - AudioParameter para; - long nameLength; - my_seq_char audiofile; - /* char audioFile[] */ - }; - - struct INITaudioReply - { - long live; - long format; - AudioParameter para; - long totalSamples; - }; - - - /* CmdPLAY parameter */ - struct PLAYPara - { - long sn; - long nextSample; - long samplesPerSecond; /* audio playback speed */ - long samplesPerPacket; /* Number of samples in a packet */ - long ABsamples; /* size of client VB buffer in samples */ - long spslimit; /* QoS parameter: sps supported by the audio channel */ - }; - - /* STOP followed only by SN */ - - /* CmdSPEED parameter */ - struct SPEEDPara - { - long sn; - long samplesPerSecond; - long samplesPerPacket; /* Number of samples in a packet */ - long spslimit; - }; - - boolean init_audio (in INITaudioPara para, - out INITaudioReply reply_para); - boolean play (in PLAYPara para, out long ats); - - boolean speed (in SPEEDPara para); - - boolean stop (in long cmdsn); - - oneway void close (); - - boolean set_peer (inout string peer); - // Initializes the server to communicate to the <peer>, which can be - // "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or - // "128.252.166.57:1234"). If there is no ':' in the <address> it - // is assumed to be a port number, with the IP address being - // INADDR_ANY. - // Server returns it's UDP data port number. -}; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/MMDevice_Exporter.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/MMDevice_Exporter.idl deleted file mode 100644 index 2cee7d3f2d5..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/MMDevice_Exporter.idl +++ /dev/null @@ -1,8 +0,0 @@ -// $Id$ -#include "CosPropertyService.idl" - -interface MMDevice_Exporter : CosPropertyService::PropertySet -{ - Object get_audio_mmdevice (); - Object get_video_mmdevice (); -}; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile deleted file mode 100644 index 2fecb4b7d35..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile +++ /dev/null @@ -1,181 +0,0 @@ -#---------------------------------------------------------------------------- -# -# $Id$ -# -#---------------------------------------------------------------------------- - -MAKEFILE = Makefile -LIBNAME = libmpeg_shared -LIB2 = $(LIBNAME).a -SHLIB2 = $(LIBNAME).$(SOEXT) - -ifndef TAO_ROOT - TAO_ROOT = $(ACE_ROOT)/TAO -endif - -#TAO_IDLFLAGS = -Wb,export_macro=TAO_ORBSVCS_Export -Wb,export_include=orbsvcs_export.h - -IDL_FILES = Video_ControlS Video_ControlC Audio_ControlS Audio_ControlC ReceiverS ReceiverC MMDevice_ExporterC MMDevice_ExporterS - -# On non-Windows environment, we should at least define -# the export_include IDL flag. -override TAO_IDLFLAGS += \ - -I$(TAO_ROOT)/orbsvcs/orbsvcs - -FILES = $(IDL_FILES) - -DEFS = $(addsuffix .h,$(FILES)) -LSRC = $(addsuffix .cpp,$(FILES)) - -FILES += com fileio filters routine sendpt - -LDFLAGS += -L$(TAO_ROOT)/tao -CPPFLAGS += -I$(TAO_ROOT) -I$(TAO_ROOT)/orbsvcs $(TSS_ORB_FLAG) -I$(TAO_ROOT)/orbsvcs/orbsvcs - -MPEG_ROOT = $(TAO_ROOT)/orbsvcs/tests/AVStreams/mpeg/source -CPPFLAGS += -I$(MPEG_ROOT) - -LIBS += -lTAO -lACE - -#### If the TAO orbsvcs library wasn't built with sufficient components, -#### don't try to build here. -TAO_ORBSVCS := $(shell sh $(ACE_ROOT)/bin/ace_components --orbsvcs) -ifeq (AV,$(findstring AV,$(TAO_ORBSVCS))) - LIB = $(LIB2) - SHLIB = $(SHLIB2) -else - override INSTALL = -endif # ! AV - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(ACE_ROOT)/include/makeinclude/macros.GNU -include $(TAO_ROOT)/rules.tao.GNU -include $(ACE_ROOT)/include/makeinclude/rules.common.GNU -include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU -include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU -include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU -include $(ACE_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets (and local hacks) -#---------------------------------------------------------------------------- - -##LDFLAGS += -L$(TAO_ROOT)/tao -CPPFLAGS += -I$(TAO_ROOT) -I$(TAO_ROOT)/orbsvcs $(TSS_ORB_FLAG) -CPPFLAGS += -DSH_MEM -DNDEBUG - -.PRECIOUS: Video_ControlS.cpp Video_ControlC.cpp Audio_ControlS.cpp Audio_ControlC.cpp - -idl_stubs: $(addsuffix .h, $(IDL_FILES)) - -realclean: clean - -$(RM) $(addsuffix .h, $(IDL_FILES)) $(addsuffix .i, $(IDL_FILES)) $(addsuffix .cpp, $(IDL_FILES)) - -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -.obj/com.o .obj/com.so .shobj/com.o .shobj/com.so: com.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-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 fileio.h \ - routine.h com.h -.obj/fileio.o .obj/fileio.so .shobj/fileio.o .shobj/fileio.so: fileio.cpp routine.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-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 fileio.h -.obj/filters.o .obj/filters.so .shobj/filters.o .shobj/filters.so: filters.cpp filters.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/routine.o .obj/routine.so .shobj/routine.o .shobj/routine.so: routine.cpp routine.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-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/sendpt.o .obj/sendpt.so .shobj/sendpt.o .shobj/sendpt.so: sendpt.cpp sendpt.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 - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile.am b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile.am deleted file mode 100644 index 77a59176d2b..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Makefile.am +++ /dev/null @@ -1,85 +0,0 @@ -##--------------------------------------------------------------------------- -## $Id$ -## -## Makefile for TAO's AVStreams Tests -- -## mpeg/source/mpeg_shared directory -## -##--------------------------------------------------------------------------- - -## -## Process this file with automake to create Makefile.in -## - -## The number in AUTOMAKE_OPTIONS is the minimum required version automake -## needed to process this file. -AUTOMAKE_OPTIONS = 1.4 - -INCLUDES = -I$(top_builddir) -I$(top_srcdir) - -noinst_LTLIBRARIES = libmpeg_shared - -libmpeg_shared_LDADD = \ - $(top_builddir)/ace/libACE.la $(top_builddir)/TAO/tao/libTAO.la - -libmpeg_shared_SOURCES = \ - com.cpp \ - fileio.cpp \ - filters.cpp \ - routine.cpp \ - sendpt.cpp \ - Video_ControlS.cpp \ - Video_ControlC.cpp \ - Audio_ControlS.cpp \ - Audio_ControlC.cpp \ - ReceiverS.cpp \ - ReceiverC.cpp \ - MMDevice_ExporterC.cpp \ - MMDevice_ExporterS.cpp - -noinst_HEADERS = \ - com.h \ - fileio.h \ - filters.h \ - routine.h \ - sendpt.h \ - Video_ControlS.h \ - Video_ControlC.h \ - Audio_ControlS.h \ - Audio_ControlC.h \ - ReceiverS.h \ - ReceiverC.h \ - MMDevice_ExporterC.h \ - MMDevice_ExporterS.h - -IDL_SOURCES = \ - Audio_Control.idl \ - MMDevice_Exporter.idl \ - Receiver.idl \ - Video_Control.idl - -BUILT_SOURCES = \ - Video_ControlS.cpp \ - Video_ControlS.h \ - Video_ControlC.cpp \ - Video_ControlC.h \ - Audio_ControlS.cpp \ - Audio_ControlS.h \ - Audio_ControlC.cpp \ - Audio_ControlC.h \ - ReceiverS.cpp \ - ReceiverS.h \ - ReceiverC.cpp \ - ReceiverC.h \ - MMDevice_ExporterC.cpp \ - MMDevice_ExporterC.h \ - MMDevice_ExporterS.cpp \ - MMDevice_ExporterS.h - -EXTRA_DIST = $(IDL_SOURCES) - -## Clean up some additional files/directories possibly created during -## the configure script tests. -clean-local: - -rm -f *.bak *.rpo *.sym lib*.*_pure_* Makefile.old core - -rm -rf ptrepository Templates.DB gcctemp.c gcctemp so_locations - diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl deleted file mode 100644 index 19589c057b2..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Receiver.idl +++ /dev/null @@ -1,7 +0,0 @@ -/* _*_C++_*_ */ - -// $Id$ -interface Receiver -{ - void push_mmdevice (in Object audio_mmdevice,in string audio_file,in Object video_mmdevice,in string video_file); -}; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Video_Control.idl b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Video_Control.idl deleted file mode 100644 index 2c9a5ade7f2..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/Video_Control.idl +++ /dev/null @@ -1,112 +0,0 @@ -// -*- C++ -*- - -// $Id$ - -interface Video_Control -{ - - typedef sequence <char> my_seq_char; - const long VIDEO_PATTERN_SIZE = 100; - struct INITvideoPara - { - long sn; - long version; - my_seq_char videofile; - }; - - struct INITvideoReply - { - long live; - long format; - - long totalHeaders; - long totalFrames; - long totalGroups; - long horizontalSize; - long verticalSize; - long pelAspectRatio; - long pictureRate1000; - long vbvBufferSize; - long sizeIFrame; - long sizePFrame; - long sizeBFrame; - long sizeSystemHeader; - long sizeGop; - long averageFrameSize; - long firstGopFrames; - my_seq_char pattern; - }; - - /* CmdPOSITION, CmdPOSITIONrelease: followed by following parameter */ - struct POSITIONpara - { - long sn; - long nextGroup; - }; - - /* CmdSTEP: followed by following parameter */ - struct STEPpara - { - long sn; - long nextFrame; - }; - - /* CmdFF, CmdFB: followed by following parameter */ - struct FFpara - { - long sn; - long nextGroup; - long usecPerFrame; - long framesPerSecond; - long VStimeAdvance; - }; - - typedef FFpara FBpara; - - /*CmdPLAY: followed by following parameter */ - struct PLAYpara - { - long sn; - long collectStat; - long nextFrame; - long usecPerFrame; - long framesPerSecond; - long frameRateLimit1000; - long VStimeAdvance; - long sendPatternGops; - my_seq_char sendPattern; - }; - - /* CmdSPEED: parameter */ - struct SPEEDpara - { - long sn; - long usecPerFrame; - long framesPerSecond; - long frameRateLimit1000; - long sendPatternGops; - my_seq_char sendPattern; - }; - - - boolean init_video (in INITvideoPara para, - out INITvideoReply reply_para); - boolean stat_stream (out char ch, out long size); - oneway void close (); - boolean stat_sent (); - boolean fast_forward (in FFpara para); - boolean fast_backward (in FFpara para); - boolean step (in STEPpara para); - boolean play (in PLAYpara para, out long vts); - boolean position (in POSITIONpara para); - boolean speed (in SPEEDpara para); - boolean stop (in long cmdsn); - - boolean set_peer (inout string peer); - // Initializes the server to communicate to the <peer>, which can be - // "ip-number:port-number" (e.g., "tango.cs.wustl.edu:1234" or - // "128.252.166.57:1234"). If there is no ':' in the <address> it - // is assumed to be a port number, with the IP address being - // INADDR_ANY. - // Server returns it's UDP data port number. -}; diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.cpp deleted file mode 100644 index df6bb1229a1..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.cpp +++ /dev/null @@ -1,2136 +0,0 @@ -/* $Id$ */ - -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ - -// #include <stdio.h> -// #include <errno.h> -// #include <stdlib.h> -// #include <sys/types.h> -// #include <unistd.h> -// #include <string.h> -// #include <netdb.h> -// #include <ctype.h> -// #include <sys/select.h> -// #include <sys/socket.h> -// #include <netinet/in.h> -// #include <netinet/tcp.h> -// #include <arpa/inet.h> -// #include <sys/un.h> -// #include <time.h> -// #include <sys/time.h> -#include "include/common.h" -#include "fileio.h" -#include "routine.h" -#include "com.h" -#include "ace/OS.h" - -#ifdef NATIVE_ATM -#include "atmcom.h" -#endif - -ACE_RCSID(mpeg_shared, com, "$Id$") - -#define CONN_INET 1 -#define CONN_UNIX 2 -#define CONN_ATM 3 - -#define SERVER_FDTABLE_SIZE 50 -#define CLIENT_FDTABLE_SIZE 10 - -#define STATE_PENDING 1 -#define STATE_CONTROL 2 -#define STATE_DATA 3 -#define STATE_SINGLE 4 - -static int inet_port; -static char * unix_port, * atm_port; - -static struct FdTable -{ - int fd; /* -1 -- free item, >=0 -- fd value */ - int type; - unsigned stime; /* setup time, in seconds */ - int state; -} * fdTable = NULL; -static int size = 0; - -int ComInitClient(int pinet_port, char * punix_port, char * patm_port) -{ - int i; - - inet_port = pinet_port; - unix_port = punix_port; - atm_port = patm_port; - if (size) { - fprintf(stderr, - "Error ComInitClient: pid %d already done ComInitClient/Server\n", - ACE_OS::getpid ()); - return -1; - } - size = CLIENT_FDTABLE_SIZE; - fdTable = (struct FdTable *)ACE_OS::malloc(size * sizeof(*fdTable)); - if (fdTable == NULL) { - fprintf(stderr, - "Error ComInitClient: pid %d failed to allocated fdTable space:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - for (i = 0; i < size; i ++) { - fdTable[i].fd = -1; - } -#ifdef NATIVE_ATM - return ATMinitClient(atm_port); -#else - return 0; -#endif -} - -void ComCloseClient(void) -{ - int i; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd >= 0) ComCloseConn(fdTable[i].fd); - } -#ifdef NATIVE_ATM - ATMcloseClient(); -#endif - return; -} - -int ComCloseFd(int fd) -{ - int i; - if (!size) { - fprintf(stderr, - "Error ComCloseFd: pid %d not done ComInitClient/Server yet.\n", - ACE_OS::getpid ()); - return -1; - } - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == fd) break; - } - if (i < size) { - fdTable[i].fd = -1; - if (fdTable[i].type == CONN_ATM) { -#ifdef NATIVE_ATM - return ATMcloseFd(fd); -#else - fprintf(stderr, - "Error ComCloseFd: pid %d CONN_ATM not supported.\n", - ACE_OS::getpid ()); - return -1; -#endif - } - else { - ACE_OS::close (fd); - } - return 0; - } - else { - fprintf(stderr, - "Error ComCloseFd: pid %d can't find fd %d in table\n", - ACE_OS::getpid (), fd); - return -1; - } -} - -int ComCloseConn(int fd) -{ - int i; - if (!size) { - fprintf(stderr, - "Error ComCloseConn: pid %d not done ComInitClient/Server yet.\n", - ACE_OS::getpid ()); - return -1; - } - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == fd) break; - } - if (i < size) { - fdTable[i].fd = -1; - if (fdTable[i].type == CONN_ATM) { -#ifdef NATIVE_ATM - return ATMcloseConn(fd); -#else - fprintf(stderr, - "Error ComCloseConn: pid %d CONN_ATM not supported.\n", - ACE_OS::getpid ()); - return -1; -#endif - } - else { - ACE_OS::close (fd); - } - return 0; - } - else { - fprintf(stderr, - "Error ComCloseConn: pid %d can't find fd %d in table\n", - ACE_OS::getpid (), fd); - return -1; - } -} - -int ComOpenConnPair(char * address, int *ctr_fd, int *data_fd, int *max_pkt_size) -{ - - // This is right now called only by the audio client. - // The protocol is slightly modified as after connecting we need to - // inform that we are a audio client so that it can fork a process. - int i; - int cfd, dfd, csocktype, dsocktype; - int conn_tag = !(*max_pkt_size); - struct sockaddr_in addressIn; - struct sockaddr_un addressUn; - - if (!size) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d not done ComInitClient/Server yet.\n", - ACE_OS::getpid ()); - return -1; - } - - cfd = 0; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) cfd ++; - } - if (cfd < 2) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d no faTable entry for the pair", - ACE_OS::getpid ()); - return -1; - } - - /* tell the type of connections to establish: - If the server is on the same host, then UNIX socket is used */ - if (address[0] == 0) { - csocktype = CONN_UNIX; - dsocktype = CONN_UNIX; - } - else if (!strncasecmp(address, "atm:", 4)) { - address += 4; - csocktype = CONN_ATM; - dsocktype = CONN_ATM; - } - else if (!strncasecmp(address, "datm:", 5)) { - address += 5; - csocktype = CONN_INET; - dsocktype = CONN_ATM; - } - else { - csocktype = CONN_INET; - dsocktype = CONN_INET; - } - if (csocktype == CONN_INET || dsocktype == CONN_INET) { - struct hostent *hp; - char hostname[100]; - addressIn.sin_family = AF_INET; - if (!strncasecmp(address, "inet:", 5)) { - address += 5; - } - if (isascii(address[0]) && isdigit(address[0])) - addressIn.sin_addr.s_addr = inet_addr(address); - else { - if ((hp = gethostbyname(address)) == NULL) { /* No such host! */ - fprintf(stderr, - "Error ComOpenConnPair: pid %d host %s can't be found:", - getpid(), address); - perror(""); - return -1; - } - if (hp->h_addrtype != AF_INET) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d host %s is not of INET type address.\n", - getpid(), address); - return -1; - } - ACE_OS::memcpy ((char *)&addressIn.sin_addr.s_addr, (char *)hp->h_addr, - sizeof(addressIn.sin_addr.s_addr)); - /* - bcopy((char *)hp->h_addr, (char *)&addressIn.sin_addr.s_addr, - sizeof(addressIn.sin_addr.s_addr)); - */ - } - if (get_hostname(hostname, 100)) { - fprintf(stderr, "Error ComOpenConnPair: pid %d failed to get_hostname:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if ((hp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to its own IP address:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (hp->h_addrtype != AF_INET) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d own address is not INET type", - ACE_OS::getpid ()); - return -1; - } - - if (!memcmp((char *)hp->h_addr, (char *)&addressIn.sin_addr.s_addr, - sizeof(addressIn.sin_addr.s_addr))) { - if (csocktype == CONN_INET) csocktype = CONN_UNIX; - if (dsocktype == CONN_INET) dsocktype = CONN_UNIX; - } - } - - /* build appropriate type of Connections to Server */ - if (csocktype == CONN_UNIX && dsocktype == CONN_UNIX) { - /* build UNIX connection to server */ - addressUn.sun_family = AF_UNIX; - strncpy(addressUn.sun_path, unix_port, - sizeof(struct sockaddr_un) - sizeof(short)); - cfd = socket(AF_UNIX, SOCK_STREAM, 0); - if (cfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open UNIX cfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - usleep(10000); /* this is for waiting for the uncaught signal mentioned - below */ - if (connect(cfd, (struct sockaddr *)&addressUn, sizeof(addressUn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn UNIX cfd to server:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - i = -3; /* I don't understand why when connect() returns EINTR, the connection - is still built, and the other end can still get what written at - this end, 'i = -3' is a garbage to be written. */ - ACE_OS::write (cfd, &i, 4); - ACE_OS::close (cfd); - return -1; - } - if (time_write_int(cfd, -1) == -1 || time_read_int(cfd, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write -1 to UNIX cfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (cfd); - return -1; - } - - dfd = socket(AF_UNIX, SOCK_STREAM, 0); - if (dfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open UNIX dfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (cfd); - return -1; - } - usleep(10000); - if (connect(dfd, (struct sockaddr *)&addressUn, sizeof(addressUn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn UNIX dfd to server:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - i = -3; - ACE_OS::write (dfd, &i, 4); - ACE_OS::close (cfd); - ACE_OS::close (dfd); - return -1; - } - if (time_write_int(dfd, i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write (cfd) to UNIX dfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (cfd); - ACE_OS::close (dfd); - return -1; - } - *max_pkt_size = 0; - } - else if (csocktype == CONN_INET && dsocktype == CONN_INET) { - /* build TCP connection to server */ - addressIn.sin_port = htons(inet_port); - cfd = socket(AF_INET, SOCK_STREAM, 0); - if (cfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open TCP cfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - usleep(10000); - if (connect(cfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn TCP cfd to server:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - i = -3; - ACE_OS::write (cfd, &i, 4); - ACE_OS::close (cfd); - return -1; - } - if (conn_tag) { /* create a second connection with server */ - if (time_write_int(cfd, -1) == -1 || time_read_int(cfd, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write -1 to TCP cfd:", - getpid()); - perror(""); - close(cfd); - return -1; - } - dfd = socket(AF_INET, SOCK_STREAM, 0); - if (dfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open TCP dfd:", - getpid()); - perror(""); - close(cfd); - return -1; - } - usleep(10000); - if (connect(dfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn TCP dfd to server:", - getpid()); - perror(""); - i = -3; - write(dfd, &i, 4); - close(cfd); - close(dfd); - return -1; - } - if (time_write_int(dfd, i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write (cfd) to TCP dfd:", - getpid()); - perror(""); - close(cfd); - close(dfd); - return -1; - } - *max_pkt_size = 0; - } - else { /* create a UDP socket for data */ - // Write a byte saying that we are a audio client. - - if (time_write_int(cfd,CmdINITaudio) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write -2 to TCP cfd:", - getpid()); - perror(""); - close(cfd); - close(dfd); - return -1; - } - - dfd = socket(AF_INET, SOCK_DGRAM, 0); - if (dfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open UDP dfd:", - getpid()); - perror(""); - close(cfd); - return -1; - } - memset((char *)&addressIn, 0, sizeof(addressIn)); - - i = sizeof(addressIn); - if (getsockname(cfd, (struct sockaddr *)&addressIn, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to getsocketname on TCP cfd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - - addressIn.sin_family = AF_INET; - addressIn.sin_port = 0; - if (bind(dfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to bind UDP dfd:", - getpid()); - perror(""); - close(cfd); - close(dfd); - return -1; - } - if (time_write_int(cfd, -2) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write -2 to TCP cfd:", - getpid()); - perror(""); - close(cfd); - close(dfd); - return -1; - } - - i = sizeof(addressIn); - if (getsockname(dfd, (struct sockaddr *)&addressIn, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to getsocketname on UDP fd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - if (time_write_bytes(cfd, (char *)&addressIn.sin_port, sizeof(short)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write (port) to TCP cfd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - - fprintf(stderr, "ComOpenConnPair local UDP socket: addr - %s,%d, port - %u.\n", - inet_ntoa(addressIn.sin_addr), addressIn.sin_addr.s_addr,ntohs(addressIn.sin_port)); - - - fprintf(stderr, "ComOpenConnPair UDP port %d (should be > 0)\n", - ntohs(addressIn.sin_port)); - - - i = sizeof(addressIn); - if (getsockname(cfd, (struct sockaddr *)&addressIn, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to getsocketname on TCP cfd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - - if (time_write_bytes(cfd, (char *)&addressIn.sin_addr.s_addr, sizeof(int)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write (IP addr) to TCP cfd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - - fprintf(stderr, "ComOpenConnPair TCP cfd socket: addr - %s, port - %u.\n", - inet_ntoa(addressIn.sin_addr), ntohs(addressIn.sin_port)); - - if (time_read_bytes(cfd, (char *)&addressIn.sin_port, sizeof(short)) == -1 || - time_read_bytes(cfd, (char *)&addressIn.sin_addr.s_addr, sizeof(int)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to read (IP addr/port) from TCP cfd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - usleep(10000); - if (connect(dfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed conn UDP dfd to peer:", - getpid()); - perror(""); - close(cfd); - close(dfd); - return -1; - } - - fprintf(stderr, "ComOpenConnPair UDP dfd connects to host-%s (port %u)\n", - inet_ntoa(addressIn.sin_addr), - ntohs(addressIn.sin_port)); - -#ifndef LINUX - /* adjust the dfd REVBUF size */ - { - int len; - len = INET_SOCKET_BUFFER_SIZE + 100; - /* - if (setsockopt(dfd, SOL_SOCKET, SO_SNDBUF, (char *)&len, sizeof(len)) == -1) { - fprintf(stderr, - "Warning ComOpenConnPair: pid %d failed to set UDP dfd-snd to size %d:", - ACE_OS::getpid (), len); - ACE_OS::perror (""); - ACE_OS::close (dfd); - ACE_OS::close (cfd); - return -1; - } - */ - len = 65536; - while (setsockopt(dfd, SOL_SOCKET, SO_RCVBUF, (char *)&len, sizeof(len)) == -1) { - len -= 1024; - if (len < 8192) break; - /* - fprintf(stderr, - "Warning ComOpenConnPair: pid %d failed to set UDP dfd-rcv to size %d:", - ACE_OS::getpid (), len); - ACE_OS::perror (""); - ACE_OS::close (dfd); - ACE_OS::close (cfd); - return -1; - */ - } - if (getuid() == DEVELOPER_UID) - fprintf(stderr, "Set UDP dfd-rcv to %dB\n", len); - } -#endif - *max_pkt_size = - INET_SOCKET_BUFFER_SIZE; - /* UDP sockets on HP and SUN are discard mode */ - } - if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, - (const char *)&i, sizeof(i)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to setsockopt on TCP cfd with TCP_NODELAY:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (dfd); - ACE_OS::close (cfd); - return -1; - } - } - else if (dsocktype == CONN_ATM) { /* CONN_ATM */ -#ifdef NATIVE_ATM - if (csocktype == CONN_INET) { - /* build TCP connection to server */ - addressIn.sin_port = htons(inet_port); - cfd = socket(AF_INET, SOCK_STREAM, 0); - if (cfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open TCP1 cfd:", - getpid()); - perror(""); - return -1; - } - usleep(10000); - if (connect(cfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn TCP1 cfd to server:", - getpid()); - perror(""); - i = -3; - write(cfd, &i, 4); - close(cfd); - return -1; - } - } - else if (csocktype == CONN_UNIX) { - /* build UNIX connection to server */ - addressUn.sun_family = AF_UNIX; - strncpy(addressUn.sun_path, unix_port, - sizeof(struct sockaddr_un) - sizeof(short)); - cfd = socket(AF_UNIX, SOCK_STREAM, 0); - if (cfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open UNIX1 cfd:", - getpid()); - perror(""); - return -1; - } - usleep(10000); /* this is for waiting for the uncaught signal mentioned - below */ - if (connect(cfd, (struct sockaddr *)&addressUn, sizeof(addressUn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn UNIX1 cfd to server:", - getpid()); - perror(""); - i = -3; /* I don't understand why when select() returns EINTR, the connection - is still built, and the other end can still get what written at - this end, 'i = -3' is a garbage to be written. */ - write(cfd, &i, 4); - close(cfd); - return -1; - } - } - else { /* CONN_ATM */ - cfd = ATMopenConn(address, max_pkt_size); - if (cfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open ATM cfd conn:", - getpid()); - perror(""); - return -1; - } - usleep(100000); /* be nice to buggy ATM driver */ - } - if (time_write_int(cfd, -1) == -1 || time_read_int(cfd, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write -1 to %s cfd:", - ACE_OS::getpid (), - (csocktype == CONN_UNIX) ? "UNIX1" : - (csocktype == CONN_INET) ? "INET1" : "ATM"); - ACE_OS::perror (""); - if (csocktype == CONN_ATM) ATMcloseConn(cfd); - else ACE_OS::close (cfd); - return -1; - } - - dfd = ATMopenConn(address, max_pkt_size); - if (dfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open ATM dfd conn:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ATMcloseConn(cfd); - return -1; - } - usleep(100000); /* be nice to buggy ATM driver */ - if (time_write_int(dfd, i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write (cfd) to ATM dfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ATMcloseConn(cfd); - ATMcloseConn(dfd); - return -1; - } -#else - fprintf(stderr, - "Error ComOpenConnPair: pid %d addresstype %d not supported\n", - ACE_OS::getpid (), dsocktype); - return -1; -#endif - } - for (i = 0; i < size; i ++) { /* guaranteed to succeed */ - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = cfd; - fdTable[i].type = csocktype; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_CONTROL; - } - else { - fprintf(stderr, "<Weird>Error ComOpenConnPair: no entry for cfd %d\n", cfd); - return -1; - } - for (; i < size; i ++) { - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = dfd; - fdTable[i].type = dsocktype; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_DATA; - } - else { - fprintf(stderr, "<Wierd>Error ComOpenConnPair: no entry for dfd %d\n", dfd); - return -1; - } - *ctr_fd = cfd; - *data_fd = dfd; - ACE_DEBUG ((LM_DEBUG,"(%P|%t)Returning from ComOpenConnpair\n")); - return 0; -} - -/* address format: [ATM:|INET:]real_address | "" - - "" -- UNIX socket, reliable byte stream - [INET:]real_address -- INET sockets, reliable control byte stream, and - *max_pkt_size == 0 : reliable data byte stream, or - != 0 : unreliable packet stream; - ATM:real_address -- ATM sockets, both data and control are - unreliable packet streams; - DATM:real_address -- INET/UNIX control reliable byte stream - and ATM unreliable byte stream; - - Communication between client and server: - - ctr_fd: client --> server server --> client - -2: conn-less INET Open udp sock, send addr in net byte order - <port, addr> <port(short), addr(long)> - -1: conn-orient Send value of fd, wait to be paired - cfd>=0: data sock Paired with cfd and return. - */ - -#if 0 -int VideoComOpenConnPair (char * address, - int *ctr_fd, - int *data_fd, - int *max_pkt_size) -{ - int i; - int cfd, dfd, csocktype, dsocktype; - int conn_tag = !(*max_pkt_size); - struct sockaddr_in addressIn; - struct sockaddr_un addressUn; - - ACE_DEBUG ((LM_DEBUG, - "%s %d\n", - __FILE__,__LINE__)); - - if (!size) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d not done ComInitClient/Server yet.\n", - ACE_OS::getpid ()); - return -1; - } - - cfd = 0; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) cfd ++; - } - if (cfd < 2) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d no faTable entry for the pair", - ACE_OS::getpid ()); - return -1; - } - - /* tell the type of connections to establish: - If the server is on the same host, then UNIX socket is used */ - if (address[0] == 0) { - csocktype = CONN_UNIX; - dsocktype = CONN_UNIX; - } - else if (!strncasecmp(address, "atm:", 4)) { - address += 4; - csocktype = CONN_ATM; - dsocktype = CONN_ATM; - } - else if (!strncasecmp(address, "datm:", 5)) { - address += 5; - csocktype = CONN_INET; - dsocktype = CONN_ATM; - } - else { - csocktype = CONN_INET; - dsocktype = CONN_INET; - } - if (csocktype == CONN_INET || dsocktype == CONN_INET) { - struct hostent *hp; - char hostname[100]; - addressIn.sin_family = AF_INET; - if (!strncasecmp(address, "inet:", 5)) { - address += 5; - } - if (isascii(address[0]) && isdigit(address[0])) - addressIn.sin_addr.s_addr = inet_addr(address); - else { - if ((hp = gethostbyname(address)) == NULL) { /* No such host! */ - fprintf(stderr, - "Error ComOpenConnPair: pid %d host %s can't be found:", - getpid(), address); - perror(""); - return -1; - } - if (hp->h_addrtype != AF_INET) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d host %s is not of INET type address.\n", - getpid(), address); - return -1; - } - ACE_OS::memcpy ((char *)&addressIn.sin_addr.s_addr, (char *)hp->h_addr, - sizeof(addressIn.sin_addr.s_addr)); - /* - bcopy((char *)hp->h_addr, (char *)&addressIn.sin_addr.s_addr, - sizeof(addressIn.sin_addr.s_addr)); - */ - } - if (get_hostname(hostname, 100)) { - fprintf(stderr, "Error ComOpenConnPair: pid %d failed to get_hostname:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if ((hp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to its own IP address:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (hp->h_addrtype != AF_INET) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d own address is not INET type", - ACE_OS::getpid ()); - return -1; - } - - if (!memcmp((char *)hp->h_addr, (char *)&addressIn.sin_addr.s_addr, - sizeof(addressIn.sin_addr.s_addr))) { - if (csocktype == CONN_INET) csocktype = CONN_UNIX; - if (dsocktype == CONN_INET) dsocktype = CONN_UNIX; - } - } - - /* build appropriate type of Connections to Server */ - - if (csocktype == CONN_INET && dsocktype == CONN_INET) { - /* build TCP connection to server */ - addressIn.sin_port = htons(inet_port); - cfd = socket(AF_INET, SOCK_STREAM, 0); - if (cfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open TCP cfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - usleep(10000); - if (connect(cfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn TCP cfd to server:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - i = -3; - ACE_OS::write (cfd, &i, 4); - ACE_OS::close (cfd); - return -1; - } -// if (conn_tag) { /* create a second connection with server */ -// if (time_write_int(cfd, -1) == -1 || time_read_int(cfd, &i) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to write -1 to TCP cfd:", -// getpid()); -// perror(""); -// close(cfd); -// return -1; -// } - dfd = socket(AF_INET, SOCK_STREAM, 0); - if (dfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open TCP dfd:", - getpid()); - perror(""); - close(cfd); - return -1; - } - usleep(10000); - if (connect(dfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to conn TCP dfd to server:", - getpid()); - perror(""); - i = -3; - write(dfd, &i, 4); - close(cfd); - close(dfd); - return -1; - } - if (time_write_int(dfd, i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to write (cfd) to TCP dfd:", - getpid()); - perror(""); - close(cfd); - close(dfd); - return -1; - } - *max_pkt_size = 0; - } - else { /* create a UDP socket for data */ - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) ::VideoComOpenConnPair: making UDP connection\n")); - dfd = socket(AF_INET, SOCK_DGRAM, 0); - if (dfd == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to open UDP dfd:", - getpid()); - perror(""); - close(cfd); - return -1; - } - memset((char *)&addressIn, 0, sizeof(addressIn)); - - i = sizeof(addressIn); - if (getsockname(cfd, (struct sockaddr *)&addressIn, &i) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to getsocketname on TCP cfd:", - getpid()); - perror(""); - close(dfd); - close(cfd); - return -1; - } - -// addressIn.sin_family = AF_INET; -// addressIn.sin_port = 0; -// if (bind(dfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to bind UDP dfd:", -// getpid()); -// perror(""); -// close(cfd); -// close(dfd); -// return -1; -// } -// if (time_write_int(cfd, -2) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to write -2 to TCP cfd:", -// getpid()); -// perror(""); -// close(cfd); -// close(dfd); -// return -1; -// } - -// i = sizeof(addressIn); -// if (getsockname(dfd, (struct sockaddr *)&addressIn, &i) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to getsocketname on UDP fd:", -// getpid()); -// perror(""); -// close(dfd); -// close(cfd); -// return -1; -// } -// if (time_write_bytes(cfd, (char *)&addressIn.sin_port, sizeof(short)) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to write (port) to TCP cfd:", -// getpid()); -// perror(""); -// close(dfd); -// close(cfd); -// return -1; -// } - -// fprintf(stderr, "ComOpenConnPair local UDP socket: addr - %s, port - %u.\n", -// inet_ntoa(addressIn.sin_addr), ntohs(addressIn.sin_port)); - - -// fprintf(stderr, "ComOpenConnPair UDP port %d (should be > 0)\n", -// ntohs(addressIn.sin_port)); - -// /* -// i = sizeof(addressIn); -// if (getsockname(cfd, (struct sockaddr *)&addressIn, &i) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to getsocketname on TCP cfd:", -// getpid()); -// perror(""); -// close(dfd); -// close(cfd); -// return -1; -// } -// */ -// if (time_write_bytes(cfd, (char *)&addressIn.sin_addr.s_addr, sizeof(int)) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to write (IP addr) to TCP cfd:", -// getpid()); -// perror(""); -// close(dfd); -// close(cfd); -// return -1; -// } - -// fprintf(stderr, "ComOpenConnPair TCP cfd socket: addr - %s, port - %u.\n", -// inet_ntoa(addressIn.sin_addr), ntohs(addressIn.sin_port)); - -// if (time_read_bytes(cfd, (char *)&addressIn.sin_port, sizeof(short)) == -1 || -// time_read_bytes(cfd, (char *)&addressIn.sin_addr.s_addr, sizeof(int)) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to read (IP addr/port) from TCP cfd:", -// getpid()); -// perror(""); -// close(dfd); -// close(cfd); - // return -1; - // } - // usleep(10000); - // if (connect(dfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - // fprintf(stderr, - // "Error ComOpenConnPair: pid %d failed conn UDP dfd to peer:", - // getpid()); - // perror(""); - // close(cfd); - // close(dfd); - // return -1; - // } - - fprintf(stderr, "ComOpenConnPair UDP dfd connects to host-%s (port %u)\n", - inet_ntoa(addressIn.sin_addr), - ntohs(addressIn.sin_port)); - -#ifndef LINUX - /* adjust the dfd REVBUF size */ - { - int len; - len = INET_SOCKET_BUFFER_SIZE + 100; - /* - if (setsockopt(dfd, SOL_SOCKET, SO_SNDBUF, (char *)&len, sizeof(len)) == -1) { - fprintf(stderr, - "Warning ComOpenConnPair: pid %d failed to set UDP dfd-snd to size %d:", - ACE_OS::getpid (), len); - ACE_OS::perror (""); - ACE_OS::close (dfd); - ACE_OS::close (cfd); - return -1; - } - */ - len = 65536; - while (setsockopt(dfd, SOL_SOCKET, SO_RCVBUF, (char *)&len, sizeof(len)) == -1) { - len -= 1024; - if (len < 8192) break; - /* - fprintf(stderr, - "Warning ComOpenConnPair: pid %d failed to set UDP dfd-rcv to size %d:", - ACE_OS::getpid (), len); - ACE_OS::perror (""); - ACE_OS::close (dfd); - ACE_OS::close (cfd); - return -1; - */ - } - if (getuid() == DEVELOPER_UID) - fprintf(stderr, "Set UDP dfd-rcv to %dB\n", len); - } -#endif - *max_pkt_size = - INET_SOCKET_BUFFER_SIZE; - /* UDP sockets on HP and SUN are discard mode */ - } - if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, - (const char *)&i, sizeof(i)) == -1) { - fprintf(stderr, - "Error ComOpenConnPair: pid %d failed to setsockopt on TCP cfd with TCP_NODELAY:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (dfd); - ACE_OS::close (cfd); - return -1; - } - // } -// else if (dsocktype == CONN_ATM) { /* CONN_ATM */ -// #ifdef NATIVE_ATM -// if (csocktype == CONN_INET) { -// /* build TCP connection to server */ -// addressIn.sin_port = htons(inet_port); -// cfd = socket(AF_INET, SOCK_STREAM, 0); -// if (cfd == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to open TCP1 cfd:", -// getpid()); -// perror(""); -// return -1; -// } -// usleep(10000); -// if (connect(cfd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to conn TCP1 cfd to server:", -// getpid()); -// perror(""); -// i = -3; -// write(cfd, &i, 4); -// close(cfd); -// return -1; -// } -// } -// else if (csocktype == CONN_UNIX) { -// /* build UNIX connection to server */ -// addressUn.sun_family = AF_UNIX; -// strncpy(addressUn.sun_path, unix_port, -// sizeof(struct sockaddr_un) - sizeof(short)); -// cfd = socket(AF_UNIX, SOCK_STREAM, 0); -// if (cfd == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to open UNIX1 cfd:", -// getpid()); -// perror(""); -// return -1; -// } -// usleep(10000); /* this is for waiting for the uncaught signal mentioned -// below */ -// if (connect(cfd, (struct sockaddr *)&addressUn, sizeof(addressUn)) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to conn UNIX1 cfd to server:", -// getpid()); -// perror(""); -// i = -3; /* I don't understand why when select() returns EINTR, the connection -// is still built, and the other end can still get what written at -// this end, 'i = -3' is a garbage to be written. */ -// write(cfd, &i, 4); -// close(cfd); -// return -1; -// } -// } -// else { /* CONN_ATM */ -// cfd = ATMopenConn(address, max_pkt_size); -// if (cfd == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to open ATM cfd conn:", -// getpid()); -// perror(""); -// return -1; -// } -// usleep(100000); /* be nice to buggy ATM driver */ -// } -// if (time_write_int(cfd, -1) == -1 || time_read_int(cfd, &i) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to write -1 to %s cfd:", -// ACE_OS::getpid (), -// (csocktype == CONN_UNIX) ? "UNIX1" : -// (csocktype == CONN_INET) ? "INET1" : "ATM"); -// ACE_OS::perror (""); -// if (csocktype == CONN_ATM) ATMcloseConn(cfd); -// else ACE_OS::close (cfd); -// return -1; -// } - -// dfd = ATMopenConn(address, max_pkt_size); -// if (dfd == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to open ATM dfd conn:", -// ACE_OS::getpid ()); -// ACE_OS::perror (""); -// ATMcloseConn(cfd); -// return -1; -// } -// usleep(100000); /* be nice to buggy ATM driver */ -// if (time_write_int(dfd, i) == -1) { -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d failed to write (cfd) to ATM dfd:", -// ACE_OS::getpid ()); -// ACE_OS::perror (""); -// ATMcloseConn(cfd); -// ATMcloseConn(dfd); -// return -1; -// } -// #else -// fprintf(stderr, -// "Error ComOpenConnPair: pid %d addresstype %d not supported\n", -// ACE_OS::getpid (), dsocktype); -// return -1; -// #endif -// } - for (i = 0; i < size; i ++) { /* guaranteed to succeed */ - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = cfd; - fdTable[i].type = csocktype; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_CONTROL; - } - else { - fprintf(stderr, "<Weird>Error ComOpenConnPair: no entry for cfd %d\n", cfd); - return -1; - } - for (; i < size; i ++) { - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = dfd; - fdTable[i].type = dsocktype; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_DATA; - } - else { - fprintf(stderr, "<Wierd>Error ComOpenConnPair: no entry for dfd %d\n", dfd); - return -1; - } - *ctr_fd = cfd; - *data_fd = dfd; - return 0; -} -#endif - -/* returns: -1 -- failed, >=0 -- fd */ -int ComOpenConn(char * address, int *max_pkt_size) -{ - int i; - int fd, socktype; - struct sockaddr_in addressIn; - struct sockaddr_un addressUn; - - if (!size) { - fprintf(stderr, - "Error ComOpenConn: pid %d not done ComInitClient/Server yet.\n", - ACE_OS::getpid ()); - return -1; - } - - fd = 0; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) fd ++; - } - if (fd < 1) { - fprintf(stderr, - "Error ComOpenConn: pid %d no faTable entry for the pair", - ACE_OS::getpid ()); - return -1; - } - - /* tell the type of connections to establish: - If the server is on the same host, then UNIX socket is used */ - if (address[0] == 0) { - socktype = CONN_UNIX; - } - else if (!strncasecmp(address, "atm:", 4)) { - address += 4; - socktype = CONN_ATM; - } - else if (!strncasecmp(address, "datm:", 5)) { - address += 5; - socktype = CONN_ATM; - } - else { - socktype = CONN_INET; - } - if (socktype == CONN_INET) { - struct hostent *hp; - char hostname[100]; - addressIn.sin_family = AF_INET; - if (!strncasecmp(address, "inet:", 5)) { - address += 5; - } - if (isascii(address[0]) && isdigit(address[0])) - addressIn.sin_addr.s_addr = inet_addr(address); - else { - if ((hp = gethostbyname(address)) == NULL) { /* No such host! */ - fprintf(stderr, - "Error ComOpenConn: pid %d host %s can't be found:", - getpid(), address); - perror(""); - return -1; - } - if (hp->h_addrtype != AF_INET) { - fprintf(stderr, - "Error ComOpenConn: pid %d host %s is not of INET type address.\n", - getpid(), address); - return -1; - } - ACE_OS::memcpy ((char *)&addressIn.sin_addr.s_addr, (char *)hp->h_addr, - sizeof(addressIn.sin_addr.s_addr)); - /* - bcopy((char *)hp->h_addr, (char *)&addressIn.sin_addr.s_addr, - sizeof(addressIn.sin_addr.s_addr)); - */ - } - if (get_hostname(hostname, 100)) { - fprintf(stderr, "Error ComOpenConn: pid %d failed to get_hostname:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if ((hp = gethostbyname(hostname)) == NULL) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to its own IP address:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (hp->h_addrtype != AF_INET) { - fprintf(stderr, - "Error ComOpenConn: pid %d own address is not INET type", - ACE_OS::getpid ()); - return -1; - } - - if (!memcmp((char *)hp->h_addr, (char *)&addressIn.sin_addr.s_addr, - sizeof(addressIn.sin_addr.s_addr))) { - if (socktype == CONN_INET) socktype = CONN_UNIX; - } - } - - /* build appropriate type of Connections to Server */ - if (socktype == CONN_UNIX) { - /* build UNIX connection to server */ - addressUn.sun_family = AF_UNIX; - strncpy(addressUn.sun_path, unix_port, - sizeof(struct sockaddr_un) - sizeof(short)); - fd = socket(AF_UNIX, SOCK_STREAM, 0); - if (fd == -1) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to open UNIX fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (connect(fd, (struct sockaddr *)&addressUn, sizeof(addressUn)) == -1) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to conn UNIX fd to server:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd); - return -1; - } - *max_pkt_size = 0; - } - else if (socktype == CONN_INET) { - /* build TCP connection to server */ - addressIn.sin_port = htons(inet_port); - fd = socket(AF_INET, SOCK_STREAM, 0); - if (fd == -1) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to open TCP fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (connect(fd, (struct sockaddr *)&addressIn, sizeof(addressIn)) == -1) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to conn TCP fd to server:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd); - return -1; - } - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, - (const char *)&i, sizeof(i)) == -1) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to setsockopt on TCP fd with TCP_NODELAY:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd); - return -1; - } - *max_pkt_size = 0; - } - else if (socktype == CONN_ATM) { /* CONN_ATM */ -#ifdef NATIVE_ATM - /* CONN_ATM */ - fd = ATMopenConn(address, max_pkt_size); - if (fd == -1) { - fprintf(stderr, - "Error ComOpenConn: pid %d failed to open ATM fd conn:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } -#else - fprintf(stderr, - "Error ComOpenConn: pid %d addresstype %d not supported\n", - ACE_OS::getpid (), socktype); - return -1; -#endif - } - for (i = 0; i < size; i ++) { /* guaranteed to succeed */ - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = fd; - fdTable[i].type = socktype; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_SINGLE; - return fd; - } - else { - fprintf(stderr, "<Weird>Error ComOpenConn: no entry for fd %d\n", fd); - return -1; - } -} - - -static int fd_unix, fd_inet, fd_atm; /* for use in the server side */ - - -int ComInitServer(int pinet_port, char * punix_port, char * patm_port) -{ - int i; - - struct sockaddr_in myaddr_in; - struct sockaddr_un myaddr_un; - - inet_port = pinet_port; - unix_port = punix_port; - atm_port = patm_port; - - if (size) { - fprintf(stderr, - "Error ComInitServer: pid %d already done ComInitServer/Server\n", - ACE_OS::getpid ()); - return -1; - } - size = CLIENT_FDTABLE_SIZE; - // create and initialize the File Descriptor Table - fdTable = (struct FdTable *)ACE_OS::malloc(size * sizeof(*fdTable)); - if (fdTable == NULL) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to allocated fdTable space:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - for (i = 0; i < size; i ++) { - fdTable[i].fd = -1; - } - // Set all the file descriptor for atm ,inet and unix to be -1 - fd_atm = fd_inet = fd_unix = -1; - - memset((char *)&myaddr_in, 0, sizeof(struct sockaddr_in)); - memset((char *)&myaddr_un, 0, sizeof(struct sockaddr_un)); - - myaddr_in.sin_family = AF_INET; - - myaddr_in.sin_addr.s_addr = htonl(INADDR_ANY); - myaddr_in.sin_port = htons((short)inet_port); - - /* setup INET listen socket */ - fd_inet = socket(AF_INET, SOCK_STREAM, 0); - if (fd_inet == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to open fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - goto open_fd_unix; - } - - i = 1; - if (setsockopt(fd_inet, SOL_SOCKET, SO_REUSEADDR, - (const char *)&i, sizeof(i)) == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to setsockopt fd_inet with REUSEADDR:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd_inet); - fd_inet = -1; - goto open_fd_unix; - } - - if (bind(fd_inet, (struct sockaddr *)&myaddr_in, sizeof(struct sockaddr_in)) == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to bind fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd_inet); - fd_inet = -1; - goto open_fd_unix; - } - if (listen(fd_inet, 2) == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to listen on fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd_inet); - fd_inet = -1; - goto open_fd_unix; - } - - open_fd_unix: - - myaddr_un.sun_family = AF_UNIX; - strncpy(myaddr_un.sun_path, unix_port, - (sizeof(struct sockaddr_un) - sizeof(short))); - fd_unix = socket(AF_UNIX, SOCK_STREAM, 0); - if (fd_unix == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to open fd_unix:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - goto open_fd_atm; - } - if ((bind(fd_unix, (struct sockaddr *)&myaddr_un, - sizeof(struct sockaddr_un))) == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to bind fd_unix:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd_unix); - fd_unix = -1; - goto open_fd_atm; - } - if ((listen(fd_unix, 2)) == -1) { - fprintf(stderr, - "Error ComInitServer: pid %d failed to liston on fd_unix:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::close (fd_unix); - fd_unix = -1; - goto open_fd_atm; - } - - open_fd_atm: - -#ifdef NATIVE_ATM - fd_atm = ATMinitServer(atm_port); -#endif - - if (fd_inet >= 0 || fd_unix >= 0 || fd_atm >= 0) return 0; - else return -1; -} - -void ComCloseListen(void) -{ - if (fd_atm >= 0) { -#ifdef NATIVE_ATM - /* fd_atm is not connected to a user_plane, ignore - ATMcloseFd(fd_atm); - */ - ACE_OS::close (fd_atm); - fd_atm = -1; -#else - fprintf(stderr, "Error ComCloseListen: CONN_ATM not supported.\n"); -#endif - } - if (fd_unix >= 0) { - ACE_OS::close (fd_unix); - fd_unix = -1; - } - if (fd_inet >= 0) { - ACE_OS::close (fd_inet); - fd_inet = -1; - } - return; -} - -void ComCloseServer(void) -{ - int i; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd >= 0) ComCloseConn(fdTable[i].fd); - } - if (fd_atm >= 0) { -#ifdef NATIVE_ATM - /* fd_atm not connected to a user-plane, igore it - ATMcloseConn(fd_atm); - */ - ACE_OS::close (fd_atm); - fd_atm = -1; -#else - fprintf(stderr, "Error ComCloseServer: CONN_ATM not supported.\n"); -#endif - } - if (fd_unix >= 0) { - ACE_OS::close (fd_unix); - fd_unix = -1; - ACE_OS::unlink (unix_port); - } - if (fd_inet >= 0) { - ACE_OS::close (fd_inet); - fd_inet = -1; - } -#ifdef NATIVE_ATM - ATMcloseServer(); -#endif - return; -} - -static int change_option(int fd) -{ - struct linger linger = {1, 1}; - int i = 1; - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, - (const char *)&i, sizeof(i)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to setsockopt on fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - /* data socket also NODELAY */ - if (setsockopt(fd, SOL_SOCKET, SO_LINGER, (const char *)&linger, - sizeof(linger)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to linger on fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - return 0; -} - -int ComGetConnPair(int *ctr_fd, int *data_fd, int *max_pkt_size) -{ - int i; - int fd, fdType; - int addrlen; - struct sockaddr_in peeraddr_in; - struct fd_set read_mask; - struct timeval tval; - int nfds; - - fd = 0; - addrlen = get_sec(); - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) { - fd ++; - } - else if (fdTable[i].type == STATE_PENDING && - get_duration(fdTable[i].stime, addrlen) > 10) { - fprintf(stderr, - "ComGetConnPair: pid %d closed fd %d (PENDING >= 10 sec)\n", - ACE_OS::getpid (), fdTable[i].fd); - ComCloseConn(fdTable[i].fd); - fdTable[i].fd = -1; - fd ++; - } - } - if (fd < 2) { - fprintf(stderr, - "Error ComGetConnPair: pid %d no faTable entry for the pair", - ACE_OS::getpid ()); - return -1; - } - - FD_ZERO(&read_mask); - if (fd_inet >= 0) FD_SET(fd_inet, &read_mask); - if (fd_unix >= 0) FD_SET(fd_unix, &read_mask); - if (fd_atm >= 0) FD_SET(fd_atm, &read_mask); - - tval.tv_sec = 1; /* wait at most 1 second */ - tval.tv_usec = 0; - - - nfds = fd_inet; - if (fd_unix > nfds) nfds = fd_unix; - if (fd_atm > nfds) nfds = fd_atm; - // nfds now holds the highest numbered open file descriptor - nfds ++; // increment so that select can use o to nfds -1 no. of - // file descriptors. - errno = 0; - // fd is here used as the result of the select call -#ifdef _HPUX_SOURCE - if ((fd = select(nfds, (int *)&read_mask, NULL, NULL, &tval)) == -1) -#else - if ((fd = select(nfds, &read_mask, NULL, NULL, &tval)) == -1) -#endif - { - - if (errno == EINTR) return -1; - - fprintf(stderr, - "Error ComGetConnPair: pid %d failed on select():", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (fd == 0) return -1; /* time expire */ - - fd = -1; - // fd will be reused inside this code as the accepted socket. - if (fd == -1 && fd_unix >= 0 && FD_ISSET(fd_unix, &read_mask)) { - struct sockaddr_un peeraddr_un; - - fprintf(stderr, "Server to accept a UNIX connection.\n"); - - addrlen = sizeof(struct sockaddr_un); - fd = accept(fd_unix, (struct sockaddr *)&peeraddr_un, &addrlen); - if (fd == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to accpet on fd_unix:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - } - else fdType = CONN_UNIX; - *max_pkt_size = 0; - } - // fd here is the result of the accept for unix if fd_unix is valid - // Hence if fd_unix is present then this won't be called if the - // accept for the fd_unix succeeds. - if (fd == -1 && fd_inet >= 0 && FD_ISSET(fd_inet, &read_mask)) { - - fprintf(stderr, "Server to accept a INET connection.\n"); - - addrlen = sizeof(struct sockaddr_in); - fd = accept(fd_inet, (struct sockaddr *)&peeraddr_in, &addrlen); - if (fd == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to accpet on fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - } - else fdType = CONN_INET; - *max_pkt_size = 0; - } - if (fd == -1 && fd_atm >= 0 && FD_ISSET(fd_atm, &read_mask)) { -#ifdef NATIVE_ATM - fd = ATMaccept(fd_atm, max_pkt_size); - fdType = CONN_ATM; -#else - fprintf(stderr, - "Error ComGetConnPair: pid %d CONN_ATM not supported.\n", - ACE_OS::getpid ()); -#endif - } - // fd = -1 implies accept failed in any of the active connections - // which came out of the select call. - if (fd == -1) return -1; - - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) break; - } - // Enter the accepted fd in the file descriptor Table - if (i < size) { - fdTable[i].fd = fd; - fdTable[i].type = fdType; - fdTable[i].stime = get_sec(); - } - else { - fprintf(stderr, "Weird\n"); - } - - // read the port number for the UDP socket of the client - if (time_read_int(fd, &nfds) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to read int from %s fd:", - ACE_OS::getpid (), - fdType == CONN_ATM ? "ATM" : - fdType == CONN_INET ? "INET" : "UNIX"); - ACE_OS::perror (""); - ComCloseConn(fd); - return -1; - } - fprintf (stderr, - " Received int nfds = %d \n", - nfds); - // nfds holds the int read in time_read_int - // if nfds is -1 then read int error. - fprintf(stderr, "ComGetConnPair got %s fd = %d with value %d\n", - fdType == CONN_ATM ? "ATM" : - fdType == CONN_INET ? "INET" : "UNIX", - fd, nfds); - - if (nfds >= 0) { /* can be paired and return */ - // This is the success case where you got a control fd and a data fd. - fdTable[i].state = STATE_DATA; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == nfds) break; - } - if (i < size && fdTable[i].state == STATE_PENDING) { - fdTable[i].state = STATE_CONTROL; - } - else { - if (i >= 0) fprintf(stderr, "<Weird> i %d\n", i); - ComCloseConn(fd); - return -1; - } - // ???? - *ctr_fd = fdTable[i].fd; - *data_fd = fd; - return 0; - } - else if (nfds == -1) { /* wait to be paired */ - fdTable[i].state = STATE_PENDING; - // fd is the inet or unix accepted socket. - // why is anyone writing the fd to the peer? - // looks like he is indicating an error to the client!! - // is this a hack ;-( - if (time_write_int(fd, fd) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to write (fd) to %s fd:", - ACE_OS::getpid (), - fdType == CONN_ATM ? "ATM" : - fdType == CONN_INET ? "INET" : "UNIX"); - ACE_OS::perror (""); - ComCloseConn(fd); - return -1; - } - if (fdType == CONN_INET && change_option(fd) == -1) { - ComCloseConn(fd); - } - return -1; - } - else if (nfds == -2) { /* inet case only, UDP data sock is requested */ - int dfd; - struct sockaddr_in * in = &(peeraddr_in); - - fdTable[i].state = STATE_CONTROL; - - if (fdType == CONN_INET && change_option(fd) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to change options of TCP cfd:", - ACE_OS::getpid ()); - ComCloseConn(fd); - return -1; - } - - dfd = socket(AF_INET, SOCK_DGRAM, 0); - if (dfd == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to open dfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - return -1; - } - memset((char *)in, 0, sizeof(* in)); - - addrlen = sizeof(*in); - if (getsockname(fd, (struct sockaddr *)in, &addrlen) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to getsockname of fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - - in->sin_family = AF_INET; - in->sin_port = 0; - /* - in->sin_addr.s_addr = htonl(INADDR_ANY); - */ - if (bind(dfd, (struct sockaddr *)in, sizeof(* in)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to bind dfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - addrlen = sizeof(*in); - if (getsockname(dfd, (struct sockaddr *)in, &addrlen) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to getsockname of dfd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - if (time_write_bytes(fd, (char *)&in->sin_port, sizeof(short)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to write (dfd.port) to fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - /* - addrlen = sizeof(*in); - if (getsockname(fd, (struct sockaddr *)in, &addrlen) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to getsockname of fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - */ - if (time_write_bytes(fd, (char *)&in->sin_addr.s_addr, sizeof(int)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to write (dfd.IPaddr) to fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - - fprintf(stderr, "ComGetConnPair local UDP socket: addr - %s, port - %u.\n", - inet_ntoa(in->sin_addr), ntohs(in->sin_port)); - - if (time_read_bytes(fd, (char *)&in->sin_port, sizeof(short)) == -1 || - time_read_bytes(fd, (char *)&in->sin_addr.s_addr, sizeof(int)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to read (port, IPaddr) from fd:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } - usleep(10000); - if (connect(dfd, (struct sockaddr *)in, sizeof(*in)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed conn UDP dfd to peer:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - ComCloseConn(fd); - ACE_OS::close (dfd); - return -1; - } -#if 0 - { - int len; - len = 65536; /* INET_SOCKET_BUFFER_SIZE + 100; */ - /* - if (setsockopt(dfd, SOL_SOCKET, SO_SNDBUF, (char *)&len, sizeof(len)) == -1) { - fprintf(stderr, - "Error ComGetConnPair: pid %d failed to set UDP dfd-snd to size %d:", - getpid(), len); - perror(""); - ComCloseConn(fd); - close(dfd); - return -1; - } - */ - len = 65536; - while (setsockopt(dfd, SOL_SOCKET, SO_RCVBUF, (char *)&len, sizeof(len)) == -1) { - len -= 1024; - if (len < 8192) break; - /* - fprintf(stderr, - "Warning ComGetConnPair: pid %d failed to set UDP dfd-rcv to size %d:", - getpid(), len); - perror(""); - ComCloseConn(fd); - close(dfd); - return -1; - */ - } - if (getuid() == DEVELOPER_UID) - fprintf(stderr,"Set UDP dfd-rcv to %dB\n", len); - } -#endif - // Most common return case where the server creates a UDP socket , - // writes the port and ip addr and also gets the client's UDP - // endpoint . - *max_pkt_size = - INET_SOCKET_BUFFER_SIZE; /* UDP sockets on HP and SUN - are known to be discard mode */ - - fprintf(stderr, "ComGetConnPair UDP dfd connects to host-%s (port %u)\n", - inet_ntoa(in->sin_addr), ntohs(in->sin_port)); - - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = dfd; - fdTable[i].type = CONN_INET; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_DATA; - - *ctr_fd = fd; - *data_fd = dfd; - return 0; - } - else { - fprintf(stderr, "ComGetConnPair <Weird>: no space left\n"); - return -1; - } - } - else { - fprintf(stderr, - "Error ComGetConnPair: pid %d get invalid value %d from fd\n", - ACE_OS::getpid (), nfds); - ComCloseConn(fd); - } - return -1; -} - -/* returns: -1 -- failed, >= 0 -- fd */ -int ComGetConn(int *max_pkt_size) -{ - int i; - int fd, fdType; - int addrlen; - struct fd_set read_mask; - struct timeval tval; - int nfds; - - fd = 0; - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) { - fd ++; - } - } - if (fd < 1) { - fprintf(stderr, - "Error ComGetConn: pid %d no faTable entry for the pair", - ACE_OS::getpid ()); - return -1; - } - - FD_ZERO(&read_mask); - if (fd_inet >= 0) FD_SET(fd_inet, &read_mask); - if (fd_unix >= 0) FD_SET(fd_unix, &read_mask); - if (fd_atm >= 0) FD_SET(fd_atm, &read_mask); - - tval.tv_sec = 1; /* wait at most 1 second */ - tval.tv_usec = 0; - - nfds = fd_inet; - if (fd_unix > nfds) nfds = fd_unix; - if (fd_atm > nfds) nfds = fd_atm; - nfds ++; - errno = 0; -#ifdef _HPUX_SOURCE - if ((fd = select(nfds, (int *)&read_mask, NULL, NULL, &tval)) == -1) -#else - if ((fd = select(nfds, &read_mask, NULL, NULL, &tval)) == -1) -#endif - { - - if (errno == EINTR) return -1; - - fprintf(stderr, - "Error ComGetConn: pid %d failed on select():", - ACE_OS::getpid ()); - ACE_OS::perror (""); - return -1; - } - if (fd == 0) return -1; /* time expire */ - - fd = -1; - - if (fd == -1 && fd_unix >= 0 && FD_ISSET(fd_unix, &read_mask)) { - struct sockaddr_un peeraddr_un; - - fprintf(stderr, "Server to accept a UNIX connection.\n"); - - addrlen = sizeof(struct sockaddr_un); - fd = accept(fd_unix, (struct sockaddr *)&peeraddr_un, &addrlen); - if (fd == -1) { - fprintf(stderr, - "Error ComGetConn: pid %d failed to accpet on fd_unix:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - } - else fdType = CONN_UNIX; - *max_pkt_size = 0; - } - if (fd == -1 && fd_inet >= 0 && FD_ISSET(fd_inet, &read_mask)) { - struct sockaddr_in peeraddr_in; - - fprintf(stderr, "Server to accept a INET connection.\n"); - - addrlen = sizeof(struct sockaddr_in); - fd = accept(fd_inet, (struct sockaddr *)&peeraddr_in, &addrlen); - if (fd == -1) { - fprintf(stderr, - "Error ComGetConn: pid %d failed to accpet on fd_inet:", - ACE_OS::getpid ()); - ACE_OS::perror (""); - } - else fdType = CONN_INET; - *max_pkt_size = 0; - } - if (fd == -1 && fd_atm >= 0 && FD_ISSET(fd_atm, &read_mask)) { -#ifdef NATIVE_ATM - fd = ATMaccept(fd_atm, max_pkt_size); - fdType = CONN_ATM; -#else - fprintf(stderr, - "Error ComGetConn: pid %d CONN_ATM not supported.\n", - ACE_OS::getpid ()); -#endif - } - if (fd == -1) return -1; - - for (i = 0; i < size; i ++) { - if (fdTable[i].fd == -1) break; - } - if (i < size) { - fdTable[i].fd = fd; - fdTable[i].type = fdType; - fdTable[i].stime = get_sec(); - fdTable[i].state = STATE_SINGLE; - return fd; - } - else { - fprintf(stderr, "Weird\n"); - ComCloseConn(fd); - return -1; - } -} diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h deleted file mode 100644 index cf97b4b1796..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/com.h +++ /dev/null @@ -1,112 +0,0 @@ -/* $Id$ */ -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -/* -Some assumptions about the streams created in this file: - - PACKET STREAM: - - * send(), recv() may not work, we can only use - read()/write(). - - * write(): either send the whole packet, or send nothing - - * read(): read() will read the minimun of the - requested number of bytes and current packet size. - read() can read part of a packet, but it - will not read cross packet boundaris - - There are two modes: non-discard and dicard. If a packets is - not read all its bytes, the remaining bytes will be - or not be discarded. - - This is indicated by if (*max_pkt_size) is positive - (non-discard) or negative (discard) - - BYTE_STREAM: reliable - - * write(): might write only part of requested bytes - each time. (this is the case in SunOS4) - - * read(): might read less than requested bytes. - (this is the case in SunOS4). -*/ - -/* returns: -1 -- failed, 0 -- successful */ -int ComInitClient(int inet_port, char * unix_port, char * atm_port); - -void ComCloseClient(void); - -/* address format: [ATM:|INET:]real_address | "" - - "" -- UNIX socket, reliable byte stream - [INET:]real_address -- INET sockets, reliable control byte stream, and - *max_pkt_size == 0 : reliable data byte stream, or - != 0 : unreliable packet stream; - ATM:real_address -- ATM sockets, both data and control are - unreliable packet streams; - DATM:real_address -- INET/UNIX control reliable byte stream - and ATM unreliable byte stream; - - returns: -1 -- failed, 0 -- successful - *ctr_fd -- control connection file descriptor - *data_fd -- data connection file descriptor - *max_pkt_size -- == 0 : reliable BYTE_STREAM - > 0 : unreliable non-discard PACKET STREAM - with given maximum packet size (bytes); - < 0 : unreliable discard PACKET STREAM - with given maximum packet size (bytes); - - It is suggested that if a BYTE_STREAM is not known to be discarded, - than it is safer to indicate it as discard. - */ -int ComOpenConnPair(char * address, int *ctr_fd, int *data_fd, int *max_pkt_size); -int VideoComOpenConnPair(char * address, int *ctr_fd, int *data_fd, int *max_pkt_size); - - -/* returns: -1 -- failed, >=0 -- fd */ -int ComOpenConn(char * address, int *max_pkt_size); - -/* returns: -1 -- failed, 0 -- successful */ -int ComCloseFd(int fd); - -/* returns: -1 -- failed, 0 -- successful */ -int ComCloseConn(int fd); - -/* returns: -1 -- failed, 0 -- successful */ -int ComInitServer(int inet_port, char * unix_port, char * atm_port); - -void ComCloseListen(void); - -void ComCloseServer(void); - -/* returns: -1 -- failed, 0 -- successful - *max_pkt_size is used only for returning value -*/ -int ComGetConnPair(int *ctr_fd, int *data_fd, int *max_pkt_size); - -/* returns: -1 -- failed, >= 0 -- fd */ -int ComGetConn(int *max_pkt_size); - diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.cpp deleted file mode 100644 index 2506186cdb8..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.cpp +++ /dev/null @@ -1,410 +0,0 @@ -/* $Id$ */ - -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <pwd.h> -#include <grp.h> -#include <time.h> -#include <sys/time.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <netinet/in.h> -#include "routine.h" -#include "fileio.h" - -ACE_RCSID(mpeg_shared, fileio, "$Id$") - -/* - Statfile(filename, sb) - input: filename - path name of a directory entry; - output: sb - StatBuf structure of the given directory entry; - returns: 0 - successful, -1 - failed, with errno indicating error - */ -int StatFile(char *filename, struct StatBuf * sb) -{ - struct stat statbuf; - struct passwd *pw; - struct group *grp; - - if (stat(filename, &statbuf) == -1) - return -1; - - sb->mode = statbuf.st_mode; - sb->size = statbuf.st_size; - - strcpy(sb->ctime, ACE_OS::ctime (&(statbuf.st_ctime))); - sb->ctime[strlen(sb->ctime)-1] = 0; /* remove CR */ - - if ((pw = getpwuid(statbuf.st_uid)) == NULL) - sprintf(sb->uid, "%-10d", statbuf.st_uid); - else - strncpy(sb->uid, pw->pw_name, 32); - - if ((grp = getgrgid(statbuf.st_gid)) == NULL) - sprintf(sb->gid, "%-10d", statbuf.st_gid); - else - strncpy(sb->gid, grp->gr_name, 32); -} - -/* - read_bytes(s, buf, size) - input: s - socket to read from - buf - address of a buffer for the read - size - number of bytes to read - output: non - action: try read given number of bytes, all errors are reported, and - cause program to exit. -*/ -void read_bytes(int s, char * buf, int size) -{ - int val, remain = size; - char * ptr = buf; - - if (size == 0) return; - - for (;;) - { - val = ACE_OS::read (s, ptr, remain); - - 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; - continue; - } - if (val == -1) - { - ACE_OS::perror ("Error -- Read from socket"); - ACE_OS::exit (1); - } - if (val == 0) /* EOF encountered */ - { - fprintf(stderr, "Error -- EOF reached while trying to read %d bytes.\n", size); - ACE_OS::exit (1); - } - ptr += val; - remain -= val; - if (remain < 0) /* weird thing is happening */ - { - fprintf(stderr, "Error: read too much from socket, %d out of %d bytes.\n", - size-remain, size); - ACE_OS::exit (1); - } - if (remain == 0) - break; - } -} - -int wait_read_bytes (int s, char *buf, int size) -{ - int val, remain = size; - char * ptr = buf; - - if (size == 0) return 1; - - for (;;) - { - val = ACE_OS::read (s, ptr, remain); - - 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; - continue; - } - if (val == -1) - { - /* - ACE_OS::perror ("Error -- wait_read from socket"); - */ - return -1; - } - if (val == 0) /* EOF encountered */ - { - /* - fprintf(stderr, "Warn pid %d -- EOF on wait_read %d bytes.\n", - ACE_OS::getpid (), size); - */ - return 0; - } - ptr += val; - remain -= val; - if (remain < 0) /* weird thing is happening */ - { - fprintf(stderr, - "Error: weird, read too much from socket, %d out of %d bytes.\n", - size-remain, size); - return -1; - } - if (remain == 0) - break; - } - return size; -} - -#define WAIT_DURATION 5000000 - -int time_read_bytes(int s, char * buf, int size) -{ - int val, remain = size; - char * ptr = buf; - long start = get_usec(); - - int times = 0; - - if (size == 0) return 0; - - for (;;) { - struct fd_set read_mask; - struct timeval tval = {0, 0}; - - FD_ZERO(&read_mask); - FD_SET(s, &read_mask); -#ifdef _HPUX_SOURCE - if (select(s+1, (int *)&read_mask, NULL, NULL, &tval) <= 0) -#else - if (select(s+1, &read_mask, NULL, NULL, &tval) <= 0) -#endif - { - /* - if (get_duration(start, get_usec()) < WAIT_DURATION) { - usleep(10000); - continue; - } - */ - if (times < WAIT_DURATION / 10000) { - usleep(10000); - times ++; - continue; - } - else { - fprintf(stderr, "time_read_bytes() %d seconds expired\n", - WAIT_DURATION/1000000); - return -1; - } - } - - if (!(FD_ISSET(s, &read_mask))) continue; - - val = ACE_OS::read (s, ptr, 1); - - if (val == -1 && (errno == EINTR)) - { /* interrupted or need to wait, try again */ - errno = 0; - continue; - } - if (val == -1) - { - ACE_OS::perror ("Error -- time_read_bytes() from socket"); - return -1; - } - if (val == 0) /* EOF encountered */ - { - /* - fprintf(stderr, "Error -- EOF reached while trying to read %d bytes.\n", size); - */ - return -1; - /* 'continue' causes infinite loop if the pipe is closed by peer - continue; - */ - } - ptr += val; - remain -= val; - if (remain == 0) - return 0; - } -} - -/* - write_bytes(sock, data, len): - try write len byte of data to sock, report all errors by - warning message. -*/ -void write_bytes(int sock, char * data, int len) -{ - while (len > 0) { - int res = ACE_OS::write (sock, data, len); - if (res == -1) { - if (errno == EINTR || errno == EAGAIN) continue; - fprintf(stderr, "Error pid %d",ACE_OS::getpid ()); - ACE_OS::perror (" -- failed to write all bytes to socket"); - ACE_OS::exit (1); - } - len -= res; - data += res; - } -} - -int time_write_bytes(int sock, char * data, int plen) -{ - int len = plen; - while (len > 0) { - int res = ACE_OS::write (sock, data, len); - if (res == -1) { - if (errno == EINTR || errno == EAGAIN) continue; - fprintf(stderr, "Error pid %d",ACE_OS::getpid ()); - ACE_OS::perror (" -- failed to time_write all bytes to socket"); - return -1; - } - len -= res; - data += res; - } - return plen; -} - -int wait_write_bytes(int sock, char * data, int plen) -{ - int len = plen; - while (len > 0) { - int res = ACE_OS::write (sock, data, len); - if (res == -1) { - if (errno == EINTR || errno == EAGAIN) continue; - /* - fprintf(stderr, "Error pid %d",ACE_OS::getpid ()); - ACE_OS::perror (" -- failed to wait_write all bytes to socket"); - */ - return -1; - } - len -= res; - data += res; - } - return plen; -} - -/* read_byte: - read one byte from sock to buffer data */ - -void read_byte(int sock, char * data) -{ - read_bytes(sock, data, 1); -} - -/* read_short: - read a short integer from socket sock to buffer data, - byte order conversion is also done. -*/ -void read_short(int sock, short * data) -{ - read_bytes(sock, (char *)data, sizeof(short)); - *data = ntohs(*data); -} - -/* read_int: - read a integer from socket sock to buffer data, - byte order conversion is also done */ - -void read_int(int sock, int * data) -{ - read_bytes(sock, (char *)data, sizeof(int)); - *data = ntohl(*data); -} - -int time_read_int(int sock, int * data) -{ - if (time_read_bytes(sock, (char *)data, sizeof(int)) == -1) { - return -1; - } - *data = ntohl(*data); - return 0; -} - -/* read a string. Returns the length of the string. - transfer through the socket. - but the string in buffer might have been truncated. - the returned string is '\0' terminated */ - -int read_string(int sock, char *data, int maxlen) -{ - int len; - read_int(sock, &len); - if (len == 0) - { - data[0] = 0; - return 0; - } - if (len < maxlen) - { - read_bytes(sock, data, len); - data[len] = 0; - } - else - { - int i; - char tmp; - read_bytes(sock, data, maxlen-1); - data[maxlen-1] = 0; - for (i = 0; i < len - maxlen + 1; i ++) /* discard extra data */ - read_byte(sock, &tmp); - } - return len; -} - - -/* write_byte: - write a byte to socket sock */ - -void write_byte(int sock, char data) -{ - write_bytes(sock, &data, 1); -} - -/* write_short: - byte order convert the short integer in data and write to socket sock */ - -void write_short(int sock, short data) -{ - short val = htons(data); - write_bytes(sock, (char *)&val, sizeof(short)); -} - -/* write_int: - byte order convert the integer in data and write to socket sock */ -void write_int(int sock, int data) -{ - int val = htonl(data); - write_bytes(sock, (char *)&val, sizeof(int)); -} - -int time_write_int(int sock, int data) -{ - int val = htonl(data); - return time_write_bytes(sock, (char *)&val, sizeof(int)); -} - -/* write a string in data to socket sock, the string is led by a length */ - -void write_string(int sock, char *data) -{ - int len =ACE_OS::strlen (data); - - write_int(sock, len); - write_bytes(sock, data, len); -} - diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h deleted file mode 100644 index 640037cbd5c..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/fileio.h +++ /dev/null @@ -1,100 +0,0 @@ -/* $Id$ */ -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -/* data structure used by StatFile() */ - -#ifndef _MPEG_FILE_IO_H -#define _MPEG_FILE_IO_H - -struct StatBuf -{ - unsigned short mode; - long size; - char uid[32]; - char gid[32]; - char ctime[32]; -}; - -/* protocol of functions defined in shared.c */ - -int StatFile(char *filename, struct StatBuf * sb); - - - -/* Following read...()'s would exit(1) if requested bytes can not be - read, and EOF or error other than EINTR, EAGAIN or EWOULDBLOCK is - encountered */ - -void read_bytes(int s, char * buf, int size); - -void read_byte(int sock, char * data); - -void read_short(int sock, short * data); - -void read_int(int sock, int * data); - -int read_string(int sock, char *data, int maxlen); /* returns the length of a stream */ - - -/* Following write...()'s would exit(1) if requested bytes can not - be written to socket because of error has happened*/ - -void write_bytes(int sock, char * data, int len); - -void write_byte(int sock, char data); - -void write_short(int sock, short data); - -void write_int(int sock, int data); - -void write_string(int sock, char *data); - - -/* following returns: 0 -- succ, -1 -- failed. - time_read*() will wait at most 5 seconds before they return */ - -int time_read_bytes(int s, char * buf, int size); - -int time_read_int(int sock, int * data); - -int time_write_bytes(int sock, char * data, int len); - -int time_write_int(int sock, int data); - - -/* Following read...()'s would return 0/-1 if requested bytes can not - be read, and EOF (return 0) or error (return -1) other than EINTR, - EAGAIN or EWOULDBLOCK is encountered */ - -int wait_read_bytes(int s, char *buf, int size); - - -/* Following write...()'s would return 0/-1 if requested bytes can not - be written and error (return -1) other than EINTR, EAGAIN or is - encountered */ - -int wait_write_bytes(int s, char *buf, int size); - -#endif /* _MPEG_FILE_IO_H */ diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.cpp deleted file mode 100644 index 7458bb9ea02..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* $Id$ */ - -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -#include <stdio.h> -#include <limits.h> /* INT_MIN, INT_MAX are defined here */ -#include <errno.h> -#include <stdlib.h> -#include <string.h> -/* -#include <stdlib.h> -#include <sys/time.h> -#include <sys/types.h> -*/ -#include "filters.h" -#include "ace/OS.h" - -ACE_RCSID(mpeg_shared, filters, "$Id$") - -#define BUFSIZE 256 -#define maxval(a,b) ((a) > (b) ? (a) : (b)) -#define minval(a,b) ((a) < (b) ? (a) : (b)) - -static float FLOAT_MIN = (float)INT_MIN; -static float FLOAT_MAX = (float)INT_MAX; - -AverageFilter * NewAverageFilter(int nsamples) -{ - AverageFilter * f; - f = (AverageFilter *) ACE_OS::malloc(sizeof(*f)); - if (f == NULL) - return NULL; - f->type = FILTER_AVERAGE; - f->nsamples = nsamples; - f->buf = (double *)ACE_OS::malloc(nsamples * sizeof(double)); - if (f->buf == NULL) { - ACE_OS::free(f); - return NULL; - } - f->count = 0; - f->ptr = 0; - f->sum = 0; - return f; -} - -AverageFilter * ResetAverageFilter(AverageFilter *f, int nsamples) -{ - if (f->nsamples != nsamples) { - ACE_OS::free(f->buf); - f->nsamples = nsamples; - f->buf = (double *)ACE_OS::malloc(nsamples * sizeof(double)); - if (f->buf == NULL) { - ACE_OS::free(f); - return NULL; - } - } - f->count = 0; - f->ptr = 0; - f->sum = 0; - return f; -} - -void FreeAverageFilter(AverageFilter * f) -{ - ACE_OS::free(f->buf); - ACE_OS::free(f); -} - -double DoAverageFilter(AverageFilter *f, double value) -{ - int offset; - double oldval = f->buf[f->ptr]; - f->buf[f->ptr] = value; - f->ptr = (f->ptr + 1) % f->nsamples; - f->sum += value; - if (f->count >= f->nsamples) { - f->sum -= oldval; - } - else { - f->count ++; - } - return (double)(f->sum) / (double)f->count; -} - - -LowPassFilter * NewLowPassFilter(double Rvalue) -{ - LowPassFilter * f; - f = (LowPassFilter *)ACE_OS::malloc(sizeof(*f)); - if (f == NULL) { - return NULL; - } - if (Rvalue > 1.0) { - Rvalue = 1.0; - } - else if (Rvalue < 0.0) { - Rvalue = 0.0; - } - f->type = FILTER_LOWPASS; - f->count = 0; - f->maxcount = (int)(1.0 / maxval(Rvalue, 0.0001)); - f->R = Rvalue; - f->result = FLOAT_MIN; - return f; -} - -LowPassFilter * ResetLowPassFilter(LowPassFilter * f, double Rvalue) -{ - if (Rvalue > 1.0) { - Rvalue = 1.0; - } - else if (Rvalue < 0.0) { - Rvalue = 0.0; - } - f->count = 0; - f->maxcount = (int)(1.0 / maxval(Rvalue, 0.0001)); - f->R = Rvalue; - f->result = FLOAT_MIN; - return f; -} - -void FreeLowPassFilter(LowPassFilter * f) -{ - ACE_OS::free(f); -} - -double DoLowPassFilter(LowPassFilter * f, double value) -{ - if (f->count <= f->maxcount) { - if (!f->count) { - f->count ++; - return (f->result = value); - } - f->count ++; - return (f->result = (1.0 - (1.0/(double)f->count)) * f->result + - (1.0/(double)f->count) * value); - } - return (f->result = (1.0 - f->R) * f->result + f->R * value); -} - -MedianFilter * NewMedianFilter(int nsamples) -{ - int minv = 0, maxv = 1; - MedianFilter * f; - f = (MedianFilter *) ACE_OS::malloc(sizeof(*f)); - if (f == NULL) - return NULL; - f->type = FILTER_MEDIAN; - f->nsamples = nsamples; - f->max = maxval(maxv, minv); - f->min = minval(maxv, minv); - f->statsize = f->max - f->min + 1; - f->buf = (int *)ACE_OS::malloc(nsamples * sizeof(int)); - if (f->buf == NULL) { - ACE_OS::free(f); - return NULL; - } - f->stat = (int *)ACE_OS::malloc(f->statsize * sizeof(int)); - if (f->stat == NULL) { - ACE_OS::free(f->buf); - ACE_OS::free(f); - return NULL; - } - f->count = 0; - f->ptr = 0; - f->med = 0; - f->below = 0; - memset(f->stat, 0, f->statsize * sizeof(int)); - return f; -} - -MedianFilter * ResetMedianFilter(MedianFilter * f, int nsamples) -{ - if (f->nsamples != nsamples) { - ACE_OS::free(f->buf); - f->nsamples = nsamples; - f->buf = (int *)ACE_OS::malloc(nsamples * sizeof(int)); - if (f->buf == NULL) { - ACE_OS::free(f); - return NULL; - } - } - f->count = 0; - f->ptr = 0; - f->med = 0; - f->below = 0; - memset(f->stat, 0, f->statsize * sizeof(int)); - return f; -} - -void FreeMedianFilter(MedianFilter * f) -{ - ACE_OS::free(f->buf); - ACE_OS::free(f->stat); - ACE_OS::free(f); -} - -double DoMedianFilter(MedianFilter *f, double pvalue) -{ - int value = (int)pvalue; - int offset; - int oldval = f->buf[f->ptr]; - if (value > f->max) { - int * oldstat = f->stat; - int oldsize = f->statsize; - f->max = value + 10; - f->statsize = f->max - f->min + 1; - f->stat = (int *)ACE_OS::malloc(f->statsize * sizeof(int)); - if (f->stat == NULL) { - fprintf(stderr, "MedianFilter Failed to extend up stat to % items", - f->statsize); - ACE_OS::perror (""); - ACE_OS::exit (1); - } - memset((char *)(f->stat) + sizeof(int) * oldsize, 0, - sizeof(int) * (f->statsize - oldsize)); - ACE_OS::memcpy (f->stat, oldstat, oldsize * sizeof(int)); - } - else if (value < f->min) { - int * oldstat = f->stat; - int oldsize = f->statsize; - f->min = value - 10; - f->statsize = f->max - f->min + 1; - f->stat = (int *)ACE_OS::malloc(f->statsize * sizeof(int)); - if (f->stat == NULL) { - fprintf(stderr, "MedianFilter Failed to extend down stat to % items", - f->statsize); - ACE_OS::perror (""); - ACE_OS::exit (1); - } - memset(f->stat, 0, sizeof(int) * (f->statsize - oldsize)); - ACE_OS::memcpy ((char *)(f->stat) + sizeof(int) * (f->statsize - oldsize), - oldstat, sizeof(int) * oldsize); - f->med += f->statsize - oldsize; - } - f->buf[f->ptr] = value; - f->ptr = (f->ptr + 1) % f->nsamples; - offset = value - f->min; - if (offset < 0) { - offset = 0; - } - else if (offset >= f->statsize) { - offset = f->statsize - 1; - } - f->stat[offset] ++; - if (offset < f->med) { - f->below ++; - } - if (f->count >= f->nsamples) { - offset = oldval - f->min; - if (offset < 0) { - offset = 0; - } - else if (offset >= f->statsize) { - offset = f->statsize - 1; - } - f->stat[offset] --; - if (offset < f->med) { - f->below --; - } - } - else { - f->count ++; - } - oldval = f->count >> 1; - if (f->below > oldval) { - offset = f->med - 1; - while (offset >= 0 && (f->below - f->stat[offset]) > oldval) { - f->below -= f->stat[offset]; - offset --; - } - f->med = offset + 1; - } - else { - offset = f->med; - while (offset < f->statsize && (f->below + f->stat[offset]) <= oldval) { - f->below += f->stat[offset]; - offset ++; - } - f->med = offset; - } - return (double)(f->med + f->min); -} - -Filter * NewFilter(int type, int parameter) -{ - switch (type) { - case FILTER_LOWPASS: - return (Filter *)NewLowPassFilter(1.0/(double)parameter); - case FILTER_MEDIAN: - return (Filter *)NewMedianFilter(parameter); - case FILTER_AVERAGE: - return (Filter *)NewAverageFilter(parameter); - default: - break; - } - return NULL; -} - -Filter * ResetFilter(Filter * f, int parameter) -{ - switch (f->type) { - case FILTER_LOWPASS: - return (Filter *)ResetLowPassFilter((LowPassFilter *)f, 1.0/(double)parameter); - case FILTER_MEDIAN: - return (Filter *)ResetMedianFilter((MedianFilter *)f, parameter); - case FILTER_AVERAGE: - return (Filter *)ResetAverageFilter((AverageFilter *)f, parameter); - default: - break; - } - return NULL; -} - -void FreeFilter(Filter * f) -{ - switch (f->type) { - case FILTER_LOWPASS: - FreeLowPassFilter((LowPassFilter *)f); - break; - case FILTER_MEDIAN: - FreeMedianFilter((MedianFilter *)f); - break; - case FILTER_AVERAGE: - FreeAverageFilter((AverageFilter *)f); - break; - default: - break; - } -} - -double DoFilter(Filter *f, double value) -{ - switch (f->type) { - case FILTER_LOWPASS: - return DoLowPassFilter((LowPassFilter *)f, value); - break; - case FILTER_MEDIAN: - return DoMedianFilter((MedianFilter *)f, value); - break; - case FILTER_AVERAGE: - return DoAverageFilter((AverageFilter *)f, value); - break; - default: - break; - } - return FLOAT_MIN; -} diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h deleted file mode 100644 index 50950277478..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/filters.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $Id$ */ -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ - -#if !defined (AV_FILTERS_H) -#define AV_FILTERS_H - -#define FILTER_LOWPASS 0 -#define FILTER_MEDIAN 1 -#define FILTER_AVERAGE 2 - -typedef struct MedianFilter { - int type; - int * buf; - int nsamples; - int count; - int ptr; - int * stat; - int statsize; - int max, min; - int med; /* median offset to stat */ - int below; /* total points below the med entry */ -} MedianFilter; - -typedef struct LowPassFilter { - int type; - int count; - int maxcount; - double R; - double result; -} LowPassFilter; - -typedef struct AverageFilter { - int type; - double * buf; - int nsamples; - int ptr; - double sum; - int count; -} AverageFilter; - -typedef union Filter { - int type; - MedianFilter m; - AverageFilter a; - LowPassFilter l; -} Filter; - -Filter * NewFilter(int type, int parameter); -Filter * ResetFilter(Filter * f, int parameter); -void FreeFilter(Filter * f); -double DoFilter(Filter *f, double value); - -MedianFilter * NewMedianFilter(int nsamples); -MedianFilter * ResetMedianFilter(MedianFilter * f, int nsamples); -void FreeMedianFilter(MedianFilter * f); -double DoMedianFilter(MedianFilter *f, double value); - -AverageFilter * NewAverageFilter(int nsamples); -AverageFilter * ResetAverageFilter(AverageFilter * f, int nsamples); -void FreeAverageFilter(AverageFilter * f); -double DoAverageFilter(AverageFilter *f, double value); - -LowPassFilter * NewLowPassFilter(double R); -LowPassFilter * ResetLowPassFilter(LowPassFilter * f, double R); -void FreeLowPassFilter(LowPassFilter * f); -double DoLowPassFilter(LowPassFilter *f, double value); - -#endif /* AV_FILTERS_H */ diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.cpp deleted file mode 100644 index 254daea63ae..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/* $Id$ */ - -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -#include <stdio.h> -#include <errno.h> -#include <stdlib.h> -#include <time.h> -#include <unistd.h> -#include <limits.h> -#ifdef __svr4__ -#include <sys/systeminfo.h> -#endif -#ifdef _HPUX_SOURCE -#include <sys/rtprio.h> -#elif defined(__svr4__) -#include <sys/priocntl.h> -#include <sys/rtpriocntl.h> -#include <sys/tspriocntl.h> -#endif - -#include <sys/types.h> -#include <sys/ipc.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/sem.h> -#include <signal.h> -#include <sys/wait.h> -#include <sys/param.h> -#include <string.h> -#include "routine.h" - -ACE_RCSID(mpeg_shared, routine, "$Id$") - -#define TEST_TYPE 1 -#define SIGSETMASK 0 -#define stacksize 10000 -#define TIME_ROUND 4000 -#define BLOCK_NUM 5 -#define DELTA_MSEC 20 - -union semun sem_union; - -int get_hostname(char *name, int len) -{ -#ifdef __svr4__ - if (sysinfo(SI_HOSTNAME, name, len) == -1) return -1; - else return 0; -#else - return ACE_OS::hostname(name, len); -#endif -} - -long get_usec(void) -{ - struct timeval tp; - struct timezone tzp; - int err; - if (err=gettimeofday(&tp, &tzp)) - { - return 0; - } - else { - /* - return ((long)1000000)*(tp.tv_sec%TIME_ROUND) + (tp.tv_usec); - */ - return ((long)1000000)*(tp.tv_sec) + (tp.tv_usec); - } -} - -long get_msec(void) -{ - struct timeval tp; - struct timezone tzp; - int err; - if (err=gettimeofday(&tp, &tzp)) - { - return 0; - } - else - { - return ((long)1000)*(tp.tv_sec) + (tp.tv_usec / 1000); - } -} - -long get_sec(void) -{ - struct timeval tp; - struct timezone tzp; - int err; - if (err=gettimeofday(&tp, &tzp)) - { - return 0; - } - else - { - return tp.tv_sec; - } -} - -/* returns the difference of the two usec time values */ - -long get_duration(long val1, long val2) -{ - /* - return val2>=val1 ? val2-val1 : (val2+TIME_ROUND-val1); - */ - return val2>=val1 ? val2-val1 : ((LONG_MAX - val1) + (val2 - LONG_MIN) + 1); -} - -#ifdef LINUX -#else -int usleep(unsigned int usec) -{ - struct timeval val; - - if (usec <= 0) return -1; - val.tv_sec = usec / 1000000; - val.tv_usec = usec % 1000000; - if (select(0, NULL, NULL, NULL, &val) == -1 && errno != 4) - { - ACE_OS::perror ("sleep with select"); - ACE_OS::exit (1); - } - return 0; -} -#endif - -void beep(void) -{ - fprintf(stderr, "\007"); -} - -#ifndef FreeBSD -#include <malloc.h> -#endif -#include <sys/shm.h> - -void remove_shmem_id(int id) -{ - ACE_OS::shmctl (id, IPC_RMID, NULL); -#if 0 - /* weird also on some sunOs4 machines */ - /* weird, HPUX always report error on this operation */ - if (errno) - { - fprintf(stderr, "shmctl shm_id:%d to IPC_RMID error:", id); - ACE_OS::perror (""); - } -#endif -} - -char * creat_shared_mem_id(int size, int * id) -{ - char * shm; - int shm_id; - - shm_id = ACE_OS::shmget (IPC_PRIVATE, size, IPC_CREAT | 0666); - if (shm_id == -1) - { - shm_id = ACE_OS::shmget (IPC_PRIVATE, 0, IPC_CREAT | 0666); - if (shm_id == -1) - { - ACE_OS::perror ("Shared MEM shmget1 error"); - ACE_OS::exit (1); - } - else - { - if (shmctl(shm_id, IPC_RMID, NULL) == -1) - { - ACE_OS::perror ("Shared MEM shmctl error"); - ACE_OS::exit (1); - } - shm_id = ACE_OS::shmget (IPC_PRIVATE, 0, IPC_CREAT | 0666); - if (shm_id == -1) - { - ACE_OS::perror ("Shared MEM shmget2 error"); - ACE_OS::exit (1); - } - } - } - shm = (char *)shmat(shm_id, (char *)0, 0); - if ((int)shm == -1) - { - ACE_OS::perror ("Shared MEM shmat error"); - ACE_OS::exit (1); - } - *id = shm_id; - return shm; -} - -char * creat_shared_mem(int size) -{ - int shm_id; - char * shm = creat_shared_mem_id(size, &shm_id); - remove_shmem_id(shm_id); - return shm; -} - -void remove_shared_mem(char *ptr) -{ - ACE_OS::shmdt (ptr); -} - -#define SEM_NUM 6 -static int semId = -1; -static int masterPid = -1; -static int nextSem = -1; - -void enter_cs(int semaphore_id) -{ - struct sembuf sop; - sop.sem_num = semaphore_id; - sop.sem_op = -1; - sop.sem_flg = 0; - while (ACE_OS::semop(semId, &sop, 1) == -1) - { - if (errno == EINTR) - continue; - fprintf(stderr, "semop(enter_cs) error: pid=%d",ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::exit (1); - } -} - -void leave_cs(int semaphore_id) -{ - struct sembuf sop; - sop.sem_num = semaphore_id; - sop.sem_op = 1; - sop.sem_flg = 0; - while (ACE_OS::semop(semId, &sop, 1) == -1) - { - if (errno == EINTR) - continue; - fprintf(stderr, "semop(leave_cs) error, pid=%d",ACE_OS::getpid ()); - ACE_OS::perror (""); - ACE_OS::exit (1); - } -} - -int creat_semaphore(void) -{ - int i; - int sem_val; - int semaphore_id; - if (semId == -1) { - semId = ACE_OS::semget (IPC_PRIVATE, SEM_NUM, IPC_CREAT | 0666); - if (semId == -1) { - ACE_OS::perror ("Semaphore semget error"); - ACE_OS::exit (1); - } - masterPid =ACE_OS::getpid (); - nextSem = 0; - } - else if (masterPid !=ACE_OS::getpid ()) { - fprintf(stderr, "Error: this creat_semaphore() assumes semaphores are allocated\n"); - fprintf(stderr, " only in single process %d, while current pid=%d\n", - masterPid,ACE_OS::getpid ()); - ACE_OS::exit (1); - } - semaphore_id = nextSem ++; - if (semaphore_id >= SEM_NUM) { - fprintf(stderr, "Error: all of %d semaphores used up.\n", SEM_NUM); - ACE_OS::exit (1); - } - sem_val = ACE_OS::semctl (semId, semaphore_id, GETVAL, sem_union); -/* - fprintf(stderr, "Initial semaphore value: %d\n", sem_val); -*/ - if (sem_val == 0) - leave_cs(semaphore_id); - return semaphore_id; -} - -void delete_semaphore() -{ - if (masterPid ==ACE_OS::getpid () && semId >= 0) { - sem_union.val = 0; - ACE_OS::semctl (semId, 0, IPC_RMID, sem_union); - } else { - if (masterPid !=ACE_OS::getpid ()) - fprintf(stderr, "Pid %d not supposed to remove semId created by pid %d\n", - ACE_OS::getpid (), masterPid); - else - fprintf(stderr, "The semaphore has been deleted.\n"); - } - return; -} - -void remove_semaphore(int sid) -{ - return; - // ACE_OS::semctl (semId, semaphore_id, IPC_RMID, 0); -} - -void remove_all_semaphores (void) -{ - sem_union.val = 0; - ACE_OS::semctl (semId,0, IPC_RMID, sem_union); - return; -} - -int get_semval(int sid) -{ - int val, val1 = 0; - errno = 0; - sem_union.val = 0; - val = ACE_OS::semctl (semId, sid, GETVAL, sem_union); - if (val == -1) { - ACE_OS::perror ("getting value of a semaphore"); - ACE_OS::exit (1); - } - /* - if (val == 0) { - fprintf(stderr, "pid %d to call ACE_OS::semctl (%d, 0, GETZCNT)\n",ACE_OS::getpid (), sid); - sem_union.val = 0; - val = ACE_OS::semctl (semId, 0, GETZCNT, 0); - if (val == -1) { - ACE_OS::perror ("getting semzcnt of a semaphore"); - ACE_OS::exit (1); - } - - fprintf(stderr, "pid %d to call ACE_OS::semctl (%d, 0, GETNCNT)\n",ACE_OS::getpid (), sid); - usleep(10000000); - sem_union.val = 0; - val1 = ACE_OS::semctl (semId, sid, GETNCNT, sem_union); - if (val1 == -1) { - ACE_OS::perror ("getting semncnt of a semaphore"); - } - fprintf(stderr, "pid %d to called ACE_OS::semctl (GETNCNT)\n",ACE_OS::getpid ()); - - fprintf(stderr, "Semval val %d, val1 %d\n", val, val1); - return (0-(val + val1)); - } - else - */ - return val; -} - -void get_full_path(char *filename, char * buffer, int bufsize) -{ - char path[MAXPATHLEN]; - - path[0] = 0; - - if (*filename == '/') - strncpy(path, filename, MAXPATHLEN); - else if (*filename == '~') - { - char * env = getenv("HOME"); - if (env != NULL) - { - strncpy(path, env, MAXPATHLEN); - strncat(path, filename+1, MAXPATHLEN -ACE_OS::strlen (path)); - } - else - strncpy(path, filename, MAXPATHLEN); - } - else /* from current dir */ - { - getcwd(path, MAXPATHLEN); - if (errno) - strncpy(path, filename, MAXPATHLEN); - else - { - path[MAXPATHLEN-4] = 0; - strcat(path, "/"); - strncat(path, filename, MAXPATHLEN -ACE_OS::strlen (path)); - } - } - path[MAXPATHLEN-1] = 0; - strncpy(buffer, path, bufsize); - buffer[bufsize-1] = 0; - /* - fprintf(stderr, "%s extended to %s\n", filename, buffer); - */ -} - -void setsignal(int sig, void (func)(int)) -{ -#ifdef _HPUX_SOURCE - struct sigvec sv; - - sv.sv_handler = func; - sv.sv_mask = 0; - sv.sv_flags = 0; - if (sigvector (sig, &sv, (struct sigvec *) NULL) == -1) { - fprintf(stderr, "sigvector(%d) error", sig); - ACE_OS::perror (""); - ACE_OS::exit (1); - } -#elif defined(__svr4__) || defined(IRIX) - if (sigset(sig, func) == SIG_ERR) { - fprintf(stderr, "sigset(%d,func) error", sig); - ACE_OS::perror (""); - ACE_OS::exit (1); - } -#elif defined(sun) || defined(FreeBSD) || defined(ULTRIX) || defined(LINUX) - { - struct sigaction act; - act.sa_handler = func; -#ifdef FreeBSD - act.sa_flags = SV_INTERRUPT; -#else - act.sa_flags =/* SA_INTERRUPT;*/ SA_RESTART; -#endif - // @@ Naga commented this line. - // act.sa_mask = 0; - if (!sigaction(sig, &act, NULL)) return; - fprintf(stderr, "sigaction(%d,...) error", sig); - ACE_OS::perror (""); - ACE_OS::exit (1); - } - /* - if (signal(sig, func) == SIG_ERR) { - fprintf(stderr, "signal(%d,func) error", sig); - ACE_OS::perror (""); - ACE_OS::exit (1); - } - */ -#else - fprintf(stderr, - "Error: code for setsignal(%d,func) is missing in source/mpeg_shared/routine.cpp\n", - sig); - ACE_OS::exit (1); -#endif -} - -/* set to 'pri': 0 -lowest RT, higher value higher RT priority. -1 - Time Sharing. - For HPUX, 0 -> 127, 1 -> 127, ..., pri -> 127 - pri; - For Solaris, -> 0, 1 -> 1, pri -> pri; - - The function returns 0 on success, -1 on failure - */ -int SetRTpriority(char *msg, int pri) -{ - if (pri >= 0) { -#ifdef _HPUX_SOURCE - if (rtprio(0, 127 - pri) == -1) - { - fprintf(stderr, "%s fails to be set to RT priority %d", msg, 127 - pri); - ACE_OS::perror (""); - return -1; - } - return 0; -#elif defined(__svr4__) - pcinfo_t pci; - pcparms_t pcp; - rtparms_t * rtp = (rtparms_t *)pcp.pc_clparms; - strcpy(pci.pc_clname, "RT"); - if (priocntl(P_PID, P_MYID, PC_GETCID, (char *)&pci) == -1) { - fprintf(stderr, "%s priocntl(PC_GETCID) failed for RT pri %d", msg, pri); - ACE_OS::perror (""); - return -1; - } - pcp.pc_cid = pci.pc_cid; - rtp->rt_pri = pri; - rtp->rt_tqsecs = 0; - rtp->rt_tqnsecs = 10000000; /* 10 (ten) milliseconds */ - if (priocntl(P_PID, P_MYID, PC_SETPARMS, (char *)&pcp) == -1) { - fprintf(stderr, "%s priocntl(PC_SETPARMS) failed for RT pri %d", msg, pri); - ACE_OS::perror (""); - return -1; - } - return 0; -#else - fprintf(stderr, "%s warning: RT priority not available on this arch.\n", msg); - return -1; -#endif - } - else { /* set to TS priority */ -#ifdef _HPUX_SOURCE - if (rtprio(0, RTPRIO_RTOFF) == -1) { - fprintf(stderr, "%s fails to be set to RTPRIO_RTOFF", msg); - ACE_OS::perror (""); - return -1; - } - return 0; -#elif defined(__svr4__) - pcinfo_t pci; - pcparms_t pcp; - tsparms_t * tsp = (tsparms_t *)pcp.pc_clparms; - strcpy(pci.pc_clname, "TS"); - if (priocntl(P_PID, P_MYID, PC_GETCID, (char *)&pci) == -1) { - fprintf(stderr, "%s priocntl(PC_GETCID) failed for TS priority", msg); - ACE_OS::perror (""); - return -1; - } - pcp.pc_cid = pci.pc_cid; - tsp->ts_uprilim = 0; - tsp->ts_upri = 0; - if (priocntl(P_PID, P_MYID, PC_SETPARMS, (char *)&pcp) == -1) { - fprintf(stderr, "%s priocntl(PC_SETPARMS) failed for TS priority", msg); - ACE_OS::perror (""); - return -1; - } - return 0; -#endif - } -} diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h deleted file mode 100644 index 6afb41a69ee..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/routine.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $Id$ */ -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -/* routine.c */ -#ifndef _MPEG_ROUTINE_H -#define _MPEG_ROUTINE_H - -#include "include/common.h" -#ifdef LINUX -#else -int usleep(unsigned int usec); -#endif -void beep(void); -int get_hostname(char *name, int len); -long get_usec(void); -long get_msec(void); -long get_sec(void); -long get_duration(long valstart, long valstop); -void remove_shmem_id(int id); -char * creat_shared_mem_id(int size, int * id); -char * creat_shared_mem(int size); -void remove_shared_mem(char *ptr); -void enter_cs(int semaphore_id); -void leave_cs(int semaphore_id); -int creat_semaphore(void); -void remove_semaphore(int sid); -void remove_all_semaphores (void); -int get_semval(int sid); -void get_full_path(char *filename, char * buffer, int bufsize); -void setsignal(int sig, void (func)(int)); -int SetRTpriority(char *msg, int pri); - -#endif /* _MPEG_ROUTINE_H */ diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.cpp deleted file mode 100644 index ce036d608f8..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/* $Id$ */ - -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -#include <string.h> -#include "sendpt.h" - -ACE_RCSID(mpeg_shared, sendpt, "$Id$") - -/* parameters: - pat -- pattern - buf -- buffer for holding sendpattern computed; - len -- length of pattern and send pattern (number of frames); - f -- number of frames to send (represented by result send pattern); -*/ -void ComputeSendPattern(char * pat, char * buf, int len, int f) -{ - memset(buf, 0, len); - if (f >= len) - { - memset(buf, 1, len); - } - else if (f <= 1) - { - buf[0] = 1; - } - else - { - int i, is = 0, ps = 0, bs = 0; - - memset(buf, 1, len); - for (i = 0; i < len; i++) - { - if (pat[i] == 'I') - is ++; - else if (pat[i] == 'P') - ps ++; - else /* B frame */ - bs ++; - } - f = len - f; /* number of frames to drop */ - if (f < bs) /* drops only B frames */ - { - double scale = (double)bs / (double)f; - int ptr = 0, ptr1 = 0; - for (i = 0; i < len; i ++) - { - if (pat[i] == 'B') - { - if ( ptr == (int) ((double)ptr1 * scale + 0.5)) - { - buf[i] = 0; - ptr1 ++; - } - ptr ++; - } - } - goto endOfCompute; - } - - /* drop all B frames */ - for (i = 0; i < len; i ++) - if (pat[i] == 'B') - buf[i] = 0; - - if (f == bs) - goto endOfCompute; - - if (f > bs && f < bs + ps) /* drop also some P frames */ - { - int ptr = len - 1; - for (i = 0; i < is; i ++) - { - int j; - for (j = 0; j < (f - bs) / is; j ++) - { - while (pat[ptr] != 'P') ptr --; - buf[ptr] = 0; - ptr --; - } - while (pat[ptr] != 'I') ptr --; - } - ptr = len - 1; - for (i = 0; i < (f - bs) % is; i ++) - { - while (pat[ptr] != 'P' || buf[ptr] == 0) ptr --; - buf[ptr] = 0; - while (pat[ptr] != 'I') ptr --; - } - goto endOfCompute; - } - - /* drop all P frames */ - for (i = 0; i < len; i ++) - if (pat[i] == 'P') - buf[i] = 0; - - if (f > bs + ps) /* needs to drop some I frames */ - { - double scale = (double)is / (double)(f - bs - ps); - int ptr = 0, ptr1 = 0; - for (i = 0; i < len; i ++) - { - if (pat[i] == 'I') - { - if ( ptr == (int) ((double)ptr1 * scale + 0.5)) - { - buf[i] = 0; - ptr1 ++; - } - ptr ++; - } - } - goto endOfCompute; - } - } - endOfCompute:; -} diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.h deleted file mode 100644 index 60935fae8ed..00000000000 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_shared/sendpt.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id$ */ -/* Copyright (c) 1995 Oregon Graduate Institute of Science and Technology - * P.O.Box 91000-1000, Portland, OR 97291, USA; - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of O.G.I. not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. O.G.I. makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * O.G.I. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING - * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL - * O.G.I. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Author: Shanwei Cen - * Department of Computer Science and Engineering - * email: scen@cse.ogi.edu - */ -/* parameters: - pat -- pattern - buf -- buffer for holding sendpattern computed; - len -- length of pattern and send pattern (number of frames); - f -- number of frames to send (represented by result send pattern); -*/ -#include "ace/OS.h" - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ - -void ComputeSendPattern(char * pat, char * buf, int len, int f); - |