52 lines
952 B
Go
52 lines
952 B
Go
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())
|
|
}
|
|
}
|