From c5bed3afa20587df88de9569d297290dedcdd870 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar Date: Sat, 7 Aug 2021 00:06:28 +0400 Subject: [PATCH] added possiblity to execute custom command when starting a screenshare --- Dockerfile | 6 ------ config/config.go | 2 ++ files/static/main.js | 9 ++++++--- main.go | 29 ++++++++++++++++++++++++++++- p2prc.sh | 2 +- package-lock.json | 3 +++ 6 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 package-lock.json diff --git a/Dockerfile b/Dockerfile index ce7afb6..d253d87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,10 +30,6 @@ run apt-get -q -y update; apt-get -q -y upgrade && \ apt-get -q -y install sudo openssh-server && \ mkdir /var/run/sshd -# Installing golang and git -run apt install golang && \ - apt install git - # Set root password run echo 'root:password' >> /root/passwdfile @@ -52,8 +48,6 @@ run chpasswd -c SHA512 < /root/passwdfile && \ # Port 22 is used for ssh expose 22 -expose - # Assign /data as static volume. volume ["/data"] diff --git a/config/config.go b/config/config.go index f41156b..96d6cb2 100644 --- a/config/config.go +++ b/config/config.go @@ -23,6 +23,7 @@ type Config struct { BarrierHostName string Rooms string IPAddress string + BinaryToExecute string } // Exists reports whether the named file or directory exists. @@ -61,6 +62,7 @@ func SetDefaults() error { defaults["BarrierHostName"] = name defaults["Rooms"] = defaultPath + "room.json" defaults["IPAddress"] = "0.0.0.0" + defaults["BinaryToExecute"] = "/home/akilan/.local/share/Steam/steamapps/common/X-Plane 11" //Paths to search for config file configPaths = append(configPaths, defaultPath) diff --git a/files/static/main.js b/files/static/main.js index 729acdc..d0d2054 100644 --- a/files/static/main.js +++ b/files/static/main.js @@ -13,13 +13,16 @@ const iceConfig = { const displayMediaOptions = { noConstraint: { - video: true, + video: { + height: 1080, + frameRate: 120, + }, audio: true, }, v720p30: { video: { - height: 720, - frameRate: 60, + height: 1080, + frameRate: 120, }, audio: true, }, diff --git a/main.go b/main.go index 8d1d312..f83ce00 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ func main() { roomInfo := flag.Bool("roomInfo", false, "Getting room id of headless server") killServer := flag.Bool("killServer", false, "Kills the laplace") killChromium := flag.Bool("killChromium", false, "Kills all chromuim") + BinaryToExcute := flag.String("BinaryToExecute","","Providing path (i.e Absolute path) of binary to execute") flag.Parse() @@ -64,11 +65,27 @@ func main() { Addr = Ip4or6(Addr) } + var TaskExecute string + + if *BinaryToExcute != "" { + TaskExecute = *BinaryToExcute + } else { + // Read binary from config file + TaskExecute = Config.BinaryToExecute + } + // Starting screen share headless cmd := exec.Command("chromium-browser" ,"--no-sandbox","--auto-select-desktop-capture-source=Entire screen","--url","https://" + Addr + ":8888/?mode=headless","--ignore-certificate-errors") - if err := cmd.Run(); err != nil { + if err := cmd.Start(); err != nil { log.Fatalln(err) } + + // Makes program sleep for 2 seconds to allow chromium browser to open + time.Sleep(3 * time.Second) + + // Task to be executed + RunTask(TaskExecute) + return } @@ -131,3 +148,13 @@ func Ip4or6(s string) string { return "[" + s + "]" } + +func RunTask(task string) error { + // Halts the process + cmd := exec.Command(task) + if err := cmd.Start(); err != nil { + return err + } + + return nil +} diff --git a/p2prc.sh b/p2prc.sh index 0080985..6d08d2d 100644 --- a/p2prc.sh +++ b/p2prc.sh @@ -16,7 +16,7 @@ apt install -y barrier # Installing chromium wget https://github.com/RobRich999/Chromium_Clang/releases/download/v94.0.4585.0-r904940-linux64-deb-avx/chromium-browser-unstable_94.0.4585.0-1_amd64.deb -apt install -y ./v94.0.4585.0-r904940-linux64-deb-avx/chromium-browser-unstable_94.0.4585.0-1_amd64.deb +apt install -y ./chromium-browser-unstable_94.0.4585.0-1_amd64.deb # clone remotegameplay distribution git clone https://github.com/Akilan1999/remotegameplay diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..48e341a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +}