xs/DVBT-ts-repair-c.c

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 36 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/DVBT-ts-info-c.c ↑ Summary xs/DVBT-ts-shared-c.c »
1 // VERSION = "1.000"
2 //
3 // Standard C code loaded outside XS space. Contains useful routines used by ts TS parsing functions
4  
5 //========================================================================================================
6 // REPAIR
7 //========================================================================================================
8  
9 //---------------------------------------------------------------------------------------------------------
10 0 static void repair_ts_hook(struct TS_pidinfo *pidinfo, uint8_t *packet, unsigned packet_len, void *user_data)
11 {
12 0 struct TS_parse_data *hook_data = (struct TS_parse_data *)user_data ;
13  
14 0 ▶ if (hook_data->ofile)
Branch: 1 branch
BranchTrueFalseTotal
if (hook_data->ofile) 0 0 0
15 {
16 0 ▶ if (pidinfo->pid_error)
Branch: 1 branch
BranchTrueFalseTotal
if (pidinfo->pid_error) 0 0 0
17 {
18 0 ▶ if (hook_data->null_error_packets)
Branch: 1 branch
BranchTrueFalseTotal
if (hook_data->null_error_packets) 0 0 0
19 {
20 // convert packet to null
21 0 ts_null_packet(packet, packet_len) ;
22  
23 // write it
24 0 write(hook_data->ofile, packet, packet_len);
25 }
26 }
27 else
28 {
29 // no error
30 0 write(hook_data->ofile, packet, packet_len);
31 }
32 }
33 0 }
34  
35 //---------------------------------------------------------------------------------------------------------
36 0 int tsrepair(char *filename, char *ofilename, struct TS_settings *settings)
37 {
38 int file;
39 struct TS_parse_data hook_data ;
40 struct TS_reader *tsreader ;
41  
42 0 hook_data.settings = settings ;
43 0 hook_data.null_error_packets = settings->null_error_packets ;
44  
45 0 hook_data.ofile = open(ofilename, O_CREAT | O_TRUNC | O_WRONLY | O_LARGEFILE, 0666);
46 0 ▶ if (-1 == hook_data.ofile) {
Branch: 1 branch
BranchTrueFalseTotal
if (-1 == hook_data.ofile) { 0 0 0
47 //fprintf(stderr,"open %s: %s\n",ofilename,strerror(errno));
48 0 RETURN_DVB_ERROR(ERR_FILE);
49 }
50  
51 0 tsreader = tsreader_new(filename) ;
52 0 ▶ if (!tsreader)
Branch: 1 branch
BranchTrueFalseTotal
if (!tsreader) 0 0 0
53 {
54 //fprintf(stderr,"ERROR %s: %s\n",filename,dvb_error_str(dvb_error_code));
55 0 return(dvb_error_code);
56 }
57  
58 0 tsreader->ts_hook = repair_ts_hook ;
59 0 tsreader->user_data = &hook_data ;
60  
61 // only support the following standard settings
62 0 tsreader->debug = settings->debug ;
63 0 tsreader->error_hook = parse_error_hook ;
64  
65 // parse data
66 0 ts_parse(tsreader) ;
67  
68 0 close(hook_data.ofile) ;
69  
70 0 tsreader_free(tsreader) ;
71 0 return(dvb_error_code) ;
72 }
73  
« xs/DVBT-ts-info-c.c ↑ Summary xs/DVBT-ts-shared-c.c »