/* * ISO 13818 stream multiplexer / additional repeater tool * Copyright (C) 2001 Convergence Integrated Media GmbH Berlin * Author: Oskar Schirmer (oskar@convergence.de) */ /* * Module: Repeater * Purpose: Additional tool to repeat and pipe an input stream. * * This tool accepts a (time1,time2,filename) tuple via stdin, * opens the filename, assuming it contains a ISO 13818 Transport Stream, * and sends it packet-wise to stdout timed in such a way, that * all pakets are sent equally distributed within time2 msec. * As long as no further tuple is provided, after time1 msec the same * file is sent over and over again. */ #include #include "global.h" #define D(x) /* x */ #define MAX_ANOTATE (16 * 256) static boolean quit; static int cmdf, outf, nextf; static int combln, comlln; static byte combuf[MAX_DATA_COMB]; static int dati, dato; static byte data[MAX_ANOTATE]; static t_msec nextrdelay, nextfdelay; t_msec msec_now (void) { #define MSEC_EXPONENT 21 static long last; static int local_delta; struct timeval tv; gettimeofday (&tv,NULL); if ((tv.tv_sec & (~((1L << MSEC_EXPONENT) - 1))) != last) { last = tv.tv_sec & (~((1L << MSEC_EXPONENT) - 1)); local_delta += 1000 * (1L << MSEC_EXPONENT); } return ((tv.tv_sec & ((1L << MSEC_EXPONENT) - 1)) * 1000 + tv.tv_usec / 1000 + local_delta); } static void command_help (char *command) { fprintf (stderr, "Usage:\t%s [