aboutsummaryrefslogtreecommitdiff
path: root/hsm-stream/Hsm/Stream/FFI.hsc
blob: 3ef4f989a98d2a89cb63a641925d53d1111c59ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 ()