Commit 679e50be authored by Carlos Remuzzi's avatar Carlos Remuzzi
Browse files

habilitando conexion agnostica orientada a IP

parent 786b126b
#!/usr/bin/env bash #!/usr/bin/env bash
SIZE_STRING=$(xdpyinfo | awk '/dimensions/{print $2}') AP_ADDRESS=192.168.12.1
echo "detectando resolución $SIZE_STRING" # legacy, porque hemos empezado con la sala llamada libreCast-s1
# aqui se deberia detectar pantallas dobles o demasiado grandes
# para mostrar solo una porcion via cropping
SCREEN_WIDTH="$(cut -d'x' -f1 <<<"$SIZE_STRING")"
SCREEN_HEIGHT="$(cut -d'x' -f2 <<<"$SIZE_STRING")"
AP_NAME=libreCast-s1
if [ $# -eq 1 ];then if [ $# -eq 1 ];then
AP_NAME=$1 AP_ADDRESS=$1
fi
if [ $# -eq 2 ];then
AP_NAME=$2
fi fi
echo "connectando a $AP_NAME" invocar_nmcli() {
echo "conectando a $AP_NAME"
nmcli con up $AP_NAME
if [ $? -eq 1 ];then
exit 1
fi
}
if [ -z `pidof gst-launch-1.0` ];then main() {
if [ -z "$(pidof gst-launch-1.0)" ] ;then
pkill -15 gst-launch-1.0 pkill -15 gst-launch-1.0
if which nmcli >/dev/null 2>&1; then # AP_NAME es necesario solo si se quiere usar Network Manager
nmcli con up $AP_NAME # para la conexion automatica al AP wifi
if [ $? -eq 1 ];then if [ -n "$AP_NAME" ] ;then
exit 1 if [ which nmcli >/dev/null 2>&1 ] ; then
invocar_nmcli
else
echo "utilizando conexion manual"
fi
fi fi
else
echo "El sistema no cuenta con nmcli"
echo "Es necesario configurar la conexión a $AP_NAME manualmente"
fi
# a transmission is not running yet from this machine SIZE_STRING=$(xdpyinfo | awk '/dimensions/{print $2}')
curl --connect-timeout 3 -s -k -X GET https://192.168.12.1:5443/player/start | grep 'Player iniciado' SCREEN_WIDTH="$(cut -d'x' -f1 <<<"$SIZE_STRING")"
if [ $? -eq 0 ];then SCREEN_HEIGHT="$(cut -d'x' -f2 <<<"$SIZE_STRING")"
# por defecto no realizamos ningun recorte
CROP_STRING_X=""
CROP_STRING_Y=""
pacmd unload-module module-null-sink # en caso el ancho supere lo maximo consentido de 1920
pacmd load-module module-null-sink sink_name=libreCast if [ "$SCREEN_WIDTH" -gt 1920 ];then
pacmd update-sink-proplist libreCast device.description=libreCast echo "recortando el ancho de la pantalla ..."
pacmd set-default-sink libreCast SCREEN_WIDTH=1920
CROP_STRING_X="startx=0 endx=1919"
CROP_STRING_Y="starty=0 endy=$(( $SCREEN_HEIGHT-1 ))"
fi
# en caso el alto supere lo maximo consentido de 1080
if [ "$SCREEN_HEIGHT" -gt 1080 ];then
echo "recortando el alto de la pantalla..."
SCREEN_HEIGHT=1080
CROP_STRING_X="startx=0 endx=$(( $SCREEN_WIDTH-1 ))"
CROP_STRING_Y="starty=0 endy=1079"
fi
curl --connect-timeout 3 -s -k -X GET https://$AP_ADDRESS:5443/player/start | grep 'Player iniciado'
if [ $? -eq 0 ];then
pacmd unload-module module-null-sink
pacmd load-module module-null-sink sink_name=libreCast
pacmd update-sink-proplist libreCast device.description=libreCast
pacmd set-default-sink libreCast
gst-launch-1.0 ximagesrc use-damage=false $CROP_STRING_X $CROP_STRING_Y ! videoconvert ! videoscale ! video/x-raw,format=I420,width=$SCREEN_WIDTH,height=$SCREEN_HEIGHT,framerate=24/1,bitrate=6000 ! jpegenc quality=80 ! rtpjpegpay ! udpsink host=$AP_ADDRESS port=1234 sync=false &
gst-launch-1.0 -v pulsesrc device="libreCast.monitor" ! "audio/x-raw,rate=11500,channels=2,depth=16" ! udpsink host=$AP_ADDRESS port=5678 sync=false &
exit 0
else
# the player is already running or the player is not reachable
exit 1
fi
gst-launch-1.0 ximagesrc use-damage=false ! videoconvert ! videoscale ! video/x-raw,format=I420,width=$SCREEN_WIDTH,height=$SCREEN_HEIGHT,framerate=24/1,bitrate=6000 ! jpegenc quality=80 ! rtpjpegpay ! udpsink host=192.168.12.1 port=1234 sync=false &
gst-launch-1.0 -v pulsesrc device="libreCast.monitor" ! "audio/x-raw,rate=11500,channels=2,depth=16" ! udpsink host=192.168.12.1 port=5678 sync=false &
exit 0
else else
# the player is already running or the player is not reachable
exit 1
fi
else echo "stopping ..."
curl --connect-timeout 3 -s -k -X GET https://$AP_ADDRESS:5443/player/stop
pkill -15 gst-launch-1.0
pacmd unload-module module-null-sink
# a transmission is already running from this machine if [ -n "$AP_NAME" ] ;then
curl --connect-timeout 3 -s -k -X GET https://192.168.12.1:5443/player/stop if [ which nmcli >/dev/null 2>&1 ] ; then
pkill -15 gst-launch-1.0 nmcli con down $AP_NAME
pacmd unload-module module-null-sink else
echo "Por favor desconectarse de $AP_NAME"
fi
fi
if which nmcli >/dev/null 2>&1; then
nmcli con down $AP_NAME
fi fi
}
fi main
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment