gi-gstaudio-1.0.17: GI/GstAudio/Functions.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.GstAudio.Functions
(
-- * Methods
-- ** audioChannelGetFallbackMask #method:audioChannelGetFallbackMask#
audioChannelGetFallbackMask ,
-- ** audioChannelPositionsFromMask #method:audioChannelPositionsFromMask#
audioChannelPositionsFromMask ,
-- ** audioChannelPositionsToMask #method:audioChannelPositionsToMask#
audioChannelPositionsToMask ,
-- ** audioChannelPositionsToString #method:audioChannelPositionsToString#
audioChannelPositionsToString ,
-- ** audioChannelPositionsToValidOrder #method:audioChannelPositionsToValidOrder#
audioChannelPositionsToValidOrder ,
-- ** audioCheckValidChannelPositions #method:audioCheckValidChannelPositions#
audioCheckValidChannelPositions ,
-- ** audioClippingMetaApiGetType #method:audioClippingMetaApiGetType#
audioClippingMetaApiGetType ,
-- ** audioDownmixMetaApiGetType #method:audioDownmixMetaApiGetType#
audioDownmixMetaApiGetType ,
-- ** audioFormatInfoGetType #method:audioFormatInfoGetType#
audioFormatInfoGetType ,
-- ** audioGetChannelReorderMap #method:audioGetChannelReorderMap#
audioGetChannelReorderMap ,
-- ** audioIec61937FrameSize #method:audioIec61937FrameSize#
audioIec61937FrameSize ,
-- ** audioIec61937Payload #method:audioIec61937Payload#
audioIec61937Payload ,
-- ** audioMetaApiGetType #method:audioMetaApiGetType#
audioMetaApiGetType ,
-- ** audioReorderChannels #method:audioReorderChannels#
audioReorderChannels ,
-- ** bufferAddAudioClippingMeta #method:bufferAddAudioClippingMeta#
bufferAddAudioClippingMeta ,
-- ** bufferAddAudioDownmixMeta #method:bufferAddAudioDownmixMeta#
bufferAddAudioDownmixMeta ,
-- ** bufferAddAudioMeta #method:bufferAddAudioMeta#
bufferAddAudioMeta ,
-- ** bufferGetAudioDownmixMetaForChannels #method:bufferGetAudioDownmixMetaForChannels#
bufferGetAudioDownmixMetaForChannels ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GI.Gst.Enums as Gst.Enums
import qualified GI.Gst.Structs.Buffer as Gst.Buffer
import {-# SOURCE #-} qualified GI.GstAudio.Enums as GstAudio.Enums
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioClippingMeta as GstAudio.AudioClippingMeta
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioDownmixMeta as GstAudio.AudioDownmixMeta
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioInfo as GstAudio.AudioInfo
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioMeta as GstAudio.AudioMeta
import {-# SOURCE #-} qualified GI.GstAudio.Structs.AudioRingBufferSpec as GstAudio.AudioRingBufferSpec
-- function gst_buffer_get_audio_downmix_meta_for_channels
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to_position", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel positions of\n the destination", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to_channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels of the destination", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "to_channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels of the destination", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioDownmixMeta"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_buffer_get_audio_downmix_meta_for_channels" gst_buffer_get_audio_downmix_meta_for_channels ::
Ptr Gst.Buffer.Buffer -> -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
Ptr CInt -> -- to_position : TCArray False (-1) 2 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- to_channels : TBasicType TInt
IO (Ptr GstAudio.AudioDownmixMeta.AudioDownmixMeta)
{- |
Find the 'GI.GstAudio.Structs.AudioDownmixMeta.AudioDownmixMeta' on /@buffer@/ for the given destination
channel positions.
-}
bufferGetAudioDownmixMetaForChannels ::
(B.CallStack.HasCallStack, MonadIO m) =>
Gst.Buffer.Buffer
{- ^ /@buffer@/: a 'GI.Gst.Structs.Buffer.Buffer' -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@toPosition@/: the channel positions of
the destination -}
-> m GstAudio.AudioDownmixMeta.AudioDownmixMeta
{- ^ __Returns:__ the 'GI.GstAudio.Structs.AudioDownmixMeta.AudioDownmixMeta' on /@buffer@/. -}
bufferGetAudioDownmixMetaForChannels buffer toPosition = liftIO $ do
let toChannels = fromIntegral $ length toPosition
buffer' <- unsafeManagedPtrGetPtr buffer
let toPosition' = map (fromIntegral . fromEnum) toPosition
toPosition'' <- packStorableArray toPosition'
result <- gst_buffer_get_audio_downmix_meta_for_channels buffer' toPosition'' toChannels
checkUnexpectedReturnNULL "bufferGetAudioDownmixMetaForChannels" result
result' <- (newPtr GstAudio.AudioDownmixMeta.AudioDownmixMeta) result
touchManagedPtr buffer
freeMem toPosition''
return result'
-- function gst_buffer_add_audio_meta
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "GstAudio", name = "AudioInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the audio properties of the buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "samples", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of valid samples in the buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "offsets", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the offsets (in bytes) where each channel plane starts\n in the buffer or %NULL to calculate it (see below); must be %NULL also\n when @info->layout is %GST_AUDIO_LAYOUT_INTERLEAVED", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioMeta"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_buffer_add_audio_meta" gst_buffer_add_audio_meta ::
Ptr Gst.Buffer.Buffer -> -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
Ptr GstAudio.AudioInfo.AudioInfo -> -- info : TInterface (Name {namespace = "GstAudio", name = "AudioInfo"})
Word64 -> -- samples : TBasicType TUInt64
Word64 -> -- offsets : TBasicType TUInt64
IO (Ptr GstAudio.AudioMeta.AudioMeta)
{- |
Allocates and attaches a 'GI.GstAudio.Structs.AudioMeta.AudioMeta' on /@buffer@/, which must be writable
for that purpose. The fields of the 'GI.GstAudio.Structs.AudioMeta.AudioMeta' are directly populated
from the arguments of this function.
When /@info@/->layout is 'GI.GstAudio.Enums.AudioLayoutNonInterleaved' and /@offsets@/ is
'Nothing', the offsets are calculated with a formula that assumes the planes are
tightly packed and in sequence:
offsets[channel] = channel * /@samples@/ * sample_stride
It is not allowed for channels to overlap in memory,
i.e. for each i in [0, channels), the range
[/@offsets@/[i], /@offsets@/[i] + /@samples@/ * sample_stride) must not overlap
with any other such range. This function will assert if the parameters
specified cause this restriction to be violated.
It is, obviously, also not allowed to specify parameters that would cause
out-of-bounds memory access on /@buffer@/. This is also checked, which means
that you must add enough memory on the /@buffer@/ before adding this meta.
/Since: 1.16/
-}
bufferAddAudioMeta ::
(B.CallStack.HasCallStack, MonadIO m) =>
Gst.Buffer.Buffer
{- ^ /@buffer@/: a 'GI.Gst.Structs.Buffer.Buffer' -}
-> GstAudio.AudioInfo.AudioInfo
{- ^ /@info@/: the audio properties of the buffer -}
-> Word64
{- ^ /@samples@/: the number of valid samples in the buffer -}
-> Word64
{- ^ /@offsets@/: the offsets (in bytes) where each channel plane starts
in the buffer or 'Nothing' to calculate it (see below); must be 'Nothing' also
when /@info@/->layout is 'GI.GstAudio.Enums.AudioLayoutInterleaved' -}
-> m GstAudio.AudioMeta.AudioMeta
{- ^ __Returns:__ the 'GI.GstAudio.Structs.AudioMeta.AudioMeta' that was attached on the /@buffer@/ -}
bufferAddAudioMeta buffer info samples offsets = liftIO $ do
buffer' <- unsafeManagedPtrGetPtr buffer
info' <- unsafeManagedPtrGetPtr info
result <- gst_buffer_add_audio_meta buffer' info' samples offsets
checkUnexpectedReturnNULL "bufferAddAudioMeta" result
result' <- (newPtr GstAudio.AudioMeta.AudioMeta) result
touchManagedPtr buffer
touchManagedPtr info
return result'
-- function gst_buffer_add_audio_downmix_meta
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_position", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel positions\n of the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels of the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to_position", argType = TCArray False (-1) 4 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the channel positions of\n the destination", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to_channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels of the destination", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "matrix", argType = TBasicType TFloat, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The matrix coefficients.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "to_channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels of the destination", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from_channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels of the source", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioDownmixMeta"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_buffer_add_audio_downmix_meta" gst_buffer_add_audio_downmix_meta ::
Ptr Gst.Buffer.Buffer -> -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
Ptr CInt -> -- from_position : TCArray False (-1) 2 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- from_channels : TBasicType TInt
Ptr CInt -> -- to_position : TCArray False (-1) 4 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- to_channels : TBasicType TInt
CFloat -> -- matrix : TBasicType TFloat
IO (Ptr GstAudio.AudioDownmixMeta.AudioDownmixMeta)
{- |
Attaches 'GI.GstAudio.Structs.AudioDownmixMeta.AudioDownmixMeta' metadata to /@buffer@/ with the given parameters.
/@matrix@/ is an two-dimensional array of /@toChannels@/ times /@fromChannels@/
coefficients, i.e. the i-th output channels is constructed by multiplicating
the input channels with the coefficients in /@matrix@/[i] and taking the sum
of the results.
-}
bufferAddAudioDownmixMeta ::
(B.CallStack.HasCallStack, MonadIO m) =>
Gst.Buffer.Buffer
{- ^ /@buffer@/: a 'GI.Gst.Structs.Buffer.Buffer' -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@fromPosition@/: the channel positions
of the source -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@toPosition@/: the channel positions of
the destination -}
-> Float
{- ^ /@matrix@/: The matrix coefficients. -}
-> m GstAudio.AudioDownmixMeta.AudioDownmixMeta
{- ^ __Returns:__ the 'GI.GstAudio.Structs.AudioDownmixMeta.AudioDownmixMeta' on /@buffer@/. -}
bufferAddAudioDownmixMeta buffer fromPosition toPosition matrix = liftIO $ do
let toChannels = fromIntegral $ length toPosition
let fromChannels = fromIntegral $ length fromPosition
buffer' <- unsafeManagedPtrGetPtr buffer
let fromPosition' = map (fromIntegral . fromEnum) fromPosition
fromPosition'' <- packStorableArray fromPosition'
let toPosition' = map (fromIntegral . fromEnum) toPosition
toPosition'' <- packStorableArray toPosition'
let matrix' = realToFrac matrix
result <- gst_buffer_add_audio_downmix_meta buffer' fromPosition'' fromChannels toPosition'' toChannels matrix'
checkUnexpectedReturnNULL "bufferAddAudioDownmixMeta" result
result' <- (newPtr GstAudio.AudioDownmixMeta.AudioDownmixMeta) result
touchManagedPtr buffer
freeMem fromPosition''
freeMem toPosition''
return result'
-- function gst_buffer_add_audio_clipping_meta
-- Args : [Arg {argCName = "buffer", argType = TInterface (Name {namespace = "Gst", name = "Buffer"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GstBuffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "Gst", name = "Format"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "GstFormat of @start and @stop, GST_FORMAT_DEFAULT is samples", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "start", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Amount of audio to clip from start of buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "end", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Amount of to clip from end of buffer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstAudio", name = "AudioClippingMeta"}))
-- throws : False
-- Skip return : False
foreign import ccall "gst_buffer_add_audio_clipping_meta" gst_buffer_add_audio_clipping_meta ::
Ptr Gst.Buffer.Buffer -> -- buffer : TInterface (Name {namespace = "Gst", name = "Buffer"})
CUInt -> -- format : TInterface (Name {namespace = "Gst", name = "Format"})
Word64 -> -- start : TBasicType TUInt64
Word64 -> -- end : TBasicType TUInt64
IO (Ptr GstAudio.AudioClippingMeta.AudioClippingMeta)
{- |
Attaches 'GI.GstAudio.Structs.AudioClippingMeta.AudioClippingMeta' metadata to /@buffer@/ with the given parameters.
/Since: 1.8/
-}
bufferAddAudioClippingMeta ::
(B.CallStack.HasCallStack, MonadIO m) =>
Gst.Buffer.Buffer
{- ^ /@buffer@/: a 'GI.Gst.Structs.Buffer.Buffer' -}
-> Gst.Enums.Format
{- ^ /@format@/: GstFormat of /@start@/ and /@stop@/, GST_FORMAT_DEFAULT is samples -}
-> Word64
{- ^ /@start@/: Amount of audio to clip from start of buffer -}
-> Word64
{- ^ /@end@/: Amount of to clip from end of buffer -}
-> m GstAudio.AudioClippingMeta.AudioClippingMeta
{- ^ __Returns:__ the 'GI.GstAudio.Structs.AudioClippingMeta.AudioClippingMeta' on /@buffer@/. -}
bufferAddAudioClippingMeta buffer format start end = liftIO $ do
buffer' <- unsafeManagedPtrGetPtr buffer
let format' = (fromIntegral . fromEnum) format
result <- gst_buffer_add_audio_clipping_meta buffer' format' start end
checkUnexpectedReturnNULL "bufferAddAudioClippingMeta" result
result' <- (newPtr GstAudio.AudioClippingMeta.AudioClippingMeta) result
touchManagedPtr buffer
return result'
-- function gst_audio_reorder_channels
-- Args : [Arg {argCName = "data", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The pointer to\n the memory.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The size of the memory.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "format", argType = TInterface (Name {namespace = "GstAudio", name = "AudioFormat"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The %GstAudioFormat of the buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from", argType = TCArray False (-1) 3 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The channel positions in the buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to", argType = TCArray False (-1) 3 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The channel positions to convert to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The size of the memory.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_reorder_channels" gst_audio_reorder_channels ::
Ptr Word8 -> -- data : TCArray False (-1) 1 (TBasicType TUInt8)
Word64 -> -- size : TBasicType TUInt64
CUInt -> -- format : TInterface (Name {namespace = "GstAudio", name = "AudioFormat"})
Int32 -> -- channels : TBasicType TInt
Ptr CInt -> -- from : TCArray False (-1) 3 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Ptr CInt -> -- to : TCArray False (-1) 3 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
IO CInt
{- |
Reorders /@data@/ from the channel positions /@from@/ to the channel
positions /@to@/. /@from@/ and /@to@/ must contain the same number of
positions and the same positions, only in a different order.
Note: this function assumes the audio data is in interleaved layout
-}
audioReorderChannels ::
(B.CallStack.HasCallStack, MonadIO m) =>
ByteString
{- ^ /@data@/: The pointer to
the memory. -}
-> GstAudio.Enums.AudioFormat
{- ^ /@format@/: The @/GstAudioFormat/@ of the buffer. -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@from@/: The channel positions in the buffer. -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@to@/: The channel positions to convert to. -}
-> m Bool
{- ^ __Returns:__ 'True' if the reordering was possible. -}
audioReorderChannels data_ format from to = liftIO $ do
let channels = fromIntegral $ length to
let from_expected_length_ = fromIntegral $ length from
when (from_expected_length_ /= channels) $
error "GstAudio.audioReorderChannels : length of 'from' does not agree with that of 'to'."
let size = fromIntegral $ B.length data_
data_' <- packByteString data_
let format' = (fromIntegral . fromEnum) format
let from' = map (fromIntegral . fromEnum) from
from'' <- packStorableArray from'
let to' = map (fromIntegral . fromEnum) to
to'' <- packStorableArray to'
result <- gst_audio_reorder_channels data_' size format' channels from'' to''
let result' = (/= 0) result
freeMem data_'
freeMem from''
freeMem to''
return result'
-- function gst_audio_meta_api_get_type
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TGType)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_meta_api_get_type" gst_audio_meta_api_get_type ::
IO CGType
{- |
/No description available in the introspection data./
-}
audioMetaApiGetType ::
(B.CallStack.HasCallStack, MonadIO m) =>
m GType
audioMetaApiGetType = liftIO $ do
result <- gst_audio_meta_api_get_type
let result' = GType result
return result'
-- function gst_audio_iec61937_payload
-- Args : [Arg {argCName = "src", argType = TCArray False (-1) 1 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a buffer containing the data to payload", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @src in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dst", argType = TCArray False (-1) 3 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the destination buffer to store the\n payloaded contents in. Should not overlap with @src", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "dst_n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @dst in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "spec", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the ringbufer spec for @src", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "endianness", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the expected byte order of the payloaded data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "dst_n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @dst in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "src_n", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "size of @src in bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_iec61937_payload" gst_audio_iec61937_payload ::
Ptr Word8 -> -- src : TCArray False (-1) 1 (TBasicType TUInt8)
Word32 -> -- src_n : TBasicType TUInt
Ptr Word8 -> -- dst : TCArray False (-1) 3 (TBasicType TUInt8)
Word32 -> -- dst_n : TBasicType TUInt
Ptr GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> -- spec : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"})
Int32 -> -- endianness : TBasicType TInt
IO CInt
{- |
Payloads /@src@/ in the form specified by IEC 61937 for the type from /@spec@/ and
stores the result in /@dst@/. /@src@/ must contain exactly one frame of data and
the frame is not checked for errors.
-}
audioIec61937Payload ::
(B.CallStack.HasCallStack, MonadIO m) =>
ByteString
{- ^ /@src@/: a buffer containing the data to payload -}
-> ByteString
{- ^ /@dst@/: the destination buffer to store the
payloaded contents in. Should not overlap with /@src@/ -}
-> GstAudio.AudioRingBufferSpec.AudioRingBufferSpec
{- ^ /@spec@/: the ringbufer spec for /@src@/ -}
-> Int32
{- ^ /@endianness@/: the expected byte order of the payloaded data -}
-> m Bool
{- ^ __Returns:__ transfer-full: 'True' if the payloading was successful, 'False'
otherwise. -}
audioIec61937Payload src dst spec endianness = liftIO $ do
let dstN = fromIntegral $ B.length dst
let srcN = fromIntegral $ B.length src
src' <- packByteString src
dst' <- packByteString dst
spec' <- unsafeManagedPtrGetPtr spec
result <- gst_audio_iec61937_payload src' srcN dst' dstN spec' endianness
let result' = (/= 0) result
touchManagedPtr spec
freeMem src'
freeMem dst'
return result'
-- function gst_audio_iec61937_frame_size
-- Args : [Arg {argCName = "spec", argType = TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the ringbufer spec", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_iec61937_frame_size" gst_audio_iec61937_frame_size ::
Ptr GstAudio.AudioRingBufferSpec.AudioRingBufferSpec -> -- spec : TInterface (Name {namespace = "GstAudio", name = "AudioRingBufferSpec"})
IO Word32
{- |
Calculated the size of the buffer expected by 'GI.GstAudio.Functions.audioIec61937Payload' for
payloading type from /@spec@/.
-}
audioIec61937FrameSize ::
(B.CallStack.HasCallStack, MonadIO m) =>
GstAudio.AudioRingBufferSpec.AudioRingBufferSpec
{- ^ /@spec@/: the ringbufer spec -}
-> m Word32
{- ^ __Returns:__ the size or 0 if the given /@type@/ is not supported or cannot be
payloaded. -}
audioIec61937FrameSize spec = liftIO $ do
spec' <- unsafeManagedPtrGetPtr spec
result <- gst_audio_iec61937_frame_size spec'
touchManagedPtr spec
return result
-- function gst_audio_get_channel_reorder_map
-- Args : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "from", argType = TCArray False (-1) 0 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The channel positions to reorder from.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "to", argType = TCArray False (-1) 0 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The channel positions to reorder to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "reorder_map", argType = TCArray False (-1) 0 (TBasicType TInt), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Pointer to the reorder map.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_get_channel_reorder_map" gst_audio_get_channel_reorder_map ::
Int32 -> -- channels : TBasicType TInt
Ptr CInt -> -- from : TCArray False (-1) 0 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Ptr CInt -> -- to : TCArray False (-1) 0 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Ptr Int32 -> -- reorder_map : TCArray False (-1) 0 (TBasicType TInt)
IO CInt
{- |
Returns a reorder map for /@from@/ to /@to@/ that can be used in
custom channel reordering code, e.g. to convert from or to the
GStreamer channel order. /@from@/ and /@to@/ must contain the same
number of positions and the same positions, only in a
different order.
The resulting /@reorderMap@/ can be used for reordering by assigning
channel i of the input to channel reorder_map[i] of the output.
-}
audioGetChannelReorderMap ::
(B.CallStack.HasCallStack, MonadIO m) =>
[GstAudio.Enums.AudioChannelPosition]
{- ^ /@from@/: The channel positions to reorder from. -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@to@/: The channel positions to reorder to. -}
-> [Int32]
{- ^ /@reorderMap@/: Pointer to the reorder map. -}
-> m Bool
{- ^ __Returns:__ 'True' if the channel positions are valid and reordering
is possible. -}
audioGetChannelReorderMap from to reorderMap = liftIO $ do
let channels = fromIntegral $ length reorderMap
let to_expected_length_ = fromIntegral $ length to
when (to_expected_length_ /= channels) $
error "GstAudio.audioGetChannelReorderMap : length of 'to' does not agree with that of 'reorderMap'."
let from_expected_length_ = fromIntegral $ length from
when (from_expected_length_ /= channels) $
error "GstAudio.audioGetChannelReorderMap : length of 'from' does not agree with that of 'to'."
let from' = map (fromIntegral . fromEnum) from
from'' <- packStorableArray from'
let to' = map (fromIntegral . fromEnum) to
to'' <- packStorableArray to'
reorderMap' <- packStorableArray reorderMap
result <- gst_audio_get_channel_reorder_map channels from'' to'' reorderMap'
let result' = (/= 0) result
freeMem from''
freeMem to''
freeMem reorderMap'
return result'
-- function gst_audio_format_info_get_type
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TGType)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_format_info_get_type" gst_audio_format_info_get_type ::
IO CGType
{- |
/No description available in the introspection data./
-}
audioFormatInfoGetType ::
(B.CallStack.HasCallStack, MonadIO m) =>
m GType
audioFormatInfoGetType = liftIO $ do
result <- gst_audio_format_info_get_type
let result' = GType result
return result'
-- function gst_audio_downmix_meta_api_get_type
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TGType)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_downmix_meta_api_get_type" gst_audio_downmix_meta_api_get_type ::
IO CGType
{- |
/No description available in the introspection data./
-}
audioDownmixMetaApiGetType ::
(B.CallStack.HasCallStack, MonadIO m) =>
m GType
audioDownmixMetaApiGetType = liftIO $ do
result <- gst_audio_downmix_meta_api_get_type
let result' = GType result
return result'
-- function gst_audio_clipping_meta_api_get_type
-- Args : []
-- Lengths : []
-- returnType : Just (TBasicType TGType)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_clipping_meta_api_get_type" gst_audio_clipping_meta_api_get_type ::
IO CGType
{- |
/No description available in the introspection data./
-}
audioClippingMetaApiGetType ::
(B.CallStack.HasCallStack, MonadIO m) =>
m GType
audioClippingMetaApiGetType = liftIO $ do
result <- gst_audio_clipping_meta_api_get_type
let result' = GType result
return result'
-- function gst_audio_check_valid_channel_positions
-- Args : [Arg {argCName = "position", argType = TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The %GstAudioChannelPositions\n to check.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "force_order", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Only consider the GStreamer channel order.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_check_valid_channel_positions" gst_audio_check_valid_channel_positions ::
Ptr CInt -> -- position : TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- channels : TBasicType TInt
CInt -> -- force_order : TBasicType TBoolean
IO CInt
{- |
Checks if /@position@/ contains valid channel positions for
/@channels@/ channels. If /@forceOrder@/ is 'True' it additionally
checks if the channels are in the order required by GStreamer.
-}
audioCheckValidChannelPositions ::
(B.CallStack.HasCallStack, MonadIO m) =>
[GstAudio.Enums.AudioChannelPosition]
{- ^ /@position@/: The @/GstAudioChannelPositions/@
to check. -}
-> Bool
{- ^ /@forceOrder@/: Only consider the GStreamer channel order. -}
-> m Bool
{- ^ __Returns:__ 'True' if the channel positions are valid. -}
audioCheckValidChannelPositions position forceOrder = liftIO $ do
let channels = fromIntegral $ length position
let position' = map (fromIntegral . fromEnum) position
position'' <- packStorableArray position'
let forceOrder' = (fromIntegral . fromEnum) forceOrder
result <- gst_audio_check_valid_channel_positions position'' channels forceOrder'
let result' = (/= 0) result
freeMem position''
return result'
-- function gst_audio_channel_positions_to_valid_order
-- Args : [Arg {argCName = "position", argType = TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The channel positions to\n reorder to.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_channel_positions_to_valid_order" gst_audio_channel_positions_to_valid_order ::
Ptr CInt -> -- position : TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- channels : TBasicType TInt
IO CInt
{- |
Reorders the channel positions in /@position@/ from any order to
the GStreamer channel order.
-}
audioChannelPositionsToValidOrder ::
(B.CallStack.HasCallStack, MonadIO m) =>
[GstAudio.Enums.AudioChannelPosition]
{- ^ /@position@/: The channel positions to
reorder to. -}
-> m Bool
{- ^ __Returns:__ 'True' if the channel positions are valid and reordering
was successful. -}
audioChannelPositionsToValidOrder position = liftIO $ do
let channels = fromIntegral $ length position
let position' = map (fromIntegral . fromEnum) position
position'' <- packStorableArray position'
result <- gst_audio_channel_positions_to_valid_order position'' channels
let result' = (/= 0) result
freeMem position''
return result'
-- function gst_audio_channel_positions_to_string
-- Args : [Arg {argCName = "position", argType = TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The %GstAudioChannelPositions\n to convert.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_channel_positions_to_string" gst_audio_channel_positions_to_string ::
Ptr CInt -> -- position : TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- channels : TBasicType TInt
IO CString
{- |
Converts /@position@/ to a human-readable string representation for
debugging purposes.
-}
audioChannelPositionsToString ::
(B.CallStack.HasCallStack, MonadIO m) =>
[GstAudio.Enums.AudioChannelPosition]
{- ^ /@position@/: The @/GstAudioChannelPositions/@
to convert. -}
-> m T.Text
{- ^ __Returns:__ a newly allocated string representing
/@position@/
Since 1.10 -}
audioChannelPositionsToString position = liftIO $ do
let channels = fromIntegral $ length position
let position' = map (fromIntegral . fromEnum) position
position'' <- packStorableArray position'
result <- gst_audio_channel_positions_to_string position'' channels
checkUnexpectedReturnNULL "audioChannelPositionsToString" result
result' <- cstringToText result
freeMem result
freeMem position''
return result'
-- function gst_audio_channel_positions_to_mask
-- Args : [Arg {argCName = "position", argType = TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The %GstAudioChannelPositions", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "force_order", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Only consider the GStreamer channel order.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channel_mask", argType = TBasicType TUInt64, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the output channel mask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_channel_positions_to_mask" gst_audio_channel_positions_to_mask ::
Ptr CInt -> -- position : TCArray False (-1) 1 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
Int32 -> -- channels : TBasicType TInt
CInt -> -- force_order : TBasicType TBoolean
Ptr Word64 -> -- channel_mask : TBasicType TUInt64
IO CInt
{- |
Convert the /@position@/ array of /@channels@/ channels to a bitmask.
If /@forceOrder@/ is 'True' it additionally checks if the channels are
in the order required by GStreamer.
-}
audioChannelPositionsToMask ::
(B.CallStack.HasCallStack, MonadIO m) =>
[GstAudio.Enums.AudioChannelPosition]
{- ^ /@position@/: The @/GstAudioChannelPositions/@ -}
-> Bool
{- ^ /@forceOrder@/: Only consider the GStreamer channel order. -}
-> m ((Bool, Word64))
{- ^ __Returns:__ 'True' if the channel positions are valid and could be converted. -}
audioChannelPositionsToMask position forceOrder = liftIO $ do
let channels = fromIntegral $ length position
let position' = map (fromIntegral . fromEnum) position
position'' <- packStorableArray position'
let forceOrder' = (fromIntegral . fromEnum) forceOrder
channelMask <- allocMem :: IO (Ptr Word64)
result <- gst_audio_channel_positions_to_mask position'' channels forceOrder' channelMask
let result' = (/= 0) result
channelMask' <- peek channelMask
freeMem position''
freeMem channelMask
return (result', channelMask')
-- function gst_audio_channel_positions_from_mask
-- Args : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "channel_mask", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The input channel_mask", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "position", argType = TCArray False (-1) 0 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The\n %GstAudioChannelPosition<!-- -->s", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_channel_positions_from_mask" gst_audio_channel_positions_from_mask ::
Int32 -> -- channels : TBasicType TInt
Word64 -> -- channel_mask : TBasicType TUInt64
Ptr CInt -> -- position : TCArray False (-1) 0 (TInterface (Name {namespace = "GstAudio", name = "AudioChannelPosition"}))
IO CInt
{- |
Convert the /@channels@/ present in /@channelMask@/ to a /@position@/ array
(which should have at least /@channels@/ entries ensured by caller).
If /@channelMask@/ is set to 0, it is considered as \'not present\' for purpose
of conversion.
A partially valid /@channelMask@/ with less bits set than the number
of channels is considered valid.
-}
audioChannelPositionsFromMask ::
(B.CallStack.HasCallStack, MonadIO m) =>
Word64
{- ^ /@channelMask@/: The input channel_mask -}
-> [GstAudio.Enums.AudioChannelPosition]
{- ^ /@position@/: The
@/GstAudioChannelPosition/@\<!-- -->s -}
-> m Bool
{- ^ __Returns:__ 'True' if channel and channel mask are valid and could be converted -}
audioChannelPositionsFromMask channelMask position = liftIO $ do
let channels = fromIntegral $ length position
let position' = map (fromIntegral . fromEnum) position
position'' <- packStorableArray position'
result <- gst_audio_channel_positions_from_mask channels channelMask position''
let result' = (/= 0) result
freeMem position''
return result'
-- function gst_audio_channel_get_fallback_mask
-- Args : [Arg {argCName = "channels", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of channels", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False
foreign import ccall "gst_audio_channel_get_fallback_mask" gst_audio_channel_get_fallback_mask ::
Int32 -> -- channels : TBasicType TInt
IO Word64
{- |
Get the fallback channel-mask for the given number of channels.
This function returns a reasonable fallback channel-mask and should be
called as a last resort when the specific channel map is unknown.
/Since: 1.8/
-}
audioChannelGetFallbackMask ::
(B.CallStack.HasCallStack, MonadIO m) =>
Int32
{- ^ /@channels@/: the number of channels -}
-> m Word64
{- ^ __Returns:__ a fallback channel-mask for /@channels@/ or 0 when there is no
mask and mono. -}
audioChannelGetFallbackMask channels = liftIO $ do
result <- gst_audio_channel_get_fallback_mask channels
return result