#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "h261ctrl.h" int wait_for_connect(u_short port); 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); } H261CtrlConn connector; void IncomingMissile(ClientData clientData, int mask) { fprintf(stderr, "IncomingMissile\n"); connector.RcvPkt(); } ET_PROC( H261Connect ) { int rc = 0; if(!connector.is_connected) { fprintf(stderr, "connection req to %s\n", argv[1]); rc = connector.MakeConnect(argv[1]); } else connector.Disconnect(); return ET_OK; } ET_PROC( Disengage ) { if(connector.encpid) kill(connector.encpid, SIGKILL); if(connector.decpid) kill(connector.decpid, SIGKILL); exit(0); return ET_OK; } void setconnstatus(int status) { if(status) ET( set c_string Disconnect ); else ET( set c_string Connect ); } int main(int argc, char** argv) { char ch; int read_fd = 0; int format = CIF_TYPE; char *servaddr = "127.0.0.1"; int filefd = 0; char *filename = NULL; ClientData tmpdata; while ((ch = getopt(argc, argv, "s:r:o:a:f:")) != -1) switch(ch) { case 'o': format = atoi(optarg); break; case 'a': servaddr = optarg; break; case 'f': filename = optarg; break; default: usage(argv[0]); goto quit; } if(format != QCIF_TYPE && format != CIF_TYPE) { usage(argv[0]); exit(0); } connector.format = format; if(!filename) { usage(argv[0]); exit(0); } if( (filefd=open(filename, O_RDONLY)) < 0) { perror("open "); exit(0); } close(filefd); connector.encfilename = filename; read_fd = wait_for_connect(H261CTRLPORT); connector.ctrlfd = read_fd; if(read_fd < 0) goto quit; Tcl_CreateFileHandler(connector.ctrlfd, TCL_READABLE, IncomingMissile, tmpdata); Et_Init(&argc, argv); ET_INSTALL_COMMANDS; ET_INCLUDE(playergui.tk); Et_MainLoop(); quit: return 0; }