feat: Add Echo web API and integrate NDI monitoring
This commit is contained in:
parent
3f6d52f3bd
commit
f6be41cb9e
7 changed files with 157 additions and 135 deletions
|
@ -1,60 +0,0 @@
|
|||
package ndi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/bitfocus/gondi"
|
||||
"os"
|
||||
)
|
||||
|
||||
var NDI_LIB_PATH = ""
|
||||
|
||||
func discovery() {
|
||||
var (
|
||||
libndi = ""
|
||||
libndiEnv = os.Getenv("LIBNDI")
|
||||
)
|
||||
if libndiEnv != "" {
|
||||
libndi = libndiEnv
|
||||
} else if NDI_LIB_PATH != "" {
|
||||
libndi = fmt.Sprintf("%s/lib/libndi.so", NDI_LIB_PATH)
|
||||
} else {
|
||||
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())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue