Skip to content

Commit

Permalink
tools: jbuf plots - separate plot_loop.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Sep 27, 2023
1 parent 8d3d599 commit d163bb5
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 67 deletions.
79 changes: 12 additions & 67 deletions tools/jbuf/generate_plot.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
#!/bin/bash

if [ ! -f .env ]; then
echo ".env is missing. Copy and edit env-template!"
exit 1
fi

export `cat .env`

echo "target: $target"
echo "netif: $netif"
echo "once: $once"

if ! which jq; then
echo "Install jq"
exit 1
fi

trap "./jitter-off.sh; killall -q baresip" EXIT
if ! which gnuplot; then
echo "Install gnuplot"
exit 1
fi

function gen_datfile() {
ph=$1
Expand All @@ -26,60 +18,13 @@ function gen_datfile() {
cat jbuf.json | jq -r "${jqc}" > $filename
}

source ./jitter.sh
init_jitter $netif

strm="audio"
for jmin in 0 10 20; do
for i in 0 1; do
if [ "$i" == "0" ]; then
strm="audio"
else
strm="video"
fi

echo "########### jitter buffer $strm $jmin ###############"

sed -e "s/${strm}_jitter_buffer_delay\s*[0-9]*\-.*/${strm}_jitter_buffer_delay ${jmin}-500/" -i ${strm}/config
baresip -v -f ${strm} > /tmp/${strm}.log 2>&1 &
sleep 1
echo "/dial $target" | nc -N localhost 5555

sleep 3

enable_jitter

sleep 5

disable_jitter

sleep 25

echo "/quit" | nc -N localhost 5555

sleep 1

gen_datfile "P" jbuf.dat
gen_datfile "O" overrun.dat
gen_datfile "U" underflow.dat
gen_datfile "L" toolate.dat
gen_datfile "D" duplicate.dat
gen_datfile "S" oosequence.dat
gen_datfile "T" lost.dat

./jbuf.plot
if [ ! -d plots ]; then
mkdir plots
fi
if [ -f jbuf.eps ]; then
mv jbuf.eps plots/jbuf_${strm}_${jmin}.eps
fi
if [ -f jbuf.png ]; then
mv jbuf.png plots/jbuf_${strm}_${jmin}.png
fi
done
gen_datfile "P" jbuf.dat
gen_datfile "O" overrun.dat
gen_datfile "U" underflow.dat
gen_datfile "L" toolate.dat
gen_datfile "D" duplicate.dat
gen_datfile "S" oosequence.dat
gen_datfile "T" lost.dat

if [ $once == "true" ]; then
exit 0
fi
done
./jbuf.plot
79 changes: 79 additions & 0 deletions tools/jbuf/plot_loop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

if [ ! -f .env ]; then
echo ".env is missing. Copy and edit env-template!"
exit 1
fi

export `cat .env`

echo "target: $target"
echo "netif: $netif"
echo "once: $once"

if ! which jq; then
echo "Install jq"
exit 1
fi

trap "./jitter-off.sh; killall -q baresip" EXIT

function gen_datfile() {
ph=$1
filename=$2

jqc='.traceEvents[] | select (.ph == "'"${ph}"'") | .args.line'
cat jbuf.json | jq -r "${jqc}" > $filename
}

source ./jitter.sh
init_jitter $netif

strm="audio"
for jmin in 0 10 20; do
for i in 0 1; do
if [ "$i" == "0" ]; then
strm="audio"
else
strm="video"
fi

echo "########### jitter buffer $strm $jmin ###############"

sed -e "s/${strm}_jitter_buffer_delay\s*[0-9]*\-.*/${strm}_jitter_buffer_delay ${jmin}-500/" -i ${strm}/config
baresip -v -f ${strm} > /tmp/${strm}.log 2>&1 &
sleep 1
echo "/dial $target" | nc -N localhost 5555

sleep 3

enable_jitter

sleep 5

disable_jitter

sleep 25

echo "/quit" | nc -N localhost 5555

sleep 1

./generate_plot.sh \
|| { exit 1; }

if [ ! -d plots ]; then
mkdir plots
fi
if [ -f jbuf.eps ]; then
mv jbuf.eps plots/jbuf_${strm}_${jmin}.eps
fi
if [ -f jbuf.png ]; then
mv jbuf.png plots/jbuf_${strm}_${jmin}.png
fi
done

if [ $once == "true" ]; then
exit 0
fi
done

0 comments on commit d163bb5

Please sign in to comment.