#include #include #include #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" #ifdef _RJP_THREAD int rjp_sock_fd; #endif 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); } ET_PROC( PrintHi2 ) { printf("Hi there\n"); return ET_OK; } ET_PROC( Disengage) { printf("disengage\n"); return ET_OK; } ET_PROC( MotorStop) { printf("MotorStop\n"); return ET_OK; } ET_PROC( FreeRotate ) { printf("FreeRotate\n"); return ET_OK; } ET_PROC( Step ) { printf("Step\n"); return ET_OK; } void syntax(char* progname) { printf("%s -h -d device\n", progname); printf(" -h help on usage\n"); printf(" -p dev port device to use, default lp0\n"); } void* myXthread(void *arg) { XtAppMainLoop(app); return NULL; } int main(int argc, char** argv) { char ch; int read_fd = 0; //Widget toplevel, drawingW, picW, formW, exitW; Widget toplevel, picW, formW, exitW; int format = CIF_TYPE; frformat_t picformat; pthread_t mythread; pthread_t mythread2; 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; } rjp_sock_fd = read_fd; fprintf(stderr, "read_fd = %d\n", read_fd); pthread_create(&mythread, NULL, read_thread, &picformat); XtRealizeWidget(toplevel); init_display(toplevel, picW, picformat.cols, picformat.rows); Et_Init(&argc, argv); ET_INSTALL_COMMANDS; ET_INCLUDE(playergui.tk); pthread_create(&mythread2, NULL, myXthread, NULL); Et_MainLoop(); printf("now stepping for ten seconds\n"); printf("done stepping\n"); // XtAppMainLoop(app); quit: return 0; // motor_halt(); }