Another set of IO edits

--HG--
extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%40140
issue20
tibs 2009-05-03 20:08:52 +00:00
rodzic ef54a360b1
commit 0789bd1fa2
11 zmienionych plików z 463 dodań i 470 usunięć

Wyświetl plik

@ -105,36 +105,35 @@ extern void free_access_unit(access_unit_p *acc_unit)
}
/*
* Report on this access unit, on the given output stream.
* Report on this access unit
*/
extern void report_access_unit(FILE *stream,
access_unit_p access_unit)
extern void report_access_unit(access_unit_p access_unit)
{
int ii;
fprintf(stream,"Access unit %u",access_unit->index);
fprint_msg("Access unit %u",access_unit->index);
if (access_unit->started_primary_picture)
fprintf(stream," (%s)",access_unit->primary_start->start_reason);
fprintf(stream,":\n");
fprint_msg(" (%s)",access_unit->primary_start->start_reason);
print_msg(":\n");
if (access_unit->field_pic_flag)
fprintf(stream," %s field of frame %u\n",
(access_unit->bottom_field_flag==1?"Bottom":"Top"),
access_unit->frame_num);
fprint_msg(" %s field of frame %u\n",
(access_unit->bottom_field_flag==1?"Bottom":"Top"),
access_unit->frame_num);
else
fprintf(stream," Frame %u\n",access_unit->frame_num);
fprint_msg(" Frame %u\n",access_unit->frame_num);
if (access_unit->ignored_broken_NAL_units)
fprintf(stream," Ignored %d broken NAL unit%s\n",
access_unit->ignored_broken_NAL_units,
(access_unit->ignored_broken_NAL_units==1?"":"s"));
fprint_msg(" Ignored %d broken NAL unit%s\n",
access_unit->ignored_broken_NAL_units,
(access_unit->ignored_broken_NAL_units==1?"":"s"));
for (ii=0; ii<access_unit->nal_units->length; ii++)
{
nal_unit_p nal = access_unit->nal_units->array[ii];
if (nal == NULL)
fprintf(stream," <null>\n");
print_msg(" <null>\n");
else
{
fprintf(stream," %c",((access_unit->primary_start == nal)?'*':' '));
fprint_msg(" %c",((access_unit->primary_start == nal)?'*':' '));
report_nal(TRUE,nal);
}
}
@ -672,20 +671,20 @@ static inline int end_access_unit(access_unit_context_p context,
{
if (show_details)
{
report_access_unit(stdout,access_unit);
report_access_unit(access_unit);
if (context->pending_nal)
{
printf("... pending: ");
print_msg("... pending: ");
report_nal(TRUE,context->pending_nal);
}
if (context->end_of_sequence)
{
printf("--> EndOfSequence ");
print_msg("--> EndOfSequence ");
report_nal(TRUE,context->end_of_sequence);
}
if (context->end_of_stream)
{
printf("--> EndOfStream ");
print_msg("--> EndOfStream ");
report_nal(TRUE,context->end_of_stream);
}
}
@ -904,9 +903,9 @@ static int maybe_remember_access_unit(reverse_data_p reverse_data,
access_unit->index);
return 1;
}
if (verbose) printf("REMEMBER IDR %5d at " OFFSET_T_FORMAT_08
"/%04d for %5d\n",access_unit->index,
start_posn.infile,start_posn.inpacket,num_bytes);
if (verbose) fprint_msg("REMEMBER IDR %5d at " OFFSET_T_FORMAT_08
"/%04d for %5d\n",access_unit->index,
start_posn.infile,start_posn.inpacket,num_bytes);
}
return 0;
}
@ -1056,7 +1055,7 @@ extern int get_next_access_unit(access_unit_context_p context,
else if (nal_is_redundant(nal))
{
// pass
// printf(" ignoring redundant NAL unit\n");
// print_msg(" ignoring redundant NAL unit\n");
free_nal_unit(&nal);
}
else
@ -1270,8 +1269,8 @@ static int get_next_field_of_pair(access_unit_context_p context,
access_unit_p second;
if (show_details || context->nac->show_nal_details)
printf("@@ Looking for second field (%s time)\n",
(first_time?"first":"second"));
fprint_msg("@@ Looking for second field (%s time)\n",
(first_time?"first":"second"));
// We assume (hope) the next picture will be our second half
err = get_next_non_empty_access_unit(context,quiet,show_details,&second);
@ -1294,7 +1293,7 @@ static int get_next_field_of_pair(access_unit_context_p context,
{
// They appear to be matching fields - make a frame from them
if (show_details || context->nac->show_nal_details)
printf("@@ Merging two field access units\n");
print_msg("@@ Merging two field access units\n");
err = merge_access_unit_nals(*access_unit,&second); // (frees `second`)
if (err)
{
@ -1302,7 +1301,7 @@ static int get_next_field_of_pair(access_unit_context_p context,
return 1;
}
if (show_details)
report_access_unit(stdout,*access_unit);
report_access_unit(*access_unit);
}
else if (first_time)
{

Wyświetl plik

@ -79,10 +79,9 @@ extern int rewind_access_unit_context(access_unit_context_p context);
extern void free_access_unit(access_unit_p *acc_unit);
/*
* Report on this access unit, on the given output stream.
* Report on this access unit
*/
extern void report_access_unit(FILE *stream,
access_unit_p access_unit);
extern void report_access_unit(access_unit_p access_unit);
/*
* Retrieve the bounds of this access unit in the file it was read from.

Wyświetl plik

@ -748,7 +748,7 @@ static void find_h264_fields(ES_p es,
if (access_unit->field_pic_flag == 1)
{
report_access_unit(stdout,access_unit);
report_access_unit(access_unit);
num_fields ++;
}
else
@ -823,7 +823,7 @@ static void report_h264_frames(ES_p es,
break;
if (!quiet)
report_access_unit(stdout,access_unit);
report_access_unit(access_unit);
if (count_sizes)
{

598
pes.c

Plik diff jest za duży Load Diff

131
pidint.c
Wyświetl plik

@ -33,6 +33,7 @@
#include "compat.h"
#include "pidint_fns.h"
#include "misc_fns.h"
#include "printing_fns.h"
#include "ts_fns.h"
#include "h222_defns.h"
@ -49,14 +50,14 @@ extern int init_pidint_list(pidint_list_p list)
list->number = malloc(sizeof(int)*PIDINT_LIST_START_SIZE);
if (list->number == NULL)
{
fprintf(stderr,"### Unable to allocate array in program list datastructure\n");
print_err("### Unable to allocate array in program list datastructure\n");
return 1;
}
list->pid = malloc(sizeof(uint32_t)*PIDINT_LIST_START_SIZE);
if (list->pid == NULL)
{
free(list->number);
fprintf(stderr,"### Unable to allocate array in program list datastructure\n");
print_err("### Unable to allocate array in program list datastructure\n");
return 1;
}
return 0;
@ -73,7 +74,7 @@ extern int build_pidint_list(pidint_list_p *list)
pidint_list_p new = malloc(SIZEOF_PIDINT_LIST);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate pid/int list datastructure\n");
print_err("### Unable to allocate pid/int list datastructure\n");
return 1;
}
@ -95,7 +96,7 @@ extern int append_to_pidint_list(pidint_list_p list,
{
if (list == NULL)
{
fprintf(stderr,"### Unable to append to NULL pid/int list\n");
print_err("### Unable to append to NULL pid/int list\n");
return 1;
}
@ -105,13 +106,13 @@ extern int append_to_pidint_list(pidint_list_p list,
list->number = realloc(list->number,newsize*sizeof(int));
if (list->number == NULL)
{
fprintf(stderr,"### Unable to extend pid/int list array\n");
print_err("### Unable to extend pid/int list array\n");
return 1;
}
list->pid = realloc(list->pid,newsize*sizeof(uint32_t));
if (list->pid == NULL)
{
fprintf(stderr,"### Unable to extend pid/int list array\n");
print_err("### Unable to extend pid/int list array\n");
return 1;
}
list->size = newsize;
@ -134,15 +135,15 @@ extern int remove_from_pidint_list(pidint_list_p list,
int ii;
if (list == NULL)
{
fprintf(stderr,"### Unable to remove entry from NULL pid/int list\n");
print_err("### Unable to remove entry from NULL pid/int list\n");
return 1;
}
index = pid_index_in_pidint_list(list,pid);
if (index == -1)
{
fprintf(stderr,"### Cannot remove PID %04x from pid/int list"
" - it is not there\n",pid);
fprint_err("### Cannot remove PID %04x from pid/int list"
" - it is not there\n",pid);
return 1;
}
@ -191,21 +192,21 @@ extern void report_pidint_list(pidint_list_p list,
int pid_first)
{
if (list == NULL)
printf("%s is NULL\n",list_name);
fprint_msg("%s is NULL\n",list_name);
else if (list->length == 0)
printf("%s is empty\n",list_name);
fprint_msg("%s is empty\n",list_name);
else
{
int ii;
printf("%s:\n",list_name);
fprint_msg("%s:\n",list_name);
for (ii=0; ii<list->length; ii++)
{
if (pid_first)
printf(" PID %04x (%d) -> %s %d\n",
list->pid[ii],list->pid[ii],int_name,list->number[ii]);
fprint_msg(" PID %04x (%d) -> %s %d\n",
list->pid[ii],list->pid[ii],int_name,list->number[ii]);
else
printf(" %s %d -> PID %04x (%d)\n",
int_name,list->number[ii],list->pid[ii],list->pid[ii]);
fprint_msg(" %s %d -> PID %04x (%d)\n",
int_name,list->number[ii],list->pid[ii],list->pid[ii]);
}
}
}
@ -313,21 +314,21 @@ extern int same_pidint_list(pidint_list_p list1,
extern void report_stream_list(pidint_list_p list,
char *prefix)
{
if (prefix!=NULL) printf(prefix);
if (prefix!=NULL) print_msg(prefix);
if (list == NULL)
printf("Program stream list is NULL\n");
print_msg("Program stream list is NULL\n");
else if (list->length == 0)
printf("Program stream list is empty\n");
print_msg("Program stream list is empty\n");
else
{
int ii;
printf("Program streams:\n");
print_msg("Program streams:\n");
for (ii=0; ii<list->length; ii++)
{
if (prefix!=NULL) printf(prefix);
printf(" PID %04x (%d) -> Stream type %3d (%s)\n",
list->pid[ii],list->pid[ii],list->number[ii],
h222_stream_type_str(list->number[ii]));
if (prefix!=NULL) print_msg(prefix);
fprint_msg(" PID %04x (%d) -> Stream type %3d (%s)\n",
list->pid[ii],list->pid[ii],list->number[ii],
h222_stream_type_str(list->number[ii]));
}
}
}
@ -345,7 +346,7 @@ static int init_pmt_streams(pmt_p pmt)
pmt->streams = malloc(SIZEOF_PMT_STREAM*PMT_STREAMS_START_SIZE);
if (pmt->streams == NULL)
{
fprintf(stderr,"### Unable to allocate streams in PMT datastructure\n");
print_err("### Unable to allocate streams in PMT datastructure\n");
return 1;
}
return 0;
@ -378,16 +379,16 @@ extern pmt_p build_pmt(uint16_t program_number, byte version_number,
if (PCR_pid != 0x1FFF && (PCR_pid < 0x0010 || PCR_pid > 0x1ffe))
{
fprintf(stderr,"### Error building PMT datastructure\n"
" PCR PID %04x is outside legal program stream range\n",
PCR_pid);
fprint_err("### Error building PMT datastructure\n"
" PCR PID %04x is outside legal program stream range\n",
PCR_pid);
return NULL;
}
new = malloc(SIZEOF_PMT);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate PMT datastructure\n");
print_err("### Unable to allocate PMT datastructure\n");
return NULL;
}
@ -422,8 +423,8 @@ extern int set_pmt_program_info(pmt_p pmt,
{
if (program_info_length > PMT_MAX_INFO_LENGTH)
{
fprintf(stderr,"### Program info length %d is more than %d\n",
program_info_length,PMT_MAX_INFO_LENGTH);
fprint_err("### Program info length %d is more than %d\n",
program_info_length,PMT_MAX_INFO_LENGTH);
return 1;
}
if (pmt->program_info == NULL)
@ -431,7 +432,7 @@ extern int set_pmt_program_info(pmt_p pmt,
pmt->program_info = malloc(program_info_length);
if (pmt->program_info == NULL)
{
fprintf(stderr,"### Unable to allocate program info in PMT datastructure\n");
print_err("### Unable to allocate program info in PMT datastructure\n");
return 1;
}
}
@ -441,7 +442,7 @@ extern int set_pmt_program_info(pmt_p pmt,
pmt->program_info = realloc(pmt->program_info,program_info_length);
if (pmt->program_info == NULL)
{
fprintf(stderr,"### Unable to extend program info in PMT datastructure\n");
print_err("### Unable to extend program info in PMT datastructure\n");
return 1;
}
}
@ -465,22 +466,22 @@ extern int add_stream_to_pmt(pmt_p pmt,
{
if (pmt == NULL)
{
fprintf(stderr,"### Unable to append to NULL PMT datastructure\n");
print_err("### Unable to append to NULL PMT datastructure\n");
return 1;
}
if (elementary_PID < 0x0010 || elementary_PID > 0x1ffe)
{
fprintf(stderr,"### Error adding stream to PMT\n"
" Elementary PID %04x is outside legal program stream range\n",
elementary_PID);
fprint_err("### Error adding stream to PMT\n"
" Elementary PID %04x is outside legal program stream range\n",
elementary_PID);
return 1;
}
if (ES_info_length > PMT_MAX_INFO_LENGTH)
{
fprintf(stderr,"### ES info length %d is more than %d\n",
ES_info_length,PMT_MAX_INFO_LENGTH);
fprint_err("### ES info length %d is more than %d\n",
ES_info_length,PMT_MAX_INFO_LENGTH);
return 1;
}
@ -490,7 +491,7 @@ extern int add_stream_to_pmt(pmt_p pmt,
pmt->streams = realloc(pmt->streams,newsize*SIZEOF_PMT_STREAM);
if (pmt->streams == NULL)
{
fprintf(stderr,"### Unable to extend PMT streams array\n");
print_err("### Unable to extend PMT streams array\n");
return 1;
}
pmt->streams_size = newsize;
@ -503,7 +504,7 @@ extern int add_stream_to_pmt(pmt_p pmt,
pmt->streams[pmt->num_streams].ES_info = malloc(ES_info_length);
if (pmt->streams[pmt->num_streams].ES_info == NULL)
{
fprintf(stderr,"### Unable to allocate PMT stream ES info\n");
print_err("### Unable to allocate PMT stream ES info\n");
return 1;
}
memcpy(pmt->streams[pmt->num_streams].ES_info,ES_info,ES_info_length);
@ -539,15 +540,15 @@ extern int remove_stream_from_pmt(pmt_p pmt,
int ii;
if (pmt == NULL)
{
fprintf(stderr,"### Unable to remove entry from NULL PMT datastructure\n");
print_err("### Unable to remove entry from NULL PMT datastructure\n");
return 1;
}
index = pid_index_in_pmt(pmt,pid);
if (index == -1)
{
fprintf(stderr,"### Cannot remove PID %04x from PMT datastructure"
" - it is not there\n",pid);
fprint_err("### Cannot remove PID %04x from PMT datastructure"
" - it is not there\n",pid);
return 1;
}
@ -713,54 +714,54 @@ extern int same_pmt(pmt_p pmt1,
/*
* Report on a PMT datastructure.
*
* - `stream` is the stream to write to
* - if `is_msg`, report as a message, otherwise as an error
* - `prefix` is NULL or a string to put before each line printed
* - `pmt` is the PMT to report on
*/
extern void report_pmt(FILE *stream,
extern void report_pmt(int is_msg,
char *prefix,
pmt_p pmt)
{
if (prefix!=NULL) fprintf(stream,prefix);
if (prefix!=NULL) fprint_msg_or_err(is_msg,prefix);
if (pmt == NULL)
{
fprintf(stream,"PMT is NULL\n");
fprint_msg_or_err(is_msg,"PMT is NULL\n");
return;
}
else
fprintf(stream,"Program %d, version %d, PCR PID %04x (%d)\n",
pmt->program_number,pmt->version_number,pmt->PCR_pid,pmt->PCR_pid);
fprint_msg_or_err(is_msg,"Program %d, version %d, PCR PID %04x (%d)\n",
pmt->program_number,pmt->version_number,pmt->PCR_pid,pmt->PCR_pid);
if (pmt->program_info_length > 0)
{
if (prefix!=NULL) fprintf(stream,prefix);
print_data(stream==stdout," Program info",pmt->program_info,
if (prefix!=NULL) fprint_msg_or_err(is_msg,prefix);
print_data(is_msg," Program info",pmt->program_info,
pmt->program_info_length,pmt->program_info_length);
print_descriptors(stream,prefix," ",pmt->program_info,
print_descriptors(is_msg,prefix," ",pmt->program_info,
pmt->program_info_length);
}
if (pmt->num_streams > 0)
{
int ii;
if (prefix!=NULL) fprintf(stream,prefix);
fprintf(stream,"Program streams:\n");
if (prefix!=NULL) fprint_msg_or_err(is_msg,prefix);
fprint_msg_or_err(is_msg,"Program streams:\n");
for (ii=0; ii<pmt->num_streams; ii++)
{
if (prefix!=NULL) fprintf(stream,prefix);
fprintf(stream," PID %04x (%4d) -> Stream type %02x (%3d) %s\n",
pmt->streams[ii].elementary_PID,
pmt->streams[ii].elementary_PID,
pmt->streams[ii].stream_type,
pmt->streams[ii].stream_type,
h222_stream_type_str(pmt->streams[ii].stream_type));
if (prefix!=NULL) fprint_msg_or_err(is_msg,prefix);
fprint_msg_or_err(is_msg," PID %04x (%4d) -> Stream type %02x (%3d) %s\n",
pmt->streams[ii].elementary_PID,
pmt->streams[ii].elementary_PID,
pmt->streams[ii].stream_type,
pmt->streams[ii].stream_type,
h222_stream_type_str(pmt->streams[ii].stream_type));
if (pmt->streams[ii].ES_info_length > 0)
{
if (prefix!=NULL) fprintf(stream,prefix);
print_data(stream==stdout," ES info",
if (prefix!=NULL) fprint_msg_or_err(is_msg,prefix);
print_data(is_msg," ES info",
pmt->streams[ii].ES_info,
pmt->streams[ii].ES_info_length,
pmt->streams[ii].ES_info_length);
print_descriptors(stream,prefix," ",
print_descriptors(is_msg,prefix," ",
pmt->streams[ii].ES_info,
pmt->streams[ii].ES_info_length);
}

Wyświetl plik

@ -229,11 +229,11 @@ extern int same_pmt(pmt_p pmt1,
/*
* Report on a PMT datastructure.
*
* - `stream` is the stream to write to
* - if `is_msg`, report as a message, otherwise as an error
* - `prefix` is NULL or a string to put before each line printed
* - `pmt` is the PMT to report on
*/
extern void report_pmt(FILE *stream,
extern void report_pmt(int is_msg,
char *prefix,
pmt_p pmt);

124
ts.c
Wyświetl plik

@ -41,6 +41,7 @@
#include "ts_fns.h"
#include "tswrite_fns.h"
#include "misc_fns.h"
#include "printing_fns.h"
#include "pidint_fns.h"
#include "pes_fns.h"
@ -1005,7 +1006,7 @@ extern int write_pmt(TS_writer_p output,
if (section_length > 1021)
{
fprintf(stderr,"### PMT data is too long - will not fit in 1021 bytes\n");
report_pmt(stderr," ",pmt);
report_pmt(FALSE," ",pmt);
return 1;
}
@ -2193,7 +2194,7 @@ extern int extract_prog_list_from_pat(int verbose,
* Print out information about program descriptors
* (either from the PMT program info, or the PMT/stream ES info)
*
* - `stream` is the stream to print on
* - if `is_msg` then print as a message, otherwise as an error
* - `leader1` and `leader2` are the text to write at the start of each line
* (either or both may be NULL)
* - `desc_data` is the data containing the descriptors
@ -2203,7 +2204,7 @@ extern int extract_prog_list_from_pat(int verbose,
*
* If you want to interpret more descriptors then ITU-T J.94 is the standard
*/
extern int print_descriptors(FILE *stream,
extern int print_descriptors(int is_msg,
char *leader1,
char *leader2,
byte *desc_data,
@ -2224,8 +2225,8 @@ extern int print_descriptors(FILE *stream,
if (this_length > data_len)
{
// Not much we can do - try giving up?
fprintf(stream,"Descriptor %x says length %d, but only %d bytes left\n",
tag,this_length,data_len);
fprint_msg_or_err(is_msg,"Descriptor %x says length %d, but only %d bytes left\n",
tag,this_length,data_len);
return 1; // Hmm - well, maybe
}
@ -2249,63 +2250,63 @@ extern int print_descriptors(FILE *stream,
tag==18?"IBP":
tag>19 && tag<64?"Reserved":NULL);
if (leader1 != NULL) fputs(leader1,stream);
if (leader2 != NULL) fputs(leader2,stream);
if (leader1 != NULL) fprint_msg_or_err(is_msg,"%s",leader1);
if (leader2 != NULL) fprint_msg_or_err(is_msg,"%s",leader2);
if (name != NULL)
print_data(stream==stdout,name,data,this_length,100);
print_data(is_msg,name,data,this_length,100);
else
{
switch (tag)
{
uint32_t temp_u;
case 5:
fprintf(stream,"Registration ");
fprint_msg_or_err(is_msg,"Registration ");
if (this_length >= 4)
{
for (ii=0; ii<4; ii++)
{
if (isprint(data[ii]))
putc(data[ii],stream);
fprint_msg_or_err(is_msg,"%c",data[ii]);
else
fprintf(stream,"<%02x>",data[ii]);
fprint_msg_or_err(is_msg,"<%02x>",data[ii]);
}
if (this_length > 4)
for (ii=4; ii < this_length; ii++)
fprintf(stream," %02x",data[ii]);
fprint_msg_or_err(is_msg," %02x",data[ii]);
}
fprintf(stream,"\n");
fprint_msg_or_err(is_msg,"\n");
break;
case 9: // I see this in data, so might as well "explain" it
fprintf(stream,"Conditional access: ");
fprint_msg_or_err(is_msg,"Conditional access: ");
temp_u = (data[0] << 8) | data[1];
fprintf(stream,"id %04x (%d) ",temp_u,temp_u);
fprint_msg_or_err(is_msg,"id %04x (%d) ",temp_u,temp_u);
temp_u = ((data[2] & 0x1F) << 8) | data[3];
fprintf(stream,"PID %04x (%d) ",temp_u,temp_u);
fprint_msg_or_err(is_msg,"PID %04x (%d) ",temp_u,temp_u);
if (data_len > 4)
print_data(stream==stdout,"data",&data[4],data_len-4,data_len-4);
print_data(is_msg,"data",&data[4],data_len-4,data_len-4);
else
fprintf(stream,"\n");
fprint_msg_or_err(is_msg,"\n");
break;
case 10: // We'll assume the length is a multiple of 4
fprintf(stream,"Languages: ");
fprint_msg_or_err(is_msg,"Languages: ");
for (ii = 0; ii < this_length/4; ii++)
{
byte audio_type;
if (ii > 0) fprintf(stream,", ");
putc(*(data+(ii*4)+0),stream);
putc(*(data+(ii*4)+1),stream);
putc(*(data+(ii*4)+2),stream);
if (ii > 0) fprint_msg_or_err(is_msg,", ");
fprint_msg_or_err(is_msg,"%c",*(data+(ii*4)+0));
fprint_msg_or_err(is_msg,"%c",*(data+(ii*4)+1));
fprint_msg_or_err(is_msg,"%c",*(data+(ii*4)+2));
audio_type = *(data+(ii*4)+3);
switch (audio_type)
{
case 0: /*fprintf(stream,"/undefined");*/ break; // clearer to say nowt?
case 1: fprintf(stream,"/clean effects"); break;
case 2: fprintf(stream,"/hearing impaired"); break;
case 3: fprintf(stream,"/visual impaired commentary"); break;
default: fprintf(stream,"/reserved:0x%02x",audio_type); break;
case 0: /*fprint_msg_or_err(is_msg,"/undefined");*/ break; // clearer to say nowt?
case 1: fprint_msg_or_err(is_msg,"/clean effects"); break;
case 2: fprint_msg_or_err(is_msg,"/hearing impaired"); break;
case 3: fprint_msg_or_err(is_msg,"/visual impaired commentary"); break;
default: fprint_msg_or_err(is_msg,"/reserved:0x%02x",audio_type); break;
}
}
fprintf(stream,"\n");
fprint_msg_or_err(is_msg,"\n");
break;
case 0x56: // teletext
for (ii = 0; ii < this_length; ii += 5)
@ -2313,42 +2314,42 @@ extern int print_descriptors(FILE *stream,
int jj;
int teletext_type, teletext_magazine, teletext_page;
if (ii == 0)
fprintf(stream,"Teletext: ");
fprint_msg_or_err(is_msg,"Teletext: ");
else
{
if (leader1 != NULL) fputs(leader1,stream);
if (leader2 != NULL) fputs(leader2,stream);
fprintf(stream," ");
if (leader1 != NULL) fprint_msg_or_err(is_msg,"%s",leader1);
if (leader2 != NULL) fprint_msg_or_err(is_msg,"%s",leader2);
fprint_msg_or_err(is_msg," ");
}
fprintf(stream,"language=");
fprint_msg_or_err(is_msg,"language=");
for (jj=ii; jj<ii+3; jj++)
{
if (isprint(data[jj]))
putc(data[jj],stream);
fprint_msg_or_err(is_msg,"%c",data[jj]);
else
fprintf(stream,"<%02x>",data[jj]);
fprint_msg_or_err(is_msg,"<%02x>",data[jj]);
}
teletext_type = (data[ii+3] & 0xF8) >> 3;
teletext_magazine = (data[ii+3] & 0x07);
teletext_page = data[ii+4];
fprintf(stream,", type=");
fprint_msg_or_err(is_msg,", type=");
switch (teletext_type)
{
case 1: fprintf(stream,"Initial"); break;
case 2: fprintf(stream,"Subtitles"); break;
case 3: fprintf(stream,"Additional info"); break;
case 4: fprintf(stream,"Programme schedule"); break;
case 5: fprintf(stream,"Hearing impaired subtitles"); break;
default: fprintf(stream,"%x (reserved)",teletext_type); break;
case 1: fprint_msg_or_err(is_msg,"Initial"); break;
case 2: fprint_msg_or_err(is_msg,"Subtitles"); break;
case 3: fprint_msg_or_err(is_msg,"Additional info"); break;
case 4: fprint_msg_or_err(is_msg,"Programme schedule"); break;
case 5: fprint_msg_or_err(is_msg,"Hearing impaired subtitles"); break;
default: fprint_msg_or_err(is_msg,"%x (reserved)",teletext_type); break;
}
fprintf(stream,", magazine %d, page %x",teletext_magazine,teletext_page);
fprintf(stream,"\n");
fprint_msg_or_err(is_msg,", magazine %d, page %x",teletext_magazine,teletext_page);
fprint_msg_or_err(is_msg,"\n");
}
break;
case 0x59:
{
fprintf(stream, "subtitling_descriptor:\n");
fprint_msg_or_err(is_msg, "subtitling_descriptor:\n");
for (ii = 0; ii + 8 <= this_length; ii += 8)
{
@ -2360,34 +2361,33 @@ extern int print_descriptors(FILE *stream,
lang[1] = data[ii + 1];
lang[2] = data[ii + 2];
lang[3] = 0;
if (leader1 != NULL) fputs(leader1,stream);
if (leader2 != NULL) fputs(leader2,stream);
fprintf(stream,
" language='%s', subtitling_type=%u\n",
if (leader1 != NULL) fprint_msg_or_err(is_msg,"%s",leader1);
if (leader2 != NULL) fprint_msg_or_err(is_msg,"%s",leader2);
fprint_msg_or_err(is_msg," language='%s', subtitling_type=%u\n",
lang, subtitling_type);
if (leader1 != NULL) fputs(leader1,stream);
if (leader2 != NULL) fputs(leader2,stream);
fprintf(stream,
if (leader1 != NULL) fprint_msg_or_err(is_msg,"%s",leader1);
if (leader2 != NULL) fprint_msg_or_err(is_msg,"%s",leader2);
fprint_msg_or_err(is_msg,
" composition_page_id=%u, ancillary_page_id=%u\n",
composition_page_id, ancillary_page_id);
}
if (ii < this_length)
fprintf(stream, "### %d spare bytes at end of descriptor\n", this_length - ii);
fprint_msg_or_err(is_msg, "### %d spare bytes at end of descriptor\n", this_length - ii);
break;
}
case 0x6A:
print_data(stream==stdout,"DVB AC-3",data,this_length,100);
print_data(is_msg,"DVB AC-3",data,this_length,100);
break;
case 0x81:
print_data(stream==stdout,"ATSC AC-3",data,this_length,100);
print_data(is_msg,"ATSC AC-3",data,this_length,100);
default:
// Report the tag number as decimal since that is how H.222
// describes it in table 2-39
{
char temp_c[50]; // twice as much as I need...
sprintf(temp_c,"Descriptor tag %02x (%3d)",tag,tag);
print_data(stream==stdout,temp_c,data,this_length,100);
print_data(is_msg,temp_c,data,this_length,100);
}
break;
}
@ -2671,7 +2671,7 @@ extern int extract_pmt(int verbose,
if (verbose && program_info_length > 0)
{
printf(" Program info:\n");
print_descriptors(stdout," ",NULL,&data[12],program_info_length);
print_descriptors(TRUE," ",NULL,&data[12],program_info_length);
}
// 32 bits at the end of a program association section is reserved for a CRC
@ -2724,7 +2724,7 @@ extern int extract_pmt(int verbose,
printf(" PID %04x -> Stream %02x %s\n",pid,stream_type,
h222_stream_type_str(stream_type));
if (ES_info_length > 0)
print_descriptors(stdout," ",NULL,&stream_data[5],ES_info_length);
print_descriptors(TRUE," ",NULL,&stream_data[5],ES_info_length);
}
err = add_stream_to_pmt(*pmt,pid,stream_type,ES_info_length,
stream_data+5);
@ -2903,7 +2903,7 @@ extern int extract_stream_list_from_pmt(int verbose,
if (verbose && program_info_length > 0)
{
printf(" Program info:\n");
print_descriptors(stdout," ",NULL,&data[12],program_info_length);
print_descriptors(TRUE," ",NULL,&data[12],program_info_length);
}
// 32 bits at the end of a program association section is reserved for a CRC
@ -2949,7 +2949,7 @@ extern int extract_stream_list_from_pmt(int verbose,
buf[SARRAYSIZE-1] = '\0';
printf(" Stream %02x %-40s -> PID %04x\n",stream_type,buf,pid);
if (ES_info_length > 0)
print_descriptors(stdout," ",NULL,&stream_data[5],ES_info_length);
print_descriptors(TRUE," ",NULL,&stream_data[5],ES_info_length);
}
// For the moment, we shan't bother to remember the extra info.
err = append_to_pidint_list(*stream_list,pid,stream_type);
@ -3442,7 +3442,7 @@ extern int find_pmt(TS_reader_p tsreader,
{
printf("\n");
printf("Program map\n");
report_pmt(stdout," ",*pmt);
report_pmt(TRUE," ",*pmt);
printf("\n");
}
return 0;

Wyświetl plik

@ -549,7 +549,7 @@ extern void report_payload(int show_data,
* Print out information about program descriptors
* (either from the PMT program info, or the PMT/stream ES info)
*
* - `stream` is the stream to print on
* - if `is_msg` then print as a message, otherwise as an error
* - `leader1` and `leader2` are the text to write at the start of each line
* (either or both may be NULL)
* - `desc_data` is the data containing the descriptors
@ -557,7 +557,7 @@ extern void report_payload(int show_data,
*
* Returns 0 if all went well, 1 if something went wrong
*/
extern int print_descriptors(FILE *stream,
extern int print_descriptors(int is_msg,
char *leader1,
char *leader2,
byte *desc_data,

Wyświetl plik

@ -263,7 +263,7 @@ static int report_streams(TS_reader_p tsreader,
else if (!verbose)
printf("\nPacket %d is PMT with PID %04x (%d)\n",ii+1,pid,pid);
report_pmt(stdout," ",this_pmt);
report_pmt(TRUE," ",this_pmt);
free_pmt(&last_pmt);
last_pmt = this_pmt;

Wyświetl plik

@ -342,7 +342,7 @@ static int find_PCR_PID(TS_reader_p tsreader,
}
if (!quiet)
report_pmt(stdout," ",pmt);
report_pmt(TRUE," ",pmt);
*pcr_pid = pmt->PCR_pid;
free_pmt(&pmt);
if (!quiet)

Wyświetl plik

@ -745,7 +745,7 @@ static int report_ts(TS_reader_p tsreader,
{
fprintf(stderr,"### Internal error: stream for PID %0x returned NULL"
" in PMT\n",pid);
report_pmt(stderr," ",pmt);
report_pmt(FALSE," ",pmt);
free_pidint_list(&prog_list);
free_pmt(&pmt);
if (pmt_data) free(pmt_data);
@ -904,7 +904,7 @@ static int report_ts(TS_reader_p tsreader,
pmt_data = NULL; pmt_data_len = 0; pmt_data_used = 0;
#if 0
printf("PMT data read as:\n");
report_pmt(stdout," ",pmt);
report_pmt(TRUE," ",pmt);
printf("\n");
#endif
}