From a0f0f6985e67ddbce929bf3da6832c443db5293d Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Fri, 2 Jan 2026 00:48:59 +0000 Subject: Adds libcamera to WebRTC streaming service --- hsm-stream/Hsm/Stream/FFI.hsc | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 hsm-stream/Hsm/Stream/FFI.hsc (limited to 'hsm-stream/Hsm/Stream/FFI.hsc') diff --git a/hsm-stream/Hsm/Stream/FFI.hsc b/hsm-stream/Hsm/Stream/FFI.hsc new file mode 100644 index 0000000..3ef4f98 --- /dev/null +++ b/hsm-stream/Hsm/Stream/FFI.hsc @@ -0,0 +1,48 @@ +{-# LANGUAGE CApiFFI #-} + +module Hsm.Stream.FFI + ( GstElement + , gstInit + , gstDeinit + , gstParseLaunch + , gstStatePlaying + , gstStateNull + , gstElementSetState + , gstObjectUnref + ) +where + +import Foreign.C.String (CString) +import Foreign.C.Types (CChar, CInt) +import Foreign.Ptr (Ptr) + +data GstElement + +data GError + +newtype GStateChangeReturn + = GStateChangeReturn Int + +newtype GState + = GState Int + +foreign import capi safe "gst/gst.h gst_init" + gstInit :: Ptr CInt -> Ptr (Ptr (Ptr CChar)) -> IO () + +foreign import capi safe "gst/gst.h gst_deinit" + gstDeinit :: IO () + +foreign import capi safe "gst/gst.h gst_parse_launch" + gstParseLaunch :: CString -> Ptr GError -> IO (Ptr GstElement) + +foreign import capi safe "gst/gst.h value GST_STATE_PLAYING" + gstStatePlaying :: GState + +foreign import capi safe "gst/gst.h value GST_STATE_NULL" + gstStateNull :: GState + +foreign import capi safe "gst/gst.h gst_element_set_state" + gstElementSetState :: Ptr GstElement -> GState -> IO GStateChangeReturn + +foreign import capi safe "gst/gst.h gst_object_unref" + gstObjectUnref :: Ptr GstElement -> IO () -- cgit v1.2.1