initial commit

This commit is contained in:
Garionion 2025-04-07 15:40:14 +02:00
commit d672f04be2
Signed by: garionion
SSH key fingerprint: SHA256:6uQQGh4dHIdYnrR+qeLdgx5SDmbttGp2HusA73563QA
6 changed files with 185 additions and 0 deletions

61
flake.lock generated Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1743827369,
"narHash": "sha256-rpqepOZ8Eo1zg+KJeWoq1HAOgoMCDloqv5r2EAa9TSA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "42a1c966be226125b48c384171c44c651c236c22",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

35
flake.nix Normal file
View file

@ -0,0 +1,35 @@
{
description = "NDI Discovery Go program";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { system = system; config.allowUnfree = true; };
in {
devShell = pkgs.mkShell {
buildInputs = [
pkgs.go
pkgs.ndi
];
LIBNDI="${pkgs.ndi}/lib/libndi.so";
CFLAGS="-I${pkgs.ndi}/include";
LDFLAGS="-L${pkgs.ndi}/lib -lndi";
};
packages = {
ndi_discover = import ./package.nix { inherit pkgs; inherit self; };
};
defaultPackage = import ./package.nix { inherit pkgs; inherit self; };
apps = {
ndi_discover = {
type = "app";
program = "${self.packages.${system}.ndi_discover}/bin/ndi_discover";
};
};
});
}

7
go.mod Normal file
View file

@ -0,0 +1,7 @@
module git.entr0py.de/garionion/catie
go 1.24
require github.com/bitfocus/gondi v0.0.2
require github.com/ebitengine/purego v0.3.2 // indirect

4
go.sum Normal file
View file

@ -0,0 +1,4 @@
github.com/bitfocus/gondi v0.0.2 h1:Q/kscMhnp0iX+Vkz274vG1loBw2lKyq5yq4b1XjllTE=
github.com/bitfocus/gondi v0.0.2/go.mod h1:g/pdkw//j2qJD+l9Yv8xf3RtjnrwBrZQBmlYIJ8GXQs=
github.com/ebitengine/purego v0.3.2 h1:+pV+tskAkn/bxEcUzGtDfw2VAe3bRQ26kdzFjPPrCww=
github.com/ebitengine/purego v0.3.2/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=

52
main.go Normal file
View file

@ -0,0 +1,52 @@
package main
import (
"fmt"
"os"
"github.com/bitfocus/gondi"
)
func main() {
libndi := os.Getenv("LIBNDI")
if libndi == "" {
fmt.Println("LIBNDI environment variable is not set")
return
}
fmt.Println("Initializing NDI")
if err := gondi.InitLibrary(libndi); err != nil {
fmt.Println("Failed to initialize NDI library:", err)
return
}
version := gondi.GetVersion()
fmt.Printf("NDI version: %s\n", version)
findInstance, err := gondi.NewFindInstance(true, "", "")
if err != nil {
panic(err)
}
defer findInstance.Destroy()
// Wait for sources to appear
fmt.Println("Looking for sources...")
for {
more := findInstance.WaitForSources(5000)
if !more {
break
}
}
// Fetch the sources
sources := findInstance.GetCurrentSources()
if len(sources) == 0 {
fmt.Println("No sources found")
return
}
for _, source := range sources {
fmt.Printf("Found source: %q: %q\n", source.Name(), source.Address())
}
}

26
package.nix Normal file
View file

@ -0,0 +1,26 @@
{ pkgs ? import <nixpkgs> { }, self }:
with pkgs;
let
version = "0.0.1";
in
pkgs.buildGo124Module {
pname = "catie";
inherit version;
src = self;
buildInputs = [
ndi
];
buildFlags = [
"CGO_CFLAGS=-I${pkgs.ndi}/include"
"CGO_LDFLAGS=-L${pkgs.ndi}/lib -lndi"
];
tags = [ ];
#vendorHash = lib.fakeHash;
vendorHash = "sha256-d0dcW2uV+a2GLBcY3FgNXNeajiJjFLEyCgqwZsEpW60=";
proxyVendor = true;
}