Sunday, February 17, 2019

running fwht codecs from userspace

The fwht codec can also be executed from userspace.

steps:
1. Load the vivid driver:
It will create two files /dev/videoX, /dev/videoY.
We will use the file with lower index to generate a picture from the vivid webcam.
Listen to a local port with netcat and dump the input to a file:


$ nc -l 8888 > from-vivid-fwht-stream.brr


Then in another terminal run:
$ v4l2-ctl -d0 --stream-mmap   --stream-to-host 0.0.0.0:8888


So now a stream with a specific format is dumped into from-vivid-fwht-stream.brr
The stream is the vivid generated video compressed as a fwht format. The compression is done in userspace.
The codeflow is:
streaming_set_cap->do_handle_cap->write_buffer_to_file -> fwht_compress


Now to do the opposite:
In the opposite direction the v4l2-ctl command listens to a port and waits.
So the v4l2-ctl should be executed first:


$ v4l2-ctl -d1 --stream-out-mmap   --stream-from-host 0.0.0.0:8888
$ cat from-vivid-fwht-stream.brr | nc 0.0.0.0 8888

And the codeflow is:
streaming_set_out->do_handle_out->fill_buffer_from_file -> fwht_decompress


So what we see is that:
1. For capture device, the v4l2-ctl  can take the captured frames, compress them with the fwht format
in userspace and then send them to some <host:port> server.
In this case, the visible_width/height should be the one that the capture device output to userspace
which are the composing on the capture if supported.


2. For output device, the v4l2-ctl can serve as a server, it listen to some <host:port>.
When a client sets a connection, it then reads a compressed fwht stream from the client and
decompress it. The visible_width/height are then the crop values of the output buffer of the output
device.


In qvidcap  there is also an fwht_decompress call. This is a case where actually no video
device driver is at all used. All it does is listen to <host:port>, read the compressed frames from
a client, decompress them and show them. So in that case there is no crop/compose values involved.
So the visible_width/height is the same as the coded_width/height.


So,
terminal 1:
dafna@ubuntu:~/clean-v4l-utils$ ./utils/qvidcap/qvidcap --port=8888
terminal 2:
cat from-vivid-fwht-stream.brr2 | nc 0.0.0.0 8888

No comments:

Post a Comment