xs/DVBT-ts.c

filter: Statementstmt 0.0% 0 / 89 Branchbran 0.0% 0 / 178 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 267 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/DVBT-ts-skip.c ↑ Summary xs/shared/DVBT-common.h »
1 # VERSION = "1.000"
2  
3  
4 # /*---------------------------------------------------------------------------------------------------*/
5 # /* Repair TS file */
6  
7 int
8 dvb_ts_repair(char *filename, char *ofilename, HV *settings_href=NULL)
9 INIT:
10 struct TS_settings settings;
11 SV **val;
12  
13 CODE:
14 0 dvb_error_clear() ;
15 0 clear_settings(&settings) ;
16  
17 0 ▶ if (settings_href)
Branch: 1 branch
BranchTrueFalseTotal
if (settings_href) 0 0 0
18 {
19 0 ▶ HVF_IV(settings_href, debug, settings.debug) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
20 0 ▶ HVF_IV(settings_href, null_error_packets, settings.null_error_packets) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, null_error_packets, settings.null_error_packets) ; 0 0 0
HVF_IV(settings_href, null_error_packets, settings.null_error_packets) ; 0 0 0
21 0 ▶ HVF_SVV(settings_href, error_callback, settings.error_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
22 0 ▶ HVF_SVV(settings_href, user_data, settings.perl_data) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
23 }
24  
25 // repair
26 0 RETVAL = tsrepair(filename, ofilename, &settings) ;
27  
28 OUTPUT:
29 RETVAL
30  
31 # /*---------------------------------------------------------------------------------------------------*/
32 # /* Parse TS file */
33  
34 int
35 dvb_ts_parse(char *filename, HV *settings_href)
36 INIT:
37 struct TS_settings settings;
38 SV **val;
39 int ival ;
40  
41 CODE:
42 0 dvb_error_clear() ;
43 0 clear_settings(&settings) ;
44  
45 0 ▶ if (settings_href)
Branch: 1 branch
BranchTrueFalseTotal
if (settings_href) 0 0 0
46 {
47 0 ▶ HVF_IV(settings_href, debug, settings.debug) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
48  
49 0 ▶ HVF_IV(settings_href, num_pkts, settings.num_pkts) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, num_pkts, settings.num_pkts) ; 0 0 0
HVF_IV(settings_href, num_pkts, settings.num_pkts) ; 0 0 0
50 0 ▶ HVF_IV(settings_href, skip_pkts, settings.skip_pkts) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, skip_pkts, settings.skip_pkts) ; 0 0 0
HVF_IV(settings_href, skip_pkts, settings.skip_pkts) ; 0 0 0
51 0 ▶ HVF_IV(settings_href, origin, settings.origin) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, origin, settings.origin) ; 0 0 0
HVF_IV(settings_href, origin, settings.origin) ; 0 0 0
52  
53 0 ▶ HVF_SVV(settings_href, pid_callback, settings.pid_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, pid_callback, settings.pid_callback) ; 0 0 0
HVF_SVV(settings_href, pid_callback, settings.pid_callback) ; 0 0 0
54 0 ▶ HVF_SVV(settings_href, error_callback, settings.error_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
55 0 ▶ HVF_SVV(settings_href, payload_callback, settings.payload_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, payload_callback, settings.payload_callback) ; 0 0 0
HVF_SVV(settings_href, payload_callback, settings.payload_callback) ; 0 0 0
56 0 ▶ HVF_SVV(settings_href, ts_callback, settings.ts_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, ts_callback, settings.ts_callback) ; 0 0 0
HVF_SVV(settings_href, ts_callback, settings.ts_callback) ; 0 0 0
57 0 ▶ HVF_SVV(settings_href, pes_callback, settings.pes_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, pes_callback, settings.pes_callback) ; 0 0 0
HVF_SVV(settings_href, pes_callback, settings.pes_callback) ; 0 0 0
58 0 ▶ HVF_SVV(settings_href, pes_data_callback, settings.pes_data_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, pes_data_callback, settings.pes_data_callback) ; 0 0 0
HVF_SVV(settings_href, pes_data_callback, settings.pes_data_callback) ; 0 0 0
59 0 ▶ HVF_SVV(settings_href, progress_callback, settings.progress_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, progress_callback, settings.progress_callback) ; 0 0 0
HVF_SVV(settings_href, progress_callback, settings.progress_callback) ; 0 0 0
60 0 ▶ HVF_SVV(settings_href, mpeg2_callback, settings.mpeg2_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, mpeg2_callback, settings.mpeg2_callback) ; 0 0 0
HVF_SVV(settings_href, mpeg2_callback, settings.mpeg2_callback) ; 0 0 0
61 0 ▶ HVF_SVV(settings_href, mpeg2_rgb_callback, settings.mpeg2_rgb_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, mpeg2_rgb_callback, settings.mpeg2_rgb_callback) ; 0 0 0
HVF_SVV(settings_href, mpeg2_rgb_callback, settings.mpeg2_rgb_callback) ; 0 0 0
62 0 ▶ HVF_SVV(settings_href, audio_callback, settings.audio_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, audio_callback, settings.audio_callback) ; 0 0 0
HVF_SVV(settings_href, audio_callback, settings.audio_callback) ; 0 0 0
63  
64 0 ▶ HVF_SVV(settings_href, user_data, settings.perl_data) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
65 }
66  
67  
68 // parse
69 0 RETVAL = tsparse(filename, &settings) ;
70  
71 OUTPUT:
72 RETVAL
73  
74  
75  
76 # /*---------------------------------------------------------------------------------------------------*/
77 # /* Parse TS file - start */
78  
79 TSReader *
80 dvb_ts_parse_begin(char *filename, HV *settings_href)
81 INIT:
82 struct TS_settings settings;
83 SV **val;
84 int ival ;
85  
86 CODE:
87 0 dvb_error_clear() ;
88 0 clear_settings(&settings) ;
89  
90 0 ▶ if (settings_href)
Branch: 1 branch
BranchTrueFalseTotal
if (settings_href) 0 0 0
91 {
92 0 ▶ HVF_IV(settings_href, debug, settings.debug) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
93  
94 0 ▶ HVF_IV(settings_href, num_pkts, settings.num_pkts) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, num_pkts, settings.num_pkts) ; 0 0 0
HVF_IV(settings_href, num_pkts, settings.num_pkts) ; 0 0 0
95 0 ▶ HVF_IV(settings_href, skip_pkts, settings.skip_pkts) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, skip_pkts, settings.skip_pkts) ; 0 0 0
HVF_IV(settings_href, skip_pkts, settings.skip_pkts) ; 0 0 0
96 0 ▶ HVF_IV(settings_href, origin, settings.origin) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, origin, settings.origin) ; 0 0 0
HVF_IV(settings_href, origin, settings.origin) ; 0 0 0
97  
98 0 ▶ HVF_SVV(settings_href, pid_callback, settings.pid_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, pid_callback, settings.pid_callback) ; 0 0 0
HVF_SVV(settings_href, pid_callback, settings.pid_callback) ; 0 0 0
99 0 ▶ HVF_SVV(settings_href, error_callback, settings.error_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
100 0 ▶ HVF_SVV(settings_href, payload_callback, settings.payload_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, payload_callback, settings.payload_callback) ; 0 0 0
HVF_SVV(settings_href, payload_callback, settings.payload_callback) ; 0 0 0
101 0 ▶ HVF_SVV(settings_href, ts_callback, settings.ts_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, ts_callback, settings.ts_callback) ; 0 0 0
HVF_SVV(settings_href, ts_callback, settings.ts_callback) ; 0 0 0
102 0 ▶ HVF_SVV(settings_href, pes_callback, settings.pes_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, pes_callback, settings.pes_callback) ; 0 0 0
HVF_SVV(settings_href, pes_callback, settings.pes_callback) ; 0 0 0
103 0 ▶ HVF_SVV(settings_href, pes_data_callback, settings.pes_data_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, pes_data_callback, settings.pes_data_callback) ; 0 0 0
HVF_SVV(settings_href, pes_data_callback, settings.pes_data_callback) ; 0 0 0
104 0 ▶ HVF_SVV(settings_href, progress_callback, settings.progress_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, progress_callback, settings.progress_callback) ; 0 0 0
HVF_SVV(settings_href, progress_callback, settings.progress_callback) ; 0 0 0
105 0 ▶ HVF_SVV(settings_href, mpeg2_callback, settings.mpeg2_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, mpeg2_callback, settings.mpeg2_callback) ; 0 0 0
HVF_SVV(settings_href, mpeg2_callback, settings.mpeg2_callback) ; 0 0 0
106 0 ▶ HVF_SVV(settings_href, mpeg2_rgb_callback, settings.mpeg2_rgb_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, mpeg2_rgb_callback, settings.mpeg2_rgb_callback) ; 0 0 0
HVF_SVV(settings_href, mpeg2_rgb_callback, settings.mpeg2_rgb_callback) ; 0 0 0
107 0 ▶ HVF_SVV(settings_href, audio_callback, settings.audio_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, audio_callback, settings.audio_callback) ; 0 0 0
HVF_SVV(settings_href, audio_callback, settings.audio_callback) ; 0 0 0
108  
109 0 ▶ HVF_SVV(settings_href, user_data, settings.perl_data) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
110 }
111  
112 // parse
113 0 RETVAL = tsparse_start(filename, &settings) ;
114  
115 OUTPUT:
116 RETVAL
117  
118 # /*---------------------------------------------------------------------------------------------------*/
119 # /* Parse TS file - run */
120  
121 int
122 dvb_ts_parse_run(TSReader *tsreader)
123  
124 CODE:
125 0 dvb_error_clear() ;
126  
127 // check
128 0 ▶ VALID_READER(tsreader) ;
Branch: 2 branches
BranchTrueFalseTotal
VALID_READER(tsreader) ; 0 0 0
VALID_READER(tsreader) ; 0 0 0
129  
130 // run
131 0 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 0 0
132 0 RETVAL = tsparse_run(tsreader) ;
133  
134 OUTPUT:
135 RETVAL
136  
137  
138 # /*---------------------------------------------------------------------------------------------------*/
139 # /* Parse TS file - end */
140  
141 int
142 dvb_ts_parse_end(TSReader *tsreader)
143  
144 CODE:
145 0 dvb_error_clear() ;
146  
147 // check
148 0 ▶ VALID_READER(tsreader) ;
Branch: 2 branches
BranchTrueFalseTotal
VALID_READER(tsreader) ; 0 0 0
VALID_READER(tsreader) ; 0 0 0
149  
150 // finish
151 0 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 0 0
152 0 RETVAL = tsparse_end(tsreader) ;
153  
154 OUTPUT:
155 RETVAL
156  
157  
158 # /*---------------------------------------------------------------------------------------------------*/
159 # /* Parse TS file - stop parsing */
160  
161 int
162 dvb_ts_parse_stop(TSReader *tsreader)
163  
164 CODE:
165 0 dvb_error_clear() ;
166  
167 // check
168 0 ▶ VALID_READER(tsreader) ;
Branch: 2 branches
BranchTrueFalseTotal
VALID_READER(tsreader) ; 0 0 0
VALID_READER(tsreader) ; 0 0 0
169  
170 // stop now
171 0 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 0 0
172 0 tsreader_stop(tsreader) ;
173  
174 OUTPUT:
175 RETVAL
176  
177  
178 # /*---------------------------------------------------------------------------------------------------*/
179 # /* Set file pos */
180  
181 int
182 dvb_ts_setpos(TSReader *tsreader, int skip_pkts, int origin, unsigned num_pkts)
183  
184 CODE:
185 0 dvb_error_clear() ;
186  
187 // check
188 0 ▶ VALID_READER(tsreader) ;
Branch: 2 branches
BranchTrueFalseTotal
VALID_READER(tsreader) ; 0 0 0
VALID_READER(tsreader) ; 0 0 0
189  
190 // set position
191 0 ▶ if (!RETVAL)
Branch: 1 branch
BranchTrueFalseTotal
if (!RETVAL) 0 0 0
192 0 RETVAL = tsreader_setpos(tsreader, skip_pkts, origin, num_pkts) ;
193  
194 OUTPUT:
195 RETVAL
196  
197  
198 # /*---------------------------------------------------------------------------------------------------*/
199 # /* Read bits of the file to get quick overview */
200  
201 SV *
202 dvb_ts_info(char *filename, HV *settings_href)
203 INIT:
204 TSReader *tsreader ;
205 struct TS_settings settings;
206 SV **val;
207 0 HV *info_href = (HV *)sv_2mortal((SV *)newHV());
208 0 HV *pid_href = (HV *)sv_2mortal((SV *)newHV());
209 struct TS_pid *piditem;
210 struct list_head *item;
211 char key[256] ;
212  
213 CODE:
214 0 dvb_error_clear() ;
215  
216 /* Create Perl data */
217 0 HVS(info_href, pids, newRV((SV *)pid_href)) ;
218  
219 0 clear_settings(&settings) ;
220 0 ▶ if (settings_href)
Branch: 1 branch
BranchTrueFalseTotal
if (settings_href) 0 0 0
221 {
222 0 ▶ HVF_IV(settings_href, debug, settings.debug) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
223 }
224  
225 // get info
226 0 tsreader = tsinfo(filename, &settings) ;
227  
228 0 ▶ if (!tsreader)
Branch: 1 branch
BranchTrueFalseTotal
if (!tsreader) 0 0 0
229 {
230 0 char *errstr = dvb_error_str(dvb_error_code) ;
231 0 HVS_STR(info_href, error, errstr) ;
232 }
233 else
234 {
235 // save info in a HASH
236 0 HVS_I(info_href, tsreader->tsstate, total_pkts) ;
237 0 _store_time(info_href, "duration", (tsreader->tsstate->end_ts - tsreader->tsstate->start_ts) ) ;
238 0 _store_ts(info_href, "start_ts", tsreader->tsstate->start_ts) ;
239 0 _store_ts(info_href, "end_ts", tsreader->tsstate->end_ts) ;
240  
241 0 ▶ list_for_each(item, &tsreader->tsstate->pid_list)
Branch: 1 branch
BranchTrueFalseTotal
list_for_each(item, &tsreader->tsstate->pid_list) 0 0 0
242 {
243 HV *h ;
244  
245 0 piditem = list_entry(item, struct TS_pid, next);
246  
247 /* Convert structure fields into hash elements */
248 0 h = (HV *)sv_2mortal((SV *)newHV());
249  
250 0 _add_pidinfo(h, &piditem->pidinfo) ;
251 0 _add_pesinfo(h, &piditem->pesinfo) ;
252  
253 0 sprintf(key, "%d", piditem->pidinfo.pid) ;
254 0 hv_store(pid_href, key, strlen(key), newRV((SV *)h), 0) ;
255 }
256  
257  
258 // end
259 0 tsparse_end(tsreader) ;
260 }
261  
262 0 RETVAL = newRV((SV *)info_href);
263  
264 OUTPUT:
265 RETVAL
266  
267 # /*---------------------------------------------------------------------------------------------------*/
268 # /* Return error string */
269  
270 SV *
271 dvb_ts_error_str()
272 INIT:
273 SV *str;
274 char *error_str ;
275  
276 CODE:
277 0 error_str = dvb_error_str(dvb_error_code) ;
278 0 RETVAL = newSVpv(error_str, 0) ;
279  
280 OUTPUT:
281 RETVAL
282  
283 # /*---------------------------------------------------------------------------------------------------*/
284 # /* Return error code : 0 = no error */
285  
286 int
287 dvb_ts_error()
288  
289 CODE:
290 0 ▶ RETVAL = dvb_error_code ;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = dvb_error_code ; 0 0 0
291  
292 OUTPUT:
293 RETVAL
294  
« xs/DVBT-ts-skip.c ↑ Summary xs/shared/DVBT-common.h »