golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.0 KiB
51 lines
1.0 KiB
//go:build rpicamera |
|
// +build rpicamera |
|
|
|
package rpicamera |
|
|
|
import ( |
|
"fmt" |
|
"os" |
|
"os/exec" |
|
"strings" |
|
) |
|
|
|
func findLibrary(name string) (string, error) { |
|
byts, err := exec.Command("ldconfig", "-p").Output() |
|
if err == nil { |
|
for _, line := range strings.Split(string(byts), "\n") { |
|
f := strings.Split(line, " => ") |
|
if len(f) == 2 && strings.Contains(f[1], name+".so") { |
|
return f[1], nil |
|
} |
|
} |
|
} |
|
|
|
return "", fmt.Errorf("library '%s' not found", name) |
|
} |
|
|
|
func setupSymlink(name string) error { |
|
lib, err := findLibrary(name) |
|
if err != nil { |
|
return err |
|
} |
|
|
|
os.Remove("/dev/shm/" + name + ".so.x.x.x") |
|
return os.Symlink(lib, "/dev/shm/"+name+".so.x.x.x") |
|
} |
|
|
|
// LibcameraSetup creates libcamera simlinks that are version agnostic. |
|
func LibcameraSetup() error { |
|
err := setupSymlink("libcamera") |
|
if err != nil { |
|
return err |
|
} |
|
|
|
return setupSymlink("libcamera-base") |
|
} |
|
|
|
// LibcameraCleanup removes files created by LibcameraSetup. |
|
func LibcameraCleanup() { |
|
os.Remove("/dev/shm/libcamera-base.so.x.x.x") |
|
os.Remove("/dev/shm/libcamera.so.x.x.x") |
|
}
|
|
|