/* * 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 nextfdelay; static int num_packets; static t_msec transmission_time; t_msec msec_now (void) { static int first_call = 1; static long long first_time; static long long now; struct timeval tv; gettimeofday (&tv, NULL); #if 0 #define MSEC_EXPONENT 21 static long last; static int local_delta; 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); #endif now = (tv.tv_sec * 1000) + (tv.tv_usec / 1000); if (first_call) { first_call = 0; first_time = now; } return (t_msec)(now - first_time); } static void command_help (char *command) { fprintf (stderr, "Usage:\t%s [