librecast 1.87 KB
Newer Older
Carlos Remuzzi's avatar
Carlos Remuzzi committed
1
2
#!/usr/bin/env bash

3
4
SIZE_STRING=$(xdpyinfo | awk '/dimensions/{print $2}')
echo "detectando resolución $SIZE_STRING"
Carlos Remuzzi's avatar
Carlos Remuzzi committed
5
6
# aqui se deberia detectar pantallas dobles o demasiado grandes
# para mostrar solo una porcion via cropping
7
8
SCREEN_WIDTH="$(cut -d'x' -f1 <<<"$SIZE_STRING")"
SCREEN_HEIGHT="$(cut -d'x' -f2 <<<"$SIZE_STRING")"
9
10
11
12
13
14
15
AP_NAME=libreCast-s1

if [ $# -eq 1 ];then
  AP_NAME=$1
fi

echo "connectando a $AP_NAME"
16

Carlos Remuzzi's avatar
Carlos Remuzzi committed
17
18
if [ -z `pidof gst-launch-1.0` ];then

Carlos Remuzzi's avatar
Carlos Remuzzi committed
19
  pkill -15 gst-launch-1.0
Carlos Remuzzi's avatar
Carlos Remuzzi committed
20

21
22
23
24
25
  if which nmcli >/dev/null 2>&1; then
    nmcli con up $AP_NAME 
    if [ $? -eq 1 ];then
      exit 1
    fi
26
27
28
  else
    echo "El sistema no cuenta con nmcli"
    echo "Es necesario configurar la conexión a $AP_NAME manualmente"
29
  fi
Carlos Remuzzi's avatar
Carlos Remuzzi committed
30
31
32
33

  # a transmission is not running yet from this machine 
  curl --connect-timeout 3 -s -k -X GET https://192.168.12.1:5443/player/start | grep 'Player iniciado' 
  if [ $? -eq 0 ];then
34
35
36

    pacmd unload-module module-null-sink
    pacmd load-module module-null-sink sink_name=libreCast
37
    pacmd update-sink-proplist libreCast device.description=libreCast
38
    pacmd set-default-sink libreCast
39
40

    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 & 
41
    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 &
Carlos Remuzzi's avatar
Carlos Remuzzi committed
42
43
44
45
46
47
48
49
50
51
52
53
54
    exit 0
  else
    # the player is already running or the player is not reachable
    exit 1
  fi

else

  # a transmission is already running from this machine 
  curl --connect-timeout 3 -s -k -X GET https://192.168.12.1:5443/player/stop
  pkill -15 gst-launch-1.0
  pacmd unload-module module-null-sink

55
56
57
58
  if which nmcli >/dev/null 2>&1; then
    nmcli con down $AP_NAME 
  fi

Carlos Remuzzi's avatar
Carlos Remuzzi committed
59
60
fi