|
@@ -295,59 +295,106 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
295
|
295
|
}
|
296
|
296
|
|
297
|
297
|
check_audiostream() {
|
298
|
|
- # Uses mplayer to fetch 128Kb of stream
|
|
298
|
+ # Uses one of mplayer or mpv to retrieve a small amount of stream
|
|
299
|
+ # and attempt to decode it.
|
299
|
300
|
# $1 Stream URL
|
300
|
|
- # $2 size
|
301
|
|
- MPLAYER=$(whereis mplayer|cut -d' ' -f2)
|
302
|
|
- MPV=$(whereis mpv|cut -d' ' -f2)
|
|
301
|
+
|
|
302
|
+ MPLAYER="`which mplayer`"
|
|
303
|
+ MPV="`which mpv`"
|
303
|
304
|
if [ -x $MPLAYER ]
|
304
|
305
|
then
|
305
|
|
- tmpfile=$(mktemp -t check_audiostream.XXXXXXXXX)
|
306
|
|
-
|
307
|
|
- sz="$2"
|
308
|
|
- if [ -z "$sz" ]
|
309
|
|
- then
|
310
|
|
- sz="128kb"
|
311
|
|
- fi
|
312
|
|
- if [ "$verbose" -gt 1 ]
|
313
|
|
- then
|
314
|
|
- logdate INFO "$tc_name: Running mplayer on '$1' for $sz" 3
|
315
|
|
- fi
|
|
306
|
+ check_audiostream_mplayer "$1"
|
|
307
|
+ elif [ -x $MPV ]
|
|
308
|
+ then
|
|
309
|
+ check_audiostream_mpv "$1"
|
|
310
|
+ else
|
|
311
|
+ fail "Unable to find mplayer nor mpv"
|
|
312
|
+ fi
|
|
313
|
+}
|
316
|
314
|
|
317
|
|
- $MPLAYER -endpos $sz -ao pcm:file=$tmpfile "$1" 1>/dev/null 2>/dev/null
|
318
|
|
- res=$?
|
319
|
|
- bytes=$(du $tmpfile | cut -f1)
|
320
|
|
- rm $tmpfile 2>/dev/null
|
|
315
|
+check_audiostream_mplayer() {
|
|
316
|
+ # Uses mplayer to fetch 128Kb (by default) of stream
|
|
317
|
+ # $1 Stream URL
|
|
318
|
+ # $2 size in kb without the kb suffix
|
|
319
|
+ # $3 mplayer path
|
321
|
320
|
|
322
|
|
- if [ "$bytes" -lt 1024 ]
|
323
|
|
- then
|
324
|
|
- fail "mplayer retrieved ${bytes}B of stream instead of expected $sz"
|
325
|
|
- return
|
326
|
|
- fi
|
327
|
|
- if [ "$res" -eq 0 ]
|
328
|
|
- then
|
329
|
|
- success "mplayer retrieved $sz of stream on $1"
|
330
|
|
- else
|
331
|
|
- fail "mplayer failed to retrieve stream on $1"
|
332
|
|
- fi
|
333
|
|
- elif [ -x $MPV ]
|
|
321
|
+ tmpfile=$(mktemp -t check_audiostream.XXXXXXXXX)
|
|
322
|
+ sz="$2"
|
|
323
|
+ if [ -z "$sz" ]
|
334
|
324
|
then
|
335
|
|
- if [ "$verbose" -gt 1 ]
|
336
|
|
- then
|
337
|
|
- logdate INFO "$tc_name: Running mpv on '$1' for $sz" 3
|
338
|
|
- fi
|
339
|
|
- tmpfile=$(mktemp -t check_audiostream.XXXXXXXXX)
|
340
|
|
- $MPV --vo=null --ao=null --o=$tmpfile --of=wav --length 1 "$1" &> /dev/null
|
341
|
|
- bytes=$(du $tmpfile | cut -f1)
|
342
|
|
- rm $tmpfile 2>/dev/null
|
|
325
|
+ sz="128"
|
|
326
|
+ fi
|
|
327
|
+ MPLAYER="$3"
|
|
328
|
+ if [ -z "$MPLAYER" ]
|
|
329
|
+ then
|
|
330
|
+ MPLAYER="`which mplayer`"
|
|
331
|
+ fi
|
|
332
|
+
|
|
333
|
+ sz_kb="${sz}kb"
|
|
334
|
+ expt_sz="`expr $sz \* 8`"
|
|
335
|
+
|
|
336
|
+ if [ "$verbose" -gt 1 ]
|
|
337
|
+ then
|
|
338
|
+ logdate INFO "$tc_name: Running mplayer on '$1' for $sz_kb" 3
|
|
339
|
+ fi
|
|
340
|
+
|
|
341
|
+ $MPLAYER -endpos $sz_kb -ao pcm:file=$tmpfile "$1" 1>/dev/null 2>/dev/null
|
|
342
|
+ res=$?
|
|
343
|
+ bytes=$(du $tmpfile | cut -f1)
|
|
344
|
+ rm $tmpfile 2>/dev/null
|
|
345
|
+
|
|
346
|
+ if [ "$bytes" -lt $expt_sz ]
|
|
347
|
+ then
|
|
348
|
+ fail "mplayer retrieved ${bytes}B of stream instead of expected $sz_kb"
|
|
349
|
+ return
|
|
350
|
+ fi
|
|
351
|
+ if [ "$res" -eq 0 ]
|
|
352
|
+ then
|
|
353
|
+ success "mplayer retrieved $sz of stream on $1"
|
|
354
|
+ else
|
|
355
|
+ fail "mplayer failed to retrieve stream on $1"
|
|
356
|
+ fi
|
|
357
|
+}
|
|
358
|
+
|
|
359
|
+check_audiostream_mpv() {
|
|
360
|
+ # Uses mpv to fetch 4s of audio stream
|
|
361
|
+ # $1 Stream URL
|
|
362
|
+ # $2 time of stream to fetch
|
|
363
|
+ # $3 mpv path
|
|
364
|
+
|
|
365
|
+ time="$2"
|
|
366
|
+ if [ -z "$time" ]
|
|
367
|
+ then
|
|
368
|
+ time="4"
|
|
369
|
+ fi
|
|
370
|
+ MPV="$3"
|
|
371
|
+ if [ -z "$MPV" ]
|
|
372
|
+ then
|
|
373
|
+ MPV="`which mpv`"
|
|
374
|
+ fi
|
343
|
375
|
|
344
|
|
- if [ "$bytes" -ge 1 ]
|
345
|
|
- then
|
346
|
|
- success "mpv read successfully $1"
|
347
|
|
- else
|
348
|
|
- fail "mpv could not read $1"
|
349
|
|
- fi
|
350
|
376
|
|
|
377
|
+ if [ "$verbose" -gt 1 ]
|
|
378
|
+ then
|
|
379
|
+ logdate INFO "$tc_name: Running mpv on '$1' for ${time}s" 3
|
|
380
|
+ fi
|
|
381
|
+ start_time=`date "+%s"`
|
|
382
|
+ $MPV --vo=null --ao=null --o=/dev/null --of=wav --length $time "$1" 1> /dev/null 2>/dev/null
|
|
383
|
+ res=$?
|
|
384
|
+ stop_time=`date "+%s"`
|
|
385
|
+ run_time=`expr $stop_time - $start_time`
|
|
386
|
+
|
|
387
|
+ if [ $run_time -lt $time ]
|
|
388
|
+ then
|
|
389
|
+ fail "mpv stopped running ${run_time} after launch but ${time}s should be received"
|
|
390
|
+ return
|
|
391
|
+ fi
|
|
392
|
+
|
|
393
|
+ if [ $res -eq 0 ]
|
|
394
|
+ then
|
|
395
|
+ success "mpv retrieved ${time}s of stream on $1"
|
|
396
|
+ else
|
|
397
|
+ fail "mpv failed to retrieve ${time}s of stream on $1"
|
351
|
398
|
fi
|
352
|
399
|
}
|
353
|
400
|
|