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

3
4
5
6
AP_NAME=libreCast-s1
SCREEN_WIDTH=1920
SCREEN_HEIGHT=1080

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

Carlos Remuzzi's avatar
Carlos Remuzzi committed
9
  pkill -15 gst-launch-1.0
Carlos Remuzzi's avatar
Carlos Remuzzi committed
10

11
12
13
14
15
16
17
  if which nmcli >/dev/null 2>&1; then
    nmcli con up $AP_NAME 
    if [ $? -eq 1 ];then
      exit 1
    fi

  fi
Carlos Remuzzi's avatar
Carlos Remuzzi committed
18
19
20
21

  # 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
22
23
24
25
26
27

    pacmd unload-module module-null-sink
    pacmd load-module module-null-sink sink_name=libreCast
    pacmd update-sink-proplist Pantalla device.description=libreCast

    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 & 
Carlos Remuzzi's avatar
Carlos Remuzzi committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    gst-launch-1.0 -v pulsesrc device="Pantalla.monitor"  ! "audio/x-raw,rate=11500,channels=2,depth=16" ! udpsink host=192.168.12.1 port=5678 sync=false &
    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

42
43
44
45
  if which nmcli >/dev/null 2>&1; then
    nmcli con down $AP_NAME 
  fi

Carlos Remuzzi's avatar
Carlos Remuzzi committed
46
47
fi