-
Notifications
You must be signed in to change notification settings - Fork 6
/
tsock_video
executable file
·79 lines (65 loc) · 1.55 KB
/
tsock_video
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
puits=false
sourc=false
protocol="tcp"
port=`expr \`id -u\` % 3000 + 14578`
interrupted=1
usage() { echo "Usage: $0 [[-p|-s] [-t (tcp|mictcp)]" 1>&2; exit 1; }
# Stop all components gracefully
function graceful_stop ()
{
echo "Arret"
killall -9 cvlc > /dev/null 2>&1
killall -9 vlc > /dev/null 2>&1
killall -9 gateway > /dev/null 2>&1
if [ $interrupted -eq 1 ]; then
# Set return code to 2
exit 2
fi
}
# initialise trap to call graceful_stop function
# when signal 2 (SIGINT) is received
trap "graceful_stop" 2
while getopts "pst:" o; do
case "${o}" in
t)
protocol=${OPTARG}
if [ "$protocol" != "tcp" ] && [ "$protocol" != "mictcp" ]; then
usage
exit 1
fi
;;
p)
puits=true
;;
s)
sourc=true
;;
*)
usage
;;
esac
done
if ([ "$puits" = true ] && [ "$sourc" = true ]) || ([ "$puits" = false ] && [ "$sourc" = false ]) ; then
usage
exit 1
fi
if [ "$puits" = true ]; then
echo "Lancement du puits, protocole " $protocol
cvlc rtp://127.0.0.1:$port > /dev/null 2>&1 &
if [ "$protocol" = "mictcp" ]; then
cd build
./gateway -p -t $protocol $port &
cd ..
fi
fi
if [ "$sourc" = true ]; then
echo "Lancement de la source, protocol " $protocol
cd build
./gateway -s -t $protocol 127.0.0.1 $port &
cd ..
fi
echo "Appuyez sur ENTREE pour arreter"
read line
interrupted=0
graceful_stop