yesterday I decided to start playing with a capture card I have, but I faced a big problem: my PC is a laptop and the card is PCI bus. Since I don’t have PCI bus in my laptop, I couldn’t use it. The fastest solution was use my sister’s PC, which is a desktop one. This situation made me think about developing something to share the hardware through the network. For example: if NFS could export /dev directory, I would export it in my sister’s PC and mount it at /mnt/dev, and then access /mnt/dev/video0 in a native way. The problem is that video0 isn’t a normal file, it is a char device, and NFS does not support char device exports. If we think a little bit more, we will realize that the main problem consists on ioctl() function, which its use is very common on char devices. This function allows us communication with devices in a simple way by passing an ioctl type and some data or a pointer (most of times a pointer to structs) to the function. Each type of ioctl has different data types and sizes, so if we want to do it through the network, we need to map all the types and associate them to a fixed size (considering we cannot pass a raw pointer through the network). Anyway, it is possible to get the data size with _IOC_SIZE() function, for example:
int size = _IOC_SIZE(VIDIOC_G_MPEGCOMP);
where VIDIOC_G_MPEGCOMP is the ioctl type, and size will be the size of the data VIDIOC_G_MPEGCOMP requires.
I don’t know if I’ll have time and know-how to do the full development, so if you are able to do that and enjoy coding these crazy things, fell free to do it, and if I decide to start developing that I’ll post the progress here.
If you have more ideas or if I’m terrible wrong on my explanation, let me know.