#include #include #include #include #include #include #include #include #include #define GLOBAL #include "global.h" #include "fallbacks.h" #include #include #include #include #include #include #ifdef _RJP_THREAD #include #endif #include "video_common.h" #include "decoder.h" XtAppContext app; static u_short video_port = VIDEO_PORT; void exit_self(Widget w, XtPointer client, XtPointer call) { /* Do all clean up */ finish_display(); XtAppSetExitFlag(app); } void usage(char* progname) { fprintf(stderr, "Syntax: %s\n", progname); fprintf(stderr, "\t[-o format %d for QCIF %d for CIF\n", QCIF_TYPE, CIF_TYPE); fprintf(stderr, "\t[-p TCP_PORT DEFAULT %hd]\n", video_port); } int main(int argc, char** argv) { char ch; int read_fd = 0; Widget toplevel, picW, formW, exitW; int format = QCIF_TYPE; frformat_t picformat; Decoder *decoder = new Decoder; while ((ch = getopt(argc, argv, "p:o:h")) != -1) switch(ch) { case 'p': video_port = atoi(optarg); break; case 'o': format = atoi(optarg); break; case 'h': usage(argv[0]); goto quit; } if(format != QCIF_TYPE && format != CIF_TYPE) { usage(argv[0]); exit(0); } if(format == CIF_TYPE) picformat = CIF_FORMAT; else if(format == QCIF_TYPE) picformat = QCIF_FORMAT; #ifdef BOUNDS_CHECK else bounds_error(__LINE__, __FILE__, __PRETTY_FUNCTION__); #endif compile_h261vlc(); toplevel = XtVaAppInitialize(&app, "RJPpicviewer", NULL, 0, &argc, argv, fallbacks, NULL); formW = XtCreateManagedWidget("box", boxWidgetClass, toplevel, NULL, 0); XtVaSetValues(formW, XtNheight, picformat.rows + 50, NULL); XtVaSetValues(formW, XtNwidth, picformat.cols + 50, NULL); exitW = XtCreateManagedWidget("Exit", commandWidgetClass, formW, NULL, 0); picW = XtCreateManagedWidget("picw", coreWidgetClass, formW, NULL, 0); XtVaSetValues(picW, XtNheight, picformat.rows, NULL); XtVaSetValues(picW, XtNwidth, picformat.cols, NULL); XtAddCallback(exitW, XtNcallback, exit_self, NULL); // XtAddEventHandler(picW, ExposureMask, FALSE, Redisplay, NULL); read_fd = wait_for_connect(video_port); if(read_fd < 0) { fprintf(stderr, "connect wait failed\n"); goto quit; } fprintf(stderr, "read_fd = %d\n", read_fd); XtRealizeWidget(toplevel); decoder->init_decoder(picformat, read_fd, toplevel, picW); decoder->Start(); XtAppMainLoop(app); Thread::Cancel(decoder); Thread::Join(decoder); delete decoder; quit: return 0; }