-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun
executable file
·118 lines (98 loc) · 3.03 KB
/
run
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env zsh
if (( ${+PROJECT_DIR} )); then
local project_dir=${PROJECT_DIR}
else
local project_dir=$(pwd)
fi
# export GST_PLUGIN_PATH="/usr/lib/gstreamer-1.0:${project_dir}/build"
# export GST_PLUGIN_PATH="${project_dir}/../gst-plugins-good/install/lib/gstreamer-1.0:${project_dir}/build"
LD_LIBRARY_PATH=${project_dir}/usrsctp/build
IP_NTP_SERVER=${IP_RECEIVER}
dot_dir_default=${project_dir}/dot
gst_debug_default=""
default_variant="single"
usage() {
echo "usage: run [-fbuvR] [--dot [dir]] binary -V variant"
exit 1
}
zshexit() {
[[ ! ${+verbose[1]} ]] && set +x
}
zparseopts -D -E -- f=fetch b=build u=usrsctp R=norun d:=debug_string v=verbose -dot::=dot_dir \
V:=variant -valgrind=valgrind n:=num_buffers T:=timestamp_offset -ntp=ntp \
D:=deadline -delay:=delay -padding:=delay_padding
[[ $# < 2 ]] && norun[1]=1
(( ${+verbose[1]} )) && set -x
if (( !${+GST_DEBUG} )); then
# if given by -d > replace, otherwise take default
export GST_DEBUG=${debug_string[2]:-${gst_debug_default}}
fi
TARGET=
if (( ! ${+norun[1]} )); then
TARGET=$1
try_bin=${1}/${2}
if [[ -x $try_bin ]]; then
# echo "found $try_bin"
BIN=$try_bin
else
BIN="${project_dir}/**/${try_bin}(*[1])"
# if [[ ! -f ${~BIN} ]]; then
# echo "binary ( ${~BIN} ) not found"
# usage
# fi
fi
fi
export GST_PLUGIN_PATH=${TARGET}
# # fetch
# if (( ${+fetch[1]} )); then
# echo -e "\n####Fetching from git repo...."
# (cd ${project_dir}
# git pull origin master
# )
# fi
# # build usrsctp
# if (( ${+usrsctp[1]} )); then
# echo -e "\n####Building usrsctp...."
# cmake --build ${project_dir}/usrsctp/build
# fi
# # build gst-sctp
# if (( ${+build[1]} )); then
# echo -e "\n####Building gst-sctp...."
# (cd ${project_dir}/build;
# ninja install
# )
# fi
if (( ${+ntp[1]} )); then
sudo systemctl stop ntpd.service
sudo ntpdate ${IP_NTP_SERVER}
if (( $? )); then
echo "\033[0;31mNTP failed\033[0m"
exit 1
fi
sudo systemctl start ntpd.service
fi
if (( ${+norun[1]} )); then
exit 0
fi
if (( ${+dot_dir[1]} )); then
# the option --dot <dir> is added into the same field [1] > substitute the option
# if result is empty > take default
DOT_DIR=${${dot_dir[1]:s/--dot//}:-${dot_dir_default}}
mkdir -p $DOT_DIR
export GST_DEBUG_DUMP_DOT_DIR=$DOT_DIR
fi
if (( $(( 4294 - ( $(date +%s) - ${timestamp_offset[2]} ) )) < 500 )); then
echo "TS offset error: $(( 4294 - ( $(date +%s) - ${timestamp_offset[2]} ) )) left\tuse: $(date +%s)"
exit 1
fi
# run sender
sudo -E LD_LIBRARY_PATH=${LD_LIBRARY_PATH} \
${+valgrind[1]:+valgrind} \
${~BIN} \
--variant ${variant[2]:-$default_variant} \
--timestamp-offset ${timestamp_offset[2]} \
--deadline $(( ${deadline[2]} * 1000 )) \
${+delay[2]:+--path-delay} ${+delay[2]:+$(( ${delay[2]} * 1000 ))} \
${+delay_padding[2]:+--delay-padding} ${+delay_padding[2]:+$(( ${delay_padding[2]} * 1000 ))} \
${+num_buffers[2]:+-n} ${+num_buffers[2]:+${num_buffers[2]}} \
2>&1