diff options
author | sumedh <sumedh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-06 00:11:49 +0000 |
---|---|---|
committer | sumedh <sumedh@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-03-06 00:11:49 +0000 |
commit | 82c1d0b62e1d5875b7d4957ca6dc92f9ac45d690 (patch) | |
tree | ea5b41b8789112ce891784e1209cdb6c8d9c0a83 | |
parent | c4e488e5d562359376a64b55a734cb2f4c77ae5d (diff) | |
download | ATCD-82c1d0b62e1d5875b7d4957ca6dc92f9ac45d690.tar.gz |
*** empty log message ***
3 files changed, 268 insertions, 177 deletions
diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp index 4a4d7a4f9ff..5472bf7367e 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp @@ -11,3 +11,100 @@ int Mpeg_Global::drift_ppm = 0; /* clock drift in ppm */ int Mpeg_Global::session_limit = SESSION_NUM; int Mpeg_Global::session_num = 0; int Mpeg_Global::rttag = 0; + +// initialize the nasty int's, doubles and their friends +Video_Global::Video_Global () +{ + live_source = 0; + video_format = 0; + + pkts_sent = 0; + time_t start_time = 0; + + conn_tag = 0; + + normalExit = 1; + + serviceSocket = 0; + videoSocket = -1; + + ACE_OS::memset (videoFile, + 0, + PATH_SIZE); + + FILE *fp = 0; + + needHeader = 0; + + lastRef [0] = lastref [1] = 0; + + lastRefPtr = 0; + currentUPF = 0; + addedUPF = 0; + addedSignals = 0; + VStimeAdvance = 0; + fps = 0; /* current frames-per-second: playback speed */ + frameRateLimit = 0; + + VideoPacket * packet = 0; + packetBufSize = 0; + msgsn = 0; + packetsn = 0; + msgsize = 0; + + precmd = 0; + cmd = 0; + cmdsn = 0; + nextFrame = 0; + nextGroup = 0; + firstPatternSize = 0; + firstSendPattern = 0; + sendPatternGops = 0; + ACE_OS::memset (sendPattern, + 0, + PATTERN_SIZE); + +#ifdef STAT + framesSent = 0; +#endif + + fileSize = 0; + maxS = 0; + maxG = 0; + maxI = 0; + maxP = 0; + maxB = 0; + minS = 0x7fffffff; + minG = 0x7fffffff; + minI = 0x7fffffff; + minP = 0x7fffffff; + minB = 0x7fffffff; + + numS = 0; + numG = 0; + numF = 0; + numI = 0; + numP = 0; + numB = 0; + + averageFrameSize = 0; + horizontalSize = 0; + verticalSize = 0; + pelAspectRatio = 0; + pictureRate = 0; + vbvBufferSize = 0; + firstGopFrames = 0; + patternSize = 0; + + ACE_OS::memset (pattern, + 0, + PATTERN_SIZE); + + // struct pointers + systemHeader = 0; + + gopTable = 0; + + frameTable = 0; + +} diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h index e2796239ac6..2b1c1c879a5 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h @@ -16,6 +16,38 @@ #define STATE_DATA 3 #define STATE_SINGLE 4 +#define min(a, b) ((a) > (b) ? (b) : (a)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +/* Start codes. */ + +#define READ_BLOCK_SIZE 512 +#define MAX_TIMER_ADJUST (100 * SPEEDUP_INV_SCALE) + +#define SEQ_END_CODE 0x000001b7 +#define SEQ_START_CODE 0x000001b3 +#define GOP_START_CODE 0x000001b8 +#define PICTURE_START_CODE 0x00000100 +#define SLICE_MIN_START_CODE 0x00000101 +#define SLICE_MAX_START_CODE 0x000001af +#define EXT_START_CODE 0x000001b5 +#define USER_START_CODE 0x000001b2 + + +#define FileRead(position, buf, size) \ + { \ + if (fseek(fp, (position), 0) == -1) \ + { \ + perror("VS error on fseek VideoFile"); \ + return (-1); \ + } \ + while (fread((buf), (size), 1, fp) == 0) \ + { if (errno == EINTR) { errno = 0; continue;}\ + perror("VS error on fread VideoFile"); \ + return (-1); \ + } \ + } + // Global definitions #include <sys/types.h> @@ -41,6 +73,111 @@ public: static int rttag; }; +class Video_Global +{ + public: + Video_Global (); + + int live_source; + int video_format; + + int pkts_sent; + time_t start_time; + + int conn_tag; + + int normalExit; + + int serviceSocket; + int videoSocket; + + char videoFile[PATH_SIZE]; + FILE *fp; + int needHeader; + int lastRef[2]; + int lastRefPtr; + int currentUPF; + int addedUPF; + int addedSignals; + int VStimeAdvance; + double fps; /* current frames-per-second: playback speed */ + double frameRateLimit; + + VideoPacket * packet; + int packetBufSize; + int msgsn; + int packetsn; + int msgsize; + + unsigned char precmd; + unsigned char cmd; + int cmdsn; + int nextFrame; + int nextGroup; + int firstPatternSize; + char *firstSendPattern; + int sendPatternGops; + char sendPattern [PATTERN_SIZE]; + +#ifdef STAT + char * framesSent; +#endif + + int fileSize; + int maxS; + int maxG; + int maxI; + int maxP; + int maxB; + int minS; + int minG; + int minI; + int minP; + int minB; + int numS; + int numG; + int numF; + int numI; + int numP; + int numB; + int averageFrameSize; + int horizontalSize; + int verticalSize; + int pelAspectRatio; + int pictureRate; + int vbvBufferSize; + int firstGopFrames; + int patternSize; + char pattern [PATTERN_SIZE]; + + struct SystemHeader + { + long offset; + int size; + } * systemHeader; + + struct GopTable + { + int systemHeader; + long offset; + int headerSize; + int size; + int totalFrames; + int previousFrames; + long firstIoffset; + } * gopTable; + + struct FrameTable + { + char type; + unsigned short size; + } * frameTable; + + +}; + +typedef ACE_TSS_SINGLETON <Video_Global, ACE_SYNCH_MUTEX> VIDEO_SINGLETON; + #endif /* define MPEG_GLOBAL_H */ diff --git a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp index 647f7581dcc..47628a93a4b 100644 --- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp +++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp @@ -48,155 +48,11 @@ #include "../mpeg_shared/sendpt.h" #include "proto.h" -#define min(a, b) ((a) > (b) ? (b) : (a)) -#define max(a, b) ((a) > (b) ? (a) : (b)) - -/* Start codes. */ - -#define READ_BLOCK_SIZE 512 -#define MAX_TIMER_ADJUST (100 * SPEEDUP_INV_SCALE) - -#define SEQ_END_CODE 0x000001b7 -#define SEQ_START_CODE 0x000001b3 -#define GOP_START_CODE 0x000001b8 -#define PICTURE_START_CODE 0x00000100 -#define SLICE_MIN_START_CODE 0x00000101 -#define SLICE_MAX_START_CODE 0x000001af -#define EXT_START_CODE 0x000001b5 -#define USER_START_CODE 0x000001b2 - -//extern int Mpeg_Global::drift_ppm; -//extern int Mpeg_Global::session_limit, Mpeg_Global::session_num; - -static int live_source = 0; -static int video_format; - -static int pkts_sent = 0; -static time_t start_time; - -static int conn_tag; - -static int normalExit = 1; - -static int serviceSocket; -static int videoSocket = -1; - -static char videoFile[PATH_SIZE]; -static FILE *fp; -static int needHeader = 0; -static int lastRef[2]; -static int lastRefPtr = 0; -static int currentUPF = 0; -static int addedUPF = 0; -static int addedSignals = 0; -static int VStimeAdvance; -static double fps; /* current frames-per-second: playback speed */ -static double frameRateLimit; - -static VideoPacket * packet = NULL; -static int packetBufSize; -static int msgsn = 0; -static int packetsn = 0; -static int msgsize; - -static unsigned char precmd, cmd; -static int cmdsn; -static int nextFrame; -static int nextGroup; -static int firstPatternSize; -static char * firstSendPattern = NULL; -static int sendPatternGops; -static char sendPattern[PATTERN_SIZE]; - -#ifdef STAT -static char * framesSent = NULL; -#endif - -static int fileSize = 0; -static int maxS = 0, maxG = 0, maxI = 0, maxP = 0, maxB = 0; -static int minS=0x7fffffff, minG = 0x7fffffff; -static int minI = 0x7fffffff, minP = 0x7fffffff, minB = 0x7fffffff; -static int numS = 0, numG = 0, numF, numI = 0, numP = 0, numB = 0; -static int averageFrameSize; -static int horizontalSize; -static int verticalSize; -static int pelAspectRatio; -static int pictureRate; -static int vbvBufferSize; -static int firstGopFrames = 0; -static int patternSize = 0; -static char pattern[PATTERN_SIZE]; - -static struct SystemHeader -{ - long offset; - int size; -} * systemHeader; -static struct GopTable -{ - int systemHeader; - long offset; - int headerSize; - int size; - int totalFrames; - int previousFrames; - long firstIoffset; -} * gopTable; -static struct FrameTable -{ - char type; - unsigned short size; -} * frameTable = NULL; - -#define FileRead(position, buf, size) \ - { \ - if (fseek(fp, (position), 0) == -1) \ - { \ - perror("VS error on fseek VideoFile"); \ - return (-1); \ - } \ - while (fread((buf), (size), 1, fp) == 0) \ - { if (errno == EINTR) { errno = 0; continue;}\ - perror("VS error on fread VideoFile"); \ - return (-1); \ - } \ - } - -/* -static void FileRead(long position, char * pbuf, int psize) -{ - int size = psize; - char * buf = pbuf; - if (psize == 0) - return; - - if (fseek(fp, position, 0) == -1) - { - perror("VS error on fseek VideoFile"); - exit(1); - } - - while (size > 0) - { - int sz = min(size, READ_BLOCK_SIZE); - if (size < psize) - usleep(10); - if (fread(buf, sz, 1, fp) == 0) - { - if (errno == EINTR) - continue; - perror("VS error on fread videoFile"); - exit(1); - } - buf += sz; - size -= sz; - } -} -*/ - static int CmdRead(char *buf, int psize) { - int res = wait_read_bytes(serviceSocket, buf, psize); + int res = wait_read_bytes (VIDEO_SINGLETON::instance ()->serviceSocket, + buf, + psize); if (res == 0) return(1); if (res == -1) { fprintf(stderr, "VS error on read cmdSocket, size %d", psize); @@ -208,9 +64,9 @@ static int CmdRead(char *buf, int psize) static void CmdWrite(char *buf, int size) { - int res = wait_write_bytes(serviceSocket, buf, size); + int res = wait_write_bytes(VIDEO_SINGLETON::instance ()->serviceSocket, buf, size); if (res == -1) { - if (errno != EPIPE) perror("VS writes to serviceSocket"); + if (errno != EPIPE) perror("VS writes to VIDEO_SINGLETON::instance ()->serviceSocket"); exit(errno != EPIPE); } } @@ -1220,7 +1076,7 @@ static int INITvideo(void) VERSION / 100, VERSION % 100, para.version / 100, para.version % 100); } - write_string(serviceSocket, errmsg); + write_string(VIDEO_SINGLETON::instance ()->serviceSocket, errmsg); exit(0); } cmdsn = para.sn; @@ -1240,7 +1096,7 @@ static int INITvideo(void) failureType = 101; goto failure; } - live_source = 1; + VIDEO_SINGLETON::instance ()->live_source = 1; fileSize =0x7fffffff; maxS = maxG = maxI = maxP = maxB = minS = minG = minI = minP = minB = 1; @@ -1292,7 +1148,7 @@ static int INITvideo(void) reply.patternSize = htonl(patternSize); strncpy(reply.pattern, pattern, PATTERN_SIZE); - reply.live = htonl(live_source); + reply.live = htonl(VIDEO_SINGLETON::instance ()->live_source); reply.format = htonl(video_format); CmdWrite((char *)&cmd, 1); @@ -1304,11 +1160,11 @@ static int INITvideo(void) { int tmpSocket = videoSocket; - if (live_source) StartPlayLiveVideo(); + if (VIDEO_SINGLETON::instance ()->live_source) StartPlayLiveVideo(); - videoSocket = serviceSocket; + videoSocket = VIDEO_SINGLETON::instance ()->serviceSocket; - if (live_source) { + if (VIDEO_SINGLETON::instance ()->live_source) { int frame = 0; SendPicture(&frame); } @@ -1321,7 +1177,7 @@ static int INITvideo(void) } videoSocket = tmpSocket; - if (live_source) StopPlayLiveVideo(); + if (VIDEO_SINGLETON::instance ()->live_source) StopPlayLiveVideo(); } return 0; @@ -1343,7 +1199,7 @@ static int INITvideo(void) failureType == 100 ? "failed to connect to live video source" : failureType == 101 ? "live MPEG2 not supported" : errmsg; - write_string(serviceSocket, msg); + write_string(VIDEO_SINGLETON::instance ()->serviceSocket, msg); exit(0); } } @@ -1379,7 +1235,7 @@ static int POSITIONvideo() if (result != 0) return result; - if (live_source) return 0; + if (VIDEO_SINGLETON::instance ()->live_source) return 0; #ifdef NeedByteOrderConversion para.nextGroup = ntohl(para.nextGroup); @@ -1409,7 +1265,7 @@ static int STEPvideo() cmdsn = para.sn; - if (!live_source) { + if (!VIDEO_SINGLETON::instance ()->live_source) { if (para.nextFrame >= numF) /* send SEQ_END */ { tag = 1; @@ -1426,9 +1282,9 @@ static int STEPvideo() return result; } } - if (live_source) StartPlayLiveVideo(); + if (VIDEO_SINGLETON::instance ()->live_source) StartPlayLiveVideo(); - if (live_source) { + if (VIDEO_SINGLETON::instance ()->live_source) { SendPicture(¶.nextFrame); } else if (video_format == VIDEO_MPEG1) { @@ -1438,7 +1294,7 @@ static int STEPvideo() fprintf(stderr, "VS: wierd1\n"); } - if (live_source) StopPlayLiveVideo(); + if (VIDEO_SINGLETON::instance ()->live_source) StopPlayLiveVideo(); return 0; } @@ -1664,7 +1520,7 @@ static int FastVideoPlay(void) FFpara para; int preGroup = -1; int preHeader = -1; - int nfds = (serviceSocket > videoSocket ? serviceSocket : videoSocket) + 1; + int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : videoSocket) + 1; result = CmdRead((char *)¶, sizeof(para)); if (result != 0) @@ -1677,7 +1533,7 @@ static int FastVideoPlay(void) para.VStimeAdvance = ntohl(para.VStimeAdvance); #endif - if (live_source) return 0; + if (VIDEO_SINGLETON::instance ()->live_source) return 0; VStimeAdvance = para.VStimeAdvance; /* @@ -1706,7 +1562,7 @@ static int FastVideoPlay(void) } FD_ZERO(&read_mask); - FD_SET(serviceSocket, &read_mask); + FD_SET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask); FD_SET(videoSocket, &read_mask); #ifdef _HPUX_SOURCE if (select(nfds, (int *)&read_mask, NULL, NULL, NULL) == -1) @@ -1720,7 +1576,7 @@ static int FastVideoPlay(void) exit(1); } - if (FD_ISSET(serviceSocket, &read_mask)) /* stop */ + if (FD_ISSET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask)) /* stop */ { result = CmdRead((char *)&cmd, 1); if (result != 0) @@ -1815,7 +1671,7 @@ static int PLAYliveVideo(PLAYpara * para) int count; int first_frame; int frame = para->nextFrame; - int nfds = (serviceSocket > videoSocket ? serviceSocket : videoSocket) + 1; + int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : videoSocket) + 1; struct fd_set read_mask; struct timeval tval = {0, 0}; double ratio; @@ -1848,7 +1704,7 @@ static int PLAYliveVideo(PLAYpara * para) frame ++; FD_ZERO(&read_mask); - FD_SET(serviceSocket, &read_mask); + FD_SET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask); FD_SET(videoSocket, &read_mask); #ifdef _HPUX_SOURCE if (select(nfds, (int *)&read_mask, NULL, NULL, &tval) == -1) @@ -1863,7 +1719,7 @@ static int PLAYliveVideo(PLAYpara * para) exit(1); } - if (FD_ISSET(serviceSocket, &read_mask)) /* stop */ + if (FD_ISSET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask)) /* stop */ { unsigned char tmp; result = CmdRead((char *)&tmp, 1); @@ -1971,8 +1827,9 @@ static int PLAYvideo() CmdWrite((char *)&ts, sizeof(int)); } - if (live_source || video_format != VIDEO_MPEG1) { - if (live_source) PLAYliveVideo(¶); + if (VIDEO_SINGLETON::instance ()->live_source || video_format != VIDEO_MPEG1) { + if (VIDEO_SINGLETON::instance ()->live_source) + PLAYliveVideo (¶); return 0; } @@ -2003,7 +1860,7 @@ static int PLAYvideo() int curHeader = timerHeader; char * sp; struct fd_set read_mask; - int nfds = (serviceSocket > videoSocket ? serviceSocket : videoSocket) + 1; + int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : videoSocket) + 1; if (preGroup != curGroup || curFrame != preFrame) { @@ -2085,7 +1942,7 @@ static int PLAYvideo() } FD_ZERO(&read_mask); - FD_SET(serviceSocket, &read_mask); + FD_SET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask); FD_SET(videoSocket, &read_mask); #ifdef _HPUX_SOURCE if (select(nfds, (int *)&read_mask, NULL, NULL, NULL) == -1) @@ -2099,7 +1956,7 @@ static int PLAYvideo() exit(1); } - if (FD_ISSET(serviceSocket, &read_mask)) /* stop, speed change, loop swap */ + if (FD_ISSET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask)) /* stop, speed change, loop swap */ { unsigned char tmp; result = CmdRead((char *)&tmp, 1); @@ -2206,7 +2063,7 @@ static void on_exit_routine(void) /* fprintf(stderr, "A VS session terminated.\n"); */ - if (getpeername(serviceSocket, + if (getpeername(VIDEO_SINGLETON::instance ()->serviceSocket, (struct sockaddr *)&peeraddr_in, &size) == 0 && peeraddr_in.sin_family == AF_INET) { if (strncmp(inet_ntoa(peeraddr_in.sin_addr), "129.95.50", 9)) { @@ -2223,7 +2080,7 @@ static void on_exit_routine(void) pkts_sent, videoFile); } } - ComCloseConn(serviceSocket); + ComCloseConn(VIDEO_SINGLETON::instance ()->serviceSocket); ComCloseConn(videoSocket); } @@ -2231,7 +2088,7 @@ int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size) { int result; - serviceSocket = ctr_fd; + VIDEO_SINGLETON::instance ()->serviceSocket = ctr_fd; videoSocket = data_fd; conn_tag = max_pkt_size; |