diff --git a/consts.go b/consts.go index 6f1cb7b..b61a406 100644 --- a/consts.go +++ b/consts.go @@ -13,17 +13,17 @@ const ( V4L2_MEMORY_MMAP = 1 - VIDIOC_DQBUF = 0xc0445611 - VIDIOC_QBUF = 0xc044560f - VIDIOC_QUERYBUF = 0xc0445609 - VIDIOC_QUERYCAP = 0x80685600 - VIDIOC_REQBUFS = 0xc0145608 - VIDIOC_G_EXT_CTRLS = 0xc0185647 - VIDIOC_S_EXT_CTRLS = 0xc0185648 - VIDIOC_S_FMT = 0xc0cc5605 - VIDIOC_STREAMON = 0x40045612 - VIDIOC_STREAMOFF = 0x40045613 - VIDIOC_S_CTRL = 0xc008561c + VIDIOC_DQBUF = 0xc0585611 + VIDIOC_QBUF = 0xc058560f + VIDIOC_QUERYBUF = 0xc0585609 + VIDIOC_QUERYCAP = 0x80685600 + VIDIOC_REQBUFS = 0xc0145608 + VIDIOC_G_EXT_CTRLS = 0xc0205647 + VIDIOC_S_EXT_CTRLS = 0xc0205648 + VIDIOC_S_FMT = 0xc0d05605 + VIDIOC_STREAMON = 0x40045612 + VIDIOC_STREAMOFF = 0x40045613 + VIDIOC_S_CTRL = 0xc008561c ) // Controls (from linux/v4l2-controls.h) diff --git a/device.go b/device.go index d6172eb..719d9b7 100644 --- a/device.go +++ b/device.go @@ -5,6 +5,7 @@ package v4l2 import ( "io" "syscall" + "unsafe" "golang.org/x/sys/unix" @@ -91,7 +92,6 @@ func (dev *Device) Start() error { if err := requestBuffers(dev.fd, len(dev.buffers)); nil != err { return err } - // For each buffer... for i := 0; i < len(dev.buffers); i++ { // Get length and offset of i-th buffer @@ -99,7 +99,6 @@ func (dev *Device) Start() error { if nil != err { return err } - // Memory map i-th buffer to user-space if dev.buffers[i], err = unix.Mmap( dev.fd, @@ -127,7 +126,6 @@ func (dev *Device) Start() error { } return } - // Write buffer to channel // Note: Zero-copy. Slice bounds are written, not contents. dev.C <- Buffer{ @@ -216,7 +214,6 @@ func queryBuffer(fd int, n uint32) (length, offset uint32, err error) { if err = ioctl(fd, VIDIOC_QUERYBUF, unsafe.Pointer(&qb)); err != nil { return } - length = qb.length offset = nativeEndian.Uint32(qb.m[0:4]) return diff --git a/structs.go b/structs.go index 5728731..5384ba4 100644 --- a/structs.go +++ b/structs.go @@ -5,7 +5,7 @@ package v4l2 import "unsafe" const ( - maxSizeBufferDotM = 4 + maxSizeBufferDotM = 8 maxSizeExtControlDotValue = 8 maxSizeFormatDotFmt = 200 sizePixFormat = 48 @@ -37,7 +37,7 @@ type v4l2_pix_format struct { } type v4l2_format struct { - typ uint32 + typ uint64 fmt [maxSizeFormatDotFmt]byte // union } @@ -47,10 +47,12 @@ type v4l2_control struct { } type v4l2_requestbuffers struct { - count uint32 - typ uint32 - memory uint32 - reserved [2]uint32 + count uint32 + typ uint32 + memory uint32 + capabilities uint32 + flags uint8 + reserved [3]uint8 } type v4l2_timecode struct { @@ -64,8 +66,8 @@ type v4l2_timecode struct { } type timeval struct { - tv_sec uint32 - tv_usec uint32 + tv_sec uint64 + tv_usec uint64 } type v4l2_buffer struct {