quinn icon indicating copy to clipboard operation
quinn copied to clipboard

Create C/CPP bindings

Open VMatrix1900 opened this issue 6 years ago • 3 comments

Hi. Thanks for quinn. I want to call QUINN from C/CPP. How can I create a C/CPP bindings?

VMatrix1900 avatar Dec 20 '18 02:12 VMatrix1900

You can use Rust's FFI for that. Note that the high-level quinn crate relies on tokio, which will be difficult to interoperate with from C/C++. Binding quinn-proto and using it with an existing C/C++ event loop would make more sense, but is a complicated task in its own right. Additionally, quinn-proto's interface is currently extremely unstable. While this is an interesting use-case that we'd like to support someday, it would be difficult to accomplish at present.

Ralith avatar Dec 20 '18 02:12 Ralith

@Ralith Thanks for you reply. Actually I am trying to write an video streaming application. It pulls video stream from the camera and encodes it(this part is done in CPP) then it will send the encoded data to transport protocol(like QUINN). In this case, I can use the TOKIO event loop and pull encoding data from CPP library then send this data with QUINN. This would be easier compared to call QUINN from CPP, right?

VMatrix1900 avatar Dec 20 '18 03:12 VMatrix1900

So you have pulling video and encoding it in C++, and you want to use the transport code from Quinn in Rust. Now you have to write driver code that pushes the encoded video out over the transport. Clearly it's possible to write the driver in either C++ or Rust, but it's up to you which of those you'd prefer. You might consider which interface is more complex (the video encoding one or the network transport one) and use the language from that one, so you have less work to do in your bindings.

djc avatar Dec 20 '18 07:12 djc