{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

Variant of 'GI.GstPbutils.Objects.EncodingProfile.EncodingProfile' for audio streams.
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.GstPbutils.Objects.EncodingAudioProfile
    (

-- * Exported types
    EncodingAudioProfile(..)                ,
    IsEncodingAudioProfile                  ,
    toEncodingAudioProfile                  ,
    noEncodingAudioProfile                  ,


 -- * Methods
-- ** new #method:new#

    encodingAudioProfileNew                 ,




    ) 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.GObject.Objects.Object as GObject.Object
import qualified GI.Gst.Structs.Caps as Gst.Caps
import {-# SOURCE #-} qualified GI.GstPbutils.Objects.EncodingProfile as GstPbutils.EncodingProfile

-- | Memory-managed wrapper type.
newtype EncodingAudioProfile = EncodingAudioProfile (ManagedPtr EncodingAudioProfile)
foreign import ccall "gst_encoding_audio_profile_get_type"
    c_gst_encoding_audio_profile_get_type :: IO GType

instance GObject EncodingAudioProfile where
    gobjectType = c_gst_encoding_audio_profile_get_type


-- | Type class for types which can be safely cast to `EncodingAudioProfile`, for instance with `toEncodingAudioProfile`.
class (GObject o, O.IsDescendantOf EncodingAudioProfile o) => IsEncodingAudioProfile o
instance (GObject o, O.IsDescendantOf EncodingAudioProfile o) => IsEncodingAudioProfile o

instance O.HasParentTypes EncodingAudioProfile
type instance O.ParentTypes EncodingAudioProfile = '[GstPbutils.EncodingProfile.EncodingProfile, GObject.Object.Object]

-- | Cast to `EncodingAudioProfile`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toEncodingAudioProfile :: (MonadIO m, IsEncodingAudioProfile o) => o -> m EncodingAudioProfile
toEncodingAudioProfile = liftIO . unsafeCastTo EncodingAudioProfile

-- | A convenience alias for `Nothing` :: `Maybe` `EncodingAudioProfile`.
noEncodingAudioProfile :: Maybe EncodingAudioProfile
noEncodingAudioProfile = Nothing

#if ENABLE_OVERLOADING
type family ResolveEncodingAudioProfileMethod (t :: Symbol) (o :: *) :: * where
    ResolveEncodingAudioProfileMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveEncodingAudioProfileMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveEncodingAudioProfileMethod "copy" o = GstPbutils.EncodingProfile.EncodingProfileCopyMethodInfo
    ResolveEncodingAudioProfileMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveEncodingAudioProfileMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveEncodingAudioProfileMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveEncodingAudioProfileMethod "isEnabled" o = GstPbutils.EncodingProfile.EncodingProfileIsEnabledMethodInfo
    ResolveEncodingAudioProfileMethod "isEqual" o = GstPbutils.EncodingProfile.EncodingProfileIsEqualMethodInfo
    ResolveEncodingAudioProfileMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveEncodingAudioProfileMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveEncodingAudioProfileMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveEncodingAudioProfileMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveEncodingAudioProfileMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveEncodingAudioProfileMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveEncodingAudioProfileMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveEncodingAudioProfileMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveEncodingAudioProfileMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveEncodingAudioProfileMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveEncodingAudioProfileMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveEncodingAudioProfileMethod "getAllowDynamicOutput" o = GstPbutils.EncodingProfile.EncodingProfileGetAllowDynamicOutputMethodInfo
    ResolveEncodingAudioProfileMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveEncodingAudioProfileMethod "getDescription" o = GstPbutils.EncodingProfile.EncodingProfileGetDescriptionMethodInfo
    ResolveEncodingAudioProfileMethod "getFileExtension" o = GstPbutils.EncodingProfile.EncodingProfileGetFileExtensionMethodInfo
    ResolveEncodingAudioProfileMethod "getFormat" o = GstPbutils.EncodingProfile.EncodingProfileGetFormatMethodInfo
    ResolveEncodingAudioProfileMethod "getInputCaps" o = GstPbutils.EncodingProfile.EncodingProfileGetInputCapsMethodInfo
    ResolveEncodingAudioProfileMethod "getName" o = GstPbutils.EncodingProfile.EncodingProfileGetNameMethodInfo
    ResolveEncodingAudioProfileMethod "getPresence" o = GstPbutils.EncodingProfile.EncodingProfileGetPresenceMethodInfo
    ResolveEncodingAudioProfileMethod "getPreset" o = GstPbutils.EncodingProfile.EncodingProfileGetPresetMethodInfo
    ResolveEncodingAudioProfileMethod "getPresetName" o = GstPbutils.EncodingProfile.EncodingProfileGetPresetNameMethodInfo
    ResolveEncodingAudioProfileMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveEncodingAudioProfileMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveEncodingAudioProfileMethod "getRestriction" o = GstPbutils.EncodingProfile.EncodingProfileGetRestrictionMethodInfo
    ResolveEncodingAudioProfileMethod "getTypeNick" o = GstPbutils.EncodingProfile.EncodingProfileGetTypeNickMethodInfo
    ResolveEncodingAudioProfileMethod "setAllowDynamicOutput" o = GstPbutils.EncodingProfile.EncodingProfileSetAllowDynamicOutputMethodInfo
    ResolveEncodingAudioProfileMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveEncodingAudioProfileMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveEncodingAudioProfileMethod "setDescription" o = GstPbutils.EncodingProfile.EncodingProfileSetDescriptionMethodInfo
    ResolveEncodingAudioProfileMethod "setEnabled" o = GstPbutils.EncodingProfile.EncodingProfileSetEnabledMethodInfo
    ResolveEncodingAudioProfileMethod "setFormat" o = GstPbutils.EncodingProfile.EncodingProfileSetFormatMethodInfo
    ResolveEncodingAudioProfileMethod "setName" o = GstPbutils.EncodingProfile.EncodingProfileSetNameMethodInfo
    ResolveEncodingAudioProfileMethod "setPresence" o = GstPbutils.EncodingProfile.EncodingProfileSetPresenceMethodInfo
    ResolveEncodingAudioProfileMethod "setPreset" o = GstPbutils.EncodingProfile.EncodingProfileSetPresetMethodInfo
    ResolveEncodingAudioProfileMethod "setPresetName" o = GstPbutils.EncodingProfile.EncodingProfileSetPresetNameMethodInfo
    ResolveEncodingAudioProfileMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveEncodingAudioProfileMethod "setRestriction" o = GstPbutils.EncodingProfile.EncodingProfileSetRestrictionMethodInfo
    ResolveEncodingAudioProfileMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveEncodingAudioProfileMethod t EncodingAudioProfile, O.MethodInfo info EncodingAudioProfile p) => OL.IsLabel t (EncodingAudioProfile -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList EncodingAudioProfile
type instance O.AttributeList EncodingAudioProfile = EncodingAudioProfileAttributeList
type EncodingAudioProfileAttributeList = ('[ '("restrictionCaps", GstPbutils.EncodingProfile.EncodingProfileRestrictionCapsPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
#endif

#if ENABLE_OVERLOADING
type instance O.SignalList EncodingAudioProfile = EncodingAudioProfileSignalList
type EncodingAudioProfileSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method EncodingAudioProfile::new
-- method type : Constructor
-- Args : [Arg {argCName = "format", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #GstCaps", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "preset", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the preset(s) to use on the encoder, can be %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "restriction", argType = TInterface (Name {namespace = "Gst", name = "Caps"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the #GstCaps used to restrict the input to the encoder, can be\nNULL. See gst_encoding_profile_get_restriction() for more details.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "presence", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of time this stream must be used. 0 means any number of\n times (including never)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GstPbutils", name = "EncodingAudioProfile"}))
-- throws : False
-- Skip return : False

foreign import ccall "gst_encoding_audio_profile_new" gst_encoding_audio_profile_new ::
    Ptr Gst.Caps.Caps ->                    -- format : TInterface (Name {namespace = "Gst", name = "Caps"})
    CString ->                              -- preset : TBasicType TUTF8
    Ptr Gst.Caps.Caps ->                    -- restriction : TInterface (Name {namespace = "Gst", name = "Caps"})
    Word32 ->                               -- presence : TBasicType TUInt
    IO (Ptr EncodingAudioProfile)

{- |
Creates a new 'GI.GstPbutils.Objects.EncodingAudioProfile.EncodingAudioProfile'

All provided allocatable arguments will be internally copied, so can be
safely freed\/unreferenced after calling this method.
-}
encodingAudioProfileNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Gst.Caps.Caps
    {- ^ /@format@/: the 'GI.Gst.Structs.Caps.Caps' -}
    -> Maybe (T.Text)
    {- ^ /@preset@/: the preset(s) to use on the encoder, can be 'Nothing' -}
    -> Maybe (Gst.Caps.Caps)
    {- ^ /@restriction@/: the 'GI.Gst.Structs.Caps.Caps' used to restrict the input to the encoder, can be
NULL. See 'GI.GstPbutils.Objects.EncodingProfile.encodingProfileGetRestriction' for more details. -}
    -> Word32
    {- ^ /@presence@/: the number of time this stream must be used. 0 means any number of
 times (including never) -}
    -> m EncodingAudioProfile
    {- ^ __Returns:__ the newly created 'GI.GstPbutils.Objects.EncodingAudioProfile.EncodingAudioProfile'. -}
encodingAudioProfileNew format preset restriction presence = liftIO $ do
    format' <- unsafeManagedPtrGetPtr format
    maybePreset <- case preset of
        Nothing -> return nullPtr
        Just jPreset -> do
            jPreset' <- textToCString jPreset
            return jPreset'
    maybeRestriction <- case restriction of
        Nothing -> return nullPtr
        Just jRestriction -> do
            jRestriction' <- unsafeManagedPtrGetPtr jRestriction
            return jRestriction'
    result <- gst_encoding_audio_profile_new format' maybePreset maybeRestriction presence
    checkUnexpectedReturnNULL "encodingAudioProfileNew" result
    result' <- (wrapObject EncodingAudioProfile) result
    touchManagedPtr format
    whenJust restriction touchManagedPtr
    freeMem maybePreset
    return result'

#if ENABLE_OVERLOADING
#endif