Debian Codegraph @

debian/tests/execute

raw symbols SCIP
1 #!/bin/sh
2
3 set -e
4
5 SAMPLE='/usr/share/forensics-samples/original-files/movie2/movie-hello.mp4'
6 IP='127.0.0.1'
7 PORT_SENDER='6789'
8 PORT_RIST='19876'
9 PORT_RECEIVER='9876'
10 BANDWIDTH='2560000'
11 PASSPHRASE='SecretPassPhrase'
12 SLEEPTIME='5'
13
14 WORKDIR="$(mktemp -d)"
15 trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
16 cd "$WORKDIR"
17
18 # based on https://code.videolan.org/rist/librist/-/wikis/rist-sender-and-receiver-Command-Line-Examples-as-of-v.-0.2.0
19 # testing the following flow, with ffmpeg providing and - at the end - receiving the stream:
20 #
21 # FFMPEGSENDER RISTSENDER RISTRECEIVER FFMPEGRECEIVER
22 # +----------+ +------------+ +--------------+ +------------+
23 # | | UDP | | RIST | | UDP | |
24 # | ffmpeg +----->| ristsender +------>| ristreceiver +----->| ffmpeg |
25 # | | | | | | | |
26 # +----------+ +------------+ +--------------+ +------------+
27
28 case "$1" in
29 'psk_enc')
30 RIST_EXTRAOPTS="&congestion-control=1&aes-type=128&secret=$PASSPHRASE"
31 RIST_PROFILE='1' # Main
32 ;;
33 'simple')
34 RIST_EXTRAOPTS=''
35 RIST_PROFILE='0' # Simple
36 ;;
37 *)
38 echo 'Unknown test profile, exiting.'
39 exit 1
40 ;;
41 esac
42
43 # listen for an incoming UDP stream to copy (w/ overwrite) to a file; close stdin to allow ffmpeg to run in the background
44 ffmpeg -y -i "udp://$IP:$PORT_RECEIVER" -c copy file://$(pwd)/sample.mp4 > FFMPEGRECEIVER.log 2>&1 < /dev/null &
45 FFMPEGRECEIVER=$!
46
47 # let ristreceiver receive an incoming RIST stream and relay to UDP above
48 ristreceiver -i "rist://@$IP:$PORT_RIST?cname=RECEIVER01&bandwidth=$BANDWIDTH$RIST_EXTRAOPTS" -o "udp://$IP:$PORT_RECEIVER" -p "$RIST_PROFILE" -v 4 > RISTRECEIVER.log 2>&1 &
49 RISTRECEIVER=$!
50
51 # let ristsender relay the UDP stream via RIST above
52 ristsender -i "udp://@$IP:$PORT_SENDER" -o "rist://$IP:$PORT_RIST?cname=SENDER01&bandwidth=$BANDWIDTH$RIST_EXTRAOPTS" -p "$RIST_PROFILE" -v 4 > RISTSENDER.log 2>&1 &
53 RISTSENDER=$!
54
55 # grant the preceding commands some time to safely initialize
56 sleep "$SLEEPTIME"
57
58 # send sample file into UDP stream
59 ffmpeg -i "$SAMPLE" -f mpegts "udp://$IP:$PORT_SENDER" > FFMPEGSENDER.log 2>&1
60
61 # grant the receivers some time to finish before killing them
62 sleep "$SLEEPTIME"
63 kill -KILL $RISTSENDER $RISTRECEIVER $FFMPEGRECEIVER
64
65 # did we actually receive a video? streaming it will change it, so we cannot just compare the files ...
66 file --mime sample.mp4 | grep '^sample.mp4: video/mp4' && echo "OK: found a streamed video:"
67 ls -al "$SAMPLE" sample.mp4
68
69 # output logs for reference
70 for i in FFMPEGSENDER RISTSENDER RISTRECEIVER FFMPEGRECEIVER; do
71 echo "===== $i logs ====="
72 cat "$i.log"
73 echo
74 done