galene-stream: init at 0.2.0 (#405556)

authored by Cosima Neidahl and committed by GitHub fc35b306 e6817f33

+217 -12
+1 -1
nixos/tests/all-tests.nix
··· 547 547 ft2-clone = runTest ./ft2-clone.nix; 548 548 legit = runTest ./legit.nix; 549 549 mimir = runTest ./mimir.nix; 550 - galene = discoverTests (import ./galene.nix); 550 + galene = discoverTests (import ./galene.nix { inherit runTest; }); 551 551 gancio = runTest ./gancio.nix; 552 552 garage_1 = import ./garage { 553 553 inherit runTest;
+135 -11
nixos/tests/galene.nix
··· 1 + { runTest }: 2 + 1 3 let 2 - makeTest = import ./make-test-python.nix; 3 4 galeneTestGroupsDir = "/var/lib/galene/groups"; 4 5 galeneTestGroupFile = "galene-test-config.json"; 5 6 galenePort = 8443; ··· 7 8 galeneTestGroupAdminPassword = "1234"; 8 9 in 9 10 { 10 - basic = makeTest ( 11 + basic = runTest ( 11 12 { pkgs, lib, ... }: 12 13 { 13 14 name = "galene-works"; ··· 56 57 with subtest("galene starts"): 57 58 # Starts? 58 59 machine.wait_for_unit("galene") 59 - 60 - # Keeps running after startup? 61 - machine.sleep(10) 62 - machine.wait_for_unit("galene") 60 + machine.wait_for_open_port(${builtins.toString galenePort}) 63 61 64 62 # Reponds fine? 65 63 machine.succeed("curl -s -D - -o /dev/null 'http://localhost:${builtins.toString galenePort}' >&2") ··· 93 91 } 94 92 ); 95 93 96 - file-transfer = makeTest ( 94 + file-transfer = runTest ( 97 95 { pkgs, lib, ... }: 98 96 { 99 97 name = "galene-file-transfer-works"; ··· 143 141 with subtest("galene starts"): 144 142 # Starts? 145 143 machine.wait_for_unit("galene") 146 - 147 - # Keeps running after startup? 148 - machine.sleep(10) 149 - machine.wait_for_unit("galene") 144 + machine.wait_for_open_port(${builtins.toString galenePort}) 150 145 151 146 # Reponds fine? 152 147 machine.succeed("curl -s -D - -o /dev/null 'http://localhost:${builtins.toString galenePort}' >&2") ··· 205 200 + "${galeneTestGroupsDir}/test.json " # original 206 201 + "/root/Downloads/test.json" # Received via file-transfer 207 202 ) 203 + ''; 204 + } 205 + ); 206 + 207 + stream = runTest ( 208 + { pkgs, lib, ... }: 209 + let 210 + galeneTestGroupBotName = "bot"; 211 + galeneTestGroupBotPassword = "1234"; 212 + galeneStreamSrtPort = 9710; 213 + galeneStreamFeedImage = "galene-stream-feed.png"; 214 + galeneStreamFeedLabel = "Example"; 215 + in 216 + { 217 + name = "galene-stream-works"; 218 + meta = { 219 + # inherit (pkgs.galene-stream.meta) teams; 220 + inherit (pkgs.galene.meta) maintainers; 221 + platforms = lib.platforms.linux; 222 + }; 223 + 224 + nodes.machine = 225 + { config, pkgs, ... }: 226 + { 227 + imports = [ ./common/x11.nix ]; 228 + 229 + services.xserver.enable = true; 230 + 231 + environment = { 232 + # https://galene.org/INSTALL.html 233 + etc = { 234 + ${galeneTestGroupFile}.source = (pkgs.formats.json { }).generate galeneTestGroupFile { 235 + presenter = [ 236 + { 237 + username = galeneTestGroupBotName; 238 + password = galeneTestGroupBotPassword; 239 + } 240 + ]; 241 + other = [ { } ]; 242 + }; 243 + 244 + ${galeneStreamFeedImage}.source = 245 + pkgs.runCommand galeneStreamFeedImage 246 + { 247 + nativeBuildInputs = with pkgs; [ 248 + (imagemagick.override { ghostscriptSupport = true; }) # Add text to image 249 + ]; 250 + } 251 + '' 252 + magick -size 400x400 -background white -fill black canvas:white -pointsize 70 -annotate +100+200 '${galeneStreamFeedLabel}' $out 253 + ''; 254 + }; 255 + 256 + systemPackages = with pkgs; [ 257 + ffmpeg 258 + firefox 259 + galene-stream 260 + ]; 261 + }; 262 + 263 + services.galene = { 264 + enable = true; 265 + insecure = true; 266 + httpPort = galenePort; 267 + groupsDir = galeneTestGroupsDir; 268 + }; 269 + }; 270 + 271 + enableOCR = true; 272 + 273 + testScript = '' 274 + machine.wait_for_x() 275 + 276 + with subtest("galene starts"): 277 + # Starts? 278 + machine.wait_for_unit("galene") 279 + machine.wait_for_open_port(${builtins.toString galenePort}) 280 + 281 + # Reponds fine? 282 + machine.succeed("curl -s -D - -o /dev/null 'http://localhost:${builtins.toString galenePort}' >&2") 283 + 284 + machine.succeed("cp -v /etc/${galeneTestGroupFile} ${galeneTestGroupsDir}/test.json >&2") 285 + machine.wait_until_succeeds("curl -s -D - -o /dev/null 'http://localhost:${builtins.toString galenePort}/group/test/' >&2") 286 + 287 + with subtest("galene-stream works"): 288 + # Start interface for stream data 289 + machine.succeed( 290 + "galene-stream " 291 + + "--input 'srt://localhost:${builtins.toString galeneStreamSrtPort}?mode=listener' " 292 + + "--insecure --output 'http://localhost:${builtins.toString galenePort}/group/test/' " 293 + + "--username ${galeneTestGroupBotName} --password ${galeneTestGroupBotPassword} " 294 + + ">&2 &" 295 + ) 296 + machine.wait_for_console_text("Waiting for incoming stream...") 297 + 298 + # Start streaming 299 + machine.succeed( 300 + "ffmpeg " 301 + + "-f lavfi -i anullsrc=channel_layout=stereo:sample_rate=48000 " # need an audio track 302 + + "-re -loop 1 -i /etc/${galeneStreamFeedImage} " # loop of feed image 303 + + "-map 0:a -map 1:v " # arrange the output stream to have silent audio & looped video 304 + + "-c:a mp2 " # stream audio codec 305 + + "-c:v libx264 -pix_fmt yuv420p " # stream video codec 306 + + "-f mpegts " # stream format 307 + + "'srt://localhost:${builtins.toString galeneStreamSrtPort}' " 308 + + ">/dev/null 2>&1 &" 309 + ) 310 + machine.wait_for_console_text("Setting remote session description") 311 + 312 + # Open site 313 + machine.succeed("firefox --new-window 'http://localhost:${builtins.toString galenePort}/group/test/' >&2 &") 314 + # Note: Firefox doesn't use a regular "-" in the window title, but "—" (Hex: 0xe2 0x80 0x94) 315 + machine.wait_for_window("Test — Mozilla Firefox") 316 + machine.send_key("ctrl-minus") 317 + machine.send_key("ctrl-minus") 318 + machine.send_key("alt-f10") 319 + machine.wait_for_text(r"(Galène|Username|Password|Connect)") 320 + machine.screenshot("galene-group-test-join") 321 + 322 + # Log in as anon 323 + machine.send_key("ret") 324 + machine.sleep(5) 325 + # Close "Remember credentials?" FF prompt 326 + machine.send_key("esc") 327 + machine.sleep(5) 328 + 329 + # Look for stream 330 + machine.wait_for_text("${galeneStreamFeedLabel}") 331 + machine.screenshot("galene-stream-group-test-streams") 208 332 ''; 209 333 } 210 334 );
+81
pkgs/by-name/ga/galene-stream/package.nix
··· 1 + { 2 + lib, 3 + python3Packages, 4 + fetchFromGitHub, 5 + gitUpdater, 6 + nixosTests, 7 + galene, 8 + gobject-introspection, 9 + gst_all_1, 10 + libnice, 11 + wrapGAppsHook3, 12 + }: 13 + 14 + python3Packages.buildPythonApplication rec { 15 + pname = "galene-stream"; 16 + version = "0.2.0"; 17 + pyproject = true; 18 + 19 + src = fetchFromGitHub { 20 + owner = "erdnaxe"; 21 + repo = "galene-stream"; 22 + tag = "${version}"; 23 + hash = "sha256-3TdU3vBVuFle+jon2oJLa/rTLIiwYkvzscTDbMEXD1Q="; 24 + }; 25 + 26 + # When insecure is enabled on both galene and galene-stream, passing the ssl_context with certificate checking disabled when trying to open a websocket connection to ws:// errors out, because no ssl_context is expected to be passed for an SSL-less websocket like that 27 + # When --insecure in galene-stream, don't pass ssl_context here 28 + # TODO: How does this interact with a galene with insecure disabled? Expecting endpoint there to be wss://. Might need more sophisticated patch. 29 + postPatch = '' 30 + substituteInPlace galene_stream/galene.py \ 31 + --replace-fail 'await websockets.connect(status["endpoint"], ssl=ssl_context)' 'await websockets.connect(status["endpoint"], ssl=None if self.insecure else ssl_context)' 32 + ''; 33 + 34 + strictDeps = true; 35 + 36 + nativeBuildInputs = [ 37 + gobject-introspection 38 + wrapGAppsHook3 39 + ]; 40 + 41 + build-system = with python3Packages; [ 42 + setuptools 43 + setuptools-scm 44 + ]; 45 + 46 + buildInputs = 47 + [ 48 + libnice # libgstnice.so 49 + ] 50 + ++ (with gst_all_1; [ 51 + gst-plugins-base 52 + gst-plugins-good 53 + gst-plugins-bad 54 + gst-plugins-ugly # libgstx264.so 55 + ]); 56 + 57 + dependencies = with python3Packages; [ 58 + pygobject3 59 + websockets 60 + ]; 61 + 62 + dontWrapGApps = true; 63 + 64 + preFixup = '' 65 + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") 66 + ''; 67 + 68 + passthru = { 69 + tests.vm = nixosTests.galene.stream; 70 + updateScript = gitUpdater { }; 71 + }; 72 + 73 + meta = { 74 + description = "Gateway to send UDP, RTMP, SRT or RIST streams to Galène videoconference server"; 75 + homepage = "https://github.com/erdnaxe/galene-stream"; 76 + changelog = "https://github.com/erdnaxe/galene-stream/releases/tag/${src.tag}"; 77 + license = lib.licenses.mit; 78 + platforms = lib.platforms.linux; 79 + inherit (galene.meta) maintainers; 80 + }; 81 + }