mirror of
https://github.com/bluenviron/mediamtx.git
synced 2025-12-20 02:00:05 -08:00
rpi camera: remove patchelf dependency (#2093)
This commit is contained in:
parent
59a5d40fda
commit
2e476cf4e0
5 changed files with 33 additions and 61 deletions
|
|
@ -454,7 +454,7 @@ If you want to run the standard (non-Docker) version of the server:
|
||||||
|
|
||||||
1. Make sure that the following packages are installed:
|
1. Make sure that the following packages are installed:
|
||||||
|
|
||||||
* `libcamera0` (at least version 0.0.2)
|
* `libcamera0` (≥ 0.0.5)
|
||||||
* `libfreetype6`
|
* `libfreetype6`
|
||||||
|
|
||||||
2. download the server executable. If you're using 64-bit version of the operative system, make sure to pick the `arm64` variant.
|
2. download the server executable. If you're using 64-bit version of the operative system, make sure to pick the `arm64` variant.
|
||||||
|
|
@ -1376,7 +1376,6 @@ The server can be compiled with native support for the Raspberry Pi Camera. Comp
|
||||||
* `libcamera-dev`
|
* `libcamera-dev`
|
||||||
* `libfreetype-dev`
|
* `libfreetype-dev`
|
||||||
* `xxd`
|
* `xxd`
|
||||||
* `patchelf`
|
|
||||||
|
|
||||||
Download the repository, open a terminal in it and run:
|
Download the repository, open a terminal in it and run:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ import (
|
||||||
"github.com/bluenviron/mediamtx/internal/externalcmd"
|
"github.com/bluenviron/mediamtx/internal/externalcmd"
|
||||||
"github.com/bluenviron/mediamtx/internal/logger"
|
"github.com/bluenviron/mediamtx/internal/logger"
|
||||||
"github.com/bluenviron/mediamtx/internal/rlimit"
|
"github.com/bluenviron/mediamtx/internal/rlimit"
|
||||||
"github.com/bluenviron/mediamtx/internal/rpicamera"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var version = "v0.0.0"
|
var version = "v0.0.0"
|
||||||
|
|
@ -671,10 +670,6 @@ func (p *Core) closeResources(newConf *conf.Conf, calledByAPI bool) {
|
||||||
p.externalCmdPool.Close()
|
p.externalCmdPool.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if newConf == nil {
|
|
||||||
rpicamera.Cleanup()
|
|
||||||
}
|
|
||||||
|
|
||||||
if closeLogger {
|
if closeLogger {
|
||||||
p.logger.Close()
|
p.logger.Close()
|
||||||
p.logger = nil
|
p.logger = nil
|
||||||
|
|
|
||||||
|
|
@ -47,5 +47,3 @@ text_font.h: text_font.ttf
|
||||||
|
|
||||||
exe: $(OBJS)
|
exe: $(OBJS)
|
||||||
$(CXX) $^ $(LDFLAGS) -o $@
|
$(CXX) $^ $(LDFLAGS) -o $@
|
||||||
patchelf --replace-needed $$(basename /usr/lib/*-linux-*/libcamera.so.0*) libcamera.so.x.x.x $@
|
|
||||||
patchelf --replace-needed $$(basename /usr/lib/*-linux-*/libcamera-base.so.0*) libcamera-base.so.x.x.x $@
|
|
||||||
|
|
|
||||||
|
|
@ -82,57 +82,35 @@ func check64bit(fpath string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupSymlink(name string) error {
|
|
||||||
lib, err := findLibrary(name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if runtime.GOARCH == "arm" {
|
|
||||||
err := check64bit(lib)
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
mutex sync.Mutex
|
mutex sync.Mutex
|
||||||
setupped bool
|
checked bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupLibcameraOnce() error {
|
func checkLibraries64Bit() error {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
|
|
||||||
if !setupped {
|
if checked {
|
||||||
err := setupSymlink("libcamera")
|
return nil
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = setupSymlink("libcamera-base")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
setupped = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, name := range []string{"libcamera", "libcamera-base"} {
|
||||||
|
lib, err := findLibrary(name)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = check64bit(lib)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checked = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup cleanups files created by the camera implementation.
|
|
||||||
func Cleanup() {
|
|
||||||
if setupped {
|
|
||||||
os.Remove("/dev/shm/libcamera-base.so.x.x.x")
|
|
||||||
os.Remove("/dev/shm/libcamera.so.x.x.x")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type RPICamera struct {
|
type RPICamera struct {
|
||||||
onData func(time.Duration, [][]byte)
|
onData func(time.Duration, [][]byte)
|
||||||
|
|
||||||
|
|
@ -148,15 +126,18 @@ func New(
|
||||||
params Params,
|
params Params,
|
||||||
onData func(time.Duration, [][]byte),
|
onData func(time.Duration, [][]byte),
|
||||||
) (*RPICamera, error) {
|
) (*RPICamera, error) {
|
||||||
err := setupLibcameraOnce()
|
if runtime.GOARCH == "arm" {
|
||||||
if err != nil {
|
err := checkLibraries64Bit()
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &RPICamera{
|
c := &RPICamera{
|
||||||
onData: onData,
|
onData: onData,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
c.pipeConf, err = newPipe()
|
c.pipeConf, err = newPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -169,7 +150,6 @@ func New(
|
||||||
}
|
}
|
||||||
|
|
||||||
env := []string{
|
env := []string{
|
||||||
"LD_LIBRARY_PATH=/dev/shm",
|
|
||||||
"PIPE_CONF_FD=" + strconv.FormatInt(int64(c.pipeConf.readFD), 10),
|
"PIPE_CONF_FD=" + strconv.FormatInt(int64(c.pipeConf.readFD), 10),
|
||||||
"PIPE_VIDEO_FD=" + strconv.FormatInt(int64(c.pipeVideo.writeFD), 10),
|
"PIPE_VIDEO_FD=" + strconv.FormatInt(int64(c.pipeVideo.writeFD), 10),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
define DOCKERFILE_BINARIES
|
define DOCKERFILE_BINARIES
|
||||||
FROM $(RPI32_IMAGE) AS rpicamera32
|
FROM $(RPI32_IMAGE) AS rpicamera32
|
||||||
RUN ["cross-build-start"]
|
RUN ["cross-build-start"]
|
||||||
RUN apt update && apt install -y --no-install-recommends g++ pkg-config make libcamera-dev libfreetype-dev xxd patchelf
|
RUN apt update && apt install -y --no-install-recommends g++ pkg-config make libcamera-dev libfreetype-dev xxd
|
||||||
WORKDIR /s/internal/rpicamera
|
WORKDIR /s/internal/rpicamera/exe
|
||||||
COPY internal/rpicamera .
|
COPY internal/rpicamera/exe .
|
||||||
RUN cd exe && make -j$$(nproc)
|
RUN make -j$$(nproc)
|
||||||
|
|
||||||
FROM $(RPI64_IMAGE) AS rpicamera64
|
FROM $(RPI64_IMAGE) AS rpicamera64
|
||||||
RUN ["cross-build-start"]
|
RUN ["cross-build-start"]
|
||||||
RUN apt update && apt install -y --no-install-recommends g++ pkg-config make libcamera-dev libfreetype-dev xxd patchelf
|
RUN apt update && apt install -y --no-install-recommends g++ pkg-config make libcamera-dev libfreetype-dev xxd
|
||||||
WORKDIR /s/internal/rpicamera
|
WORKDIR /s/internal/rpicamera/exe
|
||||||
COPY internal/rpicamera .
|
COPY internal/rpicamera/exe .
|
||||||
RUN cd exe && make -j$$(nproc)
|
RUN make -j$$(nproc)
|
||||||
|
|
||||||
FROM $(BASE_IMAGE) AS build-base
|
FROM $(BASE_IMAGE) AS build-base
|
||||||
RUN apk add --no-cache zip make git tar
|
RUN apk add --no-cache zip make git tar
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue