[GStreamer][LearnGst] setup.sh 脚本

在搭建gstreamer开发环境时,需要检查依赖库是否存在,插件搜索环境变量是否正确设置等等信息,这里规划做一个 setup.sh 脚本来进行这些检查,同时尽可能地做一些自动化配置。

bash 复制代码
#!/bin/bash -i

echo "1. checking dependencies.........................................."
ret1=`pkg-config --list-all|grep gstreamer-1.0|wc -l`
if [ $ret1 -eq 1 ]; then
    echo "[pass] gstreamer-1.0"
else
	echo "LACK OF gstreamer-1.0 , please instsall"
	exit 0
fi

ret2=`pkg-config --list-all|grep glog|wc -l`
if [ $ret2 -eq 1 ]; then
    echo "[pass] glog"
else
	echo "LACK OF glog , please instsall"
	exit 0
fi
echo "1. checking dependencies.......................................... Done"

echo ""

echo "2. checking environment variables.........................................."

#all pkg-config search dir
ret3=`pkg-config --variable pc_path pkg-config`
IFS=':'
read -r -a array <<< "$ret3"
#iterate all dirs for gstreamer-1.0.pc
for element in "${array[@]}"
do
  echo "$element"
  if [ -d "$element" ]; then
    reta=`ls "$element"|grep gstreamer-1.0.pc|wc -l`
    if [ $reta -eq 1 ]; then
      rets=`sed -n '/prefix/s/^.*=\(.*\)$/\1/p' "$element"/gstreamer-1.0.pc | grep -v "{"`
	  retss=`sed -n '/pluginsdir/s/^.*=\(.*\)$/\1/p' "$element"/gstreamer-1.0.pc`
	  retfinnal=${retss/"prefix"/$rets}
	  retfinnal1=`echo $retfinnal|sed 's/[{]//g;s/[$]//g;s/[}]//g'`
    fi
  fi
done

echo "default plugin dir is $retfinnal1"
echo "my plugin dir is $PWD/_OUTPUT/"
expectedpluginpath="$retfinnal1:$PWD/_OUTPUT/"
echo "expected is $expectedpluginpath"

#delete line contain GST_PLUGIN_PATH
sed -i "/GST_PLUGIN_PATH=/d" ~/.bashrc

#append new GST_PLUGIN_PATH to ~/.bashrc
echo "export GST_PLUGIN_PATH=$expectedpluginpath" >> ~/.bashrc
echo "[after modi] GST_PLUGIN_PATH -> $GST_PLUGIN_PATH"

echo "REMEMBER to do source ~/.bashrc !"
echo "REMEMBER to do source ~/.bashrc !"
echo "REMEMBER to do source ~/.bashrc !"
echo "REMEMBER to do source ~/.bashrc !"

echo "2. checking environment variables..................................... Done"

echo ""



exit 0
相关推荐
冰山一脚201318 天前
Gstreamer的webrtcbin插件
gstreamer
allnlei2 个月前
fixation - gst_base_src_fixate
gstreamer
选与握3 个月前
gstreamer系列 -- 获取媒体信息
媒体·gstreamer
micro99817 个月前
gstreamer udp rtp发送本地视频文件
gstreamer