--- multiplexer/descref.c 2001/03/29 13:27:43 1.2 +++ multiplexer/descref.c 2001/04/09 15:26:03 1.3 @@ -11,10 +11,16 @@ #include "global.h" #include "error.h" +#include "splitts.h" static mapreference mapref; static int din; +/* Start descriptor processing into a map stream s. + * The descriptor functions are to be used always in the + * sequence "alloc, put...put, finish" + * Postcondition: din==InputIndex, enough free space for PSI. + */ void alloc_descriptor (stream_descr *s, int sourceid, int programnumber, @@ -40,6 +46,12 @@ void alloc_descriptor (stream_descr *s, } } +/* Scan a descriptor and put it into the map stream s. + * Source is raw data from file f. + * Decrease infolen^ by number of bytes processed, or set to -1 on error. + * Precondition: as thru alloc_descriptor + * Return: index increased by number of bytes processed. + */ int put_descriptor (file_descr *f, stream_descr *s, int index, @@ -73,6 +85,12 @@ int put_descriptor (file_descr *f, return (index); } +/* Scan a descriptor and put it into the map stream s. + * Source is direct data from byte pointer d. + * Decrease infolen^ by number of bytes processed, or set to -1 on error. + * Precondition: as thru alloc_descriptor + * Return: byte pointer d increased by number of bytes processed. + */ byte *put_descriptor_s (byte *d, stream_descr *s, int *infolen) @@ -102,6 +120,8 @@ byte *put_descriptor_s (byte *d, return (d); } +/* Finish the collection of descriptors into the map stream s. + */ void finish_descriptor (stream_descr *s) { if (s != NULL) { @@ -119,6 +139,9 @@ void finish_descriptor (stream_descr *s) } } +/* Save a set of descriptors map with a stream s, + * including both the references and the raw data. + */ static void save_mapreference (mapreference *map, byte *dscr, int size, @@ -139,6 +162,11 @@ static void save_mapreference (maprefere } } +/* Take a set of descriptors from map stream m, + * determine the right stream to put the descriptors into + * (either the map stream itself, or a related data stream), + * save the descriptors into that stream. + */ void validate_mapref (stream_descr *m) { stream_descr *s; @@ -153,7 +181,7 @@ void validate_mapref (stream_descr *m) s = m->fdescr->u.ps.stream[pmapref->sourceid]; break; case ct_transport: - s = m->fdescr->u.ts.stream[pmapref->sourceid]; + s = ts_file_stream (m->fdescr,pmapref->sourceid); break; default: warn (LERR,"Mapref NULL",EDES,6,1,m->fdescr->content);