Commit 7af799fb authored by Christophe Massiot's avatar Christophe Massiot

* New program multicat_validate to validate directory inputs.

parent 3423037b
$Id: INSTALL 93 2010-01-03 13:07:23Z gatty $
$Id$
Installing Multicat
===================
......
......@@ -10,12 +10,13 @@ OBJ_AGGREGARTP = aggregartp.o util.o
OBJ_REORDERTP = reordertp.o util.o
OBJ_OFFSETS = offsets.o util.o
OBJ_LASTS = lasts.o
OBJ_MULTICAT_VALIDATE = multicat_validate.o util.o
PREFIX ?= /usr/local
BIN = $(DESTDIR)/$(PREFIX)/bin
MAN = $(DESTDIR)/$(PREFIX)/share/man/man1
all: multicat ingests aggregartp reordertp offsets lasts
all: multicat ingests aggregartp reordertp offsets lasts multicat_validate
$(OBJ_MULTICAT): Makefile util.h
$(OBJ_INGESTS): Makefile util.h
......@@ -23,6 +24,7 @@ $(OBJ_AGGREGARTP): Makefile util.h
$(OBJ_REORDERTP): Makefile util.h
$(OBJ_OFFSETS): Makefile util.h
$(OBJ_LASTS): Makefile
$(OBJ_MULTICAT_VALIDATE): Makefile util.h
multicat: $(OBJ_MULTICAT)
$(CC) -o $@ $(OBJ_MULTICAT) $(LDLIBS)
......@@ -42,15 +44,18 @@ offsets: $(OBJ_OFFSETS)
lasts: $(OBJ_LASTS)
$(CC) -o $@ $(OBJ_LASTS) $(LDLIBS)
multicat_validate: $(OBJ_MULTICAT_VALIDATE)
$(CC) -o $@ $(OBJ_MULTICAT_VALIDATE) $(LDLIBS)
clean:
-rm -f multicat $(OBJ_MULTICAT) ingests $(OBJ_INGESTS) aggregartp $(OBJ_AGGREGARTP) reordertp $(OBJ_REORDERTP) offsets $(OBJ_OFFSETS) lasts $(OBJ_LASTS)
-rm -f multicat $(OBJ_MULTICAT) ingests $(OBJ_INGESTS) aggregartp $(OBJ_AGGREGARTP) reordertp $(OBJ_REORDERTP) offsets $(OBJ_OFFSETS) lasts $(OBJ_LASTS) multicat_validate
install: all
@install -d $(BIN)
@install -d $(MAN)
@install multicat ingests aggregartp reordertp offsets lasts $(BIN)
@install multicat ingests aggregartp reordertp offsets lasts multicat_validate $(BIN)
@install multicat.1 ingests.1 aggregartp.1 reordertp.1 offsets.1 lasts.1 $(MAN)
uninstall:
@rm $(BIN)/multicat $(BIN)/ingests $(BIN)/aggregartp $(BIN)/reordertp $(BIN)/offsets $(BIN)/lasts
@rm $(BIN)/multicat $(BIN)/ingests $(BIN)/aggregartp $(BIN)/reordertp $(BIN)/offsets $(BIN)/lasts $(BIN)/multicat_validate
@rm $(MAN)/multicat.1 $(MAN)/ingests.1 $(MAN)/aggregartp.1 $(MAN)/reordertp.1 $(MAN)/offsets.1 $(MAN)/lasts.1
$Id: NEWS 194 2011-07-13 19:59:32Z massiot $
$Id$
Changes between 1.0 and 2.0:
----------------------------
......@@ -6,6 +6,8 @@ Changes between 1.0 and 2.0:
"chunks" of fixed duration, accompanied with their auxiliary file
* Support for TCP sockets in multicat, aggregartp and reordertp (/tcp)
* Merge OffseTS functionality into multicat itself (-k and -d)
* New program multicat_validate to validate directory inputs
* New program lasts to determine the duration of an aux file
* Support for IPv6
* Add DVBlast-style options for host parsing (ifindex, ifaddr, ttl and tos)
* Add the ability to output a stream as fast as possible (-f)
......
$Id: README 26 2009-10-20 18:44:22Z massiot $
$Id$
Welcome to Multicat!
====================
......
......@@ -2,7 +2,7 @@
* aggregartp.c: split an RTP stream for several contribution links
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: aggregartp.c 48 2007-11-30 14:08:21Z cmassiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* ingests.c: create the aux file for a transport stream file
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: ingests.c 52 2009-10-06 16:48:00Z cmassiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* lasts.c: give the duration of an aux file
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: lasts.c 10 2005-11-16 18:09:00Z cmassiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* multicat.c: netcat-equivalent for multicast
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: multicat.c 48 2007-11-30 14:08:21Z cmassiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -612,7 +612,7 @@ static uint64_t i_output_dir_file;
static ssize_t dir_Write( const void *p_buf, size_t i_len )
{
uint64_t i_dir_file = GetDirFile( i_rotate_size, i_stc );
if ( i_dir_file != i_output_dir_file )
if ( !i_output_fd || i_dir_file != i_output_dir_file )
{
if ( i_output_fd )
{
......
/*****************************************************************************
* multicat_validate.c: validate position in directory input
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#include <string.h>
#include "util.h"
#define DEFAULT_TOLERANCE 27000000ULL
/*****************************************************************************
* Local declarations
*****************************************************************************/
static uint64_t i_rotate_size = DEFAULT_ROTATE_SIZE;
static int64_t i_tolerance = DEFAULT_TOLERANCE;
static size_t i_asked_payload_size = DEFAULT_PAYLOAD_SIZE;
static int64_t i_delay = 0;
static const char *psz_dir_name;
static uint64_t i_dir_file;
static bool b_status = false;
static void usage(void)
{
msg_Raw( NULL, "Usage: multicat_validate [-k <start time>] [-r <file duration>] [-W <tolerance>] [-m <payload size>] <input directory>" );
msg_Raw( NULL, " -k: start at the given position (in 27 MHz units, negative = from the end)" );
msg_Raw( NULL, " -r: in directory mode, rotate file after this duration (default: 97200000000 ticks = 1 hour)" );
msg_Raw( NULL, " -W: maximum tolerated wait time before the forthcoming packet (by default: 27000000 ticks = 1 second)" );
msg_Raw( NULL, " -m: size of the payload chunk, excluding optional RTP header (default 1316)" );
exit(EXIT_FAILURE);
}
static void HandleSTC( uint64_t i_stc )
{
uint64_t i_wall;
int64_t i_sleep;
retry:
i_wall = real_Date() - i_delay;
i_sleep = i_stc - i_wall;
if ( i_sleep > i_tolerance )
{
if ( b_status )
{
printf( "0\n" );
b_status = false;
}
real_Sleep( i_sleep - i_tolerance );
goto retry;
}
if ( !b_status )
printf( "1\n" );
b_status = true;
if ( i_sleep > 0 )
real_Sleep( i_sleep );
}
/*****************************************************************************
* Entry point
*****************************************************************************/
int main( int i_argc, char **pp_argv )
{
off_t i_nb_skipped_chunks;
FILE *p_input_aux;
int c;
uint64_t i_stc;
setvbuf(stdout, NULL, _IOLBF, 0);
while ( (c = getopt( i_argc, pp_argv, "k:r:W:m:h" )) != -1 )
{
switch ( c )
{
case 'k':
i_delay = strtoull( optarg, NULL, 0 );
break;
case 'r':
i_rotate_size = strtoull( optarg, NULL, 0 );
break;
case 'W':
i_tolerance = strtoull( optarg, NULL, 0 );
break;
case 'm':
i_asked_payload_size = strtol( optarg, NULL, 0 );
break;
case 'h':
default:
usage();
break;
}
}
if ( optind >= i_argc )
usage();
psz_dir_name = pp_argv[optind];
printf( "0\n" );
if ( i_delay <= 0 )
{
i_delay *= -1;
i_stc = real_Date() - i_delay;
}
else
{
i_stc = i_delay;
i_delay = real_Date() - i_stc;
}
i_dir_file = GetDirFile( i_rotate_size, i_stc );
i_nb_skipped_chunks = LookupDirAuxFile( psz_dir_name, i_dir_file, i_stc,
i_asked_payload_size );
if ( i_nb_skipped_chunks < 0 )
{
/* Try at most one more chunk */
i_dir_file++;
i_nb_skipped_chunks = LookupDirAuxFile( psz_dir_name, i_dir_file, i_stc,
i_asked_payload_size );
if ( i_nb_skipped_chunks < 0 )
{
msg_Err( NULL, "position not found" );
exit(1);
}
}
close( OpenDirFile( psz_dir_name, i_dir_file, true, i_asked_payload_size,
&p_input_aux ) );
fseeko( p_input_aux, 8 * i_nb_skipped_chunks, SEEK_SET );
for ( ; ; )
{
uint8_t p_aux[8];
if ( fread( p_aux, 8, 1, p_input_aux ) != 1 )
{
int i_fd;
fclose( p_input_aux );
i_dir_file++;
i_fd = OpenDirFile( psz_dir_name, i_dir_file, true,
i_asked_payload_size, &p_input_aux );
if ( i_fd < 0 )
{
msg_Err( NULL, "end of files reached" );
exit(1);
}
close( i_fd );
}
i_stc = FromSTC( p_aux );
HandleSTC( i_stc );
}
}
......@@ -2,7 +2,7 @@
* offsets.c: find position in an aux file
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: offsets.c 10 2005-11-16 18:09:00Z cmassiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* reordertp.c: rebuild an RTP stream from several aggregated links
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: reordertp.c 48 2007-11-30 14:08:21Z cmassiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* util.c: Utils for the multicat suite
*****************************************************************************
* Copyright (C) 2004, 2009, 2011 VideoLAN
* $Id: util.c 27 2009-10-20 19:15:04Z massiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* util.h: Utils for the multicat suite
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: multicat.h 65 2009-11-15 22:57:53Z massiot $
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment