1 |
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 |
$path = $0; |
---|
26 |
$path =~ s/digitaltvrecording.pl$//i; |
---|
27 |
if ($path ne "./"){ |
---|
28 |
push( @INC, "$path"); |
---|
29 |
} |
---|
30 |
|
---|
31 |
|
---|
32 |
$extendrecendsec = 10; |
---|
33 |
|
---|
34 |
$startupsleeptime = 32; |
---|
35 |
|
---|
36 |
|
---|
37 |
require 'foltialib.pl'; |
---|
38 |
|
---|
39 |
&writelog("digitaltvrecording: DEBUG $ARGV[0] $ARGV[1] $ARGV[2] $ARGV[3] $ARGV[4] $ARGV[5] $ARGV[6] $ARGV[7] $ARGV[8]"); |
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
&prepare; |
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
&calldigitalrecorder; |
---|
51 |
|
---|
52 |
&writelog("digitaldigitaltvrecording:RECEND:$bandtype $recch $lengthsec $stationid $sleeptype $filename $tid $countno $unittype |
---|
53 |
"); |
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
sub prepare{ |
---|
59 |
|
---|
60 |
|
---|
61 |
$bandtype = $ARGV[0] ; |
---|
62 |
$recch = $ARGV[1] ; |
---|
63 |
$lengthsec = $ARGV[2] ; |
---|
64 |
$stationid = $ARGV[3] ; |
---|
65 |
$sleeptype = $ARGV[4] ; |
---|
66 |
$filename = $ARGV[5] ; |
---|
67 |
$tid = $ARGV[6] ; |
---|
68 |
$countno = $ARGV[7] ; |
---|
69 |
$unittype = $ARGV[8] ; |
---|
70 |
|
---|
71 |
if (($bandtype eq "" )|| ($recch eq "")|| ($lengthsec eq "")){ |
---|
72 |
print "usage digitaltvrecording.pl bandtype ch length(sec) [stationid] [sleeptype] [filename] [TID] [NO] [unittype]\n"; |
---|
73 |
exit; |
---|
74 |
} |
---|
75 |
|
---|
76 |
my $intval = $recch % 10; |
---|
77 |
my $startupsleep = $startupsleeptime - $intval; |
---|
78 |
$reclengthsec = $lengthsec + (60 - $startupsleep) + 1; |
---|
79 |
|
---|
80 |
if ( $sleeptype ne "N"){ |
---|
81 |
&writelog("digitaltvrecording: DEBUG SLEEP $startupsleeptime:$intval:$startupsleep:$reclengthsec"); |
---|
82 |
sleep ( $startupsleep); |
---|
83 |
|
---|
84 |
}else{ |
---|
85 |
&writelog("digitaltvrecording: DEBUG RAPID START"); |
---|
86 |
} |
---|
87 |
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 |
$outputpath = "$recfolderpath"."/"; |
---|
99 |
|
---|
100 |
if ($countno eq "0"){ |
---|
101 |
$outputfile = $outputpath.$tid."--"; |
---|
102 |
}else{ |
---|
103 |
$outputfile = $outputpath.$tid."-".$countno."-"; |
---|
104 |
} |
---|
105 |
|
---|
106 |
if ($filename ne ""){ |
---|
107 |
|
---|
108 |
$outputfile = $filename ; |
---|
109 |
$outputfile = &filenameinjectioncheck($outputfile); |
---|
110 |
$outputfilewithoutpath = $outputfile ; |
---|
111 |
$outputfile = $outputpath.$outputfile ; |
---|
112 |
&writelog("digitaltvrecording: DEBUG FILENAME ne null \$outputfile $outputfile "); |
---|
113 |
}else{ |
---|
114 |
$outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60)); |
---|
115 |
chomp($outputfile); |
---|
116 |
$outputfile .= ".m2t"; |
---|
117 |
$outputfilewithoutpath = $outputfile ; |
---|
118 |
&writelog("digitaltvrecording: DEBUG FILENAME is null \$outputfile $outputfile "); |
---|
119 |
} |
---|
120 |
|
---|
121 |
|
---|
122 |
@wday_name = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); |
---|
123 |
$sleepcounter = 0; |
---|
124 |
$cmd=""; |
---|
125 |
|
---|
126 |
|
---|
127 |
if ( -e "$outputfile" ){ |
---|
128 |
if ( -s "$outputfile" ){ |
---|
129 |
&writelog("digitaltvrecording :ABORT :recfile $outputfile exist."); |
---|
130 |
exit 1; |
---|
131 |
} |
---|
132 |
} |
---|
133 |
|
---|
134 |
} |
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 |
|
---|
139 |
sub calldigitalrecorder{ |
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 |
my $oserr = 0; |
---|
145 |
my $originalrecch = $recch; |
---|
146 |
my $pt1recch = $recch; |
---|
147 |
my $errorflag = 0; |
---|
148 |
if ($bandtype == 0){ |
---|
149 |
|
---|
150 |
|
---|
151 |
}elsif($bandtype == 1){ |
---|
152 |
|
---|
153 |
|
---|
154 |
if ($recch == 101) { |
---|
155 |
$bssplitflag = $recch; |
---|
156 |
$recch = "b10"; |
---|
157 |
}elsif($recch == 102){ |
---|
158 |
$bssplitflag = $recch; |
---|
159 |
$recch = "b10"; |
---|
160 |
}elsif($recch == 103){ |
---|
161 |
$recch = "b11"; |
---|
162 |
}elsif($recch == 141){ |
---|
163 |
$recch = "b8"; |
---|
164 |
}elsif($recch == 151){ |
---|
165 |
$recch = "b1"; |
---|
166 |
}elsif($recch == 161){ |
---|
167 |
$recch = "b2"; |
---|
168 |
}elsif($recch == 171){ |
---|
169 |
$recch = "b4"; |
---|
170 |
}elsif($recch == 181){ |
---|
171 |
$recch = "b9"; |
---|
172 |
}elsif($recch == 191){ |
---|
173 |
$recch = "b3"; |
---|
174 |
}elsif($recch == 192){ |
---|
175 |
$recch = "b3"; |
---|
176 |
}elsif($recch == 193){ |
---|
177 |
$recch = "b3"; |
---|
178 |
}elsif($recch == 200){ |
---|
179 |
$recch = "b6"; |
---|
180 |
}elsif($recch == 211){ |
---|
181 |
$recch = "b5"; |
---|
182 |
}else{ |
---|
183 |
$recch = "b7"; |
---|
184 |
} |
---|
185 |
|
---|
186 |
|
---|
187 |
}elsif($bandtype == 2){ |
---|
188 |
|
---|
189 |
if($recch == 335){ |
---|
190 |
$pt1recch = "CS8"; |
---|
191 |
}elsif($recch == 237){ |
---|
192 |
$pt1recch = "CS2"; |
---|
193 |
}elsif($recch == 239){ |
---|
194 |
$pt1recch = "CS2"; |
---|
195 |
}elsif($recch == 306){ |
---|
196 |
$pt1recch = "CS2"; |
---|
197 |
}elsif($recch == 100){ |
---|
198 |
$pt1recch = "CS4"; |
---|
199 |
}elsif($recch == 256){ |
---|
200 |
$pt1recch = "CS4"; |
---|
201 |
}elsif($recch == 312){ |
---|
202 |
$pt1recch = "CS4"; |
---|
203 |
}elsif($recch == 322){ |
---|
204 |
$pt1recch = "CS4"; |
---|
205 |
}elsif($recch == 331){ |
---|
206 |
$pt1recch = "CS4"; |
---|
207 |
}elsif($recch == 194){ |
---|
208 |
$pt1recch = "CS4"; |
---|
209 |
}elsif($recch == 334){ |
---|
210 |
$pt1recch = "CS4"; |
---|
211 |
}elsif($recch == 221){ |
---|
212 |
$pt1recch = "CS6"; |
---|
213 |
}elsif($recch == 222){ |
---|
214 |
$pt1recch = "CS6"; |
---|
215 |
}elsif($recch == 223){ |
---|
216 |
$pt1recch = "CS6"; |
---|
217 |
}elsif($recch == 224){ |
---|
218 |
$pt1recch = "CS6"; |
---|
219 |
}elsif($recch == 292){ |
---|
220 |
$pt1recch = "CS6"; |
---|
221 |
}elsif($recch == 238){ |
---|
222 |
$pt1recch = "CS6"; |
---|
223 |
}elsif($recch == 310){ |
---|
224 |
$pt1recch = "CS6"; |
---|
225 |
}elsif($recch == 311){ |
---|
226 |
$pt1recch = "CS6"; |
---|
227 |
}elsif($recch == 343){ |
---|
228 |
$pt1recch = "CS6"; |
---|
229 |
}elsif($recch == 055){ |
---|
230 |
$pt1recch = "CS8"; |
---|
231 |
}elsif($recch == 228){ |
---|
232 |
$pt1recch = "CS10"; |
---|
233 |
}elsif($recch == 800){ |
---|
234 |
$pt1recch = "CS10"; |
---|
235 |
}elsif($recch == 801){ |
---|
236 |
$pt1recch = "CS10"; |
---|
237 |
}elsif($recch == 802){ |
---|
238 |
$pt1recch = "CS10"; |
---|
239 |
}elsif($recch == 260){ |
---|
240 |
$pt1recch = "CS12"; |
---|
241 |
}elsif($recch == 303){ |
---|
242 |
$pt1recch = "CS12"; |
---|
243 |
}elsif($recch == 323){ |
---|
244 |
$pt1recch = "CS12"; |
---|
245 |
}elsif($recch == 352){ |
---|
246 |
$pt1recch = "CS12"; |
---|
247 |
}elsif($recch == 353){ |
---|
248 |
$pt1recch = "CS12"; |
---|
249 |
}elsif($recch == 354){ |
---|
250 |
$pt1recch = "CS12"; |
---|
251 |
}elsif($recch == 361){ |
---|
252 |
$pt1recch = "CS12"; |
---|
253 |
}elsif($recch == 251){ |
---|
254 |
$pt1recch = "CS14"; |
---|
255 |
}elsif($recch == 252){ |
---|
256 |
$pt1recch = "CS14"; |
---|
257 |
}elsif($recch == 253){ |
---|
258 |
$pt1recch = "CS14"; |
---|
259 |
}elsif($recch == 254){ |
---|
260 |
$pt1recch = "CS14"; |
---|
261 |
}elsif($recch == 255){ |
---|
262 |
$pt1recch = "CS14"; |
---|
263 |
}elsif($recch == 305){ |
---|
264 |
$pt1recch = "CS16"; |
---|
265 |
}elsif($recch == 333){ |
---|
266 |
$pt1recch = "CS16"; |
---|
267 |
}elsif($recch == 342){ |
---|
268 |
$pt1recch = "CS16"; |
---|
269 |
}elsif($recch == 290){ |
---|
270 |
$pt1recch = "CS16"; |
---|
271 |
}elsif($recch == 803){ |
---|
272 |
$pt1recch = "CS16"; |
---|
273 |
}elsif($recch == 804){ |
---|
274 |
$pt1recch = "CS16"; |
---|
275 |
}elsif($recch == 240){ |
---|
276 |
$pt1recch = "CS18"; |
---|
277 |
}elsif($recch == 262){ |
---|
278 |
$pt1recch = "CS18"; |
---|
279 |
}elsif($recch == 314){ |
---|
280 |
$pt1recch = "CS18"; |
---|
281 |
}elsif($recch == 258){ |
---|
282 |
$pt1recch = "CS20"; |
---|
283 |
}elsif($recch == 302){ |
---|
284 |
$pt1recch = "CS20"; |
---|
285 |
}elsif($recch == 332){ |
---|
286 |
$pt1recch = "CS20"; |
---|
287 |
}elsif($recch == 340){ |
---|
288 |
$pt1recch = "CS20"; |
---|
289 |
}elsif($recch == 341){ |
---|
290 |
$pt1recch = "CS20"; |
---|
291 |
}elsif($recch == 160){ |
---|
292 |
$pt1recch = "CS22"; |
---|
293 |
}elsif($recch == 161){ |
---|
294 |
$pt1recch = "CS22"; |
---|
295 |
}elsif($recch == 185){ |
---|
296 |
$pt1recch = "CS22"; |
---|
297 |
}elsif($recch == 293){ |
---|
298 |
$pt1recch = "CS22"; |
---|
299 |
}elsif($recch == 301){ |
---|
300 |
$pt1recch = "CS22"; |
---|
301 |
}elsif($recch == 304){ |
---|
302 |
$pt1recch = "CS22"; |
---|
303 |
}elsif($recch == 325){ |
---|
304 |
$pt1recch = "CS22"; |
---|
305 |
|
---|
306 |
|
---|
307 |
}elsif($recch == 351){ |
---|
308 |
$pt1recch = "CS22"; |
---|
309 |
}elsif($recch == 257){ |
---|
310 |
$pt1recch = "CS24"; |
---|
311 |
}elsif($recch == 291){ |
---|
312 |
$pt1recch = "CS24"; |
---|
313 |
}elsif($recch == 300){ |
---|
314 |
$pt1recch = "CS24"; |
---|
315 |
}elsif($recch == 320){ |
---|
316 |
$pt1recch = "CS24"; |
---|
317 |
}elsif($recch == 321){ |
---|
318 |
$pt1recch = "CS24"; |
---|
319 |
}elsif($recch == 350){ |
---|
320 |
$pt1recch = "CS24"; |
---|
321 |
} |
---|
322 |
|
---|
323 |
}else{ |
---|
324 |
&writelog("digitaltvrecording :ERROR :Unsupported and type (digital CS)."); |
---|
325 |
exit 3; |
---|
326 |
} |
---|
327 |
|
---|
328 |
|
---|
329 |
|
---|
330 |
if (-e "$toolpath/perl/tool/recpt1"){ |
---|
331 |
if ($bandtype >= 1){ |
---|
332 |
&writelog("digitaltvrecording DEBUG recpt1 --b25 --sid $originalrecch $pt1recch $reclengthsec $outputfile "); |
---|
333 |
$oserr = system("$toolpath/perl/tool/recpt1 --b25 --sid $originalrecch $pt1recch $reclengthsec $outputfile "); |
---|
334 |
}else{ |
---|
335 |
&writelog("digitaltvrecording DEBUG recpt1 --b25 $originalrecch $reclengthsec $outputfile "); |
---|
336 |
$oserr = system("$toolpath/perl/tool/recpt1 --b25 $originalrecch $reclengthsec $outputfile "); |
---|
337 |
} |
---|
338 |
$oserr = $oserr >> 8; |
---|
339 |
if ($oserr > 0){ |
---|
340 |
&writelog("digitaltvrecording :ERROR :PT1 is BUSY.$oserr"); |
---|
341 |
$errorflag = 2; |
---|
342 |
} |
---|
343 |
}else{ |
---|
344 |
&writelog("digitaltvrecording :ERROR :recpt1 not found. You must install $toolpath/tool/b25 and $toolpath/tool/recpt1."); |
---|
345 |
$errorflag = 1; |
---|
346 |
} |
---|
347 |
|
---|
348 |
if ($errorflag >= 1 ){ |
---|
349 |
|
---|
350 |
if (-e "$toolpath/perl/tool/recfriio"){ |
---|
351 |
|
---|
352 |
if (! -e "$toolpath/perl/tool/friiodetect"){ |
---|
353 |
system("touch $toolpath/perl/tool/friiodetect"); |
---|
354 |
system("chown foltia:foltia $toolpath/perl/tool/friiodetect"); |
---|
355 |
system("chmod 775 $toolpath/perl/tool/friiodetect"); |
---|
356 |
&writelog("digitaltvrecording :DEBUG make lock file.$toolpath/perl/tool/friiodetect"); |
---|
357 |
} |
---|
358 |
&writelog("digitaltvrecording DEBUG recfriio --b25 --lockfile $toolpath/perl/tool/friiodetect $recch $reclengthsec $outputfile "); |
---|
359 |
$oserr = system("$toolpath/perl/tool/recfriio --b25 --lockfile $toolpath/perl/tool/friiodetect $recch $reclengthsec $outputfile "); |
---|
360 |
$oserr = $oserr >> 8; |
---|
361 |
if ($oserr > 0){ |
---|
362 |
&writelog("digitaltvrecording :ERROR :friio is BUSY.$oserr"); |
---|
363 |
exit 2; |
---|
364 |
} |
---|
365 |
|
---|
366 |
|
---|
367 |
if ($bssplitflag == 101){ |
---|
368 |
if (-e "$toolpath/perl/tool/TsSplitter.exe"){ |
---|
369 |
|
---|
370 |
system("wine $toolpath/perl/tool/TsSplitter.exe -EIT -ECM -EMM -OUT \"$outputpath\" -HD -SD2 -SD3 -1SEG -LOGFILE -WAIT2 $outputfile"); |
---|
371 |
$splitfile = $outputfile; |
---|
372 |
$splitfile =~ s/\.m2t$/_SD1.m2t/; |
---|
373 |
if (-e "$splitfile"){ |
---|
374 |
system("rm -rf $outputfile ; mv $splitfile $outputfile"); |
---|
375 |
&writelog("digitaltvrecording DEBUG rm -rf $outputfile ; mv $splitfile $outputfile: $?."); |
---|
376 |
}else{ |
---|
377 |
&writelog("digitaltvrecording ERROR File not found:$splitfile."); |
---|
378 |
} |
---|
379 |
}else{ |
---|
380 |
&writelog("digitaltvrecording ERROR $toolpath/perl/tool/TsSplitter.exe not found."); |
---|
381 |
} |
---|
382 |
}elsif($bssplitflag == 102){ |
---|
383 |
if (-e "$toolpath/perl/tool/TsSplitter.exe"){ |
---|
384 |
|
---|
385 |
system("wine $toolpath/perl/tool/TsSplitter.exe -EIT -ECM -EMM -OUT \"$outputpath\" -HD -SD1 -SD3 -1SEG -LOGFILE -WAIT2 $outputfile"); |
---|
386 |
$splitfile = $outputfile; |
---|
387 |
$splitfile =~ s/\.m2t$/_SD2.m2t/; |
---|
388 |
if (-e "$splitfile"){ |
---|
389 |
system("rm -rf $outputfile ; mv $splitfile $outputfile"); |
---|
390 |
&writelog("digitaltvrecording DEBUG rm -rf $outputfile ; mv $splitfile $outputfile: $?."); |
---|
391 |
}else{ |
---|
392 |
&writelog("digitaltvrecording ERROR File not found:$splitfile."); |
---|
393 |
} |
---|
394 |
}else{ |
---|
395 |
&writelog("digitaltvrecording ERROR $toolpath/perl/tool/TsSplitter.exe not found."); |
---|
396 |
} |
---|
397 |
}else{ |
---|
398 |
&writelog("digitaltvrecording DEBUG not split TS.$bssplitflag"); |
---|
399 |
} |
---|
400 |
|
---|
401 |
}else{ |
---|
402 |
&writelog("digitaltvrecording :ERROR :recfriio not found. You must install $toolpath/perl/tool/b25 and $toolpath/perl/tool/recfriio."); |
---|
403 |
exit 1; |
---|
404 |
} |
---|
405 |
} |
---|
406 |
} |
---|
407 |
|
---|
408 |
|
---|