From: Duncan C. <dun...@wo...> - 2007-08-26 23:29:24
|
Wed Jul 18 23:02:28 PDT 2007 Peter Gavin <pg...@gm...> * gstreamer: initial import adddir ./gstreamer adddir ./gstreamer/Media adddir ./gstreamer/Media/Streaming adddir ./gstreamer/Media/Streaming/GStreamer hunk ./Makefile.am 24 - gnomevfs/marshal.list + gnomevfs/marshal.list \ + gtk/Graphics/UI/Gtk/ModelView/Gtk2HsStore.h \ + gstreamer/hsgstreamer.h hunk ./Makefile.am 67 +if ENABLE_GSTREAMER +pkglib_LIBRARIES += libHSgstreamer.a +endif hunk ./Makefile.am 1831 +# +# gstreamer package +# +################################################################################ + +if ENABLE_GSTREAMER + +gstreamer_PKGNAME = libHSgstreamer_a + +libHSgstreamer_a_NAME = gstreamer +libHSgstreamer_a_CONFIG = gstreamer/gstreamer.$(PKGEXT) +libHSgstreamer_a_EXTERNALDEPS = base haskell98 mtl +libHSgstreamer_a_INTERNALDEPS = glib +libHSgstreamer_a_HEADER = gstreamer/hsgstreamer.h +libHSgstreamer_a_PRECOMP = gstreamer/gstreamer.precomp +libHSgstreamer_a_LIBS = $(GLIB_LIBS) $(GSTREAMER_LIBS) $(GCONF_LIBS) +libHSgstreamer_a_HCFLAGS = -fffi +libHSgstreamer_a_CFLAGS = $(filter-out -I% -D%,$(GLIB_CFLAGS) $(GSTREAMER_CFLAGS)) +libHSgstreamer_a_CPPFLAGS = $(filter -I% -D%,$(GLIB_CFLAGS) $(GSTREAMER_CFLAGS)) + +libHSgstreamer_a_SOURCESDIRS = gstreamer + +libHSgstreamer_a_LIBADD = + +gstreamer/libHSgstreamer_a.deps : glib/libHSglib_a.deps + +libHSgstreamer_a_GENERATEDSOURCES = \ + gstreamer/Media/Streaming/GStreamer/Hierarchy.chs \ + gstreamer/Media/Streaming/GStreamer/Signals.chs + +nodist_libHSgstreamer_a_SOURCES = $(libHSgstreamer_a_GENERATEDSOURCES) + +libHSgstreamer_a_SOURCES = \ + gstreamer/Media/Streaming/GStreamer/Types.chs \ + gstreamer/Media/Streaming/GStreamer/Init.chs \ + gstreamer/Media/Streaming/GStreamer/Object.chs \ + gstreamer/Media/Streaming/GStreamer/Element.chs \ + gstreamer/Media/Streaming/GStreamer/Pad.chs \ + gstreamer/Media/Streaming/GStreamer/GhostPad.chs \ + gstreamer/Media/Streaming/GStreamer/Bin.chs \ + gstreamer/Media/Streaming/GStreamer/Format.chs \ + gstreamer/Media/Streaming/GStreamer/ElementFactory.chs \ + gstreamer/Media/Streaming/GStreamer/Caps.chs \ + gstreamer/Media/Streaming/GStreamer/Structure.chs \ + gstreamer/Media/Streaming/GStreamer/Message.chs \ + gstreamer/Media/Streaming/GStreamer/Bus.chs \ + gstreamer/Media/Streaming/GStreamer/Clock.chs \ + gstreamer/Media/Streaming/GStreamer/PadTemplate.chs \ + gstreamer/Media/Streaming/GStreamer/ImplementsInterface.chs \ + gstreamer/Media/Streaming/GStreamer/Index.chs \ + gstreamer/Media/Streaming/GStreamer/IndexFactory.chs \ + gstreamer/Media/Streaming/GStreamer/Iterator.chs \ + gstreamer/Media/Streaming/GStreamer/Parse.chs \ + gstreamer/Media/Streaming/GStreamer/Pipeline.chs \ + gstreamer/Media/Streaming/GStreamer/Plugin.chs \ + gstreamer/Media/Streaming/GStreamer/PluginFeature.chs \ + gstreamer/Media/Streaming/GStreamer/Registry.chs \ + gstreamer/Media/Streaming/GStreamer/Segment.chs \ + gstreamer/Media/Streaming/GStreamer/SystemClock.chs \ + gstreamer/Media/Streaming/GStreamer/TagList.chs \ + gstreamer/Media/Streaming/GStreamer.hs \ + gstreamer/hsgstreamer.c + +htmldoc_HSFILES_HIDDEN += $(libHSgstreamer_a_GENERATEDSOURCES:.chs=.hs) + +gstreamer_Media_Streaming_GStreamer_Types_hs_HCFLAGS = -fglasgow-exts +gstreamer_Media_Streaming_GStreamer_Pad_hs_HCFLAGS = -fglasgow-exts +gstreamer_Media_Streaming_GStreamer_Element_hs_HCFLAGS = -fglasgow-exts +gstreamer_Media_Streaming_GStreamer_Iterator_hs_HCFLAGS = -fglasgow-exts +gstreamer_Media_Streaming_GStreamer_Plugin_hs_HCFLAGS = -fglasgow-exts +gstreamer_Media_Streaming_GStreamer_PluginFeature_hs_HCFLAGS = -fglasgow-exts + +libHSgstreamer_a_ALLSOURCES = $(libHSgstreamer_a_SOURCES) $(nodist_libHSgstreamer_a_SOURCES) + +gstreamer/Media/Streaming/GStreamer/Hierarchy.chs : \ + $(srcdir)/tools/hierarchyGen/hierarchy.list \ + $(srcdir)/tools/hierarchyGen/TypeGenerator$(EXEEXT) \ + $(srcdir)/tools/hierarchyGen/Hierarchy.chs.template + $(strip $(srcdir)/tools/hierarchyGen/TypeGenerator$(EXEEXT) \ + $(srcdir)/tools/hierarchyGen/hierarchy.list \ + $(srcdir)/tools/hierarchyGen/Hierarchy.chs.template \ + $@ --tag=gstreamer --lib=gstreamer --prefix=gstreamer \ + --modname=Media.Streaming.GStreamer.Hierarchy --parentname=System.Glib.GObject) + +gstreamer/Media/Streaming/GStreamer/Signals.chs : \ + $(srcdir)/tools/callbackGen/Signal.chs.template \ + $(srcdir)/gnomevfs/marshal.list \ + $(srcdir)/tools/callbackGen/HookGenerator$(EXEEXT) + $(strip $(srcdir)/tools/callbackGen/HookGenerator$(EXEEXT) \ + $(srcdir)/gstreamer/marshal.list \ + $(srcdir)/tools/callbackGen/Signal.chs.template $@ \ + Media.Streaming.GStreamer.Signals) + +am_libHSgstreamer_a_OBJECTS = \ + $(addsuffix .$(OBJEXT),$(basename $(basename $(libHSgstreamer_a_ALLSOURCES)))) + +libHSgstreamer_a_HSPPFILES = $(filter %.hs.pp, $(libHSgstreamer_a_ALLSOURCES)) +libHSgstreamer_a_CHSPPFILES = $(filter %.chs.pp,$(libHSgstreamer_a_ALLSOURCES)) +libHSgstreamer_a_CHSFILES = \ + $(filter %.chs,$(libHSgstreamer_a_ALLSOURCES:.chs.pp=.chs)) +libHSgstreamer_a_CHSFILES_HS = $(libHSgstreamer_a_CHSFILES:.chs=.hs) +libHSgstreamer_a_HSCFILES = $(filter %.hsc, $(libHSgstreamer_a_ALLSOURCES)) +libHSgstreamer_a_HSCFILES_HS = $(libHSgstreamer_a_HSCFILES:.hsc=.hs) +libHSgstreamer_a_BUILDSOURCES = \ + $(libHSgstreamer_a_HSPPFILES:.hs.pp=.hs) \ + $(libHSgstreamer_a_CHSPPFILES:.chs.pp=.chs) \ + $(libHSgstreamer_a_CHSFILES_HS) \ + $(libHSgstreamer_a_HSCFILES_HS) \ + $(libHSgstreamer_a_GENERATEDSOURCES) +libHSgstreamer_a_HSFILES = \ + $(filter %.hs,$(libHSgstreamer_a_BUILDSOURCES)) \ + $(filter %.hs,$(libHSgstreamer_a_ALLSOURCES)) + +nobase_hi_DATA += $(libHSgstreamer_a_HSFILES:.hs=.hi) + +gstreamer_MOSTLYCLEANFILES = $(am_libHSgstreamer_a_OBJECTS) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_HSFILES:.hs=.hi) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_CHSFILES:.chs=.chi) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_CHSFILES:.chs=_stub.h) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_CHSFILES:.chs=_stub.o) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_CHSFILES:.chs=_stub.c) +gstreamer_CLEANFILES = $(libHSgstreamer_a_BUILDSOURCES) +gstreamer_CLEANFILES += $(libHSgstreamer_a_CHSFILES_HS:.hs=.dep) + +$(libHSgstreamer_a_CHSFILES:.chs=.dep) : \ + $(libHSgtk_a_GENERATEDSOURCES) \ + $(libHSgstreamer_a_GENERATEDSOURCES) + +ifeq (,$(findstring clean,$(MAKECMDGOALS))) +-include $(libHSgstreamer_a_CHSFILES:.chs=.dep) gstreamer/libHSgstreamer_a.deps + endif + +if ENABLE_SPLITOBJS +libHSgstreamer_a_AR = $(srcdir)/mk/link-splitobjs.sh +else +libHSgstreamer_a_AR = $(AR) $(ARFLAGS) +endif + +libHSgstreamer_a_DEPENDENCIES = HSgstreamer.o +pkglib_DATA += HSgstreamer.o +HSgstreamer.o : $(libHSgstreamer_a_OBJECTS) + $(LD) -r $(LD_X) -o $@ $(libHSgstreamer_a_OBJECTS) $(libHSgstreamer_a_LIBADD) + +if ENABLE_PROFILING +libHSgstreamer_a_DEPENDENCIES += libHSgstreamer_p.a +pkglib_DATA += libHSgstreamer_p.a +libHSgstreamer_p.a : $(libHSgstreamer_a_HSFILES:.hs=.p_o) \ + $(libHSgstreamer_a_LIBADD:.o=.p_o) + $(AR) $(ARFLAGS) $@ $^ + +ifeq (,$(findstring clean,$(MAKECMDGOALS))) +-include gstreamer/libHSgstreamer_a.p_deps + endif + +nobase_hi_DATA += $(libHSgstreamer_a_HSFILES:.hs=.p_hi) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_HSFILES:.hs=.p_hi) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_HSFILES:.hs=.p_o) +gstreamer_MOSTLYCLEANFILES += $(libHSgstreamer_a_LIBADD:.o=.p_o) + +endif + +endif + hunk ./Makefile.am 2320 + rm -f $(gstreamer_MOSTLYCLEANFILES) merger 0.0 ( hunk ./Makefile.am 2324 - rm -f $(c2hs_CLEANFILES) - rm -f $(glib_CLEANFILES) - rm -f $(gtk_CLEANFILES) - rm -f $(glade_CLEANFILES) - rm -f $(gconf_CLEANFILES) - rm -f $(sourceview_CLEANFILES) - rm -f $(mozembed_CLEANFILES) - rm -f $(cairo_CLEANFILES) - rm -f $(svgcairo_CLEANFILES) - rm -f $(gtkglext_CLEANFILES) - rm -f $(soegtk_CLEANFILES) - rm -f $(doc_CLEANFILES) + rm -f $(c2hs_CLEANFILES) + rm -rf $(c2hs_CLEANFILES_SPLIT) + rm -f $(glib_CLEANFILES) + rm -rf $(glib_CLEANFILES_SPLIT) + rm -f $(gtk_CLEANFILES) + rm -rf $(gtk_CLEANFILES_SPLIT) + rm -f $(glade_CLEANFILES) + rm -rf $(glade_CLEANFILES_SPLIT) + rm -f $(gconf_CLEANFILES) + rm -rf $(gconf_CLEANFILES_SPLIT) + rm -f $(sourceview_CLEANFILES) + rm -rf $(sourceview_CLEANFILES_SPLIT) + rm -f $(mozembed_CLEANFILES) + rm -rf $(mozembed_CLEANFILES_SPLIT) + rm -f $(cairo_CLEANFILES) + rm -rf $(cairo_CLEANFILES_SPLIT) + rm -f $(svgcairo_CLEANFILES) + rm -rf $(svgcairo_CLEANFILES_SPLIT) + rm -f $(gtkglext_CLEANFILES) + rm -rf $(gtkglext_CLEANFILES_SPLIT) + rm -f $(soegtk_CLEANFILES) + rm -rf $(soegtk_CLEANFILES_SPLIT) + rm -f $(gnomevfs_CLEANFILES) + rm -rf $(gnomevfs_CLEANFILES_SPLIT) + rm -f $(doc_CLEANFILES) merger 0.0 ( merger 0.0 ( hunk ./Makefile.am 2335 + rm -f $(gnomevfs_CLEANFILES) hunk ./Makefile.am 2324 - rm -f $(c2hs_CLEANFILES) - rm -f $(glib_CLEANFILES) - rm -f $(gtk_CLEANFILES) - rm -f $(glade_CLEANFILES) - rm -f $(gconf_CLEANFILES) - rm -f $(sourceview_CLEANFILES) - rm -f $(mozembed_CLEANFILES) - rm -f $(cairo_CLEANFILES) - rm -f $(svgcairo_CLEANFILES) - rm -f $(gtkglext_CLEANFILES) - rm -f $(soegtk_CLEANFILES) - rm -f $(doc_CLEANFILES) + rm -f $(c2hs_CLEANFILES) + rm -rf $(c2hs_CLEANFILES_SPLIT) + rm -f $(glib_CLEANFILES) + rm -rf $(glib_CLEANFILES_SPLIT) + rm -f $(gtk_CLEANFILES) + rm -rf $(gtk_CLEANFILES_SPLIT) + rm -f $(glade_CLEANFILES) + rm -rf $(glade_CLEANFILES_SPLIT) + rm -f $(gconf_CLEANFILES) + rm -rf $(gconf_CLEANFILES_SPLIT) + rm -f $(sourceview_CLEANFILES) + rm -rf $(sourceview_CLEANFILES_SPLIT) + rm -f $(mozembed_CLEANFILES) + rm -rf $(mozembed_CLEANFILES_SPLIT) + rm -f $(cairo_CLEANFILES) + rm -rf $(cairo_CLEANFILES_SPLIT) + rm -f $(svgcairo_CLEANFILES) + rm -rf $(svgcairo_CLEANFILES_SPLIT) + rm -f $(gtkglext_CLEANFILES) + rm -rf $(gtkglext_CLEANFILES_SPLIT) + rm -f $(soegtk_CLEANFILES) + rm -rf $(soegtk_CLEANFILES_SPLIT) + rm -f $(doc_CLEANFILES) ) hunk ./Makefile.am 2336 + rm -f $(gstreamer_CLEANFILES) ) ) hunk ./configure.ac 346 +GTKHS_PKG_CHECK(gstreamer, gstreamer, GSTREAMER, [gstreamer-0.10 >= 0.10], + [build gstreamer package (default=auto)], + [gstreamer library requirement not met. Perhaps you need to install libgstreamer or libgstreamer-devel]) + hunk ./configure.ac 642 +GTKHS_REFORMAT_PACKAGE_CFLAGS(GSTREAMER_CFLAGS, GSTREAMER_CFLAGS_CQ) +GTKHS_REFORMAT_PACKAGE_LIBS(GSTREAMER_LIBS, GSTREAMER_LIBS_CQ, GSTREAMER_LIBDIR_CQ, GSTREAMER_LIBEXTRA_CQ) +AC_SUBST(GSTREAMER_CFLAGS_CQ) +AC_SUBST(GSTREAMER_LIBS_CQ) +AC_SUBST(GSTREAMER_LIBDIR_CQ) +AC_SUBST(GSTREAMER_LIBEXTRA_CQ) + hunk ./configure.ac 880 + + gstreamer/gstreamer.pkg + gstreamer/gstreamer.package.conf + gstreamer/gstreamer.cabal hunk ./configure.ac 905 +echo "* gstreamer : ${ENABLE_GSTREAMER} " addfile ./gstreamer/Media/Streaming/GStreamer.hs hunk ./gstreamer/Media/Streaming/GStreamer.hs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin +-- Created: 1-Apr-2007 +-- +-- Version $Revision$ from $Date$ +-- +-- Copyright (c) 2007 Peter Gavin +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. +-- +module Media.Streaming.GStreamer ( + [_$_] + module Media.Streaming.GStreamer.Bin, + module Media.Streaming.GStreamer.Bus, + module Media.Streaming.GStreamer.Caps, + module Media.Streaming.GStreamer.Clock, + module Media.Streaming.GStreamer.Element, + module Media.Streaming.GStreamer.ElementFactory, + module Media.Streaming.GStreamer.Format, + module Media.Streaming.GStreamer.GhostPad, + module Media.Streaming.GStreamer.ImplementsInterface, + module Media.Streaming.GStreamer.Index, + module Media.Streaming.GStreamer.IndexFactory, + module Media.Streaming.GStreamer.Init, + module Media.Streaming.GStreamer.Iterator, + module Media.Streaming.GStreamer.Message, + module Media.Streaming.GStreamer.Object, + module Media.Streaming.GStreamer.Pad, + module Media.Streaming.GStreamer.PadTemplate, + module Media.Streaming.GStreamer.Parse, + module Media.Streaming.GStreamer.Pipeline, + module Media.Streaming.GStreamer.Plugin, + module Media.Streaming.GStreamer.PluginFeature, + module Media.Streaming.GStreamer.Registry, + module Media.Streaming.GStreamer.Segment, + module Media.Streaming.GStreamer.Structure, + module Media.Streaming.GStreamer.SystemClock, + module Media.Streaming.GStreamer.TagList, + [_$_] + ) where + +import Media.Streaming.GStreamer.Bin +import Media.Streaming.GStreamer.Bus +import Media.Streaming.GStreamer.Caps +import Media.Streaming.GStreamer.Clock +import Media.Streaming.GStreamer.Element +import Media.Streaming.GStreamer.ElementFactory +import Media.Streaming.GStreamer.Format +import Media.Streaming.GStreamer.GhostPad +import Media.Streaming.GStreamer.ImplementsInterface +import Media.Streaming.GStreamer.Index +import Media.Streaming.GStreamer.IndexFactory +import Media.Streaming.GStreamer.Init +import Media.Streaming.GStreamer.Iterator +import Media.Streaming.GStreamer.Message +import Media.Streaming.GStreamer.Object +import Media.Streaming.GStreamer.Pad +import Media.Streaming.GStreamer.PadTemplate +import Media.Streaming.GStreamer.Parse +import Media.Streaming.GStreamer.Pipeline +import Media.Streaming.GStreamer.Plugin +import Media.Streaming.GStreamer.PluginFeature +import Media.Streaming.GStreamer.Registry +import Media.Streaming.GStreamer.Segment +import Media.Streaming.GStreamer.Structure +import Media.Streaming.GStreamer.SystemClock +import Media.Streaming.GStreamer.TagList addfile ./gstreamer/Media/Streaming/GStreamer/Bin.chs hunk ./gstreamer/Media/Streaming/GStreamer/Bin.chs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin +-- Created: 1-Apr-2007 +-- +-- Version $Revision$ from $Date$ +-- +-- Copyright (c) 2007 Peter Gavin +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. +-- +module Media.Streaming.GStreamer.Bin ( + [_$_] + Bin, + BinClass, + castToBin, + toBin, + fromBin, + binAdd, + binRemove, + binGetByName, + binGetByNameRecurseUp, + binGetByInterface, + binIterateElements, + binIterateRecurse, + binIterateSinks, + binIterateSorted, + binIterateSources, + binIterateAllByInterface, + binFindUnconnectedPad + [_$_] + ) where + +import Control.Exception ( bracket_ ) +import Control.Monad ( liftM ) +import System.Glib.FFI +{#import System.Glib.GType#} ( GType ) +import System.Glib.UTFString ( withUTFString ) +import System.Glib.GList ( GList + , readGList ) +{#import Media.Streaming.GStreamer.Types#} +{#import Media.Streaming.GStreamer.Signals#} + +{# context lib = "gstreamer" prefix = "gst" #} + +binAdd :: (BinClass bin, + ElementClass element) => + bin + -> element + -> IO Bool +binAdd bin element = + liftM toBool $ {# call bin_add #} (toBin bin) (toElement element) + +binRemove :: (BinClass bin, + ElementClass element) => + bin + -> element + -> IO Bool +binRemove bin element = + liftM toBool $ {# call bin_remove #} (toBin bin) (toElement element) + +binGetByName :: BinClass bin => + bin + -> String + -> IO (Maybe Element) +binGetByName bin name = + withUTFString name ({# call bin_get_by_name #} (toBin bin)) >>= maybePeek newElement + +binGetByNameRecurseUp :: BinClass bin => + bin + -> String + -> IO (Maybe Element) +binGetByNameRecurseUp bin name = + withUTFString name ({# call bin_get_by_name_recurse_up #} $ toBin bin) >>= + maybePeek newElement + +binGetByInterface :: BinClass bin => + bin + -> GType + -> IO (Maybe Element) +binGetByInterface bin iface = + {# call bin_get_by_interface #} (toBin bin) (fromIntegral iface) >>= + maybePeek newElement + +binIterateElements :: BinClass bin => + bin + -> IO (Maybe (Iterator Element)) +binIterateElements bin = + {# call bin_iterate_elements #} (toBin bin) >>= + maybePeek newIterator + +binIterateRecurse :: BinClass bin => + bin + -> IO (Maybe (Iterator Element)) +binIterateRecurse bin = + {# call bin_iterate_recurse #} (toBin bin) >>= + maybePeek newIterator + +binIterateSinks :: BinClass bin => + bin + -> IO (Maybe (Iterator Element)) +binIterateSinks bin = + {# call bin_iterate_sinks #} (toBin bin) >>= + maybePeek newIterator + +binIterateSorted :: BinClass bin => + bin + -> IO (Maybe (Iterator Element)) +binIterateSorted bin = + {# call bin_iterate_sorted #} (toBin bin) >>= + maybePeek newIterator + +binIterateSources :: BinClass bin => + bin + -> IO (Maybe (Iterator Element)) +binIterateSources bin = + {# call bin_iterate_sources #} (toBin bin) >>= + maybePeek newIterator + +binIterateAllByInterface :: BinClass bin => + bin + -> GType + -> IO (Maybe (Iterator Element)) +binIterateAllByInterface bin iface = + {# call bin_iterate_all_by_interface #} (toBin bin) (fromIntegral iface) >>= + maybePeek newIterator + +binFindUnconnectedPad :: BinClass bin => + bin + -> PadDirection + -> IO (Maybe Pad) +binFindUnconnectedPad bin direction = + {# call bin_find_unconnected_pad #} (toBin bin) (fromIntegral $ fromEnum direction) >>= + maybePeek newPad + +onBinElementAdded, afterBinElementAdded :: BinClass bin + => bin + -> (Element -> IO ()) + -> IO (ConnectId bin) +onBinElementAdded = + connect_OBJECT__NONE "element-added" False +afterBinElementAdded = + connect_OBJECT__NONE "element-added" True + +onBinElementRemoved, afterBinElementRemoved :: BinClass bin + => bin + -> (Element -> IO ()) + -> IO (ConnectId bin) +onBinElementRemoved = + connect_OBJECT__NONE "element-removed" False +afterBinElementRemoved = + connect_OBJECT__NONE "element-removed" True addfile ./gstreamer/Media/Streaming/GStreamer/Bus.chs hunk ./gstreamer/Media/Streaming/GStreamer/Bus.chs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin +-- Created: 1-Apr-2007 +-- +-- Version $Revision$ from $Date$ +-- +-- Copyright (c) 2007 Peter Gavin +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. +-- +module Media.Streaming.GStreamer.Bus ( + Bus, + BusClass, + busNew, + busPost, + busHavePending, + busPeek, + busPop, + busTimedPop, + busSetFlushing, + busCreateWatch, + busAddWatch, + busAddSignalWatch, + busRemoveSignalWatch, + busPoll + ) where + +import Control.Monad (liftM) +{#import Media.Streaming.GStreamer.Types#} +{#import Media.Streaming.GStreamer.Signals#} +{#import System.Glib.MainLoop#} +import System.Glib.Flags +import System.Glib.FFI +{#import System.Glib.GObject#} +{#import System.Glib.MainLoop#} + +{# context lib = "gstreamer" prefix = "gst" #} + +busNew :: IO Bus +busNew = + {# call bus_new #} >>= newBus + +busPost :: Bus + -> Message + -> IO Bool +busPost bus message = + do {# call gst_mini_object_ref #} (toMiniObject message) + liftM toBool $ {# call bus_post #} bus message + +busHavePending :: Bus + -> IO Bool +busHavePending bus = + liftM toBool $ {# call bus_have_pending #} bus + +busPeek :: Bus + -> IO (Maybe Message) +busPeek bus = + {# call bus_peek #} bus >>= maybePeek newMessage + +busPop :: Bus + -> IO (Maybe Message) +busPop bus = + {# call bus_pop #} bus >>= maybePeek newMessage + +busTimedPop :: Bus + -> ClockTime + -> IO (Maybe Message) +busTimedPop bus timeout = + {# call bus_timed_pop #} bus timeout >>= maybePeek newMessage + +busSetFlushing :: Bus + -> Bool + -> IO () +busSetFlushing bus flushing = + {# call bus_set_flushing #} bus $ fromBool flushing + +busCreateWatch :: Bus + -> IO Source +busCreateWatch bus = + liftM Source $ {# call bus_create_watch #} bus >>= + flip newForeignPtr sourceFinalizer +foreign import ccall unsafe "&g_source_unref" + sourceFinalizer :: FunPtr (Ptr Source -> IO ()) + +type CBusFunc = Ptr Bus + -> Ptr Message + -> {# type gpointer #} + -> IO {# type gboolean #} +marshalBusFunc :: BusFunc + -> IO {# type GstBusFunc #} +marshalBusFunc busFunc = + makeBusFunc cBusFunc + where cBusFunc :: CBusFunc + cBusFunc busPtr messagePtr userData = + do bus <- newBus_ busPtr + message <- newMessage_ messagePtr + liftM fromBool $ busFunc bus message +foreign import ccall "wrapper" + makeBusFunc :: CBusFunc + -> IO {# type GstBusFunc #} + +busAddWatch :: Bus + -> Priority + -> BusFunc + -> IO Word +busAddWatch bus priority func = + do busFuncPtr <- marshalBusFunc func + destroyNotify <- mkFunPtrDestroyNotify busFuncPtr + liftM fromIntegral $ + {# call bus_add_watch_full #} + bus + (fromIntegral priority) + busFuncPtr + nullPtr + destroyNotify + +busAddSignalWatch :: Bus + -> Priority + -> IO () +busAddSignalWatch bus priority = + {# call bus_add_signal_watch_full #} bus $ fromIntegral priority + +busRemoveSignalWatch :: Bus + -> IO () +busRemoveSignalWatch = + {# call bus_remove_signal_watch #} + +busPoll :: Bus + -> [MessageType] + -> ClockTimeDiff + -> IO Message +busPoll bus events timeout = + {# call bus_poll #} bus (fromIntegral $ fromFlags events) timeout >>= + newMessage + +onBusMessage, afterBusMessage :: BusClass bus + => bus + -> (Message -> IO ()) + -> IO (ConnectId bus) +onBusMessage = + connect_BOXED__NONE "message" newMessage_ False +afterBusMessage = + connect_BOXED__NONE "message" newMessage_ True addfile ./gstreamer/Media/Streaming/GStreamer/Caps.chs hunk ./gstreamer/Media/Streaming/GStreamer/Caps.chs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin +-- Created: 1-Apr-2007 +-- +-- Copyright (c) 2007 Peter Gavin +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. +-- +module Media.Streaming.GStreamer.Caps ( + [_$_] + Caps, + capsNone, + capsAny, + capsSize, + capsGetStructure, + capsIsEmpty, + capsIsFixed, + capsIsEqual, + capsIsEqualFixed, + capsIsAlwaysCompatible, [_$_] + capsIsSubset, + capsIntersect, + capsUnion, + capsSubtract, + capsNormalize, + capsFromString, + capsToString, + [_$_] + CapsM, + capsCreate, + capsModify, + capsAppend, + capsMerge, + capsAppendStructure, + capsMergeStructure, + capsRemoveStructure, + capsTruncate + [_$_] + ) where + +{# context lib = "gstreamer" prefix = "gst" #} + +import System.Glib.FFI +import System.Glib.UTFString +{#import Media.Streaming.GStreamer.Types#} + +capsNone :: Caps +capsNone = + unsafePerformIO $ {# call caps_new_empty #} >>= newCaps + +capsAny :: Caps +capsAny = + unsafePerformIO $ {# call caps_new_any #} >>= newCaps + +capsSize :: Caps + -> Word +capsSize caps = + fromIntegral $ unsafePerformIO $ {# call caps_get_size #} caps + +capsGetStructure :: Caps + -> Word + -> Maybe Structure +capsGetStructure caps index = + unsafePerformIO $ + {# call caps_get_structure #} caps (fromIntegral index) >>= + maybePeek newStructure_ + +capsIsEmpty :: Caps + -> Bool +capsIsEmpty caps = + toBool $ unsafePerformIO $ + {# call caps_is_empty #} caps + +capsIsFixed :: Caps + -> Bool +capsIsFixed caps = + toBool $ unsafePerformIO $ + {# call caps_is_fixed #} caps + +capsIsEqual :: Caps + -> Caps + -> Bool +capsIsEqual caps1 caps2 = + toBool $ unsafePerformIO $ + {# call caps_is_equal #} caps1 caps2 + +instance Eq Caps where + (==) = capsIsEqual + +capsIsEqualFixed :: Caps + -> Caps + -> Bool +capsIsEqualFixed caps1 caps2 = + toBool $ unsafePerformIO $ + {# call caps_is_equal_fixed #} caps1 caps2 + +capsIsAlwaysCompatible :: Caps + -> Caps + -> Bool +capsIsAlwaysCompatible caps1 caps2 = + toBool $ unsafePerformIO $ + {# call caps_is_always_compatible #} caps1 caps2 + +capsIsSubset :: Caps + -> Caps + -> Bool +capsIsSubset caps1 caps2 = + toBool $ unsafePerformIO $ + {# call caps_is_subset #} caps1 caps2 + +capsIntersect :: Caps + -> Caps + -> Caps +capsIntersect caps1 caps2 = + unsafePerformIO $ + {# call caps_intersect #} caps1 caps2 >>= + newCaps + +capsUnion :: Caps + -> Caps + -> Caps +capsUnion caps1 caps2 = + unsafePerformIO $ + {# call caps_union #} caps1 caps2 >>= + newCaps + +capsSubtract :: Caps + -> Caps + -> Caps +capsSubtract caps1 caps2 = + unsafePerformIO $ + {# call caps_subtract #} caps1 caps2 >>= + newCaps + +capsNormalize :: Caps + -> Caps +capsNormalize caps = + unsafePerformIO $ + {# call caps_normalize #} caps >>= newCaps + +capsToString :: Caps + -> String +capsToString caps = + unsafePerformIO $ + {# call caps_to_string #} caps >>= readUTFString + +capsFromString :: String + -> Caps +capsFromString string = + unsafePerformIO $ + withUTFString string {# call caps_from_string #} >>= + newCaps + +newtype CapsM a = CapsM (CapsMRep a) +type CapsMRep a = (Caps -> IO a) + +instance Monad CapsM where + (CapsM aM) >>= fbM = + CapsM $ \caps -> + do a <- aM caps + let CapsM bM = fbM a + bM caps + return a = CapsM $ const $ return a + +marshalCapsModify :: IO (Ptr Caps) + -> CapsM a + -> (Caps, a) +marshalCapsModify mkCaps (CapsM action) = + unsafePerformIO $ + do ptr <- mkCaps + caps <- newCaps_ ptr + result <- action caps + caps' <- newCaps ptr + return (caps', result) + +capsCreate :: CapsM a + -> (Caps, a) +capsCreate action = + marshalCapsModify + {# call caps_new_empty #} + action + +capsModify :: Caps + -> CapsM a + -> (Caps, a) +capsModify caps action = + marshalCapsModify + ({# call caps_copy #} caps) + action + +capsAppend :: Caps + -> CapsM () +capsAppend caps2 = + CapsM $ \caps1 -> + {# call caps_copy #} caps2 >>= newCaps_ >>= + {# call caps_append #} caps1 + +capsMerge :: Caps + -> CapsM () +capsMerge caps2 = + CapsM $ \caps1 -> + {# call caps_copy #} caps2 >>= newCaps_ >>= + {# call caps_merge #} caps1 + +capsAppendStructure :: Structure + -> CapsM () +capsAppendStructure structure = + CapsM $ \caps -> + giveStructure structure $ + {# call caps_append_structure #} caps + +capsMergeStructure :: Structure + -> CapsM () +capsMergeStructure structure = + CapsM $ \caps -> + giveStructure structure $ + {# call caps_merge_structure #} caps + +capsRemoveStructure :: Word + -> CapsM () +capsRemoveStructure idx = + CapsM $ \caps -> + {# call caps_remove_structure #} caps $ fromIntegral idx + +capsTruncate :: CapsM () +capsTruncate = + CapsM {# call caps_truncate #} addfile ./gstreamer/Media/Streaming/GStreamer/Clock.chs hunk ./gstreamer/Media/Streaming/GStreamer/Clock.chs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin +-- Created: 1-Apr-2007 +-- +-- Copyright (c) 2007 Peter Gavin +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. +-- +module Media.Streaming.GStreamer.Clock ( + ) where + +import Control.Monad (liftM, liftM4) +{#import Media.Streaming.GStreamer.Types#} +import System.Glib.FFI + +{# context lib = "gstreamer" prefix = "gst" #} + +clockAddObservation :: ClockClass clock + => clock + -> ClockTime + -> ClockTime + -> IO (Maybe Double) +clockAddObservation clock slave master = + alloca $ \rSquaredPtr -> + do success <- {# call clock_add_observation #} (toClock clock) slave master rSquaredPtr + if toBool success + then liftM (Just . realToFrac) $ peek rSquaredPtr + else return Nothing + +clockSetMaster :: (ClockClass clock, ClockClass master) + => clock + -> master + -> IO Bool +clockSetMaster clock master = + liftM toBool $ {# call clock_set_master #} (toClock clock) (toClock master) + +clockGetMaster :: ClockClass clock + => clock + -> IO (Maybe Clock) +clockGetMaster clock = + {# call clock_get_master #} (toClock clock) >>= maybePeek newClock + +clockSetResolution :: ClockClass clock + => clock + -> ClockTime + -> IO ClockTime +clockSetResolution = + {# call clock_set_resolution #} . toClock + +clockGetResolution :: ClockClass clock + => clock + -> IO ClockTime +clockGetResolution = + {# call clock_get_resolution #} . toClock + +clockGetTime :: ClockClass clock + => clock + -> IO ClockTime +clockGetTime = + {# call clock_get_time #} . toClock + +clockNewSingleShotID :: ClockClass clock + => clock + -> ClockTime + -> IO ClockID +clockNewSingleShotID clock time = + {# call clock_new_single_shot_id #} (toClock clock) time >>= + newClockID . castPtr + +clockNewPeriodicID :: ClockClass clock + => clock + -> ClockTime + -> ClockTime + -> IO ClockID +clockNewPeriodicID clock startTime interval = + {# call clock_new_periodic_id #} (toClock clock) startTime interval >>= + newClockID . castPtr + +clockGetInternalTime :: ClockClass clock + => clock + -> IO ClockTime +clockGetInternalTime = + {# call clock_get_internal_time #} . toClock + +clockGetCalibration :: ClockClass clock + => clock + -> IO (ClockTime, ClockTime, ClockTime, ClockTime) +clockGetCalibration clock = + alloca $ \internalPtr -> + alloca $ \externalPtr -> + alloca $ \rateNumPtr -> + alloca $ \rateDenomPtr -> + do {# call clock_get_calibration #} (toClock clock) + internalPtr + externalPtr + rateNumPtr + rateDenomPtr + liftM4 (\a b c d -> (a, b, c, d)) + (peek internalPtr) + (peek externalPtr) + (peek rateNumPtr) + (peek rateDenomPtr) + +clockSetCalibration :: ClockClass clock + => clock + -> ClockTime + -> ClockTime + -> ClockTime + -> ClockTime + -> IO () +clockSetCalibration = + {# call clock_set_calibration #} . toClock + +clockIDGetTime :: ClockID + -> IO ClockTime +clockIDGetTime clockID = + withClockID clockID $ {# call clock_id_get_time #} . castPtr + +clockIDWait :: ClockID + -> IO (ClockReturn, ClockTimeDiff) +clockIDWait clockID = + alloca $ \jitterPtr -> + do result <- withClockID clockID $ \clockIDPtr -> + {# call clock_id_wait #} (castPtr clockIDPtr) jitterPtr + jitter <- peek jitterPtr + return $ (toClockReturn result, jitter) + +clockIDUnschedule :: ClockID + -> IO () +clockIDUnschedule clockID = + withClockID clockID $ {# call clock_id_unschedule #} . castPtr + addfile ./gstreamer/Media/Streaming/GStreamer/Element.chs hunk ./gstreamer/Media/Streaming/GStreamer/Element.chs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin +-- Created: 1-Apr-2007 +-- +-- Version $Revision$ from $Date$ +-- +-- Copyright (c) 2007 Peter Gavin +-- +-- This library is free software; you can redistribute it and/or +-- modify it under the terms of the GNU Library General Public +-- License as published by the Free Software Foundation; either +-- version 2 of the License, or (at your option) any later version. +-- +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +-- Library General Public License for more details. +-- +module Media.Streaming.GStreamer.Element ( + [_$_] + Element, + ElementClass, + castToElement, + toElement, + fromElement, + ElementFlags(..), + State(..), + StateChange(..), + StateChangeReturn(..) + [_$_] + ) where + +import Control.Monad ( liftM ) +import Data.Maybe ( fromMaybe ) +import System.Glib.FFI +import System.Glib.Flags +import System.Glib.UTFString ( withUTFString + , peekUTFString ) +{#import System.Glib.Signals#} +{#import System.Glib.GObject#} +{#import Media.Streaming.GStreamer.Types#} +{#import Media.Streaming.GStreamer.Signals#} +import GHC.Base ( unsafeCoerce# ) + +{# context lib = "gstreamer" prefix = "gst" #} + +elementAddPad :: (ElementClass elementT, PadClass padT) => + elementT + -> padT + -> IO Bool +elementAddPad element pad = + liftM toBool $ {# call element_add_pad #} (toElement element) (toPad pad) + +elementGetPad :: ElementClass elementT => + elementT + -> String + -> IO (Maybe Pad) +elementGetPad element name = + (withUTFString name $ {# call element_get_pad #} (toElement element)) >>= + maybePeek newPad + +elementGetCompatiblePad :: (ElementClass elementT, PadClass padT) => + elementT + -> padT + -> Caps + -> IO (Maybe Pad) +elementGetCompatiblePad element pad caps = + {# call element_get_compatible_pad #} (toElement element) (toPad pad) caps >>= + maybePeek newPad + +elementGetCompatiblePadTemplate :: (ElementClass elementT, PadTemplateClass padTemplateT) => + elementT + -> padTemplateT + -> IO (Maybe PadTemplate) +elementGetCompatiblePadTemplate element padTemplate = + {# call element_get_compatible_pad_template #} (toElement element) (toPadTemplate padTemplate) >>= + maybePeek newPadTemplate + + +elementGetRequestPad :: ElementClass elementT => + elementT + -> String + -> IO (Maybe Pad) +elementGetRequestPad element name = + (withUTFString name $ {# call element_get_request_pad #} (toElement element)) >>= + maybePeek newPad_ -- no finalizer; use elementReleaseRequestPad + +elementGetStaticPad :: ElementClass elementT => + elementT + -> String + -> IO (Maybe Pad) +elementGetStaticPad element name = + (withUTFString name $ {# call element_get_static_pad #} (toElement element)) >>= + maybePeek newPad + +elementNoMorePads :: ElementClass elementT => + elementT + -> IO () +elementNoMorePads element = + {# call element_no_more_pads #} (toElement element) + +elementReleaseRequestPad :: (ElementClass elementT, PadClass padT) => + elementT + -> padT + -> IO () +elementReleaseRequestPad element pad = + {# call element_release_request_pad #} (toElement element) (toPad pad) + +elementRemovePad :: (ElementClass elementT, PadClass padT) => + elementT + -> padT + -> IO Bool +elementRemovePad element pad = + liftM toBool $ {# call element_remove_pad #} (toElement element) (toPad pad) + +elementIteratePads :: (ElementClass elementT) => + elementT + -> IO (Iterator Pad) +elementIteratePads element = + {# call element_iterate_pads #} (toElement element) >>= newIterator + +elementIterateSinkPads :: (ElementClass elementT) => + elementT + -> IO (Iterator Pad) +elementIterateSinkPads element = + {# call element_iterate_sink_pads #} (toElement element) >>= newIterator + +elementIterateSrcPads :: (ElementClass elementT) => + elementT + -> IO (Iterator Pad) +elementIterateSrcPads element = + {# call element_iterate_sink_pads #} (toElement element) >>= newIterator + +elementLink :: (ElementClass elementT1, ElementClass elementT2) => + elementT1 + -> elementT2 + -> IO Bool +elementLink element1 element2 = + liftM toBool $ {# call element_link #} (toElement element1) (toElement element2) + +elementUnlink :: (ElementClass elementT1, ElementClass elementT2) => + elementT1 + -> elementT2 + -> IO () +elementUnlink element1 element2 = + {# call element_unlink #} (toElement element1) (toElement element2) + +elementLinkPads :: (ElementClass elementT1, ElementClass elementT2) => + elementT1 + -> String + -> elementT2 + -> String + -> IO Bool +elementLinkPads src srcPadName dest destPadName = + withUTFString destPadName $ \cDestPadName -> + withUTFString srcPadName $ \cSrcPadName -> + liftM toBool $ {# call element_link_pads #} (toElement src) cSrcPadName (toElement dest) cDestPadName + +elementUnlinkPads :: (ElementClass elementT1, ElementClass elementT2) => + elementT1 + -> String + -> elementT2 + -> String + -> IO () +elementUnlinkPads src srcPadName dest destPadName = + withUTFString destPadName $ \cDestPadName -> + withUTFString srcPadName $ \cSrcPadName -> + {# call element_unlink_pads #} (toElement src) cSrcPadName (toElement dest) cDestPadName + +elementLinkPadsFiltered :: (ElementClass elementT1, ElementClass elementT2) => + elementT1 + -> String + -> elementT2 + -> String + -> Caps + -> IO Bool +elementLinkPadsFiltered src srcPadName dest destPadName filter = + withUTFString destPadName $ \cDestPadName -> + withUTFString srcPadName $ \cSrcPadName -> + liftM toBool $ {# call element_link_pads_filtered #} (toElement src) cSrcPadName (toElement dest) cDestPadName filter + +elementLinkFiltered :: (ElementClass elementT1, ElementClass elementT2) => + elementT1 + -> elementT2 + -> Maybe Caps + -> IO Bool +elementLinkFiltered element1 element2 filter = + liftM toBool $ + {# call element_link_filtered #} (toElement element1) (toElement element2) $ + fromMaybe (Caps nullForeignPtr) filter + +elementSetBaseTime :: ElementClass elementT => + elementT + -> ClockTimeDiff + -> IO () +elementSetBaseTime element time = + {# call element_set_base_time #} (toElement element) $ fromIntegral time + +elementGetBaseTime :: ElementClass elementT => + elementT + -> IO ClockTimeDiff +elementGetBaseTime element = + liftM fromIntegral $ {# call element_get_base_time #} (toElement element) + +elementSetBus :: (ElementClass elementT, BusClass busT) => + elementT + -> busT + -> IO () +elementSetBus element bus = + {# call element_set_bus #} (toElement element) (toBus bus) + +elementGetBus :: ElementClass elementT => + elementT + -> IO Bus +elementGetBus element = + {# call element_get_bus #} (toElement element) >>= newBus + +elementGetFactory :: ElementClass elementT => + elementT + -> IO ElementFactory +elementGetFactory element = + {# call element_get_factory #} (toElement element) >>= newElementFactory_ + +elementSetIndex :: (ElementClass elementT, IndexClass indexT) => + elementT + -> indexT + -> IO () +elementSetIndex element index = + {# call element_set_index #} (toElement element) (toIndex index) + +elementGetIndex :: ElementClass elementT => + elementT + -> IO (Maybe Index) +elementGetIndex element = + {# call element_get_index #} (toElement element) >>= maybePeek newIndex + +elementIsIndexable :: ElementClass elementT => + elementT + -> IO Bool +elementIsIndexable element = + liftM toBool $ {# call element_is_indexable #} (toElement element) + +elementRequiresClock :: ElementClass elementT => + elementT + -> IO Bool +elementRequiresClock element = + liftM toBool $ {# call element_requires_clock #} (toElement element) + +elementSetClock :: (ElementClass elementT, ClockClass clockT) => + elementT + -> clockT + -> IO Bool +elementSetClock element clock = + liftM toBool $ {# call element_set_clock #} (toElement element) (toClock clock) + +elementGetClock :: ElementClass elementT => + elementT + -> IO (Maybe Clock) +elementGetClock element = + {# call element_get_clock #} (toElement element) >>= maybePeek newClock + +elementProvidesClock :: ElementClass elementT => + elementT + -> IO Bool +elementProvidesClock element = + liftM toBool $ {# call element_provides_clock #} $ toElement element + +elementProvideClock :: ElementClass elementT => + elementT + -> IO (Maybe Clock) +elementProvideClock element = + {# call element_provide_clock #} (toElement element) >>= maybePeek newClock + +elementSetState :: ElementClass elementT => + elementT + -> State + -> IO StateChangeReturn +elementSetState element state = + liftM (toEnum . fromIntegral) $ {# call element_set_state #} (toElement element) $ + fromIntegral $ fromEnum state + +elementGetState :: ElementClass elementT => + elementT + -> ClockTime + -> IO (StateChangeReturn, State, State) +elementGetState element timeout = + alloca $ \statePtr -> + alloca $ \pendingPtr -> + do result <- {# call element_get_state #} (toElement element) statePtr pendingPtr $ fromIntegral timeout + state <- peek statePtr + pending <- peek pendingPtr + return (toEnum (fromIntegral result), + toEnum (fromIntegral state), + toEnum (fromIntegral pending)) + +elementSetLockedState :: ElementClass elementT => + elementT + -> Bool + -> IO Bool +elementSetLockedState element lockedState = + liftM toBool $ {# call element_set_locked_state #} (toElement element) $ fromBool lockedState + +elementIsLockedState :: ElementClass elementT => + elementT + -> IO Bool +elementIsLockedState element = + liftM toBool $ {# call element_is_locked_state #} $ toElement element + +elementAbortState :: ElementClass elementT => + elementT + -> IO () +elementAbortState element = + {# call element_abort_state #} $ toElement element + +elementStateGetName :: State + -> String +elementStateGetName state = + unsafePerformIO $ ({# call element_state_get_name #} $ fromIntegral $ fromEnum state) >>= peekUTFString + +elementStateChangeReturnGetName :: StateChangeReturn + -> String +elementStateChangeReturnGetName stateRet = + unsafePerformIO $ ({# call element_state_change_return_get_name #} $ fromIntegral $ fromEnum stateRet) >>= peekUTFString + +elementSyncStateWithParent :: ElementClass elementT => + elementT + -> IO Bool +elementSyncStateWithParent element = + liftM toBool $ {# call element_sync_state_with_parent #} $ toElement element + +elementGetQueryTypes :: ElementClass element + => element + -> IO [QueryType] +elementGetQueryTypes element = + liftM (map (toEnum . fromIntegral)) $ + {# call element_get_query_types #} (toElement element) >>= + peekArray0 0 + +elementQuery :: (ElementClass element, QueryClass query) + => element + -> query + -> IO (Maybe query) +elementQuery element query = + do query' <- {# call mini_object_copy #} (toMiniObject query) >>= + newForeignPtr_ . castPtr + success <- {# call element_query #} (toElement element) $ Query query' + if toBool success + then liftM (Just . unsafeCoerce#) $ withForeignPtr query' $ newQuery . castPtr + else return Nothing + +elementQueryConvert :: ElementClass element + => element + -> Format + -> Int64 + -> IO (Maybe (Format, Int64)) +elementQueryConvert element srcFormat srcVal = + alloca $ \destFormatPtr -> + alloca $ \destValPtr -> + do success <- {# call element_query_convert #} (toElement element) + (fromIntegral $ fromEnum srcFormat) + (fromIntegral srcVal) + destFormatPtr + destValPtr + if toBool success + then do destFormat <- peek destFormatPtr + destVal <- peek destValPtr + return $ Just (toEnum $ fromIntegral destFormat, + fromIntegral destVal) + else return Nothing + +elementQueryPosition :: ElementClass element + => element + -> IO (Maybe (Format, Int64)) +elementQueryPosition element = + alloca $ \formatPtr -> + alloca $ \curPtr -> + do success <- {# call element_query_position #} (toElement element) formatPtr curPtr + if toBool success + then do format <- peek formatPtr + cur <- peek curPtr + return $ Just (toEnum $ fromIntegral format, + fromIntegral cur) + else return Nothing + +elementQueryDuration :: ElementClass element + => element + -> IO (Maybe (Format, Int64)) +elementQueryDuration element = + alloca $ \formatPtr -> + alloca $ \durationPtr -> + do success <- {# call element_query_duration #} (toElement element) formatPtr durationPtr + if toBool success + then do format <- peek formatPtr + duration <- peek durationPtr + return $ Just (toEnum $ fromIntegral format, + fromIntegral duration) + else return Nothing + +elementSendEvent :: (ElementClass element, EventClass event) + => element + -> event + -> IO Bool +elementSendEvent element event = + liftM toBool $ + giveMiniObject (toEvent event) $ {# call element_send_event #} (toElement element) + +elementSeekSimple :: ElementClass element + => element + -> Format + -> [SeekFlags] + -> Int64 + -> IO Bool +elementSeekSimple element format seekFlags seekPos = + liftM toBool $ + {# call element_seek_simple #} (toElement element) + (fromIntegral $ fromEnum format) + (fromIntegral $ fromFlags seekFlags) + (fromIntegral seekPos) + +elementSeek :: ElementClass element + => element + -> Double + -> Format + -> [SeekFlags] + -> SeekType + -> Int64 + -> SeekType + -> Int64 + -> IO Bool +elementSeek element rate format flags curType cur stopType stop = + liftM toBool $ + {# call element_seek #} (toElement element) + (realToFrac rate) + (fromIntegral $ fromEnum format) + (fromIntegral $ fromFlags flags) + (fromIntegral $ fromEnum curType) + (fromIntegral cur) + (fromIntegral $ fromEnum stopType) + (fromIntegral stop) + +onElementNoMorePads, afterElementNoMorePads :: (ElementClass element) + => element + -> IO () + -> IO (ConnectId element) +onElementNoMorePads = + connect_NONE__NONE "no-more-pads" False +afterElementNoMorePads = + connect_NONE__NONE "no-more-pads" True + +onElementPadAdded, afterElementPadAdded :: (ElementClass element) + => element + -> (GObject -> IO ()) + -> IO (ConnectId element) +onElementPadAdded = + connect_OBJECT__NONE "pad-added" False +afterElementPadAdded = + connect_OBJECT__NONE "pad-added" True + +onElementPadRemoved, afterElementPadRemoved :: (ElementClass element) + => element + -> (GObject -> IO ()) + -> IO (ConnectId element) +onElementPadRemoved = + connect_OBJECT__NONE "pad-removed" False +afterElementPadRemoved = + connect_OBJECT__NONE "pad-removed" True addfile ./gstreamer/Media/Streaming/GStreamer/ElementFactory.chs hunk ./gstreamer/Media/Streaming/GStreamer/ElementFactory.chs 1 +-- GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*- +-- +-- Author : Peter Gavin... [truncated message content] |