Recently I am building the software for a DVR.
It will be installed on a x86 pc server with 2 or more PCIE x4 video encoder card plugged in.
We have 2 seperated proces, one has to get encoded video data from these encoder card, the other has to save these data to hard driver. Why we have 2 process? Some histroy problem.
So, what kind of IPC should we use? Socket, Pipe, or shared memory?
Currently we are using socket.
With pipes on linux, you could use the splice
functionality to get zero-copy moves of the data from one process to the other. For example, the sending process uses vmsplice()
with SPICE_F_GIFT
to gift the data into a pipe, then the receiving processes uses splice()
with SPLICE_F_MOVE
to move the data straight from the pipe into the disk file without touching it. Note that there are naturally some alignment and length restrictions around this.
Depending on how the driver for your encoder card works, potentially you could arrange things to get zero-copy all the way from the driver to the disk - the encoder card DMAs into memory and the disk DMAs it back out, without the CPU ever needing to look at it (in this case you would splice()
the data from the encoder card into the pipe, then splice()
it back out of the pipe to the disk file).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With