summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-06 04:01:59 +0000
committernaga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-03-06 04:01:59 +0000
commit6ae1e4d30599d27a7721930ae1e8380d98d98fa7 (patch)
tree8279d0fd8b1749edc5baab8a502f59883fb966e0
parent928ab6b3f1f016a623763b62b902c8d4e7689f97 (diff)
downloadATCD-6ae1e4d30599d27a7721930ae1e8380d98d98fa7.tar.gz
*** empty log message ***
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp8
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h8
-rw-r--r--TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp1132
3 files changed, 575 insertions, 573 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 5472bf7367e..5fb9fc10bbf 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.cpp
@@ -19,7 +19,7 @@ Video_Global::Video_Global ()
video_format = 0;
pkts_sent = 0;
- time_t start_time = 0;
+ start_time = 0;
conn_tag = 0;
@@ -32,11 +32,11 @@ Video_Global::Video_Global ()
0,
PATH_SIZE);
- FILE *fp = 0;
+ fp = 0;
needHeader = 0;
- lastRef [0] = lastref [1] = 0;
+ lastRef [0] = lastRef [1] = 0;
lastRefPtr = 0;
currentUPF = 0;
@@ -46,7 +46,7 @@ Video_Global::Video_Global ()
fps = 0; /* current frames-per-second: playback speed */
frameRateLimit = 0;
- VideoPacket * packet = 0;
+ packet = 0;
packetBufSize = 0;
msgsn = 0;
packetsn = 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 2b1c1c879a5..6dedd370e04 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/Globals.h
@@ -36,12 +36,12 @@
#define FileRead(position, buf, size) \
{ \
- if (fseek(fp, (position), 0) == -1) \
+ if (fseek(VIDEO_SINGLETON::instance ()->fp, (position), 0) == -1) \
{ \
perror("VS error on fseek VideoFile"); \
return (-1); \
} \
- while (fread((buf), (size), 1, fp) == 0) \
+ while (fread((buf), (size), 1, VIDEO_SINGLETON::instance ()->fp) == 0) \
{ if (errno == EINTR) { errno = 0; continue;}\
perror("VS error on fread VideoFile"); \
return (-1); \
@@ -52,6 +52,8 @@
#include <sys/types.h>
#include <sys/socket.h>
+#include "../include/common.h"
+#include "ace/Singleton.h"
class Mpeg_Global
{
@@ -176,7 +178,7 @@ class Video_Global
};
-typedef ACE_TSS_SINGLETON <Video_Global, ACE_SYNCH_MUTEX> VIDEO_SINGLETON;
+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 47628a93a4b..ab4898ddf6c 100644
--- a/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp
+++ b/TAO/orbsvcs/tests/AVStreams/mpeg/source/mpeg_server/vs.cpp
@@ -55,7 +55,7 @@ static int CmdRead(char *buf, int psize)
psize);
if (res == 0) return(1);
if (res == -1) {
- fprintf(stderr, "VS error on read cmdSocket, size %d", psize);
+ fprintf(stderr, "VS error on read VIDEO_SINGLETON::instance ()->cmdSocket, size %d", psize);
perror("");
return(-1);
}
@@ -73,12 +73,12 @@ static void CmdWrite(char *buf, int size)
static int FBread(char * buf, int size)
{ int res;
- while ((res = (conn_tag >= 0 ? wait_read_bytes(videoSocket, buf, size) :
- read(videoSocket, buf, size))) == -1)
+ while ((res = (VIDEO_SINGLETON::instance ()->conn_tag >= 0 ? wait_read_bytes(VIDEO_SINGLETON::instance ()->videoSocket, buf, size) :
+ read(VIDEO_SINGLETON::instance ()->videoSocket, buf, size))) == -1)
{
if (errno == EINTR) {errno = 0; continue; }
if (errno == EPIPE || errno == ECONNRESET) exit(0);
- perror("VS reads Feedback packet");
+ perror("VS reads Feedback VIDEO_SINGLETON::instance ()->packet");
return -1;
}
if (res < size) {
@@ -89,33 +89,33 @@ static int FBread(char * buf, int size)
}
-/* send a given packet pointed by 'packet' to the network */
+/* send a given VIDEO_SINGLETON::instance ()->packet pointed by 'VIDEO_SINGLETON::instance ()->packet' to the network */
static int send_to_network(int timeToUse)
{
int count = 0;
- VideoMessage * msghd = (VideoMessage *)(((char *)packet) - sizeof(VideoMessage));
+ VideoMessage * msghd = (VideoMessage *)(((char *)VIDEO_SINGLETON::instance ()->packet) - sizeof(VideoMessage));
int sent = 0;
- int packetSize = ntohl(packet->dataBytes);
+ int packetSize = ntohl(VIDEO_SINGLETON::instance ()->packet->dataBytes);
- msghd->packetsn = htonl(packetsn ++);
- msghd->packetSize = htonl(packetSize + sizeof(* packet));
+ msghd->packetsn = htonl(VIDEO_SINGLETON::instance ()->packetsn ++);
+ msghd->packetSize = htonl(packetSize + sizeof(* VIDEO_SINGLETON::instance ()->packet));
/*
fprintf(stderr, "VS to send pkt %d of size %d.\n",
- ntohl(msghd->packetsn), ntohl(msghd->packetSize));
+ ntohl(msghd->VIDEO_SINGLETON::instance ()->packetsn), ntohl(msghd->VIDEO_SINGLETON::instance ()->packetSize));
*/
{
VideoMessage * msg = NULL;
- int size = packetSize + sizeof(* packet); /* msghd->packetSize */
+ int size = packetSize + sizeof(* VIDEO_SINGLETON::instance ()->packet); /* msghd->VIDEO_SINGLETON::instance ()->packetSize */
int offset = 0;
int targetTime;
- if (size > msgsize)
+ if (size > VIDEO_SINGLETON::instance ()->msgsize)
{
if (!timeToUse)
{
- timeToUse = (msgsize + sizeof(*msg) + 28) * 2;
+ timeToUse = (VIDEO_SINGLETON::instance ()->msgsize + sizeof(*msg) + 28) * 2;
/*
set the max network as 500KB.
28 - UDP header size
@@ -130,8 +130,8 @@ static int send_to_network(int timeToUse)
/*
fprintf(stderr, "preset timeToUse %d.", timeToUse);
*/
- timeToUse /= (size + msgsize - 1) / msgsize;
- timeToUse = min(timeToUse, (msgsize + sizeof(*msg) + 28) * 100);
+ timeToUse /= (size + VIDEO_SINGLETON::instance ()->msgsize - 1) / VIDEO_SINGLETON::instance ()->msgsize;
+ timeToUse = min(timeToUse, (VIDEO_SINGLETON::instance ()->msgsize + sizeof(*msg) + 28) * 100);
/* limit min network bandwidth = 10K */
}
@@ -141,7 +141,7 @@ static int send_to_network(int timeToUse)
int segsize, sentsize;
int resent = 0;
- if (msg == NULL) { /* first message for current packet */
+ if (msg == NULL) { /* first message for current VIDEO_SINGLETON::instance ()->packet */
count = 0;
msg = msghd;
targetTime = get_usec();
@@ -160,16 +160,16 @@ static int send_to_network(int timeToUse)
count ++;
if (!(count % 10)) usleep(10000);
*/
- msg = (VideoMessage *)((char *)msg + msgsize);
+ msg = (VideoMessage *)((char *)msg + VIDEO_SINGLETON::instance ()->msgsize);
memcpy((char *)msg, (char *)msghd, sizeof(* msg));
}
- msg->msgsn = htonl(msgsn++);
+ msg->msgsn = htonl(VIDEO_SINGLETON::instance ()->msgsn++);
msg->msgOffset = htonl(offset);
- msg->msgSize = htonl(min(size, msgsize));
+ msg->msgSize = htonl(min(size, VIDEO_SINGLETON::instance ()->msgsize));
- segsize = min(size, msgsize)+sizeof(*msg);
- if (conn_tag != 0) { /* packet stream */
- while ((sentsize = write(videoSocket, (char *)msg, segsize)) == -1) {
+ segsize = min(size, VIDEO_SINGLETON::instance ()->msgsize)+sizeof(*msg);
+ if (VIDEO_SINGLETON::instance ()->conn_tag != 0) { /* VIDEO_SINGLETON::instance ()->packet stream */
+ while ((sentsize = write(VIDEO_SINGLETON::instance ()->videoSocket, (char *)msg, segsize)) == -1) {
if (errno == EINTR)
continue;
if (errno == ENOBUFS) {
@@ -186,19 +186,19 @@ static int send_to_network(int timeToUse)
}
}
if (errno != EPIPE) {
- fprintf(stderr, "VS error on send packet %d of size %d ",
- msgsn-1, min(size, msgsize)+sizeof(*msg));
+ fprintf(stderr, "VS error on send VIDEO_SINGLETON::instance ()->packet %d of size %d ",
+ VIDEO_SINGLETON::instance ()->msgsn-1, min(size, VIDEO_SINGLETON::instance ()->msgsize)+sizeof(*msg));
perror("");
}
exit(errno != EPIPE);
}
}
else {
- sentsize = wait_write_bytes(videoSocket, (char *)msg, segsize);
+ sentsize = wait_write_bytes(VIDEO_SINGLETON::instance ()->videoSocket, (char *)msg, segsize);
if (sentsize == -1) {
if (errno != EPIPE) {
- fprintf(stderr, "VS error on send packet %d of size %d ",
- msgsn-1, min(size, msgsize)+sizeof(*msg));
+ fprintf(stderr, "VS error on send VIDEO_SINGLETON::instance ()->packet %d of size %d ",
+ VIDEO_SINGLETON::instance ()->msgsn-1, min(size, VIDEO_SINGLETON::instance ()->msgsize)+sizeof(*msg));
perror("");
}
exit(errno != EPIPE);
@@ -212,21 +212,21 @@ static int send_to_network(int timeToUse)
break;
/*
fprintf(stderr, "VS: message %d of size %d sent.\n",
- msgsn-1, min(size, msgsize)+sizeof(*msg));
+ VIDEO_SINGLETON::instance ()->msgsn-1, min(size, VIDEO_SINGLETON::instance ()->msgsize)+sizeof(*msg));
*/
- size -= msgsize;
- offset += msgsize;
+ size -= VIDEO_SINGLETON::instance ()->msgsize;
+ offset += VIDEO_SINGLETON::instance ()->msgsize;
}
}
/*
fprintf(stderr, "sent = %d\n", sent);
*/
- if (!sent) pkts_sent ++;
+ if (!sent) VIDEO_SINGLETON::instance ()->pkts_sent ++;
return sent;
}
/*
- * send a packet with given systemHeader (optional), gop (optional) and frame.
+ * send a VIDEO_SINGLETON::instance ()->packet with given VIDEO_SINGLETON::instance ()->systemHeader (optional), gop (optional) and frame.
*
* sh - system header id, if -1, then no system header will be sent.
* otherwise, only when frame == 0, the given system header will be sent.
@@ -235,60 +235,60 @@ static int send_to_network(int timeToUse)
* frame - frame to be sent, offset internal to given gop.
*/
-/* returns: 0 - packet sent, -1 - packet not sent (failed) */
+/* returns: 0 - VIDEO_SINGLETON::instance ()->packet sent, -1 - VIDEO_SINGLETON::instance ()->packet not sent (failed) */
static int SendPacket(int shtag, int gop, int frame, int timeToUse)
/* frame maybe out of range (PLAY, STEP), in this case, END_SEQ is sent
to force display of last frame in VD */
{
- char * buf = ((char *) packet) + sizeof(VideoPacket);
- int f = gopTable[gop].previousFrames + frame;
- int sh = gopTable[gop].systemHeader;
+ char * buf = ((char *) VIDEO_SINGLETON::instance ()->packet) + sizeof(VideoPacket);
+ int f = VIDEO_SINGLETON::instance ()->gopTable[gop].previousFrames + frame;
+ int sh = VIDEO_SINGLETON::instance ()->gopTable[gop].systemHeader;
/*
- SFprintf(stderr, "VS to send packet gop-%d, frame-%d.\n", gop, frame);
+ SFprintf(stderr, "VS to send VIDEO_SINGLETON::instance ()->packet gop-%d, frame-%d.\n", gop, frame);
*/
- packet->currentUPF = ntohl(currentUPF);
+ VIDEO_SINGLETON::instance ()->packet->currentUPF = ntohl(VIDEO_SINGLETON::instance ()->currentUPF);
- if (frame >= gopTable[gop].totalFrames)
+ if (frame >= VIDEO_SINGLETON::instance ()->gopTable[gop].totalFrames)
{
- packet->cmd = htonl(cmd);
- packet->cmdsn = htonl(cmdsn);
- packet->sh = htonl(sh);
- packet->gop = htonl(gop);
- packet->frame = htonl(numF);
- packet->display = htonl(numF-1);
- packet->future = htonl((unsigned)-1);
- packet->past = htonl((unsigned)-1);
- packet->dataBytes = htonl(4);
- *(int*)((char*)packet + sizeof(*packet)) = htonl(SEQ_END_CODE);
+ VIDEO_SINGLETON::instance ()->packet->cmd = htonl(VIDEO_SINGLETON::instance ()->cmd);
+ VIDEO_SINGLETON::instance ()->packet->cmdsn = htonl(VIDEO_SINGLETON::instance ()->cmdsn);
+ VIDEO_SINGLETON::instance ()->packet->sh = htonl(sh);
+ VIDEO_SINGLETON::instance ()->packet->gop = htonl(gop);
+ VIDEO_SINGLETON::instance ()->packet->frame = htonl(VIDEO_SINGLETON::instance ()->numF);
+ VIDEO_SINGLETON::instance ()->packet->display = htonl(VIDEO_SINGLETON::instance ()->numF-1);
+ VIDEO_SINGLETON::instance ()->packet->future = htonl((unsigned)-1);
+ VIDEO_SINGLETON::instance ()->packet->past = htonl((unsigned)-1);
+ VIDEO_SINGLETON::instance ()->packet->dataBytes = htonl(4);
+ *(int*)((char*)VIDEO_SINGLETON::instance ()->packet + sizeof(*VIDEO_SINGLETON::instance ()->packet)) = htonl(SEQ_END_CODE);
return send_to_network(timeToUse);
}
if (frame)
shtag = 0;
- else if (needHeader)
+ else if (VIDEO_SINGLETON::instance ()->needHeader)
{
shtag = 1;
- needHeader = 0;
+ VIDEO_SINGLETON::instance ()->needHeader = 0;
}
- packet->cmd = htonl(cmd);
- packet->cmdsn = htonl(cmdsn);
- packet->sh = htonl(sh);
- packet->gop = htonl(gop);
- packet->frame = htonl(f);
- if (frameTable[f].type == 'B')
+ VIDEO_SINGLETON::instance ()->packet->cmd = htonl(VIDEO_SINGLETON::instance ()->cmd);
+ VIDEO_SINGLETON::instance ()->packet->cmdsn = htonl(VIDEO_SINGLETON::instance ()->cmdsn);
+ VIDEO_SINGLETON::instance ()->packet->sh = htonl(sh);
+ VIDEO_SINGLETON::instance ()->packet->gop = htonl(gop);
+ VIDEO_SINGLETON::instance ()->packet->frame = htonl(f);
+ if (VIDEO_SINGLETON::instance ()->frameTable[f].type == 'B')
{
int pre1 = -1, pre2 = -1, i = f;
while (i>0)
- if (frameTable[--i].type != 'B')
+ if (VIDEO_SINGLETON::instance ()->frameTable[--i].type != 'B')
{
pre1 = i;
break;
}
while (i>0)
- if (frameTable[--i].type != 'B')
+ if (VIDEO_SINGLETON::instance ()->frameTable[--i].type != 'B')
{
pre2 = i;
break;
@@ -302,8 +302,8 @@ static int SendPacket(int shtag, int gop, int frame, int timeToUse)
*/
return -1;
}
- if (pre1 != lastRef[lastRefPtr] ||
- pre2 != lastRef[1 - lastRefPtr])
+ if (pre1 != VIDEO_SINGLETON::instance ()->lastRef[VIDEO_SINGLETON::instance ()->lastRefPtr] ||
+ pre2 != VIDEO_SINGLETON::instance ()->lastRef[1 - VIDEO_SINGLETON::instance ()->lastRefPtr])
{
/*
fprintf(stderr,
@@ -312,53 +312,53 @@ static int SendPacket(int shtag, int gop, int frame, int timeToUse)
*/
return -1;
}
- packet->display = htonl(f);
- packet->future = htonl(pre1);
- packet->past = htonl(pre2);
+ VIDEO_SINGLETON::instance ()->packet->display = htonl(f);
+ VIDEO_SINGLETON::instance ()->packet->future = htonl(pre1);
+ VIDEO_SINGLETON::instance ()->packet->past = htonl(pre2);
}
else
{
int next = f;
int pre = f;
- while (next < numF && frameTable[++next].type == 'B');
- while (pre > 0 && frameTable[--pre].type == 'B');
- if (frameTable[f].type == 'P' && pre != lastRef[lastRefPtr])
+ while (next < VIDEO_SINGLETON::instance ()->numF && VIDEO_SINGLETON::instance ()->frameTable[++next].type == 'B');
+ while (pre > 0 && VIDEO_SINGLETON::instance ()->frameTable[--pre].type == 'B');
+ if (VIDEO_SINGLETON::instance ()->frameTable[f].type == 'P' && pre != VIDEO_SINGLETON::instance ()->lastRef[VIDEO_SINGLETON::instance ()->lastRefPtr])
{
/*
fprintf(stderr,
"send of P frame %d gaveup for past ref %d not sent.\n",
f, pre);
fprintf(stderr, "ref0=%d, ref1=%d, ptr=%d.\n",
- lastRef[0], lastRef[1], lastRefPtr);
+ VIDEO_SINGLETON::instance ()->lastRef[0], VIDEO_SINGLETON::instance ()->lastRef[1], VIDEO_SINGLETON::instance ()->lastRefPtr);
*/
return -1;
}
- packet->display = htonl(next);
- packet->future = htonl((unsigned)-1);
- packet->past = htonl(frameTable[f].type == 'P' ? pre : (unsigned)-1);
+ VIDEO_SINGLETON::instance ()->packet->display = htonl(next);
+ VIDEO_SINGLETON::instance ()->packet->future = htonl((unsigned)-1);
+ VIDEO_SINGLETON::instance ()->packet->past = htonl(VIDEO_SINGLETON::instance ()->frameTable[f].type == 'P' ? pre : (unsigned)-1);
}
{
char * ptr = buf;
int size = 0, offset = 0, i;
if (shtag) /* send system header */
{
- size = systemHeader[sh].size;
- FileRead(systemHeader[sh].offset, ptr, size);
+ size = VIDEO_SINGLETON::instance ()->systemHeader[sh].size;
+ FileRead(VIDEO_SINGLETON::instance ()->systemHeader[sh].offset, ptr, size);
ptr += size;
}
if (!frame) /* send gop header */
{
- size = gopTable[gop].headerSize;
- FileRead(gopTable[gop].offset, ptr, size);
+ size = VIDEO_SINGLETON::instance ()->gopTable[gop].headerSize;
+ FileRead(VIDEO_SINGLETON::instance ()->gopTable[gop].offset, ptr, size);
ptr += size;
}
- size = frameTable[f].size;
- for (i=gopTable[gop].previousFrames; i<f; i++)
- offset += frameTable[i].size;
- FileRead((gopTable[gop].firstIoffset + offset), ptr, size);
+ size = VIDEO_SINGLETON::instance ()->frameTable[f].size;
+ for (i=VIDEO_SINGLETON::instance ()->gopTable[gop].previousFrames; i<f; i++)
+ offset += VIDEO_SINGLETON::instance ()->frameTable[i].size;
+ FileRead((VIDEO_SINGLETON::instance ()->gopTable[gop].firstIoffset + offset), ptr, size);
ptr += size;
- packet->dataBytes = htonl(ptr - buf);
+ VIDEO_SINGLETON::instance ()->packet->dataBytes = htonl(ptr - buf);
}
{
@@ -366,13 +366,13 @@ static int SendPacket(int shtag, int gop, int frame, int timeToUse)
if (!sent)
{
/*
- fprintf(stderr, "%c%d\n", frameTable[f].type, f);
- fprintf(stderr, "%c frame %d sent.\n", frameTable[f].type, f);
+ fprintf(stderr, "%c%d\n", VIDEO_SINGLETON::instance ()->frameTable[f].type, f);
+ fprintf(stderr, "%c frame %d sent.\n", VIDEO_SINGLETON::instance ()->frameTable[f].type, f);
*/
- if (frameTable[f].type != 'B')
+ if (VIDEO_SINGLETON::instance ()->frameTable[f].type != 'B')
{
- lastRefPtr = 1 - lastRefPtr;
- lastRef[lastRefPtr] = f;
+ VIDEO_SINGLETON::instance ()->lastRefPtr = 1 - VIDEO_SINGLETON::instance ()->lastRefPtr;
+ VIDEO_SINGLETON::instance ()->lastRef[VIDEO_SINGLETON::instance ()->lastRefPtr] = f;
}
}
return sent;
@@ -387,17 +387,17 @@ static int SendReferences(int group, int frame)
int pregroup;
int result;
- if (group < 0 || group >= numG) return 0;
- if (frame <= 0 || frame >= gopTable[group].totalFrames) return 0;
+ if (group < 0 || group >= VIDEO_SINGLETON::instance ()->numG) return 0;
+ if (frame <= 0 || frame >= VIDEO_SINGLETON::instance ()->gopTable[group].totalFrames) return 0;
- orgcmd = cmd;
- cmd = CmdREF;
+ orgcmd = VIDEO_SINGLETON::instance ()->cmd;
+ VIDEO_SINGLETON::instance ()->cmd = CmdREF;
if (group > 0) {
pregroup = 1;
- base = gopTable[group].previousFrames;
+ base = VIDEO_SINGLETON::instance ()->gopTable[group].previousFrames;
for (i = 0; i <= frame; i ++) {
- if (frameTable[i + base].type == 'P') {
+ if (VIDEO_SINGLETON::instance ()->frameTable[i + base].type == 'P') {
pregroup = 0;
break;
}
@@ -407,9 +407,9 @@ static int SendReferences(int group, int frame)
if (pregroup) { /* reference frame can be in previous group */
pregroup = group -1;
- base = gopTable[pregroup].previousFrames;
- for (i = 0; i < gopTable[pregroup].totalFrames; i ++) {
- if (frameTable[i + base].type != 'B') {
+ base = VIDEO_SINGLETON::instance ()->gopTable[pregroup].previousFrames;
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->gopTable[pregroup].totalFrames; i ++) {
+ if (VIDEO_SINGLETON::instance ()->frameTable[i + base].type != 'B') {
/*
SFprintf(stderr, "REF group%d, frame%d\n", pregroup, i);
*/
@@ -420,157 +420,157 @@ static int SendReferences(int group, int frame)
}
}
- base = gopTable[group].previousFrames;
+ base = VIDEO_SINGLETON::instance ()->gopTable[group].previousFrames;
for (i = 0; i < frame; i ++) {
- if (frameTable[i + base].type != 'B') {
+ if (VIDEO_SINGLETON::instance ()->frameTable[i + base].type != 'B') {
/*
SFprintf(stderr, "REF group%d, frame%d\n", group, i);
*/
SendPacket(i == 0, group, i, 0);
}
}
- cmd = orgcmd;
+ VIDEO_SINGLETON::instance ()->cmd = orgcmd;
}
static int SendPicture(int * frame)
{
int size;
- char * buf = ((char *) packet) + sizeof(VideoPacket);
+ char * buf = ((char *) VIDEO_SINGLETON::instance ()->packet) + sizeof(VideoPacket);
/*
SFprintf(stderr, "VS to send picture %d.\n", *frame);
*/
- size = ReadLiveVideoPicture(frame, buf, packetBufSize);
+ size = ReadLiveVideoPicture(frame, buf, VIDEO_SINGLETON::instance ()->packetBufSize);
- packet->currentUPF = ntohl(currentUPF);
- packet->cmd = htonl(cmd);
- packet->cmdsn = htonl(cmdsn);
- packet->sh = packet->gop = packet->frame = packet->display = htonl(*frame);
- packet->future = htonl((unsigned)-1);
- packet->past = htonl((unsigned)-1);
+ VIDEO_SINGLETON::instance ()->packet->currentUPF = ntohl(VIDEO_SINGLETON::instance ()->currentUPF);
+ VIDEO_SINGLETON::instance ()->packet->cmd = htonl(VIDEO_SINGLETON::instance ()->cmd);
+ VIDEO_SINGLETON::instance ()->packet->cmdsn = htonl(VIDEO_SINGLETON::instance ()->cmdsn);
+ VIDEO_SINGLETON::instance ()->packet->sh = VIDEO_SINGLETON::instance ()->packet->gop = VIDEO_SINGLETON::instance ()->packet->frame = VIDEO_SINGLETON::instance ()->packet->display = htonl(*frame);
+ VIDEO_SINGLETON::instance ()->packet->future = htonl((unsigned)-1);
+ VIDEO_SINGLETON::instance ()->packet->past = htonl((unsigned)-1);
- packet->dataBytes = htonl(size);
+ VIDEO_SINGLETON::instance ()->packet->dataBytes = htonl(size);
- return send_to_network(currentUPF);
+ return send_to_network(VIDEO_SINGLETON::instance ()->currentUPF);
}
static int ReadInfoFromFile(void)
{
int fd = -1, i;
- int fnlen = strlen(videoFile);
+ int fnlen = strlen(VIDEO_SINGLETON::instance ()->videoFile);
- strcpy(&videoFile[fnlen], ".Info");
- fd = open(videoFile, O_RDONLY);
+ strcpy(&VIDEO_SINGLETON::instance ()->videoFile[fnlen], ".Info");
+ fd = open(VIDEO_SINGLETON::instance ()->videoFile, O_RDONLY);
if (fd == -1)
{
- fprintf(stderr, "Reminder: VS fails to open %s for read, ", videoFile);
+ fprintf(stderr, "Reminder: VS fails to open %s for read, ", VIDEO_SINGLETON::instance ()->videoFile);
perror("try create one");
goto fail_ReadInfoFromFile;
}
read_int(fd, &i);
- if (i != fileSize)
+ if (i != VIDEO_SINGLETON::instance ()->fileSize)
{
- fprintf(stderr, "Warning: fileSize in Info: %d not the same as actual %d.\n",
- i, fileSize);
+ fprintf(stderr, "Warning: VIDEO_SINGLETON::instance ()->fileSize in Info: %d not the same as actual %d.\n",
+ i, VIDEO_SINGLETON::instance ()->fileSize);
goto fail_ReadInfoFromFile;
}
- read_int(fd, &maxS);
- read_int(fd, &maxG);
- read_int(fd, &maxI);
- read_int(fd, &maxP);
- read_int(fd, &maxB);
- read_int(fd, &minS);
- read_int(fd, &minG);
- read_int(fd, &minI);
- read_int(fd, &minP);
- read_int(fd, &minB);
- read_int(fd, &numS);
- read_int(fd, &numG);
- read_int(fd, &numF);
- read_int(fd, &numI);
- read_int(fd, &numP);
- read_int(fd, &numB);
- read_int(fd, &averageFrameSize);
- read_int(fd, &horizontalSize);
- read_int(fd, &verticalSize);
- read_int(fd, &pelAspectRatio);
- read_int(fd, &pictureRate);
- read_int(fd, &vbvBufferSize);
- read_int(fd, &patternSize);
-
- memset(pattern, 0, PATTERN_SIZE);
- read_bytes(fd, pattern, patternSize);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->maxS);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->maxG);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->maxI);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->maxP);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->maxB);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->minS);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->minG);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->minI);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->minP);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->minB);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->numS);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->numG);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->numF);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->numI);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->numP);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->numB);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->averageFrameSize);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->horizontalSize);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->verticalSize);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->pelAspectRatio);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->pictureRate);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->vbvBufferSize);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->patternSize);
+
+ memset(VIDEO_SINGLETON::instance ()->pattern, 0, PATTERN_SIZE);
+ read_bytes(fd, VIDEO_SINGLETON::instance ()->pattern, VIDEO_SINGLETON::instance ()->patternSize);
#ifdef STAT
- framesSent = (char *)malloc((numF + 7)>>3);
- if (framesSent == NULL)
+ VIDEO_SINGLETON::instance ()->framesSent = (char *)malloc((VIDEO_SINGLETON::instance ()->numF + 7)>>3);
+ if (VIDEO_SINGLETON::instance ()->framesSent == NULL)
{
- fprintf(stderr, "Error: VS fails to alloc mem for framesSent for %d frames", numF);
+ fprintf(stderr, "Error: VS fails to alloc mem for VIDEO_SINGLETON::instance ()->framesSent for %d frames", VIDEO_SINGLETON::instance ()->numF);
perror("");
exit(1);
}
#endif
- systemHeader = (struct SystemHeader *)malloc(sizeof(struct SystemHeader) * numS);
- if (systemHeader == NULL)
+ VIDEO_SINGLETON::instance ()->systemHeader = (struct Video_Global::SystemHeader *)malloc(sizeof(struct Video_Global::SystemHeader) * VIDEO_SINGLETON::instance ()->numS);
+ if (VIDEO_SINGLETON::instance ()->systemHeader == NULL)
{
- perror("Error: VS error on malloc SystemHeader");
+ perror("Error: VS error on malloc VIDEO_SINGLETON::instance ()->SystemHeader");
exit(1);
}
- gopTable = (struct GopTable *)malloc(sizeof(struct GopTable) * numG);
- if (gopTable == NULL)
+ VIDEO_SINGLETON::instance ()->gopTable = (struct Video_Global::GopTable *)malloc(sizeof(struct Video_Global::GopTable) * VIDEO_SINGLETON::instance ()->numG);
+ if (VIDEO_SINGLETON::instance ()->gopTable == NULL)
{
perror("Error: VS error on malloc GopHeader");
exit(1);
}
- frameTable = (struct FrameTable *)malloc(sizeof(* frameTable) * numF);
- if (frameTable == NULL)
+ VIDEO_SINGLETON::instance ()->frameTable = (struct Video_Global::FrameTable *)malloc(sizeof(Video_Global::FrameTable) * VIDEO_SINGLETON::instance ()->numF);
+ if (VIDEO_SINGLETON::instance ()->frameTable == NULL)
{
- perror("Error: VS error on malloc frameTable");
+ perror("Error: VS error on malloc VIDEO_SINGLETON::instance ()->frameTable");
exit(1);
}
- packetBufSize = maxS + maxG + max(maxI, max(maxP, maxB));
- packet = (VideoPacket *)malloc(sizeof(VideoMessage) + sizeof(VideoPacket) +
- packetBufSize);
- if (packet == NULL)
+ VIDEO_SINGLETON::instance ()->packetBufSize = VIDEO_SINGLETON::instance ()->maxS + VIDEO_SINGLETON::instance ()->maxG + max(VIDEO_SINGLETON::instance ()->maxI, max(VIDEO_SINGLETON::instance ()->maxP, VIDEO_SINGLETON::instance ()->maxB));
+ VIDEO_SINGLETON::instance ()->packet = (VideoPacket *)malloc(sizeof(VideoMessage) + sizeof(VideoPacket) +
+ VIDEO_SINGLETON::instance ()->packetBufSize);
+ if (VIDEO_SINGLETON::instance ()->packet == NULL)
{
- perror("Error: VS error on malloc packet buffer");
+ perror("Error: VS error on malloc VIDEO_SINGLETON::instance ()->packet buffer");
exit(1);
}
- packet = (VideoPacket *)((char *)packet + sizeof(VideoMessage));
+ VIDEO_SINGLETON::instance ()->packet = (VideoPacket *)((char *)VIDEO_SINGLETON::instance ()->packet + sizeof(VideoMessage));
- for (i = 0; i < numS; i ++)
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numS; i ++)
{
- read_int(fd, (int *)&systemHeader[i].offset);
- read_int(fd, &systemHeader[i].size);
+ read_int(fd, (int *)&VIDEO_SINGLETON::instance ()->systemHeader[i].offset);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->systemHeader[i].size);
}
- for (i = 0; i < numG; i ++)
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numG; i ++)
{
- read_int(fd, &gopTable[i].systemHeader);
- read_int(fd, (int *)&gopTable[i].offset);
- read_int(fd, &gopTable[i].headerSize);
- read_int(fd, &gopTable[i].size);
- read_int(fd, &gopTable[i].totalFrames);
- read_int(fd, &gopTable[i].previousFrames);
- read_int(fd, (int *)&gopTable[i].firstIoffset);
- }
- for (i = 0; i < numF; i ++)
+ read_int(fd, &VIDEO_SINGLETON::instance ()->gopTable[i].systemHeader);
+ read_int(fd, (int *)&VIDEO_SINGLETON::instance ()->gopTable[i].offset);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->gopTable[i].headerSize);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->gopTable[i].size);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->gopTable[i].totalFrames);
+ read_int(fd, &VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames);
+ read_int(fd, (int *)&VIDEO_SINGLETON::instance ()->gopTable[i].firstIoffset);
+ }
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numF; i ++)
{
- read_byte(fd, &frameTable[i].type);
- read_short(fd, (short *)&frameTable[i].size);
+ read_byte(fd, &VIDEO_SINGLETON::instance ()->frameTable[i].type);
+ read_short(fd, (short *)&VIDEO_SINGLETON::instance ()->frameTable[i].size);
}
close(fd);
/*
- fprintf(stderr, "Read Info from %s\n", videoFile);
+ fprintf(stderr, "Read Info from %s\n", VIDEO_SINGLETON::instance ()->videoFile);
*/
- videoFile[fnlen] = 0;
+ VIDEO_SINGLETON::instance ()->videoFile[fnlen] = 0;
return 0;
fail_ReadInfoFromFile:
if (fd >= 0)
close(fd);
- videoFile[fnlen] = 0;
+ VIDEO_SINGLETON::instance ()->videoFile[fnlen] = 0;
/*
- fprintf(stderr, "To scan Info from %s\n", videoFile);
+ fprintf(stderr, "To scan Info from %s\n", VIDEO_SINGLETON::instance ()->videoFile);
*/
return -1;
}
@@ -578,71 +578,71 @@ static int ReadInfoFromFile(void)
static void WriteInfoToFile(void)
{
int fd = -1, i;
- int fnlen = strlen(videoFile);
+ int fnlen = strlen(VIDEO_SINGLETON::instance ()->videoFile);
- strcpy(&videoFile[fnlen], ".Info");
- fd = open(videoFile, O_WRONLY | O_CREAT, 0444);
+ strcpy(&VIDEO_SINGLETON::instance ()->videoFile[fnlen], ".Info");
+ fd = open(VIDEO_SINGLETON::instance ()->videoFile, O_WRONLY | O_CREAT, 0444);
if (fd == -1)
{
- fprintf(stderr, "VS fails to open %s for write", videoFile);
+ fprintf(stderr, "VS fails to open %s for write", VIDEO_SINGLETON::instance ()->videoFile);
perror("");
goto fail_WriteInfoToFile;
}
- write_int(fd, fileSize);
- write_int(fd, maxS);
- write_int(fd, maxG);
- write_int(fd, maxI);
- write_int(fd, maxP);
- write_int(fd, maxB);
- write_int(fd, minS);
- write_int(fd, minG);
- write_int(fd, minI);
- write_int(fd, minP);
- write_int(fd, minB);
- write_int(fd, numS);
- write_int(fd, numG);
- write_int(fd, numF);
- write_int(fd, numI);
- write_int(fd, numP);
- write_int(fd, numB);
- write_int(fd, averageFrameSize);
- write_int(fd, horizontalSize);
- write_int(fd, verticalSize);
- write_int(fd, pelAspectRatio);
- write_int(fd, pictureRate);
- write_int(fd, vbvBufferSize);
- write_int(fd, patternSize);
-
- write_bytes(fd, pattern, patternSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->fileSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->maxS);
+ write_int(fd, VIDEO_SINGLETON::instance ()->maxG);
+ write_int(fd, VIDEO_SINGLETON::instance ()->maxI);
+ write_int(fd, VIDEO_SINGLETON::instance ()->maxP);
+ write_int(fd, VIDEO_SINGLETON::instance ()->maxB);
+ write_int(fd, VIDEO_SINGLETON::instance ()->minS);
+ write_int(fd, VIDEO_SINGLETON::instance ()->minG);
+ write_int(fd, VIDEO_SINGLETON::instance ()->minI);
+ write_int(fd, VIDEO_SINGLETON::instance ()->minP);
+ write_int(fd, VIDEO_SINGLETON::instance ()->minB);
+ write_int(fd, VIDEO_SINGLETON::instance ()->numS);
+ write_int(fd, VIDEO_SINGLETON::instance ()->numG);
+ write_int(fd, VIDEO_SINGLETON::instance ()->numF);
+ write_int(fd, VIDEO_SINGLETON::instance ()->numI);
+ write_int(fd, VIDEO_SINGLETON::instance ()->numP);
+ write_int(fd, VIDEO_SINGLETON::instance ()->numB);
+ write_int(fd, VIDEO_SINGLETON::instance ()->averageFrameSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->horizontalSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->verticalSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->pelAspectRatio);
+ write_int(fd, VIDEO_SINGLETON::instance ()->pictureRate);
+ write_int(fd, VIDEO_SINGLETON::instance ()->vbvBufferSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->patternSize);
+
+ write_bytes(fd, VIDEO_SINGLETON::instance ()->pattern, VIDEO_SINGLETON::instance ()->patternSize);
- for (i = 0; i < numS; i ++)
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numS; i ++)
{
- write_int(fd, systemHeader[i].offset);
- write_int(fd, systemHeader[i].size);
+ write_int(fd, VIDEO_SINGLETON::instance ()->systemHeader[i].offset);
+ write_int(fd, VIDEO_SINGLETON::instance ()->systemHeader[i].size);
}
- for (i = 0; i < numG; i ++)
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numG; i ++)
{
- write_int(fd, gopTable[i].systemHeader);
- write_int(fd, gopTable[i].offset);
- write_int(fd, gopTable[i].headerSize);
- write_int(fd, gopTable[i].size);
- write_int(fd, gopTable[i].totalFrames);
- write_int(fd, gopTable[i].previousFrames);
- write_int(fd, gopTable[i].firstIoffset);
- }
- for (i = 0; i < numF; i ++)
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].systemHeader);
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].offset);
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].headerSize);
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].size);
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].totalFrames);
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames);
+ write_int(fd, VIDEO_SINGLETON::instance ()->gopTable[i].firstIoffset);
+ }
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numF; i ++)
{
- write_byte(fd, frameTable[i].type);
- write_short(fd, frameTable[i].size);
+ write_byte(fd, VIDEO_SINGLETON::instance ()->frameTable[i].type);
+ write_short(fd, VIDEO_SINGLETON::instance ()->frameTable[i].size);
}
close(fd);
- videoFile[fnlen] = 0;
+ VIDEO_SINGLETON::instance ()->videoFile[fnlen] = 0;
return;
fail_WriteInfoToFile:
if (fd >= 0)
close(fd);
- videoFile[fnlen] = 0;
+ VIDEO_SINGLETON::instance ()->videoFile[fnlen] = 0;
return;
}
@@ -657,7 +657,7 @@ static void WriteInfoToFile(void)
*/
#define nextByte {int val; fileptr ++; \
- if ((val = getc(fp)) == EOF) \
+ if ((val = getc(VIDEO_SINGLETON::instance ()->fp)) == EOF) \
{\
perror("Crossed EOF or error while scanning"); \
return 1; \
@@ -668,21 +668,21 @@ static void WriteInfoToFile(void)
{ \
if (pictype == 'I') \
{ \
- maxI = max(maxI, (int)(fileptr - picptr - 4)); \
- minI = min(minI, (int)(fileptr - picptr - 4)); \
+ VIDEO_SINGLETON::instance ()->maxI = max(VIDEO_SINGLETON::instance ()->maxI, (int)(fileptr - picptr - 4)); \
+ VIDEO_SINGLETON::instance ()->minI = min(VIDEO_SINGLETON::instance ()->minI, (int)(fileptr - picptr - 4)); \
} \
else if (pictype == 'P') \
{ \
- maxP = max(maxP, (int)(fileptr - picptr - 4)); \
- minP = min(minP, (int)(fileptr - picptr - 4)); \
+ VIDEO_SINGLETON::instance ()->maxP = max(VIDEO_SINGLETON::instance ()->maxP, (int)(fileptr - picptr - 4)); \
+ VIDEO_SINGLETON::instance ()->minP = min(VIDEO_SINGLETON::instance ()->minP, (int)(fileptr - picptr - 4)); \
} \
else \
{ \
- maxB = max(maxB, (int)(fileptr - picptr - 4)); \
- minB = min(minB, (int)(fileptr - picptr - 4)); \
+ VIDEO_SINGLETON::instance ()->maxB = max(VIDEO_SINGLETON::instance ()->maxB, (int)(fileptr - picptr - 4)); \
+ VIDEO_SINGLETON::instance ()->minB = min(VIDEO_SINGLETON::instance ()->minB, (int)(fileptr - picptr - 4)); \
} \
- frameTable[ftptr].type = pictype; \
- frameTable[ftptr++].size = (int)(fileptr - picptr - 4); \
+ VIDEO_SINGLETON::instance ()->frameTable[ftptr].type = pictype; \
+ VIDEO_SINGLETON::instance ()->frameTable[ftptr++].size = (int)(fileptr - picptr - 4); \
inpic = 0; \
}
@@ -699,22 +699,22 @@ static int init_MPEG1_video_file(void)
int first = 0;
int failureType = 0;
- fp = fopen(videoFile, "r");
- if (fp == NULL)
+ VIDEO_SINGLETON::instance ()->fp = fopen(VIDEO_SINGLETON::instance ()->videoFile, "r");
+ if (VIDEO_SINGLETON::instance ()->fp == NULL)
{
- fprintf(stderr, "error on opening video file %s", videoFile);
+ fprintf(stderr, "error on opening video file %s", VIDEO_SINGLETON::instance ()->videoFile);
perror("");
return 2;
}
- if (fseek(fp, 0, 2) == -1)
+ if (fseek(VIDEO_SINGLETON::instance ()->fp, 0, 2) == -1)
{
- fprintf(stderr, "File %s not seekable", videoFile);
+ fprintf(stderr, "File %s not seekable", VIDEO_SINGLETON::instance ()->videoFile);
perror("");
return 3;
}
- fileSize = ftell(fp);
+ VIDEO_SINGLETON::instance ()->fileSize = ftell(VIDEO_SINGLETON::instance ()->fp);
- fseek(fp, 0, 0);
+ fseek(VIDEO_SINGLETON::instance ()->fp, 0, 0);
if (ReadInfoFromFile())
{
@@ -742,10 +742,10 @@ static int init_MPEG1_video_file(void)
fprintf(stderr, "VS error: given file is not in MPEG format.\n");
return 4;
}
- numS ++;
+ VIDEO_SINGLETON::instance ()->numS ++;
break;
case 0xb8: /* gop_start_code */
- numG ++;
+ VIDEO_SINGLETON::instance ()->numG ++;
break;
case 0x00: /* picture_start_code */
nextByte;
@@ -753,21 +753,21 @@ static int init_MPEG1_video_file(void)
nb &= 0x38;
if (nb == 0x08)
{
- numI ++;
- if (numG == 2)
- pattern[patternSize++] = 'I';
+ VIDEO_SINGLETON::instance ()->numI ++;
+ if (VIDEO_SINGLETON::instance ()->numG == 2)
+ VIDEO_SINGLETON::instance ()->pattern[VIDEO_SINGLETON::instance ()->patternSize++] = 'I';
}
else if (nb == 0x10)
{
- numP ++;
- if (numG == 2)
- pattern[patternSize++] = 'P';
+ VIDEO_SINGLETON::instance ()->numP ++;
+ if (VIDEO_SINGLETON::instance ()->numG == 2)
+ VIDEO_SINGLETON::instance ()->pattern[VIDEO_SINGLETON::instance ()->patternSize++] = 'P';
}
else if (nb == 0x18)
{
- numB ++;
- if (numG == 2)
- pattern[patternSize++] = 'B';
+ VIDEO_SINGLETON::instance ()->numB ++;
+ if (VIDEO_SINGLETON::instance ()->numG == 2)
+ VIDEO_SINGLETON::instance ()->pattern[VIDEO_SINGLETON::instance ()->patternSize++] = 'B';
}
/*
else
@@ -786,60 +786,60 @@ static int init_MPEG1_video_file(void)
if (first != 3)
{
- fprintf(stderr, "VS error: given file \"%s\" is not of MPEG format.\n", videoFile);
+ fprintf(stderr, "VS error: given file \"%s\" is not of MPEG format.\n", VIDEO_SINGLETON::instance ()->videoFile);
return 4;
}
- pattern[patternSize] = 0;
- memset(sendPattern, 1, PATTERN_SIZE);
+ VIDEO_SINGLETON::instance ()->pattern[VIDEO_SINGLETON::instance ()->patternSize] = 0;
+ memset(VIDEO_SINGLETON::instance ()->sendPattern, 1, PATTERN_SIZE);
- numF = numI + numP + numB;
- averageFrameSize = fileptr / (unsigned)numF;
+ VIDEO_SINGLETON::instance ()->numF = VIDEO_SINGLETON::instance ()->numI + VIDEO_SINGLETON::instance ()->numP + VIDEO_SINGLETON::instance ()->numB;
+ VIDEO_SINGLETON::instance ()->averageFrameSize = fileptr / (unsigned)VIDEO_SINGLETON::instance ()->numF;
/*
fprintf(stderr, "Pass one finished, total bytes read: %u, average frame size %d\n",
- fileptr, averageFrameSize);
- fprintf(stderr, "numS-%d, numG-%d, numF-%d, numI-%d, numP-%d, numB-%d\n",
- numS, numG, numI, numI, numP, numB);
- fprintf(stderr, "Pattern detected: %s\n", pattern);
+ fileptr, VIDEO_SINGLETON::instance ()->averageFrameSize);
+ fprintf(stderr, "VIDEO_SINGLETON::instance ()->numS-%d, VIDEO_SINGLETON::instance ()->numG-%d, VIDEO_SINGLETON::instance ()->numF-%d, VIDEO_SINGLETON::instance ()->numI-%d, VIDEO_SINGLETON::instance ()->numP-%d, VIDEO_SINGLETON::instance ()->numB-%d\n",
+ VIDEO_SINGLETON::instance ()->numS, VIDEO_SINGLETON::instance ()->numG, VIDEO_SINGLETON::instance ()->numI, VIDEO_SINGLETON::instance ()->numI, VIDEO_SINGLETON::instance ()->numP, VIDEO_SINGLETON::instance ()->numB);
+ fprintf(stderr, "VIDEO_SINGLETON::Instance ()->Pattern detected: %s\n", VIDEO_SINGLETON::instance ()->pattern);
*/
- if (numF > MAX_FRAMES)
+ if (VIDEO_SINGLETON::instance ()->numF > MAX_FRAMES)
{
- fprintf(stderr, "VS error: Number of frames (%d) is bigger than MAX_FRAMES (%d).\n\
+ fprintf(stderr, "VS error: VIDEO_SINGLETON::instance ()->Number of frames (%d) is bigger than MAX_FRAMES (%d).\n\
you need to update the constant definition in common.h and recompile.\n",
- numF, MAX_FRAMES);
+ VIDEO_SINGLETON::instance ()->numF, MAX_FRAMES);
return 5;
}
#ifdef STAT
- framesSent = (char *)malloc((numF + 7)>>3);
- if (framesSent == NULL)
+ VIDEO_SINGLETON::instance ()->framesSent = (char *)malloc((VIDEO_SINGLETON::instance ()->numF + 7)>>3);
+ if (VIDEO_SINGLETON::instance ()->framesSent == NULL)
{
- fprintf(stderr, "VS fails to alloc mem for framesSent for %d frames", numF);
+ fprintf(stderr, "VS fails to alloc mem for VIDEO_SINGLETON::instance ()->framesSent for %d frames", VIDEO_SINGLETON::instance ()->numF);
perror("");
return 6;
}
#endif
- systemHeader = (struct SystemHeader *)malloc(sizeof(struct SystemHeader) * numS);
- if (systemHeader == NULL)
+ VIDEO_SINGLETON::instance ()->systemHeader = (struct Video_Global::SystemHeader *)malloc(sizeof(struct Video_Global::SystemHeader) * VIDEO_SINGLETON::instance ()->numS);
+ if (VIDEO_SINGLETON::instance ()->systemHeader == NULL)
{
- perror("VS error on malloc SystemHeader");
+ perror("VS error on malloc VIDEO_SINGLETON::instance ()->SystemHeader");
return 7;
}
- gopTable = (struct GopTable *)malloc(sizeof(struct GopTable) * numG);
- if (gopTable == NULL)
+ VIDEO_SINGLETON::instance ()->gopTable = (struct Video_Global::GopTable *)malloc(sizeof(struct Video_Global::GopTable) * VIDEO_SINGLETON::instance ()->numG);
+ if (VIDEO_SINGLETON::instance ()->gopTable == NULL)
{
perror("VS error on malloc GopHeader");
return 8;
}
- frameTable = (struct FrameTable *)malloc(sizeof(* frameTable) * numF);
- if (frameTable == NULL)
+ VIDEO_SINGLETON::instance ()->frameTable = (struct Video_Global::FrameTable *)malloc(sizeof(Video_Global::FrameTable) * VIDEO_SINGLETON::instance ()->numF);
+ if (VIDEO_SINGLETON::instance ()->frameTable == NULL)
{
- perror("VS error on malloc frameTable");
+ perror("VS error on malloc VIDEO_SINGLETON::instance ()->frameTable");
return 9;
}
- rewind(fp);
+ rewind(VIDEO_SINGLETON::instance ()->fp);
fileptr = 0;
state = 0;
inpic = 0;
@@ -859,42 +859,42 @@ static int init_MPEG1_video_file(void)
switch (nb)
{
case 0xb7: /* seq_end_code */
- if (gopptr >= 0 && gopTable[gopptr].size == 0)
- gopTable[gopptr].size = fileptr - gopTable[gopptr].offset - 4;
+ if (gopptr >= 0 && VIDEO_SINGLETON::instance ()->gopTable[gopptr].size == 0)
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].size = fileptr - VIDEO_SINGLETON::instance ()->gopTable[gopptr].offset - 4;
computePicSize;
goto exit_phase2;
break;
case 0xb3: /* seq_start_code */
- if (gopptr >= 0 && gopTable[gopptr].size == 0)
- gopTable[gopptr].size = fileptr - gopTable[gopptr].offset - 4;
+ if (gopptr >= 0 && VIDEO_SINGLETON::instance ()->gopTable[gopptr].size == 0)
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].size = fileptr - VIDEO_SINGLETON::instance ()->gopTable[gopptr].offset - 4;
computePicSize;
shptr ++;
- systemHeader[shptr].offset = fileptr - 4;
- systemHeader[shptr].size = 0;
+ VIDEO_SINGLETON::instance ()->systemHeader[shptr].offset = fileptr - 4;
+ VIDEO_SINGLETON::instance ()->systemHeader[shptr].size = 0;
break;
case 0xb8: /* gop_start_code */
- if (systemHeader[shptr].size == 0)
- systemHeader[shptr].size =fileptr - systemHeader[shptr].offset - 4;
- if (gopptr >= 0 && gopTable[gopptr].size == 0)
- gopTable[gopptr].size = fileptr - gopTable[gopptr].offset - 4;
+ if (VIDEO_SINGLETON::instance ()->systemHeader[shptr].size == 0)
+ VIDEO_SINGLETON::instance ()->systemHeader[shptr].size =fileptr - VIDEO_SINGLETON::instance ()->systemHeader[shptr].offset - 4;
+ if (gopptr >= 0 && VIDEO_SINGLETON::instance ()->gopTable[gopptr].size == 0)
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].size = fileptr - VIDEO_SINGLETON::instance ()->gopTable[gopptr].offset - 4;
computePicSize;
gopptr ++;
- gopTable[gopptr].systemHeader = shptr;
- gopTable[gopptr].offset = fileptr - 4;
- gopTable[gopptr].headerSize = 0;
- gopTable[gopptr].size = 0;
- gopTable[gopptr].totalFrames = 0;
- gopTable[gopptr].previousFrames = gopptr ?
- (gopTable[gopptr - 1].totalFrames + gopTable[gopptr - 1].previousFrames) : 0;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].systemHeader = shptr;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].offset = fileptr - 4;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].headerSize = 0;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].size = 0;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].totalFrames = 0;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].previousFrames = gopptr ?
+ (VIDEO_SINGLETON::instance ()->gopTable[gopptr - 1].totalFrames + VIDEO_SINGLETON::instance ()->gopTable[gopptr - 1].previousFrames) : 0;
break;
case 0x00: /* picture_start_code */
- if (gopTable[gopptr].headerSize == 0)
+ if (VIDEO_SINGLETON::instance ()->gopTable[gopptr].headerSize == 0)
{
- gopTable[gopptr].headerSize = fileptr - gopTable[gopptr].offset - 4;
- gopTable[gopptr].firstIoffset = fileptr - 4;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].headerSize = fileptr - VIDEO_SINGLETON::instance ()->gopTable[gopptr].offset - 4;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].firstIoffset = fileptr - 4;
}
- gopTable[gopptr].totalFrames ++;
+ VIDEO_SINGLETON::instance ()->gopTable[gopptr].totalFrames ++;
computePicSize;
picptr = fileptr - 4;
nextByte;
@@ -927,81 +927,81 @@ static int init_MPEG1_video_file(void)
}
exit_phase2:
- for (shptr = 0; shptr<numS; shptr++)
+ for (shptr = 0; shptr<VIDEO_SINGLETON::instance ()->numS; shptr++)
{
- maxS = max(maxS, systemHeader[shptr].size);
- minS = min(minS, systemHeader[shptr].size);
+ VIDEO_SINGLETON::instance ()->maxS = max(VIDEO_SINGLETON::instance ()->maxS, VIDEO_SINGLETON::instance ()->systemHeader[shptr].size);
+ VIDEO_SINGLETON::instance ()->minS = min(VIDEO_SINGLETON::instance ()->minS, VIDEO_SINGLETON::instance ()->systemHeader[shptr].size);
}
- for (gopptr = 0; gopptr<numG; gopptr++)
+ for (gopptr = 0; gopptr<VIDEO_SINGLETON::instance ()->numG; gopptr++)
{
- maxG = max(maxG, gopTable[gopptr].headerSize);
- minG = min(minG, gopTable[gopptr].headerSize);
+ VIDEO_SINGLETON::instance ()->maxG = max(VIDEO_SINGLETON::instance ()->maxG, VIDEO_SINGLETON::instance ()->gopTable[gopptr].headerSize);
+ VIDEO_SINGLETON::instance ()->minG = min(VIDEO_SINGLETON::instance ()->minG, VIDEO_SINGLETON::instance ()->gopTable[gopptr].headerSize);
}
- packetBufSize = maxS + maxG + max(maxI, max(maxP, maxB));
- packet = (VideoPacket *)malloc(sizeof(VideoMessage) + sizeof(VideoPacket) +
- packetBufSize);
- if (packet == NULL)
+ VIDEO_SINGLETON::instance ()->packetBufSize = VIDEO_SINGLETON::instance ()->maxS + VIDEO_SINGLETON::instance ()->maxG + max(VIDEO_SINGLETON::instance ()->maxI, max(VIDEO_SINGLETON::instance ()->maxP, VIDEO_SINGLETON::instance ()->maxB));
+ VIDEO_SINGLETON::instance ()->packet = (VideoPacket *)malloc(sizeof(VideoMessage) + sizeof(VideoPacket) +
+ VIDEO_SINGLETON::instance ()->packetBufSize);
+ if (VIDEO_SINGLETON::instance ()->packet == NULL)
{
- perror("VS error on malloc packet buffer");
+ perror("VS error on malloc VIDEO_SINGLETON::instance ()->packet buffer");
return 10;
}
- packet = (VideoPacket *)((char *)packet + sizeof(VideoMessage));
+ VIDEO_SINGLETON::instance ()->packet = (VideoPacket *)((char *)VIDEO_SINGLETON::instance ()->packet + sizeof(VideoMessage));
/*
fprintf(stderr, "Pass 2 finished.\n");
- fprintf(stderr, "maxS-%d, maxG-%d, maxI-%d, maxP-%d, maxB-%d.\n", maxS, maxG, maxI, maxP, maxB);
- fprintf(stderr, "minS-%d, minG-%d, minI-%d, minP-%d, minB-%d.\n", minS, minG, minI, minP, minB);
+ fprintf(stderr, "VIDEO_SINGLETON::instance ()->maxS-%d, VIDEO_SINGLETON::instance ()->maxG-%d, VIDEO_SINGLETON::instance ()->maxI-%d, VIDEO_SINGLETON::instance ()->maxP-%d, VIDEO_SINGLETON::instance ()->maxB-%d.\n", VIDEO_SINGLETON::instance ()->maxS, VIDEO_SINGLETON::instance ()->maxG, VIDEO_SINGLETON::instance ()->maxI, VIDEO_SINGLETON::instance ()->maxP, VIDEO_SINGLETON::instance ()->maxB);
+ fprintf(stderr, "VIDEO_SINGLETON::instance ()->minS-%d, VIDEO_SINGLETON::instance ()->minG-%d, VIDEO_SINGLETON::instance ()->minI-%d, VIDEO_SINGLETON::instance ()->minP-%d, VIDEO_SINGLETON::instance ()->minB-%d.\n", VIDEO_SINGLETON::instance ()->minS, VIDEO_SINGLETON::instance ()->minG, VIDEO_SINGLETON::instance ()->minI, VIDEO_SINGLETON::instance ()->minP, VIDEO_SINGLETON::instance ()->minB);
*/
/*
{
int i;
fprintf(stderr, "id: offset size -- system header table:\n");
- for (i=0; i<numS; i++)
- fprintf(stderr, "%-3d %-9u %d\n", i, systemHeader[i].offset, systemHeader[i].size);
+ for (i=0; i<VIDEO_SINGLETON::instance ()->numS; i++)
+ fprintf(stderr, "%-3d %-9u %d\n", i, VIDEO_SINGLETON::instance ()->systemHeader[i].offset, VIDEO_SINGLETON::instance ()->systemHeader[i].size);
fprintf(stderr,
"id: header offset hdsize totSize frames preframs Ioffset Isize -- GOP\n");
- for (i=0; i<numG; i++)
+ for (i=0; i<VIDEO_SINGLETON::instance ()->numG; i++)
{
fprintf(stderr, "%-4d %-8d %-8u %-8d %-8d %-8d %-8d %-8u %d\n",
i,
- gopTable[i].systemHeader,
- gopTable[i].offset,
- gopTable[i].headerSize,
- gopTable[i].size,
- gopTable[i].totalFrames,
- gopTable[i].previousFrames,
- gopTable[i].firstIoffset,
- frameTable[gopTable[i].previousFrames].size
+ VIDEO_SINGLETON::instance ()->gopTable[i].VIDEO_SINGLETON::instance ()->systemHeader,
+ VIDEO_SINGLETON::instance ()->gopTable[i].offset,
+ VIDEO_SINGLETON::instance ()->gopTable[i].headerSize,
+ VIDEO_SINGLETON::instance ()->gopTable[i].size,
+ VIDEO_SINGLETON::instance ()->gopTable[i].totalFrames,
+ VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames,
+ VIDEO_SINGLETON::instance ()->gopTable[i].firstIoffset,
+ VIDEO_SINGLETON::instance ()->frameTable[VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames].size
);
}
fprintf(stderr, "\nframe information:");
- for (i=0; i<numF; i++)
- fprintf(stderr, "%c%c%-8d", (i%10 ? '\0' : '\n'), frameTable[i].type, frameTable[i].size);
+ for (i=0; i<VIDEO_SINGLETON::instance ()->numF; i++)
+ fprintf(stderr, "%c%c%-8d", (i%10 ? '\0' : '\n'), VIDEO_SINGLETON::instance ()->frameTable[i].type, VIDEO_SINGLETON::instance ()->frameTable[i].size);
fprintf(stderr, "\n");
}
*/
- fseek(fp, systemHeader[0].offset+4, 0);
+ fseek(VIDEO_SINGLETON::instance ()->fp, VIDEO_SINGLETON::instance ()->systemHeader[0].offset+4, 0);
nextByte;
- horizontalSize = ((int)nb <<4) & 0xff0;
+ VIDEO_SINGLETON::instance ()->horizontalSize = ((int)nb <<4) & 0xff0;
nextByte;
- horizontalSize |= (nb >>4) & 0x0f;
- verticalSize = ((int)nb <<8) & 0xf00;
+ VIDEO_SINGLETON::instance ()->horizontalSize |= (nb >>4) & 0x0f;
+ VIDEO_SINGLETON::instance ()->verticalSize = ((int)nb <<8) & 0xf00;
nextByte;
- verticalSize |= (int)nb & 0xff;
+ VIDEO_SINGLETON::instance ()->verticalSize |= (int)nb & 0xff;
nextByte;
- pelAspectRatio = ((int)nb >> 4) & 0x0f;
- pictureRate = (int)nb & 0x0f;
+ VIDEO_SINGLETON::instance ()->pelAspectRatio = ((int)nb >> 4) & 0x0f;
+ VIDEO_SINGLETON::instance ()->pictureRate = (int)nb & 0x0f;
nextByte;
nextByte;
nextByte;
- vbvBufferSize = ((int)nb << 5) & 0x3e0;
+ VIDEO_SINGLETON::instance ()->vbvBufferSize = ((int)nb << 5) & 0x3e0;
nextByte;
- vbvBufferSize |= ((int)nb >>3) & 0x1f;
+ VIDEO_SINGLETON::instance ()->vbvBufferSize |= ((int)nb >>3) & 0x1f;
/*
fprintf(stderr, "SysHeader info: hsize-%d, vsize-%d, pelAspect-%d, rate-%d, vbv-%d.\n",
- horizontalSize, verticalSize, pelAspectRatio, pictureRate, vbvBufferSize);
+ VIDEO_SINGLETON::instance ()->horizontalSize, VIDEO_SINGLETON::instance ()->verticalSize, VIDEO_SINGLETON::instance ()->pelAspectRatio, VIDEO_SINGLETON::instance ()->pictureRate, VIDEO_SINGLETON::instance ()->vbvBufferSize);
*/
WriteInfoToFile();
}
@@ -1009,17 +1009,17 @@ static int init_MPEG1_video_file(void)
{
int i, j = 20;
- for (i = numG - 1;; i --) {
- if (gopTable[i].offset < 4235260) {
- fprintf(stderr, "group %d: offset %ld\n", i, gopTable[i].offset);
+ for (i = VIDEO_SINGLETON::instance ()->numG - 1;; i --) {
+ if (VIDEO_SINGLETON::instance ()->gopTable[i].offset < 4235260) {
+ fprintf(stderr, "group %d: offset %ld\n", i, VIDEO_SINGLETON::instance ()->gopTable[i].offset);
if (j -- == 0) break;
}
}
/*
- for (i = 0; i < numG; i ++) {
- if (gopTable[i].previousFrames > 1800) {
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numG; i ++) {
+ if (VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames > 1800) {
fprintf(stderr, "group %d: offset %ld pre-frames %d\n",
- i, gopTable[i].offset, gopTable[i].previousFrames);
+ i, VIDEO_SINGLETON::instance ()->gopTable[i].offset, VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames);
break;
}
}
@@ -1027,17 +1027,17 @@ static int init_MPEG1_video_file(void)
}
#endif
{
- firstPatternSize = gopTable[0].totalFrames;
- firstSendPattern = (char *)malloc(firstPatternSize);
- if (firstSendPattern == NULL)
+ VIDEO_SINGLETON::instance ()->firstPatternSize = VIDEO_SINGLETON::instance ()->gopTable[0].totalFrames;
+ VIDEO_SINGLETON::instance ()->firstSendPattern = (char *)malloc(VIDEO_SINGLETON::instance ()->firstPatternSize);
+ if (VIDEO_SINGLETON::instance ()->firstSendPattern == NULL)
{
- fprintf(stderr, "VS failed to allocate firstSendPattern for %d frames",
- firstPatternSize);
+ fprintf(stderr, "VS failed to allocate VIDEO_SINGLETON::instance ()->firstVIDEO_SINGLETON::instance ()->SendVIDEO_SINGLETON::Instance ()->Pattern for %d frames",
+ VIDEO_SINGLETON::instance ()->firstPatternSize);
perror("");
return 11;
}
}
- firstGopFrames = gopTable[0].totalFrames;
+ VIDEO_SINGLETON::instance ()->firstGopFrames = VIDEO_SINGLETON::instance ()->gopTable[0].totalFrames;
return 0;
}
@@ -1059,14 +1059,14 @@ static int INITvideo(void)
#endif
if (para.nameLength>0)
{
- result = CmdRead(videoFile, para.nameLength);
+ result = CmdRead(VIDEO_SINGLETON::instance ()->videoFile, para.nameLength);
if (result != 0)
return result;
}
if (Mpeg_Global::session_num > Mpeg_Global::session_limit || para.version != VERSION) {
char errmsg[128];
- cmd = CmdFAIL;
- CmdWrite((char *)&cmd, 1);
+ VIDEO_SINGLETON::instance ()->cmd = CmdFAIL;
+ CmdWrite((char *)&VIDEO_SINGLETON::instance ()->cmd, 1);
if (Mpeg_Global::session_num > Mpeg_Global::session_limit) {
sprintf(errmsg,
"Too many sessions being serviced, please try again later.\n");
@@ -1079,103 +1079,103 @@ static int INITvideo(void)
write_string(VIDEO_SINGLETON::instance ()->serviceSocket, errmsg);
exit(0);
}
- cmdsn = para.sn;
+ VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
/*
- fprintf(stderr, "MPEG file %s got.\n", videoFile);
+ fprintf(stderr, "MPEG file %s got.\n", VIDEO_SINGLETON::instance ()->videoFile);
*/
- videoFile[para.nameLength] = 0;
+ VIDEO_SINGLETON::instance ()->videoFile[para.nameLength] = 0;
- if (!strncasecmp("LiveVideo", videoFile, 9)) {
- if (OpenLiveVideo(&video_format, &horizontalSize,
- &verticalSize, &averageFrameSize,
- &fps, &pelAspectRatio) == -1) {
+ if (!strncasecmp("LiveVideo", VIDEO_SINGLETON::instance ()->videoFile, 9)) {
+ if (OpenLiveVideo(&VIDEO_SINGLETON::instance ()->video_format, &VIDEO_SINGLETON::instance ()->horizontalSize,
+ &VIDEO_SINGLETON::instance ()->verticalSize, &VIDEO_SINGLETON::instance ()->averageFrameSize,
+ &VIDEO_SINGLETON::instance ()->fps, &VIDEO_SINGLETON::instance ()->pelAspectRatio) == -1) {
failureType = 100;
goto failure;
}
- if (video_format == VIDEO_MPEG2) {
+ if (VIDEO_SINGLETON::instance ()->video_format == VIDEO_MPEG2) {
failureType = 101;
goto failure;
}
VIDEO_SINGLETON::instance ()->live_source = 1;
- fileSize =0x7fffffff;
- maxS = maxG = maxI = maxP = maxB = minS = minG = minI = minP = minB = 1;
- numS = numG = numF = numI = 0x7fffffff;
- numP = numB = 0;
- vbvBufferSize = 1;
- firstGopFrames = 1;
- patternSize = 1;
- pattern[0] = 'I';
- pattern[1] = 0;
- packetBufSize = verticalSize * horizontalSize * 3;
- packet = (VideoPacket *)malloc(sizeof(VideoMessage) + sizeof(VideoPacket) +
- packetBufSize);
- if (packet == NULL)
+ VIDEO_SINGLETON::instance ()->fileSize =0x7fffffff;
+ VIDEO_SINGLETON::instance ()->maxS = VIDEO_SINGLETON::instance ()->maxG = VIDEO_SINGLETON::instance ()->maxI = VIDEO_SINGLETON::instance ()->maxP = VIDEO_SINGLETON::instance ()->maxB = VIDEO_SINGLETON::instance ()->minS = VIDEO_SINGLETON::instance ()->minG = VIDEO_SINGLETON::instance ()->minI = VIDEO_SINGLETON::instance ()->minP = VIDEO_SINGLETON::instance ()->minB = 1;
+ VIDEO_SINGLETON::instance ()->numS = VIDEO_SINGLETON::instance ()->numG = VIDEO_SINGLETON::instance ()->numF = VIDEO_SINGLETON::instance ()->numI = 0x7fffffff;
+ VIDEO_SINGLETON::instance ()->numP = VIDEO_SINGLETON::instance ()->numB = 0;
+ VIDEO_SINGLETON::instance ()->vbvBufferSize = 1;
+ VIDEO_SINGLETON::instance ()->firstGopFrames = 1;
+ VIDEO_SINGLETON::instance ()->patternSize = 1;
+ VIDEO_SINGLETON::instance ()->pattern[0] = 'I';
+ VIDEO_SINGLETON::instance ()->pattern[1] = 0;
+ VIDEO_SINGLETON::instance ()->packetBufSize = VIDEO_SINGLETON::instance ()->verticalSize * VIDEO_SINGLETON::instance ()->horizontalSize * 3;
+ VIDEO_SINGLETON::instance ()->packet = (VideoPacket *)malloc(sizeof(VideoMessage) + sizeof(VideoPacket) +
+ VIDEO_SINGLETON::instance ()->packetBufSize);
+ if (VIDEO_SINGLETON::instance ()->packet == NULL)
{
- perror("Error: VS error on malloc packet buffer");
+ perror("Error: VS error on malloc VIDEO_SINGLETON::instance ()->packet buffer");
exit(1);
}
- packet = (VideoPacket *)((char *)packet + sizeof(VideoMessage));
+ VIDEO_SINGLETON::instance ()->packet = (VideoPacket *)((char *)VIDEO_SINGLETON::instance ()->packet + sizeof(VideoMessage));
}
else {
static double pictureRateTable[] = {23.976, 24, 25, 29.97, 30, 50, 59.94, 60};
- video_format = VIDEO_MPEG1;
+ VIDEO_SINGLETON::instance ()->video_format = VIDEO_MPEG1;
failureType = init_MPEG1_video_file();
if (failureType) goto failure;
- fps = pictureRateTable[pictureRate - 1];
+ VIDEO_SINGLETON::instance ()->fps = pictureRateTable[VIDEO_SINGLETON::instance ()->pictureRate - 1];
}
{
INITvideoReply reply;
- reply.totalHeaders = htonl(numS);
- reply.totalGroups = htonl(numG);
- reply.totalFrames = htonl(numF);
- reply.sizeIFrame = htonl(maxI);
- reply.sizePFrame = htonl(maxP);
- reply.sizeBFrame = htonl(maxB);
- reply.sizeSystemHeader = htonl(maxS);
- reply.sizeGop = htonl(maxG);
- reply.averageFrameSize = htonl(averageFrameSize);
- reply.verticalSize = htonl(verticalSize);
- reply.horizontalSize = htonl(horizontalSize);
- reply.pelAspectRatio = htonl(pelAspectRatio);
- reply.pictureRate1000 = htonl((int)(fps * 1000));
- reply.vbvBufferSize = htonl(vbvBufferSize);
- reply.firstGopFrames = htonl(firstGopFrames);
- reply.patternSize = htonl(patternSize);
- strncpy(reply.pattern, pattern, PATTERN_SIZE);
+ reply.totalHeaders = htonl(VIDEO_SINGLETON::instance ()->numS);
+ reply.totalGroups = htonl(VIDEO_SINGLETON::instance ()->numG);
+ reply.totalFrames = htonl(VIDEO_SINGLETON::instance ()->numF);
+ reply.sizeIFrame = htonl(VIDEO_SINGLETON::instance ()->maxI);
+ reply.sizePFrame = htonl(VIDEO_SINGLETON::instance ()->maxP);
+ reply.sizeBFrame = htonl(VIDEO_SINGLETON::instance ()->maxB);
+ reply.sizeSystemHeader = htonl(VIDEO_SINGLETON::instance ()->maxS);
+ reply.sizeGop = htonl(VIDEO_SINGLETON::instance ()->maxG);
+ reply.averageFrameSize = htonl(VIDEO_SINGLETON::instance ()->averageFrameSize);
+ reply.verticalSize = htonl(VIDEO_SINGLETON::instance ()->verticalSize);
+ reply.horizontalSize = htonl(VIDEO_SINGLETON::instance ()->horizontalSize);
+ reply.pelAspectRatio = htonl(VIDEO_SINGLETON::instance ()->pelAspectRatio);
+ reply.pictureRate1000 = htonl((int)(VIDEO_SINGLETON::instance ()->fps * 1000));
+ reply.vbvBufferSize = htonl(VIDEO_SINGLETON::instance ()->vbvBufferSize);
+ reply.firstGopFrames = htonl(VIDEO_SINGLETON::instance ()->firstGopFrames);
+ reply.patternSize = htonl(VIDEO_SINGLETON::instance ()->patternSize);
+ strncpy(reply.pattern, VIDEO_SINGLETON::instance ()->pattern, PATTERN_SIZE);
reply.live = htonl(VIDEO_SINGLETON::instance ()->live_source);
- reply.format = htonl(video_format);
+ reply.format = htonl(VIDEO_SINGLETON::instance ()->video_format);
- CmdWrite((char *)&cmd, 1);
+ CmdWrite((char *)&VIDEO_SINGLETON::instance ()->cmd, 1);
CmdWrite((char *)&reply, sizeof(reply));
- /* write the first SH, GOP and IFrame to serviceSocket (TCP),
- using code for SendPacket() */
+ /* write the first SH, GOP and IFrame to VIDEO_SINGLETON::instance ()->serviceSocket (TCP),
+ using code for SendVIDEO_SINGLETON::Instance ()->Packet() */
{
- int tmpSocket = videoSocket;
+ int tmpSocket = VIDEO_SINGLETON::instance ()->videoSocket;
if (VIDEO_SINGLETON::instance ()->live_source) StartPlayLiveVideo();
- videoSocket = VIDEO_SINGLETON::instance ()->serviceSocket;
+ VIDEO_SINGLETON::instance ()->videoSocket = VIDEO_SINGLETON::instance ()->serviceSocket;
if (VIDEO_SINGLETON::instance ()->live_source) {
int frame = 0;
SendPicture(&frame);
}
- else if (video_format == VIDEO_MPEG1) {
+ else if (VIDEO_SINGLETON::instance ()->video_format == VIDEO_MPEG1) {
SendPacket(1, 0, 0, 0);
}
else {
- fprintf(stderr, "VS: video_format %d not supported.\n",
- video_format);
+ fprintf(stderr, "VS: VIDEO_SINGLETON::instance ()->video_format %d not supported.\n",
+ VIDEO_SINGLETON::instance ()->video_format);
}
- videoSocket = tmpSocket;
+ VIDEO_SINGLETON::instance ()->videoSocket = tmpSocket;
if (VIDEO_SINGLETON::instance ()->live_source) StopPlayLiveVideo();
}
@@ -1187,9 +1187,9 @@ static int INITvideo(void)
{
char * msg;
char errmsg[64];
- cmd = CmdFAIL;
+ VIDEO_SINGLETON::instance ()->cmd = CmdFAIL;
sprintf(errmsg, "VS failed to alloc internal buf (type %d)", failureType);
- CmdWrite((char *)&cmd, 1);
+ CmdWrite((char *)&VIDEO_SINGLETON::instance ()->cmd, 1);
msg = failureType == 1 ? "not a complete MPEG stream" :
failureType == 2 ? "can't open MPEG file" :
failureType == 3 ? "MPEG file is not seekable" :
@@ -1205,22 +1205,22 @@ static int INITvideo(void)
}
#define CheckGroupRange(pnextGroup) \
-{ if ((pnextGroup) < 0 || (pnextGroup) >= numG) \
- { fprintf(stderr, "VS: %d.nextGroup(%d) out of range (%d).\n", cmd, (pnextGroup), numG); \
+{ if ((pnextGroup) < 0 || (pnextGroup) >= VIDEO_SINGLETON::instance ()->numG) \
+ { fprintf(stderr, "VS: %d.VIDEO_SINGLETON::instance ()->nextGroup(%d) out of range (%d).\n", VIDEO_SINGLETON::instance ()->cmd, (pnextGroup), VIDEO_SINGLETON::instance ()->numG); \
return 0; } }
#define CheckFrameRange(pnextFrame) \
-{ if ((pnextFrame) < 0 || (pnextFrame) >= numF) \
- { fprintf(stderr, "VS: %d.nextFrame(%d) out of range (%d).\n", cmd, (pnextFrame), numF); \
+{ if ((pnextFrame) < 0 || (pnextFrame) >= VIDEO_SINGLETON::instance ()->numF) \
+ { fprintf(stderr, "VS: %d.VIDEO_SINGLETON::instance ()->nextFrame(%d) out of range (%d).\n", VIDEO_SINGLETON::instance ()->cmd, (pnextFrame), VIDEO_SINGLETON::instance ()->numF); \
return 0; } }
static int FrameToGroup(int * frame)
{
int f = * frame;
int i = 0;
- while (i < numG && gopTable[i].previousFrames <= f) i++;
+ while (i < VIDEO_SINGLETON::instance ()->numG && VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames <= f) i++;
i --;
- * frame = f - gopTable[i].previousFrames;
+ * frame = f - VIDEO_SINGLETON::instance ()->gopTable[i].previousFrames;
return i;
}
@@ -1238,13 +1238,13 @@ static int POSITIONvideo()
if (VIDEO_SINGLETON::instance ()->live_source) return 0;
#ifdef NeedByteOrderConversion
- para.nextGroup = ntohl(para.nextGroup);
+ para.VIDEO_SINGLETON::instance ()->nextGroup = ntohl(para.VIDEO_SINGLETON::instance ()->nextGroup);
para.sn = ntohl(para.sn);
#endif
CheckGroupRange(para.nextGroup);
- cmdsn = para.sn;
- result = SendPacket(numS>1 || para.nextGroup == 0, para.nextGroup, 0, 0);
+ VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
+ result = SendPacket(VIDEO_SINGLETON::instance ()->numS>1 || para.nextGroup == 0, para.nextGroup, 0, 0);
return result;
}
@@ -1260,23 +1260,23 @@ static int STEPvideo()
return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
- para.nextFrame = ntohl(para.nextFrame);
+ para.VIDEO_SINGLETON::instance ()->nextFrame = ntohl(para.VIDEO_SINGLETON::instance ()->nextFrame);
#endif
- cmdsn = para.sn;
+ VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
if (!VIDEO_SINGLETON::instance ()->live_source) {
- if (para.nextFrame >= numF) /* send SEQ_END */
+ if (para.nextFrame >= VIDEO_SINGLETON::instance ()->numF) /* send SEQ_END */
{
tag = 1;
para.nextFrame --;
}
/*
- fprintf(stderr, "STEP . . .frame-%d\n", para.nextFrame);
+ fprintf(stderr, "STEP . . .frame-%d\n", para.VIDEO_SINGLETON::instance ()->nextFrame);
*/
CheckFrameRange(para.nextFrame);
group = FrameToGroup(&para.nextFrame);
- if (precmd != CmdSTEP && !tag ) {
+ if (VIDEO_SINGLETON::instance ()->precmd != CmdSTEP && !tag ) {
result = SendReferences(group, para.nextFrame);
if (result < 0 )
return result;
@@ -1287,8 +1287,8 @@ static int STEPvideo()
if (VIDEO_SINGLETON::instance ()->live_source) {
SendPicture(&para.nextFrame);
}
- else if (video_format == VIDEO_MPEG1) {
- SendPacket(numS>1, group, tag ? numF : para.nextFrame, 0);
+ else if (VIDEO_SINGLETON::instance ()->video_format == VIDEO_MPEG1) {
+ SendPacket(VIDEO_SINGLETON::instance ()->numS>1, group, tag ? VIDEO_SINGLETON::instance ()->numF : para.nextFrame, 0);
}
else {
fprintf(stderr, "VS: wierd1\n");
@@ -1309,7 +1309,7 @@ static void TimerProcessing(void);
static void timerHandler(int sig)
{
int val2, val3;
- int usec = currentUPF + addedUPF;
+ int usec = VIDEO_SINGLETON::instance ()->currentUPF + VIDEO_SINGLETON::instance ()->addedUPF;
if (Mpeg_Global::drift_ppm) {
usec -= (int)((double)usec * (double)Mpeg_Global::drift_ppm / 1000000.0);
@@ -1321,7 +1321,7 @@ static void timerHandler(int sig)
val3 = get_duration(preTimerVal, (val2 = get_usec()));
/*
if (val3 >= usec<< 1))
- fprintf(stderr, "Slower: %d out of currentUPF %d.\n",
+ fprintf(stderr, "Slower: %d out of VIDEO_SINGLETON::instance ()->currentUPF %d.\n",
val3, usec);
else
fprintf(stderr, "+\n");
@@ -1335,25 +1335,25 @@ static void timerHandler(int sig)
TimerProcessing();
val2 --;
}
- addedSignals += val2;
+ VIDEO_SINGLETON::instance ()->addedSignals += val2;
- if (addedSignals) {
+ if (VIDEO_SINGLETON::instance ()->addedSignals) {
val2 = timerAdjust;
if (timerAdjust < MAX_TIMER_ADJUST) {
- timerAdjust += addedSignals * SPEEDUP_INV_SCALE;
+ timerAdjust += VIDEO_SINGLETON::instance ()->addedSignals * SPEEDUP_INV_SCALE;
if (val2 < SPEEDUP_INV_SCALE) {
TimerSpeed();
}
}
else {
/*
- fprintf(stderr, "VS timerAdjust %d, addedSignals %d, timerFrame %d\n",
- timerAdjust, addedSignals, timerFrame);
+ fprintf(stderr, "VS timerAdjust %d, VIDEO_SINGLETON::instance ()->addedSignals %d, timerFrame %d\n",
+ timerAdjust, VIDEO_SINGLETON::instance ()->addedSignals, timerFrame);
*/
- for (val3 = 0; val3 < addedSignals; val3 ++)
+ for (val3 = 0; val3 < VIDEO_SINGLETON::instance ()->addedSignals; val3 ++)
TimerProcessing();
}
- addedSignals = 0;
+ VIDEO_SINGLETON::instance ()->addedSignals = 0;
}
}
@@ -1375,33 +1375,33 @@ static void TimerProcessing(void)
if ((--timerAdjust) == 0)
TimerSpeed();
}
- if (cmd == CmdPLAY)
+ if (VIDEO_SINGLETON::instance ()->cmd == CmdPLAY)
{
- if (timerGroup == numG - 1 && timerFrame >= gopTable[timerGroup].totalFrames - 1)
+ if (timerGroup == VIDEO_SINGLETON::instance ()->numG - 1 && timerFrame >= VIDEO_SINGLETON::instance ()->gopTable[timerGroup].totalFrames - 1)
{
- timerFrame ++; /* force sending of END_SEQ when PLAY cmd */
+ timerFrame ++; /* force sending of END_SEQ when PLAY VIDEO_SINGLETON::instance ()->cmd */
StopTimer();
return;
}
else
{
timerFrame ++;
- if (timerFrame >= gopTable[timerGroup].totalFrames)
+ if (timerFrame >= VIDEO_SINGLETON::instance ()->gopTable[timerGroup].totalFrames)
{
timerGroup ++;
timerFrame = 0;
- timerHeader = gopTable[timerGroup].systemHeader;
+ timerHeader = VIDEO_SINGLETON::instance ()->gopTable[timerGroup].systemHeader;
}
}
}
else {
- if (cmd == CmdFF) {
- if (timerGroup == numG - 1) {
+ if (VIDEO_SINGLETON::instance ()->cmd == CmdFF) {
+ if (timerGroup == VIDEO_SINGLETON::instance ()->numG - 1) {
StopTimer();
return;
}
timerGroup ++;
- timerHeader = gopTable[timerGroup].systemHeader;
+ timerHeader = VIDEO_SINGLETON::instance ()->gopTable[timerGroup].systemHeader;
}
else {
if (timerGroup == 0) {
@@ -1409,16 +1409,16 @@ static void TimerProcessing(void)
return;
}
timerGroup --;
- timerHeader = gopTable[timerGroup].systemHeader;
+ timerHeader = VIDEO_SINGLETON::instance ()->gopTable[timerGroup].systemHeader;
}
}
}
static void StartTimer(void)
{
- addedUPF = 0;
- addedSignals = 0;
- timerAdjust = (VStimeAdvance * SPEEDUP_INV_SCALE) / currentUPF;
+ VIDEO_SINGLETON::instance ()->addedUPF = 0;
+ VIDEO_SINGLETON::instance ()->addedSignals = 0;
+ timerAdjust = (VIDEO_SINGLETON::instance ()->VStimeAdvance * SPEEDUP_INV_SCALE) / VIDEO_SINGLETON::instance ()->currentUPF;
/*
SFprintf(stderr, "VS StartTimer(): fast-start frames %d\n",
timerAdjust / SPEEDUP_INV_SCALE);
@@ -1428,14 +1428,14 @@ static void StartTimer(void)
timerOn = 1;
preTimerVal = get_usec();
/*
- fprintf(stderr, "VS: timer started at %d upf.\n", currentUPF + addedUPF);
+ fprintf(stderr, "VS: timer started at %d upf.\n", VIDEO_SINGLETON::instance ()->currentUPF + VIDEO_SINGLETON::instance ()->addedUPF);
*/
}
static void TimerSpeed(void)
{
struct itimerval val;
- int usec = currentUPF + addedUPF;
+ int usec = VIDEO_SINGLETON::instance ()->currentUPF + VIDEO_SINGLETON::instance ()->addedUPF;
if (Mpeg_Global::drift_ppm) {
/*
int drift = (double)usec * (double)Mpeg_Global::drift_ppm / 1000000.0;
@@ -1452,8 +1452,8 @@ static void TimerSpeed(void)
setitimer(ITIMER_REAL, &val, NULL);
/*
SFprintf(stderr,
- "VS TimerSpeed() at %s speed, timerAdjust %d addedSignals %d.\n",
- (timerAdjust > 1) ? "higher" : "normal", timerAdjust, addedSignals);
+ "VS TimerSpeed() at %s speed, timerAdjust %d VIDEO_SINGLETON::instance ()->addedSignals %d.\n",
+ (timerAdjust > 1) ? "higher" : "normal", timerAdjust, VIDEO_SINGLETON::instance ()->addedSignals);
*/
}
@@ -1477,35 +1477,35 @@ static void GetFeedBack()
int timerUsec;
if (FBread((char *)&para, sizeof(para)) == -1 ||
- ntohl(para.cmdsn) != cmdsn) {
+ ntohl(para.cmdsn) != VIDEO_SINGLETON::instance ()->cmdsn) {
/*
- SFprintf(stderr, "VS warning: a FB packet discarded.\n");
+ SFprintf(stderr, "VS warning: a FB VIDEO_SINGLETON::instance ()->packet discarded.\n");
*/
return;
}
#ifdef NeedByteOrderConversion
- para.needHeader = ntohl(para.needHeader);
+ para.VIDEO_SINGLETON::instance ()->needHeader = ntohl(para.VIDEO_SINGLETON::instance ()->needHeader);
para.addUsecPerFrame = ntohl(para.addUsecPerFrame);
para.addFrames = ntohl(para.addFrames);
- para.sendPatternGops = ntohl(para.sendPatternGops);
- para.frameRateLimit1000 = ntohl(para.frameRateLimit1000);
+ para.VIDEO_SINGLETON::instance ()->sendVIDEO_SINGLETON::Instance ()->PatternGops = ntohl(para.VIDEO_SINGLETON::instance ()->sendVIDEO_SINGLETON::Instance ()->PatternGops);
+ para.VIDEO_SINGLETON::instance ()->frameRateLimit1000 = ntohl(para.VIDEO_SINGLETON::instance ()->frameRateLimit1000);
#endif
- frameRateLimit = para.frameRateLimit1000 / 1000.0;
- sendPatternGops = para.sendPatternGops;
+ VIDEO_SINGLETON::instance ()->frameRateLimit = para.frameRateLimit1000 / 1000.0;
+ VIDEO_SINGLETON::instance ()->sendPatternGops = para.sendPatternGops;
if (!timerOn) return;
- needHeader = para.needHeader;
- memcpy(sendPattern, para.sendPattern, PATTERN_SIZE);
+ VIDEO_SINGLETON::instance ()->needHeader = para.needHeader;
+ memcpy(VIDEO_SINGLETON::instance ()->sendPattern, para.sendPattern, PATTERN_SIZE);
if (para.addFrames <= 0 || timerAdjust < MAX_TIMER_ADJUST)
{
timerAdjust += para.addFrames * SPEEDUP_INV_SCALE;
TimerSpeed();
}
else /* drastic compensation for big gap */
- addedSignals += para.addFrames;
+ VIDEO_SINGLETON::instance ()->addedSignals += para.addFrames;
if (para.addUsecPerFrame) {
- addedUPF += para.addUsecPerFrame;
+ VIDEO_SINGLETON::instance ()->addedUPF += para.addUsecPerFrame;
TimerSpeed();
}
/*
@@ -1520,31 +1520,31 @@ static int FastVideoPlay(void)
FFpara para;
int preGroup = -1;
int preHeader = -1;
- int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : videoSocket) + 1;
+ int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > VIDEO_SINGLETON::instance ()->videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : VIDEO_SINGLETON::instance ()->videoSocket) + 1;
result = CmdRead((char *)&para, sizeof(para));
if (result != 0)
return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
- para.nextGroup = ntohl(para.nextGroup);
+ para.VIDEO_SINGLETON::instance ()->nextGroup = ntohl(para.VIDEO_SINGLETON::instance ()->nextGroup);
para.usecPerFrame = ntohl(para.usecPerFrame);
para.framesPerSecond = ntohl(para.framesPerSecond);
- para.VStimeAdvance = ntohl(para.VStimeAdvance);
+ para.VIDEO_SINGLETON::instance ()->VStimeAdvance = ntohl(para.VIDEO_SINGLETON::instance ()->VStimeAdvance);
#endif
if (VIDEO_SINGLETON::instance ()->live_source) return 0;
- VStimeAdvance = para.VStimeAdvance;
+ VIDEO_SINGLETON::instance ()->VStimeAdvance = para.VStimeAdvance;
/*
- fprintf(stderr, "VStimeAdvance from client: %d\n", VStimeAdvance);
+ fprintf(stderr, "VIDEO_SINGLETON::instance ()->VStimeAdvance from client: %d\n", VIDEO_SINGLETON::instance ()->VStimeAdvance);
*/
CheckGroupRange(para.nextGroup);
- cmdsn = para.sn;
+ VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
timerGroup = para.nextGroup;
timerFrame = 0;
- timerHeader = gopTable[timerGroup].systemHeader;
- currentUPF = para.usecPerFrame;
+ timerHeader = VIDEO_SINGLETON::instance ()->gopTable[timerGroup].systemHeader;
+ VIDEO_SINGLETON::instance ()->currentUPF = para.usecPerFrame;
StartTimer();
for (;;)
@@ -1556,14 +1556,14 @@ static int FastVideoPlay(void)
if (preGroup != timerGroup)
{
SendPacket(preHeader != timerHeader, timerGroup, 0,
- para.usecPerFrame * patternSize >> 2);
+ para.usecPerFrame * VIDEO_SINGLETON::instance ()->patternSize >> 2);
preHeader = timerHeader;
preGroup = timerGroup;
}
FD_ZERO(&read_mask);
FD_SET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask);
- FD_SET(videoSocket, &read_mask);
+ FD_SET(VIDEO_SINGLETON::instance ()->videoSocket, &read_mask);
#ifdef _HPUX_SOURCE
if (select(nfds, (int *)&read_mask, NULL, NULL, NULL) == -1)
#else
@@ -1578,27 +1578,27 @@ static int FastVideoPlay(void)
}
if (FD_ISSET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask)) /* stop */
{
- result = CmdRead((char *)&cmd, 1);
+ result = CmdRead((char *)&VIDEO_SINGLETON::instance ()->cmd, 1);
if (result != 0)
return result;
- if (cmd == CmdCLOSE) {
+ if (VIDEO_SINGLETON::instance ()->cmd == CmdCLOSE) {
exit(0);
}
- else if (cmd != CmdSTOP) {
- fprintf(stderr, "VS error: cmd=%d while STOP is expected.\n", cmd);
- normalExit = 0;
+ else if (VIDEO_SINGLETON::instance ()->cmd != CmdSTOP) {
+ fprintf(stderr, "VS error: VIDEO_SINGLETON::instance ()->cmd=%d while STOP is expected.\n", VIDEO_SINGLETON::instance ()->cmd);
+ VIDEO_SINGLETON::instance ()->normalExit = 0;
exit(1);
}
- result = CmdRead((char *)&cmdsn, sizeof(int));
+ result = CmdRead((char *)&VIDEO_SINGLETON::instance ()->cmdsn, sizeof(int));
if (result != 0 )
return result;
#ifdef NeedByteOrderConversion
- cmdsn = ntohl(cmdsn);
+ VIDEO_SINGLETON::instance ()->cmdsn = ntohl(VIDEO_SINGLETON::instance ()->cmdsn);
#endif
StopTimer();
break;
}
- if (FD_ISSET(videoSocket, &read_mask)) /* feedback, speed adjustment */
+ if (FD_ISSET(VIDEO_SINGLETON::instance ()->videoSocket, &read_mask)) /* feedback, speed adjustment */
{
GetFeedBack();
}
@@ -1624,8 +1624,8 @@ static void FBvideo()
static void ComputeFirstSendPattern(float limit)
{
- char * buf = firstSendPattern;
- int len = firstPatternSize;
+ char * buf = VIDEO_SINGLETON::instance ()->firstSendPattern;
+ int len = VIDEO_SINGLETON::instance ()->firstPatternSize;
char * pat = (char *)malloc(len);
int f;
@@ -1635,7 +1635,7 @@ static void ComputeFirstSendPattern(float limit)
exit(1);
}
for (f = 0; f < len; f ++) {
- pat[f] = frameTable[f].type;
+ pat[f] = VIDEO_SINGLETON::instance ()->frameTable[f].type;
}
memset(buf, 0, len);
@@ -1643,7 +1643,7 @@ static void ComputeFirstSendPattern(float limit)
limit = 1.0;
f = (int)((double)len *
- ((double)limit / (1000000.0 / (double)currentUPF)) + 0.5);
+ ((double)limit / (1000000.0 / (double)VIDEO_SINGLETON::instance ()->currentUPF)) + 0.5);
/* rounded to integer, instead of truncated */
if (f >= len)
f = len;
@@ -1654,7 +1654,7 @@ static void ComputeFirstSendPattern(float limit)
/*
f = len - f;
- fprintf(stderr, "FirstSendPattern (%d frames dropped): ", f);
+ fprintf(stderr, "VIDEO_SINGLETON::instance ()->FirstVIDEO_SINGLETON::instance ()->SendVIDEO_SINGLETON::Instance ()->Pattern (%d frames dropped): ", f);
{
int i;
for (i = 0; i < len; i ++)
@@ -1671,21 +1671,21 @@ static int PLAYliveVideo(PLAYpara * para)
int count;
int first_frame;
int frame = para->nextFrame;
- int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : videoSocket) + 1;
+ int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > VIDEO_SINGLETON::instance ()->videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : VIDEO_SINGLETON::instance ()->videoSocket) + 1;
struct fd_set read_mask;
struct timeval tval = {0, 0};
double ratio;
int result;
- currentUPF = (int)(1000000.0 / fps); /* ignore para.usecPerFrame */
- if (frameRateLimit < fps) {
+ VIDEO_SINGLETON::instance ()->currentUPF = (int)(1000000.0 / VIDEO_SINGLETON::instance ()->fps); /* ignore para.usecPerFrame */
+ if (VIDEO_SINGLETON::instance ()->frameRateLimit < VIDEO_SINGLETON::instance ()->fps) {
doscale = 1;
- ratio = min(frameRateLimit, fps) / fps;
+ ratio = min(VIDEO_SINGLETON::instance ()->frameRateLimit, VIDEO_SINGLETON::instance ()->fps) / VIDEO_SINGLETON::instance ()->fps;
first_frame = frame;
count = 0;
/*
- fprintf(stderr, "doscale %d, frameRateLimit %5.2f, fps %5.2f, ratio %5.2f\n",
- doscale, frameRateLimit, fps, ratio);
+ fprintf(stderr, "doscale %d, VIDEO_SINGLETON::instance ()->frameRateLimit %5.2f, VIDEO_SINGLETON::instance ()->fps %5.2f, ratio %5.2f\n",
+ doscale, VIDEO_SINGLETON::instance ()->frameRateLimit, VIDEO_SINGLETON::instance ()->fps, ratio);
*/
}
else doscale = 0;
@@ -1705,7 +1705,7 @@ static int PLAYliveVideo(PLAYpara * para)
FD_ZERO(&read_mask);
FD_SET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask);
- FD_SET(videoSocket, &read_mask);
+ FD_SET(VIDEO_SINGLETON::instance ()->videoSocket, &read_mask);
#ifdef _HPUX_SOURCE
if (select(nfds, (int *)&read_mask, NULL, NULL, &tval) == -1)
#else
@@ -1730,15 +1730,15 @@ static int PLAYliveVideo(PLAYpara * para)
exit(0);
}
else if (tmp == CmdSTOP) {
- cmd = tmp;
+ VIDEO_SINGLETON::instance ()->cmd = tmp;
/*
- fprintf(stderr, "VS: CmdSTOP. . .\n");
+ fprintf(stderr, "VS: VIDEO_SINGLETON::Instance ()->CmdSTOP. . .\n");
*/
- result = CmdRead((char *)&cmdsn, sizeof(int));
+ result = CmdRead((char *)&VIDEO_SINGLETON::instance ()->cmdsn, sizeof(int));
if (result != 0)
return result;
#ifdef NeedByteOrderConversion
- cmdsn = ntohl(cmdsn);
+ VIDEO_SINGLETON::instance ()->cmdsn = ntohl(VIDEO_SINGLETON::instance ()->cmdsn);
#endif
StopPlayLiveVideo();
break;
@@ -1747,7 +1747,7 @@ static int PLAYliveVideo(PLAYpara * para)
{
SPEEDpara para;
/*
- fprintf(stderr, "VS: CmdSPEED. . .\n");
+ fprintf(stderr, "VS: VIDEO_SINGLETON::Instance ()->CmdSPEED. . .\n");
*/
result = CmdRead((char *)&para, sizeof(para));
if (result != 0)
@@ -1756,35 +1756,35 @@ static int PLAYliveVideo(PLAYpara * para)
}
else
{
- fprintf(stderr, "VS error(live): cmd=%d while expect STOP/SPEED.\n", tmp);
- normalExit = 0;
+ fprintf(stderr, "VS error(live): VIDEO_SINGLETON::instance ()->cmd=%d while expect STOP/SPEED.\n", tmp);
+ VIDEO_SINGLETON::instance ()->normalExit = 0;
StopPlayLiveVideo();
exit(1);
}
}
- if (FD_ISSET(videoSocket, &read_mask)) /* feedback, only for frame rate
+ if (FD_ISSET(VIDEO_SINGLETON::instance ()->videoSocket, &read_mask)) /* feedback, only for frame rate
adjustment */
{
VideoFeedBackPara para;
if (FBread((char *)&para, sizeof(para)) == -1 ||
- ntohl(para.cmdsn) != cmdsn) {
+ ntohl(para.cmdsn) != VIDEO_SINGLETON::instance ()->cmdsn) {
/*
- SFprintf(stderr, "VS warning: a FB packet discarded.\n");
+ SFprintf(stderr, "VS warning: a FB VIDEO_SINGLETON::instance ()->packet discarded.\n");
*/
return 0;
}
#ifdef NeedByteOrderConversion
- para.frameRateLimit1000 = ntohl(para.frameRateLimit1000);
+ para.VIDEO_SINGLETON::instance ()->frameRateLimit1000 = ntohl(para.VIDEO_SINGLETON::instance ()->frameRateLimit1000);
#endif
- frameRateLimit = para.frameRateLimit1000 / 1000.0;
- if (frameRateLimit < fps) {
+ VIDEO_SINGLETON::instance ()->frameRateLimit = para.frameRateLimit1000 / 1000.0;
+ if (VIDEO_SINGLETON::instance ()->frameRateLimit < VIDEO_SINGLETON::instance ()->fps) {
doscale = 1;
- ratio = min(frameRateLimit, fps) / fps;
+ ratio = min(VIDEO_SINGLETON::instance ()->frameRateLimit, VIDEO_SINGLETON::instance ()->fps) / VIDEO_SINGLETON::instance ()->fps;
first_frame = frame;
count = 0;
/*
- fprintf(stderr, "doscale %d, frameRateLimit %5.2f, fps %5.2f, ratio %5.2f\n",
- doscale, frameRateLimit, fps, ratio);
+ fprintf(stderr, "doscale %d, VIDEO_SINGLETON::instance ()->frameRateLimit %5.2f, VIDEO_SINGLETON::instance ()->fps %5.2f, ratio %5.2f\n",
+ doscale, VIDEO_SINGLETON::instance ()->frameRateLimit, VIDEO_SINGLETON::instance ()->fps, ratio);
*/
}
else doscale = 0;
@@ -1808,45 +1808,45 @@ static int PLAYvideo()
return result;
#ifdef NeedByteOrderConversion
para.sn = ntohl(para.sn);
- para.nextFrame = ntohl(para.nextFrame);
+ para.VIDEO_SINGLETON::instance ()->nextFrame = ntohl(para.VIDEO_SINGLETON::instance ()->nextFrame);
para.usecPerFrame = ntohl(para.usecPerFrame);
para.framesPerSecond = ntohl(para.framesPerSecond);
- para.frameRateLimit1000 = ntohl(para.frameRateLimit1000);
+ para.VIDEO_SINGLETON::instance ()->frameRateLimit1000 = ntohl(para.VIDEO_SINGLETON::instance ()->frameRateLimit1000);
para.collectStat = ntohl(para.collectStat);
- para.sendPatternGops = ntohl(para.sendPatternGops);
- para.VStimeAdvance = ntohl(para.VStimeAdvance);
+ para.VIDEO_SINGLETON::instance ()->sendVIDEO_SINGLETON::Instance ()->PatternGops = ntohl(para.VIDEO_SINGLETON::instance ()->sendVIDEO_SINGLETON::Instance ()->PatternGops);
+ para.VIDEO_SINGLETON::instance ()->VStimeAdvance = ntohl(para.VIDEO_SINGLETON::instance ()->VStimeAdvance);
#endif
- frameRateLimit = para.frameRateLimit1000 / 1000.0;
- cmdsn = para.sn;
- currentUPF = para.usecPerFrame;
- VStimeAdvance = para.VStimeAdvance;
+ VIDEO_SINGLETON::instance ()->frameRateLimit = para.frameRateLimit1000 / 1000.0;
+ VIDEO_SINGLETON::instance ()->cmdsn = para.sn;
+ VIDEO_SINGLETON::instance ()->currentUPF = para.usecPerFrame;
+ VIDEO_SINGLETON::instance ()->VStimeAdvance = para.VStimeAdvance;
{
int ts = htonl(get_usec());
CmdWrite((char *)&ts, sizeof(int));
}
- if (VIDEO_SINGLETON::instance ()->live_source || video_format != VIDEO_MPEG1) {
+ if (VIDEO_SINGLETON::instance ()->live_source || VIDEO_SINGLETON::instance ()->video_format != VIDEO_MPEG1) {
if (VIDEO_SINGLETON::instance ()->live_source)
PLAYliveVideo (&para);
return 0;
}
- fprintf(stderr, "VStimeAdvance from client: %d\n", VStimeAdvance);
+ fprintf(stderr, "VIDEO_SINGLETON::instance ()->VStimeAdvance from client: %d\n", VIDEO_SINGLETON::instance ()->VStimeAdvance);
- sendPatternGops = para.sendPatternGops;
- ComputeFirstSendPattern(frameRateLimit);
+ VIDEO_SINGLETON::instance ()->sendPatternGops = para.sendPatternGops;
+ ComputeFirstSendPattern(VIDEO_SINGLETON::instance ()->frameRateLimit);
#ifdef STAT
if (para.collectStat)
- memset(framesSent, 0, (numF + 7)>>3);
+ memset(VIDEO_SINGLETON::instance ()->framesSent, 0, (VIDEO_SINGLETON::instance ()->numF + 7)>>3);
#endif
CheckFrameRange(para.nextFrame);
timerFrame = para.nextFrame;
timerGroup = FrameToGroup(&timerFrame);
- timerHeader = gopTable[timerGroup].systemHeader;
- memcpy(sendPattern, para.sendPattern, PATTERN_SIZE);
+ timerHeader = VIDEO_SINGLETON::instance ()->gopTable[timerGroup].systemHeader;
+ memcpy(VIDEO_SINGLETON::instance ()->sendPattern, para.sendPattern, PATTERN_SIZE);
result = SendReferences(timerGroup, timerFrame);
if (result < 0)
return result;
@@ -1860,7 +1860,7 @@ static int PLAYvideo()
int curHeader = timerHeader;
char * sp;
struct fd_set read_mask;
- int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : videoSocket) + 1;
+ int nfds = (VIDEO_SINGLETON::instance ()->serviceSocket > VIDEO_SINGLETON::instance ()->videoSocket ? VIDEO_SINGLETON::instance ()->serviceSocket : VIDEO_SINGLETON::instance ()->videoSocket) + 1;
if (preGroup != curGroup || curFrame != preFrame)
{
@@ -1869,7 +1869,7 @@ static int PLAYvideo()
if (curGroup == 0)
{
int i = curFrame + 1;
- while (i < firstPatternSize && !firstSendPattern[i])
+ while (i < VIDEO_SINGLETON::instance ()->firstPatternSize && !VIDEO_SINGLETON::instance ()->firstSendPattern[i])
{
frameStep ++;
i++;
@@ -1878,8 +1878,8 @@ static int PLAYvideo()
else /* (curGroup > 0) */
{
int i = curFrame + 1;
- sp = sendPattern + ((curGroup - 1) % sendPatternGops) * patternSize;
- while (i < patternSize && !sp[i])
+ sp = VIDEO_SINGLETON::instance ()->sendPattern + ((curGroup - 1) % VIDEO_SINGLETON::instance ()->sendPatternGops) * VIDEO_SINGLETON::instance ()->patternSize;
+ while (i < VIDEO_SINGLETON::instance ()->patternSize && !sp[i])
{
frameStep ++;
i++;
@@ -1887,12 +1887,12 @@ static int PLAYvideo()
}
if (curGroup == 0)
{
- if (firstSendPattern[curFrame])
+ if (VIDEO_SINGLETON::instance ()->firstSendPattern[curFrame])
sendStatus = 0;
- else /* (!firstSendPattern[curFrame]) */
+ else /* (!VIDEO_SINGLETON::instance ()->firstVIDEO_SINGLETON::instance ()->SendVIDEO_SINGLETON::Instance ()->Pattern[curFrame]) */
{
int i = curFrame - 1;
- while (i > 0 && !firstSendPattern[i])
+ while (i > 0 && !VIDEO_SINGLETON::instance ()->firstSendPattern[i])
i--;
if (i > preFrame)
/* the frame (curGroup, i) hasn't been sent yet */
@@ -1924,7 +1924,7 @@ static int PLAYvideo()
{
sendStatus = SendPacket(preHeader != curHeader,
curGroup, curFrame,
- (currentUPF + addedUPF) * frameStep);
+ (VIDEO_SINGLETON::instance ()->currentUPF + VIDEO_SINGLETON::instance ()->addedUPF) * frameStep);
if (!sendStatus)
{
preHeader = curHeader;
@@ -1933,8 +1933,8 @@ static int PLAYvideo()
#ifdef STAT
if (para.collectStat)
{
- int f = gopTable[curGroup].previousFrames + curFrame;
- framesSent[f>>3] |= (1 << (f % 8));
+ int f = VIDEO_SINGLETON::instance ()->gopTable[curGroup].previousFrames + curFrame;
+ VIDEO_SINGLETON::instance ()->framesSent[f>>3] |= (1 << (f % 8));
}
#endif
}
@@ -1943,7 +1943,7 @@ static int PLAYvideo()
FD_ZERO(&read_mask);
FD_SET(VIDEO_SINGLETON::instance ()->serviceSocket, &read_mask);
- FD_SET(videoSocket, &read_mask);
+ FD_SET(VIDEO_SINGLETON::instance ()->videoSocket, &read_mask);
#ifdef _HPUX_SOURCE
if (select(nfds, (int *)&read_mask, NULL, NULL, NULL) == -1)
#else
@@ -1967,15 +1967,15 @@ static int PLAYvideo()
exit(0);
}
else if (tmp == CmdSTOP) {
- cmd = tmp;
+ VIDEO_SINGLETON::instance ()->cmd = tmp;
/*
- fprintf(stderr, "VS: CmdSTOP. . .\n");
+ fprintf(stderr, "VS: VIDEO_SINGLETON::Instance ()->CmdSTOP. . .\n");
*/
- result = CmdRead((char *)&cmdsn, sizeof(int));
+ result = CmdRead((char *)&VIDEO_SINGLETON::instance ()->cmdsn, sizeof(int));
if (result != 0)
return result;
#ifdef NeedByteOrderConversion
- cmdsn = ntohl(cmdsn);
+ VIDEO_SINGLETON::instance ()->cmdsn = ntohl(VIDEO_SINGLETON::instance ()->cmdsn);
#endif
StopTimer();
break;
@@ -1984,7 +1984,7 @@ static int PLAYvideo()
{
SPEEDpara para;
/*
- fprintf(stderr, "VS: CmdSPEED. . .\n");
+ fprintf(stderr, "VS: VIDEO_SINGLETON::Instance ()->CmdSPEED. . .\n");
*/
result = CmdRead((char *)&para, sizeof(para));
if (result != 0)
@@ -1996,21 +1996,21 @@ static int PLAYvideo()
para.sendPatternGops = ntohl(para.sendPatternGops);
para.frameRateLimit1000 = ntohl(para.frameRateLimit1000);
#endif
- frameRateLimit = para.frameRateLimit1000 / 1000.0;
- sendPatternGops = para.sendPatternGops;
- currentUPF = para.usecPerFrame;
- addedUPF = 0;
- memcpy(sendPattern, para.sendPattern, PATTERN_SIZE);
+ VIDEO_SINGLETON::instance ()->frameRateLimit = para.frameRateLimit1000 / 1000.0;
+ VIDEO_SINGLETON::instance ()->sendPatternGops = para.sendPatternGops;
+ VIDEO_SINGLETON::instance ()->currentUPF = para.usecPerFrame;
+ VIDEO_SINGLETON::instance ()->addedUPF = 0;
+ memcpy(VIDEO_SINGLETON::instance ()->sendPattern, para.sendPattern, PATTERN_SIZE);
TimerSpeed();
}
else
{
- fprintf(stderr, "VS error: cmd=%d while expect STOP/SPEED.\n", tmp);
- normalExit = 0;
+ fprintf(stderr, "VS error: VIDEO_SINGLETON::instance ()->cmd=%d while expect STOP/SPEED.\n", tmp);
+ VIDEO_SINGLETON::instance ()->normalExit = 0;
exit(1);
}
}
- if (FD_ISSET(videoSocket, &read_mask)) /* feedBack, speed adjustment */
+ if (FD_ISSET(VIDEO_SINGLETON::instance ()->videoSocket, &read_mask)) /* feedBack, speed adjustment */
{
GetFeedBack();
}
@@ -2023,11 +2023,11 @@ static int PLAYvideo()
static void STATstream(void)
{
int i, j = 0;
- for (i = 0; i < numF; i++)
+ for (i = 0; i < VIDEO_SINGLETON::instance ()->numF; i++)
{
- short size = htons(frameTable[i].size);
- char type = frameTable[i].type;
- if (i == gopTable[j].previousFrames)
+ short size = htons(VIDEO_SINGLETON::instance ()->frameTable[i].size);
+ char type = VIDEO_SINGLETON::instance ()->frameTable[i].type;
+ if (i == VIDEO_SINGLETON::instance ()->gopTable[j].previousFrames)
{
type = tolower(type);
j ++;
@@ -2040,11 +2040,11 @@ static void STATstream(void)
static void STATsent(void)
{
#ifdef STAT
- CmdWrite((char *)framesSent, (numF + 7) / 8);
+ CmdWrite((char *)VIDEO_SINGLETON::instance ()->framesSent, (VIDEO_SINGLETON::instance ()->numF + 7) / 8);
#else
int i;
char zeroByte = 0;
- for (i = 0; i < (numF + 7) / 8; i++)
+ for (i = 0; i < (VIDEO_SINGLETON::instance ()->numF + 7) / 8; i++)
CmdWrite((char *)&zeroByte, 1);
#endif
}
@@ -2054,7 +2054,7 @@ static void on_exit_routine(void)
struct sockaddr_in peeraddr_in;
int size = sizeof(peeraddr_in);
/*
- if (!normalExit) {
+ if (!VIDEO_SINGLETON::instance ()->normalExit) {
fprintf(stderr, "VS exitting abnormally, dump core...\n");
kill(getpid(), SIGSEGV);
usleep(2000000);
@@ -2069,19 +2069,19 @@ static void on_exit_routine(void)
if (strncmp(inet_ntoa(peeraddr_in.sin_addr), "129.95.50", 9)) {
struct hostent *hp;
time_t val = time(NULL);
- char * buf = ctime(&start_time);
+ char * buf = ctime(&VIDEO_SINGLETON::instance ()->start_time);
hp = gethostbyaddr((char *)&(peeraddr_in.sin_addr), 4, AF_INET);
buf[strlen(buf)-1] = 0;
printf("%s: %s %3dm%02ds %dP %s\n",
buf,
hp == NULL ? inet_ntoa(peeraddr_in.sin_addr) : hp->h_name,
- (val - start_time) / 60, (val - start_time) % 60,
- pkts_sent, videoFile);
+ (val - VIDEO_SINGLETON::instance ()->start_time) / 60, (val - VIDEO_SINGLETON::instance ()->start_time) % 60,
+ VIDEO_SINGLETON::instance ()->pkts_sent, VIDEO_SINGLETON::instance ()->videoFile);
}
}
ComCloseConn(VIDEO_SINGLETON::instance ()->serviceSocket);
- ComCloseConn(videoSocket);
+ ComCloseConn(VIDEO_SINGLETON::instance ()->videoSocket);
}
int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
@@ -2089,23 +2089,23 @@ int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
int result;
VIDEO_SINGLETON::instance ()->serviceSocket = ctr_fd;
- videoSocket = data_fd;
- conn_tag = max_pkt_size;
+ VIDEO_SINGLETON::instance ()->videoSocket = data_fd;
+ VIDEO_SINGLETON::instance ()->conn_tag = max_pkt_size;
- if (max_pkt_size > 0) msgsize = max_pkt_size;
- else if (max_pkt_size < 0) msgsize = - max_pkt_size;
- else msgsize = 1024 * 1024;
+ if (max_pkt_size > 0) VIDEO_SINGLETON::instance ()->msgsize = max_pkt_size;
+ else if (max_pkt_size < 0) VIDEO_SINGLETON::instance ()->msgsize = - max_pkt_size;
+ else VIDEO_SINGLETON::instance ()->msgsize = 1024 * 1024;
/*
- SFprintf(stderr, "VS msgsize = %d\n", msgsize);
+ SFprintf(stderr, "VS VIDEO_SINGLETON::instance ()->msgsize = %d\n", VIDEO_SINGLETON::instance ()->msgsize);
*/
- msgsize -= sizeof(VideoMessage);
+ VIDEO_SINGLETON::instance ()->msgsize -= sizeof(VideoMessage);
- start_time = time(NULL);
+ VIDEO_SINGLETON::instance ()->start_time = time(NULL);
atexit(on_exit_routine);
- lastRef[0] = lastRef[1] = -1;
- lastRefPtr = 0;
+ VIDEO_SINGLETON::instance ()->lastRef[0] = VIDEO_SINGLETON::instance ()->lastRef[1] = -1;
+ VIDEO_SINGLETON::instance ()->lastRefPtr = 0;
result = INITvideo();
@@ -2121,8 +2121,8 @@ int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
fprintf(stderr, "VS: waiting for a new command...\n");
- precmd = cmd;
- result = CmdRead((char *)&cmd, 1);
+ VIDEO_SINGLETON::instance ()->precmd = VIDEO_SINGLETON::instance ()->cmd;
+ result = CmdRead((char *)&VIDEO_SINGLETON::instance ()->cmd, 1);
if (result != 0)
{
cerr << result;
@@ -2130,9 +2130,9 @@ int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
"(%P|%t) VideoServer "),
result);
}
- fprintf(stderr, "VS got cmd %d\n", cmd);
+ fprintf(stderr, "VS got VIDEO_SINGLETON::instance ()->cmd %d\n", VIDEO_SINGLETON::instance ()->cmd);
- switch (cmd)
+ switch (VIDEO_SINGLETON::instance ()->cmd)
{
case CmdPOSITION:
case CmdPOSITIONrelease:
@@ -2159,7 +2159,7 @@ int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
case CmdCLOSE:
/*
fprintf(stderr, "a session closed.\n");
- normalExit =1;
+ VIDEO_SINGLETON::instance ()->normalExit =1;
*/
// exit(0);
return 0;
@@ -2172,8 +2172,8 @@ int VideoServer(int ctr_fd, int data_fd, int rttag, int max_pkt_size)
break;
default:
fprintf(stderr,
- "VS error: video channel command %d not known.\n", cmd);
- normalExit = 0;
+ "VS error: video channel command %d not known.\n", VIDEO_SINGLETON::instance ()->cmd);
+ VIDEO_SINGLETON::instance ()->normalExit = 0;
return -1;
break;
}