Skip to content

Commit

Permalink
Adding new calls and examples for capture pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvivien committed Sep 18, 2022
1 parent 5326ab3 commit 00a4e67
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 707 deletions.
18 changes: 0 additions & 18 deletions device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ func Open(path string, options ...Option) (*Device, error) {
}

// ensures IOType is set, only MemMap supported now
//if reflect.ValueOf(dev.config.ioType).IsZero() {
dev.config.ioType = v4l2.IOTypeMMAP
//}

// reset crop, only if cropping supported
if cropcap, err := v4l2.GetCropCapability(dev.fd, dev.bufType); err == nil {
Expand Down Expand Up @@ -425,19 +423,3 @@ func (d *Device) startStreamLoop(ctx context.Context) error {

return nil
}

// prepareCaptureBuffer prepares a frame buffer for stream capture
func (d *Device) prepareCaptureBuffer(fd uintptr, ioType v4l2.IOType, bufType v4l2.BufType) (v4l2.Buffer, error) {
bufInfo, err := v4l2.DequeueBuffer(fd, ioType, bufType)
if err != nil {
return v4l2.Buffer{}, fmt.Errorf("capture buffer info: dequeue: %w", err)
}

// requeue/clear used buffer, prepare for next read
if _, err := v4l2.QueueBuffer(fd, ioType, bufType, bufInfo.Index); err != nil {
return v4l2.Buffer{}, fmt.Errorf("capture buffer info: queue: %w", err)
}

// return captured buffer info
return bufInfo, nil
}
30 changes: 30 additions & 0 deletions examples/ccapture/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# V4L2 video capture example in C

This an example in C showing a minimally required steps to capture video using V4L2. This is can be used to run tests on devices and compare results with the Go4VL code.

## Build and run
On a Linux machine, run the following:

```
gcc -o capture capture.c
```

Run the program using:

```
./capture
```

Or, run `--help` to see available flags:

```
./capture --help
```

## Debugging with `strace`

To view the ioctl calls made when running the capture program:

```
strace -o trace.log -e trace=ioctl ./capture
```
Loading

0 comments on commit 00a4e67

Please sign in to comment.