From a967370df58163d7f5219a285a8331b3f79930a3 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sat, 13 Mar 2004 15:27:01 +0000 Subject: [PATCH] gst-indent run on core Original commit message from CVS: gst-indent run on core --- ChangeLog | 4 + .../bonobo-gstmediaplay/bonobo-gstmediaplay.c | 182 +- .../bonobo-media-gstreamer-factory.c | 52 +- docs/gst/tmpl/gst.sgml | 6 - docs/gst/tmpl/gstbin.sgml | 56 +- docs/gst/tmpl/gstclock.sgml | 30 +- docs/gst/tmpl/gstcpu.sgml | 10 - docs/gst/tmpl/gstelement.sgml | 106 +- docs/gst/tmpl/gstformat.sgml | 12 - docs/gst/tmpl/gstindex.sgml | 26 +- docs/gst/tmpl/gstmemchunk.sgml | 6 - docs/gst/tmpl/gstobject.sgml | 82 +- docs/gst/tmpl/gstpad.sgml | 5 + docs/gst/tmpl/gstpadtemplate.sgml | 18 +- docs/gst/tmpl/gstplugin.sgml | 8 - docs/gst/tmpl/gstquery.sgml | 18 +- docs/gst/tmpl/gstreamer-unused.sgml | 89 + docs/gst/tmpl/gstregistry.sgml | 11 - docs/gst/tmpl/gsttag.sgml | 14 - docs/gst/tmpl/gstthread.sgml | 18 +- docs/gst/tmpl/gstxml.sgml | 22 - docs/random/omega/testing/gstobject.c | 268 +-- examples/appreader/appreader.c | 18 +- examples/cutter/cutter.c | 116 +- examples/cutter/cutter.h | 4 +- examples/helloworld/helloworld.c | 6 +- examples/helloworld2/helloworld2.c | 38 +- examples/launch/mp3parselaunch.c | 12 +- examples/mixer/mixer.c | 234 ++- examples/mixer/mixer.h | 4 +- examples/pingpong/pingpong.c | 12 +- examples/plugins/example.c | 237 ++- examples/plugins/example.h | 14 +- examples/queue/queue.c | 46 +- examples/queue2/queue2.c | 70 +- examples/queue3/queue3.c | 62 +- examples/queue4/queue4.c | 74 +- examples/retag/retag.c | 23 +- examples/retag/transcode.c | 22 +- examples/thread/thread.c | 68 +- examples/typefind/typefind.c | 47 +- examples/xml/createxml.c | 32 +- examples/xml/runxml.c | 33 +- gst/autoplug/gstsearchfuncs.c | 321 ++-- gst/autoplug/gstsearchfuncs.h | 44 +- gst/autoplug/gstspider.c | 516 +++--- gst/autoplug/gstspider.h | 39 +- gst/autoplug/gstspideridentity.c | 377 ++-- gst/autoplug/gstspideridentity.h | 22 +- gst/autoplug/spidertest.c | 89 +- gst/cothreads.c | 210 ++- gst/cothreads.h | 72 +- gst/elements/gstaggregator.c | 163 +- gst/elements/gstaggregator.h | 23 +- gst/elements/gstbufferstore.c | 193 +- gst/elements/gstbufferstore.h | 42 +- gst/elements/gstelements.c | 65 +- gst/elements/gstfakesink.c | 212 ++- gst/elements/gstfakesink.h | 33 +- gst/elements/gstfakesrc.c | 369 ++-- gst/elements/gstfakesrc.h | 82 +- gst/elements/gstfdsink.c | 73 +- gst/elements/gstfdsink.h | 12 +- gst/elements/gstfdsrc.c | 116 +- gst/elements/gstfdsrc.h | 25 +- gst/elements/gstfilesink.c | 258 +-- gst/elements/gstfilesink.h | 21 +- gst/elements/gstfilesrc.c | 401 ++-- gst/elements/gstfilesrc.h | 37 +- gst/elements/gstidentity.c | 152 +- gst/elements/gstidentity.h | 42 +- gst/elements/gstmd5sink.c | 439 +++-- gst/elements/gstmd5sink.h | 18 +- gst/elements/gstmultifilesrc.c | 109 +- gst/elements/gstmultifilesrc.h | 27 +- gst/elements/gstpipefilter.c | 188 +- gst/elements/gstpipefilter.h | 27 +- gst/elements/gstshaper.c | 176 +- gst/elements/gstshaper.h | 29 +- gst/elements/gststatistics.c | 197 +- gst/elements/gststatistics.h | 19 +- gst/elements/gsttee.c | 134 +- gst/elements/gsttee.h | 20 +- gst/elements/gsttypefind.c | 409 +++-- gst/elements/gsttypefind.h | 44 +- gst/gst-i18n-app.h | 2 +- gst/gst-i18n-lib.h | 2 +- gst/gst.c | 352 ++-- gst/gst.h | 27 +- gst/gstarch.h | 39 +- gst/gstatomic.c | 1 - gst/gstatomic.h | 26 +- gst/gstatomic_impl.h | 459 ++--- gst/gstbin.c | 436 ++--- gst/gstbin.h | 88 +- gst/gstbuffer.c | 163 +- gst/gstbuffer.h | 63 +- gst/gstcaps.c | 443 ++--- gst/gstcaps.h | 116 +- gst/gstclock.c | 174 +- gst/gstclock.h | 170 +- gst/gstcompat.h | 10 +- gst/gstcpu.c | 16 +- gst/gstcpu.h | 18 +- gst/gstdata.c | 61 +- gst/gstdata.h | 53 +- gst/gstdata_private.h | 1 - gst/gstelement.c | 1636 +++++++++-------- gst/gstelement.h | 489 ++--- gst/gstelementfactory.c | 178 +- gst/gsterror.c | 163 +- gst/gsterror.h | 29 +- gst/gstevent.c | 66 +- gst/gstevent.h | 162 +- gst/gstfilter.c | 7 +- gst/gstfilter.h | 7 +- gst/gstformat.c | 44 +- gst/gstformat.h | 41 +- gst/gstindex.c | 342 ++-- gst/gstindex.h | 241 +-- gst/gstinfo.c | 451 ++--- gst/gstinfo.h | 341 ++-- gst/gstinterface.c | 41 +- gst/gstinterface.h | 21 +- gst/gstlog.h | 5 +- gst/gstmacros.h | 14 +- gst/gstmemchunk.c | 50 +- gst/gstmemchunk.h | 20 +- gst/gstobject.c | 319 ++-- gst/gstobject.h | 91 +- gst/gstpad.c | 1349 +++++++------- gst/gstpad.h | 441 ++--- gst/gstparse.c | 23 +- gst/gstparse.h | 14 +- gst/gstpipeline.c | 72 +- gst/gstpipeline.h | 16 +- gst/gstplugin.c | 309 ++-- gst/gstplugin.h | 115 +- gst/gstpluginfeature.c | 64 +- gst/gstpluginfeature.h | 56 +- gst/gstprobe.c | 56 +- gst/gstprobe.h | 61 +- gst/gstquery.c | 48 +- gst/gstquery.h | 30 +- gst/gstqueue.c | 689 ++++--- gst/gstqueue.h | 52 +- gst/gstregistry.c | 118 +- gst/gstregistry.h | 135 +- gst/gstregistrypool.c | 83 +- gst/gstregistrypool.h | 32 +- gst/gstscheduler.c | 217 +-- gst/gstscheduler.h | 174 +- gst/gststructure.c | 803 ++++---- gst/gststructure.h | 144 +- gst/gstsystemclock.c | 72 +- gst/gstsystemclock.h | 22 +- gst/gsttag.c | 436 +++-- gst/gsttag.h | 263 +-- gst/gsttaginterface.c | 82 +- gst/gsttaginterface.h | 49 +- gst/gsttaglist.c | 436 +++-- gst/gsttaglist.h | 263 +-- gst/gsttagsetter.c | 82 +- gst/gsttagsetter.h | 49 +- gst/gstthread.c | 281 +-- gst/gstthread.h | 41 +- gst/gstthreaddummy.c | 105 +- gst/gsttrace.c | 40 +- gst/gsttrace.h | 77 +- gst/gsttrashstack.c | 1 - gst/gsttrashstack.h | 103 +- gst/gsttypefind.c | 90 +- gst/gsttypefind.h | 92 +- gst/gsttypes.h | 30 +- gst/gsturi.c | 109 +- gst/gsturi.h | 61 +- gst/gsturitype.h | 4 +- gst/gstutils.c | 191 +- gst/gstutils.h | 14 +- gst/gstvalue.c | 579 +++--- gst/gstvalue.h | 86 +- gst/gstxml.c | 151 +- gst/gstxml.h | 38 +- gst/indexers/gstfileindex.c | 488 +++-- gst/indexers/gstindexers.c | 26 +- gst/indexers/gstmemindex.c | 199 +- gst/parse/types.h | 28 +- gst/registries/gstxmlregistry.c | 754 ++++---- gst/registries/gstxmlregistry.h | 118 +- gst/registries/registrytest.c | 8 +- gst/schedulers/cothreads_compat.h | 20 +- gst/schedulers/gstbasicscheduler.c | 593 +++--- gst/schedulers/gstoptimalscheduler.c | 1155 ++++++------ gst/schedulers/gthread-cothreads.h | 118 +- include/mmx.h | 266 ++- include/sse.h | 318 ++-- libs/gst/bytestream/bytestream.c | 197 +- libs/gst/bytestream/bytestream.h | 65 +- libs/gst/control/control.c | 13 +- libs/gst/control/control.h | 7 +- libs/gst/control/dparam.c | 469 ++--- libs/gst/control/dparam.h | 72 +- libs/gst/control/dparam_smooth.c | 731 ++++---- libs/gst/control/dparam_smooth.h | 49 +- libs/gst/control/dparamcommon.h | 5 +- libs/gst/control/dparammanager.c | 1371 +++++++------- libs/gst/control/dparammanager.h | 188 +- libs/gst/control/dplinearinterp.c | 67 +- libs/gst/control/dplinearinterp.h | 17 +- libs/gst/control/unitconvert.c | 628 ++++--- libs/gst/control/unitconvert.h | 52 +- libs/gst/getbits/gbtest.c | 116 +- libs/gst/getbits/getbits.c | 143 +- libs/gst/getbits/getbits.h | 35 +- libs/gst/getbits/gstgetbits_generic.c | 94 +- libs/gst/getbits/gstgetbits_inl.h | 2 +- plugins/elements/gstaggregator.c | 163 +- plugins/elements/gstaggregator.h | 23 +- plugins/elements/gstbufferstore.c | 193 +- plugins/elements/gstbufferstore.h | 42 +- plugins/elements/gstelements.c | 65 +- plugins/elements/gstfakesink.c | 212 ++- plugins/elements/gstfakesink.h | 33 +- plugins/elements/gstfakesrc.c | 369 ++-- plugins/elements/gstfakesrc.h | 82 +- plugins/elements/gstfdsink.c | 73 +- plugins/elements/gstfdsink.h | 12 +- plugins/elements/gstfdsrc.c | 116 +- plugins/elements/gstfdsrc.h | 25 +- plugins/elements/gstfilesink.c | 258 +-- plugins/elements/gstfilesink.h | 21 +- plugins/elements/gstfilesrc.c | 401 ++-- plugins/elements/gstfilesrc.h | 37 +- plugins/elements/gstidentity.c | 152 +- plugins/elements/gstidentity.h | 42 +- plugins/elements/gstmd5sink.c | 439 +++-- plugins/elements/gstmd5sink.h | 18 +- plugins/elements/gstmultifilesrc.c | 109 +- plugins/elements/gstmultifilesrc.h | 27 +- plugins/elements/gstpipefilter.c | 188 +- plugins/elements/gstpipefilter.h | 27 +- plugins/elements/gstqueue.c | 689 ++++--- plugins/elements/gstqueue.h | 52 +- plugins/elements/gstshaper.c | 176 +- plugins/elements/gstshaper.h | 29 +- plugins/elements/gststatistics.c | 197 +- plugins/elements/gststatistics.h | 19 +- plugins/elements/gsttee.c | 134 +- plugins/elements/gsttee.h | 20 +- plugins/elements/gsttypefind.c | 409 +++-- plugins/elements/gsttypefind.h | 44 +- plugins/indexers/gstfileindex.c | 488 +++-- plugins/indexers/gstindexers.c | 26 +- plugins/indexers/gstmemindex.c | 199 +- po/sr.po | 63 +- tests/bufspeed/gstmempool.c | 65 +- tests/bufspeed/gstmempool.h | 27 +- tests/bufspeed/test1.c | 6 +- tests/bufspeed/test2.c | 6 +- tests/instantiate/create.c | 5 +- tests/lat.c | 214 ++- tests/memchunk/gmemchunktest.c | 31 +- tests/memchunk/gstmemchunk.c | 70 +- tests/memchunk/gstmemchunk.h | 17 +- tests/memchunk/gstmemchunktest.c | 33 +- tests/muxing/case1.c | 27 +- tests/negotiation/capsnego1.c | 76 +- tests/old/examples/appreader/appreader.c | 18 +- tests/old/examples/cutter/cutter.c | 116 +- tests/old/examples/cutter/cutter.h | 4 +- tests/old/examples/helloworld/helloworld.c | 6 +- tests/old/examples/helloworld2/helloworld2.c | 38 +- tests/old/examples/launch/mp3parselaunch.c | 12 +- tests/old/examples/mixer/mixer.c | 234 ++- tests/old/examples/mixer/mixer.h | 4 +- tests/old/examples/pingpong/pingpong.c | 12 +- tests/old/examples/plugins/example.c | 237 ++- tests/old/examples/plugins/example.h | 14 +- tests/old/examples/queue/queue.c | 46 +- tests/old/examples/queue2/queue2.c | 70 +- tests/old/examples/queue3/queue3.c | 62 +- tests/old/examples/queue4/queue4.c | 74 +- tests/old/examples/retag/retag.c | 23 +- tests/old/examples/retag/transcode.c | 22 +- tests/old/examples/thread/thread.c | 68 +- tests/old/examples/typefind/typefind.c | 47 +- tests/old/examples/xml/createxml.c | 32 +- tests/old/examples/xml/runxml.c | 33 +- tests/old/testsuite/bins/interface.c | 19 +- tests/old/testsuite/bytestream/gstbstest.c | 169 +- tests/old/testsuite/bytestream/test1.c | 87 +- tests/old/testsuite/caps/app_fixate.c | 17 +- tests/old/testsuite/caps/caps.c | 221 +-- tests/old/testsuite/caps/compatibility.c | 79 +- tests/old/testsuite/caps/fixed.c | 17 +- tests/old/testsuite/caps/intersect2.c | 135 +- tests/old/testsuite/caps/intersection.c | 115 +- tests/old/testsuite/caps/normalisation.c | 56 +- tests/old/testsuite/caps/string-conversions.c | 120 +- tests/old/testsuite/caps/union.c | 23 +- tests/old/testsuite/caps/value_compare.c | 82 +- tests/old/testsuite/caps/value_intersect.c | 53 +- tests/old/testsuite/cleanup/cleanup1.c | 8 +- tests/old/testsuite/cleanup/cleanup2.c | 9 +- tests/old/testsuite/cleanup/cleanup3.c | 11 +- tests/old/testsuite/cleanup/cleanup4.c | 6 +- tests/old/testsuite/cleanup/cleanup5.c | 12 +- tests/old/testsuite/clock/clock1.c | 20 +- tests/old/testsuite/clock/clock2.c | 13 +- tests/old/testsuite/debug/category.c | 48 +- tests/old/testsuite/debug/commandline.c | 31 +- tests/old/testsuite/debug/global.c | 68 +- tests/old/testsuite/debug/output.c | 50 +- tests/old/testsuite/debug/printf_extension.c | 10 +- tests/old/testsuite/dynparams/dparamstest.c | 153 +- tests/old/testsuite/elements/fake.c | 29 +- tests/old/testsuite/elements/name.c | 8 +- tests/old/testsuite/elements/property.c | 51 +- tests/old/testsuite/elements/property.h | 10 +- tests/old/testsuite/elements/tee.c | 46 +- tests/old/testsuite/ghostpads/ghostpads.c | 22 +- tests/old/testsuite/indexers/cache1.c | 76 +- tests/old/testsuite/indexers/indexdump.c | 33 +- tests/old/testsuite/parse/parse1.c | 25 +- tests/old/testsuite/parse/parse2.c | 24 +- tests/old/testsuite/plugin/dynamic.c | 7 +- tests/old/testsuite/plugin/linked.c | 6 +- tests/old/testsuite/plugin/loading.c | 26 +- tests/old/testsuite/plugin/registry.c | 4 +- tests/old/testsuite/plugin/static.c | 7 +- tests/old/testsuite/plugin/static2.c | 44 +- tests/old/testsuite/plugin/testplugin.c | 18 +- tests/old/testsuite/plugin/testplugin2.c | 19 +- tests/old/testsuite/plugin/testplugin2_s.c | 20 +- tests/old/testsuite/plugin/testplugin_s.c | 19 +- tests/old/testsuite/refcounting/bin.c | 110 +- tests/old/testsuite/refcounting/element.c | 62 +- tests/old/testsuite/refcounting/element_pad.c | 48 +- tests/old/testsuite/refcounting/mainloop.c | 18 +- tests/old/testsuite/refcounting/mem.c | 24 +- tests/old/testsuite/refcounting/mem.h | 2 +- tests/old/testsuite/refcounting/object.c | 66 +- tests/old/testsuite/refcounting/pad.c | 71 +- tests/old/testsuite/refcounting/sched.c | 26 +- tests/old/testsuite/refcounting/thread.c | 107 +- tests/old/testsuite/states/locked.c | 15 +- tests/old/testsuite/tags/merge.c | 23 +- tests/old/testsuite/test_gst_init.c | 4 +- tests/old/testsuite/threads/queue.c | 27 +- tests/old/testsuite/threads/thread.c | 34 +- tests/old/testsuite/threads/threadb.c | 31 +- tests/old/testsuite/threads/threadc.c | 35 +- tests/old/testsuite/threads/threadd.c | 47 +- tests/old/testsuite/threads/threade.c | 25 +- tests/old/testsuite/threads/threadf.c | 18 +- tests/probes/probetest.c | 40 +- tests/sched/dynamic-pipeline.c | 105 +- tests/sched/interrupt1.c | 9 +- tests/sched/interrupt2.c | 9 +- tests/sched/interrupt3.c | 9 +- tests/sched/runxml.c | 49 +- tests/sched/sched-stress.c | 13 +- tests/seeking/seeking1.c | 44 +- tests/threadstate/test1.c | 20 +- tests/threadstate/test2.c | 20 +- tests/threadstate/threadstate1.c | 31 +- tests/threadstate/threadstate2.c | 18 +- tests/threadstate/threadstate3.c | 37 +- tests/threadstate/threadstate4.c | 44 +- tests/threadstate/threadstate5.c | 44 +- testsuite/bins/interface.c | 19 +- testsuite/bytestream/gstbstest.c | 169 +- testsuite/bytestream/test1.c | 87 +- testsuite/caps/app_fixate.c | 17 +- testsuite/caps/caps.c | 221 +-- testsuite/caps/compatibility.c | 79 +- testsuite/caps/fixed.c | 17 +- testsuite/caps/intersect2.c | 135 +- testsuite/caps/intersection.c | 115 +- testsuite/caps/normalisation.c | 56 +- testsuite/caps/string-conversions.c | 120 +- testsuite/caps/union.c | 23 +- testsuite/caps/value_compare.c | 82 +- testsuite/caps/value_intersect.c | 53 +- testsuite/cleanup/cleanup1.c | 8 +- testsuite/cleanup/cleanup2.c | 9 +- testsuite/cleanup/cleanup3.c | 11 +- testsuite/cleanup/cleanup4.c | 6 +- testsuite/cleanup/cleanup5.c | 12 +- testsuite/clock/clock1.c | 20 +- testsuite/clock/clock2.c | 13 +- testsuite/debug/category.c | 48 +- testsuite/debug/commandline.c | 31 +- testsuite/debug/global.c | 68 +- testsuite/debug/output.c | 50 +- testsuite/debug/printf_extension.c | 10 +- testsuite/dynparams/dparamstest.c | 153 +- testsuite/elements/fake.c | 29 +- testsuite/elements/name.c | 8 +- testsuite/elements/property.c | 51 +- testsuite/elements/property.h | 10 +- testsuite/elements/tee.c | 46 +- testsuite/ghostpads/ghostpads.c | 22 +- testsuite/indexers/cache1.c | 76 +- testsuite/indexers/indexdump.c | 33 +- testsuite/parse/parse1.c | 25 +- testsuite/parse/parse2.c | 24 +- testsuite/plugin/dynamic.c | 7 +- testsuite/plugin/linked.c | 6 +- testsuite/plugin/loading.c | 26 +- testsuite/plugin/registry.c | 4 +- testsuite/plugin/static.c | 7 +- testsuite/plugin/static2.c | 44 +- testsuite/plugin/testplugin.c | 18 +- testsuite/plugin/testplugin2.c | 19 +- testsuite/plugin/testplugin2_s.c | 20 +- testsuite/plugin/testplugin_s.c | 19 +- testsuite/refcounting/bin.c | 110 +- testsuite/refcounting/element.c | 62 +- testsuite/refcounting/element_pad.c | 48 +- testsuite/refcounting/mainloop.c | 18 +- testsuite/refcounting/mem.c | 24 +- testsuite/refcounting/mem.h | 2 +- testsuite/refcounting/object.c | 66 +- testsuite/refcounting/pad.c | 71 +- testsuite/refcounting/sched.c | 26 +- testsuite/refcounting/thread.c | 107 +- testsuite/states/locked.c | 15 +- testsuite/tags/merge.c | 23 +- testsuite/test_gst_init.c | 4 +- testsuite/threads/queue.c | 27 +- testsuite/threads/thread.c | 34 +- testsuite/threads/threadb.c | 31 +- testsuite/threads/threadc.c | 35 +- testsuite/threads/threadd.c | 47 +- testsuite/threads/threade.c | 25 +- testsuite/threads/threadf.c | 18 +- tools/gst-complete.c | 166 +- tools/gst-compprep.c | 115 +- tools/gst-inspect.c | 740 ++++---- tools/gst-launch.c | 212 ++- tools/gst-md5sum.c | 63 +- tools/gst-register.c | 74 +- tools/gst-run.c | 216 +-- tools/gst-typefind.c | 16 +- tools/gst-xmlinspect.c | 635 +++---- 446 files changed, 24680 insertions(+), 24206 deletions(-) diff --git a/ChangeLog b/ChangeLog index dfb635d44..196972c1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-03-13 Thomas Vander Stichele + + * *.c, *.h: commit of gst-indent run on core + 2004-03-13 Thomas Vander Stichele * tools/gst-indent: diff --git a/components/bonobo-gstmediaplay/bonobo-gstmediaplay.c b/components/bonobo-gstmediaplay/bonobo-gstmediaplay.c index d7e5026b9..4d7610eac 100644 --- a/components/bonobo-gstmediaplay/bonobo-gstmediaplay.c +++ b/components/bonobo-gstmediaplay/bonobo-gstmediaplay.c @@ -38,11 +38,12 @@ static BonoboGenericFactory *factory = NULL; /* * BonoboControl data */ -typedef struct { - BonoboControl *bonobo_object; - BonoboUIComponent *uic; +typedef struct +{ + BonoboControl *bonobo_object; + BonoboUIComponent *uic; - GstPlay *play; + GstPlay *play; } control_data_t; /* @@ -50,20 +51,20 @@ typedef struct { * encounters a fatal CORBA exception. */ static void -control_system_exception_cb (BonoboControl *control, CORBA_Object corba_object, - CORBA_Environment *ev, gpointer data) +control_system_exception_cb (BonoboControl * control, CORBA_Object corba_object, + CORBA_Environment * ev, gpointer data) { bonobo_object_unref (BONOBO_OBJECT (control)); } static void -control_update (control_data_t *control_data) +control_update (control_data_t * control_data) { gtk_widget_queue_draw (GTK_WIDGET (control_data->play)); } static void -verb_Play_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) +verb_Play_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname) { control_data_t *control_data = (control_data_t *) user_data; @@ -72,7 +73,7 @@ verb_Play_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) } static void -verb_Pause_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) +verb_Pause_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname) { control_data_t *control_data = (control_data_t *) user_data; @@ -81,7 +82,7 @@ verb_Pause_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) } static void -verb_Stop_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) +verb_Stop_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname) { control_data_t *control_data = (control_data_t *) user_data; @@ -89,51 +90,53 @@ verb_Stop_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) control_update (control_data); } -typedef struct { +typedef struct +{ control_data_t *control_data; GtkFileSelection *selector; } file_select_struct; - -static void -filename_selected (GtkButton *ok, gpointer user_data) + +static void +filename_selected (GtkButton * ok, gpointer user_data) { file_select_struct *select = (file_select_struct *) user_data; gchar *selected_filename; - - selected_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION(select->selector)); + + selected_filename = + gtk_file_selection_get_filename (GTK_FILE_SELECTION (select->selector)); gst_play_set_uri (select->control_data->play, selected_filename); gst_play_play (select->control_data->play); control_update (select->control_data); - g_free(select); + g_free (select); } static void -verb_Open_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) +verb_Open_cb (BonoboUIComponent * uic, gpointer user_data, const char *cname) { control_data_t *control_data = (control_data_t *) user_data; - file_select_struct *data = g_new0(file_select_struct, 1); + file_select_struct *data = g_new0 (file_select_struct, 1); GtkWidget *file_selector; - file_selector = gtk_file_selection_new("Select a media file"); - + file_selector = gtk_file_selection_new ("Select a media file"); + data->selector = GTK_FILE_SELECTION (file_selector); data->control_data = control_data; - - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button), - "clicked", GTK_SIGNAL_FUNC (filename_selected), data); - - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->ok_button), - "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) file_selector); - - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION(file_selector)->cancel_button), - "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), - (gpointer) file_selector); - + + gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)-> + ok_button), "clicked", GTK_SIGNAL_FUNC (filename_selected), data); + + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)-> + ok_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) file_selector); + + gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (file_selector)-> + cancel_button), "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), + (gpointer) file_selector); + gtk_widget_show (file_selector); } @@ -142,37 +145,36 @@ verb_Open_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) * in with our container's menus. */ static void -control_create_menus (control_data_t *control_data) +control_create_menus (control_data_t * control_data) { BonoboControl *control = control_data->bonobo_object; Bonobo_UIContainer remote_uic; GdkPixbuf *pixbuf; - static char ui [] = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - ""; - - g_print("create menu\n"); + static char ui[] = + "" + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " ""; + + g_print ("create menu\n"); /* * Get our container's UIContainer server. */ @@ -206,8 +208,8 @@ control_create_menus (control_data_t *control_data) node = bonobo_ui_node_from_string (ui); bonobo_ui_util_translate_ui (node); bonobo_ui_util_fixup_help (control_data->uic, node, - DATADIR, "gstmediaplay"); - + DATADIR, "gstmediaplay"); + bonobo_ui_component_set_tree (control_data->uic, "/", node, NULL); bonobo_ui_node_free (node); @@ -225,11 +227,11 @@ control_create_menus (control_data_t *control_data) bonobo_ui_util_set_pixbuf (control_data->uic, "/commands/Stop", pixbuf); gdk_pixbuf_unref (pixbuf); - g_print("create menu done\n"); + g_print ("create menu done\n"); } static void -control_remove_menus (control_data_t *control_data) +control_remove_menus (control_data_t * control_data) { bonobo_ui_component_unset_container (control_data->uic); } @@ -238,18 +240,18 @@ control_remove_menus (control_data_t *control_data) * Clean up our supplementary BonoboControl data sturctures. */ static void -control_destroy_cb (BonoboControl *control, gpointer data) +control_destroy_cb (BonoboControl * control, gpointer data) { control_data_t *control_data = (control_data_t *) data; control_data->play = NULL; - - g_free (control_data); + + g_free (control_data); running_objects--; if (running_objects > 0) return; - + /* * When the last object has gone, unref the factory & quit. */ @@ -258,7 +260,7 @@ control_destroy_cb (BonoboControl *control, gpointer data) } static void -control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) +control_activate_cb (BonoboControl * control, gboolean activate, gpointer data) { control_data_t *control_data = (control_data_t *) data; @@ -284,17 +286,17 @@ control_activate_cb (BonoboControl *control, gboolean activate, gpointer data) } static void -control_set_frame_cb (BonoboControl *control, gpointer data) +control_set_frame_cb (BonoboControl * control, gpointer data) { control_create_menus ((control_data_t *) data); } static BonoboObject * -bonobo_gstmediaplay_factory (BonoboGenericFactory *this, void *data) +bonobo_gstmediaplay_factory (BonoboGenericFactory * this, void *data) { - BonoboControl *bonobo_object; - control_data_t *control_data; - GtkWidget *vbox; + BonoboControl *bonobo_object; + control_data_t *control_data; + GtkWidget *vbox; gst_init (NULL, NULL); /* @@ -311,7 +313,7 @@ bonobo_gstmediaplay_factory (BonoboGenericFactory *this, void *data) vbox = gtk_vbox_new (TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (control_data->play), - TRUE, TRUE, 0); + TRUE, TRUE, 0); gtk_widget_show_all (vbox); gst_play_set_uri (control_data->play, "/opt/data/armageddon1.mpg"); @@ -337,39 +339,39 @@ bonobo_gstmediaplay_factory (BonoboGenericFactory *this, void *data) * the "activate" signal. */ gtk_signal_connect (GTK_OBJECT (bonobo_object), "activate", - GTK_SIGNAL_FUNC (control_activate_cb), control_data); + GTK_SIGNAL_FUNC (control_activate_cb), control_data); gtk_signal_connect (GTK_OBJECT (bonobo_object), "set_frame", - GTK_SIGNAL_FUNC (control_set_frame_cb), control_data); + GTK_SIGNAL_FUNC (control_set_frame_cb), control_data); /* * The "system_exception" signal is raised when the BonoboControl * encounters a fatal CORBA exception. */ gtk_signal_connect (GTK_OBJECT (bonobo_object), "system_exception", - GTK_SIGNAL_FUNC (control_system_exception_cb), control_data); + GTK_SIGNAL_FUNC (control_system_exception_cb), control_data); /* * We'll need to be able to cleanup when this control gets * destroyed. */ gtk_signal_connect (GTK_OBJECT (bonobo_object), "destroy", - GTK_SIGNAL_FUNC (control_destroy_cb), control_data); + GTK_SIGNAL_FUNC (control_destroy_cb), control_data); bonobo_ui_component_add_verb (control_data->uic, "Play", - verb_Play_cb, control_data); + verb_Play_cb, control_data); bonobo_ui_component_add_verb (control_data->uic, "Pause", - verb_Pause_cb, control_data); + verb_Pause_cb, control_data); bonobo_ui_component_add_verb (control_data->uic, "Stop", - verb_Stop_cb, control_data); + verb_Stop_cb, control_data); bonobo_ui_component_add_verb (control_data->uic, "Open", - verb_Open_cb, control_data); + verb_Open_cb, control_data); /* * Count the new running object */ running_objects++; - g_print("running objects: %d\n", running_objects); + g_print ("running objects: %d\n", running_objects); return BONOBO_OBJECT (bonobo_object); } @@ -377,9 +379,10 @@ bonobo_gstmediaplay_factory (BonoboGenericFactory *this, void *data) static void init_gstmediaplay_factory (void) { - factory = bonobo_generic_factory_new ( - "OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18", - bonobo_gstmediaplay_factory, NULL); + factory = + bonobo_generic_factory_new + ("OAFIID:bonobo_gstmediaplay_factory:420f20ca-55d7-4a33-b327-0b246136db18", + bonobo_gstmediaplay_factory, NULL); } static void @@ -393,9 +396,8 @@ init_server_factory (int argc, char **argv) CORBA_exception_init (&ev); - gnome_init_with_popt_table("bonobo-gstmediaplay", VERSION, - argc, argv, - oaf_popt_options, 0, NULL); + gnome_init_with_popt_table ("bonobo-gstmediaplay", VERSION, + argc, argv, oaf_popt_options, 0, NULL); orb = oaf_init (argc, argv); if (bonobo_init (orb, NULL, NULL) == FALSE) @@ -403,7 +405,7 @@ init_server_factory (int argc, char **argv) CORBA_exception_free (&ev); } - + int main (int argc, char **argv) { diff --git a/components/bonobo-media/bonobo-media-gstreamer-factory.c b/components/bonobo-media/bonobo-media-gstreamer-factory.c index e2eb3dbc2..c18b78080 100644 --- a/components/bonobo-media/bonobo-media-gstreamer-factory.c +++ b/components/bonobo-media/bonobo-media-gstreamer-factory.c @@ -27,48 +27,48 @@ #include #include -static BonoboObject* gstreamer_factory (BonoboGenericFactory *factory, - gpointer user_data) +static BonoboObject * +gstreamer_factory (BonoboGenericFactory * factory, gpointer user_data) { - return BONOBO_OBJECT (bonobo_media_gstreamer_new ()); + return BONOBO_OBJECT (bonobo_media_gstreamer_new ()); } -static void init_bonobo (int argc, char **argv) +static void +init_bonobo (int argc, char **argv) { - CORBA_ORB orb; + CORBA_ORB orb; - gnome_init_with_popt_table ("bonobo-media-gstreamer", VERSION, - argc, argv, - oaf_popt_options, 0, NULL); + gnome_init_with_popt_table ("bonobo-media-gstreamer", VERSION, + argc, argv, oaf_popt_options, 0, NULL); - orb = oaf_init (argc, argv); + orb = oaf_init (argc, argv); - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error ("Could not initialize Bonobo"); + if (bonobo_init (orb, NULL, NULL) == FALSE) + g_error ("Could not initialize Bonobo"); } -static void last_unref_cb (BonoboObject *bonobo_object, - BonoboGenericFactory *factory) +static void +last_unref_cb (BonoboObject * bonobo_object, BonoboGenericFactory * factory) { - bonobo_object_unref (BONOBO_OBJECT (factory)); - gtk_main_quit (); + bonobo_object_unref (BONOBO_OBJECT (factory)); + gtk_main_quit (); } -int main (int argc, char **argv) +int +main (int argc, char **argv) { - BonoboGenericFactory *factory; + BonoboGenericFactory *factory; - gst_init (&argc, &argv); - init_bonobo (argc, argv); + gst_init (&argc, &argv); + init_bonobo (argc, argv); - factory = bonobo_generic_factory_new ( - "OAFIID:Bonobo_Media_GStreamer_Factory", - gstreamer_factory, NULL); + factory = bonobo_generic_factory_new ("OAFIID:Bonobo_Media_GStreamer_Factory", + gstreamer_factory, NULL); - gtk_signal_connect (GTK_OBJECT (bonobo_context_running_get ()), "last_unref", - GTK_SIGNAL_FUNC (last_unref_cb), factory); + gtk_signal_connect (GTK_OBJECT (bonobo_context_running_get ()), "last_unref", + GTK_SIGNAL_FUNC (last_unref_cb), factory); - bonobo_main (); + bonobo_main (); - return 0; + return 0; } diff --git a/docs/gst/tmpl/gst.sgml b/docs/gst/tmpl/gst.sgml index 46383192d..c69075193 100644 --- a/docs/gst/tmpl/gst.sgml +++ b/docs/gst/tmpl/gst.sgml @@ -174,12 +174,6 @@ pipeline and Microsoft's DirectShow for some background. @use_threads: - - -The variable that holds the GStreamer log domain - - - The major version of GStreamer at compile time diff --git a/docs/gst/tmpl/gstbin.sgml b/docs/gst/tmpl/gstbin.sgml index 68c62da4b..8a0038e0b 100644 --- a/docs/gst/tmpl/gstbin.sgml +++ b/docs/gst/tmpl/gstbin.sgml @@ -72,6 +72,34 @@ The GstBin object + + + + + +@gstbin: the object which received the signal. +@arg1: the element that was added to the bin + + + + + + +@gstbin: the object which received the signal. +@arg1: the element that was removed from the bin + + + +This signal is emitted when a bin iterates, either automatically or +due to a #gst_bin_iterate() call. The return value is used to +determine if the object method handler processed any data. +In most normal cases, a user-provided signal handler should return +FALSE. + + +@gstbin: the object which received the signal. +@Returns: TRUE if the state of the bin was advanced. + The signature of the callback for the post and pre iterate function as set with @@ -224,31 +252,3 @@ gst_bin_set_pre_iterate_function() and gst_bin_set_post_iterate_function(). @clock: - - - - - -@gstbin: the object which received the signal. -@arg1: the element that was added to the bin - - - - - - -@gstbin: the object which received the signal. -@arg1: the element that was removed from the bin - - - -This signal is emitted when a bin iterates, either automatically or -due to a #gst_bin_iterate() call. The return value is used to -determine if the object method handler processed any data. -In most normal cases, a user-provided signal handler should return -FALSE. - - -@gstbin: the object which received the signal. -@Returns: TRUE if the state of the bin was advanced. - diff --git a/docs/gst/tmpl/gstclock.sgml b/docs/gst/tmpl/gstclock.sgml index 998e6b907..ae99e7a9c 100644 --- a/docs/gst/tmpl/gstclock.sgml +++ b/docs/gst/tmpl/gstclock.sgml @@ -235,6 +235,21 @@ Get the clock flags + + + + + + + +Maximum allowed diff for clock sync requests against the real time. + + + + +Boolean property to activate stat generation on the clock. + + @@ -402,18 +417,3 @@ Get the clock flags @id: - - - - - - - -Maximum allowed diff for clock sync requests against the real time. - - - - -Boolean property to activate stat generation on the clock. - - diff --git a/docs/gst/tmpl/gstcpu.sgml b/docs/gst/tmpl/gstcpu.sgml index d04c68278..c1b8f9bce 100644 --- a/docs/gst/tmpl/gstcpu.sgml +++ b/docs/gst/tmpl/gstcpu.sgml @@ -20,16 +20,6 @@ You'll get a bitmask of flags with gst_cpu_get_flags(). - - -Flags that represent cpu capabilities - - -@GST_CPU_FLAG_MMX: The cpu is mmx enabled -@GST_CPU_FLAG_SSE: The cpu is sse enabled -@GST_CPU_FLAG_MMXEXT: The cpu has extended mmx instructions -@GST_CPU_FLAG_3DNOW: The cpu is 3DNOW enabled - Request a set of bits specifiying the features of the CPU. diff --git a/docs/gst/tmpl/gstelement.sgml b/docs/gst/tmpl/gstelement.sgml index 4b966d915..358c35169 100644 --- a/docs/gst/tmpl/gstelement.sgml +++ b/docs/gst/tmpl/gstelement.sgml @@ -71,6 +71,59 @@ The element object + + +Signal emited when the element goes to PAUSED due to an end-of-stream +condition. + + +@gstelement: the object which received the signal. + + + +This signal is emitted when an element has encountered an error that caused +it to fail performing its function. + + +@gstelement: the object which received the signal. +@arg1: the original #GstElement that generated the error. +@arg2: a #GError containing the translated error message. +@arg3: a debug string providing additional untranslated debug information, or NULL. + + + + + + +@gstelement: the object which received the signal. +@arg1: +@arg2: + + + +Is triggered whenever a new pad is added to an element. + + +@gstelement: the object which received the signal. +@arg1: the new pad that was added + + + +Is triggered whenever a pad has been removed from the element. + + +@gstelement: the object which received the signal. +@arg1: The pad that was removed. + + + +Is triggered whenever the state of an element changes. + + +@gstelement: the object which received the signal. +@arg1: the new state of the object +@arg2: + Gets the name of the element. @@ -966,56 +1019,3 @@ Helper macro to create query type functions @...: list of query types. - - -Signal emited when the element goes to PAUSED due to an end-of-stream -condition. - - -@gstelement: the object which received the signal. - - - -This signal is emitted when an element has encountered an error that caused -it to fail performing its function. - - -@gstelement: the object which received the signal. -@arg1: the original #GstElement that generated the error. -@arg2: a #GError containing the translated error message. -@arg3: a debug string providing additional untranslated debug information, or NULL. - - - - - - -@gstelement: the object which received the signal. -@arg1: -@arg2: - - - -Is triggered whenever a new pad is added to an element. - - -@gstelement: the object which received the signal. -@arg1: the new pad that was added - - - -Is triggered whenever a pad has been removed from the element. - - -@gstelement: the object which received the signal. -@arg1: The pad that was removed. - - - -Is triggered whenever the state of an element changes. - - -@gstelement: the object which received the signal. -@arg1: the new state of the object -@arg2: - diff --git a/docs/gst/tmpl/gstformat.sgml b/docs/gst/tmpl/gstformat.sgml index 6b21fedbd..8cc1a1060 100644 --- a/docs/gst/tmpl/gstformat.sgml +++ b/docs/gst/tmpl/gstformat.sgml @@ -15,18 +15,6 @@ formats can be used to perform seeking or conversions/query operations. #GstPad, #GstElement - - -Standard predefined formats - - -@GST_FORMAT_UNDEFINED: undefined format -@GST_FORMAT_DEFAULT: the default format of the pad/element -@GST_FORMAT_BYTES: bytes -@GST_FORMAT_TIME: time in nanoseconds -@GST_FORMAT_BUFFERS: buffers -@GST_FORMAT_PERCENT: percentage of stream - The PERCENT format is between 0 and this value diff --git a/docs/gst/tmpl/gstindex.sgml b/docs/gst/tmpl/gstindex.sgml index d828fa311..cdc3cfa10 100644 --- a/docs/gst/tmpl/gstindex.sgml +++ b/docs/gst/tmpl/gstindex.sgml @@ -209,6 +209,19 @@ The GstIndex object + + +Is emited when a new entry is added to the index. + + +@gstindex: the object which received the signal. +@arg1: The entry added to the index. + + + + + + @@ -401,16 +414,3 @@ The GstIndex object @id: - - -Is emited when a new entry is added to the index. - - -@gstindex: the object which received the signal. -@arg1: The entry added to the index. - - - - - - diff --git a/docs/gst/tmpl/gstmemchunk.sgml b/docs/gst/tmpl/gstmemchunk.sgml index 1d3bd10d6..02ed6a225 100644 --- a/docs/gst/tmpl/gstmemchunk.sgml +++ b/docs/gst/tmpl/gstmemchunk.sgml @@ -21,12 +21,6 @@ The GstMemChunk is used to allocate critical resources for #GstBuffer and #GstAtomic, #GstBuffer, #GstEvent, #GstData - - -The memchunk structure - - - diff --git a/docs/gst/tmpl/gstobject.sgml b/docs/gst/tmpl/gstobject.sgml index 52616a221..cf69ab93e 100644 --- a/docs/gst/tmpl/gstobject.sgml +++ b/docs/gst/tmpl/gstobject.sgml @@ -40,6 +40,47 @@ The GstObject + + +The deep notify signal is used to be notified of property changes. +it is typically attached to the toplevel bin to receive notifications +from all the elements contained in that bin. + + +@gstobject: the object which received the signal. +@arg1: the object that originated the signal +@arg2: the property that changed + + + +Is trigered whenever a new object is saved to XML. You can connect to +this signal to insert custom XML tags into the core XML. + + +@gstobject: the object which received the signal. +@arg1: the xmlNodePtr of the parent node + + + +Is emitted when the parent of an object is set. + + +@gstobject: the object which received the signal. +@arg1: the new parent + + + +Is emitted when the parent of an object is unset. + + +@gstobject: the object which received the signal. +@arg1: the old parent + + + +The name of the object + + This macro returns the entire set of flags for the object. @@ -290,44 +331,3 @@ Check if the object has been destroyed. @Returns: - - -The deep notify signal is used to be notified of property changes. -it is typically attached to the toplevel bin to receive notifications -from all the elements contained in that bin. - - -@gstobject: the object which received the signal. -@arg1: the object that originated the signal -@arg2: the property that changed - - - -Is trigered whenever a new object is saved to XML. You can connect to -this signal to insert custom XML tags into the core XML. - - -@gstobject: the object which received the signal. -@arg1: the xmlNodePtr of the parent node - - - -Is emitted when the parent of an object is set. - - -@gstobject: the object which received the signal. -@arg1: the new parent - - - -Is emitted when the parent of an object is unset. - - -@gstobject: the object which received the signal. -@arg1: the old parent - - - -The name of the object - - diff --git a/docs/gst/tmpl/gstpad.sgml b/docs/gst/tmpl/gstpad.sgml index 4d043c8f7..3316ea671 100644 --- a/docs/gst/tmpl/gstpad.sgml +++ b/docs/gst/tmpl/gstpad.sgml @@ -1193,6 +1193,11 @@ The Ghostpad object + + + + + diff --git a/docs/gst/tmpl/gstpadtemplate.sgml b/docs/gst/tmpl/gstpadtemplate.sgml index 0955989f1..1b78afa85 100644 --- a/docs/gst/tmpl/gstpadtemplate.sgml +++ b/docs/gst/tmpl/gstpadtemplate.sgml @@ -86,6 +86,15 @@ The padtemplate object. + + +This signal is fired when an element creates a pad from this +template. + + +@gstpadtemplate: the object which received the signal. +@arg1: The pad that was created. + Flags for the padtemplate @@ -167,12 +176,3 @@ Check if the properties of the padtemplate are fixed @Returns: - - -This signal is fired when an element creates a pad from this -template. - - -@gstpadtemplate: the object which received the signal. -@arg1: The pad that was created. - diff --git a/docs/gst/tmpl/gstplugin.sgml b/docs/gst/tmpl/gstplugin.sgml index e265e785b..4ce971d73 100644 --- a/docs/gst/tmpl/gstplugin.sgml +++ b/docs/gst/tmpl/gstplugin.sgml @@ -41,14 +41,6 @@ The error quark - - -Get the error quark - - -@Returns: The error quark used in GError messages - - The plugin loading errors diff --git a/docs/gst/tmpl/gstquery.sgml b/docs/gst/tmpl/gstquery.sgml index 07925836c..4baa8c06b 100644 --- a/docs/gst/tmpl/gstquery.sgml +++ b/docs/gst/tmpl/gstquery.sgml @@ -15,20 +15,6 @@ Query types can be used to perform queries on pads and elements. #GstPad, #GstElement - - -Standard predefined Query types - - -@GST_QUERY_NONE: invalid query type -@GST_QUERY_TOTAL: total length of stream -@GST_QUERY_POSITION: current position in stream -@GST_QUERY_LATENCY: latency of stream -@GST_QUERY_JITTER: current jitter of stream -@GST_QUERY_START: start of configured segment -@GST_QUERY_SEGMENT_END: end of configured segment -@GST_QUERY_RATE: current rate of the stream - Rates are relative to this value @@ -89,8 +75,10 @@ Convenience function to define a function that returns an array of query types. -@type: +@Param1: @Returns: + +@type: diff --git a/docs/gst/tmpl/gstreamer-unused.sgml b/docs/gst/tmpl/gstreamer-unused.sgml index 238b6fe1e..238d21915 100644 --- a/docs/gst/tmpl/gstreamer-unused.sgml +++ b/docs/gst/tmpl/gstreamer-unused.sgml @@ -4556,6 +4556,16 @@ can perform necessary cleanup. @pool: The pool that is being destroyed @user_data: user data as set on th bufferpool + + +Flags that represent cpu capabilities + + +@GST_CPU_FLAG_MMX: The cpu is mmx enabled +@GST_CPU_FLAG_SSE: The cpu is sse enabled +@GST_CPU_FLAG_MMXEXT: The cpu has extended mmx instructions +@GST_CPU_FLAG_3DNOW: The cpu is 3DNOW enabled + @@ -5158,6 +5168,18 @@ Indicates the mmapped area should be touched to bring it into memory. + + +Standard predefined formats + + +@GST_FORMAT_UNDEFINED: undefined format +@GST_FORMAT_DEFAULT: the default format of the pad/element +@GST_FORMAT_BYTES: bytes +@GST_FORMAT_TIME: time in nanoseconds +@GST_FORMAT_BUFFERS: buffers +@GST_FORMAT_PERCENT: percentage of stream + @@ -5275,6 +5297,12 @@ Specify the location of the file. The location must be a fully qualified URL. + + +The memchunk structure + + + An entry in the memchunk area @@ -5505,6 +5533,20 @@ Sets the command to be executed. + + +Standard predefined Query types + + +@GST_QUERY_NONE: invalid query type +@GST_QUERY_TOTAL: total length of stream +@GST_QUERY_POSITION: current position in stream +@GST_QUERY_LATENCY: latency of stream +@GST_QUERY_JITTER: current jitter of stream +@GST_QUERY_START: start of configured segment +@GST_QUERY_SEGMENT_END: end of configured segment +@GST_QUERY_RATE: current rate of the stream + @@ -5571,6 +5613,17 @@ the region types for #gst_pad_pullregion. @global_reg: @local_reg: + + +The return value of registry operations + + +@GST_REGISTRY_OK: The registry reported no error. +@GST_REGISTRY_LOAD_ERROR: There was a load error +@GST_REGISTRY_SAVE_ERROR: There was an error saving the registry +@GST_REGISTRY_PLUGIN_LOAD_ERROR: There was an error loading a plugin +@GST_REGISTRY_PLUGIN_SIGNATURE_ERROR: There was an error saving a plugin + @@ -5798,6 +5851,20 @@ Flags for the GstSrc element + + + + + +@GST_TAG_MERGE_UNDEFINED: +@GST_TAG_MERGE_REPLACE_ALL: +@GST_TAG_MERGE_REPLACE: +@GST_TAG_MERGE_APPEND: +@GST_TAG_MERGE_PREPEND: +@GST_TAG_MERGE_KEEP: +@GST_TAG_MERGE_KEEP_ALL: +@GST_TAG_MERGE_COUNT: + @@ -5921,6 +5988,15 @@ Query the element for the current mime type + + + + + +@gstxml: the object which received the signal. +@arg1: +@arg2: + @@ -6676,6 +6752,12 @@ must be defined to activate the tracing functionality. @llink: @Returns: + + +The variable that holds the GStreamer log domain + + + @@ -9561,6 +9643,13 @@ Destroys the pipeline. @Returns: + + +Get the error quark + + +@Returns: The error quark used in GError messages + diff --git a/docs/gst/tmpl/gstregistry.sgml b/docs/gst/tmpl/gstregistry.sgml index 8a58d32b3..34d263c91 100644 --- a/docs/gst/tmpl/gstregistry.sgml +++ b/docs/gst/tmpl/gstregistry.sgml @@ -14,17 +14,6 @@ The registry holds the available plugins in the system. #GstPlugin, #GstPluginFeature - - -The return value of registry operations - - -@GST_REGISTRY_OK: The registry reported no error. -@GST_REGISTRY_LOAD_ERROR: There was a load error -@GST_REGISTRY_SAVE_ERROR: There was an error saving the registry -@GST_REGISTRY_PLUGIN_LOAD_ERROR: There was an error loading a plugin -@GST_REGISTRY_PLUGIN_SIGNATURE_ERROR: There was an error saving a plugin - Flags for the registry diff --git a/docs/gst/tmpl/gsttag.sgml b/docs/gst/tmpl/gsttag.sgml index 568ed82e6..e8c22e79c 100644 --- a/docs/gst/tmpl/gsttag.sgml +++ b/docs/gst/tmpl/gsttag.sgml @@ -14,20 +14,6 @@ GstTag - - - - - -@GST_TAG_MERGE_UNDEFINED: -@GST_TAG_MERGE_REPLACE_ALL: -@GST_TAG_MERGE_REPLACE: -@GST_TAG_MERGE_APPEND: -@GST_TAG_MERGE_PREPEND: -@GST_TAG_MERGE_KEEP: -@GST_TAG_MERGE_KEEP_ALL: -@GST_TAG_MERGE_COUNT: - diff --git a/docs/gst/tmpl/gstthread.sgml b/docs/gst/tmpl/gstthread.sgml index 6d7021906..38a7691b0 100644 --- a/docs/gst/tmpl/gstthread.sgml +++ b/docs/gst/tmpl/gstthread.sgml @@ -34,15 +34,6 @@ The GstThread object - - - - - -@name: -@Returns: - - @@ -55,3 +46,12 @@ The GstThread object The thread priority + + + + + +@name: +@Returns: + + diff --git a/docs/gst/tmpl/gstxml.sgml b/docs/gst/tmpl/gstxml.sgml index 08450b21b..ea4e4bd24 100644 --- a/docs/gst/tmpl/gstxml.sgml +++ b/docs/gst/tmpl/gstxml.sgml @@ -105,25 +105,3 @@ All GstElements can be serialized to an XML presentation and subsequently loaded @Returns: - - - - - -@: -@: -@: - -@gstxml: the object which received the signal. -@arg1: -@arg2: - - - - - - -@gstxml: the object which received the signal. -@arg1: -@arg2: - diff --git a/docs/random/omega/testing/gstobject.c b/docs/random/omega/testing/gstobject.c index c179ebc7d..41f11b82d 100644 --- a/docs/random/omega/testing/gstobject.c +++ b/docs/random/omega/testing/gstobject.c @@ -3,13 +3,16 @@ static gchar *_subject, *_category; static gint _testnum = 0; static gboolean _passed; -static gint _total_tests = 0,_passed_tests = 0; +static gint _total_tests = 0, _passed_tests = 0; static gint _random_size; -void tabpad(gchar *str,gint width) { +void +tabpad (gchar * str, gint width) +{ int i; - for (i=0;irefcount == 1); - ASSERT(GTK_OBJECT_FLOATING(object) == TRUE); + ASSERT (object->refcount == 1); + ASSERT (GTK_OBJECT_FLOATING (object) == TRUE); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("increment refcount"); + TEST ("increment refcount"); /* setup */ /* action */ - gst_object_ref(object); + gst_object_ref (object); /* assertions */ - ASSERT(object->refcount == 2); - ASSERT(GTK_OBJECT_FLOATING(object) == TRUE); + ASSERT (object->refcount == 2); + ASSERT (GTK_OBJECT_FLOATING (object) == TRUE); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("sink object"); + TEST ("sink object"); /* setup */ /* action */ - gst_object_sink(object); + gst_object_sink (object); /* assertions */ - ASSERT(object->refcount == 1); - ASSERT(GTK_OBJECT_FLOATING(object) == FALSE); + ASSERT (object->refcount == 1); + ASSERT (GTK_OBJECT_FLOATING (object) == FALSE); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("increment refcount after sink"); + TEST ("increment refcount after sink"); /* setup */ /* action */ - gst_object_ref(object); + gst_object_ref (object); /* assertions */ - ASSERT(object->refcount == 2); - ASSERT(GTK_OBJECT_FLOATING(object) == FALSE); + ASSERT (object->refcount == 2); + ASSERT (GTK_OBJECT_FLOATING (object) == FALSE); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("decrement refcount after sink"); + TEST ("decrement refcount after sink"); /* setup */ /* action */ - gst_object_unref(object); + gst_object_unref (object); /* assertions */ - ASSERT(object->refcount == 1); - ASSERT(GTK_OBJECT_FLOATING(object) == FALSE); + ASSERT (object->refcount == 1); + ASSERT (GTK_OBJECT_FLOATING (object) == FALSE); /* cleanup */ - ENDTEST(); + ENDTEST (); /* category cleanup */ - g_free(object); + g_free (object); /* new category */ - TEST_CATEGORY("Parentage"); + TEST_CATEGORY ("Parentage"); /* category setup */ - object = gst_object_new(); - parent = gst_object_new(); - newparent = gst_object_new(); - gtkobject = gtk_type_new(gtk_object_get_type()); + object = gst_object_new (); + parent = gst_object_new (); + newparent = gst_object_new (); + gtkobject = gtk_type_new (gtk_object_get_type ()); /* category assertions */ - ASSERT(object != NULL); - ASSERT(object->refcount == 1); - ASSERT(object->parent == NULL); - ASSERT(parent != NULL); - ASSERT(newparent != NULL); - ASSERT(gtkobject != NULL); - ASSERT(!GST_IS_OBJECT(gtkobject)); - - TEST("gst_object_set_parent: null object"); + ASSERT (object != NULL); + ASSERT (object->refcount == 1); + ASSERT (object->parent == NULL); + ASSERT (parent != NULL); + ASSERT (newparent != NULL); + ASSERT (gtkobject != NULL); + ASSERT (!GST_IS_OBJECT (gtkobject)); + + TEST ("gst_object_set_parent: null object"); /* setup */ /* action */ - gst_object_set_parent(NULL,NULL); + gst_object_set_parent (NULL, NULL); /* assertions */ - ASSERT(object->parent == NULL); + ASSERT (object->parent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_set_parent: invalid object"); + TEST ("gst_object_set_parent: invalid object"); /* setup */ /* action */ - gst_object_set_parent((GstObject*)gtkobject,NULL); + gst_object_set_parent ((GstObject *) gtkobject, NULL); /* assertions */ - ASSERT(object->parent == NULL); + ASSERT (object->parent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_set_parent: null parent"); + TEST ("gst_object_set_parent: null parent"); /* setup */ /* action */ - gst_object_set_parent(object,NULL); + gst_object_set_parent (object, NULL); /* assertions */ - ASSERT(object->parent == NULL); + ASSERT (object->parent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_set_parent: invalid parent"); + TEST ("gst_object_set_parent: invalid parent"); /* setup */ /* action */ - gst_object_set_parent(object,(GstObject*)gtkobject); + gst_object_set_parent (object, (GstObject *) gtkobject); /* assertions */ - ASSERT(object->parent == NULL); + ASSERT (object->parent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_set_parent: valid object, parent is object"); + TEST ("gst_object_set_parent: valid object, parent is object"); /* setup */ /* action */ - gst_object_set_parent(object,object); + gst_object_set_parent (object, object); /* assertions */ - ASSERT(object->parent == NULL); + ASSERT (object->parent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_set_parent: valid object and parent"); + TEST ("gst_object_set_parent: valid object and parent"); /* setup */ /* action */ - gst_object_set_parent(object,parent); + gst_object_set_parent (object, parent); /* assertions */ - ASSERT(object->parent == parent); + ASSERT (object->parent == parent); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_set_parent: parent already set"); + TEST ("gst_object_set_parent: parent already set"); /* setup */ /* action */ - gst_object_set_parent(object,newparent); + gst_object_set_parent (object, newparent); /* assertions */ - ASSERT(object->parent != newparent); - ASSERT(object->parent == parent); + ASSERT (object->parent != newparent); + ASSERT (object->parent == parent); /* cleanup */ - g_free(object); - ENDTEST(); + g_free (object); + ENDTEST (); - TEST("gst_object_get_parent: null object"); + TEST ("gst_object_get_parent: null object"); /* setup */ /* action */ - curparent = gst_object_get_parent(NULL); + curparent = gst_object_get_parent (NULL); /* assertions */ - ASSERT(curparent == NULL); + ASSERT (curparent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_get_parent: invalid object"); + TEST ("gst_object_get_parent: invalid object"); /* setup */ /* action */ - curparent = gst_object_get_parent((GstObject*)gtkobject); + curparent = gst_object_get_parent ((GstObject *) gtkobject); /* assertions */ - ASSERT(curparent == NULL); + ASSERT (curparent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_get_parent: no parent"); + TEST ("gst_object_get_parent: no parent"); /* setup */ - object = gst_object_new(); + object = gst_object_new (); /* action */ - curparent = gst_object_get_parent(object); + curparent = gst_object_get_parent (object); /* assertions */ - ASSERT(curparent == NULL); + ASSERT (curparent == NULL); /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_get_parent: valid parent"); + TEST ("gst_object_get_parent: valid parent"); /* setup */ - gst_object_set_parent(object,parent); + gst_object_set_parent (object, parent); /* action */ - curparent = gst_object_get_parent(object); + curparent = gst_object_get_parent (object); /* assertions */ - ASSERT(curparent == parent); + ASSERT (curparent == parent); /* cleanup */ - g_free(object); - ENDTEST(); + g_free (object); + ENDTEST (); - TEST("gst_object_unparent: null object"); + TEST ("gst_object_unparent: null object"); /* setup */ /* action */ - gst_object_unparent(NULL); + gst_object_unparent (NULL); /* assertions */ /* NONE - FIXME! */ /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_unparent: invalid object"); + TEST ("gst_object_unparent: invalid object"); /* setup */ /* action */ - gst_object_unparent((GstObject*)gtkobject); + gst_object_unparent ((GstObject *) gtkobject); /* assertions */ /* NONE - FIXME! */ /* cleanup */ - ENDTEST(); + ENDTEST (); - TEST("gst_object_unparent: no parent"); + TEST ("gst_object_unparent: no parent"); /* setup */ - object = gst_object_new(); - + object = gst_object_new (); + /* category cleanup */ - g_free(object); - g_free(parent); - g_free(newparent); - g_free(gtkobject); + g_free (object); + g_free (parent); + g_free (newparent); + g_free (gtkobject); - fprintf(stderr,"\n\nTotal tests:\t%d\n",_total_tests); - fprintf(stderr,"Total passed:\t%d\n",_passed_tests); - fprintf(stderr,"Total FAILED:\t%d\n",_total_tests-_passed_tests); + fprintf (stderr, "\n\nTotal tests:\t%d\n", _total_tests); + fprintf (stderr, "Total passed:\t%d\n", _passed_tests); + fprintf (stderr, "Total FAILED:\t%d\n", _total_tests - _passed_tests); } diff --git a/examples/appreader/appreader.c b/examples/appreader/appreader.c index f735b5131..5e8768a37 100644 --- a/examples/appreader/appreader.c +++ b/examples/appreader/appreader.c @@ -20,21 +20,21 @@ #include static void -fill_queue (GstElement *queue, gint level, GstBin *pipeline) +fill_queue (GstElement * queue, gint level, GstBin * pipeline) { /* this needs to iterate till something is pushed * in the queue */ gst_bin_iterate (pipeline); } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstElement *queue, *src, *pipeline; GstBuffer *buffer; gboolean done = FALSE; GstPad *pad; - + gst_init (&argc, &argv); queue = gst_element_factory_make ("queue", "queue"); @@ -50,19 +50,19 @@ main (gint argc, gchar *argv[]) gst_element_link_many (src, queue, NULL); pad = gst_element_get_pad (queue, "src"); - g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), pipeline); + g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), + pipeline); gst_element_set_state (pipeline, GST_STATE_PLAYING); - do { + do { /* get buffer into the app */ buffer = GST_RPAD_GETFUNC (pad) (pad); /* just exit on any event */ if (GST_IS_EVENT (buffer)) { done = TRUE; - } - else { + } else { gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer)); } gst_data_unref (GST_DATA (buffer)); @@ -71,6 +71,6 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (pipeline)); - + return 0; } diff --git a/examples/cutter/cutter.c b/examples/cutter/cutter.c index f22a44138..fb235d845 100644 --- a/examples/cutter/cutter.c +++ b/examples/cutter/cutter.c @@ -16,23 +16,24 @@ #define DEBUG -gboolean playing = TRUE; -gboolean cut_start_signalled = FALSE; -gboolean cut_stop_signalled = FALSE; - -int id = 0; /* increment this for each new cut */ -GstElement *main_bin; -GstElement *audiosrc; -GstElement *queue; -GstElement *thread; -GstElement *cutter; -GstElement *disksink; -GstElement *encoder; -char buffer[255]; +gboolean playing = TRUE; +gboolean cut_start_signalled = FALSE; +gboolean cut_stop_signalled = FALSE; + +int id = 0; /* increment this for each new cut */ +GstElement *main_bin; +GstElement *audiosrc; +GstElement *queue; +GstElement *thread; +GstElement *cutter; +GstElement *disksink; +GstElement *encoder; +char buffer[255]; /* signal callbacks */ -void cut_start (GstElement *element) +void +cut_start (GstElement * element) { g_print ("\nDEBUG: main: cut start\n"); /* we should pause the pipeline, unlink cutter and disksink @@ -45,12 +46,14 @@ void cut_start (GstElement *element) { time_t seconds; struct tm *ct; + time (&seconds); ct = localtime (&seconds); /* sprintf (buffer, "/news/incoming/audio/cutter.%06d.wav", id); */ - sprintf (buffer, "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav", - ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, - ct->tm_hour, ct->tm_min, ct->tm_sec); + sprintf (buffer, + "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav", + ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, ct->tm_hour, ct->tm_min, + ct->tm_sec); } g_print ("DEBUG: cut_start: setting new location to %s\n", buffer); g_object_set (G_OBJECT (disksink), "location", buffer, NULL); @@ -62,13 +65,15 @@ void cut_start (GstElement *element) return; } -void cut_start_signal (GstElement *element) +void +cut_start_signal (GstElement * element) { g_print ("\nDEBUG: main: cut start signal\n"); cut_start_signalled = TRUE; } -void cut_stop (GstElement *element) +void +cut_stop (GstElement * element) { g_print ("\nDEBUG: main: cut stop\n"); /* we should pause the pipeline, unlink disksink, create a fake disksink, @@ -85,42 +90,41 @@ void cut_stop (GstElement *element) return; } -void cut_stop_signal (GstElement *element) +void +cut_stop_signal (GstElement * element) { g_print ("\nDEBUG: main: cut stop signal\n"); cut_stop_signalled = TRUE; } -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { /*int i, j; */ /*gboolean done; */ - + /*char buffer[20]; */ - + /*output_channel_t *channel_out; */ - + GstElement *audiosrc; - gst_init (&argc,&argv); + gst_init (&argc, &argv); /* if (argc == 1) { g_print("usage: %s <...>\n", argv[0]); exit(-1); }*/ - + /* set up input channel and main bin */ - g_print ("creating main bin\n"); + g_print ("creating main bin\n"); /* create cutter */ cutter = gst_element_factory_make ("cutter", "cutter"); - g_object_set (G_OBJECT (cutter), - "threshold_dB", -40.0, - "runlength", 0.5, - "prelength", 1.0, - NULL); + g_object_set (G_OBJECT (cutter), + "threshold_dB", -40.0, "runlength", 0.5, "prelength", 1.0, NULL); /* create an audio src */ if (!(audiosrc = gst_element_factory_make ("osssrc", "audio_src"))) @@ -128,21 +132,20 @@ int main (int argc, char *argv[]) /* set params */ - g_object_set (G_OBJECT (audiosrc), "frequency", 44100, - "channels", 1, - "format", 16, NULL); + g_object_set (G_OBJECT (audiosrc), "frequency", 44100, + "channels", 1, "format", 16, NULL); if (!(encoder = gst_element_factory_make ("passthrough", "encoder"))) g_error ("Could not create 'passthrough' element !\n"); - + if (!(disksink = gst_element_factory_make ("afsink", "disk_sink"))) g_error ("Could not create 'afsink' element !\n"); - + g_object_set (G_OBJECT (disksink), "location", "/dev/null", NULL); thread = gst_thread_new ("thread"); g_assert (thread != NULL); - + /* create main bin */ main_bin = gst_pipeline_new ("bin"); g_assert (main_bin != NULL); @@ -161,10 +164,10 @@ int main (int argc, char *argv[]) /* set signal handlers */ g_print ("setting signal handlers\n"); - g_signal_connect (G_OBJECT(cutter), "cut_start", - (GCallback)cut_start_signal, NULL); - g_signal_connect (G_OBJECT(cutter), "cut_stop", - (GCallback)cut_stop_signal, NULL); + g_signal_connect (G_OBJECT (cutter), "cut_start", + (GCallback) cut_start_signal, NULL); + g_signal_connect (G_OBJECT (cutter), "cut_stop", + (GCallback) cut_stop_signal, NULL); /* start playing */ g_print ("setting to play\n"); @@ -173,23 +176,20 @@ int main (int argc, char *argv[]) g_print ("setting thread to play\n"); gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); */ - while (playing) - { + while (playing) { /* g_print ("> "); */ - gst_bin_iterate (GST_BIN (main_bin)); + gst_bin_iterate (GST_BIN (main_bin)); /* g_print (" <"); */ - if (cut_start_signalled) - { - g_print ("\nDEBUG: main: cut_start_signalled true !\n"); - cut_start (cutter); - cut_start_signalled = FALSE; - } - if (cut_stop_signalled) - { - g_print ("\nDEBUG: main: cut_stop_signalled true !\n"); - cut_stop (cutter); - cut_stop_signalled = FALSE; - } + if (cut_start_signalled) { + g_print ("\nDEBUG: main: cut_start_signalled true !\n"); + cut_start (cutter); + cut_start_signalled = FALSE; + } + if (cut_stop_signalled) { + g_print ("\nDEBUG: main: cut_stop_signalled true !\n"); + cut_stop (cutter); + cut_stop_signalled = FALSE; + } } g_print ("we're done iterating.\n"); /* stop the bin */ @@ -199,5 +199,5 @@ int main (int argc, char *argv[]) gst_object_unref (GST_OBJECT (disksink)); gst_object_unref (GST_OBJECT (main_bin)); - exit(0); + exit (0); } diff --git a/examples/cutter/cutter.h b/examples/cutter/cutter.h index f7ba2d6ca..202ab33e6 100644 --- a/examples/cutter/cutter.h +++ b/examples/cutter/cutter.h @@ -3,12 +3,12 @@ * thomas@apestaart.org */ -typedef struct +typedef struct { GstElement *pipe; GstElement *disksink; GstElement *audiosink; - + char *location; int channel_id; } output_channel_t; diff --git a/examples/helloworld/helloworld.c b/examples/helloworld/helloworld.c index 95197305d..9cf72e842 100644 --- a/examples/helloworld/helloworld.c +++ b/examples/helloworld/helloworld.c @@ -1,7 +1,8 @@ #include #include -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *decoder, *osssink; @@ -36,7 +37,7 @@ int main (int argc, char *argv[]) /* link the elements */ gst_element_link_many (filesrc, decoder, osssink, NULL); - + /* start playing */ gst_element_set_state (bin, GST_STATE_PLAYING); @@ -47,4 +48,3 @@ int main (int argc, char *argv[]) exit (0); } - diff --git a/examples/helloworld2/helloworld2.c b/examples/helloworld2/helloworld2.c index 981576aed..28a32789d 100644 --- a/examples/helloworld2/helloworld2.c +++ b/examples/helloworld2/helloworld2.c @@ -1,7 +1,8 @@ #include static void -gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline) +gst_play_have_type (GstElement * typefind, GstCaps * caps, + GstElement * pipeline) { GstElement *osssink; GstElement *new_element; @@ -21,18 +22,15 @@ gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline) /* unlink_pads the typefind from the pipeline and remove it */ gst_element_unlink_pads (cache, "src", typefind, "sink"); gst_bin_remove (GST_BIN (autobin), typefind); - + /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); autoplug = gst_autoplug_factory_make ("staticrender"); g_assert (autoplug != NULL); - new_element = gst_autoplug_to_renderers (autoplug, - caps, - osssink, - NULL); + new_element = gst_autoplug_to_renderers (autoplug, caps, osssink, NULL); if (!new_element) { g_print ("could not autoplug, no suitable codecs found...\n"); @@ -51,7 +49,7 @@ gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline) } static void -gst_play_cache_empty (GstElement *element, GstElement *pipeline) +gst_play_cache_empty (GstElement * element, GstElement * pipeline) { GstElement *autobin; GstElement *filesrc; @@ -77,8 +75,8 @@ gst_play_cache_empty (GstElement *element, GstElement *pipeline) fprintf (stderr, "done with cache_empty\n"); } -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc; GstElement *pipeline; @@ -105,23 +103,24 @@ main (int argc, char *argv[]) autobin = gst_bin_new ("autobin"); cache = gst_element_factory_make ("autoplugcache", "cache"); - g_signal_connect (G_OBJECT (cache), "cache_empty", - G_CALLBACK (gst_play_cache_empty), pipeline); + g_signal_connect (G_OBJECT (cache), "cache_empty", + G_CALLBACK (gst_play_cache_empty), pipeline); typefind = gst_element_factory_make ("typefind", "typefind"); - g_signal_connect (G_OBJECT (typefind), "have_type", - G_CALLBACK (gst_play_have_type), pipeline); + g_signal_connect (G_OBJECT (typefind), "have_type", + G_CALLBACK (gst_play_have_type), pipeline); gst_bin_add (GST_BIN (autobin), cache); gst_bin_add (GST_BIN (autobin), typefind); gst_element_link_pads (cache, "src", typefind, "sink"); - gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), "sink"); + gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), + "sink"); - gst_bin_add (GST_BIN( pipeline), autobin); + gst_bin_add (GST_BIN (pipeline), autobin); gst_element_link_pads (filesrc, "src", autobin, "sink"); /* start playing */ - gst_element_set_state( GST_ELEMENT (pipeline), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); @@ -130,6 +129,5 @@ main (int argc, char *argv[]) gst_object_unref (GST_OBJECT (pipeline)); - exit(0); + exit (0); } - diff --git a/examples/launch/mp3parselaunch.c b/examples/launch/mp3parselaunch.c index a0cb19036..a8009712f 100644 --- a/examples/launch/mp3parselaunch.c +++ b/examples/launch/mp3parselaunch.c @@ -2,7 +2,7 @@ #include int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *pipeline; GstElement *filesrc; @@ -15,20 +15,22 @@ main (int argc, char *argv[]) return -1; } - pipeline = (GstElement*) gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error); + pipeline = + (GstElement *) + gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error); if (!pipeline) { fprintf (stderr, "Parse error: %s", error->message); exit (1); } - + filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc"); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); - + gst_element_set_state (pipeline, GST_STATE_NULL); - + return 0; } diff --git a/examples/mixer/mixer.c b/examples/mixer/mixer.c index 6b27f5b94..c2990724f 100644 --- a/examples/mixer/mixer.c +++ b/examples/mixer/mixer.c @@ -24,88 +24,90 @@ /*#define AUTOPLUG * define if you want autoplugging of input channels * */ /* function prototypes */ -input_channel_t* create_input_channel (int id, char* location); -void destroy_input_channel (input_channel_t *pipe); -void env_register_cp (GstElement *volenv, double cp_time, double cp_level); +input_channel_t *create_input_channel (int id, char *location); +void destroy_input_channel (input_channel_t * pipe); +void env_register_cp (GstElement * volenv, double cp_time, double cp_level); gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element) +void +eos (GstElement * element) { - g_print("have eos, quitting ?\n"); + g_print ("have eos, quitting ?\n"); /* playing = FALSE; */ } -G_GNUC_UNUSED static GstCaps* -gst_play_type_find (GstBin *bin, GstElement *element) +G_GNUC_UNUSED static GstCaps * +gst_play_type_find (GstBin * bin, GstElement * element) { GstElement *typefind; GstElement *pipeline; GstCaps *caps = NULL; GST_DEBUG ("GstPipeline: typefind for element \"%s\"", - GST_ELEMENT_NAME(element)); + GST_ELEMENT_NAME (element)); pipeline = gst_pipeline_new ("autoplug_pipeline"); - + typefind = gst_element_factory_make ("typefind", "typefind"); g_return_val_if_fail (typefind != NULL, FALSE); gst_pad_link (gst_element_get_pad (element, "src"), - gst_element_get_pad (typefind, "sink")); + gst_element_get_pad (typefind, "sink")); gst_bin_add (bin, typefind); gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (bin)); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); - + /* push a buffer... the have_type signal handler will set the found flag */ gst_bin_iterate (GST_BIN (pipeline)); - + gst_element_set_state (pipeline, GST_STATE_NULL); caps = gst_pad_get_caps (gst_element_get_pad (element, "src")); gst_pad_unlink (gst_element_get_pad (element, "src"), - gst_element_get_pad (typefind, "sink")); + gst_element_get_pad (typefind, "sink")); gst_bin_remove (bin, typefind); gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin)); gst_object_unref (GST_OBJECT (typefind)); gst_object_unref (GST_OBJECT (pipeline)); - + return caps; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { int i, j; int num_channels; - + char buffer[20]; - - GList *input_channels; /* structure holding all the input channels */ - + + GList *input_channels; /* structure holding all the input channels */ + input_channel_t *channel_in; - + GstElement *main_bin; GstElement *adder; GstElement *audiosink; - GstPad *pad; /* to request pads for the adder */ + GstPad *pad; /* to request pads for the adder */ - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc == 1) { - g_print("usage: %s <...>\n", argv[0]); - exit(-1); + g_print ("usage: %s <...>\n", argv[0]); + exit (-1); } num_channels = argc - 1; - + /* set up output channel and main bin */ - + /* create adder */ adder = gst_element_factory_make ("adder", "adderel"); @@ -113,33 +115,33 @@ int main(int argc,char *argv[]) audiosink = gst_element_factory_make ("esdsink", "play_audio"); /* create main bin */ - main_bin = gst_pipeline_new("bin"); + main_bin = gst_pipeline_new ("bin"); /* link adder and output to bin */ - GST_INFO ( "main: adding adder to bin"); - gst_bin_add (GST_BIN(main_bin), adder); - GST_INFO ( "main: adding audiosink to bin"); - gst_bin_add (GST_BIN(main_bin), audiosink); + GST_INFO ("main: adding adder to bin"); + gst_bin_add (GST_BIN (main_bin), adder); + GST_INFO ("main: adding audiosink to bin"); + gst_bin_add (GST_BIN (main_bin), audiosink); /* link adder and audiosink */ - gst_pad_link(gst_element_get_pad(adder,"src"), - gst_element_get_pad(audiosink,"sink")); - + gst_pad_link (gst_element_get_pad (adder, "src"), + gst_element_get_pad (audiosink, "sink")); + /* start looping */ input_channels = NULL; - - for (i = 1; i < argc; ++i) - { + + for (i = 1; i < argc; ++i) { printf ("Opening channel %d from file %s...\n", i, argv[i]); channel_in = create_input_channel (i, argv[i]); input_channels = g_list_append (input_channels, channel_in); - if (i > 1) gst_element_set_state (main_bin, GST_STATE_PAUSED); - gst_bin_add (GST_BIN(main_bin), channel_in->pipe); + if (i > 1) + gst_element_set_state (main_bin, GST_STATE_PAUSED); + gst_bin_add (GST_BIN (main_bin), channel_in->pipe); /* request pads and link to adder */ - GST_INFO ( "requesting pad\n"); + GST_INFO ("requesting pad\n"); pad = gst_element_get_request_pad (adder, "sink%d"); printf ("\tGot new adder sink pad %s\n", gst_pad_get_name (pad)); sprintf (buffer, "channel%d", i); @@ -155,78 +157,71 @@ int main(int argc,char *argv[]) * at a level ensuring no distortion * example for three songs : * song1 : starts at full level, plays 5 seconds, faded out at 10 seconds, - * sleep until 25, fade to end level at 30 + * sleep until 25, fade to end level at 30 * song2 : starts silent, fades in at 5 seconds, full blast at 10 seconds, - * full level until 15, faded out at 20, sleep until 25, fade to end at 30 + * full level until 15, faded out at 20, sleep until 25, fade to end at 30 * song3 : starts muted, fades in from 15, full at 20, until 25, fade to end level */ - if (i == 1) - { + if (i == 1) { /* first song gets special treatment for end style */ - env_register_cp (channel_in->volenv, 0.0, 1.0); - } - else - { - env_register_cp (channel_in->volenv, 0.0 , 0.0000001); /* start muted */ - env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */ - env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0); + env_register_cp (channel_in->volenv, 0.0, 1.0); + } else { + env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */ + env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */ + env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0); } - env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */ + env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */ - if (i != num_channels) - { - env_register_cp (channel_in->volenv, i * 10.0 , 0.0000001); /* fade to black */ - env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */ - } - env_register_cp (channel_in->volenv, num_channels * 10.0 , 1.0 / num_channels); /* to end level */ + if (i != num_channels) { + env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */ + env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */ + } + env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */ #ifndef GST_DISABLE_LOADSAVE gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w")); #endif /* start playing */ - gst_element_set_state(main_bin, GST_STATE_PLAYING); + gst_element_set_state (main_bin, GST_STATE_PLAYING); /* write out the schedule */ - gst_scheduler_show(GST_ELEMENT_SCHED(main_bin)); + gst_scheduler_show (GST_ELEMENT_SCHED (main_bin)); playing = TRUE; j = 0; /*printf ("main: start iterating from 0"); */ - while (playing && j < 100) - { + while (playing && j < 100) { /* printf ("main: iterating %d\n", j); */ - gst_bin_iterate(GST_BIN(main_bin)); - /*fprintf(stderr,"after iterate()\n"); */ + gst_bin_iterate (GST_BIN (main_bin)); + /*fprintf(stderr,"after iterate()\n"); */ ++j; } } printf ("main: all the channels are open\n"); - while (playing) - { - gst_bin_iterate(GST_BIN(main_bin)); + while (playing) { + gst_bin_iterate (GST_BIN (main_bin)); /*fprintf(stderr,"after iterate()\n"); */ } /* stop the bin */ - gst_element_set_state(main_bin, GST_STATE_NULL); + gst_element_set_state (main_bin, GST_STATE_NULL); - while (input_channels) - { + while (input_channels) { destroy_input_channel (input_channels->data); input_channels = g_list_next (input_channels); } g_list_free (input_channels); - - gst_object_unref(GST_OBJECT(audiosink)); - gst_object_unref(GST_OBJECT(main_bin)); + gst_object_unref (GST_OBJECT (audiosink)); - exit(0); + gst_object_unref (GST_OBJECT (main_bin)); + + exit (0); } -input_channel_t* -create_input_channel (int id, char* location) +input_channel_t * +create_input_channel (int id, char *location) { /* create an input channel, reading from location * return a pointer to the channel @@ -234,51 +229,48 @@ create_input_channel (int id, char* location) */ input_channel_t *channel; - - char buffer[20]; /* hold the names */ + + char buffer[20]; /* hold the names */ /* GstAutoplug *autoplug; GstCaps *srccaps; */ - GstElement *new_element; + GstElement *new_element; GstElement *decoder; - GST_DEBUG ( "c_i_p : creating channel with id %d for file %s", - id, location); - + GST_DEBUG ("c_i_p : creating channel with id %d for file %s", id, location); + /* allocate channel */ channel = (input_channel_t *) malloc (sizeof (input_channel_t)); - if (channel == NULL) - { + if (channel == NULL) { printf ("create_input_channel : could not allocate memory for channel !\n"); return NULL; } /* create channel */ - GST_DEBUG ( "c_i_p : creating pipeline"); + GST_DEBUG ("c_i_p : creating pipeline"); sprintf (buffer, "pipeline%d", id); channel->pipe = gst_bin_new (buffer); - g_assert(channel->pipe != NULL); - + g_assert (channel->pipe != NULL); + /* create elements */ - GST_DEBUG ( "c_i_p : creating filesrc"); + GST_DEBUG ("c_i_p : creating filesrc"); sprintf (buffer, "filesrc%d", id); channel->filesrc = gst_element_factory_make ("filesrc", buffer); - g_assert(channel->filesrc != NULL); + g_assert (channel->filesrc != NULL); - GST_DEBUG ( "c_i_p : setting location"); - g_object_set(G_OBJECT(channel->filesrc),"location", location, NULL); + GST_DEBUG ("c_i_p : setting location"); + g_object_set (G_OBJECT (channel->filesrc), "location", location, NULL); /* add filesrc to the bin before autoplug */ - gst_bin_add(GST_BIN(channel->pipe), channel->filesrc); + gst_bin_add (GST_BIN (channel->pipe), channel->filesrc); /* link signal to eos of filesrc */ - g_signal_connect (G_OBJECT(channel->filesrc),"eos", - G_CALLBACK(eos),NULL); + g_signal_connect (G_OBJECT (channel->filesrc), "eos", G_CALLBACK (eos), NULL); #ifdef DEBUG @@ -287,7 +279,7 @@ create_input_channel (int id, char* location) sprintf (buffer, "volenv%d", id); channel->volenv = gst_element_factory_make ("volenv", buffer); - g_assert(channel->volenv != NULL); + g_assert (channel->volenv != NULL); /* autoplug the pipe */ @@ -308,7 +300,7 @@ create_input_channel (int id, char* location) gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_NULL); gst_bin_remove (GST_BIN (pipeline), channel->pipe); - + } #endif @@ -317,7 +309,6 @@ create_input_channel (int id, char* location) g_print ("could not autoplug, unknown media type...\n"); exit (-1); } - #ifdef DEBUG printf ("DEBUG : c_i_p : creating autoplug\n"); #endif @@ -328,51 +319,49 @@ create_input_channel (int id, char* location) #ifdef DEBUG printf ("DEBUG : c_i_p : autoplugging\n"); #endif - - new_element = gst_autoplug_to_caps (autoplug, srccaps, - gst_caps_new ("audio/raw", NULL), NULL); - + + new_element = gst_autoplug_to_caps (autoplug, srccaps, + gst_caps_new ("audio/raw", NULL), NULL); + if (!new_element) { g_print ("could not autoplug, no suitable codecs found...\n"); exit (-1); } - #else new_element = gst_bin_new ("autoplug_bin"); /* static plug, use mad plugin and assume mp3 input */ printf ("using static plugging for input channel\n"); - decoder = gst_element_factory_make ("mad", "mpg123"); - if (!decoder) - { + decoder = gst_element_factory_make ("mad", "mpg123"); + if (!decoder) { fprintf (stderr, "Could not get a decoder element !\n"); exit (1); } gst_bin_add (GST_BIN (new_element), decoder); - gst_element_add_ghost_pad (new_element, - gst_element_get_pad (decoder, "sink"), "sink"); - gst_element_add_ghost_pad (new_element, - gst_element_get_pad (decoder, "src"), "src_00"); - -#endif + gst_element_add_ghost_pad (new_element, + gst_element_get_pad (decoder, "sink"), "sink"); + gst_element_add_ghost_pad (new_element, + gst_element_get_pad (decoder, "src"), "src_00"); + +#endif #ifndef GST_DISABLE_LOADSAVE gst_xml_write_file (GST_ELEMENT (new_element), fopen ("mixer.gst", "w")); -#endif +#endif - gst_bin_add (GST_BIN(channel->pipe), channel->volenv); + gst_bin_add (GST_BIN (channel->pipe), channel->volenv); gst_bin_add (GST_BIN (channel->pipe), new_element); - + gst_element_link_pads (channel->filesrc, "src", new_element, "sink"); gst_element_link_pads (new_element, "src_00", channel->volenv, "sink"); - + /* add a ghost pad */ sprintf (buffer, "channel%d", id); gst_element_add_ghost_pad (channel->pipe, - gst_element_get_pad (channel->volenv, "src"), buffer); + gst_element_get_pad (channel->volenv, "src"), buffer); + - #ifdef DEBUG printf ("DEBUG : c_i_p : end function\n"); #endif @@ -381,12 +370,12 @@ create_input_channel (int id, char* location) } void -destroy_input_channel (input_channel_t *channel) +destroy_input_channel (input_channel_t * channel) { /* * destroy an input channel */ - + #ifdef DEBUG printf ("DEBUG : d_i_p : start\n"); #endif @@ -398,11 +387,12 @@ destroy_input_channel (input_channel_t *channel) free (channel); } -void env_register_cp (GstElement *volenv, double cp_time, double cp_level) +void +env_register_cp (GstElement * volenv, double cp_time, double cp_level) { char buffer[30]; sprintf (buffer, "%f:%f", cp_time, cp_level); - g_object_set(G_OBJECT(volenv), "controlpoint", buffer, NULL); + g_object_set (G_OBJECT (volenv), "controlpoint", buffer, NULL); } diff --git a/examples/mixer/mixer.h b/examples/mixer/mixer.h index 4cae18e30..76e55f6ea 100644 --- a/examples/mixer/mixer.h +++ b/examples/mixer/mixer.h @@ -3,10 +3,10 @@ * thomas@apestaart.org */ -typedef struct +typedef struct { GstElement *pipe, *filesrc, *volenv; - + char *location; int channel_id; } input_channel_t; diff --git a/examples/pingpong/pingpong.c b/examples/pingpong/pingpong.c index c0cc60206..59f7be64f 100644 --- a/examples/pingpong/pingpong.c +++ b/examples/pingpong/pingpong.c @@ -19,7 +19,7 @@ #include -static GstElement* +static GstElement * make_bin (gint count) { GstElement *bin; @@ -42,7 +42,7 @@ make_bin (gint count) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *aggregator, *sink; @@ -53,9 +53,9 @@ main (gint argc, gchar *argv[]) gst_init (&argc, &argv); pipeline = gst_pipeline_new ("main"); - g_signal_connect (pipeline, "deep_notify", - G_CALLBACK (gst_element_default_deep_notify), NULL); - + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + aggregator = gst_element_factory_make ("aggregator", "mixer"); sink = gst_element_factory_make ("fakesink", "sink"); @@ -85,7 +85,7 @@ main (gint argc, gchar *argv[]) i = 4; while (i--) gst_bin_iterate (GST_BIN (pipeline)); - + g_print ("playing bin1\n"); gst_element_set_state (bin1, GST_STATE_PLAYING); diff --git a/examples/plugins/example.c b/examples/plugins/example.c index 796d33940..42144a0aa 100644 --- a/examples/plugins/example.c +++ b/examples/plugins/example.c @@ -27,18 +27,18 @@ * plugin, as well as author and version data. Use the GST_ELEMENT_DETAILS * macro when defining it. */ -static GstElementDetails example_details = GST_ELEMENT_DETAILS ( - "An example plugin", - "Example/FirstExample", - "Shows the basic structure of a plugin", - "your name " -); +static GstElementDetails example_details = +GST_ELEMENT_DETAILS ("An example plugin", + "Example/FirstExample", + "Shows the basic structure of a plugin", + "your name "); /* These are the signals that this element can fire. They are zero- * based because the numbers themselves are private to the object. * LAST_SIGNAL is used for initialization of the signal array. */ -enum { +enum +{ ASDF, /* FILL ME */ LAST_SIGNAL @@ -47,51 +47,46 @@ enum { /* Arguments are identified the same way, but cannot be zero, so you * must leave the ARG_0 entry in as a placeholder. */ -enum { +enum +{ ARG_0, ARG_ACTIVE - /* FILL ME */ + /* FILL ME */ }; /* The PadFactory structures describe what pads the element has or * can have. They can be quite complex, but for this example plugin * they are rather simple. */ -GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink", /* The name of the pad */ - GST_PAD_SINK, /* Direction of the pad */ - GST_PAD_ALWAYS, /* The pad exists for every instance */ - GST_STATIC_CAPS ( - "unknown/unknown, " /* The MIME media type */ - "foo:int=1, " /* an integer property */ - "bar:boolean=true, " /* a boolean property */ - "baz:int={ 1, 3 }" /* a list of values */ - ) -); +GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", /* The name of the pad */ + GST_PAD_SINK, /* Direction of the pad */ + GST_PAD_ALWAYS, /* The pad exists for every instance */ + GST_STATIC_CAPS ("unknown/unknown, " /* The MIME media type */ + "foo:int=1, " /* an integer property */ + "bar:boolean=true, " /* a boolean property */ + "baz:int={ 1, 3 }" /* a list of values */ + ) + ); /* This factory is much simpler, and defines the source pad. */ -GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "unknown/unknown" - ) -); +GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("unknown/unknown") + ); /* A number of functon prototypes are given so we can refer to them later. */ -static void gst_example_class_init (GstExampleClass *klass); -static void gst_example_init (GstExample *example); +static void gst_example_class_init (GstExampleClass * klass); +static void gst_example_init (GstExample * example); -static void gst_example_chain (GstPad *pad, GstData *_data); +static void gst_example_chain (GstPad * pad, GstData * _data); -static void gst_example_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_example_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); -static GstElementStateReturn - gst_example_change_state (GstElement *element); +static void gst_example_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_example_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static GstElementStateReturn gst_example_change_state (GstElement * element); /* The parent class pointer needs to be kept around for some object * operations. @@ -109,23 +104,25 @@ static guint gst_example_signals[LAST_SIGNAL] = { 0 }; * and pointers to the various functions that define the class. */ GType -gst_example_get_type(void) +gst_example_get_type (void) { static GType example_type = 0; if (!example_type) { static const GTypeInfo example_info = { - sizeof(GstExampleClass), + sizeof (GstExampleClass), NULL, NULL, - (GClassInitFunc)gst_example_class_init, + (GClassInitFunc) gst_example_class_init, NULL, NULL, - sizeof(GstExample), + sizeof (GstExample), 0, - (GInstanceInitFunc)gst_example_init, + (GInstanceInitFunc) gst_example_init, }; - example_type = g_type_register_static(GST_TYPE_ELEMENT, "GstExample", &example_info, 0); + example_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstExample", &example_info, + 0); } return example_type; } @@ -135,7 +132,7 @@ gst_example_get_type(void) * it, based on the pointer to the function provided above. */ static void -gst_example_class_init (GstExampleClass *klass) +gst_example_class_init (GstExampleClass * klass) { /* Class pointers are needed to supply pointers to the private * implementations of parent class methods. @@ -146,27 +143,24 @@ gst_example_class_init (GstExampleClass *klass) /* Since the example class contains the parent classes, you can simply * cast the pointer to get access to the parent classes. */ - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; /* The parent class is needed for class method overrides. */ - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); /* Here we add an argument to the object. This argument is an integer, * and can be both read and written. */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE, - g_param_spec_int("active","active","active", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ /* Here we add a signal to the object. This is avery useless signal * called asdf. The signal will also pass a pointer to the listeners * which happens to be the example element itself */ gst_example_signals[ASDF] = - g_signal_new("asdf", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, - GST_TYPE_EXAMPLE); + g_signal_new ("asdf", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_EXAMPLE); /* The last thing is to provide the functions that implement get and set @@ -193,31 +187,33 @@ gst_example_class_init (GstExampleClass *klass) * the plugin. */ static void -gst_example_init(GstExample *example) +gst_example_init (GstExample * example) { /* First we create the sink pad, which is the input to the element. * We will use the template constructed by the factory. */ - example->sinkpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&sink_template), "sink"); + example->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sink_template), + "sink"); /* Setting the chain function allows us to supply the function that will * actually be performing the work. Without this, the element would do * nothing, with undefined results (assertion failures and such). */ - gst_pad_set_chain_function(example->sinkpad,gst_example_chain); + gst_pad_set_chain_function (example->sinkpad, gst_example_chain); /* We then must add this pad to the element's list of pads. The base * element class manages the list of pads, and provides accessors to it. */ - gst_element_add_pad(GST_ELEMENT(example),example->sinkpad); + gst_element_add_pad (GST_ELEMENT (example), example->sinkpad); /* The src pad, the output of the element, is created and registered * in the same way, with the exception of the chain function. Source * pads don't have chain functions, because they can't accept buffers, * they only produce them. */ - example->srcpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&src_template), "src"); - gst_element_add_pad(GST_ELEMENT(example),example->srcpad); + example->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&src_template), + "src"); + gst_element_add_pad (GST_ELEMENT (example), example->srcpad); /* Initialization of element's private variables. */ example->active = FALSE; @@ -228,7 +224,7 @@ gst_example_init(GstExample *example) * as the buffer provided by the peer element. */ static void -gst_example_chain (GstPad *pad, GstData *_data) +gst_example_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstExample *example; @@ -237,34 +233,35 @@ gst_example_chain (GstPad *pad, GstData *_data) /* Some of these checks are of dubious value, since if there were not * already true, the chain function would never be called. */ - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); /* We need to get a pointer to the element this pad belogs to. */ - example = GST_EXAMPLE(gst_pad_get_parent (pad)); + example = GST_EXAMPLE (gst_pad_get_parent (pad)); /* A few more sanity checks to make sure that the element that owns * this pad is the right kind of element, in case something got confused. */ - g_return_if_fail(example != NULL); - g_return_if_fail(GST_IS_EXAMPLE(example)); + g_return_if_fail (example != NULL); + g_return_if_fail (GST_IS_EXAMPLE (example)); /* If we are supposed to be doing something, here's where it happens. */ if (example->active) { /* In this example we're going to copy the buffer to another one, * so we need to allocate a new buffer first. */ - outbuf = gst_buffer_new(); + outbuf = gst_buffer_new (); /* We need to copy the size and offset of the buffer at a minimum. */ GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf); GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf); /* Then allocate the memory for the new buffer */ - GST_BUFFER_DATA (outbuf) = (guchar *)g_malloc (GST_BUFFER_SIZE (outbuf)); + GST_BUFFER_DATA (outbuf) = (guchar *) g_malloc (GST_BUFFER_SIZE (outbuf)); /* Then copy the data in the incoming buffer into the new buffer. */ - memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (outbuf)); + memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), + GST_BUFFER_SIZE (outbuf)); /* we don't need the incomming buffer anymore so we unref it. When we are * the last plugin with a handle to the buffer, its memory will be freed */ @@ -274,15 +271,14 @@ gst_example_chain (GstPad *pad, GstData *_data) * in the pipeline, through the element's source pad, which is stored * in the element's structure. */ - gst_pad_push(example->srcpad,GST_DATA (outbuf)); + gst_pad_push (example->srcpad, GST_DATA (outbuf)); /* For fun we'll emit our useless signal here */ - g_signal_emit(G_OBJECT (example), gst_example_signals[ASDF], 0, - example); + g_signal_emit (G_OBJECT (example), gst_example_signals[ASDF], 0, example); - /* If we're not doing something, just send the original incoming buffer. */ + /* If we're not doing something, just send the original incoming buffer. */ } else { - gst_pad_push(example->srcpad,GST_DATA (buf)); + gst_pad_push (example->srcpad, GST_DATA (buf)); } } @@ -290,15 +286,16 @@ gst_example_chain (GstPad *pad, GstData *_data) * enable the element to respond to various arguments. */ static void -gst_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_example_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstExample *example; /* It's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_EXAMPLE(object)); + g_return_if_fail (GST_IS_EXAMPLE (object)); /* Get a pointer of the right type. */ - example = GST_EXAMPLE(object); + example = GST_EXAMPLE (object); /* Check the argument id to see which argument we're setting. */ switch (prop_id) { @@ -309,7 +306,7 @@ gst_example_set_property (GObject *object, guint prop_id, const GValue *value, G * is running, if you are using threads. */ example->active = g_value_get_int (value); - g_print("example: set active to %d\n",example->active); + g_print ("example: set active to %d\n", example->active); break; default: break; @@ -318,13 +315,14 @@ gst_example_set_property (GObject *object, guint prop_id, const GValue *value, G /* The set function is simply the inverse of the get fuction. */ static void -gst_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_example_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstExample *example; /* It's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_EXAMPLE(object)); - example = GST_EXAMPLE(object); + g_return_if_fail (GST_IS_EXAMPLE (object)); + example = GST_EXAMPLE (object); switch (prop_id) { case ARG_ACTIVE: @@ -342,38 +340,38 @@ gst_example_get_property (GObject *object, guint prop_id, GValue *value, GParamS * in the various state transitions. */ static GstElementStateReturn -gst_example_change_state (GstElement *element) +gst_example_change_state (GstElement * element) { GstExample *example; - + /* cast to our plugin */ - example = GST_EXAMPLE(element); - + example = GST_EXAMPLE (element); + /* we perform our actions based on the state transition * of the element */ switch (GST_STATE_TRANSITION (element)) { - /* The NULL to READY transition is used to - * create threads (if any) */ + /* The NULL to READY transition is used to + * create threads (if any) */ case GST_STATE_NULL_TO_READY: break; - /* In the READY to PAUSED state, the element should - * open devices (if any) */ + /* In the READY to PAUSED state, the element should + * open devices (if any) */ case GST_STATE_READY_TO_PAUSED: break; - /* In the PAUSED to PLAYING state, the element should - * prepare itself for operation or continue after a PAUSE */ + /* In the PAUSED to PLAYING state, the element should + * prepare itself for operation or continue after a PAUSE */ case GST_STATE_PAUSED_TO_PLAYING: break; - /* In the PLAYING to PAUSED state, the element should - * PAUSE itself and make sure it can resume operation */ + /* In the PLAYING to PAUSED state, the element should + * PAUSE itself and make sure it can resume operation */ case GST_STATE_PLAYING_TO_PAUSED: break; - /* In the PAUSED to READY state, the element should reset - * its internal state and close any devices. */ + /* In the PAUSED to READY state, the element should reset + * its internal state and close any devices. */ case GST_STATE_PAUSED_TO_READY: break; - /* The element should free all resources, terminate threads - * and put itself into its initial state again */ + /* The element should free all resources, terminate threads + * and put itself into its initial state again */ case GST_STATE_READY_TO_NULL: break; } @@ -387,13 +385,14 @@ gst_example_change_state (GstElement *element) * this function is called to register everything that the plugin provides. */ static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { /* We need to register each element we provide with the plugin. This consists * of the name of the element, a rank that gives the importance of the element * when compared to similar plugins and the GType identifier. */ - if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, GST_TYPE_EXAMPLE)) + if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, + GST_TYPE_EXAMPLE)) return FALSE; /* Now we can return successfully. */ @@ -411,21 +410,19 @@ plugin_init (GstPlugin *plugin) * The symbol pointing to this structure is the only symbol looked up when * loading the plugin. */ -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, /* The major version of the core that this was built with */ - GST_VERSION_MINOR, /* The minor version of the core that this was built with */ - "example", /* The name of the plugin. This must be unique: plugins with - * the same name will be assumed to be identical, and only - * one will be loaded. */ - "an example plugin", /* a short description of the plugin in English */ - plugin_init, /* Pointer to the initialisation function for the plugin. */ - "0.1", /* The version number of the plugin */ - "LGPL", /* ieffective license the plugin can be shipped with. Must be - * valid for all libraries it links to, too. */ - "my nifty plugin package", - /* package this plugin belongs to. */ - "http://www.mydomain.com" - /* originating URL for this plugin. This is the place to look - * for updates, information and so on. */ -); - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, /* The major version of the core that this was built with */ + GST_VERSION_MINOR, /* The minor version of the core that this was built with */ + "example", /* The name of the plugin. This must be unique: plugins with + * the same name will be assumed to be identical, and only + * one will be loaded. */ + "an example plugin", /* a short description of the plugin in English */ + plugin_init, /* Pointer to the initialisation function for the plugin. */ + "0.1", /* The version number of the plugin */ + "LGPL", /* ieffective license the plugin can be shipped with. Must be + * valid for all libraries it links to, too. */ + "my nifty plugin package", + /* package this plugin belongs to. */ + "http://www.mydomain.com" + /* originating URL for this plugin. This is the place to look + * for updates, information and so on. */ + ); diff --git a/examples/plugins/example.h b/examples/plugins/example.h index cbb7b28ce..2e065ecf6 100644 --- a/examples/plugins/example.h +++ b/examples/plugins/example.h @@ -24,7 +24,6 @@ #include G_BEGIN_DECLS - /* This is the definition of the element's object structure. */ typedef struct _GstExample GstExample; @@ -33,11 +32,12 @@ typedef struct _GstExample GstExample; * the beginning of the object. This allows the element to be cast to * an Element or even an Object. */ -struct _GstExample { +struct _GstExample +{ GstElement element; /* We need to keep track of our pads, so we do so here. */ - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; /* We'll use this to decide whether to do anything to the data we get. */ gboolean active; @@ -49,11 +49,12 @@ struct _GstExample { * structure. */ typedef struct _GstExampleClass GstExampleClass; -struct _GstExampleClass { +struct _GstExampleClass +{ GstElementClass parent_class; /* signals */ - void (*asdf) (GstElement *element, GstExample *example); + void (*asdf) (GstElement * element, GstExample * example); }; /* Five standard preprocessing macros are used in the Gtk+ object system. @@ -80,8 +81,7 @@ struct _GstExampleClass { /* This is the only prototype needed, because it is used in the above * GST_TYPE_EXAMPLE macro. */ -GType gst_example_get_type(void); +GType gst_example_get_type (void); G_END_DECLS - #endif /* __GST_EXAMPLE_H__ */ diff --git a/examples/queue/queue.c b/examples/queue/queue.c index 5f3a9c046..7e027839e 100644 --- a/examples/queue/queue.c +++ b/examples/queue/queue.c @@ -1,56 +1,56 @@ #include #include -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *parse, *decode, *queue; GstElement *bin; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - bin = gst_bin_new("bin"); - g_assert(bin != NULL); + bin = gst_bin_new ("bin"); + g_assert (bin != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); - parse = gst_element_factory_make("mp3parse", "parse"); - decode = gst_element_factory_make("mpg123", "decode"); + parse = gst_element_factory_make ("mp3parse", "parse"); + decode = gst_element_factory_make ("mpg123", "decode"); - queue = gst_element_factory_make("queue", "queue"); + queue = gst_element_factory_make ("queue", "queue"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (bin), filesrc, parse, decode, queue, NULL); - gst_bin_add(GST_BIN(thread), osssink); - gst_bin_add(GST_BIN(bin), thread); + gst_bin_add (GST_BIN (thread), osssink); + gst_bin_add (GST_BIN (bin), thread); gst_element_link_many (filesrc, parse, decode, queue, osssink, NULL); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); - while (gst_bin_iterate(GST_BIN(bin))); + while (gst_bin_iterate (GST_BIN (bin))); - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/examples/queue2/queue2.c b/examples/queue2/queue2.c index b6eae69d4..7d5862600 100644 --- a/examples/queue2/queue2.c +++ b/examples/queue2/queue2.c @@ -4,78 +4,78 @@ gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); playing = FALSE; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue; GstElement *pipeline; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - pipeline = gst_pipeline_new("pipeline"); - g_assert(pipeline != NULL); + pipeline = gst_pipeline_new ("pipeline"); + g_assert (pipeline != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect (G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); - queue = gst_element_factory_make("queue", "queue"); + queue = gst_element_factory_make ("queue", "queue"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); /* add objects to the main pipeline */ /* - gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); - gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue); + gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); + gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue); - gst_bin_add(GST_BIN(thread), osssink); + gst_bin_add(GST_BIN(thread), osssink); - gst_pad_link(gst_element_get_pad(queue,"src"), - gst_element_get_pad(osssink,"sink")); + gst_pad_link(gst_element_get_pad(queue,"src"), + gst_element_get_pad(osssink,"sink")); - if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { - g_print("cannot autoplug pipeline\n"); - exit(-1); - } - */ + if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { + g_print("cannot autoplug pipeline\n"); + exit(-1); + } + */ - gst_bin_add(GST_BIN(pipeline), thread); + gst_bin_add (GST_BIN (pipeline), thread); /* make it ready */ - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); playing = TRUE; while (playing) { - gst_bin_iterate(GST_BIN(pipeline)); + gst_bin_iterate (GST_BIN (pipeline)); } - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/examples/queue3/queue3.c b/examples/queue3/queue3.c index da92fcf7b..3a17854d7 100644 --- a/examples/queue3/queue3.c +++ b/examples/queue3/queue3.c @@ -4,73 +4,73 @@ gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); playing = FALSE; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue, *parse, *decode; GstElement *bin; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - bin = gst_bin_new("bin"); - g_assert(bin != NULL); + bin = gst_bin_new ("bin"); + g_assert (bin != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect(G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); - queue = gst_element_factory_make("queue", "queue"); + queue = gst_element_factory_make ("queue", "queue"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); - parse = gst_element_factory_make("mp3parse", "parse"); - decode = gst_element_factory_make("mpg123", "decode"); + parse = gst_element_factory_make ("mp3parse", "parse"); + decode = gst_element_factory_make ("mpg123", "decode"); /* add objects to the main bin */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), queue); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), queue); - gst_bin_add(GST_BIN(thread), parse); - gst_bin_add(GST_BIN(thread), decode); - gst_bin_add(GST_BIN(thread), osssink); + gst_bin_add (GST_BIN (thread), parse); + gst_bin_add (GST_BIN (thread), decode); + gst_bin_add (GST_BIN (thread), osssink); gst_element_link_many (filesrc, queue, parse, decode, osssink, NULL); /* make it ready */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); playing = TRUE; while (playing) { - gst_bin_iterate(GST_BIN(bin)); + gst_bin_iterate (GST_BIN (bin)); } - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/examples/queue4/queue4.c b/examples/queue4/queue4.c index 193b12fa3..8ea60d89e 100644 --- a/examples/queue4/queue4.c +++ b/examples/queue4/queue4.c @@ -4,81 +4,81 @@ gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); playing = FALSE; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue, *queue2, *parse, *decode; GstElement *bin; GstElement *thread, *thread2; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); - thread2 = gst_thread_new("thread2"); - g_assert(thread2 != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); + thread2 = gst_thread_new ("thread2"); + g_assert (thread2 != NULL); /* create a new bin to hold the elements */ - bin = gst_bin_new("bin"); - g_assert(bin != NULL); + bin = gst_bin_new ("bin"); + g_assert (bin != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect(G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); - queue = gst_element_factory_make("queue", "queue"); - queue2 = gst_element_factory_make("queue", "queue2"); + queue = gst_element_factory_make ("queue", "queue"); + queue2 = gst_element_factory_make ("queue", "queue2"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); - parse = gst_element_factory_make("mp3parse", "parse"); - decode = gst_element_factory_make("mpg123", "decode"); + parse = gst_element_factory_make ("mp3parse", "parse"); + decode = gst_element_factory_make ("mpg123", "decode"); /* add objects to the main bin */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), queue); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), queue); - gst_bin_add(GST_BIN(thread), parse); - gst_bin_add(GST_BIN(thread), decode); - gst_bin_add(GST_BIN(thread), queue2); + gst_bin_add (GST_BIN (thread), parse); + gst_bin_add (GST_BIN (thread), decode); + gst_bin_add (GST_BIN (thread), queue2); - gst_bin_add(GST_BIN(thread2), osssink); + gst_bin_add (GST_BIN (thread2), osssink); gst_element_link_many (filesrc, queue, parse, decode, queue2, osssink, NULL); - gst_bin_add(GST_BIN(bin), thread); - gst_bin_add(GST_BIN(bin), thread2); + gst_bin_add (GST_BIN (bin), thread); + gst_bin_add (GST_BIN (bin), thread2); /* make it ready */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); playing = TRUE; while (playing) { - gst_bin_iterate(GST_BIN(bin)); + gst_bin_iterate (GST_BIN (bin)); } - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/examples/retag/retag.c b/examples/retag/retag.c index 8ab3fb9b0..0b10fa353 100644 --- a/examples/retag/retag.c +++ b/examples/retag/retag.c @@ -16,11 +16,11 @@ #include int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *tag_changer, *filesink; gchar *artist, *title, *ext, *filename; - + /* initialize GStreamer */ gst_init (&argc, &argv); @@ -36,7 +36,8 @@ main (int argc, char *argv[]) artist = argv[1]; artist = g_strdup (artist); ext = strrchr (artist, '.'); - if (ext) *ext = '\0'; + if (ext) + *ext = '\0'; title = strstr (artist, " - "); if (title == NULL) { g_print ("The format of the mp3 file is invalid.\n"); @@ -44,8 +45,8 @@ main (int argc, char *argv[]) } *title = '\0'; title += 3; - - + + /* create a new bin to hold the elements */ bin = gst_pipeline_new ("pipeline"); g_assert (bin); @@ -66,25 +67,24 @@ main (int argc, char *argv[]) g_assert (filesink); /* set the filenames */ - filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */ + filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesink), "location", filename, NULL); /* make sure the tag setter uses our stuff (though that should already be default) */ - gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_KEEP); + gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer), + GST_TAG_MERGE_KEEP); /* set the tagging information */ gst_tag_setter_add (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_REPLACE, - GST_TAG_ARTIST, artist, - GST_TAG_TITLE, title, - NULL); + GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (bin), filesrc, tag_changer, filesink, NULL); /* link the elements */ g_assert (gst_element_link_many (filesrc, tag_changer, filesink)); - + /* start playing */ gst_element_set_state (bin, GST_STATE_PLAYING); @@ -100,4 +100,3 @@ main (int argc, char *argv[]) return 0; } - diff --git a/examples/retag/transcode.c b/examples/retag/transcode.c index 07bd64fc1..ba0d98634 100644 --- a/examples/retag/transcode.c +++ b/examples/retag/transcode.c @@ -16,11 +16,11 @@ #include int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *decoder, *encoder, *filesink; gchar *artist, *title, *ext, *filename; - + /* initialize GStreamer */ gst_init (&argc, &argv); @@ -36,7 +36,8 @@ main (int argc, char *argv[]) artist = argv[1]; artist = g_strdup (artist); ext = strrchr (artist, '.'); - if (ext) *ext = '\0'; + if (ext) + *ext = '\0'; title = strstr (artist, " - "); if (title == NULL) { g_print ("The format of the mp3 file is invalid.\n"); @@ -45,8 +46,8 @@ main (int argc, char *argv[]) } *title = '\0'; title += 3; - - + + /* create a new bin to hold the elements */ bin = gst_pipeline_new ("pipeline"); g_assert (bin); @@ -68,13 +69,13 @@ main (int argc, char *argv[]) g_print ("cound not find plugin \"vorbisenc\""); return 1; } - + /* and a file writer */ filesink = gst_element_factory_make ("filesink", "filesink"); g_assert (filesink); /* set the filenames */ - filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */ + filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesink), "location", filename, NULL); g_free (filename); @@ -84,16 +85,14 @@ main (int argc, char *argv[]) gst_tag_setter_set_merge_mode (GST_TAG_SETTER (encoder), GST_TAG_MERGE_KEEP); /* set the tagging information */ gst_tag_setter_add (GST_TAG_SETTER (encoder), GST_TAG_MERGE_REPLACE, - GST_TAG_ARTIST, artist, - GST_TAG_TITLE, title, - NULL); + GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (bin), filesrc, decoder, encoder, filesink, NULL); /* link the elements */ gst_element_link_many (filesrc, decoder, encoder, filesink, NULL); - + /* start playing */ gst_element_set_state (bin, GST_STATE_PLAYING); @@ -104,4 +103,3 @@ main (int argc, char *argv[]) return 0; } - diff --git a/examples/thread/thread.c b/examples/thread/thread.c index f47deca1d..5478da84d 100644 --- a/examples/thread/thread.c +++ b/examples/thread/thread.c @@ -2,73 +2,75 @@ #include /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - GstThread *thread = GST_THREAD(data); - g_print("have eos, quitting\n"); + GstThread *thread = GST_THREAD (data); + + g_print ("have eos, quitting\n"); /* stop the bin */ - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL); - gst_main_quit(); + gst_main_quit (); } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink; GstElement *pipeline; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - pipeline = gst_pipeline_new("pipeline"); - g_assert(pipeline != NULL); + pipeline = gst_pipeline_new ("pipeline"); + g_assert (pipeline != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect(G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); /* add objects to the main pipeline */ /* - gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); - gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink); + gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); + gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink); - if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { - g_print("unable to handle stream\n"); - exit(-1); - } - */ + if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { + g_print("unable to handle stream\n"); + exit(-1); + } + */ /*gst_bin_remove(GST_BIN(pipeline), filesrc); */ /*gst_bin_add(GST_BIN(thread), filesrc); */ - gst_bin_add(GST_BIN(thread), GST_ELEMENT(pipeline)); + gst_bin_add (GST_BIN (thread), GST_ELEMENT (pipeline)); /* make it ready */ - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); - gst_main(); + gst_main (); - gst_object_unref(GST_OBJECT(thread)); + gst_object_unref (GST_OBJECT (thread)); - exit(0); + exit (0); } diff --git a/examples/typefind/typefind.c b/examples/typefind/typefind.c index a562306d3..1640ce29e 100644 --- a/examples/typefind/typefind.c +++ b/examples/typefind/typefind.c @@ -1,12 +1,12 @@ #include void -type_found (GstElement *typefind, const GstCaps * caps) +type_found (GstElement * typefind, const GstCaps * caps) { xmlDocPtr doc; xmlNodePtr parent; - - doc = xmlNewDoc ("1.0"); + + doc = xmlNewDoc ("1.0"); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL); parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL); @@ -16,46 +16,45 @@ type_found (GstElement *typefind, const GstCaps * caps) xmlDocDump (stdout, doc); } -int -main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *typefind; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new bin to hold the elements */ - bin = gst_pipeline_new("bin"); - g_assert(bin != NULL); + bin = gst_pipeline_new ("bin"); + g_assert (bin != NULL); /* create a file reader */ - filesrc = gst_element_factory_make("filesrc", "file_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); + filesrc = gst_element_factory_make ("filesrc", "file_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); - typefind = gst_element_factory_make("typefind", "typefind"); - g_assert(typefind != NULL); + typefind = gst_element_factory_make ("typefind", "typefind"); + g_assert (typefind != NULL); /* add objects to the main pipeline */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), typefind); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), typefind); - g_signal_connect (G_OBJECT (typefind), "have_type", - G_CALLBACK (type_found), NULL); + g_signal_connect (G_OBJECT (typefind), "have_type", + G_CALLBACK (type_found), NULL); gst_element_link (filesrc, typefind); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); - gst_bin_iterate(GST_BIN(bin)); + gst_bin_iterate (GST_BIN (bin)); - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/examples/xml/createxml.c b/examples/xml/createxml.c index c0c93e9a4..d1426e2d0 100644 --- a/examples/xml/createxml.c +++ b/examples/xml/createxml.c @@ -4,34 +4,37 @@ gboolean playing; static void -object_saved (GstObject *object, xmlNodePtr parent, gpointer data) +object_saved (GstObject * object, xmlNodePtr parent, gpointer data) { xmlNodePtr child; xmlNsPtr ns; - + /* first see if the namespace is already known */ - ns = xmlSearchNsByHref (parent->doc, parent, "http://gstreamer.net/gst-test/1.0/"); + ns = xmlSearchNsByHref (parent->doc, parent, + "http://gstreamer.net/gst-test/1.0/"); if (ns == NULL) { xmlNodePtr root = xmlDocGetRootElement (parent->doc); + /* add namespace to root node */ ns = xmlNewNs (root, "http://gstreamer.net/gst-test/1.0/", "test"); } - child = xmlNewChild(parent, ns, "comment", NULL); - - xmlNewChild(child, NULL, "text", (gchar *)data); + child = xmlNewChild (parent, ns, "comment", NULL); + + xmlNewChild (child, NULL, "text", (gchar *) data); } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue, *queue2, *decode; GstElement *pipeline; GstElement *thread, *thread2; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create new threads to hold the elements */ @@ -42,12 +45,10 @@ int main(int argc,char *argv[]) /* these signals will allow us to save custom tags with the gst xml output */ g_signal_connect (G_OBJECT (thread), "object_saved", - G_CALLBACK (object_saved), - g_strdup ("decoder thread")); + G_CALLBACK (object_saved), g_strdup ("decoder thread")); g_signal_connect (G_OBJECT (thread2), "object_saved", - G_CALLBACK (object_saved), - g_strdup ("render thread")); - + G_CALLBACK (object_saved), g_strdup ("render thread")); + /* create a new bin to hold the elements */ pipeline = gst_pipeline_new ("pipeline"); g_assert (pipeline != NULL); @@ -89,4 +90,3 @@ int main(int argc,char *argv[]) exit (0); } - diff --git a/examples/xml/runxml.c b/examples/xml/runxml.c index e754d5f09..119d05ec3 100644 --- a/examples/xml/runxml.c +++ b/examples/xml/runxml.c @@ -5,7 +5,7 @@ gboolean playing; G_GNUC_UNUSED static void -xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data) +xml_loaded (GstXML * xml, GstObject * object, xmlNodePtr self, gpointer data) { xmlNodePtr children = self->xmlChildrenNode; @@ -14,10 +14,11 @@ xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data) xmlNodePtr nodes = children->xmlChildrenNode; while (nodes) { - if (!strcmp (nodes->name, "text")) { - gchar *name = g_strdup (xmlNodeGetContent (nodes)); - g_print ("object %s loaded with comment '%s'\n", - gst_object_get_name (object), name); + if (!strcmp (nodes->name, "text")) { + gchar *name = g_strdup (xmlNodeGetContent (nodes)); + + g_print ("object %s loaded with comment '%s'\n", + gst_object_get_name (object), name); } nodes = nodes->next; } @@ -26,13 +27,14 @@ xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data) } } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstXML *xml; GstElement *pipeline; gboolean ret; - gst_init(&argc,&argv); + gst_init (&argc, &argv); xml = gst_xml_new (); @@ -40,21 +42,20 @@ int main(int argc,char *argv[]) /* G_CALLBACK (xml_loaded), xml); */ if (argc == 2) - ret = gst_xml_parse_file(xml, argv[1], NULL); + ret = gst_xml_parse_file (xml, argv[1], NULL); else - ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL); - + ret = gst_xml_parse_file (xml, "xmlTest.gst", NULL); + g_assert (ret == TRUE); - pipeline = gst_xml_get_element(xml, "pipeline"); + pipeline = gst_xml_get_element (xml, "pipeline"); g_assert (pipeline != NULL); - gst_element_set_state(pipeline, GST_STATE_PLAYING); + gst_element_set_state (pipeline, GST_STATE_PLAYING); - while (gst_bin_iterate(GST_BIN(pipeline))); + while (gst_bin_iterate (GST_BIN (pipeline))); - gst_element_set_state(pipeline, GST_STATE_NULL); + gst_element_set_state (pipeline, GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/gst/autoplug/gstsearchfuncs.c b/gst/autoplug/gstsearchfuncs.c index 10da7d56b..e8e6afc9d 100644 --- a/gst/autoplug/gstsearchfuncs.c +++ b/gst/autoplug/gstsearchfuncs.c @@ -35,17 +35,17 @@ GST_DEBUG_CATEGORY_EXTERN (GST_CAT_AUTOPLUG_ATTEMPT); * though the GLib version should take a function as argument... */ static void -g_list_free_list_and_elements (GList *list) +g_list_free_list_and_elements (GList * list) { GList *walk = list; - - while (walk) - { + + while (walk) { g_free (walk->data); walk = g_list_next (walk); } g_list_free (list); } + /** * gst_autoplug_caps_intersect: * @src: a source #GstCaps @@ -56,19 +56,19 @@ g_list_free_list_and_elements (GList *list) * Returns: TRUE, if both caps intersect. */ gboolean -gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink) +gst_autoplug_caps_intersect (const GstCaps * src, const GstCaps * sink) { GstCaps *caps; /* get an intersection */ caps = gst_caps_intersect (src, sink); - + /* if the caps can't link, there is no intersection */ if (gst_caps_is_empty (caps)) { gst_caps_free (caps); return FALSE; } - + /* hurrah, we can link, now remove the intersection */ gst_caps_free (caps); return TRUE; @@ -84,25 +84,24 @@ gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink) * Returns: #GstPadTemplate that can connect to the given caps */ GstPadTemplate * -gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src) +gst_autoplug_can_connect_src (GstElementFactory * fac, const GstCaps * src) { GList *templs; - + templs = fac->padtemplates; - - while (templs) - { - if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && - gst_autoplug_caps_intersect (src, - GST_PAD_TEMPLATE_CAPS (templs->data))) - { + + while (templs) { + if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && + gst_autoplug_caps_intersect (src, + GST_PAD_TEMPLATE_CAPS (templs->data))) { return GST_PAD_TEMPLATE (templs->data); } templs = g_list_next (templs); } - - return NULL; + + return NULL; } + /** * gst_autoplug_can_connect_sink: * @fac: factory to connect to @@ -113,74 +112,73 @@ gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src) * Returns: #GstPadTemplate that can connect to the given caps */ GstPadTemplate * -gst_autoplug_can_connect_sink (GstElementFactory *fac, const GstCaps *sink) +gst_autoplug_can_connect_sink (GstElementFactory * fac, const GstCaps * sink) { GList *templs; - + templs = fac->padtemplates; - - while (templs) - { + + while (templs) { GstCaps *caps = GST_PAD_TEMPLATE_CAPS (templs->data); + if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) && - gst_autoplug_caps_intersect (caps, sink)) - { + gst_autoplug_caps_intersect (caps, sink)) { return GST_PAD_TEMPLATE (templs->data); } templs = g_list_next (templs); } - return NULL; + return NULL; } + GstPadTemplate * -gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest) +gst_autoplug_can_match (GstElementFactory * src, GstElementFactory * dest) { GList *srctemps, *desttemps; srctemps = src->padtemplates; while (srctemps) { - GstPadTemplate *srctemp = (GstPadTemplate *)srctemps->data; + GstPadTemplate *srctemp = (GstPadTemplate *) srctemps->data; desttemps = dest->padtemplates; while (desttemps) { - GstPadTemplate *desttemp = (GstPadTemplate *)desttemps->data; + GstPadTemplate *desttemp = (GstPadTemplate *) desttemps->data; if (srctemp->direction == GST_PAD_SRC && - desttemp->direction == GST_PAD_SINK) { - if (gst_autoplug_caps_intersect (gst_pad_template_get_caps (srctemp), - gst_pad_template_get_caps (desttemp))) { - GST_DEBUG ("factory \"%s\" can connect with factory \"%s\"", - GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest)); - return desttemp; - } + desttemp->direction == GST_PAD_SINK) { + if (gst_autoplug_caps_intersect (gst_pad_template_get_caps (srctemp), + gst_pad_template_get_caps (desttemp))) { + GST_DEBUG ("factory \"%s\" can connect with factory \"%s\"", + GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest)); + return desttemp; + } } desttemps = g_list_next (desttemps); } srctemps = g_list_next (srctemps); } - GST_DEBUG ("factory \"%s\" cannot connect with factory \"%s\"", - GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest)); + GST_DEBUG ("factory \"%s\" cannot connect with factory \"%s\"", + GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest)); return NULL; } /* returns TRUE if the factory has padtemplates with the specified direction */ gboolean -gst_autoplug_factory_has_direction (GstElementFactory *fac, GstPadDirection dir) +gst_autoplug_factory_has_direction (GstElementFactory * fac, + GstPadDirection dir) { GList *templs = fac->padtemplates; - - while (templs) - { - if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) - { + + while (templs) { + if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) { return TRUE; } templs = g_list_next (templs); } - + return FALSE; } @@ -188,52 +186,54 @@ gst_autoplug_factory_has_direction (GstElementFactory *fac, GstPadDirection dir) * These functions return a new list so be sure to free it. */ GList * -gst_autoplug_factories_sinks (GList *factories) +gst_autoplug_factories_sinks (GList * factories) { GList *ret = NULL; - - while (factories) - { + + while (factories) { if (gst_autoplug_factory_has_sink (factories->data)) ret = g_list_prepend (ret, factories->data); factories = g_list_next (factories); } - return ret; + return ret; } + GList * -gst_autoplug_factories_srcs (GList *factories) +gst_autoplug_factories_srcs (GList * factories) { GList *ret = NULL; - - while (factories) - { + + while (factories) { if (gst_autoplug_factory_has_src (factories->data)) ret = g_list_prepend (ret, factories->data); factories = g_list_next (factories); } - return ret; + return ret; } -GList * -gst_autoplug_factories_filters (GList *factories) + +GList * +gst_autoplug_factories_filters (GList * factories) { GList *ret = NULL; - - while (factories) - { + + while (factories) { /* if you want it faster do src/sink check at once, don't call two functions */ - if (gst_autoplug_factory_has_src (factories->data) && gst_autoplug_factory_has_sink (factories->data)) + if (gst_autoplug_factory_has_src (factories->data) + && gst_autoplug_factory_has_sink (factories->data)) ret = g_list_prepend (ret, factories->data); factories = g_list_next (factories); } - return ret; + return ret; } -static gint -gst_autoplug_rank_compare (const GstElementFactory *a, const GstElementFactory *b) +static gint +gst_autoplug_rank_compare (const GstElementFactory * a, + const GstElementFactory * b) { - if (GST_PLUGIN_FEATURE (a)->rank > GST_PLUGIN_FEATURE (b)->rank) return -1; - return (GST_PLUGIN_FEATURE (a)->rank < GST_PLUGIN_FEATURE (b)->rank) ? 1 : 0; + if (GST_PLUGIN_FEATURE (a)->rank > GST_PLUGIN_FEATURE (b)->rank) + return -1; + return (GST_PLUGIN_FEATURE (a)->rank < GST_PLUGIN_FEATURE (b)->rank) ? 1 : 0; } /* returns all factories which have sinks with non-NULL caps and srcs with @@ -241,42 +241,38 @@ gst_autoplug_rank_compare (const GstElementFactory *a, const GstElementFactory * * rank descending. */ GList * -gst_autoplug_factories_filters_with_sink_caps (GList *factories) +gst_autoplug_factories_filters_with_sink_caps (GList * factories) { GList *ret = NULL; GstElementFactory *factory; GList *templs; - while (factories) - { + while (factories) { factory = (GstElementFactory *) factories->data; templs = factory->padtemplates; - if (GST_PLUGIN_FEATURE (factory)->rank > 0){ + if (GST_PLUGIN_FEATURE (factory)->rank > 0) { gboolean have_src = FALSE; gboolean have_sink = FALSE; - while (templs) - { - if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) - { - have_src = TRUE; - } - if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && (GST_PAD_TEMPLATE_CAPS (templs->data) != NULL)) - { - have_sink = TRUE; - } - if (have_src && have_sink) - { - ret = g_list_prepend (ret, factory); - break; - } - templs = g_list_next (templs); + while (templs) { + if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) { + have_src = TRUE; + } + if ((GST_PAD_TEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) + && (GST_PAD_TEMPLATE_CAPS (templs->data) != NULL)) { + have_sink = TRUE; + } + if (have_src && have_sink) { + ret = g_list_prepend (ret, factory); + break; + } + templs = g_list_next (templs); } } factories = g_list_next (factories); } - return g_list_sort(ret, (GCompareFunc)gst_autoplug_rank_compare); + return g_list_sort (ret, (GCompareFunc) gst_autoplug_rank_compare); } @@ -284,32 +280,31 @@ gst_autoplug_factories_filters_with_sink_caps (GList *factories) /* returns all factories which have a maximum of maxtemplates GstPadTemplates in direction dir */ GList * -gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates) +gst_autoplug_factories_at_most_templates (GList * factories, + GstPadDirection dir, guint maxtemplates) { GList *ret = NULL; - - while (factories) - { + + while (factories) { guint count = 0; GList *templs = ((GstElementFactory *) factories->data)->padtemplates; - while (templs) - { - if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) - { - count++; + while (templs) { + if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) { + count++; } if (count > maxtemplates) - break; + break; templs = g_list_next (templs); } if (count <= maxtemplates) ret = g_list_prepend (ret, factories->data); - + factories = g_list_next (factories); } return ret; } + /********************************************************************* * * SHORTEST PATH ALGORITHM @@ -327,39 +322,38 @@ gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir, * to get the shortest path. */ GList * -gst_autoplug_sp (const GstCaps *srccaps, const GstCaps *sinkcaps, GList *factories) +gst_autoplug_sp (const GstCaps * srccaps, const GstCaps * sinkcaps, + GList * factories) { GList *factory_nodes = NULL; - guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */ - GstAutoplugNode *bestnode = NULL; /* best (unconnected) endpoint currently */ - + guint curcost = GST_AUTOPLUG_MAX_COST; /* below this cost, there is no path */ + GstAutoplugNode *bestnode = NULL; /* best (unconnected) endpoint currently */ + g_return_val_if_fail (srccaps != NULL, NULL); g_return_val_if_fail (sinkcaps != NULL, NULL); - + GST_INFO ("attempting to autoplug via shortest path from %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, srccaps, sinkcaps); /* wrap all factories as GstAutoplugNode * initialize the cost */ - while (factories) - { + while (factories) { GstAutoplugNode *node = g_new0 (GstAutoplugNode, 1); + node->prev = NULL; node->fac = (GstElementFactory *) factories->data; GST_DEBUG ("trying with %s", node->fac->details.longname); node->templ = gst_autoplug_can_connect_src (node->fac, srccaps); - node->cost = (node->templ ? gst_autoplug_get_cost (node->fac) - : GST_AUTOPLUG_MAX_COST); + node->cost = (node->templ ? gst_autoplug_get_cost (node->fac) + : GST_AUTOPLUG_MAX_COST); node->endpoint = gst_autoplug_can_connect_sink (node->fac, sinkcaps); if (node->templ && node->endpoint) - GST_DEBUG ("%s makes connection possible", - node->fac->details.longname); + GST_DEBUG ("%s makes connection possible", node->fac->details.longname); else GST_DEBUG ("direct connection with %s not possible", - node->fac->details.longname); - if ((node->endpoint != NULL) && - ((bestnode == NULL) || (node->cost < bestnode->cost))) - { + node->fac->details.longname); + if ((node->endpoint != NULL) && + ((bestnode == NULL) || (node->cost < bestnode->cost))) { bestnode = node; } factory_nodes = g_list_prepend (factory_nodes, node); @@ -367,80 +361,81 @@ gst_autoplug_sp (const GstCaps *srccaps, const GstCaps *sinkcaps, GList *factori curcost = node->cost < curcost ? node->cost : curcost; factories = g_list_next (factories); } - + /* check if we even have possible endpoints */ - if (bestnode == NULL) - { + if (bestnode == NULL) { GST_DEBUG ("no factory found that could connect to sink caps"); g_list_free_list_and_elements (factory_nodes); return NULL; } - + /* iterate until we found the best path */ - while (curcost < GST_AUTOPLUG_MAX_COST) - { + while (curcost < GST_AUTOPLUG_MAX_COST) { GList *nodes = factory_nodes; - guint nextcost = GST_AUTOPLUG_MAX_COST; /* next cost to check */ - GST_DEBUG ("iterating at current cost %d, bestnode %s at %d", curcost, GST_OBJECT_NAME (bestnode->fac), bestnode->cost); + guint nextcost = GST_AUTOPLUG_MAX_COST; /* next cost to check */ + + GST_DEBUG ("iterating at current cost %d, bestnode %s at %d", curcost, + GST_OBJECT_NAME (bestnode->fac), bestnode->cost); /* check if we already have a valid best connection to the sink */ - if (bestnode->cost <= curcost) - { + if (bestnode->cost <= curcost) { GList *ret; - GST_DEBUG ("found a way to connect via %s", GST_OBJECT_NAME ((GstObject *) bestnode->fac)); + + GST_DEBUG ("found a way to connect via %s", + GST_OBJECT_NAME ((GstObject *) bestnode->fac)); /* enter all factories into the return list */ ret = g_list_prepend (NULL, bestnode->fac); bestnode = bestnode->prev; - while (bestnode != NULL) - { - ret = g_list_prepend (ret, bestnode->fac); - bestnode = bestnode->prev; + while (bestnode != NULL) { + ret = g_list_prepend (ret, bestnode->fac); + bestnode = bestnode->prev; } g_list_free_list_and_elements (factory_nodes); return ret; } - + /* iterate over all factories we have * if they have the current cost, calculate if this * factory supplies shorter paths to other elements */ - while (nodes) - { - if (((GstAutoplugNode *) nodes->data)->cost == curcost) - { - /* now check all elements if we got a shorter path */ - GList *sinknodes = factory_nodes; - GstAutoplugNode *srcnode = (GstAutoplugNode *) nodes->data; - while (sinknodes) - { - GstAutoplugNode *sinknode = (GstAutoplugNode *) sinknodes->data; - GstPadTemplate *templ; - if ((sinknode->cost > srcnode->cost + gst_autoplug_get_cost (sinknode->fac)) && (templ = gst_autoplug_can_match(srcnode->fac, sinknode->fac))) - { - /* we got a shorter path - * now enter that path to that node */ - sinknode->prev = srcnode; - sinknode->templ = templ; - sinknode->cost = srcnode->cost + gst_autoplug_get_cost (sinknode->fac); - /* make sure to set which cost to view next */ - nextcost = (nextcost > sinknode->cost) ? sinknode->cost : nextcost; - /* did we get a new best node? */ - if (sinknode->endpoint && (sinknode->cost < bestnode->cost)) - { - bestnode = sinknode; - } - } - sinknodes = g_list_next (sinknodes); - } - /* FIXME: for speed remove the item we just iterated with from the factory_nodes - * but don't free it yet and don't forget to free it. - */ + while (nodes) { + if (((GstAutoplugNode *) nodes->data)->cost == curcost) { + /* now check all elements if we got a shorter path */ + GList *sinknodes = factory_nodes; + GstAutoplugNode *srcnode = (GstAutoplugNode *) nodes->data; + + while (sinknodes) { + GstAutoplugNode *sinknode = (GstAutoplugNode *) sinknodes->data; + GstPadTemplate *templ; + + if ((sinknode->cost > + srcnode->cost + gst_autoplug_get_cost (sinknode->fac)) + && (templ = + gst_autoplug_can_match (srcnode->fac, sinknode->fac))) { + /* we got a shorter path + * now enter that path to that node */ + sinknode->prev = srcnode; + sinknode->templ = templ; + sinknode->cost = + srcnode->cost + gst_autoplug_get_cost (sinknode->fac); + /* make sure to set which cost to view next */ + nextcost = (nextcost > sinknode->cost) ? sinknode->cost : nextcost; + /* did we get a new best node? */ + if (sinknode->endpoint && (sinknode->cost < bestnode->cost)) { + bestnode = sinknode; + } + } + sinknodes = g_list_next (sinknodes); + } + /* FIXME: for speed remove the item we just iterated with from the factory_nodes + * but don't free it yet and don't forget to free it. + */ } nodes = g_list_next (nodes); } curcost = nextcost; } - - GST_DEBUG ("found no path from source caps to sink caps"); + + GST_DEBUG ("found no path from source caps to sink caps"); g_list_free_list_and_elements (factory_nodes); - return NULL; + return NULL; } diff --git a/gst/autoplug/gstsearchfuncs.h b/gst/autoplug/gstsearchfuncs.h index 0b8d8dfa0..db944cc9d 100644 --- a/gst/autoplug/gstsearchfuncs.h +++ b/gst/autoplug/gstsearchfuncs.h @@ -30,21 +30,27 @@ /* struct for a node, in the search tree */ typedef struct _GstAutoplugNode GstAutoplugNode; - -struct _GstAutoplugNode { - GstAutoplugNode *prev; /* previous node */ - GstElementFactory *fac; /* factory of element to connect to */ - GstPadTemplate *templ; /* template which can connect */ - guint cost; /* total cost to get here */ - GstPadTemplate *endpoint; /* pad template that can connect to sink caps */ + +struct _GstAutoplugNode +{ + GstAutoplugNode *prev; /* previous node */ + GstElementFactory *fac; /* factory of element to connect to */ + GstPadTemplate *templ; /* template which can connect */ + guint cost; /* total cost to get here */ + GstPadTemplate *endpoint; /* pad template that can connect to sink caps */ }; /* helper functions */ -gboolean gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink); -GstPadTemplate * gst_autoplug_can_connect_src (GstElementFactory *fac, const GstCaps *src); -GstPadTemplate * gst_autoplug_can_connect_sink (GstElementFactory *fac, const GstCaps *sink); -GstPadTemplate * gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest); -gboolean gst_autoplug_factory_has_direction (GstElementFactory *fac, GstPadDirection dir); +gboolean gst_autoplug_caps_intersect (const GstCaps * src, + const GstCaps * sink); +GstPadTemplate *gst_autoplug_can_connect_src (GstElementFactory * fac, + const GstCaps * src); +GstPadTemplate *gst_autoplug_can_connect_sink (GstElementFactory * fac, + const GstCaps * sink); +GstPadTemplate *gst_autoplug_can_match (GstElementFactory * src, + GstElementFactory * dest); +gboolean gst_autoplug_factory_has_direction (GstElementFactory * fac, + GstPadDirection dir); #define gst_autoplug_factory_has_sink(fac) gst_autoplug_factory_has_direction((fac), GST_PAD_SINK) #define gst_autoplug_factory_has_src(fac) gst_autoplug_factory_has_direction((fac), GST_PAD_SRC) @@ -52,13 +58,15 @@ gboolean gst_autoplug_factory_has_direction (Gs #define gst_autoplug_get_cost(fac) 1 /* factory selections */ -GList * gst_autoplug_factories_sinks (GList *factories); -GList * gst_autoplug_factories_srcs (GList *factories); -GList * gst_autoplug_factories_filters (GList *factories); -GList * gst_autoplug_factories_filters_with_sink_caps(GList *factories); -GList * gst_autoplug_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates); +GList *gst_autoplug_factories_sinks (GList * factories); +GList *gst_autoplug_factories_srcs (GList * factories); +GList *gst_autoplug_factories_filters (GList * factories); +GList *gst_autoplug_factories_filters_with_sink_caps (GList * factories); +GList *gst_autoplug_factories_at_most_templates (GList * factories, + GstPadDirection dir, guint maxtemplates); /* shortest path algorithm */ -GList * gst_autoplug_sp (const GstCaps *src_caps, const GstCaps *sink_caps, GList *factories); +GList *gst_autoplug_sp (const GstCaps * src_caps, const GstCaps * sink_caps, + GList * factories); #endif /* __GST_SEARCHFUNCS_H__ */ diff --git a/gst/autoplug/gstspider.c b/gst/autoplug/gstspider.c index 7182cc0bc..58e98844f 100644 --- a/gst/autoplug/gstspider.c +++ b/gst/autoplug/gstspider.c @@ -19,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - + /* * TODO: * - handle automatic removal of unneeded elements @@ -54,12 +54,14 @@ GST_DEBUG_CATEGORY (gst_spider_debug); #define GST_CAT_DEFAULT gst_spider_debug /* signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_FACTORIES, /* FILL ME TOO */ @@ -67,88 +69,96 @@ enum { /* generic templates */ static GstStaticPadTemplate spider_src_factory = -GST_STATIC_PAD_TEMPLATE ( - "src_%d", - GST_PAD_SRC, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GST_STATIC_PAD_TEMPLATE ("src_%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); /* standard GObject stuff */ -static void gst_spider_class_init (GstSpiderClass *klass); -static void gst_spider_init (GstSpider *spider); -static void gst_spider_dispose (GObject *object); +static void gst_spider_class_init (GstSpiderClass * klass); +static void gst_spider_init (GstSpider * spider); +static void gst_spider_dispose (GObject * object); /* element class functions */ -static GstPad* gst_spider_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name); -static void gst_spider_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_spider_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static GstPad *gst_spider_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * name); +static void gst_spider_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_spider_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); /* link functions */ -static GstSpiderConnection * gst_spider_link_new (GstSpiderIdentity *src); -static void gst_spider_link_destroy (GstSpiderConnection *conn); -static void gst_spider_link_reset (GstSpiderConnection *conn, GstElement *to); -static void gst_spider_link_add (GstSpiderConnection *conn, GstElement *element); -static GstSpiderConnection * gst_spider_link_find (GstSpiderIdentity *src); -static GstSpiderConnection * gst_spider_link_get (GstSpiderIdentity *src); +static GstSpiderConnection *gst_spider_link_new (GstSpiderIdentity * src); +static void gst_spider_link_destroy (GstSpiderConnection * conn); +static void gst_spider_link_reset (GstSpiderConnection * conn, GstElement * to); +static void gst_spider_link_add (GstSpiderConnection * conn, + GstElement * element); +static GstSpiderConnection *gst_spider_link_find (GstSpiderIdentity * src); +static GstSpiderConnection *gst_spider_link_get (GstSpiderIdentity * src); /* autoplugging functions */ -static GstElement * gst_spider_find_element_to_plug (GstElement *src, GstElementFactory *fac, GstPadDirection dir); -static GstPadLinkReturn gst_spider_plug (GstSpiderConnection *conn); -static GstPadLinkReturn gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad); +static GstElement *gst_spider_find_element_to_plug (GstElement * src, + GstElementFactory * fac, GstPadDirection dir); +static GstPadLinkReturn gst_spider_plug (GstSpiderConnection * conn); +static GstPadLinkReturn gst_spider_plug_from_srcpad (GstSpiderConnection * conn, + GstPad * srcpad); /*static GstPadLinkReturn gst_spider_plug_peers (GstSpider *spider, GstPad *srcpad, GstPad *sinkpad); */ -static GstPadLinkReturn gst_spider_create_and_plug (GstSpiderConnection *conn, GList *plugpath); +static GstPadLinkReturn gst_spider_create_and_plug (GstSpiderConnection * conn, + GList * plugpath); /* random functions */ -static gchar * gst_spider_unused_elementname (GstBin *bin, const gchar *startwith); +static gchar *gst_spider_unused_elementname (GstBin * bin, + const gchar * startwith); /* debugging stuff static void print_spider_contents (GstSpider *spider); static void print_spider_link (GstSpiderConnection *conn); */ /* === variables === */ -static GstElementClass * parent_class = NULL; +static GstElementClass *parent_class = NULL; /* no signals yet static guint gst_spider_signals[LAST_SIGNAL] = { 0 };*/ /* GObject and GStreamer init functions */ GType -gst_spider_get_type(void) +gst_spider_get_type (void) { static GType spider_type = 0; if (!spider_type) { static const GTypeInfo spider_info = { - sizeof(GstSpiderClass), + sizeof (GstSpiderClass), NULL, NULL, (GClassInitFunc) gst_spider_class_init, NULL, NULL, - sizeof(GstSpider), + sizeof (GstSpider), 0, - (GInstanceInitFunc)gst_spider_init, + (GInstanceInitFunc) gst_spider_init, }; - spider_type = g_type_register_static (GST_TYPE_BIN, "GstSpider", &spider_info, 0); + spider_type = + g_type_register_static (GST_TYPE_BIN, "GstSpider", &spider_info, 0); } return spider_type; } static void -gst_spider_class_init (GstSpiderClass *klass) +gst_spider_class_init (GstSpiderClass * klass) { - GObjectClass *gobject_class; - GstElementClass *gstelement_class; + GObjectClass *gobject_class; + GstElementClass *gstelement_class; - gobject_class = (GObjectClass*) klass; - gstelement_class = (GstElementClass*) klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_BIN); + parent_class = g_type_class_ref (GST_TYPE_BIN); /* properties */ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FACTORIES, - g_param_spec_pointer ("factories", "allowed factories", "allowed factories for autoplugging", G_PARAM_READWRITE)); + g_param_spec_pointer ("factories", "allowed factories", + "allowed factories for autoplugging", G_PARAM_READWRITE)); gobject_class->set_property = gst_spider_set_property; gobject_class->get_property = gst_spider_get_property; @@ -157,74 +167,81 @@ gst_spider_class_init (GstSpiderClass *klass) gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&spider_src_factory)); gst_element_class_set_details (gstelement_class, &gst_spider_details); - - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_request_new_pad); + + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_spider_request_new_pad); } -static void -gst_spider_init (GstSpider *spider) +static void +gst_spider_init (GstSpider * spider) { /* use only elements which have sources and sinks and where the sinks have caps */ /* FIXME: How do we handle factories that are added after the spider was constructed? */ - spider->factories = gst_autoplug_factories_filters_with_sink_caps ((GList *) - gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY)); + spider->factories = gst_autoplug_factories_filters_with_sink_caps ((GList *) + gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY)); spider->links = NULL; spider->sink_ident = gst_spider_identity_new_sink ("sink_ident"); gst_bin_add (GST_BIN (spider), GST_ELEMENT (spider->sink_ident)); - gst_element_add_ghost_pad (GST_ELEMENT(spider), spider->sink_ident->sink, "sink"); - + gst_element_add_ghost_pad (GST_ELEMENT (spider), spider->sink_ident->sink, + "sink"); + } static void -gst_spider_dispose (GObject *object) +gst_spider_dispose (GObject * object) { GstSpider *spider; - + spider = GST_SPIDER (object); g_list_free (spider->factories); - + ((GObjectClass *) parent_class)->dispose (object); } static GstPad * -gst_spider_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name) +gst_spider_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * name) { GstPad *returnpad; gchar *padname; GstSpiderIdentity *identity; GstSpider *spider; - + g_return_val_if_fail (templ != NULL, NULL); g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL); - g_return_val_if_fail (GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC, NULL); - + g_return_val_if_fail (GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC, + NULL); + spider = GST_SPIDER (element); - + /* create an identity object, so we have a pad */ - padname = gst_spider_unused_elementname ((GstBin *)spider, "src_"); + padname = gst_spider_unused_elementname ((GstBin *) spider, "src_"); identity = gst_spider_identity_new_src (padname); returnpad = identity->src; - + /* FIXME: use the requested name for the pad */ - gst_object_replace ((GstObject **) &returnpad->padtemplate, (GstObject *) templ); - + gst_object_replace ((GstObject **) & returnpad->padtemplate, + (GstObject *) templ); + gst_bin_add (GST_BIN (element), GST_ELEMENT (identity)); - + returnpad = gst_element_add_ghost_pad (element, returnpad, padname); g_free (padname); gst_spider_link_new (identity); - GST_DEBUG ("successuflly created requested pad %s:%s", GST_DEBUG_PAD_NAME (returnpad)); - + GST_DEBUG ("successuflly created requested pad %s:%s", + GST_DEBUG_PAD_NAME (returnpad)); + return returnpad; } static void -gst_spider_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_spider_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstSpider *spider; GList *list; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_SPIDER (object)); @@ -233,8 +250,7 @@ gst_spider_set_property (GObject *object, guint prop_id, const GValue *value, GP switch (prop_id) { case ARG_FACTORIES: list = (GList *) g_value_get_pointer (value); - while (list) - { + while (list) { g_return_if_fail (list->data != NULL); g_return_if_fail (GST_IS_ELEMENT_FACTORY (list->data)); list = g_list_next (list); @@ -247,12 +263,13 @@ gst_spider_set_property (GObject *object, guint prop_id, const GValue *value, GP } } static void -gst_spider_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_spider_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstSpider *spider; /* it's not null if we got it, but it might not be ours */ - spider = GST_SPIDER(object); + spider = GST_SPIDER (object); switch (prop_id) { case ARG_FACTORIES: @@ -263,161 +280,167 @@ gst_spider_get_property (GObject *object, guint prop_id, GValue *value, GParamSp break; } } + /* get a name for an element that isn't used yet */ static gchar * -gst_spider_unused_elementname (GstBin *bin, const gchar *startwith) +gst_spider_unused_elementname (GstBin * bin, const gchar * startwith) { - gchar * name = g_strdup_printf ("%s%d", startwith, 0); + gchar *name = g_strdup_printf ("%s%d", startwith, 0); guint i; - - for (i = 0; gst_bin_get_by_name (bin, name) != NULL; ) - { + + for (i = 0; gst_bin_get_by_name (bin, name) != NULL;) { g_free (name); name = g_strdup_printf ("%s%d", startwith, ++i); } - + return name; } static void -gst_spider_link_sometimes (GstElement *src, GstPad *pad, GstSpiderConnection *conn) +gst_spider_link_sometimes (GstElement * src, GstPad * pad, + GstSpiderConnection * conn) { gulong signal_id = conn->signal_id; - + /* try to autoplug the elements */ if (gst_spider_plug_from_srcpad (conn, pad) != GST_PAD_LINK_REFUSED) { - GST_DEBUG ("%s:%s was autoplugged to %s:%s, removing callback", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (conn->src->sink)); + GST_DEBUG ("%s:%s was autoplugged to %s:%s, removing callback", + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (conn->src->sink)); g_signal_handler_disconnect (src, signal_id); signal_id = 0; } } + /* create a new link from those two elements */ static GstSpiderConnection * -gst_spider_link_new (GstSpiderIdentity *src) +gst_spider_link_new (GstSpiderIdentity * src) { GstSpider *spider = GST_SPIDER (GST_OBJECT_PARENT (src)); - + GstSpiderConnection *conn = g_new0 (GstSpiderConnection, 1); + conn->src = src; conn->path = NULL; conn->current = (GstElement *) spider->sink_ident; spider->links = g_list_prepend (spider->links, conn); - + return conn; } static void -gst_spider_link_destroy (GstSpiderConnection *conn) +gst_spider_link_destroy (GstSpiderConnection * conn) { GstSpider *spider = GST_SPIDER (GST_OBJECT_PARENT (conn->src)); + /* reset link to unplugged */ gst_spider_link_reset (conn, (GstElement *) spider->sink_ident); g_free (conn); } static void -gst_spider_link_reset (GstSpiderConnection *conn, GstElement *to) +gst_spider_link_reset (GstSpiderConnection * conn, GstElement * to) { GstSpider *spider = GST_SPIDER (GST_OBJECT_PARENT (conn->src)); - GST_DEBUG ("resetting link from %s to %s, currently at %s to %s", GST_ELEMENT_NAME (spider->sink_ident), - GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (to)); - while ((conn->path != NULL) && ((GstElement *) conn->path->data != to)) - { + + GST_DEBUG ("resetting link from %s to %s, currently at %s to %s", + GST_ELEMENT_NAME (spider->sink_ident), GST_ELEMENT_NAME (conn->src), + GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (to)); + while ((conn->path != NULL) && ((GstElement *) conn->path->data != to)) { gst_object_unref ((GstObject *) conn->path->data); conn->path = g_list_delete_link (conn->path, conn->path); } - if (conn->path == NULL) - { + if (conn->path == NULL) { conn->current = (GstElement *) spider->sink_ident; } else { conn->current = to; } } + /* add an element to the link */ static void -gst_spider_link_add (GstSpiderConnection *conn, GstElement *element) +gst_spider_link_add (GstSpiderConnection * conn, GstElement * element) { gst_object_ref ((GstObject *) element); gst_object_sink ((GstObject *) element); conn->path = g_list_prepend (conn->path, element); conn->current = element; } + /* find the link from those two elements */ static GstSpiderConnection * -gst_spider_link_find (GstSpiderIdentity *src) +gst_spider_link_find (GstSpiderIdentity * src) { GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (src); GList *list = spider->links; - - while (list) - { + + while (list) { GstSpiderConnection *conn = (GstSpiderConnection *) list->data; - if (conn->src == src){ + + if (conn->src == src) { return conn; } - list = g_list_next(list); + list = g_list_next (list); } return NULL; } + /* get a new link from those two elements * search first; if none is found, create a new one */ static GstSpiderConnection * -gst_spider_link_get (GstSpiderIdentity *src) +gst_spider_link_get (GstSpiderIdentity * src) { GstSpiderConnection *ret; - - if ((ret = gst_spider_link_find (src)) != NULL) - { + + if ((ret = gst_spider_link_find (src)) != NULL) { return ret; } return gst_spider_link_new (src); -} -void -gst_spider_identity_plug (GstSpiderIdentity *ident) +} + +void +gst_spider_identity_plug (GstSpiderIdentity * ident) { GstSpider *spider; const GList *padlist; GstPadDirection dir; GstSpiderConnection *conn; - + /* checks */ g_return_if_fail (ident != NULL); g_return_if_fail (GST_IS_SPIDER_IDENTITY (ident)); spider = GST_SPIDER (GST_ELEMENT_PARENT (ident)); g_assert (spider != NULL); g_assert (GST_IS_SPIDER (spider)); - + /* return if we're already plugged */ - if (ident->plugged) return; + if (ident->plugged) + return; /* check if there is at least one element factory that can handle the identity's src caps */ { GstCaps *src_caps = gst_pad_get_caps (ident->src); - if (! gst_caps_is_empty (src_caps) && ! gst_caps_is_any (src_caps)) - { + + if (!gst_caps_is_empty (src_caps) && !gst_caps_is_any (src_caps)) { GList *factories; GstPadTemplate *padtemp; gboolean found = FALSE; factories = spider->factories; - while (factories) - { - if ((padtemp = gst_autoplug_can_connect_src (factories->data, src_caps))) - { - const GstCaps *caps = gst_pad_template_get_caps (padtemp); - GST_DEBUG ("can connect src to pad template: %" GST_PTR_FORMAT, caps); - found = TRUE; - } - factories = factories->next; + while (factories) { + if ((padtemp = + gst_autoplug_can_connect_src (factories->data, src_caps))) { + const GstCaps *caps = gst_pad_template_get_caps (padtemp); + + GST_DEBUG ("can connect src to pad template: %" GST_PTR_FORMAT, caps); + found = TRUE; + } + factories = factories->next; } - if (!found) - { + if (!found) { const char *mime; mime = gst_structure_get_name (gst_caps_get_structure (src_caps, 0)); - GST_ELEMENT_ERROR (spider, STREAM, CODEC_NOT_FOUND, - (_("There is no element present to handle the stream's mime type %s."), mime), - (NULL)); + GST_ELEMENT_ERROR (spider, STREAM, CODEC_NOT_FOUND, + (_("There is no element present to handle the stream's mime type %s."), mime), (NULL)); gst_caps_free (src_caps); return; } @@ -428,10 +451,8 @@ gst_spider_identity_plug (GstSpiderIdentity *ident) /* get the direction of our ident */ - if (GST_PAD_PEER (ident->sink)) - { - if (GST_PAD_PEER (ident->src)) - { + if (GST_PAD_PEER (ident->sink)) { + if (GST_PAD_PEER (ident->src)) { /* Hey, the ident is linked on both sides */ g_warning ("Trying to autoplug a linked element. Aborting..."); return; @@ -439,8 +460,7 @@ gst_spider_identity_plug (GstSpiderIdentity *ident) dir = GST_PAD_SINK; } } else { - if (GST_PAD_PEER (ident->src)) - { + if (GST_PAD_PEER (ident->src)) { dir = GST_PAD_SRC; } else { /* the ident isn't linked on either side */ @@ -451,8 +471,7 @@ gst_spider_identity_plug (GstSpiderIdentity *ident) /* now iterate all possible pads and link when needed */ padlist = gst_element_get_pad_list (GST_ELEMENT (spider)); - while (padlist) - { + while (padlist) { GstPad *otherpad; GstSpiderIdentity *peer; @@ -460,169 +479,182 @@ gst_spider_identity_plug (GstSpiderIdentity *ident) otherpad = (GstPad *) GST_GPAD_REALPAD (padlist->data); peer = (GstSpiderIdentity *) GST_PAD_PARENT (otherpad); /* we only want to link to the other side */ - if (dir != GST_PAD_DIRECTION (otherpad)) - { + if (dir != GST_PAD_DIRECTION (otherpad)) { /* we only link to plugged in elements */ - if (peer->plugged == TRUE) - { - /* plug in the right direction */ - if (dir == GST_PAD_SINK) - { + if (peer->plugged == TRUE) { + /* plug in the right direction */ + if (dir == GST_PAD_SINK) { conn = gst_spider_link_get (peer); - } else { + } else { conn = gst_spider_link_get (ident); - } - if ((GstElement *) spider->sink_ident == conn->current) - { + } + if ((GstElement *) spider->sink_ident == conn->current) { gst_spider_plug (conn); } } } padlist = g_list_next (padlist); } - - ident->plugged = TRUE; + + ident->plugged = TRUE; } + void -gst_spider_identity_unplug (GstSpiderIdentity *ident) +gst_spider_identity_unplug (GstSpiderIdentity * ident) { GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (ident); GList *list = spider->links; - - while (list) - { + + while (list) { GstSpiderConnection *conn = list->data; GList *cur = list; + list = g_list_next (list); - if (conn->src == ident) - { + if (conn->src == ident) { g_list_delete_link (spider->links, cur); gst_spider_link_destroy (conn); } } ident->plugged = FALSE; } + /* links src to sink using the elementfactories in plugpath * plugpath will be removed afterwards */ static GstPadLinkReturn -gst_spider_create_and_plug (GstSpiderConnection *conn, GList *plugpath) +gst_spider_create_and_plug (GstSpiderConnection * conn, GList * plugpath) { GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (conn->src); GList *endelements = NULL, *templist = NULL; GstElement *element; - + /* exit if plugging is already done */ if ((GstElement *) conn->src == conn->current) return GST_PAD_LINK_DONE; - + /* try to shorten the list at the end and not duplicate link code */ - if (plugpath != NULL) - { + if (plugpath != NULL) { templist = g_list_last (plugpath); element = (GstElement *) conn->src; - while ((plugpath != NULL) && (element = gst_spider_find_element_to_plug (element, (GstElementFactory *) plugpath->data, GST_PAD_SINK))) - { + while ((plugpath != NULL) + && (element = + gst_spider_find_element_to_plug (element, + (GstElementFactory *) plugpath->data, GST_PAD_SINK))) { GList *cur = templist; + endelements = g_list_prepend (endelements, element); templist = g_list_previous (templist); - g_list_delete_link (cur, cur); + g_list_delete_link (cur, cur); } } - + /* do the linking */ - while (conn->current != (GstElement *) (endelements == NULL ? conn->src : endelements->data)) - { + while (conn->current != (GstElement *) (endelements == + NULL ? conn->src : endelements->data)) { /* get sink element to plug, src is conn->current */ - if (plugpath == NULL) - { - element = (GstElement *) (endelements == NULL ? conn->src : endelements->data); + if (plugpath == NULL) { + element = + (GstElement *) (endelements == NULL ? conn->src : endelements->data); } else { - element = gst_element_factory_create ((GstElementFactory *) plugpath->data, NULL); - GST_DEBUG ("Adding element %s of type %s and syncing state with autoplugger", - GST_ELEMENT_NAME (element), GST_PLUGIN_FEATURE_NAME (plugpath->data)); + element = + gst_element_factory_create ((GstElementFactory *) plugpath->data, + NULL); + GST_DEBUG + ("Adding element %s of type %s and syncing state with autoplugger", + GST_ELEMENT_NAME (element), GST_PLUGIN_FEATURE_NAME (plugpath->data)); gst_bin_add (GST_BIN (spider), element); } /* insert and link new element */ if (gst_element_link (conn->current, element)) { - gst_element_sync_state_with_parent (element); + gst_element_sync_state_with_parent (element); } else { /* check if the src has SOMETIMES templates. If so, link a callback */ GList *templs = gst_element_get_pad_template_list (conn->current); - + /* remove element that couldn't be linked, if it wasn't the endpoint */ if (element != (GstElement *) conn->src) - gst_bin_remove (GST_BIN (spider), element); - + gst_bin_remove (GST_BIN (spider), element); + while (templs) { - GstPadTemplate *templ = (GstPadTemplate *) templs->data; - if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PAD_TEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES)) - { - GST_DEBUG ("adding callback to link element %s to %s", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); - conn->signal_id = g_signal_connect (G_OBJECT (conn->current), "new_pad", - G_CALLBACK (gst_spider_link_sometimes), conn); + GstPadTemplate *templ = (GstPadTemplate *) templs->data; + + if ((GST_PAD_TEMPLATE_DIRECTION (templ) == GST_PAD_SRC) + && (GST_PAD_TEMPLATE_PRESENCE (templ) == GST_PAD_SOMETIMES)) { + GST_DEBUG ("adding callback to link element %s to %s", + GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); + conn->signal_id = + g_signal_connect (G_OBJECT (conn->current), "new_pad", + G_CALLBACK (gst_spider_link_sometimes), conn); g_list_free (plugpath); return GST_PAD_LINK_DELAYED; - } - templs = g_list_next (templs); + } + templs = g_list_next (templs); } - GST_DEBUG ("no chance to link element %s to %s", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); + GST_DEBUG ("no chance to link element %s to %s", + GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); g_list_free (plugpath); return GST_PAD_LINK_REFUSED; } - GST_DEBUG ("added element %s and attached it to element %s", GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (conn->current)); + GST_DEBUG ("added element %s and attached it to element %s", + GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (conn->current)); gst_spider_link_add (conn, element); if (plugpath != NULL) plugpath = g_list_delete_link (plugpath, plugpath); } - + /* ref all elements at the end */ - while (endelements) - { + while (endelements) { gst_spider_link_add (conn, endelements->data); endelements = g_list_delete_link (endelements, endelements); } - + return GST_PAD_LINK_DONE; } + /* checks, if src is already linked to an element from factory fac on direction dir */ static GstElement * -gst_spider_find_element_to_plug (GstElement *src, GstElementFactory *fac, GstPadDirection dir) +gst_spider_find_element_to_plug (GstElement * src, GstElementFactory * fac, + GstPadDirection dir) { GList *padlist = GST_ELEMENT_PADS (src); - - while (padlist) - { + + while (padlist) { GstPad *pad = (GstPad *) GST_PAD_REALIZE (padlist->data); + /* is the pad on the right side and is it linked? */ - if ((GST_PAD_DIRECTION (pad) == dir) && (pad = (GstPad *) (GST_RPAD_PEER (pad)))) - { + if ((GST_PAD_DIRECTION (pad) == dir) + && (pad = (GstPad *) (GST_RPAD_PEER (pad)))) { /* is the element the pad is linked to of the right type? */ GstElement *element = GST_PAD_PARENT (pad); - - if (G_TYPE_FROM_INSTANCE (element) == gst_element_factory_get_element_type (fac)) { - return element; + + if (G_TYPE_FROM_INSTANCE (element) == + gst_element_factory_get_element_type (fac)) { + return element; } } padlist = g_list_next (padlist); } - + return NULL; } + /* try to establish the link */ static GstPadLinkReturn -gst_spider_plug (GstSpiderConnection *conn) +gst_spider_plug (GstSpiderConnection * conn) { GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (conn->src); + if ((GstElement *) conn->src == conn->current) return GST_PAD_LINK_DONE; if ((GstElement *) spider->sink_ident == conn->current) return gst_spider_plug_from_srcpad (conn, spider->sink_ident->src); - g_warning ("FIXME: autoplugging only possible from GstSpiderIdentity conn->sink yet (yep, that's technical)\n"); + g_warning + ("FIXME: autoplugging only possible from GstSpiderIdentity conn->sink yet (yep, that's technical)\n"); return GST_PAD_LINK_REFUSED; } + /* try to establish the link using this pad */ static GstPadLinkReturn -gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad) +gst_spider_plug_from_srcpad (GstSpiderConnection * conn, GstPad * srcpad) { GstElement *element; GList *plugpath; @@ -633,37 +665,38 @@ gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad) GstCaps *caps2; g_assert ((GstElement *) GST_OBJECT_PARENT (srcpad) == conn->current); - GST_DEBUG ("trying to plug from %s:%s to %s", - GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (conn->src)); - + GST_DEBUG ("trying to plug from %s:%s to %s", + GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (conn->src)); + /* see if they match already */ if (gst_pad_link (srcpad, conn->src->sink)) { - GST_DEBUG ("%s:%s and %s:%s can link directly", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (conn->src->sink)); + GST_DEBUG ("%s:%s and %s:%s can link directly", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (conn->src->sink)); gst_pad_unlink (srcpad, conn->src->sink); gst_spider_create_and_plug (conn, NULL); return GST_PAD_LINK_OK; } - + /* find a path from src to sink */ caps1 = gst_pad_get_caps (srcpad); caps2 = gst_pad_get_caps (conn->src->sink); plugpath = gst_autoplug_sp (caps1, caps2, spider->factories); gst_caps_free (caps1); gst_caps_free (caps2); - + /* prints out the path that was found for plugging */ /* g_print ("found path from %s to %s:\n", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); - templist = plugpath; - while (templist) - { - g_print("%s\n", GST_OBJECT_NAME (templist->data)); - templist = g_list_next (templist); - }*/ - + templist = plugpath; + while (templist) + { + g_print("%s\n", GST_OBJECT_NAME (templist->data)); + templist = g_list_next (templist); + } */ + /* if there is no way to plug: return */ if (plugpath == NULL) { - GST_DEBUG ("no chance to plug from %s to %s", GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); + GST_DEBUG ("no chance to plug from %s to %s", + GST_ELEMENT_NAME (conn->current), GST_ELEMENT_NAME (conn->src)); return GST_PAD_LINK_REFUSED; } GST_DEBUG ("found a link that needs %d elements", g_list_length (plugpath)); @@ -673,53 +706,50 @@ gst_spider_plug_from_srcpad (GstSpiderConnection *conn, GstPad *srcpad) * plugging and alter the plugpath to represent the elements, that must be plugged */ element = conn->current; - while ((plugpath != NULL) && (element = gst_spider_find_element_to_plug (element, (GstElementFactory *) plugpath->data, GST_PAD_SRC))) - { + while ((plugpath != NULL) + && (element = + gst_spider_find_element_to_plug (element, + (GstElementFactory *) plugpath->data, GST_PAD_SRC))) { gst_spider_link_add (conn, element); plugpath = g_list_delete_link (plugpath, plugpath); } - - GST_DEBUG ("%d elements must be inserted to establish the link", g_list_length (plugpath)); + + GST_DEBUG ("%d elements must be inserted to establish the link", + g_list_length (plugpath)); /* create the elements and plug them */ result = gst_spider_create_and_plug (conn, plugpath); - + /* reset the "current" element */ - if (result == GST_PAD_LINK_REFUSED) - { - gst_spider_link_reset (conn, startelement); + if (result == GST_PAD_LINK_REFUSED) { + gst_spider_link_reset (conn, startelement); } - - return result; + + return result; } -GstElementDetails gst_spider_details = GST_ELEMENT_DETAILS ( - "Spider", - "Generic", - "Automatically link sinks and sources", - "Benjamin Otte " -); +GstElementDetails gst_spider_details = GST_ELEMENT_DETAILS ("Spider", + "Generic", + "Automatically link sinks and sources", + "Benjamin Otte "); static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { - GST_DEBUG_CATEGORY_INIT (gst_spider_debug, "spider", 0, "spider autoplugging element"); + GST_DEBUG_CATEGORY_INIT (gst_spider_debug, "spider", 0, + "spider autoplugging element"); - if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY, GST_TYPE_SPIDER)) + if (!gst_element_register (plugin, "spider", GST_RANK_SECONDARY, + GST_TYPE_SPIDER)) return FALSE; - if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE, GST_TYPE_SPIDER_IDENTITY)) + if (!gst_element_register (plugin, "spideridentity", GST_RANK_NONE, + GST_TYPE_SPIDER_IDENTITY)) return FALSE; return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstspider", - "a 1:n autoplugger", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstspider", + "a 1:n autoplugger", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/gst/autoplug/gstspider.h b/gst/autoplug/gstspider.h index 0958ddcad..6b5b6e010 100644 --- a/gst/autoplug/gstspider.h +++ b/gst/autoplug/gstspider.h @@ -19,17 +19,16 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - + #ifndef __GST_SPIDER_H__ #define __GST_SPIDER_H__ #include #include "gstspideridentity.h" -G_BEGIN_DECLS - -extern GstElementDetails gst_spider_details; -GST_DEBUG_CATEGORY_EXTERN(gst_spider_debug); +G_BEGIN_DECLS extern GstElementDetails gst_spider_details; + +GST_DEBUG_CATEGORY_EXTERN (gst_spider_debug); /* * Theory of operation: @@ -46,7 +45,8 @@ GST_DEBUG_CATEGORY_EXTERN(gst_spider_debug); * are refcounted once for every path. * A GstSpider keeps a list of all GstSpiderConnections in it. */ -typedef struct { +typedef struct +{ GstSpiderIdentity *src; /* dunno if the path should stay here or if its too much load. * it's at least easier then always searching it */ @@ -60,35 +60,36 @@ typedef struct { #define GST_SPIDER(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPIDER,GstSpider)) #define GST_SPIDER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPIDER,GstSpiderClass)) + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SPIDER,GstSpiderClass)) #define GST_IS_SPIDER(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPIDER)) #define GST_IS_SPIDER_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPIDER)) - + typedef struct _GstSpider GstSpider; typedef struct _GstSpiderClass GstSpiderClass; -struct _GstSpider { - GstBin parent; - +struct _GstSpider +{ + GstBin parent; + GstSpiderIdentity *sink_ident; - GList * factories; /* factories to use for plugging */ + GList *factories; /* factories to use for plugging */ - GList * links; /* GStSpiderConnection list of all links */ + GList *links; /* GStSpiderConnection list of all links */ }; - -struct _GstSpiderClass { + +struct _GstSpiderClass +{ GstBinClass parent_class; }; /* default initialization stuff */ -GType gst_spider_get_type (void); +GType gst_spider_get_type (void); /* private link functions to be called by GstSpiderIdentity */ -void gst_spider_identity_plug (GstSpiderIdentity *ident); -void gst_spider_identity_unplug (GstSpiderIdentity *ident); +void gst_spider_identity_plug (GstSpiderIdentity * ident); +void gst_spider_identity_unplug (GstSpiderIdentity * ident); G_END_DECLS - #endif /* __GST_SPIDER_H__ */ diff --git a/gst/autoplug/gstspideridentity.c b/gst/autoplug/gstspideridentity.c index e172bbda6..caefdffda 100644 --- a/gst/autoplug/gstspideridentity.c +++ b/gst/autoplug/gstspideridentity.c @@ -30,159 +30,174 @@ GST_DEBUG_CATEGORY_STATIC (gst_spider_identity_debug); #define GST_CAT_DEFAULT gst_spider_identity_debug -static GstElementDetails gst_spider_identity_details = GST_ELEMENT_DETAILS ( - "SpiderIdentity", - "Generic", - "Link between spider and outside elements", - "Benjamin Otte " -); +static GstElementDetails gst_spider_identity_details = +GST_ELEMENT_DETAILS ("SpiderIdentity", + "Generic", + "Link between spider and outside elements", + "Benjamin Otte "); /* generic templates * delete me when meging with spider.c */ -static GstStaticPadTemplate spider_src_factory = -GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +static GstStaticPadTemplate spider_src_factory = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); static GstStaticPadTemplate spider_sink_factory = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); /* SpiderIdentity signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 - /* FILL ME */ + /* FILL ME */ }; /* GObject stuff */ -static void gst_spider_identity_class_init (GstSpiderIdentityClass *klass); -static void gst_spider_identity_init (GstSpiderIdentity *spider_identity); +static void gst_spider_identity_class_init (GstSpiderIdentityClass * klass); +static void gst_spider_identity_init (GstSpiderIdentity * spider_identity); /* functions set in pads, elements and stuff */ -static void gst_spider_identity_chain (GstPad *pad, GstBuffer *buf); -static GstElementStateReturn gst_spider_identity_change_state (GstElement *element); -static GstPadLinkReturn gst_spider_identity_link (GstPad *pad, const GstCaps *caps); -static GstCaps * gst_spider_identity_getcaps (GstPad *pad); +static void gst_spider_identity_chain (GstPad * pad, GstBuffer * buf); +static GstElementStateReturn gst_spider_identity_change_state (GstElement * + element); +static GstPadLinkReturn gst_spider_identity_link (GstPad * pad, + const GstCaps * caps); +static GstCaps *gst_spider_identity_getcaps (GstPad * pad); + /* loop functions */ -static void gst_spider_identity_dumb_loop (GstSpiderIdentity *ident); -static void gst_spider_identity_src_loop (GstSpiderIdentity *ident); -static void gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident); +static void gst_spider_identity_dumb_loop (GstSpiderIdentity * ident); +static void gst_spider_identity_src_loop (GstSpiderIdentity * ident); +static void gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity * + ident); -static gboolean gst_spider_identity_handle_src_event (GstPad *pad, GstEvent *event); +static gboolean gst_spider_identity_handle_src_event (GstPad * pad, + GstEvent * event); /* other functions */ -static void gst_spider_identity_start_type_finding (GstSpiderIdentity *ident); +static void gst_spider_identity_start_type_finding (GstSpiderIdentity * ident); + +static GstElementClass *parent_class = NULL; -static GstElementClass * parent_class = NULL; /* no signals static guint gst_spider_identity_signals[LAST_SIGNAL] = { 0 }; */ GType -gst_spider_identity_get_type (void) +gst_spider_identity_get_type (void) { static GType spider_identity_type = 0; if (!spider_identity_type) { static const GTypeInfo spider_identity_info = { - sizeof(GstSpiderIdentityClass), NULL, + sizeof (GstSpiderIdentityClass), NULL, NULL, - (GClassInitFunc)gst_spider_identity_class_init, + (GClassInitFunc) gst_spider_identity_class_init, NULL, NULL, - sizeof(GstSpiderIdentity), + sizeof (GstSpiderIdentity), 0, - (GInstanceInitFunc)gst_spider_identity_init, + (GInstanceInitFunc) gst_spider_identity_init, }; - spider_identity_type = g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity", - &spider_identity_info, 0); - GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity", - 0, "spider autoplugging proxy element"); + spider_identity_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstSpiderIdentity", + &spider_identity_info, 0); + GST_DEBUG_CATEGORY_INIT (gst_spider_identity_debug, "spideridentity", 0, + "spider autoplugging proxy element"); } return spider_identity_type; } -static void -gst_spider_identity_class_init (GstSpiderIdentityClass *klass) +static void +gst_spider_identity_class_init (GstSpiderIdentityClass * klass) { GstElementClass *gstelement_class = (GstElementClass *) klass; - + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); - + /* add our two pad templates */ gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&spider_src_factory)); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&spider_sink_factory)); - gst_element_class_set_details (gstelement_class, &gst_spider_identity_details); - - gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_spider_identity_change_state); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_identity_request_new_pad); + gst_element_class_set_details (gstelement_class, + &gst_spider_identity_details); + + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_spider_identity_change_state); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_spider_identity_request_new_pad); } -static void -gst_spider_identity_init (GstSpiderIdentity *ident) +static void +gst_spider_identity_init (GstSpiderIdentity * ident) { /* sink */ - ident->sink = gst_pad_new_from_template ( - gst_static_pad_template_get (&spider_sink_factory), "sink"); + ident->sink = + gst_pad_new_from_template (gst_static_pad_template_get + (&spider_sink_factory), "sink"); gst_element_add_pad (GST_ELEMENT (ident), ident->sink); - gst_pad_set_link_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_link)); - gst_pad_set_getcaps_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); + gst_pad_set_link_function (ident->sink, + GST_DEBUG_FUNCPTR (gst_spider_identity_link)); + gst_pad_set_getcaps_function (ident->sink, + GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); /* src */ - ident->src = gst_pad_new_from_template ( - gst_static_pad_template_get (&spider_src_factory), "src"); + ident->src = + gst_pad_new_from_template (gst_static_pad_template_get + (&spider_src_factory), "src"); gst_element_add_pad (GST_ELEMENT (ident), ident->src); - gst_pad_set_link_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_link)); - gst_pad_set_getcaps_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); - gst_pad_set_event_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event)); + gst_pad_set_link_function (ident->src, + GST_DEBUG_FUNCPTR (gst_spider_identity_link)); + gst_pad_set_getcaps_function (ident->src, + GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); + gst_pad_set_event_function (ident->src, + GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event)); /* variables */ ident->plugged = FALSE; } -static void -gst_spider_identity_chain (GstPad *pad, GstBuffer *buf) +static void +gst_spider_identity_chain (GstPad * pad, GstBuffer * buf) { GstSpiderIdentity *ident; - - /*g_print ("chaining on pad %s:%s with buffer %p\n", GST_DEBUG_PAD_NAME (pad), buf);*/ + + /*g_print ("chaining on pad %s:%s with buffer %p\n", GST_DEBUG_PAD_NAME (pad), buf); */ g_return_if_fail (pad != NULL); g_return_if_fail (GST_IS_PAD (pad)); - if (buf == NULL) return; + if (buf == NULL) + return; ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); if (GST_IS_EVENT (buf)) { /* start hack for current event stuff here */ /* check for unlinked elements and send them the EOS event, too */ - if (GST_EVENT_TYPE (GST_EVENT (buf)) == GST_EVENT_EOS) - { + if (GST_EVENT_TYPE (GST_EVENT (buf)) == GST_EVENT_EOS) { GstSpider *spider = (GstSpider *) GST_OBJECT_PARENT (ident); GList *list = spider->links; - while (list) - { + + while (list) { GstSpiderConnection *conn = (GstSpiderConnection *) list->data; + list = g_list_next (list); - if (conn->current != (GstElement *) conn->src) { - GST_DEBUG ("sending EOS to unconnected element %s from %s", - GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident)); - gst_pad_push (conn->src->src, GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS)))); - gst_element_set_eos (GST_ELEMENT (conn->src)); + if (conn->current != (GstElement *) conn->src) { + GST_DEBUG ("sending EOS to unconnected element %s from %s", + GST_ELEMENT_NAME (conn->src), GST_ELEMENT_NAME (ident)); + gst_pad_push (conn->src->src, + GST_DATA (GST_BUFFER (gst_event_new (GST_EVENT_EOS)))); + gst_element_set_eos (GST_ELEMENT (conn->src)); } } } @@ -194,40 +209,48 @@ gst_spider_identity_chain (GstPad *pad, GstBuffer *buf) if ((ident->src != NULL) && (GST_PAD_PEER (ident->src) != NULL)) { /* g_print("pushing buffer %p (refcount %d - buffersize %d) to pad %s:%s\n", buf, GST_BUFFER_REFCOUNT (buf), GST_BUFFER_SIZE (buf), GST_DEBUG_PAD_NAME (ident->src)); */ - GST_LOG ( "push %p %" G_GINT64_FORMAT, buf, GST_BUFFER_OFFSET (buf)); + GST_LOG ("push %p %" G_GINT64_FORMAT, buf, GST_BUFFER_OFFSET (buf)); gst_pad_push (ident->src, GST_DATA (buf)); } else if (GST_IS_BUFFER (buf)) { gst_buffer_unref (buf); } } -GstSpiderIdentity* -gst_spider_identity_new_src (gchar *name) +GstSpiderIdentity * +gst_spider_identity_new_src (gchar * name) { - GstSpiderIdentity *ret = (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name); + GstSpiderIdentity *ret = + (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name); /* set the right functions */ - gst_element_set_loop_function (GST_ELEMENT (ret), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_src_loop)); - + gst_element_set_loop_function (GST_ELEMENT (ret), + (GstElementLoopFunction) + GST_DEBUG_FUNCPTR (gst_spider_identity_src_loop)); + return ret; } -GstSpiderIdentity* -gst_spider_identity_new_sink (gchar *name) + +GstSpiderIdentity * +gst_spider_identity_new_sink (gchar * name) { - GstSpiderIdentity *ret = (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name); + GstSpiderIdentity *ret = + (GstSpiderIdentity *) gst_element_factory_make ("spideridentity", name); /* set the right functions */ - gst_element_set_loop_function (GST_ELEMENT (ret), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); + gst_element_set_loop_function (GST_ELEMENT (ret), + (GstElementLoopFunction) + GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); return ret; } /* shamelessly stolen from gstqueue.c to get proxy links */ static GstPadLinkReturn -gst_spider_identity_link (GstPad *pad, const GstCaps *caps) +gst_spider_identity_link (GstPad * pad, const GstCaps * caps) { - GstSpiderIdentity *spider_identity = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); + GstSpiderIdentity *spider_identity = + GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); GstPad *otherpad; - if (pad == spider_identity->src) + if (pad == spider_identity->src) otherpad = spider_identity->sink; else otherpad = spider_identity->src; @@ -239,13 +262,13 @@ gst_spider_identity_link (GstPad *pad, const GstCaps *caps) return gst_pad_try_set_caps (otherpad, caps); } -static GstCaps* -gst_spider_identity_getcaps (GstPad *pad) +static GstCaps * +gst_spider_identity_getcaps (GstPad * pad) { GstSpiderIdentity *ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); GstPad *otherpad; - if (pad == ident->src) + if (pad == ident->src) otherpad = ident->sink; else otherpad = ident->src; @@ -253,8 +276,10 @@ gst_spider_identity_getcaps (GstPad *pad) if (otherpad != NULL) { if (GST_PAD_PEER (otherpad)) { GstCaps *ret = gst_pad_get_allowed_caps (otherpad); + if (ident->caps) { GstCaps *ret2 = gst_caps_intersect (ident->caps, ret); + gst_caps_free (ret); ret = ret2; } @@ -267,44 +292,52 @@ gst_spider_identity_getcaps (GstPad *pad) return gst_caps_new_any (); } -GstPad* -gst_spider_identity_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name) +GstPad * +gst_spider_identity_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * name) { GstSpiderIdentity *ident; - + /*checks */ g_return_val_if_fail (templ != NULL, NULL); g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL); ident = GST_SPIDER_IDENTITY (element); g_return_val_if_fail (ident != NULL, NULL); g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), NULL); - - switch (GST_PAD_TEMPLATE_DIRECTION (templ)) - { + + switch (GST_PAD_TEMPLATE_DIRECTION (templ)) { case GST_PAD_SINK: - if (ident->sink != NULL) break; + if (ident->sink != NULL) + break; /* sink */ - GST_DEBUG ( "element %s requests new sink pad", GST_ELEMENT_NAME(ident)); + GST_DEBUG ("element %s requests new sink pad", GST_ELEMENT_NAME (ident)); ident->sink = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (ident), ident->sink); - gst_pad_set_link_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_link)); - gst_pad_set_getcaps_function (ident->sink, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); + gst_pad_set_link_function (ident->sink, + GST_DEBUG_FUNCPTR (gst_spider_identity_link)); + gst_pad_set_getcaps_function (ident->sink, + GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); return ident->sink; case GST_PAD_SRC: /* src */ - if (ident->src != NULL) break; - GST_DEBUG ( "element %s requests new src pad", GST_ELEMENT_NAME(ident)); + if (ident->src != NULL) + break; + GST_DEBUG ("element %s requests new src pad", GST_ELEMENT_NAME (ident)); ident->src = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (ident), ident->src); - gst_pad_set_link_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_link)); - gst_pad_set_getcaps_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); - gst_pad_set_event_function (ident->src, GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event)); + gst_pad_set_link_function (ident->src, + GST_DEBUG_FUNCPTR (gst_spider_identity_link)); + gst_pad_set_getcaps_function (ident->src, + GST_DEBUG_FUNCPTR (gst_spider_identity_getcaps)); + gst_pad_set_event_function (ident->src, + GST_DEBUG_FUNCPTR (gst_spider_identity_handle_src_event)); return ident->src; default: break; } - - GST_DEBUG ( "element %s requested a new pad but none could be created", GST_ELEMENT_NAME(ident)); + + GST_DEBUG ("element %s requested a new pad but none could be created", + GST_ELEMENT_NAME (ident)); return NULL; } @@ -314,17 +347,17 @@ gst_spider_identity_request_new_pad (GstElement *element, GstPadTemplate *templ * ... */ static GstElementStateReturn -gst_spider_identity_change_state (GstElement *element) +gst_spider_identity_change_state (GstElement * element) { GstSpiderIdentity *ident; GstSpider *spider; GstElementStateReturn ret = GST_STATE_SUCCESS; - + /* element check */ ident = GST_SPIDER_IDENTITY (element); g_return_val_if_fail (ident != NULL, GST_STATE_FAILURE); g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), GST_STATE_FAILURE); - + switch (GST_STATE_TRANSITION (element)) { case GST_STATE_PAUSED_TO_READY: gst_caps_replace (&ident->caps, NULL); @@ -334,55 +367,58 @@ gst_spider_identity_change_state (GstElement *element) spider = GST_SPIDER (GST_ELEMENT_PARENT (ident)); g_return_val_if_fail (spider != NULL, GST_STATE_FAILURE); g_return_val_if_fail (GST_IS_SPIDER (spider), GST_STATE_FAILURE); - + /* start typefinding or plugging */ - if ((GST_RPAD_PEER (ident->sink) != NULL) && (GST_RPAD_PEER (ident->src) == NULL)) - { - GstCaps *caps = gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink)); - if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) - { - gst_spider_identity_start_type_finding (ident); + if ((GST_RPAD_PEER (ident->sink) != NULL) + && (GST_RPAD_PEER (ident->src) == NULL)) { + GstCaps *caps = + gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink)); + if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) { + gst_spider_identity_start_type_finding (ident); gst_caps_free (caps); - break; - } else { - gst_spider_identity_plug (ident); - } + break; + } else { + gst_spider_identity_plug (ident); + } gst_caps_free (caps); } /* autoplug on src */ - if ((GST_RPAD_PEER (ident->src) != NULL) && (GST_RPAD_PEER (ident->sink) == NULL)) - { - gst_spider_identity_plug (ident); + if ((GST_RPAD_PEER (ident->src) != NULL) + && (GST_RPAD_PEER (ident->sink) == NULL)) { + gst_spider_identity_plug (ident); } default: break; } - - if ((ret != GST_STATE_FAILURE) && (GST_ELEMENT_CLASS (parent_class)->change_state)) + + if ((ret != GST_STATE_FAILURE) + && (GST_ELEMENT_CLASS (parent_class)->change_state)) ret = GST_ELEMENT_CLASS (parent_class)->change_state (element); - + return ret; } static void -gst_spider_identity_start_type_finding (GstSpiderIdentity *ident) +gst_spider_identity_start_type_finding (GstSpiderIdentity * ident) { /* GstElement* typefind; gchar *name;*/ gboolean restart = FALSE; - - GST_DEBUG ("element %s starts typefinding", GST_ELEMENT_NAME(ident)); - if (GST_STATE (GST_ELEMENT_PARENT (ident)) == GST_STATE_PLAYING) - { - gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), GST_STATE_PAUSED); + + GST_DEBUG ("element %s starts typefinding", GST_ELEMENT_NAME (ident)); + if (GST_STATE (GST_ELEMENT_PARENT (ident)) == GST_STATE_PLAYING) { + gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), + GST_STATE_PAUSED); restart = TRUE; } - gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_sink_loop_type_finding)); + gst_element_set_loop_function (GST_ELEMENT (ident), + (GstElementLoopFunction) + GST_DEBUG_FUNCPTR (gst_spider_identity_sink_loop_type_finding)); - if (restart) - { - gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), GST_STATE_PLAYING); + if (restart) { + gst_element_set_state (GST_ELEMENT (GST_ELEMENT_PARENT (ident)), + GST_STATE_PLAYING); } } @@ -390,7 +426,7 @@ gst_spider_identity_start_type_finding (GstSpiderIdentity *ident) * we have to use a dumb one */ static void -gst_spider_identity_dumb_loop (GstSpiderIdentity *ident) +gst_spider_identity_dumb_loop (GstSpiderIdentity * ident) { GstBuffer *buf; @@ -402,27 +438,31 @@ gst_spider_identity_dumb_loop (GstSpiderIdentity *ident) gst_spider_identity_chain (ident->sink, buf); } + /* do nothing until we're linked - then disable yourself */ static void -gst_spider_identity_src_loop (GstSpiderIdentity *ident) +gst_spider_identity_src_loop (GstSpiderIdentity * ident) { /* checks - disable for speed */ g_return_if_fail (ident != NULL); g_return_if_fail (GST_IS_SPIDER_IDENTITY (ident)); - + /* we don't want a loop function if we're plugged */ - if (ident->sink && GST_PAD_PEER (ident->sink)) - { - gst_element_set_loop_function (GST_ELEMENT (ident), (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); + if (ident->sink && GST_PAD_PEER (ident->sink)) { + gst_element_set_loop_function (GST_ELEMENT (ident), + (GstElementLoopFunction) + GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); gst_spider_identity_dumb_loop (ident); return; } gst_element_interrupt (GST_ELEMENT (ident)); } + /* This loop function is only needed when typefinding. */ -typedef struct { +typedef struct +{ GstBuffer *buffer; guint best_probability; GstCaps *caps; @@ -431,19 +471,20 @@ guint8 * spider_find_peek (gpointer data, gint64 offset, guint size) { SpiderTypeFind *find = (SpiderTypeFind *) data; - gint64 buffer_offset = GST_BUFFER_OFFSET_IS_VALID (find->buffer) ? - GST_BUFFER_OFFSET (find->buffer) : 0; - - if (offset >= buffer_offset && offset + size <= buffer_offset + GST_BUFFER_SIZE (find->buffer)) { - GST_LOG ("peek %"G_GINT64_FORMAT", %u successful", offset, size); + gint64 buffer_offset = GST_BUFFER_OFFSET_IS_VALID (find->buffer) ? + GST_BUFFER_OFFSET (find->buffer) : 0; + + if (offset >= buffer_offset + && offset + size <= buffer_offset + GST_BUFFER_SIZE (find->buffer)) { + GST_LOG ("peek %" G_GINT64_FORMAT ", %u successful", offset, size); return GST_BUFFER_DATA (find->buffer) + offset - buffer_offset; } else { - GST_LOG ("peek %"G_GINT64_FORMAT", %u failed", offset, size); + GST_LOG ("peek %" G_GINT64_FORMAT ", %u failed", offset, size); return NULL; } } static void -spider_find_suggest (gpointer data, guint probability, const GstCaps *caps) +spider_find_suggest (gpointer data, guint probability, const GstCaps * caps) { SpiderTypeFind *find = (SpiderTypeFind *) data; @@ -454,7 +495,7 @@ spider_find_suggest (gpointer data, guint probability, const GstCaps *caps) } } static void -gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) +gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity * ident) { GstData *data; GstTypeFind gst_find; @@ -468,7 +509,7 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) gst_spider_identity_chain (ident->sink, GST_BUFFER (data)); return; } - + find.buffer = GST_BUFFER (data); /* maybe there are already valid caps now? */ find.caps = gst_pad_get_allowed_caps (ident->sink); @@ -478,10 +519,10 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) gst_caps_free (find.caps); find.caps = NULL; } - + /* now do the actual typefinding with the supplied buffer */ walk = type_list = gst_type_find_factory_get_list (); - + find.best_probability = 0; find.caps = NULL; gst_find.data = &find; @@ -490,7 +531,8 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) while (walk) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (walk->data); - GST_DEBUG ("trying typefind function %s", GST_PLUGIN_FEATURE_NAME (factory)); + GST_DEBUG ("trying typefind function %s", + GST_PLUGIN_FEATURE_NAME (factory)); gst_type_find_factory_call_function (factory, &gst_find); if (find.best_probability >= GST_TYPE_FIND_MAXIMUM) goto plug; @@ -503,23 +545,24 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) end: /* remove loop function */ - gst_element_set_loop_function (GST_ELEMENT (ident), - (GstElementLoopFunction) GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); - + gst_element_set_loop_function (GST_ELEMENT (ident), + (GstElementLoopFunction) + GST_DEBUG_FUNCPTR (gst_spider_identity_dumb_loop)); + /* push the buffer */ gst_spider_identity_chain (ident->sink, find.buffer); - + return; plug: - GST_INFO ("typefind function found caps"); + GST_INFO ("typefind function found caps"); ident->caps = find.caps; if (GST_PAD_IS_LINKED (ident->src)) { GstPadLinkReturn ret; ret = gst_pad_try_set_caps (ident->src, find.caps); - if (GST_PAD_LINK_FAILED (ret)){ - g_critical("could not set caps on spideridentity src pad\n"); + if (GST_PAD_LINK_FAILED (ret)) { + g_critical ("could not set caps on spideridentity src pad\n"); } } GST_LOG_OBJECT (ident, "spider starting caps: %" GST_PTR_FORMAT, find.caps); @@ -532,12 +575,12 @@ plug: } static gboolean -gst_spider_identity_handle_src_event (GstPad *pad, GstEvent *event) +gst_spider_identity_handle_src_event (GstPad * pad, GstEvent * event) { gboolean res = TRUE; GstSpiderIdentity *ident; - GST_DEBUG ( "spider_identity src_event"); + GST_DEBUG ("spider_identity src_event"); ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); diff --git a/gst/autoplug/gstspideridentity.h b/gst/autoplug/gstspideridentity.h index 1e09aba58..d3744c9f4 100644 --- a/gst/autoplug/gstspideridentity.h +++ b/gst/autoplug/gstspideridentity.h @@ -27,7 +27,6 @@ #include G_BEGIN_DECLS - #define GST_TYPE_SPIDER_IDENTITY \ (gst_spider_identity_get_type()) #define GST_SPIDER_IDENTITY(obj) \ @@ -38,35 +37,36 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPIDER_IDENTITY)) #define GST_IS_SPIDER_IDENTITY_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SPIDER_IDENTITY)) - typedef struct _GstSpiderIdentity GstSpiderIdentity; typedef struct _GstSpiderIdentityClass GstSpiderIdentityClass; -struct _GstSpiderIdentity { +struct _GstSpiderIdentity +{ GstElement element; /* sink and source */ GstPad *sink; GstPad *src; - + /* plugged into autoplugger yet? */ gboolean plugged; - + /* Caps from typefinding */ GstCaps *caps; }; -struct _GstSpiderIdentityClass { +struct _GstSpiderIdentityClass +{ GstElementClass parent_class; }; -GType gst_spider_identity_get_type (void); +GType gst_spider_identity_get_type (void); -GstSpiderIdentity* gst_spider_identity_new_sink (gchar *name); -GstSpiderIdentity* gst_spider_identity_new_src (gchar *name); -GstPad* gst_spider_identity_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *name); +GstSpiderIdentity *gst_spider_identity_new_sink (gchar * name); +GstSpiderIdentity *gst_spider_identity_new_src (gchar * name); +GstPad *gst_spider_identity_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * name); G_END_DECLS - #endif /* __GST_SPIDER_IDENTITY_H__ */ diff --git a/gst/autoplug/spidertest.c b/gst/autoplug/spidertest.c index b6dc5970c..c2c8e563b 100644 --- a/gst/autoplug/spidertest.c +++ b/gst/autoplug/spidertest.c @@ -4,41 +4,40 @@ /* returns all factories which have a maximum of maxtemplates GstPadTemplates in direction dir */ GList * -gst_factories_at_most_templates(GList *factories, GstPadDirection dir, guint maxtemplates) +gst_factories_at_most_templates (GList * factories, GstPadDirection dir, + guint maxtemplates) { GList *ret = NULL; - - while (factories) - { + + while (factories) { guint count = 0; GList *templs = ((GstElementFactory *) factories->data)->padtemplates; - while (templs) - { - if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) - { - count++; + while (templs) { + if (GST_PAD_TEMPLATE_DIRECTION (templs->data) == dir) { + count++; } if (count > maxtemplates) - break; + break; templs = g_list_next (templs); } if (count <= maxtemplates) ret = g_list_prepend (ret, factories->data); - + factories = g_list_next (factories); } return ret; } static void -property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) +property_change_callback (GObject * object, GstObject * orig, + GParamSpec * pspec) { - GValue value = { 0, }; /* the important thing is that value.type = 0 */ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ gchar *str = 0; - + if (pspec->flags & G_PARAM_READABLE) { - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_object_get_property (G_OBJECT (orig), pspec->name, &value); if (G_IS_PARAM_SPEC_STRING (pspec)) str = g_value_dup_string (&value); @@ -48,17 +47,17 @@ property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) str = g_strdup_printf ("%" G_GINT64_FORMAT, g_value_get_int64 (&value)); else str = g_strdup_value_contents (&value); - + g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str); g_free (str); - g_value_unset(&value); + g_value_unset (&value); } else { g_warning ("Parameter not readable. What's up with that?"); } } static void -error_callback (GObject *object, GstObject *orig, gchar *error) +error_callback (GObject * object, GstObject * orig, gchar * error) { g_print ("ERROR: %s: %s\n", GST_OBJECT_NAME (orig), error); } @@ -70,42 +69,44 @@ error_callback (GObject *object, GstObject *orig, gchar *error) * USAGE: spidertest * If mediafile can be recognized, xvideo and oss audio output are tried. */ -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *decoder, *osssink, *videosink; GList *facs; - + if (argc < 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } - gst_init(&argc,&argv); + gst_init (&argc, &argv); /* create a new bin to hold the elements */ - bin = gst_pipeline_new("pipeline"); - g_signal_connect (bin, "deep_notify", G_CALLBACK (property_change_callback), NULL); + bin = gst_pipeline_new ("pipeline"); + g_signal_connect (bin, "deep_notify", G_CALLBACK (property_change_callback), + NULL); g_signal_connect (bin, "error", G_CALLBACK (error_callback), NULL); - + /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_object_set(G_OBJECT(filesrc),"location", argv[1], NULL); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); /* now it's time to get the decoder */ - decoder = gst_element_factory_make("spider", "spider"); + decoder = gst_element_factory_make ("spider", "spider"); if (!decoder) { g_print ("could not find plugin \"spider\"\n"); exit (-2); } - + /* only use decoding plugins */ g_object_get (decoder, "factories", &facs, NULL); - facs = gst_factories_at_most_templates(facs, GST_PAD_SINK, 1); + facs = gst_factories_at_most_templates (facs, GST_PAD_SINK, 1); g_object_set (decoder, "factories", facs, NULL); /* create video and audio sink */ - osssink = gst_element_factory_make("osssink", "audio"); - videosink = gst_element_factory_make("xvideosink", "video"); + osssink = gst_element_factory_make ("osssink", "audio"); + videosink = gst_element_factory_make ("xvideosink", "video"); if ((!osssink) || (!videosink)) { g_print ("could not create output plugins\n"); @@ -113,16 +114,15 @@ int main(int argc,char *argv[]) } /* add objects to the main pipeline */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), decoder); - gst_bin_add(GST_BIN(bin), osssink); - gst_bin_add(GST_BIN(bin), videosink); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), decoder); + gst_bin_add (GST_BIN (bin), osssink); + gst_bin_add (GST_BIN (bin), videosink); /* link objects */ - if (!(gst_element_link(filesrc, decoder) && - gst_element_link(decoder, osssink) && - gst_element_link(decoder, videosink))) - { + if (!(gst_element_link (filesrc, decoder) && + gst_element_link (decoder, osssink) && + gst_element_link (decoder, videosink))) { g_print ("the pipeline could not be linked\n"); exit (-4); } @@ -130,10 +130,9 @@ int main(int argc,char *argv[]) /* gst_bin_use_clock (GST_BIN (bin), gst_system_clock_obtain ());*/ /* start playing */ - gst_element_set_state(bin, GST_STATE_PLAYING); + gst_element_set_state (bin, GST_STATE_PLAYING); - while (gst_bin_iterate(GST_BIN(bin))); + while (gst_bin_iterate (GST_BIN (bin))); - exit(0); + exit (0); } - diff --git a/gst/cothreads.c b/gst/cothreads.c index 7edebc7fc..60e4a3a44 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -59,11 +59,11 @@ #define COTHREAD_MAXTHREADS 16 #define COTHREAD_STACKSIZE (STACK_SIZE/COTHREAD_MAXTHREADS) -static void cothread_destroy (cothread_state *cothread); +static void cothread_destroy (cothread_state * cothread); struct _cothread_context { - cothread_state *cothreads[COTHREAD_MAXTHREADS]; /* array of cothread states */ + cothread_state *cothreads[COTHREAD_MAXTHREADS]; /* array of cothread states */ int ncothreads; int current; unsigned long stack_top; @@ -92,10 +92,10 @@ cothread_get_current_context (void) cothread_context *ctx; ctx = g_static_private_get (&_cothread_ctx_key); - g_assert(ctx); + g_assert (ctx); #ifdef COTHREAD_PARANOID - g_assert (ctx->thread == g_thread_self()); + g_assert (ctx->thread == g_thread_self ()); #endif return ctx; @@ -112,15 +112,15 @@ cothread_context * cothread_context_init (void) { char __csf; - void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */ + void *current_stack_frame = &__csf; /* Get pointer inside current stack frame */ cothread_context *ctx; /* if there already is a cotread context for this thread, * just return it */ ctx = g_static_private_get (&_cothread_ctx_key); if (ctx) { - GST_CAT_INFO (GST_CAT_COTHREADS, - "returning private _cothread_ctx_key %p", ctx); + GST_CAT_INFO (GST_CAT_COTHREADS, + "returning private _cothread_ctx_key %p", ctx); return ctx; } @@ -133,16 +133,17 @@ cothread_context_init (void) ctx->ncothreads = 1; ctx->current = 0; ctx->data = g_hash_table_new (g_str_hash, g_str_equal); - ctx->thread = g_thread_self(); + ctx->thread = g_thread_self (); GST_CAT_INFO (GST_CAT_COTHREADS, "initializing cothreads"); /* set this thread's context pointer */ - GST_CAT_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to %p in thread %p", - ctx,g_thread_self()); + GST_CAT_INFO (GST_CAT_COTHREADS, + "setting private _cothread_ctx_key to %p in thread %p", ctx, + g_thread_self ()); g_static_private_set (&_cothread_ctx_key, ctx, NULL); - g_assert(ctx == cothread_get_current_context()); + g_assert (ctx == cothread_get_current_context ()); /* clear the cothread data */ memset (ctx->cothreads, 0, sizeof (ctx->cothreads)); @@ -170,8 +171,8 @@ cothread_context_init (void) ctx->cothreads[0]->flags = COTHREAD_STARTED; ctx->cothreads[0]->sp = (void *) current_stack_frame; - GST_CAT_INFO (GST_CAT_COTHREADS, "0th cothread is %p at sp:%p", - ctx->cothreads[0], ctx->cothreads[0]->sp); + GST_CAT_INFO (GST_CAT_COTHREADS, "0th cothread is %p at sp:%p", + ctx->cothreads[0], ctx->cothreads[0]->sp); return ctx; } @@ -183,12 +184,12 @@ cothread_context_init (void) * Free the cothread context. */ void -cothread_context_free (cothread_context *ctx) +cothread_context_free (cothread_context * ctx) { gint i; g_return_if_fail (ctx != NULL); - g_assert (ctx->thread == g_thread_self()); + g_assert (ctx->thread == g_thread_self ()); g_assert (ctx->current == 0); GST_CAT_INFO (GST_CAT_COTHREADS, "free cothread context"); @@ -199,13 +200,14 @@ cothread_context_free (cothread_context *ctx) } } if (ctx->cothreads[0]) { - g_free(ctx->cothreads[0]); + g_free (ctx->cothreads[0]); ctx->cothreads[0] = NULL; } g_hash_table_destroy (ctx->data); /* make sure we free the private key for cothread context */ - GST_CAT_INFO (GST_CAT_COTHREADS, "setting private _cothread_ctx_key to NULL in thread %p", - g_thread_self()); + GST_CAT_INFO (GST_CAT_COTHREADS, + "setting private _cothread_ctx_key to NULL in thread %p", + g_thread_self ()); g_static_private_set (&_cothread_ctx_key, NULL, NULL); g_free (ctx); } @@ -218,8 +220,8 @@ cothread_context_free (cothread_context *ctx) * * Returns: the new cothread state or NULL on error */ -cothread_state* -cothread_create (cothread_context *ctx) +cothread_state * +cothread_create (cothread_context * ctx) { cothread_state *cothread; void *mmaped = 0; @@ -228,8 +230,8 @@ cothread_create (cothread_context *ctx) g_return_val_if_fail (ctx != NULL, NULL); - GST_CAT_DEBUG (GST_CAT_COTHREADS, "manager sef %p, cothread self %p", - ctx->thread, g_thread_self()); + GST_CAT_DEBUG (GST_CAT_COTHREADS, "manager sef %p, cothread self %p", + ctx->thread, g_thread_self ()); if (ctx->ncothreads == COTHREAD_MAXTHREADS) { /* this is pretty fatal */ @@ -241,7 +243,7 @@ cothread_create (cothread_context *ctx) if (ctx->cothreads[slot] == NULL) break; else if (ctx->cothreads[slot]->flags & COTHREAD_DESTROYED && - slot != ctx->current) { + slot != ctx->current) { cothread_destroy (ctx->cothreads[slot]); break; } @@ -251,66 +253,69 @@ cothread_create (cothread_context *ctx) /* cothread stack space of the thread is mapped in reverse, with cothread 0 * stack space at the top */ - cothread = (cothread_state *) (ctx->stack_top - (slot + 1) * COTHREAD_STACKSIZE); + cothread = + (cothread_state *) (ctx->stack_top - (slot + 1) * COTHREAD_STACKSIZE); GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread pointer is %p", cothread); #if 0 /* This tests to see whether or not we can grow down the stack */ { unsigned long ptr; - for(ptr=ctx->stack_top - 4096; ptr > (unsigned long)cothread; ptr -= 4096){ + + for (ptr = ctx->stack_top - 4096; ptr > (unsigned long) cothread; + ptr -= 4096) { GST_CAT_DEBUG (GST_CAT_COTHREADS, "touching location 0x%08lx", ptr); - *(volatile unsigned int *)ptr = *(volatile unsigned int *)ptr; - GST_CAT_DEBUG (GST_CAT_COTHREADS, "ok (0x%08x)", *(unsigned int *)ptr); + *(volatile unsigned int *) ptr = *(volatile unsigned int *) ptr; + GST_CAT_DEBUG (GST_CAT_COTHREADS, "ok (0x%08x)", *(unsigned int *) ptr); } } #endif #ifdef _SC_PAGESIZE - page_size = sysconf(_SC_PAGESIZE); + page_size = sysconf (_SC_PAGESIZE); #else - page_size = getpagesize(); + page_size = getpagesize (); #endif /* The mmap is necessary on Linux/i386, and possibly others, since the * kernel is picky about when we can expand our stack. */ GST_CAT_DEBUG (GST_CAT_COTHREADS, "mmaping %p, size 0x%08x", cothread, - COTHREAD_STACKSIZE); + COTHREAD_STACKSIZE); /* Remap with a guard page. This decreases our stack size by 8 kB (for * 4 kB pages) and also wastes almost 4 kB for the cothreads * structure */ - munmap((void *)cothread, COTHREAD_STACKSIZE); + munmap ((void *) cothread, COTHREAD_STACKSIZE); mmaped = mmap ((void *) cothread, page_size, - PROT_READ | PROT_WRITE, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); mmaped = mmap (((void *) cothread) + page_size * 2, - COTHREAD_STACKSIZE - page_size * 2, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + COTHREAD_STACKSIZE - page_size * 2, + PROT_READ | PROT_WRITE | PROT_EXEC, + MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); GST_CAT_DEBUG (GST_CAT_COTHREADS, "coming out of mmap"); if (mmaped == MAP_FAILED) { perror ("mmap'ing cothread stack space"); return NULL; } - if (mmaped != (void *)cothread + page_size * 2) { + if (mmaped != (void *) cothread + page_size * 2) { g_warning ("could not mmap requested memory for cothread"); return NULL; } cothread->magic_number = COTHREAD_MAGIC_NUMBER; - GST_CAT_DEBUG (GST_CAT_COTHREADS, "create cothread %d with magic number 0x%x", - slot, cothread->magic_number); + GST_CAT_DEBUG (GST_CAT_COTHREADS, + "create cothread %d with magic number 0x%x", slot, + cothread->magic_number); cothread->ctx = ctx; cothread->cothreadnum = slot; cothread->flags = 0; cothread->priv = NULL; cothread->sp = ((guchar *) cothread + COTHREAD_STACKSIZE); cothread->stack_size = COTHREAD_STACKSIZE - page_size * 2; - cothread->stack_base = (void *)cothread + 2 * page_size; + cothread->stack_base = (void *) cothread + 2 * page_size; - GST_CAT_INFO (GST_CAT_COTHREADS, - "created cothread #%d in slot %d: %p at sp:%p", - ctx->ncothreads, slot, cothread, cothread->sp); + GST_CAT_INFO (GST_CAT_COTHREADS, + "created cothread #%d in slot %d: %p at sp:%p", + ctx->ncothreads, slot, cothread, cothread->sp); ctx->cothreads[slot] = cothread; ctx->ncothreads++; @@ -325,12 +330,12 @@ cothread_create (cothread_context *ctx) * Free the given cothread state */ void -cothread_free (cothread_state *cothread) +cothread_free (cothread_state * cothread) { g_return_if_fail (cothread != NULL); - GST_CAT_INFO (GST_CAT_COTHREADS, "flag cothread %d for destruction", - cothread->cothreadnum); + GST_CAT_INFO (GST_CAT_COTHREADS, "flag cothread %d for destruction", + cothread->cothreadnum); /* we simply flag the cothread for destruction here */ if (cothread) @@ -340,7 +345,7 @@ cothread_free (cothread_state *cothread) } static void -cothread_destroy (cothread_state *cothread) +cothread_destroy (cothread_state * cothread) { cothread_context *ctx; gint cothreadnum; @@ -349,27 +354,28 @@ cothread_destroy (cothread_state *cothread) cothreadnum = cothread->cothreadnum; ctx = cothread->ctx; - g_assert (ctx->thread == g_thread_self()); - g_assert (ctx == cothread_get_current_context()); + g_assert (ctx->thread == g_thread_self ()); + g_assert (ctx == cothread_get_current_context ()); - GST_CAT_INFO (GST_CAT_COTHREADS, "destroy cothread %d %p %d", - cothreadnum, cothread, ctx->current); + GST_CAT_INFO (GST_CAT_COTHREADS, "destroy cothread %d %p %d", + cothreadnum, cothread, ctx->current); /* cothread 0 needs to be destroyed specially */ - g_assert(cothreadnum != 0); + g_assert (cothreadnum != 0); /* we have to unlock here because we might be switched out * with the lock held */ cothread_unlock (cothread); /* doing cleanups of the cothread create */ - GST_CAT_DEBUG (GST_CAT_COTHREADS, "destroy cothread %d with magic number 0x%x", - cothreadnum, cothread->magic_number); + GST_CAT_DEBUG (GST_CAT_COTHREADS, + "destroy cothread %d with magic number 0x%x", cothreadnum, + cothread->magic_number); g_assert (cothread->magic_number == COTHREAD_MAGIC_NUMBER); g_assert (cothread->priv == NULL); - memset(cothread,0,sizeof(*cothread)); + memset (cothread, 0, sizeof (*cothread)); ctx->cothreads[cothreadnum] = NULL; ctx->ncothreads--; @@ -385,7 +391,8 @@ cothread_destroy (cothread_state *cothread) * Set the cothread function */ void -cothread_setfunc (cothread_state* cothread, cothread_func func, int argc, char **argv) +cothread_setfunc (cothread_state * cothread, cothread_func func, int argc, + char **argv) { cothread->func = func; cothread->argc = argc; @@ -399,7 +406,7 @@ cothread_setfunc (cothread_state* cothread, cothread_func func, int argc, char * * Stop the cothread and reset the stack and program counter. */ void -cothread_stop (cothread_state* cothread) +cothread_stop (cothread_state * cothread) { cothread->flags &= ~COTHREAD_STARTED; } @@ -412,13 +419,13 @@ cothread_stop (cothread_state* cothread) * * Returns: the #cothread_state of the main (0th) cothread. */ -cothread_state* -cothread_main (cothread_context* ctx) +cothread_state * +cothread_main (cothread_context * ctx) { - g_assert (ctx->thread == g_thread_self()); + g_assert (ctx->thread == g_thread_self ()); - GST_CAT_DEBUG (GST_CAT_COTHREADS, "returning %p, the 0th cothread", - ctx->cothreads[0]); + GST_CAT_DEBUG (GST_CAT_COTHREADS, "returning %p, the 0th cothread", + ctx->cothreads[0]); return ctx->cothreads[0]; } @@ -429,10 +436,10 @@ cothread_main (cothread_context* ctx) * * Returns: the #cothread_state of the main (0th) thread in the current GThread */ -cothread_state* +cothread_state * cothread_current_main (void) { - cothread_context *ctx = cothread_get_current_context(); + cothread_context *ctx = cothread_get_current_context (); return ctx->cothreads[0]; } @@ -444,10 +451,10 @@ cothread_current_main (void) * * Returns: the #cothread_state of the current cothread */ -cothread_state* +cothread_state * cothread_current (void) { - cothread_context *ctx = cothread_get_current_context(); + cothread_context *ctx = cothread_get_current_context (); return ctx->cothreads[ctx->current]; } @@ -455,9 +462,10 @@ cothread_current (void) static void cothread_stub (void) { - cothread_context *ctx = cothread_get_current_context(); + cothread_context *ctx = cothread_get_current_context (); cothread_state *cothread = ctx->cothreads[ctx->current]; -#ifndef GST_DISABLE_GST_DEBUG + +#ifndef GST_DISABLE_GST_DEBUG char __csf; void *current_stack_frame = &__csf; #endif @@ -469,11 +477,13 @@ cothread_stub (void) while (TRUE) { cothread->func (cothread->argc, cothread->argv); - GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited", ctx->current); + GST_CAT_DEBUG (GST_CAT_COTHREADS, "cothread[%d] thread->func exited", + ctx->current); GST_CAT_DEBUG (GST_CAT_COTHREADS, "sp=%p", current_stack_frame); - GST_CAT_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx,cothread_get_current_context()); - g_assert (ctx == cothread_get_current_context()); + GST_CAT_DEBUG (GST_CAT_COTHREADS, "ctx=%p current=%p", ctx, + cothread_get_current_context ()); + g_assert (ctx == cothread_get_current_context ()); g_assert (ctx->current != 0); @@ -489,12 +499,13 @@ cothread_stub (void) * * Returns: the current cothread id */ -int cothread_getcurrent (void) G_GNUC_NO_INSTRUMENT; - int cothread_getcurrent (void) + G_GNUC_NO_INSTRUMENT; + + int cothread_getcurrent (void) { - cothread_context *ctx = cothread_get_current_context(); + cothread_context *ctx = cothread_get_current_context (); if (!ctx) return -1; @@ -510,7 +521,7 @@ cothread_getcurrent (void) * set private data for the cothread. */ void -cothread_set_private (cothread_state *cothread, gpointer data) +cothread_set_private (cothread_state * cothread, gpointer data) { cothread->priv = data; } @@ -524,9 +535,10 @@ cothread_set_private (cothread_state *cothread, gpointer data) * adds data to a cothread */ void -cothread_context_set_data (cothread_state *cothread, gchar *key, gpointer data) +cothread_context_set_data (cothread_state * cothread, gchar * key, + gpointer data) { - cothread_context *ctx = cothread_get_current_context(); + cothread_context *ctx = cothread_get_current_context (); g_hash_table_insert (ctx->data, key, data); } @@ -540,7 +552,7 @@ cothread_context_set_data (cothread_state *cothread, gchar *key, gpointer data) * Returns: the private data of the cothread */ gpointer -cothread_get_private (cothread_state *cothread) +cothread_get_private (cothread_state * cothread) { return cothread->priv; } @@ -555,9 +567,9 @@ cothread_get_private (cothread_state *cothread) * Returns: the data associated with the key */ gpointer -cothread_context_get_data (cothread_state *cothread, gchar *key) +cothread_context_get_data (cothread_state * cothread, gchar * key) { - cothread_context *ctx = cothread_get_current_context(); + cothread_context *ctx = cothread_get_current_context (); return g_hash_table_lookup (ctx->data, key); } @@ -569,7 +581,7 @@ cothread_context_get_data (cothread_state *cothread, gchar *key) * Switches to the given cothread state */ void -cothread_switch (cothread_state *cothread) +cothread_switch (cothread_state * cothread) { cothread_context *ctx; cothread_state *current; @@ -582,7 +594,7 @@ cothread_switch (cothread_state *cothread) ctx = cothread->ctx; /* paranoia check to make sure we're in the right thread */ - g_assert (ctx->thread == g_thread_self()); + g_assert (ctx->thread == g_thread_self ()); #ifdef COTHREAD_PARANOID if (ctx == NULL) @@ -599,9 +611,9 @@ cothread_switch (cothread_state *cothread) /* find the number of the thread to switch to */ - GST_CAT_INFO (GST_CAT_COTHREAD_SWITCH, - "switching from cothread #%d to cothread #%d", - ctx->current, cothread->cothreadnum); + GST_CAT_INFO (GST_CAT_COTHREAD_SWITCH, + "switching from cothread #%d to cothread #%d", + ctx->current, cothread->cothreadnum); ctx->current = cothread->cothreadnum; /* save the current stack pointer, frame pointer, and pc */ @@ -610,13 +622,13 @@ cothread_switch (cothread_state *cothread) #endif enter = setjmp (current->jmp); if (enter != 0) { - GST_CAT_DEBUG (GST_CAT_COTHREADS, - "enter cothread #%d %d sp=%p jmpbuf=%p", - current->cothreadnum, enter, current->sp, current->jmp); + GST_CAT_DEBUG (GST_CAT_COTHREADS, + "enter cothread #%d %d sp=%p jmpbuf=%p", + current->cothreadnum, enter, current->sp, current->jmp); return; } - GST_CAT_DEBUG (GST_CAT_COTHREADS, "exit cothread #%d %d sp=%p jmpbuf=%p", - current->cothreadnum, enter, current->sp, current->jmp); + GST_CAT_DEBUG (GST_CAT_COTHREADS, "exit cothread #%d %d sp=%p jmpbuf=%p", + current->cothreadnum, enter, current->sp, current->jmp); enter = 1; if (current->flags & COTHREAD_DESTROYED) { @@ -629,22 +641,21 @@ cothread_switch (cothread_state *cothread) GST_CAT_DEBUG (GST_CAT_COTHREADS, "via longjmp() jmpbuf %p", cothread->jmp); /* switch to it */ longjmp (cothread->jmp, 1); - } - else { + } else { #ifdef HAVE_MAKECONTEXT ucontext_t ucp; GST_CAT_DEBUG (GST_CAT_COTHREADS, "making context"); - g_assert (cothread != cothread_main(ctx)); + g_assert (cothread != cothread_main (ctx)); getcontext (&ucp); - ucp.uc_stack.ss_sp = (void *)cothread->stack_base; + ucp.uc_stack.ss_sp = (void *) cothread->stack_base; ucp.uc_stack.ss_size = cothread->stack_size; makecontext (&ucp, cothread_stub, 0); setcontext (&ucp); #else - GST_ARCH_SETUP_STACK ((char*)cothread->sp); + GST_ARCH_SETUP_STACK ((char *) cothread->sp); GST_ARCH_SET_SP (cothread->sp); /* start it */ GST_ARCH_CALL (cothread_stub); @@ -668,7 +679,8 @@ nocurrent: exit (2); #endif /* COTHREAD_PARANOID */ selfswitch: - g_warning ("cothread: trying to switch to same thread, legal but not necessary"); + g_warning + ("cothread: trying to switch to same thread, legal but not necessary"); return; } @@ -679,7 +691,7 @@ selfswitch: * Locks the cothread state. */ void -cothread_lock (cothread_state *cothread) +cothread_lock (cothread_state * cothread) { } @@ -692,7 +704,7 @@ cothread_lock (cothread_state *cothread) * Returns: TRUE if the cothread could be locked. */ gboolean -cothread_trylock (cothread_state *cothread) +cothread_trylock (cothread_state * cothread) { return TRUE; } @@ -704,6 +716,6 @@ cothread_trylock (cothread_state *cothread) * Unlock the cothread state. */ void -cothread_unlock (cothread_state *cothread) +cothread_unlock (cothread_state * cothread) { } diff --git a/gst/cothreads.h b/gst/cothreads.h index da4fc0241..370c52aa1 100644 --- a/gst/cothreads.h +++ b/gst/cothreads.h @@ -26,56 +26,56 @@ #include #include -typedef struct _cothread_state cothread_state; -typedef struct _cothread_context cothread_context; +typedef struct _cothread_state cothread_state; +typedef struct _cothread_context cothread_context; -typedef int (*cothread_func) (int argc,char **argv); +typedef int (*cothread_func) (int argc, char **argv); #define COTHREAD_STARTED 0x01 #define COTHREAD_DESTROYED 0x02 -struct _cothread_state { - cothread_context *ctx; - int cothreadnum; - gpointer priv; +struct _cothread_state +{ + cothread_context *ctx; + int cothreadnum; + gpointer priv; - cothread_func func; - int argc; - char **argv; + cothread_func func; + int argc; + char **argv; - int flags; - void *sp; - jmp_buf jmp; - void *stack_base; - unsigned long stack_size; + int flags; + void *sp; + jmp_buf jmp; + void *stack_base; + unsigned long stack_size; - int magic_number; + int magic_number; }; -cothread_context* cothread_context_init (void); -void cothread_context_free (cothread_context *ctx); -void cothread_context_set_data (cothread_state *cothread, - gchar *key, gpointer data); -gpointer cothread_context_get_data (cothread_state *cothread, gchar *key); +cothread_context *cothread_context_init (void); +void cothread_context_free (cothread_context * ctx); +void cothread_context_set_data (cothread_state * cothread, + gchar * key, gpointer data); +gpointer cothread_context_get_data (cothread_state * cothread, gchar * key); -cothread_state* cothread_create (cothread_context *ctx); -void cothread_free (cothread_state *cothread); -void cothread_setfunc (cothread_state *cothread, cothread_func func, - int argc, char **argv); -void cothread_stop (cothread_state *cothread); +cothread_state *cothread_create (cothread_context * ctx); +void cothread_free (cothread_state * cothread); +void cothread_setfunc (cothread_state * cothread, cothread_func func, + int argc, char **argv); +void cothread_stop (cothread_state * cothread); -void cothread_switch (cothread_state *cothread); -void cothread_set_private (cothread_state *cothread, - gpointer data); -gpointer cothread_get_private (cothread_state *cothread); +void cothread_switch (cothread_state * cothread); +void cothread_set_private (cothread_state * cothread, gpointer data); +gpointer cothread_get_private (cothread_state * cothread); -void cothread_lock (cothread_state *cothread); -gboolean cothread_trylock (cothread_state *cothread); -void cothread_unlock (cothread_state *cothread); +void cothread_lock (cothread_state * cothread); +gboolean cothread_trylock (cothread_state * cothread); +void cothread_unlock (cothread_state * cothread); -cothread_state* cothread_main (cothread_context *ctx); -cothread_state* cothread_current_main (void); -cothread_state* cothread_current (void); +cothread_state *cothread_main (cothread_context * ctx); +cothread_state *cothread_current_main (void); +cothread_state *cothread_current (void); #endif /* __COTHREAD_H__ */ diff --git a/gst/elements/gstaggregator.c b/gst/elements/gstaggregator.c index b4945b8a0..1ad3b2a98 100644 --- a/gst/elements/gstaggregator.c +++ b/gst/elements/gstaggregator.c @@ -29,20 +29,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_aggregator_debug); #define GST_CAT_DEFAULT gst_aggregator_debug -GstElementDetails gst_aggregator_details = GST_ELEMENT_DETAILS ( - "Aggregator pipe fitting", - "Generic", - "N-to-1 pipe fitting", - "Wim Taymans " -); +GstElementDetails gst_aggregator_details = +GST_ELEMENT_DETAILS ("Aggregator pipe fitting", + "Generic", + "N-to-1 pipe fitting", + "Wim Taymans "); /* Aggregator signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_NUM_PADS, ARG_SILENT, @@ -51,12 +52,11 @@ enum { /* FILL ME */ }; -GstStaticPadTemplate aggregator_src_template = GST_STATIC_PAD_TEMPLATE ( - "sink%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate aggregator_src_template = +GST_STATIC_PAD_TEMPLATE ("sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_AGGREGATOR_SCHED (gst_aggregator_sched_get_type()) static GType @@ -64,75 +64,80 @@ gst_aggregator_sched_get_type (void) { static GType aggregator_sched_type = 0; static GEnumValue aggregator_sched[] = { - { AGGREGATOR_LOOP, "1", "Loop Based"}, - { AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"}, - { AGGREGATOR_CHAIN, "4", "Chain Based"}, + {AGGREGATOR_LOOP, "1", "Loop Based"}, + {AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"}, + {AGGREGATOR_CHAIN, "4", "Chain Based"}, {0, NULL, NULL}, }; if (!aggregator_sched_type) { - aggregator_sched_type = g_enum_register_static ("GstAggregatorSched", aggregator_sched); + aggregator_sched_type = + g_enum_register_static ("GstAggregatorSched", aggregator_sched); } return aggregator_sched_type; } #define AGGREGATOR_IS_LOOP_BASED(ag) ((ag)->sched != AGGREGATOR_CHAIN) -static GstPad* gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *temp, const - gchar *unused); -static void gst_aggregator_update_functions (GstAggregator *aggregator); +static GstPad *gst_aggregator_request_new_pad (GstElement * element, + GstPadTemplate * temp, const gchar * unused); +static void gst_aggregator_update_functions (GstAggregator * aggregator); -static void gst_aggregator_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_aggregator_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_aggregator_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_aggregator_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_aggregator_chain (GstPad *pad, GstData *_data); -static void gst_aggregator_loop (GstElement *element); +static void gst_aggregator_chain (GstPad * pad, GstData * _data); +static void gst_aggregator_loop (GstElement * element); #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_aggregator_debug, "aggregator", 0, "aggregator element"); -GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement, + GST_TYPE_ELEMENT, _do_init); static void gst_aggregator_base_init (gpointer g_class) { - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&aggregator_src_template)); gst_element_class_set_details (gstelement_class, &gst_aggregator_details); } static void -gst_aggregator_class_init (GstAggregatorClass *klass) +gst_aggregator_class_init (GstAggregatorClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*) klass; - gstelement_class = (GstElementClass*) klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, - g_param_spec_int ("num_pads", "Num pads", "The number of source pads", - 0, G_MAXINT, 0, G_PARAM_READABLE)); + g_param_spec_int ("num_pads", "Num pads", "The number of source pads", + 0, G_MAXINT, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "Silent", "Don't produce messages", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "Silent", "Don't produce messages", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED, - g_param_spec_enum ("sched", "Scheduling", "The type of scheduling this element should use", - GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE)); + g_param_spec_enum ("sched", "Scheduling", + "The type of scheduling this element should use", + GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last_message", "Last message", "The current state of the element", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last_message", "Last message", + "The current state of the element", NULL, G_PARAM_READABLE)); - gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_aggregator_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_aggregator_get_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_aggregator_request_new_pad); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad); } -static void -gst_aggregator_init (GstAggregator *aggregator) +static void +gst_aggregator_init (GstAggregator * aggregator) { aggregator->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_getcaps_function (aggregator->srcpad, gst_pad_proxy_getcaps); @@ -146,8 +151,9 @@ gst_aggregator_init (GstAggregator *aggregator) gst_aggregator_update_functions (aggregator); } -static GstPad* -gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_aggregator_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *sinkpad; @@ -162,43 +168,42 @@ gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, cons aggregator = GST_AGGREGATOR (element); - name = g_strdup_printf ("sink%d",aggregator->numsinkpads); - + name = g_strdup_printf ("sink%d", aggregator->numsinkpads); + sinkpad = gst_pad_new_from_template (templ, name); g_free (name); - + if (!AGGREGATOR_IS_LOOP_BASED (aggregator)) { gst_pad_set_chain_function (sinkpad, gst_aggregator_chain); } gst_pad_set_getcaps_function (sinkpad, gst_pad_proxy_getcaps); gst_element_add_pad (GST_ELEMENT (aggregator), sinkpad); - + aggregator->sinkpads = g_list_prepend (aggregator->sinkpads, sinkpad); aggregator->numsinkpads++; - + return sinkpad; } static void -gst_aggregator_update_functions (GstAggregator *aggregator) +gst_aggregator_update_functions (GstAggregator * aggregator) { GList *pads; if (AGGREGATOR_IS_LOOP_BASED (aggregator)) { - gst_element_set_loop_function (GST_ELEMENT (aggregator), GST_DEBUG_FUNCPTR (gst_aggregator_loop)); - } - else { + gst_element_set_loop_function (GST_ELEMENT (aggregator), + GST_DEBUG_FUNCPTR (gst_aggregator_loop)); + } else { gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL); } pads = aggregator->sinkpads; while (pads) { GstPad *pad = GST_PAD (pads->data); - + if (AGGREGATOR_IS_LOOP_BASED (aggregator)) { gst_pad_set_get_function (pad, NULL); - } - else { + } else { gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL); } pads = g_list_next (pads); @@ -206,7 +211,8 @@ gst_aggregator_update_functions (GstAggregator *aggregator) } static void -gst_aggregator_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_aggregator_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstAggregator *aggregator; @@ -229,7 +235,8 @@ gst_aggregator_set_property (GObject *object, guint prop_id, const GValue *value } static void -gst_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_aggregator_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstAggregator *aggregator; @@ -256,15 +263,17 @@ gst_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GPar } } -static void -gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guchar *debug) +static void +gst_aggregator_push (GstAggregator * aggregator, GstPad * pad, GstBuffer * buf, + guchar * debug) { if (!aggregator->silent) { g_free (aggregator->last_message); - aggregator->last_message = g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %" - G_GUINT64_FORMAT ")", - debug, GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); + aggregator->last_message = + g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %" + G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (aggregator), "last_message"); } @@ -272,8 +281,8 @@ gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guc gst_pad_push (aggregator->srcpad, GST_DATA (buf)); } -static void -gst_aggregator_loop (GstElement *element) +static void +gst_aggregator_loop (GstElement * element) { GstAggregator *aggregator; GstBuffer *buf; @@ -288,6 +297,7 @@ gst_aggregator_loop (GstElement *element) * active ones */ while (pads) { GstPad *pad = GST_PAD (pads->data); + pads = g_list_next (pads); /* we need to check is the pad is usable. IS_USABLE will check @@ -296,15 +306,14 @@ gst_aggregator_loop (GstElement *element) * and that the peer pad is also enabled. */ if (GST_PAD_IS_USABLE (pad)) { - buf = GST_BUFFER (gst_pad_pull (pad)); - debug = "loop"; + buf = GST_BUFFER (gst_pad_pull (pad)); + debug = "loop"; /* then push it forward */ - gst_aggregator_push (aggregator, pad, buf, debug); + gst_aggregator_push (aggregator, pad, buf, debug); } } - } - else { + } else { if (aggregator->sched == AGGREGATOR_LOOP_SELECT) { GstPad *pad; @@ -314,8 +323,7 @@ gst_aggregator_loop (GstElement *element) buf = GST_BUFFER (gst_pad_pull (pad)); gst_aggregator_push (aggregator, pad, buf, debug); - } - else { + } else { g_assert_not_reached (); } } @@ -328,8 +336,8 @@ gst_aggregator_loop (GstElement *element) * * Chain a buffer on a pad. */ -static void -gst_aggregator_chain (GstPad *pad, GstData *_data) +static void +gst_aggregator_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstAggregator *aggregator; @@ -343,4 +351,3 @@ gst_aggregator_chain (GstPad *pad, GstData *_data) gst_aggregator_push (aggregator, pad, buf, "chain"); } - diff --git a/gst/elements/gstaggregator.h b/gst/elements/gstaggregator.h index 7e6105bf0..e0e9261a4 100644 --- a/gst/elements/gstaggregator.h +++ b/gst/elements/gstaggregator.h @@ -26,11 +26,9 @@ #include -G_BEGIN_DECLS - - -typedef enum { - AGGREGATOR_LOOP = 1, +G_BEGIN_DECLS typedef enum +{ + AGGREGATOR_LOOP = 1, AGGREGATOR_LOOP_SELECT, AGGREGATOR_CHAIN } GstAggregatorSchedType; @@ -46,10 +44,11 @@ typedef enum { #define GST_IS_AGGREGATOR_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AGGREGATOR)) -typedef struct _GstAggregator GstAggregator; -typedef struct _GstAggregatorClass GstAggregatorClass; +typedef struct _GstAggregator GstAggregator; +typedef struct _GstAggregatorClass GstAggregatorClass; -struct _GstAggregator { +struct _GstAggregator +{ GstElement element; GstPad *srcpad; @@ -63,14 +62,14 @@ struct _GstAggregator { gchar *last_message; }; -struct _GstAggregatorClass { +struct _GstAggregatorClass +{ GstElementClass parent_class; }; -GType gst_aggregator_get_type (void); +GType gst_aggregator_get_type (void); -gboolean gst_aggregator_factory_init (GstElementFactory *factory); +gboolean gst_aggregator_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_AGGREGATOR_H__ */ diff --git a/gst/elements/gstbufferstore.c b/gst/elements/gstbufferstore.c index cb433f41b..a942f78d2 100644 --- a/gst/elements/gstbufferstore.c +++ b/gst/elements/gstbufferstore.c @@ -29,47 +29,53 @@ GST_DEBUG_CATEGORY_STATIC (gst_buffer_store_debug); #define GST_CAT_DEFAULT gst_buffer_store_debug -enum { +enum +{ CLEARED, BUFFER_ADDED, LAST_SIGNAL }; -enum { +enum +{ ARG_0 }; -static void gst_buffer_store_dispose (GObject * object); +static void gst_buffer_store_dispose (GObject * object); + +static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store, + GstBuffer * buffer); +static void gst_buffer_store_cleared_func (GstBufferStore * store); -static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store, - GstBuffer * buffer); -static void gst_buffer_store_cleared_func (GstBufferStore * store); - static guint gst_buffer_store_signals[LAST_SIGNAL] = { 0 }; #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_buffer_store_debug, "GstBufferStore", 0, "buffer store helper"); -GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT, _do_init); +GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT, + _do_init); G_GNUC_UNUSED static void -debug_buffers (GstBufferStore *store) +debug_buffers (GstBufferStore * store) { GList *walk = store->buffers; - + g_printerr ("BUFFERS in store:\n"); while (walk) { - g_print ("%15"G_GUINT64_FORMAT" - %7u\n", GST_BUFFER_OFFSET (walk->data), GST_BUFFER_SIZE (walk->data)); + g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data), + GST_BUFFER_SIZE (walk->data)); walk = g_list_next (walk); } g_printerr ("\n"); } + static gboolean -continue_accu (GSignalInvocationHint *ihint, GValue *return_accu, - const GValue *handler_return, gpointer data) +continue_accu (GSignalInvocationHint * ihint, GValue * return_accu, + const GValue * handler_return, gpointer data) { gboolean do_continue = g_value_get_boolean (handler_return); + g_value_set_boolean (return_accu, do_continue); return do_continue; @@ -79,31 +85,31 @@ gst_buffer_store_base_init (gpointer g_class) { } static void -gst_buffer_store_class_init (GstBufferStoreClass *store_class) +gst_buffer_store_class_init (GstBufferStoreClass * store_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (store_class); gobject_class->dispose = gst_buffer_store_dispose; - - gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared", - G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL, - gst_marshal_VOID__VOID, G_TYPE_NONE, 0); - gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added", - G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL, - gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER); + + gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared", + G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL, + gst_marshal_VOID__VOID, G_TYPE_NONE, 0); + gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added", + G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL, + gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER); store_class->cleared = gst_buffer_store_cleared_func; store_class->buffer_added = gst_buffer_store_add_buffer_func; } static void -gst_buffer_store_init (GstBufferStore *store) +gst_buffer_store_init (GstBufferStore * store) { store->buffers = NULL; } static void -gst_buffer_store_dispose (GObject *object) +gst_buffer_store_dispose (GObject * object) { GstBufferStore *store = GST_BUFFER_STORE (object); @@ -111,22 +117,24 @@ gst_buffer_store_dispose (GObject *object) parent_class->dispose (object); } + static gboolean -gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) +gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer) { g_assert (buffer != NULL); - + if (!GST_BUFFER_OFFSET_IS_VALID (buffer) && - store->buffers && - GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { + store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { /* we assumed valid offsets, but suddenly they are not anymore */ - GST_DEBUG_OBJECT (store, "attempting to add buffer %p with invalid offset to store with valid offset, abort", - buffer); + GST_DEBUG_OBJECT (store, + "attempting to add buffer %p with invalid offset to store with valid offset, abort", + buffer); return FALSE; - } else if (!store->buffers || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { + } else if (!store->buffers + || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { /* the starting buffer had an invalid offset, in that case we assume continuous buffers */ GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u", - buffer, GST_BUFFER_SIZE (buffer)); + buffer, GST_BUFFER_SIZE (buffer)); gst_data_ref (GST_DATA (buffer)); store->buffers = g_list_append (store->buffers, buffer); return TRUE; @@ -134,10 +142,12 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) /* both list and buffer have valid offsets, we can really go wild */ GList *walk, *current_list = NULL; GstBuffer *current; - + g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer)); - GST_LOG_OBJECT (store, "attempting to add buffer %p with offset %"G_GUINT64_FORMAT" and size %u", - buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + GST_LOG_OBJECT (store, + "attempting to add buffer %p with offset %" G_GUINT64_FORMAT + " and size %u", buffer, GST_BUFFER_OFFSET (buffer), + GST_BUFFER_SIZE (buffer)); /* we keep a sorted list of non-overlapping buffers */ walk = store->buffers; while (walk) { @@ -148,9 +158,10 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) continue; } else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) { guint needed_size; + if (walk) { - needed_size = MIN (GST_BUFFER_SIZE (buffer), - GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current)); + needed_size = MIN (GST_BUFFER_SIZE (buffer), + GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current)); } else { needed_size = GST_BUFFER_SIZE (buffer); } @@ -161,14 +172,17 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) if (needed_size < GST_BUFFER_SIZE (buffer)) { /* need to create subbuffer to not have overlapping data */ GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size); + g_assert (sub); buffer = sub; } else { gst_data_ref (GST_DATA (buffer)); } /* replace current buffer with new one */ - GST_INFO_OBJECT (store, "replacing buffer %p with buffer %p with offset %"G_GINT64_FORMAT" and size %u", - current_list->data, buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + GST_INFO_OBJECT (store, + "replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT + " and size %u", current_list->data, buffer, + GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); gst_data_unref (GST_DATA (current_list->data)); current_list->data = buffer; buffer = NULL; @@ -176,8 +190,9 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } } else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) { GList *previous = g_list_previous (current_list); - guint64 start_offset = previous ? - GST_BUFFER_OFFSET (previous->data) + GST_BUFFER_SIZE (previous->data) : 0; + guint64 start_offset = previous ? + GST_BUFFER_OFFSET (previous->data) + + GST_BUFFER_SIZE (previous->data) : 0; if (start_offset == GST_BUFFER_OFFSET (current)) { buffer = NULL; @@ -185,23 +200,28 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } else { /* we have data to insert */ if (start_offset > GST_BUFFER_OFFSET (buffer) || - GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > GST_BUFFER_OFFSET (current)) { + GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > + GST_BUFFER_OFFSET (current)) { GstBuffer *sub; /* need a subbuffer */ - start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 : - start_offset - GST_BUFFER_OFFSET (buffer); + start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 : + start_offset - GST_BUFFER_OFFSET (buffer); sub = gst_buffer_create_sub (buffer, start_offset, - MIN (GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (current) - start_offset - GST_BUFFER_OFFSET (buffer))); + MIN (GST_BUFFER_SIZE (buffer), + GST_BUFFER_OFFSET (current) - start_offset - + GST_BUFFER_OFFSET (buffer))); g_assert (sub); GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer); buffer = sub; } else { gst_data_ref (GST_DATA (buffer)); } - GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u", - buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); - store->buffers = g_list_insert_before (store->buffers, current_list, buffer); + GST_INFO_OBJECT (store, + "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", + buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + store->buffers = + g_list_insert_before (store->buffers, current_list, buffer); buffer = NULL; break; } @@ -209,8 +229,9 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } if (buffer) { gst_data_ref (GST_DATA (buffer)); - GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u", - buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + GST_INFO_OBJECT (store, + "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", + buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); if (current_list) { g_list_append (current_list, buffer); } else { @@ -222,12 +243,13 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } } static void -gst_buffer_store_cleared_func (GstBufferStore *store) +gst_buffer_store_cleared_func (GstBufferStore * store) { g_list_foreach (store->buffers, (GFunc) gst_data_unref, NULL); g_list_free (store->buffers); store->buffers = NULL; } + /** * gst_buffer_store_new: * @@ -240,6 +262,7 @@ gst_buffer_store_new (void) { return GST_BUFFER_STORE (g_object_new (GST_TYPE_BUFFER_STORE, NULL)); } + /** * gst_buffer_store_clear: * @store: a bufferstore @@ -249,12 +272,13 @@ gst_buffer_store_new (void) */ /* FIXME: call this function _reset ? */ void -gst_buffer_store_clear (GstBufferStore *store) +gst_buffer_store_clear (GstBufferStore * store) { g_return_if_fail (GST_IS_BUFFER_STORE (store)); - - g_signal_emit (store, gst_buffer_store_signals [CLEARED], 0, NULL); + + g_signal_emit (store, gst_buffer_store_signals[CLEARED], 0, NULL); } + /** * gst_buffer_store_add_buffer: * @store: a bufferstore @@ -265,10 +289,10 @@ gst_buffer_store_clear (GstBufferStore *store) * Returns: TRUE, if the buffer was added, FALSE if an error occured. */ gboolean -gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer) +gst_buffer_store_add_buffer (GstBufferStore * store, GstBuffer * buffer) { gboolean ret; - + g_return_val_if_fail (GST_IS_BUFFER_STORE (store), FALSE); g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); @@ -276,11 +300,13 @@ gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer) GST_BUFFER_OFFSET_IS_VALID (store->buffers->data) && !GST_BUFFER_OFFSET_IS_VALID (buffer)) return FALSE; - - g_signal_emit (store, gst_buffer_store_signals [BUFFER_ADDED], 0, buffer, &ret); - + + g_signal_emit (store, gst_buffer_store_signals[BUFFER_ADDED], 0, buffer, + &ret); + return ret; } + /** * gst_buffer_store_get_buffer: * @store: a bufferstore @@ -295,7 +321,7 @@ gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer) * available. */ GstBuffer * -gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size) +gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size) { GstBuffer *current; GList *walk; @@ -324,38 +350,39 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size) if (cur_offset > offset) { /* #include do_nothing_loop (); */ - } else if (cur_offset == offset && - GST_BUFFER_SIZE (current) == size) { - GST_LOG_OBJECT (store, "found matching buffer %p for offset %"G_GUINT64_FORMAT" and size %u", - current, offset, size); + } else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) { + GST_LOG_OBJECT (store, + "found matching buffer %p for offset %" G_GUINT64_FORMAT + " and size %u", current, offset, size); ret = current; gst_data_ref (GST_DATA (ret)); - GST_LOG_OBJECT (store, "refcount %d", - GST_DATA_REFCOUNT_VALUE(ret)); + GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret)); break; } else if (cur_offset + GST_BUFFER_SIZE (current) > offset) { if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) { ret = gst_buffer_create_sub (current, offset - cur_offset, size); - GST_LOG_OBJECT (store, "created subbuffer %p from buffer %p for offset %llu and size %u", - ret, current, offset, size); + GST_LOG_OBJECT (store, + "created subbuffer %p from buffer %p for offset %llu and size %u", + ret, current, offset, size); break; } /* uh, the requested data spans some buffers */ ret = gst_buffer_new_and_alloc (size); - GST_LOG_OBJECT (store, "created buffer %p for offset %"G_GUINT64_FORMAT - " and size %u, will fill with data now", - ret, offset, size); + GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT + " and size %u, will fill with data now", ret, offset, size); data = GST_BUFFER_DATA (ret); tmp = GST_BUFFER_SIZE (current) - offset + cur_offset; memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp); data += tmp; size -= tmp; while (size) { - if (walk == NULL || - (have_offset && - GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data))) { - GST_DEBUG_OBJECT (store, "not all data for offset %"G_GUINT64_FORMAT" and remaining size %u available, aborting", - offset, size); + if (walk == NULL || + (have_offset && + GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != + GST_BUFFER_OFFSET (walk->data))) { + GST_DEBUG_OBJECT (store, + "not all data for offset %" G_GUINT64_FORMAT + " and remaining size %u available, aborting", offset, size); gst_data_unref (GST_DATA (ret)); ret = NULL; goto out; @@ -373,9 +400,10 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size) } } out: - + return ret; } + /** * gst_buffer_store_get_size: * @store: a bufferstore @@ -388,7 +416,7 @@ out: * offset. */ guint -gst_buffer_store_get_size (GstBufferStore *store, guint64 offset) +gst_buffer_store_get_size (GstBufferStore * store, guint64 offset) { GList *walk; gboolean have_offset; @@ -408,8 +436,9 @@ gst_buffer_store_get_size (GstBufferStore *store, guint64 offset) have_offset = FALSE; } while (walk) { - if (have_offset && counting && - cur_offset + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data)) { + if (have_offset && counting && + cur_offset + GST_BUFFER_SIZE (current) != + GST_BUFFER_OFFSET (walk->data)) { break; } current = GST_BUFFER (walk->data); @@ -432,6 +461,6 @@ gst_buffer_store_get_size (GstBufferStore *store, guint64 offset) cur_offset += GST_BUFFER_SIZE (current); } } - + return ret; } diff --git a/gst/elements/gstbufferstore.h b/gst/elements/gstbufferstore.h index 15fff8e6a..09dc4c59f 100644 --- a/gst/elements/gstbufferstore.h +++ b/gst/elements/gstbufferstore.h @@ -28,46 +28,42 @@ #include G_BEGIN_DECLS - #define GST_TYPE_BUFFER_STORE (gst_buffer_store_get_type ()) #define GST_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_STORE, GstBufferStore)) #define GST_IS_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_STORE)) #define GST_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_STORE, GstBufferStoreClass)) #define GST_IS_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_STORE)) #define GST_BUFFER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_STORE, GstBufferStoreClass)) +typedef struct _GstBufferStore GstBufferStore; +typedef struct _GstBufferStoreClass GstBufferStoreClass; -typedef struct _GstBufferStore GstBufferStore; -typedef struct _GstBufferStoreClass GstBufferStoreClass; - -struct _GstBufferStore { - GObject object; +struct _GstBufferStore +{ + GObject object; - GList * buffers; + GList *buffers; }; -struct _GstBufferStoreClass { - GObjectClass parent_class; +struct _GstBufferStoreClass +{ + GObjectClass parent_class; /* signals */ - void (* cleared) (GstBufferStore * store); - gboolean (* buffer_added) (GstBufferStore * store, - GstBuffer * buffer); + void (*cleared) (GstBufferStore * store); + gboolean (*buffer_added) (GstBufferStore * store, GstBuffer * buffer); }; -GType gst_buffer_store_get_type (void); +GType gst_buffer_store_get_type (void); -GstBufferStore * gst_buffer_store_new (void); -void gst_buffer_store_clear (GstBufferStore * store); +GstBufferStore *gst_buffer_store_new (void); +void gst_buffer_store_clear (GstBufferStore * store); -gboolean gst_buffer_store_add_buffer (GstBufferStore * store, - GstBuffer * buffer); +gboolean gst_buffer_store_add_buffer (GstBufferStore * store, + GstBuffer * buffer); -GstBuffer * gst_buffer_store_get_buffer (GstBufferStore * store, - guint64 offset, - guint size); -guint gst_buffer_store_get_size (GstBufferStore * store, - guint64 offset); +GstBuffer *gst_buffer_store_get_buffer (GstBufferStore * store, + guint64 offset, guint size); +guint gst_buffer_store_get_size (GstBufferStore * store, guint64 offset); G_END_DECLS - #endif /* __GST_BUFFER_STORE_H__ */ diff --git a/gst/elements/gstelements.c b/gst/elements/gstelements.c index 42e068589..12e19d4c7 100644 --- a/gst/elements/gstelements.c +++ b/gst/elements/gstelements.c @@ -44,42 +44,44 @@ #include "gsttypefind.h" -struct _elements_entry { +struct _elements_entry +{ gchar *name; guint rank; - GType (*type) (void); + GType (*type) (void); }; -extern GType gst_filesrc_get_type(void); +extern GType gst_filesrc_get_type (void); extern GstElementDetails gst_filesrc_details; static struct _elements_entry _elements[] = { - { "aggregator", GST_RANK_NONE, gst_aggregator_get_type }, - { "fakesrc", GST_RANK_NONE, gst_fakesrc_get_type }, - { "fakesink", GST_RANK_NONE, gst_fakesink_get_type }, - { "fdsink", GST_RANK_NONE, gst_fdsink_get_type }, - { "fdsrc", GST_RANK_NONE, gst_fdsrc_get_type }, - { "filesrc", GST_RANK_NONE, gst_filesrc_get_type }, - { "filesink", GST_RANK_NONE, gst_filesink_get_type }, - { "identity", GST_RANK_NONE, gst_identity_get_type }, - { "md5sink", GST_RANK_NONE, gst_md5sink_get_type }, - { "multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type }, - { "pipefilter", GST_RANK_NONE, gst_pipefilter_get_type }, - { "shaper", GST_RANK_NONE, gst_shaper_get_type }, - { "statistics", GST_RANK_NONE, gst_statistics_get_type }, - { "tee", GST_RANK_NONE, gst_tee_get_type }, - { "typefind", GST_RANK_NONE, gst_type_find_element_get_type }, - { NULL, 0 }, + {"aggregator", GST_RANK_NONE, gst_aggregator_get_type}, + {"fakesrc", GST_RANK_NONE, gst_fakesrc_get_type}, + {"fakesink", GST_RANK_NONE, gst_fakesink_get_type}, + {"fdsink", GST_RANK_NONE, gst_fdsink_get_type}, + {"fdsrc", GST_RANK_NONE, gst_fdsrc_get_type}, + {"filesrc", GST_RANK_NONE, gst_filesrc_get_type}, + {"filesink", GST_RANK_NONE, gst_filesink_get_type}, + {"identity", GST_RANK_NONE, gst_identity_get_type}, + {"md5sink", GST_RANK_NONE, gst_md5sink_get_type}, + {"multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type}, + {"pipefilter", GST_RANK_NONE, gst_pipefilter_get_type}, + {"shaper", GST_RANK_NONE, gst_shaper_get_type}, + {"statistics", GST_RANK_NONE, gst_statistics_get_type}, + {"tee", GST_RANK_NONE, gst_tee_get_type}, + {"typefind", GST_RANK_NONE, gst_type_find_element_get_type}, + {NULL, 0}, }; static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { struct _elements_entry *my_elements = _elements; - - while ((*my_elements).name) { - if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, ((*my_elements).type) ())) + + while ((*my_elements).name) { + if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, + ((*my_elements).type) ())) return FALSE; my_elements++; } @@ -87,15 +89,8 @@ plugin_init (GstPlugin *plugin) return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstelements", - "standard GStreamer elements", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstelements", + "standard GStreamer elements", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index 4541f6274..78ecac6cf 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -31,22 +31,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_fakesink_debug); #define GST_CAT_DEFAULT gst_fakesink_debug -GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS ( - "Fake Sink", - "Sink", - "Black hole for data", - "Erik Walthinsen " -); +GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS ("Fake Sink", + "Sink", + "Black hole for data", + "Erik Walthinsen "); /* FakeSink signals and args */ -enum { +enum +{ /* FILL ME */ SIGNAL_HANDOFF, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_STATE_ERROR, ARG_NUM_SINKS, @@ -57,12 +57,10 @@ enum { ARG_LAST_MESSAGE, }; -GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_FAKESINK_STATE_ERROR (gst_fakesink_state_error_get_type()) static GType @@ -70,17 +68,24 @@ gst_fakesink_state_error_get_type (void) { static GType fakesink_state_error_type = 0; static GEnumValue fakesink_state_error[] = { - { FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"}, - { FAKESINK_STATE_ERROR_NULL_READY, "1", "Fail state change from NULL to READY"}, - { FAKESINK_STATE_ERROR_READY_PAUSED, "2", "Fail state change from READY to PAUSED"}, - { FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", "Fail state change from PAUSED to PLAYING"}, - { FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", "Fail state change from PLAYING to PAUSED"}, - { FAKESINK_STATE_ERROR_PAUSED_READY , "5", "Fail state change from PAUSED to READY"}, - { FAKESINK_STATE_ERROR_READY_NULL , "6", "Fail state change from READY to NULL"}, + {FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"}, + {FAKESINK_STATE_ERROR_NULL_READY, "1", + "Fail state change from NULL to READY"}, + {FAKESINK_STATE_ERROR_READY_PAUSED, "2", + "Fail state change from READY to PAUSED"}, + {FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", + "Fail state change from PAUSED to PLAYING"}, + {FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", + "Fail state change from PLAYING to PAUSED"}, + {FAKESINK_STATE_ERROR_PAUSED_READY, "5", + "Fail state change from PAUSED to READY"}, + {FAKESINK_STATE_ERROR_READY_NULL, "6", + "Fail state change from READY to NULL"}, {0, NULL, NULL}, }; if (!fakesink_state_error_type) { - fakesink_state_error_type = g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error); + fakesink_state_error_type = + g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error); } return fakesink_state_error_type; } @@ -88,82 +93,86 @@ gst_fakesink_state_error_get_type (void) #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fakesink_debug, "fakesink", 0, "fakesink element"); -GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_fakesink_set_clock (GstElement *element, GstClock *clock); -static GstPad* gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const - gchar *unused); +static void gst_fakesink_set_clock (GstElement * element, GstClock * clock); +static GstPad *gst_fakesink_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * unused); -static void gst_fakesink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fakesink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_fakesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fakesink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstElementStateReturn - gst_fakesink_change_state (GstElement *element); +static GstElementStateReturn gst_fakesink_change_state (GstElement * element); -static void gst_fakesink_chain (GstPad *pad, GstData *_data); +static void gst_fakesink_chain (GstPad * pad, GstData * _data); static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 }; static void gst_fakesink_base_init (gpointer g_class) { - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + gst_element_class_set_details (gstelement_class, &gst_fakesink_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&fakesink_sink_template)); } static void -gst_fakesink_class_init (GstFakeSinkClass *klass) +gst_fakesink_class_init (GstFakeSinkClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS, - g_param_spec_int ("num_sinks", "Number of sinks", "The number of sinkpads", - 1, G_MAXINT, 1, G_PARAM_READABLE)); + g_param_spec_int ("num_sinks", "Number of sinks", + "The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR, - g_param_spec_enum ("state_error", "State Error", "Generate a state change error", - GST_TYPE_FAKESINK_STATE_ERROR, FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE)); + g_param_spec_enum ("state_error", "State Error", + "Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR, + FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last_message", "Last Message", "The message describing current status", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last_message", "Last Message", + "The message describing current status", NULL, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC, - g_param_spec_boolean ("sync", "Sync", "Sync on the clock", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, - g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before unreffing the buffer", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("signal-handoffs", "Signal handoffs", + "Send a signal before unreffing the buffer", FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "Silent", + "Don't produce last_message events", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, - g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout", + FALSE, G_PARAM_READWRITE)); gst_fakesink_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, - gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, - GST_TYPE_BUFFER, GST_TYPE_PAD); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, + gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, + GST_TYPE_BUFFER, GST_TYPE_PAD); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad); - gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesink_change_state); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad); + gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock); + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_fakesink_change_state); } -static void -gst_fakesink_init (GstFakeSink *fakesink) +static void +gst_fakesink_init (GstFakeSink * fakesink) { GstPad *pad; @@ -182,17 +191,18 @@ gst_fakesink_init (GstFakeSink *fakesink) } static void -gst_fakesink_set_clock (GstElement *element, GstClock *clock) -{ +gst_fakesink_set_clock (GstElement * element, GstClock * clock) +{ GstFakeSink *sink; sink = GST_FAKESINK (element); sink->clock = clock; -} +} -static GstPad* -gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_fakesink_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *sinkpad; @@ -212,14 +222,15 @@ gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const sinkpad = gst_pad_new_from_template (templ, name); g_free (name); gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_fakesink_chain)); - + gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad); return sinkpad; } static void -gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_fakesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstFakeSink *sink; @@ -247,16 +258,17 @@ gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, } } -static void -gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fakesink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFakeSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FAKESINK (object)); - + sink = GST_FAKESINK (object); - + switch (prop_id) { case ARG_NUM_SINKS: g_value_set_int (value, GST_ELEMENT (sink)->numsinkpads); @@ -285,8 +297,8 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam } } -static void -gst_fakesink_chain (GstPad *pad, GstData *_data) +static void +gst_fakesink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstFakeSink *fakesink; @@ -299,51 +311,52 @@ gst_fakesink_chain (GstPad *pad, GstData *_data) if (GST_IS_EVENT (buf)) { GstEvent *event = GST_EVENT (buf); - - if (!fakesink->silent) { + + if (!fakesink->silent) { g_free (fakesink->last_message); - fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p", - GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event); - + fakesink->last_message = + g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p", + GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event); + g_object_notify (G_OBJECT (fakesink), "last_message"); } - + switch (GST_EVENT_TYPE (event)) { case GST_EVENT_DISCONTINUOUS: - if (fakesink->sync && fakesink->clock) { - gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value; - gst_element_set_time (GST_ELEMENT (fakesink), value); + if (fakesink->sync && fakesink->clock) { + gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value; + + gst_element_set_time (GST_ELEMENT (fakesink), value); } default: gst_pad_event_default (pad, event); - break; + break; } return; } - if (fakesink->sync && fakesink->clock) { + if (fakesink->sync && fakesink->clock) { gst_element_wait (GST_ELEMENT (fakesink), GST_BUFFER_TIMESTAMP (buf)); } - if (!fakesink->silent) { + if (!fakesink->silent) { g_free (fakesink->last_message); - fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %" - G_GINT64_FORMAT ", duration: %" - G_GINT64_FORMAT ", offset: %" - G_GINT64_FORMAT ", flags: %d) %p", - GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), - GST_BUFFER_TIMESTAMP (buf), - GST_BUFFER_DURATION (buf), - GST_BUFFER_OFFSET (buf), - GST_BUFFER_FLAGS (buf), buf); - + fakesink->last_message = + g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %" + G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %" + G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), + GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf), + GST_BUFFER_FLAGS (buf), buf); + g_object_notify (G_OBJECT (fakesink), "last_message"); } if (fakesink->signal_handoffs) - g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad); + g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, + buf, pad); if (fakesink->dump) { gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); @@ -353,7 +366,7 @@ gst_fakesink_chain (GstPad *pad, GstData *_data) } static GstElementStateReturn -gst_fakesink_change_state (GstElement *element) +gst_fakesink_change_state (GstElement * element) { GstFakeSink *fakesink = GST_FAKESINK (element); @@ -395,4 +408,3 @@ error: GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL)); return GST_STATE_FAILURE; } - diff --git a/gst/elements/gstfakesink.h b/gst/elements/gstfakesink.h index a8e7cd067..2c0e2812d 100644 --- a/gst/elements/gstfakesink.h +++ b/gst/elements/gstfakesink.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FAKESINK \ (gst_fakesink_get_type()) #define GST_FAKESINK(obj) \ @@ -39,8 +37,8 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FAKESINK)) #define GST_IS_FAKESINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK)) - -typedef enum { + typedef enum +{ FAKESINK_STATE_ERROR_NONE = 0, FAKESINK_STATE_ERROR_NULL_READY, FAKESINK_STATE_ERROR_READY_PAUSED, @@ -53,30 +51,31 @@ typedef enum { typedef struct _GstFakeSink GstFakeSink; typedef struct _GstFakeSinkClass GstFakeSinkClass; -struct _GstFakeSink { - GstElement element; +struct _GstFakeSink +{ + GstElement element; - gboolean silent; - gboolean dump; - gboolean sync; - gboolean signal_handoffs; - GstClock *clock; + gboolean silent; + gboolean dump; + gboolean sync; + gboolean signal_handoffs; + GstClock *clock; GstFakeSinkStateError state_error; - gchar *last_message; + gchar *last_message; }; -struct _GstFakeSinkClass { +struct _GstFakeSinkClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); + void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad); }; -GType gst_fakesink_get_type(void); +GType gst_fakesink_get_type (void); -gboolean gst_fakesink_factory_init (GstElementFactory *factory); +gboolean gst_fakesink_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_FAKESINK_H__ */ diff --git a/gst/elements/gstfakesrc.c b/gst/elements/gstfakesrc.c index 1fb082a54..2443b8132 100644 --- a/gst/elements/gstfakesrc.c +++ b/gst/elements/gstfakesrc.c @@ -38,23 +38,23 @@ GST_DEBUG_CATEGORY_STATIC (gst_fakesrc_debug); #define GST_CAT_DEFAULT gst_fakesrc_debug -GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS ( - "Fake Source", - "Source", - "Push empty (no data) buffers around", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS ("Fake Source", + "Source", + "Push empty (no data) buffers around", + "Erik Walthinsen , " + "Wim Taymans "); /* FakeSrc signals and args */ -enum { +enum +{ /* FILL ME */ SIGNAL_HANDOFF, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_NUM_SOURCES, ARG_LOOP_BASED, @@ -74,43 +74,42 @@ enum { ARG_LAST_MESSAGE, }; -GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE ( - "src%d", - GST_PAD_SRC, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type()) static GType -gst_fakesrc_output_get_type (void) +gst_fakesrc_output_get_type (void) { static GType fakesrc_output_type = 0; static GEnumValue fakesrc_output[] = { - { FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"}, - { FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"}, - { FAKESRC_PING_PONG, "3", "Ping-Pong"}, - { FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"}, - { FAKESRC_RANDOM, "5", "Random"}, - { FAKESRC_PATTERN_LOOP, "6", "Patttern loop"}, - { FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"}, - { FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"}, + {FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"}, + {FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"}, + {FAKESRC_PING_PONG, "3", "Ping-Pong"}, + {FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"}, + {FAKESRC_RANDOM, "5", "Random"}, + {FAKESRC_PATTERN_LOOP, "6", "Patttern loop"}, + {FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"}, + {FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"}, {0, NULL, NULL}, }; if (!fakesrc_output_type) { - fakesrc_output_type = g_enum_register_static ("GstFakeSrcOutput", fakesrc_output); + fakesrc_output_type = + g_enum_register_static ("GstFakeSrcOutput", fakesrc_output); } return fakesrc_output_type; } #define GST_TYPE_FAKESRC_DATA (gst_fakesrc_data_get_type()) static GType -gst_fakesrc_data_get_type (void) +gst_fakesrc_data_get_type (void) { static GType fakesrc_data_type = 0; static GEnumValue fakesrc_data[] = { - { FAKESRC_DATA_ALLOCATE, "1", "Allocate data"}, - { FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"}, + {FAKESRC_DATA_ALLOCATE, "1", "Allocate data"}, + {FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"}, {0, NULL, NULL}, }; if (!fakesrc_data_type) { @@ -121,36 +120,40 @@ gst_fakesrc_data_get_type (void) #define GST_TYPE_FAKESRC_SIZETYPE (gst_fakesrc_sizetype_get_type()) static GType -gst_fakesrc_sizetype_get_type (void) +gst_fakesrc_sizetype_get_type (void) { static GType fakesrc_sizetype_type = 0; static GEnumValue fakesrc_sizetype[] = { - { FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"}, - { FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"}, - { FAKESRC_SIZETYPE_RANDOM, "3", "Random sized buffers (sizemin <= size <= sizemax)"}, + {FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"}, + {FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"}, + {FAKESRC_SIZETYPE_RANDOM, "3", + "Random sized buffers (sizemin <= size <= sizemax)"}, {0, NULL, NULL}, }; if (!fakesrc_sizetype_type) { - fakesrc_sizetype_type = g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype); + fakesrc_sizetype_type = + g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype); } return fakesrc_sizetype_type; } #define GST_TYPE_FAKESRC_FILLTYPE (gst_fakesrc_filltype_get_type()) static GType -gst_fakesrc_filltype_get_type (void) +gst_fakesrc_filltype_get_type (void) { static GType fakesrc_filltype_type = 0; static GEnumValue fakesrc_filltype[] = { - { FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"}, - { FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"}, - { FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"}, - { FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"}, - { FAKESRC_FILLTYPE_PATTERN_CONT, "5", "Fill buffers with pattern 0x00 -> 0xff that spans buffers"}, + {FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"}, + {FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"}, + {FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"}, + {FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"}, + {FAKESRC_FILLTYPE_PATTERN_CONT, "5", + "Fill buffers with pattern 0x00 -> 0xff that spans buffers"}, {0, NULL, NULL}, }; if (!fakesrc_filltype_type) { - fakesrc_filltype_type = g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype); + fakesrc_filltype_type = + g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype); } return fakesrc_filltype_type; } @@ -158,106 +161,113 @@ gst_fakesrc_filltype_get_type (void) #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fakesrc_debug, "fakesrc", 0, "fakesrc element"); -GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT, + _do_init); -static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ,const gchar *unused); -static void gst_fakesrc_update_functions (GstFakeSrc *src); -static void gst_fakesrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fakesrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static GstPad *gst_fakesrc_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * unused); +static void gst_fakesrc_update_functions (GstFakeSrc * src); +static void gst_fakesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fakesrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstElementStateReturn gst_fakesrc_change_state (GstElement *element); +static GstElementStateReturn gst_fakesrc_change_state (GstElement * element); -static GstData* gst_fakesrc_get (GstPad *pad); -static void gst_fakesrc_loop (GstElement *element); +static GstData *gst_fakesrc_get (GstPad * pad); +static void gst_fakesrc_loop (GstElement * element); static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; static void gst_fakesrc_base_init (gpointer g_class) { - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + gst_element_class_set_details (gstelement_class, &gst_fakesrc_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&fakesrc_src_template)); } static void -gst_fakesrc_class_init (GstFakeSrcClass *klass) +gst_fakesrc_class_init (GstFakeSrcClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES, - g_param_spec_int ("num-sources", "num-sources", "Number of sources", - 1, G_MAXINT, 1, G_PARAM_READABLE)); + g_param_spec_int ("num-sources", "num-sources", "Number of sources", + 1, G_MAXINT, 1, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, - g_param_spec_boolean ("loop-based", "loop-based", "Enable loop-based operation", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("loop-based", "loop-based", + "Enable loop-based operation", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT, - g_param_spec_enum ("output", "output", "Output method (currently unused)", - GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE)); + g_param_spec_enum ("output", "output", "Output method (currently unused)", + GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA, - g_param_spec_enum ("data", "data", "Data allocation method", - GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE)); + g_param_spec_enum ("data", "data", "Data allocation method", + GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE, - g_param_spec_enum ("sizetype", "sizetype", "How to determine buffer sizes", - GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); + g_param_spec_enum ("sizetype", "sizetype", + "How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE, + FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, - g_param_spec_int ("sizemin","sizemin","Minimum buffer size", - 0, G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE)); + g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0, + G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, - g_param_spec_int ("sizemax","sizemax","Maximum buffer size", - 0, G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE)); + g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0, + G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE, - g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation", - 0, G_MAXINT, DEFAULT_PARENTSIZE, G_PARAM_READWRITE)); + g_param_spec_int ("parentsize", "parentsize", + "Size of parent buffer for sub-buffered allocation", 0, G_MAXINT, + DEFAULT_PARENTSIZE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE, - g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all", - GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); + g_param_spec_enum ("filltype", "filltype", + "How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE, + FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN, - g_param_spec_string ("pattern", "pattern", "pattern", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("pattern", "pattern", "pattern", NULL, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS, - g_param_spec_int ("num-buffers", "num-buffers", "Number of buffers to output before sending EOS", - G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); + g_param_spec_int ("num-buffers", "num-buffers", + "Number of buffers to output before sending EOS", G_MININT, G_MAXINT, + 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS, - g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last-message", "last-message", "The last status message", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last-message", "last-message", + "The last status message", NULL, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "Silent", + "Don't produce last_message events", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, - g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before pushing the buffer", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("signal-handoffs", "Signal handoffs", + "Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, - g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout", + FALSE, G_PARAM_READWRITE)); gst_fakesrc_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL, - gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, - GST_TYPE_BUFFER, GST_TYPE_PAD); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL, + gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, + GST_TYPE_BUFFER, GST_TYPE_PAD); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state); } -static void -gst_fakesrc_init (GstFakeSrc *fakesrc) +static void +gst_fakesrc_init (GstFakeSrc * fakesrc) { GstPad *pad; @@ -289,8 +299,9 @@ gst_fakesrc_init (GstFakeSrc *fakesrc) fakesrc->last_message = NULL; } -static GstPad* -gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_fakesrc_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *srcpad; @@ -317,7 +328,7 @@ gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ, const g } static const GstFormat * -gst_fakesrc_get_formats (GstPad *pad) +gst_fakesrc_get_formats (GstPad * pad) { static const GstFormat formats[] = { GST_FORMAT_DEFAULT, @@ -327,7 +338,7 @@ gst_fakesrc_get_formats (GstPad *pad) } static const GstQueryType * -gst_fakesrc_get_query_types (GstPad *pad) +gst_fakesrc_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -340,8 +351,8 @@ gst_fakesrc_get_query_types (GstPad *pad) } static gboolean -gst_fakesrc_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_fakesrc_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFakeSrc *src = GST_FAKESRC (GST_PAD_PARENT (pad)); @@ -360,24 +371,24 @@ gst_fakesrc_query (GstPad *pad, GstQueryType type, break; default: return FALSE; - } + } return TRUE; } static const GstEventMask * -gst_fakesrc_get_event_mask (GstPad *pad) +gst_fakesrc_get_event_mask (GstPad * pad) { static const GstEventMask masks[] = { - { GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH }, - { GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP }, - { GST_EVENT_FLUSH, 0 }, - { 0, 0 }, + {GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH}, + {GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP}, + {GST_EVENT_FLUSH, 0}, + {0, 0}, }; return masks; } static gboolean -gst_fakesrc_event_handler (GstPad *pad, GstEvent *event) +gst_fakesrc_event_handler (GstPad * pad, GstEvent * event) { GstFakeSrc *src; @@ -388,14 +399,15 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event) src->buffer_count = GST_EVENT_SEEK_OFFSET (event); if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { - break; + break; } /* else we do a flush too */ case GST_EVENT_SEEK_SEGMENT: src->segment_start = GST_EVENT_SEEK_OFFSET (event); src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event); src->buffer_count = src->segment_start; - src->segment_loop = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP; + src->segment_loop = + GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP; break; case GST_EVENT_FLUSH: src->need_flush = TRUE; @@ -409,14 +421,14 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event) } static void -gst_fakesrc_update_functions (GstFakeSrc *src) +gst_fakesrc_update_functions (GstFakeSrc * src) { GList *pads; if (src->loop_based) { - gst_element_set_loop_function (GST_ELEMENT (src), GST_DEBUG_FUNCPTR (gst_fakesrc_loop)); - } - else { + gst_element_set_loop_function (GST_ELEMENT (src), + GST_DEBUG_FUNCPTR (gst_fakesrc_loop)); + } else { gst_element_set_loop_function (GST_ELEMENT (src), NULL); } @@ -426,8 +438,7 @@ gst_fakesrc_update_functions (GstFakeSrc *src) if (src->loop_based) { gst_pad_set_get_function (pad, NULL); - } - else { + } else { gst_pad_set_get_function (pad, GST_DEBUG_FUNCPTR (gst_fakesrc_get)); } @@ -441,7 +452,7 @@ gst_fakesrc_update_functions (GstFakeSrc *src) } static void -gst_fakesrc_alloc_parent (GstFakeSrc *src) +gst_fakesrc_alloc_parent (GstFakeSrc * src) { GstBuffer *buf; @@ -454,13 +465,14 @@ gst_fakesrc_alloc_parent (GstFakeSrc *src) } static void -gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_fakesrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFakeSrc *src; /* it's not null if we got it, but it might not be ours */ src = GST_FAKESRC (object); - + switch (prop_id) { case ARG_LOOP_BASED: src->loop_based = g_value_get_boolean (value); @@ -473,13 +485,13 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G src->data = g_value_get_enum (value); if (src->data == FAKESRC_DATA_SUBBUFFER) { - if (!src->parent) - gst_fakesrc_alloc_parent (src); + if (!src->parent) + gst_fakesrc_alloc_parent (src); } else { - if (src->parent) { - gst_buffer_unref (src->parent); - src->parent = NULL; - } + if (src->parent) { + gst_buffer_unref (src->parent); + src->parent = NULL; + } } break; case ARG_SIZETYPE: @@ -504,7 +516,7 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G break; case ARG_EOS: src->eos = g_value_get_boolean (value); - GST_INFO ( "will EOS on next buffer"); + GST_INFO ("will EOS on next buffer"); break; case ARG_SILENT: src->silent = g_value_get_boolean (value); @@ -520,16 +532,17 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G } } -static void -gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fakesrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFakeSrc *src; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FAKESRC (object)); - + src = GST_FAKESRC (object); - + switch (prop_id) { case ARG_NUM_SOURCES: g_value_set_int (value, GST_ELEMENT (src)->numsrcpads); @@ -586,9 +599,9 @@ gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS } static void -gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf) +gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf) { - if (GST_BUFFER_SIZE (buf) == 0) + if (GST_BUFFER_SIZE (buf) == 0) return; switch (src->filltype) { @@ -601,7 +614,7 @@ gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf) guint8 *ptr = GST_BUFFER_DATA (buf); for (i = GST_BUFFER_SIZE (buf); i; i--) { - *ptr++ = (gint8)((255.0)*rand()/(RAND_MAX)); + *ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX)); } break; } @@ -623,29 +636,29 @@ gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf) } } -static GstBuffer* -gst_fakesrc_alloc_buffer (GstFakeSrc *src, guint size) +static GstBuffer * +gst_fakesrc_alloc_buffer (GstFakeSrc * src, guint size) { GstBuffer *buf; buf = gst_buffer_new (); - GST_BUFFER_SIZE(buf) = size; + GST_BUFFER_SIZE (buf) = size; - if (size != 0) { + if (size != 0) { switch (src->filltype) { case FAKESRC_FILLTYPE_NOTHING: - GST_BUFFER_DATA(buf) = g_malloc (size); - break; + GST_BUFFER_DATA (buf) = g_malloc (size); + break; case FAKESRC_FILLTYPE_NULL: - GST_BUFFER_DATA(buf) = g_malloc0 (size); - break; + GST_BUFFER_DATA (buf) = g_malloc0 (size); + break; case FAKESRC_FILLTYPE_RANDOM: case FAKESRC_FILLTYPE_PATTERN: case FAKESRC_FILLTYPE_PATTERN_CONT: default: - GST_BUFFER_DATA(buf) = g_malloc (size); - gst_fakesrc_prepare_buffer (src, buf); - break; + GST_BUFFER_DATA (buf) = g_malloc (size); + gst_fakesrc_prepare_buffer (src, buf); + break; } } @@ -653,7 +666,7 @@ gst_fakesrc_alloc_buffer (GstFakeSrc *src, guint size) } static guint -gst_fakesrc_get_size (GstFakeSrc *src) +gst_fakesrc_get_size (GstFakeSrc * src) { guint size; @@ -662,11 +675,14 @@ gst_fakesrc_get_size (GstFakeSrc *src) size = src->sizemax; break; case FAKESRC_SIZETYPE_RANDOM: - size = src->sizemin + (guint8)(((gfloat)src->sizemax)*rand()/(RAND_MAX + (gfloat)src->sizemin)); + size = + src->sizemin + + (guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX + + (gfloat) src->sizemin)); break; case FAKESRC_SIZETYPE_NULL: default: - size = 0; + size = 0; break; } @@ -674,7 +690,7 @@ gst_fakesrc_get_size (GstFakeSrc *src) } static GstBuffer * -gst_fakesrc_create_buffer (GstFakeSrc *src) +gst_fakesrc_create_buffer (GstFakeSrc * src) { GstBuffer *buf; guint size; @@ -682,7 +698,7 @@ gst_fakesrc_create_buffer (GstFakeSrc *src) size = gst_fakesrc_get_size (src); if (size == 0) - return gst_buffer_new(); + return gst_buffer_new (); switch (src->data) { case FAKESRC_DATA_ALLOCATE: @@ -696,21 +712,20 @@ gst_fakesrc_create_buffer (GstFakeSrc *src) } /* see if it's large enough */ if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) { - buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); - src->parentoffset += size; - } - else { + buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); + src->parentoffset += size; + } else { /* the parent is useless now */ gst_buffer_unref (src->parent); src->parent = NULL; /* try again (this will allocate a new parent) */ - return gst_fakesrc_create_buffer (src); + return gst_fakesrc_create_buffer (src); } gst_fakesrc_prepare_buffer (src, buf); break; default: g_warning ("fakesrc: dunno how to allocate buffers !"); - buf = gst_buffer_new(); + buf = gst_buffer_new (); break; } if (dump) { @@ -721,7 +736,7 @@ gst_fakesrc_create_buffer (GstFakeSrc *src) } static GstData * -gst_fakesrc_get(GstPad *pad) +gst_fakesrc_get (GstPad * pad) { GstFakeSrc *src; GstBuffer *buf; @@ -734,31 +749,29 @@ gst_fakesrc_get(GstPad *pad) if (src->need_flush) { src->need_flush = FALSE; - return GST_DATA(gst_event_new (GST_EVENT_FLUSH)); + return GST_DATA (gst_event_new (GST_EVENT_FLUSH)); } if (src->buffer_count == src->segment_end) { if (src->segment_loop) { - return GST_DATA(gst_event_new (GST_EVENT_SEGMENT_DONE)); - } - else { + return GST_DATA (gst_event_new (GST_EVENT_SEGMENT_DONE)); + } else { gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); + return GST_DATA (gst_event_new (GST_EVENT_EOS)); } } if (src->rt_num_buffers == 0) { gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); - } - else { + return GST_DATA (gst_event_new (GST_EVENT_EOS)); + } else { if (src->rt_num_buffers > 0) src->rt_num_buffers--; } if (src->eos) { - GST_INFO ( "fakesrc is setting eos on pad"); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); + GST_INFO ("fakesrc is setting eos on pad"); + return GST_DATA (gst_event_new (GST_EVENT_EOS)); } buf = gst_fakesrc_create_buffer (src); @@ -767,9 +780,10 @@ gst_fakesrc_get(GstPad *pad) if (!src->silent) { g_free (src->last_message); - src->last_message = g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %" - G_GUINT64_FORMAT " ) %p", - GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); + src->last_message = + g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %" + G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); g_object_notify (G_OBJECT (src), "last_message"); } @@ -777,7 +791,7 @@ gst_fakesrc_get(GstPad *pad) if (src->signal_handoffs) { GST_LOG_OBJECT (src, "pre handoff emit"); g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0, - buf, pad); + buf, pad); GST_LOG_OBJECT (src, "post handoff emit"); } @@ -791,13 +805,13 @@ gst_fakesrc_get(GstPad *pad) * generate an empty buffer and push it to the next element. */ static void -gst_fakesrc_loop(GstElement *element) +gst_fakesrc_loop (GstElement * element) { GstFakeSrc *src; const GList *pads; - g_return_if_fail(element != NULL); - g_return_if_fail(GST_IS_FAKESRC(element)); + g_return_if_fail (element != NULL); + g_return_if_fail (GST_IS_FAKESRC (element)); src = GST_FAKESRC (element); @@ -819,7 +833,7 @@ gst_fakesrc_loop(GstElement *element) } static GstElementStateReturn -gst_fakesrc_change_state (GstElement *element) +gst_fakesrc_change_state (GstElement * element) { GstFakeSrc *fakesrc; @@ -842,8 +856,8 @@ gst_fakesrc_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_READY: if (fakesrc->parent) { - gst_buffer_unref (fakesrc->parent); - fakesrc->parent = NULL; + gst_buffer_unref (fakesrc->parent); + fakesrc->parent = NULL; } g_free (fakesrc->last_message); fakesrc->last_message = NULL; @@ -860,4 +874,3 @@ gst_fakesrc_change_state (GstElement *element) return GST_STATE_SUCCESS; } - diff --git a/gst/elements/gstfakesrc.h b/gst/elements/gstfakesrc.h index e7880b201..cee8e1a95 100644 --- a/gst/elements/gstfakesrc.h +++ b/gst/elements/gstfakesrc.h @@ -26,10 +26,8 @@ #include -G_BEGIN_DECLS - - -typedef enum { +G_BEGIN_DECLS typedef enum +{ FAKESRC_FIRST_LAST_LOOP = 1, FAKESRC_LAST_FIRST_LOOP, FAKESRC_PING_PONG, @@ -40,18 +38,21 @@ typedef enum { FAKESRC_GET_ALWAYS_SUCEEDS } GstFakeSrcOutputType; -typedef enum { +typedef enum +{ FAKESRC_DATA_ALLOCATE = 1, FAKESRC_DATA_SUBBUFFER, } GstFakeSrcDataType; -typedef enum { +typedef enum +{ FAKESRC_SIZETYPE_NULL = 1, FAKESRC_SIZETYPE_FIXED, FAKESRC_SIZETYPE_RANDOM } GstFakeSrcSizeType; -typedef enum { +typedef enum +{ FAKESRC_FILLTYPE_NOTHING = 1, FAKESRC_FILLTYPE_NULL, FAKESRC_FILLTYPE_RANDOM, @@ -73,50 +74,51 @@ typedef enum { typedef struct _GstFakeSrc GstFakeSrc; typedef struct _GstFakeSrcClass GstFakeSrcClass; -struct _GstFakeSrc { - GstElement element; +struct _GstFakeSrc +{ + GstElement element; - gboolean loop_based; - gboolean eos; + gboolean loop_based; + gboolean eos; GstFakeSrcOutputType output; - GstFakeSrcDataType data; - GstFakeSrcSizeType sizetype; - GstFakeSrcFillType filltype; - - guint sizemin; - guint sizemax; - GstBuffer *parent; - guint parentsize; - guint parentoffset; - guint8 pattern_byte; - gchar *pattern; - GList *patternlist; - gint64 segment_start; - gint64 segment_end; - gboolean segment_loop; - gint num_buffers; - gint rt_num_buffers; /* we are going to change this at runtime */ - guint64 buffer_count; - gboolean silent; - gboolean signal_handoffs; - gboolean dump; - gboolean need_flush; - - gchar *last_message; + GstFakeSrcDataType data; + GstFakeSrcSizeType sizetype; + GstFakeSrcFillType filltype; + + guint sizemin; + guint sizemax; + GstBuffer *parent; + guint parentsize; + guint parentoffset; + guint8 pattern_byte; + gchar *pattern; + GList *patternlist; + gint64 segment_start; + gint64 segment_end; + gboolean segment_loop; + gint num_buffers; + gint rt_num_buffers; /* we are going to change this at runtime */ + guint64 buffer_count; + gboolean silent; + gboolean signal_handoffs; + gboolean dump; + gboolean need_flush; + + gchar *last_message; }; -struct _GstFakeSrcClass { +struct _GstFakeSrcClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); + void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad); }; -GType gst_fakesrc_get_type(void); +GType gst_fakesrc_get_type (void); -gboolean gst_fakesrc_factory_init (GstElementFactory *factory); +gboolean gst_fakesrc_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_FAKESRC_H__ */ diff --git a/gst/elements/gstfdsink.c b/gst/elements/gstfdsink.c index 70f358669..707b66dca 100644 --- a/gst/elements/gstfdsink.c +++ b/gst/elements/gstfdsink.c @@ -30,21 +30,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_fdsink_debug); #define GST_CAT_DEFAULT gst_fdsink_debug -GstElementDetails gst_fdsink_details = GST_ELEMENT_DETAILS ( - "Filedescriptor Sink", - "Sink/File", - "Write data to a file descriptor", - "Erik Walthinsen " -); +GstElementDetails gst_fdsink_details = +GST_ELEMENT_DETAILS ("Filedescriptor Sink", + "Sink/File", + "Write data to a file descriptor", + "Erik Walthinsen "); /* FdSink signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_FD }; @@ -53,25 +54,26 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fdsink_debug, "fdsink", 0, "fdsink element"); -GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_fdsink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fdsink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_fdsink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fdsink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_fdsink_chain (GstPad *pad,GstData *_data); +static void gst_fdsink_chain (GstPad * pad, GstData * _data); static void gst_fdsink_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_fdsink_details); } static void -gst_fdsink_class_init (GstFdSinkClass *klass) +gst_fdsink_class_init (GstFdSinkClass * klass) { GObjectClass *gobject_class; @@ -79,15 +81,15 @@ gst_fdsink_class_init (GstFdSinkClass *klass) g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, - g_param_spec_int ("fd", "fd", "An open file descriptor to write to", - 0, G_MAXINT, 1, G_PARAM_READWRITE)); + g_param_spec_int ("fd", "fd", "An open file descriptor to write to", + 0, G_MAXINT, 1, G_PARAM_READWRITE)); gobject_class->set_property = gst_fdsink_set_property; gobject_class->get_property = gst_fdsink_get_property; } -static void -gst_fdsink_init (GstFdSink *fdsink) +static void +gst_fdsink_init (GstFdSink * fdsink) { fdsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (fdsink), fdsink->sinkpad); @@ -96,8 +98,8 @@ gst_fdsink_init (GstFdSink *fdsink) fdsink->fd = 1; } -static void -gst_fdsink_chain (GstPad *pad, GstData *_data) +static void +gst_fdsink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstFdSink *fdsink; @@ -107,25 +109,27 @@ gst_fdsink_chain (GstPad *pad, GstData *_data) g_return_if_fail (buf != NULL); fdsink = GST_FDSINK (gst_pad_get_parent (pad)); - + g_return_if_fail (fdsink->fd >= 0); - + if (GST_BUFFER_DATA (buf)) { - GST_DEBUG ("writing %d bytes to file descriptor %d",GST_BUFFER_SIZE (buf), fdsink->fd); + GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf), + fdsink->fd); write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); } - + gst_buffer_unref (buf); } -static void -gst_fdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_fdsink_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFdSink *fdsink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSINK (object)); - + fdsink = GST_FDSINK (object); switch (prop_id) { @@ -137,14 +141,15 @@ gst_fdsink_set_property (GObject *object, guint prop_id, const GValue *value, GP } } -static void -gst_fdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fdsink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFdSink *fdsink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSINK (object)); - + fdsink = GST_FDSINK (object); switch (prop_id) { diff --git a/gst/elements/gstfdsink.h b/gst/elements/gstfdsink.h index 838705a72..9a495d3c3 100644 --- a/gst/elements/gstfdsink.h +++ b/gst/elements/gstfdsink.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FDSINK \ (gst_fdsink_get_type()) #define GST_FDSINK(obj) \ @@ -39,11 +37,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSINK)) #define GST_IS_FDSINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK)) - typedef struct _GstFdSink GstFdSink; typedef struct _GstFdSinkClass GstFdSinkClass; -struct _GstFdSink { +struct _GstFdSink +{ GstElement element; GstPad *sinkpad; @@ -51,12 +49,12 @@ struct _GstFdSink { int fd; }; -struct _GstFdSinkClass { +struct _GstFdSinkClass +{ GstElementClass parent_class; }; -GType gst_fdsink_get_type(void); +GType gst_fdsink_get_type (void); G_END_DECLS - #endif /* __GST_FDSINK_H__ */ diff --git a/gst/elements/gstfdsrc.c b/gst/elements/gstfdsrc.c index e7337705e..18984cf69 100644 --- a/gst/elements/gstfdsrc.c +++ b/gst/elements/gstfdsrc.c @@ -39,21 +39,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_fdsrc_debug); #define GST_CAT_DEFAULT gst_fdsrc_debug -GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ( - "Disk Source", - "Source/File", - "Synchronous read from a file", - "Erik Walthinsen " -); +GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ("Disk Source", + "Source/File", + "Synchronous read from a file", + "Erik Walthinsen "); /* FdSrc signals and args */ -enum { +enum +{ SIGNAL_TIMEOUT, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_FD, ARG_BLOCKSIZE, @@ -65,52 +65,56 @@ static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 }; #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element"); -GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_fdsrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fdsrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_fdsrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fdsrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstData * gst_fdsrc_get (GstPad *pad); +static GstData *gst_fdsrc_get (GstPad * pad); static void gst_fdsrc_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_fdsrc_details); } static void -gst_fdsrc_class_init (GstFdSrcClass *klass) +gst_fdsrc_class_init (GstFdSrcClass * klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, - g_param_spec_int ("fd", "fd", "An open file descriptor to read from", - 0, G_MAXINT, 0, G_PARAM_READWRITE)); + g_param_spec_int ("fd", "fd", "An open file descriptor to read from", + 0, G_MAXINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, - g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer", - 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE)); + g_param_spec_ulong ("blocksize", "Block size", + "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT, - g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds", - 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); + g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds", + 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); gst_fdsrc_signals[SIGNAL_TIMEOUT] = - g_signal_new ("timeout", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gobject_class->set_property = gst_fdsrc_set_property; gobject_class->get_property = gst_fdsrc_get_property; } -static void gst_fdsrc_init(GstFdSrc *fdsrc) { +static void +gst_fdsrc_init (GstFdSrc * fdsrc) +{ fdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - + gst_pad_set_get_function (fdsrc->srcpad, gst_fdsrc_get); gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad); @@ -122,14 +126,15 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) { } -static void -gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFdSrc *src; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSRC (object)); - + src = GST_FDSRC (object); switch (prop_id) { @@ -147,14 +152,15 @@ gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa } } -static void -gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fdsrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFdSrc *src; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSRC (object)); - + src = GST_FDSRC (object); switch (prop_id) { @@ -174,7 +180,7 @@ gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe } static GstData * -gst_fdsrc_get(GstPad *pad) +gst_fdsrc_get (GstPad * pad) { GstFdSrc *src; GstBuffer *buf; @@ -191,38 +197,31 @@ gst_fdsrc_get(GstPad *pad) FD_ZERO (&readfds); FD_SET (src->fd, &readfds); - if (src->timeout != 0) - { + if (src->timeout != 0) { GST_TIME_TO_TIMEVAL (src->timeout, t); - } - else + } else tp = NULL; - do - { + do { retval = select (1, &readfds, NULL, NULL, tp); - } while (retval == -1 && errno == EINTR); /* retry if interrupted */ + } while (retval == -1 && errno == EINTR); /* retry if interrupted */ - if (retval == -1) - { - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("select on file descriptor: %s.", g_strerror(errno))); + if (retval == -1) { + GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), + ("select on file descriptor: %s.", g_strerror (errno))); gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); - } - else if (retval == 0) - { + } else if (retval == 0) { g_signal_emit (G_OBJECT (src), gst_fdsrc_signals[SIGNAL_TIMEOUT], 0); gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); + return GST_DATA (gst_event_new (GST_EVENT_EOS)); } - do - { + do { readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize); - } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ + } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ - if (readbytes > 0) - { + if (readbytes > 0) { GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_SIZE (buf) = readbytes; GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE; @@ -230,15 +229,12 @@ gst_fdsrc_get(GstPad *pad) /* we're done, return the buffer */ return GST_DATA (buf); - } - else if (readbytes == 0) - { + } else if (readbytes == 0) { gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); - } - else - { - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("read on file descriptor: %s.", g_strerror(errno))); + } else { + GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), + ("read on file descriptor: %s.", g_strerror (errno))); gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); } diff --git a/gst/elements/gstfdsrc.h b/gst/elements/gstfdsrc.h index 3bb9e7812..f300352cd 100644 --- a/gst/elements/gstfdsrc.h +++ b/gst/elements/gstfdsrc.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FDSRC \ (gst_fdsrc_get_type()) #define GST_FDSRC(obj) \ @@ -39,12 +37,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSRC)) #define GST_IS_FDSRC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC)) - - typedef struct _GstFdSrc GstFdSrc; typedef struct _GstFdSrcClass GstFdSrcClass; -struct _GstFdSrc { +struct _GstFdSrc +{ GstElement element; /* pads */ GstPad *srcpad; @@ -52,22 +49,22 @@ struct _GstFdSrc { /* fd */ gint fd; - gulong curoffset; /* current offset in file */ - gulong blocksize; /* bytes per read */ - guint64 timeout; /* read timeout, in nanoseconds */ - - gulong seq; /* buffer sequence number */ + gulong curoffset; /* current offset in file */ + gulong blocksize; /* bytes per read */ + guint64 timeout; /* read timeout, in nanoseconds */ + + gulong seq; /* buffer sequence number */ }; -struct _GstFdSrcClass { +struct _GstFdSrcClass +{ GstElementClass parent_class; /* signals */ - void (*timeout) (GstElement *element); + void (*timeout) (GstElement * element); }; -GType gst_fdsrc_get_type(void); +GType gst_fdsrc_get_type (void); G_END_DECLS - #endif /* __GST_FDSRC_H__ */ diff --git a/gst/elements/gstfilesink.c b/gst/elements/gstfilesink.c index fb575cdc6..e52eb80fe 100644 --- a/gst/elements/gstfilesink.c +++ b/gst/elements/gstfilesink.c @@ -39,28 +39,28 @@ GST_DEBUG_CATEGORY_STATIC (gst_filesink_debug); #define GST_CAT_DEFAULT gst_filesink_debug -GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS ( - "File Sink", - "Sink/File", - "Write stream to a file", - "Thomas " -); +GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS ("File Sink", + "Sink/File", + "Write stream to a file", + "Thomas "); /* FileSink signals and args */ -enum { +enum +{ /* FILL ME */ SIGNAL_HANDOFF, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATION }; static const GstFormat * -gst_filesink_get_formats (GstPad *pad) +gst_filesink_get_formats (GstPad * pad) { static const GstFormat formats[] = { GST_FORMAT_BYTES, @@ -70,7 +70,7 @@ gst_filesink_get_formats (GstPad *pad) } static const GstQueryType * -gst_filesink_get_query_types (GstPad *pad) +gst_filesink_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -80,24 +80,25 @@ gst_filesink_get_query_types (GstPad *pad) return types; } -static void gst_filesink_dispose (GObject *object); +static void gst_filesink_dispose (GObject * object); + +static void gst_filesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_filesink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_filesink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_filesink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static gboolean gst_filesink_open_file (GstFileSink * sink); +static void gst_filesink_close_file (GstFileSink * sink); -static gboolean gst_filesink_open_file (GstFileSink *sink); -static void gst_filesink_close_file (GstFileSink *sink); +static gboolean gst_filesink_handle_event (GstPad * pad, GstEvent * event); +static gboolean gst_filesink_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); +static void gst_filesink_chain (GstPad * pad, GstData * _data); -static gboolean gst_filesink_handle_event (GstPad *pad, GstEvent *event); -static gboolean gst_filesink_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); -static void gst_filesink_chain (GstPad *pad,GstData *_data); +static void gst_filesink_uri_handler_init (gpointer g_iface, + gpointer iface_data); -static void gst_filesink_uri_handler_init (gpointer g_iface, gpointer iface_data); - -static GstElementStateReturn gst_filesink_change_state (GstElement *element); +static GstElementStateReturn gst_filesink_change_state (GstElement * element); static guint gst_filesink_signals[LAST_SIGNAL] = { 0 }; @@ -109,12 +110,15 @@ _do_init (GType filesink_type) NULL, NULL }; - g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, &urihandler_info); - GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, "filesink element"); + g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, + &urihandler_info); + GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, + "filesink element"); } -GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT, _do_init); - +GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT, + _do_init); + static void gst_filesink_base_init (gpointer g_class) @@ -125,26 +129,26 @@ gst_filesink_base_init (gpointer g_class) gst_element_class_set_details (gstelement_class, &gst_filesink_details); } static void -gst_filesink_class_init (GstFileSinkClass *klass) +gst_filesink_class_init (GstFileSinkClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, - g_param_spec_string ("location", "File Location", "Location of the file to write", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("location", "File Location", + "Location of the file to write", NULL, G_PARAM_READWRITE)); gst_filesink_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gobject_class->set_property = gst_filesink_set_property; gobject_class->get_property = gst_filesink_get_property; - gobject_class->dispose = gst_filesink_dispose; + gobject_class->dispose = gst_filesink_dispose; } -static void -gst_filesink_init (GstFileSink *filesink) +static void +gst_filesink_init (GstFileSink * filesink) { GstPad *pad; @@ -152,7 +156,7 @@ gst_filesink_init (GstFileSink *filesink) gst_element_add_pad (GST_ELEMENT (filesink), pad); gst_pad_set_chain_function (pad, gst_filesink_chain); - GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE); + GST_FLAG_SET (GST_ELEMENT (filesink), GST_ELEMENT_EVENT_AWARE); gst_pad_set_query_function (pad, gst_filesink_pad_query); gst_pad_set_query_type_function (pad, gst_filesink_get_query_types); @@ -162,19 +166,20 @@ gst_filesink_init (GstFileSink *filesink) filesink->file = NULL; } static void -gst_filesink_dispose (GObject *object) +gst_filesink_dispose (GObject * object) { GstFileSink *sink = GST_FILESINK (object); G_OBJECT_CLASS (parent_class)->dispose (object); - + g_free (sink->uri); sink->uri = NULL; g_free (sink->filename); sink->filename = NULL; } + static gboolean -gst_filesink_set_location (GstFileSink *sink, const gchar *location) +gst_filesink_set_location (GstFileSink * sink, const gchar * location) { /* the element must be stopped or paused in order to do this */ if (GST_STATE (sink) > GST_STATE_PAUSED) @@ -192,14 +197,15 @@ gst_filesink_set_location (GstFileSink *sink, const gchar *location) sink->filename = NULL; sink->uri = NULL; } - + if (GST_STATE (sink) == GST_STATE_PAUSED) gst_filesink_open_file (sink); return TRUE; } static void -gst_filesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_filesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstFileSink *sink; @@ -216,16 +222,17 @@ gst_filesink_set_property (GObject *object, guint prop_id, const GValue *value, } } -static void -gst_filesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_filesink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFileSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FILESINK (object)); - + sink = GST_FILESINK (object); - + switch (prop_id) { case ARG_LOCATION: g_value_set_string (value, sink->filename); @@ -237,23 +244,22 @@ gst_filesink_get_property (GObject *object, guint prop_id, GValue *value, GParam } static gboolean -gst_filesink_open_file (GstFileSink *sink) +gst_filesink_open_file (GstFileSink * sink) { g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN), FALSE); /* open the file */ - if (sink->filename == NULL || sink->filename[0] == '\0') - { + if (sink->filename == NULL || sink->filename[0] == '\0') { GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, - (_("No file name specified for writing.")), (NULL)); + (_("No file name specified for writing.")), (NULL)); return FALSE; } sink->file = fopen (sink->filename, "w"); if (sink->file == NULL) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (_("Could not open file \"%s\" for writing."), sink->filename), - GST_ERROR_SYSTEM); + (_("Could not open file \"%s\" for writing."), sink->filename), + GST_ERROR_SYSTEM); return FALSE; } @@ -265,24 +271,21 @@ gst_filesink_open_file (GstFileSink *sink) } static void -gst_filesink_close_file (GstFileSink *sink) +gst_filesink_close_file (GstFileSink * sink) { g_return_if_fail (GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN)); - if (fclose (sink->file) != 0) - { + if (fclose (sink->file) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Error closing file \"%s\"."), sink->filename), - GST_ERROR_SYSTEM); - } - else { + (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM); + } else { GST_FLAG_UNSET (sink, GST_FILESINK_OPEN); } } static gboolean -gst_filesink_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_filesink_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFileSink *sink = GST_FILESINK (GST_PAD_PARENT (pad)); @@ -290,23 +293,23 @@ gst_filesink_pad_query (GstPad *pad, GstQueryType type, case GST_QUERY_TOTAL: switch (*format) { case GST_FORMAT_BYTES: - if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) { - *value = sink->data_written; /* FIXME - doesn't the kernel provide - such a function? */ - break; - } - default: + if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { + *value = sink->data_written; /* FIXME - doesn't the kernel provide + such a function? */ + break; + } + default: return FALSE; } break; case GST_QUERY_POSITION: switch (*format) { case GST_FORMAT_BYTES: - if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) { - *value = ftell (sink->file); - break; - } - default: + if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { + *value = ftell (sink->file); + break; + } + default: return FALSE; } break; @@ -319,60 +322,58 @@ gst_filesink_pad_query (GstPad *pad, GstQueryType type, /* handle events (search) */ static gboolean -gst_filesink_handle_event (GstPad *pad, GstEvent *event) +gst_filesink_handle_event (GstPad * pad, GstEvent * event) { GstEventType type; GstFileSink *filesink; filesink = GST_FILESINK (gst_pad_get_parent (pad)); - g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN), - FALSE); + g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN), FALSE); type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN; switch (type) { case GST_EVENT_SEEK: g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES, - FALSE); + FALSE); if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) - if (fflush (filesink->file)) - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - GST_ERROR_SYSTEM); - - switch (GST_EVENT_SEEK_METHOD(event)) - { - case GST_SEEK_METHOD_SET: - fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET); - break; - case GST_SEEK_METHOD_CUR: - fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR); - break; - case GST_SEEK_METHOD_END: - fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END); - break; - default: - g_warning ("unknown seek method!"); - break; + if (fflush (filesink->file)) + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + GST_ERROR_SYSTEM); + + switch (GST_EVENT_SEEK_METHOD (event)) { + case GST_SEEK_METHOD_SET: + fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET); + break; + case GST_SEEK_METHOD_CUR: + fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR); + break; + case GST_SEEK_METHOD_END: + fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END); + break; + default: + g_warning ("unknown seek method!"); + break; } break; case GST_EVENT_DISCONTINUOUS: { gint64 offset; - + if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset)) - fseek (filesink->file, offset, SEEK_SET); + fseek (filesink->file, offset, SEEK_SET); gst_event_unref (event); break; } case GST_EVENT_FLUSH: if (fflush (filesink->file)) { - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - GST_ERROR_SYSTEM); + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + GST_ERROR_SYSTEM); } break; case GST_EVENT_EOS: @@ -394,8 +395,8 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *event) * * take the buffer from the pad and write to file if it's open */ -static void -gst_filesink_chain (GstPad *pad, GstData *_data) +static void +gst_filesink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstFileSink *filesink; @@ -406,27 +407,26 @@ gst_filesink_chain (GstPad *pad, GstData *_data) filesink = GST_FILESINK (gst_pad_get_parent (pad)); - if (GST_IS_EVENT(buf)) - { - gst_filesink_handle_event(pad, GST_EVENT(buf)); + if (GST_IS_EVENT (buf)) { + gst_filesink_handle_event (pad, GST_EVENT (buf)); return; } - if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) - { + if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) { guint bytes_written = 0, back_pending = 0; - if (ftell(filesink->file) < filesink->data_written) - back_pending = filesink->data_written - ftell(filesink->file); + + if (ftell (filesink->file) < filesink->data_written) + back_pending = filesink->data_written - ftell (filesink->file); while (bytes_written < GST_BUFFER_SIZE (buf)) { size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, - GST_BUFFER_SIZE (buf) - bytes_written, - filesink->file); + GST_BUFFER_SIZE (buf) - bytes_written, + filesink->file); + if (wrote <= 0) { - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - ("Only %d of %d bytes written: %s", - bytes_written, GST_BUFFER_SIZE (buf), - strerror (errno))); + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + ("Only %d of %d bytes written: %s", + bytes_written, GST_BUFFER_SIZE (buf), strerror (errno))); break; } bytes_written += wrote; @@ -438,25 +438,24 @@ gst_filesink_chain (GstPad *pad, GstData *_data) gst_buffer_unref (buf); g_signal_emit (G_OBJECT (filesink), - gst_filesink_signals[SIGNAL_HANDOFF], 0, - filesink); + gst_filesink_signals[SIGNAL_HANDOFF], 0, filesink); } static GstElementStateReturn -gst_filesink_change_state (GstElement *element) +gst_filesink_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_FILESINK (element), GST_STATE_FAILURE); switch (GST_STATE_TRANSITION (element)) { case GST_STATE_PAUSED_TO_READY: if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) - gst_filesink_close_file (GST_FILESINK (element)); + gst_filesink_close_file (GST_FILESINK (element)); break; case GST_STATE_READY_TO_PAUSED: if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) { - if (!gst_filesink_open_file (GST_FILESINK (element))) - return GST_STATE_FAILURE; + if (!gst_filesink_open_file (GST_FILESINK (element))) + return GST_STATE_FAILURE; } break; } @@ -475,20 +474,21 @@ gst_filesink_uri_get_type (void) return GST_URI_SINK; } static gchar ** -gst_filesink_uri_get_protocols(void) +gst_filesink_uri_get_protocols (void) { - static gchar *protocols[] = {"file", NULL}; + static gchar *protocols[] = { "file", NULL }; return protocols; } static const gchar * -gst_filesink_uri_get_uri (GstURIHandler *handler) +gst_filesink_uri_get_uri (GstURIHandler * handler) { GstFileSink *sink = GST_FILESINK (handler); - + return sink->uri; } + static gboolean -gst_filesink_uri_set_uri (GstURIHandler *handler, const gchar *uri) +gst_filesink_uri_set_uri (GstURIHandler * handler, const gchar * uri) { gchar *protocol, *location; gboolean ret; diff --git a/gst/elements/gstfilesink.h b/gst/elements/gstfilesink.h index bd85a1d01..5a06f3e06 100644 --- a/gst/elements/gstfilesink.h +++ b/gst/elements/gstfilesink.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FILESINK \ (gst_filesink_get_type()) #define GST_FILESINK(obj) \ @@ -39,17 +37,18 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESINK)) #define GST_IS_FILESINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESINK)) - typedef struct _GstFileSink GstFileSink; typedef struct _GstFileSinkClass GstFileSinkClass; -typedef enum { - GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST, +typedef enum +{ + GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST, - GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 + GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstFileSinkFlags; -struct _GstFileSink { +struct _GstFileSink +{ GstElement element; gchar *filename; @@ -59,15 +58,15 @@ struct _GstFileSink { guint64 data_written; }; -struct _GstFileSinkClass { +struct _GstFileSinkClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstPad *pad); + void (*handoff) (GstElement * element, GstPad * pad); }; -GType gst_filesink_get_type(void); +GType gst_filesink_get_type (void); G_END_DECLS - #endif /* __GST_FILESINK_H__ */ diff --git a/gst/elements/gstfilesrc.c b/gst/elements/gstfilesrc.c index 7882e9866..1f7ae1ed8 100644 --- a/gst/elements/gstfilesrc.c +++ b/gst/elements/gstfilesrc.c @@ -77,23 +77,23 @@ GST_DEBUG_CATEGORY_STATIC (gst_filesrc_debug); #define GST_CAT_DEFAULT gst_filesrc_debug -GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS ( - "File Source", - "Source/File", - "Read from arbitrary point in a file", - "Erik Walthinsen " -); +GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS ("File Source", + "Source/File", + "Read from arbitrary point in a file", + "Erik Walthinsen "); #define DEFAULT_BLOCKSIZE 4*1024 #define DEFAULT_MMAPSIZE 4*1024*1024 /* FileSrc signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATION, ARG_FD, @@ -103,22 +103,20 @@ enum { }; static const GstEventMask * -gst_filesrc_get_event_mask (GstPad *pad) +gst_filesrc_get_event_mask (GstPad * pad) { static const GstEventMask masks[] = { - { GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | - GST_SEEK_METHOD_SET | - GST_SEEK_METHOD_END | - GST_SEEK_FLAG_FLUSH }, - { GST_EVENT_FLUSH, 0 }, - { GST_EVENT_SIZE, 0 }, - { 0, 0 } + {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | + GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH}, + {GST_EVENT_FLUSH, 0}, + {GST_EVENT_SIZE, 0}, + {0, 0} }; return masks; } static const GstQueryType * -gst_filesrc_get_query_types (GstPad *pad) +gst_filesrc_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -129,7 +127,7 @@ gst_filesrc_get_query_types (GstPad *pad) } static const GstFormat * -gst_filesrc_get_formats (GstPad *pad) +gst_filesrc_get_formats (GstPad * pad) { static const GstFormat formats[] = { GST_FORMAT_BYTES, @@ -138,22 +136,23 @@ gst_filesrc_get_formats (GstPad *pad) return formats; } -static void gst_filesrc_dispose (GObject *object); +static void gst_filesrc_dispose (GObject * object); -static void gst_filesrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_filesrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_filesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_filesrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static gboolean gst_filesrc_check_filesize (GstFileSrc *src); -static GstData * gst_filesrc_get (GstPad *pad); -static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event); -static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); +static gboolean gst_filesrc_check_filesize (GstFileSrc * src); +static GstData *gst_filesrc_get (GstPad * pad); +static gboolean gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event); +static gboolean gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); -static GstElementStateReturn gst_filesrc_change_state (GstElement *element); +static GstElementStateReturn gst_filesrc_change_state (GstElement * element); -static void gst_filesrc_uri_handler_init (gpointer g_iface, gpointer iface_data); +static void gst_filesrc_uri_handler_init (gpointer g_iface, + gpointer iface_data); static void _do_init (GType filesrc_type) @@ -163,12 +162,14 @@ _do_init (GType filesrc_type) NULL, NULL }; - g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, &urihandler_info); + g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, + &urihandler_info); GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element"); } -GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT, _do_init); - +GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT, + _do_init); + static void gst_filesrc_base_init (gpointer g_class) { @@ -177,41 +178,42 @@ gst_filesrc_base_init (gpointer g_class) gst_element_class_set_details (gstelement_class, &gst_filesrc_details); } static void -gst_filesrc_class_init (GstFileSrcClass *klass) +gst_filesrc_class_init (GstFileSrcClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); - gobject_class = (GObjectClass*)klass; + gobject_class = (GObjectClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, - g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d", - 0, G_MAXINT, 0, G_PARAM_READABLE)); + g_param_spec_int ("fd", "File-descriptor", + "File-descriptor for the file being mmap()d", 0, G_MAXINT, 0, + G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, - g_param_spec_string ("location", "File Location", "Location of the file to read", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("location", "File Location", + "Location of the file to read", NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, - g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer", - 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE)); + g_param_spec_ulong ("blocksize", "Block size", + "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE, - g_param_spec_ulong ("mmapsize", "mmap() Block Size", - "Size in bytes of mmap()d regions", - 0, G_MAXULONG, DEFAULT_MMAPSIZE, G_PARAM_READWRITE)); + g_param_spec_ulong ("mmapsize", "mmap() Block Size", + "Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH, - g_param_spec_boolean ("touch", "Touch read data", - "Touch data to force disk read", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("touch", "Touch read data", + "Touch data to force disk read", FALSE, G_PARAM_READWRITE)); - gobject_class->dispose = gst_filesrc_dispose; - gobject_class->set_property = gst_filesrc_set_property; - gobject_class->get_property = gst_filesrc_get_property; + gobject_class->dispose = gst_filesrc_dispose; + gobject_class->set_property = gst_filesrc_set_property; + gobject_class->get_property = gst_filesrc_get_property; gstelement_class->change_state = gst_filesrc_change_state; } static void -gst_filesrc_init (GstFileSrc *src) +gst_filesrc_init (GstFileSrc * src) { src->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_get_function (src->srcpad, gst_filesrc_get); @@ -222,7 +224,7 @@ gst_filesrc_init (GstFileSrc *src) gst_pad_set_formats_function (src->srcpad, gst_filesrc_get_formats); gst_element_add_pad (GST_ELEMENT (src), src->srcpad); - src->pagesize = getpagesize(); + src->pagesize = getpagesize (); src->filename = NULL; src->fd = 0; @@ -233,13 +235,13 @@ gst_filesrc_init (GstFileSrc *src) src->touch = FALSE; src->mapbuf = NULL; - src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */ + src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */ src->seek_happened = FALSE; } static void -gst_filesrc_dispose (GObject *object) +gst_filesrc_dispose (GObject * object) { GstFileSrc *src; @@ -254,15 +256,16 @@ gst_filesrc_dispose (GObject *object) } static gboolean -gst_filesrc_set_location (GstFileSrc *src, const gchar *location) +gst_filesrc_set_location (GstFileSrc * src, const gchar * location) { /* the element must be stopped in order to do this */ - if (GST_STATE (src) != GST_STATE_READY && - GST_STATE (src) != GST_STATE_NULL) + if (GST_STATE (src) != GST_STATE_READY && GST_STATE (src) != GST_STATE_NULL) return FALSE; - if (src->filename) g_free (src->filename); - if (src->uri) g_free (src->uri); + if (src->filename) + g_free (src->filename); + if (src->uri) + g_free (src->uri); /* clear the filename if we get a NULL (is that possible?) */ if (location == NULL) { src->filename = NULL; @@ -278,7 +281,8 @@ gst_filesrc_set_location (GstFileSrc *src, const gchar *location) } static void -gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_filesrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFileSrc *src; @@ -297,11 +301,12 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G break; case ARG_MMAPSIZE: if ((src->mapsize % src->pagesize) == 0) { - src->mapsize = g_value_get_ulong (value); - g_object_notify (G_OBJECT (src), "mmapsize"); + src->mapsize = g_value_get_ulong (value); + g_object_notify (G_OBJECT (src), "mmapsize"); } else { - GST_INFO_OBJECT (src, "invalid mapsize, must be a multiple of pagesize, which is %d", - src->pagesize); + GST_INFO_OBJECT (src, + "invalid mapsize, must be a multiple of pagesize, which is %d", + src->pagesize); } break; case ARG_TOUCH: @@ -314,7 +319,8 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G } static void -gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_filesrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFileSrc *src; @@ -346,9 +352,9 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS } static void -gst_filesrc_free_parent_mmap (GstBuffer *buf) +gst_filesrc_free_parent_mmap (GstBuffer * buf) { - GST_LOG ("freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u", + GST_LOG ("freeing mmap()d buffer at %" G_GUINT64_FORMAT "+%u", GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf)); #ifdef MADV_DONTNEED @@ -359,16 +365,15 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf) munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf)); /* cast to unsigned long, since there's no gportable way to print * guint64 as hex */ - GST_LOG ("unmapped region %08lx+%08lx at %p", + GST_LOG ("unmapped region %08lx+%08lx at %p", (unsigned long) GST_BUFFER_OFFSET (buf), - (unsigned long) GST_BUFFER_MAXSIZE (buf), - GST_BUFFER_DATA (buf)); + (unsigned long) GST_BUFFER_MAXSIZE (buf), GST_BUFFER_DATA (buf)); GST_BUFFER_DATA (buf) = NULL; } static GstBuffer * -gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) +gst_filesrc_map_region (GstFileSrc * src, off_t offset, size_t size) { GstBuffer *buf; gint retval; @@ -376,20 +381,20 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) g_return_val_if_fail (offset >= 0, NULL); - GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",offset,(unsigned long)size); + GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory", + offset, (unsigned long) size); mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset); if (mmapregion == NULL) { GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), ("mmap call failed.")); return NULL; - } - else if (mmapregion == MAP_FAILED) { + } else if (mmapregion == MAP_FAILED) { GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s", - (unsigned long)size, src->fd, offset, strerror (errno)); + (unsigned long) size, src->fd, offset, strerror (errno)); return NULL; } - GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p", - (unsigned long)offset, (unsigned long)size, mmapregion); + GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p", + (unsigned long) offset, (unsigned long) size, mmapregion); /* time to allocate a new mapbuf */ buf = gst_buffer_new (); @@ -398,7 +403,8 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) #ifdef MADV_SEQUENTIAL /* madvise to tell the kernel what to do with it */ - retval = madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL); + retval = + madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL); #endif /* fill in the rest of the fields */ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY); @@ -415,7 +421,7 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) } static GstBuffer * -gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) +gst_filesrc_map_small_region (GstFileSrc * src, off_t offset, size_t size) { size_t mapsize; off_t mod, mapbase; @@ -428,9 +434,10 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) GstBuffer *ret; mapbase = offset - mod; - mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize; + mapsize = + ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize; /* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/ - map = gst_filesrc_map_region(src, mapbase, mapsize); + map = gst_filesrc_map_region (src, mapbase, mapsize); if (map == NULL) return NULL; @@ -442,7 +449,7 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) return ret; } - return gst_filesrc_map_region(src,offset,size); + return gst_filesrc_map_region (src, offset, size); } /** @@ -452,19 +459,19 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) * Push a new buffer from the filesrc at the current offset. */ static GstBuffer * -gst_filesrc_get_mmap (GstFileSrc *src) +gst_filesrc_get_mmap (GstFileSrc * src) { GstBuffer *buf = NULL; size_t readsize, mapsize; - off_t readend,mapstart,mapend; + off_t readend, mapstart, mapend; int i; /* calculate end pointers so we don't have to do so repeatedly later */ readsize = src->block_size; - readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */ + readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */ mapstart = GST_BUFFER_OFFSET (src->mapbuf); mapsize = GST_BUFFER_SIZE (src->mapbuf); - mapend = mapstart + mapsize; /* note this is the byte *after* the map */ + mapend = mapstart + mapsize; /* note this is the byte *after* the map */ /* check to see if we're going to overflow the end of the file */ if (readend > src->filelen) { @@ -474,40 +481,46 @@ gst_filesrc_get_mmap (GstFileSrc *src) } } - GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx", - (unsigned long)readsize, (unsigned long)readend, - (unsigned long)mapstart, (unsigned long)mapend); + GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx", + (unsigned long) readsize, (unsigned long) readend, + (unsigned long) mapstart, (unsigned long) mapend); /* if the start is past the mapstart */ if (src->curoffset >= mapstart) { /* if the end is before the mapend, the buffer is in current mmap region... */ /* ('cause by definition if readend is in the buffer, so's readstart) */ if (readend <= mapend) { - GST_LOG_OBJECT (src, "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf", - src->curoffset, (int)readsize, mapstart, mapsize); - buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, - readsize); + GST_LOG_OBJECT (src, + "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf", + src->curoffset, (int) readsize, mapstart, mapsize); + buf = + gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, + readsize); GST_BUFFER_OFFSET (buf) = src->curoffset; - /* if the start actually is within the current mmap region, map an overlap buffer */ + /* if the start actually is within the current mmap region, map an overlap buffer */ } else if (src->curoffset < mapend) { - GST_LOG_OBJECT (src, "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap", - (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize); + GST_LOG_OBJECT (src, + "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap", + (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, + (gint) mapsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); if (buf == NULL) - return NULL; + return NULL; } /* the only other option is that buffer is totally outside, which means we search for it */ - /* now we can assume that the start is *before* the current mmap region */ - /* if the readend is past mapstart, we have two options */ + /* now we can assume that the start is *before* the current mmap region */ + /* if the readend is past mapstart, we have two options */ } else if (readend >= mapstart) { /* either the read buffer overlaps the start of the mmap region */ /* or the read buffer fully contains the current mmap region */ - /* either way, it's really not relevant, we just create a new region anyway*/ - GST_LOG_OBJECT (src, "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it", - (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize); + /* either way, it's really not relevant, we just create a new region anyway */ + GST_LOG_OBJECT (src, + "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it", + (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, + (gint) mapsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); if (buf == NULL) return NULL; @@ -517,32 +530,35 @@ gst_filesrc_get_mmap (GstFileSrc *src) if (buf == NULL) { /* first check to see if there's a map that covers the right region already */ GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d", - src->curoffset,(int)readsize); - + src->curoffset, (int) readsize); + /* if the read buffer crosses a mmap region boundary, create a one-off region */ if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) { - GST_LOG_OBJECT (src, "read buf %llu+%d crosses a %d-byte boundary, creating a one-off", - src->curoffset,(int)readsize,(int)src->mapsize); + GST_LOG_OBJECT (src, + "read buf %llu+%d crosses a %d-byte boundary, creating a one-off", + src->curoffset, (int) readsize, (int) src->mapsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); if (buf == NULL) return NULL; - /* otherwise we will create a new mmap region and set it to the default */ + /* otherwise we will create a new mmap region and set it to the default */ } else { size_t mapsize; off_t nextmap = src->curoffset - (src->curoffset % src->mapsize); - GST_LOG_OBJECT (src, "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering", - src->curoffset, readsize, nextmap, src->mapsize); + + GST_LOG_OBJECT (src, + "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering", + src->curoffset, readsize, nextmap, src->mapsize); /* first, we're done with the old mapbuf */ - gst_buffer_unref(src->mapbuf); + gst_buffer_unref (src->mapbuf); mapsize = src->mapsize; /* double the mapsize as long as the readsize is smaller */ while (readsize - (src->curoffset - nextmap) > mapsize) { GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d", - readsize, (int)mapsize); - mapsize <<=1; + readsize, (int) mapsize); + mapsize <<= 1; } /* create a new one */ src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize); @@ -550,8 +566,11 @@ gst_filesrc_get_mmap (GstFileSrc *src) return NULL; /* subbuffer it */ - buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, readsize); - GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap; + buf = + gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, + readsize); + GST_BUFFER_OFFSET (buf) = + GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap; } } @@ -559,18 +578,18 @@ gst_filesrc_get_mmap (GstFileSrc *src) if (src->touch) { volatile guchar *p = GST_BUFFER_DATA (buf), c; - for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize) + for (i = 0; i < GST_BUFFER_SIZE (buf); i += src->pagesize) c = p[i]; } /* we're done, return the buffer */ g_assert (src->curoffset == GST_BUFFER_OFFSET (buf)); - src->curoffset += GST_BUFFER_SIZE(buf); + src->curoffset += GST_BUFFER_SIZE (buf); return buf; } static GstBuffer * -gst_filesrc_get_read (GstFileSrc *src) +gst_filesrc_get_read (GstFileSrc * src) { GstBuffer *buf = NULL; size_t readsize; @@ -578,7 +597,8 @@ gst_filesrc_get_read (GstFileSrc *src) readsize = src->block_size; if (src->curoffset + readsize > src->filelen) { - if (!gst_filesrc_check_filesize (src) || src->curoffset + readsize > src->filelen) { + if (!gst_filesrc_check_filesize (src) + || src->curoffset + readsize > src->filelen) { readsize = src->filelen - src->curoffset; } } @@ -587,12 +607,13 @@ gst_filesrc_get_read (GstFileSrc *src) g_return_val_if_fail (buf != NULL, NULL); ret = read (src->fd, GST_BUFFER_DATA (buf), readsize); - if (ret < 0){ + if (ret < 0) { GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM); return NULL; } if (ret < readsize) { - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("unexpected end of file.")); + GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), + ("unexpected end of file.")); return NULL; } @@ -606,7 +627,7 @@ gst_filesrc_get_read (GstFileSrc *src) } static GstData * -gst_filesrc_get (GstPad *pad) +gst_filesrc_get (GstPad * pad) { GstFileSrc *src; @@ -626,7 +647,9 @@ gst_filesrc_get (GstPad *pad) src->seek_happened = FALSE; GST_DEBUG_OBJECT (src, "sending discont"); - event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL); + event = + gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, + NULL); return GST_DATA (event); } @@ -634,77 +657,76 @@ gst_filesrc_get (GstPad *pad) g_assert (src->curoffset <= src->filelen); if (src->curoffset == src->filelen) { if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) { - GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT, - src->curoffset, src->filelen); + GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, + src->curoffset, src->filelen); gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); } } - if (src->using_mmap){ + if (src->using_mmap) { return GST_DATA (gst_filesrc_get_mmap (src)); - }else{ + } else { return GST_DATA (gst_filesrc_get_read (src)); } } /* TRUE if the filesize of the file was updated */ static gboolean -gst_filesrc_check_filesize (GstFileSrc *src) +gst_filesrc_check_filesize (GstFileSrc * src) { struct stat stat_results; - - g_return_val_if_fail (GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE); - fstat(src->fd, &stat_results); - GST_DEBUG_OBJECT (src, "checked filesize on %s (was %"G_GUINT64_FORMAT", is %"G_GUINT64_FORMAT")", - src->filename, src->filelen, (guint64) stat_results.st_size); + g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE); + + fstat (src->fd, &stat_results); + GST_DEBUG_OBJECT (src, + "checked filesize on %s (was %" G_GUINT64_FORMAT ", is %" G_GUINT64_FORMAT + ")", src->filename, src->filelen, (guint64) stat_results.st_size); if (src->filelen == (guint64) stat_results.st_size) return FALSE; src->filelen = stat_results.st_size; return TRUE; } + /* open the file and mmap it, necessary to go to READY state */ static gboolean -gst_filesrc_open_file (GstFileSrc *src) +gst_filesrc_open_file (GstFileSrc * src) { - g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE); - if (src->filename == NULL || src->filename[0] == '\0') - { + if (src->filename == NULL || src->filename[0] == '\0') { GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, - (_("No file name specified for reading.")), (NULL)); + (_("No file name specified for reading.")), (NULL)); return FALSE; } - GST_INFO_OBJECT (src, "opening file %s",src->filename); + GST_INFO_OBJECT (src, "opening file %s", src->filename); /* open the file */ src->fd = open (src->filename, O_RDONLY); - if (src->fd < 0) - { + if (src->fd < 0) { if (errno == ENOENT) GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL)); else GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, - (_("Could not open file \"%s\" for reading."), src->filename), - GST_ERROR_SYSTEM); + (_("Could not open file \"%s\" for reading."), src->filename), + GST_ERROR_SYSTEM); return FALSE; } else { /* check if it is a regular file, otherwise bail out */ struct stat stat_results; - fstat(src->fd, &stat_results); + fstat (src->fd, &stat_results); - if (!S_ISREG(stat_results.st_mode)) { + if (!S_ISREG (stat_results.st_mode)) { GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, - (_("File \"%s\" isn't a regular file."), src->filename), - (NULL)); - close(src->fd); + (_("File \"%s\" isn't a regular file."), src->filename), (NULL)); + close (src->fd); return FALSE; } - + /* find the file length */ src->filelen = stat_results.st_size; @@ -712,7 +734,7 @@ gst_filesrc_open_file (GstFileSrc *src) src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize); if (src->mapbuf == NULL) { src->using_mmap = FALSE; - }else{ + } else { src->using_mmap = TRUE; } @@ -725,7 +747,7 @@ gst_filesrc_open_file (GstFileSrc *src) /* unmap and close the file */ static void -gst_filesrc_close_file (GstFileSrc *src) +gst_filesrc_close_file (GstFileSrc * src) { g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN)); @@ -747,9 +769,9 @@ gst_filesrc_close_file (GstFileSrc *src) static GstElementStateReturn -gst_filesrc_change_state (GstElement *element) +gst_filesrc_change_state (GstElement * element) { - GstFileSrc *src = GST_FILESRC(element); + GstFileSrc *src = GST_FILESRC (element); switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: @@ -758,13 +780,13 @@ gst_filesrc_change_state (GstElement *element) break; case GST_STATE_READY_TO_PAUSED: if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) { - if (!gst_filesrc_open_file (GST_FILESRC (element))) - return GST_STATE_FAILURE; + if (!gst_filesrc_open_file (GST_FILESRC (element))) + return GST_STATE_FAILURE; } break; case GST_STATE_PAUSED_TO_READY: if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) - gst_filesrc_close_file (GST_FILESRC (element)); + gst_filesrc_close_file (GST_FILESRC (element)); src->seek_happened = TRUE; break; default: @@ -778,8 +800,8 @@ gst_filesrc_change_state (GstElement *element) } static gboolean -gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad)); @@ -794,14 +816,14 @@ gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, case GST_QUERY_POSITION: switch (*format) { case GST_FORMAT_BYTES: - *value = src->curoffset; - break; + *value = src->curoffset; + break; case GST_FORMAT_PERCENT: if (src->filelen == 0) return FALSE; - *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen; - break; - default: + *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen; + break; + default: return FALSE; } break; @@ -813,7 +835,7 @@ gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, } static gboolean -gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event) +gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event) { GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad)); @@ -831,35 +853,41 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event) offset = GST_EVENT_SEEK_OFFSET (event); switch (GST_EVENT_SEEK_METHOD (event)) { - case GST_SEEK_METHOD_SET: - if (offset > src->filelen && (!gst_filesrc_check_filesize (src) || offset > src->filelen)) { - goto error; + case GST_SEEK_METHOD_SET: + if (offset > src->filelen && (!gst_filesrc_check_filesize (src) + || offset > src->filelen)) { + goto error; } - src->curoffset = offset; - GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, src->curoffset); + src->curoffset = offset; + GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, + src->curoffset); break; - case GST_SEEK_METHOD_CUR: - if (offset + src->curoffset > src->filelen) - if (!gst_filesrc_check_filesize (src) || offset + src->curoffset > src->filelen) + case GST_SEEK_METHOD_CUR: + if (offset + src->curoffset > src->filelen) + if (!gst_filesrc_check_filesize (src) + || offset + src->curoffset > src->filelen) goto error; - src->curoffset += offset; - GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, src->curoffset); + src->curoffset += offset; + GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, + src->curoffset); break; - case GST_SEEK_METHOD_END: - if (ABS (offset) > src->filelen) { - if (!gst_filesrc_check_filesize (src) || ABS (offset) > src->filelen) + case GST_SEEK_METHOD_END: + if (ABS (offset) > src->filelen) { + if (!gst_filesrc_check_filesize (src) + || ABS (offset) > src->filelen) goto error; goto error; } - src->curoffset = src->filelen - ABS (offset); - GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, src->curoffset); + src->curoffset = src->filelen - ABS (offset); + GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, + src->curoffset); break; default: - goto error; + goto error; break; } src->seek_happened = TRUE; - src->need_flush = GST_EVENT_SEEK_FLAGS(event) & GST_SEEK_FLAG_FLUSH; + src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; break; } case GST_EVENT_SIZE: @@ -867,7 +895,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event) goto error; } src->block_size = GST_EVENT_SIZE_VALUE (event); - g_object_notify (G_OBJECT (src), "blocksize"); + g_object_notify (G_OBJECT (src), "blocksize"); break; case GST_EVENT_FLUSH: src->need_flush = TRUE; @@ -892,20 +920,21 @@ gst_filesrc_uri_get_type (void) return GST_URI_SRC; } static gchar ** -gst_filesrc_uri_get_protocols(void) +gst_filesrc_uri_get_protocols (void) { - static gchar *protocols[] = {"file", NULL}; + static gchar *protocols[] = { "file", NULL }; return protocols; } static const gchar * -gst_filesrc_uri_get_uri (GstURIHandler *handler) +gst_filesrc_uri_get_uri (GstURIHandler * handler) { GstFileSrc *src = GST_FILESRC (handler); - + return src->uri; } + static gboolean -gst_filesrc_uri_set_uri (GstURIHandler *handler, const gchar *uri) +gst_filesrc_uri_set_uri (GstURIHandler * handler, const gchar * uri) { gchar *protocol, *location; gboolean ret; diff --git a/gst/elements/gstfilesrc.h b/gst/elements/gstfilesrc.h index 8ebda1e5c..b37ce9c36 100644 --- a/gst/elements/gstfilesrc.h +++ b/gst/elements/gstfilesrc.h @@ -29,21 +29,19 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FILESRC \ (gst_filesrc_get_type()) #define GST_FILESRC(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FILESRC,GstFileSrc)) #define GST_FILESRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass)) + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass)) #define GST_IS_FILESRC(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESRC)) #define GST_IS_FILESRC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESRC)) - -typedef enum { - GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST, + typedef enum +{ + GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST, GST_FILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstFileSrcFlags; @@ -51,20 +49,21 @@ typedef enum { typedef struct _GstFileSrc GstFileSrc; typedef struct _GstFileSrcClass GstFileSrcClass; -struct _GstFileSrc { +struct _GstFileSrc +{ GstElement element; GstPad *srcpad; - guint pagesize; /* system page size*/ - - gchar *filename; /* filename */ - gchar *uri; /* caching the URI */ - gint fd; /* open file descriptor*/ - off_t filelen; /* what's the file length?*/ + guint pagesize; /* system page size */ - off_t curoffset; /* current offset in file*/ - off_t block_size; /* bytes per read */ - gboolean touch; /* whether to touch every page */ + gchar *filename; /* filename */ + gchar *uri; /* caching the URI */ + gint fd; /* open file descriptor */ + off_t filelen; /* what's the file length? */ + + off_t curoffset; /* current offset in file */ + off_t block_size; /* bytes per read */ + gboolean touch; /* whether to touch every page */ gboolean using_mmap; GstBuffer *mapbuf; @@ -74,12 +73,12 @@ struct _GstFileSrc { gboolean need_flush; }; -struct _GstFileSrcClass { +struct _GstFileSrcClass +{ GstElementClass parent_class; }; -GType gst_filesrc_get_type(void); +GType gst_filesrc_get_type (void); G_END_DECLS - #endif /* __GST_FILESRC_H__ */ diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 6fd3e755a..832f33d74 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -34,22 +34,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_identity_debug); #define GST_CAT_DEFAULT gst_identity_debug -GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS ( - "Identity", - "Generic", - "Pass data without modification", - "Erik Walthinsen " -); +GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS ("Identity", + "Generic", + "Pass data without modification", + "Erik Walthinsen "); /* Identity signals and args */ -enum { +enum +{ SIGNAL_HANDOFF, /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOOP_BASED, ARG_SLEEP_TIME, @@ -65,12 +65,15 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_identity_debug, "identity", 0, "identity element"); -GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_identity_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_identity_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_identity_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_identity_chain (GstPad *pad, GstData *_data); +static void gst_identity_chain (GstPad * pad, GstData * _data); static guint gst_identity_signals[LAST_SIGNAL] = { 0 }; @@ -78,11 +81,11 @@ static void gst_identity_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_identity_details); } -static void -gst_identity_class_init (GstIdentityClass *klass) +static void +gst_identity_class_init (GstIdentityClass * klass) { GObjectClass *gobject_class; @@ -90,50 +93,52 @@ gst_identity_class_init (GstIdentityClass *klass) g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, - g_param_spec_boolean ("loop-based", "Loop-based", - "Set to TRUE to use loop-based rather than chain-based scheduling", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("loop-based", "Loop-based", + "Set to TRUE to use loop-based rather than chain-based scheduling", + TRUE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME, - g_param_spec_uint ("sleep-time", "Sleep time", "Microseconds to sleep between processing", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("sleep-time", "Sleep time", + "Microseconds to sleep between processing", 0, G_MAXUINT, 0, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE, - g_param_spec_uint ("duplicate", "Duplicate Buffers", "Push the buffers N times", - 0, G_MAXUINT, 1, G_PARAM_READWRITE)); + g_param_spec_uint ("duplicate", "Duplicate Buffers", + "Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER, - g_param_spec_int ("error_after", "Error After", "Error after N buffers", - G_MININT, G_MAXINT, -1, G_PARAM_READWRITE)); + g_param_spec_int ("error_after", "Error After", "Error after N buffers", + G_MININT, G_MAXINT, -1, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY, - g_param_spec_float ("drop_probability", "Drop Probability", "The Probability a buffer is dropped", - 0.0, 1.0, 0.0, G_PARAM_READWRITE)); + g_param_spec_float ("drop_probability", "Drop Probability", + "The Probability a buffer is dropped", 0.0, 1.0, 0.0, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last-message", "last-message", "last-message", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last-message", "last-message", "last-message", NULL, + G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, - g_param_spec_boolean("dump", "Dump", "Dump buffer contents", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE, + G_PARAM_READWRITE)); gst_identity_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL, - gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, - GST_TYPE_BUFFER); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL, + gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_BUFFER); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property); } -static void -gst_identity_init (GstIdentity *identity) +static void +gst_identity_init (GstIdentity * identity) { identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad); - gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain)); + gst_pad_set_chain_function (identity->sinkpad, + GST_DEBUG_FUNCPTR (gst_identity_chain)); gst_pad_set_link_function (identity->sinkpad, gst_pad_proxy_pad_link); gst_pad_set_getcaps_function (identity->sinkpad, gst_pad_proxy_getcaps); - + identity->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); gst_pad_set_link_function (identity->srcpad, gst_pad_proxy_pad_link); @@ -150,8 +155,8 @@ gst_identity_init (GstIdentity *identity) identity->srccaps = NULL; } -static void -gst_identity_chain (GstPad *pad, GstData *_data) +static void +gst_identity_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstIdentity *identity; @@ -168,20 +173,20 @@ gst_identity_chain (GstPad *pad, GstData *_data) if (identity->error_after == 0) { gst_buffer_unref (buf); GST_ELEMENT_ERROR (identity, CORE, FAILED, - (_("Failed after iterations as requested.")), - (NULL)); + (_("Failed after iterations as requested.")), (NULL)); return; } } if (identity->drop_probability > 0.0) { - if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) { + if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) { if (identity->last_message != NULL) { g_free (identity->last_message); } - identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %" - G_GINT64_FORMAT ")", - GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); + identity->last_message = + g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %" + G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); gst_buffer_unref (buf); return; @@ -194,16 +199,17 @@ gst_identity_chain (GstPad *pad, GstData *_data) for (i = identity->duplicate; i; i--) { if (!identity->silent) { g_free (identity->last_message); - identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %" - G_GINT64_FORMAT ")", - GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); + identity->last_message = + g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %" + G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); } g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, - buf); + buf); - if (i>1) + if (i > 1) gst_buffer_ref (buf); gst_pad_push (identity->srcpad, GST_DATA (buf)); @@ -213,8 +219,8 @@ gst_identity_chain (GstPad *pad, GstData *_data) } } -static void -gst_identity_loop (GstElement *element) +static void +gst_identity_loop (GstElement * element) { GstIdentity *identity; GstBuffer *buf; @@ -223,43 +229,42 @@ gst_identity_loop (GstElement *element) g_return_if_fail (GST_IS_IDENTITY (element)); identity = GST_IDENTITY (element); - + buf = GST_BUFFER (gst_pad_pull (identity->sinkpad)); if (GST_IS_EVENT (buf)) { GstEvent *event = GST_EVENT (buf); if (GST_EVENT_IS_INTERRUPT (event)) { gst_event_unref (event); - } - else { + } else { gst_pad_event_default (identity->sinkpad, event); } - } - else { + } else { gst_identity_chain (identity->sinkpad, GST_DATA (buf)); } } -static void -gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_identity_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstIdentity *identity; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_IDENTITY (object)); - + identity = GST_IDENTITY (object); switch (prop_id) { case ARG_LOOP_BASED: identity->loop_based = g_value_get_boolean (value); if (identity->loop_based) { - gst_element_set_loop_function (GST_ELEMENT (identity), gst_identity_loop); - gst_pad_set_chain_function (identity->sinkpad, NULL); - } - else { - gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); - gst_element_set_loop_function (GST_ELEMENT (identity), NULL); + gst_element_set_loop_function (GST_ELEMENT (identity), + gst_identity_loop); + gst_pad_set_chain_function (identity->sinkpad, NULL); + } else { + gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); + gst_element_set_loop_function (GST_ELEMENT (identity), NULL); } break; case ARG_SLEEP_TIME: @@ -285,12 +290,15 @@ gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, } } -static void gst_identity_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { +static void +gst_identity_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ GstIdentity *identity; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_IDENTITY (object)); - + identity = GST_IDENTITY (object); switch (prop_id) { diff --git a/gst/elements/gstidentity.h b/gst/elements/gstidentity.h index 00dffdfc5..36097f8d0 100644 --- a/gst/elements/gstidentity.h +++ b/gst/elements/gstidentity.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_IDENTITY \ (gst_identity_get_type()) #define GST_IDENTITY(obj) \ @@ -40,36 +38,36 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IDENTITY)) #define GST_IS_IDENTITY_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY)) - typedef struct _GstIdentity GstIdentity; typedef struct _GstIdentityClass GstIdentityClass; -struct _GstIdentity { - GstElement element; - - GstPad *sinkpad; - GstPad *srcpad; - - gboolean loop_based; - guint duplicate; - gint error_after; - gfloat drop_probability; - guint sleep_time; - gboolean silent; - gboolean dump; - gchar *last_message; - GstCaps *srccaps; +struct _GstIdentity +{ + GstElement element; + + GstPad *sinkpad; + GstPad *srcpad; + + gboolean loop_based; + guint duplicate; + gint error_after; + gfloat drop_probability; + guint sleep_time; + gboolean silent; + gboolean dump; + gchar *last_message; + GstCaps *srccaps; }; -struct _GstIdentityClass { +struct _GstIdentityClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstBuffer *buf); + void (*handoff) (GstElement * element, GstBuffer * buf); }; -GType gst_identity_get_type(void); +GType gst_identity_get_type (void); G_END_DECLS - #endif /* __GST_IDENTITY_H__ */ diff --git a/gst/elements/gstmd5sink.c b/gst/elements/gstmd5sink.c index a75ea075e..72e6f3b46 100644 --- a/gst/elements/gstmd5sink.c +++ b/gst/elements/gstmd5sink.c @@ -35,63 +35,64 @@ GST_DEBUG_CATEGORY_STATIC (gst_md5sink_debug); #define GST_CAT_DEFAULT gst_md5sink_debug -GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS ( - "MD5 Sink", - "Sink", - "compute MD5 for incoming data", - "Benjamin Otte " -); +GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS ("MD5 Sink", + "Sink", + "compute MD5 for incoming data", + "Benjamin Otte "); /* MD5Sink signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_MD5, /* FILL ME */ }; -GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_md5sink_debug, "md5sink", 0, "md5sink element"); -GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT, + _do_init); /* GObject stuff */ /*static void gst_md5sink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);*/ -static void gst_md5sink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_md5sink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_md5sink_chain (GstPad *pad, GstData *_data); -static GstElementStateReturn gst_md5sink_change_state (GstElement *element); +static void gst_md5sink_chain (GstPad * pad, GstData * _data); +static GstElementStateReturn gst_md5sink_change_state (GstElement * element); /* MD5 stuff */ -static void md5_init_ctx (GstMD5Sink *ctx); -static gpointer md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf); -static gpointer md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf); -static void md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx); -static void md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx); +static void md5_init_ctx (GstMD5Sink * ctx); +static gpointer md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf); +static gpointer md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf); +static void md5_process_bytes (const void *buffer, size_t len, + GstMD5Sink * ctx); +static void md5_process_block (const void *buffer, size_t len, + GstMD5Sink * ctx); /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ -static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; +static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* MD5 functions */ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ static void -md5_init_ctx (GstMD5Sink *ctx) +md5_init_ctx (GstMD5Sink * ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; @@ -101,13 +102,14 @@ md5_init_ctx (GstMD5Sink *ctx) ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } + /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ static gpointer -md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf) +md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf) { /* Take yet unprocessed bytes into account. */ guint32 bytes = ctx->buflen; @@ -122,22 +124,23 @@ md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf) memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(guint32 *) &ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3); - *(guint32 *) &ctx->buffer[bytes + pad + 4] = GUINT32_TO_LE ((ctx->total[1] << 3) | - (ctx->total[0] >> 29)); + *(guint32 *) & ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3); + *(guint32 *) & ctx->buffer[bytes + pad + 4] = + GUINT32_TO_LE ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); return md5_read_ctx (ctx, resbuf); } + /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ static gpointer -md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf) +md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf) { ((guint32 *) resbuf)[0] = GUINT32_TO_LE (ctx->A); ((guint32 *) resbuf)[1] = GUINT32_TO_LE (ctx->B); @@ -148,66 +151,60 @@ md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf) } static void -md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx) +md5_process_bytes (const void *buffer, size_t len, GstMD5Sink * ctx) { /*const void aligned_buffer = buffer; */ /* When we already have some bits in our internal buffer concatenate both inputs first. */ - if (ctx->buflen != 0) - { - size_t left_over = ctx->buflen; - size_t add = 128 - left_over > len ? len : 128 - left_over; - - /* Only put full words in the buffer. */ - /* Forcing alignment here appears to be only an optimization. - * The glibc source uses __alignof__, which seems to be a - * gratuitous usage of a GCC extension, when sizeof() will - * work fine. (And don't question the sanity of using - * sizeof(guint32) instead of 4. */ - /* add -= add % __alignof__ (guint32); */ - add -= add % sizeof(guint32); - - memcpy (&ctx->buffer[left_over], buffer, add); - ctx->buflen += add; - - if (ctx->buflen > 64) - { - md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - - ctx->buflen &= 63; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], - ctx->buflen); - } - - buffer = (const char *) buffer + add; - len -= add; + if (ctx->buflen != 0) { + size_t left_over = ctx->buflen; + size_t add = 128 - left_over > len ? len : 128 - left_over; + + /* Only put full words in the buffer. */ + /* Forcing alignment here appears to be only an optimization. + * The glibc source uses __alignof__, which seems to be a + * gratuitous usage of a GCC extension, when sizeof() will + * work fine. (And don't question the sanity of using + * sizeof(guint32) instead of 4. */ + /* add -= add % __alignof__ (guint32); */ + add -= add % sizeof (guint32); + + memcpy (&ctx->buffer[left_over], buffer, add); + ctx->buflen += add; + + if (ctx->buflen > 64) { + md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); + + ctx->buflen &= 63; + /* The regions in the following copy operation cannot overlap. */ + memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); } + buffer = (const char *) buffer + add; + len -= add; + } + /* Process available complete blocks. */ - if (len > 64) - { - md5_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; - } + if (len > 64) { + md5_process_block (buffer, len & ~63, ctx); + buffer = (const char *) buffer + (len & ~63); + len &= 63; + } /* Move remaining bytes in internal buffer. */ - if (len > 0) - { - size_t left_over = ctx->buflen; - - memcpy (&ctx->buffer[left_over], buffer, len); - left_over += len; - if (left_over >= 64) - { - md5_process_block (ctx->buffer, 64, ctx); - left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[64], left_over); - } - ctx->buflen = left_over; + if (len > 0) { + size_t left_over = ctx->buflen; + + memcpy (&ctx->buffer[left_over], buffer, len); + left_over += len; + if (left_over >= 64) { + md5_process_block (ctx->buffer, 64, ctx); + left_over -= 64; + memcpy (ctx->buffer, &ctx->buffer[64], left_over); } + ctx->buflen = left_over; + } } @@ -223,7 +220,7 @@ md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ static void -md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) +md5_process_block (const void *buffer, size_t len, GstMD5Sink * ctx) { guint32 correct_words[16]; const guint32 *words = buffer; @@ -243,20 +240,19 @@ md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) /* Process all bytes in the buffer with 64 bytes in each round of the loop. */ - while (words < endp) - { - guint32 *cwp = correct_words; - guint32 A_save = A; - guint32 B_save = B; - guint32 C_save = C; - guint32 D_save = D; - - /* First round: using the given function, the context and a constant - the next context is computed. Because the algorithms processing - unit is a 32-bit word and it is determined to work on words in - little endian byte order we perhaps have to change the byte order - before the computation. To reduce the work for the next steps - we store the swapped words in the array CORRECT_WORDS. */ + while (words < endp) { + guint32 *cwp = correct_words; + guint32 A_save = A; + guint32 B_save = B; + guint32 C_save = C; + guint32 D_save = D; + + /* First round: using the given function, the context and a constant + the next context is computed. Because the algorithms processing + unit is a 32-bit word and it is determined to work on words in + little endian byte order we perhaps have to change the byte order + before the computation. To reduce the work for the next steps + we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ @@ -268,37 +264,37 @@ md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) } \ while (0) - /* It is unfortunate that C does not provide an operator for - cyclic rotation. Hope the C compiler is smart enough. */ + /* It is unfortunate that C does not provide an operator for + cyclic rotation. Hope the C compiler is smart enough. */ #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) - /* Before we start, one word to the strange constants. - They are defined in RFC 1321 as - - T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 - */ - - /* Round 1. */ - OP (A, B, C, D, 7, 0xd76aa478); - OP (D, A, B, C, 12, 0xe8c7b756); - OP (C, D, A, B, 17, 0x242070db); - OP (B, C, D, A, 22, 0xc1bdceee); - OP (A, B, C, D, 7, 0xf57c0faf); - OP (D, A, B, C, 12, 0x4787c62a); - OP (C, D, A, B, 17, 0xa8304613); - OP (B, C, D, A, 22, 0xfd469501); - OP (A, B, C, D, 7, 0x698098d8); - OP (D, A, B, C, 12, 0x8b44f7af); - OP (C, D, A, B, 17, 0xffff5bb1); - OP (B, C, D, A, 22, 0x895cd7be); - OP (A, B, C, D, 7, 0x6b901122); - OP (D, A, B, C, 12, 0xfd987193); - OP (C, D, A, B, 17, 0xa679438e); - OP (B, C, D, A, 22, 0x49b40821); - - /* For the second to fourth round we have the possibly swapped words - in CORRECT_WORDS. Redefine the macro to take an additional first - argument specifying the function to use. */ + /* Before we start, one word to the strange constants. + They are defined in RFC 1321 as + + T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 + */ + + /* Round 1. */ + OP (A, B, C, D, 7, 0xd76aa478); + OP (D, A, B, C, 12, 0xe8c7b756); + OP (C, D, A, B, 17, 0x242070db); + OP (B, C, D, A, 22, 0xc1bdceee); + OP (A, B, C, D, 7, 0xf57c0faf); + OP (D, A, B, C, 12, 0x4787c62a); + OP (C, D, A, B, 17, 0xa8304613); + OP (B, C, D, A, 22, 0xfd469501); + OP (A, B, C, D, 7, 0x698098d8); + OP (D, A, B, C, 12, 0x8b44f7af); + OP (C, D, A, B, 17, 0xffff5bb1); + OP (B, C, D, A, 22, 0x895cd7be); + OP (A, B, C, D, 7, 0x6b901122); + OP (D, A, B, C, 12, 0xfd987193); + OP (C, D, A, B, 17, 0xa679438e); + OP (B, C, D, A, 22, 0x49b40821); + + /* For the second to fourth round we have the possibly swapped words + in CORRECT_WORDS. Redefine the macro to take an additional first + argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ do \ @@ -309,66 +305,66 @@ md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) } \ while (0) - /* Round 2. */ - OP (FG, A, B, C, D, 1, 5, 0xf61e2562); - OP (FG, D, A, B, C, 6, 9, 0xc040b340); - OP (FG, C, D, A, B, 11, 14, 0x265e5a51); - OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); - OP (FG, A, B, C, D, 5, 5, 0xd62f105d); - OP (FG, D, A, B, C, 10, 9, 0x02441453); - OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); - OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); - OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); - OP (FG, D, A, B, C, 14, 9, 0xc33707d6); - OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); - OP (FG, B, C, D, A, 8, 20, 0x455a14ed); - OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); - OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); - OP (FG, C, D, A, B, 7, 14, 0x676f02d9); - OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); - - /* Round 3. */ - OP (FH, A, B, C, D, 5, 4, 0xfffa3942); - OP (FH, D, A, B, C, 8, 11, 0x8771f681); - OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); - OP (FH, B, C, D, A, 14, 23, 0xfde5380c); - OP (FH, A, B, C, D, 1, 4, 0xa4beea44); - OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); - OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); - OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); - OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); - OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); - OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); - OP (FH, B, C, D, A, 6, 23, 0x04881d05); - OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); - OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); - OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); - OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); - - /* Round 4. */ - OP (FI, A, B, C, D, 0, 6, 0xf4292244); - OP (FI, D, A, B, C, 7, 10, 0x432aff97); - OP (FI, C, D, A, B, 14, 15, 0xab9423a7); - OP (FI, B, C, D, A, 5, 21, 0xfc93a039); - OP (FI, A, B, C, D, 12, 6, 0x655b59c3); - OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); - OP (FI, C, D, A, B, 10, 15, 0xffeff47d); - OP (FI, B, C, D, A, 1, 21, 0x85845dd1); - OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); - OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); - OP (FI, C, D, A, B, 6, 15, 0xa3014314); - OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); - OP (FI, A, B, C, D, 4, 6, 0xf7537e82); - OP (FI, D, A, B, C, 11, 10, 0xbd3af235); - OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); - OP (FI, B, C, D, A, 9, 21, 0xeb86d391); - - /* Add the starting values of the context. */ - A += A_save; - B += B_save; - C += C_save; - D += D_save; - } + /* Round 2. */ + OP (FG, A, B, C, D, 1, 5, 0xf61e2562); + OP (FG, D, A, B, C, 6, 9, 0xc040b340); + OP (FG, C, D, A, B, 11, 14, 0x265e5a51); + OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); + OP (FG, A, B, C, D, 5, 5, 0xd62f105d); + OP (FG, D, A, B, C, 10, 9, 0x02441453); + OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); + OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); + OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); + OP (FG, D, A, B, C, 14, 9, 0xc33707d6); + OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); + OP (FG, B, C, D, A, 8, 20, 0x455a14ed); + OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); + OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); + OP (FG, C, D, A, B, 7, 14, 0x676f02d9); + OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); + + /* Round 3. */ + OP (FH, A, B, C, D, 5, 4, 0xfffa3942); + OP (FH, D, A, B, C, 8, 11, 0x8771f681); + OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); + OP (FH, B, C, D, A, 14, 23, 0xfde5380c); + OP (FH, A, B, C, D, 1, 4, 0xa4beea44); + OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); + OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); + OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); + OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); + OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); + OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); + OP (FH, B, C, D, A, 6, 23, 0x04881d05); + OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); + OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); + OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); + OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); + + /* Round 4. */ + OP (FI, A, B, C, D, 0, 6, 0xf4292244); + OP (FI, D, A, B, C, 7, 10, 0x432aff97); + OP (FI, C, D, A, B, 14, 15, 0xab9423a7); + OP (FI, B, C, D, A, 5, 21, 0xfc93a039); + OP (FI, A, B, C, D, 12, 6, 0x655b59c3); + OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); + OP (FI, C, D, A, B, 10, 15, 0xffeff47d); + OP (FI, B, C, D, A, 1, 21, 0x85845dd1); + OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); + OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); + OP (FI, C, D, A, B, 6, 15, 0xa3014314); + OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); + OP (FI, A, B, C, D, 4, 6, 0xf7537e82); + OP (FI, D, A, B, C, 11, 10, 0xbd3af235); + OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); + OP (FI, B, C, D, A, 9, 21, 0xeb86d391); + + /* Add the starting values of the context. */ + A += A_save; + B += B_save; + C += C_save; + D += D_save; + } /* Put checksum in context given as argument. */ ctx->A = A; @@ -381,14 +377,14 @@ static void gst_md5sink_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_md5sink_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&md5_sink_template)); } static void -gst_md5sink_class_init (GstMD5SinkClass *klass) +gst_md5sink_class_init (GstMD5SinkClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; @@ -400,18 +396,20 @@ gst_md5sink_class_init (GstMD5SinkClass *klass) gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_md5sink_get_property); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5, - g_param_spec_string ("md5", "md5", "current value of the md5 sum", - "", G_PARAM_READABLE)); + g_param_spec_string ("md5", "md5", "current value of the md5 sum", + "", G_PARAM_READABLE)); - gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_md5sink_change_state); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state); } -static void -gst_md5sink_init (GstMD5Sink *md5sink) +static void +gst_md5sink_init (GstMD5Sink * md5sink) { GstPad *pad; - pad = gst_pad_new_from_template (gst_static_pad_template_get ( - &md5_sink_template), "sink"); + + pad = + gst_pad_new_from_template (gst_static_pad_template_get + (&md5_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (md5sink), pad); gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_md5sink_chain)); @@ -419,15 +417,15 @@ gst_md5sink_init (GstMD5Sink *md5sink) } static GstElementStateReturn -gst_md5sink_change_state (GstElement *element) +gst_md5sink_change_state (GstElement * element) { GstMD5Sink *sink; - + /* element check */ sink = GST_MD5SINK (element); g_return_val_if_fail (GST_IS_MD5SINK (sink), GST_STATE_FAILURE); - + switch (GST_STATE_TRANSITION (element)) { case GST_STATE_READY_TO_PAUSED: md5_init_ctx (sink); @@ -440,38 +438,39 @@ gst_md5sink_change_state (GstElement *element) default: break; } - + if ((GST_ELEMENT_CLASS (parent_class)->change_state)) return GST_ELEMENT_CLASS (parent_class)->change_state (element); - + return GST_STATE_SUCCESS; } -static void -gst_md5sink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_md5sink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstMD5Sink *sink; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_MD5SINK (object)); - + sink = GST_MD5SINK (object); - + switch (prop_id) { case ARG_MD5: - { - /* you could actually get a value for the current md5. - * This is currently disabled. - * md5_read_ctx (sink, sink->md5); */ - /* md5 is a guchar[16] */ - int i; - guchar *md5string = g_malloc0 (33); - - for (i = 0; i < 16; ++i) - sprintf (md5string + i * 2, "%02x", sink->md5[i]); - g_value_set_string (value, md5string); - g_free (md5string); - } + { + /* you could actually get a value for the current md5. + * This is currently disabled. + * md5_read_ctx (sink, sink->md5); */ + /* md5 is a guchar[16] */ + int i; + guchar *md5string = g_malloc0 (33); + + for (i = 0; i < 16; ++i) + sprintf (md5string + i * 2, "%02x", sink->md5[i]); + g_value_set_string (value, md5string); + g_free (md5string); + } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -479,8 +478,8 @@ gst_md5sink_get_property (GObject *object, guint prop_id, GValue *value, GParamS } } -static void -gst_md5sink_chain (GstPad *pad, GstData *_data) +static void +gst_md5sink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstMD5Sink *md5sink; @@ -491,11 +490,9 @@ gst_md5sink_chain (GstPad *pad, GstData *_data) md5sink = GST_MD5SINK (gst_pad_get_parent (pad)); - if (GST_IS_BUFFER (buf)) - { + if (GST_IS_BUFFER (buf)) { md5_process_bytes (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), md5sink); } - + gst_buffer_unref (buf); } - diff --git a/gst/elements/gstmd5sink.h b/gst/elements/gstmd5sink.h index fc847b2a2..8a35d1a41 100644 --- a/gst/elements/gstmd5sink.h +++ b/gst/elements/gstmd5sink.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_MD5SINK \ (gst_md5sink_get_type()) #define GST_MD5SINK(obj) \ @@ -40,11 +38,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MD5SINK)) #define GST_IS_MD5SINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MD5SINK)) - typedef struct _GstMD5Sink GstMD5Sink; typedef struct _GstMD5SinkClass GstMD5SinkClass; -struct _GstMD5Sink { +struct _GstMD5Sink +{ GstElement element; /* md5 information */ @@ -56,21 +54,21 @@ struct _GstMD5Sink { guint32 total[2]; guint32 buflen; gchar buffer[128]; - + /* latest md5 */ guchar md5[16]; - + }; -struct _GstMD5SinkClass { +struct _GstMD5SinkClass +{ GstElementClass parent_class; }; -GType gst_md5sink_get_type (void); +GType gst_md5sink_get_type (void); -gboolean gst_md5sink_factory_init (GstElementFactory *factory); +gboolean gst_md5sink_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_MD5SINK_H__ */ diff --git a/gst/elements/gstmultifilesrc.c b/gst/elements/gstmultifilesrc.c index b24fca98f..d819c3e4e 100644 --- a/gst/elements/gstmultifilesrc.c +++ b/gst/elements/gstmultifilesrc.c @@ -40,20 +40,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_multifilesrc_debug); #define GST_CAT_DEFAULT gst_multifilesrc_debug -GstElementDetails gst_multifilesrc_details = GST_ELEMENT_DETAILS ( - "Multi File Source", - "Source/File", - "Read from multiple files in order", - "Dominic Ludlam " -); +GstElementDetails gst_multifilesrc_details = +GST_ELEMENT_DETAILS ("Multi File Source", + "Source/File", + "Read from multiple files in order", + "Dominic Ludlam "); /* FileSrc signals and args */ -enum { +enum +{ NEW_FILE, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATIONS }; @@ -61,18 +62,24 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_multifilesrc_debug, "multifilesrc", 0, "multifilesrc element"); -GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_multifilesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_multifilesrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static GstData *gst_multifilesrc_get (GstPad * pad); -static GstData * gst_multifilesrc_get (GstPad *pad); /*static GstBuffer * gst_multifilesrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/ -static GstElementStateReturn gst_multifilesrc_change_state (GstElement *element); +static GstElementStateReturn gst_multifilesrc_change_state (GstElement * + element); -static gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad); -static void gst_multifilesrc_close_file (GstMultiFileSrc *src); +static gboolean gst_multifilesrc_open_file (GstMultiFileSrc * src, + GstPad * srcpad); +static void gst_multifilesrc_close_file (GstMultiFileSrc * src); static guint gst_multifilesrc_signals[LAST_SIGNAL] = { 0 }; @@ -80,28 +87,25 @@ static void gst_multifilesrc_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_multifilesrc_details); } static void -gst_multifilesrc_class_init (GstMultiFileSrcClass *klass) +gst_multifilesrc_class_init (GstMultiFileSrcClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; gst_multifilesrc_signals[NEW_FILE] = - g_signal_new ("new-file", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, - g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, - G_TYPE_STRING); + g_signal_new ("new-file", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, + g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS, - g_param_spec_pointer("locations","locations","locations", - G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */ gobject_class->set_property = gst_multifilesrc_set_property; gobject_class->get_property = gst_multifilesrc_get_property; @@ -110,12 +114,12 @@ gst_multifilesrc_class_init (GstMultiFileSrcClass *klass) } static void -gst_multifilesrc_init (GstMultiFileSrc *multifilesrc) +gst_multifilesrc_init (GstMultiFileSrc * multifilesrc) { /* GST_FLAG_SET (filesrc, GST_SRC_); */ multifilesrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_get_function (multifilesrc->srcpad,gst_multifilesrc_get); + gst_pad_set_get_function (multifilesrc->srcpad, gst_multifilesrc_get); /* gst_pad_set_getregion_function (multifilesrc->srcpad,gst_multifilesrc_get_region); */ gst_element_add_pad (GST_ELEMENT (multifilesrc), multifilesrc->srcpad); @@ -128,7 +132,8 @@ gst_multifilesrc_init (GstMultiFileSrc *multifilesrc) } static void -gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_multifilesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstMultiFileSrc *src; @@ -144,11 +149,11 @@ gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *val /* clear the filename if we get a NULL */ if (g_value_get_pointer (value) == NULL) { - gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); - src->listptr = NULL; - /* otherwise set the new filenames */ + gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); + src->listptr = NULL; + /* otherwise set the new filenames */ } else { - src->listptr = g_value_get_pointer (value); + src->listptr = g_value_get_pointer (value); } break; default: @@ -157,7 +162,8 @@ gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *val } static void -gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_multifilesrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstMultiFileSrc *src; @@ -183,7 +189,7 @@ gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GP * Push a new buffer from the filesrc at the current offset. */ static GstData * -gst_multifilesrc_get (GstPad *pad) +gst_multifilesrc_get (GstPad * pad) { GstMultiFileSrc *src; GstBuffer *buf; @@ -193,7 +199,7 @@ gst_multifilesrc_get (GstPad *pad) src = GST_MULTIFILESRC (gst_pad_get_parent (pad)); if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN)) - gst_multifilesrc_close_file(src); + gst_multifilesrc_close_file (src); if (!src->listptr) { return GST_DATA (gst_event_new (GST_EVENT_EOS)); @@ -203,11 +209,11 @@ gst_multifilesrc_get (GstPad *pad) src->currentfilename = (gchar *) list->data; src->listptr = src->listptr->next; - if (!gst_multifilesrc_open_file(src, pad)) - return NULL; + if (!gst_multifilesrc_open_file (src, pad)) + return NULL; - /* emitted after the open, as the user may free the list and string from here*/ - g_signal_emit(G_OBJECT(src), gst_multifilesrc_signals[NEW_FILE], 0, list); + /* emitted after the open, as the user may free the list and string from here */ + g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0, list); /* create the buffer */ /* FIXME: should eventually use a bufferpool for this */ @@ -231,24 +237,23 @@ gst_multifilesrc_get (GstPad *pad) } /* open the file and mmap it, necessary to go to READY state */ -static -gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad) +static gboolean +gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad) { g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN), FALSE); - if (src->currentfilename == NULL || src->currentfilename[0] == '\0') - { + if (src->currentfilename == NULL || src->currentfilename[0] == '\0') { GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, - (_("No file name specified for reading.")), (NULL)); + (_("No file name specified for reading.")), (NULL)); return FALSE; } /* open the file */ src->fd = open ((const char *) src->currentfilename, O_RDONLY); if (src->fd < 0) { - GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, - (_("Could not open file \"%s\" for reading."), src->currentfilename), - GST_ERROR_SYSTEM); + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, + (_("Could not open file \"%s\" for reading."), src->currentfilename), + GST_ERROR_SYSTEM); return FALSE; } else { @@ -257,12 +262,12 @@ gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad) lseek (src->fd, 0, SEEK_SET); /* map the file into memory */ src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0); - madvise (src->map,src->size, 2); + madvise (src->map, src->size, 2); /* collapse state if that failed */ if (src->map == NULL) { close (src->fd); GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), - ("mmap call failed.")); + ("mmap call failed.")); return FALSE; } GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN); @@ -273,7 +278,7 @@ gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad) /* unmap and close the file */ static void -gst_multifilesrc_close_file (GstMultiFileSrc *src) +gst_multifilesrc_close_file (GstMultiFileSrc * src) { g_return_if_fail (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN)); @@ -291,7 +296,7 @@ gst_multifilesrc_close_file (GstMultiFileSrc *src) } static GstElementStateReturn -gst_multifilesrc_change_state (GstElement *element) +gst_multifilesrc_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_MULTIFILESRC (element), GST_STATE_FAILURE); diff --git a/gst/elements/gstmultifilesrc.h b/gst/elements/gstmultifilesrc.h index 6e1b6eba2..463123b5d 100644 --- a/gst/elements/gstmultifilesrc.h +++ b/gst/elements/gstmultifilesrc.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_MULTIFILESRC \ (gst_multifilesrc_get_type()) #define GST_MULTIFILESRC(obj) \ @@ -39,41 +37,42 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIFILESRC)) #define GST_IS_MULTIFILESRC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIFILESRC)) + typedef enum +{ + GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST, -typedef enum { - GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST, - - GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 + GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstMultiFileSrcFlags; typedef struct _GstMultiFileSrc GstMultiFileSrc; typedef struct _GstMultiFileSrcClass GstMultiFileSrcClass; -struct _GstMultiFileSrc { +struct _GstMultiFileSrc +{ GstElement element; /* pads */ GstPad *srcpad; /* current file details */ - gchar *currentfilename; + gchar *currentfilename; GSList *listptr; /* mapping parameters */ gint fd; - gulong size; /* how long is the file? */ - guchar *map; /* where the file is mapped to */ + gulong size; /* how long is the file? */ + guchar *map; /* where the file is mapped to */ gboolean new_seek; }; -struct _GstMultiFileSrcClass { +struct _GstMultiFileSrcClass +{ GstElementClass parent_class; - void (*new_file) (GstMultiFileSrc *multifilesrc, gchar *newfilename); + void (*new_file) (GstMultiFileSrc * multifilesrc, gchar * newfilename); }; -GType gst_multifilesrc_get_type(void); +GType gst_multifilesrc_get_type (void); G_END_DECLS - #endif /* __GST_MULTIFILESRC_H__ */ diff --git a/gst/elements/gstpipefilter.c b/gst/elements/gstpipefilter.c index 1dfc1c384..0ba8bfc9d 100644 --- a/gst/elements/gstpipefilter.c +++ b/gst/elements/gstpipefilter.c @@ -40,22 +40,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_pipefilter_debug); #define GST_CAT_DEFAULT gst_pipefilter_debug -GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS ( - "Pipefilter", - "Filter", - "Interoperate with an external program using stdin and stdout", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS ("Pipefilter", + "Filter", + "Interoperate with an external program using stdin and stdout", + "Erik Walthinsen , " + "Wim Taymans "); /* Pipefilter signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_COMMAND }; @@ -64,46 +64,47 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_pipefilter_debug, "pipefilter", 0, "pipefilter element"); -GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_pipefilter_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_pipefilter_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstData* gst_pipefilter_get (GstPad *pad); -static void gst_pipefilter_chain (GstPad *pad, GstData *_data); -static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event); +static GstData *gst_pipefilter_get (GstPad * pad); +static void gst_pipefilter_chain (GstPad * pad, GstData * _data); +static gboolean gst_pipefilter_handle_event (GstPad * pad, GstEvent * event); -static GstElementStateReturn gst_pipefilter_change_state (GstElement *element); +static GstElementStateReturn gst_pipefilter_change_state (GstElement * element); static void gst_pipefilter_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_pipefilter_details); } -static void -gst_pipefilter_class_init (GstPipefilterClass *klass) +static void +gst_pipefilter_class_init (GstPipefilterClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - gobject_class->set_property = gst_pipefilter_set_property; + gobject_class->set_property = gst_pipefilter_set_property; gobject_class->get_property = gst_pipefilter_get_property; - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND, - g_param_spec_string("command","command","command", - NULL, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */ gstelement_class->change_state = gst_pipefilter_change_state; } static void -gst_pipefilter_init (GstPipefilter *pipefilter) +gst_pipefilter_init (GstPipefilter * pipefilter) { GST_FLAG_SET (pipefilter, GST_ELEMENT_DECOUPLED); @@ -122,7 +123,7 @@ gst_pipefilter_init (GstPipefilter *pipefilter) } static gboolean -gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) +gst_pipefilter_handle_event (GstPad * pad, GstEvent * event) { GstPipefilter *pipefilter; @@ -133,9 +134,9 @@ gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: if (close (pipefilter->fdin[1]) < 0) - perror("close"); + perror ("close"); if (close (pipefilter->fdout[0]) < 0) - perror("close"); + perror ("close"); break; default: break; @@ -146,8 +147,8 @@ gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) return TRUE; } -static GstData* -gst_pipefilter_get (GstPad *pad) +static GstData * +gst_pipefilter_get (GstPad * pad) { GstPipefilter *pipefilter; GstBuffer *newbuf; @@ -157,16 +158,18 @@ gst_pipefilter_get (GstPad *pad) /* create the buffer */ /* FIXME: should eventually use a bufferpool for this */ - newbuf = gst_buffer_new(); - g_return_val_if_fail(newbuf, NULL); + newbuf = gst_buffer_new (); + g_return_val_if_fail (newbuf, NULL); /* allocate the space for the buffer data */ - GST_BUFFER_DATA(newbuf) = g_malloc(pipefilter->bytes_per_read); - g_return_val_if_fail(GST_BUFFER_DATA(newbuf) != NULL, NULL); + GST_BUFFER_DATA (newbuf) = g_malloc (pipefilter->bytes_per_read); + g_return_val_if_fail (GST_BUFFER_DATA (newbuf) != NULL, NULL); /* read it in from the file */ GST_DEBUG ("attemting to read %ld bytes", pipefilter->bytes_per_read); - readbytes = read(pipefilter->fdout[0], GST_BUFFER_DATA(newbuf), pipefilter->bytes_per_read); + readbytes = + read (pipefilter->fdout[0], GST_BUFFER_DATA (newbuf), + pipefilter->bytes_per_read); GST_DEBUG ("read %ld bytes", readbytes); if (readbytes < 0) { GST_ELEMENT_ERROR (pipefilter, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM); @@ -178,15 +181,15 @@ gst_pipefilter_get (GstPad *pad) } - GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset; - GST_BUFFER_SIZE(newbuf) = readbytes; + GST_BUFFER_OFFSET (newbuf) = pipefilter->curoffset; + GST_BUFFER_SIZE (newbuf) = readbytes; pipefilter->curoffset += readbytes; return GST_DATA (newbuf); } static void -gst_pipefilter_chain (GstPad *pad,GstData *_data) +gst_pipefilter_chain (GstPad * pad, GstData * _data) { GstBuffer *buf; GstPipefilter *pipefilter; @@ -194,8 +197,8 @@ gst_pipefilter_chain (GstPad *pad,GstData *_data) guchar *data; gulong size; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); if (GST_IS_EVENT (_data)) { gst_pipefilter_handle_event (pad, GST_EVENT (_data)); @@ -205,32 +208,33 @@ gst_pipefilter_chain (GstPad *pad,GstData *_data) pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad)); buf = GST_BUFFER (_data); - data = GST_BUFFER_DATA(buf); - size = GST_BUFFER_SIZE(buf); + data = GST_BUFFER_DATA (buf); + size = GST_BUFFER_SIZE (buf); GST_DEBUG ("attemting to write %ld bytes", size); - writebytes = write(pipefilter->fdin[1],data,size); + writebytes = write (pipefilter->fdin[1], data, size); GST_DEBUG ("written %ld bytes", writebytes); if (writebytes < 0) { GST_ELEMENT_ERROR (pipefilter, RESOURCE, WRITE, (NULL), GST_ERROR_SYSTEM); return; } - gst_buffer_unref(buf); + gst_buffer_unref (buf); } static void -gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_pipefilter_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstPipefilter *pipefilter; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_PIPEFILTER(object)); - pipefilter = GST_PIPEFILTER(object); + g_return_if_fail (GST_IS_PIPEFILTER (object)); + pipefilter = GST_PIPEFILTER (object); switch (prop_id) { case ARG_COMMAND: - pipefilter->orig_command = g_strdup(g_value_get_string (value)); - pipefilter->command = g_strsplit(g_value_get_string (value), " ", 0); + pipefilter->orig_command = g_strdup (g_value_get_string (value)); + pipefilter->command = g_strsplit (g_value_get_string (value), " ", 0); break; default: break; @@ -238,13 +242,14 @@ gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value } static void -gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_pipefilter_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstPipefilter *pipefilter; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_PIPEFILTER(object)); - pipefilter = GST_PIPEFILTER(object); + g_return_if_fail (GST_IS_PIPEFILTER (object)); + pipefilter = GST_PIPEFILTER (object); switch (prop_id) { case ARG_COMMAND: @@ -258,78 +263,75 @@ gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GPar /* open the file, necessary to go to RUNNING state */ static gboolean -gst_pipefilter_open_file (GstPipefilter *src) +gst_pipefilter_open_file (GstPipefilter * src) { - g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN), FALSE); - pipe(src->fdin); - pipe(src->fdout); + pipe (src->fdin); + pipe (src->fdout); - if((src->childpid = fork()) == -1) - { + if ((src->childpid = fork ()) == -1) { GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM); return FALSE; } - if(src->childpid == 0) - { - close(src->fdin[1]); - close(src->fdout[0]); + if (src->childpid == 0) { + close (src->fdin[1]); + close (src->fdout[0]); /* child */ - dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */ - dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */ - execvp(src->command[0], &src->command[0]); + dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */ + dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */ + execvp (src->command[0], &src->command[0]); /* will only be reached if execvp has an error */ GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM); return FALSE; - - } - else { - close(src->fdin[0]); - close(src->fdout[1]); + + } else { + close (src->fdin[0]); + close (src->fdout[1]); } - - GST_FLAG_SET(src,GST_PIPEFILTER_OPEN); + + GST_FLAG_SET (src, GST_PIPEFILTER_OPEN); return TRUE; } /* close the file */ static void -gst_pipefilter_close_file (GstPipefilter *src) +gst_pipefilter_close_file (GstPipefilter * src) { - g_return_if_fail(GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN)); + g_return_if_fail (GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN)); /* close the file */ - close(src->fdout[0]); - close(src->fdout[1]); - close(src->fdin[0]); - close(src->fdin[1]); + close (src->fdout[0]); + close (src->fdout[1]); + close (src->fdin[0]); + close (src->fdin[1]); /* zero out a lot of our state */ src->curoffset = 0; src->seq = 0; - GST_FLAG_UNSET(src,GST_PIPEFILTER_OPEN); + GST_FLAG_UNSET (src, GST_PIPEFILTER_OPEN); } static GstElementStateReturn -gst_pipefilter_change_state (GstElement *element) +gst_pipefilter_change_state (GstElement * element) { - g_return_val_if_fail(GST_IS_PIPEFILTER(element), FALSE); + g_return_val_if_fail (GST_IS_PIPEFILTER (element), FALSE); - /* if going down into NULL state, close the file if it's open */ - if (GST_STATE_PENDING(element) == GST_STATE_NULL) { - if (GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN)) - gst_pipefilter_close_file(GST_PIPEFILTER(element)); - /* otherwise (READY or higher) we need to open the file */ + /* if going down into NULL state, close the file if it's open */ + if (GST_STATE_PENDING (element) == GST_STATE_NULL) { + if (GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) + gst_pipefilter_close_file (GST_PIPEFILTER (element)); + /* otherwise (READY or higher) we need to open the file */ } else { - if (!GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN)) { - if (!gst_pipefilter_open_file(GST_PIPEFILTER(element))) - return GST_STATE_FAILURE; + if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) { + if (!gst_pipefilter_open_file (GST_PIPEFILTER (element))) + return GST_STATE_FAILURE; } } - - if (GST_ELEMENT_CLASS(parent_class)->change_state) - return GST_ELEMENT_CLASS(parent_class)->change_state(element); + + if (GST_ELEMENT_CLASS (parent_class)->change_state) + return GST_ELEMENT_CLASS (parent_class)->change_state (element); return GST_STATE_SUCCESS; } diff --git a/gst/elements/gstpipefilter.h b/gst/elements/gstpipefilter.h index 08c3a4718..73af81f78 100644 --- a/gst/elements/gstpipefilter.h +++ b/gst/elements/gstpipefilter.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_PIPEFILTER \ (gst_pipefilter_get_type()) #define GST_PIPEFILTER(obj) \ @@ -40,17 +38,18 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PIPEFILTER)) #define GST_IS_PIPEFILTER_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PIPEFILTER)) + typedef enum +{ + GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST, -typedef enum { - GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST, - - GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 + GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstPipeFilterFlags; typedef struct _GstPipefilter GstPipefilter; typedef struct _GstPipefilterClass GstPipefilterClass; -struct _GstPipefilter { +struct _GstPipefilter +{ GstElement element; GstPad *sinkpad; @@ -62,20 +61,20 @@ struct _GstPipefilter { /* fd */ gint fdout[2]; gint fdin[2]; - pid_t childpid; + pid_t childpid; - gulong curoffset; /* current offset in file */ - gulong bytes_per_read; /* bytes per read */ + gulong curoffset; /* current offset in file */ + gulong bytes_per_read; /* bytes per read */ - gulong seq; /* buffer sequence number */ + gulong seq; /* buffer sequence number */ }; -struct _GstPipefilterClass { +struct _GstPipefilterClass +{ GstElementClass parent_class; }; -GType gst_pipefilter_get_type(void); +GType gst_pipefilter_get_type (void); G_END_DECLS - #endif /* __GST_PIPEFILTER_H__ */ diff --git a/gst/elements/gstshaper.c b/gst/elements/gstshaper.c index 34301f1a6..afa1666bc 100644 --- a/gst/elements/gstshaper.c +++ b/gst/elements/gstshaper.c @@ -32,21 +32,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_shaper_debug); #define GST_CAT_DEFAULT gst_shaper_debug -GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS ( - "Shaper", - "Generic", - "Synchronizes streams on different pads", - "Wim Taymans " -); +GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS ("Shaper", + "Generic", + "Synchronizes streams on different pads", + "Wim Taymans "); /* Shaper signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_POLICY, ARG_SILENT, @@ -55,24 +55,20 @@ enum { typedef struct { - GstPad *sinkpad; - GstPad *srcpad; - GstBuffer *buffer; + GstPad *sinkpad; + GstPad *srcpad; + GstBuffer *buffer; } GstShaperConnection; -GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ( - "src%d", - GST_PAD_SRC, - GST_PAD_SOMETIMES, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS_ANY); -GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_SHAPER_POLICY (gst_shaper_policy_get_type()) static GType @@ -80,12 +76,13 @@ gst_shaper_policy_get_type (void) { static GType shaper_policy_type = 0; static GEnumValue shaper_policy[] = { - { SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"}, - { SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"}, + {SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"}, + {SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"}, {0, NULL, NULL}, }; if (!shaper_policy_type) { - shaper_policy_type = g_enum_register_static ("GstShaperPolicy", shaper_policy); + shaper_policy_type = + g_enum_register_static ("GstShaperPolicy", shaper_policy); } return shaper_policy_type; } @@ -93,24 +90,25 @@ gst_shaper_policy_get_type (void) #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_shaper_debug, "shaper", 0, "shaper element"); -GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_shaper_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_shaper_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_shaper_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_shaper_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstPad* gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, - const gchar *unused); +static GstPad *gst_shaper_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * unused); -static void gst_shaper_loop (GstElement *element); +static void gst_shaper_loop (GstElement * element); static void gst_shaper_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_shaper_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&shaper_src_template)); @@ -118,41 +116,43 @@ gst_shaper_base_init (gpointer g_class) gst_static_pad_template_get (&shaper_sink_template)); } -static void -gst_shaper_class_init (GstShaperClass *klass) +static void +gst_shaper_class_init (GstShaperClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*) klass; - gstelement_class = (GstElementClass*) klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY, - g_param_spec_enum ("policy", "Policy", "Shaper policy", - GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE)); + g_param_spec_enum ("policy", "Policy", "Shaper policy", + GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last-message", "last-message", "last-message", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last-message", "last-message", "last-message", + NULL, G_PARAM_READABLE)); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad); } -static GstCaps* -gst_shaper_getcaps (GstPad *pad) +static GstCaps * +gst_shaper_getcaps (GstPad * pad) { GstPad *otherpad; GstShaperConnection *connection; connection = gst_pad_get_element_private (pad); - otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); + otherpad = + (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); if (GST_PAD_PEER (otherpad)) { return gst_pad_get_caps (GST_PAD_PEER (otherpad)); @@ -161,8 +161,8 @@ gst_shaper_getcaps (GstPad *pad) } } -static GList* -gst_shaper_get_internal_link (GstPad *pad) +static GList * +gst_shaper_get_internal_link (GstPad * pad) { GList *res = NULL; GstShaperConnection *connection; @@ -170,7 +170,8 @@ gst_shaper_get_internal_link (GstPad *pad) connection = gst_pad_get_element_private (pad); - otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); + otherpad = + (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); res = g_list_prepend (res, otherpad); @@ -178,20 +179,21 @@ gst_shaper_get_internal_link (GstPad *pad) } static GstPadLinkReturn -gst_shaper_link (GstPad *pad, const GstCaps *caps) +gst_shaper_link (GstPad * pad, const GstCaps * caps) { GstPad *otherpad; GstShaperConnection *connection; connection = gst_pad_get_element_private (pad); - otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); + otherpad = + (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); return gst_pad_try_set_caps (otherpad, caps); } -static GstShaperConnection* -gst_shaper_create_connection (GstShaper *shaper) +static GstShaperConnection * +gst_shaper_create_connection (GstShaper * shaper) { GstShaperConnection *connection; gchar *padname; @@ -201,21 +203,25 @@ gst_shaper_create_connection (GstShaper *shaper) connection = g_new0 (GstShaperConnection, 1); padname = g_strdup_printf ("sink%d", shaper->nconnections); - connection->sinkpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&shaper_sink_template), padname); + connection->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&shaper_sink_template), padname); g_free (padname); gst_pad_set_getcaps_function (connection->sinkpad, gst_shaper_getcaps); - gst_pad_set_internal_link_function (connection->sinkpad, gst_shaper_get_internal_link); + gst_pad_set_internal_link_function (connection->sinkpad, + gst_shaper_get_internal_link); gst_pad_set_link_function (connection->sinkpad, gst_shaper_link); gst_pad_set_element_private (connection->sinkpad, connection); gst_element_add_pad (GST_ELEMENT (shaper), connection->sinkpad); padname = g_strdup_printf ("src%d", shaper->nconnections); - connection->srcpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&shaper_src_template), padname); + connection->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&shaper_src_template), padname); g_free (padname); gst_pad_set_getcaps_function (connection->srcpad, gst_shaper_getcaps); - gst_pad_set_internal_link_function (connection->srcpad, gst_shaper_get_internal_link); + gst_pad_set_internal_link_function (connection->srcpad, + gst_shaper_get_internal_link); gst_pad_set_link_function (connection->srcpad, gst_shaper_link); gst_pad_set_element_private (connection->srcpad, connection); gst_element_add_pad (GST_ELEMENT (shaper), connection->srcpad); @@ -225,8 +231,9 @@ gst_shaper_create_connection (GstShaper *shaper) return connection; } -static GstPad* -gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_shaper_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { GstShaper *shaper = GST_SHAPER (element); GstShaperConnection *connection; @@ -236,8 +243,8 @@ gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, const gc return connection->sinkpad; } -static void -gst_shaper_init (GstShaper *shaper) +static void +gst_shaper_init (GstShaper * shaper) { gst_element_set_loop_function (GST_ELEMENT (shaper), gst_shaper_loop); @@ -248,8 +255,8 @@ gst_shaper_init (GstShaper *shaper) shaper->last_message = NULL; } -static void -gst_shaper_loop (GstElement *element) +static void +gst_shaper_loop (GstElement * element) { GstShaper *shaper; GSList *connections; @@ -278,16 +285,15 @@ gst_shaper_loop (GstElement *element) gst_pad_push (connection->srcpad, GST_DATA (buffer)); switch (type) { - /* on EOS we disable the pad so that we don't pull on - * it again and never get more data */ - case GST_EVENT_EOS: + /* on EOS we disable the pad so that we don't pull on + * it again and never get more data */ + case GST_EVENT_EOS: gst_pad_set_active (connection->sinkpad, FALSE); break; default: break; } - } - else { + } else { /* we store the buffer */ connection->buffer = buffer; } @@ -295,9 +301,8 @@ gst_shaper_loop (GstElement *element) /* FIXME policy stuff goes here */ /* find connection with lowest timestamp */ if (min == NULL || (connection->buffer != NULL && - (GST_BUFFER_TIMESTAMP (connection->buffer) < - GST_BUFFER_TIMESTAMP (min->buffer)))) - { + (GST_BUFFER_TIMESTAMP (connection->buffer) < + GST_BUFFER_TIMESTAMP (min->buffer)))) { min = connection; } connections = g_slist_next (connections); @@ -309,20 +314,21 @@ gst_shaper_loop (GstElement *element) /* since we pushed a buffer, it's not EOS */ eos = FALSE; } - + if (eos) { gst_element_set_eos (element); } } -static void -gst_shaper_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_shaper_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstShaper *shaper; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_SHAPER (object)); - + shaper = GST_SHAPER (object); switch (prop_id) { @@ -338,12 +344,15 @@ gst_shaper_set_property (GObject *object, guint prop_id, const GValue *value, GP } } -static void gst_shaper_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { +static void +gst_shaper_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ GstShaper *shaper; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_SHAPER (object)); - + shaper = GST_SHAPER (object); switch (prop_id) { @@ -361,4 +370,3 @@ static void gst_shaper_get_property(GObject *object, guint prop_id, GValue *valu break; } } - diff --git a/gst/elements/gstshaper.h b/gst/elements/gstshaper.h index 2cbaf5336..07f1eb83c 100644 --- a/gst/elements/gstshaper.h +++ b/gst/elements/gstshaper.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_SHAPER \ (gst_shaper_get_type()) #define GST_SHAPER(obj) \ @@ -40,8 +38,8 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SHAPER)) #define GST_IS_SHAPER_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SHAPER)) - -typedef enum { + typedef enum +{ SHAPER_POLICY_TIMESTAMPS = 1, SHAPER_POLICY_BUFFERSIZE } GstShaperPolicyType; @@ -49,26 +47,27 @@ typedef enum { typedef struct _GstShaper GstShaper; typedef struct _GstShaperClass GstShaperClass; -struct _GstShaper { - GstElement element; +struct _GstShaper +{ + GstElement element; - GSList *connections; - gint nconnections; + GSList *connections; + gint nconnections; - GstShaperPolicyType policy; + GstShaperPolicyType policy; - gboolean silent; - gchar *last_message; + gboolean silent; + gchar *last_message; }; -struct _GstShaperClass { +struct _GstShaperClass +{ GstElementClass parent_class; }; -GType gst_shaper_get_type (void); -gboolean gst_shaper_factory_init (GstElementFactory *factory); +GType gst_shaper_get_type (void); +gboolean gst_shaper_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_SHAPER_H__ */ diff --git a/gst/elements/gststatistics.c b/gst/elements/gststatistics.c index 65e578b25..73f656fb3 100644 --- a/gst/elements/gststatistics.c +++ b/gst/elements/gststatistics.c @@ -30,21 +30,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_statistics_debug); #define GST_CAT_DEFAULT gst_statistics_debug -GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS ( - "Statistics", - "Generic", - "Statistics on buffers/bytes/events", - "David I. Lehn " -); +GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS ("Statistics", + "Generic", + "Statistics on buffers/bytes/events", + "David I. Lehn "); /* Statistics signals and args */ -enum { +enum +{ SIGNAL_UPDATE, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_BUFFERS, ARG_BYTES, @@ -61,14 +61,17 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_statistics_debug, "statistics", 0, "statistics element"); -GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_statistics_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_statistics_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_statistics_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_statistics_chain (GstPad *pad, GstData *_data); -static void gst_statistics_reset (GstStatistics *statistics); -static void gst_statistics_print (GstStatistics *statistics); +static void gst_statistics_chain (GstPad * pad, GstData * _data); +static void gst_statistics_reset (GstStatistics * statistics); +static void gst_statistics_print (GstStatistics * statistics); static guint gst_statistics_signals[LAST_SIGNAL] = { 0, }; @@ -79,71 +82,75 @@ static void gst_statistics_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_statistics_details); } -static void -gst_statistics_class_init (GstStatisticsClass *klass) +static void +gst_statistics_class_init (GstStatisticsClass * klass) { GObjectClass *gobject_class; - + gobject_class = G_OBJECT_CLASS (klass); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS, - g_param_spec_int64 ("buffers", "buffers", "total buffers count", - 0, G_MAXINT64, 0, G_PARAM_READABLE)); + g_param_spec_int64 ("buffers", "buffers", "total buffers count", + 0, G_MAXINT64, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES, - g_param_spec_int64 ("bytes", "bytes", "total bytes count", - 0, G_MAXINT64, 0, G_PARAM_READABLE)); + g_param_spec_int64 ("bytes", "bytes", "total bytes count", + 0, G_MAXINT64, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS, - g_param_spec_int64 ("events", "events", "total event count", - 0, G_MAXINT64, 0, G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFER_UPDATE_FREQ, - g_param_spec_int64 ("buffer_update_freq", "buffer update freq", "buffer update frequency", - 0, G_MAXINT64, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES_UPDATE_FREQ, - g_param_spec_int64 ("bytes_update_freq", "bytes update freq", "bytes update frequency", - 0, G_MAXINT64, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_UPDATE_FREQ, - g_param_spec_int64 ("event_update_freq", "event update freq", "event update frequency", - 0, G_MAXINT64, 0, G_PARAM_READWRITE)); + g_param_spec_int64 ("events", "events", "total event count", + 0, G_MAXINT64, 0, G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq", + "buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq", + "bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq", + "event update freq", "event update frequency", 0, G_MAXINT64, 0, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS, - g_param_spec_boolean ("update_on_eos", "update on EOS", "update on EOS event", - TRUE,G_PARAM_READWRITE)); + g_param_spec_boolean ("update_on_eos", "update on EOS", + "update on EOS event", TRUE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE, - g_param_spec_boolean ("update", "update", "update", - TRUE,G_PARAM_READWRITE)); + g_param_spec_boolean ("update", "update", "update", TRUE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - TRUE,G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", TRUE, + G_PARAM_READWRITE)); gst_statistics_signals[SIGNAL_UPDATE] = - g_signal_new ("update", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_statistics_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property); } -static void -gst_statistics_init (GstStatistics *statistics) +static void +gst_statistics_init (GstStatistics * statistics) { statistics->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (statistics), statistics->sinkpad); - gst_pad_set_chain_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_chain)); - + gst_pad_set_chain_function (statistics->sinkpad, + GST_DEBUG_FUNCPTR (gst_statistics_chain)); + statistics->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (statistics), statistics->srcpad); statistics->timer = NULL; statistics->last_timer = NULL; - gst_statistics_reset(statistics); + gst_statistics_reset (statistics); } static void -gst_statistics_reset (GstStatistics *statistics) +gst_statistics_reset (GstStatistics * statistics) { g_return_if_fail (statistics != NULL); g_return_if_fail (GST_IS_STATISTICS (statistics)); @@ -169,15 +176,16 @@ gst_statistics_reset (GstStatistics *statistics) statistics->silent = FALSE; if (!statistics->timer) { - statistics->timer = g_timer_new(); + statistics->timer = g_timer_new (); } if (!statistics->last_timer) { - statistics->last_timer = g_timer_new(); + statistics->last_timer = g_timer_new (); } } static void -print_stats(gboolean first, const gchar *name, const gchar *type, stats *base, stats *final, double time) +print_stats (gboolean first, const gchar * name, const gchar * type, + stats * base, stats * final, double time) { const gchar *header0 = "statistics"; const gchar *headerN = " "; @@ -187,25 +195,21 @@ print_stats(gboolean first, const gchar *name, const gchar *type, stats *base, s delta.bytes = final->bytes - base->bytes; delta.events = final->events - base->events; - g_print("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT - " bytes:%" G_GINT64_FORMAT - " events:%" G_GINT64_FORMAT "\n", - first ? header0 : headerN, - name, type, time, - final->buffers, - final->bytes, - final->events); - g_print("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n", - headerN, - name, type, - delta.buffers/time, - delta.bytes/time, - delta.events/time, - ((double)delta.bytes/(double)delta.buffers)); + g_print ("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT + " bytes:%" G_GINT64_FORMAT + " events:%" G_GINT64_FORMAT "\n", + first ? header0 : headerN, + name, type, time, final->buffers, final->bytes, final->events); + g_print ("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n", + headerN, + name, type, + delta.buffers / time, + delta.bytes / time, + delta.events / time, ((double) delta.bytes / (double) delta.buffers)); } static void -gst_statistics_print (GstStatistics *statistics) +gst_statistics_print (GstStatistics * statistics) { const gchar *name; double elapsed; @@ -214,22 +218,23 @@ gst_statistics_print (GstStatistics *statistics) g_return_if_fail (statistics != NULL); g_return_if_fail (GST_IS_STATISTICS (statistics)); - name = gst_object_get_name(GST_OBJECT(statistics)); + name = gst_object_get_name (GST_OBJECT (statistics)); if (!name) { name = ""; } - elapsed = g_timer_elapsed(statistics->timer, NULL); - last_elapsed = g_timer_elapsed(statistics->last_timer, NULL); + elapsed = g_timer_elapsed (statistics->timer, NULL); + last_elapsed = g_timer_elapsed (statistics->last_timer, NULL); - print_stats(1, name, "total", &zero_stats, &statistics->stats, elapsed); - print_stats(0, name, "last", &statistics->last_stats, &statistics->stats, last_elapsed); + print_stats (1, name, "total", &zero_stats, &statistics->stats, elapsed); + print_stats (0, name, "last", &statistics->last_stats, &statistics->stats, + last_elapsed); statistics->last_stats = statistics->stats; - g_timer_reset(statistics->last_timer); + g_timer_reset (statistics->last_timer); } -static void -gst_statistics_chain (GstPad *pad, GstData *_data) +static void +gst_statistics_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstStatistics *statistics; @@ -241,20 +246,21 @@ gst_statistics_chain (GstPad *pad, GstData *_data) statistics = GST_STATISTICS (gst_pad_get_parent (pad)); - if (GST_IS_EVENT(buf)) { + if (GST_IS_EVENT (buf)) { GstEvent *event = GST_EVENT (buf); + statistics->stats.events += 1; - if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) { + if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { gst_element_set_eos (GST_ELEMENT (statistics)); if (statistics->update_on_eos) { - update = TRUE; + update = TRUE; } } if (statistics->update_freq.events) { statistics->update_count.events += 1; if (statistics->update_count.events == statistics->update_freq.events) { - statistics->update_count.events = 0; - update = TRUE; + statistics->update_count.events = 0; + update = TRUE; } } } else { @@ -262,17 +268,17 @@ gst_statistics_chain (GstPad *pad, GstData *_data) if (statistics->update_freq.buffers) { statistics->update_count.buffers += 1; if (statistics->update_count.buffers == statistics->update_freq.buffers) { - statistics->update_count.buffers = 0; - update = TRUE; + statistics->update_count.buffers = 0; + update = TRUE; } } - statistics->stats.bytes += GST_BUFFER_SIZE(buf); + statistics->stats.bytes += GST_BUFFER_SIZE (buf); if (statistics->update_freq.bytes) { - statistics->update_count.bytes += GST_BUFFER_SIZE(buf); + statistics->update_count.bytes += GST_BUFFER_SIZE (buf); if (statistics->update_count.bytes >= statistics->update_freq.bytes) { - statistics->update_count.bytes = 0; - update = TRUE; + statistics->update_count.bytes = 0; + update = TRUE; } } } @@ -280,24 +286,26 @@ gst_statistics_chain (GstPad *pad, GstData *_data) if (update) { if (statistics->update) { GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics)); - g_signal_emit (G_OBJECT (statistics), gst_statistics_signals[SIGNAL_UPDATE], 0); + g_signal_emit (G_OBJECT (statistics), + gst_statistics_signals[SIGNAL_UPDATE], 0); GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics)); } if (!statistics->silent) { - gst_statistics_print(statistics); + gst_statistics_print (statistics); } } gst_pad_push (statistics->srcpad, GST_DATA (buf)); } -static void -gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_statistics_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstStatistics *statistics; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_STATISTICS (object)); - + statistics = GST_STATISTICS (object); switch (prop_id) { @@ -325,12 +333,15 @@ gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value } } -static void gst_statistics_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { +static void +gst_statistics_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ GstStatistics *statistics; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_STATISTICS (object)); - + statistics = GST_STATISTICS (object); switch (prop_id) { diff --git a/gst/elements/gststatistics.h b/gst/elements/gststatistics.h index 4c1ab57a3..72ad4d1e6 100644 --- a/gst/elements/gststatistics.h +++ b/gst/elements/gststatistics.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_STATISTICS \ (gst_statistics_get_type()) #define GST_STATISTICS(obj) \ @@ -39,19 +37,20 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_STATISTICS)) #define GST_IS_STATISTICS_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STATISTICS)) - typedef struct _GstStatistics GstStatistics; typedef struct _GstStatisticsClass GstStatisticsClass; typedef struct _stats stats; -struct _stats { +struct _stats +{ gint64 buffers; gint64 bytes; gint64 events; }; -struct _GstStatistics { +struct _GstStatistics +{ GstElement element; GstPad *sinkpad; @@ -65,20 +64,20 @@ struct _GstStatistics { stats update_count; stats update_freq; - gboolean update_on_eos; + gboolean update_on_eos; gboolean update; gboolean silent; }; -struct _GstStatisticsClass { +struct _GstStatisticsClass +{ GstElementClass parent_class; /* signals */ - void (*update) (GstElement *element); + void (*update) (GstElement * element); }; -GType gst_statistics_get_type(void); +GType gst_statistics_get_type (void); G_END_DECLS - #endif /* __GST_STATISTICS_H__ */ diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index 0fc41588b..310a587e1 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -31,21 +31,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_tee_debug); #define GST_CAT_DEFAULT gst_tee_debug -GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS ( - "Tee pipe fitting", - "Generic", - "1-to-N pipe fitting", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS ("Tee pipe fitting", + "Generic", + "1-to-N pipe fitting", + "Erik Walthinsen , " + "Wim Taymans "); /* Tee signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_SILENT, ARG_NUM_PADS, @@ -53,89 +53,93 @@ enum { /* FILL ME */ }; -GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ( - "src%d", - GST_PAD_SRC, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_tee_debug, "tee", 0, "tee element"); GST_BOILERPLATE_FULL (GstTee, gst_tee, GstElement, GST_TYPE_ELEMENT, _do_init); -static GstPad* gst_tee_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *unused); +static GstPad *gst_tee_request_new_pad (GstElement * element, + GstPadTemplate * temp, const gchar * unused); -static void gst_tee_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_tee_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_tee_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_tee_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_tee_chain (GstPad *pad, GstData *_data); +static void gst_tee_chain (GstPad * pad, GstData * _data); static void gst_tee_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_tee_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&tee_src_template)); } static void -gst_tee_class_init (GstTeeClass *klass) +gst_tee_class_init (GstTeeClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, - g_param_spec_int ("num_pads", "num_pads", "num_pads", - 0, G_MAXINT, 0, G_PARAM_READABLE)); + g_param_spec_int ("num_pads", "num_pads", "num_pads", + 0, G_MAXINT, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", + TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last_message", "last_message", "last_message", - NULL, G_PARAM_READABLE)); - + g_param_spec_string ("last_message", "last_message", "last_message", + NULL, G_PARAM_READABLE)); + - gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_tee_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_tee_get_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_tee_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_tee_request_new_pad); } -static void -gst_tee_init (GstTee *tee) +static void +gst_tee_init (GstTee * tee) { tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain)); - gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); - gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); + gst_pad_set_link_function (tee->sinkpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); + gst_pad_set_getcaps_function (tee->sinkpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); tee->last_message = NULL; } /* helper compare function */ -gint name_pad_compare (gconstpointer a, gconstpointer b) +gint +name_pad_compare (gconstpointer a, gconstpointer b) { - GstPad* pad = (GstPad*) a; + GstPad *pad = (GstPad *) a; gchar *name = (gchar *) b; - + g_assert (GST_IS_PAD (pad)); - return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */ + return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */ } -static GstPad* -gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *srcpad; @@ -144,7 +148,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar const GList *pads; g_return_val_if_fail (GST_IS_TEE (element), NULL); - + if (templ->direction != GST_PAD_SRC) { g_warning ("gsttee: request new pad that is not a SRC pad\n"); return NULL; @@ -154,13 +158,12 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar /* try names in order and find one that's not in use atm */ pads = gst_element_get_pad_list (element); - + name = NULL; - while (!name) - { + while (!name) { name = g_strdup_printf ("src%d", i); - if (g_list_find_custom ((GList *)pads, (gconstpointer) name, name_pad_compare) != NULL) - { + if (g_list_find_custom ((GList *) pads, (gconstpointer) name, + name_pad_compare) != NULL) { /* this name is taken, use the next one */ ++i; g_free (name); @@ -172,11 +175,13 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar tee->last_message = g_strdup_printf ("new pad %s", name); g_object_notify (G_OBJECT (tee), "last_message"); } - + srcpad = gst_pad_new_from_template (templ, name); g_free (name); - gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); - gst_pad_set_getcaps_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); + gst_pad_set_link_function (srcpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); + gst_pad_set_getcaps_function (srcpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); gst_element_add_pad (GST_ELEMENT (tee), srcpad); GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL; @@ -188,7 +193,8 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar } static void -gst_tee_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_tee_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstTee *tee; @@ -209,7 +215,8 @@ gst_tee_set_property (GObject *object, guint prop_id, const GValue *value, GPara } static void -gst_tee_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_tee_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstTee *tee; @@ -241,8 +248,8 @@ gst_tee_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec * * Chain a buffer on a pad. */ -static void -gst_tee_chain (GstPad *pad, GstData *_data) +static void +gst_tee_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstTee *tee; @@ -255,11 +262,12 @@ gst_tee_chain (GstPad *pad, GstData *_data) tee = GST_TEE (gst_pad_get_parent (pad)); gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads - 1); - + pads = gst_element_get_pad_list (GST_ELEMENT (tee)); while (pads) { GstPad *outpad = GST_PAD (pads->data); + pads = g_list_next (pads); if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC) @@ -267,9 +275,10 @@ gst_tee_chain (GstPad *pad, GstData *_data) if (!tee->silent) { g_free (tee->last_message); - tee->last_message = g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %" - G_GUINT64_FORMAT ") %p", - GST_DEBUG_PAD_NAME (outpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); + tee->last_message = + g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %" + G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); g_object_notify (G_OBJECT (tee), "last_message"); } @@ -279,4 +288,3 @@ gst_tee_chain (GstPad *pad, GstData *_data) gst_buffer_unref (buf); } } - diff --git a/gst/elements/gsttee.h b/gst/elements/gsttee.h index b58a6c031..aa6279428 100644 --- a/gst/elements/gsttee.h +++ b/gst/elements/gsttee.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_TEE \ (gst_tee_get_type()) #define GST_TEE(obj) \ @@ -39,27 +37,27 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEE)) #define GST_IS_TEE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEE)) +typedef struct _GstTee GstTee; +typedef struct _GstTeeClass GstTeeClass; -typedef struct _GstTee GstTee; -typedef struct _GstTeeClass GstTeeClass; - -struct _GstTee { +struct _GstTee +{ GstElement element; GstPad *sinkpad; gboolean silent; - gchar *last_message; + gchar *last_message; }; -struct _GstTeeClass { +struct _GstTeeClass +{ GstElementClass parent_class; }; -GType gst_tee_get_type (void); +GType gst_tee_get_type (void); -gboolean gst_tee_factory_init (GstElementFactory *factory); +gboolean gst_tee_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_TEE_H__ */ diff --git a/gst/elements/gsttypefind.c b/gst/elements/gsttypefind.c index dc76baac9..0e70b9889 100644 --- a/gst/elements/gsttypefind.c +++ b/gst/elements/gsttypefind.c @@ -49,42 +49,42 @@ GST_DEBUG_CATEGORY_STATIC (gst_type_find_element_debug); #define GST_CAT_DEFAULT gst_type_find_element_debug -GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS ( - "TypeFind", - "Generic", - "Finds the media type of a stream", - "Benjamin Otte " -); +GstElementDetails gst_type_find_element_details = +GST_ELEMENT_DETAILS ("TypeFind", + "Generic", + "Finds the media type of a stream", + "Benjamin Otte "); /* generic templates */ -GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); - -GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate type_find_element_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate type_find_element_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); /* TypeFind signals and args */ -enum { +enum +{ HAVE_TYPE, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_CAPS, ARG_MINIMUM, ARG_MAXIMUM }; -enum { - MODE_NORMAL, /* act as identity */ - MODE_TYPEFIND, /* do typefinding */ +enum +{ + MODE_NORMAL, /* act as identity */ + MODE_TYPEFIND, /* do typefinding */ }; @@ -92,32 +92,28 @@ enum { GST_DEBUG_CATEGORY_INIT (gst_type_find_element_debug, "typefind", \ GST_DEBUG_BG_YELLOW | GST_DEBUG_FG_GREEN, "type finding element"); -GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_type_find_element_dispose (GObject * object); -static void gst_type_find_element_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); -static void gst_type_find_element_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); +static void gst_type_find_element_dispose (GObject * object); +static void gst_type_find_element_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void gst_type_find_element_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); -static const GstEventMask * - gst_type_find_element_src_event_mask (GstPad * pad); -static gboolean gst_type_find_element_src_event (GstPad * pad, - GstEvent * event); +static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad); +static gboolean gst_type_find_element_src_event (GstPad * pad, + GstEvent * event); -static void gst_type_find_element_chain (GstPad * sinkpad, - GstData * data); +static void gst_type_find_element_chain (GstPad * sinkpad, GstData * data); static GstElementStateReturn - gst_type_find_element_change_state (GstElement * element); +gst_type_find_element_change_state (GstElement * element); static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 }; static void -gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) +gst_type_find_element_have_type (GstTypeFindElement * typefind, + guint probability, const GstCaps * caps) { g_assert (typefind->caps == NULL); g_assert (caps != NULL); @@ -130,53 +126,62 @@ static void gst_type_find_element_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_set_details (gstelement_class, &gst_type_find_element_details); + + gst_element_class_set_details (gstelement_class, + &gst_type_find_element_details); } static void -gst_type_find_element_class_init (GstTypeFindElementClass *typefind_class) +gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (typefind_class); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (typefind_class); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_type_find_element_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_type_find_element_get_property); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose); + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_type_find_element_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_type_find_element_get_property); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose); typefind_class->have_type = gst_type_find_element_have_type; g_object_class_install_property (gobject_class, ARG_CAPS, - g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"), - gst_caps_get_type(), G_PARAM_READABLE)); + g_param_spec_boxed ("caps", _("caps"), + _("detected capabilities in stream"), gst_caps_get_type (), + G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_MINIMUM, - g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps", - GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE)); + g_param_spec_uint ("minimum", _("minimum"), + "minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM, + GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MINIMUM, - g_param_spec_uint ("maximum", _("maximum"), "probability to stop typefinding", - GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE)); - - gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", - G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, - gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, - G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE); - - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); + g_param_spec_uint ("maximum", _("maximum"), + "probability to stop typefinding", GST_TYPE_FIND_MINIMUM, + GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE)); + + gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", + G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, + gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, + G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE); + + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); } static void -gst_type_find_element_init (GstTypeFindElement *typefind) +gst_type_find_element_init (GstTypeFindElement * typefind) { /* sinkpad */ - typefind->sink = gst_pad_new_from_template ( - gst_static_pad_template_get (&type_find_element_sink_template), "sink"); - gst_pad_set_chain_function (typefind->sink, - gst_type_find_element_chain); + typefind->sink = + gst_pad_new_from_template (gst_static_pad_template_get + (&type_find_element_sink_template), "sink"); + gst_pad_set_chain_function (typefind->sink, gst_type_find_element_chain); gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink); /* srcpad */ - typefind->src = gst_pad_new_from_template ( - gst_static_pad_template_get (&type_find_element_src_template), "src"); + typefind->src = + gst_pad_new_from_template (gst_static_pad_template_get + (&type_find_element_src_template), "src"); gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event); - gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask); + gst_pad_set_event_mask_function (typefind->src, + gst_type_find_element_src_event_mask); gst_pad_use_explicit_caps (typefind->src); gst_element_add_pad (GST_ELEMENT (typefind), typefind->src); @@ -189,7 +194,7 @@ gst_type_find_element_init (GstTypeFindElement *typefind) GST_FLAG_SET (typefind, GST_ELEMENT_EVENT_AWARE); } static void -gst_type_find_element_dispose (GObject *object) +gst_type_find_element_dispose (GObject * object) { GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (object); @@ -201,8 +206,8 @@ gst_type_find_element_dispose (GObject *object) } } static void -gst_type_find_element_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_type_find_element_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstTypeFindElement *typefind; @@ -225,8 +230,8 @@ gst_type_find_element_set_property (GObject *object, guint prop_id, } } static void -gst_type_find_element_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +gst_type_find_element_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstTypeFindElement *typefind; @@ -250,18 +255,21 @@ gst_type_find_element_get_property (GObject *object, guint prop_id, } } static const GstEventMask * -gst_type_find_element_src_event_mask (GstPad *pad) +gst_type_find_element_src_event_mask (GstPad * pad) { static const GstEventMask mask[] = { - { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH}, + {GST_EVENT_SEEK, + GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | + GST_SEEK_FLAG_FLUSH}, /* add more if you want, event masks suck and need to die anyway */ - { 0, } + {0,} }; - + return mask; } -static gboolean -gst_type_find_element_src_event (GstPad *pad, GstEvent *event) + +static gboolean +gst_type_find_element_src_event (GstPad * pad, GstEvent * event) { GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); @@ -272,15 +280,16 @@ gst_type_find_element_src_event (GstPad *pad, GstEvent *event) } return gst_pad_event_default (pad, event); } -typedef struct { - GstTypeFindFactory * factory; - gint probability; - GstCaps * caps; - gint64 requested_offset; - guint requested_size; - - GList * buffers; - GstTypeFindElement * self; +typedef struct +{ + GstTypeFindFactory *factory; + gint probability; + GstCaps *caps; + gint64 requested_offset; + guint requested_size; + + GList *buffers; + GstTypeFindElement *self; } TypeFindEntry; static inline TypeFindEntry * @@ -289,42 +298,45 @@ new_entry (void) return g_new0 (TypeFindEntry, 1); } static void -free_entry_buffers (TypeFindEntry *entry) +free_entry_buffers (TypeFindEntry * entry) { g_list_foreach (entry->buffers, (GFunc) gst_data_unref, NULL); g_list_free (entry->buffers); entry->buffers = NULL; } static void -free_entry (TypeFindEntry *entry) +free_entry (TypeFindEntry * entry) { free_entry_buffers (entry); - + if (entry->caps) gst_caps_free (entry->caps); g_free (entry); } static void -start_typefinding (GstTypeFindElement *typefind) +start_typefinding (GstTypeFindElement * typefind) { g_assert (typefind->caps == NULL); g_assert (typefind->possibilities == NULL); - + GST_DEBUG_OBJECT (typefind, "starting typefinding"); - typefind->mode = MODE_TYPEFIND; - typefind->stream_length_available = TRUE; - typefind->stream_length = 0; + typefind->mode = MODE_TYPEFIND; + typefind->stream_length_available = TRUE; + typefind->stream_length = 0; } static void -stop_typefinding (GstTypeFindElement *typefind) +stop_typefinding (GstTypeFindElement * typefind) { /* stop all typefinding and set mode back to normal */ - gboolean push_cached_buffers = gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING; - - GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : ""); + gboolean push_cached_buffers = + gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING; + + GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", + push_cached_buffers ? " and pushing cached buffers" : ""); if (typefind->possibilities != NULL) { /* this should only happen on PAUSED => READY or EOS */ - GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities)); + GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", + g_list_length (typefind->possibilities)); g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL); g_list_free (typefind->possibilities); typefind->possibilities = NULL; @@ -336,51 +348,59 @@ stop_typefinding (GstTypeFindElement *typefind) GstBuffer *buffer; guint size = gst_buffer_store_get_size (typefind->store, 0); - if (size && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) { + if (size + && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) { GST_LOG_OBJECT (typefind, "pushing cached data (%u bytes)", size); gst_pad_push (typefind->src, GST_DATA (buffer)); } else { size = 0; } GST_LOG_OBJECT (typefind, "seeking back to current position %u", size); - if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink), - gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, size))) { - GST_WARNING_OBJECT (typefind, "could not seek to required position %u, hope for the best", size); + if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink), + gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, + size))) { + GST_WARNING_OBJECT (typefind, + "could not seek to required position %u, hope for the best", size); } } gst_buffer_store_clear (typefind->store); } + static guint64 find_element_get_length (gpointer data) { TypeFindEntry *entry = (TypeFindEntry *) data; GstTypeFindElement *typefind = entry->self; GstFormat format = GST_FORMAT_BYTES; - + if (!typefind->stream_length_available) { - GST_LOG_OBJECT (entry->self, "'%s' called get_length () but we know it's not available", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_LOG_OBJECT (entry->self, + "'%s' called get_length () but we know it's not available", + GST_PLUGIN_FEATURE_NAME (entry->factory)); return 0; } if (entry->self->stream_length == 0) { - typefind->stream_length_available = gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL, - &format, &entry->self->stream_length); + typefind->stream_length_available = + gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL, + &format, &entry->self->stream_length); if (format != GST_FORMAT_BYTES) typefind->stream_length_available = FALSE; if (!typefind->stream_length_available) { - GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () but it's not available", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_DEBUG_OBJECT (entry->self, + "'%s' called get_length () but it's not available", + GST_PLUGIN_FEATURE_NAME (entry->factory)); return 0; } else { - GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () and it's %"G_GUINT64_FORMAT" bytes", - GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length); + GST_DEBUG_OBJECT (entry->self, + "'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes", + GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length); } } - + return entry->self->stream_length; } static void -gst_type_find_element_handle_event (GstPad *pad, GstEvent *event) +gst_type_find_element_handle_event (GstPad * pad, GstEvent * event) { TypeFindEntry *entry; GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); @@ -388,20 +408,24 @@ gst_type_find_element_handle_event (GstPad *pad, GstEvent *event) if (typefind->mode == MODE_TYPEFIND) { /* need to do more? */ switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_EOS: - /* this should only happen when we got all available data */ - entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL; - if (entry && entry->probability >= typefind->min_probability) { - GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)", - GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); - g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps); - } - stop_typefinding (typefind); - gst_pad_event_default (pad, event); - break; - default: - gst_data_unref (GST_DATA (event)); - break; + case GST_EVENT_EOS: + /* this should only happen when we got all available data */ + entry = + (TypeFindEntry *) typefind->possibilities ? typefind-> + possibilities->data : NULL; + if (entry && entry->probability >= typefind->min_probability) { + GST_INFO_OBJECT (typefind, + "'%s' is the best typefind left after we got all data, using it now (probability %u)", + GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); + g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, + entry->probability, entry->caps); + } + stop_typefinding (typefind); + gst_pad_event_default (pad, event); + break; + default: + gst_data_unref (GST_DATA (event)); + break; } } else { gst_pad_event_default (pad, event); @@ -412,9 +436,9 @@ find_peek (gpointer data, gint64 offset, guint size) { GstBuffer *buf; TypeFindEntry *entry = (TypeFindEntry *) data; - - GST_LOG_OBJECT (entry->self, "'%s' called peek (%"G_GINT64_FORMAT", %u)", - GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size); + + GST_LOG_OBJECT (entry->self, "'%s' called peek (%" G_GINT64_FORMAT ", %u)", + GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size); if (offset >= 0) { buf = gst_buffer_store_get_buffer (entry->self->store, offset, size); } else { @@ -424,7 +448,9 @@ find_peek (gpointer data, gint64 offset, guint size) if (length == 0) { buf = NULL; } else { - buf = gst_buffer_store_get_buffer (entry->self->store, length + offset, size); + buf = + gst_buffer_store_get_buffer (entry->self->store, length + offset, + size); } } @@ -433,8 +459,9 @@ find_peek (gpointer data, gint64 offset, guint size) return GST_BUFFER_DATA (buf); } else { if (entry->requested_size == 0) { - GST_LOG_OBJECT (entry->self, "setting requested peek (%"G_GINT64_FORMAT", %u) on '%s'", - offset, size, GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_LOG_OBJECT (entry->self, + "setting requested peek (%" G_GINT64_FORMAT ", %u) on '%s'", offset, + size, GST_PLUGIN_FEATURE_NAME (entry->factory)); entry->requested_offset = offset; entry->requested_size = size; } @@ -442,12 +469,12 @@ find_peek (gpointer data, gint64 offset, guint size) } } static void -find_suggest (gpointer data, guint probability, const GstCaps *caps) +find_suggest (gpointer data, guint probability, const GstCaps * caps) { TypeFindEntry *entry = (TypeFindEntry *) data; - - GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", - GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps); + + GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", + GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps); if (((gint) probability) > entry->probability) { entry->probability = probability; gst_caps_replace (&entry->caps, gst_caps_copy (caps)); @@ -472,13 +499,13 @@ compare_type_find_factory (gconstpointer fac1, gconstpointer fac2) return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank; } static void -gst_type_find_element_chain (GstPad *pad, GstData *data) +gst_type_find_element_chain (GstPad * pad, GstData * data) { GstTypeFindElement *typefind; GList *entries; TypeFindEntry *entry; GList *walk; - GstTypeFind find = {find_peek, find_suggest, NULL, find_element_get_length }; + GstTypeFind find = { find_peek, find_suggest, NULL, find_element_get_length }; typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); if (GST_IS_EVENT (data)) { @@ -489,36 +516,39 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) case MODE_NORMAL: gst_pad_push (typefind->src, data); return; - case MODE_TYPEFIND: { + case MODE_TYPEFIND:{ guint64 current_offset; - + gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data)); - current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? - GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : + current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? + GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : gst_buffer_store_get_size (typefind->store, 0); gst_data_unref (data); if (typefind->possibilities == NULL) { /* not yet started, get all typefinding functions into our "queue" */ GList *all_factories = gst_type_find_factory_get_list (); - GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", - g_list_length ((GList *) all_factories)); - + + GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", + g_list_length ((GList *) all_factories)); + all_factories = g_list_sort (all_factories, compare_type_find_factory); walk = all_factories; while (all_factories) { entry = new_entry (); - + entry->factory = GST_TYPE_FIND_FACTORY (all_factories->data); entry->self = typefind; entry->probability = 0; - typefind->possibilities = g_list_prepend (typefind->possibilities, entry); + typefind->possibilities = + g_list_prepend (typefind->possibilities, entry); all_factories = g_list_next (all_factories); } g_list_free (all_factories); } /* call every typefind function once */ walk = entries = typefind->possibilities; - GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", g_list_length (entries)); + GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", + g_list_length (entries)); typefind->possibilities = NULL; while (walk) { find.data = entry = (TypeFindEntry *) walk->data; @@ -529,16 +559,19 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gst_type_find_factory_call_function (entry->factory, &find); free_entry_buffers (entry); if (entry->probability == 0 && entry->requested_size == 0) { - GST_DEBUG_OBJECT (typefind, "'%s' was removed - no chance of being the right plugin", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_DEBUG_OBJECT (typefind, + "'%s' was removed - no chance of being the right plugin", + GST_PLUGIN_FEATURE_NAME (entry->factory)); free_entry (entry); } else if (entry->probability >= typefind->max_probability) { /* wooha, got caps */ GstCaps *found_caps = entry->caps; guint probability = entry->probability; - - GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW", - GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability); + + GST_INFO_OBJECT (typefind, + "'%s' returned %u/%u probability, using it NOW", + GST_PLUGIN_FEATURE_NAME (entry->factory), probability, + typefind->max_probability); while (walk) { free_entry ((TypeFindEntry *) walk->data); walk = g_list_next (walk); @@ -549,11 +582,13 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) walk = g_list_next (walk); } typefind->possibilities = NULL; - g_list_free (typefind->possibilities); - g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps); + g_list_free (typefind->possibilities); + g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, + probability, found_caps); free_entry (entry); } else { - typefind->possibilities = g_list_prepend (typefind->possibilities, entry); + typefind->possibilities = + g_list_prepend (typefind->possibilities, entry); } } g_list_free (entries); @@ -564,8 +599,9 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL)); } else { /* set up typefind element for next iteration */ - typefind->possibilities = g_list_sort (typefind->possibilities, compare_type_find_entry); - + typefind->possibilities = + g_list_sort (typefind->possibilities, compare_type_find_entry); + /* look for typefind functions that require data without seeking */ for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) { entry = (TypeFindEntry *) walk->data; @@ -582,19 +618,27 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gint64 seek_offset; GstEvent *event; - seek_offset = entry->requested_offset > 0 ? entry->requested_offset : - find_element_get_length (entry) + entry->requested_offset; - seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset); - event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset); + seek_offset = + entry->requested_offset > + 0 ? entry-> + requested_offset : find_element_get_length (entry) + + entry->requested_offset; + seek_offset += + gst_buffer_store_get_size (typefind->store, seek_offset); + event = + gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, + seek_offset); if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) { /* done seeking */ - GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT, - GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); + GST_DEBUG_OBJECT (typefind, + "'%s' was reset - seeked to %" G_GINT64_FORMAT, + GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); break; } else if (entry->requested_offset < 0) { /* impossible to seek */ - GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT, - GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); + GST_DEBUG_OBJECT (typefind, + "'%s' was reset - couldn't seek to %" G_GINT64_FORMAT, + GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); entry->requested_size = 0; entry->requested_offset = 0; } @@ -605,21 +649,26 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) walk = g_list_next (typefind->possibilities); while (walk) { GList *cur = walk; + entry = (TypeFindEntry *) walk->data; walk = g_list_next (walk); if (entry->requested_size == 0) { - GST_DEBUG_OBJECT (typefind, "'%s' was removed - higher possibilities available", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_DEBUG_OBJECT (typefind, + "'%s' was removed - higher possibilities available", + GST_PLUGIN_FEATURE_NAME (entry->factory)); free_entry (entry); - typefind->possibilities = g_list_delete_link (typefind->possibilities, cur); + typefind->possibilities = + g_list_delete_link (typefind->possibilities, cur); } } if (g_list_next (typefind->possibilities) == NULL) { entry = (TypeFindEntry *) typefind->possibilities->data; if (entry->probability > typefind->min_probability) { - GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)", - GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); - g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps); + GST_INFO_OBJECT (typefind, + "'%s' is the only typefind left, using it now (probability %u)", + GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); + g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], + 0, entry->probability, entry->caps); free_entry (entry); g_list_free (typefind->possibilities); typefind->possibilities = NULL; @@ -635,7 +684,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) } } static GstElementStateReturn -gst_type_find_element_change_state (GstElement *element) +gst_type_find_element_change_state (GstElement * element) { GstTypeFindElement *typefind; @@ -652,6 +701,6 @@ gst_type_find_element_change_state (GstElement *element) default: break; } - + return GST_ELEMENT_CLASS (parent_class)->change_state (element); } diff --git a/gst/elements/gsttypefind.h b/gst/elements/gsttypefind.h index 03eeccdcb..f2d8c7123 100644 --- a/gst/elements/gsttypefind.h +++ b/gst/elements/gsttypefind.h @@ -29,48 +29,44 @@ #include "gstbufferstore.h" G_BEGIN_DECLS - - - #define GST_TYPE_TYPE_FIND_ELEMENT (gst_type_find_element_get_type ()) #define GST_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElement)) #define GST_IS_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_ELEMENT)) #define GST_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass)) #define GST_IS_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_ELEMENT)) #define GST_TYPE_FIND_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass)) +typedef struct _GstTypeFindElement GstTypeFindElement; +typedef struct _GstTypeFindElementClass GstTypeFindElementClass; -typedef struct _GstTypeFindElement GstTypeFindElement; -typedef struct _GstTypeFindElementClass GstTypeFindElementClass; +struct _GstTypeFindElement +{ + GstElement element; -struct _GstTypeFindElement { - GstElement element; + GstPad *sink; + GstPad *src; - GstPad * sink; - GstPad * src; + guint min_probability; + guint max_probability; + GstCaps *caps; - guint min_probability; - guint max_probability; - GstCaps * caps; + guint mode; + GstBufferStore *store; + guint64 stream_length; + gboolean stream_length_available; - guint mode; - GstBufferStore * store; - guint64 stream_length; - gboolean stream_length_available; - - GList * possibilities; + GList *possibilities; }; -struct _GstTypeFindElementClass { - GstElementClass parent_class; +struct _GstTypeFindElementClass +{ + GstElementClass parent_class; /* signals */ - void (*have_type) (GstTypeFindElement *element, - guint probability, - const GstCaps * caps); + void (*have_type) (GstTypeFindElement * element, + guint probability, const GstCaps * caps); }; GType gst_type_find_element_get_type (void); G_END_DECLS - #endif /* __GST_TYPE_FIND_ELEMENT_H__ */ diff --git a/gst/gst-i18n-app.h b/gst/gst-i18n-app.h index 19a59f37c..5cad5a379 100644 --- a/gst/gst-i18n-app.h +++ b/gst/gst-i18n-app.h @@ -23,7 +23,7 @@ #ifndef __GST_I18N_APP_H__ #define __GST_I18N_APP_H__ -#include "gettext.h" /* included with gettext distribution and copied */ +#include "gettext.h" /* included with gettext distribution and copied */ /* we want to use shorthand _() for translating and N_() for marking */ #define _(String) gettext (String) diff --git a/gst/gst-i18n-lib.h b/gst/gst-i18n-lib.h index f5db797d1..b5828bc56 100644 --- a/gst/gst-i18n-lib.h +++ b/gst/gst-i18n-lib.h @@ -23,7 +23,7 @@ #ifndef __GST_I18N_LIB_H__ #define __GST_I18N_LIB_H__ -#include "gettext.h" /* included with gettext distribution and copied */ +#include "gettext.h" /* included with gettext distribution and copied */ #ifndef GETTEXT_PACKAGE #error You must define GETTEXT_PACKAGE before including this header. diff --git a/gst/gst.c b/gst/gst.c index a13b6755e..b12000cc6 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -53,6 +53,7 @@ static gboolean _gst_use_threads = TRUE; static gboolean _gst_enable_cpu_opt = TRUE; static gboolean gst_initialized = FALSE; + /* this will be set in popt callbacks when a problem has been encountered */ static gboolean _gst_initialization_failure = FALSE; extern gint _gst_trace_on; @@ -63,23 +64,20 @@ gboolean _gst_disable_segtrap = FALSE; extern GThreadFunctions gst_thread_dummy_functions; -static void load_plugin_func (gpointer data, gpointer user_data); -static void init_popt_callback (poptContext context, - enum poptCallbackReason reason, - const GstPoptOption *option, - const char *arg, void *data); -static gboolean init_pre (void); -static gboolean init_post (void); +static void load_plugin_func (gpointer data, gpointer user_data); +static void init_popt_callback (poptContext context, + enum poptCallbackReason reason, + const GstPoptOption * option, const char *arg, void *data); +static gboolean init_pre (void); +static gboolean init_post (void); static GSList *preload_plugins = NULL; const gchar *g_log_domain_gstreamer = "GStreamer"; static void -debug_log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) +debug_log_handler (const gchar * log_domain, + GLogLevelFlags log_level, const gchar * message, gpointer user_data) { g_log_default_handler (log_domain, log_level, message, user_data); /* FIXME: do we still need this ? fatal errors these days are all @@ -87,8 +85,9 @@ debug_log_handler (const gchar *log_domain, /* g_on_error_query (NULL); */ } -enum { - ARG_VERSION=1, +enum +{ + ARG_VERSION = 1, ARG_FATAL_WARNINGS, #ifndef GST_DISABLE_GST_DEBUG ARG_DEBUG_LEVEL, @@ -114,27 +113,56 @@ enum { * the GST_SCHEDULER_DEFAULT_NAME define. */ static const GstPoptOption gstreamer_options[] = { - {NULL, NUL, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *) &init_popt_callback, 0, NULL, NULL}, + {NULL, NUL, POPT_ARG_CALLBACK | POPT_CBFLAG_PRE | POPT_CBFLAG_POST, + (void *) &init_popt_callback, 0, NULL, NULL}, /* make sure we use our GETTEXT_PACKAGE as the domain for popt translations */ {NULL, NUL, POPT_ARG_INTL_DOMAIN, GETTEXT_PACKAGE, 0, NULL, NULL}, - {"gst-version", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, N_("Print the GStreamer version"), NULL}, - {"gst-fatal-warnings", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL}, + {"gst-version", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, ARG_VERSION, + N_("Print the GStreamer version"), NULL}, + {"gst-fatal-warnings", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_FATAL_WARNINGS, N_("Make all warnings fatal"), NULL}, #ifndef GST_DISABLE_GST_DEBUG - {"gst-debug-help", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL}, - {"gst-debug-level", NUL, POPT_ARG_INT|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_LEVEL, N_("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"), N_("LEVEL")}, - {"gst-debug", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG, N_("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"), N_("LIST")}, - {"gst-debug-no-color", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_NO_COLOR, N_("Disable colored debugging output"), NULL}, - {"gst-debug-disable", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG_DISABLE, N_("Disable debugging")}, + {"gst-debug-help", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_DEBUG_HELP, N_("Print available debug categories and exit"), NULL}, + {"gst-debug-level", NUL, POPT_ARG_INT | POPT_ARGFLAG_STRIP, NULL, + ARG_DEBUG_LEVEL, + N_ + ("Default debug level from 1 (only error) to 5 (anything) or 0 for no output"), + N_("LEVEL")}, + {"gst-debug", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, ARG_DEBUG, + N_ + ("Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3"), + N_("LIST")}, + {"gst-debug-no-color", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_DEBUG_NO_COLOR, N_("Disable colored debugging output"), NULL}, + {"gst-debug-disable", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_DEBUG_DISABLE, N_("Disable debugging")}, #endif - {"gst-disable-cpu-opt",NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_DISABLE_CPU_OPT,N_("Disable accelerated CPU instructions"), NULL}, - {"gst-plugin-spew", NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_SPEW, N_("Enable verbose plugin loading diagnostics"), NULL}, - {"gst-plugin-path", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_PATH, N_("path list for loading plugins (separated by '" G_SEARCHPATH_SEPARATOR_S "')"),N_("PATHS")}, - {"gst-plugin-load", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_PLUGIN_LOAD, N_("Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"), N_("PLUGINS")}, - {"gst-disable-segtrap",NUL, POPT_ARG_NONE|POPT_ARGFLAG_STRIP, NULL, ARG_SEGTRAP_DISABLE,N_("Disable trapping of segmentation faults during plugin loading"), NULL}, - {"gst-scheduler", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_SCHEDULER, N_("Scheduler to use ('"GST_SCHEDULER_DEFAULT_NAME"' is the default)"), N_("SCHEDULER")}, - {"gst-registry", NUL, POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, ARG_REGISTRY, N_("Registry to use") , N_("REGISTRY")}, + {"gst-disable-cpu-opt", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_DISABLE_CPU_OPT, N_("Disable accelerated CPU instructions"), NULL}, + {"gst-plugin-spew", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_PLUGIN_SPEW, N_("Enable verbose plugin loading diagnostics"), NULL}, + {"gst-plugin-path", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, + ARG_PLUGIN_PATH, + N_("path list for loading plugins (separated by '" + G_SEARCHPATH_SEPARATOR_S "')"), N_("PATHS")}, + {"gst-plugin-load", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, + ARG_PLUGIN_LOAD, + N_ + ("Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH"), + N_("PLUGINS")}, + {"gst-disable-segtrap", NUL, POPT_ARG_NONE | POPT_ARGFLAG_STRIP, NULL, + ARG_SEGTRAP_DISABLE, + N_("Disable trapping of segmentation faults during plugin loading"), + NULL}, + {"gst-scheduler", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, + ARG_SCHEDULER, + N_("Scheduler to use ('" GST_SCHEDULER_DEFAULT_NAME + "' is the default)"), N_("SCHEDULER")}, + {"gst-registry", NUL, POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, + ARG_REGISTRY, N_("Registry to use"), N_("REGISTRY")}, POPT_TABLEEND }; @@ -212,13 +240,14 @@ gst_init (int *argc, char **argv[]) */ void gst_init_with_popt_table (int *argc, char **argv[], - const GstPoptOption *popt_options) + const GstPoptOption * popt_options) { if (!gst_init_check_with_popt_table (argc, argv, popt_options)) { g_print ("Could not initialize GStreamer !\n"); exit (1); } } + /** * gst_init_check_with_popt_table: * @argc: pointer to application's argc @@ -233,25 +262,29 @@ gst_init_with_popt_table (int *argc, char **argv[], */ gboolean gst_init_check_with_popt_table (int *argc, char **argv[], - const GstPoptOption *popt_options) + const GstPoptOption * popt_options) { poptContext context; gint nextopt; GstPoptOption *options; GstPoptOption options_with[] = { - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, "GStreamer options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0, "Application options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", + NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, + "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) popt_options, 0, + "Application options:", NULL}, POPT_TABLEEND }; GstPoptOption options_without[] = { - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", NULL}, - {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, "GStreamer options:", NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, poptHelpOptions, 0, "Help options:", + NULL}, + {NULL, NUL, POPT_ARG_INCLUDE_TABLE, (GstPoptOption *) gstreamer_options, 0, + "GStreamer options:", NULL}, POPT_TABLEEND }; - if (gst_initialized) - { + if (gst_initialized) { GST_DEBUG ("already initialized gst"); return TRUE; } @@ -260,8 +293,10 @@ gst_init_check_with_popt_table (int *argc, char **argv[], if (argc || argv) g_warning ("gst_init: Only one of argc or argv was NULL"); - if (!init_pre ()) return FALSE; - if (!init_post ()) return FALSE; + if (!init_pre ()) + return FALSE; + if (!init_post ()) + return FALSE; gst_initialized = TRUE; return TRUE; } @@ -271,21 +306,19 @@ gst_init_check_with_popt_table (int *argc, char **argv[], } else { options = options_with; } - context = poptGetContext ("GStreamer", *argc, (const char**)*argv, - options, 0); + context = poptGetContext ("GStreamer", *argc, (const char **) *argv, + options, 0); - while ((nextopt = poptGetNextOpt (context)) > 0) - { + while ((nextopt = poptGetNextOpt (context)) > 0) { /* we only check for failures here, actual work is done in callbacks */ - if (_gst_initialization_failure) return FALSE; + if (_gst_initialization_failure) + return FALSE; } if (nextopt != -1) { g_print ("Error on option %s: %s.\nRun '%s --help' " - "to see a full list of available command line options.\n", - poptBadOption (context, 0), - poptStrerror (nextopt), - (*argv)[0]); + "to see a full list of available command line options.\n", + poptBadOption (context, 0), poptStrerror (nextopt), (*argv)[0]); poptFreeContext (context); return FALSE; @@ -305,7 +338,7 @@ add_path_func (gpointer data, gpointer user_data) GstRegistry *registry = GST_REGISTRY (user_data); GST_INFO ("Adding plugin path: \"%s\"", (gchar *) data); - gst_registry_add_path (registry, (gchar *)data); + gst_registry_add_path (registry, (gchar *) data); } #endif @@ -316,7 +349,7 @@ prepare_for_load_plugin_func (gpointer data, gpointer user_data) } static void -parse_debug_list (const gchar *list) +parse_debug_list (const gchar * list) { gchar **split; gchar **walk; @@ -326,16 +359,18 @@ parse_debug_list (const gchar *list) walk = split = g_strsplit (list, ",", 0); while (walk[0]) { - gchar **values = g_strsplit ( walk[0], ":", 2); + gchar **values = g_strsplit (walk[0], ":", 2); + if (values[0] && values[1]) { gint level = 0; + g_strstrip (values[0]); g_strstrip (values[1]); level = strtol (values[1], NULL, 0); if (level >= 0 && level < GST_LEVEL_COUNT) { - GST_DEBUG ("setting debugging to level %d for name \"%s\"", - level, values[0]); - gst_debug_set_threshold_for_name (values[0], level); + GST_DEBUG ("setting debugging to level %d for name \"%s\"", + level, values[0]); + gst_debug_set_threshold_for_name (values[0], level); } } g_strfreev (values); @@ -365,7 +400,8 @@ load_plugin_func (gpointer data, gpointer user_data) } static void -split_and_iterate (const gchar *stringlist, gchar *separator, GFunc iterator, gpointer user_data) +split_and_iterate (const gchar * stringlist, gchar * separator, GFunc iterator, + gpointer user_data) { gchar **strings; gint j = 0; @@ -379,10 +415,10 @@ split_and_iterate (const gchar *stringlist, gchar *separator, GFunc iterator, gp while (strings[j]) { iterator (strings[j], user_data); if (++j == MAX_PATH_SPLIT) { - lastlist = g_strdup (strings[j]); - g_strfreev (strings); - j=0; - break; + lastlist = g_strdup (strings[j]); + g_strfreev (strings); + j = 0; + break; } } } @@ -404,7 +440,7 @@ init_pre (void) g_thread_init (&gst_thread_dummy_functions); } /* we need threading to be enabled right here */ - _gst_debug_init(); + _gst_debug_init (); #ifdef ENABLE_NLS setlocale (LC_ALL, ""); @@ -426,7 +462,8 @@ init_pre (void) gchar *user_reg; const gchar *homedir; - _global_registry = gst_xml_registry_new ("global_registry", GLOBAL_REGISTRY_FILE); + _global_registry = + gst_xml_registry_new ("global_registry", GLOBAL_REGISTRY_FILE); #ifdef PLUGINS_USE_BUILDDIR /* location libgstelements.so */ @@ -434,19 +471,17 @@ init_pre (void) gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/elements"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/types"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/autoplug"); - gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/schedulers"); + gst_registry_add_path (_global_registry, + PLUGINS_BUILDDIR "/gst/schedulers"); gst_registry_add_path (_global_registry, PLUGINS_BUILDDIR "/gst/indexers"); #else /* add the main (installed) library path */ gst_registry_add_path (_global_registry, PLUGINS_DIR); #endif /* PLUGINS_USE_BUILDDIR */ - if (g_getenv ("GST_REGISTRY")) - { + if (g_getenv ("GST_REGISTRY")) { user_reg = g_strdup (g_getenv ("GST_REGISTRY")); - } - else - { + } else { homedir = g_get_home_dir (); user_reg = g_strjoin ("/", homedir, LOCAL_REGISTRY_FILE, NULL); } @@ -460,13 +495,17 @@ init_pre (void) } static gboolean -gst_register_core_elements (GstPlugin *plugin) +gst_register_core_elements (GstPlugin * plugin) { /* register some standard builtin types */ - g_assert (gst_element_register (plugin, "bin", GST_RANK_PRIMARY, GST_TYPE_BIN)); - g_assert (gst_element_register (plugin, "pipeline", GST_RANK_PRIMARY, GST_TYPE_PIPELINE)); - g_assert (gst_element_register (plugin, "thread", GST_RANK_PRIMARY, GST_TYPE_THREAD)); - g_assert (gst_element_register (plugin, "queue", GST_RANK_PRIMARY, GST_TYPE_QUEUE)); + g_assert (gst_element_register (plugin, "bin", GST_RANK_PRIMARY, + GST_TYPE_BIN)); + g_assert (gst_element_register (plugin, "pipeline", GST_RANK_PRIMARY, + GST_TYPE_PIPELINE)); + g_assert (gst_element_register (plugin, "thread", GST_RANK_PRIMARY, + GST_TYPE_THREAD)); + g_assert (gst_element_register (plugin, "queue", GST_RANK_PRIMARY, + GST_TYPE_QUEUE)); return TRUE; } @@ -502,6 +541,7 @@ init_post (void) { GLogLevelFlags llf; const gchar *plugin_path; + #ifndef GST_DISABLE_TRACE GstTrace *gst_trace; #endif /* GST_DISABLE_TRACE */ @@ -510,7 +550,7 @@ init_post (void) g_log_set_handler (g_log_domain_gstreamer, llf, debug_log_handler, NULL); GST_INFO ("Initializing GStreamer Core Library version %s %s", - VERSION, _gst_use_threads ? "" : "(no threads)"); + VERSION, _gst_use_threads ? "" : "(no threads)"); _gst_format_initialize (); _gst_query_type_initialize (); @@ -532,7 +572,8 @@ init_post (void) plugin_path = g_getenv ("GST_PLUGIN_PATH"); #ifndef GST_DISABLE_REGISTRY - split_and_iterate (plugin_path, G_SEARCHPATH_SEPARATOR_S, add_path_func, _global_registry); + split_and_iterate (plugin_path, G_SEARCHPATH_SEPARATOR_S, add_path_func, + _global_registry); #endif /* GST_DISABLE_REGISTRY */ /* register core plugins */ @@ -551,7 +592,8 @@ init_post (void) if (!_gst_registry_fixed) { /* don't override command-line options */ if (g_getenv ("GST_REGISTRY")) { - g_object_set (_global_registry, "location", g_getenv ("GST_REGISTRY"), NULL); + g_object_set (_global_registry, "location", g_getenv ("GST_REGISTRY"), + NULL); _gst_registry_fixed = TRUE; } } @@ -574,7 +616,6 @@ init_post (void) g_slist_free (preload_plugins); preload_plugins = NULL; } - #ifndef GST_DISABLE_TRACE _gst_trace_on = 0; if (_gst_trace_on) { @@ -594,7 +635,7 @@ static gint sort_by_category_name (gconstpointer a, gconstpointer b) { return strcmp (gst_debug_category_get_name ((GstDebugCategory *) a), - gst_debug_category_get_name ((GstDebugCategory *) b)); + gst_debug_category_get_name ((GstDebugCategory *) b)); } static void gst_debug_help (void) @@ -608,14 +649,18 @@ gst_debug_help (void) walk2 = list2 = gst_registry_pool_plugin_list (); while (walk2) { GstPlugin *plugin = GST_PLUGIN (walk2->data); + walk2 = g_list_next (walk2); if (!gst_plugin_is_loaded (plugin)) { #ifndef GST_DISABLE_REGISTRY if (GST_IS_REGISTRY (plugin->manager)) { - GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, "loading plugin %s", plugin->desc.name); - if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), plugin) != GST_REGISTRY_OK) - GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "loading plugin %s failed", plugin->desc.name); + GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, "loading plugin %s", + plugin->desc.name); + if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), + plugin) != GST_REGISTRY_OK) + GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "loading plugin %s failed", + plugin->desc.name); } #endif /* GST_DISABLE_REGISTRY */ } @@ -634,19 +679,19 @@ gst_debug_help (void) if (gst_debug_is_colored ()) { gchar *color = gst_debug_construct_term_color (cat->color); + g_print ("%s%-20s\033[00m %1d %s %s%s\033[00m\n", - color, - gst_debug_category_get_name (cat), - gst_debug_category_get_threshold (cat), - gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), - color, - gst_debug_category_get_description (cat)); + color, + gst_debug_category_get_name (cat), + gst_debug_category_get_threshold (cat), + gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), + color, gst_debug_category_get_description (cat)); g_free (color); } else { g_print ("%-20s %1d %s %s\n", gst_debug_category_get_name (cat), - gst_debug_category_get_threshold (cat), - gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), - gst_debug_category_get_description (cat)); + gst_debug_category_get_threshold (cat), + gst_debug_level_get_name (gst_debug_category_get_threshold (cat)), + gst_debug_category_get_description (cat)); } walk = g_slist_next (walk); } @@ -657,82 +702,86 @@ gst_debug_help (void) static void init_popt_callback (poptContext context, enum poptCallbackReason reason, - const GstPoptOption *option, const char *arg, void *data) + const GstPoptOption * option, const char *arg, void *data) { GLogLevelFlags fatal_mask; if (gst_initialized) return; switch (reason) { - case POPT_CALLBACK_REASON_PRE: - if (!init_pre ()) _gst_initialization_failure = TRUE; - break; - case POPT_CALLBACK_REASON_OPTION: - switch (option->val) { - case ARG_VERSION: - g_print ("GStreamer Core Library version %s\n", GST_VERSION); - exit (0); - case ARG_FATAL_WARNINGS: - fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); - fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; - g_log_set_always_fatal (fatal_mask); + case POPT_CALLBACK_REASON_PRE: + if (!init_pre ()) + _gst_initialization_failure = TRUE; break; + case POPT_CALLBACK_REASON_OPTION: + switch (option->val) { + case ARG_VERSION: + g_print ("GStreamer Core Library version %s\n", GST_VERSION); + exit (0); + case ARG_FATAL_WARNINGS: + fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK); + fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL; + g_log_set_always_fatal (fatal_mask); + break; #ifndef GST_DISABLE_GST_DEBUG - case ARG_DEBUG_LEVEL: { - gint tmp = 0; - tmp = strtol (arg, NULL, 0); - if (tmp >= 0 && tmp < GST_LEVEL_COUNT) { - gst_debug_set_default_threshold (tmp); - } - break; - } - case ARG_DEBUG: - parse_debug_list (arg); - break; - case ARG_DEBUG_NO_COLOR: - gst_debug_set_colored (FALSE); - break; - case ARG_DEBUG_DISABLE: - gst_debug_set_active (FALSE); - break; - case ARG_DEBUG_HELP: - gst_debug_help (); - exit (0); + case ARG_DEBUG_LEVEL:{ + gint tmp = 0; + + tmp = strtol (arg, NULL, 0); + if (tmp >= 0 && tmp < GST_LEVEL_COUNT) { + gst_debug_set_default_threshold (tmp); + } + break; + } + case ARG_DEBUG: + parse_debug_list (arg); + break; + case ARG_DEBUG_NO_COLOR: + gst_debug_set_colored (FALSE); + break; + case ARG_DEBUG_DISABLE: + gst_debug_set_active (FALSE); + break; + case ARG_DEBUG_HELP: + gst_debug_help (); + exit (0); #endif - case ARG_DISABLE_CPU_OPT: - _gst_enable_cpu_opt = FALSE; - break; - case ARG_PLUGIN_SPEW: - break; - case ARG_PLUGIN_PATH: + case ARG_DISABLE_CPU_OPT: + _gst_enable_cpu_opt = FALSE; + break; + case ARG_PLUGIN_SPEW: + break; + case ARG_PLUGIN_PATH: #ifndef GST_DISABLE_REGISTRY - split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func, _user_registry); + split_and_iterate (arg, G_SEARCHPATH_SEPARATOR_S, add_path_func, + _user_registry); #endif /* GST_DISABLE_REGISTRY */ - break; - case ARG_PLUGIN_LOAD: - split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL); - break; - case ARG_SEGTRAP_DISABLE: - _gst_disable_segtrap = TRUE; - break; - case ARG_SCHEDULER: - gst_scheduler_factory_set_default_name (arg); - break; - case ARG_REGISTRY: + break; + case ARG_PLUGIN_LOAD: + split_and_iterate (arg, ",", prepare_for_load_plugin_func, NULL); + break; + case ARG_SEGTRAP_DISABLE: + _gst_disable_segtrap = TRUE; + break; + case ARG_SCHEDULER: + gst_scheduler_factory_set_default_name (arg); + break; + case ARG_REGISTRY: #ifndef GST_DISABLE_REGISTRY - g_object_set (G_OBJECT (_user_registry), "location", arg, NULL); - _gst_registry_fixed = TRUE; + g_object_set (G_OBJECT (_user_registry), "location", arg, NULL); + _gst_registry_fixed = TRUE; #endif /* GST_DISABLE_REGISTRY */ + break; + default: + g_warning ("option %d not recognized", option->val); + break; + } break; - default: - g_warning ("option %d not recognized", option->val); + case POPT_CALLBACK_REASON_POST: + if (!init_post ()) + _gst_initialization_failure = TRUE; + gst_initialized = TRUE; break; - } - break; - case POPT_CALLBACK_REASON_POST: - if (!init_post ()) _gst_initialization_failure = TRUE; - gst_initialized = TRUE; - break; } } @@ -802,6 +851,7 @@ gst_main_quit (void) g_error ("Quit more loops than there are"); else { GMainLoop *loop = mainloops->data; + mainloops = g_slist_delete_link (mainloops, mainloops); g_main_loop_quit (loop); g_main_loop_unref (loop); @@ -817,7 +867,7 @@ gst_main_quit (void) * Gets the version number of the GStreamer library. */ void -gst_version (guint *major, guint *minor, guint *micro) +gst_version (guint * major, guint * minor, guint * micro) { g_return_if_fail (major); g_return_if_fail (minor); diff --git a/gst/gst.h b/gst/gst.h index 7ccf8b1a5..bc55b0b2d 100644 --- a/gst/gst.h +++ b/gst/gst.h @@ -69,31 +69,26 @@ #include G_BEGIN_DECLS - /* make our own type for poptOption because the struct poptOption * definition is iffy */ typedef struct poptOption GstPoptOption; /* initialize GST */ -void gst_init (int *argc, char **argv[]); -gboolean gst_init_check (int *argc, char **argv[]); -void gst_init_with_popt_table (int *argc, char **argv[], - const GstPoptOption - *popt_options); -gboolean gst_init_check_with_popt_table (int *argc, char **argv[], - const GstPoptOption - *popt_options); +void gst_init (int *argc, char **argv[]); +gboolean gst_init_check (int *argc, char **argv[]); +void gst_init_with_popt_table (int *argc, char **argv[], + const GstPoptOption * popt_options); +gboolean gst_init_check_with_popt_table (int *argc, char **argv[], + const GstPoptOption * popt_options); -const GstPoptOption * gst_init_get_popt_table (void); +const GstPoptOption *gst_init_get_popt_table (void); -void gst_use_threads (gboolean use_threads); -gboolean gst_has_threads (void); +void gst_use_threads (gboolean use_threads); +gboolean gst_has_threads (void); -void gst_main (void); -void gst_main_quit (void); +void gst_main (void); +void gst_main_quit (void); G_END_DECLS - #include - #endif /* __GST_H__ */ diff --git a/gst/gstarch.h b/gst/gstarch.h index 50fef7500..e62f6992f 100644 --- a/gst/gstarch.h +++ b/gst/gstarch.h @@ -47,17 +47,18 @@ #define GST_ARCH_SET_SP(stackpointer) \ __asm__("lwz r1,%0" : : "m"(stackpointer)) - + #define GST_ARCH_CALL(target) \ __asm__( "mr r0,%0\n\t" \ "mtlr r0\n\t" \ "blrl" : : "r"(target) ); - -struct minimal_ppc_stackframe { - unsigned long back_chain; - unsigned long LR_save; - unsigned long unused1; - unsigned long unused2; + +struct minimal_ppc_stackframe +{ + unsigned long back_chain; + unsigned long LR_save; + unsigned long unused1; + unsigned long unused2; }; #define GST_ARCH_SETUP_STACK(sp) \ @@ -79,11 +80,12 @@ struct minimal_ppc_stackframe { /* Need to get more information about the stackframe format * and get the fields more correct. Check GDB sources maybe? */ -struct minimal_stackframe { - unsigned long back_chain; - unsigned long LR_save; - unsigned long unused1; - unsigned long unused2; +struct minimal_stackframe +{ + unsigned long back_chain; + unsigned long LR_save; + unsigned long unused1; + unsigned long unused2; }; #define GST_ARCH_SETUP_STACK(sp) \ @@ -141,7 +143,7 @@ struct minimal_stackframe { /* assuming the stackframe is 16 bytes */ #define GST_ARCH_SETUP_STACK(sp) sp -= 4 - + /***** HP-PA *****/ @@ -167,11 +169,12 @@ struct minimal_stackframe { #define GST_ARCH_CALL(target) \ __asm__( "basr 14,%0" : : "a"(target) ); -struct minimal_s390_stackframe { - unsigned long back_chain; - unsigned long reserved; - unsigned long greg[14]; - double freg[4]; +struct minimal_s390_stackframe +{ + unsigned long back_chain; + unsigned long reserved; + unsigned long greg[14]; + double freg[4]; }; #define GST_ARCH_SETUP_STACK(sp) \ diff --git a/gst/gstatomic.c b/gst/gstatomic.c index 5e5cda99c..8fb85433c 100644 --- a/gst/gstatomic.c +++ b/gst/gstatomic.c @@ -22,4 +22,3 @@ #include "gstatomic.h" #include "gstatomic_impl.h" - diff --git a/gst/gstatomic.h b/gst/gstatomic.h index c8355eafd..d683ebbb6 100644 --- a/gst/gstatomic.h +++ b/gst/gstatomic.h @@ -22,27 +22,25 @@ #include -G_BEGIN_DECLS - -typedef volatile gint gst_vgint; /* gtk-doc volatile workaround */ +G_BEGIN_DECLS typedef volatile gint gst_vgint; /* gtk-doc volatile workaround */ typedef struct _GstAtomicInt GstAtomicInt; -struct _GstAtomicInt { - gst_vgint counter; - GMutex *lock; /* for C fallback */ +struct _GstAtomicInt +{ + gst_vgint counter; + GMutex *lock; /* for C fallback */ }; -void gst_atomic_int_init (GstAtomicInt *aint, gint val); -void gst_atomic_int_destroy (GstAtomicInt *aint); -void gst_atomic_int_set (GstAtomicInt *aint, gint val); -gint gst_atomic_int_read (GstAtomicInt *aint); -void gst_atomic_int_add (GstAtomicInt *aint, gint val); -void gst_atomic_int_inc (GstAtomicInt *aint); -gboolean gst_atomic_int_dec_and_test (GstAtomicInt *aint); +void gst_atomic_int_init (GstAtomicInt * aint, gint val); +void gst_atomic_int_destroy (GstAtomicInt * aint); +void gst_atomic_int_set (GstAtomicInt * aint, gint val); +gint gst_atomic_int_read (GstAtomicInt * aint); +void gst_atomic_int_add (GstAtomicInt * aint, gint val); +void gst_atomic_int_inc (GstAtomicInt * aint); +gboolean gst_atomic_int_dec_and_test (GstAtomicInt * aint); G_END_DECLS - #endif /* __GST_ATOMIC_H__ */ diff --git a/gst/gstatomic_impl.h b/gst/gstatomic_impl.h index 8228d7bd2..2f25c5446 100644 --- a/gst/gstatomic_impl.h +++ b/gst/gstatomic_impl.h @@ -34,57 +34,62 @@ #include "gstmacros.h" G_BEGIN_DECLS - #if defined (GST_CAN_INLINE) || defined (__GST_ATOMIC_C__) - /***** Intel x86 *****/ #if defined (HAVE_CPU_I386) && defined(__GNUC__) - #ifdef GST_CONFIG_NO_SMP #define SMP_LOCK "" #else #define SMP_LOCK "lock ; " #endif + GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC void +gst_atomic_int_destroy (GstAtomicInt * aint) +{ +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC gint +gst_atomic_int_read (GstAtomicInt * aint) +{ + return aint->counter; +} -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; } - -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { - __asm__ __volatile__( - SMP_LOCK "addl %1,%0" - :"=m" (aint->counter) + __asm__ __volatile__ (SMP_LOCK "addl %1,%0":"=m" (aint->counter) :"ir" (val), "m" (aint->counter)); } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { - __asm__ __volatile__( - SMP_LOCK "incl %0" - :"=m" (aint->counter) + __asm__ __volatile__ (SMP_LOCK "incl %0":"=m" (aint->counter) :"m" (aint->counter)); } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { guchar res; - __asm__ __volatile__( - SMP_LOCK "decl %0; sete %1" - :"=m" (aint->counter), "=qm" (res) - :"m" (aint->counter) : "memory"); + __asm__ __volatile__ (SMP_LOCK "decl %0; sete %1":"=m" (aint->counter), + "=qm" (res) + :"m" (aint->counter):"memory"); return res != 0; } /***** PowerPC *****/ #elif defined (HAVE_CPU_PPC) && defined(__GNUC__) - #ifdef GST_CONFIG_NO_SMP #define SMP_SYNC "" #define SMP_ISYNC @@ -92,7 +97,6 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) #define SMP_SYNC "\tsync\n" #define SMP_ISYNC "\tisync\n" #endif - /* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx. * The old ATOMIC_SYNC_FIX covered some but not all of this. */ @@ -101,111 +105,123 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) #else #define PPC405_ERR77(ra,rb) #endif + GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC void +gst_atomic_int_destroy (GstAtomicInt * aint) +{ +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC gint +gst_atomic_int_read (GstAtomicInt * aint) +{ + return aint->counter; +} -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; } - -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { int t; - __asm__ __volatile__( - "1: lwarx %0,0,%3\n" - " add %0,%2,%0\n" - PPC405_ERR77(0,%3) - " stwcx. %0,0,%3 \n" - " bne- 1b\n" - : "=&r" (t), "=m" (aint->counter) - : "r" (val), "r" (&aint->counter), "m" (aint->counter) - : "cc"); + __asm__ __volatile__ ("1: lwarx %0,0,%3\n" + " add %0,%2,%0\n" PPC405_ERR77 (0, %3) + " stwcx. %0,0,%3 \n" + " bne- 1b\n":"=&r" (t), "=m" (aint->counter) + :"r" (val), "r" (&aint->counter), "m" (aint->counter) + :"cc"); } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { int t; - __asm__ __volatile__( - "1: lwarx %0,0,%2\n" - " addic %0,%0,1\n" - PPC405_ERR77(0,%2) - " stwcx. %0,0,%2\n" - " bne- 1b\n" - : "=&r" (t), "=m" (aint->counter) - : "r" (&aint->counter), "m" (aint->counter) - : "cc"); + __asm__ __volatile__ ("1: lwarx %0,0,%2\n" + " addic %0,%0,1\n" PPC405_ERR77 (0, %2) + " stwcx. %0,0,%2\n" + " bne- 1b\n":"=&r" (t), "=m" (aint->counter) + :"r" (&aint->counter), "m" (aint->counter) + :"cc"); } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { int t; - __asm__ __volatile__( - "1: lwarx %0,0,%1\n" - " addic %0,%0,-1\n" - PPC405_ERR77(0,%1) - " stwcx. %0,0,%1\n" - " bne- 1b\n" - SMP_ISYNC - : "=&r" (t) - : "r" (&aint->counter) - : "cc", "memory"); + __asm__ __volatile__ ("1: lwarx %0,0,%1\n" + " addic %0,%0,-1\n" PPC405_ERR77 (0, %1) + " stwcx. %0,0,%1\n" " bne- 1b\n" SMP_ISYNC:"=&r" (t) + :"r" (&aint->counter) + :"cc", "memory"); return t == 0; } /***** DEC[/Compaq/HP?/Intel?] Alpha *****/ #elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__) + GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC void +gst_atomic_int_destroy (GstAtomicInt * aint) +{ +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC gint +gst_atomic_int_read (GstAtomicInt * aint) +{ + return aint->counter; +} -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; } - -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { unsigned long temp; - __asm__ __volatile__( - "1: ldl_l %0,%1\n" - " addl %0,%2,%0\n" - " stl_c %0,%1\n" - " beq %0,2f\n" - ".subsection 2\n" - "2: br 1b\n" - ".previous" - :"=&r" (temp), "=m" (aint->counter) + __asm__ __volatile__ ("1: ldl_l %0,%1\n" + " addl %0,%2,%0\n" + " stl_c %0,%1\n" + " beq %0,2f\n" + ".subsection 2\n" + "2: br 1b\n" ".previous":"=&r" (temp), "=m" (aint->counter) :"Ir" (val), "m" (aint->counter)); } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { gst_atomic_int_add (aint, 1); } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { long temp, result; int val = 1; - __asm__ __volatile__( - "1: ldl_l %0,%1\n" - " subl %0,%3,%2\n" - " subl %0,%3,%0\n" - " stl_c %0,%1\n" - " beq %0,2f\n" - " mb\n" - ".subsection 2\n" - "2: br 1b\n" - ".previous" - :"=&r" (temp), "=m" (aint->counter), "=&r" (result) - :"Ir" (val), "m" (aint->counter) : "memory"); + __asm__ __volatile__ ("1: ldl_l %0,%1\n" + " subl %0,%3,%2\n" + " subl %0,%3,%0\n" + " stl_c %0,%1\n" + " beq %0,2f\n" + " mb\n" + ".subsection 2\n" + "2: br 1b\n" + ".previous":"=&r" (temp), "=m" (aint->counter), "=&r" (result) + :"Ir" (val), "m" (aint->counter):"memory"); return result == 0; } @@ -213,16 +229,38 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) /***** Sun SPARC *****/ #elif 0 && defined(HAVE_CPU_SPARC) && defined(__GNUC__) /* allegedly broken again */ - -GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { } + GST_INLINE_FUNC void +gst_atomic_int_destroy (GstAtomicInt * aint) +{ +} #ifdef GST_CONFIG_NO_SMP -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; } +GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC gint +gst_atomic_int_read (GstAtomicInt * aint) +{ + return aint->counter; +} #else -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = (val<<8); } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = (val<<8); } +GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = (val << 8); +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = (val << 8); +} /* * For SMP the trick is you embed the spin lock byte within @@ -235,8 +273,8 @@ GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint- * 31 8 7 0 */ GST_INLINE_FUNC gint -gst_atomic_int_read (GstAtomicInt *aint) -{ +gst_atomic_int_read (GstAtomicInt * aint) +{ int ret = aint->counter; while (ret & 0xff) @@ -246,8 +284,8 @@ gst_atomic_int_read (GstAtomicInt *aint) } #endif /* GST_CONFIG_NO_SMP */ -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { volatile int increment, *ptr; int lock = 1; @@ -256,41 +294,28 @@ gst_atomic_int_add (GstAtomicInt *aint, gint val) ptr = &(aint->counter); #if __GNUC__ > 3 || (__GNUC__ >=3 && __GNUC_MINOR__ >= 2) - __asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n" - "\torcc %[lock], 0, %[ignore]\n" - "\tbne 1b\n" /* go back until we have the lock */ - "\tld [%[ptr]], %[inc]\n" - "\tsra %[inc], 8, %[inc]\n" - "\tadd %[inc], %[val], %[inc]\n" - "\tsll %[inc], 8, %[lock]\n" - "\tst %[lock],[%[ptr]]\n" /* Release the lock */ - : [inc] "=&r" (increment), [lock] "=r" (lock), - [ignore] "=&r" (ignore) - : "0" (increment), [ptr] "r" (ptr), [val] "r" (val) - ); + __asm__ __volatile__ ("1: ldstub [%[ptr] + 3], %[lock]\n" "\torcc %[lock], 0, %[ignore]\n" "\tbne 1b\n" /* go back until we have the lock */ + "\tld [%[ptr]], %[inc]\n" "\tsra %[inc], 8, %[inc]\n" "\tadd %[inc], %[val], %[inc]\n" "\tsll %[inc], 8, %[lock]\n" "\tst %[lock],[%[ptr]]\n" /* Release the lock */ + :[inc] "=&r" (increment),[lock] "=r" (lock),[ignore] "=&r" (ignore) + :"0" (increment),[ptr] "r" (ptr),[val] "r" (val) + ); #else - __asm__ __volatile__("1: ldstub [%4 + 3], %1\n" - "\torcc %1, 0, %2\n" - "\tbne 1b\n" /* go back until we have the lock */ - "\tld [%4], %0\n" - "\tsra %0, 8, %0\n" - "\tadd %0, %5, %0\n" - "\tsll %0, 8, %1\n" - "\tst %1,[%4]\n" /* Release the lock */ - : "=&r" (increment), "=r" (lock), "=&r" (ignore) - : "0" (increment), "r" (ptr), "r" (val) - ); + __asm__ __volatile__ ("1: ldstub [%4 + 3], %1\n" "\torcc %1, 0, %2\n" "\tbne 1b\n" /* go back until we have the lock */ + "\tld [%4], %0\n" "\tsra %0, 8, %0\n" "\tadd %0, %5, %0\n" "\tsll %0, 8, %1\n" "\tst %1,[%4]\n" /* Release the lock */ + :"=&r" (increment), "=r" (lock), "=&r" (ignore) + :"0" (increment), "r" (ptr), "r" (val) + ); #endif } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { gst_atomic_int_add (aint, 1); } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { volatile int increment, *ptr; int lock = 1; @@ -299,30 +324,17 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) ptr = &aint->counter; #if __GNUC__ > 3 || (__GNUC__ >=3 && __GNUC_MINOR__ >= 2) - __asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n" - "\torcc %[lock], 0, %[ignore]\n" - "\tbne 1b\n" /* go back until we have the lock */ - "\tld [%[ptr]], %[inc]\n" - "\tsra %[inc], 8, %[inc]\n" - "\tsub %[inc], 1, %[inc]\n" - "\tsll %[inc], 8, %[lock]\n" - "\tst %[lock],[%[ptr]]\n" /* Release the lock */ - : [inc] "=&r" (increment), [lock] "=r" (lock), - [ignore] "=&r" (ignore) - : "0" (increment), [ptr] "r" (ptr) - ); + __asm__ __volatile__ ("1: ldstub [%[ptr] + 3], %[lock]\n" "\torcc %[lock], 0, %[ignore]\n" "\tbne 1b\n" /* go back until we have the lock */ + "\tld [%[ptr]], %[inc]\n" "\tsra %[inc], 8, %[inc]\n" "\tsub %[inc], 1, %[inc]\n" "\tsll %[inc], 8, %[lock]\n" "\tst %[lock],[%[ptr]]\n" /* Release the lock */ + :[inc] "=&r" (increment),[lock] "=r" (lock),[ignore] "=&r" (ignore) + :"0" (increment),[ptr] "r" (ptr) + ); #else - __asm__ __volatile__("1: ldstub [%4 + 3], %1\n" - "\torcc %1, 0, %2\n" - "\tbne 1b\n" /* go back until we have the lock */ - "\tld [%4], %0\n" - "\tsra %0, 8, %0\n" - "\tsub %0, 1, %0\n" - "\tsll %0, 8, %1\n" - "\tst %1,[%4]\n" /* Release the lock */ - : "=&r" (increment), "=r" (lock), "=&r" (ignore) - : "0" (increment), "r" (ptr) - ); + __asm__ __volatile__ ("1: ldstub [%4 + 3], %1\n" "\torcc %1, 0, %2\n" "\tbne 1b\n" /* go back until we have the lock */ + "\tld [%4], %0\n" "\tsra %0, 8, %0\n" "\tsub %0, 1, %0\n" "\tsll %0, 8, %1\n" "\tst %1,[%4]\n" /* Release the lock */ + :"=&r" (increment), "=r" (lock), "=&r" (ignore) + :"0" (increment), "r" (ptr) + ); #endif return increment == 0; @@ -332,63 +344,93 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) /* This is disabled because the asm code is broken on most MIPS * processors and doesn't generally compile. */ #elif defined(HAVE_CPU_MIPS) && defined(__GNUC__) && 0 - -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; } + GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC void +gst_atomic_int_destroy (GstAtomicInt * aint) +{ +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC gint +gst_atomic_int_read (GstAtomicInt * aint) +{ + return aint->counter; +} /* this only works on MIPS II and better */ -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { unsigned long temp; - __asm__ __volatile__( - "1: ll %0, %1 # atomic_add\n" - " addu %0, %2 \n" - " sc %0, %1 \n" - " beqz %0, 1b \n" - : "=&r" (temp), "=m" (aint->counter) - : "Ir" (val), "m" (aint->counter)); + __asm__ __volatile__ ("1: ll %0, %1 # atomic_add\n" + " addu %0, %2 \n" + " sc %0, %1 \n" + " beqz %0, 1b \n":"=&r" (temp), + "=m" (aint->counter) + :"Ir" (val), "m" (aint->counter)); } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { gst_atomic_int_add (aint, 1); } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { unsigned long temp, result; int val = 1; - __asm__ __volatile__( - ".set push \n" - ".set noreorder # atomic_sub_return\n" - "1: ll %1, %2 \n" - " subu %0, %1, %3 \n" - " sc %0, %2 \n" - " beqz %0, 1b \n" - " subu %0, %1, %3 \n" - ".set pop \n" - : "=&r" (result), "=&r" (temp), "=m" (aint->counter) - : "Ir" (val), "m" (aint->counter) - : "memory"); + __asm__ __volatile__ (".set push \n" + ".set noreorder # atomic_sub_return\n" + "1: ll %1, %2 \n" + " subu %0, %1, %3 \n" + " sc %0, %2 \n" + " beqz %0, 1b \n" + " subu %0, %1, %3 \n" + ".set pop \n":"=&r" (result), + "=&r" (temp), "=m" (aint->counter) + :"Ir" (val), "m" (aint->counter) + :"memory"); return result == 0; } /***** S/390 *****/ #elif defined(HAVE_CPU_S390) && defined(__GNUC__) -typedef struct { volatile int counter; } atomic_t __attribute__ ((aligned (4))); + typedef struct +{ + volatile int counter; +} atomic_t __attribute__ ((aligned (4))); -GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { } -GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; } -GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; } +GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC void +gst_atomic_int_destroy (GstAtomicInt * aint) +{ +} +GST_INLINE_FUNC void +gst_atomic_int_set (GstAtomicInt * aint, gint val) +{ + aint->counter = val; +} +GST_INLINE_FUNC gint +gst_atomic_int_read (GstAtomicInt * aint) +{ + return aint->counter; +} #define __CS_LOOP(old_val, new_val, ptr, op_val, op_string) \ __asm__ __volatile__(" l %0,0(%3)\n" \ @@ -400,49 +442,51 @@ GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->c "+m" (((atomic_t *)(ptr))->counter) \ : "a" (ptr), "d" (op_val) : "cc" ); -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { int old_val, new_val; - __CS_LOOP(old_val, new_val, aint, val, "ar"); + + __CS_LOOP (old_val, new_val, aint, val, "ar"); } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { int old_val, new_val; - __CS_LOOP(old_val, new_val, aint, 1, "ar"); + + __CS_LOOP (old_val, new_val, aint, 1, "ar"); } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { int old_val, new_val; - __CS_LOOP(old_val, new_val, aint, 1, "sr"); + + __CS_LOOP (old_val, new_val, aint, 1, "sr"); return new_val == 0; } -#else +#else #warning consider putting your architecture specific atomic implementations here - /* * generic implementation */ -GST_INLINE_FUNC void -gst_atomic_int_init (GstAtomicInt *aint, gint val) + GST_INLINE_FUNC void +gst_atomic_int_init (GstAtomicInt * aint, gint val) { aint->counter = val; aint->lock = g_mutex_new (); } GST_INLINE_FUNC void -gst_atomic_int_destroy (GstAtomicInt *aint) +gst_atomic_int_destroy (GstAtomicInt * aint) { g_mutex_free (aint->lock); } GST_INLINE_FUNC void -gst_atomic_int_set (GstAtomicInt *aint, gint val) +gst_atomic_int_set (GstAtomicInt * aint, gint val) { g_mutex_lock (aint->lock); aint->counter = val; @@ -450,7 +494,7 @@ gst_atomic_int_set (GstAtomicInt *aint, gint val) } GST_INLINE_FUNC gint -gst_atomic_int_read (GstAtomicInt *aint) +gst_atomic_int_read (GstAtomicInt * aint) { gint res; @@ -461,8 +505,8 @@ gst_atomic_int_read (GstAtomicInt *aint) return res; } -GST_INLINE_FUNC void -gst_atomic_int_add (GstAtomicInt *aint, gint val) +GST_INLINE_FUNC void +gst_atomic_int_add (GstAtomicInt * aint, gint val) { g_mutex_lock (aint->lock); aint->counter += val; @@ -470,7 +514,7 @@ gst_atomic_int_add (GstAtomicInt *aint, gint val) } GST_INLINE_FUNC void -gst_atomic_int_inc (GstAtomicInt *aint) +gst_atomic_int_inc (GstAtomicInt * aint) { g_mutex_lock (aint->lock); aint->counter++; @@ -478,10 +522,10 @@ gst_atomic_int_inc (GstAtomicInt *aint) } GST_INLINE_FUNC gboolean -gst_atomic_int_dec_and_test (GstAtomicInt *aint) +gst_atomic_int_dec_and_test (GstAtomicInt * aint) { gboolean res; - + g_mutex_lock (aint->lock); aint->counter--; res = (aint->counter == 0); @@ -490,11 +534,11 @@ gst_atomic_int_dec_and_test (GstAtomicInt *aint) return res; } -#endif +#endif /* * common functions - */ -GST_INLINE_FUNC GstAtomicInt* + */ +GST_INLINE_FUNC GstAtomicInt * gst_atomic_int_new (gint val) { GstAtomicInt *aint; @@ -506,14 +550,13 @@ gst_atomic_int_new (gint val) } GST_INLINE_FUNC void -gst_atomic_int_free (GstAtomicInt *aint) +gst_atomic_int_free (GstAtomicInt * aint) { gst_atomic_int_destroy (aint); g_free (aint); } -#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)*/ +#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__) */ G_END_DECLS - #endif /* __GST_ATOMIC_IMPL_H__ */ diff --git a/gst/gstbin.c b/gst/gstbin.c index dea4c2852..37907a18f 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -33,40 +33,38 @@ #include "gstscheduler.h" #include "gstindex.h" -static GstElementDetails gst_bin_details = GST_ELEMENT_DETAILS ( - "Generic bin", - "Generic/Bin", - "Simple container object", - "Erik Walthinsen " -); +static GstElementDetails gst_bin_details = GST_ELEMENT_DETAILS ("Generic bin", + "Generic/Bin", + "Simple container object", + "Erik Walthinsen "); GType _gst_bin_type = 0; -static gboolean _gst_boolean_did_something_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, const GValue *handler_return, gpointer dummy); +static gboolean _gst_boolean_did_something_accumulator (GSignalInvocationHint * + ihint, GValue * return_accu, const GValue * handler_return, gpointer dummy); -static void gst_bin_dispose (GObject * object); +static void gst_bin_dispose (GObject * object); -static GstElementStateReturn gst_bin_change_state (GstElement *element); -static GstElementStateReturn gst_bin_change_state_norecurse (GstBin *bin); +static GstElementStateReturn gst_bin_change_state (GstElement * element); +static GstElementStateReturn gst_bin_change_state_norecurse (GstBin * bin); #ifndef GST_DISABLE_INDEX -static void gst_bin_set_index (GstElement *element, GstIndex *index); +static void gst_bin_set_index (GstElement * element, GstIndex * index); #endif -static void gst_bin_add_func (GstBin *bin, GstElement *element); -static void gst_bin_remove_func (GstBin *bin, GstElement *element); -static void gst_bin_child_state_change_func (GstBin *bin, GstElementState oldstate, - GstElementState newstate, GstElement *child); +static void gst_bin_add_func (GstBin * bin, GstElement * element); +static void gst_bin_remove_func (GstBin * bin, GstElement * element); +static void gst_bin_child_state_change_func (GstBin * bin, + GstElementState oldstate, GstElementState newstate, GstElement * child); -static GstClock* gst_bin_get_clock_func (GstElement *element); -static void gst_bin_set_clock_func (GstElement *element, GstClock *clock); +static GstClock *gst_bin_get_clock_func (GstElement * element); +static void gst_bin_set_clock_func (GstElement * element, GstClock * clock); -static gboolean gst_bin_iterate_func (GstBin *bin); +static gboolean gst_bin_iterate_func (GstBin * bin); #ifndef GST_DISABLE_LOADSAVE -static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent); -static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self); +static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent); +static void gst_bin_restore_thyself (GstObject * object, xmlNodePtr self); #endif /* Bin signals and args */ @@ -81,12 +79,12 @@ enum enum { ARG_0 - /* FILL ME */ + /* FILL ME */ }; -static void gst_bin_base_init (gpointer g_class); -static void gst_bin_class_init (GstBinClass * klass); -static void gst_bin_init (GstBin * bin); +static void gst_bin_base_init (gpointer g_class); +static void gst_bin_class_init (GstBinClass * klass); +static void gst_bin_init (GstBin * bin); static GstElementClass *parent_class = NULL; static guint gst_bin_signals[LAST_SIGNAL] = { 0 }; @@ -108,7 +106,8 @@ gst_bin_get_type (void) NULL }; - _gst_bin_type = g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0); + _gst_bin_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstBin", &bin_info, 0); } return _gst_bin_type; } @@ -117,7 +116,7 @@ static void gst_bin_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_bin_details); } @@ -135,40 +134,42 @@ gst_bin_class_init (GstBinClass * klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); gst_bin_signals[ELEMENT_ADDED] = - g_signal_new ("element-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstBinClass, element_added), NULL, NULL, - gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT); + g_signal_new ("element-added", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstBinClass, element_added), NULL, + NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT); gst_bin_signals[ELEMENT_REMOVED] = - g_signal_new ("element-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstBinClass, element_removed), NULL, NULL, - gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT); + g_signal_new ("element-removed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GstBinClass, element_removed), NULL, + NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_ELEMENT); gst_bin_signals[ITERATE] = - g_signal_new ("iterate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstBinClass, iterate), - _gst_boolean_did_something_accumulator, NULL, - gst_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); + g_signal_new ("iterate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstBinClass, iterate), + _gst_boolean_did_something_accumulator, NULL, gst_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, 0); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_bin_dispose); #ifndef GST_DISABLE_LOADSAVE - gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_bin_save_thyself); - gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_bin_restore_thyself); + gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_bin_save_thyself); + gstobject_class->restore_thyself = + GST_DEBUG_FUNCPTR (gst_bin_restore_thyself); #endif - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_bin_change_state); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_bin_change_state); #ifndef GST_DISABLE_INDEX - gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_bin_set_index); + gstelement_class->set_index = GST_DEBUG_FUNCPTR (gst_bin_set_index); #endif - klass->add_element = GST_DEBUG_FUNCPTR (gst_bin_add_func); - klass->remove_element = GST_DEBUG_FUNCPTR (gst_bin_remove_func); - klass->child_state_change = GST_DEBUG_FUNCPTR (gst_bin_child_state_change_func); - klass->iterate = GST_DEBUG_FUNCPTR (gst_bin_iterate_func); + klass->add_element = GST_DEBUG_FUNCPTR (gst_bin_add_func); + klass->remove_element = GST_DEBUG_FUNCPTR (gst_bin_remove_func); + klass->child_state_change = + GST_DEBUG_FUNCPTR (gst_bin_child_state_change_func); + klass->iterate = GST_DEBUG_FUNCPTR (gst_bin_iterate_func); } static gboolean -_gst_boolean_did_something_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, const GValue *handler_return, gpointer dummy) +_gst_boolean_did_something_accumulator (GSignalInvocationHint * ihint, + GValue * return_accu, const GValue * handler_return, gpointer dummy) { gboolean did_something; @@ -205,19 +206,19 @@ gst_bin_new (const gchar * name) return gst_element_factory_make ("bin", name); } -static GstClock* -gst_bin_get_clock_func (GstElement *element) +static GstClock * +gst_bin_get_clock_func (GstElement * element) { - if (GST_ELEMENT_SCHED (element)) + if (GST_ELEMENT_SCHED (element)) return gst_scheduler_get_clock (GST_ELEMENT_SCHED (element)); return NULL; } static void -gst_bin_set_clock_func (GstElement *element, GstClock *clock) +gst_bin_set_clock_func (GstElement * element, GstClock * clock) { - if (GST_ELEMENT_SCHED (element)) + if (GST_ELEMENT_SCHED (element)) gst_scheduler_use_clock (GST_ELEMENT_SCHED (element), clock); } @@ -229,8 +230,8 @@ gst_bin_set_clock_func (GstElement *element, GstClock *clock) * * Returns: the #GstClock of the bin */ -GstClock* -gst_bin_get_clock (GstBin *bin) +GstClock * +gst_bin_get_clock (GstBin * bin) { g_return_val_if_fail (bin != NULL, NULL); g_return_val_if_fail (GST_IS_BIN (bin), NULL); @@ -247,7 +248,7 @@ gst_bin_get_clock (GstBin *bin) * force it to use no clock at all. */ void -gst_bin_use_clock (GstBin *bin, GstClock *clock) +gst_bin_use_clock (GstBin * bin, GstClock * clock) { g_return_if_fail (GST_IS_BIN (bin)); @@ -261,20 +262,20 @@ gst_bin_use_clock (GstBin *bin, GstClock *clock) * Let the bin select a clock automatically. */ void -gst_bin_auto_clock (GstBin *bin) +gst_bin_auto_clock (GstBin * bin) { g_return_if_fail (GST_IS_BIN (bin)); - if (GST_ELEMENT_SCHED (bin)) + if (GST_ELEMENT_SCHED (bin)) gst_scheduler_auto_clock (GST_ELEMENT_SCHED (bin)); } #ifndef GST_DISABLE_INDEX static void -gst_bin_set_index (GstElement *element, GstIndex *index) +gst_bin_set_index (GstElement * element, GstIndex * index) { GstBin *bin = GST_BIN (element); - + g_return_if_fail (GST_IS_BIN (bin)); g_list_foreach (bin->children, (GFunc) gst_element_set_index, index); @@ -282,27 +283,28 @@ gst_bin_set_index (GstElement *element, GstIndex *index) #endif static void -gst_bin_set_element_sched (GstElement *element, GstScheduler *sched) +gst_bin_set_element_sched (GstElement * element, GstScheduler * sched) { GST_CAT_LOG (GST_CAT_SCHEDULING, "setting element \"%s\" sched to %p", - GST_ELEMENT_NAME (element), sched); + GST_ELEMENT_NAME (element), sched); /* if it's actually a Bin */ if (GST_IS_BIN (element)) { if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) { GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, - "child is already a manager, not resetting sched"); + "child is already a manager, not resetting sched"); if (GST_ELEMENT_SCHED (element)) - gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element)); + gst_scheduler_add_scheduler (sched, GST_ELEMENT_SCHED (element)); return; } GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, - "setting child bin's scheduler to be the same as the parent's"); + "setting child bin's scheduler to be the same as the parent's"); gst_scheduler_add_element (sched, element); /* set the children's schedule */ - g_list_foreach (GST_BIN (element)->children, (GFunc) gst_bin_set_element_sched, sched); + g_list_foreach (GST_BIN (element)->children, + (GFunc) gst_bin_set_element_sched, sched); } /* otherwise, if it's just a regular old element */ else { @@ -320,19 +322,19 @@ gst_bin_set_element_sched (GstElement *element, GstScheduler *sched) /* we only operate on real pads */ if (!GST_IS_REAL_PAD (pad)) - continue; + continue; /* if the peer element exists and is a candidate */ if (GST_PAD_PEER (pad)) { - if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) { - GST_CAT_LOG (GST_CAT_SCHEDULING, - "peer is in same scheduler, telling scheduler"); - - if (GST_PAD_IS_SRC (pad)) - gst_scheduler_pad_link (sched, pad, GST_PAD_PEER (pad)); - else - gst_scheduler_pad_link (sched, GST_PAD_PEER (pad), pad); - } + if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) { + GST_CAT_LOG (GST_CAT_SCHEDULING, + "peer is in same scheduler, telling scheduler"); + + if (GST_PAD_IS_SRC (pad)) + gst_scheduler_pad_link (sched, pad, GST_PAD_PEER (pad)); + else + gst_scheduler_pad_link (sched, GST_PAD_PEER (pad), pad); + } } } } @@ -340,30 +342,32 @@ gst_bin_set_element_sched (GstElement *element, GstScheduler *sched) static void -gst_bin_unset_element_sched (GstElement *element, GstScheduler *sched) +gst_bin_unset_element_sched (GstElement * element, GstScheduler * sched) { if (GST_ELEMENT_SCHED (element) == NULL) { GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element \"%s\" has no scheduler", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); return; } - GST_CAT_DEBUG (GST_CAT_SCHEDULING, "removing element \"%s\" from its sched %p", - GST_ELEMENT_NAME (element), GST_ELEMENT_SCHED (element)); + GST_CAT_DEBUG (GST_CAT_SCHEDULING, + "removing element \"%s\" from its sched %p", GST_ELEMENT_NAME (element), + GST_ELEMENT_SCHED (element)); /* if it's actually a Bin */ if (GST_IS_BIN (element)) { if (GST_FLAG_IS_SET (element, GST_BIN_FLAG_MANAGER)) { GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, - "child is already a manager, not unsetting sched"); + "child is already a manager, not unsetting sched"); if (sched) { - gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element)); + gst_scheduler_remove_scheduler (sched, GST_ELEMENT_SCHED (element)); } return; } /* for each child, remove them from their schedule */ - g_list_foreach (GST_BIN (element)->children, (GFunc) gst_bin_unset_element_sched, sched); + g_list_foreach (GST_BIN (element)->children, + (GFunc) gst_bin_unset_element_sched, sched); gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element); } @@ -381,18 +385,19 @@ gst_bin_unset_element_sched (GstElement *element, GstScheduler *sched) /* we only operate on real pads */ if (!GST_IS_REAL_PAD (pad)) - continue; + continue; /* if the peer element exists and is a candidate */ if (GST_PAD_PEER (pad)) { - if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) { - GST_CAT_LOG (GST_CAT_SCHEDULING, "peer is in same scheduler, telling scheduler"); - - if (GST_PAD_IS_SRC (pad)) - gst_scheduler_pad_unlink (sched, pad, GST_PAD_PEER (pad)); - else - gst_scheduler_pad_unlink (sched, GST_PAD_PEER (pad), pad); - } + if (gst_pad_get_scheduler (GST_PAD_PEER (pad)) == sched) { + GST_CAT_LOG (GST_CAT_SCHEDULING, + "peer is in same scheduler, telling scheduler"); + + if (GST_PAD_IS_SRC (pad)) + gst_scheduler_pad_unlink (sched, pad, GST_PAD_PEER (pad)); + else + gst_scheduler_pad_unlink (sched, GST_PAD_PEER (pad), pad); + } } } gst_scheduler_remove_element (GST_ELEMENT_SCHED (element), element); @@ -409,7 +414,7 @@ gst_bin_unset_element_sched (GstElement *element, GstScheduler *sched) * Add a list of elements to a bin. Uses #gst_bin_add. */ void -gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) +gst_bin_add_many (GstBin * bin, GstElement * element_1, ...) { va_list args; @@ -420,15 +425,15 @@ gst_bin_add_many (GstBin *bin, GstElement *element_1, ...) while (element_1) { gst_bin_add (bin, element_1); - - element_1 = va_arg (args, GstElement*); + + element_1 = va_arg (args, GstElement *); } va_end (args); } static void -gst_bin_add_func (GstBin *bin, GstElement *element) +gst_bin_add_func (GstBin * bin, GstElement * element) { gint state_idx = 0; GstElementState state; @@ -438,11 +443,10 @@ gst_bin_add_func (GstBin *bin, GstElement *element) g_return_if_fail (GST_ELEMENT_PARENT (element) == NULL); /* then check to see if the element's name is already taken in the bin */ - if (gst_object_check_uniqueness (bin->children, - GST_ELEMENT_NAME (element)) == FALSE) - { + if (gst_object_check_uniqueness (bin->children, + GST_ELEMENT_NAME (element)) == FALSE) { g_warning ("Name %s is not unique in bin %s, not adding\n", - GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin)); + GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin)); return; } @@ -454,7 +458,8 @@ gst_bin_add_func (GstBin *bin, GstElement *element) /* bump our internal state counter */ state = GST_STATE (element); - while (state >>= 1) state_idx++; + while (state >>= 1) + state_idx++; bin->child_states[state_idx]++; /* now we have to deal with manager stuff @@ -465,8 +470,8 @@ gst_bin_add_func (GstBin *bin, GstElement *element) gst_bin_set_element_sched (element, sched); } - GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin, "added element \"%s\"", - GST_OBJECT_NAME (element)); + GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, bin, "added element \"%s\"", + GST_OBJECT_NAME (element)); g_signal_emit (G_OBJECT (bin), gst_bin_signals[ELEMENT_ADDED], 0, element); } @@ -480,30 +485,29 @@ gst_bin_add_func (GstBin *bin, GstElement *element) * add a reference. */ void -gst_bin_add (GstBin *bin, GstElement *element) +gst_bin_add (GstBin * bin, GstElement * element) { GstBinClass *bclass; - + g_return_if_fail (GST_IS_BIN (bin)); g_return_if_fail (GST_IS_ELEMENT (element)); GST_CAT_INFO_OBJECT (GST_CAT_PARENTAGE, bin, "adding element \"%s\"", - GST_OBJECT_NAME (element)); + GST_OBJECT_NAME (element)); bclass = GST_BIN_GET_CLASS (bin); if (bclass->add_element) { bclass->add_element (bin, element); - } - else { + } else { GST_ELEMENT_ERROR (bin, CORE, FAILED, (NULL), - ("cannot add element %s to bin %s", - GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin))); + ("cannot add element %s to bin %s", + GST_ELEMENT_NAME (element), GST_ELEMENT_NAME (bin))); } } static void -gst_bin_remove_func (GstBin *bin, GstElement *element) +gst_bin_remove_func (GstBin * bin, GstElement * element) { gint state_idx = 0; GstElementState state; @@ -514,7 +518,7 @@ gst_bin_remove_func (GstBin *bin, GstElement *element) /* the element must be in the bin's list of children */ if (g_list_find (bin->children, element) == NULL) { g_warning ("no element \"%s\" in bin \"%s\"\n", GST_ELEMENT_NAME (element), - GST_ELEMENT_NAME (bin)); + GST_ELEMENT_NAME (bin)); return; } @@ -527,11 +531,12 @@ gst_bin_remove_func (GstBin *bin, GstElement *element) /* bump our internal state counter */ state = GST_STATE (element); - while (state >>= 1) state_idx++; + while (state >>= 1) + state_idx++; bin->child_states[state_idx]--; - GST_CAT_INFO_OBJECT (GST_CAT_PARENTAGE, bin, "removed child \"%s\"", - GST_OBJECT_NAME (element)); + GST_CAT_INFO_OBJECT (GST_CAT_PARENTAGE, bin, "removed child \"%s\"", + GST_OBJECT_NAME (element)); /* ref as we're going to emit a signal */ gst_object_ref (GST_OBJECT (element)); @@ -560,12 +565,12 @@ gst_bin_remove_func (GstBin *bin, GstElement *element) * #gst_object_ref before removing it from the bin. */ void -gst_bin_remove (GstBin *bin, GstElement *element) +gst_bin_remove (GstBin * bin, GstElement * element) { GstBinClass *bclass; GST_CAT_DEBUG (GST_CAT_PARENTAGE, "[%s]: trying to remove child %s", - GST_ELEMENT_NAME (bin), GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (bin), GST_ELEMENT_NAME (element)); g_return_if_fail (GST_IS_BIN (bin)); g_return_if_fail (GST_IS_ELEMENT (element)); @@ -575,8 +580,7 @@ gst_bin_remove (GstBin *bin, GstElement *element) if (bclass->remove_element) { bclass->remove_element (bin, element); - } - else { + } else { g_warning ("cannot remove elements from bin %s\n", GST_ELEMENT_NAME (bin)); } } @@ -590,7 +594,7 @@ gst_bin_remove (GstBin *bin, GstElement *element) * Remove a list of elements from a bin. Uses #gst_bin_remove. */ void -gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) +gst_bin_remove_many (GstBin * bin, GstElement * element_1, ...) { va_list args; @@ -601,8 +605,8 @@ gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) while (element_1) { gst_bin_remove (bin, element_1); - - element_1 = va_arg (args, GstElement*); + + element_1 = va_arg (args, GstElement *); } va_end (args); @@ -619,57 +623,58 @@ gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...) * of a child. */ void -gst_bin_child_state_change (GstBin *bin, GstElementState oldstate, - GstElementState newstate, GstElement *child) +gst_bin_child_state_change (GstBin * bin, GstElementState oldstate, + GstElementState newstate, GstElement * child) { GstBinClass *bclass; - + g_return_if_fail (GST_IS_BIN (bin)); g_return_if_fail (GST_IS_ELEMENT (child)); GST_CAT_LOG (GST_CAT_STATES, "child %s changed state in bin %s from %s to %s", - GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin), - gst_element_state_get_name (oldstate), - gst_element_state_get_name (newstate)); + GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin), + gst_element_state_get_name (oldstate), + gst_element_state_get_name (newstate)); bclass = GST_BIN_GET_CLASS (bin); if (bclass->child_state_change) { bclass->child_state_change (bin, oldstate, newstate, child); - } - else { - g_warning ("cannot signal state change of child %s to bin %s\n", - GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin)); + } else { + g_warning ("cannot signal state change of child %s to bin %s\n", + GST_ELEMENT_NAME (child), GST_ELEMENT_NAME (bin)); } } static void -gst_bin_child_state_change_func (GstBin *bin, GstElementState oldstate, - GstElementState newstate, GstElement *child) +gst_bin_child_state_change_func (GstBin * bin, GstElementState oldstate, + GstElementState newstate, GstElement * child) { gint old_idx = 0, new_idx = 0, i; - while (oldstate >>= 1) old_idx++; - while (newstate >>= 1) new_idx++; + while (oldstate >>= 1) + old_idx++; + while (newstate >>= 1) + new_idx++; GST_LOCK (bin); bin->child_states[old_idx]--; bin->child_states[new_idx]++; - + for (i = GST_NUM_STATES - 1; i >= 0; i--) { if (bin->child_states[i] != 0) { gint state = (1 << i); + if (GST_STATE (bin) != state) { GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, bin, - "highest child state is %s, changing bin state accordingly", - gst_element_state_get_name (state)); + "highest child state is %s, changing bin state accordingly", + gst_element_state_get_name (state)); GST_STATE_PENDING (bin) = state; - GST_UNLOCK (bin); + GST_UNLOCK (bin); gst_bin_change_state_norecurse (bin); if (state != GST_STATE (bin)) { - g_warning ("%s: state change in callback %d %d", - GST_ELEMENT_NAME (bin), - state, GST_STATE (bin)); + g_warning ("%s: state change in callback %d %d", + GST_ELEMENT_NAME (bin), state, GST_STATE (bin)); } return; } @@ -699,18 +704,17 @@ gst_bin_change_state (GstElement * element) transition = GST_STATE_TRANSITION (element); GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "changing state of children from %s to %s", - gst_element_state_get_name (old_state), - gst_element_state_get_name (pending)); + "changing state of children from %s to %s", + gst_element_state_get_name (old_state), + gst_element_state_get_name (pending)); if (pending == GST_STATE_VOID_PENDING) return GST_STATE_SUCCESS; - if (old_state == pending) - { - GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, - "old and pending state are both %s, returning", - gst_element_state_get_name (pending)); + if (old_state == pending) { + GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, + "old and pending state are both %s, returning", + gst_element_state_get_name (pending)); return GST_STATE_SUCCESS; } @@ -728,16 +732,16 @@ gst_bin_change_state (GstElement * element) old_child_state = GST_STATE (child); GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "changing state of child %s from current %s to pending %s", - GST_ELEMENT_NAME (child), gst_element_state_get_name (old_child_state), - gst_element_state_get_name (pending)); + "changing state of child %s from current %s to pending %s", + GST_ELEMENT_NAME (child), gst_element_state_get_name (old_child_state), + gst_element_state_get_name (pending)); switch (gst_element_set_state (child, pending)) { case GST_STATE_FAILURE: GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "child '%s' failed to go to state %d(%s)", - GST_ELEMENT_NAME (child), - pending, gst_element_state_get_name (pending)); + "child '%s' failed to go to state %d(%s)", + GST_ELEMENT_NAME (child), + pending, gst_element_state_get_name (pending)); gst_element_set_state (child, old_child_state); /* There was a check for elements being in the same scheduling group @@ -750,30 +754,31 @@ gst_bin_change_state (GstElement * element) break; case GST_STATE_ASYNC: GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "child '%s' is changing state asynchronously", - GST_ELEMENT_NAME (child)); + "child '%s' is changing state asynchronously", + GST_ELEMENT_NAME (child)); have_async = TRUE; break; case GST_STATE_SUCCESS: - GST_CAT_DEBUG (GST_CAT_STATES, "child '%s' changed state to %d(%s) successfully", - GST_ELEMENT_NAME (child), pending, gst_element_state_get_name (pending)); - break; + GST_CAT_DEBUG (GST_CAT_STATES, + "child '%s' changed state to %d(%s) successfully", + GST_ELEMENT_NAME (child), pending, + gst_element_state_get_name (pending)); + break; } } GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "done changing bin's state from %s to %s, now in %s", - gst_element_state_get_name (old_state), - gst_element_state_get_name (pending), - gst_element_state_get_name (GST_STATE (element))); + "done changing bin's state from %s to %s, now in %s", + gst_element_state_get_name (old_state), + gst_element_state_get_name (pending), + gst_element_state_get_name (GST_STATE (element))); if (have_async) ret = GST_STATE_ASYNC; else { if (parent_class->change_state) { - ret = parent_class->change_state(element); - } - else + ret = parent_class->change_state (element); + } else ret = GST_STATE_SUCCESS; } return ret; @@ -790,8 +795,7 @@ gst_bin_change_state_norecurse (GstBin * bin) ret = parent_class->change_state (GST_ELEMENT (bin)); return ret; - } - else + } else return GST_STATE_FAILURE; } @@ -842,8 +846,8 @@ gst_bin_get_by_name (GstBin * bin, const gchar * name) g_return_val_if_fail (GST_IS_BIN (bin), NULL); g_return_val_if_fail (name != NULL, NULL); - GST_CAT_INFO (GST_CAT_PARENTAGE, "[%s]: looking up child element %s", - GST_ELEMENT_NAME (bin), name); + GST_CAT_INFO (GST_CAT_PARENTAGE, "[%s]: looking up child element %s", + GST_ELEMENT_NAME (bin), name); children = bin->children; while (children) { @@ -925,10 +929,10 @@ gst_bin_get_list (GstBin * bin) * Returns: An element inside the bin implementing the interface. */ GstElement * -gst_bin_get_by_interface (GstBin *bin, GType interface) +gst_bin_get_by_interface (GstBin * bin, GType interface) { GList *walk; - + g_return_val_if_fail (GST_IS_BIN (bin), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL); @@ -938,6 +942,7 @@ gst_bin_get_by_interface (GstBin *bin, GType interface) return GST_ELEMENT (walk->data); if (GST_IS_BIN (walk->data)) { GstElement *ret; + ret = gst_bin_get_by_interface (GST_BIN (walk->data), interface); if (ret) return ret; @@ -961,10 +966,10 @@ gst_bin_get_by_interface (GstBin *bin, GType interface) * Returns: An element inside the bin implementing the interface. */ GList * -gst_bin_get_all_by_interface (GstBin *bin, GType interface) +gst_bin_get_all_by_interface (GstBin * bin, GType interface) { GList *walk, *ret = NULL; - + g_return_val_if_fail (GST_IS_BIN (bin), NULL); g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface), NULL); @@ -973,13 +978,13 @@ gst_bin_get_all_by_interface (GstBin *bin, GType interface) if (G_TYPE_CHECK_INSTANCE_TYPE (walk->data, interface)) ret = g_list_prepend (ret, walk->data); if (GST_IS_BIN (walk->data)) { - ret = g_list_concat (ret, + ret = g_list_concat (ret, gst_bin_get_all_by_interface (GST_BIN (walk->data), interface)); } walk = g_list_next (walk); } - return ret; + return ret; } /** @@ -995,7 +1000,7 @@ gst_bin_get_all_by_interface (GstBin *bin, GType interface) * this function returns #GST_STATE_FAILURE. */ GstElementStateReturn -gst_bin_sync_children_state (GstBin *bin) +gst_bin_sync_children_state (GstBin * bin) { GList *children; GstElement *element; @@ -1006,31 +1011,33 @@ gst_bin_sync_children_state (GstBin *bin) state = GST_STATE (bin); children = bin->children; - GST_CAT_INFO (GST_CAT_STATES, "syncing state of children with bin \"%s\"'s state %s", - GST_ELEMENT_NAME (bin), gst_element_state_get_name (state)); + GST_CAT_INFO (GST_CAT_STATES, + "syncing state of children with bin \"%s\"'s state %s", + GST_ELEMENT_NAME (bin), gst_element_state_get_name (state)); while (children) { element = GST_ELEMENT (children->data); children = children->next; - if (GST_STATE(element) != state) { + if (GST_STATE (element) != state) { switch (gst_element_set_state (element, state)) { - case GST_STATE_SUCCESS: - break; - case GST_STATE_ASYNC: - if (ret == GST_STATE_SUCCESS) - ret = GST_STATE_ASYNC; - break; - case GST_STATE_FAILURE: - ret = GST_STATE_FAILURE; - default: - /* make sure gst_element_set_state never returns this */ - g_assert_not_reached (); + case GST_STATE_SUCCESS: + break; + case GST_STATE_ASYNC: + if (ret == GST_STATE_SUCCESS) + ret = GST_STATE_ASYNC; + break; + case GST_STATE_FAILURE: + ret = GST_STATE_FAILURE; + default: + /* make sure gst_element_set_state never returns this */ + g_assert_not_reached (); } } } return ret; } + #ifndef GST_DISABLE_LOADSAVE static xmlNodePtr gst_bin_save_thyself (GstObject * object, xmlNodePtr parent) @@ -1045,8 +1052,8 @@ gst_bin_save_thyself (GstObject * object, xmlNodePtr parent) childlist = xmlNewChild (parent, NULL, "children", NULL); - GST_CAT_INFO (GST_CAT_XML, "[%s]: saving %d children", - GST_ELEMENT_NAME (bin), bin->numchildren); + GST_CAT_INFO (GST_CAT_XML, "[%s]: saving %d children", + GST_ELEMENT_NAME (bin), bin->numchildren); children = bin->children; while (children) { @@ -1067,17 +1074,19 @@ gst_bin_restore_thyself (GstObject * object, xmlNodePtr self) while (field) { if (!strcmp (field->name, "children")) { - GST_CAT_INFO (GST_CAT_XML, "[%s]: loading children", GST_ELEMENT_NAME (object)); + GST_CAT_INFO (GST_CAT_XML, "[%s]: loading children", + GST_ELEMENT_NAME (object)); childlist = field->xmlChildrenNode; while (childlist) { if (!strcmp (childlist->name, "element")) { - GstElement *element = gst_xml_make_element (childlist, GST_OBJECT (bin)); - - /* it had to be parented to find the pads, now we ref and unparent so - * we can add it to the bin */ - gst_object_ref (GST_OBJECT (element)); - gst_object_unparent (GST_OBJECT (element)); - + GstElement *element = + gst_xml_make_element (childlist, GST_OBJECT (bin)); + + /* it had to be parented to find the pads, now we ref and unparent so + * we can add it to the bin */ + gst_object_ref (GST_OBJECT (element)); + gst_object_unparent (GST_OBJECT (element)); + gst_bin_add (bin, element); } childlist = childlist->next; @@ -1101,14 +1110,12 @@ gst_bin_iterate_func (GstBin * bin) if (state == GST_SCHEDULER_STATE_RUNNING) { return TRUE; - } - else if (state == GST_SCHEDULER_STATE_ERROR) { + } else if (state == GST_SCHEDULER_STATE_ERROR) { gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); } - } - else { - g_warning ("bin \"%s\" is not the managing bin, can't be iterated on!\n", - GST_ELEMENT_NAME (bin)); + } else { + g_warning ("bin \"%s\" is not the managing bin, can't be iterated on!\n", + GST_ELEMENT_NAME (bin)); } return FALSE; @@ -1124,7 +1131,7 @@ gst_bin_iterate_func (GstBin * bin) * can be used to determine it the bin is in EOS. */ gboolean -gst_bin_iterate (GstBin *bin) +gst_bin_iterate (GstBin * bin) { gboolean running; @@ -1141,10 +1148,11 @@ gst_bin_iterate (GstBin *bin) GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, bin, "finished iteration"); if (!running) { - if (GST_STATE (bin) == GST_STATE_PLAYING && + if (GST_STATE (bin) == GST_STATE_PLAYING && GST_STATE_PENDING (bin) == GST_STATE_VOID_PENDING) { - GST_CAT_DEBUG (GST_CAT_DATAFLOW, "[%s]: polling for child shutdown after useless iteration", - GST_ELEMENT_NAME (bin)); + GST_CAT_DEBUG (GST_CAT_DATAFLOW, + "[%s]: polling for child shutdown after useless iteration", + GST_ELEMENT_NAME (bin)); g_usleep (1); running = TRUE; } diff --git a/gst/gstbin.h b/gst/gstbin.h index 60cdbf6cf..5071ace73 100644 --- a/gst/gstbin.h +++ b/gst/gstbin.h @@ -26,9 +26,7 @@ #include -G_BEGIN_DECLS - -extern GType _gst_bin_type; +G_BEGIN_DECLS extern GType _gst_bin_type; #define GST_TYPE_BIN (_gst_bin_type) #define GST_IS_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BIN)) @@ -37,11 +35,12 @@ extern GType _gst_bin_type; #define GST_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BIN, GstBin)) #define GST_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BIN, GstBinClass)) -typedef void (*GstBinPrePostIterateFunction) (GstBin *bin, gpointer user_data); +typedef void (*GstBinPrePostIterateFunction) (GstBin * bin, gpointer user_data); -typedef enum { +typedef enum +{ /* this bin is a manager of child elements, i.e. a pipeline or thread */ - GST_BIN_FLAG_MANAGER = GST_ELEMENT_FLAG_LAST, + GST_BIN_FLAG_MANAGER = GST_ELEMENT_FLAG_LAST, /* this bin iterates itself */ GST_BIN_SELF_SCHEDULABLE, @@ -52,81 +51,78 @@ typedef enum { GST_BIN_FLAG_FIXED_CLOCK, /* padding */ - GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5 + GST_BIN_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 5 } GstBinFlags; /*typedef struct _GstBin GstBin; */ /*typedef struct _GstBinClass GstBinClass; */ -struct _GstBin { - GstElement element; +struct _GstBin +{ + GstElement element; /* our children */ - gint numchildren; - GList *children; + gint numchildren; + GList *children; GstElementState child_states[GST_NUM_STATES]; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstBinClass { +struct _GstBinClass +{ GstElementClass parent_class; /* vtable */ - void (*add_element) (GstBin *bin, GstElement *element); - void (*remove_element) (GstBin *bin, GstElement *element); - void (*child_state_change) (GstBin *bin, GstElementState oldstate, - GstElementState newstate, GstElement *element); + void (*add_element) (GstBin * bin, GstElement * element); + void (*remove_element) (GstBin * bin, GstElement * element); + void (*child_state_change) (GstBin * bin, GstElementState oldstate, + GstElementState newstate, GstElement * element); /* run a full iteration of operation */ - gboolean (*iterate) (GstBin *bin); + gboolean (*iterate) (GstBin * bin); /* signals */ - void (*element_added) (GstBin *bin, GstElement *child); - void (*element_removed) (GstBin *bin, GstElement *child); + void (*element_added) (GstBin * bin, GstElement * child); + void (*element_removed) (GstBin * bin, GstElement * child); gpointer _gst_reserved[GST_PADDING]; }; -GType gst_bin_get_type (void); -GstElement* gst_bin_new (const gchar *name); +GType gst_bin_get_type (void); +GstElement *gst_bin_new (const gchar * name); /* add and remove elements from the bin */ -void gst_bin_add (GstBin *bin, GstElement *element); -void gst_bin_add_many (GstBin *bin, GstElement *element_1, ...); -void gst_bin_remove (GstBin *bin, GstElement *element); -void gst_bin_remove_many (GstBin *bin, GstElement *element_1, ...); +void gst_bin_add (GstBin * bin, GstElement * element); +void gst_bin_add_many (GstBin * bin, GstElement * element_1, ...); +void gst_bin_remove (GstBin * bin, GstElement * element); +void gst_bin_remove_many (GstBin * bin, GstElement * element_1, ...); /* retrieve a single element or the list of children */ -GstElement* gst_bin_get_by_name (GstBin *bin, const gchar *name); -GstElement* gst_bin_get_by_name_recurse_up (GstBin *bin, const gchar *name); -G_CONST_RETURN GList* - gst_bin_get_list (GstBin *bin); -GstElement* gst_bin_get_by_interface (GstBin *bin, GType interface); -GList * gst_bin_get_all_by_interface (GstBin *bin, GType interface); +GstElement *gst_bin_get_by_name (GstBin * bin, const gchar * name); +GstElement *gst_bin_get_by_name_recurse_up (GstBin * bin, const gchar * name); +G_CONST_RETURN GList *gst_bin_get_list (GstBin * bin); +GstElement *gst_bin_get_by_interface (GstBin * bin, GType interface); +GList *gst_bin_get_all_by_interface (GstBin * bin, GType interface); -gboolean gst_bin_iterate (GstBin *bin); +gboolean gst_bin_iterate (GstBin * bin); -void gst_bin_use_clock (GstBin *bin, GstClock *clock); -GstClock* gst_bin_get_clock (GstBin *bin); -void gst_bin_auto_clock (GstBin *bin); +void gst_bin_use_clock (GstBin * bin, GstClock * clock); +GstClock *gst_bin_get_clock (GstBin * bin); +void gst_bin_auto_clock (GstBin * bin); -GstElementStateReturn gst_bin_sync_children_state (GstBin *bin); +GstElementStateReturn gst_bin_sync_children_state (GstBin * bin); /* internal */ /* one of our childs signaled a state change */ -void gst_bin_child_state_change (GstBin *bin, GstElementState oldstate, - GstElementState newstate, GstElement *child); +void gst_bin_child_state_change (GstBin * bin, GstElementState oldstate, + GstElementState newstate, GstElement * child); -void gst_bin_set_pre_iterate_function (GstBin *bin, - GstBinPrePostIterateFunction func, - gpointer user_data); -void gst_bin_set_post_iterate_function (GstBin *bin, - GstBinPrePostIterateFunction func, - gpointer user_data); +void gst_bin_set_pre_iterate_function (GstBin * bin, + GstBinPrePostIterateFunction func, gpointer user_data); +void gst_bin_set_post_iterate_function (GstBin * bin, + GstBinPrePostIterateFunction func, gpointer user_data); G_END_DECLS - - #endif /* __GST_BIN_H__ */ diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index cc0f52658..bcf881944 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -43,15 +43,14 @@ void _gst_buffer_initialize (void) { _gst_buffer_type = g_boxed_type_register_static ("GstBuffer", - (GBoxedCopyFunc) gst_data_copy, - (GBoxedFreeFunc) gst_data_unref); + (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref); #ifndef GST_DISABLE_TRACE _gst_buffer_trace = gst_alloc_trace_register (GST_BUFFER_TRACE_NAME); #endif - chunk = gst_mem_chunk_new ("GstBufferChunk", sizeof (GstBuffer), - sizeof (GstBuffer) * 200, 0); + chunk = gst_mem_chunk_new ("GstBufferChunk", sizeof (GstBuffer), + sizeof (GstBuffer) * 200, 0); GST_CAT_LOG (GST_CAT_BUFFER, "Buffers are initialized now"); } @@ -63,7 +62,7 @@ gst_buffer_get_type (void) } static void -_gst_buffer_sub_free (GstBuffer *buffer) +_gst_buffer_sub_free (GstBuffer * buffer) { gst_data_unref (GST_DATA (buffer->buffer_private)); @@ -71,7 +70,7 @@ _gst_buffer_sub_free (GstBuffer *buffer) GST_BUFFER_SIZE (buffer) = 0; _GST_DATA_DISPOSE (GST_DATA (buffer)); - + gst_mem_chunk_free (chunk, GST_DATA (buffer)); #ifndef GST_DISABLE_TRACE gst_alloc_trace_free (_gst_buffer_trace, buffer); @@ -86,14 +85,14 @@ _gst_buffer_sub_free (GstBuffer *buffer) * unless the GST_BUFFER_DONTFREE flags was set or the buffer data is NULL. */ void -gst_buffer_default_free (GstBuffer *buffer) +gst_buffer_default_free (GstBuffer * buffer) { g_return_if_fail (buffer != NULL); /* free our data */ if (GST_BUFFER_FREE_DATA_FUNC (buffer)) { GST_BUFFER_FREE_DATA_FUNC (buffer) (buffer); - } else if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_DONTFREE)) { + } else if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_DONTFREE)) { g_free (GST_BUFFER_DATA (buffer)); } @@ -118,16 +117,17 @@ gst_buffer_default_free (GstBuffer *buffer) * the other. */ void -gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src) +gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src) { g_return_if_fail (dest != NULL); g_return_if_fail (src != NULL); - - GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src); - GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src); - GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src); - GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src); + + GST_BUFFER_TIMESTAMP (dest) = GST_BUFFER_TIMESTAMP (src); + GST_BUFFER_DURATION (dest) = GST_BUFFER_DURATION (src); + GST_BUFFER_OFFSET (dest) = GST_BUFFER_OFFSET (src); + GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_END (src); } + /** * gst_buffer_default_copy: * @buffer: a #GstBuffer to make a copy of. @@ -136,8 +136,8 @@ gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src) * * Returns: the new #GstBuffer. */ -GstBuffer* -gst_buffer_default_copy (GstBuffer *buffer) +GstBuffer * +gst_buffer_default_copy (GstBuffer * buffer) { GstBuffer *copy; @@ -149,17 +149,17 @@ gst_buffer_default_copy (GstBuffer *buffer) gst_alloc_trace_new (_gst_buffer_trace, copy); #endif - _GST_DATA_INIT (GST_DATA (copy), - _gst_buffer_type, - 0, - (GstDataFreeFunction) gst_buffer_default_free, - (GstDataCopyFunction) gst_buffer_default_copy); + _GST_DATA_INIT (GST_DATA (copy), + _gst_buffer_type, + 0, + (GstDataFreeFunction) gst_buffer_default_free, + (GstDataCopyFunction) gst_buffer_default_copy); /* we simply copy everything from our parent */ - GST_BUFFER_DATA (copy) = g_memdup (GST_BUFFER_DATA (buffer), - GST_BUFFER_SIZE (buffer)); - GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer); - GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer); + GST_BUFFER_DATA (copy) = g_memdup (GST_BUFFER_DATA (buffer), + GST_BUFFER_SIZE (buffer)); + GST_BUFFER_SIZE (copy) = GST_BUFFER_SIZE (buffer); + GST_BUFFER_MAXSIZE (copy) = GST_BUFFER_SIZE (buffer); gst_buffer_stamp (copy, buffer); GST_BUFFER_FREE_DATA_FUNC (copy) = NULL; @@ -175,11 +175,11 @@ gst_buffer_default_copy (GstBuffer *buffer) * * Returns: the new #GstBuffer. */ -GstBuffer* +GstBuffer * gst_buffer_new (void) { GstBuffer *newbuf; - + newbuf = gst_mem_chunk_alloc (chunk); #ifndef GST_DISABLE_TRACE gst_alloc_trace_new (_gst_buffer_trace, newbuf); @@ -187,19 +187,19 @@ gst_buffer_new (void) GST_CAT_LOG (GST_CAT_BUFFER, "new %p", newbuf); - _GST_DATA_INIT (GST_DATA (newbuf), - _gst_buffer_type, - 0, - (GstDataFreeFunction) gst_buffer_default_free, - (GstDataCopyFunction) gst_buffer_default_copy); - - GST_BUFFER_DATA (newbuf) = NULL; - GST_BUFFER_SIZE (newbuf) = 0; - GST_BUFFER_MAXSIZE (newbuf) = GST_BUFFER_MAXSIZE_NONE; - GST_BUFFER_TIMESTAMP (newbuf) = GST_CLOCK_TIME_NONE; - GST_BUFFER_DURATION (newbuf) = GST_CLOCK_TIME_NONE; - GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET_NONE; - GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_NONE; + _GST_DATA_INIT (GST_DATA (newbuf), + _gst_buffer_type, + 0, + (GstDataFreeFunction) gst_buffer_default_free, + (GstDataCopyFunction) gst_buffer_default_copy); + + GST_BUFFER_DATA (newbuf) = NULL; + GST_BUFFER_SIZE (newbuf) = 0; + GST_BUFFER_MAXSIZE (newbuf) = GST_BUFFER_MAXSIZE_NONE; + GST_BUFFER_TIMESTAMP (newbuf) = GST_CLOCK_TIME_NONE; + GST_BUFFER_DURATION (newbuf) = GST_CLOCK_TIME_NONE; + GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET_NONE; + GST_BUFFER_OFFSET_END (newbuf) = GST_BUFFER_OFFSET_NONE; GST_BUFFER_FREE_DATA_FUNC (newbuf) = NULL; GST_BUFFER_PRIVATE (newbuf) = NULL; @@ -214,15 +214,15 @@ gst_buffer_new (void) * * Returns: the new #GstBuffer. */ -GstBuffer* +GstBuffer * gst_buffer_new_and_alloc (guint size) { GstBuffer *newbuf; newbuf = gst_buffer_new (); - GST_BUFFER_DATA (newbuf) = g_malloc (size); - GST_BUFFER_SIZE (newbuf) = size; + GST_BUFFER_DATA (newbuf) = g_malloc (size); + GST_BUFFER_SIZE (newbuf) = size; GST_BUFFER_MAXSIZE (newbuf) = size; return newbuf; @@ -242,12 +242,12 @@ gst_buffer_new_and_alloc (guint size) * * Returns: the new #GstBuffer, or NULL if there was an error. */ -GstBuffer* -gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size) +GstBuffer * +gst_buffer_create_sub (GstBuffer * parent, guint offset, guint size) { GstBuffer *buffer; gpointer buffer_data; - + g_return_val_if_fail (parent != NULL, NULL); g_return_val_if_fail (GST_BUFFER_REFCOUNT_VALUE (parent) > 0, NULL); g_return_val_if_fail (size > 0, NULL); @@ -272,32 +272,31 @@ gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size) /* make sure nobody overwrites data in the new buffer * by setting the READONLY flag */ - _GST_DATA_INIT (GST_DATA (buffer), - _gst_buffer_type, - GST_DATA_FLAG_SHIFT (GST_BUFFER_SUBBUFFER) | - GST_DATA_FLAG_SHIFT (GST_DATA_READONLY), - (GstDataFreeFunction) _gst_buffer_sub_free, - (GstDataCopyFunction) gst_buffer_default_copy); + _GST_DATA_INIT (GST_DATA (buffer), + _gst_buffer_type, + GST_DATA_FLAG_SHIFT (GST_BUFFER_SUBBUFFER) | + GST_DATA_FLAG_SHIFT (GST_DATA_READONLY), + (GstDataFreeFunction) _gst_buffer_sub_free, + (GstDataCopyFunction) gst_buffer_default_copy); /* set the right values in the child */ - GST_BUFFER_DATA (buffer) = buffer_data; - GST_BUFFER_SIZE (buffer) = size; - GST_BUFFER_MAXSIZE (buffer) = size; + GST_BUFFER_DATA (buffer) = buffer_data; + GST_BUFFER_SIZE (buffer) = size; + GST_BUFFER_MAXSIZE (buffer) = size; GST_BUFFER_FREE_DATA_FUNC (buffer) = NULL; GST_BUFFER_PRIVATE (buffer) = parent; /* we can copy the timestamp and offset if the new buffer starts at * offset 0 */ if (offset == 0) { - GST_BUFFER_TIMESTAMP (buffer) = GST_BUFFER_TIMESTAMP (parent); - GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET (parent); - } - else { - GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE; - GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE; + GST_BUFFER_TIMESTAMP (buffer) = GST_BUFFER_TIMESTAMP (parent); + GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET (parent); + } else { + GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE; + GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE; } - GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE; - GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE; + GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE; + GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE; if (GST_BUFFER_FLAG_IS_SET (parent, GST_BUFFER_DONTKEEP)) { GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTKEEP); @@ -324,8 +323,8 @@ gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size) * * Returns: the new #GstBuffer that's the concatenation of the source buffers. */ -GstBuffer* -gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2) +GstBuffer * +gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2) { GstBuffer *result; @@ -347,7 +346,7 @@ gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2) * FALSE if a copy would be required. */ gboolean -gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2) +gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2) { g_return_val_if_fail (buf1 != NULL && buf2 != NULL, FALSE); g_return_val_if_fail (GST_BUFFER_REFCOUNT_VALUE (buf1) > 0, FALSE); @@ -355,9 +354,9 @@ gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2) /* it's only fast if we have subbuffers of the same parent */ return ((GST_BUFFER_FLAG_IS_SET (buf1, GST_BUFFER_SUBBUFFER)) && - (GST_BUFFER_FLAG_IS_SET (buf2, GST_BUFFER_SUBBUFFER)) && - (buf1->buffer_private == buf2->buffer_private) && - ((buf1->data + buf1->size) == buf2->data)); + (GST_BUFFER_FLAG_IS_SET (buf2, GST_BUFFER_SUBBUFFER)) && + (buf1->buffer_private == buf2->buffer_private) && + ((buf1->data + buf1->size) == buf2->data)); } /** @@ -380,8 +379,9 @@ gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2) * * Returns: the new #GstBuffer that spans the two source buffers. */ -GstBuffer* -gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) +GstBuffer * +gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2, + guint32 len) { GstBuffer *newbuf; @@ -394,21 +394,21 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) /* if the two buffers have the same parent and are adjacent */ if (gst_buffer_is_span_fast (buf1, buf2)) { GstBuffer *parent = GST_BUFFER (buf1->buffer_private); + /* we simply create a subbuffer of the common parent */ - newbuf = gst_buffer_create_sub (parent, - buf1->data - parent->data + offset, len); - } - else { - GST_CAT_DEBUG (GST_CAT_BUFFER, "slow path taken while spanning buffers %p and %p", - buf1, buf2); + newbuf = gst_buffer_create_sub (parent, + buf1->data - parent->data + offset, len); + } else { + GST_CAT_DEBUG (GST_CAT_BUFFER, + "slow path taken while spanning buffers %p and %p", buf1, buf2); /* otherwise we simply have to brute-force copy the buffers */ newbuf = gst_buffer_new_and_alloc (len); /* copy the first buffer's data across */ memcpy (newbuf->data, buf1->data + offset, buf1->size - offset); /* copy the second buffer's data across */ - memcpy (newbuf->data + (buf1->size - offset), buf2->data, - len - (buf1->size - offset)); + memcpy (newbuf->data + (buf1->size - offset), buf2->data, + len - (buf1->size - offset)); /* if the offset is 0, the new buffer has the same timestamp as buf1 */ if (offset == 0) { GST_BUFFER_OFFSET (newbuf) = GST_BUFFER_OFFSET (buf1); @@ -422,8 +422,8 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) if (GST_BUFFER_DURATION_IS_VALID (buf1) && GST_BUFFER_DURATION_IS_VALID (buf2)) { /* add duration */ - GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) + - GST_BUFFER_DURATION (buf2); + GST_BUFFER_DURATION (newbuf) = GST_BUFFER_DURATION (buf1) + + GST_BUFFER_DURATION (buf2); } if (GST_BUFFER_OFFSET_END_IS_VALID (buf2)) { /* add offset_end */ @@ -433,4 +433,3 @@ gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len) return newbuf; } - diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 8fb65b1e0..da2c11c9d 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -27,11 +27,9 @@ #include #include -G_BEGIN_DECLS +G_BEGIN_DECLS typedef struct _GstBuffer GstBuffer; -typedef struct _GstBuffer GstBuffer; - -typedef void (*GstBufferFreeDataFunc) (GstBuffer *buffer); +typedef void (*GstBufferFreeDataFunc) (GstBuffer * buffer); #define GST_BUFFER_TRACE_NAME "GstBuffer" @@ -74,27 +72,29 @@ extern GType _gst_buffer_type; #define GST_BUFFER_OFFSET_END_IS_VALID(buffer) (GST_BUFFER_OFFSET_END (buffer) != GST_BUFFER_OFFSET_NONE) #define GST_BUFFER_MAXSIZE_IS_VALID(buffer) (GST_BUFFER_MAXSIZE (buffer) != GST_BUFFER_MAXSIZE_NONE) -typedef enum { - GST_BUFFER_READONLY = GST_DATA_READONLY, - GST_BUFFER_SUBBUFFER = GST_DATA_FLAG_LAST, +typedef enum +{ + GST_BUFFER_READONLY = GST_DATA_READONLY, + GST_BUFFER_SUBBUFFER = GST_DATA_FLAG_LAST, GST_BUFFER_ORIGINAL, GST_BUFFER_DONTFREE, GST_BUFFER_KEY_UNIT, GST_BUFFER_DONTKEEP, - GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8 + GST_BUFFER_FLAG_LAST = GST_DATA_FLAG_LAST + 8 } GstBufferFlag; -struct _GstBuffer { - GstData data_type; +struct _GstBuffer +{ + GstData data_type; /* pointer to data and its size */ - guint8 *data; /* pointer to buffer data */ - guint size; /* size of buffer data */ - guint maxsize; /* max size of this buffer */ + guint8 *data; /* pointer to buffer data */ + guint size; /* size of buffer data */ + guint maxsize; /* max size of this buffer */ /* timestamp */ - GstClockTime timestamp; - GstClockTime duration; + GstClockTime timestamp; + GstClockTime duration; /* media specific offset * for video frames, this could be the number of frames, @@ -103,19 +103,19 @@ struct _GstBuffer { * offset_end is the last offset contained in the buffer. The format specifies * the meaning of both of them exactly. */ - guint64 offset; - guint64 offset_end; + guint64 offset; + guint64 offset_end; - GstBufferFreeDataFunc free_data; - gpointer buffer_private; + GstBufferFreeDataFunc free_data; + gpointer buffer_private; gpointer _gst_reserved[GST_PADDING]; }; /* allocation */ -GType gst_buffer_get_type (void); -GstBuffer* gst_buffer_new (void); -GstBuffer* gst_buffer_new_and_alloc (guint size); +GType gst_buffer_get_type (void); +GstBuffer *gst_buffer_new (void); +GstBuffer *gst_buffer_new_and_alloc (guint size); #define gst_buffer_set_data(buf, data, size) \ G_STMT_START { \ @@ -128,25 +128,26 @@ G_STMT_START { \ #define gst_buffer_ref_by_count(buf,c) GST_BUFFER (gst_data_ref_by_count (GST_DATA (buf), c)) #define gst_buffer_unref(buf) gst_data_unref (GST_DATA (buf)) /* copy buffer */ -void gst_buffer_stamp (GstBuffer *dest, const GstBuffer *src); +void gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src); + #define gst_buffer_copy(buf) GST_BUFFER (gst_data_copy (GST_DATA (buf))) #define gst_buffer_is_writable(buf) gst_data_is_writable (GST_DATA (buf)) #define gst_buffer_copy_on_write(buf) GST_BUFFER (gst_data_copy_on_write (GST_DATA (buf))) /* creating a subbuffer */ -GstBuffer* gst_buffer_create_sub (GstBuffer *parent, guint offset, guint size); +GstBuffer *gst_buffer_create_sub (GstBuffer * parent, guint offset, guint size); /* merge, span, or append two buffers, intelligently */ -GstBuffer* gst_buffer_merge (GstBuffer *buf1, GstBuffer *buf2); -gboolean gst_buffer_is_span_fast (GstBuffer *buf1, GstBuffer *buf2); -GstBuffer* gst_buffer_span (GstBuffer *buf1, guint32 offset, GstBuffer *buf2, guint32 len); +GstBuffer *gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2); +gboolean gst_buffer_is_span_fast (GstBuffer * buf1, GstBuffer * buf2); +GstBuffer *gst_buffer_span (GstBuffer * buf1, guint32 offset, GstBuffer * buf2, + guint32 len); /* --- private --- */ -void _gst_buffer_initialize (void); +void _gst_buffer_initialize (void); -void gst_buffer_default_free (GstBuffer *buffer); -GstBuffer* gst_buffer_default_copy (GstBuffer *buffer); +void gst_buffer_default_free (GstBuffer * buffer); +GstBuffer *gst_buffer_default_copy (GstBuffer * buffer); G_END_DECLS - #endif /* __GST_BUFFER_H__ */ diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 30eef84eb..4d079f199 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -40,27 +40,26 @@ } G_STMT_END -static void gst_caps_transform_to_string (const GValue *src_value, - GValue *dest_value); -static gboolean gst_caps_from_string_inplace (GstCaps *caps, - const gchar *string); -static GstCaps * gst_caps_copy_conditional (const GstCaps *src); +static void gst_caps_transform_to_string (const GValue * src_value, + GValue * dest_value); +static gboolean gst_caps_from_string_inplace (GstCaps * caps, + const gchar * string); +static GstCaps *gst_caps_copy_conditional (const GstCaps * src); GType gst_caps_get_type (void) { static GType gst_caps_type = 0; - + if (!gst_caps_type) { gst_caps_type = g_boxed_type_register_static ("GstCaps", - (GBoxedCopyFunc)gst_caps_copy_conditional, - (GBoxedFreeFunc)gst_caps_free); - + (GBoxedCopyFunc) gst_caps_copy_conditional, + (GBoxedFreeFunc) gst_caps_free); + g_value_register_transform_func (gst_caps_type, - G_TYPE_STRING, - gst_caps_transform_to_string); + G_TYPE_STRING, gst_caps_transform_to_string); } - + return gst_caps_type; } @@ -77,10 +76,10 @@ gst_caps_get_type (void) GstCaps * gst_caps_new_empty (void) { - GstCaps *caps = g_new0(GstCaps, 1); + GstCaps *caps = g_new0 (GstCaps, 1); caps->type = GST_TYPE_CAPS; - caps->structs = g_ptr_array_new(); + caps->structs = g_ptr_array_new (); return caps; } @@ -96,10 +95,10 @@ gst_caps_new_empty (void) GstCaps * gst_caps_new_any (void) { - GstCaps *caps = g_new0(GstCaps, 1); + GstCaps *caps = g_new0 (GstCaps, 1); caps->type = GST_TYPE_CAPS; - caps->structs = g_ptr_array_new(); + caps->structs = g_ptr_array_new (); caps->flags = GST_CAPS_FLAGS_ANY; return caps; @@ -117,24 +116,22 @@ gst_caps_new_any (void) * Returns: the new #GstCaps */ GstCaps * -gst_caps_new_simple (const char *media_type, - const char *fieldname, - ...) +gst_caps_new_simple (const char *media_type, const char *fieldname, ...) { GstCaps *caps; GstStructure *structure; va_list var_args; - caps = g_new0(GstCaps, 1); + caps = g_new0 (GstCaps, 1); caps->type = GST_TYPE_CAPS; - caps->structs = g_ptr_array_new(); + caps->structs = g_ptr_array_new (); va_start (var_args, fieldname); structure = gst_structure_new_valist (media_type, fieldname, var_args); va_end (var_args); gst_caps_append_structure (caps, structure); - + return caps; } @@ -150,7 +147,7 @@ gst_caps_new_simple (const char *media_type, * Returns: the new #GstCaps */ GstCaps * -gst_caps_new_full (GstStructure *struct1, ...) +gst_caps_new_full (GstStructure * struct1, ...) { GstCaps *caps; va_list var_args; @@ -174,16 +171,15 @@ gst_caps_new_full (GstStructure *struct1, ...) * Returns: the new #GstCaps */ GstCaps * -gst_caps_new_full_valist (GstStructure *structure, - va_list var_args) +gst_caps_new_full_valist (GstStructure * structure, va_list var_args) { GstCaps *caps; - caps = g_new0(GstCaps, 1); + caps = g_new0 (GstCaps, 1); caps->type = GST_TYPE_CAPS; - caps->structs = g_ptr_array_new(); + caps->structs = g_ptr_array_new (); - while(structure){ + while (structure) { gst_caps_append_structure (caps, structure); structure = va_arg (var_args, GstStructure *); } @@ -201,22 +197,22 @@ gst_caps_new_full_valist (GstStructure *structure, * Returns: the new #GstCaps */ GstCaps * -gst_caps_copy (const GstCaps *caps) +gst_caps_copy (const GstCaps * caps) { GstCaps *newcaps; GstStructure *structure; int i; - g_return_val_if_fail(caps != NULL, NULL); + g_return_val_if_fail (caps != NULL, NULL); - newcaps = g_new0(GstCaps, 1); + newcaps = g_new0 (GstCaps, 1); newcaps->type = GST_TYPE_CAPS; newcaps->flags = caps->flags; - newcaps->structs = g_ptr_array_new(); + newcaps->structs = g_ptr_array_new (); - for(i=0;istructs->len;i++){ + for (i = 0; i < caps->structs->len; i++) { structure = gst_caps_get_structure (caps, i); - gst_caps_append_structure (newcaps, gst_structure_copy(structure)); + gst_caps_append_structure (newcaps, gst_structure_copy (structure)); } return newcaps; @@ -230,22 +226,22 @@ gst_caps_copy (const GstCaps *caps) * values. */ void -gst_caps_free (GstCaps *caps) +gst_caps_free (GstCaps * caps) { GstStructure *structure; int i; - - g_return_if_fail(caps != NULL); - for(i=0;istructs->len;i++){ + g_return_if_fail (caps != NULL); + + for (i = 0; i < caps->structs->len; i++) { structure = gst_caps_get_structure (caps, i); gst_structure_free (structure); } - g_ptr_array_free(caps->structs, TRUE); + g_ptr_array_free (caps->structs, TRUE); #ifdef USE_POISONING - memset (caps, 0xff, sizeof(GstCaps)); + memset (caps, 0xff, sizeof (GstCaps)); #endif - g_free(caps); + g_free (caps); } /** @@ -257,14 +253,14 @@ gst_caps_free (GstCaps *caps) * Returns: the new #GstCaps */ const GstCaps * -gst_static_caps_get (GstStaticCaps *static_caps) +gst_static_caps_get (GstStaticCaps * static_caps) { - GstCaps *caps = (GstCaps *)static_caps; + GstCaps *caps = (GstCaps *) static_caps; gboolean ret; if (caps->type == 0) { caps->type = GST_TYPE_CAPS; - caps->structs = g_ptr_array_new(); + caps->structs = g_ptr_array_new (); ret = gst_caps_from_string_inplace (caps, static_caps->string); if (!ret) { @@ -287,8 +283,7 @@ gst_static_caps_get (GstStaticCaps *static_caps) * @caps2 is freed. */ void -gst_caps_append (GstCaps *caps1, - GstCaps *caps2) +gst_caps_append (GstCaps * caps1, GstCaps * caps2) { GstStructure *structure; int i; @@ -299,15 +294,15 @@ gst_caps_append (GstCaps *caps1, #ifdef USE_POISONING CAPS_POISON (caps2); #endif - for(i=0;istructs->len;i++){ + for (i = 0; i < caps2->structs->len; i++) { structure = gst_caps_get_structure (caps2, i); gst_caps_append_structure (caps1, structure); } - g_ptr_array_free(caps2->structs, TRUE); + g_ptr_array_free (caps2->structs, TRUE); #ifdef USE_POISONING - memset (caps2, 0xff, sizeof(GstCaps)); + memset (caps2, 0xff, sizeof (GstCaps)); #endif - g_free(caps2); + g_free (caps2); } /** @@ -319,12 +314,11 @@ gst_caps_append (GstCaps *caps1, * becomes the owner of @structure. */ void -gst_caps_append_structure (GstCaps *caps, - GstStructure *structure) +gst_caps_append_structure (GstCaps * caps, GstStructure * structure) { - g_return_if_fail(caps != NULL); + g_return_if_fail (caps != NULL); - if (structure){ + if (structure) { #if 0 #ifdef USE_POISONING STRUCTURE_POISON (structure); @@ -341,7 +335,7 @@ gst_caps_append_structure (GstCaps *caps, * Returns: */ GstCaps * -gst_caps_split_one (GstCaps *caps) +gst_caps_split_one (GstCaps * caps) { /* FIXME */ g_critical ("unimplemented"); @@ -356,7 +350,7 @@ gst_caps_split_one (GstCaps *caps) * Returns: the number of structures that @caps contains */ int -gst_caps_get_size (const GstCaps *caps) +gst_caps_get_size (const GstCaps * caps) { g_return_val_if_fail (caps != NULL, 0); @@ -379,13 +373,13 @@ gst_caps_get_size (const GstCaps *caps) * Returns: a pointer to the #GstStructure corresponding to @index */ GstStructure * -gst_caps_get_structure (const GstCaps *caps, int index) +gst_caps_get_structure (const GstCaps * caps, int index) { g_return_val_if_fail (caps != NULL, NULL); g_return_val_if_fail (index >= 0, NULL); g_return_val_if_fail (index < caps->structs->len, NULL); - return g_ptr_array_index(caps->structs, index); + return g_ptr_array_index (caps->structs, index); } /** @@ -398,21 +392,21 @@ gst_caps_get_structure (const GstCaps *caps, int index) * Returns: the new @GstCaps */ GstCaps * -gst_caps_copy_1 (const GstCaps *caps) +gst_caps_copy_1 (const GstCaps * caps) { GstCaps *newcaps; GstStructure *structure; - g_return_val_if_fail(caps != NULL, NULL); + g_return_val_if_fail (caps != NULL, NULL); - newcaps = g_new0(GstCaps, 1); + newcaps = g_new0 (GstCaps, 1); newcaps->type = GST_TYPE_CAPS; newcaps->flags = caps->flags; - newcaps->structs = g_ptr_array_new(); + newcaps->structs = g_ptr_array_new (); - if (caps->structs->len > 0){ + if (caps->structs->len > 0) { structure = gst_caps_get_structure (caps, 0); - gst_caps_append_structure (newcaps, gst_structure_copy(structure)); + gst_caps_append_structure (newcaps, gst_structure_copy (structure)); } return newcaps; @@ -429,7 +423,7 @@ gst_caps_copy_1 (const GstCaps *caps) * manner as @gst_structure_set(), and be NULL-terminated. */ void -gst_caps_set_simple (GstCaps *caps, char *field, ...) +gst_caps_set_simple (GstCaps * caps, char *field, ...) { GstStructure *structure; va_list var_args; @@ -441,7 +435,7 @@ gst_caps_set_simple (GstCaps *caps, char *field, ...) va_start (var_args, field); gst_structure_set_valist (structure, field, var_args); - va_end(var_args); + va_end (var_args); } /** @@ -455,9 +449,7 @@ gst_caps_set_simple (GstCaps *caps, char *field, ...) * manner as @gst_structure_set(), and be NULL-terminated. */ void -gst_caps_set_simple_valist (GstCaps *caps, - char *field, - va_list varargs) +gst_caps_set_simple_valist (GstCaps * caps, char *field, va_list varargs) { GstStructure *structure; @@ -478,9 +470,9 @@ gst_caps_set_simple_valist (GstCaps *caps, * Returns: TRUE if @caps represents any format. */ gboolean -gst_caps_is_any (const GstCaps *caps) +gst_caps_is_any (const GstCaps * caps) { - g_return_val_if_fail(caps != NULL, FALSE); + g_return_val_if_fail (caps != NULL, FALSE); return (caps->flags & GST_CAPS_FLAGS_ANY); } @@ -492,11 +484,12 @@ gst_caps_is_any (const GstCaps *caps) * Returns: TRUE if @caps represents no formats. */ gboolean -gst_caps_is_empty (const GstCaps *caps) +gst_caps_is_empty (const GstCaps * caps) { - g_return_val_if_fail(caps != NULL, FALSE); + g_return_val_if_fail (caps != NULL, FALSE); - if (caps->flags & GST_CAPS_FLAGS_ANY) return FALSE; + if (caps->flags & GST_CAPS_FLAGS_ANY) + return FALSE; return (caps->structs == NULL) || (caps->structs->len == 0); } @@ -508,21 +501,22 @@ gst_caps_is_empty (const GstCaps *caps) * Returns: TRUE if @caps contains more than one structure */ gboolean -gst_caps_is_chained (const GstCaps *caps) +gst_caps_is_chained (const GstCaps * caps) { - g_return_val_if_fail(caps != NULL, FALSE); + g_return_val_if_fail (caps != NULL, FALSE); return (caps->structs->len > 1); } static gboolean -gst_caps_is_fixed_foreach (GQuark field_id, - GValue *value, - gpointer unused) +gst_caps_is_fixed_foreach (GQuark field_id, GValue * value, gpointer unused) { GType type = G_VALUE_TYPE (value); - if (G_TYPE_IS_FUNDAMENTAL (type)) return TRUE; - if (type == GST_TYPE_FOURCC) return TRUE; + + if (G_TYPE_IS_FUNDAMENTAL (type)) + return TRUE; + if (type == GST_TYPE_FOURCC) + return TRUE; return FALSE; } @@ -537,13 +531,14 @@ gst_caps_is_fixed_foreach (GQuark field_id, * Returns: TRUE if @caps is fixed */ gboolean -gst_caps_is_fixed (const GstCaps *caps) +gst_caps_is_fixed (const GstCaps * caps) { GstStructure *structure; - g_return_val_if_fail(caps != NULL, FALSE); + g_return_val_if_fail (caps != NULL, FALSE); - if (caps->structs->len != 1) return FALSE; + if (caps->structs->len != 1) + return FALSE; structure = gst_caps_get_structure (caps, 0); @@ -551,14 +546,13 @@ gst_caps_is_fixed (const GstCaps *caps) } static gboolean -gst_structure_is_equal_foreach (GQuark field_id, - GValue *val2, - gpointer data) +gst_structure_is_equal_foreach (GQuark field_id, GValue * val2, gpointer data) { GstStructure *struct1 = (GstStructure *) data; const GValue *val1 = gst_structure_id_get_value (struct1, field_id); - if (val1 == NULL) return FALSE; + if (val1 == NULL) + return FALSE; if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) { return TRUE; } @@ -577,12 +571,12 @@ gst_structure_is_equal_foreach (GQuark field_id, * Returns: TRUE if the arguments represent the same format */ gboolean -gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2) +gst_caps_is_equal_fixed (const GstCaps * caps1, const GstCaps * caps2) { GstStructure *struct1, *struct2; - g_return_val_if_fail (gst_caps_is_fixed(caps1), FALSE); - g_return_val_if_fail (gst_caps_is_fixed(caps2), FALSE); + g_return_val_if_fail (gst_caps_is_fixed (caps1), FALSE); + g_return_val_if_fail (gst_caps_is_fixed (caps2), FALSE); struct1 = gst_caps_get_structure (caps1, 0); struct2 = gst_caps_get_structure (caps2, 0); @@ -595,19 +589,19 @@ gst_caps_is_equal_fixed (const GstCaps *caps1, const GstCaps *caps2) } return gst_structure_foreach (struct1, gst_structure_is_equal_foreach, - struct2); + struct2); } static gboolean -gst_structure_field_has_compatible (GQuark field_id, - GValue *val2, - gpointer data) +gst_structure_field_has_compatible (GQuark field_id, + GValue * val2, gpointer data) { GValue dest = { 0 }; GstStructure *struct1 = (GstStructure *) data; const GValue *val1 = gst_structure_id_get_value (struct1, field_id); - if (val1 == NULL) return FALSE; + if (val1 == NULL) + return FALSE; if (gst_value_intersect (&dest, val1, val2)) { g_value_unset (&dest); return TRUE; @@ -617,25 +611,25 @@ gst_structure_field_has_compatible (GQuark field_id, } static gboolean -gst_cap_is_always_compatible (const GstStructure *struct1, - const GstStructure *struct2) +gst_cap_is_always_compatible (const GstStructure * struct1, + const GstStructure * struct2) { - if(struct1->name != struct2->name){ + if (struct1->name != struct2->name) { return FALSE; } /* the reversed order is important */ - return gst_structure_foreach ((GstStructure *) struct2, - gst_structure_field_has_compatible, (gpointer) struct1); + return gst_structure_foreach ((GstStructure *) struct2, + gst_structure_field_has_compatible, (gpointer) struct1); } static gboolean -gst_caps_cap_is_always_compatible (const GstStructure *struct1, - const GstCaps *caps2) +gst_caps_cap_is_always_compatible (const GstStructure * struct1, + const GstCaps * caps2) { int i; - for(i=0;istructs->len;i++){ + for (i = 0; i < caps2->structs->len; i++) { GstStructure *struct2 = gst_caps_get_structure (caps2, i); if (gst_cap_is_always_compatible (struct1, struct2)) { @@ -654,7 +648,7 @@ gst_caps_cap_is_always_compatible (const GstStructure *struct1, * Returns: TRUE if @caps1 is a subset of @caps2. */ gboolean -gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2) +gst_caps_is_always_compatible (const GstCaps * caps1, const GstCaps * caps2) { int i; @@ -663,16 +657,16 @@ gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2) /* FIXME: is this right ? */ g_return_val_if_fail (!gst_caps_is_empty (caps1), FALSE); g_return_val_if_fail (!gst_caps_is_empty (caps2), FALSE); - + if (gst_caps_is_any (caps2)) return TRUE; if (gst_caps_is_any (caps1)) return FALSE; - - for(i=0;istructs->len;i++) { + + for (i = 0; i < caps1->structs->len; i++) { GstStructure *struct1 = gst_caps_get_structure (caps1, i); - if (gst_caps_cap_is_always_compatible(struct1, caps2) == FALSE){ + if (gst_caps_cap_is_always_compatible (struct1, caps2) == FALSE) { return FALSE; } @@ -681,14 +675,15 @@ gst_caps_is_always_compatible (const GstCaps *caps1, const GstCaps *caps2) return FALSE; } -typedef struct { +typedef struct +{ GstStructure *dest; const GstStructure *intersect; gboolean first_run; } IntersectData; static gboolean -gst_caps_structure_intersect_field (GQuark id, GValue *val1, gpointer data) +gst_caps_structure_intersect_field (GQuark id, GValue * val1, gpointer data) { IntersectData *idata = (IntersectData *) data; GValue dest_value = { 0 }; @@ -704,32 +699,33 @@ gst_caps_structure_intersect_field (GQuark id, GValue *val1, gpointer data) return FALSE; } } - + return TRUE; } static GstStructure * -gst_caps_structure_intersect (const GstStructure *struct1, - const GstStructure *struct2) +gst_caps_structure_intersect (const GstStructure * struct1, + const GstStructure * struct2) { IntersectData data; - g_return_val_if_fail(struct1 != NULL, NULL); - g_return_val_if_fail(struct2 != NULL, NULL); + g_return_val_if_fail (struct1 != NULL, NULL); + g_return_val_if_fail (struct2 != NULL, NULL); - if (struct1->name != struct2->name) return NULL; + if (struct1->name != struct2->name) + return NULL; data.dest = gst_structure_id_empty_new (struct1->name); data.intersect = struct2; data.first_run = TRUE; - if (!gst_structure_foreach ((GstStructure *) struct1, - gst_caps_structure_intersect_field, &data)) + if (!gst_structure_foreach ((GstStructure *) struct1, + gst_caps_structure_intersect_field, &data)) goto error; - + data.intersect = struct1; data.first_run = FALSE; - if (!gst_structure_foreach ((GstStructure *) struct2, - gst_caps_structure_intersect_field, &data)) + if (!gst_structure_foreach ((GstStructure *) struct2, + gst_caps_structure_intersect_field, &data)) goto error; return data.dest; @@ -741,8 +737,8 @@ error: #if 0 static GstStructure * -gst_caps_structure_union (const GstStructure *struct1, - const GstStructure *struct2) +gst_caps_structure_union (const GstStructure * struct1, + const GstStructure * struct2) { int i; GstStructure *dest; @@ -752,11 +748,12 @@ gst_caps_structure_union (const GstStructure *struct1, /* FIXME this doesn't actually work */ - if (struct1->name != struct2->name) return NULL; + if (struct1->name != struct2->name) + return NULL; dest = gst_structure_id_empty_new (struct1->name); - for(i=0;ifields->len;i++){ + for (i = 0; i < struct1->fields->len; i++) { GValue dest_value = { 0 }; field1 = GST_STRUCTURE_FIELD (struct1, i); @@ -766,7 +763,7 @@ gst_caps_structure_union (const GstStructure *struct1, continue; } else { if (gst_value_union (&dest_value, &field1->value, &field2->value)) { - gst_structure_set_value (dest, g_quark_to_string(field1->name), + gst_structure_set_value (dest, g_quark_to_string (field1->name), &dest_value); } else { ret = gst_value_compare (&field1->value, &field2->value); @@ -791,13 +788,13 @@ gst_caps_structure_union (const GstStructure *struct1, * Returns: the new #GstCaps */ GstCaps * -gst_caps_intersect (const GstCaps *caps1, - const GstCaps *caps2) +gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2) { - int i,j; + int i, j; GstStructure *struct1; GstStructure *struct2; GstCaps *dest; + #if 0 GstCaps *caps; #endif @@ -805,22 +802,24 @@ gst_caps_intersect (const GstCaps *caps1, g_return_val_if_fail (caps1 != NULL, NULL); g_return_val_if_fail (caps2 != NULL, NULL); - if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)){ + if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)) { return gst_caps_new_empty (); } - if (gst_caps_is_any (caps1)) return gst_caps_copy (caps2); - if (gst_caps_is_any (caps2)) return gst_caps_copy (caps1); + if (gst_caps_is_any (caps1)) + return gst_caps_copy (caps2); + if (gst_caps_is_any (caps2)) + return gst_caps_copy (caps1); - dest = gst_caps_new_empty(); - for(i=0;istructs->len;i++){ + dest = gst_caps_new_empty (); + for (i = 0; i < caps1->structs->len; i++) { struct1 = gst_caps_get_structure (caps1, i); - for(j=0;jstructs->len;j++){ + for (j = 0; j < caps2->structs->len; j++) { GstStructure *istruct; struct2 = gst_caps_get_structure (caps2, j); istruct = gst_caps_structure_intersect (struct1, struct2); - gst_caps_append_structure(dest, istruct); + gst_caps_append_structure (dest, istruct); } } @@ -845,8 +844,7 @@ gst_caps_intersect (const GstCaps *caps1, * Returns: the new #GstCaps */ GstCaps * -gst_caps_union (const GstCaps *caps1, - const GstCaps *caps2) +gst_caps_union (const GstCaps * caps1, const GstCaps * caps2) { GstCaps *dest1; GstCaps *dest2; @@ -860,22 +858,21 @@ gst_caps_union (const GstCaps *caps1, return dest1; } -typedef struct _NormalizeForeach { +typedef struct _NormalizeForeach +{ GstCaps *caps; GstStructure *structure; } NormalizeForeach; static gboolean -gst_caps_normalize_foreach (GQuark field_id, - GValue *value, - gpointer ptr) +gst_caps_normalize_foreach (GQuark field_id, GValue * value, gpointer ptr) { NormalizeForeach *nf = (NormalizeForeach *) ptr; GValue val = { 0 }; int i; if (G_VALUE_TYPE (value) == GST_TYPE_LIST) { - for (i=1; istructure); @@ -903,53 +900,54 @@ gst_caps_normalize_foreach (GQuark field_id, * Returns: the new #GstCaps */ GstCaps * -gst_caps_normalize (const GstCaps *caps) +gst_caps_normalize (const GstCaps * caps) { NormalizeForeach nf; GstCaps *newcaps; int i; - g_return_val_if_fail(caps != NULL, NULL); + g_return_val_if_fail (caps != NULL, NULL); newcaps = gst_caps_copy (caps); nf.caps = newcaps; - for(i=0;istructs->len;i++){ + for (i = 0; i < newcaps->structs->len; i++) { nf.structure = gst_caps_get_structure (newcaps, i); while (!gst_structure_foreach (nf.structure, - gst_caps_normalize_foreach, - &nf)); + gst_caps_normalize_foreach, &nf)); } return newcaps; } static gboolean -simplify_foreach (GQuark field_id, - GValue *value, - gpointer user_data) +simplify_foreach (GQuark field_id, GValue * value, gpointer user_data) { GstStructure *s2 = (GstStructure *) user_data; const GValue *v2; v2 = gst_structure_id_get_value (s2, field_id); - if (v2 == NULL) return FALSE; + if (v2 == NULL) + return FALSE; - if (gst_value_compare (value, v2) == GST_VALUE_EQUAL) return TRUE; + if (gst_value_compare (value, v2) == GST_VALUE_EQUAL) + return TRUE; return FALSE; } static gboolean -gst_caps_structure_simplify (GstStructure *struct1, - const GstStructure *struct2) +gst_caps_structure_simplify (GstStructure * struct1, + const GstStructure * struct2) { /* FIXME this is just a simple compare. Better would be to merge * the two structures */ - if (struct1->name != struct2->name) return FALSE; - if (struct1->fields->len != struct2->fields->len) return FALSE; + if (struct1->name != struct2->name) + return FALSE; + if (struct1->fields->len != struct2->fields->len) + return FALSE; - return gst_structure_foreach (struct1, simplify_foreach, (void *)struct2); + return gst_structure_foreach (struct1, simplify_foreach, (void *) struct2); } /** @@ -964,7 +962,7 @@ gst_caps_structure_simplify (GstStructure *struct1, * Returns: the new #GstCaps */ GstCaps * -gst_caps_simplify (const GstCaps *caps) +gst_caps_simplify (const GstCaps * caps) { int i; int j; @@ -978,17 +976,17 @@ gst_caps_simplify (const GstCaps *caps) newcaps = gst_caps_new_empty (); - for(i=0;istructs->len;i++){ + for (i = 1; i < caps->structs->len; i++) { structure = gst_caps_get_structure (caps, i); - g_string_append(s, "; "); - sstr = gst_structure_to_string(structure); - g_string_append(s, sstr); - g_free(sstr); + g_string_append (s, "; "); + sstr = gst_structure_to_string (structure); + g_string_append (s, sstr); + g_free (sstr); } - return g_string_free(s, FALSE); + return g_string_free (s, FALSE); } static gboolean -gst_caps_from_string_inplace (GstCaps *caps, - const gchar *string) +gst_caps_from_string_inplace (GstCaps * caps, const gchar * string) { GstStructure *structure; gchar *s; - if (strcmp("ANY", string)==0) { + if (strcmp ("ANY", string) == 0) { caps->flags = GST_CAPS_FLAGS_ANY; return TRUE; } - if (strcmp("NONE", string)==0) { + if (strcmp ("NONE", string) == 0) { return TRUE; } - structure = gst_structure_from_string(string, &s); + structure = gst_structure_from_string (string, &s); if (structure == NULL) { return FALSE; } @@ -1110,16 +1107,18 @@ gst_caps_from_string_inplace (GstCaps *caps, while (*s == ';') { s++; - while (g_ascii_isspace(*s))s++; - structure = gst_structure_from_string(s, &s); + while (g_ascii_isspace (*s)) + s++; + structure = gst_structure_from_string (s, &s); if (structure == NULL) { return FALSE; } gst_caps_append_structure (caps, structure); - while (g_ascii_isspace(*s))s++; + while (g_ascii_isspace (*s)) + s++; } - if (*s != 0){ + if (*s != 0) { return FALSE; } @@ -1135,11 +1134,11 @@ gst_caps_from_string_inplace (GstCaps *caps, * Returns: a new #GstCaps */ GstCaps * -gst_caps_from_string (const gchar *string) +gst_caps_from_string (const gchar * string) { GstCaps *caps; - caps = gst_caps_new_empty(); + caps = gst_caps_new_empty (); if (gst_caps_from_string_inplace (caps, string)) { return caps; } else { @@ -1149,18 +1148,17 @@ gst_caps_from_string (const gchar *string) } static void -gst_caps_transform_to_string (const GValue *src_value, - GValue *dest_value) +gst_caps_transform_to_string (const GValue * src_value, GValue * dest_value) { g_return_if_fail (src_value != NULL); g_return_if_fail (dest_value != NULL); dest_value->data[0].v_pointer = - gst_caps_to_string (src_value->data[0].v_pointer); + gst_caps_to_string (src_value->data[0].v_pointer); } static GstCaps * -gst_caps_copy_conditional (const GstCaps *src) +gst_caps_copy_conditional (const GstCaps * src) { if (src) { return gst_caps_copy (src); @@ -1172,13 +1170,12 @@ gst_caps_copy_conditional (const GstCaps *src) /* fixate utility functions */ gboolean -gst_caps_structure_fixate_field_nearest_int (GstStructure *structure, - const char *field_name, - int target) +gst_caps_structure_fixate_field_nearest_int (GstStructure * structure, + const char *field_name, int target) { const GValue *value; - g_return_val_if_fail(gst_structure_has_field (structure, field_name), FALSE); + g_return_val_if_fail (gst_structure_has_field (structure, field_name), FALSE); value = gst_structure_get_value (structure, field_name); @@ -1187,10 +1184,13 @@ gst_caps_structure_fixate_field_nearest_int (GstStructure *structure, return FALSE; } else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) { int x; + x = gst_value_get_int_range_min (value); - if (target < x) target = x; + if (target < x) + target = x; x = gst_value_get_int_range_max (value); - if (target > x) target = x; + if (target > x) + target = x; gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL); return TRUE; } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) { @@ -1200,17 +1200,18 @@ gst_caps_structure_fixate_field_nearest_int (GstStructure *structure, int best_index = -1; n = gst_value_list_get_size (value); - for(i=0;i x) target = x; + if (target > x) + target = x; gst_structure_set (structure, field_name, G_TYPE_DOUBLE, target, NULL); return TRUE; } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) { @@ -1249,17 +1252,18 @@ gst_caps_structure_fixate_field_nearest_double (GstStructure *structure, int best_index = -1; n = gst_value_list_get_size (value); - for(i=0;i G_BEGIN_DECLS - #define GST_TYPE_CAPS gst_caps_get_type() #define GST_CAPS(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GST_TYPE_CAPS, GstCaps)) #define GST_IS_CAPS(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_CAPS)) - #define GST_CAPS_FLAGS_ANY (1 << 0) - #define GST_CAPS_ANY gst_caps_new_any() #define GST_CAPS_NONE gst_caps_new_empty() - #define GST_STATIC_CAPS_ANY GST_STATIC_CAPS("ANY") #define GST_STATIC_CAPS_NONE GST_STATIC_CAPS("NONE") - #define GST_CAPS_IS_SIMPLE(caps) (gst_caps_get_size(caps) == 1) #define gst_caps_is_simple(caps) GST_CAPS_IS_SIMPLE(caps) - #ifndef GST_DISABLE_DEPRECATED #define GST_DEBUG_CAPS(string, caps) \ GST_DEBUG ( string "%s: " GST_PTR_FORMAT, caps) #endif - #define GST_STATIC_CAPS(string) \ { \ /* caps */ { 0 }, \ /* string */ string, \ } - typedef struct _GstCaps GstCaps; typedef struct _GstStaticCaps GstStaticCaps; -struct _GstCaps { +struct _GstCaps +{ GType type; guint16 flags; GPtrArray *structs; }; -struct _GstStaticCaps { +struct _GstStaticCaps +{ GstCaps caps; const char *string; }; -GType gst_caps_get_type (void) G_GNUC_CONST; -GstCaps * gst_caps_new_empty (void); -GstCaps * gst_caps_new_any (void); -GstCaps * gst_caps_new_simple (const char *media_type, - const char *fieldname, - ...); -GstCaps * gst_caps_new_full (GstStructure *struct1, - ...); -GstCaps * gst_caps_new_full_valist (GstStructure *structure, - va_list var_args); -GstCaps * gst_caps_copy (const GstCaps *caps); -void gst_caps_free (GstCaps *caps); -G_CONST_RETURN GstCaps * gst_static_caps_get (GstStaticCaps *caps); +GType +gst_caps_get_type (void) + G_GNUC_CONST; + GstCaps *gst_caps_new_empty (void); + GstCaps *gst_caps_new_any (void); + GstCaps *gst_caps_new_simple (const char *media_type, + const char *fieldname, ...); + GstCaps *gst_caps_new_full (GstStructure * struct1, ...); + GstCaps *gst_caps_new_full_valist (GstStructure * structure, + va_list var_args); + GstCaps *gst_caps_copy (const GstCaps * caps); + void gst_caps_free (GstCaps * caps); + G_CONST_RETURN GstCaps *gst_static_caps_get (GstStaticCaps * caps); /* manipulation */ -void gst_caps_append (GstCaps *caps1, - GstCaps *caps2); -void gst_caps_append_structure (GstCaps *caps1, - GstStructure *structure); -GstCaps * gst_caps_split_one (GstCaps *caps); -int gst_caps_get_size (const GstCaps *caps); -GstStructure * gst_caps_get_structure (const GstCaps *caps, - int index); + void gst_caps_append (GstCaps * caps1, GstCaps * caps2); + void gst_caps_append_structure (GstCaps * caps1, GstStructure * structure); + GstCaps *gst_caps_split_one (GstCaps * caps); + int gst_caps_get_size (const GstCaps * caps); + GstStructure *gst_caps_get_structure (const GstCaps * caps, int index); + #ifndef GST_DISABLE_DEPRECATED -GstCaps * gst_caps_copy_1 (const GstCaps *caps); + GstCaps *gst_caps_copy_1 (const GstCaps * caps); #endif -void gst_caps_set_simple (GstCaps *caps, - char *field, ...); -void gst_caps_set_simple_valist (GstCaps *caps, - char *field, - va_list varargs); + void gst_caps_set_simple (GstCaps * caps, char *field, ...); + void gst_caps_set_simple_valist (GstCaps * caps, + char *field, va_list varargs); /* tests */ -gboolean gst_caps_is_any (const GstCaps *caps); -gboolean gst_caps_is_empty (const GstCaps *caps); + gboolean gst_caps_is_any (const GstCaps * caps); + gboolean gst_caps_is_empty (const GstCaps * caps); + #ifndef GST_DISABLE_DEPRECATED -gboolean gst_caps_is_chained (const GstCaps *caps); + gboolean gst_caps_is_chained (const GstCaps * caps); #endif -gboolean gst_caps_is_fixed (const GstCaps *caps); -gboolean gst_caps_is_equal_fixed (const GstCaps *caps1, - const GstCaps *caps2); -gboolean gst_caps_is_always_compatible (const GstCaps *caps1, - const GstCaps *caps2); + gboolean gst_caps_is_fixed (const GstCaps * caps); + gboolean gst_caps_is_equal_fixed (const GstCaps * caps1, + const GstCaps * caps2); + gboolean gst_caps_is_always_compatible (const GstCaps * caps1, + const GstCaps * caps2); /* operations */ -GstCaps * gst_caps_intersect (const GstCaps *caps1, - const GstCaps *caps2); -GstCaps * gst_caps_union (const GstCaps *caps1, - const GstCaps *caps2); -GstCaps * gst_caps_normalize (const GstCaps *caps); -GstCaps * gst_caps_simplify (const GstCaps *caps); + GstCaps *gst_caps_intersect (const GstCaps * caps1, const GstCaps * caps2); + GstCaps *gst_caps_union (const GstCaps * caps1, const GstCaps * caps2); + GstCaps *gst_caps_normalize (const GstCaps * caps); + GstCaps *gst_caps_simplify (const GstCaps * caps); #ifndef GST_DISABLE_LOADSAVE -xmlNodePtr gst_caps_save_thyself (const GstCaps *caps, - xmlNodePtr parent); -GstCaps * gst_caps_load_thyself (xmlNodePtr parent); + xmlNodePtr gst_caps_save_thyself (const GstCaps * caps, xmlNodePtr parent); + GstCaps *gst_caps_load_thyself (xmlNodePtr parent); #endif /* utility */ -void gst_caps_replace (GstCaps **caps, - GstCaps *newcaps); -gchar * gst_caps_to_string (const GstCaps *caps); -GstCaps * gst_caps_from_string (const gchar *string); - -gboolean gst_caps_structure_fixate_field_nearest_int (GstStructure *structure, - const char *field_name, - int target); -gboolean gst_caps_structure_fixate_field_nearest_double (GstStructure *structure, - const char *field_name, - double target); + void gst_caps_replace (GstCaps ** caps, GstCaps * newcaps); + gchar *gst_caps_to_string (const GstCaps * caps); + GstCaps *gst_caps_from_string (const gchar * string); -G_END_DECLS + gboolean gst_caps_structure_fixate_field_nearest_int (GstStructure * + structure, const char *field_name, int target); + gboolean gst_caps_structure_fixate_field_nearest_double (GstStructure * + structure, const char *field_name, double target); +G_END_DECLS #endif /* __GST_CAPS_H__ */ diff --git a/gst/gstclock.c b/gst/gstclock.c index 490c878c2..fcf1b70ef 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -37,35 +37,37 @@ static GstAllocTrace *_gst_clock_entry_trace; #define DEFAULT_EVENT_DIFF (GST_SECOND) #define DEFAULT_MAX_DIFF (2 * GST_SECOND) -enum { +enum +{ ARG_0, ARG_STATS, ARG_MAX_DIFF, ARG_EVENT_DIFF }; -static GstMemChunk *_gst_clock_entries_chunk; +static GstMemChunk *_gst_clock_entries_chunk; + +void gst_clock_id_unlock (GstClockID id); -void gst_clock_id_unlock (GstClockID id); - -static void gst_clock_class_init (GstClockClass *klass); -static void gst_clock_init (GstClock *clock); -static void gst_clock_dispose (GObject *object); +static void gst_clock_class_init (GstClockClass * klass); +static void gst_clock_init (GstClock * clock); +static void gst_clock_dispose (GObject * object); -static void gst_clock_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_clock_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec * pspec); -static void gst_clock_update_stats (GstClock *clock); +static void gst_clock_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_clock_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_clock_update_stats (GstClock * clock); static GstObjectClass *parent_class = NULL; + /* static guint gst_clock_signals[LAST_SIGNAL] = { 0 }; */ static GstClockID -gst_clock_entry_new (GstClock *clock, GstClockTime time, - GstClockTime interval, GstClockEntryType type) +gst_clock_entry_new (GstClock * clock, GstClockTime time, + GstClockTime interval, GstClockEntryType type) { GstClockEntry *entry; @@ -94,14 +96,12 @@ gst_clock_entry_new (GstClock *clock, GstClockTime time, * Returns: An id that can be used to request the time notification. */ GstClockID -gst_clock_new_single_shot_id (GstClock *clock, GstClockTime time) +gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time) { g_return_val_if_fail (GST_IS_CLOCK (clock), NULL); - return gst_clock_entry_new (clock, - time, - GST_CLOCK_TIME_NONE, - GST_CLOCK_ENTRY_SINGLE); + return gst_clock_entry_new (clock, + time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE); } /** @@ -117,17 +117,15 @@ gst_clock_new_single_shot_id (GstClock *clock, GstClockTime time) * Returns: An id that can be used to request the time notification. */ GstClockID -gst_clock_new_periodic_id (GstClock *clock, GstClockTime start_time, - GstClockTime interval) +gst_clock_new_periodic_id (GstClock * clock, GstClockTime start_time, + GstClockTime interval) { g_return_val_if_fail (GST_IS_CLOCK (clock), NULL); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (start_time), NULL); g_return_val_if_fail (interval != 0, NULL); - return gst_clock_entry_new (clock, - start_time, - interval, - GST_CLOCK_ENTRY_PERIODIC); + return gst_clock_entry_new (clock, + start_time, interval, GST_CLOCK_ENTRY_PERIODIC); } /** @@ -143,7 +141,7 @@ gst_clock_id_get_time (GstClockID id) { g_return_val_if_fail (id != NULL, GST_CLOCK_TIME_NONE); - return GST_CLOCK_ENTRY_TIME ((GstClockEntry *)id); + return GST_CLOCK_ENTRY_TIME ((GstClockEntry *) id); } @@ -158,30 +156,30 @@ gst_clock_id_get_time (GstClockID id) * Returns: the result of the blocking wait. */ GstClockReturn -gst_clock_id_wait (GstClockID id, GstClockTimeDiff *jitter) +gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter) { GstClockEntry *entry; GstClock *clock; GstClockReturn res = GST_CLOCK_UNSUPPORTED; GstClockTime requested; GstClockClass *cclass; - + g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR); entry = (GstClockEntry *) id; requested = GST_CLOCK_ENTRY_TIME (entry); - if (! GST_CLOCK_TIME_IS_VALID (requested)) { + if (!GST_CLOCK_TIME_IS_VALID (requested)) { GST_CAT_DEBUG (GST_CAT_CLOCK, "invalid time requested, returning _TIMEOUT"); return GST_CLOCK_TIMEOUT; } clock = GST_CLOCK_ENTRY_CLOCK (entry); cclass = GST_CLOCK_GET_CLASS (clock); - + if (cclass->wait) { GstClockTime now; - + GST_LOCK (clock); clock->entries = g_list_prepend (clock->entries, entry); GST_UNLOCK (clock); @@ -223,20 +221,20 @@ gst_clock_id_wait (GstClockID id, GstClockTimeDiff *jitter) */ GstClockReturn gst_clock_id_wait_async (GstClockID id, - GstClockCallback func, gpointer user_data) + GstClockCallback func, gpointer user_data) { GstClockEntry *entry; GstClock *clock; GstClockReturn res = GST_CLOCK_UNSUPPORTED; GstClockClass *cclass; - + g_return_val_if_fail (id != NULL, GST_CLOCK_ERROR); g_return_val_if_fail (func != NULL, GST_CLOCK_ERROR); entry = (GstClockEntry *) id; clock = entry->clock; - if (! GST_CLOCK_TIME_IS_VALID (GST_CLOCK_ENTRY_TIME (entry))) { + if (!GST_CLOCK_TIME_IS_VALID (GST_CLOCK_ENTRY_TIME (entry))) { (func) (clock, GST_CLOCK_TIME_NONE, id, user_data); return GST_CLOCK_TIMEOUT; } @@ -254,11 +252,11 @@ gst_clock_id_wait_async (GstClockID id, } static void -gst_clock_reschedule_func (GstClockEntry *entry) +gst_clock_reschedule_func (GstClockEntry * entry) { entry->status = GST_CLOCK_ENTRY_OK; - - gst_clock_id_unlock ((GstClockID)entry); + + gst_clock_id_unlock ((GstClockID) entry); } /** @@ -273,7 +271,7 @@ gst_clock_id_unschedule (GstClockID id) GstClockEntry *entry; GstClock *clock; GstClockClass *cclass; - + g_return_if_fail (id != NULL); entry = (GstClockEntry *) id; @@ -314,7 +312,7 @@ gst_clock_id_unlock (GstClockID id) GstClockEntry *entry; GstClock *clock; GstClockClass *cclass; - + g_return_if_fail (id != NULL); entry = (GstClockEntry *) id; @@ -348,20 +346,20 @@ gst_clock_get_type (void) (GInstanceInitFunc) gst_clock_init, NULL }; - clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock", - &clock_info, G_TYPE_FLAG_ABSTRACT); + clock_type = g_type_register_static (GST_TYPE_OBJECT, "GstClock", + &clock_info, G_TYPE_FLAG_ABSTRACT); } return clock_type; } static void -gst_clock_class_init (GstClockClass *klass) +gst_clock_class_init (GstClockClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; - gobject_class = (GObjectClass*) klass; - gstobject_class = (GstObjectClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; parent_class = g_type_class_ref (GST_TYPE_OBJECT); @@ -369,31 +367,33 @@ gst_clock_class_init (GstClockClass *klass) g_thread_init (NULL); _gst_clock_entries_chunk = gst_mem_chunk_new ("GstClockEntries", - sizeof (GstClockEntry), sizeof (GstClockEntry) * 32, - G_ALLOC_AND_FREE); + sizeof (GstClockEntry), sizeof (GstClockEntry) * 32, G_ALLOC_AND_FREE); #ifndef GST_DISABLE_TRACE - _gst_clock_entry_trace = gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME); + _gst_clock_entry_trace = + gst_alloc_trace_register (GST_CLOCK_ENTRY_TRACE_NAME); #endif - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_clock_dispose); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_clock_dispose); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_clock_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_clock_get_property); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATS, - g_param_spec_boolean ("stats", "Stats", "Enable clock stats", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("stats", "Stats", "Enable clock stats", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_DIFF, - g_param_spec_int64 ("max-diff", "Max diff", "The maximum amount of time to wait in nanoseconds", - 0, G_MAXINT64, DEFAULT_MAX_DIFF, G_PARAM_READWRITE)); + g_param_spec_int64 ("max-diff", "Max diff", + "The maximum amount of time to wait in nanoseconds", 0, G_MAXINT64, + DEFAULT_MAX_DIFF, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_DIFF, - g_param_spec_uint64 ("event-diff", "event diff", - "The amount of time that may elapse until 2 events are treated as happening at different times", - 0, G_MAXUINT64, DEFAULT_EVENT_DIFF, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_param_spec_uint64 ("event-diff", "event diff", + "The amount of time that may elapse until 2 events are treated as happening at different times", + 0, G_MAXUINT64, DEFAULT_EVENT_DIFF, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); } static void -gst_clock_init (GstClock *clock) +gst_clock_init (GstClock * clock) { clock->max_diff = DEFAULT_MAX_DIFF; @@ -408,7 +408,7 @@ gst_clock_init (GstClock *clock) } static void -gst_clock_dispose (GObject *object) +gst_clock_dispose (GObject * object) { GstClock *clock = GST_CLOCK (object); @@ -429,7 +429,7 @@ gst_clock_dispose (GObject *object) * Returns: the new speed of the clock. */ gdouble -gst_clock_set_speed (GstClock *clock, gdouble speed) +gst_clock_set_speed (GstClock * clock, gdouble speed) { g_return_val_if_fail (GST_IS_CLOCK (clock), 0.0); @@ -446,7 +446,7 @@ gst_clock_set_speed (GstClock *clock, gdouble speed) * Returns: the speed of the clock. */ gdouble -gst_clock_get_speed (GstClock *clock) +gst_clock_get_speed (GstClock * clock) { g_return_val_if_fail (GST_IS_CLOCK (clock), 0.0); @@ -464,7 +464,7 @@ gst_clock_get_speed (GstClock *clock) * Returns: the new resolution of the clock. */ guint64 -gst_clock_set_resolution (GstClock *clock, guint64 resolution) +gst_clock_set_resolution (GstClock * clock, guint64 resolution) { GstClockClass *cclass; @@ -474,7 +474,8 @@ gst_clock_set_resolution (GstClock *clock, guint64 resolution) cclass = GST_CLOCK_GET_CLASS (clock); if (cclass->change_resolution) - clock->resolution = cclass->change_resolution (clock, clock->resolution, resolution); + clock->resolution = + cclass->change_resolution (clock, clock->resolution, resolution); return clock->resolution; } @@ -488,7 +489,7 @@ gst_clock_set_resolution (GstClock *clock, guint64 resolution) * Returns: the resolution of the clock in microseconds. */ guint64 -gst_clock_get_resolution (GstClock *clock) +gst_clock_get_resolution (GstClock * clock) { GstClockClass *cclass; @@ -511,10 +512,10 @@ gst_clock_get_resolution (GstClock *clock) * As soon as the clock is activated, the time will start ticking. */ void -gst_clock_set_active (GstClock *clock, gboolean active) +gst_clock_set_active (GstClock * clock, gboolean active) { g_return_if_fail (GST_IS_CLOCK (clock)); - + GST_ERROR_OBJECT (clock, "called deprecated function that does nothing now."); return; @@ -529,7 +530,7 @@ gst_clock_set_active (GstClock *clock, gboolean active) * Returns: TRUE if the clock is active. */ gboolean -gst_clock_is_active (GstClock *clock) +gst_clock_is_active (GstClock * clock) { g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE); @@ -545,7 +546,7 @@ gst_clock_is_active (GstClock *clock) * Reset the clock to time 0. */ void -gst_clock_reset (GstClock *clock) +gst_clock_reset (GstClock * clock) { GstClockTime time = G_GINT64_CONSTANT (0); GstClockClass *cclass; @@ -555,7 +556,7 @@ gst_clock_reset (GstClock *clock) GST_ERROR_OBJECT (clock, "called deprecated function."); cclass = GST_CLOCK_GET_CLASS (clock); - + if (cclass->get_internal_time) { time = cclass->get_internal_time (clock); } @@ -580,7 +581,7 @@ gst_clock_reset (GstClock *clock) * discontinuitity in the pipeline is honoured. */ gboolean -gst_clock_handle_discont (GstClock *clock, guint64 time) +gst_clock_handle_discont (GstClock * clock, guint64 time) { GST_ERROR_OBJECT (clock, "called deprecated function."); @@ -597,7 +598,7 @@ gst_clock_handle_discont (GstClock *clock, guint64 time) * Returns: the time of the clock. */ GstClockTime -gst_clock_get_time (GstClock *clock) +gst_clock_get_time (GstClock * clock) { GstClockTime ret = G_GINT64_CONSTANT (0); GstClockClass *cclass; @@ -612,8 +613,7 @@ gst_clock_get_time (GstClock *clock) /* make sure the time is increasing, else return last_time */ if ((gint64) ret < (gint64) clock->last_time) { ret = clock->last_time; - } - else { + } else { clock->last_time = ret; } @@ -632,23 +632,23 @@ gst_clock_get_time (GstClock *clock) * Returns: the time of the event */ GstClockTime -gst_clock_get_event_time (GstClock *clock) +gst_clock_get_event_time (GstClock * clock) { GstClockTime time; - + g_return_val_if_fail (GST_IS_CLOCK (clock), GST_CLOCK_TIME_NONE); - + time = gst_clock_get_time (clock); if (clock->last_event + clock->max_event_diff >= time) { - GST_LOG_OBJECT (clock, "reporting last event time %"G_GUINT64_FORMAT, + GST_LOG_OBJECT (clock, "reporting last event time %" G_GUINT64_FORMAT, clock->last_event); } else { - GST_LOG_OBJECT (clock, "reporting new event time %"G_GUINT64_FORMAT, + GST_LOG_OBJECT (clock, "reporting new event time %" G_GUINT64_FORMAT, clock->last_event); clock->last_event = time; } - + return clock->last_event; } @@ -661,7 +661,7 @@ gst_clock_get_event_time (GstClock *clock) * Returns: a clockid or NULL is no event is pending. */ GstClockID -gst_clock_get_next_id (GstClock *clock) +gst_clock_get_next_id (GstClock * clock) { GstClockEntry *entry = NULL; @@ -676,16 +676,16 @@ gst_clock_get_next_id (GstClock *clock) } static void -gst_clock_update_stats (GstClock *clock) +gst_clock_update_stats (GstClock * clock) { } static void -gst_clock_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_clock_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstClock *clock; - + clock = GST_CLOCK (object); switch (prop_id) { @@ -704,15 +704,15 @@ gst_clock_set_property (GObject *object, guint prop_id, default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; - } + } } static void -gst_clock_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec * pspec) +gst_clock_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstClock *clock; - + clock = GST_CLOCK (object); switch (prop_id) { @@ -728,5 +728,5 @@ gst_clock_get_property (GObject *object, guint prop_id, default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; - } + } } diff --git a/gst/gstclock.h b/gst/gstclock.h index f4e76bce7..7255db038 100644 --- a/gst/gstclock.h +++ b/gst/gstclock.h @@ -26,7 +26,6 @@ #include G_BEGIN_DECLS - /* --- standard type macros --- */ #define GST_TYPE_CLOCK (gst_clock_get_type ()) #define GST_CLOCK(clock) (G_TYPE_CHECK_INSTANCE_CAST ((clock), GST_TYPE_CLOCK, GstClock)) @@ -34,10 +33,9 @@ G_BEGIN_DECLS #define GST_CLOCK_CLASS(cclass) (G_TYPE_CHECK_CLASS_CAST ((cclass), GST_TYPE_CLOCK, GstClockClass)) #define GST_IS_CLOCK_CLASS(cclass) (G_TYPE_CHECK_CLASS_TYPE ((cclass), GST_TYPE_CLOCK)) #define GST_CLOCK_GET_CLASS(clock) (G_TYPE_INSTANCE_GET_CLASS ((clock), GST_TYPE_CLOCK, GstClockClass)) - -typedef guint64 GstClockTime; -typedef gint64 GstClockTimeDiff; -typedef gpointer GstClockID; +typedef guint64 GstClockTime; +typedef gint64 GstClockTimeDiff; +typedef gpointer GstClockID; #define GST_CLOCK_TIME_NONE ((GstClockTime)-1) #define GST_CLOCK_TIME_IS_VALID(time) ((time) != GST_CLOCK_TIME_NONE) @@ -57,22 +55,24 @@ G_STMT_START { \ #define GST_CLOCK_ENTRY_TRACE_NAME "GstClockEntry" -typedef struct _GstClockEntry GstClockEntry; -typedef struct _GstClock GstClock; -typedef struct _GstClockClass GstClockClass; +typedef struct _GstClockEntry GstClockEntry; +typedef struct _GstClock GstClock; +typedef struct _GstClockClass GstClockClass; /* --- prototype for async callbacks --- */ -typedef gboolean (*GstClockCallback) (GstClock *clock, GstClockTime time, - GstClockID id, gpointer user_data); +typedef gboolean (*GstClockCallback) (GstClock * clock, GstClockTime time, + GstClockID id, gpointer user_data); -typedef enum { +typedef enum +{ /* --- protected --- */ GST_CLOCK_ENTRY_OK, GST_CLOCK_ENTRY_EARLY, GST_CLOCK_ENTRY_RESTART } GstClockEntryStatus; -typedef enum { +typedef enum +{ /* --- protected --- */ GST_CLOCK_ENTRY_SINGLE, GST_CLOCK_ENTRY_PERIODIC @@ -85,120 +85,118 @@ typedef enum { #define GST_CLOCK_ENTRY_INTERVAL(entry) ((entry)->interval) #define GST_CLOCK_ENTRY_STATUS(entry) ((entry)->status) -struct _GstClockEntry { +struct _GstClockEntry +{ /* --- protected --- */ - GstClock *clock; - GstClockEntryType type; - GstClockTime time; - GstClockTime interval; - GstClockEntryStatus status; - GstClockCallback func; - gpointer user_data; + GstClock *clock; + GstClockEntryType type; + GstClockTime time; + GstClockTime interval; + GstClockEntryStatus status; + GstClockCallback func; + gpointer user_data; }; typedef enum { - GST_CLOCK_STOPPED = 0, - GST_CLOCK_TIMEOUT = 1, - GST_CLOCK_EARLY = 2, - GST_CLOCK_ERROR = 3, - GST_CLOCK_UNSUPPORTED = 4 + GST_CLOCK_STOPPED = 0, + GST_CLOCK_TIMEOUT = 1, + GST_CLOCK_EARLY = 2, + GST_CLOCK_ERROR = 3, + GST_CLOCK_UNSUPPORTED = 4 } GstClockReturn; typedef enum { - GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC = (1 << 1), - GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC = (1 << 2), - GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC = (1 << 3), - GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC = (1 << 4), - GST_CLOCK_FLAG_CAN_SET_RESOLUTION = (1 << 5), - GST_CLOCK_FLAG_CAN_SET_SPEED = (1 << 6) + GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC = (1 << 1), + GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC = (1 << 2), + GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC = (1 << 3), + GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC = (1 << 4), + GST_CLOCK_FLAG_CAN_SET_RESOLUTION = (1 << 5), + GST_CLOCK_FLAG_CAN_SET_SPEED = (1 << 6) } GstClockFlags; #define GST_CLOCK_FLAGS(clock) (GST_CLOCK(clock)->flags) -struct _GstClock { - GstObject object; +struct _GstClock +{ + GstObject object; - GstClockFlags flags; + GstClockFlags flags; /* --- protected --- */ - GstClockTime start_time; - GstClockTime last_time; - gint64 max_diff; + GstClockTime start_time; + GstClockTime last_time; + gint64 max_diff; /* --- private --- */ - guint64 resolution; - GList *entries; - GMutex *active_mutex; - GCond *active_cond; - gboolean stats; - - GstClockTime last_event; - GstClockTime max_event_diff; - + guint64 resolution; + GList *entries; + GMutex *active_mutex; + GCond *active_cond; + gboolean stats; + + GstClockTime last_event; + GstClockTime max_event_diff; + gpointer _gst_reserved[GST_PADDING]; }; -struct _GstClockClass { - GstObjectClass parent_class; +struct _GstClockClass +{ + GstObjectClass parent_class; /* vtable */ - gdouble (*change_speed) (GstClock *clock, - gdouble oldspeed, gdouble newspeed); - gdouble (*get_speed) (GstClock *clock); - guint64 (*change_resolution) (GstClock *clock, guint64 old_resolution, - guint64 new_resolution); - guint64 (*get_resolution) (GstClock *clock); + gdouble (*change_speed) (GstClock * clock, + gdouble oldspeed, gdouble newspeed); + gdouble (*get_speed) (GstClock * clock); + guint64 (*change_resolution) (GstClock * clock, guint64 old_resolution, + guint64 new_resolution); + guint64 (*get_resolution) (GstClock * clock); - GstClockTime (*get_internal_time) (GstClock *clock); + GstClockTime (*get_internal_time) (GstClock * clock); /* waiting on an ID */ - GstClockEntryStatus (*wait) (GstClock *clock, GstClockEntry *entry); - GstClockEntryStatus (*wait_async) (GstClock *clock, GstClockEntry *entry); - void (*unschedule) (GstClock *clock, GstClockEntry *entry); - void (*unlock) (GstClock *clock, GstClockEntry *entry); + GstClockEntryStatus (*wait) (GstClock * clock, GstClockEntry * entry); + GstClockEntryStatus (*wait_async) (GstClock * clock, GstClockEntry * entry); + void (*unschedule) (GstClock * clock, GstClockEntry * entry); + void (*unlock) (GstClock * clock, GstClockEntry * entry); gpointer _gst_reserved[GST_PADDING]; }; -GType gst_clock_get_type (void); +GType gst_clock_get_type (void); -gdouble gst_clock_set_speed (GstClock *clock, gdouble speed); -gdouble gst_clock_get_speed (GstClock *clock); +gdouble gst_clock_set_speed (GstClock * clock, gdouble speed); +gdouble gst_clock_get_speed (GstClock * clock); -guint64 gst_clock_set_resolution (GstClock *clock, guint64 resolution); -guint64 gst_clock_get_resolution (GstClock *clock); +guint64 gst_clock_set_resolution (GstClock * clock, guint64 resolution); +guint64 gst_clock_get_resolution (GstClock * clock); -void gst_clock_set_active (GstClock *clock, gboolean active); -gboolean gst_clock_is_active (GstClock *clock); -void gst_clock_reset (GstClock *clock); -gboolean gst_clock_handle_discont (GstClock *clock, guint64 time); +void gst_clock_set_active (GstClock * clock, gboolean active); +gboolean gst_clock_is_active (GstClock * clock); +void gst_clock_reset (GstClock * clock); +gboolean gst_clock_handle_discont (GstClock * clock, guint64 time); -GstClockTime gst_clock_get_time (GstClock *clock); -GstClockTime gst_clock_get_event_time (GstClock *clock); +GstClockTime gst_clock_get_time (GstClock * clock); +GstClockTime gst_clock_get_event_time (GstClock * clock); -GstClockID gst_clock_get_next_id (GstClock *clock); +GstClockID gst_clock_get_next_id (GstClock * clock); /* creating IDs that can be used to get notifications */ -GstClockID gst_clock_new_single_shot_id (GstClock *clock, - GstClockTime time); -GstClockID gst_clock_new_periodic_id (GstClock *clock, - GstClockTime start_time, - GstClockTime interval); +GstClockID gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time); +GstClockID gst_clock_new_periodic_id (GstClock * clock, + GstClockTime start_time, GstClockTime interval); /* operations on IDs */ -GstClockTime gst_clock_id_get_time (GstClockID id); -GstClockReturn gst_clock_id_wait (GstClockID id, - GstClockTimeDiff *jitter); -GstClockReturn gst_clock_id_wait_async (GstClockID id, - GstClockCallback func, - gpointer user_data); -void gst_clock_id_unschedule (GstClockID id); -void gst_clock_id_unlock (GstClockID id); -void gst_clock_id_free (GstClockID id); +GstClockTime gst_clock_id_get_time (GstClockID id); +GstClockReturn gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter); +GstClockReturn gst_clock_id_wait_async (GstClockID id, + GstClockCallback func, gpointer user_data); +void gst_clock_id_unschedule (GstClockID id); +void gst_clock_id_unlock (GstClockID id); +void gst_clock_id_free (GstClockID id); G_END_DECLS - #endif /* __GST_CLOCK_H__ */ diff --git a/gst/gstcompat.h b/gst/gstcompat.h index 5ec345846..204c3a6ce 100644 --- a/gst/gstcompat.h +++ b/gst/gstcompat.h @@ -26,10 +26,8 @@ #define __GSTCOMPAT_H__ G_BEGIN_DECLS - #ifndef GST_DISABLE_DEPRECATED /* 0.5.2 changes */ - /* element functions */ #define gst_element_connect(a,b) gst_element_link(a,b) #define gst_element_connect_pads(a,b,c,d) \ @@ -43,7 +41,6 @@ G_BEGIN_DECLS #define gst_element_connect_filtered(a,b,c) \ gst_element_link_filtered(a,b,c) #define gst_element_disconnect(a,b) gst_element_unlink(a,b) - /* pad functions */ #define gst_pad_connect(a,b) gst_pad_link(a,b) #define gst_pad_connect_filtered(a,b,c) gst_pad_link_filtered(a,b,c) @@ -51,19 +48,17 @@ G_BEGIN_DECLS #define gst_pad_proxy_connect(a,b) gst_pad_proxy_link(a,b) #define gst_pad_set_connect_function(a,b) \ gst_pad_set_link_function(a,b) - /* pad macros */ #define GST_PAD_IS_CONNECTED(a) GST_PAD_IS_LINKED(a) - /* pad enums */ #define GST_PAD_CONNECT_REFUSED GST_PAD_LINK_REFUSED #define GST_PAD_CONNECT_DELAYED GST_PAD_LINK_DELAYED #define GST_PAD_CONNECT_OK GST_PAD_LINK_OK #define GST_PAD_CONNECT_DONE GST_PAD_LINK_DONE -typedef GstPadLinkReturn GstPadConnectReturn; +typedef GstPadLinkReturn GstPadConnectReturn; /* pad function types */ -typedef GstPadLinkFunction GstPadConnectFunction; +typedef GstPadLinkFunction GstPadConnectFunction; /* probably not used */ /* @@ -72,5 +67,4 @@ typedef GstPadLinkFunction GstPadConnectFunction; #endif /* not GST_DISABLE_DEPRECATED */ G_END_DECLS - #endif /* __GSTCOMPAT_H__ */ diff --git a/gst/gstcpu.c b/gst/gstcpu.c index 41db47d7a..8d47f86c5 100644 --- a/gst/gstcpu.c +++ b/gst/gstcpu.c @@ -32,11 +32,12 @@ static guint32 _gst_cpu_flags = 0; #ifdef HAVE_CPU_I386 #define _gst_cpu_initialize_arch _gst_cpu_initialize_i386 -void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *, unsigned long *); -gboolean _gst_cpu_initialize_i386 (gulong *flags, GString *featurelist); +void gst_cpuid_i386 (int, unsigned long *, unsigned long *, unsigned long *, + unsigned long *); +gboolean _gst_cpu_initialize_i386 (gulong * flags, GString * featurelist); #else #define _gst_cpu_initialize_arch _gst_cpu_initialize_none -gboolean _gst_cpu_initialize_none (gulong *flags, GString *featurelist); +gboolean _gst_cpu_initialize_none (gulong * flags, GString * featurelist); #endif @@ -45,26 +46,27 @@ _gst_cpu_initialize (gboolean opt) { GString *featurelist = g_string_new (""); gulong flags = 0; - + if (opt) { if (!_gst_cpu_initialize_arch (&flags, featurelist)) g_string_append (featurelist, "NONE"); } else g_string_append (featurelist, "(DISABLED)"); - GST_CAT_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", flags, featurelist->str); + GST_CAT_INFO (GST_CAT_GST_INIT, "CPU features: (%08lx) %s", flags, + featurelist->str); g_string_free (featurelist, TRUE); } gboolean -_gst_cpu_initialize_none (gulong *flags, GString *featurelist) +_gst_cpu_initialize_none (gulong * flags, GString * featurelist) { return FALSE; } #ifdef HAVE_CPU_I386 gboolean -_gst_cpu_initialize_i386 (gulong *flags, GString *featurelist) +_gst_cpu_initialize_i386 (gulong * flags, GString * featurelist) { gboolean AMD; gulong eax = 0, ebx = 0, ecx = 0, edx = 0; diff --git a/gst/gstcpu.h b/gst/gstcpu.h index 85c338487..f641cb97c 100644 --- a/gst/gstcpu.h +++ b/gst/gstcpu.h @@ -24,19 +24,17 @@ #ifndef __GST_CPU_H__ #define __GST_CPU_H__ -G_BEGIN_DECLS - -typedef enum { - GST_CPU_FLAG_MMX = (1<<0), - GST_CPU_FLAG_SSE = (1<<1), - GST_CPU_FLAG_MMXEXT = (1<<2), - GST_CPU_FLAG_3DNOW = (1<<3) +G_BEGIN_DECLS typedef enum +{ + GST_CPU_FLAG_MMX = (1 << 0), + GST_CPU_FLAG_SSE = (1 << 1), + GST_CPU_FLAG_MMXEXT = (1 << 2), + GST_CPU_FLAG_3DNOW = (1 << 3) } GstCPUFlags; -void _gst_cpu_initialize (gboolean useopt); +void _gst_cpu_initialize (gboolean useopt); -GstCPUFlags gst_cpu_get_flags (void); +GstCPUFlags gst_cpu_get_flags (void); G_END_DECLS - #endif /* __GST_CPU_H__ */ diff --git a/gst/gstdata.c b/gst/gstdata.c index 09e893b4c..27664820f 100644 --- a/gst/gstdata.c +++ b/gst/gstdata.c @@ -31,12 +31,11 @@ GType gst_data_get_type (void) { static GType type = 0; - + if (!type) type = g_boxed_type_register_static ("GstData", - (GBoxedCopyFunc) gst_data_copy, - (GBoxedFreeFunc) gst_data_unref); - return type; + (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref); + return type; } /** @@ -51,7 +50,8 @@ gst_data_get_type (void) * function will be called when this data is freed or copied respectively. */ void -gst_data_init (GstData *data, GType type, guint16 flags, GstDataFreeFunction free, GstDataCopyFunction copy) +gst_data_init (GstData * data, GType type, guint16 flags, + GstDataFreeFunction free, GstDataCopyFunction copy) { g_return_if_fail (data != NULL); @@ -68,7 +68,7 @@ gst_data_init (GstData *data, GType type, guint16 flags, GstDataFreeFunction fre * the relevant GstData info. */ void -gst_data_copy_into (const GstData *data, GstData *target) +gst_data_copy_into (const GstData * data, GstData * target) { g_return_if_fail (data != NULL); } @@ -81,7 +81,7 @@ gst_data_copy_into (const GstData *data, GstData *target) * mainly used by subclass implementors. */ void -gst_data_dispose (GstData *data) +gst_data_dispose (GstData * data) { g_return_if_fail (data != NULL); @@ -99,13 +99,13 @@ gst_data_dispose (GstData *data) * of the original buffer is not changed so you should unref it when you don't * need it anymore. */ -GstData* -gst_data_copy (const GstData *data) +GstData * +gst_data_copy (const GstData * data) { g_return_val_if_fail (data != NULL, NULL); if (data->copy) - return data->copy (data); + return data->copy (data); return NULL; } @@ -120,7 +120,7 @@ gst_data_copy (const GstData *data) * be copied before it can be modified safely. */ gboolean -gst_data_is_writable (GstData *data) +gst_data_is_writable (GstData * data) { gint refcount; @@ -147,8 +147,8 @@ gst_data_is_writable (GstData *data) * is decreased when a copy is made, so you are not supposed to use it after a * call to this function. */ -GstData* -gst_data_copy_on_write (GstData *data) +GstData * +gst_data_copy_on_write (GstData * data) { gint refcount; @@ -158,11 +158,12 @@ gst_data_copy_on_write (GstData *data) if (refcount == 1 && !GST_DATA_FLAG_IS_SET (data, GST_DATA_READONLY)) return GST_DATA (data); - + if (data->copy) { - GstData *copy = data->copy (data); + GstData *copy = data->copy (data); + gst_data_unref (data); - return copy; + return copy; } return NULL; @@ -176,15 +177,15 @@ gst_data_copy_on_write (GstData *data) * * Returns: the data */ -GstData* -gst_data_ref (GstData *data) +GstData * +gst_data_ref (GstData * data) { g_return_val_if_fail (data != NULL, NULL); - g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE(data) > 0, NULL); + g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0, NULL); GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data, - GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + 1); - + GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + 1); + gst_atomic_int_inc (&data->refcount); return data; @@ -199,15 +200,15 @@ gst_data_ref (GstData *data) * * Returns: the data */ -GstData* -gst_data_ref_by_count (GstData *data, gint count) +GstData * +gst_data_ref_by_count (GstData * data, gint count) { g_return_val_if_fail (data != NULL, NULL); g_return_val_if_fail (count >= 0, NULL); - g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE(data) > 0, NULL); + g_return_val_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0, NULL); GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data, - GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + count); + GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + count); gst_atomic_int_add (&data->refcount, count); @@ -225,22 +226,22 @@ gst_data_ref_by_count (GstData *data, gint count) * data. When the data has been used by some plugin, it must unref()s it. * Applications usually don't need to unref() anything. */ -void -gst_data_unref (GstData *data) +void +gst_data_unref (GstData * data) { gint zero; g_return_if_fail (data != NULL); GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data, - GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) - 1); + GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) - 1); g_return_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0); zero = gst_atomic_int_dec_and_test (&data->refcount); /* if we ended up with the refcount at zero, free the data */ if (zero) { - if (data->free) - data->free (data); + if (data->free) + data->free (data); } } diff --git a/gst/gstdata.h b/gst/gstdata.h index 1c3da1f0d..08bd0653b 100644 --- a/gst/gstdata.h +++ b/gst/gstdata.h @@ -29,32 +29,28 @@ #include G_BEGIN_DECLS - /* type */ #define GST_DATA(data) ((GstData*)(data)) #define GST_DATA_TYPE(data) (GST_DATA(data)->type) - /* flags */ #define GST_DATA_FLAGS(data) (GST_DATA(data)->flags) #define GST_DATA_FLAG_SHIFT(flag) (1<<(flag)) #define GST_DATA_FLAG_IS_SET(data,flag) (GST_DATA_FLAGS(data) & (1<<(flag))) #define GST_DATA_FLAG_SET(data,flag) G_STMT_START{ (GST_DATA_FLAGS(data) |= (1<<(flag))); }G_STMT_END #define GST_DATA_FLAG_UNSET(data,flag) G_STMT_START{ (GST_DATA_FLAGS(data) &= ~(1<<(flag))); }G_STMT_END - /* Macros for the GType */ #define GST_TYPE_DATA (gst_data_get_type ()) - typedef struct _GstData GstData; -typedef void (*GstDataFreeFunction) (GstData *data); -typedef GstData* (*GstDataCopyFunction) (const GstData *data); +typedef void (*GstDataFreeFunction) (GstData * data); +typedef GstData *(*GstDataCopyFunction) (const GstData * data); typedef enum { - GST_DATA_READONLY = 1, + GST_DATA_READONLY = 1, /* insert more */ - GST_DATA_FLAG_LAST = 8 + GST_DATA_FLAG_LAST = 8 } GstDataFlags; /* refcount */ @@ -66,41 +62,42 @@ typedef enum #define GST_DATA_FREE_FUNC(data) (GST_DATA(data)->free) -struct _GstData { - GType type; +struct _GstData +{ + GType type; /* refcounting */ - GstAtomicInt refcount; + GstAtomicInt refcount; + + guint16 flags; - guint16 flags; - /* utility function pointers, can override default */ - GstDataFreeFunction free; /* free the data */ - GstDataCopyFunction copy; /* copy the data */ + GstDataFreeFunction free; /* free the data */ + GstDataCopyFunction copy; /* copy the data */ gpointer _gst_reserved[GST_PADDING]; }; /* function used by subclasses only */ -void gst_data_init (GstData *data, GType type, guint16 flags, - GstDataFreeFunction free, - GstDataCopyFunction copy); -void gst_data_dispose (GstData *data); -void gst_data_copy_into (const GstData *data, GstData *target); +void gst_data_init (GstData * data, GType type, guint16 flags, + GstDataFreeFunction free, GstDataCopyFunction copy); +void gst_data_dispose (GstData * data); +void gst_data_copy_into (const GstData * data, GstData * target); /* basic operations on data */ -GstData* gst_data_copy (const GstData *data); -gboolean gst_data_is_writable (GstData *data); -GstData* gst_data_copy_on_write (GstData *data); +GstData *gst_data_copy (const GstData * data); +gboolean gst_data_is_writable (GstData * data); +GstData *gst_data_copy_on_write (GstData * data); /* reference counting */ -GstData* gst_data_ref (GstData* data); -GstData* gst_data_ref_by_count (GstData* data, gint count); -void gst_data_unref (GstData* data); +GstData *gst_data_ref (GstData * data); +GstData *gst_data_ref_by_count (GstData * data, gint count); +void gst_data_unref (GstData * data); /* GType for GstData */ -GType gst_data_get_type (void) G_GNUC_CONST; +GType +gst_data_get_type (void) + G_GNUC_CONST; G_END_DECLS - #endif /* __GST_DATA_H__ */ diff --git a/gst/gstdata_private.h b/gst/gstdata_private.h index 6efb12917..4ba02e369 100644 --- a/gst/gstdata_private.h +++ b/gst/gstdata_private.h @@ -35,4 +35,3 @@ G_STMT_START { \ G_STMT_START { \ gst_atomic_int_destroy (&(data)->refcount); \ } G_STMT_END; - diff --git a/gst/gstelement.c b/gst/gstelement.c index fba5a6dba..cc7c129d2 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -36,7 +36,8 @@ #include "gst-i18n-lib.h" /* Element signals and args */ -enum { +enum +{ STATE_CHANGE, NEW_PAD, PAD_REMOVED, @@ -47,34 +48,38 @@ enum { LAST_SIGNAL }; -enum { +enum +{ ARG_0 - /* FILL ME */ + /* FILL ME */ }; -extern void __gst_element_details_clear (GstElementDetails *dp); -extern void __gst_element_details_copy (GstElementDetails *dest, - const GstElementDetails *src); +extern void __gst_element_details_clear (GstElementDetails * dp); +extern void __gst_element_details_copy (GstElementDetails * dest, + const GstElementDetails * src); -static void gst_element_class_init (GstElementClass *klass); -static void gst_element_init (GstElement *element); -static void gst_element_base_class_init (gpointer g_class); -static void gst_element_base_class_finalize (gpointer g_class); +static void gst_element_class_init (GstElementClass * klass); +static void gst_element_init (GstElement * element); +static void gst_element_base_class_init (gpointer g_class); +static void gst_element_base_class_finalize (gpointer g_class); -static void gst_element_real_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_element_real_get_property (GObject *object, guint prop_id, GValue *value, - GParamSpec *pspec); +static void gst_element_real_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_element_real_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_element_dispose (GObject *object); +static void gst_element_dispose (GObject * object); -static GstElementStateReturn gst_element_change_state (GstElement *element); -static void gst_element_error_func (GstElement* element, GstElement *source, GError *error, gchar *debug); -static void gst_element_found_tag_func (GstElement* element, GstElement *source, const GstTagList *tag_list); +static GstElementStateReturn gst_element_change_state (GstElement * element); +static void gst_element_error_func (GstElement * element, GstElement * source, + GError * error, gchar * debug); +static void gst_element_found_tag_func (GstElement * element, + GstElement * source, const GstTagList * tag_list); #ifndef GST_DISABLE_LOADSAVE -static xmlNodePtr gst_element_save_thyself (GstObject *object, xmlNodePtr parent); -static void gst_element_restore_thyself (GstObject *parent, xmlNodePtr self); +static xmlNodePtr gst_element_save_thyself (GstObject * object, + xmlNodePtr parent); +static void gst_element_restore_thyself (GstObject * parent, xmlNodePtr self); #endif GType _gst_element_type = 0; @@ -82,85 +87,85 @@ GType _gst_element_type = 0; static GstObjectClass *parent_class = NULL; static guint gst_element_signals[LAST_SIGNAL] = { 0 }; -GType gst_element_get_type (void) +GType +gst_element_get_type (void) { if (!_gst_element_type) { static const GTypeInfo element_info = { - sizeof(GstElementClass), + sizeof (GstElementClass), gst_element_base_class_init, gst_element_base_class_finalize, - (GClassInitFunc)gst_element_class_init, + (GClassInitFunc) gst_element_class_init, NULL, NULL, - sizeof(GstElement), + sizeof (GstElement), 0, - (GInstanceInitFunc)gst_element_init, + (GInstanceInitFunc) gst_element_init, NULL }; - _gst_element_type = g_type_register_static(GST_TYPE_OBJECT, "GstElement", - &element_info, G_TYPE_FLAG_ABSTRACT); + _gst_element_type = g_type_register_static (GST_TYPE_OBJECT, "GstElement", + &element_info, G_TYPE_FLAG_ABSTRACT); } return _gst_element_type; } static void -gst_element_class_init (GstElementClass *klass) +gst_element_class_init (GstElementClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; - gobject_class = (GObjectClass*) klass; - gstobject_class = (GstObjectClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_OBJECT); + parent_class = g_type_class_ref (GST_TYPE_OBJECT); gst_element_signals[STATE_CHANGE] = - g_signal_new ("state-change", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstElementClass, state_change), NULL, NULL, - gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, - G_TYPE_INT, G_TYPE_INT); + g_signal_new ("state-change", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstElementClass, state_change), NULL, + NULL, gst_marshal_VOID__INT_INT, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); gst_element_signals[NEW_PAD] = - g_signal_new ("new-pad", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstElementClass, new_pad), NULL, NULL, - gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + g_signal_new ("new-pad", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstElementClass, new_pad), NULL, NULL, + gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); gst_element_signals[PAD_REMOVED] = - g_signal_new ("pad-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstElementClass, pad_removed), NULL, NULL, - gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + g_signal_new ("pad-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstElementClass, pad_removed), NULL, NULL, + gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); gst_element_signals[ERROR] = - g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL, - gst_marshal_VOID__OBJECT_OBJECT_STRING, G_TYPE_NONE, 3, - GST_TYPE_ELEMENT, GST_TYPE_G_ERROR, - G_TYPE_STRING); - gst_element_signals[EOS] = - g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstElementClass, eos), NULL, NULL, - gst_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("error", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstElementClass, error), NULL, NULL, + gst_marshal_VOID__OBJECT_OBJECT_STRING, G_TYPE_NONE, 3, GST_TYPE_ELEMENT, + GST_TYPE_G_ERROR, G_TYPE_STRING); + gst_element_signals[EOS] = + g_signal_new ("eos", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstElementClass, eos), NULL, NULL, + gst_marshal_VOID__VOID, G_TYPE_NONE, 0); gst_element_signals[FOUND_TAG] = - g_signal_new ("found-tag", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstElementClass, found_tag), NULL, NULL, - gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2, - GST_TYPE_ELEMENT, GST_TYPE_TAG_LIST); + g_signal_new ("found-tag", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstElementClass, found_tag), NULL, NULL, + gst_marshal_VOID__OBJECT_BOXED, G_TYPE_NONE, 2, GST_TYPE_ELEMENT, + GST_TYPE_TAG_LIST); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_element_real_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_element_real_get_property); + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_element_real_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_element_real_get_property); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_element_dispose); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_element_dispose); #ifndef GST_DISABLE_LOADSAVE - gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_element_save_thyself); - gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_element_restore_thyself); + gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_element_save_thyself); + gstobject_class->restore_thyself = + GST_DEBUG_FUNCPTR (gst_element_restore_thyself); #endif - klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state); - klass->error = GST_DEBUG_FUNCPTR (gst_element_error_func); - klass->found_tag = GST_DEBUG_FUNCPTR (gst_element_found_tag_func); - klass->numpadtemplates = 0; + klass->change_state = GST_DEBUG_FUNCPTR (gst_element_change_state); + klass->error = GST_DEBUG_FUNCPTR (gst_element_error_func); + klass->found_tag = GST_DEBUG_FUNCPTR (gst_element_found_tag_func); + klass->numpadtemplates = 0; - klass->elementfactory = NULL; + klass->elementfactory = NULL; } static void @@ -170,8 +175,10 @@ gst_element_base_class_init (gpointer g_class) GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_element_real_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_element_real_get_property); + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_element_real_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_element_real_get_property); memset (&element_class->details, 0, sizeof (GstElementDetails)); element_class->padtemplates = NULL; @@ -188,7 +195,7 @@ gst_element_base_class_finalize (gpointer g_class) } static void -gst_element_init (GstElement *element) +gst_element_init (GstElement * element) { element->current_state = GST_STATE_NULL; element->pending_state = GST_STATE_VOID_PENDING; @@ -205,7 +212,8 @@ gst_element_init (GstElement *element) } static void -gst_element_real_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_element_real_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstElementClass *oclass = GST_ELEMENT_GET_CLASS (object); @@ -214,7 +222,8 @@ gst_element_real_set_property (GObject *object, guint prop_id, const GValue *val } static void -gst_element_real_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_element_real_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstElementClass *oclass = GST_ELEMENT_GET_CLASS (object); @@ -235,7 +244,8 @@ gst_element_real_get_property (GObject *object, guint prop_id, GValue *value, GP * The default handler will simply print the error string using g_print. */ void -gst_element_default_error (GObject *object, GstObject *source, GError *error, gchar *debug) +gst_element_default_error (GObject * object, GstObject * source, GError * error, + gchar * debug) { gchar *name = gst_object_get_path_string (source); @@ -246,13 +256,15 @@ gst_element_default_error (GObject *object, GstObject *source, GError *error, gc g_free (name); } -typedef struct { +typedef struct +{ const GParamSpec *pspec; GValue value; } prop_value_t; static void -element_set_property (GstElement *element, const GParamSpec *pspec, const GValue *value) +element_set_property (GstElement * element, const GParamSpec * pspec, + const GValue * value) { prop_value_t *prop_value = g_new0 (prop_value_t, 1); @@ -263,15 +275,16 @@ element_set_property (GstElement *element, const GParamSpec *pspec, const GValue } static void -element_get_property (GstElement *element, const GParamSpec *pspec, GValue *value) +element_get_property (GstElement * element, const GParamSpec * pspec, + GValue * value) { g_mutex_lock (element->property_mutex); - g_object_get_property ((GObject*)element, pspec->name, value); + g_object_get_property ((GObject *) element, pspec->name, value); g_mutex_unlock (element->property_mutex); } static void -gst_element_threadsafe_properties_pre_run (GstElement *element) +gst_element_threadsafe_properties_pre_run (GstElement * element) { GST_DEBUG ("locking element %s", GST_OBJECT_NAME (element)); g_mutex_lock (element->property_mutex); @@ -279,7 +292,7 @@ gst_element_threadsafe_properties_pre_run (GstElement *element) } static void -gst_element_threadsafe_properties_post_run (GstElement *element) +gst_element_threadsafe_properties_post_run (GstElement * element) { GST_DEBUG ("unlocking element %s", GST_OBJECT_NAME (element)); g_mutex_unlock (element->property_mutex); @@ -294,10 +307,10 @@ gst_element_threadsafe_properties_post_run (GstElement *element) * threadsafe way. */ void -gst_element_enable_threadsafe_properties (GstElement *element) +gst_element_enable_threadsafe_properties (GstElement * element) { g_return_if_fail (GST_IS_ELEMENT (element)); - + GST_FLAG_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES); element->pre_run_func = gst_element_threadsafe_properties_pre_run; element->post_run_func = gst_element_threadsafe_properties_post_run; @@ -315,10 +328,10 @@ gst_element_enable_threadsafe_properties (GstElement *element) * this element. */ void -gst_element_disable_threadsafe_properties (GstElement *element) +gst_element_disable_threadsafe_properties (GstElement * element) { g_return_if_fail (GST_IS_ELEMENT (element)); - + GST_FLAG_UNSET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES); element->pre_run_func = NULL; element->post_run_func = NULL; @@ -333,12 +346,13 @@ gst_element_disable_threadsafe_properties (GstElement *element) * element. */ void -gst_element_set_pending_properties (GstElement *element) +gst_element_set_pending_properties (GstElement * element) { prop_value_t *prop_value; while ((prop_value = g_async_queue_try_pop (element->prop_value_queue))) { - g_object_set_property ((GObject*)element, prop_value->pspec->name, &prop_value->value); + g_object_set_property ((GObject *) element, prop_value->pspec->name, + &prop_value->value); g_value_unset (&prop_value->value); g_free (prop_value); } @@ -357,12 +371,12 @@ gst_element_set_pending_properties (GstElement *element) * they will be queued and set on the object when it is scheduled again. */ void -gst_element_set (GstElement *element, const gchar *first_property_name, ...) +gst_element_set (GstElement * element, const gchar * first_property_name, ...) { va_list var_args; - + g_return_if_fail (GST_IS_ELEMENT (element)); - + va_start (var_args, first_property_name); gst_element_set_valist (element, first_property_name, var_args); va_end (var_args); @@ -379,12 +393,12 @@ gst_element_set (GstElement *element, const gchar *first_property_name, ...) * the element will be locked before getting the given properties. */ void -gst_element_get (GstElement *element, const gchar *first_property_name, ...) +gst_element_get (GstElement * element, const gchar * first_property_name, ...) { va_list var_args; - + g_return_if_fail (GST_IS_ELEMENT (element)); - + va_start (var_args, first_property_name); gst_element_get_valist (element, first_property_name, var_args); va_end (var_args); @@ -400,18 +414,19 @@ gst_element_get (GstElement *element, const gchar *first_property_name, ...) * the property change will be put on the async queue. */ void -gst_element_set_valist (GstElement *element, const gchar *first_property_name, va_list var_args) +gst_element_set_valist (GstElement * element, const gchar * first_property_name, + va_list var_args) { const gchar *name; GObject *object; - + g_return_if_fail (GST_IS_ELEMENT (element)); - + object = (GObject *) element; - GST_CAT_DEBUG (GST_CAT_PROPERTIES, - "setting valist of properties starting with %s on element %s", - first_property_name, gst_element_get_name (element)); + GST_CAT_DEBUG (GST_CAT_PROPERTIES, + "setting valist of properties starting with %s on element %s", + first_property_name, gst_element_get_name (element)); if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) { g_object_set_valist (object, first_property_name, var_args); @@ -419,54 +434,46 @@ gst_element_set_valist (GstElement *element, const gchar *first_property_name, v } g_object_ref (object); - + name = first_property_name; - while (name) - { - GValue value = { 0, }; - GParamSpec *pspec; - gchar *error = NULL; - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); - - if (!pspec) - { - g_warning ("%s: object class `%s' has no property named `%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (object), - name); - break; - } - if (!(pspec->flags & G_PARAM_WRITABLE)) - { - g_warning ("%s: property `%s' of object class `%s' is not writable", - G_STRLOC, - pspec->name, - G_OBJECT_TYPE_NAME (object)); - break; - } - - g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - - G_VALUE_COLLECT (&value, var_args, 0, &error); - if (error) - { - g_warning ("%s: %s", G_STRLOC, error); - g_free (error); - - /* we purposely leak the value here, it might not be - * in a sane state if an error condition occoured - */ - break; - } - - element_set_property (element, pspec, &value); - g_value_unset (&value); - - name = va_arg (var_args, gchar*); + while (name) { + GValue value = { 0, }; + GParamSpec *pspec; + gchar *error = NULL; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); + + if (!pspec) { + g_warning ("%s: object class `%s' has no property named `%s'", + G_STRLOC, G_OBJECT_TYPE_NAME (object), name); + break; + } + if (!(pspec->flags & G_PARAM_WRITABLE)) { + g_warning ("%s: property `%s' of object class `%s' is not writable", + G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object)); + break; } + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + + G_VALUE_COLLECT (&value, var_args, 0, &error); + if (error) { + g_warning ("%s: %s", G_STRLOC, error); + g_free (error); + + /* we purposely leak the value here, it might not be + * in a sane state if an error condition occoured + */ + break; + } + + element_set_property (element, pspec, &value); + g_value_unset (&value); + + name = va_arg (var_args, gchar *); + } + g_object_unref (object); } @@ -480,14 +487,15 @@ gst_element_set_valist (GstElement *element, const gchar *first_property_name, v * the element will be locked before getting the given properties. */ void -gst_element_get_valist (GstElement *element, const gchar *first_property_name, va_list var_args) +gst_element_get_valist (GstElement * element, const gchar * first_property_name, + va_list var_args) { const gchar *name; GObject *object; - + g_return_if_fail (GST_IS_ELEMENT (element)); - - object = (GObject*)element; + + object = (GObject *) element; if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) { g_object_get_valist (object, first_property_name, var_args); @@ -495,52 +503,44 @@ gst_element_get_valist (GstElement *element, const gchar *first_property_name, v } g_object_ref (object); - + name = first_property_name; - - while (name) - { - GValue value = { 0, }; - GParamSpec *pspec; - gchar *error; - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); - - if (!pspec) - { - g_warning ("%s: object class `%s' has no property named `%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (object), - name); - break; - } - if (!(pspec->flags & G_PARAM_READABLE)) - { - g_warning ("%s: property `%s' of object class `%s' is not readable", - G_STRLOC, - pspec->name, - G_OBJECT_TYPE_NAME (object)); - break; - } - - g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - - element_get_property (element, pspec, &value); - - G_VALUE_LCOPY (&value, var_args, 0, &error); - if (error) - { - g_warning ("%s: %s", G_STRLOC, error); - g_free (error); - g_value_unset (&value); - break; - } - + + while (name) { + GValue value = { 0, }; + GParamSpec *pspec; + gchar *error; + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); + + if (!pspec) { + g_warning ("%s: object class `%s' has no property named `%s'", + G_STRLOC, G_OBJECT_TYPE_NAME (object), name); + break; + } + if (!(pspec->flags & G_PARAM_READABLE)) { + g_warning ("%s: property `%s' of object class `%s' is not readable", + G_STRLOC, pspec->name, G_OBJECT_TYPE_NAME (object)); + break; + } + + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + + element_get_property (element, pspec, &value); + + G_VALUE_LCOPY (&value, var_args, 0, &error); + if (error) { + g_warning ("%s: %s", G_STRLOC, error); + g_free (error); g_value_unset (&value); - - name = va_arg (var_args, gchar*); + break; } - + + g_value_unset (&value); + + name = va_arg (var_args, gchar *); + } + g_object_unref (object); } @@ -554,41 +554,39 @@ gst_element_get_valist (GstElement *element, const gchar *first_property_name, v * the property will be put on the async queue. */ void -gst_element_set_property (GstElement *element, const gchar *property_name, - const GValue *value) +gst_element_set_property (GstElement * element, const gchar * property_name, + const GValue * value) { GParamSpec *pspec; GObject *object; - + g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (property_name != NULL); g_return_if_fail (G_IS_VALUE (value)); - - object = (GObject*) element; + + object = (GObject *) element; GST_CAT_DEBUG (GST_CAT_PROPERTIES, "setting property %s on element %s", - property_name, gst_element_get_name (element)); + property_name, gst_element_get_name (element)); if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) { g_object_set_property (object, property_name, value); return; } g_object_ref (object); - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), - property_name); - + + pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), + property_name); + if (!pspec) g_warning ("%s: object class `%s' has no property named `%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (object), - property_name); + G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name); else element_set_property (element, pspec, value); - + g_object_unref (object); } - + /** * gst_element_get_property: * @element: a #GstElement to get properties of. @@ -599,16 +597,17 @@ gst_element_set_property (GstElement *element, const gchar *property_name, * the element will be locked before getting the given property. */ void -gst_element_get_property (GstElement *element, const gchar *property_name, GValue *value) +gst_element_get_property (GstElement * element, const gchar * property_name, + GValue * value) { GParamSpec *pspec; GObject *object; - + g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (property_name != NULL); g_return_if_fail (G_IS_VALUE (value)); - - object = (GObject*)element; + + object = (GObject *) element; if (!GST_FLAG_IS_SET (element, GST_ELEMENT_USE_THREADSAFE_PROPERTIES)) { g_object_get_property (object, property_name, value); @@ -616,52 +615,46 @@ gst_element_get_property (GstElement *element, const gchar *property_name, GValu } g_object_ref (object); - - pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), property_name); - + + pspec = + g_object_class_find_property (G_OBJECT_GET_CLASS (object), property_name); + if (!pspec) g_warning ("%s: object class `%s' has no property named `%s'", - G_STRLOC, - G_OBJECT_TYPE_NAME (object), - property_name); - else - { - GValue *prop_value, tmp_value = { 0, }; - - /* auto-conversion of the callers value type - */ - if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec)) - { - g_value_reset (value); - prop_value = value; - } - else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), G_VALUE_TYPE (value))) - { - g_warning ("can't retrieve property `%s' of type `%s' as value of type `%s'", - pspec->name, - g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), - G_VALUE_TYPE_NAME (value)); - g_object_unref (object); - return; - } - else - { - g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); - prop_value = &tmp_value; - } - element_get_property (element, pspec, prop_value); - if (prop_value != value) - { - g_value_transform (prop_value, value); - g_value_unset (&tmp_value); - } + G_STRLOC, G_OBJECT_TYPE_NAME (object), property_name); + else { + GValue *prop_value, tmp_value = { 0, }; + + /* auto-conversion of the callers value type + */ + if (G_VALUE_TYPE (value) == G_PARAM_SPEC_VALUE_TYPE (pspec)) { + g_value_reset (value); + prop_value = value; + } else if (!g_value_type_transformable (G_PARAM_SPEC_VALUE_TYPE (pspec), + G_VALUE_TYPE (value))) { + g_warning + ("can't retrieve property `%s' of type `%s' as value of type `%s'", + pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)), + G_VALUE_TYPE_NAME (value)); + g_object_unref (object); + return; + } else { + g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + prop_value = &tmp_value; + } + element_get_property (element, pspec, prop_value); + if (prop_value != value) { + g_value_transform (prop_value, value); + g_value_unset (&tmp_value); } - + } + g_object_unref (object); } -static GstPad* -gst_element_request_pad (GstElement *element, GstPadTemplate *templ, const gchar* name) +static GstPad * +gst_element_request_pad (GstElement * element, GstPadTemplate * templ, + const gchar * name) { GstPad *newpad = NULL; GstElementClass *oclass; @@ -669,7 +662,7 @@ gst_element_request_pad (GstElement *element, GstPadTemplate *templ, const gchar oclass = GST_ELEMENT_GET_CLASS (element); if (oclass->request_new_pad) - newpad = (oclass->request_new_pad)(element, templ, name); + newpad = (oclass->request_new_pad) (element, templ, name); return newpad; } @@ -683,7 +676,7 @@ gst_element_request_pad (GstElement *element, GstPadTemplate *templ, const gchar * with gst_element_get_request_pad(). */ void -gst_element_release_request_pad (GstElement *element, GstPad *pad) +gst_element_release_request_pad (GstElement * element, GstPad * pad) { GstElementClass *oclass; @@ -705,7 +698,7 @@ gst_element_release_request_pad (GstElement *element, GstPad *pad) * Returns: TRUE if the element requires a clock */ gboolean -gst_element_requires_clock (GstElement *element) +gst_element_requires_clock (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); @@ -721,7 +714,7 @@ gst_element_requires_clock (GstElement *element) * Returns: TRUE if the element provides a clock */ gboolean -gst_element_provides_clock (GstElement *element) +gst_element_provides_clock (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); @@ -736,7 +729,7 @@ gst_element_provides_clock (GstElement *element) * Sets the clock for the element. */ void -gst_element_set_clock (GstElement *element, GstClock *clock) +gst_element_set_clock (GstElement * element, GstClock * clock) { GstElementClass *oclass; @@ -747,7 +740,7 @@ gst_element_set_clock (GstElement *element, GstClock *clock) if (oclass->set_clock) oclass->set_clock (element, clock); - gst_object_replace ((GstObject **)&element->clock, (GstObject *)clock); + gst_object_replace ((GstObject **) & element->clock, (GstObject *) clock); } /** @@ -758,15 +751,15 @@ gst_element_set_clock (GstElement *element, GstClock *clock) * * Returns: the #GstClock of the element. */ -GstClock* -gst_element_get_clock (GstElement *element) +GstClock * +gst_element_get_clock (GstElement * element) { GstElementClass *oclass; g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); oclass = GST_ELEMENT_GET_CLASS (element); - + if (oclass->get_clock) return oclass->get_clock (element); @@ -784,7 +777,8 @@ gst_element_get_clock (GstElement *element) * Returns: the #GstClockReturn result of the wait operation. */ GstClockReturn -gst_element_clock_wait (GstElement *element, GstClockID id, GstClockTimeDiff *jitter) +gst_element_clock_wait (GstElement * element, GstClockID id, + GstClockTimeDiff * jitter) { GstClockReturn res; @@ -792,15 +786,17 @@ gst_element_clock_wait (GstElement *element, GstClockID id, GstClockTimeDiff *ji if (GST_ELEMENT_SCHED (element)) { GST_CAT_DEBUG (GST_CAT_CLOCK, "waiting on scheduler clock"); - res = gst_scheduler_clock_wait (GST_ELEMENT_SCHED (element), element, id, jitter); - } - else { + res = + gst_scheduler_clock_wait (GST_ELEMENT_SCHED (element), element, id, + jitter); + } else { GST_CAT_DEBUG (GST_CAT_CLOCK, "no scheduler, returning GST_CLOCK_TIMEOUT"); res = GST_CLOCK_TIMEOUT; } return res; } + #undef GST_CAT_DEFAULT #define GST_CAT_DEFAULT GST_CAT_CLOCK /** @@ -813,7 +809,7 @@ gst_element_clock_wait (GstElement *element, GstClockID id, GstClockTimeDiff *ji * is no time available. */ GstClockTime -gst_element_get_time (GstElement *element) +gst_element_get_time (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), GST_CLOCK_TIME_NONE); @@ -832,7 +828,7 @@ gst_element_get_time (GstElement *element) default: g_assert_not_reached (); return GST_CLOCK_TIME_NONE; - } + } } /** @@ -847,23 +843,24 @@ gst_element_get_time (GstElement *element) * Returns: TRUE on success */ gboolean -gst_element_wait (GstElement *element, GstClockTime timestamp) +gst_element_wait (GstElement * element, GstClockTime timestamp) { GstClockID id; GstClockReturn ret; - + g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (GST_IS_CLOCK (element->clock), FALSE); g_return_val_if_fail (element->current_state == GST_STATE_PLAYING, FALSE); g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); - + /* shortcut when we're already late... */ if (gst_element_get_time (element) >= timestamp) { GST_INFO_OBJECT (element, "called gst_element_wait and was late"); return TRUE; } - - id = gst_clock_new_single_shot_id (element->clock, element->base_time + timestamp); + + id = gst_clock_new_single_shot_id (element->clock, + element->base_time + timestamp); ret = gst_element_clock_wait (element, id, NULL); gst_clock_id_free (id); @@ -882,10 +879,10 @@ gst_element_wait (GstElement *element, GstClockTime timestamp) * more accurate. */ void -gst_element_set_time (GstElement *element, GstClockTime time) +gst_element_set_time (GstElement * element, GstClockTime time) { GstClockTime event_time; - + g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_CLOCK (element->clock)); g_return_if_fail (element->current_state >= GST_STATE_PAUSED); @@ -896,7 +893,7 @@ gst_element_set_time (GstElement *element, GstClockTime time) break; case GST_STATE_PLAYING: event_time = gst_clock_get_event_time (element->clock); - GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, + GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "clock time %llu: setting element time to %llu", event_time, time); element->base_time = event_time - time; break; @@ -917,10 +914,10 @@ gst_element_set_time (GstElement *element, GstClockTime time) * #GST_STATE_PLAYING. It is more accurate than gst_element_set_time(). */ void -gst_element_adjust_time (GstElement *element, GstClockTimeDiff diff) +gst_element_adjust_time (GstElement * element, GstClockTimeDiff diff) { GstClockTime time; - + g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_CLOCK (element->clock)); g_return_if_fail (element->current_state >= GST_STATE_PAUSED); @@ -963,7 +960,7 @@ gst_element_adjust_time (GstElement *element, GstClockTimeDiff diff) * Returns: TRUE if the element can be indexed. */ gboolean -gst_element_is_indexable (GstElement *element) +gst_element_is_indexable (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); @@ -978,7 +975,7 @@ gst_element_is_indexable (GstElement *element) * Set the specified GstIndex on the element. */ void -gst_element_set_index (GstElement *element, GstIndex *index) +gst_element_set_index (GstElement * element, GstIndex * index) { GstElementClass *oclass; @@ -1000,8 +997,8 @@ gst_element_set_index (GstElement *element, GstIndex *index) * Returns: a #GstIndex or NULL when no index was set on the * element. */ -GstIndex* -gst_element_get_index (GstElement *element) +GstIndex * +gst_element_get_index (GstElement * element) { GstElementClass *oclass; @@ -1026,7 +1023,7 @@ gst_element_get_index (GstElement *element) * Returns: TRUE if the locks could be released. */ gboolean -gst_element_release_locks (GstElement *element) +gst_element_release_locks (GstElement * element) { GstElementClass *oclass; @@ -1036,7 +1033,7 @@ gst_element_release_locks (GstElement *element) if (oclass->release_locks) return oclass->release_locks (element); - + return TRUE; } @@ -1051,7 +1048,7 @@ gst_element_release_locks (GstElement *element) * Pads are automatically activated when the element is in state PLAYING. */ void -gst_element_add_pad (GstElement *element, GstPad *pad) +gst_element_add_pad (GstElement * element, GstPad * pad) { g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_PAD (pad)); @@ -1061,10 +1058,11 @@ gst_element_add_pad (GstElement *element, GstPad *pad) g_return_if_fail (GST_PAD_PARENT (pad) == NULL); /* then check to see if there's already a pad by that name here */ - g_return_if_fail (gst_object_check_uniqueness (element->pads, GST_PAD_NAME(pad)) == TRUE); + g_return_if_fail (gst_object_check_uniqueness (element->pads, + GST_PAD_NAME (pad)) == TRUE); GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element, "adding pad '%s'", - GST_STR_NULL (GST_OBJECT_NAME (pad))); + GST_STR_NULL (GST_OBJECT_NAME (pad))); /* set the pad's parent */ gst_object_set_parent (GST_OBJECT (pad), GST_OBJECT (element)); @@ -1074,21 +1072,21 @@ gst_element_add_pad (GstElement *element, GstPad *pad) element->numpads++; switch (gst_pad_get_direction (pad)) { - case GST_PAD_SRC: - element->numsrcpads++; - break; - case GST_PAD_SINK: - element->numsinkpads++; - break; - default: - /* can happen for ghost pads */ - break; + case GST_PAD_SRC: + element->numsrcpads++; + break; + case GST_PAD_SINK: + element->numsinkpads++; + break; + default: + /* can happen for ghost pads */ + break; } /* activate element when we are playing */ if (GST_STATE (element) == GST_STATE_PLAYING) gst_pad_set_active (pad, TRUE); - + /* emit the NEW_PAD signal */ g_signal_emit (G_OBJECT (element), gst_element_signals[NEW_PAD], 0, pad); } @@ -1106,7 +1104,8 @@ gst_element_add_pad (GstElement *element, GstPad *pad) * Returns: the added ghost #GstPad, or NULL on error. */ GstPad * -gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name) +gst_element_add_ghost_pad (GstElement * element, GstPad * pad, + const gchar * name) { GstPad *ghostpad; @@ -1114,12 +1113,13 @@ gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name) g_return_val_if_fail (GST_IS_PAD (pad), NULL); /* then check to see if there's already a pad by that name here */ - g_return_val_if_fail (gst_object_check_uniqueness (element->pads, name) == TRUE, NULL); + g_return_val_if_fail (gst_object_check_uniqueness (element->pads, + name) == TRUE, NULL); ghostpad = gst_ghost_pad_new (name, pad); gst_element_add_pad (element, ghostpad); - + return ghostpad; } @@ -1132,7 +1132,7 @@ gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name) * referenced elsewhere. */ void -gst_element_remove_pad (GstElement *element, GstPad *pad) +gst_element_remove_pad (GstElement * element, GstPad * pad) { g_return_if_fail (element != NULL); g_return_if_fail (GST_IS_ELEMENT (element)); @@ -1150,20 +1150,20 @@ gst_element_remove_pad (GstElement *element, GstPad *pad) } else if (GST_IS_GHOST_PAD (pad)) { g_object_set (pad, "real-pad", NULL, NULL); } - + /* remove it from the list */ element->pads = g_list_remove (element->pads, pad); element->numpads--; switch (gst_pad_get_direction (pad)) { - case GST_PAD_SRC: - element->numsrcpads--; - break; - case GST_PAD_SINK: - element->numsinkpads--; - break; - default: - /* can happen for ghost pads */ - break; + case GST_PAD_SRC: + element->numsrcpads--; + break; + case GST_PAD_SINK: + element->numsinkpads--; + break; + default: + /* can happen for ghost pads */ + break; } g_signal_emit (G_OBJECT (element), gst_element_signals[PAD_REMOVED], 0, pad); @@ -1180,13 +1180,13 @@ gst_element_remove_pad (GstElement *element, GstPad *pad) * instead. */ void -gst_element_remove_ghost_pad (GstElement *element, GstPad *pad) +gst_element_remove_ghost_pad (GstElement * element, GstPad * pad) { g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_GHOST_PAD (pad)); g_warning ("gst_element_remove_ghost_pad is deprecated.\n" - "Use gst_element_remove_pad instead."); + "Use gst_element_remove_pad instead."); gst_element_remove_pad (element, pad); } @@ -1202,8 +1202,8 @@ gst_element_remove_ghost_pad (GstElement *element, GstPad *pad) * * Returns: the #GstPad if found, otherwise %NULL. */ -GstPad* -gst_element_get_pad (GstElement *element, const gchar *name) +GstPad * +gst_element_get_pad (GstElement * element, const gchar * name) { GstPad *pad; @@ -1212,7 +1212,7 @@ gst_element_get_pad (GstElement *element, const gchar *name) g_return_val_if_fail (name != NULL, NULL); pad = gst_element_get_static_pad (element, name); - if (!pad) + if (!pad) pad = gst_element_get_request_pad (element, name); return pad; @@ -1229,10 +1229,10 @@ gst_element_get_pad (GstElement *element, const gchar *name) * Returns: the requested #GstPad if found, otherwise NULL. */ GstPad * -gst_element_get_static_pad (GstElement *element, const gchar *name) +gst_element_get_static_pad (GstElement * element, const gchar * name) { GList *walk; - + g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); g_return_val_if_fail (name != NULL, NULL); @@ -1240,16 +1240,18 @@ gst_element_get_static_pad (GstElement *element, const gchar *name) walk = element->pads; while (walk) { GstPad *pad; - - pad = GST_PAD(walk->data); - if (strcmp (GST_PAD_NAME(pad), name) == 0) { - GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "found pad %s:%s", GST_DEBUG_PAD_NAME (pad)); + + pad = GST_PAD (walk->data); + if (strcmp (GST_PAD_NAME (pad), name) == 0) { + GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "found pad %s:%s", + GST_DEBUG_PAD_NAME (pad)); return pad; } walk = g_list_next (walk); } - GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "no such pad '%s' in element \"%s\"", name, GST_OBJECT_NAME (element)); + GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "no such pad '%s' in element \"%s\"", + name, GST_OBJECT_NAME (element)); return NULL; } @@ -1263,8 +1265,8 @@ gst_element_get_static_pad (GstElement *element, const gchar *name) * * Returns: requested #GstPad if found, otherwise NULL. */ -GstPad* -gst_element_get_request_pad (GstElement *element, const gchar *name) +GstPad * +gst_element_get_request_pad (GstElement * element, const gchar * name) { GstPadTemplate *templ = NULL; GstPad *pad; @@ -1285,43 +1287,45 @@ gst_element_get_request_pad (GstElement *element, const gchar *name) if (templ) templ_found = TRUE; } else { - list = gst_element_get_pad_template_list(element); + list = gst_element_get_pad_template_list (element); while (!templ_found && list) { - templ = (GstPadTemplate*) list->data; + templ = (GstPadTemplate *) list->data; if (templ->presence == GST_PAD_REQUEST) { - /* Because of sanity checks in gst_pad_template_new(), we know that %s - and %d, occurring at the end of the name_template, are the only - possibilities. */ - GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name, templ->name_template); - if ((str = strchr (templ->name_template, '%')) && - strncmp (templ->name_template, name, str - templ->name_template) == 0 && - strlen (name) > str - templ->name_template) { - data = name + (str - templ->name_template); - if (*(str+1) == 'd') { - /* it's an int */ - n = (gint) strtol (data, &endptr, 10); - if (endptr && *endptr == '\0') { - templ_found = TRUE; - req_name = name; - break; - } - } else { - /* it's a string */ - templ_found = TRUE; - req_name = name; - break; - } - } + /* Because of sanity checks in gst_pad_template_new(), we know that %s + and %d, occurring at the end of the name_template, are the only + possibilities. */ + GST_CAT_DEBUG (GST_CAT_PADS, "comparing %s to %s", name, + templ->name_template); + if ((str = strchr (templ->name_template, '%')) + && strncmp (templ->name_template, name, + str - templ->name_template) == 0 + && strlen (name) > str - templ->name_template) { + data = name + (str - templ->name_template); + if (*(str + 1) == 'd') { + /* it's an int */ + n = (gint) strtol (data, &endptr, 10); + if (endptr && *endptr == '\0') { + templ_found = TRUE; + req_name = name; + break; + } + } else { + /* it's a string */ + templ_found = TRUE; + req_name = name; + break; + } + } } list = list->next; } } - + if (!templ_found) - return NULL; - + return NULL; + pad = gst_element_request_pad (element, templ, req_name); - + return pad; } @@ -1334,8 +1338,8 @@ gst_element_get_request_pad (GstElement *element, const gchar *name) * * Returns: the #GList of pads. */ -const GList* -gst_element_get_pad_list (GstElement *element) +const GList * +gst_element_get_pad_list (GstElement * element) { g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); @@ -1353,17 +1357,18 @@ gst_element_get_pad_list (GstElement *element) * functions of classes. */ void -gst_element_class_add_pad_template (GstElementClass *klass, - GstPadTemplate *templ) +gst_element_class_add_pad_template (GstElementClass * klass, + GstPadTemplate * templ) { g_return_if_fail (GST_IS_ELEMENT_CLASS (klass)); g_return_if_fail (GST_IS_PAD_TEMPLATE (templ)); /* avoid registering pad templates with the same name */ - g_return_if_fail (gst_element_class_get_pad_template (klass, templ->name_template) == NULL); - + g_return_if_fail (gst_element_class_get_pad_template (klass, + templ->name_template) == NULL); + klass->padtemplates = g_list_append (klass->padtemplates, - gst_object_ref (GST_OBJECT (templ))); + gst_object_ref (GST_OBJECT (templ))); klass->numpadtemplates++; } @@ -1375,12 +1380,13 @@ gst_element_class_add_pad_template (GstElementClass *klass, * Sets the detailed information for a #GstElementClass. * This function is for use in _base_init functions only. */ -void -gst_element_class_set_details (GstElementClass *klass, const GstElementDetails *details) +void +gst_element_class_set_details (GstElementClass * klass, + const GstElementDetails * details) { g_return_if_fail (GST_IS_ELEMENT_CLASS (klass)); g_return_if_fail (GST_IS_ELEMENT_DETAILS (details)); - + __gst_element_details_copy (&klass->details, details); } @@ -1393,8 +1399,8 @@ gst_element_class_set_details (GstElementClass *klass, const GstElementDetails * * * Returns: the #GList of padtemplates. */ -GList* -gst_element_class_get_pad_template_list (GstElementClass *element_class) +GList * +gst_element_class_get_pad_template_list (GstElementClass * element_class) { g_return_val_if_fail (element_class != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT_CLASS (element_class), NULL); @@ -1412,8 +1418,9 @@ gst_element_class_get_pad_template_list (GstElementClass *element_class) * Returns: the #GstPadTemplate with the given name, or NULL if none was found. * No unreferencing is necessary. */ -GstPadTemplate* -gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name) +GstPadTemplate * +gst_element_class_get_pad_template (GstElementClass * element_class, + const gchar * name) { GList *padlist; @@ -1424,7 +1431,7 @@ gst_element_class_get_pad_template (GstElementClass *element_class, const gchar padlist = gst_element_class_get_pad_template_list (element_class); while (padlist) { - GstPadTemplate *padtempl = (GstPadTemplate*) padlist->data; + GstPadTemplate *padtempl = (GstPadTemplate *) padlist->data; if (strcmp (padtempl->name_template, name) == 0) return padtempl; @@ -1444,8 +1451,8 @@ gst_element_class_get_pad_template (GstElementClass *element_class, const gchar * * Returns: the #GList of padtemplates. */ -GList* -gst_element_get_pad_template_list (GstElement *element) +GList * +gst_element_get_pad_template_list (GstElement * element) { g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); @@ -1465,15 +1472,15 @@ gst_element_get_pad_template_list (GstElement *element) * Returns: the #GstPadTemplate with the given name, or NULL if none was found. * No unreferencing is necessary. */ -GstPadTemplate* -gst_element_get_pad_template (GstElement *element, const gchar *name) +GstPadTemplate * +gst_element_get_pad_template (GstElement * element, const gchar * name) { g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); g_return_val_if_fail (name != NULL, NULL); return gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element), - name); + name); } /** @@ -1487,9 +1494,9 @@ gst_element_get_pad_template (GstElement *element, const gchar *name) * Returns: a compatible #GstPadTemplate, or NULL if none was found. No * unreferencing is necessary. */ -GstPadTemplate* -gst_element_get_compatible_pad_template (GstElement *element, - GstPadTemplate *compattempl) +GstPadTemplate * +gst_element_get_compatible_pad_template (GstElement * element, + GstPadTemplate * compattempl) { GstPadTemplate *newtempl = NULL; GList *padlist; @@ -1500,10 +1507,11 @@ gst_element_get_compatible_pad_template (GstElement *element, padlist = gst_element_get_pad_template_list (element); - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "Looking for a suitable pad template..."); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, + "Looking for a suitable pad template..."); while (padlist) { - GstPadTemplate *padtempl = (GstPadTemplate*) padlist->data; + GstPadTemplate *padtempl = (GstPadTemplate *) padlist->data; GstCaps *intersection; /* Ignore name @@ -1512,19 +1520,22 @@ gst_element_get_compatible_pad_template (GstElement *element, * Check caps */ if (padtempl->direction != compattempl->direction) { - GST_CAT_DEBUG (GST_CAT_CAPS, "compatible direction: found %s pad template \"%s\"", - padtempl->direction == GST_PAD_SRC ? "src" : "sink", - padtempl->name_template); + GST_CAT_DEBUG (GST_CAT_CAPS, + "compatible direction: found %s pad template \"%s\"", + padtempl->direction == GST_PAD_SRC ? "src" : "sink", + padtempl->name_template); intersection = gst_caps_intersect (GST_PAD_TEMPLATE_CAPS (compattempl), - GST_PAD_TEMPLATE_CAPS (padtempl)); + GST_PAD_TEMPLATE_CAPS (padtempl)); - GST_CAT_DEBUG (GST_CAT_CAPS, "caps are %scompatible", (intersection ? "" : "not ")); + GST_CAT_DEBUG (GST_CAT_CAPS, "caps are %scompatible", + (intersection ? "" : "not ")); if (!gst_caps_is_empty (intersection)) - newtempl = padtempl; + newtempl = padtempl; gst_caps_free (intersection); - if (newtempl) break; + if (newtempl) + break; } padlist = g_list_next (padlist); @@ -1544,32 +1555,33 @@ gst_element_get_compatible_pad_template (GstElement *element, * * Returns: the #GstPad, or NULL if one could not be found or created. */ -static GstPad* -gst_element_get_pad_from_template (GstElement *element, GstPadTemplate *templ) +static GstPad * +gst_element_get_pad_from_template (GstElement * element, GstPadTemplate * templ) { GstPad *ret = NULL; GstPadPresence presence; - + /* If this function is ever exported, we need check the validity of `element' * and `templ', and to make sure the template actually belongs to the * element. */ presence = GST_PAD_TEMPLATE_PRESENCE (templ); - + switch (presence) { - case GST_PAD_ALWAYS: - case GST_PAD_SOMETIMES: - ret = gst_element_get_static_pad (element, templ->name_template); - if (!ret && presence == GST_PAD_ALWAYS) - g_warning ("Element %s has an ALWAYS template %s, but no pad of the same name", - GST_OBJECT_NAME (element), templ->name_template); - break; - - case GST_PAD_REQUEST: - ret = gst_element_request_pad (element, templ, NULL); - break; - } - + case GST_PAD_ALWAYS: + case GST_PAD_SOMETIMES: + ret = gst_element_get_static_pad (element, templ->name_template); + if (!ret && presence == GST_PAD_ALWAYS) + g_warning + ("Element %s has an ALWAYS template %s, but no pad of the same name", + GST_OBJECT_NAME (element), templ->name_template); + break; + + case GST_PAD_REQUEST: + ret = gst_element_request_pad (element, templ, NULL); + break; + } + return ret; } @@ -1583,8 +1595,9 @@ gst_element_get_pad_from_template (GstElement *element, GstPadTemplate *templ) * * Returns: a #GstPad, or %NULL if one could not be found or created. */ -GstPad* -gst_element_request_compatible_pad (GstElement *element, GstPadTemplate *templ) +GstPad * +gst_element_request_compatible_pad (GstElement * element, + GstPadTemplate * templ) { GstPadTemplate *templ_new; GstPad *pad = NULL; @@ -1618,9 +1631,9 @@ gst_element_request_compatible_pad (GstElement *element, GstPadTemplate *templ) * Returns: the #GstPad to which a link can be made, or %NULL if one cannot be * found. */ -GstPad* -gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, - const GstCaps *filtercaps) +GstPad * +gst_element_get_compatible_pad_filtered (GstElement * element, GstPad * pad, + const GstCaps * filtercaps) { const GList *pads; GstPadTemplate *templ; @@ -1630,8 +1643,9 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); g_return_val_if_fail (GST_IS_PAD (pad), NULL); - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "finding pad in %s compatible with %s:%s", - GST_ELEMENT_NAME (element), GST_DEBUG_PAD_NAME (pad)); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, + "finding pad in %s compatible with %s:%s", GST_ELEMENT_NAME (element), + GST_DEBUG_PAD_NAME (pad)); /* let's use the real pad */ pad = (GstPad *) GST_PAD_REALIZE (pad); @@ -1642,8 +1656,9 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, pads = gst_element_get_pad_list (element); while (pads) { GstPad *current = GST_PAD (pads->data); + if (GST_PAD_PEER (current) == NULL && - gst_pad_can_link_filtered (pad, current, filtercaps)) { + gst_pad_can_link_filtered (pad, current, filtercaps)) { return current; } pads = g_list_next (pads); @@ -1654,6 +1669,7 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, templcaps = gst_pad_get_caps (pad); if (filtercaps != NULL) { GstCaps *temp; + temp = gst_caps_intersect (filtercaps, templcaps); gst_caps_free (templcaps); templcaps = temp; @@ -1664,11 +1680,12 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, foundpad = gst_element_request_compatible_pad (element, templ); gst_object_unref (GST_OBJECT (templ)); - if (foundpad) return foundpad; + if (foundpad) + return foundpad; GST_CAT_INFO_OBJECT (GST_CAT_ELEMENT_PADS, element, - "Could not find a compatible pad to link to %s:%s", - GST_DEBUG_PAD_NAME (pad)); + "Could not find a compatible pad to link to %s:%s", + GST_DEBUG_PAD_NAME (pad)); return NULL; } @@ -1685,8 +1702,8 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, * Returns: the #GstPad to which a link can be made, or %NULL if one * could not be found. */ -GstPad* -gst_element_get_compatible_pad (GstElement *element, GstPad *pad) +GstPad * +gst_element_get_compatible_pad (GstElement * element, GstPad * pad) { return gst_element_get_compatible_pad_filtered (element, pad, NULL); } @@ -1707,9 +1724,8 @@ gst_element_get_compatible_pad (GstElement *element, GstPad *pad) * Returns: TRUE if the pads could be linked, FALSE otherwise. */ gboolean -gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, - GstElement *dest, const gchar *destpadname, - const GstCaps *filtercaps) +gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname, + GstElement * dest, const gchar * destpadname, const GstCaps * filtercaps) { const GList *srcpads, *destpads, *srctempls, *desttempls, *l; GstPad *srcpad, *destpad; @@ -1719,26 +1735,30 @@ gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, g_return_val_if_fail (GST_IS_ELEMENT (src), FALSE); g_return_val_if_fail (GST_IS_ELEMENT (dest), FALSE); - GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "trying to link element %s:%s to element %s:%s", - GST_ELEMENT_NAME (src), srcpadname ? srcpadname : "(any)", - GST_ELEMENT_NAME (dest), destpadname ? destpadname : "(any)"); + GST_CAT_INFO (GST_CAT_ELEMENT_PADS, + "trying to link element %s:%s to element %s:%s", GST_ELEMENT_NAME (src), + srcpadname ? srcpadname : "(any)", GST_ELEMENT_NAME (dest), + destpadname ? destpadname : "(any)"); /* now get the pads we're trying to link and a list of all remaining pads */ if (srcpadname) { srcpad = gst_element_get_pad (src, srcpadname); if (!srcpad) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", GST_ELEMENT_NAME (src), srcpadname); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", + GST_ELEMENT_NAME (src), srcpadname); return FALSE; } else { if (!(GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC)) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad", GST_DEBUG_PAD_NAME (srcpad)); - return FALSE; + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no src pad", + GST_DEBUG_PAD_NAME (srcpad)); + return FALSE; } if (GST_PAD_PEER (srcpad) != NULL) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", GST_DEBUG_PAD_NAME (srcpad)); - return FALSE; + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", + GST_DEBUG_PAD_NAME (srcpad)); + return FALSE; } - } + } srcpads = NULL; } else { srcpads = gst_element_get_pad_list (src); @@ -1747,16 +1767,19 @@ gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, if (destpadname) { destpad = gst_element_get_pad (dest, destpadname); if (!destpad) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", GST_ELEMENT_NAME (dest), destpadname); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no pad %s:%s", + GST_ELEMENT_NAME (dest), destpadname); return FALSE; } else { if (!(GST_PAD_DIRECTION (destpad) == GST_PAD_SINK)) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad", GST_DEBUG_PAD_NAME (destpad)); - return FALSE; + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is no sink pad", + GST_DEBUG_PAD_NAME (destpad)); + return FALSE; } if (GST_PAD_PEER (destpad) != NULL) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", GST_DEBUG_PAD_NAME (destpad)); - return FALSE; + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is already linked", + GST_DEBUG_PAD_NAME (destpad)); + return FALSE; } } destpads = NULL; @@ -1772,101 +1795,103 @@ gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, if (srcpad) { /* loop through the allowed pads in the source, trying to find a * compatible destination pad */ - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "looping through allowed src and dest pads"); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, + "looping through allowed src and dest pads"); do { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s", - GST_DEBUG_PAD_NAME (srcpad)); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s", + GST_DEBUG_PAD_NAME (srcpad)); if ((GST_PAD_DIRECTION (srcpad) == GST_PAD_SRC) && - (GST_PAD_PEER (srcpad) == NULL)) { - GstPad *temp = gst_element_get_compatible_pad_filtered (dest, srcpad, - filtercaps); - if (temp && gst_pad_link_filtered (srcpad, temp, filtercaps)) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (temp)); - return TRUE; - } + (GST_PAD_PEER (srcpad) == NULL)) { + GstPad *temp = gst_element_get_compatible_pad_filtered (dest, srcpad, + filtercaps); + + if (temp && gst_pad_link_filtered (srcpad, temp, filtercaps)) { + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (temp)); + return TRUE; + } } /* find a better way for this mess */ if (srcpads) { srcpads = g_list_next (srcpads); - if (srcpads) + if (srcpads) srcpad = (GstPad *) GST_PAD_REALIZE (srcpads->data); } } while (srcpads); } if (srcpadname) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s", - GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest)); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s:%s to %s", + GST_DEBUG_PAD_NAME (srcpad), GST_ELEMENT_NAME (dest)); return FALSE; } - if (destpad) { + if (destpad) { /* loop through the existing pads in the destination */ do { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s", - GST_DEBUG_PAD_NAME (destpad)); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s", + GST_DEBUG_PAD_NAME (destpad)); if ((GST_PAD_DIRECTION (destpad) == GST_PAD_SINK) && - (GST_PAD_PEER (destpad) == NULL)) { - GstPad *temp = gst_element_get_compatible_pad_filtered (src, destpad, - filtercaps); - if (temp && gst_pad_link_filtered (temp, destpad, filtercaps)) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s", - GST_DEBUG_PAD_NAME (temp), GST_DEBUG_PAD_NAME (destpad)); - return TRUE; - } + (GST_PAD_PEER (destpad) == NULL)) { + GstPad *temp = gst_element_get_compatible_pad_filtered (src, destpad, + filtercaps); + + if (temp && gst_pad_link_filtered (temp, destpad, filtercaps)) { + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "linked pad %s:%s to pad %s:%s", + GST_DEBUG_PAD_NAME (temp), GST_DEBUG_PAD_NAME (destpad)); + return TRUE; + } } if (destpads) { destpads = g_list_next (destpads); - if (destpads) + if (destpads) destpad = (GstPad *) GST_PAD_REALIZE (destpads->data); } } while (destpads); } if (destpadname) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s", - GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad)); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s:%s", + GST_ELEMENT_NAME (src), GST_DEBUG_PAD_NAME (destpad)); return FALSE; } - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, - "we might have request pads on both sides, checking..."); + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, + "we might have request pads on both sides, checking..."); srctempls = gst_element_get_pad_template_list (src); desttempls = gst_element_get_pad_template_list (dest); - + if (srctempls && desttempls) { while (srctempls) { - srctempl = (GstPadTemplate*) srctempls->data; + srctempl = (GstPadTemplate *) srctempls->data; if (srctempl->presence == GST_PAD_REQUEST) { - for (l=desttempls; l; l=l->next) { - desttempl = (GstPadTemplate*) l->data; - if (desttempl->presence == GST_PAD_REQUEST && + for (l = desttempls; l; l = l->next) { + desttempl = (GstPadTemplate *) l->data; + if (desttempl->presence == GST_PAD_REQUEST && desttempl->direction != srctempl->direction) { - if (gst_caps_is_always_compatible (gst_pad_template_get_caps (srctempl), - gst_pad_template_get_caps (desttempl))) { - srcpad = gst_element_get_request_pad (src, - srctempl->name_template); - destpad = gst_element_get_request_pad (dest, - desttempl->name_template); - if (gst_pad_link_filtered (srcpad, destpad, filtercaps)) { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, - "linked pad %s:%s to pad %s:%s", - GST_DEBUG_PAD_NAME (srcpad), - GST_DEBUG_PAD_NAME (destpad)); - return TRUE; - } - /* it failed, so we release the request pads */ - gst_element_release_request_pad (src, srcpad); - gst_element_release_request_pad (dest, destpad); - } - } - } + if (gst_caps_is_always_compatible (gst_pad_template_get_caps + (srctempl), gst_pad_template_get_caps (desttempl))) { + srcpad = + gst_element_get_request_pad (src, srctempl->name_template); + destpad = + gst_element_get_request_pad (dest, desttempl->name_template); + if (gst_pad_link_filtered (srcpad, destpad, filtercaps)) { + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, + "linked pad %s:%s to pad %s:%s", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (destpad)); + return TRUE; + } + /* it failed, so we release the request pads */ + gst_element_release_request_pad (src, srcpad); + gst_element_release_request_pad (dest, destpad); + } + } + } } srctempls = srctempls->next; } } - - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s", - GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest)); - return FALSE; + + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "no link possible from %s to %s", + GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest)); + return FALSE; } /** @@ -1883,8 +1908,8 @@ gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, * Returns: TRUE if the elements could be linked, FALSE otherwise. */ gboolean -gst_element_link_filtered (GstElement *src, GstElement *dest, - const GstCaps *filtercaps) +gst_element_link_filtered (GstElement * src, GstElement * dest, + const GstCaps * filtercaps) { return gst_element_link_pads_filtered (src, NULL, dest, NULL, filtercaps); } @@ -1900,26 +1925,26 @@ gst_element_link_filtered (GstElement *src, GstElement *dest, * Returns: TRUE on success, FALSE otherwise. */ gboolean -gst_element_link_many (GstElement *element_1, GstElement *element_2, ...) +gst_element_link_many (GstElement * element_1, GstElement * element_2, ...) { va_list args; g_return_val_if_fail (element_1 != NULL && element_2 != NULL, FALSE); - g_return_val_if_fail (GST_IS_ELEMENT (element_1) && - GST_IS_ELEMENT (element_2), FALSE); + g_return_val_if_fail (GST_IS_ELEMENT (element_1) && + GST_IS_ELEMENT (element_2), FALSE); va_start (args, element_2); while (element_2) { if (!gst_element_link (element_1, element_2)) return FALSE; - + element_1 = element_2; - element_2 = va_arg (args, GstElement*); + element_2 = va_arg (args, GstElement *); } va_end (args); - + return TRUE; } @@ -1934,7 +1959,7 @@ gst_element_link_many (GstElement *element_1, GstElement *element_2, ...) * Returns: TRUE if the elements could be linked, FALSE otherwise. */ gboolean -gst_element_link (GstElement *src, GstElement *dest) +gst_element_link (GstElement * src, GstElement * dest) { return gst_element_link_pads_filtered (src, NULL, dest, NULL, NULL); } @@ -1954,10 +1979,11 @@ gst_element_link (GstElement *src, GstElement *dest) * Returns: TRUE if the pads could be linked, FALSE otherwise. */ gboolean -gst_element_link_pads (GstElement *src, const gchar *srcpadname, - GstElement *dest, const gchar *destpadname) +gst_element_link_pads (GstElement * src, const gchar * srcpadname, + GstElement * dest, const gchar * destpadname) { - return gst_element_link_pads_filtered (src, srcpadname, dest, destpadname, NULL); + return gst_element_link_pads_filtered (src, srcpadname, dest, destpadname, + NULL); } /** @@ -1970,16 +1996,16 @@ gst_element_link_pads (GstElement *src, const gchar *srcpadname, * Unlinks the two named pads of the source and destination elements. */ void -gst_element_unlink_pads (GstElement *src, const gchar *srcpadname, - GstElement *dest, const gchar *destpadname) +gst_element_unlink_pads (GstElement * src, const gchar * srcpadname, + GstElement * dest, const gchar * destpadname) { - GstPad *srcpad,*destpad; + GstPad *srcpad, *destpad; g_return_if_fail (src != NULL); - g_return_if_fail (GST_IS_ELEMENT(src)); + g_return_if_fail (GST_IS_ELEMENT (src)); g_return_if_fail (srcpadname != NULL); g_return_if_fail (dest != NULL); - g_return_if_fail (GST_IS_ELEMENT(dest)); + g_return_if_fail (GST_IS_ELEMENT (dest)); g_return_if_fail (destpadname != NULL); /* obtain the pads requested */ @@ -1990,12 +2016,13 @@ gst_element_unlink_pads (GstElement *src, const gchar *srcpadname, } destpad = gst_element_get_pad (dest, destpadname); if (srcpad == NULL) { - GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"", destpadname); + GST_WARNING_OBJECT (dest, "destination element has no pad \"%s\"", + destpadname); return; } /* we're satisified they can be unlinked, let's do it */ - gst_pad_unlink (srcpad,destpad); + gst_pad_unlink (srcpad, destpad); } /** @@ -2007,7 +2034,7 @@ gst_element_unlink_pads (GstElement *src, const gchar *srcpadname, * Unlinks a series of elements. Uses gst_element_unlink(). */ void -gst_element_unlink_many (GstElement *element_1, GstElement *element_2, ...) +gst_element_unlink_many (GstElement * element_1, GstElement * element_2, ...) { va_list args; @@ -2018,9 +2045,9 @@ gst_element_unlink_many (GstElement *element_1, GstElement *element_2, ...) while (element_2) { gst_element_unlink (element_1, element_2); - + element_1 = element_2; - element_2 = va_arg (args, GstElement*); + element_2 = va_arg (args, GstElement *); } va_end (args); @@ -2035,7 +2062,7 @@ gst_element_unlink_many (GstElement *element_1, GstElement *element_2, ...) * of the sink element to which they are linked. */ void -gst_element_unlink (GstElement *src, GstElement *dest) +gst_element_unlink (GstElement * src, GstElement * dest) { const GList *srcpads; GstPad *pad; @@ -2044,7 +2071,7 @@ gst_element_unlink (GstElement *src, GstElement *dest) g_return_if_fail (GST_IS_ELEMENT (dest)); GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "unlinking \"%s\" and \"%s\"", - GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest)); + GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (dest)); srcpads = gst_element_get_pad_list (src); @@ -2057,10 +2084,8 @@ gst_element_unlink (GstElement *src, GstElement *dest) /* see if the pad is connected and is really a pad * of dest */ - if (peerpad && - (GST_OBJECT_PARENT (peerpad) == (GstObject*) dest)) - { - gst_pad_unlink (pad, peerpad); + if (peerpad && (GST_OBJECT_PARENT (peerpad) == (GstObject *) dest)) { + gst_pad_unlink (pad, peerpad); } } @@ -2069,48 +2094,48 @@ gst_element_unlink (GstElement *src, GstElement *dest) } static void -gst_element_error_func (GstElement* element, GstElement *source, - GError *error, gchar *debug) +gst_element_error_func (GstElement * element, GstElement * source, + GError * error, gchar * debug) { /* tell the parent */ if (GST_OBJECT_PARENT (element)) { - GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarding error \"%s\" from %s to %s", - error->message, GST_ELEMENT_NAME (element), - GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); + GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, + "forwarding error \"%s\" from %s to %s", error->message, + GST_ELEMENT_NAME (element), + GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); gst_object_ref (GST_OBJECT (element)); g_signal_emit (G_OBJECT (GST_OBJECT_PARENT (element)), - gst_element_signals[ERROR], 0, source, error, debug); + gst_element_signals[ERROR], 0, source, error, debug); gst_object_unref (GST_OBJECT (element)); - GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarded error \"%s\" from %s to %s", - error->message, GST_ELEMENT_NAME (element), - GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); + GST_CAT_DEBUG (GST_CAT_ERROR_SYSTEM, "forwarded error \"%s\" from %s to %s", + error->message, GST_ELEMENT_NAME (element), + GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); } } -static GstPad* -gst_element_get_random_pad (GstElement *element, GstPadDirection dir) +static GstPad * +gst_element_get_random_pad (GstElement * element, GstPadDirection dir) { GList *pads = element->pads; + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "getting a random pad"); while (pads) { GstPad *pad = GST_PAD (pads->data); GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "checking pad %s:%s", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); if (GST_PAD_DIRECTION (pad) == dir) { if (GST_PAD_IS_LINKED (pad)) { return pad; + } else { + GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is not linked", + GST_DEBUG_PAD_NAME (pad)); } - else { - GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is not linked", - GST_DEBUG_PAD_NAME (pad)); - } - } - else { + } else { GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "pad %s:%s is in wrong direction", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); } pads = g_list_next (pads); @@ -2129,19 +2154,20 @@ gst_element_get_random_pad (GstElement *element, GstPadDirection dir) * * Returns: An array of #GstEventMask elements. */ -const GstEventMask* -gst_element_get_event_masks (GstElement *element) +const GstEventMask * +gst_element_get_event_masks (GstElement * element) { GstElementClass *oclass; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); - + oclass = GST_ELEMENT_GET_CLASS (element); if (oclass->get_event_masks) return oclass->get_event_masks (element); else { GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK); + if (pad) return gst_pad_get_event_masks (GST_PAD_PEER (pad)); } @@ -2161,27 +2187,28 @@ gst_element_get_event_masks (GstElement *element) * Returns: TRUE if the event was handled. */ gboolean -gst_element_send_event (GstElement *element, GstEvent *event) +gst_element_send_event (GstElement * element, GstEvent * event) { GstElementClass *oclass; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + oclass = GST_ELEMENT_GET_CLASS (element); if (oclass->send_event) return oclass->send_event (element, event); else { GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK); + if (pad) { GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "sending event to random pad %s:%s", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); return gst_pad_send_event (GST_PAD_PEER (pad), event); } } GST_CAT_DEBUG (GST_CAT_ELEMENT_PADS, "can't send event on element %s", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); return FALSE; } @@ -2196,9 +2223,7 @@ gst_element_send_event (GstElement *element, GstEvent *event) * Returns: TRUE if the event was handled. */ gboolean -gst_element_seek (GstElement *element, - GstSeekType seek_type, - guint64 offset) +gst_element_seek (GstElement * element, GstSeekType seek_type, guint64 offset) { GstEvent *event = gst_event_new_seek (seek_type, offset); @@ -2216,19 +2241,20 @@ gst_element_seek (GstElement *element, * * Returns: An array of #GstQueryType elements. */ -const GstQueryType* -gst_element_get_query_types (GstElement *element) +const GstQueryType * +gst_element_get_query_types (GstElement * element) { GstElementClass *oclass; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); - + oclass = GST_ELEMENT_GET_CLASS (element); if (oclass->get_query_types) return oclass->get_query_types (element); else { GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK); + if (pad) return gst_pad_get_query_types (GST_PAD_PEER (pad)); } @@ -2252,8 +2278,8 @@ gst_element_get_query_types (GstElement *element) * Returns: TRUE if the query could be performed. */ gboolean -gst_element_query (GstElement *element, GstQueryType type, - GstFormat *format, gint64 *value) +gst_element_query (GstElement * element, GstQueryType type, + GstFormat * format, gint64 * value) { GstElementClass *oclass; @@ -2262,11 +2288,12 @@ gst_element_query (GstElement *element, GstQueryType type, g_return_val_if_fail (value != NULL, FALSE); oclass = GST_ELEMENT_GET_CLASS (element); - + if (oclass->query) return oclass->query (element, type, format, value); else { GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SRC); + if (pad) return gst_pad_query (pad, type, format, value); pad = gst_element_get_random_pad (element, GST_PAD_SINK); @@ -2288,19 +2315,20 @@ gst_element_query (GstElement *element, GstQueryType type, * * Returns: An array of #GstFormat elements. */ -const GstFormat* -gst_element_get_formats (GstElement *element) +const GstFormat * +gst_element_get_formats (GstElement * element) { GstElementClass *oclass; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); - + oclass = GST_ELEMENT_GET_CLASS (element); if (oclass->get_formats) return oclass->get_formats (element); else { GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK); + if (pad) return gst_pad_get_formats (GST_PAD_PEER (pad)); } @@ -2324,9 +2352,9 @@ gst_element_get_formats (GstElement *element) * Returns: TRUE if the conversion could be performed. */ gboolean -gst_element_convert (GstElement *element, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_element_convert (GstElement * element, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { GstElementClass *oclass; @@ -2343,14 +2371,13 @@ gst_element_convert (GstElement *element, if (oclass->convert) return oclass->convert (element, - src_format, src_value, - dest_format, dest_value); + src_format, src_value, dest_format, dest_value); else { GstPad *pad = gst_element_get_random_pad (element, GST_PAD_SINK); + if (pad) - return gst_pad_convert (GST_PAD_PEER (pad), - src_format, src_value, - dest_format, dest_value); + return gst_pad_convert (GST_PAD_PEER (pad), + src_format, src_value, dest_format, dest_value); } return FALSE; @@ -2365,13 +2392,15 @@ gst_element_convert (GstElement *element, * Returns: a newly allocated string, or NULL if the format was NULL or "" */ gchar * -_gst_element_error_printf (const gchar *format, ...) +_gst_element_error_printf (const gchar * format, ...) { va_list args; gchar *buffer; - if (format == NULL) return NULL; - if (format[0] == 0) return NULL; + if (format == NULL) + return NULL; + if (format[0] == 0) + return NULL; va_start (args, format); buffer = g_strdup_vprintf (format, args); @@ -2393,10 +2422,9 @@ _gst_element_error_printf (const gchar *format, ...) * This function is used internally by elements. * It results in the "error" signal. */ -void -gst_element_error_full -(GstElement *element, GQuark domain, gint code, gchar *message, gchar *debug, - const gchar *file, const gchar *function, gint line) +void gst_element_error_full + (GstElement * element, GQuark domain, gint code, gchar * message, + gchar * debug, const gchar * file, const gchar * function, gint line) { GError *error = NULL; gchar *name; @@ -2407,34 +2435,31 @@ gst_element_error_full g_return_if_fail (GST_IS_ELEMENT (element)); /* check if we send the given message or the default error message */ - if ((message == NULL) || (message[0] == 0)) - { + if ((message == NULL) || (message[0] == 0)) { /* we got this message from g_strdup_printf (""); */ g_free (message); sent_message = gst_error_get_message (domain, code); - } - else + } else sent_message = message; - if ((debug == NULL) || (debug[0] == 0)) - { + if ((debug == NULL) || (debug[0] == 0)) { /* we got this debug from g_strdup_printf (""); */ g_free (debug); debug = NULL; } - + /* create error message */ GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "signaling error in %s: %s", - GST_ELEMENT_NAME (element), - sent_message); + GST_ELEMENT_NAME (element), sent_message); error = g_error_new (domain, code, sent_message); /* if the element was already in error, stop now */ if (GST_FLAG_IS_SET (element, GST_ELEMENT_IN_ERROR)) { GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "recursive ERROR detected in %s", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); g_free (sent_message); - if (debug) g_free (debug); + if (debug) + g_free (debug); return; } @@ -2445,19 +2470,17 @@ gst_element_error_full name = gst_object_get_path_string (GST_OBJECT (element)); if (debug) sent_debug = g_strdup_printf ("%s(%d): %s: %s:\n%s", - file, line, function, name, - debug ? debug : ""); + file, line, function, name, debug ? debug : ""); else sent_debug = NULL; g_free (debug); g_free (name); g_signal_emit (G_OBJECT (element), gst_element_signals[ERROR], 0, element, - error, sent_debug); + error, sent_debug); GST_CAT_INFO (GST_CAT_ERROR_SYSTEM, "signalled error in %s: %s", - GST_ELEMENT_NAME (element), - sent_message); + GST_ELEMENT_NAME (element), sent_message); - /* tell the scheduler */ + /* tell the scheduler */ if (element->sched) { gst_scheduler_error (element->sched, element); } @@ -2468,7 +2491,7 @@ gst_element_error_full ret = gst_element_set_state (element, GST_STATE_PAUSED); if (ret != GST_STATE_SUCCESS) { g_warning ("could not PAUSE element \"%s\" after error, help!", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); } } @@ -2494,12 +2517,13 @@ gst_element_error_full * Returns: TRUE, if the element's state is locked. */ gboolean -gst_element_is_locked_state (GstElement *element) +gst_element_is_locked_state (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); return GST_FLAG_IS_SET (element, GST_ELEMENT_LOCKED_STATE) ? TRUE : FALSE; } + /** * gst_element_set_locked_state: * @element: a #GstElement @@ -2509,7 +2533,7 @@ gst_element_is_locked_state (GstElement *element) * this element anymore. */ void -gst_element_set_locked_state (GstElement *element, gboolean locked_state) +gst_element_set_locked_state (GstElement * element, gboolean locked_state) { gboolean old; @@ -2521,15 +2545,16 @@ gst_element_set_locked_state (GstElement *element, gboolean locked_state) return; if (locked_state) { - GST_CAT_DEBUG (GST_CAT_STATES, "locking state of element %s", - GST_ELEMENT_NAME (element)); + GST_CAT_DEBUG (GST_CAT_STATES, "locking state of element %s", + GST_ELEMENT_NAME (element)); GST_FLAG_SET (element, GST_ELEMENT_LOCKED_STATE); } else { - GST_CAT_DEBUG (GST_CAT_STATES, "unlocking state of element %s", - GST_ELEMENT_NAME (element)); + GST_CAT_DEBUG (GST_CAT_STATES, "unlocking state of element %s", + GST_ELEMENT_NAME (element)); GST_FLAG_UNSET (element, GST_ELEMENT_LOCKED_STATE); } } + /** * gst_element_sync_state_with_parent: * @element: a #GstElement. @@ -2540,22 +2565,25 @@ gst_element_set_locked_state (GstElement *element, gboolean locked_state) * Returns: TRUE, if the element's state could be synced to the parent's state. */ gboolean -gst_element_sync_state_with_parent (GstElement *element) +gst_element_sync_state_with_parent (GstElement * element) { GstElement *parent; g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE); - parent = GST_ELEMENT (GST_ELEMENT_PARENT(element)); + parent = GST_ELEMENT (GST_ELEMENT_PARENT (element)); g_return_val_if_fail (GST_IS_BIN (parent), FALSE); - - GST_CAT_DEBUG (GST_CAT_STATES, "syncing state of element %s (%s) to %s (%s)", - GST_ELEMENT_NAME (element), gst_element_state_get_name (GST_STATE (element)), - GST_ELEMENT_NAME (parent), gst_element_state_get_name (GST_STATE (parent))); + + GST_CAT_DEBUG (GST_CAT_STATES, "syncing state of element %s (%s) to %s (%s)", + GST_ELEMENT_NAME (element), + gst_element_state_get_name (GST_STATE (element)), + GST_ELEMENT_NAME (parent), + gst_element_state_get_name (GST_STATE (parent))); if (gst_element_set_state (element, GST_STATE (parent)) == GST_STATE_FAILURE) { return FALSE; } return TRUE; } + /** * gst_element_get_state: * @element: a #GstElement to get the state of. @@ -2565,7 +2593,7 @@ gst_element_sync_state_with_parent (GstElement *element) * Returns: the #GstElementState of the element. */ GstElementState -gst_element_get_state (GstElement *element) +gst_element_get_state (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_VOID_PENDING); @@ -2579,7 +2607,7 @@ gst_element_get_state (GstElement *element) * Waits and blocks until the element changed its state. */ void -gst_element_wait_state_change (GstElement *element) +gst_element_wait_state_change (GstElement * element) { g_mutex_lock (element->state_mutex); g_cond_wait (element->state_cond, element->state_mutex); @@ -2599,7 +2627,7 @@ gst_element_wait_state_change (GstElement *element) * (using #GstElementStateReturn). */ GstElementStateReturn -gst_element_set_state (GstElement *element, GstElementState state) +gst_element_set_state (GstElement * element, GstElementState state) { GstElementClass *oclass; GstElementState curpending; @@ -2608,27 +2636,26 @@ gst_element_set_state (GstElement *element, GstElementState state) g_return_val_if_fail (GST_IS_ELEMENT (element), GST_STATE_FAILURE); /* start with the current state */ - curpending = GST_STATE(element); + curpending = GST_STATE (element); - if (state == curpending) - { + if (state == curpending) { GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "element is already in requested state %s", - gst_element_state_get_name (state)); + "element is already in requested state %s", + gst_element_state_get_name (state)); return (GST_STATE_SUCCESS); } GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, "setting state from %s to %s", - gst_element_state_get_name (curpending), - gst_element_state_get_name (state)); + gst_element_state_get_name (curpending), + gst_element_state_get_name (state)); /* loop until the final requested state is set */ - while (GST_STATE (element) != state + while (GST_STATE (element) != state && GST_STATE (element) != GST_STATE_VOID_PENDING) { /* move the curpending state in the correct direction */ - if (curpending < state) + if (curpending < state) curpending <<= 1; - else + else curpending >>= 1; /* set the pending state variable */ @@ -2636,10 +2663,10 @@ gst_element_set_state (GstElement *element, GstElementState state) GST_STATE_PENDING (element) = curpending; if (curpending != state) { - GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "intermediate: setting state from %s to %s", - gst_element_state_get_name (GST_STATE (element)), - gst_element_state_get_name (curpending)); + GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, + "intermediate: setting state from %s to %s", + gst_element_state_get_name (GST_STATE (element)), + gst_element_state_get_name (curpending)); } /* call the state change function so it can set the state */ @@ -2649,28 +2676,28 @@ gst_element_set_state (GstElement *element, GstElementState state) switch (return_val) { case GST_STATE_FAILURE: - GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "have failed change_state return"); - goto exit; + GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, + "have failed change_state return"); + goto exit; case GST_STATE_ASYNC: - GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "element will change state async"); - goto exit; + GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, + "element will change state async"); + goto exit; case GST_STATE_SUCCESS: - /* Last thing we do is verify that a successful state change really - * did change the state... */ - /* if it did not, this is an error - fix the element that does this */ + /* Last thing we do is verify that a successful state change really + * did change the state... */ + /* if it did not, this is an error - fix the element that does this */ if (GST_STATE (element) != curpending) { g_warning ("element %s claimed state-change success," - "but state didn't change to %s. State is %s (%s pending), fix the element", - GST_ELEMENT_NAME (element), - gst_element_state_get_name (curpending), - gst_element_state_get_name (GST_STATE (element)), - gst_element_state_get_name (GST_STATE_PENDING (element))); + "but state didn't change to %s. State is %s (%s pending), fix the element", + GST_ELEMENT_NAME (element), + gst_element_state_get_name (curpending), + gst_element_state_get_name (GST_STATE (element)), + gst_element_state_get_name (GST_STATE_PENDING (element))); return_val = GST_STATE_FAILURE; - goto exit; + goto exit; } - break; + break; default: /* somebody added a GST_STATE_ and forgot to do stuff here ! */ g_assert_not_reached (); @@ -2682,7 +2709,7 @@ exit: } static gboolean -gst_element_negotiate_pads (GstElement *element) +gst_element_negotiate_pads (GstElement * element) { GList *pads = GST_ELEMENT_PADS (element); @@ -2693,7 +2720,7 @@ gst_element_negotiate_pads (GstElement *element) GstRealPad *srcpad; pads = g_list_next (pads); - + if (!GST_IS_REAL_PAD (pad)) continue; @@ -2705,24 +2732,24 @@ gst_element_negotiate_pads (GstElement *element) GstRealPad *sinkpad; GstElementState otherstate; GstElement *parent; - + sinkpad = GST_RPAD_PEER (GST_PAD_REALIZE (srcpad)); /* check the parent of the peer pad, if there is no parent do nothing */ parent = GST_PAD_PARENT (sinkpad); - if (!parent) + if (!parent) continue; /* skips pads that were already negotiating */ if (GST_FLAG_IS_SET (sinkpad, GST_PAD_NEGOTIATING) || - GST_FLAG_IS_SET (srcpad, GST_PAD_NEGOTIATING)) + GST_FLAG_IS_SET (srcpad, GST_PAD_NEGOTIATING)) continue; otherstate = GST_STATE (parent); /* swap pads if needed */ if (!GST_PAD_IS_SRC (srcpad)) { - GstRealPad *temp; + GstRealPad *temp; temp = srcpad; srcpad = sinkpad; @@ -2731,18 +2758,15 @@ gst_element_negotiate_pads (GstElement *element) /* only try to negotiate if the peer element is in PAUSED or higher too */ if (otherstate >= GST_STATE_READY) { - GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element, - "perform negotiate for %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), - GST_DEBUG_PAD_NAME (sinkpad)); - if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED) + GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element, + "perform negotiate for %s:%s and %s:%s", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + if (gst_pad_renegotiate (pad) == GST_PAD_LINK_REFUSED) return FALSE; - } - else { - GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element, - "not negotiating %s:%s and %s:%s, not in READY yet", - GST_DEBUG_PAD_NAME (srcpad), - GST_DEBUG_PAD_NAME (sinkpad)); + } else { + GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, element, + "not negotiating %s:%s and %s:%s, not in READY yet", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); } } } @@ -2751,7 +2775,7 @@ gst_element_negotiate_pads (GstElement *element) } static void -gst_element_clear_pad_caps (GstElement *element) +gst_element_clear_pad_caps (GstElement * element) { GList *pads = GST_ELEMENT_PADS (element); @@ -2761,7 +2785,7 @@ gst_element_clear_pad_caps (GstElement *element) GstPad *pad = GST_PAD (pads->data); gst_pad_unnegotiate (pad); - if (GST_IS_REAL_PAD (pad)){ + if (GST_IS_REAL_PAD (pad)) { gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), NULL); } @@ -2770,12 +2794,13 @@ gst_element_clear_pad_caps (GstElement *element) } static void -gst_element_pads_activate (GstElement *element, gboolean active) +gst_element_pads_activate (GstElement * element, gboolean active) { GList *pads = element->pads; while (pads) { GstPad *pad = GST_PAD (pads->data); + pads = g_list_next (pads); if (!GST_IS_REAL_PAD (pad)) @@ -2786,7 +2811,7 @@ gst_element_pads_activate (GstElement *element, gboolean active) } static GstElementStateReturn -gst_element_change_state (GstElement *element) +gst_element_change_state (GstElement * element) { GstElementState old_state; GstObject *parent; @@ -2798,19 +2823,18 @@ gst_element_change_state (GstElement *element) old_pending = GST_STATE_PENDING (element); old_transition = GST_STATE_TRANSITION (element); - if (old_pending == GST_STATE_VOID_PENDING || + if (old_pending == GST_STATE_VOID_PENDING || old_state == GST_STATE_PENDING (element)) { GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element, - "element is already in the %s state", - gst_element_state_get_name (old_state)); + "element is already in the %s state", + gst_element_state_get_name (old_state)); return GST_STATE_SUCCESS; } - + GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, - "default handler sets state from %s to %s %04x", - gst_element_state_get_name (old_state), - gst_element_state_get_name (old_pending), - old_transition); + "default handler sets state from %s to %s %04x", + gst_element_state_get_name (old_state), + gst_element_state_get_name (old_pending), old_transition); /* we set the state change early for the negotiation functions */ GST_STATE (element) = old_pending; @@ -2820,6 +2844,7 @@ gst_element_change_state (GstElement *element) case GST_STATE_PLAYING_TO_PAUSED: if (element->clock) { GstClockTime time = gst_clock_get_event_time (element->clock); + g_assert (time >= element->base_time); element->base_time = time - element->base_time; GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %" @@ -2831,19 +2856,20 @@ gst_element_change_state (GstElement *element) gst_element_pads_activate (element, TRUE); if (element->clock) { GstClockTime time = gst_clock_get_event_time (element->clock); + element->base_time = time - element->base_time; GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, element, "setting base time to %" G_GINT64_FORMAT, element->base_time); } break; - /* if we are going to paused, we try to negotiate the pads */ + /* if we are going to paused, we try to negotiate the pads */ case GST_STATE_READY_TO_PAUSED: g_assert (element->base_time == 0); - if (!gst_element_negotiate_pads (element)) - goto failure; + if (!gst_element_negotiate_pads (element)) + goto failure; break; - /* going to the READY state clears all pad caps */ - /* FIXME: Why doesn't this happen on READY => NULL? -- Company */ + /* going to the READY state clears all pad caps */ + /* FIXME: Why doesn't this happen on READY => NULL? -- Company */ case GST_STATE_PAUSED_TO_READY: element->base_time = 0; gst_element_clear_pad_caps (element); @@ -2855,29 +2881,29 @@ gst_element_change_state (GstElement *element) parent = GST_ELEMENT_PARENT (element); GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, - "signaling state change from %s to %s", - gst_element_state_get_name (old_state), - gst_element_state_get_name (GST_STATE (element))); + "signaling state change from %s to %s", + gst_element_state_get_name (old_state), + gst_element_state_get_name (GST_STATE (element))); /* tell the scheduler if we have one */ if (element->sched) { - if (gst_scheduler_state_transition (element->sched, element, - old_transition) != GST_STATE_SUCCESS) { - GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, - "scheduler could not change state"); + if (gst_scheduler_state_transition (element->sched, element, + old_transition) != GST_STATE_SUCCESS) { + GST_CAT_INFO_OBJECT (GST_CAT_STATES, element, + "scheduler could not change state"); goto failure; } } /* tell our parent about the state change */ if (parent && GST_IS_BIN (parent)) { - gst_bin_child_state_change (GST_BIN (parent), old_state, - GST_STATE (element), element); + gst_bin_child_state_change (GST_BIN (parent), old_state, + GST_STATE (element), element); } /* at this point the state of the element could have changed again */ g_signal_emit (G_OBJECT (element), gst_element_signals[STATE_CHANGE], - 0, old_state, GST_STATE (element)); + 0, old_state, GST_STATE (element)); /* signal the state change in case somebody is waiting for us */ g_mutex_lock (element->state_mutex); @@ -2902,16 +2928,16 @@ failure: * * Returns: the #GstElementFactory used for creating this element. */ -GstElementFactory* -gst_element_get_factory (GstElement *element) +GstElementFactory * +gst_element_get_factory (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); - + return GST_ELEMENT_GET_CLASS (element)->elementfactory; } static void -gst_element_dispose (GObject *object) +gst_element_dispose (GObject * object) { GstElement *element = GST_ELEMENT (object); GList *pads; @@ -2924,14 +2950,15 @@ gst_element_dispose (GObject *object) /* first we break all our links with the ouside */ if (element->pads) { GList *orig; + orig = pads = g_list_copy (element->pads); while (pads) { pad = GST_PAD (pads->data); if (GST_PAD_PEER (pad)) { - GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "unlinking pad '%s'", - GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad))))); - gst_pad_unlink (pad, GST_PAD (GST_PAD_PEER (pad))); + GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "unlinking pad '%s'", + GST_OBJECT_NAME (GST_OBJECT (GST_PAD (GST_PAD_PEER (pad))))); + gst_pad_unlink (pad, GST_PAD (GST_PAD_PEER (pad))); } gst_element_remove_pad (element, pad); @@ -2959,8 +2986,8 @@ gst_element_dispose (GObject *object) g_mutex_free (element->property_mutex); element->property_mutex = NULL; - gst_object_replace ((GstObject **)&element->sched, NULL); - gst_object_replace ((GstObject **)&element->clock, NULL); + gst_object_replace ((GstObject **) & element->sched, NULL); + gst_object_replace ((GstObject **) & element->clock, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -2976,8 +3003,7 @@ gst_element_dispose (GObject *object) * Returns: the new #xmlNodePtr. */ static xmlNodePtr -gst_element_save_thyself (GstObject *object, - xmlNodePtr parent) +gst_element_save_thyself (GstObject * object, xmlNodePtr parent) { GList *pads; GstElementClass *oclass; @@ -2992,48 +3018,47 @@ gst_element_save_thyself (GstObject *object, oclass = GST_ELEMENT_GET_CLASS (element); - xmlNewChild(parent, NULL, "name", GST_ELEMENT_NAME(element)); + xmlNewChild (parent, NULL, "name", GST_ELEMENT_NAME (element)); if (oclass->elementfactory != NULL) { - GstElementFactory *factory = (GstElementFactory *)oclass->elementfactory; + GstElementFactory *factory = (GstElementFactory *) oclass->elementfactory; - xmlNewChild (parent, NULL, "type", - GST_PLUGIN_FEATURE (factory)->name); + xmlNewChild (parent, NULL, "type", GST_PLUGIN_FEATURE (factory)->name); } -/* FIXME: what is this? */ +/* FIXME: what is this? */ /* if (element->manager) */ /* xmlNewChild(parent, NULL, "manager", GST_ELEMENT_NAME(element->manager)); */ /* params */ specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &nspecs); - - for (i=0; iflags & G_PARAM_READABLE) { xmlNodePtr param; char *contents; - - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (spec)); - + + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (spec)); + g_object_get_property (G_OBJECT (element), spec->name, &value); param = xmlNewChild (parent, NULL, "param", NULL); xmlNewChild (param, NULL, "name", spec->name); - + if (G_IS_PARAM_SPEC_STRING (spec)) contents = g_value_dup_string (&value); else if (G_IS_PARAM_SPEC_ENUM (spec)) contents = g_strdup_printf ("%d", g_value_get_enum (&value)); else if (G_IS_PARAM_SPEC_INT64 (spec)) contents = g_strdup_printf ("%" G_GINT64_FORMAT, - g_value_get_int64 (&value)); + g_value_get_int64 (&value)); else contents = g_strdup_value_contents (&value); - + xmlNewChild (param, NULL, "value", contents); g_free (contents); - - g_value_unset(&value); + + g_value_unset (&value); } } @@ -3041,9 +3066,11 @@ gst_element_save_thyself (GstObject *object, while (pads) { GstPad *pad = GST_PAD (pads->data); + /* figure out if it's a direct pad or a ghostpad */ if (GST_ELEMENT (GST_OBJECT_PARENT (pad)) == element) { xmlNodePtr padtag = xmlNewChild (parent, NULL, "pad", NULL); + gst_object_save_thyself (GST_OBJECT (pad), padtag); } pads = g_list_next (pads); @@ -3053,7 +3080,7 @@ gst_element_save_thyself (GstObject *object, } static void -gst_element_restore_thyself (GstObject *object, xmlNodePtr self) +gst_element_restore_thyself (GstObject * object, xmlNodePtr self) { xmlNodePtr children; GstElement *element; @@ -3070,13 +3097,12 @@ gst_element_restore_thyself (GstObject *object, xmlNodePtr self) xmlNodePtr child = children->xmlChildrenNode; while (child) { - if (!strcmp (child->name, "name")) { - name = xmlNodeGetContent (child); - } - else if (!strcmp (child->name, "value")) { - value = xmlNodeGetContent (child); + if (!strcmp (child->name, "name")) { + name = xmlNodeGetContent (child); + } else if (!strcmp (child->name, "value")) { + value = xmlNodeGetContent (child); } - child = child->next; + child = child->next; } /* FIXME: can this just be g_object_set ? */ gst_util_set_object_arg (G_OBJECT (element), name, value); @@ -3084,7 +3110,7 @@ gst_element_restore_thyself (GstObject *object, xmlNodePtr self) } children = children->next; } - + /* pads */ children = self->xmlChildrenNode; while (children) { @@ -3107,7 +3133,7 @@ gst_element_restore_thyself (GstObject *object, xmlNodePtr self) * give control to another element. */ void -gst_element_yield (GstElement *element) +gst_element_yield (GstElement * element) { if (GST_ELEMENT_SCHED (element)) { gst_scheduler_yield (GST_ELEMENT_SCHED (element), element); @@ -3125,12 +3151,11 @@ gst_element_yield (GstElement *element) * function ASAP, depending on the scheduler implementation. */ gboolean -gst_element_interrupt (GstElement *element) +gst_element_interrupt (GstElement * element) { if (GST_ELEMENT_SCHED (element)) { return gst_scheduler_interrupt (GST_ELEMENT_SCHED (element), element); - } - else + } else return TRUE; } @@ -3143,14 +3168,15 @@ gst_element_interrupt (GstElement *element) * writing a new bin subclass. */ void -gst_element_set_scheduler (GstElement *element, - GstScheduler *sched) +gst_element_set_scheduler (GstElement * element, GstScheduler * sched) { g_return_if_fail (GST_IS_ELEMENT (element)); - - GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", sched); - gst_object_replace ((GstObject **)&GST_ELEMENT_SCHED (element), GST_OBJECT (sched)); + GST_CAT_DEBUG_OBJECT (GST_CAT_PARENTAGE, element, "setting scheduler to %p", + sched); + + gst_object_replace ((GstObject **) & GST_ELEMENT_SCHED (element), + GST_OBJECT (sched)); } /** @@ -3161,8 +3187,8 @@ gst_element_set_scheduler (GstElement *element, * * Returns: the element's #GstScheduler. */ -GstScheduler* -gst_element_get_scheduler (GstElement *element) +GstScheduler * +gst_element_get_scheduler (GstElement * element) { g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); @@ -3183,21 +3209,20 @@ gst_element_get_scheduler (GstElement *element) * a new loopfunc to be assigned, this should be no problem. */ void -gst_element_set_loop_function (GstElement *element, - GstElementLoopFunction loop) +gst_element_set_loop_function (GstElement * element, + GstElementLoopFunction loop) { gboolean need_notify = FALSE; - + g_return_if_fail (GST_IS_ELEMENT (element)); /* if the element changed from loop based to chain/get based * or vice versa, we need to inform the scheduler about that */ if ((element->loopfunc == NULL && loop != NULL) || - (element->loopfunc != NULL && loop == NULL)) - { + (element->loopfunc != NULL && loop == NULL)) { need_notify = TRUE; } - + /* set the loop function */ element->loopfunc = loop; @@ -3211,22 +3236,26 @@ gst_element_set_loop_function (GstElement *element, } } static inline void -gst_element_emit_found_tag (GstElement* element, GstElement *source, const GstTagList *tag_list) +gst_element_emit_found_tag (GstElement * element, GstElement * source, + const GstTagList * tag_list) { gst_object_ref (GST_OBJECT (element)); g_signal_emit (element, gst_element_signals[FOUND_TAG], 0, source, tag_list); gst_object_unref (GST_OBJECT (element)); } static void -gst_element_found_tag_func (GstElement* element, GstElement *source, const GstTagList *tag_list) +gst_element_found_tag_func (GstElement * element, GstElement * source, + const GstTagList * tag_list) { /* tell the parent */ if (GST_OBJECT_PARENT (element)) { - GST_CAT_LOG_OBJECT (GST_CAT_EVENT, element, "forwarding tag event to %s", - GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); - gst_element_emit_found_tag (GST_ELEMENT (GST_OBJECT_PARENT (element)), source, tag_list); - } + GST_CAT_LOG_OBJECT (GST_CAT_EVENT, element, "forwarding tag event to %s", + GST_OBJECT_NAME (GST_OBJECT_PARENT (element))); + gst_element_emit_found_tag (GST_ELEMENT (GST_OBJECT_PARENT (element)), + source, tag_list); + } } + /** * gst_element_found_tags: * @element: the element that found the tags @@ -3238,10 +3267,11 @@ gst_element_found_tag_func (GstElement* element, GstElement *source, const GstTa * not when you handle an event. */ void -gst_element_found_tags (GstElement *element, const GstTagList *tag_list) +gst_element_found_tags (GstElement * element, const GstTagList * tag_list) { gst_element_emit_found_tag (element, element, tag_list); } + /** * gst_element_found_tags_for_pad: * @element: element that found the tag @@ -3259,8 +3289,8 @@ gst_element_found_tags (GstElement *element, const GstTagList *tag_list) * #GstPadGetFunction. */ void -gst_element_found_tags_for_pad (GstElement *element, GstPad *pad, GstClockTime timestamp, - GstTagList *list) +gst_element_found_tags_for_pad (GstElement * element, GstPad * pad, + GstClockTime timestamp, GstTagList * list) { GstEvent *tag_event; @@ -3281,23 +3311,24 @@ gst_element_found_tags_for_pad (GstElement *element, GstPad *pad, GstClockTime t } static inline void -gst_element_set_eos_recursive (GstElement *element) +gst_element_set_eos_recursive (GstElement * element) { /* this function is only called, when we were in PLAYING before. So every parent that's PAUSED was PLAYING before. That means it has reached EOS. */ GstElement *parent; - GST_CAT_DEBUG (GST_CAT_EVENT, "setting recursive EOS on %s", - GST_OBJECT_NAME (element)); + GST_CAT_DEBUG (GST_CAT_EVENT, "setting recursive EOS on %s", + GST_OBJECT_NAME (element)); g_signal_emit (G_OBJECT (element), gst_element_signals[EOS], 0); if (!GST_OBJECT_PARENT (element)) return; - + parent = GST_ELEMENT (GST_OBJECT_PARENT (element)); if (GST_STATE (parent) == GST_STATE_PAUSED) gst_element_set_eos_recursive (parent); } + /** * gst_element_set_eos: * @element: a #GstElement to set to the EOS state. @@ -3305,12 +3336,12 @@ gst_element_set_eos_recursive (GstElement *element) * Perform the actions needed to bring the element in the EOS state. */ void -gst_element_set_eos (GstElement *element) +gst_element_set_eos (GstElement * element) { g_return_if_fail (GST_IS_ELEMENT (element)); - GST_CAT_DEBUG (GST_CAT_EVENT, "setting EOS on element %s", - GST_OBJECT_NAME (element)); + GST_CAT_DEBUG (GST_CAT_EVENT, "setting EOS on element %s", + GST_OBJECT_NAME (element)); if (GST_STATE (element) == GST_STATE_PLAYING) { gst_element_set_state (element, GST_STATE_PAUSED); @@ -3329,34 +3360,55 @@ gst_element_set_eos (GstElement *element) * * Returns: a string with the name of the state. */ -const gchar* -gst_element_state_get_name (GstElementState state) +const gchar * +gst_element_state_get_name (GstElementState state) { switch (state) { #ifdef GST_DEBUG_COLOR - case GST_STATE_VOID_PENDING: return "NONE_PENDING";break; - case GST_STATE_NULL: return "\033[01;34mNULL\033[00m";break; - case GST_STATE_READY: return "\033[01;31mREADY\033[00m";break; - case GST_STATE_PLAYING: return "\033[01;32mPLAYING\033[00m";break; - case GST_STATE_PAUSED: return "\033[01;33mPAUSED\033[00m";break; + case GST_STATE_VOID_PENDING: + return "NONE_PENDING"; + break; + case GST_STATE_NULL: + return "\033[01;34mNULL\033[00m"; + break; + case GST_STATE_READY: + return "\033[01;31mREADY\033[00m"; + break; + case GST_STATE_PLAYING: + return "\033[01;32mPLAYING\033[00m"; + break; + case GST_STATE_PAUSED: + return "\033[01;33mPAUSED\033[00m"; + break; default: /* This is a memory leak */ return g_strdup_printf ("\033[01;35;41mUNKNOWN!\033[00m(%d)", state); #else - case GST_STATE_VOID_PENDING: return "NONE_PENDING";break; - case GST_STATE_NULL: return "NULL";break; - case GST_STATE_READY: return "READY";break; - case GST_STATE_PLAYING: return "PLAYING";break; - case GST_STATE_PAUSED: return "PAUSED";break; - default: return "UNKNOWN!"; + case GST_STATE_VOID_PENDING: + return "NONE_PENDING"; + break; + case GST_STATE_NULL: + return "NULL"; + break; + case GST_STATE_READY: + return "READY"; + break; + case GST_STATE_PLAYING: + return "PLAYING"; + break; + case GST_STATE_PAUSED: + return "PAUSED"; + break; + default: + return "UNKNOWN!"; #endif } return ""; } static void -gst_element_populate_std_props (GObjectClass * klass, const gchar *prop_name, - guint arg_id, GParamFlags flags) +gst_element_populate_std_props (GObjectClass * klass, const gchar * prop_name, + guint arg_id, GParamFlags flags) { GQuark prop_id = g_quark_from_string (prop_name); GParamSpec *pspec; @@ -3387,64 +3439,45 @@ gst_element_populate_std_props (GObjectClass * klass, const gchar *prop_name, if (prop_id == fd_id) { pspec = g_param_spec_int ("fd", "File-descriptor", - "File-descriptor for the file being read", - 0, G_MAXINT, 0, flags); - } - else if (prop_id == blocksize_id) { + "File-descriptor for the file being read", 0, G_MAXINT, 0, flags); + } else if (prop_id == blocksize_id) { pspec = g_param_spec_ulong ("blocksize", "Block Size", - "Block size to read per buffer", - 0, G_MAXULONG, 4096, flags); + "Block size to read per buffer", 0, G_MAXULONG, 4096, flags); - } - else if (prop_id == bytesperread_id) { + } else if (prop_id == bytesperread_id) { pspec = g_param_spec_int ("bytesperread", "Bytes per read", - "Number of bytes to read per buffer", - G_MININT, G_MAXINT, 0, flags); + "Number of bytes to read per buffer", G_MININT, G_MAXINT, 0, flags); - } - else if (prop_id == dump_id) { - pspec = g_param_spec_boolean ("dump", "Dump", - "Dump bytes to stdout", - FALSE, flags); + } else if (prop_id == dump_id) { + pspec = g_param_spec_boolean ("dump", "Dump", + "Dump bytes to stdout", FALSE, flags); - } - else if (prop_id == filesize_id) { + } else if (prop_id == filesize_id) { pspec = g_param_spec_int64 ("filesize", "File Size", - "Size of the file being read", - 0, G_MAXINT64, 0, flags); + "Size of the file being read", 0, G_MAXINT64, 0, flags); - } - else if (prop_id == mmapsize_id) { + } else if (prop_id == mmapsize_id) { pspec = g_param_spec_ulong ("mmapsize", "mmap() Block Size", - "Size in bytes of mmap()d regions", - 0, G_MAXULONG, 4 * 1048576, flags); + "Size in bytes of mmap()d regions", 0, G_MAXULONG, 4 * 1048576, flags); - } - else if (prop_id == location_id) { + } else if (prop_id == location_id) { pspec = g_param_spec_string ("location", "File Location", - "Location of the file to read", - NULL, flags); + "Location of the file to read", NULL, flags); - } - else if (prop_id == offset_id) { + } else if (prop_id == offset_id) { pspec = g_param_spec_int64 ("offset", "File Offset", - "Byte offset of current read pointer", - 0, G_MAXINT64, 0, flags); + "Byte offset of current read pointer", 0, G_MAXINT64, 0, flags); - } - else if (prop_id == silent_id) { + } else if (prop_id == silent_id) { pspec = g_param_spec_boolean ("silent", "Silent", "Don't produce events", - FALSE, flags); + FALSE, flags); - } - else if (prop_id == touch_id) { + } else if (prop_id == touch_id) { pspec = g_param_spec_boolean ("touch", "Touch read data", - "Touch data to force disk read before " - "push ()", TRUE, flags); - } - else { + "Touch data to force disk read before " "push ()", TRUE, flags); + } else { g_warning ("Unknown - 'standard' property '%s' id %d from klass %s", - prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass))); + prop_name, arg_id, g_type_name (G_OBJECT_CLASS_TYPE (klass))); pspec = NULL; } @@ -3466,8 +3499,8 @@ gst_element_populate_std_props (GObjectClass * klass, const gchar *prop_name, * the flags determine readability / writeability. **/ void -gst_element_class_install_std_props (GstElementClass * klass, - const gchar *first_name, ...) +gst_element_class_install_std_props (GstElementClass * klass, + const gchar * first_name, ...) { const char *name; @@ -3483,7 +3516,8 @@ gst_element_class_install_std_props (GstElementClass * klass, int arg_id = va_arg (args, int); int flags = va_arg (args, int); - gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id, flags); + gst_element_populate_std_props ((GObjectClass *) klass, name, arg_id, + flags); name = va_arg (args, char *); } @@ -3499,8 +3533,8 @@ gst_element_class_install_std_props (GstElementClass * klass, * * Returns: the #GstBin, or NULL on failure. **/ -GstBin* -gst_element_get_managing_bin (GstElement *element) +GstBin * +gst_element_get_managing_bin (GstElement * element) { GstBin *bin; @@ -3510,6 +3544,6 @@ gst_element_get_managing_bin (GstElement *element) while (bin && !GST_FLAG_IS_SET (GST_OBJECT (bin), GST_BIN_FLAG_MANAGER)) bin = GST_BIN (gst_object_get_parent (GST_OBJECT (bin))); - + return bin; } diff --git a/gst/gstelement.h b/gst/gstelement.h index dc5ecd01b..d424a8b54 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -34,19 +34,19 @@ #include #include -G_BEGIN_DECLS - -typedef struct _GstElementDetails GstElementDetails; +G_BEGIN_DECLS typedef struct _GstElementDetails GstElementDetails; /* FIXME: need translatable stuff in here (how handle in registry)? */ -struct _GstElementDetails { - gchar *longname; /* long, english name */ - gchar *klass; /* type of element, as hierarchy */ - gchar *description; /* insights of one form or another */ - gchar *author; /* who wrote this thing? */ +struct _GstElementDetails +{ + gchar *longname; /* long, english name */ + gchar *klass; /* type of element, as hierarchy */ + gchar *description; /* insights of one form or another */ + gchar *author; /* who wrote this thing? */ gpointer _gst_reserved[GST_PADDING]; }; + #define GST_ELEMENT_DETAILS(longname,klass,description,author) \ { longname, klass, description, author, GST_PADDING_INIT } #define GST_IS_ELEMENT_DETAILS(details) ( \ @@ -98,9 +98,10 @@ extern GType _gst_element_type; #endif #endif -typedef enum { +typedef enum +{ /* element is complex (for some def.) and generally require a cothread */ - GST_ELEMENT_COMPLEX = GST_OBJECT_FLAG_LAST, + GST_ELEMENT_COMPLEX = GST_OBJECT_FLAG_LAST, /* input and output pads aren't directly coupled to each other examples: queues, multi-output async readers, etc. */ GST_ELEMENT_DECOUPLED, @@ -127,7 +128,7 @@ typedef enum { GST_ELEMENT_IN_ERROR, /* use some padding for future expansion */ - GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16 + GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16 } GstElementFlags; #define GST_ELEMENT_IS_THREAD_SUGGESTED(obj) (GST_FLAG_IS_SET(obj,GST_ELEMENT_THREAD_SUGGESTED)) @@ -154,113 +155,124 @@ typedef enum { typedef struct _GstElementFactory GstElementFactory; typedef struct _GstElementFactoryClass GstElementFactoryClass; -typedef void (*GstElementLoopFunction) (GstElement *element); -typedef void (*GstElementPreRunFunction) (GstElement *element); -typedef void (*GstElementPostRunFunction) (GstElement *element); +typedef void (*GstElementLoopFunction) (GstElement * element); +typedef void (*GstElementPreRunFunction) (GstElement * element); +typedef void (*GstElementPostRunFunction) (GstElement * element); -struct _GstElement { - GstObject object; +struct _GstElement +{ + GstObject object; /* element state and scheduling */ - guint8 current_state; - guint8 pending_state; + guint8 current_state; + guint8 pending_state; GstElementLoopFunction loopfunc; - GstScheduler *sched; - gpointer sched_private; + GstScheduler *sched; + gpointer sched_private; /* allocated clock */ - GstClock *clock; - GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */ + GstClock *clock; + GstClockTimeDiff base_time; /* NULL/READY: 0 - PAUSED: current time - PLAYING: difference to clock */ /* element pads */ - guint16 numpads; - guint16 numsrcpads; - guint16 numsinkpads; - GList *pads; + guint16 numpads; + guint16 numsrcpads; + guint16 numsinkpads; + GList *pads; - GMutex *state_mutex; - GCond *state_cond; + GMutex *state_mutex; + GCond *state_cond; - GstElementPreRunFunction pre_run_func; + GstElementPreRunFunction pre_run_func; GstElementPostRunFunction post_run_func; - GAsyncQueue *prop_value_queue; - GMutex *property_mutex; + GAsyncQueue *prop_value_queue; + GMutex *property_mutex; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstElementClass { - GstObjectClass parent_class; +struct _GstElementClass +{ + GstObjectClass parent_class; /* the element details */ - GstElementDetails details; + GstElementDetails details; /* factory that the element was created from */ - GstElementFactory *elementfactory; + GstElementFactory *elementfactory; /* templates for our pads */ - GList *padtemplates; - gint numpadtemplates; - + GList *padtemplates; + gint numpadtemplates; + /* signal callbacks */ - void (*state_change) (GstElement *element, GstElementState old, GstElementState state); - void (*new_pad) (GstElement *element, GstPad *pad); - void (*pad_removed) (GstElement *element, GstPad *pad); - void (*error) (GstElement *element, GstElement *source, GError *error, gchar *debug); - void (*eos) (GstElement *element); - void (*found_tag) (GstElement *element, GstElement *source, const GstTagList *tag_list); + void (*state_change) (GstElement * element, GstElementState old, + GstElementState state); + void (*new_pad) (GstElement * element, GstPad * pad); + void (*pad_removed) (GstElement * element, GstPad * pad); + void (*error) (GstElement * element, GstElement * source, GError * error, + gchar * debug); + void (*eos) (GstElement * element); + void (*found_tag) (GstElement * element, GstElement * source, + const GstTagList * tag_list); /* local pointers for get/set */ - void (*set_property) (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); - void (*get_property) (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); + void (*set_property) (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec); + void (*get_property) (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec); - /* vtable*/ - gboolean (*release_locks) (GstElement *element); + /* vtable */ + gboolean (*release_locks) (GstElement * element); /* query/convert/events functions */ - const GstEventMask* (*get_event_masks) (GstElement *element); - gboolean (*send_event) (GstElement *element, GstEvent *event); - const GstFormat* (*get_formats) (GstElement *element); - gboolean (*convert) (GstElement *element, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); - const GstQueryType* (*get_query_types) (GstElement *element); - gboolean (*query) (GstElement *element, GstQueryType type, - GstFormat *format, gint64 *value); + const GstEventMask *(*get_event_masks) (GstElement * element); + gboolean (*send_event) (GstElement * element, GstEvent * event); + const GstFormat *(*get_formats) (GstElement * element); + gboolean (*convert) (GstElement * element, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value); + const GstQueryType *(*get_query_types) (GstElement * element); + gboolean (*query) (GstElement * element, GstQueryType type, + GstFormat * format, gint64 * value); /* change the element state */ - GstElementStateReturn (*change_state) (GstElement *element); + GstElementStateReturn (*change_state) (GstElement * element); /* request/release pads */ - GstPad* (*request_new_pad) (GstElement *element, GstPadTemplate *templ, const gchar* name); - void (*release_pad) (GstElement *element, GstPad *pad); + GstPad *(*request_new_pad) (GstElement * element, GstPadTemplate * templ, + const gchar * name); + void (*release_pad) (GstElement * element, GstPad * pad); /* set/get clocks */ - GstClock* (*get_clock) (GstElement *element); - void (*set_clock) (GstElement *element, GstClock *clock); + GstClock *(*get_clock) (GstElement * element); + void (*set_clock) (GstElement * element, GstClock * clock); /* index */ - GstIndex* (*get_index) (GstElement *element); - void (*set_index) (GstElement *element, GstIndex *index); + GstIndex *(*get_index) (GstElement * element); + void (*set_index) (GstElement * element, GstIndex * index); - GstElementStateReturn (*set_state) (GstElement *element, GstElementState state); + GstElementStateReturn (*set_state) (GstElement * element, + GstElementState state); gpointer _gst_reserved[GST_PADDING]; }; -void gst_element_class_add_pad_template (GstElementClass *klass, GstPadTemplate *templ); -void gst_element_class_install_std_props (GstElementClass *klass, - const gchar *first_name, ...); -void gst_element_class_set_details (GstElementClass *klass, - const GstElementDetails *details); +void gst_element_class_add_pad_template (GstElementClass * klass, + GstPadTemplate * templ); +void gst_element_class_install_std_props (GstElementClass * klass, + const gchar * first_name, ...); +void gst_element_class_set_details (GstElementClass * klass, + const GstElementDetails * details); #define gst_element_default_deep_notify gst_object_default_deep_notify -void gst_element_default_error (GObject *object, GstObject *orig, GError *error, gchar *debug); +void gst_element_default_error (GObject * object, GstObject * orig, + GError * error, gchar * debug); -GType gst_element_get_type (void); -void gst_element_set_loop_function (GstElement *element, - GstElementLoopFunction loop); +GType gst_element_get_type (void); +void gst_element_set_loop_function (GstElement * element, + GstElementLoopFunction loop); #define gst_element_get_name(elem) gst_object_get_name(GST_OBJECT(elem)) #define gst_element_set_name(elem,name) gst_object_set_name(GST_OBJECT(elem),name) @@ -268,125 +280,129 @@ void gst_element_set_loop_function (GstElement *element, #define gst_element_set_parent(elem,parent) gst_object_set_parent(GST_OBJECT(elem),parent) /* threadsafe versions of their g_object_* counterparts */ -void gst_element_set (GstElement *element, const gchar *first_property_name, ...); -void gst_element_get (GstElement *element, const gchar *first_property_name, ...); -void gst_element_set_valist (GstElement *element, const gchar *first_property_name, - va_list var_args); -void gst_element_get_valist (GstElement *element, const gchar *first_property_name, - va_list var_args); -void gst_element_set_property (GstElement *element, const gchar *property_name, - const GValue *value); -void gst_element_get_property (GstElement *element, const gchar *property_name, - GValue *value); - -void gst_element_enable_threadsafe_properties (GstElement *element); -void gst_element_disable_threadsafe_properties (GstElement *element); -void gst_element_set_pending_properties (GstElement *element); +void gst_element_set (GstElement * element, const gchar * first_property_name, + ...); +void gst_element_get (GstElement * element, const gchar * first_property_name, + ...); +void gst_element_set_valist (GstElement * element, + const gchar * first_property_name, va_list var_args); +void gst_element_get_valist (GstElement * element, + const gchar * first_property_name, va_list var_args); +void gst_element_set_property (GstElement * element, + const gchar * property_name, const GValue * value); +void gst_element_get_property (GstElement * element, + const gchar * property_name, GValue * value); + +void gst_element_enable_threadsafe_properties (GstElement * element); +void gst_element_disable_threadsafe_properties (GstElement * element); +void gst_element_set_pending_properties (GstElement * element); /* clocking */ -gboolean gst_element_requires_clock (GstElement *element); -gboolean gst_element_provides_clock (GstElement *element); -GstClock* gst_element_get_clock (GstElement *element); -void gst_element_set_clock (GstElement *element, GstClock *clock); -GstClockReturn gst_element_clock_wait (GstElement *element, - GstClockID id, GstClockTimeDiff *jitter); -GstClockTime gst_element_get_time (GstElement *element); -gboolean gst_element_wait (GstElement *element, GstClockTime timestamp); -void gst_element_set_time (GstElement *element, GstClockTime time); -void gst_element_adjust_time (GstElement *element, GstClockTimeDiff diff); - +gboolean gst_element_requires_clock (GstElement * element); +gboolean gst_element_provides_clock (GstElement * element); +GstClock *gst_element_get_clock (GstElement * element); +void gst_element_set_clock (GstElement * element, GstClock * clock); +GstClockReturn gst_element_clock_wait (GstElement * element, + GstClockID id, GstClockTimeDiff * jitter); +GstClockTime gst_element_get_time (GstElement * element); +gboolean gst_element_wait (GstElement * element, GstClockTime timestamp); +void gst_element_set_time (GstElement * element, GstClockTime time); +void gst_element_adjust_time (GstElement * element, GstClockTimeDiff diff); + /* indexs */ -gboolean gst_element_is_indexable (GstElement *element); -void gst_element_set_index (GstElement *element, GstIndex *index); -GstIndex* gst_element_get_index (GstElement *element); - - -gboolean gst_element_release_locks (GstElement *element); - -void gst_element_yield (GstElement *element); -gboolean gst_element_interrupt (GstElement *element); -void gst_element_set_scheduler (GstElement *element, GstScheduler *sched); -GstScheduler* gst_element_get_scheduler (GstElement *element); - -void gst_element_add_pad (GstElement *element, GstPad *pad); -void gst_element_remove_pad (GstElement *element, GstPad *pad); -GstPad * gst_element_add_ghost_pad (GstElement *element, GstPad *pad, const gchar *name); -void gst_element_remove_ghost_pad (GstElement *element, GstPad *pad); - -GstPad* gst_element_get_pad (GstElement *element, const gchar *name); -GstPad* gst_element_get_static_pad (GstElement *element, const gchar *name); -GstPad* gst_element_get_request_pad (GstElement *element, const gchar *name); -void gst_element_release_request_pad (GstElement *element, GstPad *pad); - -G_CONST_RETURN GList* - gst_element_get_pad_list (GstElement *element); -GstPad* gst_element_get_compatible_pad (GstElement *element, GstPad *pad); -GstPad* gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, - const GstCaps *filtercaps); - -GstPadTemplate* gst_element_class_get_pad_template (GstElementClass *element_class, const gchar *name); -GList* gst_element_class_get_pad_template_list (GstElementClass *element_class); -GstPadTemplate* gst_element_get_pad_template (GstElement *element, const gchar *name); -GList* gst_element_get_pad_template_list (GstElement *element); -GstPadTemplate* gst_element_get_compatible_pad_template (GstElement *element, GstPadTemplate *compattempl); - -gboolean gst_element_link (GstElement *src, GstElement *dest); -gboolean gst_element_link_many (GstElement *element_1, - GstElement *element_2, ...); -gboolean gst_element_link_filtered (GstElement *src, GstElement *dest, - const GstCaps *filtercaps); -void gst_element_unlink (GstElement *src, GstElement *dest); -void gst_element_unlink_many (GstElement *element_1, - GstElement *element_2, ...); - -gboolean gst_element_link_pads (GstElement *src, const gchar *srcpadname, - GstElement *dest, const gchar *destpadname); -gboolean gst_element_link_pads_filtered (GstElement *src, const gchar *srcpadname, - GstElement *dest, const gchar *destpadname, - const GstCaps *filtercaps); -void gst_element_unlink_pads (GstElement *src, const gchar *srcpadname, - GstElement *dest, const gchar *destpadname); - -G_CONST_RETURN GstEventMask* - gst_element_get_event_masks (GstElement *element); -gboolean gst_element_send_event (GstElement *element, GstEvent *event); -gboolean gst_element_seek (GstElement *element, GstSeekType seek_type, - guint64 offset); -G_CONST_RETURN GstQueryType* - gst_element_get_query_types (GstElement *element); -gboolean gst_element_query (GstElement *element, GstQueryType type, - GstFormat *format, gint64 *value); -G_CONST_RETURN GstFormat* - gst_element_get_formats (GstElement *element); -gboolean gst_element_convert (GstElement *element, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); - -void gst_element_found_tags (GstElement *element, const GstTagList *tag_list); -void gst_element_found_tags_for_pad (GstElement *element, GstPad *pad, GstClockTime timestamp, - GstTagList *list); - -void gst_element_set_eos (GstElement *element); - -gchar * _gst_element_error_printf (const gchar *format, ...); -void gst_element_error_full (GstElement *element, GQuark domain, gint code, - gchar *message, gchar *debug, - const gchar *file, const gchar *function, gint line); - -gboolean gst_element_is_locked_state (GstElement *element); -void gst_element_set_locked_state (GstElement *element, gboolean locked_state); -gboolean gst_element_sync_state_with_parent (GstElement *element); - -GstElementState gst_element_get_state (GstElement *element); -GstElementStateReturn gst_element_set_state (GstElement *element, GstElementState state); - -void gst_element_wait_state_change (GstElement *element); - -G_CONST_RETURN gchar* gst_element_state_get_name (GstElementState state); - -GstElementFactory* gst_element_get_factory (GstElement *element); - -GstBin* gst_element_get_managing_bin (GstElement *element); +gboolean gst_element_is_indexable (GstElement * element); +void gst_element_set_index (GstElement * element, GstIndex * index); +GstIndex *gst_element_get_index (GstElement * element); + + +gboolean gst_element_release_locks (GstElement * element); + +void gst_element_yield (GstElement * element); +gboolean gst_element_interrupt (GstElement * element); +void gst_element_set_scheduler (GstElement * element, GstScheduler * sched); +GstScheduler *gst_element_get_scheduler (GstElement * element); + +void gst_element_add_pad (GstElement * element, GstPad * pad); +void gst_element_remove_pad (GstElement * element, GstPad * pad); +GstPad *gst_element_add_ghost_pad (GstElement * element, GstPad * pad, + const gchar * name); +void gst_element_remove_ghost_pad (GstElement * element, GstPad * pad); + +GstPad *gst_element_get_pad (GstElement * element, const gchar * name); +GstPad *gst_element_get_static_pad (GstElement * element, const gchar * name); +GstPad *gst_element_get_request_pad (GstElement * element, const gchar * name); +void gst_element_release_request_pad (GstElement * element, GstPad * pad); + +G_CONST_RETURN GList *gst_element_get_pad_list (GstElement * element); +GstPad *gst_element_get_compatible_pad (GstElement * element, GstPad * pad); +GstPad *gst_element_get_compatible_pad_filtered (GstElement * element, + GstPad * pad, const GstCaps * filtercaps); + +GstPadTemplate *gst_element_class_get_pad_template (GstElementClass * + element_class, const gchar * name); +GList *gst_element_class_get_pad_template_list (GstElementClass * + element_class); +GstPadTemplate *gst_element_get_pad_template (GstElement * element, + const gchar * name); +GList *gst_element_get_pad_template_list (GstElement * element); +GstPadTemplate *gst_element_get_compatible_pad_template (GstElement * element, + GstPadTemplate * compattempl); + +gboolean gst_element_link (GstElement * src, GstElement * dest); +gboolean gst_element_link_many (GstElement * element_1, + GstElement * element_2, ...); +gboolean gst_element_link_filtered (GstElement * src, GstElement * dest, + const GstCaps * filtercaps); +void gst_element_unlink (GstElement * src, GstElement * dest); +void gst_element_unlink_many (GstElement * element_1, + GstElement * element_2, ...); + +gboolean gst_element_link_pads (GstElement * src, const gchar * srcpadname, + GstElement * dest, const gchar * destpadname); +gboolean gst_element_link_pads_filtered (GstElement * src, + const gchar * srcpadname, GstElement * dest, const gchar * destpadname, + const GstCaps * filtercaps); +void gst_element_unlink_pads (GstElement * src, const gchar * srcpadname, + GstElement * dest, const gchar * destpadname); + +G_CONST_RETURN GstEventMask *gst_element_get_event_masks (GstElement * element); +gboolean gst_element_send_event (GstElement * element, GstEvent * event); +gboolean gst_element_seek (GstElement * element, GstSeekType seek_type, + guint64 offset); +G_CONST_RETURN GstQueryType *gst_element_get_query_types (GstElement * element); +gboolean gst_element_query (GstElement * element, GstQueryType type, + GstFormat * format, gint64 * value); +G_CONST_RETURN GstFormat *gst_element_get_formats (GstElement * element); +gboolean gst_element_convert (GstElement * element, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value); + +void gst_element_found_tags (GstElement * element, const GstTagList * tag_list); +void gst_element_found_tags_for_pad (GstElement * element, GstPad * pad, + GstClockTime timestamp, GstTagList * list); + +void gst_element_set_eos (GstElement * element); + +gchar *_gst_element_error_printf (const gchar * format, ...); +void gst_element_error_full (GstElement * element, GQuark domain, gint code, + gchar * message, gchar * debug, + const gchar * file, const gchar * function, gint line); + +gboolean gst_element_is_locked_state (GstElement * element); +void gst_element_set_locked_state (GstElement * element, gboolean locked_state); +gboolean gst_element_sync_state_with_parent (GstElement * element); + +GstElementState gst_element_get_state (GstElement * element); +GstElementStateReturn gst_element_set_state (GstElement * element, + GstElementState state); + +void gst_element_wait_state_change (GstElement * element); + +G_CONST_RETURN gchar *gst_element_state_get_name (GstElementState state); + +GstElementFactory *gst_element_get_factory (GstElement * element); + +GstBin *gst_element_get_managing_bin (GstElement * element); /* @@ -403,66 +419,69 @@ GstBin* gst_element_get_managing_bin (GstElement *element); #define GST_IS_ELEMENT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ELEMENT_FACTORY)) #define GST_IS_ELEMENT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ELEMENT_FACTORY)) -struct _GstElementFactory { - GstPluginFeature parent; +struct _GstElementFactory +{ + GstPluginFeature parent; - GType type; /* unique GType of element or 0 if not loaded */ + GType type; /* unique GType of element or 0 if not loaded */ - GstElementDetails details; + GstElementDetails details; - GList * padtemplates; - guint numpadtemplates; + GList *padtemplates; + guint numpadtemplates; /* URI interface stuff */ - guint uri_type; - gchar ** uri_protocols; - - GList * interfaces; /* interfaces this element implements */ + guint uri_type; + gchar **uri_protocols; + + GList *interfaces; /* interfaces this element implements */ gpointer _gst_reserved[GST_PADDING]; }; -struct _GstElementFactoryClass { +struct _GstElementFactoryClass +{ GstPluginFeatureClass parent_class; gpointer _gst_reserved[GST_PADDING]; }; -GType gst_element_factory_get_type (void); - -gboolean gst_element_register (GstPlugin *plugin, - const gchar *elementname, - guint rank, - GType type); - -GstElementFactory * gst_element_factory_find (const gchar *name); -GType gst_element_factory_get_element_type (GstElementFactory *factory); -G_CONST_RETURN gchar * gst_element_factory_get_longname (GstElementFactory *factory); -G_CONST_RETURN gchar * gst_element_factory_get_klass (GstElementFactory *factory); -G_CONST_RETURN gchar * gst_element_factory_get_description (GstElementFactory *factory); -G_CONST_RETURN gchar * gst_element_factory_get_author (GstElementFactory *factory); -guint gst_element_factory_get_num_pad_templates (GstElementFactory *factory); -G_CONST_RETURN GList * gst_element_factory_get_pad_templates (GstElementFactory *factory); -guint gst_element_factory_get_uri_type (GstElementFactory *factory); -gchar ** gst_element_factory_get_uri_protocols (GstElementFactory *factory); - -GstElement* gst_element_factory_create (GstElementFactory *factory, - const gchar *name); -GstElement* gst_element_factory_make (const gchar *factoryname, const gchar *name); - -gboolean gst_element_factory_can_src_caps (GstElementFactory *factory, - const GstCaps *caps); -gboolean gst_element_factory_can_sink_caps (GstElementFactory *factory, - const GstCaps *caps); - -void __gst_element_factory_add_pad_template (GstElementFactory *elementfactory, - GstPadTemplate *templ); -void __gst_element_factory_add_interface (GstElementFactory *elementfactory, - const gchar *interfacename); +GType gst_element_factory_get_type (void); + +gboolean gst_element_register (GstPlugin * plugin, + const gchar * elementname, guint rank, GType type); + +GstElementFactory *gst_element_factory_find (const gchar * name); +GType gst_element_factory_get_element_type (GstElementFactory * factory); +G_CONST_RETURN gchar *gst_element_factory_get_longname (GstElementFactory * + factory); +G_CONST_RETURN gchar *gst_element_factory_get_klass (GstElementFactory * + factory); +G_CONST_RETURN gchar *gst_element_factory_get_description (GstElementFactory * + factory); +G_CONST_RETURN gchar *gst_element_factory_get_author (GstElementFactory * + factory); +guint gst_element_factory_get_num_pad_templates (GstElementFactory * factory); +G_CONST_RETURN GList *gst_element_factory_get_pad_templates (GstElementFactory * + factory); +guint gst_element_factory_get_uri_type (GstElementFactory * factory); +gchar **gst_element_factory_get_uri_protocols (GstElementFactory * factory); + +GstElement *gst_element_factory_create (GstElementFactory * factory, + const gchar * name); +GstElement *gst_element_factory_make (const gchar * factoryname, + const gchar * name); + +gboolean gst_element_factory_can_src_caps (GstElementFactory * factory, + const GstCaps * caps); +gboolean gst_element_factory_can_sink_caps (GstElementFactory * factory, + const GstCaps * caps); + +void __gst_element_factory_add_pad_template (GstElementFactory * elementfactory, + GstPadTemplate * templ); +void __gst_element_factory_add_interface (GstElementFactory * elementfactory, + const gchar * interfacename); G_END_DECLS - - #endif /* __GST_ELEMENT_H__ */ - diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index c0856764c..508c450cd 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -31,16 +31,17 @@ GST_DEBUG_CATEGORY_STATIC (element_factory_debug); #define GST_CAT_DEFAULT element_factory_debug -static void gst_element_factory_class_init (GstElementFactoryClass *klass); -static void gst_element_factory_init (GstElementFactory *factory); +static void gst_element_factory_class_init (GstElementFactoryClass * klass); +static void gst_element_factory_init (GstElementFactory * factory); -static void gst_element_factory_unload_thyself (GstPluginFeature *feature); +static void gst_element_factory_unload_thyself (GstPluginFeature * feature); static GstPluginFeatureClass *parent_class = NULL; + /* static guint gst_element_factory_signals[LAST_SIGNAL] = { 0 }; */ -GType -gst_element_factory_get_type (void) +GType +gst_element_factory_get_type (void) { static GType elementfactory_type = 0; @@ -52,36 +53,37 @@ gst_element_factory_get_type (void) (GClassInitFunc) gst_element_factory_class_init, NULL, NULL, - sizeof(GstElementFactory), + sizeof (GstElementFactory), 0, (GInstanceInitFunc) gst_element_factory_init, NULL }; - elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstElementFactory", &elementfactory_info, 0); - GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - "element factories keep information about installed elements"); + elementfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, + "GstElementFactory", &elementfactory_info, 0); + GST_DEBUG_CATEGORY_INIT (element_factory_debug, "GST_ELEMENT_FACTORY", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, + "element factories keep information about installed elements"); } return elementfactory_type; } static void -gst_element_factory_class_init (GstElementFactoryClass *klass) +gst_element_factory_class_init (GstElementFactoryClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; GstPluginFeatureClass *gstpluginfeature_class; - gobject_class = (GObjectClass*)klass; - gstobject_class = (GstObjectClass*)klass; - gstpluginfeature_class = (GstPluginFeatureClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstpluginfeature_class = (GstPluginFeatureClass *) klass; parent_class = g_type_class_peek_parent (klass); - gstpluginfeature_class->unload_thyself = GST_DEBUG_FUNCPTR (gst_element_factory_unload_thyself); + gstpluginfeature_class->unload_thyself = + GST_DEBUG_FUNCPTR (gst_element_factory_unload_thyself); } static void -gst_element_factory_init (GstElementFactory *factory) +gst_element_factory_init (GstElementFactory * factory) { factory->padtemplates = NULL; factory->numpadtemplates = 0; @@ -91,6 +93,7 @@ gst_element_factory_init (GstElementFactory *factory) factory->interfaces = NULL; } + /** * gst_element_factory_find: * @name: name of factory to find @@ -99,12 +102,12 @@ gst_element_factory_init (GstElementFactory *factory) * * Returns: #GstElementFactory if found, NULL otherwise */ -GstElementFactory* -gst_element_factory_find (const gchar *name) +GstElementFactory * +gst_element_factory_find (const gchar * name) { GstPluginFeature *feature; - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); feature = gst_registry_pool_find_feature (name, GST_TYPE_ELEMENT_FACTORY); if (feature) @@ -117,7 +120,7 @@ gst_element_factory_find (const gchar *name) } void -__gst_element_details_clear (GstElementDetails *dp) +__gst_element_details_clear (GstElementDetails * dp) { g_free (dp->longname); dp->longname = NULL; @@ -128,22 +131,26 @@ __gst_element_details_clear (GstElementDetails *dp) g_free (dp->author); dp->author = NULL; } + void -__gst_element_details_set (GstElementDetails *dest, const GstElementDetails *src) +__gst_element_details_set (GstElementDetails * dest, + const GstElementDetails * src) { dest->longname = g_strdup (src->longname); dest->klass = g_strdup (src->klass); dest->description = g_strdup (src->description); dest->author = g_strdup (src->author); } + void -__gst_element_details_copy (GstElementDetails *dest, const GstElementDetails *src) +__gst_element_details_copy (GstElementDetails * dest, + const GstElementDetails * src) { __gst_element_details_clear (dest); __gst_element_details_set (dest, src); } static void -gst_element_factory_cleanup (GstElementFactory *factory) +gst_element_factory_cleanup (GstElementFactory * factory) { __gst_element_details_clear (&factory->details); if (factory->type) { @@ -160,11 +167,12 @@ gst_element_factory_cleanup (GstElementFactory *factory) g_strfreev (factory->uri_protocols); factory->uri_protocols = NULL; } - + g_list_foreach (factory->interfaces, (GFunc) g_free, NULL); g_list_free (factory->interfaces); factory->interfaces = NULL; } + /** * gst_element_register: * @plugin: @@ -178,7 +186,8 @@ gst_element_factory_cleanup (GstElementFactory *factory) * Returns: TRUE, if the registering succeeded, FALSE on error */ gboolean -gst_element_register (GstPlugin *plugin, const gchar *name, guint rank, GType type) +gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, + GType type) { GstElementFactory *factory; GType *interfaces; @@ -192,14 +201,17 @@ gst_element_register (GstPlugin *plugin, const gchar *name, guint rank, GType ty if (!factory) { klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); - factory = GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL)); + factory = + GST_ELEMENT_FACTORY (g_object_new (GST_TYPE_ELEMENT_FACTORY, NULL)); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); - GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", g_type_name (type)); + GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", + g_type_name (type)); } else { g_return_val_if_fail (factory->type == 0, FALSE); klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); gst_element_factory_cleanup (factory); - GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s", g_type_name (type)); + GST_LOG_OBJECT (factory, "Reuse existing elementfactory for type %s", + g_type_name (type)); } factory->type = type; @@ -210,8 +222,9 @@ gst_element_register (GstPlugin *plugin, const gchar *name, guint rank, GType ty /* special stuff for URI handling */ if (g_type_is_a (type, GST_TYPE_URI_HANDLER)) { - GstURIHandlerInterface *iface = (GstURIHandlerInterface *) - g_type_interface_peek (klass, GST_TYPE_URI_HANDLER); + GstURIHandlerInterface *iface = (GstURIHandlerInterface *) + g_type_interface_peek (klass, GST_TYPE_URI_HANDLER); + if (!iface || !iface->get_type || !iface->get_protocols) goto error; factory->uri_type = iface->get_type (); @@ -227,7 +240,7 @@ gst_element_register (GstPlugin *plugin, const gchar *name, guint rank, GType ty __gst_element_factory_add_interface (factory, g_type_name (interfaces[i])); } g_free (interfaces); - + gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); @@ -237,6 +250,7 @@ error: gst_element_factory_cleanup (factory); return FALSE; } + /** * gst_element_factory_create: * @factory: factory to instantiate @@ -248,9 +262,8 @@ error: * * Returns: new #GstElement or NULL if the element couldn't be created */ -GstElement* -gst_element_factory_create (GstElementFactory *factory, - const gchar *name) +GstElement * +gst_element_factory_create (GstElementFactory * factory, const gchar * name) { GstElement *element; GstElementClass *oclass; @@ -264,17 +277,17 @@ gst_element_factory_create (GstElementFactory *factory, if (name) GST_INFO ("creating \"%s\" named \"%s\"", GST_PLUGIN_FEATURE_NAME (factory), - GST_STR_NULL (name)); + GST_STR_NULL (name)); else GST_INFO ("creating \"%s\"", GST_PLUGIN_FEATURE_NAME (factory)); if (factory->type == 0) { - g_critical ("Factory for `%s' has no type", - GST_PLUGIN_FEATURE_NAME (factory)); - return NULL; + g_critical ("Factory for `%s' has no type", + GST_PLUGIN_FEATURE_NAME (factory)); + return NULL; } - oclass = GST_ELEMENT_CLASS (g_type_class_ref (factory->type)); + oclass = GST_ELEMENT_CLASS (g_type_class_ref (factory->type)); if (oclass->elementfactory == NULL) oclass->elementfactory = factory; @@ -288,6 +301,7 @@ gst_element_factory_create (GstElementFactory *factory, return element; } + /** * gst_element_factory_make: * @factoryname: a named factory to instantiate @@ -300,22 +314,21 @@ gst_element_factory_create (GstElementFactory *factory, * * Returns: new #GstElement or NULL if unable to create element */ -GstElement* -gst_element_factory_make (const gchar *factoryname, const gchar *name) +GstElement * +gst_element_factory_make (const gchar * factoryname, const gchar * name) { GstElementFactory *factory; GstElement *element; g_return_val_if_fail (factoryname != NULL, NULL); - GST_LOG ("gstelementfactory: make \"%s\" \"%s\"", - factoryname, GST_STR_NULL (name)); + GST_LOG ("gstelementfactory: make \"%s\" \"%s\"", + factoryname, GST_STR_NULL (name)); /* gst_plugin_load_element_factory (factoryname); */ factory = gst_element_factory_find (factoryname); if (factory == NULL) { - GST_INFO ("no such element factory \"%s\"!", - factoryname); + GST_INFO ("no such element factory \"%s\"!", factoryname); return NULL; } element = gst_element_factory_create (factory, name); @@ -326,9 +339,10 @@ gst_element_factory_make (const gchar *factoryname, const gchar *name) return element; } + void -__gst_element_factory_add_pad_template (GstElementFactory *factory, - GstPadTemplate *templ) +__gst_element_factory_add_pad_template (GstElementFactory * factory, + GstPadTemplate * templ) { g_return_if_fail (factory != NULL); g_return_if_fail (templ != NULL); @@ -339,6 +353,7 @@ __gst_element_factory_add_pad_template (GstElementFactory *factory, factory->padtemplates = g_list_append (factory->padtemplates, templ); factory->numpadtemplates++; } + /** * gst_element_factory_get_element_type: * @factory: factory to get managed #GType from @@ -348,12 +363,13 @@ __gst_element_factory_add_pad_template (GstElementFactory *factory, * Returns: the #GType for elements managed by this factory */ GType -gst_element_factory_get_element_type (GstElementFactory *factory) +gst_element_factory_get_element_type (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0); return factory->type; } + /** * gst_element_factory_get_longname: * @factory: a #GstElementFactory @@ -363,12 +379,13 @@ gst_element_factory_get_element_type (GstElementFactory *factory) * Returns: the longname */ G_CONST_RETURN gchar * -gst_element_factory_get_longname (GstElementFactory *factory) +gst_element_factory_get_longname (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); return factory->details.longname; } + /** * gst_element_factory_get_class: * @factory: a #GstElementFactory @@ -378,12 +395,13 @@ gst_element_factory_get_longname (GstElementFactory *factory) * Returns: the class */ G_CONST_RETURN gchar * -gst_element_factory_get_klass (GstElementFactory *factory) +gst_element_factory_get_klass (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); return factory->details.klass; } + /** * gst_element_factory_get_description: * @factory: a #GstElementFactory @@ -393,12 +411,13 @@ gst_element_factory_get_klass (GstElementFactory *factory) * Returns: the description */ G_CONST_RETURN gchar * -gst_element_factory_get_description (GstElementFactory *factory) +gst_element_factory_get_description (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); return factory->details.description; } + /** * gst_element_factory_get_author: * @factory: a #GstElementFactory @@ -408,12 +427,13 @@ gst_element_factory_get_description (GstElementFactory *factory) * Returns: the author */ G_CONST_RETURN gchar * -gst_element_factory_get_author (GstElementFactory *factory) +gst_element_factory_get_author (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); return factory->details.author; } + /** * gst_element_factory_get_num_pad_templates: * @factory: a #GstElementFactory @@ -423,12 +443,13 @@ gst_element_factory_get_author (GstElementFactory *factory) * Returns: the number of pad_templates */ guint -gst_element_factory_get_num_pad_templates (GstElementFactory *factory) +gst_element_factory_get_num_pad_templates (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), 0); return factory->numpadtemplates; } + /** * __gst_element_factory_add_interface: * @elementfactory: The elementfactory to add the interface to @@ -438,14 +459,17 @@ gst_element_factory_get_num_pad_templates (GstElementFactory *factory) * element. */ void -__gst_element_factory_add_interface (GstElementFactory *elementfactory, const gchar *interfacename) +__gst_element_factory_add_interface (GstElementFactory * elementfactory, + const gchar * interfacename) { g_return_if_fail (GST_IS_ELEMENT_FACTORY (elementfactory)); g_return_if_fail (interfacename != NULL); - g_return_if_fail (interfacename[0] != '\0'); /* no empty string */ - - elementfactory->interfaces = g_list_prepend (elementfactory->interfaces, g_strdup (interfacename)); + g_return_if_fail (interfacename[0] != '\0'); /* no empty string */ + + elementfactory->interfaces = + g_list_prepend (elementfactory->interfaces, g_strdup (interfacename)); } + /** * gst_element_factory_get_pad_templates: * @factory: a #GstElementFactory @@ -455,12 +479,13 @@ __gst_element_factory_add_interface (GstElementFactory *elementfactory, const gc * Returns: the padtemplates */ G_CONST_RETURN GList * -gst_element_factory_get_pad_templates (GstElementFactory *factory) +gst_element_factory_get_pad_templates (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); return factory->padtemplates; } + /** * gst_element_factory_get_uri_type: * @factory: a #GstElementFactory @@ -470,12 +495,13 @@ gst_element_factory_get_pad_templates (GstElementFactory *factory) * Returns: type of URIs this element supports */ guint -gst_element_factory_get_uri_type (GstElementFactory *factory) +gst_element_factory_get_uri_type (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), GST_URI_UNKNOWN); return factory->uri_type; } + /** * gst_element_factory_get_uri_protocols: * @factory: a #GstElementFactory @@ -487,12 +513,13 @@ gst_element_factory_get_uri_type (GstElementFactory *factory) * Returns: the supported protocols or NULL */ gchar ** -gst_element_factory_get_uri_protocols (GstElementFactory *factory) +gst_element_factory_get_uri_protocols (GstElementFactory * factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); return factory->uri_protocols; } + /** * gst_element_factory_can_src_caps : * @factory: factory to query @@ -503,21 +530,22 @@ gst_element_factory_get_uri_protocols (GstElementFactory *factory) * Returns: true if it can src the capabilities */ gboolean -gst_element_factory_can_src_caps (GstElementFactory *factory, - const GstCaps *caps) +gst_element_factory_can_src_caps (GstElementFactory * factory, + const GstCaps * caps) { GList *templates; - g_return_val_if_fail(factory != NULL, FALSE); - g_return_val_if_fail(caps != NULL, FALSE); + g_return_val_if_fail (factory != NULL, FALSE); + g_return_val_if_fail (caps != NULL, FALSE); templates = factory->padtemplates; while (templates) { - GstPadTemplate *template = (GstPadTemplate *)templates->data; + GstPadTemplate *template = (GstPadTemplate *) templates->data; if (template->direction == GST_PAD_SRC) { - if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps)) + if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), + caps)) return TRUE; } templates = g_list_next (templates); @@ -525,6 +553,7 @@ gst_element_factory_can_src_caps (GstElementFactory *factory, return FALSE; } + /** * gst_element_factory_can_sink_caps : * @factory: factory to query @@ -535,21 +564,22 @@ gst_element_factory_can_src_caps (GstElementFactory *factory, * Returns: true if it can sink the capabilities */ gboolean -gst_element_factory_can_sink_caps (GstElementFactory *factory, - const GstCaps *caps) +gst_element_factory_can_sink_caps (GstElementFactory * factory, + const GstCaps * caps) { GList *templates; - g_return_val_if_fail(factory != NULL, FALSE); - g_return_val_if_fail(caps != NULL, FALSE); + g_return_val_if_fail (factory != NULL, FALSE); + g_return_val_if_fail (caps != NULL, FALSE); templates = factory->padtemplates; while (templates) { - GstPadTemplate *template = (GstPadTemplate *)templates->data; + GstPadTemplate *template = (GstPadTemplate *) templates->data; if (template->direction == GST_PAD_SINK) { - if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template))) + if (gst_caps_is_always_compatible (caps, + GST_PAD_TEMPLATE_CAPS (template))) return TRUE; } templates = g_list_next (templates); @@ -558,7 +588,7 @@ gst_element_factory_can_sink_caps (GstElementFactory *factory, return FALSE; } static void -gst_element_factory_unload_thyself (GstPluginFeature *feature) +gst_element_factory_unload_thyself (GstPluginFeature * feature) { GstElementFactory *factory; diff --git a/gst/gsterror.c b/gst/gsterror.c index 1324af1fb..b5d10d5f3 100644 --- a/gst/gsterror.c +++ b/gst/gsterror.c @@ -37,149 +37,134 @@ GType gst_g_error_get_type (void) { static GType type = 0; - + if (!type) type = g_boxed_type_register_static ("GstGError", - (GBoxedCopyFunc) g_error_copy, - (GBoxedFreeFunc) g_error_free); - return type; + (GBoxedCopyFunc) g_error_copy, (GBoxedFreeFunc) g_error_free); + return type; } /* initialize the dynamic table of translated core errors */ -static gchar ** _gst_core_errors_init () +static gchar ** +_gst_core_errors_init () { gchar **t = NULL; t = g_new0 (gchar *, GST_CORE_ERROR_NUM_ERRORS); TABLE (t, CORE, FAILED, - N_("GStreamer encountered a general core library error.")); + N_("GStreamer encountered a general core library error.")); TABLE (t, CORE, TOO_LAZY, - N_("GStreamer developers were too lazy to assign an error code " - "to this error. Please file a bug.")); + N_("GStreamer developers were too lazy to assign an error code " + "to this error. Please file a bug.")); TABLE (t, CORE, NOT_IMPLEMENTED, - N_("Internal GStreamer error: code not implemented. File a bug.")); + N_("Internal GStreamer error: code not implemented. File a bug.")); TABLE (t, CORE, STATE_CHANGE, - N_("Internal GStreamer error: state change failed. File a bug.")); + N_("Internal GStreamer error: state change failed. File a bug.")); TABLE (t, CORE, PAD, - N_("Internal GStreamer error: pad problem. File a bug.")); + N_("Internal GStreamer error: pad problem. File a bug.")); TABLE (t, CORE, THREAD, - N_("Internal GStreamer error: thread problem. File a bug.")); + N_("Internal GStreamer error: thread problem. File a bug.")); TABLE (t, CORE, SCHEDULER, - N_("Internal GStreamer error: scheduler problem. File a bug.")); + N_("Internal GStreamer error: scheduler problem. File a bug.")); TABLE (t, CORE, NEGOTIATION, - N_("Internal GStreamer error: negotiation problem. File a bug.")); + N_("Internal GStreamer error: negotiation problem. File a bug.")); TABLE (t, CORE, EVENT, - N_("Internal GStreamer error: event problem. File a bug.")); + N_("Internal GStreamer error: event problem. File a bug.")); TABLE (t, CORE, SEEK, - N_("Internal GStreamer error: seek problem. File a bug.")); + N_("Internal GStreamer error: seek problem. File a bug.")); TABLE (t, CORE, CAPS, - N_("Internal GStreamer error: caps problem. File a bug.")); + N_("Internal GStreamer error: caps problem. File a bug.")); TABLE (t, CORE, TAG, - N_("Internal GStreamer error: tag problem. File a bug.")); + N_("Internal GStreamer error: tag problem. File a bug.")); return t; } /* initialize the dynamic table of translated library errors */ -static gchar ** _gst_library_errors_init () +static gchar ** +_gst_library_errors_init () { gchar **t = NULL; t = g_new0 (gchar *, GST_LIBRARY_ERROR_NUM_ERRORS); TABLE (t, LIBRARY, FAILED, - N_("GStreamer encountered a general supporting library error.")); + N_("GStreamer encountered a general supporting library error.")); TABLE (t, LIBRARY, TOO_LAZY, - N_("GStreamer developers were too lazy to assign an error code " - "to this error. Please file a bug.")); - TABLE (t, LIBRARY, INIT, - N_("Could not initialize supporting library.")); - TABLE (t, LIBRARY, SHUTDOWN, - N_("Could not close supporting library.")); - TABLE (t, LIBRARY, SETTINGS, - N_("Could not close supporting library.")); + N_("GStreamer developers were too lazy to assign an error code " + "to this error. Please file a bug.")); + TABLE (t, LIBRARY, INIT, N_("Could not initialize supporting library.")); + TABLE (t, LIBRARY, SHUTDOWN, N_("Could not close supporting library.")); + TABLE (t, LIBRARY, SETTINGS, N_("Could not close supporting library.")); return t; } /* initialize the dynamic table of translated resource errors */ -static gchar ** _gst_resource_errors_init () +static gchar ** +_gst_resource_errors_init () { gchar **t = NULL; t = g_new0 (gchar *, GST_RESOURCE_ERROR_NUM_ERRORS); TABLE (t, RESOURCE, FAILED, - N_("GStreamer encountered a general supporting library error.")); + N_("GStreamer encountered a general supporting library error.")); TABLE (t, RESOURCE, TOO_LAZY, - N_("GStreamer developers were too lazy to assign an error code " - "to this error. Please file a bug.")); - TABLE (t, RESOURCE, NOT_FOUND, - N_("Resource not found.")); - TABLE (t, RESOURCE, BUSY, - N_("Resource busy or not available.")); - TABLE (t, RESOURCE, OPEN_READ, - N_("Could not open resource for reading.")); - TABLE (t, RESOURCE, OPEN_WRITE, - N_("Could not open resource for writing.")); + N_("GStreamer developers were too lazy to assign an error code " + "to this error. Please file a bug.")); + TABLE (t, RESOURCE, NOT_FOUND, N_("Resource not found.")); + TABLE (t, RESOURCE, BUSY, N_("Resource busy or not available.")); + TABLE (t, RESOURCE, OPEN_READ, N_("Could not open resource for reading.")); + TABLE (t, RESOURCE, OPEN_WRITE, N_("Could not open resource for writing.")); TABLE (t, RESOURCE, OPEN_READ_WRITE, - N_("Could not open resource for reading and writing.")); - TABLE (t, RESOURCE, CLOSE, - N_("Could not close resource.")); - TABLE (t, RESOURCE, READ, - N_("Could not read from resource.")); - TABLE (t, RESOURCE, WRITE, - N_("Could not write to resource.")); - TABLE (t, RESOURCE, SEEK, - N_("Could not perform seek on resource.")); - TABLE (t, RESOURCE, SYNC, - N_("Could not synchronize on resource.")); + N_("Could not open resource for reading and writing.")); + TABLE (t, RESOURCE, CLOSE, N_("Could not close resource.")); + TABLE (t, RESOURCE, READ, N_("Could not read from resource.")); + TABLE (t, RESOURCE, WRITE, N_("Could not write to resource.")); + TABLE (t, RESOURCE, SEEK, N_("Could not perform seek on resource.")); + TABLE (t, RESOURCE, SYNC, N_("Could not synchronize on resource.")); TABLE (t, RESOURCE, SETTINGS, - N_("Could not get/set settings from/on resource.")); + N_("Could not get/set settings from/on resource.")); return t; } /* initialize the dynamic table of translated stream errors */ -static gchar ** _gst_stream_errors_init () +static gchar ** +_gst_stream_errors_init () { gchar **t = NULL; t = g_new0 (gchar *, GST_STREAM_ERROR_NUM_ERRORS); TABLE (t, STREAM, FAILED, - N_("GStreamer encountered a general supporting library error.")); + N_("GStreamer encountered a general supporting library error.")); TABLE (t, STREAM, TOO_LAZY, - N_("GStreamer developers were too lazy to assign an error code " - "to this error. Please file a bug.")); + N_("GStreamer developers were too lazy to assign an error code " + "to this error. Please file a bug.")); TABLE (t, STREAM, NOT_IMPLEMENTED, - N_("Element doesn't implement handling of this stream. " - "Please file a bug.")); - TABLE (t, STREAM, TYPE_NOT_FOUND, - N_("Could not determine type of stream.")); + N_("Element doesn't implement handling of this stream. " + "Please file a bug.")); + TABLE (t, STREAM, TYPE_NOT_FOUND, N_("Could not determine type of stream.")); TABLE (t, STREAM, WRONG_TYPE, - N_("The stream is of a different type than handled by this element.")); + N_("The stream is of a different type than handled by this element.")); TABLE (t, STREAM, CODEC_NOT_FOUND, - N_("There is no codec present that can handle the stream's type.")); - TABLE (t, STREAM, DECODE, - N_("Could not decode stream.")); - TABLE (t, STREAM, ENCODE, - N_("Could not encode stream.")); - TABLE (t, STREAM, DEMUX, - N_("Could not demultiplex stream.")); - TABLE (t, STREAM, MUX, - N_("Could not multiplex stream.")); - TABLE (t, STREAM, FORMAT, - N_("Stream is of the wrong format.")); + N_("There is no codec present that can handle the stream's type.")); + TABLE (t, STREAM, DECODE, N_("Could not decode stream.")); + TABLE (t, STREAM, ENCODE, N_("Could not encode stream.")); + TABLE (t, STREAM, DEMUX, N_("Could not demultiplex stream.")); + TABLE (t, STREAM, MUX, N_("Could not multiplex stream.")); + TABLE (t, STREAM, FORMAT, N_("Stream is of the wrong format.")); return t; } QUARK_FUNC (core) -QUARK_FUNC (library) -QUARK_FUNC (resource) -QUARK_FUNC (stream) + QUARK_FUNC (library) + QUARK_FUNC (resource) + QUARK_FUNC (stream) /** * gst_error_get_message: @@ -189,9 +174,7 @@ QUARK_FUNC (stream) * Returns: a newly allocated string describing the error message in the * current locale. */ - -gchar * -gst_error_get_message (GQuark domain, gint code) + gchar *gst_error_get_message (GQuark domain, gint code) { static gchar **gst_core_errors = NULL; static gchar **gst_library_errors = NULL; @@ -211,18 +194,24 @@ gst_error_get_message (GQuark domain, gint code) gst_stream_errors = _gst_stream_errors_init (); - if (domain == GST_CORE_ERROR) message = gst_core_errors [code]; - else if (domain == GST_LIBRARY_ERROR) message = gst_library_errors [code]; - else if (domain == GST_RESOURCE_ERROR) message = gst_resource_errors[code]; - else if (domain == GST_STREAM_ERROR) message = gst_stream_errors [code]; - else - { + if (domain == GST_CORE_ERROR) + message = gst_core_errors[code]; + else if (domain == GST_LIBRARY_ERROR) + message = gst_library_errors[code]; + else if (domain == GST_RESOURCE_ERROR) + message = gst_resource_errors[code]; + else if (domain == GST_STREAM_ERROR) + message = gst_stream_errors[code]; + else { g_warning ("No error messages for domain %s", g_quark_to_string (domain)); - return g_strdup_printf (_("No error message for domain %s."), g_quark_to_string (domain)); + return g_strdup_printf (_("No error message for domain %s."), + g_quark_to_string (domain)); } if (message) return g_strdup (_(message)); else - return g_strdup_printf (_("No standard error message for domain %s and code %d."), - g_quark_to_string (domain), code); + return + g_strdup_printf (_ + ("No standard error message for domain %s and code %d."), + g_quark_to_string (domain), code); } diff --git a/gst/gsterror.h b/gst/gsterror.h index c1c96e8ba..888e246a5 100644 --- a/gst/gsterror.h +++ b/gst/gsterror.h @@ -21,7 +21,6 @@ #define __GST_ERROR_H__ G_BEGIN_DECLS - /* * we define FIXME error domains: * GST_CORE_ERROR @@ -31,12 +30,12 @@ G_BEGIN_DECLS * * Check GError API docs for rationale for naming. */ - /* Core errors are anything that can go wrong in or using * the core GStreamer library */ /* FIXME: should we divide in numerical blocks so we can easily add for example PAD errors later ? */ -typedef enum { + typedef enum +{ GST_CORE_ERROR_FAILED = 1, GST_CORE_ERROR_TOO_LAZY, GST_CORE_ERROR_NOT_IMPLEMENTED, @@ -55,7 +54,8 @@ GstCoreError; /* Library errors are for errors from the library being used by elements initializing, closing, ... */ -typedef enum { +typedef enum +{ GST_LIBRARY_ERROR_FAILED = 1, GST_LIBRARY_ERROR_TOO_LAZY, GST_LIBRARY_ERROR_INIT, @@ -69,7 +69,8 @@ GstLibraryError; /* Resource errors are for anything external used by an element: memory, files, network connections, process space, ... They're typically used by source and sink elements */ -typedef enum { +typedef enum +{ GST_RESOURCE_ERROR_FAILED = 1, GST_RESOURCE_ERROR_TOO_LAZY, GST_RESOURCE_ERROR_NOT_FOUND, @@ -90,7 +91,8 @@ GstResourceError; /* Stream errors are for anything related to the stream being processed: format errors, media type errors, ... They're typically used by decoders, demuxers, converters, ... */ -typedef enum { +typedef enum +{ GST_STREAM_ERROR_FAILED = 1, GST_STREAM_ERROR_TOO_LAZY, GST_STREAM_ERROR_NOT_IMPLEMENTED, @@ -116,15 +118,12 @@ GstStreamError; #define GST_ERROR_SYSTEM ("system error: %s", g_strerror (errno)) -GType gst_g_error_get_type (void); -gchar * gst_error_get_message (GQuark domain, gint code); -GQuark gst_stream_error_quark (void); -GQuark gst_core_error_quark (void); -GQuark gst_resource_error_quark (void); -GQuark gst_library_error_quark (void); +GType gst_g_error_get_type (void); +gchar *gst_error_get_message (GQuark domain, gint code); +GQuark gst_stream_error_quark (void); +GQuark gst_core_error_quark (void); +GQuark gst_resource_error_quark (void); +GQuark gst_library_error_quark (void); G_END_DECLS - #endif /* __GST_ERROR_H__ */ - - diff --git a/gst/gstevent.c b/gst/gstevent.c index bf463f7e7..c42e1b10e 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -48,19 +48,18 @@ _gst_event_initialize (void) { /* register the type */ _gst_event_type = g_boxed_type_register_static ("GstEvent", - (GBoxedCopyFunc) gst_data_copy, - (GBoxedFreeFunc) gst_data_unref); + (GBoxedCopyFunc) gst_data_copy, (GBoxedFreeFunc) gst_data_unref); #ifndef GST_DISABLE_TRACE _event_trace = gst_alloc_trace_register (GST_EVENT_TRACE_NAME); #endif chunk = gst_mem_chunk_new ("GstEventChunk", sizeof (GstEvent), - sizeof (GstEvent) * 50, 0); + sizeof (GstEvent) * 50, 0); } -static GstEvent* -_gst_event_copy (GstEvent *event) +static GstEvent * +_gst_event_copy (GstEvent * event) { GstEvent *copy; @@ -70,14 +69,17 @@ _gst_event_copy (GstEvent *event) #endif memcpy (copy, event, sizeof (GstEvent)); - + /* FIXME copy/ref additional fields */ switch (GST_EVENT_TYPE (event)) { case GST_EVENT_TAG: - copy->event_data.structure.structure = gst_tag_list_copy ((GstTagList *) event->event_data.structure.structure); + copy->event_data.structure.structure = + gst_tag_list_copy ((GstTagList *) event->event_data.structure. + structure); break; case GST_EVENT_NAVIGATION: - copy->event_data.structure.structure = gst_structure_copy (event->event_data.structure.structure); + copy->event_data.structure.structure = + gst_structure_copy (event->event_data.structure.structure); default: break; } @@ -86,7 +88,7 @@ _gst_event_copy (GstEvent *event) } static void -_gst_event_free (GstEvent* event) +_gst_event_free (GstEvent * event) { GST_CAT_INFO (GST_CAT_EVENT, "freeing event %p", event); @@ -96,7 +98,7 @@ _gst_event_free (GstEvent* event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_TAG: if (GST_IS_TAG_LIST (event->event_data.structure.structure)) { - gst_tag_list_free (event->event_data.structure.structure); + gst_tag_list_free (event->event_data.structure.structure); } else { g_warning ("tag event %p didn't contain a valid tag list!", event); GST_ERROR ("tag event %p didn't contain a valid tag list!", event); @@ -125,16 +127,16 @@ _gst_event_free (GstEvent* event) * Returns: TRUE if the eventmask is found inside the array */ gboolean -gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask) +gst_event_masks_contains (const GstEventMask * masks, GstEventMask * mask) { g_return_val_if_fail (mask != NULL, FALSE); if (!masks) return FALSE; - + while (masks->type) { if (masks->type == mask->type && - (masks->flags & mask->flags) == mask->flags) + (masks->flags & mask->flags) == mask->flags) return TRUE; masks++; @@ -157,7 +159,7 @@ gst_event_get_type (void) * * Returns: A new event. */ -GstEvent* +GstEvent * gst_event_new (GstEventType type) { GstEvent *event; @@ -170,10 +172,10 @@ gst_event_new (GstEventType type) GST_CAT_INFO (GST_CAT_EVENT, "creating new event %p %d", event, type); _GST_DATA_INIT (GST_DATA (event), - _gst_event_type, - 0, - (GstDataFreeFunction) _gst_event_free, - (GstDataCopyFunction) _gst_event_copy); + _gst_event_type, + 0, + (GstDataFreeFunction) _gst_event_free, + (GstDataCopyFunction) _gst_event_copy); GST_EVENT_TYPE (event) = type; GST_EVENT_TIMESTAMP (event) = G_GINT64_CONSTANT (0); @@ -191,7 +193,7 @@ gst_event_new (GstEventType type) * * Returns: A new seek event. */ -GstEvent* +GstEvent * gst_event_new_seek (GstSeekType type, gint64 offset) { GstEvent *event; @@ -218,8 +220,9 @@ gst_event_new_seek (GstSeekType type, gint64 offset) * * Returns: A new discontinuous event. */ -GstEvent* -gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1, va_list var_args) +GstEvent * +gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1, + va_list var_args) { GstEvent *event; gint count = 0; @@ -229,7 +232,8 @@ gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1, va_li while (format1 != GST_FORMAT_UNDEFINED && count < 8) { - GST_EVENT_DISCONT_OFFSET (event, count).format = format1 & GST_SEEK_FORMAT_MASK; + GST_EVENT_DISCONT_OFFSET (event, count).format = + format1 & GST_SEEK_FORMAT_MASK; GST_EVENT_DISCONT_OFFSET (event, count).value = va_arg (var_args, gint64); format1 = va_arg (var_args, GstFormat); @@ -238,7 +242,7 @@ gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1, va_li } GST_EVENT_DISCONT_OFFSET_LEN (event) = count; - + return event; } @@ -255,7 +259,7 @@ gst_event_new_discontinuous_valist (gboolean new_media, GstFormat format1, va_li * * Returns: A new discontinuous event. */ -GstEvent* +GstEvent * gst_event_new_discontinuous (gboolean new_media, GstFormat format1, ...) { va_list var_args; @@ -281,7 +285,7 @@ gst_event_new_discontinuous (gboolean new_media, GstFormat format1, ...) * Returns: TRUE if the discont event caries the specified format/value pair. */ gboolean -gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value) +gst_event_discont_get_value (GstEvent * event, GstFormat format, gint64 * value) { gint i, n; @@ -291,12 +295,12 @@ gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value) n = GST_EVENT_DISCONT_OFFSET_LEN (event); for (i = 0; i < n; i++) { - if (GST_EVENT_DISCONT_OFFSET(event,i).format == format) { - *value = GST_EVENT_DISCONT_OFFSET(event,i).value; + if (GST_EVENT_DISCONT_OFFSET (event, i).format == format) { + *value = GST_EVENT_DISCONT_OFFSET (event, i).value; return TRUE; } } - + return FALSE; } @@ -310,7 +314,7 @@ gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value) * * Returns: The new size event. */ -GstEvent* +GstEvent * gst_event_new_size (GstFormat format, gint64 value) { GstEvent *event; @@ -319,7 +323,7 @@ gst_event_new_size (GstFormat format, gint64 value) GST_EVENT_SIZE_FORMAT (event) = format; GST_EVENT_SIZE_VALUE (event) = value; - + return event; } @@ -334,7 +338,7 @@ gst_event_new_size (GstFormat format, gint64 value) * * Returns: A new segment seek event. */ -GstEvent* +GstEvent * gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop) { GstEvent *event; diff --git a/gst/gstevent.h b/gst/gstevent.h index 9eaec60dc..2c898ba9b 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -30,28 +30,27 @@ #include #include -G_BEGIN_DECLS - -extern GType _gst_event_type; - -typedef enum { - GST_EVENT_UNKNOWN = 0, - GST_EVENT_EOS = 1, - GST_EVENT_FLUSH = 2, - GST_EVENT_EMPTY = 3, - GST_EVENT_DISCONTINUOUS = 4, - /*GST_EVENT_NEW_MEDIA = 5, <- removed */ - GST_EVENT_QOS = 6, - GST_EVENT_SEEK = 7, - GST_EVENT_SEEK_SEGMENT = 8, - GST_EVENT_SEGMENT_DONE = 9, - GST_EVENT_SIZE = 10, - GST_EVENT_RATE = 11, - GST_EVENT_FILLER = 12, - GST_EVENT_TS_OFFSET = 13, - GST_EVENT_INTERRUPT = 14, - GST_EVENT_NAVIGATION = 15, - GST_EVENT_TAG = 16 +G_BEGIN_DECLS extern GType _gst_event_type; + +typedef enum +{ + GST_EVENT_UNKNOWN = 0, + GST_EVENT_EOS = 1, + GST_EVENT_FLUSH = 2, + GST_EVENT_EMPTY = 3, + GST_EVENT_DISCONTINUOUS = 4, + /*GST_EVENT_NEW_MEDIA = 5, <- removed */ + GST_EVENT_QOS = 6, + GST_EVENT_SEEK = 7, + GST_EVENT_SEEK_SEGMENT = 8, + GST_EVENT_SEGMENT_DONE = 9, + GST_EVENT_SIZE = 10, + GST_EVENT_RATE = 11, + GST_EVENT_FILLER = 12, + GST_EVENT_TS_OFFSET = 13, + GST_EVENT_INTERRUPT = 14, + GST_EVENT_NAVIGATION = 15, + GST_EVENT_TAG = 16 } GstEventType; #define GST_EVENT_TRACE_NAME "GstEvent" @@ -73,17 +72,18 @@ typedef enum { #define GST_SEEK_METHOD_MASK 0x000f0000 #define GST_SEEK_FLAGS_MASK 0xfff00000 -typedef enum { - GST_EVENT_FLAG_NONE = 0, +typedef enum +{ + GST_EVENT_FLAG_NONE = 0, /* indicates negative rates are supported */ - GST_RATE_FLAG_NEGATIVE = (1 << 1) + GST_RATE_FLAG_NEGATIVE = (1 << 1) } GstEventFlag; typedef struct { - GstEventType type; - GstEventFlag flags; + GstEventType type; + GstEventFlag flags; } GstEventMask; #ifndef GST_DISABLE_DEPRECATED @@ -113,31 +113,33 @@ functionname (type pad) \ #endif /* seek events, extends GstEventFlag */ -typedef enum { +typedef enum +{ /* | with some format */ /* | with one of these */ - GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)), - GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)), - GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)), + GST_SEEK_METHOD_CUR = (1 << (GST_SEEK_METHOD_SHIFT + 0)), + GST_SEEK_METHOD_SET = (1 << (GST_SEEK_METHOD_SHIFT + 1)), + GST_SEEK_METHOD_END = (1 << (GST_SEEK_METHOD_SHIFT + 2)), /* | with optional seek flags */ /* seek flags */ - GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)), - GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)), - GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)), - GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3)) - + GST_SEEK_FLAG_FLUSH = (1 << (GST_SEEK_FLAGS_SHIFT + 0)), + GST_SEEK_FLAG_ACCURATE = (1 << (GST_SEEK_FLAGS_SHIFT + 1)), + GST_SEEK_FLAG_KEY_UNIT = (1 << (GST_SEEK_FLAGS_SHIFT + 2)), + GST_SEEK_FLAG_SEGMENT_LOOP = (1 << (GST_SEEK_FLAGS_SHIFT + 3)) + } GstSeekType; -typedef enum { +typedef enum +{ GST_SEEK_CERTAIN, GST_SEEK_FUZZY } GstSeekAccuracy; typedef struct { - GstFormat format; - gint64 value; + GstFormat format; + gint64 value; } GstFormatValue; #define GST_EVENT_SEEK_TYPE(event) (GST_EVENT(event)->event_data.seek.type) @@ -157,44 +159,51 @@ typedef struct #define GST_EVENT_RATE_VALUE(event) (GST_EVENT(event)->event_data.rate.value) -struct _GstEvent { +struct _GstEvent +{ GstData data; - GstEventType type; - guint64 timestamp; - GstObject *src; - - union { - struct { - GstSeekType type; - gint64 offset; - gint64 endoffset; - GstSeekAccuracy accuracy; + GstEventType type; + guint64 timestamp; + GstObject *src; + + union + { + struct + { + GstSeekType type; + gint64 offset; + gint64 endoffset; + GstSeekAccuracy accuracy; } seek; - struct { - GstFormatValue offsets[8]; - gint noffsets; - gboolean new_media; + struct + { + GstFormatValue offsets[8]; + gint noffsets; + gboolean new_media; } discont; - struct { - GstFormat format; - gint64 value; + struct + { + GstFormat format; + gint64 value; } size; - struct { - gdouble value; + struct + { + gdouble value; } rate; - struct { - GstStructure *structure; + struct + { + GstStructure *structure; } structure; } event_data; gpointer _gst_reserved[GST_PADDING]; }; -void _gst_event_initialize (void); - -GType gst_event_get_type (void); -GstEvent* gst_event_new (GstEventType type); +void _gst_event_initialize (void); + +GType gst_event_get_type (void); +GstEvent *gst_event_new (GstEventType type); /* refcounting */ #define gst_event_ref(ev) GST_EVENT (gst_data_ref (GST_DATA (ev))) @@ -203,24 +212,26 @@ GstEvent* gst_event_new (GstEventType type); /* copy buffer */ #define gst_event_copy(ev) GST_EVENT (gst_data_copy (GST_DATA (ev))) -gboolean gst_event_masks_contains (const GstEventMask *masks, GstEventMask *mask); +gboolean gst_event_masks_contains (const GstEventMask * masks, + GstEventMask * mask); /* seek event */ -GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset); +GstEvent *gst_event_new_seek (GstSeekType type, gint64 offset); -GstEvent* gst_event_new_segment_seek (GstSeekType type, gint64 start, gint64 stop); +GstEvent *gst_event_new_segment_seek (GstSeekType type, gint64 start, + gint64 stop); /* size events */ -GstEvent* gst_event_new_size (GstFormat format, gint64 value); +GstEvent *gst_event_new_size (GstFormat format, gint64 value); /* discontinous event */ -GstEvent* gst_event_new_discontinuous (gboolean new_media, - GstFormat format1, ...); -GstEvent* gst_event_new_discontinuous_valist (gboolean new_media, - GstFormat format1, - va_list var_args); -gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value); +GstEvent *gst_event_new_discontinuous (gboolean new_media, + GstFormat format1, ...); +GstEvent *gst_event_new_discontinuous_valist (gboolean new_media, + GstFormat format1, va_list var_args); +gboolean gst_event_discont_get_value (GstEvent * event, GstFormat format, + gint64 * value); #define gst_event_new_filler() gst_event_new(GST_EVENT_FILLER) @@ -228,5 +239,4 @@ gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 #define gst_event_new_flush() gst_event_new(GST_EVENT_FLUSH) G_END_DECLS - #endif /* __GST_EVENT_H__ */ diff --git a/gst/gstfilter.c b/gst/gstfilter.c index b6483f5b5..4f1395ef6 100644 --- a/gst/gstfilter.c +++ b/gst/gstfilter.c @@ -19,8 +19,9 @@ #include -GList* -gst_filter_run (const GList *list, GstFilterFunc func, gboolean first, gpointer user_data) +GList * +gst_filter_run (const GList * list, GstFilterFunc func, gboolean first, + gpointer user_data) { const GList *walk = list; GList *result = NULL; @@ -30,7 +31,7 @@ gst_filter_run (const GList *list, GstFilterFunc func, gboolean first, gpointer gpointer data = walk->data; walk = g_list_next (walk); - + if (func) res = func (data, user_data); diff --git a/gst/gstfilter.h b/gst/gstfilter.h index 6ecb6a113..fa250f16a 100644 --- a/gst/gstfilter.h +++ b/gst/gstfilter.h @@ -23,11 +23,10 @@ #include G_BEGIN_DECLS + typedef gboolean (*GstFilterFunc) (gpointer obj, gpointer user_data); -typedef gboolean (*GstFilterFunc) (gpointer obj, gpointer user_data); - -GList* gst_filter_run (const GList *list, GstFilterFunc func, gboolean first, gpointer user_data); +GList *gst_filter_run (const GList * list, GstFilterFunc func, gboolean first, + gpointer user_data); G_END_DECLS - #endif /* __GST_FILTER_H_ */ diff --git a/gst/gstformat.c b/gst/gstformat.c index b5dd33178..6881a0179 100644 --- a/gst/gstformat.c +++ b/gst/gstformat.c @@ -29,18 +29,18 @@ static GList *_gst_formats = NULL; static GHashTable *_nick_to_format = NULL; static GHashTable *_format_to_nick = NULL; -static gint _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */ +static gint _n_values = 1; /* we start from 1 because 0 reserved for UNDEFINED */ static GstFormatDefinition standard_definitions[] = { - { GST_FORMAT_DEFAULT, "default", "Default format for the media type" }, - { GST_FORMAT_BYTES, "bytes", "Bytes" }, - { GST_FORMAT_TIME, "time", "Time" }, - { GST_FORMAT_BUFFERS, "buffers", "Buffers" }, - { GST_FORMAT_PERCENT, "percent", "Percent" }, - { 0, NULL, NULL } + {GST_FORMAT_DEFAULT, "default", "Default format for the media type"}, + {GST_FORMAT_BYTES, "bytes", "Bytes"}, + {GST_FORMAT_TIME, "time", "Time"}, + {GST_FORMAT_BUFFERS, "buffers", "Buffers"}, + {GST_FORMAT_PERCENT, "percent", "Percent"}, + {0, NULL, NULL} }; -void +void _gst_format_initialize (void) { GstFormatDefinition *standards = standard_definitions; @@ -49,10 +49,11 @@ _gst_format_initialize (void) _nick_to_format = g_hash_table_new (g_str_hash, g_str_equal); _format_to_nick = g_hash_table_new (NULL, NULL); } - + while (standards->nick) { g_hash_table_insert (_nick_to_format, standards->nick, standards); - g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value), standards); + g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (standards->value), + standards); _gst_formats = g_list_append (_gst_formats, standards); standards++; @@ -72,28 +73,29 @@ _gst_format_initialize (void) * with the same nick. */ GstFormat -gst_format_register (const gchar *nick, const gchar *description) +gst_format_register (const gchar * nick, const gchar * description) { GstFormatDefinition *format; GstFormat query; - + g_return_val_if_fail (nick != NULL, 0); g_return_val_if_fail (description != NULL, 0); query = gst_format_get_by_nick (nick); if (query != GST_FORMAT_UNDEFINED) return query; - + format = g_new0 (GstFormatDefinition, 1); format->value = _n_values; format->nick = g_strdup (nick); format->description = g_strdup (description); g_hash_table_insert (_nick_to_format, format->nick, format); - g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (format->value), format); + g_hash_table_insert (_format_to_nick, GINT_TO_POINTER (format->value), + format); _gst_formats = g_list_append (_gst_formats, format); _n_values++; - + return format->value; } @@ -107,14 +109,14 @@ gst_format_register (const gchar *nick, const gchar *description) * if the format was not registered. */ GstFormat -gst_format_get_by_nick (const gchar *nick) +gst_format_get_by_nick (const gchar * nick) { GstFormatDefinition *format; - + g_return_val_if_fail (nick != NULL, 0); format = g_hash_table_lookup (_nick_to_format, nick); - + if (format != NULL) return format->value; else @@ -131,7 +133,7 @@ gst_format_get_by_nick (const gchar *nick) * Returns: TRUE if the format is found inside the array */ gboolean -gst_formats_contains (const GstFormat *formats, GstFormat format) +gst_formats_contains (const GstFormat * formats, GstFormat format) { if (!formats) return FALSE; @@ -154,7 +156,7 @@ gst_formats_contains (const GstFormat *formats, GstFormat format) * * Returns: The #GstFormatDefinition for @format or NULL on failure. */ -const GstFormatDefinition* +const GstFormatDefinition * gst_format_get_details (GstFormat format) { return g_hash_table_lookup (_format_to_nick, GINT_TO_POINTER (format)); @@ -167,7 +169,7 @@ gst_format_get_details (GstFormat format) * * Returns: A GList of #GstFormatDefinition. */ -const GList* +const GList * gst_format_get_definitions (void) { return _gst_formats; diff --git a/gst/gstformat.h b/gst/gstformat.h index eaaed5028..156992394 100644 --- a/gst/gstformat.h +++ b/gst/gstformat.h @@ -27,15 +27,14 @@ #include -G_BEGIN_DECLS - -typedef enum { - GST_FORMAT_UNDEFINED = 0, /* must be first in list */ - GST_FORMAT_DEFAULT = 1, /* samples for audio, frames/fields for video */ - GST_FORMAT_BYTES = 2, - GST_FORMAT_TIME = 3, - GST_FORMAT_BUFFERS = 4, - GST_FORMAT_PERCENT = 5 +G_BEGIN_DECLS typedef enum +{ + GST_FORMAT_UNDEFINED = 0, /* must be first in list */ + GST_FORMAT_DEFAULT = 1, /* samples for audio, frames/fields for video */ + GST_FORMAT_BYTES = 2, + GST_FORMAT_TIME = 3, + GST_FORMAT_BUFFERS = 4, + GST_FORMAT_PERCENT = 5 } GstFormat; /* a percentage is always relative to 1000000 */ @@ -44,11 +43,11 @@ typedef enum { typedef struct _GstFormatDefinition GstFormatDefinition; -struct _GstFormatDefinition +struct _GstFormatDefinition { - GstFormat value; - gchar *nick; - gchar *description; + GstFormat value; + gchar *nick; + gchar *description; }; #ifdef G_HAVE_ISO_VARARGS @@ -75,22 +74,18 @@ functionname (type object) \ } #endif -void _gst_format_initialize (void); +void _gst_format_initialize (void); /* register a new format */ -GstFormat gst_format_register (const gchar *nick, - const gchar *description); -GstFormat gst_format_get_by_nick (const gchar *nick); +GstFormat gst_format_register (const gchar * nick, const gchar * description); +GstFormat gst_format_get_by_nick (const gchar * nick); /* check if a format is in an array of formats */ -gboolean gst_formats_contains (const GstFormat *formats, GstFormat format); +gboolean gst_formats_contains (const GstFormat * formats, GstFormat format); /* query for format details */ -G_CONST_RETURN GstFormatDefinition* - gst_format_get_details (GstFormat format); -G_CONST_RETURN GList* - gst_format_get_definitions (void); +G_CONST_RETURN GstFormatDefinition *gst_format_get_details (GstFormat format); +G_CONST_RETURN GList *gst_format_get_definitions (void); G_END_DECLS - #endif /* __GST_FORMAT_H__ */ diff --git a/gst/gstindex.c b/gst/gstindex.c index 342331e81..f7e74d06d 100644 --- a/gst/gstindex.c +++ b/gst/gstindex.c @@ -29,32 +29,34 @@ #include "gstmarshal.h" /* Index signals and args */ -enum { +enum +{ ENTRY_ADDED, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_RESOLVER - /* FILL ME */ + /* FILL ME */ }; -static void gst_index_class_init (GstIndexClass *klass); -static void gst_index_init (GstIndex *index); +static void gst_index_class_init (GstIndexClass * klass); +static void gst_index_init (GstIndex * index); -static void gst_index_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_index_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_index_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_index_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstIndexGroup* gst_index_group_new (guint groupnum); +static GstIndexGroup *gst_index_group_new (guint groupnum); -static gboolean gst_index_path_resolver (GstIndex *index, GstObject *writer, - gchar **writer_string, gpointer data); -static gboolean gst_index_gtype_resolver (GstIndex *index, GstObject *writer, - gchar **writer_string, gpointer data); -static void gst_index_add_entry (GstIndex *index, GstIndexEntry *entry); +static gboolean gst_index_path_resolver (GstIndex * index, GstObject * writer, + gchar ** writer_string, gpointer data); +static gboolean gst_index_gtype_resolver (GstIndex * index, GstObject * writer, + gchar ** writer_string, gpointer data); +static void gst_index_add_entry (GstIndex * index, GstIndexEntry * entry); static GstObject *parent_class = NULL; static guint gst_index_signals[LAST_SIGNAL] = { 0 }; @@ -62,15 +64,14 @@ static guint gst_index_signals[LAST_SIGNAL] = { 0 }; typedef struct { GstIndexResolverMethod method; - GstIndexResolver resolver; - gpointer user_data; + GstIndexResolver resolver; + gpointer user_data; } ResolverEntry; -static const ResolverEntry resolvers[] = -{ - { GST_INDEX_RESOLVER_CUSTOM, NULL, NULL }, - { GST_INDEX_RESOLVER_GTYPE, gst_index_gtype_resolver, NULL }, - { GST_INDEX_RESOLVER_PATH, gst_index_path_resolver, NULL }, +static const ResolverEntry resolvers[] = { + {GST_INDEX_RESOLVER_CUSTOM, NULL, NULL}, + {GST_INDEX_RESOLVER_GTYPE, gst_index_gtype_resolver, NULL}, + {GST_INDEX_RESOLVER_PATH, gst_index_path_resolver, NULL}, }; #define GST_TYPE_INDEX_RESOLVER (gst_index_resolver_get_type()) @@ -79,13 +80,17 @@ gst_index_resolver_get_type (void) { static GType index_resolver_type = 0; static GEnumValue index_resolver[] = { - { GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM", "Use a custom resolver"}, - { GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE", "Resolve an object to its GType[.padname]"}, - { GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH", "Resolve an object to its path in the pipeline"}, + {GST_INDEX_RESOLVER_CUSTOM, "GST_INDEX_RESOLVER_CUSTOM", + "Use a custom resolver"}, + {GST_INDEX_RESOLVER_GTYPE, "GST_INDEX_RESOLVER_GTYPE", + "Resolve an object to its GType[.padname]"}, + {GST_INDEX_RESOLVER_PATH, "GST_INDEX_RESOLVER_PATH", + "Resolve an object to its path in the pipeline"}, {0, NULL, NULL}, }; if (!index_resolver_type) { - index_resolver_type = g_enum_register_static ("GstIndexResolver", index_resolver); + index_resolver_type = + g_enum_register_static ("GstIndexResolver", index_resolver); } return index_resolver_type; } @@ -97,66 +102,68 @@ gst_index_entry_get_type (void) if (!index_entry_type) { index_entry_type = g_boxed_type_register_static ("GstIndexEntry", - (GBoxedCopyFunc) gst_index_entry_copy, - (GBoxedFreeFunc) gst_index_entry_free); + (GBoxedCopyFunc) gst_index_entry_copy, + (GBoxedFreeFunc) gst_index_entry_free); } return index_entry_type; } GType -gst_index_get_type (void) { +gst_index_get_type (void) +{ static GType index_type = 0; if (!index_type) { static const GTypeInfo index_info = { - sizeof(GstIndexClass), + sizeof (GstIndexClass), NULL, NULL, - (GClassInitFunc)gst_index_class_init, + (GClassInitFunc) gst_index_class_init, NULL, NULL, - sizeof(GstIndex), + sizeof (GstIndex), 1, - (GInstanceInitFunc)gst_index_init, + (GInstanceInitFunc) gst_index_init, NULL }; - index_type = g_type_register_static(GST_TYPE_OBJECT, "GstIndex", &index_info, 0); + index_type = + g_type_register_static (GST_TYPE_OBJECT, "GstIndex", &index_info, 0); } return index_type; } static void -gst_index_class_init (GstIndexClass *klass) +gst_index_class_init (GstIndexClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_OBJECT); + parent_class = g_type_class_ref (GST_TYPE_OBJECT); gst_index_signals[ENTRY_ADDED] = - g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL, - gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, - GST_TYPE_INDEX_ENTRY); + g_signal_new ("entry-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstIndexClass, entry_added), NULL, NULL, + gst_marshal_VOID__BOXED, G_TYPE_NONE, 1, GST_TYPE_INDEX_ENTRY); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_index_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_index_get_property); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RESOLVER, - g_param_spec_enum ("resolver", "Resolver", "Select a predefined object to string mapper", - GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH, G_PARAM_READWRITE)); + g_param_spec_enum ("resolver", "Resolver", + "Select a predefined object to string mapper", + GST_TYPE_INDEX_RESOLVER, GST_INDEX_RESOLVER_PATH, G_PARAM_READWRITE)); } static void -gst_index_init (GstIndex *index) +gst_index_init (GstIndex * index) { - index->curgroup = gst_index_group_new(0); + index->curgroup = gst_index_group_new (0); index->maxgroup = 0; - index->groups = g_list_prepend(NULL, index->curgroup); + index->groups = g_list_prepend (NULL, index->curgroup); index->writers = g_hash_table_new (NULL, NULL); index->last_id = 0; @@ -167,13 +174,13 @@ gst_index_init (GstIndex *index) GST_FLAG_SET (index, GST_INDEX_WRITABLE); GST_FLAG_SET (index, GST_INDEX_READABLE); - - GST_DEBUG ( "created new index"); + + GST_DEBUG ("created new index"); } static void -gst_index_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_index_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstIndex *index; @@ -192,8 +199,8 @@ gst_index_set_property (GObject *object, guint prop_id, } static void -gst_index_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +gst_index_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstIndex *index; @@ -210,16 +217,16 @@ gst_index_get_property (GObject *object, guint prop_id, } static GstIndexGroup * -gst_index_group_new(guint groupnum) +gst_index_group_new (guint groupnum) { - GstIndexGroup *indexgroup = g_new(GstIndexGroup,1); + GstIndexGroup *indexgroup = g_new (GstIndexGroup, 1); indexgroup->groupnum = groupnum; indexgroup->entries = NULL; indexgroup->certainty = GST_INDEX_UNKNOWN; indexgroup->peergroup = -1; - GST_DEBUG ( "created new index group %d",groupnum); + GST_DEBUG ("created new index group %d", groupnum); return indexgroup; } @@ -231,7 +238,7 @@ gst_index_group_new(guint groupnum) * * Returns: a new index object */ -GstIndex* +GstIndex * gst_index_new (void) { GstIndex *index; @@ -251,7 +258,7 @@ gst_index_new (void) * to it. */ void -gst_index_commit (GstIndex *index, gint id) +gst_index_commit (GstIndex * index, gint id) { GstIndexClass *iclass; @@ -271,7 +278,7 @@ gst_index_commit (GstIndex *index, gint id) * Returns: the id of the current group. */ gint -gst_index_get_group(GstIndex *index) +gst_index_get_group (GstIndex * index) { return index->curgroup->groupnum; } @@ -286,11 +293,11 @@ gst_index_get_group(GstIndex *index) * Returns: the id of the newly created group. */ gint -gst_index_new_group(GstIndex *index) +gst_index_new_group (GstIndex * index) { - index->curgroup = gst_index_group_new(++index->maxgroup); - index->groups = g_list_append(index->groups,index->curgroup); - GST_DEBUG ( "created new group %d in index",index->maxgroup); + index->curgroup = gst_index_group_new (++index->maxgroup); + index->groups = g_list_append (index->groups, index->curgroup); + GST_DEBUG ("created new group %d in index", index->maxgroup); return index->maxgroup; } @@ -305,7 +312,7 @@ gst_index_new_group(GstIndex *index) * did not exist. */ gboolean -gst_index_set_group(GstIndex *index, gint groupnum) +gst_index_set_group (GstIndex * index, gint groupnum) { GList *list; GstIndexGroup *indexgroup; @@ -317,17 +324,17 @@ gst_index_set_group(GstIndex *index, gint groupnum) /* else search for the proper group */ list = index->groups; while (list) { - indexgroup = (GstIndexGroup *)(list->data); - list = g_list_next(list); + indexgroup = (GstIndexGroup *) (list->data); + list = g_list_next (list); if (indexgroup->groupnum == groupnum) { index->curgroup = indexgroup; - GST_DEBUG ( "switched to index group %d", indexgroup->groupnum); + GST_DEBUG ("switched to index group %d", indexgroup->groupnum); return TRUE; } } /* couldn't find the group in question */ - GST_DEBUG ( "couldn't find index group %d",groupnum); + GST_DEBUG ("couldn't find index group %d", groupnum); return FALSE; } @@ -339,7 +346,7 @@ gst_index_set_group(GstIndex *index, gint groupnum) * Set the certainty of the given index. */ void -gst_index_set_certainty(GstIndex *index, GstIndexCertainty certainty) +gst_index_set_certainty (GstIndex * index, GstIndexCertainty certainty) { index->curgroup->certainty = certainty; } @@ -353,7 +360,7 @@ gst_index_set_certainty(GstIndex *index, GstIndexCertainty certainty) * Returns: the certainty of the index. */ GstIndexCertainty -gst_index_get_certainty(GstIndex *index) +gst_index_get_certainty (GstIndex * index) { return index->curgroup->certainty; } @@ -368,8 +375,8 @@ gst_index_get_certainty(GstIndex *index) * it can select what entries should be stored in the index. */ void -gst_index_set_filter (GstIndex *index, - GstIndexFilter filter, gpointer user_data) +gst_index_set_filter (GstIndex * index, + GstIndexFilter filter, gpointer user_data) { g_return_if_fail (GST_IS_INDEX (index)); @@ -387,8 +394,8 @@ gst_index_set_filter (GstIndex *index, * ids to writer descriptions. */ void -gst_index_set_resolver (GstIndex *index, - GstIndexResolver resolver, gpointer user_data) +gst_index_set_resolver (GstIndex * index, + GstIndexResolver resolver, gpointer user_data) { g_return_if_fail (GST_IS_INDEX (index)); @@ -404,9 +411,9 @@ gst_index_set_resolver (GstIndex *index, * Copies an entry and returns the result. */ GstIndexEntry * -gst_index_entry_copy (GstIndexEntry *entry) +gst_index_entry_copy (GstIndexEntry * entry) { - return g_memdup(entry, sizeof(*entry)); + return g_memdup (entry, sizeof (*entry)); } /** @@ -416,7 +423,7 @@ gst_index_entry_copy (GstIndexEntry *entry) * Free the memory used by the given entry. */ void -gst_index_entry_free (GstIndexEntry *entry) +gst_index_entry_free (GstIndexEntry * entry) { g_free (entry); } @@ -433,18 +440,18 @@ gst_index_entry_free (GstIndexEntry *entry) * * Returns: a pointer to the newly added entry in the index. */ -GstIndexEntry* -gst_index_add_format (GstIndex *index, gint id, GstFormat format) +GstIndexEntry * +gst_index_add_format (GstIndex * index, gint id, GstFormat format) { GstIndexEntry *entry; - const GstFormatDefinition* def; + const GstFormatDefinition *def; g_return_val_if_fail (GST_IS_INDEX (index), NULL); g_return_val_if_fail (format != 0, NULL); if (!GST_INDEX_IS_WRITABLE (index) || id == -1) return NULL; - + entry = g_new0 (GstIndexEntry, 1); entry->type = GST_INDEX_ENTRY_FORMAT; entry->id = id; @@ -468,17 +475,17 @@ gst_index_add_format (GstIndex *index, gint id, GstFormat format) * * Returns: a pointer to the newly added entry in the index. */ -GstIndexEntry* -gst_index_add_id (GstIndex *index, gint id, gchar *description) +GstIndexEntry * +gst_index_add_id (GstIndex * index, gint id, gchar * description) { GstIndexEntry *entry; g_return_val_if_fail (GST_IS_INDEX (index), NULL); g_return_val_if_fail (description != NULL, NULL); - + if (!GST_INDEX_IS_WRITABLE (index) || id == -1) return NULL; - + entry = g_new0 (GstIndexEntry, 1); entry->type = GST_INDEX_ENTRY_ID; entry->id = id; @@ -490,8 +497,8 @@ gst_index_add_id (GstIndex *index, gint id, gchar *description) } static gboolean -gst_index_path_resolver (GstIndex *index, GstObject *writer, - gchar **writer_string, gpointer data) +gst_index_path_resolver (GstIndex * index, GstObject * writer, + gchar ** writer_string, gpointer data) { *writer_string = gst_object_get_path_string (writer); @@ -499,18 +506,17 @@ gst_index_path_resolver (GstIndex *index, GstObject *writer, } static gboolean -gst_index_gtype_resolver (GstIndex *index, GstObject *writer, - gchar **writer_string, gpointer data) +gst_index_gtype_resolver (GstIndex * index, GstObject * writer, + gchar ** writer_string, gpointer data) { if (GST_IS_PAD (writer)) { GstElement *element = gst_pad_get_parent (GST_PAD (writer)); - *writer_string = g_strdup_printf ("%s.%s", - g_type_name (G_OBJECT_TYPE (element)), - gst_object_get_name (writer)); - } - else { - *writer_string = g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer))); + *writer_string = g_strdup_printf ("%s.%s", + g_type_name (G_OBJECT_TYPE (element)), gst_object_get_name (writer)); + } else { + *writer_string = + g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer))); } return TRUE; @@ -532,8 +538,8 @@ gst_index_gtype_resolver (GstIndex *index, GstObject *writer, * * Returns: TRUE if the writer would be mapped to an id. */ -gboolean -gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id) +gboolean +gst_index_get_writer_id (GstIndex * index, GstObject * writer, gint * id) { gchar *writer_string = NULL; GstIndexEntry *entry; @@ -548,7 +554,7 @@ gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id) /* first try to get a previously cached id */ entry = g_hash_table_lookup (index->writers, writer); - if (entry == NULL) { + if (entry == NULL) { iclass = GST_INDEX_GET_CLASS (index); @@ -556,11 +562,12 @@ gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id) if (index->resolver) { gboolean res; - res = index->resolver (index, writer, &writer_string, index->resolver_user_data); - if (!res) - return FALSE; - } - else { + res = + index->resolver (index, writer, &writer_string, + index->resolver_user_data); + if (!res) + return FALSE; + } else { g_warning ("no resolver found"); return FALSE; } @@ -584,8 +591,7 @@ gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id) entry->data.id.description = writer_string; } g_hash_table_insert (index->writers, writer, entry); - } - else { + } else { *id = entry->id; } @@ -593,7 +599,7 @@ gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id) } static void -gst_index_add_entry (GstIndex *index, GstIndexEntry *entry) +gst_index_add_entry (GstIndex * index, GstIndexEntry * entry) { GstIndexClass *iclass; @@ -619,25 +625,25 @@ gst_index_add_entry (GstIndex *index, GstIndexEntry *entry) * * Returns: a pointer to the newly added entry in the index. */ -GstIndexEntry* -gst_index_add_associationv (GstIndex *index, gint id, GstAssocFlags flags, - int n, const GstIndexAssociation *list) +GstIndexEntry * +gst_index_add_associationv (GstIndex * index, gint id, GstAssocFlags flags, + int n, const GstIndexAssociation * list) { GstIndexEntry *entry; g_return_val_if_fail (n > 0, NULL); g_return_val_if_fail (list != NULL, NULL); g_return_val_if_fail (GST_IS_INDEX (index), NULL); - + if (!GST_INDEX_IS_WRITABLE (index) || id == -1) return NULL; - + entry = g_malloc (sizeof (GstIndexEntry)); entry->type = GST_INDEX_ENTRY_ASSOCIATION; entry->id = id; entry->data.assoc.flags = flags; - entry->data.assoc.assocs = g_memdup(list, sizeof (GstIndexAssociation) * n); + entry->data.assoc.assocs = g_memdup (list, sizeof (GstIndexAssociation) * n); entry->data.assoc.nassocs = n; gst_index_add_entry (index, entry); @@ -660,9 +666,9 @@ gst_index_add_associationv (GstIndex *index, gint id, GstAssocFlags flags, * * Returns: a pointer to the newly added entry in the index. */ -GstIndexEntry* -gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags, - GstFormat format, gint64 value, ...) +GstIndexEntry * +gst_index_add_association (GstIndex * index, gint id, GstAssocFlags flags, + GstFormat format, gint64 value, ...) { va_list args; GstIndexEntry *entry; @@ -673,11 +679,11 @@ gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags, g_return_val_if_fail (GST_IS_INDEX (index), NULL); g_return_val_if_fail (format != 0, NULL); - + if (!GST_INDEX_IS_WRITABLE (index) || id == -1) return NULL; - - array = g_array_new(FALSE, FALSE, sizeof(GstIndexAssociation)); + + array = g_array_new (FALSE, FALSE, sizeof (GstIndexAssociation)); va_start (args, value); @@ -717,22 +723,20 @@ gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags, * * Returns: a pointer to the newly added entry in the index. */ -GstIndexEntry* -gst_index_add_object (GstIndex *index, gint id, gchar *key, - GType type, gpointer object) +GstIndexEntry * +gst_index_add_object (GstIndex * index, gint id, gchar * key, + GType type, gpointer object) { if (!GST_INDEX_IS_WRITABLE (index) || id == -1) return NULL; - + return NULL; } static gint -gst_index_compare_func (gconstpointer a, - gconstpointer b, - gpointer user_data) +gst_index_compare_func (gconstpointer a, gconstpointer b, gpointer user_data) { - return (gint)a - (gint)b; + return (gint) a - (gint) b; } /** @@ -749,18 +753,18 @@ gst_index_compare_func (gconstpointer a, * Returns: the entry associated with the value or NULL if the * value was not found. */ -GstIndexEntry* -gst_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value) +GstIndexEntry * +gst_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value) { g_return_val_if_fail (GST_IS_INDEX (index), NULL); if (id == -1) return NULL; - return gst_index_get_assoc_entry_full (index, id, method, flags, format, value, - gst_index_compare_func, NULL); + return gst_index_get_assoc_entry_full (index, id, method, flags, format, + value, gst_index_compare_func, NULL); } /** @@ -780,12 +784,10 @@ gst_index_get_assoc_entry (GstIndex *index, gint id, * Returns: the entry associated with the value or NULL if the * value was not found. */ -GstIndexEntry* -gst_index_get_assoc_entry_full (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data) +GstIndexEntry * +gst_index_get_assoc_entry_full (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data) { GstIndexClass *iclass; @@ -797,8 +799,9 @@ gst_index_get_assoc_entry_full (GstIndex *index, gint id, iclass = GST_INDEX_GET_CLASS (index); if (iclass->get_assoc_entry) - return iclass->get_assoc_entry (index, id, method, flags, format, value, func, user_data); - + return iclass->get_assoc_entry (index, id, method, flags, format, value, + func, user_data); + return NULL; } @@ -814,8 +817,8 @@ gst_index_get_assoc_entry_full (GstIndex *index, gint id, * format. */ gboolean -gst_index_entry_assoc_map (GstIndexEntry *entry, - GstFormat format, gint64 *value) +gst_index_entry_assoc_map (GstIndexEntry * entry, + GstFormat format, gint64 * value) { gint i; @@ -823,23 +826,24 @@ gst_index_entry_assoc_map (GstIndexEntry *entry, g_return_val_if_fail (value != NULL, FALSE); for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) { - if (GST_INDEX_ASSOC_FORMAT (entry, i) == format) { - *value = GST_INDEX_ASSOC_VALUE (entry, i); - return TRUE; - } + if (GST_INDEX_ASSOC_FORMAT (entry, i) == format) { + *value = GST_INDEX_ASSOC_VALUE (entry, i); + return TRUE; + } } return FALSE; } -static void gst_index_factory_class_init (GstIndexFactoryClass *klass); -static void gst_index_factory_init (GstIndexFactory *factory); +static void gst_index_factory_class_init (GstIndexFactoryClass * klass); +static void gst_index_factory_init (GstIndexFactory * factory); static GstPluginFeatureClass *factory_parent_class = NULL; + /* static guint gst_index_factory_signals[LAST_SIGNAL] = { 0 }; */ -GType -gst_index_factory_get_type (void) +GType +gst_index_factory_get_type (void) { static GType indexfactory_type = 0; @@ -851,33 +855,33 @@ gst_index_factory_get_type (void) (GClassInitFunc) gst_index_factory_class_init, NULL, NULL, - sizeof(GstIndexFactory), + sizeof (GstIndexFactory), 0, (GInstanceInitFunc) gst_index_factory_init, NULL }; - indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstIndexFactory", &indexfactory_info, 0); + indexfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, + "GstIndexFactory", &indexfactory_info, 0); } return indexfactory_type; } static void -gst_index_factory_class_init (GstIndexFactoryClass *klass) +gst_index_factory_class_init (GstIndexFactoryClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; GstPluginFeatureClass *gstpluginfeature_class; - gobject_class = (GObjectClass*)klass; - gstobject_class = (GstObjectClass*)klass; - gstpluginfeature_class = (GstPluginFeatureClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstpluginfeature_class = (GstPluginFeatureClass *) klass; factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE); } static void -gst_index_factory_init (GstIndexFactory *factory) +gst_index_factory_init (GstIndexFactory * factory) { } @@ -891,12 +895,12 @@ gst_index_factory_init (GstIndexFactory *factory) * * Returns: a new #GstIndexFactory. */ -GstIndexFactory* -gst_index_factory_new (const gchar *name, const gchar *longdesc, GType type) +GstIndexFactory * +gst_index_factory_new (const gchar * name, const gchar * longdesc, GType type) { GstIndexFactory *factory; - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); factory = gst_index_factory_find (name); if (!factory) { factory = GST_INDEX_FACTORY (g_object_new (GST_TYPE_INDEX_FACTORY, NULL)); @@ -918,7 +922,7 @@ gst_index_factory_new (const gchar *name, const gchar *longdesc, GType type) * Removes the index from the global list. */ void -gst_index_factory_destroy (GstIndexFactory *factory) +gst_index_factory_destroy (GstIndexFactory * factory) { g_return_if_fail (factory != NULL); @@ -933,8 +937,8 @@ gst_index_factory_destroy (GstIndexFactory *factory) * * Returns: #GstIndexFactory if found, NULL otherwise */ -GstIndexFactory* -gst_index_factory_find (const gchar *name) +GstIndexFactory * +gst_index_factory_find (const gchar * name) { GstPluginFeature *feature; @@ -958,8 +962,8 @@ gst_index_factory_find (const gchar *name) * * Returns: A new #GstIndex instance. */ -GstIndex* -gst_index_factory_create (GstIndexFactory *factory) +GstIndex * +gst_index_factory_create (GstIndexFactory * factory) { GstIndex *new = NULL; @@ -968,7 +972,7 @@ gst_index_factory_create (GstIndexFactory *factory) if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) { g_return_val_if_fail (factory->type != 0, NULL); - new = GST_INDEX (g_object_new(factory->type,NULL)); + new = GST_INDEX (g_object_new (factory->type, NULL)); } return new; @@ -983,8 +987,8 @@ gst_index_factory_create (GstIndexFactory *factory) * * Returns: A new #GstIndex instance. */ -GstIndex* -gst_index_factory_make (const gchar *name) +GstIndex * +gst_index_factory_make (const gchar * name) { GstIndexFactory *factory; diff --git a/gst/gstindex.h b/gst/gstindex.h index b24a93ec4..1dee5307c 100644 --- a/gst/gstindex.h +++ b/gst/gstindex.h @@ -29,35 +29,35 @@ #include G_BEGIN_DECLS - #define GST_TYPE_INDEX (gst_index_get_type ()) #define GST_INDEX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_INDEX, GstIndex)) #define GST_IS_INDEX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_INDEX)) #define GST_INDEX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_INDEX, GstIndexClass)) #define GST_IS_INDEX_CLASS(klass) (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_INDEX)) #define GST_INDEX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_INDEX, GstIndexClass)) - #define GST_TYPE_INDEX_ENTRY (gst_index_entry_get_type()) - typedef struct _GstIndexEntry GstIndexEntry; typedef struct _GstIndexGroup GstIndexGroup; typedef struct _GstIndex GstIndex; typedef struct _GstIndexClass GstIndexClass; -typedef enum { +typedef enum +{ GST_INDEX_UNKNOWN, GST_INDEX_CERTAIN, GST_INDEX_FUZZY } GstIndexCertainty; -typedef enum { +typedef enum +{ GST_INDEX_ENTRY_ID, GST_INDEX_ENTRY_ASSOCIATION, GST_INDEX_ENTRY_OBJECT, GST_INDEX_ENTRY_FORMAT } GstIndexEntryType; -typedef enum { +typedef enum +{ GST_INDEX_LOOKUP_EXACT, GST_INDEX_LOOKUP_BEFORE, GST_INDEX_LOOKUP_AFTER @@ -70,17 +70,19 @@ typedef enum { typedef struct _GstIndexAssociation GstIndexAssociation; -struct _GstIndexAssociation { - GstFormat format; - gint64 value; +struct _GstIndexAssociation +{ + GstFormat format; + gint64 value; }; -typedef enum { - GST_ASSOCIATION_FLAG_NONE = 0, +typedef enum +{ + GST_ASSOCIATION_FLAG_NONE = 0, GST_ASSOCIATION_FLAG_KEY_UNIT = (1 << 0), /* new flags should start here */ - GST_ASSOCIATION_FLAG_LAST = (1 << 8) + GST_ASSOCIATION_FLAG_LAST = (1 << 8) } GstAssocFlags; #define GST_INDEX_FORMAT_FORMAT(entry) ((entry)->data.format.format) @@ -90,33 +92,39 @@ typedef enum { #define GST_INDEX_ID_DESCRIPTION(entry) ((entry)->data.id.description) -struct _GstIndexEntry { - GstIndexEntryType type; - gint id; +struct _GstIndexEntry +{ + GstIndexEntryType type; + gint id; - union { - struct { - gchar *description; + union + { + struct + { + gchar *description; } id; - struct { - gint nassocs; - GstIndexAssociation - *assocs; - GstAssocFlags flags; + struct + { + gint nassocs; + GstIndexAssociation * assocs; + GstAssocFlags flags; } assoc; - struct { - gchar *key; - GType type; - gpointer object; + struct + { + gchar *key; + GType type; + gpointer object; } object; - struct { - GstFormat format; - gchar *key; + struct + { + GstFormat format; + gchar *key; } format; } data; }; -struct _GstIndexGroup { +struct _GstIndexGroup +{ /* unique ID of group in index */ gint groupnum; @@ -130,112 +138,112 @@ struct _GstIndexGroup { gint peergroup; }; -typedef gboolean (*GstIndexFilter) (GstIndex *index, - GstIndexEntry *entry); +typedef gboolean (*GstIndexFilter) (GstIndex * index, GstIndexEntry * entry); -typedef enum { +typedef enum +{ GST_INDEX_RESOLVER_CUSTOM, GST_INDEX_RESOLVER_GTYPE, GST_INDEX_RESOLVER_PATH } GstIndexResolverMethod; -typedef gboolean (*GstIndexResolver) (GstIndex *index, - GstObject *writer, - gchar **writer_string, - gpointer user_data); -typedef enum { - GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST, - GST_INDEX_READABLE, +typedef gboolean (*GstIndexResolver) (GstIndex * index, + GstObject * writer, gchar ** writer_string, gpointer user_data); +typedef enum +{ + GST_INDEX_WRITABLE = GST_OBJECT_FLAG_LAST, + GST_INDEX_READABLE, - GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8 + GST_INDEX_FLAG_LAST = GST_OBJECT_FLAG_LAST + 8 } GstIndexFlags; #define GST_INDEX_IS_READABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_READABLE)) #define GST_INDEX_IS_WRITABLE(obj) (GST_FLAG_IS_SET (obj, GST_INDEX_WRITABLE)) -struct _GstIndex { - GstObject object; +struct _GstIndex +{ + GstObject object; - GList *groups; - GstIndexGroup *curgroup; - gint maxgroup; + GList *groups; + GstIndexGroup *curgroup; + gint maxgroup; GstIndexResolverMethod method; - GstIndexResolver resolver; - gpointer resolver_user_data; + GstIndexResolver resolver; + gpointer resolver_user_data; - GstIndexFilter filter; - gpointer filter_user_data; + GstIndexFilter filter; + gpointer filter_user_data; - GHashTable *writers; - gint last_id; + GHashTable *writers; + gint last_id; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstIndexClass { +struct _GstIndexClass +{ GstObjectClass parent_class; - gboolean (*get_writer_id) (GstIndex *index, gint *writer_id, gchar *writer_string); + gboolean (*get_writer_id) (GstIndex * index, gint * writer_id, + gchar * writer_string); - void (*commit) (GstIndex *index, gint id); + void (*commit) (GstIndex * index, gint id); /* abstract methods */ - void (*add_entry) (GstIndex *index, GstIndexEntry *entry); + void (*add_entry) (GstIndex * index, GstIndexEntry * entry); - GstIndexEntry* (*get_assoc_entry) (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data); + GstIndexEntry *(*get_assoc_entry) (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value, + GCompareDataFunc func, gpointer user_data); /* signals */ - void (*entry_added) (GstIndex *index, GstIndexEntry *entry); + void (*entry_added) (GstIndex * index, GstIndexEntry * entry); gpointer _gst_reserved[GST_PADDING]; }; -GType gst_index_get_type (void); -GstIndex* gst_index_new (void); -void gst_index_commit (GstIndex *index, gint id); - -gint gst_index_get_group (GstIndex *index); -gint gst_index_new_group (GstIndex *index); -gboolean gst_index_set_group (GstIndex *index, gint groupnum); - -void gst_index_set_certainty (GstIndex *index, - GstIndexCertainty certainty); -GstIndexCertainty gst_index_get_certainty (GstIndex *index); - -void gst_index_set_filter (GstIndex *index, - GstIndexFilter filter, gpointer user_data); -void gst_index_set_resolver (GstIndex *index, - GstIndexResolver resolver, gpointer user_data); - -gboolean gst_index_get_writer_id (GstIndex *index, GstObject *writer, gint *id); - -GstIndexEntry* gst_index_add_format (GstIndex *index, gint id, GstFormat format); -GstIndexEntry* gst_index_add_association (GstIndex *index, gint id, GstAssocFlags flags, - GstFormat format, gint64 value, ...); -GstIndexEntry* gst_index_add_object (GstIndex *index, gint id, gchar *key, - GType type, gpointer object); -GstIndexEntry* gst_index_add_id (GstIndex *index, gint id, - gchar *description); - -GstIndexEntry* gst_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value); -GstIndexEntry* gst_index_get_assoc_entry_full (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data); +GType gst_index_get_type (void); +GstIndex *gst_index_new (void); +void gst_index_commit (GstIndex * index, gint id); + +gint gst_index_get_group (GstIndex * index); +gint gst_index_new_group (GstIndex * index); +gboolean gst_index_set_group (GstIndex * index, gint groupnum); + +void gst_index_set_certainty (GstIndex * index, GstIndexCertainty certainty); +GstIndexCertainty gst_index_get_certainty (GstIndex * index); + +void gst_index_set_filter (GstIndex * index, + GstIndexFilter filter, gpointer user_data); +void gst_index_set_resolver (GstIndex * index, + GstIndexResolver resolver, gpointer user_data); + +gboolean gst_index_get_writer_id (GstIndex * index, GstObject * writer, + gint * id); + +GstIndexEntry *gst_index_add_format (GstIndex * index, gint id, + GstFormat format); +GstIndexEntry *gst_index_add_association (GstIndex * index, gint id, + GstAssocFlags flags, GstFormat format, gint64 value, ...); +GstIndexEntry *gst_index_add_object (GstIndex * index, gint id, gchar * key, + GType type, gpointer object); +GstIndexEntry *gst_index_add_id (GstIndex * index, gint id, + gchar * description); + +GstIndexEntry *gst_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value); +GstIndexEntry *gst_index_get_assoc_entry_full (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data); /* working with index entries */ GType gst_index_entry_get_type (void); -GstIndexEntry * gst_index_entry_copy (GstIndexEntry *entry); -void gst_index_entry_free (GstIndexEntry *entry); -gboolean gst_index_entry_assoc_map (GstIndexEntry *entry, - GstFormat format, gint64 *value); +GstIndexEntry *gst_index_entry_copy (GstIndexEntry * entry); +void gst_index_entry_free (GstIndexEntry * entry); +gboolean gst_index_entry_assoc_map (GstIndexEntry * entry, + GstFormat format, gint64 * value); /* * creating indexs * @@ -250,32 +258,33 @@ gboolean gst_index_entry_assoc_map (GstIndexEntry *entry, typedef struct _GstIndexFactory GstIndexFactory; typedef struct _GstIndexFactoryClass GstIndexFactoryClass; -struct _GstIndexFactory { +struct _GstIndexFactory +{ GstPluginFeature feature; - - gchar *longdesc; /* long description of the index (well, don't overdo it..) */ - GType type; /* unique GType of the index */ + + gchar *longdesc; /* long description of the index (well, don't overdo it..) */ + GType type; /* unique GType of the index */ gpointer _gst_reserved[GST_PADDING]; }; -struct _GstIndexFactoryClass { - GstPluginFeatureClass parent; +struct _GstIndexFactoryClass +{ + GstPluginFeatureClass parent; gpointer _gst_reserved[GST_PADDING]; }; -GType gst_index_factory_get_type (void); +GType gst_index_factory_get_type (void); -GstIndexFactory* gst_index_factory_new (const gchar *name, - const gchar *longdesc, GType type); -void gst_index_factory_destroy (GstIndexFactory *factory); +GstIndexFactory *gst_index_factory_new (const gchar * name, + const gchar * longdesc, GType type); +void gst_index_factory_destroy (GstIndexFactory * factory); -GstIndexFactory* gst_index_factory_find (const gchar *name); +GstIndexFactory *gst_index_factory_find (const gchar * name); -GstIndex* gst_index_factory_create (GstIndexFactory *factory); -GstIndex* gst_index_factory_make (const gchar *name); +GstIndex *gst_index_factory_create (GstIndexFactory * factory); +GstIndex *gst_index_factory_make (const gchar * name); G_END_DECLS - #endif /* __GST_INDEX_H__ */ diff --git a/gst/gstinfo.c b/gst/gstinfo.c index 3579f27dc..695899266 100644 --- a/gst/gstinfo.c +++ b/gst/gstinfo.c @@ -33,9 +33,9 @@ #ifdef HAVE_PRINTF_EXTENSION #include #endif -#include /* fprintf */ +#include /* fprintf */ #include -#include /* G_VA_COPY */ +#include /* G_VA_COPY */ #include "gstinfo.h" #include "gstlog.h" #include "gst_private.h" @@ -44,57 +44,62 @@ #include "gstscheduler.h" #include "gst_private.h" -GST_DEBUG_CATEGORY_STATIC(GST_CAT_DEBUG); +GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEBUG); #if 0 #if defined __sgi__ #include -typedef struct DL_INFO { - const char * dli_fname; - void * dli_fbase; - const char * dli_sname; - void * dli_saddr; - int dli_version; - int dli_reserved1; - long dli_reserved[4]; +typedef struct DL_INFO +{ + const char *dli_fname; + void *dli_fbase; + const char *dli_sname; + void *dli_saddr; + int dli_version; + int dli_reserved1; + long dli_reserved[4]; } Dl_info; + #define _RLD_DLADDR 14 -int dladdr(void *address, Dl_info *dl); +int dladdr (void *address, Dl_info * dl); -int dladdr(void *address, Dl_info *dl) +int +dladdr (void *address, Dl_info * dl) { void *v; - v = _rld_new_interface(_RLD_DLADDR,address,dl); - return (int)v; + + v = _rld_new_interface (_RLD_DLADDR, address, dl); + return (int) v; } #endif /* __sgi__ */ #endif extern gchar *_gst_progname; -static void gst_debug_reset_threshold (gpointer category, - gpointer unused); -static void gst_debug_reset_all_thresholds (void); +static void gst_debug_reset_threshold (gpointer category, gpointer unused); +static void gst_debug_reset_all_thresholds (void); #ifdef HAVE_PRINTF_EXTENSION -static int _gst_info_printf_extension (FILE *stream, const struct printf_info *info, - const void *const *args); -static int _gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n, - int *argtypes); +static int _gst_info_printf_extension (FILE * stream, + const struct printf_info *info, const void *const *args); +static int _gst_info_printf_extension_arginfo (const struct printf_info *info, + size_t n, int *argtypes); #endif -struct _GstDebugMessage { - gchar * message; - const gchar * format; - va_list arguments; +struct _GstDebugMessage +{ + gchar *message; + const gchar *format; + va_list arguments; }; /* list of all name/level pairs from --gst-debug and GST_DEBUG */ static GStaticMutex __level_name_mutex = G_STATIC_MUTEX_INIT; static GSList *__level_name = NULL; -typedef struct { - GPatternSpec * pat; - GstDebugLevel level; +typedef struct +{ + GPatternSpec *pat; + GstDebugLevel level; } LevelNameEntry; /* list of all categories */ @@ -102,9 +107,10 @@ static GStaticMutex __cat_mutex = G_STATIC_MUTEX_INIT; static GSList *__categories = NULL; /* all registered debug handlers */ -typedef struct { - GstLogFunction func; - gpointer user_data; +typedef struct +{ + GstLogFunction func; + gpointer user_data; } LogFuncEntry; static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT; static GSList *__log_functions = NULL; @@ -152,7 +158,8 @@ GstDebugCategory *GST_CAT_SEEK = NULL; * Initializes the debugging system. * Normally you don't want to call this, because gst_init does it for you. */ -void _gst_debug_init (void) +void +_gst_debug_init (void) { gst_atomic_int_init (&__default_level, GST_LEVEL_DEFAULT); gst_atomic_int_init (&__use_color, 1); @@ -163,104 +170,73 @@ void _gst_debug_init (void) #endif /* do NOT use a single debug function before this line has been run */ - GST_CAT_DEFAULT = _gst_debug_category_new ("default", - GST_DEBUG_UNDERLINE, - NULL); - GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG", - GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, - "debugging subsystem"); + GST_CAT_DEFAULT = _gst_debug_category_new ("default", + GST_DEBUG_UNDERLINE, NULL); + GST_CAT_DEBUG = _gst_debug_category_new ("GST_DEBUG", + GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, "debugging subsystem"); gst_debug_add_log_function (gst_debug_log_default, NULL); /* FIXME: add descriptions here */ - GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT", - GST_DEBUG_BOLD | GST_DEBUG_FG_RED, - NULL); - GST_CAT_COTHREADS = _gst_debug_category_new ("GST_COTHREADS", - GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, - NULL); + GST_CAT_GST_INIT = _gst_debug_category_new ("GST_INIT", + GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL); + GST_CAT_COTHREADS = _gst_debug_category_new ("GST_COTHREADS", + GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL); GST_CAT_COTHREAD_SWITCH = _gst_debug_category_new ("GST_COTHREAD_SWITCH", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN, - NULL); - GST_CAT_AUTOPLUG = _gst_debug_category_new ("GST_AUTOPLUG", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, - NULL); + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_GREEN, NULL); + GST_CAT_AUTOPLUG = _gst_debug_category_new ("GST_AUTOPLUG", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL); GST_CAT_AUTOPLUG_ATTEMPT = _gst_debug_category_new ("GST_AUTOPLUG_ATTEMPT", - GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN | GST_DEBUG_BG_BLUE, - NULL); - GST_CAT_PARENTAGE = _gst_debug_category_new ("GST_PARENTAGE", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); - GST_CAT_STATES = _gst_debug_category_new ("GST_STATES", - GST_DEBUG_BOLD | GST_DEBUG_FG_RED, - NULL); - GST_CAT_PLANNING = _gst_debug_category_new ("GST_PLANNING", - GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, - NULL); - GST_CAT_SCHEDULING = _gst_debug_category_new ("GST_SCHEDULING", - GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, - NULL); - GST_CAT_DATAFLOW = _gst_debug_category_new ("GST_DATAFLOW", - GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, - NULL); - GST_CAT_BUFFER = _gst_debug_category_new ("GST_BUFFER", - GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, - NULL); - GST_CAT_CAPS = _gst_debug_category_new ("GST_CAPS", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, - NULL); - GST_CAT_CLOCK = _gst_debug_category_new ("GST_CLOCK", - GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, - NULL); - GST_CAT_ELEMENT_PADS = _gst_debug_category_new ("GST_ELEMENT_PADS", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); - GST_CAT_PADS = _gst_debug_category_new ("GST_PADS", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); - GST_CAT_PIPELINE = _gst_debug_category_new ("GST_PIPELINE", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); + GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN | GST_DEBUG_BG_BLUE, NULL); + GST_CAT_PARENTAGE = _gst_debug_category_new ("GST_PARENTAGE", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); + GST_CAT_STATES = _gst_debug_category_new ("GST_STATES", + GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL); + GST_CAT_PLANNING = _gst_debug_category_new ("GST_PLANNING", + GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL); + GST_CAT_SCHEDULING = _gst_debug_category_new ("GST_SCHEDULING", + GST_DEBUG_BOLD | GST_DEBUG_FG_MAGENTA, NULL); + GST_CAT_DATAFLOW = _gst_debug_category_new ("GST_DATAFLOW", + GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL); + GST_CAT_BUFFER = _gst_debug_category_new ("GST_BUFFER", + GST_DEBUG_BOLD | GST_DEBUG_FG_GREEN, NULL); + GST_CAT_CAPS = _gst_debug_category_new ("GST_CAPS", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL); + GST_CAT_CLOCK = _gst_debug_category_new ("GST_CLOCK", + GST_DEBUG_BOLD | GST_DEBUG_FG_YELLOW, NULL); + GST_CAT_ELEMENT_PADS = _gst_debug_category_new ("GST_ELEMENT_PADS", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); + GST_CAT_PADS = _gst_debug_category_new ("GST_PADS", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); + GST_CAT_PIPELINE = _gst_debug_category_new ("GST_PIPELINE", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); GST_CAT_PLUGIN_LOADING = _gst_debug_category_new ("GST_PLUGIN_LOADING", - GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, - NULL); - GST_CAT_PLUGIN_INFO = _gst_debug_category_new ("GST_PLUGIN_INFO", - GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, - NULL); - GST_CAT_PROPERTIES = _gst_debug_category_new ("GST_PROPERTIES", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_BLUE, - NULL); - GST_CAT_THREAD = _gst_debug_category_new ("GST_THREAD", - GST_DEBUG_BOLD | GST_DEBUG_FG_RED, - NULL); - GST_CAT_TYPES = _gst_debug_category_new ("GST_TYPES", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); - GST_CAT_XML = _gst_debug_category_new ("GST_XML", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); - GST_CAT_NEGOTIATION = _gst_debug_category_new ("GST_NEGOTIATION", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, - NULL); - GST_CAT_REFCOUNTING = _gst_debug_category_new ("GST_REFCOUNTING", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_GREEN, - NULL); - GST_CAT_ERROR_SYSTEM = _gst_debug_category_new ("GST_ERROR_SYSTEM", - GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_WHITE, - NULL); - - GST_CAT_EVENT = _gst_debug_category_new ("GST_EVENT", - GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, - NULL); - GST_CAT_PARAMS = _gst_debug_category_new ("GST_PARAMS", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLACK | GST_DEBUG_BG_YELLOW, - NULL); - GST_CAT_CALL_TRACE = _gst_debug_category_new ("GST_CALL_TRACE", - GST_DEBUG_BOLD, - NULL); - GST_CAT_SEEK = _gst_debug_category_new ("GST_SEEK", - 0, - "plugins reacting to seek events"); + GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, NULL); + GST_CAT_PLUGIN_INFO = _gst_debug_category_new ("GST_PLUGIN_INFO", + GST_DEBUG_BOLD | GST_DEBUG_FG_CYAN, NULL); + GST_CAT_PROPERTIES = _gst_debug_category_new ("GST_PROPERTIES", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_BLUE, NULL); + GST_CAT_THREAD = _gst_debug_category_new ("GST_THREAD", + GST_DEBUG_BOLD | GST_DEBUG_FG_RED, NULL); + GST_CAT_TYPES = _gst_debug_category_new ("GST_TYPES", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); + GST_CAT_XML = _gst_debug_category_new ("GST_XML", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); + GST_CAT_NEGOTIATION = _gst_debug_category_new ("GST_NEGOTIATION", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE, NULL); + GST_CAT_REFCOUNTING = _gst_debug_category_new ("GST_REFCOUNTING", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_GREEN, NULL); + GST_CAT_ERROR_SYSTEM = _gst_debug_category_new ("GST_ERROR_SYSTEM", + GST_DEBUG_BOLD | GST_DEBUG_FG_RED | GST_DEBUG_BG_WHITE, NULL); + + GST_CAT_EVENT = _gst_debug_category_new ("GST_EVENT", + GST_DEBUG_BOLD | GST_DEBUG_FG_WHITE | GST_DEBUG_BG_RED, NULL); + GST_CAT_PARAMS = _gst_debug_category_new ("GST_PARAMS", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLACK | GST_DEBUG_BG_YELLOW, NULL); + GST_CAT_CALL_TRACE = _gst_debug_category_new ("GST_CALL_TRACE", + GST_DEBUG_BOLD, NULL); + GST_CAT_SEEK = _gst_debug_category_new ("GST_SEEK", + 0, "plugins reacting to seek events"); } /* we can't do this further above, because we initialize the GST_CAT_DEFAULT struct */ @@ -279,16 +255,19 @@ void _gst_debug_init (void) * * Logs the given message using the currently registered debugging handlers. */ -void gst_debug_log (GstDebugCategory *category, GstDebugLevel level, - const gchar *file, const gchar *function, gint line, - GObject *object, const gchar *format, ...) +void +gst_debug_log (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, + GObject * object, const gchar * format, ...) { va_list var_args; - + va_start (var_args, format); - gst_debug_log_valist (category, level, file, function, line, object, format, var_args); + gst_debug_log_valist (category, level, file, function, line, object, format, + var_args); va_end (var_args); } + /** * gst_debug_log_valist: * @category: category to log @@ -302,9 +281,10 @@ void gst_debug_log (GstDebugCategory *category, GstDebugLevel level, * * Logs the given message using the currently registered debugging handlers. */ -void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level, - const gchar *file, const gchar *function, gint line, - GObject *object, const gchar *format, va_list args) +void +gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, + GObject * object, const gchar * format, va_list args) { GstDebugMessage message; LogFuncEntry *entry; @@ -318,16 +298,18 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level, message.message = NULL; message.format = format; G_VA_COPY (message.arguments, args); - + handler = __log_functions; while (handler) { entry = handler->data; handler = g_slist_next (handler); - entry->func (category, level, file, function, line, object, &message, entry->user_data); + entry->func (category, level, file, function, line, object, &message, + entry->user_data); } g_free (message.message); va_end (message.arguments); } + /** * gst_debug_message_get: * @message: a debug message @@ -336,7 +318,7 @@ void gst_debug_log_valist (GstDebugCategory *category, GstDebugLevel level, * in debug handlers to extract the message. */ const gchar * -gst_debug_message_get (GstDebugMessage *message) +gst_debug_message_get (GstDebugMessage * message) { if (message->message == NULL) { message->message = g_strdup_vprintf (message->format, message->arguments); @@ -348,7 +330,7 @@ gst_debug_message_get (GstDebugMessage *message) static gchar * gst_debug_print_object (gpointer ptr) { - GObject *object = (GObject *)ptr; + GObject *object = (GObject *) ptr; #ifdef unused /* This is a cute trick to detect unmapped memory, but is unportable, @@ -356,7 +338,7 @@ gst_debug_print_object (gpointer ptr) { int ret; - ret = madvise ((void *)((unsigned long)ptr & (~0xfff)), 4096, 0); + ret = madvise ((void *) ((unsigned long) ptr & (~0xfff)), 4096, 0); if (ret == -1 && errno == ENOMEM) { buffer = g_strdup_printf ("%p (unmapped memory)", ptr); } @@ -367,14 +349,14 @@ gst_debug_print_object (gpointer ptr) if (object == NULL) { return g_strdup ("(NULL)"); } - if (*(GType *)ptr == GST_TYPE_CAPS) { - return gst_caps_to_string ((GstCaps *)ptr); + if (*(GType *) ptr == GST_TYPE_CAPS) { + return gst_caps_to_string ((GstCaps *) ptr); } - if (*(GType *)ptr == GST_TYPE_STRUCTURE) { - return gst_structure_to_string ((GstStructure *)ptr); + if (*(GType *) ptr == GST_TYPE_STRUCTURE) { + return gst_structure_to_string ((GstStructure *) ptr); } #ifdef USE_POISONING - if (*(guint32 *)ptr == 0xffffffff) { + if (*(guint32 *) ptr == 0xffffffff) { return g_strdup_printf ("", ptr); } #endif @@ -385,7 +367,7 @@ gst_debug_print_object (gpointer ptr) return g_strdup_printf ("<%s>", GST_OBJECT_NAME (object)); } if (G_IS_OBJECT (object)) { - return g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME(object), object); + return g_strdup_printf ("<%s@%p>", G_OBJECT_TYPE_NAME (object), object); } return g_strdup_printf ("%p", ptr); @@ -419,7 +401,8 @@ gst_debug_construct_term_color (guint colorinfo) g_string_append_printf (color, ";3%1d", colorinfo & GST_DEBUG_FG_MASK); } if (colorinfo & GST_DEBUG_BG_MASK) { - g_string_append_printf (color, ";4%1d", (colorinfo & GST_DEBUG_BG_MASK) >> 4); + g_string_append_printf (color, ";4%1d", + (colorinfo & GST_DEBUG_BG_MASK) >> 4); } g_string_append (color, "m"); @@ -427,6 +410,7 @@ gst_debug_construct_term_color (guint colorinfo) g_string_free (color, FALSE); return ret; } + /** * gst_debug_log_default: * @category: category to log @@ -446,24 +430,26 @@ gst_debug_construct_term_color (guint colorinfo) * gst_debug_remove_log_function (gst_debug_log_default); */ void -gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level, - const gchar *file, const gchar *function, gint line, - GObject *object, GstDebugMessage *message, gpointer unused) +gst_debug_log_default (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, + GObject * object, GstDebugMessage * message, gpointer unused) { gchar *color; gchar *clear; gchar *obj; gchar *pidcolor; gint pid; - + if (level > gst_debug_category_get_threshold (category)) return; - - pid = getpid(); + + pid = getpid (); /* color info */ if (gst_debug_is_colored ()) { - color = gst_debug_construct_term_color (gst_debug_category_get_color (category)); + color = + gst_debug_construct_term_color (gst_debug_category_get_color + (category)); clear = "\033[00m"; pidcolor = g_strdup_printf ("\033[3%1dm", pid % 6 + 31); } else { @@ -474,17 +460,17 @@ gst_debug_log_default (GstDebugCategory *category, GstDebugLevel level, obj = object ? gst_debug_print_object (object) : g_strdup (""); - g_printerr ("%s %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n", - gst_debug_level_get_name (level), - color, gst_debug_category_get_name (category), clear, - pidcolor, pid, clear, - color, file, line, function, obj, clear, - gst_debug_message_get (message)); + g_printerr ("%s %s%15s%s(%s%5d%s) %s%s(%d):%s:%s%s %s\n", + gst_debug_level_get_name (level), + color, gst_debug_category_get_name (category), clear, + pidcolor, pid, clear, + color, file, line, function, obj, clear, gst_debug_message_get (message)); g_free (color); g_free (pidcolor); g_free (obj); } + /** * gst_debug_level_get_name: * @level: the level to get the name for @@ -497,17 +483,24 @@ const gchar * gst_debug_level_get_name (GstDebugLevel level) { switch (level) { - case GST_LEVEL_NONE: return ""; - case GST_LEVEL_ERROR: return "ERROR"; - case GST_LEVEL_WARNING: return "WARN "; - case GST_LEVEL_INFO: return "INFO "; - case GST_LEVEL_DEBUG: return "DEBUG"; - case GST_LEVEL_LOG: return "LOG "; + case GST_LEVEL_NONE: + return ""; + case GST_LEVEL_ERROR: + return "ERROR"; + case GST_LEVEL_WARNING: + return "WARN "; + case GST_LEVEL_INFO: + return "INFO "; + case GST_LEVEL_DEBUG: + return "DEBUG"; + case GST_LEVEL_LOG: + return "LOG "; default: g_warning ("invalid level specified for gst_debug_level_get_name"); return ""; } } + /** * gst_debug_add_log_function: * @func: the function to use @@ -539,28 +532,32 @@ gst_debug_add_log_function (GstLogFunction func, gpointer data) g_static_mutex_unlock (&__log_func_mutex); GST_DEBUG ("prepended log function %p (user data %p) to log functions", - func, data); + func, data); } + static gint gst_debug_compare_log_function_by_func (gconstpointer entry, gconstpointer func) { gpointer entryfunc = ((LogFuncEntry *) entry)->func; - + return (entryfunc < func) ? -1 : (entryfunc > func) ? 1 : 0; } + static gint gst_debug_compare_log_function_by_data (gconstpointer entry, gconstpointer data) { gpointer entrydata = ((LogFuncEntry *) entry)->user_data; - + return (entrydata < data) ? -1 : (entrydata > data) ? 1 : 0; } + static guint gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data) { GSList *found; GSList *new; guint removals = 0; + g_static_mutex_lock (&__log_func_mutex); new = __log_functions; while ((found = g_slist_find_custom (new, data, func))) { @@ -578,6 +575,7 @@ gst_debug_remove_with_compare_func (GCompareFunc func, gpointer data) return removals; } + /** * gst_debug_remove_log_function: * @func: the log function to remove @@ -590,15 +588,18 @@ guint gst_debug_remove_log_function (GstLogFunction func) { guint removals; - + g_return_val_if_fail (func != NULL, 0); - removals = gst_debug_remove_with_compare_func (gst_debug_compare_log_function_by_func, func); - GST_DEBUG ("removed log function %p %d times from log function list", - func, removals); + removals = + gst_debug_remove_with_compare_func + (gst_debug_compare_log_function_by_func, func); + GST_DEBUG ("removed log function %p %d times from log function list", func, + removals); return removals; } + /** * gst_debug_remove_log_function_by_data: * @data: user data of the log function to remove @@ -612,12 +613,16 @@ gst_debug_remove_log_function_by_data (gpointer data) { guint removals; - removals = gst_debug_remove_with_compare_func (gst_debug_compare_log_function_by_data, data); - GST_DEBUG ("removed %d log functions with user data %p from log function list", - removals, data); + removals = + gst_debug_remove_with_compare_func + (gst_debug_compare_log_function_by_data, data); + GST_DEBUG + ("removed %d log functions with user data %p from log function list", + removals, data); return removals; } + /** * gst_debug_set_colored: * @colored: Whether to use colored output or not @@ -629,6 +634,7 @@ gst_debug_set_colored (gboolean colored) { gst_atomic_int_set (&__use_color, colored ? 1 : 0); } + /** * gst_debug_is_colored: * @@ -641,6 +647,7 @@ gst_debug_is_colored (void) { return gst_atomic_int_read (&__use_color) == 0 ? FALSE : TRUE; } + /** * gst_debug_set_active: * @active: Whether to use debugging output or not @@ -656,6 +663,7 @@ gst_debug_set_active (gboolean active) { __gst_debug_enabled = active; } + /** * gst_debug_is_active: * @@ -668,6 +676,7 @@ gst_debug_is_active (void) { return __gst_debug_enabled; } + /** * gst_debug_set_default_threshold: * @level: level to set @@ -681,6 +690,7 @@ gst_debug_set_default_threshold (GstDebugLevel level) gst_atomic_int_set (&__default_level, level); gst_debug_reset_all_thresholds (); } + /** * gst_debug_get_default_threshold: * @@ -690,7 +700,7 @@ gst_debug_set_default_threshold (GstDebugLevel level) */ GstDebugLevel gst_debug_get_default_threshold (void) -{ +{ return (GstDebugLevel) gst_atomic_int_read (&__default_level); } static void @@ -698,15 +708,16 @@ gst_debug_reset_threshold (gpointer category, gpointer unused) { GstDebugCategory *cat = (GstDebugCategory *) category; GSList *walk; - + g_static_mutex_lock (&__level_name_mutex); walk = __level_name; while (walk) { LevelNameEntry *entry = walk->data; + walk = g_slist_next (walk); if (g_pattern_match_string (entry->pat, cat->name)) { GST_LOG ("category %s matches pattern %p - gets set to level %d", - cat->name, entry->pat, entry->level); + cat->name, entry->pat, entry->level); gst_debug_category_set_threshold (cat, entry->level); goto exit; } @@ -731,10 +742,11 @@ for_each_threshold_by_entry (gpointer data, gpointer user_data) if (g_pattern_match_string (entry->pat, cat->name)) { GST_LOG ("category %s matches pattern %p - gets set to level %d", - cat->name, entry->pat, entry->level); + cat->name, entry->pat, entry->level); gst_debug_category_set_threshold (cat, entry->level); } } + /** * gst_debug_set_threshold_for_name: * @name: name of the categories to set @@ -744,11 +756,11 @@ for_each_threshold_by_entry (gpointer data, gpointer user_data) * level. */ void -gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level) +gst_debug_set_threshold_for_name (const gchar * name, GstDebugLevel level) { GPatternSpec *pat; LevelNameEntry *entry; - + g_return_if_fail (name != NULL); pat = g_pattern_spec_new (name); @@ -762,6 +774,7 @@ gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level) g_slist_foreach (__categories, for_each_threshold_by_entry, entry); g_static_mutex_unlock (&__cat_mutex); } + /** * gst_debug_unset_threshold_for_name: * @name: name of the categories to set @@ -769,11 +782,11 @@ gst_debug_set_threshold_for_name (const gchar *name, GstDebugLevel level) * Resets all categories with the given name back to the default level. */ void -gst_debug_unset_threshold_for_name (const gchar *name) +gst_debug_unset_threshold_for_name (const gchar * name) { GSList *walk; GPatternSpec *pat; - + g_return_if_fail (name != NULL); pat = g_pattern_spec_new (name); @@ -782,6 +795,7 @@ gst_debug_unset_threshold_for_name (const gchar *name) /* improve this if you want, it's mighty slow */ while (walk) { LevelNameEntry *entry = walk->data; + if (g_pattern_spec_equal (entry->pat, pat)) { __level_name = g_slist_remove_link (__level_name, walk); g_pattern_spec_free (entry->pat); @@ -794,11 +808,12 @@ gst_debug_unset_threshold_for_name (const gchar *name) g_pattern_spec_free (pat); gst_debug_reset_all_thresholds (); } + GstDebugCategory * -_gst_debug_category_new (gchar *name, guint color, gchar *description) +_gst_debug_category_new (gchar * name, guint color, gchar * description) { GstDebugCategory *cat; - + g_return_val_if_fail (name != NULL, NULL); cat = g_new (GstDebugCategory, 1); @@ -820,6 +835,7 @@ _gst_debug_category_new (gchar *name, guint color, gchar *description) return cat; } + /** * gst_debug_category_free: * @category: #GstDebugCategory to free. @@ -827,9 +843,10 @@ _gst_debug_category_new (gchar *name, guint color, gchar *description) * Removes and frees the category and all associated resources. */ void -gst_debug_category_free (GstDebugCategory *category) +gst_debug_category_free (GstDebugCategory * category) { - if (category == NULL) return; + if (category == NULL) + return; /* remove from category list */ g_static_mutex_lock (&__cat_mutex); @@ -858,7 +875,8 @@ gst_debug_category_free (GstDebugCategory *category) * */ void -gst_debug_category_set_threshold (GstDebugCategory *category, GstDebugLevel level) +gst_debug_category_set_threshold (GstDebugCategory * category, + GstDebugLevel level) { g_return_if_fail (category != NULL); @@ -876,7 +894,7 @@ gst_debug_category_set_threshold (GstDebugCategory *category, GstDebugLevel leve * gst_debug_category_set_threshold(). */ void -gst_debug_category_reset_threshold (GstDebugCategory *category) +gst_debug_category_reset_threshold (GstDebugCategory * category) { gst_debug_reset_threshold (category, NULL); } @@ -890,7 +908,7 @@ gst_debug_category_reset_threshold (GstDebugCategory *category) * Returns: the #GstDebugLevel that is used as threshold. */ GstDebugLevel -gst_debug_category_get_threshold (GstDebugCategory *category) +gst_debug_category_get_threshold (GstDebugCategory * category) { return gst_atomic_int_read (category->threshold); } @@ -904,7 +922,7 @@ gst_debug_category_get_threshold (GstDebugCategory *category) * Returns: the name of the category. */ const gchar * -gst_debug_category_get_name (GstDebugCategory *category) +gst_debug_category_get_name (GstDebugCategory * category) { return category->name; } @@ -919,7 +937,7 @@ gst_debug_category_get_name (GstDebugCategory *category) * Returns: the color of the category. */ guint -gst_debug_category_get_color (GstDebugCategory *category) +gst_debug_category_get_color (GstDebugCategory * category) { return category->color; } @@ -933,10 +951,11 @@ gst_debug_category_get_color (GstDebugCategory *category) * Returns: the description of the category. */ const gchar * -gst_debug_category_get_description (GstDebugCategory *category) +gst_debug_category_get_description (GstDebugCategory * category) { return category->description; } + /** * gst_debug_get_all_categories: * @@ -957,44 +976,49 @@ gst_debug_get_all_categories (void) ret = g_slist_copy (__categories); g_static_mutex_unlock (&__cat_mutex); - return ret; + return ret; } /*** FUNCTION POINTERS ********************************************************/ GHashTable *__gst_function_pointers = NULL; -const gchar *_gst_debug_nameof_funcptr (void *ptr) G_GNUC_NO_INSTRUMENT; - -/* This function MUST NOT return NULL */ const gchar * _gst_debug_nameof_funcptr (void *ptr) + G_GNUC_NO_INSTRUMENT; + +/* This function MUST NOT return NULL */ + const gchar *_gst_debug_nameof_funcptr (void *ptr) { gchar *ptrname; + #ifdef HAVE_DLADDR Dl_info dlinfo; #endif - if (__gst_function_pointers && (ptrname = g_hash_table_lookup(__gst_function_pointers,ptr))) { + if (__gst_function_pointers + && (ptrname = g_hash_table_lookup (__gst_function_pointers, ptr))) { return ptrname; } /* we need to create an entry in the hash table for this one so we don't leak * the name */ #ifdef HAVE_DLADDR - if (dladdr(ptr,&dlinfo) && dlinfo.dli_sname) { + if (dladdr (ptr, &dlinfo) && dlinfo.dli_sname) { gchar *name = g_strdup (dlinfo.dli_sname); + _gst_debug_register_funcptr (ptr, name); return name; } else #endif { gchar *name = g_strdup_printf ("%p", ptr); + _gst_debug_register_funcptr (ptr, name); return name; } } void * -_gst_debug_register_funcptr (void *ptr, gchar *ptrname) +_gst_debug_register_funcptr (void *ptr, gchar * ptrname) { if (!__gst_function_pointers) __gst_function_pointers = g_hash_table_new (g_direct_hash, g_direct_equal); @@ -1006,7 +1030,7 @@ _gst_debug_register_funcptr (void *ptr, gchar *ptrname) #ifdef HAVE_PRINTF_EXTENSION static int -_gst_info_printf_extension (FILE *stream, const struct printf_info *info, +_gst_info_printf_extension (FILE * stream, const struct printf_info *info, const void *const *args) { char *buffer; @@ -1014,7 +1038,7 @@ _gst_info_printf_extension (FILE *stream, const struct printf_info *info, void *ptr; buffer = NULL; - ptr = *(void **)args[0]; + ptr = *(void **) args[0]; buffer = gst_debug_print_object (ptr); len = fprintf (stream, "%*s", (info->left ? -info->width : info->width), @@ -1040,32 +1064,39 @@ _gst_info_printf_extension_arginfo (const struct printf_info *info, size_t n, /* FIXME make this thread specific */ static GSList *stack_trace = NULL; -void __cyg_profile_func_enter(void *this_fn,void *call_site) G_GNUC_NO_INSTRUMENT; -void __cyg_profile_func_enter(void *this_fn,void *call_site) +void +__cyg_profile_func_enter (void *this_fn, void *call_site) + G_GNUC_NO_INSTRUMENT; + void __cyg_profile_func_enter (void *this_fn, void *call_site) { gchar *name = _gst_debug_nameof_funcptr (this_fn); gchar *site = _gst_debug_nameof_funcptr (call_site); - - GST_CAT_DEBUG(GST_CAT_CALL_TRACE, "entering function %s from %s", name, site); - stack_trace = g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)", this_fn, name, call_site, site)); + + GST_CAT_DEBUG (GST_CAT_CALL_TRACE, "entering function %s from %s", name, + site); + stack_trace = + g_slist_prepend (stack_trace, g_strdup_printf ("%8p in %s from %p (%s)", + this_fn, name, call_site, site)); g_free (name); g_free (site); } -void __cyg_profile_func_exit(void *this_fn,void *call_site) G_GNUC_NO_INSTRUMENT; -void __cyg_profile_func_exit(void *this_fn,void *call_site) +void +__cyg_profile_func_exit (void *this_fn, void *call_site) + G_GNUC_NO_INSTRUMENT; + void __cyg_profile_func_exit (void *this_fn, void *call_site) { gchar *name = _gst_debug_nameof_funcptr (this_fn); - GST_CAT_DEBUG(GST_CAT_CALL_TRACE, "leaving function %s", name); + GST_CAT_DEBUG (GST_CAT_CALL_TRACE, "leaving function %s", name); g_free (stack_trace->data); stack_trace = g_slist_delete_link (stack_trace, stack_trace); g_free (name); } -void +void gst_debug_print_stack_trace (void) { GSList *walk = stack_trace; @@ -1083,7 +1114,7 @@ gst_debug_print_stack_trace (void) } } #else -void +void gst_debug_print_stack_trace (void) { /* nothing because it's compiled out */ diff --git a/gst/gstinfo.h b/gst/gstinfo.h index 28df24f0b..1f7b3271a 100644 --- a/gst/gstinfo.h +++ b/gst/gstinfo.h @@ -31,16 +31,15 @@ #include G_BEGIN_DECLS - /* * GStreamer's debugging subsystem is an easy way to get information about what * the application is doing. * It is not meant for programming errors. Use GLibs methods (g_warning and so * on for that. */ - /* log levels */ -typedef enum { + typedef enum +{ GST_LEVEL_NONE = 0, GST_LEVEL_ERROR, GST_LEVEL_WARNING, @@ -64,28 +63,29 @@ typedef enum { * Background color codes: * 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white */ -typedef enum { +typedef enum +{ /* colors */ - GST_DEBUG_FG_BLACK = 0x0000, - GST_DEBUG_FG_RED = 0x0001, - GST_DEBUG_FG_GREEN = 0x0002, - GST_DEBUG_FG_YELLOW = 0x0003, - GST_DEBUG_FG_BLUE = 0x0004, - GST_DEBUG_FG_MAGENTA = 0x0005, - GST_DEBUG_FG_CYAN = 0x0006, - GST_DEBUG_FG_WHITE = 0x0007, + GST_DEBUG_FG_BLACK = 0x0000, + GST_DEBUG_FG_RED = 0x0001, + GST_DEBUG_FG_GREEN = 0x0002, + GST_DEBUG_FG_YELLOW = 0x0003, + GST_DEBUG_FG_BLUE = 0x0004, + GST_DEBUG_FG_MAGENTA = 0x0005, + GST_DEBUG_FG_CYAN = 0x0006, + GST_DEBUG_FG_WHITE = 0x0007, /* background colors */ - GST_DEBUG_BG_BLACK = 0x0000, - GST_DEBUG_BG_RED = 0x0010, - GST_DEBUG_BG_GREEN = 0x0020, - GST_DEBUG_BG_YELLOW = 0x0030, - GST_DEBUG_BG_BLUE = 0x0040, - GST_DEBUG_BG_MAGENTA = 0x0050, - GST_DEBUG_BG_CYAN = 0x0060, - GST_DEBUG_BG_WHITE = 0x0070, + GST_DEBUG_BG_BLACK = 0x0000, + GST_DEBUG_BG_RED = 0x0010, + GST_DEBUG_BG_GREEN = 0x0020, + GST_DEBUG_BG_YELLOW = 0x0030, + GST_DEBUG_BG_BLUE = 0x0040, + GST_DEBUG_BG_MAGENTA = 0x0050, + GST_DEBUG_BG_CYAN = 0x0060, + GST_DEBUG_BG_WHITE = 0x0070, /* other formats */ - GST_DEBUG_BOLD = 0x0100, - GST_DEBUG_UNDERLINE = 0x0200 + GST_DEBUG_BOLD = 0x0100, + GST_DEBUG_UNDERLINE = 0x0200 } GstDebugColorFlags; #define GST_DEBUG_FG_MASK (0x000F) @@ -93,13 +93,14 @@ typedef enum { #define GST_DEBUG_FORMAT_MASK (0xFF00) typedef struct _GstDebugCategory GstDebugCategory; -struct _GstDebugCategory { - /*< private >*/ - GstAtomicInt * threshold; - guint color; /* see defines above */ - - const gchar * name; - const gchar * description; +struct _GstDebugCategory +{ + /*< private > */ + GstAtomicInt *threshold; + guint color; /* see defines above */ + + const gchar *name; + const gchar *description; }; /********** some convenience macros for debugging **********/ @@ -127,14 +128,11 @@ struct _GstDebugCategory { typedef struct _GstDebugMessage GstDebugMessage; -typedef void (*GstLogFunction) (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - GstDebugMessage * message, - gpointer data); +typedef void (*GstLogFunction) (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, GObject * object, GstDebugMessage * message, gpointer data); /* Disable this subsystem if no varargs macro can be found. Use a trick so the core builds the functions nonetheless if it wasn't @@ -150,57 +148,51 @@ typedef void (*GstLogFunction) (GstDebugCategory * category, #ifndef __GST_DISABLE_GST_DEBUG -void _gst_debug_init (void); +void _gst_debug_init (void); /* note we can't use G_GNUC_PRINTF (7, 8) because gcc chokes on %P, which * we use for GST_PTR_FORMAT. */ -void gst_debug_log (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - const gchar * format, - ...) G_GNUC_NO_INSTRUMENT; -void gst_debug_log_valist (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - const gchar * format, - va_list args) G_GNUC_NO_INSTRUMENT; - -const gchar * gst_debug_message_get (GstDebugMessage * message); - -void gst_debug_log_default (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - GstDebugMessage * message, - gpointer unused) G_GNUC_NO_INSTRUMENT; - -G_CONST_RETURN gchar * - gst_debug_level_get_name (GstDebugLevel level); - -void gst_debug_add_log_function (GstLogFunction func, - gpointer data); -guint gst_debug_remove_log_function (GstLogFunction func); -guint gst_debug_remove_log_function_by_data (gpointer data); - -void gst_debug_set_active (gboolean active); -gboolean gst_debug_is_active (void); - -void gst_debug_set_colored (gboolean colored); -gboolean gst_debug_is_colored (void); - -void gst_debug_set_default_threshold (GstDebugLevel level); -GstDebugLevel gst_debug_get_default_threshold (void); -void gst_debug_set_threshold_for_name (const gchar * name, - GstDebugLevel level); -void gst_debug_unset_threshold_for_name (const gchar * name); +void +gst_debug_log (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, GObject * object, const gchar * format, ...) + G_GNUC_NO_INSTRUMENT; + void gst_debug_log_valist (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, const gchar * format, va_list args) G_GNUC_NO_INSTRUMENT; + + const gchar *gst_debug_message_get (GstDebugMessage * message); + + void gst_debug_log_default (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, + GstDebugMessage * message, gpointer unused) G_GNUC_NO_INSTRUMENT; + + G_CONST_RETURN gchar *gst_debug_level_get_name (GstDebugLevel level); + + void gst_debug_add_log_function (GstLogFunction func, gpointer data); + guint gst_debug_remove_log_function (GstLogFunction func); + guint gst_debug_remove_log_function_by_data (gpointer data); + + void gst_debug_set_active (gboolean active); + gboolean gst_debug_is_active (void); + + void gst_debug_set_colored (gboolean colored); + gboolean gst_debug_is_colored (void); + + void gst_debug_set_default_threshold (GstDebugLevel level); + GstDebugLevel gst_debug_get_default_threshold (void); + void gst_debug_set_threshold_for_name (const gchar * name, + GstDebugLevel level); + void gst_debug_unset_threshold_for_name (const gchar * name); /** * GST_DEBUG_CATEGORY: @@ -227,9 +219,8 @@ void gst_debug_unset_threshold_for_name (const gchar * name); */ #define GST_DEBUG_CATEGORY_STATIC(cat) static GstDebugCategory *cat = NULL /* do not use this function, use the macros below */ -GstDebugCategory *_gst_debug_category_new (gchar * name, - guint color, - gchar * description); + GstDebugCategory *_gst_debug_category_new (gchar * name, + guint color, gchar * description); /** * GST_DEBUG_CATEGORY_INIT: * @cat: the category to initialize. @@ -270,24 +261,27 @@ GstDebugCategory *_gst_debug_category_new (gchar * name, cat = _gst_debug_category_new (name,color,description); \ }G_STMT_END -void gst_debug_category_free (GstDebugCategory * category); -void gst_debug_category_set_threshold (GstDebugCategory * category, - GstDebugLevel level); -void gst_debug_category_reset_threshold (GstDebugCategory * category); -GstDebugLevel gst_debug_category_get_threshold (GstDebugCategory * category); -G_CONST_RETURN gchar * - gst_debug_category_get_name (GstDebugCategory * category); -guint gst_debug_category_get_color (GstDebugCategory * category); -G_CONST_RETURN gchar * - gst_debug_category_get_description (GstDebugCategory * category); -GSList * gst_debug_get_all_categories (void); + void gst_debug_category_free (GstDebugCategory * category); + void gst_debug_category_set_threshold (GstDebugCategory * category, + GstDebugLevel level); + void gst_debug_category_reset_threshold (GstDebugCategory * category); + GstDebugLevel gst_debug_category_get_threshold (GstDebugCategory * + category); + G_CONST_RETURN gchar *gst_debug_category_get_name (GstDebugCategory * + category); + guint gst_debug_category_get_color (GstDebugCategory * category); + G_CONST_RETURN gchar *gst_debug_category_get_description (GstDebugCategory + * category); + GSList *gst_debug_get_all_categories (void); -gchar * gst_debug_construct_term_color (guint colorinfo); + gchar *gst_debug_construct_term_color (guint colorinfo); -extern GstDebugCategory * GST_CAT_DEFAULT; + extern GstDebugCategory *GST_CAT_DEFAULT; + /* this symbol may not be used */ -extern gboolean __gst_debug_enabled; + extern gboolean __gst_debug_enabled; + #ifdef G_HAVE_ISO_VARARGS #define GST_CAT_LEVEL_LOG(cat,level,object,...) G_STMT_START{ \ if (__gst_debug_enabled) { \ @@ -386,10 +380,8 @@ extern gboolean __gst_debug_enabled; /********** function pointer stuff **********/ -void* _gst_debug_register_funcptr (void * ptr, - gchar * ptrname); -G_CONST_RETURN gchar* - _gst_debug_nameof_funcptr (void * ptr); + void *_gst_debug_register_funcptr (void *ptr, gchar * ptrname); + G_CONST_RETURN gchar *_gst_debug_nameof_funcptr (void *ptr); #define GST_DEBUG_FUNCPTR(ptr) (_gst_debug_register_funcptr((void *)(ptr), #ptr) , ptr) #define GST_DEBUG_FUNCPTR_NAME(ptr) _gst_debug_nameof_funcptr((void *)ptr) @@ -403,34 +395,34 @@ G_CONST_RETURN gchar* # pragma GCC poison _gst_debug_category_new #endif -#define _gst_debug_init() /* NOP */ +#define _gst_debug_init() /* NOP */ -#define gst_debug_set_log_function(func,data) /* NOP */ -#define gst_debug_reset_log_function(void) /* NOP */ -#define gst_debug_set_default_threshold(level) /* NOP */ +#define gst_debug_set_log_function(func,data) /* NOP */ +#define gst_debug_reset_log_function(void) /* NOP */ +#define gst_debug_set_default_threshold(level) /* NOP */ #define gst_debug_get_default_threshold() (GST_LEVEL_NONE) -#define gst_debug_category_set_threshold_for_name(name, level) /* NOP */ -#define gst_debug_category_unset_threshold_for_name(name) /* NOP */ +#define gst_debug_category_set_threshold_for_name(name, level) /* NOP */ +#define gst_debug_category_unset_threshold_for_name(name) /* NOP */ #define gst_debug_level_get_name(level) ("NONE") #define gst_debug_add_log_function(func,data) (FALSE) #define gst_debug_remove_log_function(func) (0) #define gst_debug_remove_log_function_by_data(data) (0) -#define gst_debug_set_active(active) /* NOP */ +#define gst_debug_set_active(active) /* NOP */ #define gst_debug_is_active() (FALSE) -#define gst_debug_set_colored(colored) /* NOP */ +#define gst_debug_set_colored(colored) /* NOP */ #define gst_debug_is_colored() (FALSE) -#define gst_debug_set_default_threshold(level) /* NOP */ +#define gst_debug_set_default_threshold(level) /* NOP */ #define gst_debug_get_default_threshold() (GST_LEVEL_NONE) #define gst_debug_set_threshold_for_name(name,level) /* NOP */ #define gst_debug_unset_threshold_for_name(name) /* NOP */ -#define GST_DEBUG_CATEGORY(var) /* NOP */ -#define GST_DEBUG_CATEGORY_EXTERN(var) /* NOP */ -#define GST_DEBUG_CATEGORY_STATIC(var) /* NOP */ +#define GST_DEBUG_CATEGORY(var) /* NOP */ +#define GST_DEBUG_CATEGORY_EXTERN(var) /* NOP */ +#define GST_DEBUG_CATEGORY_STATIC(var) /* NOP */ #define GST_DEBUG_CATEGORY_INIT(var,name,color,desc) /* NOP */ -#define gst_debug_category_free(category) /* NOP */ -#define gst_debug_category_set_threshold(category,level) /* NOP */ +#define gst_debug_category_free(category) /* NOP */ +#define gst_debug_category_set_threshold(category,level) /* NOP */ #define gst_debug_category_reset_threshold(category) /* NOP */ #define gst_debug_category_get_threshold(category) (GST_LEVEL_NONE) #define gst_debug_category_get_name(cat) ("") @@ -441,76 +433,76 @@ G_CONST_RETURN gchar* #ifdef G_HAVE_ISO_VARARGS -#define GST_CAT_LEVEL_LOG(cat,level,...) /* NOP */ +#define GST_CAT_LEVEL_LOG(cat,level,...) /* NOP */ -#define GST_CAT_ERROR_OBJECT(...) /* NOP */ -#define GST_CAT_WARNING_OBJECT(...) /* NOP */ -#define GST_CAT_INFO_OBJECT(...) /* NOP */ -#define GST_CAT_DEBUG_OBJECT(...) /* NOP */ -#define GST_CAT_LOG_OBJECT(...) /* NOP */ +#define GST_CAT_ERROR_OBJECT(...) /* NOP */ +#define GST_CAT_WARNING_OBJECT(...) /* NOP */ +#define GST_CAT_INFO_OBJECT(...) /* NOP */ +#define GST_CAT_DEBUG_OBJECT(...) /* NOP */ +#define GST_CAT_LOG_OBJECT(...) /* NOP */ -#define GST_CAT_ERROR(...) /* NOP */ -#define GST_CAT_WARNING(...) /* NOP */ -#define GST_CAT_INFO(...) /* NOP */ -#define GST_CAT_DEBUG(...) /* NOP */ -#define GST_CAT_LOG(...) /* NOP */ +#define GST_CAT_ERROR(...) /* NOP */ +#define GST_CAT_WARNING(...) /* NOP */ +#define GST_CAT_INFO(...) /* NOP */ +#define GST_CAT_DEBUG(...) /* NOP */ +#define GST_CAT_LOG(...) /* NOP */ -#define GST_ERROR_OBJECT(...) /* NOP */ -#define GST_WARNING_OBJECT(...) /* NOP */ -#define GST_INFO_OBJECT(...) /* NOP */ -#define GST_DEBUG_OBJECT(...) /* NOP */ -#define GST_LOG_OBJECT(...) /* NOP */ +#define GST_ERROR_OBJECT(...) /* NOP */ +#define GST_WARNING_OBJECT(...) /* NOP */ +#define GST_INFO_OBJECT(...) /* NOP */ +#define GST_DEBUG_OBJECT(...) /* NOP */ +#define GST_LOG_OBJECT(...) /* NOP */ -#define GST_ERROR(...) /* NOP */ -#define GST_WARNING(...) /* NOP */ -#define GST_INFO(...) /* NOP */ -#define GST_DEBUG(...) /* NOP */ -#define GST_LOG(...) /* NOP */ +#define GST_ERROR(...) /* NOP */ +#define GST_WARNING(...) /* NOP */ +#define GST_INFO(...) /* NOP */ +#define GST_DEBUG(...) /* NOP */ +#define GST_LOG(...) /* NOP */ #ifdef GST_DEBUG_ENABLE_DEPRECATED -#define GST_INFO_ELEMENT(cat,obj,...) /* NOP */ -#define GST_DEBUG_ELEMENT(cat,obj,...) /* NOP */ -#define GST_DEBUG_ENTER(...) /* NOP */ -#define GST_DEBUG_LEAVE(...) /* NOP */ -#define GST_INFO_ENTER(...) /* NOP */ -#define GST_INFO_LEAVE(...) /* NOP */ +#define GST_INFO_ELEMENT(cat,obj,...) /* NOP */ +#define GST_DEBUG_ELEMENT(cat,obj,...) /* NOP */ +#define GST_DEBUG_ENTER(...) /* NOP */ +#define GST_DEBUG_LEAVE(...) /* NOP */ +#define GST_INFO_ENTER(...) /* NOP */ +#define GST_INFO_LEAVE(...) /* NOP */ #endif /* GST_DEBUG_ENABLE_DEPRECATED */ #else /* !G_HAVE_ISO_VARARGS */ -#define GST_CAT_LEVEL_LOG(cat,level,args...) /* NOP */ +#define GST_CAT_LEVEL_LOG(cat,level,args...) /* NOP */ -#define GST_CAT_ERROR_OBJECT(args...) /* NOP */ -#define GST_CAT_WARNING_OBJECT(args...) /* NOP */ -#define GST_CAT_INFO_OBJECT(args...) /* NOP */ -#define GST_CAT_DEBUG_OBJECT(args...) /* NOP */ -#define GST_CAT_LOG_OBJECT(args...) /* NOP */ +#define GST_CAT_ERROR_OBJECT(args...) /* NOP */ +#define GST_CAT_WARNING_OBJECT(args...) /* NOP */ +#define GST_CAT_INFO_OBJECT(args...) /* NOP */ +#define GST_CAT_DEBUG_OBJECT(args...) /* NOP */ +#define GST_CAT_LOG_OBJECT(args...) /* NOP */ -#define GST_CAT_ERROR(args...) /* NOP */ -#define GST_CAT_WARNING(args...) /* NOP */ -#define GST_CAT_INFO(args...) /* NOP */ -#define GST_CAT_DEBUG(args...) /* NOP */ -#define GST_CAT_LOG(args...) /* NOP */ +#define GST_CAT_ERROR(args...) /* NOP */ +#define GST_CAT_WARNING(args...) /* NOP */ +#define GST_CAT_INFO(args...) /* NOP */ +#define GST_CAT_DEBUG(args...) /* NOP */ +#define GST_CAT_LOG(args...) /* NOP */ -#define GST_ERROR_OBJECT(args...) /* NOP */ -#define GST_WARNING_OBJECT(args...) /* NOP */ -#define GST_INFO_OBJECT(args...) /* NOP */ -#define GST_DEBUG_OBJECT(args...) /* NOP */ -#define GST_LOG_OBJECT(args...) /* NOP */ +#define GST_ERROR_OBJECT(args...) /* NOP */ +#define GST_WARNING_OBJECT(args...) /* NOP */ +#define GST_INFO_OBJECT(args...) /* NOP */ +#define GST_DEBUG_OBJECT(args...) /* NOP */ +#define GST_LOG_OBJECT(args...) /* NOP */ -#define GST_ERROR(args...) /* NOP */ -#define GST_WARNING(args...) /* NOP */ -#define GST_INFO(args...) /* NOP */ -#define GST_DEBUG(args...) /* NOP */ -#define GST_LOG(args...) /* NOP */ +#define GST_ERROR(args...) /* NOP */ +#define GST_WARNING(args...) /* NOP */ +#define GST_INFO(args...) /* NOP */ +#define GST_DEBUG(args...) /* NOP */ +#define GST_LOG(args...) /* NOP */ #ifdef GST_DEBUG_ENABLE_DEPRECATED -#define GST_INFO_ELEMENT(cat,obj,args...) /* NOP */ -#define GST_DEBUG_ELEMENT(cat,obj,args...) /* NOP */ -#define GST_DEBUG_ENTER(args...) /* NOP */ -#define GST_DEBUG_LEAVE(args...) /* NOP */ -#define GST_INFO_ENTER(args...) /* NOP */ -#define GST_INFO_LEAVE(args...) /* NOP */ +#define GST_INFO_ELEMENT(cat,obj,args...) /* NOP */ +#define GST_DEBUG_ELEMENT(cat,obj,args...) /* NOP */ +#define GST_DEBUG_ENTER(args...) /* NOP */ +#define GST_DEBUG_LEAVE(args...) /* NOP */ +#define GST_INFO_ENTER(args...) /* NOP */ +#define GST_INFO_LEAVE(args...) /* NOP */ #endif /* GST_DEBUG_ENABLE_DEPRECATED */ #endif /* G_HAVE_ISO_VARARGS */ @@ -523,5 +515,4 @@ G_CONST_RETURN gchar* void gst_debug_print_stack_trace (void); G_END_DECLS - #endif /* __GSTINFO_H__ */ diff --git a/gst/gstinterface.c b/gst/gstinterface.c index d2ea20d3e..f451fda14 100644 --- a/gst/gstinterface.c +++ b/gst/gstinterface.c @@ -29,10 +29,10 @@ #include "gstlog.h" static void -gst_implements_interface_class_init (GstImplementsInterfaceClass *ifklass); +gst_implements_interface_class_init (GstImplementsInterfaceClass * ifklass); static gboolean -gst_implements_interface_supported_default (GstImplementsInterface *iface, - GType iface_type); +gst_implements_interface_supported_default (GstImplementsInterface * iface, + GType iface_type); GType gst_implements_interface_get_type (void) @@ -54,25 +54,23 @@ gst_implements_interface_get_type (void) }; gst_interface_type = g_type_register_static (G_TYPE_INTERFACE, - "GstImplementsInterface", - &gst_interface_info, 0); + "GstImplementsInterface", &gst_interface_info, 0); - g_type_interface_add_prerequisite (gst_interface_type, - GST_TYPE_ELEMENT); + g_type_interface_add_prerequisite (gst_interface_type, GST_TYPE_ELEMENT); } return gst_interface_type; } static void -gst_implements_interface_class_init (GstImplementsInterfaceClass *klass) +gst_implements_interface_class_init (GstImplementsInterfaceClass * klass) { klass->supported = gst_implements_interface_supported_default; } static gboolean -gst_implements_interface_supported_default (GstImplementsInterface *interface, - GType iface_type) +gst_implements_interface_supported_default (GstImplementsInterface * interface, + GType iface_type) { /* Well, if someone didn't set the virtual function, * then something is clearly wrong. So big no-no here */ @@ -92,20 +90,18 @@ gst_implements_interface_supported_default (GstImplementsInterface *interface, */ gboolean -gst_element_implements_interface (GstElement *element, - GType iface_type) +gst_element_implements_interface (GstElement * element, GType iface_type) { - if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (element), - iface_type)) { + if (G_TYPE_CHECK_INSTANCE_TYPE (G_OBJECT (element), iface_type)) { GstImplementsInterface *iface; GstImplementsInterfaceClass *ifclass; iface = G_TYPE_CHECK_INSTANCE_CAST (G_OBJECT (element), - iface_type, GstImplementsInterface); + iface_type, GstImplementsInterface); ifclass = GST_IMPLEMENTS_INTERFACE_GET_CLASS (iface); if (ifclass->supported != NULL && - ifclass->supported (iface, iface_type) == TRUE) { + ifclass->supported (iface, iface_type) == TRUE) { return TRUE; } } @@ -125,23 +121,21 @@ gst_element_implements_interface (GstElement *element, */ gpointer -gst_implements_interface_cast (gpointer from, - GType iface_type) +gst_implements_interface_cast (gpointer from, GType iface_type) { GstImplementsInterface *iface; /* check cast, give warning+fail if it's invalid */ if (!(iface = G_TYPE_CHECK_INSTANCE_CAST (from, iface_type, - GstImplementsInterface))) { + GstImplementsInterface))) { return NULL; } /* if we're an element, take care that this interface * is actually implemented */ if (GST_IS_ELEMENT (from)) { - g_return_val_if_fail ( - gst_element_implements_interface (GST_ELEMENT (from), iface_type), - NULL); + g_return_val_if_fail (gst_element_implements_interface (GST_ELEMENT (from), + iface_type), NULL); } return iface; @@ -159,8 +153,7 @@ gst_implements_interface_cast (gpointer from, */ gboolean -gst_implements_interface_check (gpointer from, - GType type) +gst_implements_interface_check (gpointer from, GType type) { GstImplementsInterface *iface; diff --git a/gst/gstinterface.h b/gst/gstinterface.h index 8cd5ba3b1..6b1c25604 100644 --- a/gst/gstinterface.h +++ b/gst/gstinterface.h @@ -26,7 +26,6 @@ #include G_BEGIN_DECLS - #define GST_TYPE_IMPLEMENTS_INTERFACE \ (gst_implements_interface_get_type ()) #define GST_IMPLEMENTS_INTERFACE(obj) \ @@ -42,19 +41,18 @@ G_BEGIN_DECLS #define GST_IMPLEMENTS_INTERFACE_GET_CLASS(inst) \ (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_IMPLEMENTS_INTERFACE, \ GstImplementsInterfaceClass)) - typedef struct _GstImplementsInterface GstImplementsInterface; /* This small extra virtual function is here to provide an * interface functionality on a per-instance basis rather * than a per-class basis, which is the case for glib. */ -typedef struct _GstImplementsInterfaceClass { +typedef struct _GstImplementsInterfaceClass +{ GTypeInterface parent; /* virtual functions */ - gboolean (* supported) (GstImplementsInterface *iface, - GType iface_type); + gboolean (*supported) (GstImplementsInterface * iface, GType iface_type); gpointer _gst_reserved[GST_PADDING]; } GstImplementsInterfaceClass; @@ -64,16 +62,13 @@ typedef struct _GstImplementsInterfaceClass { #define GST_IMPLEMENTS_INTERFACE_CHECK_INSTANCE_TYPE(obj, type) \ (gst_implements_interface_check ((obj), (type))) -GType gst_implements_interface_get_type (void); +GType gst_implements_interface_get_type (void); /* wrapper functions to check for functionality implementation */ -gboolean gst_element_implements_interface (GstElement *element, - GType iface_type); -gpointer gst_implements_interface_cast (gpointer from, - GType type); -gboolean gst_implements_interface_check (gpointer from, - GType type); +gboolean gst_element_implements_interface (GstElement * element, + GType iface_type); +gpointer gst_implements_interface_cast (gpointer from, GType type); +gboolean gst_implements_interface_check (gpointer from, GType type); G_END_DECLS - #endif /* __GST_IMPLEMENTS_INTERFACE_H__ */ diff --git a/gst/gstlog.h b/gst/gstlog.h index 87596487f..9514b2f6e 100644 --- a/gst/gstlog.h +++ b/gst/gstlog.h @@ -25,9 +25,7 @@ #include -G_BEGIN_DECLS - -extern const char *g_log_domain_gstreamer; +G_BEGIN_DECLS extern const char *g_log_domain_gstreamer; #ifdef G_HAVE_ISO_VARARGS @@ -51,5 +49,4 @@ extern const char *g_log_domain_gstreamer; #endif G_END_DECLS - #endif /* __GST_LOG_H__ */ diff --git a/gst/gstmacros.h b/gst/gstmacros.h index 537d90ffc..3b040592e 100644 --- a/gst/gstmacros.h +++ b/gst/gstmacros.h @@ -21,24 +21,18 @@ #define __GST_MACROS_H__ G_BEGIN_DECLS - #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) # define GST_GNUC_CONSTRUCTOR \ - __attribute__ ((constructor)) -#else /* !__GNUC__ */ + __attribute__ ((constructor)) +#else /* !__GNUC__ */ # define GST_GNUC_CONSTRUCTOR #endif /* !__GNUC__ */ - #if defined (__GNUC__) && !defined (GST_IMPLEMENT_INLINES) # define GST_INLINE_FUNC extern __inline__ # define GST_CAN_INLINE 1 #else -# define GST_INLINE_FUNC extern +# define GST_INLINE_FUNC extern # undef GST_CAN_INLINE #endif - -G_END_DECLS - + G_END_DECLS #endif /* __GST_MACROS_H__ */ - - diff --git a/gst/gstmemchunk.c b/gst/gstmemchunk.c index b13833cba..ca32648b0 100644 --- a/gst/gstmemchunk.c +++ b/gst/gstmemchunk.c @@ -32,19 +32,19 @@ typedef struct _GstMemChunkElement GstMemChunkElement; struct _GstMemChunkElement { - GstTrashStackElement elem; /* make sure we can safely push it on the trashstack */ - gpointer area; /* pointer to data areas */ + GstTrashStackElement elem; /* make sure we can safely push it on the trashstack */ + gpointer area; /* pointer to data areas */ }; struct _GstMemChunk { - GstTrashStack stack; + GstTrashStack stack; - gchar *name; - gulong area_size; - gulong chunk_size; - gulong atom_size; - gboolean cleanup; + gchar *name; + gulong area_size; + gulong chunk_size; + gulong atom_size; + gboolean cleanup; }; /******************************************************* @@ -59,17 +59,17 @@ struct _GstMemChunk * */ static gboolean -populate (GstMemChunk *mem_chunk) +populate (GstMemChunk * mem_chunk) { guint8 *area; gint i; if (mem_chunk->cleanup) return FALSE; - + area = (guint8 *) g_malloc0 (mem_chunk->area_size); - for (i=0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) { + for (i = 0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) { GST_MEM_CHUNK_AREA (area + i) = area; gst_trash_stack_push (&mem_chunk->stack, area + i); } @@ -90,8 +90,8 @@ populate (GstMemChunk *mem_chunk) * * Returns: a new #GstMemChunk */ -GstMemChunk* -gst_mem_chunk_new (gchar* name, gint atom_size, gulong area_size, gint type) +GstMemChunk * +gst_mem_chunk_new (gchar * name, gint atom_size, gulong area_size, gint type) { GstMemChunk *mem_chunk; @@ -101,7 +101,7 @@ gst_mem_chunk_new (gchar* name, gint atom_size, gulong area_size, gint type) mem_chunk = g_malloc (sizeof (GstMemChunk)); mem_chunk->chunk_size = atom_size + sizeof (GstMemChunkElement); - area_size = (area_size/atom_size) * mem_chunk->chunk_size; + area_size = (area_size / atom_size) * mem_chunk->chunk_size; mem_chunk->name = g_strdup (name); mem_chunk->atom_size = atom_size; @@ -129,7 +129,7 @@ free_area (gpointer key, gpointer value, gpointer user_data) * Free the memory allocated by the memchunk */ void -gst_mem_chunk_destroy (GstMemChunk *mem_chunk) +gst_mem_chunk_destroy (GstMemChunk * mem_chunk) { GHashTable *elements = g_hash_table_new (NULL, NULL); gpointer data; @@ -140,10 +140,10 @@ gst_mem_chunk_destroy (GstMemChunk *mem_chunk) while (data) { GstMemChunkElement *elem = GST_MEM_CHUNK_LINK (data); - g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL); - + g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL); + data = gst_mem_chunk_alloc (mem_chunk); - } + } g_hash_table_foreach_remove (elements, free_area, NULL); g_hash_table_destroy (elements); @@ -162,10 +162,10 @@ gst_mem_chunk_destroy (GstMemChunk *mem_chunk) * Returns: a pointer to the allocated memory region. */ gpointer -gst_mem_chunk_alloc (GstMemChunk *mem_chunk) +gst_mem_chunk_alloc (GstMemChunk * mem_chunk) { GstMemChunkElement *chunk; - + g_return_val_if_fail (mem_chunk != NULL, NULL); again: @@ -174,7 +174,7 @@ again: if (!chunk) { if (populate (mem_chunk)) goto again; - else + else return NULL; } @@ -192,13 +192,13 @@ again: * Returns: a pointer to the allocated memory region. */ gpointer -gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk) +gst_mem_chunk_alloc0 (GstMemChunk * mem_chunk) { gpointer mem = gst_mem_chunk_alloc (mem_chunk); if (mem) memset (mem, 0, mem_chunk->atom_size); - + return mem; } @@ -210,10 +210,10 @@ gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk) * Free the memeory region allocated from the chunk. */ void -gst_mem_chunk_free (GstMemChunk *mem_chunk, gpointer mem) +gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem) { GstMemChunkElement *chunk; - + g_return_if_fail (mem_chunk != NULL); g_return_if_fail (mem != NULL); diff --git a/gst/gstmemchunk.h b/gst/gstmemchunk.h index 6e0d7087e..e62a21db1 100644 --- a/gst/gstmemchunk.h +++ b/gst/gstmemchunk.h @@ -22,22 +22,16 @@ #include -G_BEGIN_DECLS +G_BEGIN_DECLS typedef struct _GstMemChunk GstMemChunk; -typedef struct _GstMemChunk GstMemChunk; +GstMemChunk *gst_mem_chunk_new (gchar * name, + gint atom_size, gulong area_size, gint type); -GstMemChunk* gst_mem_chunk_new (gchar *name, - gint atom_size, - gulong area_size, - gint type); +void gst_mem_chunk_destroy (GstMemChunk * mem_chunk); -void gst_mem_chunk_destroy (GstMemChunk *mem_chunk); - -gpointer gst_mem_chunk_alloc (GstMemChunk *mem_chunk); -gpointer gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk); -void gst_mem_chunk_free (GstMemChunk *mem_chunk, - gpointer mem); +gpointer gst_mem_chunk_alloc (GstMemChunk * mem_chunk); +gpointer gst_mem_chunk_alloc0 (GstMemChunk * mem_chunk); +void gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem); G_END_DECLS - #endif /* __GST_MEM_CHUNK_H__ */ diff --git a/gst/gstobject.c b/gst/gstobject.c index 474c77c3a..b25f2bd8f 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -31,7 +31,8 @@ #endif /* Object signals and args */ -enum { +enum +{ PARENT_SET, PARENT_UNSET, #ifndef GST_DISABLE_LOADSAVE_REGISTRY @@ -41,52 +42,56 @@ enum { LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_NAME - /* FILL ME */ + /* FILL ME */ }; -enum { +enum +{ SO_OBJECT_LOADED, SO_LAST_SIGNAL }; GType _gst_object_type = 0; static GHashTable *object_name_counts = NULL; + G_LOCK_DEFINE_STATIC (object_name_mutex); typedef struct _GstSignalObject GstSignalObject; typedef struct _GstSignalObjectClass GstSignalObjectClass; -static GType gst_signal_object_get_type (void); -static void gst_signal_object_class_init (GstSignalObjectClass *klass); -static void gst_signal_object_init (GstSignalObject *object); +static GType gst_signal_object_get_type (void); +static void gst_signal_object_class_init (GstSignalObjectClass * klass); +static void gst_signal_object_init (GstSignalObject * object); #ifndef GST_DISABLE_LOADSAVE_REGISTRY static guint gst_signal_object_signals[SO_LAST_SIGNAL] = { 0 }; #endif -static void gst_object_class_init (GstObjectClass *klass); -static void gst_object_init (GstObject *object); +static void gst_object_class_init (GstObjectClass * klass); +static void gst_object_init (GstObject * object); + #ifndef GST_DISABLE_TRACE -static GObject * gst_object_constructor (GType type, guint n_construct_properties, - GObjectConstructParam *construct_params); +static GObject *gst_object_constructor (GType type, + guint n_construct_properties, GObjectConstructParam * construct_params); #endif -static void gst_object_set_property (GObject * object, guint prop_id, const GValue * value, - GParamSpec * pspec); -static void gst_object_get_property (GObject * object, guint prop_id, GValue * value, - GParamSpec * pspec); -static void gst_object_dispatch_properties_changed (GObject *object, - guint n_pspecs, - GParamSpec **pspecs); +static void gst_object_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_object_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_object_dispatch_properties_changed (GObject * object, + guint n_pspecs, GParamSpec ** pspecs); -static void gst_object_dispose (GObject *object); -static void gst_object_finalize (GObject *object); +static void gst_object_dispose (GObject * object); +static void gst_object_finalize (GObject * object); #ifndef GST_DISABLE_LOADSAVE_REGISTRY -static void gst_object_real_restore_thyself (GstObject *object, xmlNodePtr self); +static void gst_object_real_restore_thyself (GstObject * object, + xmlNodePtr self); #endif static GObjectClass *parent_class = NULL; @@ -108,17 +113,19 @@ gst_object_get_type (void) (GInstanceInitFunc) gst_object_init, NULL }; - _gst_object_type = g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info, G_TYPE_FLAG_ABSTRACT); + _gst_object_type = + g_type_register_static (G_TYPE_OBJECT, "GstObject", &object_info, + G_TYPE_FLAG_ABSTRACT); } return _gst_object_type; } static void -gst_object_class_init (GstObjectClass *klass) +gst_object_class_init (GstObjectClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; parent_class = g_type_class_ref (G_TYPE_OBJECT); @@ -126,35 +133,32 @@ gst_object_class_init (GstObjectClass *klass) gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_object_get_property); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NAME, - g_param_spec_string ("name", "Name", "The name of the object", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("name", "Name", "The name of the object", + NULL, G_PARAM_READWRITE)); gst_object_signals[PARENT_SET] = - g_signal_new ("parent-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstObjectClass, parent_set), NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + g_signal_new ("parent-set", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstObjectClass, parent_set), NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); gst_object_signals[PARENT_UNSET] = - g_signal_new ("parent-unset", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstObjectClass, parent_unset), NULL, NULL, - g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - G_TYPE_OBJECT); + g_signal_new ("parent-unset", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstObjectClass, parent_unset), NULL, + NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_OBJECT); #ifndef GST_DISABLE_LOADSAVE_REGISTRY /* FIXME This should be the GType of xmlNodePtr instead of G_TYPE_POINTER */ gst_object_signals[OBJECT_SAVED] = - g_signal_new ("object-saved", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstObjectClass, object_saved), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, - G_TYPE_POINTER); - + g_signal_new ("object-saved", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstObjectClass, object_saved), NULL, + NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + klass->restore_thyself = gst_object_real_restore_thyself; #endif gst_object_signals[DEEP_NOTIFY] = - g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS, - G_STRUCT_OFFSET (GstObjectClass, deep_notify), NULL, NULL, - gst_marshal_VOID__OBJECT_PARAM, G_TYPE_NONE, - 2, G_TYPE_OBJECT, G_TYPE_PARAM); + g_signal_new ("deep-notify", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | + G_SIGNAL_NO_HOOKS, G_STRUCT_OFFSET (GstObjectClass, deep_notify), NULL, + NULL, gst_marshal_VOID__OBJECT_PARAM, G_TYPE_NONE, 2, G_TYPE_OBJECT, + G_TYPE_PARAM); klass->path_string_separator = "/"; @@ -162,7 +166,7 @@ gst_object_class_init (GstObjectClass *klass) /* see the comments at gst_object_dispatch_properties_changed */ gobject_class->dispatch_properties_changed - = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed); + = GST_DEBUG_FUNCPTR (gst_object_dispatch_properties_changed); gobject_class->dispose = gst_object_dispose; gobject_class->finalize = gst_object_finalize; @@ -172,9 +176,9 @@ gst_object_class_init (GstObjectClass *klass) } static void -gst_object_init (GstObject *object) +gst_object_init (GstObject * object) { - object->lock = g_mutex_new(); + object->lock = g_mutex_new (); object->parent = NULL; object->name = NULL; @@ -184,11 +188,14 @@ gst_object_init (GstObject *object) #ifndef GST_DISABLE_TRACE static GObject * -gst_object_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params) +gst_object_constructor (GType type, guint n_construct_properties, + GObjectConstructParam * construct_params) { const gchar *name; GstAllocTrace *trace; - GObject *obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, construct_params); + GObject *obj = + G_OBJECT_CLASS (parent_class)->constructor (type, n_construct_properties, + construct_params); name = g_type_name (type); @@ -197,7 +204,7 @@ gst_object_constructor (GType type, guint n_construct_properties, GObjectConstru trace = gst_alloc_trace_register (name); } gst_alloc_trace_new (trace, obj); - + return obj; } #endif @@ -209,14 +216,13 @@ gst_object_constructor (GType type, guint n_construct_properties, GObjectConstru * * Returns: A pointer to the object */ -GstObject* -gst_object_ref (GstObject *object) +GstObject * +gst_object_ref (GstObject * object) { g_return_val_if_fail (GST_IS_OBJECT (object), NULL); GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "ref %d->%d", - G_OBJECT (object)->ref_count, - G_OBJECT (object)->ref_count + 1); + G_OBJECT (object)->ref_count, G_OBJECT (object)->ref_count + 1); g_object_ref (G_OBJECT (object)); return object; @@ -230,14 +236,13 @@ gst_object_ref (GstObject *object) * zero, destroy the object. */ void -gst_object_unref (GstObject *object) +gst_object_unref (GstObject * object) { g_return_if_fail (GST_IS_OBJECT (object)); g_return_if_fail (G_OBJECT (object)->ref_count > 0); GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "unref %d->%d", - G_OBJECT (object)->ref_count, - G_OBJECT (object)->ref_count - 1); + G_OBJECT (object)->ref_count, G_OBJECT (object)->ref_count - 1); g_object_unref (G_OBJECT (object)); } @@ -252,7 +257,7 @@ gst_object_unref (GstObject *object) * Use #gst_object_set_parent to have this done for you. */ void -gst_object_sink (GstObject *object) +gst_object_sink (GstObject * object) { g_return_if_fail (object != NULL); g_return_if_fail (GST_IS_OBJECT (object)); @@ -274,29 +279,31 @@ gst_object_sink (GstObject *object) * puts the newobj in *oldobj. */ void -gst_object_replace (GstObject **oldobj, GstObject *newobj) +gst_object_replace (GstObject ** oldobj, GstObject * newobj) { g_return_if_fail (oldobj != NULL); g_return_if_fail (*oldobj == NULL || GST_IS_OBJECT (*oldobj)); g_return_if_fail (newobj == NULL || GST_IS_OBJECT (newobj)); - - GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s %s", - *oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)", - newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)"); + + GST_CAT_LOG (GST_CAT_REFCOUNTING, "replace %s %s", + *oldobj ? GST_STR_NULL (GST_OBJECT_NAME (*oldobj)) : "(NONE)", + newobj ? GST_STR_NULL (GST_OBJECT_NAME (newobj)) : "(NONE)"); if (*oldobj != newobj) { - if (newobj) gst_object_ref (newobj); - if (*oldobj) gst_object_unref (*oldobj); + if (newobj) + gst_object_ref (newobj); + if (*oldobj) + gst_object_unref (*oldobj); *oldobj = newobj; } } static void -gst_object_dispose (GObject *object) +gst_object_dispose (GObject * object) { GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "dispose"); - + GST_FLAG_SET (GST_OBJECT (object), GST_DESTROYED); GST_OBJECT_PARENT (object) = NULL; @@ -305,7 +312,7 @@ gst_object_dispose (GObject *object) /* finalize is called when the object has to free its resources */ static void -gst_object_finalize (GObject *object) +gst_object_finalize (GObject * object) { GstObject *gstobject = GST_OBJECT (object); @@ -321,7 +328,7 @@ gst_object_finalize (GObject *object) { const gchar *name; GstAllocTrace *trace; - + name = g_type_name (G_OBJECT_TYPE (object)); trace = gst_alloc_trace_get (name); g_assert (trace); @@ -338,25 +345,27 @@ gst_object_finalize (GObject *object) * top-level bin to catch property-change notifications for all contained * elements. */ static void -gst_object_dispatch_properties_changed (GObject *object, - guint n_pspecs, - GParamSpec **pspecs) +gst_object_dispatch_properties_changed (GObject * object, + guint n_pspecs, GParamSpec ** pspecs) { GstObject *gst_object; guint i; /* do the standard dispatching */ - G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs, pspecs); + G_OBJECT_CLASS (parent_class)->dispatch_properties_changed (object, n_pspecs, + pspecs); /* now let the parent dispatch those, too */ gst_object = GST_OBJECT_PARENT (object); while (gst_object) { /* need own category? */ for (i = 0; i < n_pspecs; i++) { - GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)", GST_OBJECT_NAME (object), - GST_OBJECT_NAME (gst_object), pspecs[i]->name); - g_signal_emit (gst_object, gst_object_signals[DEEP_NOTIFY], g_quark_from_string (pspecs[i]->name), - (GstObject *) object, pspecs[i]); + GST_CAT_LOG (GST_CAT_EVENT, "deep notification from %s to %s (%s)", + GST_OBJECT_NAME (object), GST_OBJECT_NAME (gst_object), + pspecs[i]->name); + g_signal_emit (gst_object, gst_object_signals[DEEP_NOTIFY], + g_quark_from_string (pspecs[i]->name), (GstObject *) object, + pspecs[i]); } gst_object = GST_OBJECT_PARENT (gst_object); @@ -378,10 +387,10 @@ gst_object_dispatch_properties_changed (GObject *object, * using g_print. */ void -gst_object_default_deep_notify (GObject *object, GstObject *orig, - GParamSpec *pspec, gchar **excluded_props) +gst_object_default_deep_notify (GObject * object, GstObject * orig, + GParamSpec * pspec, gchar ** excluded_props) { - GValue value = { 0, }; /* the important thing is that value.type = 0 */ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ gchar *str = 0; gchar *name = NULL; @@ -389,7 +398,7 @@ gst_object_default_deep_notify (GObject *object, GstObject *orig, /* let's not print these out for excluded properties... */ while (excluded_props != NULL && *excluded_props != NULL) { if (strcmp (pspec->name, *excluded_props) == 0) - return; + return; excluded_props++; } g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); @@ -397,13 +406,14 @@ gst_object_default_deep_notify (GObject *object, GstObject *orig, if (G_IS_PARAM_SPEC_ENUM (pspec)) { GEnumValue *enum_value; - enum_value = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (pspec->value_type)), - g_value_get_enum (&value)); + + enum_value = + g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (pspec->value_type)), + g_value_get_enum (&value)); str = g_strdup_printf ("%s (%d)", enum_value->value_nick, - enum_value->value); - } - else { + enum_value->value); + } else { str = g_strdup_value_contents (&value); } name = gst_object_get_path_string (orig); @@ -413,19 +423,18 @@ gst_object_default_deep_notify (GObject *object, GstObject *orig, g_value_unset (&value); } else { name = gst_object_get_path_string (orig); - g_warning ("Parameter %s not readable in %s.", - pspec->name, name); + g_warning ("Parameter %s not readable in %s.", pspec->name, name); g_free (name); } } static void -gst_object_set_name_default (GstObject *object) +gst_object_set_name_default (GstObject * object) { gint count; gchar *name, *tmp; const gchar *type_name; - + type_name = G_OBJECT_TYPE_NAME (object); /* to ensure guaranteed uniqueness across threads, only one thread @@ -434,13 +443,13 @@ gst_object_set_name_default (GstObject *object) if (!object_name_counts) { object_name_counts = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, NULL); + g_free, NULL); } count = GPOINTER_TO_INT (g_hash_table_lookup (object_name_counts, type_name)); - g_hash_table_insert (object_name_counts, g_strdup (type_name), - GINT_TO_POINTER (count + 1)); - + g_hash_table_insert (object_name_counts, g_strdup (type_name), + GINT_TO_POINTER (count + 1)); + G_UNLOCK (object_name_mutex); /* GstFooSink -> foosinkN */ @@ -449,7 +458,7 @@ gst_object_set_name_default (GstObject *object) tmp = g_strdup_printf ("%s%d", type_name, count); name = g_ascii_strdown (tmp, strlen (tmp)); g_free (tmp); - + gst_object_set_name (object, name); g_free (name); } @@ -463,7 +472,7 @@ gst_object_set_name_default (GstObject *object) * name (if @name is NULL). */ void -gst_object_set_name (GstObject *object, const gchar *name) +gst_object_set_name (GstObject * object, const gchar * name) { g_return_if_fail (object != NULL); g_return_if_fail (GST_IS_OBJECT (object)); @@ -485,8 +494,8 @@ gst_object_set_name (GstObject *object, const gchar *name) * * Returns: name of the object */ -const gchar* -gst_object_get_name (GstObject *object) +const gchar * +gst_object_get_name (GstObject * object) { g_return_val_if_fail (GST_IS_OBJECT (object), NULL); @@ -504,7 +513,7 @@ gst_object_get_name (GstObject *object) * Causes the parent-set signal to be emitted. */ void -gst_object_set_parent (GstObject *object, GstObject *parent) +gst_object_set_parent (GstObject * object, GstObject * parent) { g_return_if_fail (object != NULL); g_return_if_fail (GST_IS_OBJECT (object)); @@ -528,8 +537,8 @@ gst_object_set_parent (GstObject *object, GstObject *parent) * * Returns: parent of the object */ -GstObject* -gst_object_get_parent (GstObject *object) +GstObject * +gst_object_get_parent (GstObject * object) { g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (GST_IS_OBJECT (object), NULL); @@ -544,16 +553,17 @@ gst_object_get_parent (GstObject *object) * Clear the parent of @object, removing the associated reference. */ void -gst_object_unparent (GstObject *object) +gst_object_unparent (GstObject * object) { g_return_if_fail (object != NULL); - g_return_if_fail (GST_IS_OBJECT(object)); + g_return_if_fail (GST_IS_OBJECT (object)); if (object->parent == NULL) return; GST_CAT_LOG_OBJECT (GST_CAT_REFCOUNTING, object, "unparent"); - - g_signal_emit (G_OBJECT (object), gst_object_signals[PARENT_UNSET], 0, object->parent); + + g_signal_emit (G_OBJECT (object), gst_object_signals[PARENT_UNSET], 0, + object->parent); object->parent = NULL; gst_object_unref (object); @@ -569,7 +579,7 @@ gst_object_unparent (GstObject *object) * Returns: TRUE if the name does not appear in the list, FALSE if it does. */ gboolean -gst_object_check_uniqueness (GList *list, const gchar *name) +gst_object_check_uniqueness (GList * list, const gchar * name) { g_return_val_if_fail (name != NULL, FALSE); @@ -577,8 +587,8 @@ gst_object_check_uniqueness (GList *list, const gchar *name) GstObject *child = GST_OBJECT (list->data); list = g_list_next (list); - - if (strcmp (GST_OBJECT_NAME (child), name) == 0) + + if (strcmp (GST_OBJECT_NAME (child), name) == 0) return FALSE; } @@ -597,7 +607,7 @@ gst_object_check_uniqueness (GList *list, const gchar *name) * Returns: the new xmlNodePtr with the saved object */ xmlNodePtr -gst_object_save_thyself (GstObject *object, xmlNodePtr parent) +gst_object_save_thyself (GstObject * object, xmlNodePtr parent) { GstObjectClass *oclass; @@ -610,7 +620,8 @@ gst_object_save_thyself (GstObject *object, xmlNodePtr parent) if (oclass->save_thyself) oclass->save_thyself (object, parent); - g_signal_emit (G_OBJECT (object), gst_object_signals[OBJECT_SAVED], 0, parent); + g_signal_emit (G_OBJECT (object), gst_object_signals[OBJECT_SAVED], 0, + parent); return parent; } @@ -623,7 +634,7 @@ gst_object_save_thyself (GstObject *object, xmlNodePtr parent) * Restores the given object with the data from the parent XML node. */ void -gst_object_restore_thyself (GstObject *object, xmlNodePtr self) +gst_object_restore_thyself (GstObject * object, xmlNodePtr self) { GstObjectClass *oclass; @@ -638,25 +649,25 @@ gst_object_restore_thyself (GstObject *object, xmlNodePtr self) } static void -gst_object_real_restore_thyself (GstObject *object, xmlNodePtr self) +gst_object_real_restore_thyself (GstObject * object, xmlNodePtr self) { g_return_if_fail (object != NULL); g_return_if_fail (GST_IS_OBJECT (object)); g_return_if_fail (self != NULL); - - gst_class_signal_emit_by_name (object, "object_loaded", self); + + gst_class_signal_emit_by_name (object, "object_loaded", self); } #endif /* GST_DISABLE_LOADSAVE_REGISTRY */ static void -gst_object_set_property (GObject* object, guint prop_id, - const GValue* value, GParamSpec* pspec) +gst_object_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstObject *gstobject; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_OBJECT (object)); - + gstobject = GST_OBJECT (object); switch (prop_id) { @@ -670,19 +681,19 @@ gst_object_set_property (GObject* object, guint prop_id, } static void -gst_object_get_property (GObject* object, guint prop_id, - GValue* value, GParamSpec* pspec) +gst_object_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstObject *gstobject; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_OBJECT (object)); - + gstobject = GST_OBJECT (object); switch (prop_id) { case ARG_NAME: - g_value_set_string (value, (gchar*)GST_OBJECT_NAME (gstobject)); + g_value_set_string (value, (gchar *) GST_OBJECT_NAME (gstobject)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -699,8 +710,8 @@ gst_object_get_property (GObject* object, guint prop_id, * * Returns: a string describing the path of the object */ -gchar* -gst_object_get_path_string (GstObject *object) +gchar * +gst_object_get_path_string (GstObject * object) { GSList *parentage = NULL; GSList *parents; @@ -740,18 +751,18 @@ gst_object_get_path_string (GstObject *object) separator = oclass->path_string_separator; free_component = FALSE; } else { - component = g_strdup_printf("%p",parents->data); + component = g_strdup_printf ("%p", parents->data); separator = "/"; free_component = TRUE; } prevpath = path; path = g_strjoin (separator, prevpath, component, NULL); - g_free(prevpath); + g_free (prevpath); if (free_component) - g_free((gchar *)component); + g_free ((gchar *) component); - parents = g_slist_next(parents); + parents = g_slist_next (parents); } g_slist_free (parentage); @@ -761,17 +772,20 @@ gst_object_get_path_string (GstObject *object) -struct _GstSignalObject { +struct _GstSignalObject +{ GObject object; }; -struct _GstSignalObjectClass { - GObjectClass parent_class; +struct _GstSignalObjectClass +{ + GObjectClass parent_class; /* signals */ #ifndef GST_DISABLE_LOADSAVE_REGISTRY - void (*object_loaded) (GstSignalObject *object, GstObject *new, xmlNodePtr self); -#endif /* GST_DISABLE_LOADSAVE_REGISTRY */ + void (*object_loaded) (GstSignalObject * object, GstObject * new, + xmlNodePtr self); +#endif /* GST_DISABLE_LOADSAVE_REGISTRY */ }; static GType @@ -781,42 +795,44 @@ gst_signal_object_get_type (void) if (!signal_object_type) { static const GTypeInfo signal_object_info = { - sizeof(GstSignalObjectClass), + sizeof (GstSignalObjectClass), NULL, NULL, - (GClassInitFunc)gst_signal_object_class_init, + (GClassInitFunc) gst_signal_object_class_init, NULL, NULL, - sizeof(GstSignalObject), + sizeof (GstSignalObject), 16, - (GInstanceInitFunc)gst_signal_object_init, + (GInstanceInitFunc) gst_signal_object_init, NULL }; - signal_object_type = g_type_register_static(G_TYPE_OBJECT, "GstSignalObject", &signal_object_info, 0); + signal_object_type = + g_type_register_static (G_TYPE_OBJECT, "GstSignalObject", + &signal_object_info, 0); } return signal_object_type; } static void -gst_signal_object_class_init (GstSignalObjectClass *klass) +gst_signal_object_class_init (GstSignalObjectClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; parent_class = g_type_class_ref (G_TYPE_OBJECT); #ifndef GST_DISABLE_LOADSAVE_REGISTRY gst_signal_object_signals[SO_OBJECT_LOADED] = - g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstSignalObjectClass, object_loaded), NULL, NULL, - gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, - G_TYPE_OBJECT, G_TYPE_POINTER); + g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSignalObjectClass, object_loaded), + NULL, NULL, gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, + G_TYPE_OBJECT, G_TYPE_POINTER); #endif } static void -gst_signal_object_init (GstSignalObject *object) +gst_signal_object_init (GstSignalObject * object) { } @@ -832,10 +848,8 @@ gst_signal_object_init (GstSignalObject *object) * Returns: the signal id. */ guint -gst_class_signal_connect (GstObjectClass *klass, - const gchar *name, - gpointer func, - gpointer func_data) +gst_class_signal_connect (GstObjectClass * klass, + const gchar * name, gpointer func, gpointer func_data) { return g_signal_connect (klass->signal_object, name, func, func_data); } @@ -850,9 +864,8 @@ gst_class_signal_connect (GstObjectClass *klass, * emits the named class signal. */ void -gst_class_signal_emit_by_name (GstObject *object, - const gchar *name, - xmlNodePtr self) +gst_class_signal_emit_by_name (GstObject * object, + const gchar * name, xmlNodePtr self) { GstObjectClass *oclass; diff --git a/gst/gstobject.h b/gst/gstobject.h index 0cb918ff7..d67c9744f 100644 --- a/gst/gstobject.h +++ b/gst/gstobject.h @@ -30,9 +30,7 @@ #include -G_BEGIN_DECLS - -extern GType _gst_object_type; +G_BEGIN_DECLS extern GType _gst_object_type; #define GST_TYPE_OBJECT (_gst_object_type) #define GST_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_OBJECT)) @@ -49,45 +47,48 @@ extern GType _gst_object_type; typedef enum { - GST_DESTROYED = 0, + GST_DESTROYED = 0, GST_FLOATING, - GST_OBJECT_FLAG_LAST = 4 + GST_OBJECT_FLAG_LAST = 4 } GstObjectFlags; -struct _GstObject { - GObject object; +struct _GstObject +{ + GObject object; - gchar *name; + gchar *name; /* locking for all sorts of things */ - GMutex *lock; + GMutex *lock; /* this object's parent */ - GstObject *parent; + GstObject *parent; - guint32 flags; + guint32 flags; gpointer _gst_reserved[GST_PADDING]; }; /* signal_object is used to signal to the whole class */ -struct _GstObjectClass { - GObjectClass parent_class; +struct _GstObjectClass +{ + GObjectClass parent_class; - gchar *path_string_separator; - GObject *signal_object; + gchar *path_string_separator; + GObject *signal_object; /* signals */ - void (*parent_set) (GstObject *object, GstObject *parent); - void (*parent_unset) (GstObject *object, GstObject *parent); - void (*object_saved) (GstObject *object, xmlNodePtr parent); - void (*deep_notify) (GstObject *object, GstObject *orig, GParamSpec *pspec); + void (*parent_set) (GstObject * object, GstObject * parent); + void (*parent_unset) (GstObject * object, GstObject * parent); + void (*object_saved) (GstObject * object, xmlNodePtr parent); + void (*deep_notify) (GstObject * object, GstObject * orig, + GParamSpec * pspec); /* functions go here */ - void (*destroy) (GstObject *object); + void (*destroy) (GstObject * object); - xmlNodePtr (*save_thyself) (GstObject *object, xmlNodePtr parent); - void (*restore_thyself) (GstObject *object, xmlNodePtr self); + xmlNodePtr (*save_thyself) (GstObject * object, xmlNodePtr parent); + void (*restore_thyself) (GstObject * object, xmlNodePtr self); gpointer _gst_reserved[GST_PADDING]; }; @@ -111,57 +112,51 @@ struct _GstObjectClass { /* normal GObject stuff */ -GType gst_object_get_type (void); +GType gst_object_get_type (void); /* name routines */ -void gst_object_set_name (GstObject *object, const gchar *name); -G_CONST_RETURN gchar* - gst_object_get_name (GstObject *object); +void gst_object_set_name (GstObject * object, const gchar * name); +G_CONST_RETURN gchar *gst_object_get_name (GstObject * object); /* parentage routines */ -void gst_object_set_parent (GstObject *object, GstObject *parent); -GstObject* gst_object_get_parent (GstObject *object); -void gst_object_unparent (GstObject *object); +void gst_object_set_parent (GstObject * object, GstObject * parent); +GstObject *gst_object_get_parent (GstObject * object); +void gst_object_unparent (GstObject * object); -void gst_object_default_deep_notify (GObject *object, GstObject *orig, - GParamSpec *pspec, gchar **excluded_props); +void gst_object_default_deep_notify (GObject * object, GstObject * orig, + GParamSpec * pspec, gchar ** excluded_props); -gboolean gst_object_check_uniqueness (GList *list, const gchar *name); +gboolean gst_object_check_uniqueness (GList * list, const gchar * name); #ifndef GST_DISABLE_LOADSAVE_REGISTRY -xmlNodePtr gst_object_save_thyself (GstObject *object, xmlNodePtr parent); -void gst_object_restore_thyself (GstObject *object, xmlNodePtr self); +xmlNodePtr gst_object_save_thyself (GstObject * object, xmlNodePtr parent); +void gst_object_restore_thyself (GstObject * object, xmlNodePtr self); #else #pragma GCC poison gst_object_save_thyself #pragma GCC poison gst_object_restore_thyself #endif /* refcounting + life cycle */ -GstObject * gst_object_ref (GstObject *object); -void gst_object_unref (GstObject *object); -void gst_object_sink (GstObject *object); +GstObject *gst_object_ref (GstObject * object); +void gst_object_unref (GstObject * object); +void gst_object_sink (GstObject * object); /* replace object pointer */ -void gst_object_replace (GstObject **oldobj, GstObject *newobj); +void gst_object_replace (GstObject ** oldobj, GstObject * newobj); /* printing out the 'path' of the object */ -gchar * gst_object_get_path_string (GstObject *object); +gchar *gst_object_get_path_string (GstObject * object); -guint gst_class_signal_connect (GstObjectClass *klass, - const gchar *name, - gpointer func, - gpointer func_data); +guint gst_class_signal_connect (GstObjectClass * klass, + const gchar * name, gpointer func, gpointer func_data); #ifndef GST_DISABLE_LOADSAVE_REGISTRY -void gst_class_signal_emit_by_name (GstObject *object, - const gchar *name, - xmlNodePtr self); +void gst_class_signal_emit_by_name (GstObject * object, + const gchar * name, xmlNodePtr self); #else #pragma GCC poison gst_class_signal_emit_by_name #endif G_END_DECLS - #endif /* __GST_OBJECT_H__ */ - diff --git a/gst/gstpad.c b/gst/gstpad.c index c5b70874d..a0cc5fa8d 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -36,7 +36,8 @@ #define GST_CAT_DEFAULT GST_CAT_PADS -enum { +enum +{ TEMPL_PAD_CREATED, /* FILL ME */ TEMPL_LAST_SIGNAL @@ -48,45 +49,46 @@ static guint gst_pad_template_signals[TEMPL_LAST_SIGNAL] = { 0 }; GType _gst_pad_type = 0; /***** Start with the base GstPad class *****/ -static void gst_pad_class_init (GstPadClass *klass); -static void gst_pad_init (GstPad *pad); -static void gst_pad_dispose (GObject *object); +static void gst_pad_class_init (GstPadClass * klass); +static void gst_pad_init (GstPad * pad); +static void gst_pad_dispose (GObject * object); -static void gst_pad_set_pad_template (GstPad *pad, GstPadTemplate *templ); -static GstCaps * _gst_pad_default_fixate_func (GstPad *pad, const GstCaps *caps); +static void gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ); +static GstCaps *_gst_pad_default_fixate_func (GstPad * pad, + const GstCaps * caps); -static gboolean gst_pad_link_try (GstPadLink *link); -static void gst_pad_link_free (GstPadLink *link); +static gboolean gst_pad_link_try (GstPadLink * link); +static void gst_pad_link_free (GstPadLink * link); #ifndef GST_DISABLE_LOADSAVE -static xmlNodePtr gst_pad_save_thyself (GstObject *object, xmlNodePtr parent); +static xmlNodePtr gst_pad_save_thyself (GstObject * object, xmlNodePtr parent); #endif static GstObject *pad_parent_class = NULL; GType -gst_pad_get_type (void) +gst_pad_get_type (void) { if (!_gst_pad_type) { static const GTypeInfo pad_info = { sizeof (GstPadClass), NULL, NULL, (GClassInitFunc) gst_pad_class_init, NULL, NULL, - sizeof (GstPad), + sizeof (GstPad), 32, (GInstanceInitFunc) gst_pad_init, NULL }; - _gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad", - &pad_info, 0); + _gst_pad_type = g_type_register_static (GST_TYPE_OBJECT, "GstPad", + &pad_info, 0); } return _gst_pad_type; } static void -gst_pad_class_init (GstPadClass *klass) +gst_pad_class_init (GstPadClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; pad_parent_class = g_type_class_ref (GST_TYPE_OBJECT); @@ -94,12 +96,12 @@ gst_pad_class_init (GstPadClass *klass) } static void -gst_pad_init (GstPad *pad) +gst_pad_init (GstPad * pad) { /* all structs are initialized to NULL by glib */ } static void -gst_pad_dispose (GObject *object) +gst_pad_dispose (GObject * object) { GstPad *pad = GST_PAD (object); @@ -112,7 +114,8 @@ gst_pad_dispose (GObject *object) /***** Then do the Real Pad *****/ /* Pad signals and args */ -enum { +enum +{ REAL_LINKED, REAL_UNLINKED, REAL_FIXATE, @@ -120,25 +123,24 @@ enum { REAL_LAST_SIGNAL }; -enum { +enum +{ REAL_ARG_0, REAL_ARG_CAPS, REAL_ARG_ACTIVE - /* FILL ME */ + /* FILL ME */ }; -static void gst_real_pad_class_init (GstRealPadClass *klass); -static void gst_real_pad_init (GstRealPad *pad); -static void gst_real_pad_dispose (GObject *object); +static void gst_real_pad_class_init (GstRealPadClass * klass); +static void gst_real_pad_init (GstRealPad * pad); +static void gst_real_pad_dispose (GObject * object); -static gboolean _gst_real_pad_fixate_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, const GValue *handler_return, gpointer dummy); -static void gst_real_pad_set_property (GObject *object, guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gst_real_pad_get_property (GObject *object, guint prop_id, - GValue *value, - GParamSpec *pspec); +static gboolean _gst_real_pad_fixate_accumulator (GSignalInvocationHint * ihint, + GValue * return_accu, const GValue * handler_return, gpointer dummy); +static void gst_real_pad_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_real_pad_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); GType _gst_real_pad_type = 0; @@ -146,7 +148,8 @@ static GstPad *real_pad_parent_class = NULL; static guint gst_real_pad_signals[REAL_LAST_SIGNAL] = { 0 }; GType -gst_real_pad_get_type (void) { +gst_real_pad_get_type (void) +{ if (!_gst_real_pad_type) { static const GTypeInfo pad_info = { sizeof (GstRealPadClass), NULL, NULL, @@ -155,52 +158,50 @@ gst_real_pad_get_type (void) { 32, (GInstanceInitFunc) gst_real_pad_init, NULL }; - _gst_real_pad_type = g_type_register_static (GST_TYPE_PAD, "GstRealPad", - &pad_info, 0); + _gst_real_pad_type = g_type_register_static (GST_TYPE_PAD, "GstRealPad", + &pad_info, 0); } return _gst_real_pad_type; } static void -gst_real_pad_class_init (GstRealPadClass *klass) +gst_real_pad_class_init (GstRealPadClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; - gobject_class = (GObjectClass*) klass; - gstobject_class = (GstObjectClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; real_pad_parent_class = g_type_class_ref (GST_TYPE_PAD); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_real_pad_dispose); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_real_pad_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_real_pad_get_property); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_real_pad_dispose); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_real_pad_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_real_pad_get_property); gst_real_pad_signals[REAL_LINKED] = - g_signal_new ("linked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstRealPadClass, linked), NULL, NULL, - gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - GST_TYPE_PAD); + g_signal_new ("linked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstRealPadClass, linked), NULL, NULL, + gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD); gst_real_pad_signals[REAL_UNLINKED] = - g_signal_new ("unlinked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstRealPadClass, unlinked), NULL, NULL, - gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - GST_TYPE_PAD); + g_signal_new ("unlinked", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstRealPadClass, unlinked), NULL, NULL, + gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD); gst_real_pad_signals[REAL_FIXATE] = - g_signal_new ("fixate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstRealPadClass, appfixatefunc), - _gst_real_pad_fixate_accumulator, NULL, - gst_marshal_BOXED__BOXED, GST_TYPE_CAPS, 1, - GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE); + g_signal_new ("fixate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstRealPadClass, appfixatefunc), + _gst_real_pad_fixate_accumulator, NULL, + gst_marshal_BOXED__BOXED, GST_TYPE_CAPS, 1, + GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE); /* gtk_object_add_arg_type ("GstRealPad::active", G_TYPE_BOOLEAN, */ /* GTK_ARG_READWRITE, REAL_ARG_ACTIVE); */ g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_ACTIVE, - g_param_spec_boolean ("active", "Active", "Whether the pad is active.", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("active", "Active", "Whether the pad is active.", + TRUE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), REAL_ARG_CAPS, - g_param_spec_boxed ("caps", "Caps", "The capabilities of the pad", - GST_TYPE_CAPS, G_PARAM_READABLE)); + g_param_spec_boxed ("caps", "Caps", "The capabilities of the pad", + GST_TYPE_CAPS, G_PARAM_READABLE)); #ifndef GST_DISABLE_LOADSAVE gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_pad_save_thyself); @@ -209,8 +210,8 @@ gst_real_pad_class_init (GstRealPadClass *klass) } static gboolean -_gst_real_pad_fixate_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, const GValue *handler_return, gpointer dummy) +_gst_real_pad_fixate_accumulator (GSignalInvocationHint * ihint, + GValue * return_accu, const GValue * handler_return, gpointer dummy) { if (gst_value_get_caps (handler_return)) { g_value_copy (handler_return, return_accu); @@ -221,7 +222,7 @@ _gst_real_pad_fixate_accumulator (GSignalInvocationHint *ihint, } static void -gst_real_pad_init (GstRealPad *pad) +gst_real_pad_init (GstRealPad * pad) { pad->direction = GST_PAD_UNKNOWN; pad->peer = NULL; @@ -238,24 +239,24 @@ gst_real_pad_init (GstRealPad *pad) pad->linkfunc = NULL; pad->getcapsfunc = NULL; - pad->eventfunc = gst_pad_event_default; - pad->convertfunc = gst_pad_convert_default; - pad->queryfunc = gst_pad_query_default; - pad->intlinkfunc = gst_pad_get_internal_links_default; + pad->eventfunc = gst_pad_event_default; + pad->convertfunc = gst_pad_convert_default; + pad->queryfunc = gst_pad_query_default; + pad->intlinkfunc = gst_pad_get_internal_links_default; - pad->eventmaskfunc = gst_pad_get_event_masks_default; - pad->formatsfunc = gst_pad_get_formats_default; - pad->querytypefunc = gst_pad_get_query_types_default; + pad->eventmaskfunc = gst_pad_get_event_masks_default; + pad->formatsfunc = gst_pad_get_formats_default; + pad->querytypefunc = gst_pad_get_query_types_default; GST_FLAG_SET (pad, GST_PAD_DISABLED); GST_FLAG_UNSET (pad, GST_PAD_NEGOTIATING); - + gst_probe_dispatcher_init (&pad->probedisp); } static void -gst_real_pad_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_real_pad_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { g_return_if_fail (GST_IS_PAD (object)); @@ -270,8 +271,8 @@ gst_real_pad_set_property (GObject *object, guint prop_id, } static void -gst_real_pad_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +gst_real_pad_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { g_return_if_fail (GST_IS_PAD (object)); @@ -302,9 +303,8 @@ gst_real_pad_get_property (GObject *object, guint prop_id, * * Returns: a new #GstPad, or NULL in case of an error. */ -GstPad* -gst_pad_custom_new (GType type, const gchar *name, - GstPadDirection direction) +GstPad * +gst_pad_custom_new (GType type, const gchar * name, GstPadDirection direction) { GstRealPad *pad; @@ -328,9 +328,8 @@ gst_pad_custom_new (GType type, const gchar *name, * * Returns: a new #GstPad, or NULL in case of an error. */ -GstPad* -gst_pad_new (const gchar *name, - GstPadDirection direction) +GstPad * +gst_pad_new (const gchar * name, GstPadDirection direction) { return gst_pad_custom_new (gst_real_pad_get_type (), name, direction); } @@ -347,9 +346,9 @@ gst_pad_new (const gchar *name, * * Returns: a new #GstPad, or NULL in case of an error. */ -GstPad* -gst_pad_custom_new_from_template (GType type, GstPadTemplate *templ, - const gchar *name) +GstPad * +gst_pad_custom_new_from_template (GType type, GstPadTemplate * templ, + const gchar * name) { GstPad *pad; @@ -372,11 +371,11 @@ gst_pad_custom_new_from_template (GType type, GstPadTemplate *templ, * * Returns: a new #GstPad, or NULL in case of an error. */ -GstPad* -gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name) +GstPad * +gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name) { - return gst_pad_custom_new_from_template (gst_real_pad_get_type (), - templ, name); + return gst_pad_custom_new_from_template (gst_real_pad_get_type (), + templ, name); } /* FIXME 0.9: GST_PAD_UNKNOWN needs to die! */ @@ -389,7 +388,7 @@ gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name) * Returns: the #GstPadDirection of the pad. */ GstPadDirection -gst_pad_get_direction (GstPad *pad) +gst_pad_get_direction (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_UNKNOWN); @@ -407,7 +406,7 @@ gst_pad_get_direction (GstPad *pad) * Activates or deactivates the given pad. */ void -gst_pad_set_active (GstPad *pad, gboolean active) +gst_pad_set_active (GstPad * pad, gboolean active) { GstRealPad *realpad; gboolean old; @@ -422,15 +421,15 @@ gst_pad_set_active (GstPad *pad, gboolean active) realpad = GST_PAD_REALIZE (pad); if (active) { - GST_CAT_DEBUG (GST_CAT_PADS, "activating pad %s:%s", - GST_DEBUG_PAD_NAME (realpad)); + GST_CAT_DEBUG (GST_CAT_PADS, "activating pad %s:%s", + GST_DEBUG_PAD_NAME (realpad)); GST_FLAG_UNSET (realpad, GST_PAD_DISABLED); } else { - GST_CAT_DEBUG (GST_CAT_PADS, "de-activating pad %s:%s", - GST_DEBUG_PAD_NAME (realpad)); + GST_CAT_DEBUG (GST_CAT_PADS, "de-activating pad %s:%s", + GST_DEBUG_PAD_NAME (realpad)); GST_FLAG_SET (realpad, GST_PAD_DISABLED); } - + g_object_notify (G_OBJECT (realpad), "active"); } @@ -443,7 +442,7 @@ gst_pad_set_active (GstPad *pad, gboolean active) * Returns: TRUE if the pad is active. */ gboolean -gst_pad_is_active (GstPad *pad) +gst_pad_is_active (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), FALSE); @@ -459,7 +458,7 @@ gst_pad_is_active (GstPad *pad) * name will be assigned. */ void -gst_pad_set_name (GstPad *pad, const gchar *name) +gst_pad_set_name (GstPad * pad, const gchar * name) { g_return_if_fail (GST_IS_PAD (pad)); @@ -476,8 +475,8 @@ gst_pad_set_name (GstPad *pad, const gchar *name) * Returns: the name of the pad. This is not a newly allocated pointer * so you must not free it. */ -const gchar* -gst_pad_get_name (GstPad *pad) +const gchar * +gst_pad_get_name (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -492,15 +491,15 @@ gst_pad_get_name (GstPad *pad) * Sets the given chain function for the pad. The chain function is called to * process a #GstData input buffer. */ -void -gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain) +void +gst_pad_set_chain_function (GstPad * pad, GstPadChainFunction chain) { g_return_if_fail (GST_IS_REAL_PAD (pad)); g_return_if_fail (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK); GST_RPAD_CHAINFUNC (pad) = chain; GST_CAT_DEBUG (GST_CAT_PADS, "chainfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (chain)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (chain)); } /** @@ -513,16 +512,15 @@ gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain) * return %NULL. */ void -gst_pad_set_get_function (GstPad *pad, - GstPadGetFunction get) +gst_pad_set_get_function (GstPad * pad, GstPadGetFunction get) { g_return_if_fail (GST_IS_REAL_PAD (pad)); g_return_if_fail (GST_RPAD_DIRECTION (pad) == GST_PAD_SRC); GST_RPAD_GETFUNC (pad) = get; - + GST_CAT_DEBUG (GST_CAT_PADS, "getfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (get)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (get)); } /** @@ -533,8 +531,7 @@ gst_pad_set_get_function (GstPad *pad, * Sets the given event handler for the pad. */ void -gst_pad_set_event_function (GstPad *pad, - GstPadEventFunction event) +gst_pad_set_event_function (GstPad * pad, GstPadEventFunction event) { g_return_if_fail (GST_IS_REAL_PAD (pad)); g_return_if_fail (GST_RPAD_DIRECTION (pad) == GST_PAD_SRC); @@ -542,7 +539,7 @@ gst_pad_set_event_function (GstPad *pad, GST_RPAD_EVENTFUNC (pad) = event; GST_CAT_DEBUG (GST_CAT_PADS, "eventfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (event)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (event)); } /** @@ -553,15 +550,15 @@ gst_pad_set_event_function (GstPad *pad, * Sets the given event mask function for the pad. */ void -gst_pad_set_event_mask_function (GstPad *pad, - GstPadEventMaskFunction mask_func) +gst_pad_set_event_mask_function (GstPad * pad, + GstPadEventMaskFunction mask_func) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_EVENTMASKFUNC (pad) = mask_func; GST_CAT_DEBUG (GST_CAT_PADS, "eventmaskfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (mask_func)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (mask_func)); } /** @@ -573,11 +570,11 @@ gst_pad_set_event_mask_function (GstPad *pad, * Returns: a zero-terminated array of #GstEventMask, or NULL if the pad does * not have an event mask function. */ -const GstEventMask* -gst_pad_get_event_masks (GstPad *pad) +const GstEventMask * +gst_pad_get_event_masks (GstPad * pad) { GstRealPad *rpad; - + g_return_val_if_fail (GST_IS_PAD (pad), NULL); rpad = GST_PAD_REALIZE (pad); @@ -591,7 +588,7 @@ gst_pad_get_event_masks (GstPad *pad) } static gboolean -gst_pad_get_event_masks_dispatcher (GstPad *pad, const GstEventMask **data) +gst_pad_get_event_masks_dispatcher (GstPad * pad, const GstEventMask ** data) { *data = gst_pad_get_event_masks (pad); @@ -607,15 +604,15 @@ gst_pad_get_event_masks_dispatcher (GstPad *pad, const GstEventMask **data) * Returns: a zero-terminated array of #GstEventMask, or NULL if none of the * internally-linked pads have an event mask function. */ -const GstEventMask* -gst_pad_get_event_masks_default (GstPad *pad) +const GstEventMask * +gst_pad_get_event_masks_default (GstPad * pad) { GstEventMask *result = NULL; g_return_val_if_fail (GST_IS_PAD (pad), NULL); - gst_pad_dispatcher (pad, (GstPadDispatcherFunction) - gst_pad_get_event_masks_dispatcher, &result); + gst_pad_dispatcher (pad, (GstPadDispatcherFunction) + gst_pad_get_event_masks_dispatcher, &result); return result; } @@ -628,15 +625,14 @@ gst_pad_get_event_masks_default (GstPad *pad) * Sets the given convert function for the pad. */ void -gst_pad_set_convert_function (GstPad *pad, - GstPadConvertFunction convert) +gst_pad_set_convert_function (GstPad * pad, GstPadConvertFunction convert) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_CONVERTFUNC (pad) = convert; GST_CAT_DEBUG (GST_CAT_PADS, "convertfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (convert)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (convert)); } /** @@ -647,14 +643,14 @@ gst_pad_set_convert_function (GstPad *pad, * Set the given query function for the pad. */ void -gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query) +gst_pad_set_query_function (GstPad * pad, GstPadQueryFunction query) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_QUERYFUNC (pad) = query; GST_CAT_DEBUG (GST_CAT_PADS, "queryfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (query)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (query)); } /** @@ -665,14 +661,15 @@ gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query) * Set the given query type function for the pad. */ void -gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func) +gst_pad_set_query_type_function (GstPad * pad, + GstPadQueryTypeFunction type_func) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_QUERYTYPEFUNC (pad) = type_func; GST_CAT_DEBUG (GST_CAT_PADS, "querytypefunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (type_func)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (type_func)); } /** @@ -684,11 +681,11 @@ gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func) * * Returns: a zero-terminated array of #GstQueryType. */ -const GstQueryType* -gst_pad_get_query_types (GstPad *pad) +const GstQueryType * +gst_pad_get_query_types (GstPad * pad) { GstRealPad *rpad; - + g_return_val_if_fail (GST_IS_PAD (pad), NULL); rpad = GST_PAD_REALIZE (pad); @@ -702,7 +699,7 @@ gst_pad_get_query_types (GstPad *pad) } static gboolean -gst_pad_get_query_types_dispatcher (GstPad *pad, const GstQueryType **data) +gst_pad_get_query_types_dispatcher (GstPad * pad, const GstQueryType ** data) { *data = gst_pad_get_query_types (pad); @@ -719,15 +716,15 @@ gst_pad_get_query_types_dispatcher (GstPad *pad, const GstQueryType **data) * Returns: an zero-terminated array of #GstQueryType, or NULL if none of the * internally-linked pads has a query types function. */ -const GstQueryType* -gst_pad_get_query_types_default (GstPad *pad) +const GstQueryType * +gst_pad_get_query_types_default (GstPad * pad) { GstQueryType *result = NULL; g_return_val_if_fail (GST_IS_PAD (pad), NULL); - gst_pad_dispatcher (pad, (GstPadDispatcherFunction) - gst_pad_get_query_types_dispatcher, &result); + gst_pad_dispatcher (pad, (GstPadDispatcherFunction) + gst_pad_get_query_types_dispatcher, &result); return result; } @@ -740,14 +737,13 @@ gst_pad_get_query_types_default (GstPad *pad) * Sets the given internal link function for the pad. */ void -gst_pad_set_internal_link_function (GstPad *pad, - GstPadIntLinkFunction intlink) +gst_pad_set_internal_link_function (GstPad * pad, GstPadIntLinkFunction intlink) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_INTLINKFUNC (pad) = intlink; GST_CAT_DEBUG (GST_CAT_PADS, "internal link for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (intlink)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (intlink)); } /** @@ -758,13 +754,13 @@ gst_pad_set_internal_link_function (GstPad *pad, * Sets the given formats function for the pad. */ void -gst_pad_set_formats_function (GstPad *pad, GstPadFormatsFunction formats) +gst_pad_set_formats_function (GstPad * pad, GstPadFormatsFunction formats) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_FORMATSFUNC (pad) = formats; GST_CAT_DEBUG (GST_CAT_PADS, "formats function for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (formats)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (formats)); } /** @@ -795,14 +791,13 @@ gst_pad_set_formats_function (GstPad *pad, GstPadFormatsFunction formats) * on other pads. */ void -gst_pad_set_link_function (GstPad *pad, - GstPadLinkFunction link) +gst_pad_set_link_function (GstPad * pad, GstPadLinkFunction link) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_LINKFUNC (pad) = link; GST_CAT_DEBUG (GST_CAT_PADS, "linkfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (link)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (link)); } /** @@ -814,14 +809,13 @@ gst_pad_set_link_function (GstPad *pad, * when the pad is unlinked. */ void -gst_pad_set_unlink_function (GstPad *pad, - GstPadUnlinkFunction unlink) +gst_pad_set_unlink_function (GstPad * pad, GstPadUnlinkFunction unlink) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_UNLINKFUNC (pad) = unlink; GST_CAT_DEBUG (GST_CAT_PADS, "unlinkfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (unlink)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (unlink)); } /** @@ -840,13 +834,13 @@ gst_pad_set_unlink_function (GstPad *pad, * and only if the caps are still non-fixed. */ void -gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate) +gst_pad_set_fixate_function (GstPad * pad, GstPadFixateFunction fixate) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_FIXATEFUNC (pad) = fixate; GST_CAT_DEBUG (GST_CAT_PADS, "fixatefunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (fixate)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (fixate)); } /** @@ -875,14 +869,13 @@ gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate) * Note that the return value from @getcaps is owned by the caller. */ void -gst_pad_set_getcaps_function (GstPad *pad, - GstPadGetCapsFunction getcaps) +gst_pad_set_getcaps_function (GstPad * pad, GstPadGetCapsFunction getcaps) { g_return_if_fail (GST_IS_REAL_PAD (pad)); GST_RPAD_GETCAPSFUNC (pad) = getcaps; GST_CAT_DEBUG (GST_CAT_PADS, "getcapsfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (getcaps)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (getcaps)); } /** @@ -894,15 +887,15 @@ gst_pad_set_getcaps_function (GstPad *pad, * bufferalloc function can only be set on sinkpads. */ void -gst_pad_set_bufferalloc_function (GstPad *pad, - GstPadBufferAllocFunction bufalloc) +gst_pad_set_bufferalloc_function (GstPad * pad, + GstPadBufferAllocFunction bufalloc) { g_return_if_fail (GST_IS_REAL_PAD (pad)); g_return_if_fail (GST_PAD_IS_SINK (pad)); GST_RPAD_BUFFERALLOCFUNC (pad) = bufalloc; GST_CAT_DEBUG (GST_CAT_PADS, "bufferallocfunc for %s:%s set to %s", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (bufalloc)); + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_FUNCPTR_NAME (bufalloc)); } /* FIXME 0.9: Do we actually want to allow the case where src and sink are @@ -916,8 +909,7 @@ gst_pad_set_bufferalloc_function (GstPad *pad, * both pads. */ void -gst_pad_unlink (GstPad *srcpad, - GstPad *sinkpad) +gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad) { GstRealPad *realsrc, *realsink; GstScheduler *src_sched, *sink_sched; @@ -926,8 +918,8 @@ gst_pad_unlink (GstPad *srcpad, g_return_if_fail (GST_IS_PAD (sinkpad)); GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "unlinking %s:%s(%p) and %s:%s(%p)", - GST_DEBUG_PAD_NAME (srcpad), srcpad, - GST_DEBUG_PAD_NAME (sinkpad), sinkpad); + GST_DEBUG_PAD_NAME (srcpad), srcpad, + GST_DEBUG_PAD_NAME (sinkpad), sinkpad); realsrc = GST_PAD_REALIZE (srcpad); realsink = GST_PAD_REALIZE (sinkpad); @@ -944,7 +936,7 @@ gst_pad_unlink (GstPad *srcpad, realsink = temppad; } g_return_if_fail ((GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) && - (GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK)); + (GST_RPAD_DIRECTION (realsink) == GST_PAD_SINK)); if (GST_RPAD_UNLINKFUNC (realsrc)) { GST_RPAD_UNLINKFUNC (realsrc) (GST_PAD (realsrc)); @@ -957,7 +949,8 @@ gst_pad_unlink (GstPad *srcpad, src_sched = gst_pad_get_scheduler (GST_PAD (realsrc)); sink_sched = gst_pad_get_scheduler (GST_PAD (realsink)); - if (GST_RPAD_LINK (realsrc)) gst_pad_link_free (GST_RPAD_LINK (realsrc)); + if (GST_RPAD_LINK (realsrc)) + gst_pad_link_free (GST_RPAD_LINK (realsrc)); /* first clear peers */ GST_RPAD_PEER (realsrc) = NULL; @@ -967,9 +960,7 @@ gst_pad_unlink (GstPad *srcpad, /* now tell the scheduler */ if (src_sched && src_sched == sink_sched) { - gst_scheduler_pad_unlink (src_sched, - GST_PAD (realsrc), - GST_PAD (realsink)); + gst_scheduler_pad_unlink (src_sched, GST_PAD (realsrc), GST_PAD (realsink)); } /* hold a reference, as they can go away in the signal handlers */ @@ -978,13 +969,13 @@ gst_pad_unlink (GstPad *srcpad, /* fire off a signal to each of the pads telling them * that they've been unlinked */ - g_signal_emit (G_OBJECT (realsrc), gst_real_pad_signals[REAL_UNLINKED], - 0, realsink); - g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_UNLINKED], - 0, realsrc); + g_signal_emit (G_OBJECT (realsrc), gst_real_pad_signals[REAL_UNLINKED], + 0, realsink); + g_signal_emit (G_OBJECT (realsink), gst_real_pad_signals[REAL_UNLINKED], + 0, realsrc); GST_CAT_INFO (GST_CAT_ELEMENT_PADS, "unlinked %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); gst_object_unref (GST_OBJECT (realsrc)); gst_object_unref (GST_OBJECT (realsink)); @@ -999,14 +990,15 @@ gst_pad_unlink (GstPad *srcpad, * Returns: TRUE if the pad is linked, FALSE otherwise. */ gboolean -gst_pad_is_linked (GstPad *pad) +gst_pad_is_linked (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), FALSE); return GST_PAD_PEER (pad) != NULL; } -struct _GstPadLink { +struct _GstPadLink +{ GType type; gboolean bla; @@ -1025,7 +1017,7 @@ struct _GstPadLink { }; static gboolean -gst_pad_check_schedulers (GstRealPad *realsrc, GstRealPad *realsink) +gst_pad_check_schedulers (GstRealPad * realsrc, GstRealPad * realsink) { GstScheduler *src_sched, *sink_sched; gint num_decoupled = 0; @@ -1053,6 +1045,7 @@ static GstPadLink * gst_pad_link_new (void) { GstPadLink *link; + link = g_new0 (GstPadLink, 1); link->sinknotify = TRUE; link->srcnotify = TRUE; @@ -1060,23 +1053,29 @@ gst_pad_link_new (void) } static void -gst_pad_link_free (GstPadLink *link) -{ - if (link->srccaps) gst_caps_free (link->srccaps); - if (link->sinkcaps) gst_caps_free (link->sinkcaps); - if (link->filtercaps) gst_caps_free (link->filtercaps); - if (link->caps) gst_caps_free (link->caps); +gst_pad_link_free (GstPadLink * link) +{ + if (link->srccaps) + gst_caps_free (link->srccaps); + if (link->sinkcaps) + gst_caps_free (link->sinkcaps); + if (link->filtercaps) + gst_caps_free (link->filtercaps); + if (link->caps) + gst_caps_free (link->caps); #ifdef USE_POISONING - memset(link,0xff, sizeof(*link)); + memset (link, 0xff, sizeof (*link)); #endif g_free (link); } -static void gst_pad_link_intersect (GstPadLink *link) +static void +gst_pad_link_intersect (GstPadLink * link) { GstCaps *pad_intersection; - if (link->caps) gst_caps_free (link->caps); + if (link->caps) + gst_caps_free (link->caps); GST_DEBUG ("intersecting link from %s:%s to %s:%s", GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad)); @@ -1098,20 +1097,20 @@ static void gst_pad_link_intersect (GstPadLink *link) } static gboolean -gst_pad_link_ready_for_negotiation (GstPadLink *link) +gst_pad_link_ready_for_negotiation (GstPadLink * link) { GstElement *parent; parent = GST_PAD_PARENT (link->srcpad); if (!parent || GST_STATE (parent) < GST_STATE_READY) { GST_DEBUG ("parent %s of pad %s:%s is not READY", - GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->srcpad)); + GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->srcpad)); return FALSE; } parent = GST_PAD_PARENT (link->sinkpad); if (!parent || GST_STATE (parent) < GST_STATE_READY) { GST_DEBUG ("parent %s of pad %s:%s is not READY", - GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_ELEMENT_NAME (parent), GST_DEBUG_PAD_NAME (link->sinkpad)); return FALSE; } @@ -1119,7 +1118,7 @@ gst_pad_link_ready_for_negotiation (GstPadLink *link) } static void -gst_pad_link_fixate (GstPadLink *link) +gst_pad_link_fixate (GstPadLink * link) { GstCaps *caps; GstCaps *newcaps; @@ -1127,14 +1126,14 @@ gst_pad_link_fixate (GstPadLink *link) caps = link->caps; g_return_if_fail (caps != NULL); - g_return_if_fail (!gst_caps_is_empty(caps)); + g_return_if_fail (!gst_caps_is_empty (caps)); GST_DEBUG ("trying to fixate caps %" GST_PTR_FORMAT, caps); while (!gst_caps_is_fixed (caps)) { int i; - for (i=0;i<5;i++){ + for (i = 0; i < 5; i++) { newcaps = NULL; switch (i) { case 0: @@ -1148,32 +1147,31 @@ gst_pad_link_fixate (GstPadLink *link) GST_DEBUG ("app sinkpad signal fixated to %" GST_PTR_FORMAT, newcaps); break; case 2: - if (GST_RPAD_FIXATEFUNC(link->srcpad)) { - newcaps = GST_RPAD_FIXATEFUNC(link->srcpad) ( - GST_PAD (link->srcpad), caps); + if (GST_RPAD_FIXATEFUNC (link->srcpad)) { + newcaps = + GST_RPAD_FIXATEFUNC (link->srcpad) (GST_PAD (link->srcpad), + caps); GST_DEBUG ("srcpad %s:%s fixated to %" GST_PTR_FORMAT, - GST_DEBUG_PAD_NAME (link->srcpad), newcaps); - } - else + GST_DEBUG_PAD_NAME (link->srcpad), newcaps); + } else GST_DEBUG ("srcpad %s:%s doesn't have a fixate function", - GST_DEBUG_PAD_NAME (link->srcpad)); + GST_DEBUG_PAD_NAME (link->srcpad)); break; case 3: - if (GST_RPAD_FIXATEFUNC(link->sinkpad)) { - newcaps = GST_RPAD_FIXATEFUNC(link->sinkpad) ( - GST_PAD (link->sinkpad), caps); + if (GST_RPAD_FIXATEFUNC (link->sinkpad)) { + newcaps = + GST_RPAD_FIXATEFUNC (link->sinkpad) (GST_PAD (link->sinkpad), + caps); GST_DEBUG ("sinkpad %s:%s fixated to %" GST_PTR_FORMAT, - GST_DEBUG_PAD_NAME (link->sinkpad), newcaps); - } - else + GST_DEBUG_PAD_NAME (link->sinkpad), newcaps); + } else GST_DEBUG ("sinkpad %s:%s doesn't have a fixate function", - GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_DEBUG_PAD_NAME (link->sinkpad)); break; case 4: - newcaps = _gst_pad_default_fixate_func ( - GST_PAD(link->srcpad), caps); - GST_DEBUG ("core fixated to %"GST_PTR_FORMAT, newcaps); + newcaps = _gst_pad_default_fixate_func (GST_PAD (link->srcpad), caps); + GST_DEBUG ("core fixated to %" GST_PTR_FORMAT, newcaps); break; } if (newcaps) { @@ -1188,59 +1186,62 @@ gst_pad_link_fixate (GstPadLink *link) } static GstPadLinkReturn -gst_pad_link_call_link_functions (GstPadLink *link) +gst_pad_link_call_link_functions (GstPadLink * link) { gboolean negotiating; GstPadLinkReturn res; - if (link->srcnotify && GST_RPAD_LINKFUNC (link->srcpad)){ + if (link->srcnotify && GST_RPAD_LINKFUNC (link->srcpad)) { GST_DEBUG ("calling link function on pad %s:%s", - GST_DEBUG_PAD_NAME (link->srcpad)); + GST_DEBUG_PAD_NAME (link->srcpad)); negotiating = GST_FLAG_IS_SET (link->srcpad, GST_PAD_NEGOTIATING); /* set the NEGOTIATING flag if not already done */ - if (!negotiating) GST_FLAG_SET (link->srcpad, GST_PAD_NEGOTIATING); - + if (!negotiating) + GST_FLAG_SET (link->srcpad, GST_PAD_NEGOTIATING); + /* call the link function */ - res = GST_RPAD_LINKFUNC (link->srcpad) (GST_PAD (link->srcpad), - link->caps); + res = GST_RPAD_LINKFUNC (link->srcpad) (GST_PAD (link->srcpad), link->caps); /* unset again after negotiating only if we set it */ - if (!negotiating) GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING); + if (!negotiating) + GST_FLAG_UNSET (link->srcpad, GST_PAD_NEGOTIATING); GST_DEBUG ("got reply %d from link function on pad %s:%s", - res, GST_DEBUG_PAD_NAME (link->srcpad)); + res, GST_DEBUG_PAD_NAME (link->srcpad)); if (GST_PAD_LINK_FAILED (res)) { GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps", - GST_DEBUG_PAD_NAME (link->srcpad)); + GST_DEBUG_PAD_NAME (link->srcpad)); return res; } } - if (link->sinknotify && GST_RPAD_LINKFUNC (link->sinkpad)){ + if (link->sinknotify && GST_RPAD_LINKFUNC (link->sinkpad)) { GST_DEBUG ("calling link function on pad %s:%s", - GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_DEBUG_PAD_NAME (link->sinkpad)); negotiating = GST_FLAG_IS_SET (link->sinkpad, GST_PAD_NEGOTIATING); /* set the NEGOTIATING flag if not already done */ - if (!negotiating) GST_FLAG_SET (link->sinkpad, GST_PAD_NEGOTIATING); - + if (!negotiating) + GST_FLAG_SET (link->sinkpad, GST_PAD_NEGOTIATING); + /* call the link function */ res = GST_RPAD_LINKFUNC (link->sinkpad) (GST_PAD (link->sinkpad), - link->caps); + link->caps); /* unset again after negotiating only if we set it */ - if (!negotiating) GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING); + if (!negotiating) + GST_FLAG_UNSET (link->sinkpad, GST_PAD_NEGOTIATING); GST_DEBUG ("got reply %d from link function on pad %s:%s", - res, GST_DEBUG_PAD_NAME (link->sinkpad)); + res, GST_DEBUG_PAD_NAME (link->sinkpad)); if (GST_PAD_LINK_FAILED (res)) { GST_CAT_INFO (GST_CAT_CAPS, "pad %s:%s doesn't accept caps", - GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_DEBUG_PAD_NAME (link->sinkpad)); return res; } } @@ -1249,7 +1250,7 @@ gst_pad_link_call_link_functions (GstPadLink *link) } static GstPadLinkReturn -gst_pad_link_negotiate (GstPadLink *link) +gst_pad_link_negotiate (GstPadLink * link) { GST_DEBUG ("negotiating link from pad %s:%s to pad %s:%s", GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad)); @@ -1280,12 +1281,12 @@ gst_pad_link_negotiate (GstPadLink *link) * Returns: TRUE if the link succeeded, FALSE if not. */ static gboolean -gst_pad_link_try (GstPadLink *link) +gst_pad_link_try (GstPadLink * link) { GstPad *srcpad, *sinkpad; GstPadLink *oldlink; GstPadLinkReturn ret; - + /* we use assertions here, because this function is static */ g_assert (link); srcpad = link->srcpad; @@ -1294,8 +1295,8 @@ gst_pad_link_try (GstPadLink *link) g_assert (sinkpad); oldlink = GST_RPAD_LINK (srcpad); g_assert (oldlink == GST_RPAD_LINK (sinkpad)); - - ret = gst_pad_link_negotiate (link); + + ret = gst_pad_link_negotiate (link); if (GST_PAD_LINK_FAILED (ret) && oldlink && oldlink->caps) { oldlink->srcnotify = link->srcnotify; oldlink->sinknotify = link->sinknotify; @@ -1311,8 +1312,8 @@ gst_pad_link_try (GstPadLink *link) gst_caps_replace (&link->caps, NULL); } - GST_RPAD_PEER (srcpad) = GST_REAL_PAD(link->sinkpad); - GST_RPAD_PEER (sinkpad) = GST_REAL_PAD(link->srcpad); + GST_RPAD_PEER (srcpad) = GST_REAL_PAD (link->sinkpad); + GST_RPAD_PEER (sinkpad) = GST_REAL_PAD (link->srcpad); if (oldlink) gst_pad_link_free (oldlink); GST_RPAD_LINK (srcpad) = link; @@ -1321,7 +1322,7 @@ gst_pad_link_try (GstPadLink *link) g_object_notify (G_OBJECT (srcpad), "caps"); g_object_notify (G_OBJECT (sinkpad), "caps"); } - + return ret; } @@ -1349,7 +1350,7 @@ gst_pad_link_try (GstPadLink *link) * when you just need success/failure information. */ GstPadLinkReturn -gst_pad_renegotiate (GstPad *pad) +gst_pad_renegotiate (GstPad * pad) { GstPadLink *link; @@ -1367,8 +1368,8 @@ gst_pad_renegotiate (GstPad *pad) return GST_PAD_LINK_DELAYED; } - if (GST_REAL_PAD(pad)->link->filtercaps) { - link->filtercaps = gst_caps_copy (GST_REAL_PAD(pad)->link->filtercaps); + if (GST_REAL_PAD (pad)->link->filtercaps) { + link->filtercaps = gst_caps_copy (GST_REAL_PAD (pad)->link->filtercaps); } link->srccaps = gst_pad_get_caps (link->srcpad); link->sinkcaps = gst_pad_get_caps (link->sinkpad); @@ -1393,7 +1394,7 @@ gst_pad_renegotiate (GstPad *pad) * when you just need success/failure information. */ GstPadLinkReturn -gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps) +gst_pad_try_set_caps (GstPad * pad, const GstCaps * caps) { GstPadLink *link; GstPadLink *oldlink; @@ -1404,11 +1405,11 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps) /* setting non-fixed caps on a pad is not allowed */ if (!gst_caps_is_fixed (caps)) { - GST_CAT_INFO (GST_CAT_CAPS, - "trying to set unfixed caps on pad %s:%s, not allowed", - GST_DEBUG_PAD_NAME (pad)); + GST_CAT_INFO (GST_CAT_CAPS, + "trying to set unfixed caps on pad %s:%s, not allowed", + GST_DEBUG_PAD_NAME (pad)); g_warning ("trying to set non fixed caps on pad %s:%s, not allowed", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); GST_DEBUG ("unfixed caps %" GST_PTR_FORMAT, caps); return GST_PAD_LINK_REFUSED; @@ -1423,8 +1424,7 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps) g_return_val_if_fail (GST_PAD_LINK_SINK (pad), GST_PAD_LINK_REFUSED); /* if the desired caps are already there, it's trivially ok */ - if (GST_PAD_CAPS (pad) && gst_caps_is_equal_fixed (caps, - GST_PAD_CAPS (pad))) { + if (GST_PAD_CAPS (pad) && gst_caps_is_equal_fixed (caps, GST_PAD_CAPS (pad))) { return GST_PAD_LINK_OK; } @@ -1438,17 +1438,17 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps) return GST_PAD_LINK_DELAYED; } - oldlink = GST_REAL_PAD(pad)->link; + oldlink = GST_REAL_PAD (pad)->link; if (oldlink && oldlink->filtercaps) { link->filtercaps = gst_caps_copy (oldlink->filtercaps); } if (link->srcpad == pad) { - link->srccaps = gst_caps_copy(caps); + link->srccaps = gst_caps_copy (caps); link->sinkcaps = gst_pad_get_caps (link->sinkpad); link->srcnotify = FALSE; } else { link->srccaps = gst_pad_get_caps (link->srcpad); - link->sinkcaps = gst_caps_copy(caps); + link->sinkcaps = gst_caps_copy (caps); link->sinknotify = FALSE; } @@ -1467,7 +1467,7 @@ gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps) * Returns: a #GstPadLinkReturn, like gst_pad_try_set_caps(). */ GstPadLinkReturn -gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps) +gst_pad_try_set_caps_nonfixed (GstPad * pad, const GstCaps * caps) { GstPadLink *link; GstPadLink *oldlink; @@ -1488,6 +1488,7 @@ gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps) * with what we're setting, it's trivially OK. */ if (GST_PAD_CAPS (pad)) { GstCaps *intersection; + intersection = gst_caps_intersect (caps, GST_PAD_CAPS (pad)); if (!gst_caps_is_empty (intersection)) { gst_caps_free (intersection); @@ -1506,17 +1507,17 @@ gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps) return GST_PAD_LINK_DELAYED; } - oldlink = GST_REAL_PAD(pad)->link; + oldlink = GST_REAL_PAD (pad)->link; if (oldlink && oldlink->filtercaps) { link->filtercaps = gst_caps_copy (oldlink->filtercaps); } if (link->srcpad == pad) { - link->srccaps = gst_caps_copy(caps); + link->srccaps = gst_caps_copy (caps); link->sinkcaps = gst_pad_get_caps (link->sinkpad); link->srcnotify = FALSE; } else { link->srccaps = gst_pad_get_caps (link->srcpad); - link->sinkcaps = gst_caps_copy(caps); + link->sinkcaps = gst_caps_copy (caps); link->sinknotify = FALSE; } @@ -1537,8 +1538,8 @@ gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps) * Returns: TRUE if the pads can be linked, FALSE otherwise. */ gboolean -gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, - const GstCaps *filtercaps) +gst_pad_can_link_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps) { GstRealPad *realsrc, *realsink; GstPadLink *link; @@ -1555,7 +1556,7 @@ gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE); GST_CAT_INFO (GST_CAT_PADS, "trying to link %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); /* now we need to deal with the real/ghost stuff */ realsrc = GST_PAD_REALIZE (srcpad); @@ -1563,36 +1564,36 @@ gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); + GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); } /* FIXME: shouldn't we convert this to g_return_val_if_fail? */ if (GST_RPAD_PEER (realsrc) != NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed", - GST_DEBUG_PAD_NAME (realsrc)); + GST_DEBUG_PAD_NAME (realsrc)); return FALSE; } if (GST_RPAD_PEER (realsink) != NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed", - GST_DEBUG_PAD_NAME (realsink)); + GST_DEBUG_PAD_NAME (realsink)); return FALSE; } if (GST_PAD_PARENT (realsrc) == NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed", - GST_DEBUG_PAD_NAME (realsrc)); + GST_DEBUG_PAD_NAME (realsrc)); return FALSE; } if (GST_PAD_PARENT (realsink) == NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed", - GST_DEBUG_PAD_NAME (realsrc)); + GST_DEBUG_PAD_NAME (realsrc)); return FALSE; } if (!gst_pad_check_schedulers (realsrc, realsink)) { g_warning ("linking pads with different scheds requires " - "exactly one decoupled element (such as queue)"); + "exactly one decoupled element (such as queue)"); return FALSE; } - + g_return_val_if_fail (realsrc != NULL, GST_PAD_LINK_REFUSED); g_return_val_if_fail (realsink != NULL, GST_PAD_LINK_REFUSED); @@ -1607,21 +1608,23 @@ gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, } if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) { - GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s is not a source pad, failed", - GST_DEBUG_PAD_NAME (link->srcpad)); + GST_CAT_INFO (GST_CAT_PADS, + "Real src pad %s:%s is not a source pad, failed", + GST_DEBUG_PAD_NAME (link->srcpad)); gst_pad_link_free (link); return FALSE; - } + } if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) { GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed", - GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_DEBUG_PAD_NAME (link->sinkpad)); gst_pad_link_free (link); return FALSE; } link->srccaps = gst_pad_get_caps (link->srcpad); link->sinkcaps = gst_pad_get_caps (link->sinkpad); - if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps); + if (filtercaps) + link->filtercaps = gst_caps_copy (filtercaps); gst_pad_link_intersect (link); if (gst_caps_is_empty (link->caps)) { @@ -1643,7 +1646,7 @@ gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, * Returns: TRUE if the pads can be linked, FALSE otherwise. */ gboolean -gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad) +gst_pad_can_link (GstPad * srcpad, GstPad * sinkpad) { return gst_pad_can_link_filtered (srcpad, sinkpad, NULL); } @@ -1660,8 +1663,8 @@ gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad) * Returns: TRUE if the pads have been linked, FALSE otherwise. */ gboolean -gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, - const GstCaps *filtercaps) +gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps) { GstRealPad *realsrc, *realsink; GstScheduler *src_sched, *sink_sched; @@ -1674,7 +1677,7 @@ gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE); GST_CAT_INFO (GST_CAT_PADS, "trying to link %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); /* now we need to deal with the real/ghost stuff */ realsrc = GST_PAD_REALIZE (srcpad); @@ -1682,36 +1685,36 @@ gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); + GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); } /* FIXME: shouldn't we convert this to g_return_val_if_fail? */ if (GST_RPAD_PEER (realsrc) != NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real source pad %s:%s has a peer, failed", - GST_DEBUG_PAD_NAME (realsrc)); + GST_DEBUG_PAD_NAME (realsrc)); return FALSE; } if (GST_RPAD_PEER (realsink) != NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has a peer, failed", - GST_DEBUG_PAD_NAME (realsink)); + GST_DEBUG_PAD_NAME (realsink)); return FALSE; } if (GST_PAD_PARENT (realsrc) == NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s has no parent, failed", - GST_DEBUG_PAD_NAME (realsrc)); + GST_DEBUG_PAD_NAME (realsrc)); return FALSE; } if (GST_PAD_PARENT (realsink) == NULL) { GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s has no parent, failed", - GST_DEBUG_PAD_NAME (realsrc)); + GST_DEBUG_PAD_NAME (realsrc)); return FALSE; } if (!gst_pad_check_schedulers (realsrc, realsink)) { g_warning ("linking pads with different scheds requires " - "exactly one decoupled element (such as queue)"); + "exactly one decoupled element (such as queue)"); return FALSE; } - + g_return_val_if_fail (realsrc != NULL, GST_PAD_LINK_REFUSED); g_return_val_if_fail (realsink != NULL, GST_PAD_LINK_REFUSED); @@ -1726,49 +1729,49 @@ gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, } if (GST_RPAD_DIRECTION (link->srcpad) != GST_PAD_SRC) { - GST_CAT_INFO (GST_CAT_PADS, "Real src pad %s:%s is not a source pad, failed", - GST_DEBUG_PAD_NAME (link->srcpad)); + GST_CAT_INFO (GST_CAT_PADS, + "Real src pad %s:%s is not a source pad, failed", + GST_DEBUG_PAD_NAME (link->srcpad)); gst_pad_link_free (link); return FALSE; - } + } if (GST_RPAD_DIRECTION (link->sinkpad) != GST_PAD_SINK) { GST_CAT_INFO (GST_CAT_PADS, "Real sink pad %s:%s is not a sink pad, failed", - GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_DEBUG_PAD_NAME (link->sinkpad)); gst_pad_link_free (link); return FALSE; } link->srccaps = gst_pad_get_caps (link->srcpad); link->sinkcaps = gst_pad_get_caps (link->sinkpad); - if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps); + if (filtercaps) + link->filtercaps = gst_caps_copy (filtercaps); if (gst_pad_link_try (link) == GST_PAD_LINK_REFUSED) return FALSE; /* fire off a signal to each of the pads telling them * that they've been linked */ - g_signal_emit (G_OBJECT (link->srcpad), gst_real_pad_signals[REAL_LINKED], - 0, link->sinkpad); - g_signal_emit (G_OBJECT (link->sinkpad), gst_real_pad_signals[REAL_LINKED], - 0, link->srcpad); + g_signal_emit (G_OBJECT (link->srcpad), gst_real_pad_signals[REAL_LINKED], + 0, link->sinkpad); + g_signal_emit (G_OBJECT (link->sinkpad), gst_real_pad_signals[REAL_LINKED], + 0, link->srcpad); src_sched = gst_pad_get_scheduler (GST_PAD (link->srcpad)); sink_sched = gst_pad_get_scheduler (GST_PAD (link->sinkpad)); /* now tell the scheduler */ if (src_sched && src_sched == sink_sched) { - gst_scheduler_pad_link (src_sched, - GST_PAD (link->srcpad), GST_PAD (link->sinkpad)); - } - else { - GST_CAT_INFO (GST_CAT_PADS, "not telling link to scheduler %s:%s and %s:%s, %p %p", - GST_DEBUG_PAD_NAME (link->srcpad), - GST_DEBUG_PAD_NAME (link->sinkpad), - src_sched, sink_sched); + gst_scheduler_pad_link (src_sched, + GST_PAD (link->srcpad), GST_PAD (link->sinkpad)); + } else { + GST_CAT_INFO (GST_CAT_PADS, + "not telling link to scheduler %s:%s and %s:%s, %p %p", + GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad), + src_sched, sink_sched); } GST_CAT_INFO (GST_CAT_PADS, "linked %s:%s and %s:%s, successful", - GST_DEBUG_PAD_NAME (link->srcpad), - GST_DEBUG_PAD_NAME (link->sinkpad)); + GST_DEBUG_PAD_NAME (link->srcpad), GST_DEBUG_PAD_NAME (link->sinkpad)); return TRUE; } @@ -1783,7 +1786,7 @@ gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, * Returns: TRUE if the pad could be linked, FALSE otherwise. */ gboolean -gst_pad_link (GstPad *srcpad, GstPad *sinkpad) +gst_pad_link (GstPad * srcpad, GstPad * sinkpad) { return gst_pad_link_filtered (srcpad, sinkpad, NULL); } @@ -1798,7 +1801,7 @@ gst_pad_link (GstPad *srcpad, GstPad *sinkpad) * instead. */ void -gst_pad_set_parent (GstPad *pad, GstElement *parent) +gst_pad_set_parent (GstPad * pad, GstElement * parent) { g_return_if_fail (GST_IS_PAD (pad)); g_return_if_fail (GST_PAD_PARENT (pad) == NULL); @@ -1817,8 +1820,8 @@ gst_pad_set_parent (GstPad *pad, GstElement *parent) * * Returns: the parent #GstElement. */ -GstElement* -gst_pad_get_parent (GstPad *pad) +GstElement * +gst_pad_get_parent (GstPad * pad) { g_return_val_if_fail (pad != NULL, NULL); g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -1827,15 +1830,16 @@ gst_pad_get_parent (GstPad *pad) } static void -gst_pad_set_pad_template (GstPad *pad, GstPadTemplate *templ) +gst_pad_set_pad_template (GstPad * pad, GstPadTemplate * templ) { /* this function would need checks if it weren't static */ - gst_object_replace ((GstObject **) &pad->padtemplate, (GstObject *) templ); - + gst_object_replace ((GstObject **) & pad->padtemplate, (GstObject *) templ); + if (templ) - g_signal_emit (G_OBJECT (templ), gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad); -} + g_signal_emit (G_OBJECT (templ), + gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad); +} /** * gst_pad_get_pad_template: @@ -1846,12 +1850,12 @@ gst_pad_set_pad_template (GstPad *pad, GstPadTemplate *templ) * Returns: the #GstPadTemplate from which this pad was instantiated, or %NULL * if this pad has no template. */ -GstPadTemplate* -gst_pad_get_pad_template (GstPad *pad) +GstPadTemplate * +gst_pad_get_pad_template (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); - return GST_PAD_PAD_TEMPLATE (pad); + return GST_PAD_PAD_TEMPLATE (pad); } @@ -1867,28 +1871,28 @@ gst_pad_get_pad_template (GstPad *pad) * Returns: the #GstScheduler of the pad, or %NULL if there is no parent or the * parent is not yet in a managing bin. */ -GstScheduler* -gst_pad_get_scheduler (GstPad *pad) +GstScheduler * +gst_pad_get_scheduler (GstPad * pad) { GstScheduler *scheduler = NULL; GstElement *parent; - + g_return_val_if_fail (GST_IS_PAD (pad), NULL); - + parent = gst_pad_get_parent (pad); if (parent) { if (GST_FLAG_IS_SET (parent, GST_ELEMENT_DECOUPLED)) { GstRealPad *peer = GST_RPAD_PEER (pad); if (peer) { - scheduler = gst_element_get_scheduler (gst_pad_get_parent (GST_PAD (peer))); + scheduler = + gst_element_get_scheduler (gst_pad_get_parent (GST_PAD (peer))); } - } - else { + } else { scheduler = gst_element_get_scheduler (parent); } } - + return scheduler; } @@ -1902,8 +1906,8 @@ gst_pad_get_scheduler (GstPad *pad) * * Returns: the parent #GstElement. */ -GstElement* -gst_pad_get_real_parent (GstPad *pad) +GstElement * +gst_pad_get_real_parent (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -1920,8 +1924,7 @@ gst_pad_get_real_parent (GstPad *pad) * 0.9. */ void -gst_pad_add_ghost_pad (GstPad *pad, - GstPad *ghostpad) +gst_pad_add_ghost_pad (GstPad * pad, GstPad * ghostpad) { GstRealPad *realpad; @@ -1929,7 +1932,7 @@ gst_pad_add_ghost_pad (GstPad *pad, g_return_if_fail (GST_IS_GHOST_PAD (ghostpad)); /* if we're ghosting a ghost pad, drill down to find the real pad */ - realpad = (GstRealPad*)pad; + realpad = (GstRealPad *) pad; while (GST_IS_GHOST_PAD (realpad)) realpad = GST_GPAD_REALPAD (realpad); g_return_if_fail (GST_IS_REAL_PAD (realpad)); @@ -1949,8 +1952,7 @@ gst_pad_add_ghost_pad (GstPad *pad, * Removes a ghost pad from a pad. Private, will be removed from the API in 0.9. */ void -gst_pad_remove_ghost_pad (GstPad *pad, - GstPad *ghostpad) +gst_pad_remove_ghost_pad (GstPad * pad, GstPad * ghostpad) { GstRealPad *realpad; @@ -1972,48 +1974,47 @@ gst_pad_remove_ghost_pad (GstPad *pad, * * Returns: a #GList of ghost pads. */ -GList* -gst_pad_get_ghost_pad_list (GstPad *pad) +GList * +gst_pad_get_ghost_pad_list (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); - return GST_PAD_REALIZE(pad)->ghostpads; + return GST_PAD_REALIZE (pad)->ghostpads; } static gboolean -_gst_pad_default_fixate_foreach (GQuark field_id, GValue *value, - gpointer s) +_gst_pad_default_fixate_foreach (GQuark field_id, GValue * value, gpointer s) { - GstStructure *structure = (GstStructure *)s; + GstStructure *structure = (GstStructure *) s; GType type = G_VALUE_TYPE (value); - - if (G_TYPE_IS_FUNDAMENTAL (type) || type == GST_TYPE_FOURCC) return TRUE; + + if (G_TYPE_IS_FUNDAMENTAL (type) || type == GST_TYPE_FOURCC) + return TRUE; if (type == GST_TYPE_INT_RANGE) { gst_structure_set (structure, g_quark_to_string (field_id), - G_TYPE_INT, gst_value_get_int_range_min (value), NULL); + G_TYPE_INT, gst_value_get_int_range_min (value), NULL); return FALSE; } if (type == GST_TYPE_DOUBLE_RANGE) { gst_structure_set (structure, g_quark_to_string (field_id), - G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL); + G_TYPE_DOUBLE, gst_value_get_double_range_min (value), NULL); return FALSE; } if (type == GST_TYPE_LIST) { gst_structure_set_value (structure, g_quark_to_string (field_id), - gst_value_list_get_value (value, 0)); + gst_value_list_get_value (value, 0)); return FALSE; } - g_critical ("don't know how to fixate type %s", g_type_name(type)); + g_critical ("don't know how to fixate type %s", g_type_name (type)); return TRUE; } static GstCaps * -_gst_pad_default_fixate_func (GstPad *pad, const GstCaps *caps) +_gst_pad_default_fixate_func (GstPad * pad, const GstCaps * caps) { - static GstStaticCaps octetcaps = GST_STATIC_CAPS ( - "application/octet-stream"); + static GstStaticCaps octetcaps = GST_STATIC_CAPS ("application/octet-stream"); GstStructure *structure; GstCaps *newcaps; @@ -2026,13 +2027,13 @@ _gst_pad_default_fixate_func (GstPad *pad, const GstCaps *caps) } if (caps->structs->len > 1) { - return gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, 0)), NULL); + return gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (caps, + 0)), NULL); } newcaps = gst_caps_copy (caps); structure = gst_caps_get_structure (newcaps, 0); - gst_structure_foreach (structure, _gst_pad_default_fixate_foreach, - structure); + gst_structure_foreach (structure, _gst_pad_default_fixate_foreach, structure); return newcaps; } @@ -2048,13 +2049,13 @@ _gst_pad_default_fixate_func (GstPad *pad, const GstCaps *caps) * Returns: TRUE if the pads were succesfully negotiated, FALSE otherwise. */ gboolean -gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad) +gst_pad_perform_negotiate (GstPad * srcpad, GstPad * sinkpad) { return GST_PAD_LINK_SUCCESSFUL (gst_pad_renegotiate (srcpad)); } static void -gst_pad_link_unnegotiate (GstPadLink *link) +gst_pad_link_unnegotiate (GstPadLink * link) { g_return_if_fail (link != NULL); @@ -2082,21 +2083,21 @@ gst_pad_link_unnegotiate (GstPadLink *link) * needs renegotiation. */ void -gst_pad_unnegotiate (GstPad *pad) +gst_pad_unnegotiate (GstPad * pad) { GstPadLink *link; g_return_if_fail (GST_IS_PAD (pad)); link = GST_RPAD_LINK (GST_PAD_REALIZE (pad)); - if (link) + if (link) gst_pad_link_unnegotiate (link); } /* returning NULL indicates that the arguments are invalid */ -static GstPadLink* -gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad, - const GstCaps *filtercaps) +static GstPadLink * +gst_pad_link_prepare (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps) { GstRealPad *realsrc, *realsink; GstPadLink *link; @@ -2109,7 +2110,7 @@ gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad, if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { GST_CAT_DEBUG (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); + GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); } g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, NULL); @@ -2119,16 +2120,16 @@ gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad, if (!gst_pad_check_schedulers (realsrc, realsink)) { g_warning ("linking pads with different scheds requires " - "exactly one decoupled element (such as queue)"); + "exactly one decoupled element (such as queue)"); return NULL; } - + if (GST_RPAD_DIRECTION (realsrc) == GST_RPAD_DIRECTION (realsink)) { g_warning ("%s:%s and %s:%s are both %s pads, failed", - GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink), - GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink"); + GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink), + GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink"); return NULL; - } + } link = gst_pad_link_new (); @@ -2142,7 +2143,8 @@ gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad, link->srccaps = gst_pad_get_caps (link->srcpad); link->sinkcaps = gst_pad_get_caps (link->sinkpad); - if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps); + if (filtercaps) + link->filtercaps = gst_caps_copy (filtercaps); return link; } @@ -2159,20 +2161,21 @@ gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad, * Returns: TRUE if the pads were succesfully renegotiated, FALSE otherwise. */ gboolean -gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, - const GstCaps *filtercaps) +gst_pad_try_relink_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps) { GstPadLink *link; - + GST_INFO ("trying to relink %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT - " with filtercaps %" GST_PTR_FORMAT, srcpad, sinkpad); + " with filtercaps %" GST_PTR_FORMAT, srcpad, sinkpad); link = gst_pad_link_prepare (srcpad, sinkpad, filtercaps); - if (!link) return FALSE; - - if (GST_RPAD_PEER (link->srcpad) != (GstRealPad*)link->sinkpad) { + if (!link) + return FALSE; + + if (GST_RPAD_PEER (link->srcpad) != (GstRealPad *) link->sinkpad) { g_warning ("Pads %s:%s and %s:%s were never linked", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); gst_pad_link_free (link); return FALSE; } @@ -2196,8 +2199,8 @@ gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, * Returns: TRUE if the pads were succesfully relinked, FALSE otherwise. */ gboolean -gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, - const GstCaps *filtercaps) +gst_pad_relink_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps) { if (gst_pad_try_relink_filtered (srcpad, sinkpad, filtercaps)) return TRUE; @@ -2220,7 +2223,7 @@ gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, * Returns: the intersection of the other pads' allowed caps. */ GstCaps * -gst_pad_proxy_getcaps (GstPad *pad) +gst_pad_proxy_getcaps (GstPad * pad) { GstElement *element; const GList *pads; @@ -2233,7 +2236,7 @@ gst_pad_proxy_getcaps (GstPad *pad) element = gst_pad_get_parent (pad); pads = gst_element_get_pad_list (element); - + caps = gst_caps_new_any (); while (pads) { GstPad *otherpad = GST_PAD (pads->data); @@ -2241,6 +2244,7 @@ gst_pad_proxy_getcaps (GstPad *pad) if (otherpad != pad) { GstCaps *allowed = gst_pad_get_allowed_caps (otherpad); + temp = gst_caps_intersect (caps, allowed); gst_caps_free (caps); gst_caps_free (allowed); @@ -2264,7 +2268,7 @@ gst_pad_proxy_getcaps (GstPad *pad) * Returns: GST_PAD_LINK_OK if sucessful */ GstPadLinkReturn -gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps) +gst_pad_proxy_pad_link (GstPad * pad, const GstCaps * caps) { GstElement *element; const GList *pads; @@ -2278,14 +2282,14 @@ gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps) element = gst_pad_get_parent (pad); pads = gst_element_get_pad_list (element); - + while (pads) { GstPad *otherpad = GST_PAD (pads->data); if (otherpad != pad) { ret = gst_pad_try_set_caps (otherpad, caps); if (GST_PAD_LINK_FAILED (ret)) { - return ret; + return ret; } } pads = g_list_next (pads); @@ -2305,7 +2309,7 @@ gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps) * Returns: a fixated caps, or NULL if caps cannot be fixed */ GstCaps * -gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps) +gst_pad_proxy_fixate (GstPad * pad, const GstCaps * caps) { GstElement *element; const GList *pads; @@ -2329,18 +2333,19 @@ gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps) othercaps = gst_pad_get_negotiated_caps (otherpad); if (othercaps) { - GstCaps *icaps; - icaps = gst_caps_intersect (othercaps, caps); - if (!gst_caps_is_empty (icaps)) { - return icaps; - } else { - gst_caps_free (icaps); - } + GstCaps *icaps; + + icaps = gst_caps_intersect (othercaps, caps); + if (!gst_caps_is_empty (icaps)) { + return icaps; + } else { + gst_caps_free (icaps); + } } } pads = g_list_next (pads); } - + return NULL; } @@ -2360,7 +2365,7 @@ gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps) * Returns: TRUE if the caps were set correctly, otherwise FALSE */ gboolean -gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps) +gst_pad_set_explicit_caps (GstPad * pad, const GstCaps * caps) { GstPadLinkReturn link_ret; @@ -2375,8 +2380,8 @@ gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps) return TRUE; } - gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), gst_caps_copy(caps)); - + gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), gst_caps_copy (caps)); + if (!GST_PAD_IS_LINKED (pad)) { GST_CAT_DEBUG (GST_CAT_PADS, "pad is not linked"); return TRUE; @@ -2384,7 +2389,7 @@ gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps) link_ret = gst_pad_try_set_caps (pad, caps); if (link_ret == GST_PAD_LINK_REFUSED) { GST_ELEMENT_ERROR (gst_pad_get_parent (pad), CORE, PAD, (NULL), - ("failed to negotiate (try_set_caps returned REFUSED)")); + ("failed to negotiate (try_set_caps returned REFUSED)")); return FALSE; } @@ -2392,7 +2397,7 @@ gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps) } static GstCaps * -gst_pad_explicit_getcaps (GstPad *pad) +gst_pad_explicit_getcaps (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -2405,7 +2410,7 @@ gst_pad_explicit_getcaps (GstPad *pad) } static GstPadLinkReturn -gst_pad_explicit_link (GstPad *pad, const GstCaps *caps) +gst_pad_explicit_link (GstPad * pad, const GstCaps * caps) { g_return_val_if_fail (GST_IS_PAD (pad), GST_PAD_LINK_REFUSED); g_return_val_if_fail (caps != NULL, GST_PAD_LINK_REFUSED); @@ -2431,7 +2436,7 @@ gst_pad_explicit_link (GstPad *pad, const GstCaps *caps) * better in gstreamer-0.9. */ void -gst_pad_use_explicit_caps (GstPad *pad) +gst_pad_use_explicit_caps (GstPad * pad) { g_return_if_fail (GST_IS_PAD (pad)); @@ -2450,7 +2455,7 @@ gst_pad_use_explicit_caps (GstPad *pad) * Returns: TRUE if the peer pad accepted the caps, FALSE otherwise. */ GstPadLinkReturn -gst_pad_proxy_link (GstPad *pad, const GstCaps *caps) +gst_pad_proxy_link (GstPad * pad, const GstCaps * caps) { return gst_pad_try_set_caps (pad, caps); } @@ -2462,7 +2467,7 @@ gst_pad_proxy_link (GstPad *pad, const GstCaps *caps) * Returns: TRUE if the pad has successfully negotiated caps. */ gboolean -gst_pad_is_negotiated (GstPad *pad) +gst_pad_is_negotiated (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), FALSE); @@ -2484,7 +2489,7 @@ gst_pad_is_negotiated (GstPad *pad) * negotiated. */ G_CONST_RETURN GstCaps * -gst_pad_get_negotiated_caps (GstPad *pad) +gst_pad_get_negotiated_caps (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -2505,8 +2510,8 @@ gst_pad_get_negotiated_caps (GstPad *pad) * Returns: the #GstCaps of this pad. This function returns a new caps, so use * gst_caps_free to get rid of it. */ -GstCaps* -gst_pad_get_caps (GstPad *pad) +GstCaps * +gst_pad_get_caps (GstPad * pad) { GstRealPad *realpad; @@ -2515,7 +2520,7 @@ gst_pad_get_caps (GstPad *pad) realpad = GST_PAD_REALIZE (pad); GST_CAT_DEBUG (GST_CAT_CAPS, "get pad caps of %s:%s (%p)", - GST_DEBUG_PAD_NAME (realpad), realpad); + GST_DEBUG_PAD_NAME (realpad), realpad); if (GST_RPAD_GETCAPSFUNC (realpad)) { GstCaps *caps; @@ -2525,8 +2530,8 @@ gst_pad_get_caps (GstPad *pad) if (caps == NULL) { g_critical ("pad %s:%s returned NULL caps from getcaps function\n", - GST_ELEMENT_NAME(GST_PAD_PARENT(GST_PAD (realpad))), - GST_PAD_NAME(realpad)); + GST_ELEMENT_NAME (GST_PAD_PARENT (GST_PAD (realpad))), + GST_PAD_NAME (realpad)); caps = gst_caps_new_any (); } @@ -2536,15 +2541,16 @@ gst_pad_get_caps (GstPad *pad) const GstCaps *caps; caps = GST_PAD_TEMPLATE_CAPS (templ); - GST_CAT_DEBUG (GST_CAT_CAPS, "using pad template %p with caps %"GST_PTR_FORMAT, - templ, caps); + GST_CAT_DEBUG (GST_CAT_CAPS, + "using pad template %p with caps %" GST_PTR_FORMAT, templ, caps); #if 0 /* FIXME we should enable something like this someday, but this is * a bit buggy */ if (!gst_caps_is_fixed (caps)) { - g_warning("pad %s:%s (%p) has no getcaps function and the pad template returns non-fixed caps. Element is probably broken.\n", - GST_DEBUG_PAD_NAME (realpad), realpad); + g_warning + ("pad %s:%s (%p) has no getcaps function and the pad template returns non-fixed caps. Element is probably broken.\n", + GST_DEBUG_PAD_NAME (realpad), realpad); } #endif @@ -2554,11 +2560,11 @@ gst_pad_get_caps (GstPad *pad) #if 0 /* FIXME enable */ - g_warning("pad %s:%s (%p) has no pad template\n", + g_warning ("pad %s:%s (%p) has no pad template\n", GST_DEBUG_PAD_NAME (realpad), realpad); #endif - return gst_caps_new_any(); + return gst_caps_new_any (); } /** @@ -2570,10 +2576,11 @@ gst_pad_get_caps (GstPad *pad) * Returns: the #GstCaps of this pad template. If you intend to keep a reference * on the caps, make a copy (see gst_caps_copy ()). */ -const GstCaps* -gst_pad_get_pad_template_caps (GstPad *pad) +const GstCaps * +gst_pad_get_pad_template_caps (GstPad * pad) { static GstStaticCaps anycaps = GST_STATIC_CAPS ("ANY"); + g_return_val_if_fail (GST_IS_PAD (pad), NULL); if (GST_PAD_PAD_TEMPLATE (pad)) @@ -2582,11 +2589,11 @@ gst_pad_get_pad_template_caps (GstPad *pad) #if 0 /* FIXME this should be enabled some day */ /* wingo: why? mail the list during 0.9 when you find this :) */ - g_warning("pad %s:%s (%p) has no pad template\n", + g_warning ("pad %s:%s (%p) has no pad template\n", GST_DEBUG_PAD_NAME (realpad), realpad); #endif - return gst_static_caps_get(&anycaps); + return gst_static_caps_get (&anycaps); } /* FIXME 0.9: This function should probably die, or at least be renamed to @@ -2601,15 +2608,15 @@ gst_pad_get_pad_template_caps (GstPad *pad) * Returns: the #GstCaps of this pad template, or NULL if not found. If you * intend to keep a reference on the caps, make a copy (see gst_caps_copy ()). */ -const GstCaps* -gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name) +const GstCaps * +gst_pad_template_get_caps_by_name (GstPadTemplate * templ, const gchar * name) { GstCaps *caps; g_return_val_if_fail (templ != NULL, NULL); caps = GST_PAD_TEMPLATE_CAPS (templ); - if (!caps) + if (!caps) return NULL; /* FIXME */ @@ -2630,25 +2637,23 @@ gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name) * checked, FALSE if the capabilities are not compatible. */ gboolean -gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad) +gst_pad_check_compatibility (GstPad * srcpad, GstPad * sinkpad) { g_return_val_if_fail (GST_IS_PAD (srcpad), FALSE); g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE); if (GST_PAD_CAPS (srcpad) && GST_PAD_CAPS (sinkpad)) { - if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad), - GST_PAD_CAPS (sinkpad))) { + if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad), + GST_PAD_CAPS (sinkpad))) { return FALSE; - } - else { + } else { return TRUE; } - } - else { - GST_CAT_DEBUG (GST_CAT_PADS, - "could not check capabilities of pads (%s:%s) and (%s:%s) %p %p", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad), - GST_PAD_CAPS (srcpad), GST_PAD_CAPS (sinkpad)); + } else { + GST_CAT_DEBUG (GST_CAT_PADS, + "could not check capabilities of pads (%s:%s) and (%s:%s) %p %p", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad), + GST_PAD_CAPS (srcpad), GST_PAD_CAPS (sinkpad)); return TRUE; } } @@ -2661,8 +2666,8 @@ gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad) * * Returns: the peer #GstPad. */ -GstPad* -gst_pad_get_peer (GstPad *pad) +GstPad * +gst_pad_get_peer (GstPad * pad) { g_return_val_if_fail (GST_IS_PAD (pad), NULL); @@ -2679,8 +2684,8 @@ gst_pad_get_peer (GstPad *pad) * Returns: the allowed #GstCaps of the pad link. Free the caps when * you no longer need it. */ -GstCaps* -gst_pad_get_allowed_caps (GstPad *pad) +GstCaps * +gst_pad_get_allowed_caps (GstPad * pad) { const GstCaps *mycaps; GstCaps *caps; @@ -2690,8 +2695,8 @@ gst_pad_get_allowed_caps (GstPad *pad) g_return_val_if_fail (GST_IS_REAL_PAD (pad), NULL); - GST_CAT_DEBUG (GST_CAT_PROPERTIES, "get allowed caps of %s:%s", - GST_DEBUG_PAD_NAME (pad)); + GST_CAT_DEBUG (GST_CAT_PROPERTIES, "get allowed caps of %s:%s", + GST_DEBUG_PAD_NAME (pad)); mycaps = gst_pad_get_pad_template_caps (pad); if (GST_RPAD_PEER (pad) == NULL) { @@ -2720,7 +2725,7 @@ gst_pad_get_allowed_caps (GstPad *pad) * changed, and that a renegotiation is suggested. */ void -gst_pad_caps_change_notify (GstPad *pad) +gst_pad_caps_change_notify (GstPad * pad) { } @@ -2739,7 +2744,7 @@ gst_pad_caps_change_notify (GstPad *pad) * on the console and returns FALSE otherwise. */ gboolean -gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed) +gst_pad_recover_caps_error (GstPad * pad, const GstCaps * allowed) { /* FIXME */ return FALSE; @@ -2755,38 +2760,38 @@ gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed) * * Returns: a new, empty #GstBuffer, or NULL if there is an error */ -GstBuffer* -gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size) +GstBuffer * +gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size) { GstRealPad *peer; g_return_val_if_fail (GST_IS_PAD (pad), NULL); g_return_val_if_fail (GST_PAD_IS_SRC (pad), NULL); - + peer = GST_RPAD_PEER (pad); if (!peer) - return gst_buffer_new_and_alloc(size); + return gst_buffer_new_and_alloc (size); GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting buffer", GST_DEBUG_PAD_NAME (pad)); if (peer->bufferallocfunc) { - GST_CAT_DEBUG (GST_CAT_PADS, - "calling bufferallocfunc &%s (@%p) of peer pad %s:%s", - GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc), - &peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad*) peer))); + GST_CAT_DEBUG (GST_CAT_PADS, + "calling bufferallocfunc &%s (@%p) of peer pad %s:%s", + GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc), + &peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad *) peer))); return (peer->bufferallocfunc) (GST_PAD (peer), offset, size); } else { - return gst_buffer_new_and_alloc(size); + return gst_buffer_new_and_alloc (size); } } static void -gst_real_pad_dispose (GObject *object) +gst_real_pad_dispose (GObject * object) { GstPad *pad = GST_PAD (object); - + /* No linked pad can ever be disposed. * It has to have a parent to be linked * and a parent would hold a reference */ @@ -2795,7 +2800,8 @@ gst_real_pad_dispose (GObject *object) well... */ g_assert (GST_PAD_PEER (pad) == NULL); - GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "dispose %s:%s", GST_DEBUG_PAD_NAME(pad)); + GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "dispose %s:%s", + GST_DEBUG_PAD_NAME (pad)); /* we destroy the ghostpads, because they are nothing without the real pad */ if (GST_REAL_PAD (pad)->ghostpads) { @@ -2807,33 +2813,34 @@ gst_real_pad_dispose (GObject *object) GstPad *ghostpad = GST_PAD (ghostpads->data); if (GST_IS_ELEMENT (GST_OBJECT_PARENT (ghostpad))) { - GstElement *parent = GST_ELEMENT (GST_OBJECT_PARENT (ghostpad)); + GstElement *parent = GST_ELEMENT (GST_OBJECT_PARENT (ghostpad)); - GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "removing ghost pad from element '%s'", - GST_OBJECT_NAME (parent)); - gst_element_remove_pad (parent, ghostpad); + GST_CAT_DEBUG (GST_CAT_REFCOUNTING, + "removing ghost pad from element '%s'", GST_OBJECT_NAME (parent)); + gst_element_remove_pad (parent, ghostpad); } else { - /* handle the case where we have some floating ghost pad that was never - added to an element */ - g_object_set (ghostpad, "real-pad", NULL, NULL); + /* handle the case where we have some floating ghost pad that was never + added to an element */ + g_object_set (ghostpad, "real-pad", NULL, NULL); } ghostpads = g_list_next (ghostpads); } g_list_free (orig); /* as the ghost pads are removed, they remove themselves from ->ghostpads. So it should be empty now. Let's assert that. */ - g_assert (GST_REAL_PAD(pad)->ghostpads == NULL); + g_assert (GST_REAL_PAD (pad)->ghostpads == NULL); } if (GST_IS_ELEMENT (GST_OBJECT_PARENT (pad))) { GST_CAT_DEBUG (GST_CAT_REFCOUNTING, "removing pad from element '%s'", - GST_OBJECT_NAME (GST_OBJECT (GST_ELEMENT (GST_OBJECT_PARENT (pad))))); - + GST_OBJECT_NAME (GST_OBJECT (GST_ELEMENT (GST_OBJECT_PARENT (pad))))); + gst_element_remove_pad (GST_ELEMENT (GST_OBJECT_PARENT (pad)), pad); } - + if (GST_RPAD_EXPLICIT_CAPS (pad)) { - GST_ERROR_OBJECT (pad, "still explicit caps %"GST_PTR_FORMAT" set", GST_RPAD_EXPLICIT_CAPS (pad)); + GST_ERROR_OBJECT (pad, "still explicit caps %" GST_PTR_FORMAT " set", + GST_RPAD_EXPLICIT_CAPS (pad)); g_warning ("pad %p has still explicit caps set", pad); gst_caps_replace (&GST_RPAD_EXPLICIT_CAPS (pad), NULL); } @@ -2852,7 +2859,7 @@ gst_real_pad_dispose (GObject *object) * in the element to a pad of an element up in the hierarchy. */ void -gst_pad_load_and_link (xmlNodePtr self, GstObject *parent) +gst_pad_load_and_link (xmlNodePtr self, GstObject * parent) { xmlNodePtr field = self->xmlChildrenNode; GstPad *pad = NULL, *targetpad; @@ -2863,27 +2870,27 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject *parent) while (field) { if (!strcmp (field->name, "name")) { - pad = gst_element_get_pad (GST_ELEMENT (parent), - xmlNodeGetContent (field)); - } - else if (!strcmp(field->name, "peer")) { + pad = gst_element_get_pad (GST_ELEMENT (parent), + xmlNodeGetContent (field)); + } else if (!strcmp (field->name, "peer")) { peer = xmlNodeGetContent (field); } field = field->next; } g_return_if_fail (pad != NULL); - if (peer == NULL) return; + if (peer == NULL) + return; split = g_strsplit (peer, ".", 2); if (split[0] == NULL || split[1] == NULL) { - GST_CAT_DEBUG (GST_CAT_XML, - "Could not parse peer '%s' for pad %s:%s, leaving unlinked", - peer, GST_DEBUG_PAD_NAME (pad)); + GST_CAT_DEBUG (GST_CAT_XML, + "Could not parse peer '%s' for pad %s:%s, leaving unlinked", + peer, GST_DEBUG_PAD_NAME (pad)); return; } - + g_return_if_fail (split[0] != NULL); g_return_if_fail (split[1] != NULL); @@ -2891,15 +2898,16 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject *parent) if (grandparent && GST_IS_BIN (grandparent)) { target = gst_bin_get_by_name_recurse_up (GST_BIN (grandparent), split[0]); - } - else + } else goto cleanup; - if (target == NULL) goto cleanup; + if (target == NULL) + goto cleanup; targetpad = gst_element_get_pad (target, split[1]); - if (targetpad == NULL) goto cleanup; + if (targetpad == NULL) + goto cleanup; gst_pad_link (pad, targetpad); @@ -2917,7 +2925,7 @@ cleanup: * Returns: the #xmlNodePtr representation of the pad. */ static xmlNodePtr -gst_pad_save_thyself (GstObject *object, xmlNodePtr parent) +gst_pad_save_thyself (GstObject * object, xmlNodePtr parent) { GstRealPad *realpad; GstPad *peer; @@ -2929,13 +2937,12 @@ gst_pad_save_thyself (GstObject *object, xmlNodePtr parent) xmlNewChild (parent, NULL, "name", GST_PAD_NAME (realpad)); if (GST_RPAD_PEER (realpad) != NULL) { gchar *content; - + peer = GST_PAD (GST_RPAD_PEER (realpad)); /* first check to see if the peer's parent's parent is the same */ /* we just save it off */ content = g_strdup_printf ("%s.%s", - GST_OBJECT_NAME (GST_PAD_PARENT (peer)), - GST_PAD_NAME (peer)); + GST_OBJECT_NAME (GST_PAD_PARENT (peer)), GST_PAD_NAME (peer)); xmlNewChild (parent, NULL, "peer", content); g_free (content); } else @@ -2957,7 +2964,7 @@ gst_pad_save_thyself (GstObject *object, xmlNodePtr parent) * Returns: the #xmlNodePtr representation of the pad. */ xmlNodePtr -gst_ghost_pad_save_thyself (GstPad *pad, xmlNodePtr parent) +gst_ghost_pad_save_thyself (GstPad * pad, xmlNodePtr parent) { xmlNodePtr self; @@ -2981,8 +2988,8 @@ gst_ghost_pad_save_thyself (GstPad *pad, xmlNodePtr parent) * Pushes a buffer or an event to the peer of @pad. @pad must be linked. May * only be called by @pad's parent. */ -void -gst_pad_push (GstPad *pad, GstData *data) +void +gst_pad_push (GstPad * pad, GstData * data) { GstRealPad *peer; @@ -2992,52 +2999,51 @@ gst_pad_push (GstPad *pad, GstData *data) if (!gst_probe_dispatcher_dispatch (&(GST_REAL_PAD (pad)->probedisp), &data)) return; - + if (!GST_PAD_IS_LINKED (pad)) { - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, "not pushing data %p as pad is unconnected", data); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, + "not pushing data %p as pad is unconnected", data); gst_data_unref (data); return; - } + } GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, "pushing"); peer = GST_RPAD_PEER (pad); if (!peer) { - g_warning ("push on pad %s:%s but it is unlinked", - GST_DEBUG_PAD_NAME (pad)); - } - else { + g_warning ("push on pad %s:%s but it is unlinked", + GST_DEBUG_PAD_NAME (pad)); + } else { if (!GST_IS_EVENT (data) && !GST_PAD_IS_ACTIVE (peer)) { - g_warning ("push on peer of pad %s:%s but peer is not active", - GST_DEBUG_PAD_NAME (pad)); + g_warning ("push on peer of pad %s:%s but peer is not active", + GST_DEBUG_PAD_NAME (pad)); return; } if (peer->chainhandler) { if (data) { - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, - "calling chainhandler &%s of peer pad %s:%s", - GST_DEBUG_FUNCPTR_NAME (peer->chainhandler), - GST_DEBUG_PAD_NAME (GST_PAD (peer))); - if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) - return; - - (peer->chainhandler) (GST_PAD (peer), data); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, + "calling chainhandler &%s of peer pad %s:%s", + GST_DEBUG_FUNCPTR_NAME (peer->chainhandler), + GST_DEBUG_PAD_NAME (GST_PAD (peer))); + if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) + return; + + (peer->chainhandler) (GST_PAD (peer), data); return; - } - else { - g_warning ("trying to push a NULL buffer on pad %s:%s", - GST_DEBUG_PAD_NAME (peer)); + } else { + g_warning ("trying to push a NULL buffer on pad %s:%s", + GST_DEBUG_PAD_NAME (peer)); return; } - } - else { + } else { g_warning ("internal error: push on pad %s:%s but it has no chainhandler", - GST_DEBUG_PAD_NAME (peer)); + GST_DEBUG_PAD_NAME (peer)); } } /* clean up the mess here */ - if (data != NULL) gst_data_unref (data); + if (data != NULL) + gst_data_unref (data); } /** @@ -3049,47 +3055,45 @@ gst_pad_push (GstPad *pad, GstData *data) * * Returns: a new #GstData from the peer pad. */ -GstData* -gst_pad_pull (GstPad *pad) +GstData * +gst_pad_pull (GstPad * pad) { GstRealPad *peer; - + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, "pulling"); g_return_val_if_fail (GST_PAD_DIRECTION (pad) == GST_PAD_SINK, - GST_DATA (gst_event_new (GST_EVENT_INTERRUPT))); + GST_DATA (gst_event_new (GST_EVENT_INTERRUPT))); peer = GST_RPAD_PEER (pad); if (!peer) { GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), - ("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad))); - } - else { -restart: + ("pull on pad %s:%s but it was unlinked", GST_DEBUG_PAD_NAME (pad))); + } else { + restart: if (peer->gethandler) { GstData *data; GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, pad, - "calling gethandler %s of peer pad %s:%s", - GST_DEBUG_FUNCPTR_NAME (peer->gethandler), - GST_DEBUG_PAD_NAME (peer)); + "calling gethandler %s of peer pad %s:%s", + GST_DEBUG_FUNCPTR_NAME (peer->gethandler), GST_DEBUG_PAD_NAME (peer)); data = (peer->gethandler) (GST_PAD (peer)); if (data) { - if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) - goto restart; - return data; + if (!gst_probe_dispatcher_dispatch (&peer->probedisp, &data)) + goto restart; + return data; } /* no null buffers allowed */ GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), - ("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad))); + ("NULL buffer during pull on %s:%s", GST_DEBUG_PAD_NAME (pad))); } else { GST_ELEMENT_ERROR (GST_PAD_PARENT (pad), CORE, PAD, (NULL), - ("pull on pad %s:%s but the peer pad %s:%s has no gethandler", - GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer))); + ("pull on pad %s:%s but the peer pad %s:%s has no gethandler", + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (peer))); } } return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); @@ -3105,13 +3109,13 @@ restart: * Returns: the #GstPad that has a buffer available. * Use #gst_pad_pull() to get the buffer. */ -GstPad* -gst_pad_selectv (GList *padlist) +GstPad * +gst_pad_selectv (GList * padlist) { GstPad *pad; - pad = gst_scheduler_pad_select (GST_PAD_PARENT (padlist->data)->sched, - padlist); + pad = gst_scheduler_pad_select (GST_PAD_PARENT (padlist->data)->sched, + padlist); return pad; } @@ -3126,8 +3130,8 @@ gst_pad_selectv (GList *padlist) * Returns: the #GstPad that has a buffer available. * Use #gst_pad_pull() to get the buffer. */ -GstPad* -gst_pad_select (GstPad *pad, ...) +GstPad * +gst_pad_select (GstPad * pad, ...) { GstPad *result; va_list var_args; @@ -3140,7 +3144,7 @@ gst_pad_select (GstPad *pad, ...) result = gst_pad_select_valist (pad, var_args); va_end (var_args); - + return result; } @@ -3154,8 +3158,8 @@ gst_pad_select (GstPad *pad, ...) * Returns: the #GstPad that has a buffer available. * Use #gst_pad_pull() to get the buffer. */ -GstPad* -gst_pad_select_valist (GstPad *pad, va_list var_args) +GstPad * +gst_pad_select_valist (GstPad * pad, va_list var_args) { GstPad *result; GList *padlist = NULL; @@ -3178,9 +3182,9 @@ gst_pad_select_valist (GstPad *pad, va_list var_args) * templates * */ -static void gst_pad_template_class_init (GstPadTemplateClass *klass); -static void gst_pad_template_init (GstPadTemplate *templ); -static void gst_pad_template_dispose (GObject *object); +static void gst_pad_template_class_init (GstPadTemplateClass * klass); +static void gst_pad_template_init (GstPadTemplate * templ); +static void gst_pad_template_dispose (GObject * object); GType gst_pad_template_get_type (void) @@ -3195,28 +3199,28 @@ gst_pad_template_get_type (void) 32, (GInstanceInitFunc) gst_pad_template_init, NULL }; - padtemplate_type = g_type_register_static(GST_TYPE_OBJECT, "GstPadTemplate", - &padtemplate_info, 0); + padtemplate_type = + g_type_register_static (GST_TYPE_OBJECT, "GstPadTemplate", + &padtemplate_info, 0); } return padtemplate_type; } static void -gst_pad_template_class_init (GstPadTemplateClass *klass) +gst_pad_template_class_init (GstPadTemplateClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; - gobject_class = (GObjectClass*) klass; - gstobject_class = (GstObjectClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; padtemplate_parent_class = g_type_class_ref (GST_TYPE_OBJECT); gst_pad_template_signals[TEMPL_PAD_CREATED] = - g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstPadTemplateClass, pad_created), - NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, - GST_TYPE_PAD); + g_signal_new ("pad-created", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstPadTemplateClass, pad_created), + NULL, NULL, gst_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GST_TYPE_PAD); gobject_class->dispose = gst_pad_template_dispose; @@ -3224,12 +3228,12 @@ gst_pad_template_class_init (GstPadTemplateClass *klass) } static void -gst_pad_template_init (GstPadTemplate *templ) +gst_pad_template_init (GstPadTemplate * templ) { } static void -gst_pad_template_dispose (GObject *object) +gst_pad_template_dispose (GObject * object) { GstPadTemplate *templ = GST_PAD_TEMPLATE (object); @@ -3250,35 +3254,34 @@ gst_pad_template_dispose (GObject *object) * naming. */ static gboolean -name_is_valid (const gchar *name, GstPadPresence presence) +name_is_valid (const gchar * name, GstPadPresence presence) { const gchar *str; - + if (presence == GST_PAD_ALWAYS) { if (strchr (name, '%')) { g_warning ("invalid name template %s: conversion specifications are not" - " allowed for GST_PAD_ALWAYS padtemplates", name); + " allowed for GST_PAD_ALWAYS padtemplates", name); return FALSE; } } else if (presence == GST_PAD_REQUEST) { if ((str = strchr (name, '%')) && strchr (str + 1, '%')) { g_warning ("invalid name template %s: only one conversion specification" - " allowed in GST_PAD_REQUEST padtemplate", name); + " allowed in GST_PAD_REQUEST padtemplate", name); return FALSE; } - if (str && (*(str+1) != 's' && *(str+1) != 'd')) { + if (str && (*(str + 1) != 's' && *(str + 1) != 'd')) { g_warning ("invalid name template %s: conversion specification must be of" - " type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name); + " type '%%d' or '%%s' for GST_PAD_REQUEST padtemplate", name); return FALSE; } - if (str && (*(str+2) != '\0')) { + if (str && (*(str + 2) != '\0')) { g_warning ("invalid name template %s: conversion specification must" - " appear at the end of the GST_PAD_REQUEST padtemplate name", - name); + " appear at the end of the GST_PAD_REQUEST padtemplate name", name); return FALSE; } } - + return TRUE; } @@ -3290,8 +3293,8 @@ name_is_valid (const gchar *name, GstPadPresence presence) * * Returns: a new #GstPadTemplate. */ -GstPadTemplate* -gst_static_pad_template_get (GstStaticPadTemplate *pad_template) +GstPadTemplate * +gst_static_pad_template_get (GstStaticPadTemplate * pad_template) { GstPadTemplate *new; @@ -3299,16 +3302,14 @@ gst_static_pad_template_get (GstStaticPadTemplate *pad_template) return NULL; new = g_object_new (gst_pad_template_get_type (), - "name", pad_template->name_template, - NULL); + "name", pad_template->name_template, NULL); - GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = - g_strdup (pad_template->name_template); + GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (pad_template->name_template); GST_PAD_TEMPLATE_DIRECTION (new) = pad_template->direction; GST_PAD_TEMPLATE_PRESENCE (new) = pad_template->presence; - GST_PAD_TEMPLATE_CAPS (new) = gst_caps_copy ( - gst_static_caps_get (&pad_template->static_caps)); + GST_PAD_TEMPLATE_CAPS (new) = + gst_caps_copy (gst_static_caps_get (&pad_template->static_caps)); return new; } @@ -3326,10 +3327,9 @@ gst_static_pad_template_get (GstStaticPadTemplate *pad_template) * * Returns: a new #GstPadTemplate. */ -GstPadTemplate* -gst_pad_template_new (const gchar *name_template, - GstPadDirection direction, GstPadPresence presence, - GstCaps *caps) +GstPadTemplate * +gst_pad_template_new (const gchar * name_template, + GstPadDirection direction, GstPadPresence presence, GstCaps * caps) { GstPadTemplate *new; @@ -3342,14 +3342,14 @@ gst_pad_template_new (const gchar *name_template, #ifdef USE_POISONING if (caps) { GstCaps *newcaps = gst_caps_copy (caps); - gst_caps_free(caps); + + gst_caps_free (caps); caps = newcaps; } #endif #endif new = g_object_new (gst_pad_template_get_type (), - "name", name_template, - NULL); + "name", name_template, NULL); GST_PAD_TEMPLATE_NAME_TEMPLATE (new) = g_strdup (name_template); GST_PAD_TEMPLATE_DIRECTION (new) = direction; @@ -3368,8 +3368,8 @@ gst_pad_template_new (const gchar *name_template, * Returns: the #GstCaps of the pad template. If you need to keep a reference to * the caps, make a copy (see gst_caps_copy ()). */ -const GstCaps* -gst_pad_template_get_caps (GstPadTemplate *templ) +const GstCaps * +gst_pad_template_get_caps (GstPadTemplate * templ) { g_return_val_if_fail (GST_IS_PAD_TEMPLATE (templ), NULL); @@ -3385,7 +3385,7 @@ gst_pad_template_get_caps (GstPadTemplate *templ) * This function can only be used by the element that owns the pad. */ void -gst_pad_set_element_private (GstPad *pad, gpointer priv) +gst_pad_set_element_private (GstPad * pad, gpointer priv) { pad->element_private = priv; } @@ -3399,7 +3399,7 @@ gst_pad_set_element_private (GstPad *pad, gpointer priv) * Returns: a #gpointer to the private data. */ gpointer -gst_pad_get_element_private (GstPad *pad) +gst_pad_get_element_private (GstPad * pad) { return pad->element_private; } @@ -3408,25 +3408,26 @@ gst_pad_get_element_private (GstPad *pad) /***** ghost pads *****/ GType _gst_ghost_pad_type = 0; -static void gst_ghost_pad_class_init (GstGhostPadClass *klass); -static void gst_ghost_pad_init (GstGhostPad *pad); -static void gst_ghost_pad_dispose (GObject *object); -static void gst_ghost_pad_get_property (GObject* object, guint prop_id, - GValue* value, GParamSpec* pspec); -static void gst_ghost_pad_set_property (GObject* object, guint prop_id, - const GValue* value, GParamSpec* pspec); +static void gst_ghost_pad_class_init (GstGhostPadClass * klass); +static void gst_ghost_pad_init (GstGhostPad * pad); +static void gst_ghost_pad_dispose (GObject * object); +static void gst_ghost_pad_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_ghost_pad_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); static GstPad *ghost_pad_parent_class = NULL; + /* static guint gst_ghost_pad_signals[LAST_SIGNAL] = { 0 }; */ -enum +enum { GPAD_ARG_0, GPAD_ARG_REAL_PAD - /* fill me */ + /* fill me */ }; GType -gst_ghost_pad_get_type (void) +gst_ghost_pad_get_type (void) { if (!_gst_ghost_pad_type) { static const GTypeInfo pad_info = { @@ -3437,18 +3438,18 @@ gst_ghost_pad_get_type (void) (GInstanceInitFunc) gst_ghost_pad_init, NULL }; - _gst_ghost_pad_type = g_type_register_static (GST_TYPE_PAD, "GstGhostPad", - &pad_info, 0); + _gst_ghost_pad_type = g_type_register_static (GST_TYPE_PAD, "GstGhostPad", + &pad_info, 0); } return _gst_ghost_pad_type; } static void -gst_ghost_pad_class_init (GstGhostPadClass *klass) +gst_ghost_pad_class_init (GstGhostPadClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; ghost_pad_parent_class = g_type_class_ref (GST_TYPE_PAD); @@ -3457,18 +3458,18 @@ gst_ghost_pad_class_init (GstGhostPadClass *klass) gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_ghost_pad_get_property); g_object_class_install_property (gobject_class, GPAD_ARG_REAL_PAD, - g_param_spec_object ("real-pad", "Real pad", "The real pad for the ghost pad", - GST_TYPE_PAD, G_PARAM_READWRITE)); + g_param_spec_object ("real-pad", "Real pad", + "The real pad for the ghost pad", GST_TYPE_PAD, G_PARAM_READWRITE)); } static void -gst_ghost_pad_init (GstGhostPad *pad) +gst_ghost_pad_init (GstGhostPad * pad) { /* zeroed by glib */ } static void -gst_ghost_pad_dispose (GObject *object) +gst_ghost_pad_dispose (GObject * object) { g_object_set (object, "real-pad", NULL, NULL); @@ -3476,26 +3477,26 @@ gst_ghost_pad_dispose (GObject *object) } static void -gst_ghost_pad_set_property (GObject* object, guint prop_id, - const GValue* value, GParamSpec* pspec) +gst_ghost_pad_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { - GstPad *ghostpad = (GstPad*)object; - GstPad *oldrealpad = (GstPad*)GST_GPAD_REALPAD (ghostpad); + GstPad *ghostpad = (GstPad *) object; + GstPad *oldrealpad = (GstPad *) GST_GPAD_REALPAD (ghostpad); GstPad *realpad = NULL; - + switch (prop_id) { case GPAD_ARG_REAL_PAD: realpad = g_value_get_object (value); - + if (oldrealpad) { - if (realpad == oldrealpad) - return; - else - gst_pad_remove_ghost_pad (oldrealpad, ghostpad); + if (realpad == oldrealpad) + return; + else + gst_pad_remove_ghost_pad (oldrealpad, ghostpad); } - + if (realpad) - gst_pad_add_ghost_pad (realpad, ghostpad); + gst_pad_add_ghost_pad (realpad, ghostpad); break; default: @@ -3505,8 +3506,8 @@ gst_ghost_pad_set_property (GObject* object, guint prop_id, } static void -gst_ghost_pad_get_property (GObject* object, guint prop_id, - GValue* value, GParamSpec* pspec) +gst_ghost_pad_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { switch (prop_id) { case GPAD_ARG_REAL_PAD: @@ -3529,22 +3530,17 @@ gst_ghost_pad_get_property (GObject* object, guint prop_id, * * Returns: a new ghost #GstPad, or %NULL in case of an error. */ -GstPad* -gst_ghost_pad_new (const gchar *name, - GstPad *pad) +GstPad * +gst_ghost_pad_new (const gchar * name, GstPad * pad) { GstPad *gpad; g_return_val_if_fail (GST_IS_PAD (pad), NULL); - gpad = g_object_new (GST_TYPE_GHOST_PAD, - "name", name, - "real-pad", pad, - NULL); + gpad = g_object_new (GST_TYPE_GHOST_PAD, "name", name, "real-pad", pad, NULL); - GST_CAT_DEBUG (GST_CAT_PADS, "created ghost pad \"%s\" for pad %s:%s", - GST_OBJECT_NAME (gpad), - GST_DEBUG_PAD_NAME (pad)); + GST_CAT_DEBUG (GST_CAT_PADS, "created ghost pad \"%s\" for pad %s:%s", + GST_OBJECT_NAME (gpad), GST_DEBUG_PAD_NAME (pad)); return gpad; } @@ -3561,15 +3557,15 @@ gst_ghost_pad_new (const gchar *name, * * Returns: a newly allocated #GList of pads. */ -GList* -gst_pad_get_internal_links_default (GstPad *pad) +GList * +gst_pad_get_internal_links_default (GstPad * pad) { GList *res = NULL; GstElement *parent; GList *parent_pads; GstPadDirection direction; GstRealPad *rpad; - + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); rpad = GST_PAD_REALIZE (pad); @@ -3580,11 +3576,11 @@ gst_pad_get_internal_links_default (GstPad *pad) while (parent_pads) { GstRealPad *parent_pad = GST_PAD_REALIZE (parent_pads->data); - + if (parent_pad->direction != direction) { res = g_list_prepend (res, parent_pad); } - + parent_pads = g_list_next (parent_pads); } @@ -3601,8 +3597,8 @@ gst_pad_get_internal_links_default (GstPad *pad) * * Returns: a newly allocated #GList of pads. */ -GList* -gst_pad_get_internal_links (GstPad *pad) +GList * +gst_pad_get_internal_links (GstPad * pad) { GList *res = NULL; GstRealPad *rpad; @@ -3618,34 +3614,35 @@ gst_pad_get_internal_links (GstPad *pad) } -static gboolean -gst_pad_event_default_dispatch (GstPad *pad, GstElement *element, - GstEvent *event) +static gboolean +gst_pad_event_default_dispatch (GstPad * pad, GstElement * element, + GstEvent * event) { GList *orig, *pads; - GST_INFO_OBJECT (pad, "Sending event %p to all internally linked pads", event); + GST_INFO_OBJECT (pad, "Sending event %p to all internally linked pads", + event); orig = pads = gst_pad_get_internal_links (pad); while (pads) { GstPad *eventpad = GST_PAD (pads->data); + pads = g_list_next (pads); /* for all of the internally-linked pads that are actually linked */ if (GST_PAD_IS_LINKED (eventpad)) { if (GST_PAD_DIRECTION (eventpad) == GST_PAD_SRC) { /* increase the refcount */ - gst_event_ref (event); - gst_pad_push (eventpad, GST_DATA (event)); - } - else { + gst_event_ref (event); + gst_pad_push (eventpad, GST_DATA (event)); + } else { GstPad *peerpad = GST_PAD (GST_RPAD_PEER (eventpad)); /* we only send the event on one pad, multi-sinkpad elements * should implement a handler */ - g_list_free (orig); - return gst_pad_send_event (peerpad, event); + g_list_free (orig); + return gst_pad_send_event (peerpad, event); } } } @@ -3667,14 +3664,14 @@ gst_pad_event_default_dispatch (GstPad *pad, GstElement *element, * * Returns: TRUE if the event was sent succesfully. */ -gboolean -gst_pad_event_default (GstPad *pad, GstEvent *event) +gboolean +gst_pad_event_default (GstPad * pad, GstEvent * event) { GstElement *element; - + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (event != NULL, FALSE); - + element = GST_PAD_PARENT (pad); switch (GST_EVENT_TYPE (event)) { @@ -3685,21 +3682,25 @@ gst_pad_event_default (GstPad *pad, GstEvent *event) case GST_EVENT_DISCONTINUOUS: { guint64 time; - + if (gst_element_requires_clock (element) && element->clock) { if (gst_event_discont_get_value (event, GST_FORMAT_TIME, &time)) { - gst_element_set_time (element, time); + gst_element_set_time (element, time); } else { GstFormat format = GST_FORMAT_TIME; guint i; + for (i = 0; i < event->event_data.discont.noffsets; i++) { - if (gst_pad_convert (pad, event->event_data.discont.offsets[i].format, - event->event_data.discont.offsets[i].value, &format, &time)) { + if (gst_pad_convert (pad, + event->event_data.discont.offsets[i].format, + event->event_data.discont.offsets[i].value, &format, + &time)) { gst_element_set_time (element, time); } else if (i == event->event_data.discont.noffsets) { - g_warning ("can't adjust clock to new time when time not provided"); + g_warning + ("can't adjust clock to new time when time not provided"); } - } + } } } } @@ -3723,12 +3724,12 @@ gst_pad_event_default (GstPad *pad, GstEvent *event) * Returns: TRUE if one of the dispatcher functions returned TRUE. */ gboolean -gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch, - gpointer data) +gst_pad_dispatcher (GstPad * pad, GstPadDispatcherFunction dispatch, + gpointer data) { gboolean res = FALSE; GList *int_pads, *orig; - + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (dispatch != NULL, FALSE); @@ -3741,13 +3742,13 @@ gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch, if (int_peer) { res = dispatch (GST_PAD (int_peer), data); if (res) - break; + break; } int_pads = g_list_next (int_pads); } g_list_free (orig); - + return res; } @@ -3761,7 +3762,7 @@ gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch, * Returns: TRUE if the event was handled. */ gboolean -gst_pad_send_event (GstPad *pad, GstEvent *event) +gst_pad_send_event (GstPad * pad, GstEvent * event) { gboolean success = FALSE; GstRealPad *rpad; @@ -3775,7 +3776,7 @@ gst_pad_send_event (GstPad *pad, GstEvent *event) GST_EVENT_SRC (event) = gst_object_ref (GST_OBJECT (rpad)); GST_CAT_DEBUG (GST_CAT_EVENT, "have event %d on pad %s:%s", - GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (rpad)); + GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (rpad)); if (GST_RPAD_EVENTHANDLER (rpad)) success = GST_RPAD_EVENTHANDLER (rpad) (GST_PAD (rpad), event); @@ -3787,19 +3788,19 @@ gst_pad_send_event (GstPad *pad, GstEvent *event) return success; } -typedef struct +typedef struct { - GstFormat src_format; - gint64 src_value; - GstFormat *dest_format; - gint64 *dest_value; + GstFormat src_format; + gint64 src_value; + GstFormat *dest_format; + gint64 *dest_value; } GstPadConvertData; static gboolean -gst_pad_convert_dispatcher (GstPad *pad, GstPadConvertData *data) +gst_pad_convert_dispatcher (GstPad * pad, GstPadConvertData * data) { - return gst_pad_convert (pad, data->src_format, data->src_value, - data->dest_format, data->dest_value); + return gst_pad_convert (pad, data->src_format, data->src_value, + data->dest_format, data->dest_value); } /** @@ -3818,9 +3819,9 @@ gst_pad_convert_dispatcher (GstPad *pad, GstPadConvertData *data) * Returns: TRUE if the conversion could be performed. */ gboolean -gst_pad_convert_default (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_pad_convert_default (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { GstPadConvertData data; @@ -3833,8 +3834,8 @@ gst_pad_convert_default (GstPad *pad, data.dest_format = dest_format; data.dest_value = dest_value; - return gst_pad_dispatcher (pad, (GstPadDispatcherFunction) - gst_pad_convert_dispatcher, &data); + return gst_pad_dispatcher (pad, (GstPadDispatcherFunction) + gst_pad_convert_dispatcher, &data); } /** @@ -3850,40 +3851,40 @@ gst_pad_convert_default (GstPad *pad, * Returns: TRUE if the conversion could be performed. */ gboolean -gst_pad_convert (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value) +gst_pad_convert (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value) { GstRealPad *rpad; - + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (dest_format != NULL, FALSE); g_return_val_if_fail (dest_value != NULL, FALSE); if (src_format == *dest_format) { - *dest_value = src_value; + *dest_value = src_value; return TRUE; - } + } rpad = GST_PAD_REALIZE (pad); if (GST_RPAD_CONVERTFUNC (rpad)) { - return GST_RPAD_CONVERTFUNC (rpad) (GST_PAD (rpad), src_format, - src_value, dest_format, dest_value); + return GST_RPAD_CONVERTFUNC (rpad) (GST_PAD (rpad), src_format, + src_value, dest_format, dest_value); } return FALSE; } -typedef struct +typedef struct { - GstQueryType type; - GstFormat *format; - gint64 *value; + GstQueryType type; + GstFormat *format; + gint64 *value; } GstPadQueryData; static gboolean -gst_pad_query_dispatcher (GstPad *pad, GstPadQueryData *data) +gst_pad_query_dispatcher (GstPad * pad, GstPadQueryData * data) { return gst_pad_query (pad, data->type, data->format, data->value); } @@ -3900,8 +3901,8 @@ gst_pad_query_dispatcher (GstPad *pad, GstPadQueryData *data) * Returns: TRUE if the query could be performed. */ gboolean -gst_pad_query_default (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_pad_query_default (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstPadQueryData data; @@ -3913,8 +3914,8 @@ gst_pad_query_default (GstPad *pad, GstQueryType type, data.format = format; data.value = value; - return gst_pad_dispatcher (pad, (GstPadDispatcherFunction) - gst_pad_query_dispatcher, &data); + return gst_pad_dispatcher (pad, (GstPadDispatcherFunction) + gst_pad_query_dispatcher, &data); } /** @@ -3933,11 +3934,11 @@ gst_pad_query_default (GstPad *pad, GstQueryType type, * Returns: TRUE if the query could be performed. */ gboolean -gst_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstRealPad *rpad; - + g_return_val_if_fail (GST_IS_PAD (pad), FALSE); g_return_val_if_fail (format != NULL, FALSE); g_return_val_if_fail (value != NULL, FALSE); @@ -3953,7 +3954,7 @@ gst_pad_query (GstPad *pad, GstQueryType type, } static gboolean -gst_pad_get_formats_dispatcher (GstPad *pad, const GstFormat **data) +gst_pad_get_formats_dispatcher (GstPad * pad, const GstFormat ** data) { *data = gst_pad_get_formats (pad); @@ -3968,15 +3969,15 @@ gst_pad_get_formats_dispatcher (GstPad *pad, const GstFormat **data) * * Returns: An array of GstFormats ended with a 0 value. */ -const GstFormat* -gst_pad_get_formats_default (GstPad *pad) +const GstFormat * +gst_pad_get_formats_default (GstPad * pad) { GstFormat *result = NULL; g_return_val_if_fail (GST_IS_PAD (pad), NULL); - gst_pad_dispatcher (pad, (GstPadDispatcherFunction) - gst_pad_get_formats_dispatcher, &result); + gst_pad_dispatcher (pad, (GstPadDispatcherFunction) + gst_pad_get_formats_dispatcher, &result); return result; } @@ -3989,11 +3990,11 @@ gst_pad_get_formats_default (GstPad *pad) * * Returns: An array of GstFormats ended with a 0 value. */ -const GstFormat* -gst_pad_get_formats (GstPad *pad) +const GstFormat * +gst_pad_get_formats (GstPad * pad) { GstRealPad *rpad; - + g_return_val_if_fail (GST_IS_PAD (pad), NULL); rpad = GST_PAD_REALIZE (pad); diff --git a/gst/gstpad.h b/gst/gstpad.h index c8702a90e..1d265e259 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -34,16 +34,14 @@ #include -G_BEGIN_DECLS - -extern GType _gst_pad_type; +G_BEGIN_DECLS extern GType _gst_pad_type; extern GType _gst_real_pad_type; extern GType _gst_ghost_pad_type; /* * Pad base class */ -#define GST_TYPE_PAD (_gst_pad_type) +#define GST_TYPE_PAD (_gst_pad_type) #define GST_IS_PAD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD)) #define GST_IS_PAD_FAST(obj) (G_OBJECT_TYPE(obj) == GST_TYPE_REAL_PAD || \ G_OBJECT_TYPE(obj) == GST_TYPE_GHOST_PAD) @@ -78,16 +76,18 @@ typedef struct _GstRealPad GstRealPad; typedef struct _GstRealPadClass GstRealPadClass; typedef struct _GstGhostPad GstGhostPad; typedef struct _GstGhostPadClass GstGhostPadClass; + /*typedef struct _GstPadTemplate GstPadTemplate;*/ /*typedef struct _GstPadTemplateClass GstPadTemplateClass;*/ typedef struct _GstStaticPadTemplate GstStaticPadTemplate; typedef struct _GstPadLink GstPadLink; -typedef enum { +typedef enum +{ GST_PAD_LINK_REFUSED = -1, - GST_PAD_LINK_DELAYED = 0, - GST_PAD_LINK_OK = 1, - GST_PAD_LINK_DONE = 2 + GST_PAD_LINK_DELAYED = 0, + GST_PAD_LINK_OK = 1, + GST_PAD_LINK_DONE = 2 } GstPadLinkReturn; #define GST_PAD_LINK_FAILED(ret) (ret < GST_PAD_LINK_OK) @@ -106,120 +106,129 @@ typedef enum { #endif #endif - + /* this defines the functions used to chain buffers * pad is the sink pad (so the same chain function can be used for N pads) * buf is the buffer being passed */ -typedef void (*GstPadChainFunction) (GstPad *pad,GstData *data); -typedef GstData* (*GstPadGetFunction) (GstPad *pad); -typedef gboolean (*GstPadEventFunction) (GstPad *pad, GstEvent *event); -typedef gboolean (*GstPadConvertFunction) (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); -typedef gboolean (*GstPadQueryFunction) (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); -typedef GList* (*GstPadIntLinkFunction) (GstPad *pad); -typedef const GstFormat* (*GstPadFormatsFunction) (GstPad *pad); -typedef const GstEventMask* (*GstPadEventMaskFunction) (GstPad *pad); -typedef const GstQueryType* (*GstPadQueryTypeFunction) (GstPad *pad); - -typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad *pad, const GstCaps *caps); -typedef void (*GstPadUnlinkFunction) (GstPad *pad); -typedef GstCaps* (*GstPadGetCapsFunction) (GstPad *pad); -typedef GstCaps* (*GstPadFixateFunction) (GstPad *pad, const GstCaps *caps); -typedef GstBuffer* (*GstPadBufferAllocFunction) (GstPad *pad, guint64 offset, guint size); - -typedef gboolean (*GstPadDispatcherFunction) (GstPad *pad, gpointer data); - -typedef enum { +typedef void (*GstPadChainFunction) (GstPad * pad, GstData * data); +typedef GstData *(*GstPadGetFunction) (GstPad * pad); +typedef gboolean (*GstPadEventFunction) (GstPad * pad, GstEvent * event); +typedef gboolean (*GstPadConvertFunction) (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value); +typedef gboolean (*GstPadQueryFunction) (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); +typedef GList *(*GstPadIntLinkFunction) (GstPad * pad); +typedef const GstFormat *(*GstPadFormatsFunction) (GstPad * pad); +typedef const GstEventMask *(*GstPadEventMaskFunction) (GstPad * pad); +typedef const GstQueryType *(*GstPadQueryTypeFunction) (GstPad * pad); + +typedef GstPadLinkReturn (*GstPadLinkFunction) (GstPad * pad, + const GstCaps * caps); +typedef void (*GstPadUnlinkFunction) (GstPad * pad); +typedef GstCaps *(*GstPadGetCapsFunction) (GstPad * pad); +typedef GstCaps *(*GstPadFixateFunction) (GstPad * pad, const GstCaps * caps); +typedef GstBuffer *(*GstPadBufferAllocFunction) (GstPad * pad, guint64 offset, + guint size); + +typedef gboolean (*GstPadDispatcherFunction) (GstPad * pad, gpointer data); + +typedef enum +{ GST_PAD_UNKNOWN, GST_PAD_SRC, GST_PAD_SINK } GstPadDirection; -typedef enum { - GST_PAD_DISABLED = GST_OBJECT_FLAG_LAST, +typedef enum +{ + GST_PAD_DISABLED = GST_OBJECT_FLAG_LAST, GST_PAD_NEGOTIATING, - GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 + GST_PAD_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 } GstPadFlags; -struct _GstPad { - GstObject object; +struct _GstPad +{ + GstObject object; - gpointer element_private; + gpointer element_private; - GstPadTemplate *padtemplate; /* the template for this pad */ + GstPadTemplate *padtemplate; /* the template for this pad */ gpointer _gst_reserved[GST_PADDING]; }; -struct _GstPadClass { +struct _GstPadClass +{ GstObjectClass parent_class; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstRealPad { - GstPad pad; +struct _GstRealPad +{ + GstPad pad; /* the pad capabilities */ - GstCaps *caps; - GstPadFixateFunction appfixatefunc; - GstCaps *appfilter; - GstPadGetCapsFunction getcapsfunc; - GstPadFixateFunction fixatefunc; - - GstPadDirection direction; + GstCaps *caps; + GstPadFixateFunction appfixatefunc; + GstCaps *appfilter; + GstPadGetCapsFunction getcapsfunc; + GstPadFixateFunction fixatefunc; + + GstPadDirection direction; - GstPadLinkFunction linkfunc; - GstPadUnlinkFunction unlinkfunc; - GstRealPad *peer; + GstPadLinkFunction linkfunc; + GstPadUnlinkFunction unlinkfunc; + GstRealPad *peer; - gpointer sched_private; + gpointer sched_private; /* data transport functions */ - GstPadChainFunction chainfunc; - GstPadChainFunction chainhandler; - GstPadGetFunction getfunc; - GstPadGetFunction gethandler; - GstPadEventFunction eventfunc; - GstPadEventFunction eventhandler; - GstPadEventMaskFunction eventmaskfunc; + GstPadChainFunction chainfunc; + GstPadChainFunction chainhandler; + GstPadGetFunction getfunc; + GstPadGetFunction gethandler; + GstPadEventFunction eventfunc; + GstPadEventFunction eventhandler; + GstPadEventMaskFunction eventmaskfunc; - GList *ghostpads; + GList *ghostpads; /* query/convert/formats functions */ - GstPadConvertFunction convertfunc; - GstPadQueryFunction queryfunc; - GstPadFormatsFunction formatsfunc; - GstPadQueryTypeFunction querytypefunc; - GstPadIntLinkFunction intlinkfunc; + GstPadConvertFunction convertfunc; + GstPadQueryFunction queryfunc; + GstPadFormatsFunction formatsfunc; + GstPadQueryTypeFunction querytypefunc; + GstPadIntLinkFunction intlinkfunc; - GstPadBufferAllocFunction bufferallocfunc; + GstPadBufferAllocFunction bufferallocfunc; - GstProbeDispatcher probedisp; + GstProbeDispatcher probedisp; - GstPadLink *link; - GstCaps *explicit_caps; + GstPadLink *link; + GstCaps *explicit_caps; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstRealPadClass { - GstPadClass parent_class; +struct _GstRealPadClass +{ + GstPadClass parent_class; /* signal callbacks */ - void (*caps_nego_failed) (GstPad *pad, GstCaps *caps); + void (*caps_nego_failed) (GstPad * pad, GstCaps * caps); - void (*linked) (GstPad *pad, GstPad *peer); - void (*unlinked) (GstPad *pad, GstPad *peer); - GstPadFixateFunction appfixatefunc; + void (*linked) (GstPad * pad, GstPad * peer); + void (*unlinked) (GstPad * pad, GstPad * peer); + GstPadFixateFunction appfixatefunc; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstGhostPad { +struct _GstGhostPad +{ GstPad pad; GstRealPad *realpad; @@ -227,7 +236,8 @@ struct _GstGhostPad { gpointer _gst_reserved[GST_PADDING]; }; -struct _GstGhostPadClass { +struct _GstGhostPadClass +{ GstPadClass parent_class; gpointer _gst_reserved[GST_PADDING]; @@ -293,7 +303,8 @@ struct _GstGhostPadClass { #define GST_IS_PAD_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PAD_TEMPLATE)) #define GST_IS_PAD_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PAD_TEMPLATE)) -typedef enum { +typedef enum +{ GST_PAD_ALWAYS, GST_PAD_SOMETIMES, GST_PAD_REQUEST @@ -304,39 +315,43 @@ typedef enum { #define GST_PAD_TEMPLATE_PRESENCE(templ) (((GstPadTemplate *)(templ))->presence) #define GST_PAD_TEMPLATE_CAPS(templ) (((GstPadTemplate *)(templ))->caps) -typedef enum { - GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST, +typedef enum +{ + GST_PAD_TEMPLATE_FIXED = GST_OBJECT_FLAG_LAST, - GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 + GST_PAD_TEMPLATE_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 } GstPadTemplateFlags; #define GST_PAD_TEMPLATE_IS_FIXED(templ) (GST_FLAG_IS_SET(templ, GST_PAD_TEMPLATE_FIXED)) -struct _GstPadTemplate { - GstObject object; +struct _GstPadTemplate +{ + GstObject object; - gchar *name_template; - GstPadDirection direction; - GstPadPresence presence; - GstCaps *caps; + gchar *name_template; + GstPadDirection direction; + GstPadPresence presence; + GstCaps *caps; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstPadTemplateClass { - GstObjectClass parent_class; +struct _GstPadTemplateClass +{ + GstObjectClass parent_class; /* signal callbacks */ - void (*pad_created) (GstPadTemplate *templ, GstPad *pad); + void (*pad_created) (GstPadTemplate * templ, GstPad * pad); gpointer _gst_reserved[GST_PADDING]; }; -struct _GstStaticPadTemplate { - gchar *name_template; - GstPadDirection direction; - GstPadPresence presence; - GstStaticCaps static_caps; +struct _GstStaticPadTemplate +{ + gchar *name_template; + GstPadDirection direction; + GstPadPresence presence; + GstStaticCaps static_caps; }; #define GST_STATIC_PAD_TEMPLATE(padname, dir, pres, caps) \ @@ -348,140 +363,145 @@ struct _GstStaticPadTemplate { } -GType gst_pad_get_type (void); -GType gst_real_pad_get_type (void); -GType gst_ghost_pad_get_type (void); +GType gst_pad_get_type (void); +GType gst_real_pad_get_type (void); +GType gst_ghost_pad_get_type (void); /* creating pads */ -GstPad* gst_pad_new (const gchar *name, GstPadDirection direction); -GstPad* gst_pad_new_from_template (GstPadTemplate *templ, const gchar *name); -GstPad* gst_pad_custom_new (GType type, const gchar *name, GstPadDirection direction); -GstPad* gst_pad_custom_new_from_template (GType type, GstPadTemplate *templ, const gchar *name); +GstPad *gst_pad_new (const gchar * name, GstPadDirection direction); +GstPad *gst_pad_new_from_template (GstPadTemplate * templ, const gchar * name); +GstPad *gst_pad_custom_new (GType type, const gchar * name, + GstPadDirection direction); +GstPad *gst_pad_custom_new_from_template (GType type, GstPadTemplate * templ, + const gchar * name); -void gst_pad_set_name (GstPad *pad, const gchar *name); -G_CONST_RETURN gchar* gst_pad_get_name (GstPad *pad); +void gst_pad_set_name (GstPad * pad, const gchar * name); +G_CONST_RETURN gchar *gst_pad_get_name (GstPad * pad); -GstPadDirection gst_pad_get_direction (GstPad *pad); +GstPadDirection gst_pad_get_direction (GstPad * pad); -void gst_pad_set_active (GstPad *pad, gboolean active); -gboolean gst_pad_is_active (GstPad *pad); +void gst_pad_set_active (GstPad * pad, gboolean active); +gboolean gst_pad_is_active (GstPad * pad); -void gst_pad_set_element_private (GstPad *pad, gpointer priv); -gpointer gst_pad_get_element_private (GstPad *pad); +void gst_pad_set_element_private (GstPad * pad, gpointer priv); +gpointer gst_pad_get_element_private (GstPad * pad); -void gst_pad_set_parent (GstPad *pad, GstElement *parent); -GstElement* gst_pad_get_parent (GstPad *pad); -GstElement* gst_pad_get_real_parent (GstPad *pad); +void gst_pad_set_parent (GstPad * pad, GstElement * parent); +GstElement *gst_pad_get_parent (GstPad * pad); +GstElement *gst_pad_get_real_parent (GstPad * pad); -GstScheduler* gst_pad_get_scheduler (GstPad *pad); +GstScheduler *gst_pad_get_scheduler (GstPad * pad); -void gst_pad_add_ghost_pad (GstPad *pad, GstPad *ghostpad); -void gst_pad_remove_ghost_pad (GstPad *pad, GstPad *ghostpad); -GList* gst_pad_get_ghost_pad_list (GstPad *pad); +void gst_pad_add_ghost_pad (GstPad * pad, GstPad * ghostpad); +void gst_pad_remove_ghost_pad (GstPad * pad, GstPad * ghostpad); +GList *gst_pad_get_ghost_pad_list (GstPad * pad); -GstPadTemplate* gst_pad_get_pad_template (GstPad *pad); +GstPadTemplate *gst_pad_get_pad_template (GstPad * pad); -void gst_pad_set_bufferalloc_function (GstPad *pad, GstPadBufferAllocFunction bufferalloc); -GstBuffer* gst_pad_alloc_buffer (GstPad *pad, guint64 offset, gint size); +void gst_pad_set_bufferalloc_function (GstPad * pad, + GstPadBufferAllocFunction bufferalloc); +GstBuffer *gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size); /* data passing setup functions */ -void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain); -void gst_pad_set_get_function (GstPad *pad, GstPadGetFunction get); -void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event); -void gst_pad_set_event_mask_function (GstPad *pad, GstPadEventMaskFunction mask_func); -G_CONST_RETURN GstEventMask* - gst_pad_get_event_masks (GstPad *pad); -G_CONST_RETURN GstEventMask* - gst_pad_get_event_masks_default (GstPad *pad); +void gst_pad_set_chain_function (GstPad * pad, GstPadChainFunction chain); +void gst_pad_set_get_function (GstPad * pad, GstPadGetFunction get); +void gst_pad_set_event_function (GstPad * pad, GstPadEventFunction event); +void gst_pad_set_event_mask_function (GstPad * pad, + GstPadEventMaskFunction mask_func); +G_CONST_RETURN GstEventMask *gst_pad_get_event_masks (GstPad * pad); +G_CONST_RETURN GstEventMask *gst_pad_get_event_masks_default (GstPad * pad); /* pad links */ -void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link); -gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad); -gboolean gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps); -void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink); +void gst_pad_set_link_function (GstPad * pad, GstPadLinkFunction link); +gboolean gst_pad_can_link (GstPad * srcpad, GstPad * sinkpad); +gboolean gst_pad_can_link_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps); +void gst_pad_set_unlink_function (GstPad * pad, GstPadUnlinkFunction unlink); -gboolean gst_pad_link (GstPad *srcpad, GstPad *sinkpad); -gboolean gst_pad_link_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps); -void gst_pad_unlink (GstPad *srcpad, GstPad *sinkpad); -gboolean gst_pad_is_linked (GstPad *pad); +gboolean gst_pad_link (GstPad * srcpad, GstPad * sinkpad); +gboolean gst_pad_link_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps); +void gst_pad_unlink (GstPad * srcpad, GstPad * sinkpad); +gboolean gst_pad_is_linked (GstPad * pad); -GstPad* gst_pad_get_peer (GstPad *pad); +GstPad *gst_pad_get_peer (GstPad * pad); /* capsnego functions */ -G_CONST_RETURN GstCaps* gst_pad_get_negotiated_caps (GstPad *pad); -gboolean gst_pad_is_negotiated (GstPad *pad); -GstCaps* gst_pad_get_caps (GstPad *pad); -G_CONST_RETURN GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); -GstPadLinkReturn gst_pad_try_set_caps (GstPad *pad, const GstCaps *caps); -GstPadLinkReturn gst_pad_try_set_caps_nonfixed (GstPad *pad, const GstCaps *caps); -gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad); - -void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps); -void gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate); -GstCaps * gst_pad_proxy_getcaps (GstPad *pad); -GstPadLinkReturn gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps); -GstCaps * gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps); +G_CONST_RETURN GstCaps *gst_pad_get_negotiated_caps (GstPad * pad); +gboolean gst_pad_is_negotiated (GstPad * pad); +GstCaps *gst_pad_get_caps (GstPad * pad); +G_CONST_RETURN GstCaps *gst_pad_get_pad_template_caps (GstPad * pad); +GstPadLinkReturn gst_pad_try_set_caps (GstPad * pad, const GstCaps * caps); +GstPadLinkReturn gst_pad_try_set_caps_nonfixed (GstPad * pad, + const GstCaps * caps); +gboolean gst_pad_check_compatibility (GstPad * srcpad, GstPad * sinkpad); + +void gst_pad_set_getcaps_function (GstPad * pad, GstPadGetCapsFunction getcaps); +void gst_pad_set_fixate_function (GstPad * pad, GstPadFixateFunction fixate); +GstCaps *gst_pad_proxy_getcaps (GstPad * pad); +GstPadLinkReturn gst_pad_proxy_pad_link (GstPad * pad, const GstCaps * caps); +GstCaps *gst_pad_proxy_fixate (GstPad * pad, const GstCaps * caps); + #ifndef GST_DISABLE_DEPRECATED -GstPadLinkReturn gst_pad_proxy_link (GstPad *pad, const GstCaps *caps); +GstPadLinkReturn gst_pad_proxy_link (GstPad * pad, const GstCaps * caps); #endif -gboolean gst_pad_set_explicit_caps (GstPad *pad, const GstCaps *caps); -void gst_pad_use_explicit_caps (GstPad *pad); -gboolean gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps); +gboolean gst_pad_set_explicit_caps (GstPad * pad, const GstCaps * caps); +void gst_pad_use_explicit_caps (GstPad * pad); +gboolean gst_pad_relink_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps); #ifndef GST_DISABLE_DEPRECATED -gboolean gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad); +gboolean gst_pad_perform_negotiate (GstPad * srcpad, GstPad * sinkpad); #endif -GstPadLinkReturn gst_pad_renegotiate (GstPad *pad); -void gst_pad_unnegotiate (GstPad *pad); -gboolean gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps); -GstCaps* gst_pad_get_allowed_caps (GstPad *pad); -void gst_pad_caps_change_notify (GstPad *pad); +GstPadLinkReturn gst_pad_renegotiate (GstPad * pad); +void gst_pad_unnegotiate (GstPad * pad); +gboolean gst_pad_try_relink_filtered (GstPad * srcpad, GstPad * sinkpad, + const GstCaps * filtercaps); +GstCaps *gst_pad_get_allowed_caps (GstPad * pad); +void gst_pad_caps_change_notify (GstPad * pad); -gboolean gst_pad_recover_caps_error (GstPad *pad, const GstCaps *allowed); +gboolean gst_pad_recover_caps_error (GstPad * pad, const GstCaps * allowed); /* data passing functions */ -void gst_pad_push (GstPad *pad, GstData *data); -GstData* gst_pad_pull (GstPad *pad); -gboolean gst_pad_send_event (GstPad *pad, GstEvent *event); -gboolean gst_pad_event_default (GstPad *pad, GstEvent *event); -GstPad* gst_pad_selectv (GList *padlist); -GstPad* gst_pad_select (GstPad *pad, ...); -GstPad* gst_pad_select_valist (GstPad *pad, va_list varargs); +void gst_pad_push (GstPad * pad, GstData * data); +GstData *gst_pad_pull (GstPad * pad); +gboolean gst_pad_send_event (GstPad * pad, GstEvent * event); +gboolean gst_pad_event_default (GstPad * pad, GstEvent * event); +GstPad *gst_pad_selectv (GList * padlist); +GstPad *gst_pad_select (GstPad * pad, ...); +GstPad *gst_pad_select_valist (GstPad * pad, va_list varargs); /* convert/query/format functions */ -void gst_pad_set_formats_function (GstPad *pad, - GstPadFormatsFunction formats); -G_CONST_RETURN GstFormat* - gst_pad_get_formats (GstPad *pad); -G_CONST_RETURN GstFormat* - gst_pad_get_formats_default (GstPad *pad); - -void gst_pad_set_convert_function (GstPad *pad, GstPadConvertFunction convert); -gboolean gst_pad_convert (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); -gboolean gst_pad_convert_default (GstPad *pad, - GstFormat src_format, gint64 src_value, - GstFormat *dest_format, gint64 *dest_value); - -void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query); -void gst_pad_set_query_type_function (GstPad *pad, GstPadQueryTypeFunction type_func); -G_CONST_RETURN GstQueryType* - gst_pad_get_query_types (GstPad *pad); -G_CONST_RETURN GstQueryType* - gst_pad_get_query_types_default (GstPad *pad); -gboolean gst_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); -gboolean gst_pad_query_default (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); - -void gst_pad_set_internal_link_function (GstPad *pad, GstPadIntLinkFunction intlink); -GList* gst_pad_get_internal_links (GstPad *pad); -GList* gst_pad_get_internal_links_default (GstPad *pad); - +void gst_pad_set_formats_function (GstPad * pad, GstPadFormatsFunction formats); +G_CONST_RETURN GstFormat *gst_pad_get_formats (GstPad * pad); +G_CONST_RETURN GstFormat *gst_pad_get_formats_default (GstPad * pad); + +void gst_pad_set_convert_function (GstPad * pad, GstPadConvertFunction convert); +gboolean gst_pad_convert (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value); +gboolean gst_pad_convert_default (GstPad * pad, + GstFormat src_format, gint64 src_value, + GstFormat * dest_format, gint64 * dest_value); + +void gst_pad_set_query_function (GstPad * pad, GstPadQueryFunction query); +void gst_pad_set_query_type_function (GstPad * pad, + GstPadQueryTypeFunction type_func); +G_CONST_RETURN GstQueryType *gst_pad_get_query_types (GstPad * pad); +G_CONST_RETURN GstQueryType *gst_pad_get_query_types_default (GstPad * pad); +gboolean gst_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); +gboolean gst_pad_query_default (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); + +void gst_pad_set_internal_link_function (GstPad * pad, + GstPadIntLinkFunction intlink); +GList *gst_pad_get_internal_links (GstPad * pad); +GList *gst_pad_get_internal_links_default (GstPad * pad); + /* misc helper functions */ -gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch, - gpointer data); +gboolean gst_pad_dispatcher (GstPad * pad, GstPadDispatcherFunction dispatch, + gpointer data); #define gst_pad_add_probe(pad, probe) \ (gst_probe_dispatcher_add_probe (&(GST_REAL_PAD (pad)->probedisp), probe)) @@ -489,31 +509,28 @@ gboolean gst_pad_dispatcher (GstPad *pad, GstPadDispatcherFunction dispatch (gst_probe_dispatcher_remove_probe (&(GST_REAL_PAD (pad)->probedisp), probe)) #ifndef GST_DISABLE_LOADSAVE -void gst_pad_load_and_link (xmlNodePtr self, GstObject *parent); +void gst_pad_load_and_link (xmlNodePtr self, GstObject * parent); #endif /* ghostpads */ -GstPad* gst_ghost_pad_new (const gchar *name, GstPad *pad); +GstPad *gst_ghost_pad_new (const gchar * name, GstPad * pad); /* templates and factories */ -GType gst_pad_template_get_type (void); +GType gst_pad_template_get_type (void); -GstPadTemplate* gst_pad_template_new (const gchar *name_template, - GstPadDirection direction, GstPadPresence presence, - GstCaps *caps); +GstPadTemplate *gst_pad_template_new (const gchar * name_template, + GstPadDirection direction, GstPadPresence presence, GstCaps * caps); -GstPadTemplate * gst_static_pad_template_get (GstStaticPadTemplate *templ); -const GstCaps* gst_pad_template_get_caps (GstPadTemplate *templ); -const GstCaps* gst_pad_template_get_caps_by_name (GstPadTemplate *templ, const gchar *name); +GstPadTemplate *gst_static_pad_template_get (GstStaticPadTemplate * templ); +const GstCaps *gst_pad_template_get_caps (GstPadTemplate * templ); +const GstCaps *gst_pad_template_get_caps_by_name (GstPadTemplate * templ, + const gchar * name); #ifndef GST_DISABLE_LOADSAVE -xmlNodePtr gst_ghost_pad_save_thyself (GstPad *pad, - xmlNodePtr parent); +xmlNodePtr gst_ghost_pad_save_thyself (GstPad * pad, xmlNodePtr parent); #endif G_END_DECLS - - #endif /* __GST_PAD_H__ */ diff --git a/gst/gstparse.c b/gst/gstparse.c index 835d74559..065e3d5b2 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -30,32 +30,35 @@ extern GstElement *_gst_parse_launch (const gchar *, GError **); -GQuark +GQuark gst_parse_error_quark (void) { static GQuark quark = 0; + if (!quark) quark = g_quark_from_static_string ("gst_parse_error"); return quark; } -static gchar *_gst_parse_escape (const gchar *str) +static gchar * +_gst_parse_escape (const gchar * str) { GString *gstr = NULL; - + g_return_val_if_fail (str != NULL, NULL); - + gstr = g_string_sized_new (strlen (str)); - + while (*str) { if (*str == ' ') g_string_append_c (gstr, '\\'); g_string_append_c (gstr, *str); str++; } - + return gstr->str; } + /** * gst_parse_launchv: * @argv: null-terminated array of arguments @@ -68,7 +71,7 @@ static gchar *_gst_parse_escape (const gchar *str) * Returns: a new element on success and NULL on failure. */ GstElement * -gst_parse_launchv (const gchar **argv, GError **error) +gst_parse_launchv (const gchar ** argv, GError ** error) { GstElement *element; GString *str; @@ -89,7 +92,7 @@ gst_parse_launchv (const gchar **argv, GError **error) g_string_append (str, " "); argvp++; } - + element = gst_parse_launch (str->str, error); g_string_free (str, TRUE); @@ -112,7 +115,7 @@ gst_parse_launchv (const gchar **argv, GError **error) * a #GstPipeline ant that is returned. */ GstElement * -gst_parse_launch (const gchar * pipeline_description, GError **error) +gst_parse_launch (const gchar * pipeline_description, GError ** error) { GstElement *element; static GStaticMutex flex_lock = G_STATIC_MUTEX_INIT; @@ -120,7 +123,7 @@ gst_parse_launch (const gchar * pipeline_description, GError **error) g_return_val_if_fail (pipeline_description != NULL, NULL); GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description %s", - pipeline_description); + pipeline_description); /* the need for the mutex will go away with flex 2.5.6 */ g_static_mutex_lock (&flex_lock); diff --git a/gst/gstparse.h b/gst/gstparse.h index 70e24600e..863fee1e3 100644 --- a/gst/gstparse.h +++ b/gst/gstparse.h @@ -26,10 +26,9 @@ #include G_BEGIN_DECLS - #ifndef GST_DISABLE_PARSE + GQuark gst_parse_error_quark (void); -GQuark gst_parse_error_quark (void); #define GST_PARSE_ERROR gst_parse_error_quark () typedef enum @@ -44,16 +43,13 @@ typedef enum } GstParseError; -GstElement* gst_parse_launch (const gchar *pipeline_description, GError **error); -GstElement* gst_parse_launchv (const gchar **argv, GError **error); +GstElement *gst_parse_launch (const gchar * pipeline_description, + GError ** error); +GstElement *gst_parse_launchv (const gchar ** argv, GError ** error); #else /* GST_DISABLE_PARSE */ - #pragma GCC poison gst_parse_launch #pragma GCC poison gst_parse_launchv - #endif /* GST_DISABLE_PARSE */ - -G_END_DECLS - + G_END_DECLS #endif /* __GST_PARSE_H__ */ diff --git a/gst/gstpipeline.c b/gst/gstpipeline.c index d7b4166c2..ca2827720 100644 --- a/gst/gstpipeline.c +++ b/gst/gstpipeline.c @@ -26,56 +26,58 @@ #include "gstinfo.h" #include "gstscheduler.h" -static GstElementDetails gst_pipeline_details = GST_ELEMENT_DETAILS ( - "Pipeline object", - "Generic/Bin", - "Complete pipeline object", - "Erik Walthinsen " -); +static GstElementDetails gst_pipeline_details = +GST_ELEMENT_DETAILS ("Pipeline object", + "Generic/Bin", + "Complete pipeline object", + "Erik Walthinsen "); /* Pipeline signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0 - /* FILL ME */ + /* FILL ME */ }; -static void gst_pipeline_base_init (gpointer g_class); -static void gst_pipeline_class_init (gpointer g_class, - gpointer class_data); -static void gst_pipeline_init (GTypeInstance *instance, - gpointer g_class); +static void gst_pipeline_base_init (gpointer g_class); +static void gst_pipeline_class_init (gpointer g_class, gpointer class_data); +static void gst_pipeline_init (GTypeInstance * instance, gpointer g_class); -static void gst_pipeline_dispose (GObject * object); +static void gst_pipeline_dispose (GObject * object); -static GstElementStateReturn gst_pipeline_change_state (GstElement * element); +static GstElementStateReturn gst_pipeline_change_state (GstElement * element); static GstBinClass *parent_class = NULL; + /* static guint gst_pipeline_signals[LAST_SIGNAL] = { 0 }; */ GType -gst_pipeline_get_type (void) { +gst_pipeline_get_type (void) +{ static GType pipeline_type = 0; if (!pipeline_type) { static const GTypeInfo pipeline_info = { - sizeof(GstPipelineClass), + sizeof (GstPipelineClass), gst_pipeline_base_init, NULL, - (GClassInitFunc)gst_pipeline_class_init, + (GClassInitFunc) gst_pipeline_class_init, NULL, NULL, - sizeof(GstPipeline), + sizeof (GstPipeline), 0, gst_pipeline_init, NULL }; - pipeline_type = g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0); + pipeline_type = + g_type_register_static (GST_TYPE_BIN, "GstPipeline", &pipeline_info, 0); } return pipeline_type; } @@ -84,7 +86,7 @@ static void gst_pipeline_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_pipeline_details); } @@ -97,17 +99,18 @@ gst_pipeline_class_init (gpointer g_class, gpointer class_data) parent_class = g_type_class_peek_parent (klass); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pipeline_dispose); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_pipeline_dispose); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_pipeline_change_state); + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_pipeline_change_state); } static void -gst_pipeline_init (GTypeInstance *instance, gpointer g_class) +gst_pipeline_init (GTypeInstance * instance, gpointer g_class) { GstScheduler *scheduler; GstPipeline *pipeline = GST_PIPELINE (instance); - + /* pipelines are managing bins */ GST_FLAG_SET (pipeline, GST_BIN_FLAG_MANAGER); @@ -119,19 +122,19 @@ gst_pipeline_init (GTypeInstance *instance, gpointer g_class) const gchar *name = gst_scheduler_factory_get_default_name (); g_error ("Critical error: could not get scheduler \"%s\"\n" - "Are you sure you have a registry ?\n" - "Run gst-register as root if you haven't done so yet.", name); + "Are you sure you have a registry ?\n" + "Run gst-register as root if you haven't done so yet.", name); } } static void -gst_pipeline_dispose (GObject *object) +gst_pipeline_dispose (GObject * object) { GstPipeline *pipeline = GST_PIPELINE (object); G_OBJECT_CLASS (parent_class)->dispose (object); - gst_object_replace ((GstObject **)&GST_ELEMENT_SCHED (pipeline), NULL); + gst_object_replace ((GstObject **) & GST_ELEMENT_SCHED (pipeline), NULL); } /** @@ -142,14 +145,14 @@ gst_pipeline_dispose (GObject *object) * * Returns: newly created GstPipeline */ -GstElement* -gst_pipeline_new (const gchar *name) +GstElement * +gst_pipeline_new (const gchar * name) { return gst_element_factory_make ("pipeline", name); } static GstElementStateReturn -gst_pipeline_change_state (GstElement *element) +gst_pipeline_change_state (GstElement * element) { switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: @@ -165,7 +168,7 @@ gst_pipeline_change_state (GstElement *element) * might not be in cothread 0 */ #if 0 if (GST_ELEMENT_SCHED (element)) { - gst_scheduler_reset (GST_ELEMENT_SCHED (element)); + gst_scheduler_reset (GST_ELEMENT_SCHED (element)); } #endif break; @@ -176,4 +179,3 @@ gst_pipeline_change_state (GstElement *element) return GST_STATE_SUCCESS; } - diff --git a/gst/gstpipeline.h b/gst/gstpipeline.h index 5dd5b11c0..47bf9c391 100644 --- a/gst/gstpipeline.h +++ b/gst/gstpipeline.h @@ -27,34 +27,32 @@ #include G_BEGIN_DECLS - #define GST_TYPE_PIPELINE (gst_pipeline_get_type ()) #define GST_PIPELINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PIPELINE, GstPipeline)) #define GST_IS_PIPELINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PIPELINE)) #define GST_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PIPELINE, GstPipelineClass)) #define GST_IS_PIPELINE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PIPELINE)) #define GST_PIPELINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PIPELINE, GstPipelineClass)) - typedef struct _GstPipeline GstPipeline; typedef struct _GstPipelineClass GstPipelineClass; -struct _GstPipeline { - GstBin bin; +struct _GstPipeline +{ + GstBin bin; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstPipelineClass { +struct _GstPipelineClass +{ GstBinClass parent_class; gpointer _gst_reserved[GST_PADDING]; }; -GType gst_pipeline_get_type (void); -GstElement* gst_pipeline_new (const gchar *name); +GType gst_pipeline_get_type (void); +GstElement *gst_pipeline_new (const gchar * name); G_END_DECLS - #endif /* __GST_PIPELINE_H__ */ - diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 5cf56829b..b95af4999 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -47,7 +47,7 @@ static GList *_gst_plugin_static = NULL; /* static variables for segfault handling of plugin loading */ static char *_gst_plugin_fault_handler_filename = NULL; -extern gboolean *_gst_disable_segtrap; /* see gst.c */ +extern gboolean *_gst_disable_segtrap; /* see gst.c */ static gboolean *_gst_plugin_fault_handler_is_setup = FALSE; /* list of valid licenses. @@ -68,17 +68,16 @@ static gchar *valid_licenses[] = { NULL }; -static void gst_plugin_desc_copy (GstPluginDesc *dest, - const GstPluginDesc *src); +static void gst_plugin_desc_copy (GstPluginDesc * dest, + const GstPluginDesc * src); -static GstPlugin * gst_plugin_register_func (GstPlugin *plugin, - GModule *module, - GstPluginDesc *desc); +static GstPlugin *gst_plugin_register_func (GstPlugin * plugin, + GModule * module, GstPluginDesc * desc); static GstPlugin * -gst_plugin_copy (GstPlugin *plugin) +gst_plugin_copy (GstPlugin * plugin) { - return g_memdup(plugin, sizeof(*plugin)); + return g_memdup (plugin, sizeof (*plugin)); } GType @@ -88,16 +87,17 @@ gst_plugin_get_type (void) if (plugin_type == 0) { plugin_type = g_boxed_type_register_static ("GstPlugin", - (GBoxedCopyFunc) gst_plugin_copy, g_free); + (GBoxedCopyFunc) gst_plugin_copy, g_free); } return plugin_type; } -GQuark +GQuark gst_plugin_error_quark (void) { static GQuark quark = 0; + if (!quark) quark = g_quark_from_static_string ("gst_plugin_error"); return quark; @@ -110,19 +110,22 @@ gst_plugin_error_quark (void) * When the main module is known, we can register the plugin right away. * */ void -_gst_plugin_register_static (GstPluginDesc *desc) +_gst_plugin_register_static (GstPluginDesc * desc) { if (main_module == NULL) { - if (GST_CAT_DEFAULT) GST_LOG ("queueing static plugin \"%s\" for loading later on", desc->name); + if (GST_CAT_DEFAULT) + GST_LOG ("queueing static plugin \"%s\" for loading later on", + desc->name); _gst_plugin_static = g_list_prepend (_gst_plugin_static, desc); - } - else { + } else { GstPlugin *plugin; - if (GST_CAT_DEFAULT) GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name); + if (GST_CAT_DEFAULT) + GST_LOG ("attempting to load static plugin \"%s\" now...", desc->name); plugin = g_new0 (GstPlugin, 1); if (gst_plugin_register_func (plugin, main_module, desc)) { - if (GST_CAT_DEFAULT) GST_INFO ("loaded static plugin \"%s\"", desc->name); + if (GST_CAT_DEFAULT) + GST_INFO ("loaded static plugin \"%s\"", desc->name); gst_registry_pool_add_plugin (plugin); } } @@ -131,10 +134,11 @@ _gst_plugin_register_static (GstPluginDesc *desc) void _gst_plugin_initialize (void) { - main_module = g_module_open (NULL, G_MODULE_BIND_LAZY); + main_module = g_module_open (NULL, G_MODULE_BIND_LAZY); /* now register all static plugins */ - g_list_foreach (_gst_plugin_static, (GFunc) _gst_plugin_register_static, NULL); + g_list_foreach (_gst_plugin_static, (GFunc) _gst_plugin_register_static, + NULL); } /* this function could be extended to check if the plugin license matches the @@ -142,12 +146,12 @@ _gst_plugin_initialize (void) * We'll wait for someone who's interested in it to code it :) */ static gboolean -gst_plugin_check_license (const gchar *license) +gst_plugin_check_license (const gchar * license) { gchar **check_license = valid_licenses; g_assert (check_license); - + while (*check_license) { if (strcmp (license, *check_license) == 0) return TRUE; @@ -161,46 +165,51 @@ gst_plugin_check_version (gint major, gint minor) { /* return NULL if the major and minor version numbers are not compatible */ /* with ours. */ - if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR) + if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR) return FALSE; return TRUE; } -static GstPlugin* -gst_plugin_register_func (GstPlugin *plugin, GModule *module, GstPluginDesc *desc) +static GstPlugin * +gst_plugin_register_func (GstPlugin * plugin, GModule * module, + GstPluginDesc * desc) { g_assert (plugin->module == NULL); if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) { - if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" has incompatible version, not loading", - plugin->filename); + if (GST_CAT_DEFAULT) + GST_INFO ("plugin \"%s\" has incompatible version, not loading", + plugin->filename); return FALSE; } - if (!desc->license || !desc->description || !desc->package || - !desc->origin) { - if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading", - plugin->filename); + if (!desc->license || !desc->description || !desc->package || !desc->origin) { + if (GST_CAT_DEFAULT) + GST_INFO ("plugin \"%s\" has incorrect GstPluginDesc, not loading", + plugin->filename); return FALSE; } - + if (!gst_plugin_check_license (desc->license)) { - if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading", - plugin->filename, desc->license); + if (GST_CAT_DEFAULT) + GST_INFO ("plugin \"%s\" has invalid license \"%s\", not loading", + plugin->filename, desc->license); return FALSE; } - + gst_plugin_desc_copy (&plugin->desc, desc); plugin->module = module; if (!((desc->plugin_init) (plugin))) { - if (GST_CAT_DEFAULT) GST_INFO ("plugin \"%s\" failed to initialise", plugin->filename); + if (GST_CAT_DEFAULT) + GST_INFO ("plugin \"%s\" failed to initialise", plugin->filename); plugin->module = NULL; return FALSE; } - - if (GST_CAT_DEFAULT) GST_LOG ("plugin \"%s\" initialised", GST_STR_NULL (plugin->filename)); + + if (GST_CAT_DEFAULT) + GST_LOG ("plugin \"%s\" initialised", GST_STR_NULL (plugin->filename)); return plugin; } @@ -230,8 +239,7 @@ _gst_plugin_fault_handler_sighandler (int signum) /* We need to restore the fault handler or we'll keep getting it */ _gst_plugin_fault_handler_restore (); - switch (signum) - { + switch (signum) { case SIGSEGV: g_print ("\nERROR: "); g_print ("Caught a segmentation fault while loading plugin file:\n"); @@ -257,9 +265,11 @@ _gst_plugin_fault_handler_setup (void) struct sigaction action; /* if asked to leave segfaults alone, just return */ - if (_gst_disable_segtrap) return; + if (_gst_disable_segtrap) + return; - if (_gst_plugin_fault_handler_is_setup) return; + if (_gst_plugin_fault_handler_is_setup) + return; memset (&action, 0, sizeof (action)); action.sa_handler = _gst_plugin_fault_handler_sighandler; @@ -267,8 +277,7 @@ _gst_plugin_fault_handler_setup (void) sigaction (SIGSEGV, &action, NULL); } -static void -_gst_plugin_fault_handler_setup (); +static void _gst_plugin_fault_handler_setup (); /** * gst_plugin_load_file: @@ -280,7 +289,7 @@ _gst_plugin_fault_handler_setup (); * Returns: a new GstPlugin or NULL, if an error occurred. */ GstPlugin * -gst_plugin_load_file (const gchar *filename, GError **error) +gst_plugin_load_file (const gchar * filename, GError ** error) { GstPlugin *plugin; GModule *module; @@ -290,22 +299,20 @@ gst_plugin_load_file (const gchar *filename, GError **error) g_return_val_if_fail (filename != NULL, NULL); - GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"", filename); + GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"", + filename); if (g_module_supported () == FALSE) { g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_MODULE, - "Dynamic loading not supported"); + GST_PLUGIN_ERROR, + GST_PLUGIN_ERROR_MODULE, "Dynamic loading not supported"); return NULL; } if (stat (filename, &file_status)) { g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_MODULE, - "Problem opening file %s\n", - filename); + GST_PLUGIN_ERROR, + GST_PLUGIN_ERROR_MODULE, "Problem opening file %s\n", filename); return NULL; } @@ -322,36 +329,37 @@ gst_plugin_load_file (const gchar *filename, GError **error) free_plugin = TRUE; plugin = g_new0 (GstPlugin, 1); plugin->filename = g_strdup (filename); - GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin, filename); + GST_DEBUG ("created new GstPlugin %p for file \"%s\"", plugin, + filename); } else { free_plugin = FALSE; if (gst_plugin_is_loaded (plugin)) { if (strcmp (plugin->filename, filename) != 0) { - GST_WARNING ("plugin %p from file \"%s\" with same name %s is already " - "loaded, aborting loading of \"%s\"", - plugin, plugin->filename, plugin->desc.name, filename); - g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_NAME_MISMATCH, - "already a plugin with name \"%s\" loaded", - desc->name); - if (free_plugin) g_free (plugin); + GST_WARNING + ("plugin %p from file \"%s\" with same name %s is already " + "loaded, aborting loading of \"%s\"", plugin, plugin->filename, + plugin->desc.name, filename); + g_set_error (error, GST_PLUGIN_ERROR, + GST_PLUGIN_ERROR_NAME_MISMATCH, + "already a plugin with name \"%s\" loaded", desc->name); + if (free_plugin) + g_free (plugin); return NULL; } - GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now", plugin, filename); + GST_LOG ("Plugin %p for file \"%s\" already loaded, returning it now", + plugin, filename); return plugin; } } - GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...", plugin, filename); + GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...", + plugin, filename); if (g_module_symbol (module, "plugin_init", &ptr)) { - g_print ("plugin %p from file \"%s\" exports a symbol named plugin_init\n", - plugin, plugin->filename); - g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_NAME_MISMATCH, - "plugin \"%s\" exports a symbol named plugin_init", - desc->name); + g_print + ("plugin %p from file \"%s\" exports a symbol named plugin_init\n", + plugin, plugin->filename); + g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_NAME_MISMATCH, + "plugin \"%s\" exports a symbol named plugin_init", desc->name); } /* this is where we load the actual .so, so let's trap SIGSEGV */ @@ -359,46 +367,44 @@ gst_plugin_load_file (const gchar *filename, GError **error) _gst_plugin_fault_handler_filename = plugin->filename; if (gst_plugin_register_func (plugin, module, desc)) { - /* remove signal handler */ - _gst_plugin_fault_handler_restore (); - _gst_plugin_fault_handler_filename = NULL; - GST_INFO ("plugin \"%s\" loaded", plugin->filename); - return plugin; + /* remove signal handler */ + _gst_plugin_fault_handler_restore (); + _gst_plugin_fault_handler_filename = NULL; + GST_INFO ("plugin \"%s\" loaded", plugin->filename); + return plugin; } else { - /* remove signal handler */ - _gst_plugin_fault_handler_restore (); - GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"", filename); + /* remove signal handler */ + _gst_plugin_fault_handler_restore (); + GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"", + filename); /* plugin == NULL */ - g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_MODULE, - "gst_plugin_register_func failed for plugin \"%s\"", - filename); - if (free_plugin) g_free (plugin); - return NULL; + g_set_error (error, + GST_PLUGIN_ERROR, + GST_PLUGIN_ERROR_MODULE, + "gst_plugin_register_func failed for plugin \"%s\"", filename); + if (free_plugin) + g_free (plugin); + return NULL; } } else { GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename); g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_MODULE, - "Could not find plugin entry point in \"%s\"", - filename); + GST_PLUGIN_ERROR, + GST_PLUGIN_ERROR_MODULE, + "Could not find plugin entry point in \"%s\"", filename); } return NULL; } else { - GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename, g_module_error()); - g_set_error (error, - GST_PLUGIN_ERROR, - GST_PLUGIN_ERROR_MODULE, - "Error loading plugin %s, reason: %s\n", - filename, g_module_error()); + GST_DEBUG ("Error loading plugin %s, reason: %s\n", filename, + g_module_error ()); + g_set_error (error, GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE, + "Error loading plugin %s, reason: %s\n", filename, g_module_error ()); return NULL; } } static void -gst_plugin_desc_copy (GstPluginDesc *dest, const GstPluginDesc *src) +gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src) { dest->major_version = src->major_version; dest->minor_version = src->minor_version; @@ -417,10 +423,11 @@ gst_plugin_desc_copy (GstPluginDesc *dest, const GstPluginDesc *src) g_free (dest->origin); dest->origin = g_strdup (src->origin); } + #if 0 /* unused */ static void -gst_plugin_desc_free (GstPluginDesc *desc) +gst_plugin_desc_free (GstPluginDesc * desc) { g_free (desc->name); g_free (desc->description); @@ -441,20 +448,21 @@ gst_plugin_desc_free (GstPluginDesc *desc) * Returns: whether or not the plugin unloaded */ gboolean -gst_plugin_unload_plugin (GstPlugin *plugin) +gst_plugin_unload_plugin (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, FALSE); - if (!plugin->module) + if (!plugin->module) return TRUE; if (g_module_close (plugin->module)) { plugin->module = NULL; - GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded", plugin->filename); + GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "plugin \"%s\" unloaded", + plugin->filename); return TRUE; - } - else { - GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"", plugin->filename); + } else { + GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "failed to unload plugin \"%s\"", + plugin->filename); return FALSE; } } @@ -467,8 +475,8 @@ gst_plugin_unload_plugin (GstPlugin *plugin) * * Returns: the name of the plugin */ -const gchar* -gst_plugin_get_name (GstPlugin *plugin) +const gchar * +gst_plugin_get_name (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); @@ -483,8 +491,8 @@ gst_plugin_get_name (GstPlugin *plugin) * * Returns: the long name of the plugin */ -G_CONST_RETURN gchar* -gst_plugin_get_description (GstPlugin *plugin) +G_CONST_RETURN gchar * +gst_plugin_get_description (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); @@ -499,13 +507,14 @@ gst_plugin_get_description (GstPlugin *plugin) * * Returns: the filename of the plugin */ -G_CONST_RETURN gchar* -gst_plugin_get_filename (GstPlugin *plugin) +G_CONST_RETURN gchar * +gst_plugin_get_filename (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); return plugin->filename; } + /** * gst_plugin_get_license: * @plugin: plugin to get the license of @@ -514,13 +523,14 @@ gst_plugin_get_filename (GstPlugin *plugin) * * Returns: the license of the plugin */ -G_CONST_RETURN gchar* -gst_plugin_get_license (GstPlugin *plugin) +G_CONST_RETURN gchar * +gst_plugin_get_license (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); return plugin->desc.license; } + /** * gst_plugin_get_package: * @plugin: plugin to get the package of @@ -529,13 +539,14 @@ gst_plugin_get_license (GstPlugin *plugin) * * Returns: the package of the plugin */ -G_CONST_RETURN gchar* -gst_plugin_get_package (GstPlugin *plugin) +G_CONST_RETURN gchar * +gst_plugin_get_package (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); return plugin->desc.package; } + /** * gst_plugin_get_origin: * @plugin: plugin to get the origin of @@ -544,13 +555,14 @@ gst_plugin_get_package (GstPlugin *plugin) * * Returns: the origin of the plugin */ -G_CONST_RETURN gchar* -gst_plugin_get_origin (GstPlugin *plugin) +G_CONST_RETURN gchar * +gst_plugin_get_origin (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); return plugin->desc.origin; } + /** * gst_plugin_get_module: * @plugin: plugin to query @@ -562,12 +574,13 @@ gst_plugin_get_origin (GstPlugin *plugin) * loaded yet. */ GModule * -gst_plugin_get_module (GstPlugin *plugin) +gst_plugin_get_module (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, FALSE); return plugin->module; } + /** * gst_plugin_is_loaded: * @plugin: plugin to query @@ -577,7 +590,7 @@ gst_plugin_get_module (GstPlugin *plugin) * Returns: TRUE is loaded, FALSE otherwise */ gboolean -gst_plugin_is_loaded (GstPlugin *plugin) +gst_plugin_is_loaded (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, FALSE); @@ -597,30 +610,31 @@ gst_plugin_is_loaded (GstPlugin *plugin) * * Returns: a GList of features, g_list_free after use. */ -GList* -gst_plugin_feature_filter (GstPlugin *plugin, - GstPluginFeatureFilter filter, - gboolean first, - gpointer user_data) +GList * +gst_plugin_feature_filter (GstPlugin * plugin, + GstPluginFeatureFilter filter, gboolean first, gpointer user_data) { - return gst_filter_run (plugin->features, (GstFilterFunc) filter, first, user_data); + return gst_filter_run (plugin->features, (GstFilterFunc) filter, first, + user_data); } typedef struct -{ +{ GstPluginFeatureFilter filter; - gboolean first; - gpointer user_data; - GList *result; + gboolean first; + gpointer user_data; + GList *result; } FeatureFilterData; static gboolean -_feature_filter (GstPlugin *plugin, gpointer user_data) +_feature_filter (GstPlugin * plugin, gpointer user_data) { GList *result; FeatureFilterData *data = (FeatureFilterData *) user_data; - result = gst_plugin_feature_filter (plugin, data->filter, data->first, data->user_data); + result = + gst_plugin_feature_filter (plugin, data->filter, data->first, + data->user_data); if (result) { data->result = g_list_concat (data->result, result); return TRUE; @@ -642,11 +656,9 @@ _feature_filter (GstPlugin *plugin, gpointer user_data) * * Returns: a GList of features, g_list_free after use. */ -GList* -gst_plugin_list_feature_filter (GList *list, - GstPluginFeatureFilter filter, - gboolean first, - gpointer user_data) +GList * +gst_plugin_list_feature_filter (GList * list, + GstPluginFeatureFilter filter, gboolean first, gpointer user_data) { FeatureFilterData data; GList *result; @@ -673,7 +685,7 @@ gst_plugin_list_feature_filter (GList *list, * Returns: TRUE if the plugin is of the given name. */ gboolean -gst_plugin_name_filter (GstPlugin *plugin, const gchar *name) +gst_plugin_name_filter (GstPlugin * plugin, const gchar * name) { return (plugin->desc.name && !strcmp (plugin->desc.name, name)); } @@ -688,8 +700,8 @@ gst_plugin_name_filter (GstPlugin *plugin, const gchar *name) * * Returns: a GstPluginFeature or NULL if the feature was not found. */ -GstPluginFeature* -gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type) +GstPluginFeature * +gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type) { GList *walk; GstPluginFeature *result = NULL; @@ -699,12 +711,11 @@ gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type) data.type = type; data.name = name; - - walk = gst_filter_run (plugin->features, - (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE, - &data); - if (walk) + walk = gst_filter_run (plugin->features, + (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE, &data); + + if (walk) result = GST_PLUGIN_FEATURE (walk->data); return result; @@ -720,7 +731,7 @@ gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type) * See #gst_plugin_get_feature_list */ void -gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature) +gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature) { GstPluginFeature *oldfeature; @@ -728,8 +739,8 @@ gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature) g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature)); g_return_if_fail (feature != NULL); - oldfeature = gst_plugin_find_feature (plugin, - GST_PLUGIN_FEATURE_NAME (feature), G_OBJECT_TYPE (feature)); + oldfeature = gst_plugin_find_feature (plugin, + GST_PLUGIN_FEATURE_NAME (feature), G_OBJECT_TYPE (feature)); if (!oldfeature) { feature->manager = plugin; @@ -746,8 +757,8 @@ gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature) * * Returns: a GList of features, use g_list_free to free the list. */ -GList* -gst_plugin_get_feature_list (GstPlugin *plugin) +GList * +gst_plugin_get_feature_list (GstPlugin * plugin) { g_return_val_if_fail (plugin != NULL, NULL); @@ -763,7 +774,7 @@ gst_plugin_get_feature_list (GstPlugin *plugin) * Returns: whether the plugin was loaded or not */ gboolean -gst_plugin_load (const gchar *name) +gst_plugin_load (const gchar * name) { GstPlugin *plugin; GError *error = NULL; @@ -793,7 +804,7 @@ gst_plugin_load (const gchar *name) * Returns: whether the library was loaded or not */ gboolean -gst_library_load (const gchar *name) +gst_library_load (const gchar * name) { gboolean res; diff --git a/gst/gstplugin.h b/gst/gstplugin.h index c9cdc644a..5ac9dd77b 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -30,9 +30,8 @@ #include #include -G_BEGIN_DECLS +G_BEGIN_DECLS GQuark gst_plugin_error_quark (void); -GQuark gst_plugin_error_quark (void); #define GST_PLUGIN_ERROR gst_plugin_error_quark () typedef enum @@ -44,38 +43,41 @@ typedef enum #define GST_PLUGIN(plugin) ((GstPlugin *) (plugin)) -typedef struct _GstPlugin GstPlugin; -typedef struct _GstPluginDesc GstPluginDesc; +typedef struct _GstPlugin GstPlugin; +typedef struct _GstPluginDesc GstPluginDesc; /* Initialiser function: returns TRUE if plugin initialised successfully */ -typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin); +typedef gboolean (*GstPluginInitFunc) (GstPlugin * plugin); + /* exiting function when plugin is unloaded */ -typedef void (*GstPluginExitFunc) (GstPlugin *plugin); +typedef void (*GstPluginExitFunc) (GstPlugin * plugin); -struct _GstPluginDesc { - gint major_version; /* major version of core that plugin was compiled for */ - gint minor_version; /* minor version of core that plugin was compiled for */ - gchar *name; /* unique name of plugin */ - gchar *description; /* description of plugin */ +struct _GstPluginDesc +{ + gint major_version; /* major version of core that plugin was compiled for */ + gint minor_version; /* minor version of core that plugin was compiled for */ + gchar *name; /* unique name of plugin */ + gchar *description; /* description of plugin */ GstPluginInitFunc plugin_init; /* pointer to plugin_init function */ GstPluginExitFunc plugin_exit; /* pointer to exiting function */ - gchar *version; /* version of the plugin */ - gchar *license; /* effective license of plugin */ - gchar *package; /* package plugin belongs to */ - gchar *origin; /* URL to provider of plugin */ - + gchar *version; /* version of the plugin */ + gchar *license; /* effective license of plugin */ + gchar *package; /* package plugin belongs to */ + gchar *origin; /* URL to provider of plugin */ + gpointer _gst_reserved[GST_PADDING]; }; -struct _GstPlugin { - GstPluginDesc desc; +struct _GstPlugin +{ + GstPluginDesc desc; - gchar * filename; - GList * features; /* list of features provided */ - gint numfeatures; + gchar *filename; + GList *features; /* list of features provided */ + gint numfeatures; - gpointer manager; /* managing registry */ - GModule * module; /* contains the module if the plugin is loaded */ + gpointer manager; /* managing registry */ + GModule *module; /* contains the module if the plugin is loaded */ gpointer _gst_reserved[GST_PADDING]; }; @@ -113,51 +115,46 @@ _gst_plugin_static_init__ ##init (void) \ GST_PADDING_INIT \ }; \ _gst_plugin_register_static (&plugin_desc_); \ -} +} #define GST_LICENSE_UNKNOWN "unknown" /* function for filters */ -typedef gboolean (*GstPluginFilter) (GstPlugin *plugin, - gpointer user_data); +typedef gboolean (*GstPluginFilter) (GstPlugin * plugin, gpointer user_data); #define GST_TYPE_PLUGIN (gst_plugin_get_type()) -GType gst_plugin_get_type (void); -void _gst_plugin_initialize (void); -void _gst_plugin_register_static (GstPluginDesc *desc); - -G_CONST_RETURN gchar* gst_plugin_get_name (GstPlugin *plugin); -G_CONST_RETURN gchar* gst_plugin_get_description (GstPlugin *plugin); -G_CONST_RETURN gchar* gst_plugin_get_filename (GstPlugin *plugin); -G_CONST_RETURN gchar* gst_plugin_get_license (GstPlugin *plugin); -G_CONST_RETURN gchar* gst_plugin_get_package (GstPlugin *plugin); -G_CONST_RETURN gchar* gst_plugin_get_origin (GstPlugin *plugin); -GModule * gst_plugin_get_module (GstPlugin *plugin); -gboolean gst_plugin_is_loaded (GstPlugin *plugin); - -GList* gst_plugin_feature_filter (GstPlugin *plugin, - GstPluginFeatureFilter filter, - gboolean first, - gpointer user_data); -GList* gst_plugin_list_feature_filter (GList *list, - GstPluginFeatureFilter filter, - gboolean first, - gpointer user_data); -gboolean gst_plugin_name_filter (GstPlugin *plugin, const gchar *name); - -GList* gst_plugin_get_feature_list (GstPlugin *plugin); -GstPluginFeature* gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type); - -GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error); -gboolean gst_plugin_unload_plugin (GstPlugin *plugin); - -void gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature); +GType gst_plugin_get_type (void); +void _gst_plugin_initialize (void); +void _gst_plugin_register_static (GstPluginDesc * desc); + +G_CONST_RETURN gchar *gst_plugin_get_name (GstPlugin * plugin); +G_CONST_RETURN gchar *gst_plugin_get_description (GstPlugin * plugin); +G_CONST_RETURN gchar *gst_plugin_get_filename (GstPlugin * plugin); +G_CONST_RETURN gchar *gst_plugin_get_license (GstPlugin * plugin); +G_CONST_RETURN gchar *gst_plugin_get_package (GstPlugin * plugin); +G_CONST_RETURN gchar *gst_plugin_get_origin (GstPlugin * plugin); +GModule *gst_plugin_get_module (GstPlugin * plugin); +gboolean gst_plugin_is_loaded (GstPlugin * plugin); + +GList *gst_plugin_feature_filter (GstPlugin * plugin, + GstPluginFeatureFilter filter, gboolean first, gpointer user_data); +GList *gst_plugin_list_feature_filter (GList * list, + GstPluginFeatureFilter filter, gboolean first, gpointer user_data); +gboolean gst_plugin_name_filter (GstPlugin * plugin, const gchar * name); + +GList *gst_plugin_get_feature_list (GstPlugin * plugin); +GstPluginFeature *gst_plugin_find_feature (GstPlugin * plugin, + const gchar * name, GType type); + +GstPlugin *gst_plugin_load_file (const gchar * filename, GError ** error); +gboolean gst_plugin_unload_plugin (GstPlugin * plugin); + +void gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature); /* shortcuts to load from the registry pool */ -gboolean gst_plugin_load (const gchar *name); -gboolean gst_library_load (const gchar *name); +gboolean gst_plugin_load (const gchar * name); +gboolean gst_library_load (const gchar * name); G_END_DECLS - #endif /* __GST_PLUGIN_H__ */ diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c index fe873eb1a..9af992a04 100644 --- a/gst/gstpluginfeature.c +++ b/gst/gstpluginfeature.c @@ -29,10 +29,11 @@ #include -static void gst_plugin_feature_class_init (GstPluginFeatureClass *klass); -static void gst_plugin_feature_init (GstPluginFeature *feature); +static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass); +static void gst_plugin_feature_init (GstPluginFeature * feature); static GObjectClass *parent_class = NULL; + /* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */ GType @@ -53,24 +54,25 @@ gst_plugin_feature_get_type (void) (GInstanceInitFunc) gst_plugin_feature_init, NULL }; - plugin_feature_type = g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature", - &plugin_feature_info, G_TYPE_FLAG_ABSTRACT); + plugin_feature_type = + g_type_register_static (G_TYPE_OBJECT, "GstPluginFeature", + &plugin_feature_info, G_TYPE_FLAG_ABSTRACT); } return plugin_feature_type; } static void -gst_plugin_feature_class_init (GstPluginFeatureClass *klass) +gst_plugin_feature_class_init (GstPluginFeatureClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; parent_class = g_type_class_ref (G_TYPE_OBJECT); } static void -gst_plugin_feature_init (GstPluginFeature *feature) +gst_plugin_feature_init (GstPluginFeature * feature) { feature->manager = NULL; } @@ -85,25 +87,25 @@ gst_plugin_feature_init (GstPluginFeature *feature) * Returns: a boolean indicating the feature is loaded. */ gboolean -gst_plugin_feature_ensure_loaded (GstPluginFeature *feature) +gst_plugin_feature_ensure_loaded (GstPluginFeature * feature) { GstPlugin *plugin; - + g_return_val_if_fail (feature != NULL, FALSE); g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE); plugin = (GstPlugin *) (feature->manager); if (plugin && !gst_plugin_is_loaded (plugin)) { -#ifndef GST_DISABLE_REGISTRY +#ifndef GST_DISABLE_REGISTRY if (GST_IS_REGISTRY (plugin->manager)) { - GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, - "loading plugin %s for feature", plugin->desc.name); + GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, + "loading plugin %s for feature", plugin->desc.name); - if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), plugin) != GST_REGISTRY_OK) + if (gst_registry_load_plugin (GST_REGISTRY (plugin->manager), + plugin) != GST_REGISTRY_OK) return FALSE; - } - else + } else #endif /* GST_DISABLE_REGISTRY */ return FALSE; } @@ -118,13 +120,13 @@ gst_plugin_feature_ensure_loaded (GstPluginFeature *feature) * in the plugin and will eventually unload the plugin */ void -gst_plugin_feature_unload_thyself (GstPluginFeature *feature) +gst_plugin_feature_unload_thyself (GstPluginFeature * feature) { - GstPluginFeatureClass *oclass; + GstPluginFeatureClass *oclass; g_return_if_fail (feature != NULL); g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature)); - + oclass = GST_PLUGIN_FEATURE_GET_CLASS (feature); if (oclass->unload_thyself) @@ -132,12 +134,14 @@ gst_plugin_feature_unload_thyself (GstPluginFeature *feature) } gboolean -gst_plugin_feature_type_name_filter (GstPluginFeature *feature, - GstTypeNameData *data) +gst_plugin_feature_type_name_filter (GstPluginFeature * feature, + GstTypeNameData * data) { - return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) && - (data->name == NULL || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature)))); + return ((data->type == 0 || data->type == G_OBJECT_TYPE (feature)) && + (data->name == NULL + || !strcmp (data->name, GST_PLUGIN_FEATURE_NAME (feature)))); } + /** * gst_plugin_feature_set_rank: * @feature: feature to rank @@ -147,13 +151,14 @@ gst_plugin_feature_type_name_filter (GstPluginFeature *feature, * the most appropriate feature. */ void -gst_plugin_feature_set_rank (GstPluginFeature *feature, guint rank) +gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank) { g_return_if_fail (feature != NULL); g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature)); feature->rank = rank; } + /** * gst_plugin_feature_set_name: * @feature: a feature @@ -164,7 +169,7 @@ gst_plugin_feature_set_rank (GstPluginFeature *feature, guint rank) * allowed. */ void -gst_plugin_feature_set_name (GstPluginFeature *feature, const gchar *name) +gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name) { g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature)); g_return_if_fail (name != NULL); @@ -175,6 +180,7 @@ gst_plugin_feature_set_name (GstPluginFeature *feature, const gchar *name) feature->name = g_strdup (name); } } + /** * gst_plugin_feature_get rank: * @feature: a feature @@ -184,12 +190,13 @@ gst_plugin_feature_set_name (GstPluginFeature *feature, const gchar *name) * Returns: The rank of the feature */ guint -gst_plugin_feature_get_rank (GstPluginFeature *feature) +gst_plugin_feature_get_rank (GstPluginFeature * feature) { g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), GST_RANK_NONE); - + return feature->rank; } + /** * gst_plugin_feature_get_name: * @feature: a feature @@ -199,10 +206,9 @@ gst_plugin_feature_get_rank (GstPluginFeature *feature) * Returns: the name */ G_CONST_RETURN gchar * -gst_plugin_feature_get_name (GstPluginFeature *feature) +gst_plugin_feature_get_name (GstPluginFeature * feature) { g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), NULL); - + return feature->name; } - diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h index 66994070a..b7ee62c08 100644 --- a/gst/gstpluginfeature.h +++ b/gst/gstpluginfeature.h @@ -28,64 +28,62 @@ #include G_BEGIN_DECLS - #define GST_TYPE_PLUGIN_FEATURE (gst_plugin_feature_get_type()) #define GST_PLUGIN_FEATURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN_FEATURE, GstPluginFeature)) #define GST_IS_PLUGIN_FEATURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN_FEATURE)) #define GST_PLUGIN_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN_FEATURE, GstPluginFeatureClass)) #define GST_IS_PLUGIN_FEATURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN_FEATURE)) #define GST_PLUGIN_FEATURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN_FEATURE, GstPluginFeatureClass)) - #define GST_PLUGIN_FEATURE_NAME(feature) (GST_PLUGIN_FEATURE (feature)->name) - typedef struct _GstPluginFeature GstPluginFeature; typedef struct _GstPluginFeatureClass GstPluginFeatureClass; -struct _GstPluginFeature { - GObject object; +struct _GstPluginFeature +{ + GObject object; - /*< private >*/ - gchar *name; - guint rank; + /*< private > */ + gchar *name; + guint rank; - gpointer manager; + gpointer manager; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstPluginFeatureClass { - GObjectClass parent_class; +struct _GstPluginFeatureClass +{ + GObjectClass parent_class; - void (*unload_thyself) (GstPluginFeature *feature); + void (*unload_thyself) (GstPluginFeature * feature); gpointer _gst_reserved[GST_PADDING]; }; -typedef struct { - const gchar *name; - GType type; +typedef struct +{ + const gchar *name; + GType type; } GstTypeNameData; /* filter */ -typedef gboolean (*GstPluginFeatureFilter) (GstPluginFeature *feature, - gpointer user_data); +typedef gboolean (*GstPluginFeatureFilter) (GstPluginFeature * feature, + gpointer user_data); /* normal GObject stuff */ -GType gst_plugin_feature_get_type (void); +GType gst_plugin_feature_get_type (void); -gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature *feature); -void gst_plugin_feature_unload_thyself (GstPluginFeature *feature); +gboolean gst_plugin_feature_ensure_loaded (GstPluginFeature * feature); +void gst_plugin_feature_unload_thyself (GstPluginFeature * feature); -gboolean gst_plugin_feature_type_name_filter (GstPluginFeature *feature, - GstTypeNameData *data); +gboolean gst_plugin_feature_type_name_filter (GstPluginFeature * feature, + GstTypeNameData * data); -void gst_plugin_feature_set_rank (GstPluginFeature *feature, guint rank); -void gst_plugin_feature_set_name (GstPluginFeature *feature, const gchar *name); -guint gst_plugin_feature_get_rank (GstPluginFeature *feature); -G_CONST_RETURN gchar *gst_plugin_feature_get_name (GstPluginFeature *feature); +void gst_plugin_feature_set_rank (GstPluginFeature * feature, guint rank); +void gst_plugin_feature_set_name (GstPluginFeature * feature, + const gchar * name); +guint gst_plugin_feature_get_rank (GstPluginFeature * feature); +G_CONST_RETURN gchar *gst_plugin_feature_get_name (GstPluginFeature * feature); G_END_DECLS - - #endif /* __GST_PLUGIN_FEATURE_H__ */ - diff --git a/gst/gstprobe.c b/gst/gstprobe.c index f00cc360d..d5abbc288 100644 --- a/gst/gstprobe.c +++ b/gst/gstprobe.c @@ -34,10 +34,9 @@ * * Returns: a new #GstProbe. */ -GstProbe* -gst_probe_new (gboolean single_shot, - GstProbeCallback callback, - gpointer user_data) +GstProbe * +gst_probe_new (gboolean single_shot, + GstProbeCallback callback, gpointer user_data) { GstProbe *probe; @@ -46,9 +45,9 @@ gst_probe_new (gboolean single_shot, probe = g_new0 (GstProbe, 1); probe->single_shot = single_shot; - probe->callback = callback; - probe->user_data = user_data; - + probe->callback = callback; + probe->user_data = user_data; + return probe; } @@ -59,12 +58,12 @@ gst_probe_new (gboolean single_shot, * Free the memeory associated with the probe. */ void -gst_probe_destroy (GstProbe *probe) +gst_probe_destroy (GstProbe * probe) { g_return_if_fail (probe); #ifdef USE_POISONING - memset(probe, 0xff, sizeof(*probe)); + memset (probe, 0xff, sizeof (*probe)); #endif g_free (probe); @@ -80,15 +79,15 @@ gst_probe_destroy (GstProbe *probe) * Returns: the result of the probe callback function. */ gboolean -gst_probe_perform (GstProbe *probe, GstData **data) +gst_probe_perform (GstProbe * probe, GstData ** data) { gboolean res = TRUE; g_return_val_if_fail (probe, res); - + if (probe->callback) res = probe->callback (probe, data, probe->user_data); - + return res; } @@ -99,15 +98,15 @@ gst_probe_perform (GstProbe *probe, GstData **data) * * Returns: a new probe dispatcher. */ -GstProbeDispatcher* +GstProbeDispatcher * gst_probe_dispatcher_new (void) { GstProbeDispatcher *disp; - + disp = g_new0 (GstProbeDispatcher, 1); gst_probe_dispatcher_init (disp); - + return disp; } @@ -118,13 +117,13 @@ gst_probe_dispatcher_new (void) * Free the memory allocated by the probe dispatcher. All pending * probes are removed first. */ -void -gst_probe_dispatcher_destroy (GstProbeDispatcher *disp) +void +gst_probe_dispatcher_destroy (GstProbeDispatcher * disp) { g_return_if_fail (disp); - + #ifdef USE_POISONING - memset(disp, 0xff, sizeof(*disp)); + memset (disp, 0xff, sizeof (*disp)); #endif /* FIXME, free pending probes */ @@ -139,7 +138,7 @@ gst_probe_dispatcher_destroy (GstProbeDispatcher *disp) * dispatchers. */ void -gst_probe_dispatcher_init (GstProbeDispatcher *disp) +gst_probe_dispatcher_init (GstProbeDispatcher * disp) { g_return_if_fail (disp); @@ -155,8 +154,8 @@ gst_probe_dispatcher_init (GstProbeDispatcher *disp) * Activate or deactivate the given dispatcher * dispatchers. */ -void -gst_probe_dispatcher_set_active (GstProbeDispatcher *disp, gboolean active) +void +gst_probe_dispatcher_set_active (GstProbeDispatcher * disp, gboolean active) { g_return_if_fail (disp); @@ -171,11 +170,11 @@ gst_probe_dispatcher_set_active (GstProbeDispatcher *disp, gboolean active) * Adds the given probe to the dispatcher. */ void -gst_probe_dispatcher_add_probe (GstProbeDispatcher *disp, GstProbe *probe) +gst_probe_dispatcher_add_probe (GstProbeDispatcher * disp, GstProbe * probe) { g_return_if_fail (disp); g_return_if_fail (probe); - + disp->probes = g_slist_prepend (disp->probes, probe); } @@ -187,11 +186,11 @@ gst_probe_dispatcher_add_probe (GstProbeDispatcher *disp, GstProbe *probe) * Removes the given probe from the dispatcher. */ void -gst_probe_dispatcher_remove_probe (GstProbeDispatcher *disp, GstProbe *probe) +gst_probe_dispatcher_remove_probe (GstProbeDispatcher * disp, GstProbe * probe) { g_return_if_fail (disp); g_return_if_fail (probe); - + disp->probes = g_slist_remove (disp->probes, probe); } @@ -204,8 +203,8 @@ gst_probe_dispatcher_remove_probe (GstProbeDispatcher *disp, GstProbe *probe) * * Returns: TRUE if all callbacks returned TRUE. */ -gboolean -gst_probe_dispatcher_dispatch (GstProbeDispatcher *disp, GstData **data) +gboolean +gst_probe_dispatcher_dispatch (GstProbeDispatcher * disp, GstData ** data) { GSList *walk; gboolean res = TRUE; @@ -215,6 +214,7 @@ gst_probe_dispatcher_dispatch (GstProbeDispatcher *disp, GstData **data) walk = disp->probes; while (walk) { GstProbe *probe = (GstProbe *) walk->data; + walk = g_slist_next (walk); res &= gst_probe_perform (probe, data); diff --git a/gst/gstprobe.h b/gst/gstprobe.h index 1be6c2680..19d1513eb 100644 --- a/gst/gstprobe.h +++ b/gst/gstprobe.h @@ -27,50 +27,49 @@ #include #include -G_BEGIN_DECLS - -typedef struct _GstProbe GstProbe; +G_BEGIN_DECLS typedef struct _GstProbe GstProbe; /* the callback should return FALSE if the data should be discarded */ -typedef gboolean (*GstProbeCallback) (GstProbe *probe, - GstData **data, - gpointer user_data); - -struct _GstProbe { - gboolean single_shot; - - GstProbeCallback callback; - gpointer user_data; +typedef gboolean (*GstProbeCallback) (GstProbe * probe, + GstData ** data, gpointer user_data); + +struct _GstProbe +{ + gboolean single_shot; + + GstProbeCallback callback; + gpointer user_data; }; -GstProbe* gst_probe_new (gboolean single_shot, - GstProbeCallback callback, - gpointer user_data); -void gst_probe_destroy (GstProbe *probe); +GstProbe *gst_probe_new (gboolean single_shot, + GstProbeCallback callback, gpointer user_data); +void gst_probe_destroy (GstProbe * probe); -gboolean gst_probe_perform (GstProbe *probe, GstData **data); +gboolean gst_probe_perform (GstProbe * probe, GstData ** data); typedef struct _GstProbeDispatcher GstProbeDispatcher; -struct _GstProbeDispatcher { - gboolean active; - - GSList *probes; +struct _GstProbeDispatcher +{ + gboolean active; + + GSList *probes; }; -GstProbeDispatcher* gst_probe_dispatcher_new (void); -void gst_probe_dispatcher_destroy (GstProbeDispatcher *disp); -void gst_probe_dispatcher_init (GstProbeDispatcher *disp); +GstProbeDispatcher *gst_probe_dispatcher_new (void); +void gst_probe_dispatcher_destroy (GstProbeDispatcher * disp); +void gst_probe_dispatcher_init (GstProbeDispatcher * disp); -void gst_probe_dispatcher_set_active (GstProbeDispatcher *disp, gboolean active); -void gst_probe_dispatcher_add_probe (GstProbeDispatcher *disp, GstProbe *probe); -void gst_probe_dispatcher_remove_probe (GstProbeDispatcher *disp, GstProbe *probe); +void gst_probe_dispatcher_set_active (GstProbeDispatcher * disp, + gboolean active); +void gst_probe_dispatcher_add_probe (GstProbeDispatcher * disp, + GstProbe * probe); +void gst_probe_dispatcher_remove_probe (GstProbeDispatcher * disp, + GstProbe * probe); -gboolean gst_probe_dispatcher_dispatch (GstProbeDispatcher *disp, GstData **data); +gboolean gst_probe_dispatcher_dispatch (GstProbeDispatcher * disp, + GstData ** data); G_END_DECLS - - #endif /* __GST_PAD_H__ */ - diff --git a/gst/gstquery.c b/gst/gstquery.c index ca8497bbf..fb6839bb8 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -29,20 +29,20 @@ static GList *_gst_queries = NULL; static GHashTable *_nick_to_query = NULL; static GHashTable *_query_type_to_nick = NULL; -static gint _n_values = 1; /* we start from 1 because 0 reserved for NONE */ +static gint _n_values = 1; /* we start from 1 because 0 reserved for NONE */ static GstQueryTypeDefinition standard_definitions[] = { - { GST_QUERY_TOTAL, "total", "Total length" }, - { GST_QUERY_POSITION, "position", "Current Position" }, - { GST_QUERY_LATENCY, "latency", "Latency" }, - { GST_QUERY_JITTER, "jitter", "Jitter" }, - { GST_QUERY_START, "start", "Start position of stream" }, - { GST_QUERY_SEGMENT_END, "segment_end", "End position of the stream" }, - { GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1" }, - { 0, NULL, NULL } + {GST_QUERY_TOTAL, "total", "Total length"}, + {GST_QUERY_POSITION, "position", "Current Position"}, + {GST_QUERY_LATENCY, "latency", "Latency"}, + {GST_QUERY_JITTER, "jitter", "Jitter"}, + {GST_QUERY_START, "start", "Start position of stream"}, + {GST_QUERY_SEGMENT_END, "segment_end", "End position of the stream"}, + {GST_QUERY_RATE, "rate", "Configured rate 1000000 = 1"}, + {0, NULL, NULL} }; -void +void _gst_query_type_initialize (void) { GstQueryTypeDefinition *standards = standard_definitions; @@ -51,10 +51,11 @@ _gst_query_type_initialize (void) _nick_to_query = g_hash_table_new (g_str_hash, g_str_equal); _query_type_to_nick = g_hash_table_new (NULL, NULL); } - + while (standards->nick) { g_hash_table_insert (_nick_to_query, standards->nick, standards); - g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (standards->value), standards); + g_hash_table_insert (_query_type_to_nick, + GINT_TO_POINTER (standards->value), standards); _gst_queries = g_list_append (_gst_queries, standards); standards++; @@ -74,28 +75,29 @@ _gst_query_type_initialize (void) * with the same nick. */ GstQueryType -gst_query_type_register (const gchar *nick, const gchar *description) +gst_query_type_register (const gchar * nick, const gchar * description) { GstQueryTypeDefinition *query; GstQueryType lookup; - + g_return_val_if_fail (nick != NULL, 0); g_return_val_if_fail (description != NULL, 0); lookup = gst_query_type_get_by_nick (nick); if (lookup != GST_QUERY_NONE) return lookup; - + query = g_new0 (GstQueryTypeDefinition, 1); query->value = _n_values; query->nick = g_strdup (nick); query->description = g_strdup (description); g_hash_table_insert (_nick_to_query, query->nick, query); - g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value), query); + g_hash_table_insert (_query_type_to_nick, GINT_TO_POINTER (query->value), + query); _gst_queries = g_list_append (_gst_queries, query); _n_values++; - + return query->value; } @@ -109,14 +111,14 @@ gst_query_type_register (const gchar *nick, const gchar *description) * if the query was not registered. */ GstQueryType -gst_query_type_get_by_nick (const gchar *nick) +gst_query_type_get_by_nick (const gchar * nick) { GstQueryTypeDefinition *query; - + g_return_val_if_fail (nick != NULL, 0); query = g_hash_table_lookup (_nick_to_query, nick); - + if (query != NULL) return query->value; else @@ -133,7 +135,7 @@ gst_query_type_get_by_nick (const gchar *nick) * Returns: TRUE if the query is found inside the array */ gboolean -gst_query_types_contains (const GstQueryType *types, GstQueryType type) +gst_query_types_contains (const GstQueryType * types, GstQueryType type) { if (!types) return FALSE; @@ -156,7 +158,7 @@ gst_query_types_contains (const GstQueryType *types, GstQueryType type) * * Returns: The #GstQueryTypeDefinition for @query or NULL on failure. */ -const GstQueryTypeDefinition* +const GstQueryTypeDefinition * gst_query_type_get_details (GstQueryType type) { return g_hash_table_lookup (_query_type_to_nick, GINT_TO_POINTER (type)); @@ -169,7 +171,7 @@ gst_query_type_get_details (GstQueryType type) * * Returns: A GList of #GstQueryTypeDefinition. */ -const GList* +const GList * gst_query_type_get_definitions (void) { return _gst_queries; diff --git a/gst/gstquery.h b/gst/gstquery.h index 32053e2f8..aa8fbf331 100644 --- a/gst/gstquery.h +++ b/gst/gstquery.h @@ -26,9 +26,8 @@ #include -G_BEGIN_DECLS - -typedef enum { +G_BEGIN_DECLS typedef enum +{ GST_QUERY_NONE = 0, GST_QUERY_TOTAL, GST_QUERY_POSITION, @@ -46,9 +45,9 @@ typedef struct _GstQueryTypeDefinition GstQueryTypeDefinition; struct _GstQueryTypeDefinition { - GstQueryType value; - gchar *nick; - gchar *description; + GstQueryType value; + gchar *nick; + gchar *description; }; #ifdef G_HAVE_ISO_VARARGS @@ -75,22 +74,21 @@ functionname (type object) \ } #endif -void _gst_query_type_initialize (void); +void _gst_query_type_initialize (void); /* register a new query */ -GstQueryType gst_query_type_register (const gchar *nick, - const gchar *description); -GstQueryType gst_query_type_get_by_nick (const gchar *nick); +GstQueryType gst_query_type_register (const gchar * nick, + const gchar * description); +GstQueryType gst_query_type_get_by_nick (const gchar * nick); /* check if a query is in an array of querys */ -gboolean gst_query_types_contains (const GstQueryType *types, GstQueryType type); +gboolean gst_query_types_contains (const GstQueryType * types, + GstQueryType type); /* query for query details */ -G_CONST_RETURN GstQueryTypeDefinition* - gst_query_type_get_details (GstQueryType type); -G_CONST_RETURN GList* gst_query_type_get_definitions (void); +G_CONST_RETURN GstQueryTypeDefinition *gst_query_type_get_details (GstQueryType + type); +G_CONST_RETURN GList *gst_query_type_get_definitions (void); G_END_DECLS - #endif /* __GST_QUERY_H__ */ - diff --git a/gst/gstqueue.c b/gst/gstqueue.c index 8dfd62f4d..03f1131c9 100644 --- a/gst/gstqueue.c +++ b/gst/gstqueue.c @@ -30,23 +30,23 @@ #include "gstinfo.h" #include "gsterror.h" -static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ( - "Queue", - "Generic", - "Simple data queue", - "Erik Walthinsen " -); +static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ("Queue", + "Generic", + "Simple data queue", + "Erik Walthinsen "); /* Queue signals and args */ -enum { +enum +{ SIGNAL_UNDERRUN, SIGNAL_RUNNING, SIGNAL_OVERRUN, LAST_SIGNAL }; -enum { +enum +{ ARG_0, /* FIXME: don't we have another way of doing this * "Gstreamer format" (frame/byte/time) queries? */ @@ -62,46 +62,38 @@ enum { ARG_LEAKY, ARG_MAY_DEADLOCK, ARG_BLOCK_TIMEOUT - /* FILL ME */ + /* FILL ME */ }; -typedef struct _GstQueueEventResponse { +typedef struct _GstQueueEventResponse +{ GstEvent *event; gboolean ret, handled; } GstQueueEventResponse; -static void gst_queue_base_init (GstQueueClass *klass); -static void gst_queue_class_init (GstQueueClass *klass); -static void gst_queue_init (GstQueue *queue); -static void gst_queue_dispose (GObject *object); - -static void gst_queue_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gst_queue_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gst_queue_chain (GstPad *pad, - GstData *data); -static GstData *gst_queue_get (GstPad *pad); - -static gboolean gst_queue_handle_src_event (GstPad *pad, - GstEvent *event); - -static GstCaps *gst_queue_getcaps (GstPad *pad); -static GstPadLinkReturn - gst_queue_link (GstPad *pad, - const GstCaps *caps); -static void gst_queue_locked_flush (GstQueue *queue); +static void gst_queue_base_init (GstQueueClass * klass); +static void gst_queue_class_init (GstQueueClass * klass); +static void gst_queue_init (GstQueue * queue); +static void gst_queue_dispose (GObject * object); + +static void gst_queue_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void gst_queue_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); + +static void gst_queue_chain (GstPad * pad, GstData * data); +static GstData *gst_queue_get (GstPad * pad); + +static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event); + +static GstCaps *gst_queue_getcaps (GstPad * pad); +static GstPadLinkReturn gst_queue_link (GstPad * pad, const GstCaps * caps); +static void gst_queue_locked_flush (GstQueue * queue); + +static GstElementStateReturn gst_queue_change_state (GstElement * element); +static gboolean gst_queue_release_locks (GstElement * element); -static GstElementStateReturn - gst_queue_change_state (GstElement *element); -static gboolean gst_queue_release_locks (GstElement *element); - #define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ()) static GType @@ -109,13 +101,13 @@ queue_leaky_get_type (void) { static GType queue_leaky_type = 0; static GEnumValue queue_leaky[] = { - { GST_QUEUE_NO_LEAK, "0", "Not Leaky" }, - { GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream" }, - { GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream" }, - { 0, NULL, NULL }, + {GST_QUEUE_NO_LEAK, "0", "Not Leaky"}, + {GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream"}, + {GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"}, + {0, NULL, NULL}, }; if (!queue_leaky_type) { - queue_leaky_type = g_enum_register_static("GstQueueLeaky", queue_leaky); + queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky); } return queue_leaky_type; } @@ -124,7 +116,7 @@ static GstElementClass *parent_class = NULL; static guint gst_queue_signals[LAST_SIGNAL] = { 0 }; GType -gst_queue_get_type (void) +gst_queue_get_type (void) { static GType queue_type = 0; @@ -143,14 +135,14 @@ gst_queue_get_type (void) }; queue_type = g_type_register_static (GST_TYPE_ELEMENT, - "GstQueue", &queue_info, 0); + "GstQueue", &queue_info, 0); } return queue_type; } static void -gst_queue_base_init (GstQueueClass *klass) +gst_queue_base_init (GstQueueClass * klass) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); @@ -158,7 +150,7 @@ gst_queue_base_init (GstQueueClass *klass) } static void -gst_queue_class_init (GstQueueClass *klass) +gst_queue_class_init (GstQueueClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); @@ -167,112 +159,117 @@ gst_queue_class_init (GstQueueClass *klass) /* signals */ gst_queue_signals[SIGNAL_UNDERRUN] = - g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gst_queue_signals[SIGNAL_RUNNING] = - g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gst_queue_signals[SIGNAL_OVERRUN] = - g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /* properties */ g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES, - g_param_spec_uint ("current-level-bytes", "Current level (kB)", - "Current amount of data in the queue (bytes)", - 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_param_spec_uint ("current-level-bytes", "Current level (kB)", + "Current amount of data in the queue (bytes)", + 0, G_MAXUINT, 0, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS, - g_param_spec_uint ("current-level-buffers", "Current level (buffers)", - "Current number of buffers in the queue", - 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_param_spec_uint ("current-level-buffers", "Current level (buffers)", + "Current number of buffers in the queue", + 0, G_MAXUINT, 0, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME, - g_param_spec_uint64 ("current-level-time", "Current level (ns)", - "Current amount of data in the queue (in ns)", - 0, G_MAXUINT64, 0, G_PARAM_READABLE)); + g_param_spec_uint64 ("current-level-time", "Current level (ns)", + "Current amount of data in the queue (in ns)", + 0, G_MAXUINT64, 0, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES, - g_param_spec_uint ("max-size-bytes", "Max. size (kB)", - "Max. amount of data in the queue (bytes, 0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("max-size-bytes", "Max. size (kB)", + "Max. amount of data in the queue (bytes, 0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS, - g_param_spec_uint ("max-size-buffers", "Max. size (buffers)", - "Max. number of buffers in the queue (0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("max-size-buffers", "Max. size (buffers)", + "Max. number of buffers in the queue (0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME, - g_param_spec_uint64 ("max-size-time", "Max. size (ns)", - "Max. amount of data in the queue (in ns, 0=disable)", - 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); + g_param_spec_uint64 ("max-size-time", "Max. size (ns)", + "Max. amount of data in the queue (in ns, 0=disable)", + 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES, - g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)", - "Min. amount of data in the queue to allow reading (bytes, 0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)", + "Min. amount of data in the queue to allow reading (bytes, 0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS, - g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)", - "Min. number of buffers in the queue to allow reading (0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)", + "Min. number of buffers in the queue to allow reading (0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME, - g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)", - "Min. amount of data in the queue to allow reading (in ns, 0=disable)", - 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); + g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)", + "Min. amount of data in the queue to allow reading (in ns, 0=disable)", + 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_LEAKY, - g_param_spec_enum ("leaky", "Leaky", - "Where the queue leaks, if at all", - GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE)); + g_param_spec_enum ("leaky", "Leaky", + "Where the queue leaks, if at all", + GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK, - g_param_spec_boolean ("may_deadlock", "May Deadlock", - "The queue may deadlock if it's full and not PLAYING", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("may_deadlock", "May Deadlock", + "The queue may deadlock if it's full and not PLAYING", + TRUE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT, - g_param_spec_uint64 ("block_timeout", "Timeout for Block", - "Nanoseconds until blocked queue times out and returns filler event. " - "Value of -1 disables timeout", - 0, G_MAXUINT64, -1, G_PARAM_READWRITE)); + g_param_spec_uint64 ("block_timeout", "Timeout for Block", + "Nanoseconds until blocked queue times out and returns filler event. " + "Value of -1 disables timeout", + 0, G_MAXUINT64, -1, G_PARAM_READWRITE)); /* set several parent class virtual functions */ - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state); gstelement_class->release_locks = GST_DEBUG_FUNCPTR (gst_queue_release_locks); } static void -gst_queue_init (GstQueue *queue) +gst_queue_init (GstQueue * queue) { /* scheduling on this kind of element is, well, interesting */ GST_FLAG_SET (queue, GST_ELEMENT_DECOUPLED); GST_FLAG_SET (queue, GST_ELEMENT_EVENT_AWARE); queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); - gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain)); + gst_pad_set_chain_function (queue->sinkpad, + GST_DEBUG_FUNCPTR (gst_queue_chain)); gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad); - gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link)); - gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps)); + gst_pad_set_link_function (queue->sinkpad, + GST_DEBUG_FUNCPTR (gst_queue_link)); + gst_pad_set_getcaps_function (queue->sinkpad, + GST_DEBUG_FUNCPTR (gst_queue_getcaps)); gst_pad_set_active (queue->sinkpad, TRUE); queue->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_get)); gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad); gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_link)); - gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps)); - gst_pad_set_event_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); + gst_pad_set_getcaps_function (queue->srcpad, + GST_DEBUG_FUNCPTR (gst_queue_getcaps)); + gst_pad_set_event_function (queue->srcpad, + GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); gst_pad_set_active (queue->srcpad, TRUE); - queue->cur_level.buffers = 0; /* no content */ - queue->cur_level.bytes = 0; /* no content */ - queue->cur_level.time = 0; /* no content */ - queue->max_size.buffers = 100; /* 100 buffers */ - queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */ - queue->max_size.time = GST_SECOND; /* 1 s. */ - queue->min_threshold.buffers = 0; /* no threshold */ - queue->min_threshold.bytes = 0; /* no threshold */ - queue->min_threshold.time = 0; /* no threshold */ + queue->cur_level.buffers = 0; /* no content */ + queue->cur_level.bytes = 0; /* no content */ + queue->cur_level.time = 0; /* no content */ + queue->max_size.buffers = 100; /* 100 buffers */ + queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */ + queue->max_size.time = GST_SECOND; /* 1 s. */ + queue->min_threshold.buffers = 0; /* no threshold */ + queue->min_threshold.bytes = 0; /* no threshold */ + queue->min_threshold.time = 0; /* no threshold */ queue->leaky = GST_QUEUE_NO_LEAK; queue->may_deadlock = TRUE; @@ -288,11 +285,11 @@ gst_queue_init (GstQueue *queue) queue->queue = g_queue_new (); GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue, - "initialized queue's not_empty & not_full conditions"); + "initialized queue's not_empty & not_full conditions"); } static void -gst_queue_dispose (GObject *object) +gst_queue_dispose (GObject * object) { GstQueue *queue = GST_QUEUE (object); @@ -300,6 +297,7 @@ gst_queue_dispose (GObject *object) while (!g_queue_is_empty (queue->queue)) { GstData *data = g_queue_pop_head (queue->queue); + gst_data_unref (data); } g_queue_free (queue->queue); @@ -309,6 +307,7 @@ gst_queue_dispose (GObject *object) g_cond_free (queue->event_done); while (!g_queue_is_empty (queue->events)) { GstEvent *event = g_queue_pop_head (queue->events); + gst_event_unref (event); } @@ -317,7 +316,7 @@ gst_queue_dispose (GObject *object) } static GstCaps * -gst_queue_getcaps (GstPad *pad) +gst_queue_getcaps (GstPad * pad) { GstQueue *queue; @@ -331,7 +330,7 @@ gst_queue_getcaps (GstPad *pad) } static GstPadLinkReturn -gst_queue_link (GstPad *pad, const GstCaps *caps) +gst_queue_link (GstPad * pad, const GstCaps * caps) { GstQueue *queue; GstPadLinkReturn link_ret; @@ -357,10 +356,11 @@ gst_queue_link (GstPad *pad, const GstCaps *caps) } static void -gst_queue_locked_flush (GstQueue *queue) +gst_queue_locked_flush (GstQueue * queue) { while (!g_queue_is_empty (queue->queue)) { GstData *data = g_queue_pop_head (queue->queue); + /* First loose the reference we added when putting that data in the queue */ gst_data_unref (data); /* Then loose another reference because we are supposed to destroy that @@ -380,11 +380,12 @@ gst_queue_locked_flush (GstQueue *queue) } static void -gst_queue_handle_pending_events (GstQueue *queue) +gst_queue_handle_pending_events (GstQueue * queue) { /* check for events to send upstream */ - while (!g_queue_is_empty (queue->events)){ + while (!g_queue_is_empty (queue->events)) { GstQueueEventResponse *er = g_queue_pop_head (queue->events); + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "sending event upstream"); er->ret = gst_pad_event_default (queue->srcpad, er->event); er->handled = TRUE; @@ -411,8 +412,7 @@ gst_queue_handle_pending_events (GstQueue *queue) queue->queue->length) static void -gst_queue_chain (GstPad *pad, - GstData *data) +gst_queue_chain (GstPad * pad, GstData * data) { GstQueue *queue; @@ -421,10 +421,11 @@ gst_queue_chain (GstPad *pad, g_return_if_fail (data != NULL); queue = GST_QUEUE (GST_OBJECT_PARENT (pad)); - + restart: /* we have to lock the queue since we span threads */ - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p", g_thread_self ()); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p", + g_thread_self ()); g_mutex_lock (queue->qlock); GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ()); @@ -432,170 +433,167 @@ restart: /* assume don't need to flush this buffer when the queue is filled */ queue->flush = FALSE; - + if (GST_IS_EVENT (data)) { switch (GST_EVENT_TYPE (data)) { case GST_EVENT_FLUSH: - STATUS (queue, "received flush event"); - gst_queue_locked_flush (queue); - STATUS (queue, "after flush"); + STATUS (queue, "received flush event"); + gst_queue_locked_flush (queue); + STATUS (queue, "after flush"); break; case GST_EVENT_EOS: STATUS (queue, "received EOS"); break; default: /* we put the event in the queue, we don't have to act ourselves */ - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "adding event %p of type %d", - data, GST_EVENT_TYPE (data)); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, + "adding event %p of type %d", data, GST_EVENT_TYPE (data)); break; } } - + if (GST_IS_BUFFER (data)) - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "adding buffer %p of size %d", - data, GST_BUFFER_SIZE (data)); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, + "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data)); /* We make space available if we're "full" according to whatever * the user defined as "full". Note that this only applies to buffers. * We always handle events and they don't count in our statistics. */ if (GST_IS_BUFFER (data) && ((queue->max_size.buffers > 0 && - queue->cur_level.buffers >= queue->max_size.buffers) || - (queue->max_size.bytes > 0 && - queue->cur_level.bytes >= queue->max_size.bytes) || - (queue->max_size.time > 0 && - queue->cur_level.time >= queue->max_size.time))) { + queue->cur_level.buffers >= queue->max_size.buffers) || + (queue->max_size.bytes > 0 && + queue->cur_level.bytes >= queue->max_size.bytes) || + (queue->max_size.time > 0 && + queue->cur_level.time >= queue->max_size.time))) { g_mutex_unlock (queue->qlock); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0); g_mutex_lock (queue->qlock); /* how are we going to make space for this buffer? */ switch (queue->leaky) { - /* leak current buffer */ + /* leak current buffer */ case GST_QUEUE_LEAK_UPSTREAM: - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "queue is full, leaking buffer on upstream end"); - /* now we can clean up and exit right away */ - g_mutex_unlock (queue->qlock); - goto out_unref; - - /* leak first buffer in the queue */ - case GST_QUEUE_LEAK_DOWNSTREAM: { - /* this is a bit hacky. We'll manually iterate the list - * and find the first buffer from the head on. We'll - * unref that and "fix up" the GQueue object... */ - GList *item; - GstData *leak = NULL; - - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "queue is full, leaking buffer on downstream end"); - - for (item = queue->queue->head; item != NULL; item = item->next) { - if (GST_IS_BUFFER (item->data)) { - leak = item->data; - break; - } - } - - /* if we didn't find anything, it means we have no buffers - * in here. That cannot happen, since we had >= 1 bufs */ - g_assert (leak); - - /* Now remove it from the list, fixing up the GQueue - * CHECKME: is a queue->head the first or the last item? */ - item = g_list_delete_link (queue->queue->head, item); - queue->queue->head = g_list_first (item); - queue->queue->tail = g_list_last (item); - queue->queue->length--; - - /* and unref the data at the end. Twice, because we keep a ref - * to make things read-only. Also keep our list uptodate. */ - queue->cur_level.bytes -= GST_BUFFER_SIZE (data); - queue->cur_level.buffers --; - if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) - queue->cur_level.time -= GST_BUFFER_DURATION (data); - - gst_data_unref (data); - gst_data_unref (data); - break; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "queue is full, leaking buffer on upstream end"); + /* now we can clean up and exit right away */ + g_mutex_unlock (queue->qlock); + goto out_unref; + + /* leak first buffer in the queue */ + case GST_QUEUE_LEAK_DOWNSTREAM:{ + /* this is a bit hacky. We'll manually iterate the list + * and find the first buffer from the head on. We'll + * unref that and "fix up" the GQueue object... */ + GList *item; + GstData *leak = NULL; + + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "queue is full, leaking buffer on downstream end"); + + for (item = queue->queue->head; item != NULL; item = item->next) { + if (GST_IS_BUFFER (item->data)) { + leak = item->data; + break; + } + } + + /* if we didn't find anything, it means we have no buffers + * in here. That cannot happen, since we had >= 1 bufs */ + g_assert (leak); + + /* Now remove it from the list, fixing up the GQueue + * CHECKME: is a queue->head the first or the last item? */ + item = g_list_delete_link (queue->queue->head, item); + queue->queue->head = g_list_first (item); + queue->queue->tail = g_list_last (item); + queue->queue->length--; + + /* and unref the data at the end. Twice, because we keep a ref + * to make things read-only. Also keep our list uptodate. */ + queue->cur_level.bytes -= GST_BUFFER_SIZE (data); + queue->cur_level.buffers--; + if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) + queue->cur_level.time -= GST_BUFFER_DURATION (data); + + gst_data_unref (data); + gst_data_unref (data); + break; } default: - g_warning ("Unknown leaky type, using default"); - /* fall-through */ + g_warning ("Unknown leaky type, using default"); + /* fall-through */ - /* don't leak. Instead, wait for space to be available */ + /* don't leak. Instead, wait for space to be available */ case GST_QUEUE_NO_LEAK: - STATUS (queue, "pre-full wait"); - - while ((queue->max_size.buffers > 0 && - queue->cur_level.buffers >= queue->max_size.buffers) || - (queue->max_size.bytes > 0 && - queue->cur_level.bytes >= queue->max_size.bytes) || - (queue->max_size.time > 0 && - queue->cur_level.time >= queue->max_size.time)) { - /* if there's a pending state change for this queue - * or its manager, switch back to iterator so bottom - * half of state change executes */ - if (queue->interrupt) { - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); - g_mutex_unlock (queue->qlock); - if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), - GST_ELEMENT (queue))) { - goto out_unref; - } + STATUS (queue, "pre-full wait"); + + while ((queue->max_size.buffers > 0 && + queue->cur_level.buffers >= queue->max_size.buffers) || + (queue->max_size.bytes > 0 && + queue->cur_level.bytes >= queue->max_size.bytes) || + (queue->max_size.time > 0 && + queue->cur_level.time >= queue->max_size.time)) { + /* if there's a pending state change for this queue + * or its manager, switch back to iterator so bottom + * half of state change executes */ + if (queue->interrupt) { + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); + g_mutex_unlock (queue->qlock); + if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), + GST_ELEMENT (queue))) { + goto out_unref; + } /* if we got here because we were unlocked after a - * flush, we don't need to add the buffer to the - * queue again */ + * flush, we don't need to add the buffer to the + * queue again */ if (queue->flush) { - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "not adding pending buffer after flush"); + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "not adding pending buffer after flush"); goto out_unref; } - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "adding pending buffer after interrupt"); + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "adding pending buffer after interrupt"); goto restart; - } + } - if (GST_STATE (queue) != GST_STATE_PLAYING) { + if (GST_STATE (queue) != GST_STATE_PLAYING) { /* this means the other end is shut down. Try to - * signal to resolve the error */ + * signal to resolve the error */ if (!queue->may_deadlock) { - g_mutex_unlock (queue->qlock); - gst_data_unref (data); - GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), - ("deadlock found, shutting down source pad elements")); + g_mutex_unlock (queue->qlock); + gst_data_unref (data); + GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), + ("deadlock found, shutting down source pad elements")); /* we don't go to out_unref here, since we want to - * unref the buffer *before* calling GST_ELEMENT_ERROR */ + * unref the buffer *before* calling GST_ELEMENT_ERROR */ return; } else { - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "%s: waiting for the app to restart " - "source pad elements", - GST_ELEMENT_NAME (queue)); + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, + "%s: waiting for the app to restart " + "source pad elements", GST_ELEMENT_NAME (queue)); } - } - - /* OK, we've got a serious issue here. Imagine the situation - * where the puller (next element) is sending an event here, - * so it cannot pull events from the queue, and we cannot - * push data further because the queue is 'full' and therefore, - * we wait here (and do not handle events): deadlock! to solve - * that, we handle pending upstream events here, too. */ - gst_queue_handle_pending_events (queue); - - STATUS (queue, "waiting for item_del signal"); - g_cond_wait (queue->item_del, queue->qlock); - STATUS (queue, "received item_del signal"); - } - - STATUS (queue, "post-full wait"); - g_mutex_unlock (queue->qlock); - g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0); - g_mutex_lock (queue->qlock); - break; + } + + /* OK, we've got a serious issue here. Imagine the situation + * where the puller (next element) is sending an event here, + * so it cannot pull events from the queue, and we cannot + * push data further because the queue is 'full' and therefore, + * we wait here (and do not handle events): deadlock! to solve + * that, we handle pending upstream events here, too. */ + gst_queue_handle_pending_events (queue); + + STATUS (queue, "waiting for item_del signal"); + g_cond_wait (queue->item_del, queue->qlock); + STATUS (queue, "received item_del signal"); + } + + STATUS (queue, "post-full wait"); + g_mutex_unlock (queue->qlock); + g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0); + g_mutex_lock (queue->qlock); + break; } } @@ -628,7 +626,7 @@ out_unref: } static GstData * -gst_queue_get (GstPad *pad) +gst_queue_get (GstPad * pad) { GstQueue *queue; GstData *data; @@ -641,70 +639,69 @@ gst_queue_get (GstPad *pad) restart: /* have to lock for thread-safety */ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "locking t:%p", g_thread_self ()); + "locking t:%p", g_thread_self ()); g_mutex_lock (queue->qlock); - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "locked t:%p", g_thread_self ()); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ()); if (queue->queue->length == 0 || (queue->min_threshold.buffers > 0 && - queue->cur_level.buffers < queue->min_threshold.buffers) || + queue->cur_level.buffers < queue->min_threshold.buffers) || (queue->min_threshold.bytes > 0 && - queue->cur_level.bytes < queue->min_threshold.bytes) || + queue->cur_level.bytes < queue->min_threshold.bytes) || (queue->min_threshold.time > 0 && - queue->cur_level.time < queue->min_threshold.time)) { + queue->cur_level.time < queue->min_threshold.time)) { g_mutex_unlock (queue->qlock); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0); g_mutex_lock (queue->qlock); STATUS (queue, "pre-empty wait"); while (queue->queue->length == 0 || - (queue->min_threshold.buffers > 0 && - queue->cur_level.buffers < queue->min_threshold.buffers) || - (queue->min_threshold.bytes > 0 && - queue->cur_level.bytes < queue->min_threshold.bytes) || - (queue->min_threshold.time > 0 && - queue->cur_level.time < queue->min_threshold.time)) { + (queue->min_threshold.buffers > 0 && + queue->cur_level.buffers < queue->min_threshold.buffers) || + (queue->min_threshold.bytes > 0 && + queue->cur_level.bytes < queue->min_threshold.bytes) || + (queue->min_threshold.time > 0 && + queue->cur_level.time < queue->min_threshold.time)) { /* if there's a pending state change for this queue or its * manager, switch back to iterator so bottom half of state * change executes. */ if (queue->interrupt) { - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); - g_mutex_unlock (queue->qlock); - if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), - GST_ELEMENT (queue))) - return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); - goto restart; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); + g_mutex_unlock (queue->qlock); + if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), + GST_ELEMENT (queue))) + return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + goto restart; } if (GST_STATE (queue) != GST_STATE_PLAYING) { - /* this means the other end is shut down */ - if (!queue->may_deadlock) { - g_mutex_unlock (queue->qlock); - GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), - ("deadlock found, shutting down sink pad elements")); - goto restart; - } else { - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "%s: waiting for the app to restart " - "source pad elements", - GST_ELEMENT_NAME (queue)); - } + /* this means the other end is shut down */ + if (!queue->may_deadlock) { + g_mutex_unlock (queue->qlock); + GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), + ("deadlock found, shutting down sink pad elements")); + goto restart; + } else { + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, + "%s: waiting for the app to restart " + "source pad elements", GST_ELEMENT_NAME (queue)); + } } STATUS (queue, "waiting for item_add"); - + if (queue->block_timeout != GST_CLOCK_TIME_NONE) { - GTimeVal timeout; - g_get_current_time (&timeout); - g_time_val_add (&timeout, queue->block_timeout / 1000); - if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)){ - g_mutex_unlock (queue->qlock); + GTimeVal timeout; + + g_get_current_time (&timeout); + g_time_val_add (&timeout, queue->block_timeout / 1000); + if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) { + g_mutex_unlock (queue->qlock); GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "Sending filler event"); - return GST_DATA (gst_event_new_filler ()); - } + "Sending filler event"); + return GST_DATA (gst_event_new_filler ()); + } } else { - g_cond_wait (queue->item_add, queue->qlock); + g_cond_wait (queue->item_add, queue->qlock); } STATUS (queue, "got item_add signal"); } @@ -718,8 +715,8 @@ restart: /* There's something in the list now, whatever it is */ data = g_queue_pop_head (queue->queue); GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "retrieved data %p from queue", data); - + "retrieved data %p from queue", data); + if (data == NULL) return NULL; @@ -746,15 +743,15 @@ restart: * locked too so it'd cause a deadlock. */ if (GST_IS_EVENT (data)) { GstEvent *event = GST_EVENT (data); + switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "queue \"%s\" eos", - GST_ELEMENT_NAME (queue)); - gst_element_set_eos (GST_ELEMENT (queue)); - break; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "queue \"%s\" eos", GST_ELEMENT_NAME (queue)); + gst_element_set_eos (GST_ELEMENT (queue)); + break; default: - break; + break; } } @@ -763,8 +760,7 @@ restart: static gboolean -gst_queue_handle_src_event (GstPad *pad, - GstEvent *event) +gst_queue_handle_src_event (GstPad * pad, GstEvent * event) { GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad)); gboolean res; @@ -779,45 +775,45 @@ gst_queue_handle_src_event (GstPad *pad, er.handled = FALSE; g_queue_push_tail (queue->events, &er); GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "Preparing for loop for event handler"); + "Preparing for loop for event handler"); /* see the chain function on why this is here - it prevents a deadlock */ g_cond_signal (queue->item_del); while (!er.handled) { GTimeVal timeout; + g_get_current_time (&timeout); - g_time_val_add (&timeout, 500 * 1000); /* half a second */ + g_time_val_add (&timeout, 500 * 1000); /* half a second */ if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) && - !er.handled) { - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "timeout in upstream event handling"); - /* remove ourselves from the pending list. Since we're - * locked, others cannot reference this anymore. */ - queue->queue->head = g_list_remove (queue->queue->head, &er); - queue->queue->head = g_list_first (queue->queue->head); - queue->queue->tail = g_list_last (queue->queue->head); - queue->queue->length--; - res = FALSE; - goto handled; + !er.handled) { + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, + "timeout in upstream event handling"); + /* remove ourselves from the pending list. Since we're + * locked, others cannot reference this anymore. */ + queue->queue->head = g_list_remove (queue->queue->head, &er); + queue->queue->head = g_list_first (queue->queue->head); + queue->queue->tail = g_list_last (queue->queue->head); + queue->queue->length--; + res = FALSE; + goto handled; } } - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "Event handled"); + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled"); res = er.ret; } else { - res = gst_pad_event_default (pad, event); + res = gst_pad_event_default (pad, event); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_FLUSH: - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "FLUSH event, flushing queue\n"); - gst_queue_locked_flush (queue); - break; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "FLUSH event, flushing queue\n"); + gst_queue_locked_flush (queue); + break; case GST_EVENT_SEEK: - if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { - gst_queue_locked_flush (queue); - } + if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { + gst_queue_locked_flush (queue); + } default: - break; + break; } } handled: @@ -827,7 +823,7 @@ handled: } static gboolean -gst_queue_release_locks (GstElement *element) +gst_queue_release_locks (GstElement * element) { GstQueue *queue; @@ -843,7 +839,7 @@ gst_queue_release_locks (GstElement *element) } static GstElementStateReturn -gst_queue_change_state (GstElement *element) +gst_queue_change_state (GstElement * element) { GstQueue *queue; GstElementStateReturn ret = GST_STATE_SUCCESS; @@ -863,31 +859,30 @@ gst_queue_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_PLAYING: if (!GST_PAD_IS_LINKED (queue->sinkpad)) { - GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, - "queue %s is not linked", - GST_ELEMENT_NAME (queue)); - /* FIXME can this be? */ - g_cond_signal (queue->item_add); - - ret = GST_STATE_FAILURE; - goto error; + GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, + "queue %s is not linked", GST_ELEMENT_NAME (queue)); + /* FIXME can this be? */ + g_cond_signal (queue->item_add); + + ret = GST_STATE_FAILURE; + goto error; } else { - GstScheduler *src_sched, *sink_sched; - - src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad)); - sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad)); + GstScheduler *src_sched, *sink_sched; + + src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad)); + sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad)); - if (src_sched == sink_sched) { - GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, - "queue %s does not connect different schedulers", - GST_ELEMENT_NAME (queue)); + if (src_sched == sink_sched) { + GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, + "queue %s does not connect different schedulers", + GST_ELEMENT_NAME (queue)); g_warning ("queue %s does not connect different schedulers", - GST_ELEMENT_NAME (queue)); + GST_ELEMENT_NAME (queue)); ret = GST_STATE_FAILURE; goto error; - } + } } queue->interrupt = FALSE; break; @@ -917,10 +912,8 @@ error: static void -gst_queue_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +gst_queue_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) { GstQueue *queue = GST_QUEUE (object); @@ -965,10 +958,8 @@ gst_queue_set_property (GObject *object, } static void -gst_queue_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gst_queue_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) { GstQueue *queue = GST_QUEUE (object); diff --git a/gst/gstqueue.h b/gst/gstqueue.h index d4ce60244..c999fc46e 100644 --- a/gst/gstqueue.h +++ b/gst/gstqueue.h @@ -29,7 +29,6 @@ G_BEGIN_DECLS - #define GST_TYPE_QUEUE \ (gst_queue_get_type()) #define GST_QUEUE(obj) \ @@ -40,17 +39,18 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE)) #define GST_IS_QUEUE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE)) - -enum { - GST_QUEUE_NO_LEAK = 0, - GST_QUEUE_LEAK_UPSTREAM = 1, - GST_QUEUE_LEAK_DOWNSTREAM = 2 + enum +{ + GST_QUEUE_NO_LEAK = 0, + GST_QUEUE_LEAK_UPSTREAM = 1, + GST_QUEUE_LEAK_DOWNSTREAM = 2 }; typedef struct _GstQueue GstQueue; typedef struct _GstQueueClass GstQueueClass; -struct _GstQueue { +struct _GstQueue +{ GstElement element; GstPad *sinkpad; @@ -59,13 +59,14 @@ struct _GstQueue { /* the queue of data we're keeping our grubby hands on */ GQueue *queue; - struct { - guint buffers; /* no. of buffers */ - guint bytes; /* no. of bytes */ - guint64 time; /* amount of time */ - } cur_level, /* currently in the queue */ - max_size, /* max. amount of data allowed in the queue */ - min_threshold; /* min. amount of data required to wake reader */ + struct + { + guint buffers; /* no. of buffers */ + guint bytes; /* no. of bytes */ + guint64 time; /* amount of time */ + } cur_level, /* currently in the queue */ + max_size, /* max. amount of data allowed in the queue */ + min_threshold; /* min. amount of data required to wake reader */ /* whether we leak data, and at which end */ gint leaky; @@ -80,27 +81,28 @@ struct _GstQueue { gboolean interrupt; gboolean flush; - GMutex *qlock; /* lock for queue (vs object lock) */ - GCond *item_add; /* signals buffers now available for reading */ - GCond *item_del; /* signals space now available for writing */ - GCond *event_done; /* upstream event signaller */ + GMutex *qlock; /* lock for queue (vs object lock) */ + GCond *item_add; /* signals buffers now available for reading */ + GCond *item_del; /* signals space now available for writing */ + GCond *event_done; /* upstream event signaller */ - GTimeVal *timeval; /* the timeout for the queue locking */ - GQueue *events; /* upstream events get decoupled here */ + GTimeVal *timeval; /* the timeout for the queue locking */ + GQueue *events; /* upstream events get decoupled here */ GstCaps *negotiated_caps; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstQueueClass { +struct _GstQueueClass +{ GstElementClass parent_class; /* signals - 'running' is called from both sides * which might make it sort of non-useful... */ - void (*underrun) (GstQueue *queue); - void (*running) (GstQueue *queue); - void (*overrun) (GstQueue *queue); + void (*underrun) (GstQueue * queue); + void (*running) (GstQueue * queue); + void (*overrun) (GstQueue * queue); gpointer _gst_reserved[GST_PADDING]; }; @@ -108,6 +110,4 @@ struct _GstQueueClass { GType gst_queue_get_type (void); G_END_DECLS - - #endif /* __GST_QUEUE_H__ */ diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 73d481390..3b1329f4a 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -37,16 +37,17 @@ #include "gstfilter.h" /* Element signals and args */ -enum { +enum +{ PLUGIN_ADDED, LAST_SIGNAL }; -static void gst_registry_class_init (GstRegistryClass *klass); -static void gst_registry_init (GstRegistry *registry); +static void gst_registry_class_init (GstRegistryClass * klass); +static void gst_registry_init (GstRegistry * registry); static GObjectClass *parent_class = NULL; -static guint gst_registry_signals[LAST_SIGNAL] = { 0 }; +static guint gst_registry_signals[LAST_SIGNAL] = { 0 }; GType gst_registry_get_type (void) @@ -67,31 +68,30 @@ gst_registry_get_type (void) NULL }; registry_type = g_type_register_static (G_TYPE_OBJECT, "GstRegistry", - ®istry_info, G_TYPE_FLAG_ABSTRACT); + ®istry_info, G_TYPE_FLAG_ABSTRACT); } return registry_type; } static void -gst_registry_class_init (GstRegistryClass *klass) +gst_registry_class_init (GstRegistryClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + gobject_class = (GObjectClass *) klass; parent_class = g_type_class_ref (G_TYPE_OBJECT); gst_registry_signals[PLUGIN_ADDED] = - g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL, NULL, - gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, - G_TYPE_POINTER); + g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL, + NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); gobject_class->dispose = NULL; } static void -gst_registry_init (GstRegistry *registry) +gst_registry_init (GstRegistry * registry) { registry->priority = 0; registry->loaded = FALSE; @@ -107,7 +107,7 @@ gst_registry_init (GstRegistry *registry) * Returns: TRUE on success. */ gboolean -gst_registry_load (GstRegistry *registry) +gst_registry_load (GstRegistry * registry) { GstRegistryClass *rclass; @@ -130,7 +130,7 @@ gst_registry_load (GstRegistry *registry) * Returns: TRUE if loaded. */ gboolean -gst_registry_is_loaded (GstRegistry *registry) +gst_registry_is_loaded (GstRegistry * registry) { g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE); @@ -146,7 +146,7 @@ gst_registry_is_loaded (GstRegistry *registry) * Returns: TRUE on success */ gboolean -gst_registry_save (GstRegistry *registry) +gst_registry_save (GstRegistry * registry) { GstRegistryClass *rclass; @@ -169,7 +169,7 @@ gst_registry_save (GstRegistry *registry) * Returns: TRUE on success */ gboolean -gst_registry_rebuild (GstRegistry *registry) +gst_registry_rebuild (GstRegistry * registry) { GstRegistryClass *rclass; @@ -192,7 +192,7 @@ gst_registry_rebuild (GstRegistry *registry) * Returns: TRUE on success */ gboolean -gst_registry_unload (GstRegistry *registry) +gst_registry_unload (GstRegistry * registry) { GstRegistryClass *rclass; @@ -216,13 +216,13 @@ gst_registry_unload (GstRegistry *registry) * added, do nothing. */ void -gst_registry_add_path (GstRegistry *registry, const gchar *path) +gst_registry_add_path (GstRegistry * registry, const gchar * path) { g_return_if_fail (GST_IS_REGISTRY (registry)); g_return_if_fail (path != NULL); if (g_list_find_custom (registry->paths, path, (GCompareFunc) strcmp)) { - g_warning ("path %s already added to registry", path); + g_warning ("path %s already added to registry", path); return; } @@ -237,8 +237,8 @@ gst_registry_add_path (GstRegistry *registry, const gchar *path) * * Returns: A Glist of paths as strings. g_list_free after use. */ -GList* -gst_registry_get_path_list (GstRegistry *registry) +GList * +gst_registry_get_path_list (GstRegistry * registry) { g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL); @@ -253,7 +253,7 @@ gst_registry_get_path_list (GstRegistry *registry) * Clear the paths of the given registry */ void -gst_registry_clear_paths (GstRegistry *registry) +gst_registry_clear_paths (GstRegistry * registry) { g_return_if_fail (GST_IS_REGISTRY (registry)); @@ -273,15 +273,16 @@ gst_registry_clear_paths (GstRegistry *registry) * * Returns: TRUE on success. */ -gboolean -gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin) +gboolean +gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin) { g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE); - + plugin->manager = registry; registry->plugins = g_list_prepend (registry->plugins, plugin); - g_signal_emit (G_OBJECT (registry), gst_registry_signals[PLUGIN_ADDED], 0, plugin); + g_signal_emit (G_OBJECT (registry), gst_registry_signals[PLUGIN_ADDED], 0, + plugin); return TRUE; } @@ -294,7 +295,7 @@ gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin) * Remove the plugin from the registry. */ void -gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin) +gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin) { g_return_if_fail (GST_IS_REGISTRY (registry)); @@ -314,15 +315,14 @@ gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin) * * Returns: a GList of plugins, g_list_free after use. */ -GList* -gst_registry_plugin_filter (GstRegistry *registry, - GstPluginFilter filter, - gboolean first, - gpointer user_data) +GList * +gst_registry_plugin_filter (GstRegistry * registry, + GstPluginFilter filter, gboolean first, gpointer user_data) { g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL); - return gst_filter_run (registry->plugins, (GstFilterFunc) filter, first, user_data); + return gst_filter_run (registry->plugins, (GstFilterFunc) filter, first, + user_data); } /** @@ -339,15 +339,14 @@ gst_registry_plugin_filter (GstRegistry *registry, * * Returns: a GList of plugin features, g_list_free after use. */ -GList* -gst_registry_feature_filter (GstRegistry *registry, - GstPluginFeatureFilter filter, - gboolean first, - gpointer user_data) +GList * +gst_registry_feature_filter (GstRegistry * registry, + GstPluginFeatureFilter filter, gboolean first, gpointer user_data) { g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL); - return gst_plugin_list_feature_filter (registry->plugins, filter, first, user_data); + return gst_plugin_list_feature_filter (registry->plugins, filter, first, + user_data); } /** @@ -359,8 +358,8 @@ gst_registry_feature_filter (GstRegistry *registry, * * Returns: The plugin with the given name or NULL if the plugin was not found. */ -GstPlugin* -gst_registry_find_plugin (GstRegistry *registry, const gchar *name) +GstPlugin * +gst_registry_find_plugin (GstRegistry * registry, const gchar * name) { GList *walk; GstPlugin *result = NULL; @@ -368,11 +367,9 @@ gst_registry_find_plugin (GstRegistry *registry, const gchar *name) g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL); g_return_val_if_fail (name != NULL, NULL); - walk = gst_registry_plugin_filter (registry, - (GstPluginFilter) gst_plugin_name_filter, - TRUE, - (gpointer) name); - if (walk) + walk = gst_registry_plugin_filter (registry, + (GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name); + if (walk) result = GST_PLUGIN (walk->data); g_list_free (walk); @@ -391,8 +388,9 @@ gst_registry_find_plugin (GstRegistry *registry, const gchar *name) * Returns: The pluginfeature with the given name and type or NULL * if the plugin was not found. */ -GstPluginFeature* -gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type) +GstPluginFeature * +gst_registry_find_feature (GstRegistry * registry, const gchar * name, + GType type) { GstPluginFeature *feature = NULL; GList *walk; @@ -404,12 +402,11 @@ gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type) data.name = name; data.type = type; - walk = gst_registry_feature_filter (registry, - (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter, - TRUE, - &data); + walk = gst_registry_feature_filter (registry, + (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter, + TRUE, &data); - if (walk) + if (walk) feature = GST_PLUGIN_FEATURE (walk->data); g_list_free (walk); @@ -428,11 +425,12 @@ gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type) * Returns: a value indicating the result */ GstRegistryReturn -gst_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin) +gst_registry_load_plugin (GstRegistry * registry, GstPlugin * plugin) { GstRegistryClass *rclass; - g_return_val_if_fail (GST_IS_REGISTRY (registry), GST_REGISTRY_PLUGIN_LOAD_ERROR); + g_return_val_if_fail (GST_IS_REGISTRY (registry), + GST_REGISTRY_PLUGIN_LOAD_ERROR); rclass = GST_REGISTRY_GET_CLASS (registry); @@ -452,11 +450,12 @@ gst_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin) * Returns: a value indicating the result */ GstRegistryReturn -gst_registry_unload_plugin (GstRegistry *registry, GstPlugin *plugin) +gst_registry_unload_plugin (GstRegistry * registry, GstPlugin * plugin) { GstRegistryClass *rclass; - g_return_val_if_fail (GST_IS_REGISTRY (registry), GST_REGISTRY_PLUGIN_LOAD_ERROR); + g_return_val_if_fail (GST_IS_REGISTRY (registry), + GST_REGISTRY_PLUGIN_LOAD_ERROR); rclass = GST_REGISTRY_GET_CLASS (registry); @@ -476,11 +475,12 @@ gst_registry_unload_plugin (GstRegistry *registry, GstPlugin *plugin) * Returns: a value indicating the result */ GstRegistryReturn -gst_registry_update_plugin (GstRegistry *registry, GstPlugin *plugin) +gst_registry_update_plugin (GstRegistry * registry, GstPlugin * plugin) { GstRegistryClass *rclass; - g_return_val_if_fail (GST_IS_REGISTRY (registry), GST_REGISTRY_PLUGIN_LOAD_ERROR); + g_return_val_if_fail (GST_IS_REGISTRY (registry), + GST_REGISTRY_PLUGIN_LOAD_ERROR); rclass = GST_REGISTRY_GET_CLASS (registry); diff --git a/gst/gstregistry.h b/gst/gstregistry.h index ed1072721..7fed8757a 100644 --- a/gst/gstregistry.h +++ b/gst/gstregistry.h @@ -43,25 +43,25 @@ S_IRGRP | S_IWGRP | \ S_IROTH | S_IWOTH) -G_BEGIN_DECLS - -typedef enum { - GST_REGISTRY_OK = (0), - GST_REGISTRY_LOAD_ERROR = (1 << 1), - GST_REGISTRY_SAVE_ERROR = (1 << 2), - GST_REGISTRY_PLUGIN_LOAD_ERROR = (1 << 3), - GST_REGISTRY_PLUGIN_SIGNATURE_ERROR = (1 << 4) +G_BEGIN_DECLS typedef enum +{ + GST_REGISTRY_OK = (0), + GST_REGISTRY_LOAD_ERROR = (1 << 1), + GST_REGISTRY_SAVE_ERROR = (1 << 2), + GST_REGISTRY_PLUGIN_LOAD_ERROR = (1 << 3), + GST_REGISTRY_PLUGIN_SIGNATURE_ERROR = (1 << 4) } GstRegistryReturn; -typedef enum { - GST_REGISTRY_READABLE = (1 << 1), - GST_REGISTRY_WRITABLE = (1 << 2), - GST_REGISTRY_EXISTS = (1 << 3), - GST_REGISTRY_REMOTE = (1 << 4), - GST_REGISTRY_DELAYED_LOADING = (1 << 5) +typedef enum +{ + GST_REGISTRY_READABLE = (1 << 1), + GST_REGISTRY_WRITABLE = (1 << 2), + GST_REGISTRY_EXISTS = (1 << 3), + GST_REGISTRY_REMOTE = (1 << 4), + GST_REGISTRY_DELAYED_LOADING = (1 << 5) } GstRegistryFlags; - + #define GST_TYPE_REGISTRY (gst_registry_get_type ()) #define GST_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_REGISTRY, GstRegistry)) #define GST_IS_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_REGISTRY)) @@ -72,75 +72,80 @@ typedef enum { typedef struct _GstRegistry GstRegistry; typedef struct _GstRegistryClass GstRegistryClass; -struct _GstRegistry { - GObject object; +struct _GstRegistry +{ + GObject object; - gint priority; + gint priority; GstRegistryFlags flags; - gchar *name; - gchar *details; + gchar *name; + gchar *details; - gboolean loaded; - GList *plugins; + gboolean loaded; + GList *plugins; - GList *paths; + GList *paths; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstRegistryClass { - GObjectClass parent_class; +struct _GstRegistryClass +{ + GObjectClass parent_class; /* vtable */ - gboolean (*load) (GstRegistry *registry); - gboolean (*save) (GstRegistry *registry); - gboolean (*rebuild) (GstRegistry *registry); - gboolean (*unload) (GstRegistry *registry); - - GstRegistryReturn (*load_plugin) (GstRegistry *registry, GstPlugin *plugin); - GstRegistryReturn (*unload_plugin) (GstRegistry *registry, GstPlugin *plugin); - GstRegistryReturn (*update_plugin) (GstRegistry *registry, GstPlugin *plugin); + gboolean (*load) (GstRegistry * registry); + gboolean (*save) (GstRegistry * registry); + gboolean (*rebuild) (GstRegistry * registry); + gboolean (*unload) (GstRegistry * registry); + + GstRegistryReturn (*load_plugin) (GstRegistry * registry, + GstPlugin * plugin); + GstRegistryReturn (*unload_plugin) (GstRegistry * registry, + GstPlugin * plugin); + GstRegistryReturn (*update_plugin) (GstRegistry * registry, + GstPlugin * plugin); /* signals */ - void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin); + void (*plugin_added) (GstRegistry * registry, GstPlugin * plugin); gpointer _gst_reserved[GST_PADDING]; }; /* normal GObject stuff */ -GType gst_registry_get_type (void); - -gboolean gst_registry_load (GstRegistry *registry); -gboolean gst_registry_is_loaded (GstRegistry *registry); -gboolean gst_registry_save (GstRegistry *registry); -gboolean gst_registry_rebuild (GstRegistry *registry); -gboolean gst_registry_unload (GstRegistry *registry); - -void gst_registry_add_path (GstRegistry *registry, const gchar *path); -GList* gst_registry_get_path_list (GstRegistry *registry); -void gst_registry_clear_paths (GstRegistry *registry); - -gboolean gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin); -void gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin); - -GList* gst_registry_plugin_filter (GstRegistry *registry, - GstPluginFilter filter, - gboolean first, - gpointer user_data); -GList* gst_registry_feature_filter (GstRegistry *registry, - GstPluginFeatureFilter filter, - gboolean first, - gpointer user_data); - -GstPlugin* gst_registry_find_plugin (GstRegistry *registry, const gchar *name); -GstPluginFeature* gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type); - -GstRegistryReturn gst_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin); -GstRegistryReturn gst_registry_unload_plugin (GstRegistry *registry, GstPlugin *plugin); -GstRegistryReturn gst_registry_update_plugin (GstRegistry *registry, GstPlugin *plugin); +GType gst_registry_get_type (void); + +gboolean gst_registry_load (GstRegistry * registry); +gboolean gst_registry_is_loaded (GstRegistry * registry); +gboolean gst_registry_save (GstRegistry * registry); +gboolean gst_registry_rebuild (GstRegistry * registry); +gboolean gst_registry_unload (GstRegistry * registry); + +void gst_registry_add_path (GstRegistry * registry, const gchar * path); +GList *gst_registry_get_path_list (GstRegistry * registry); +void gst_registry_clear_paths (GstRegistry * registry); + +gboolean gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin); +void gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin); + +GList *gst_registry_plugin_filter (GstRegistry * registry, + GstPluginFilter filter, gboolean first, gpointer user_data); +GList *gst_registry_feature_filter (GstRegistry * registry, + GstPluginFeatureFilter filter, gboolean first, gpointer user_data); + +GstPlugin *gst_registry_find_plugin (GstRegistry * registry, + const gchar * name); +GstPluginFeature *gst_registry_find_feature (GstRegistry * registry, + const gchar * name, GType type); + +GstRegistryReturn gst_registry_load_plugin (GstRegistry * registry, + GstPlugin * plugin); +GstRegistryReturn gst_registry_unload_plugin (GstRegistry * registry, + GstPlugin * plugin); +GstRegistryReturn gst_registry_update_plugin (GstRegistry * registry, + GstPlugin * plugin); G_END_DECLS - #endif /* __GST_REGISTRY_H__ */ diff --git a/gst/gstregistrypool.c b/gst/gstregistrypool.c index 76fd48082..7173a0587 100644 --- a/gst/gstregistrypool.c +++ b/gst/gstregistrypool.c @@ -31,6 +31,7 @@ /* list of registries in the pool */ static GList *_gst_registry_pool = NULL; + /* list of plugins without a registry, like statically linked * plugins */ static GList *_gst_registry_pool_plugins = NULL; @@ -42,7 +43,7 @@ static GList *_gst_registry_pool_plugins = NULL; * * Returns: a Glist of GstRegistries, g_list_free after use. */ -GList* +GList * gst_registry_pool_list (void) { return g_list_copy (_gst_registry_pool); @@ -63,13 +64,15 @@ gst_registry_compare_func (gconstpointer a, gconstpointer b) * Add the registry to the pool with the given priority. */ void -gst_registry_pool_add (GstRegistry *registry, guint priority) +gst_registry_pool_add (GstRegistry * registry, guint priority) { g_return_if_fail (GST_IS_REGISTRY (registry)); registry->priority = priority; - _gst_registry_pool = g_list_insert_sorted (_gst_registry_pool, registry, gst_registry_compare_func); + _gst_registry_pool = + g_list_insert_sorted (_gst_registry_pool, registry, + gst_registry_compare_func); } /** @@ -79,7 +82,7 @@ gst_registry_pool_add (GstRegistry *registry, guint priority) * Remove the registry from the pool. */ void -gst_registry_pool_remove (GstRegistry *registry) +gst_registry_pool_remove (GstRegistry * registry) { g_return_if_fail (GST_IS_REGISTRY (registry)); @@ -94,14 +97,15 @@ gst_registry_pool_remove (GstRegistry *registry) * Add the plugin to the global pool of plugins. */ void -gst_registry_pool_add_plugin (GstPlugin *plugin) +gst_registry_pool_add_plugin (GstPlugin * plugin) { - _gst_registry_pool_plugins = g_list_prepend (_gst_registry_pool_plugins, plugin); + _gst_registry_pool_plugins = + g_list_prepend (_gst_registry_pool_plugins, plugin); } #ifndef GST_DISABLE_REGISTRY static void -_registry_load_func (GstRegistry *registry, gpointer user_data) +_registry_load_func (GstRegistry * registry, gpointer user_data) { if (!(registry->flags & GST_REGISTRY_DELAYED_LOADING)) { gst_registry_load (registry); @@ -130,7 +134,7 @@ gst_registry_pool_load_all (void) * * Returns: a GList of plugins, g_list_free after use. */ -GList* +GList * gst_registry_pool_plugin_list (void) { return gst_registry_pool_plugin_filter (NULL, FALSE, NULL); @@ -148,12 +152,13 @@ gst_registry_pool_plugin_list (void) * * Returns: a GList of plugins, g_list_free after use. */ -GList* -gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first, gpointer user_data) +GList * +gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first, + gpointer user_data) { GList *result = NULL; GList *temp; - + #ifndef GST_DISABLE_REGISTRY GList *walk; @@ -167,12 +172,14 @@ gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first, gpointe return temp; result = g_list_concat (result, temp); - + walk = g_list_next (walk); } #endif /* GST_DISABLE_REGISTRY */ - temp = gst_filter_run (_gst_registry_pool_plugins, (GstFilterFunc) filter, first, user_data); + temp = + gst_filter_run (_gst_registry_pool_plugins, (GstFilterFunc) filter, first, + user_data); result = g_list_concat (result, temp); @@ -187,7 +194,7 @@ gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first, gpointe * * Returns: a GList of pluginfeatures, g_list_free after use. */ -GList* +GList * gst_registry_pool_feature_list (GType type) { GstTypeNameData data; @@ -196,9 +203,8 @@ gst_registry_pool_feature_list (GType type) data.type = type; return gst_registry_pool_feature_filter ( - (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter, - FALSE, - &data); + (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter, + FALSE, &data); } /** @@ -214,14 +220,16 @@ gst_registry_pool_feature_list (GType type) * * Returns: a GList of pluginfeatures, g_list_free after use. */ -GList* -gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first, gpointer user_data) +GList * +gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first, + gpointer user_data) { GList *result = NULL; GList *temp; - + #ifndef GST_DISABLE_REGISTRY GList *walk; + walk = _gst_registry_pool; while (walk) { @@ -232,12 +240,14 @@ gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first, return temp; result = g_list_concat (result, temp); - + walk = g_list_next (walk); } #endif /* GST_DISABLE_REGISTRY */ - temp = gst_plugin_list_feature_filter (_gst_registry_pool_plugins, filter, first, user_data); + temp = + gst_plugin_list_feature_filter (_gst_registry_pool_plugins, filter, first, + user_data); result = g_list_concat (result, temp); @@ -253,21 +263,23 @@ gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first, * Returns: The plugin with the given name or NULL if the plugin * was not found. */ -GstPlugin* -gst_registry_pool_find_plugin (const gchar *name) +GstPlugin * +gst_registry_pool_find_plugin (const gchar * name) { GstPlugin *result = NULL; GList *walk; g_return_val_if_fail (name != NULL, NULL); - - walk = gst_registry_pool_plugin_filter ((GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name); + + walk = + gst_registry_pool_plugin_filter ((GstPluginFilter) gst_plugin_name_filter, + TRUE, (gpointer) name); if (walk) result = GST_PLUGIN (walk->data); g_list_free (walk); - + return result; } @@ -282,8 +294,8 @@ gst_registry_pool_find_plugin (const gchar *name) * Returns: A pluginfeature with the given name and type or NULL if the feature * was not found. */ -GstPluginFeature* -gst_registry_pool_find_feature (const gchar *name, GType type) +GstPluginFeature * +gst_registry_pool_find_feature (const gchar * name, GType type) { GstPluginFeature *result = NULL; GList *walk; @@ -294,10 +306,11 @@ gst_registry_pool_find_feature (const gchar *name, GType type) data.type = type; data.name = name; - walk = gst_registry_pool_feature_filter ((GstPluginFeatureFilter) gst_plugin_feature_type_name_filter, - TRUE, &data); - - if (walk) + walk = + gst_registry_pool_feature_filter ((GstPluginFeatureFilter) + gst_plugin_feature_type_name_filter, TRUE, &data); + + if (walk) result = GST_PLUGIN_FEATURE (walk->data); g_list_free (walk); @@ -313,7 +326,7 @@ gst_registry_pool_find_feature (const gchar *name, GType type) * * Returns: The registry with the flags. */ -GstRegistry* +GstRegistry * gst_registry_pool_get_prefered (GstRegistryFlags flags) { #ifndef GST_DISABLE_REGISTRY @@ -324,7 +337,7 @@ gst_registry_pool_get_prefered (GstRegistryFlags flags) if (registry->flags & flags) return registry; - + walk = g_list_next (walk); } #endif /* GST_DISABLE_REGISTRY */ diff --git a/gst/gstregistrypool.h b/gst/gstregistrypool.h index cd1c65519..5e00d1ce3 100644 --- a/gst/gstregistrypool.h +++ b/gst/gstregistrypool.h @@ -25,35 +25,33 @@ #define __GST_REGISTRY_POOL_H__ G_BEGIN_DECLS - #include #include - /* the pool of registries */ -GList* gst_registry_pool_list (void); + GList * gst_registry_pool_list (void); -void gst_registry_pool_add (GstRegistry *registry, guint priority); -void gst_registry_pool_remove (GstRegistry *registry); +void gst_registry_pool_add (GstRegistry * registry, guint priority); +void gst_registry_pool_remove (GstRegistry * registry); -void gst_registry_pool_add_plugin (GstPlugin *plugin); +void gst_registry_pool_add_plugin (GstPlugin * plugin); -void gst_registry_pool_load_all (void); +void gst_registry_pool_load_all (void); /* query the plugins/features */ -GList* gst_registry_pool_plugin_filter (GstPluginFilter filter, - gboolean first, gpointer user_data); -GList* gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, - gboolean first, gpointer user_data); +GList *gst_registry_pool_plugin_filter (GstPluginFilter filter, + gboolean first, gpointer user_data); +GList *gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, + gboolean first, gpointer user_data); /* some predefined filters */ -GList* gst_registry_pool_plugin_list (void); -GList* gst_registry_pool_feature_list (GType type); +GList *gst_registry_pool_plugin_list (void); +GList *gst_registry_pool_feature_list (GType type); -GstPlugin* gst_registry_pool_find_plugin (const gchar *name); -GstPluginFeature* gst_registry_pool_find_feature (const gchar *name, GType type); +GstPlugin *gst_registry_pool_find_plugin (const gchar * name); +GstPluginFeature *gst_registry_pool_find_feature (const gchar * name, + GType type); -GstRegistry* gst_registry_pool_get_prefered (GstRegistryFlags flags); +GstRegistry *gst_registry_pool_get_prefered (GstRegistryFlags flags); G_END_DECLS - #endif /* __GST_REGISTRY_POOL_H__ */ diff --git a/gst/gstscheduler.c b/gst/gstscheduler.c index 9485ea796..174e63e74 100644 --- a/gst/gstscheduler.c +++ b/gst/gstscheduler.c @@ -27,9 +27,9 @@ #include "gstinfo.h" #include "gstregistrypool.h" -static void gst_scheduler_class_init (GstSchedulerClass *klass); -static void gst_scheduler_init (GstScheduler *sched); -static void gst_scheduler_dispose (GObject *object); +static void gst_scheduler_class_init (GstSchedulerClass * klass); +static void gst_scheduler_init (GstScheduler * sched); +static void gst_scheduler_dispose (GObject * object); static GstObjectClass *parent_class = NULL; @@ -54,26 +54,27 @@ gst_scheduler_get_type (void) NULL }; - _gst_scheduler_type = g_type_register_static (GST_TYPE_OBJECT, "GstScheduler", - &scheduler_info, G_TYPE_FLAG_ABSTRACT); + _gst_scheduler_type = + g_type_register_static (GST_TYPE_OBJECT, "GstScheduler", + &scheduler_info, G_TYPE_FLAG_ABSTRACT); } return _gst_scheduler_type; } static void -gst_scheduler_class_init (GstSchedulerClass *klass) +gst_scheduler_class_init (GstSchedulerClass * klass) { GObjectClass *gobject_class; - - gobject_class = (GObjectClass*) klass; - + + gobject_class = (GObjectClass *) klass; + parent_class = g_type_class_ref (GST_TYPE_OBJECT); gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_scheduler_dispose); } static void -gst_scheduler_init (GstScheduler *sched) +gst_scheduler_init (GstScheduler * sched) { sched->clock_providers = NULL; sched->clock_receivers = NULL; @@ -85,19 +86,17 @@ gst_scheduler_init (GstScheduler *sched) } static void -gst_scheduler_dispose (GObject *object) +gst_scheduler_dispose (GObject * object) { GstScheduler *sched = GST_SCHEDULER (object); /* thse lists should all be NULL */ - GST_DEBUG ( "scheduler %p dispose %p %p %p", - object, - sched->clock_providers, - sched->clock_receivers, - sched->schedulers); + GST_DEBUG ("scheduler %p dispose %p %p %p", + object, + sched->clock_providers, sched->clock_receivers, sched->schedulers); - gst_object_replace ((GstObject **)&sched->current_clock, NULL); - gst_object_replace ((GstObject **)&sched->clock, NULL); + gst_object_replace ((GstObject **) & sched->current_clock, NULL); + gst_object_replace ((GstObject **) & sched->clock, NULL); G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -109,7 +108,7 @@ gst_scheduler_dispose (GObject *object) * Prepare the scheduler. */ void -gst_scheduler_setup (GstScheduler *sched) +gst_scheduler_setup (GstScheduler * sched) { GstSchedulerClass *sclass; @@ -128,7 +127,7 @@ gst_scheduler_setup (GstScheduler *sched) * Reset the schedulers. */ void -gst_scheduler_reset (GstScheduler *sched) +gst_scheduler_reset (GstScheduler * sched) { GstSchedulerClass *sclass; @@ -149,7 +148,7 @@ gst_scheduler_reset (GstScheduler *sched) * Links the srcpad to the given sinkpad. */ void -gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) +gst_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad) { GstSchedulerClass *sclass; @@ -172,7 +171,8 @@ gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) * Unlinks the srcpad from the given sinkpad. */ void -gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) +gst_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad) { GstSchedulerClass *sclass; @@ -196,7 +196,7 @@ gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) * Returns: the pad which received a buffer. */ GstPad * -gst_scheduler_pad_select (GstScheduler *sched, GList *padlist) +gst_scheduler_pad_select (GstScheduler * sched, GList * padlist) { GstSchedulerClass *sclass; @@ -219,7 +219,7 @@ gst_scheduler_pad_select (GstScheduler *sched, GList *padlist) * Add an element to the scheduler. */ void -gst_scheduler_add_element (GstScheduler *sched, GstElement *element) +gst_scheduler_add_element (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -228,8 +228,8 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element) /* if it's already in this scheduler, don't bother doing anything */ if (GST_ELEMENT_SCHED (element) == sched) { - GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p", - GST_ELEMENT_NAME (element), sched); + GST_CAT_DEBUG (GST_CAT_SCHEDULING, "element %s already in scheduler %p", + GST_ELEMENT_NAME (element), sched); return; } @@ -238,11 +238,13 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element) if (gst_element_provides_clock (element)) { sched->clock_providers = g_list_prepend (sched->clock_providers, element); - GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s", GST_ELEMENT_NAME (element)); + GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock provider %s", + GST_ELEMENT_NAME (element)); } if (gst_element_requires_clock (element)) { sched->clock_receivers = g_list_prepend (sched->clock_receivers, element); - GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", GST_ELEMENT_NAME (element)); + GST_CAT_DEBUG (GST_CAT_CLOCK, "added clock receiver %s", + GST_ELEMENT_NAME (element)); } gst_element_set_scheduler (element, sched); @@ -261,7 +263,7 @@ gst_scheduler_add_element (GstScheduler *sched, GstElement *element) * Remove an element from the scheduler. */ void -gst_scheduler_remove_element (GstScheduler *sched, GstElement *element) +gst_scheduler_remove_element (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -276,7 +278,7 @@ gst_scheduler_remove_element (GstScheduler *sched, GstElement *element) if (sclass->remove_element) sclass->remove_element (sched, element); - gst_element_set_scheduler (element, NULL); + gst_element_set_scheduler (element, NULL); } /** @@ -291,7 +293,8 @@ gst_scheduler_remove_element (GstScheduler *sched, GstElement *element) * of the state transition. */ GstElementStateReturn -gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition) +gst_scheduler_state_transition (GstScheduler * sched, GstElement * element, + gint transition) { GstSchedulerClass *sclass; @@ -302,12 +305,14 @@ gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint t switch (transition) { case GST_STATE_READY_TO_PAUSED: { - GstClock *clock = gst_scheduler_get_clock (sched); - GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler READY to PAUSED clock is %p (%s)", clock, - (clock ? GST_OBJECT_NAME (clock) : "nil")); + GstClock *clock = gst_scheduler_get_clock (sched); + + GST_CAT_DEBUG (GST_CAT_CLOCK, + "scheduler READY to PAUSED clock is %p (%s)", clock, + (clock ? GST_OBJECT_NAME (clock) : "nil")); gst_scheduler_set_clock (sched, clock); - break; + break; } } } @@ -330,7 +335,7 @@ gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint t * from a loop based element to a chain based element. */ void -gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element) +gst_scheduler_scheduling_change (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -351,7 +356,7 @@ gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element) * Notifies the scheduler that it has to monitor this scheduler. */ void -gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2) +gst_scheduler_add_scheduler (GstScheduler * sched, GstScheduler * sched2) { GstSchedulerClass *sclass; @@ -381,7 +386,7 @@ gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2) a Notifies the scheduler that it can stop monitoring this scheduler. */ void -gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2) +gst_scheduler_remove_scheduler (GstScheduler * sched, GstScheduler * sched2) { GstSchedulerClass *sclass; @@ -411,7 +416,7 @@ gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2) * Acquire a lock on the given element in the given scheduler. */ void -gst_scheduler_lock_element (GstScheduler *sched, GstElement *element) +gst_scheduler_lock_element (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -432,7 +437,7 @@ gst_scheduler_lock_element (GstScheduler *sched, GstElement *element) * Release the lock on the given element in the given scheduler. */ void -gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element) +gst_scheduler_unlock_element (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -453,7 +458,7 @@ gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element) * Tell the scheduler an element was in error */ void -gst_scheduler_error (GstScheduler *sched, GstElement *element) +gst_scheduler_error (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -477,7 +482,7 @@ gst_scheduler_error (GstScheduler *sched, GstElement *element) * if the scheduler can perform this action itself. */ gboolean -gst_scheduler_yield (GstScheduler *sched, GstElement *element) +gst_scheduler_yield (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -503,7 +508,7 @@ gst_scheduler_yield (GstScheduler *sched, GstElement *element) * function. */ gboolean -gst_scheduler_interrupt (GstScheduler *sched, GstElement *element) +gst_scheduler_interrupt (GstScheduler * sched, GstElement * element) { GstSchedulerClass *sclass; @@ -526,29 +531,28 @@ gst_scheduler_interrupt (GstScheduler *sched, GstElement *element) * * Returns: a GstClock */ -GstClock* -gst_scheduler_get_clock (GstScheduler *sched) +GstClock * +gst_scheduler_get_clock (GstScheduler * sched) { GstClock *clock = NULL; - + /* if we have a fixed clock, use that one */ if (GST_FLAG_IS_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK)) { - clock = sched->clock; + clock = sched->clock; - GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock, - (clock ? GST_OBJECT_NAME (clock) : "nil")); - } - else { + GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock, + (clock ? GST_OBJECT_NAME (clock) : "nil")); + } else { GList *schedulers = sched->schedulers; GList *providers = sched->clock_providers; /* try to get a clock from one of the schedulers we manage first */ while (schedulers) { GstScheduler *scheduler = GST_SCHEDULER (schedulers->data); - + clock = gst_scheduler_get_clock (scheduler); if (clock) - break; + break; schedulers = g_list_next (schedulers); } @@ -563,8 +567,8 @@ gst_scheduler_get_clock (GstScheduler *sched) clock = gst_system_clock_obtain (); } } - GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, sched, "scheduler selected clock %p (%s)", clock, - clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-"); + GST_CAT_LOG_OBJECT (GST_CAT_CLOCK, sched, "scheduler selected clock %p (%s)", + clock, clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-"); return clock; } @@ -579,17 +583,17 @@ gst_scheduler_get_clock (GstScheduler *sched) * to this scheduler. */ void -gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock) +gst_scheduler_use_clock (GstScheduler * sched, GstClock * clock) { g_return_if_fail (sched != NULL); g_return_if_fail (GST_IS_SCHEDULER (sched)); GST_FLAG_SET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK); - gst_object_replace ((GstObject **)&sched->clock, (GstObject *)clock); + gst_object_replace ((GstObject **) & sched->clock, (GstObject *) clock); - GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock, - (clock ? GST_OBJECT_NAME (clock) : "nil")); + GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using fixed clock %p (%s)", clock, + (clock ? GST_OBJECT_NAME (clock) : "nil")); } /** @@ -601,7 +605,7 @@ gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock) * to all the elements managed by the scheduler. */ void -gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock) +gst_scheduler_set_clock (GstScheduler * sched, GstClock * clock) { GList *receivers; GList *schedulers; @@ -612,22 +616,25 @@ gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock) receivers = sched->clock_receivers; schedulers = sched->schedulers; - gst_object_replace ((GstObject **)&sched->current_clock, (GstObject *)clock); + gst_object_replace ((GstObject **) & sched->current_clock, + (GstObject *) clock); while (receivers) { GstElement *element = GST_ELEMENT (receivers->data); - GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on element %s", clock, - (clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element)); - + GST_CAT_DEBUG (GST_CAT_CLOCK, + "scheduler setting clock %p (%s) on element %s", clock, + (clock ? GST_OBJECT_NAME (clock) : "nil"), GST_ELEMENT_NAME (element)); + gst_element_set_clock (element, clock); receivers = g_list_next (receivers); } while (schedulers) { GstScheduler *scheduler = GST_SCHEDULER (schedulers->data); - GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler setting clock %p (%s) on scheduler %p", clock, - (clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler); + GST_CAT_DEBUG (GST_CAT_CLOCK, + "scheduler setting clock %p (%s) on scheduler %p", clock, + (clock ? GST_OBJECT_NAME (clock) : "nil"), scheduler); gst_scheduler_set_clock (scheduler, clock); schedulers = g_list_next (schedulers); } @@ -640,20 +647,20 @@ gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock) * Let the scheduler select a clock automatically. */ void -gst_scheduler_auto_clock (GstScheduler *sched) +gst_scheduler_auto_clock (GstScheduler * sched) { g_return_if_fail (sched != NULL); g_return_if_fail (GST_IS_SCHEDULER (sched)); GST_FLAG_UNSET (sched, GST_SCHEDULER_FLAG_FIXED_CLOCK); - gst_object_replace ((GstObject **)&sched->clock, NULL); + gst_object_replace ((GstObject **) & sched->clock, NULL); GST_CAT_DEBUG (GST_CAT_CLOCK, "scheduler using automatic clock"); } -GstClockReturn gst_clock_id_wait (GstClockID id, - GstClockTimeDiff *jitter); +GstClockReturn gst_clock_id_wait (GstClockID id, GstClockTimeDiff * jitter); + /** * gst_scheduler_clock_wait: * @sched: the scheduler @@ -667,8 +674,8 @@ GstClockReturn gst_clock_id_wait (GstClockID id, * Returns: the status of the operation */ GstClockReturn -gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, - GstClockID id, GstClockTimeDiff *jitter) +gst_scheduler_clock_wait (GstScheduler * sched, GstElement * element, + GstClockID id, GstClockTimeDiff * jitter) { GstSchedulerClass *sclass; @@ -679,7 +686,7 @@ gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, if (sclass->clock_wait) return sclass->clock_wait (sched, element, id, jitter); - else + else return gst_clock_id_wait (id, jitter); } @@ -692,7 +699,7 @@ gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, * Returns: a boolean indicating something usefull has happened. */ gboolean -gst_scheduler_iterate (GstScheduler *sched) +gst_scheduler_iterate (GstScheduler * sched) { GstSchedulerClass *sclass; gboolean res = FALSE; @@ -716,7 +723,7 @@ gst_scheduler_iterate (GstScheduler *sched) * Dump the state of the scheduler */ void -gst_scheduler_show (GstScheduler *sched) +gst_scheduler_show (GstScheduler * sched) { GstSchedulerClass *sclass; @@ -732,14 +739,15 @@ gst_scheduler_show (GstScheduler *sched) * Factory stuff starts here * */ -static void gst_scheduler_factory_class_init (GstSchedulerFactoryClass *klass); -static void gst_scheduler_factory_init (GstSchedulerFactory *factory); +static void gst_scheduler_factory_class_init (GstSchedulerFactoryClass * klass); +static void gst_scheduler_factory_init (GstSchedulerFactory * factory); static GstPluginFeatureClass *factory_parent_class = NULL; + /* static guint gst_scheduler_factory_signals[LAST_SIGNAL] = { 0 }; */ -GType -gst_scheduler_factory_get_type (void) +GType +gst_scheduler_factory_get_type (void) { static GType schedulerfactory_type = 0; @@ -751,27 +759,27 @@ gst_scheduler_factory_get_type (void) (GClassInitFunc) gst_scheduler_factory_class_init, NULL, NULL, - sizeof(GstSchedulerFactory), + sizeof (GstSchedulerFactory), 0, (GInstanceInitFunc) gst_scheduler_factory_init, NULL }; - schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstSchedulerFactory", &schedulerfactory_info, 0); + schedulerfactory_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, + "GstSchedulerFactory", &schedulerfactory_info, 0); } return schedulerfactory_type; } static void -gst_scheduler_factory_class_init (GstSchedulerFactoryClass *klass) +gst_scheduler_factory_class_init (GstSchedulerFactoryClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; GstPluginFeatureClass *gstpluginfeature_class; - gobject_class = (GObjectClass*)klass; - gstobject_class = (GstObjectClass*)klass; - gstpluginfeature_class = (GstPluginFeatureClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstpluginfeature_class = (GstPluginFeatureClass *) klass; factory_parent_class = g_type_class_ref (GST_TYPE_PLUGIN_FEATURE); @@ -786,10 +794,10 @@ gst_scheduler_factory_class_init (GstSchedulerFactoryClass *klass) } static void -gst_scheduler_factory_init (GstSchedulerFactory *factory) +gst_scheduler_factory_init (GstSchedulerFactory * factory) { } - + /** * gst_scheduler_factory_new: @@ -801,8 +809,9 @@ gst_scheduler_factory_init (GstSchedulerFactory *factory) * * Returns: a new #GstSchedulerFactory. */ -GstSchedulerFactory* -gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type) +GstSchedulerFactory * +gst_scheduler_factory_new (const gchar * name, const gchar * longdesc, + GType type) { GstSchedulerFactory *factory; @@ -811,10 +820,10 @@ gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type) factory = gst_scheduler_factory_find (name); if (!factory) { - factory = GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL)); + factory = + GST_SCHEDULER_FACTORY (g_object_new (GST_TYPE_SCHEDULER_FACTORY, NULL)); GST_PLUGIN_FEATURE_NAME (factory) = g_strdup (name); - } - else { + } else { g_free (factory->longdesc); } @@ -831,7 +840,7 @@ gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type) * Removes the scheduler from the global list. */ void -gst_scheduler_factory_destroy (GstSchedulerFactory *factory) +gst_scheduler_factory_destroy (GstSchedulerFactory * factory) { g_return_if_fail (factory != NULL); @@ -846,8 +855,8 @@ gst_scheduler_factory_destroy (GstSchedulerFactory *factory) * * Returns: #GstSchedulerFactory if found, NULL otherwise */ -GstSchedulerFactory* -gst_scheduler_factory_find (const gchar *name) +GstSchedulerFactory * +gst_scheduler_factory_find (const gchar * name) { GstPluginFeature *feature; @@ -874,8 +883,9 @@ gst_scheduler_factory_find (const gchar *name) * * Returns: A new #GstScheduler instance with a reference count of %1. */ -GstScheduler* -gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent) +GstScheduler * +gst_scheduler_factory_create (GstSchedulerFactory * factory, + GstElement * parent) { GstScheduler *sched = NULL; @@ -911,16 +921,15 @@ gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent) * * Returns: A new #GstScheduler instance with a reference count of %1. */ -GstScheduler* -gst_scheduler_factory_make (const gchar *name, GstElement *parent) +GstScheduler * +gst_scheduler_factory_make (const gchar * name, GstElement * parent) { GstSchedulerFactory *factory; const gchar *default_name = gst_scheduler_factory_get_default_name (); if (name) factory = gst_scheduler_factory_find (name); - else - { + else { /* FIXME: do better error handling */ if (default_name == NULL) g_error ("No default scheduler name - do you have a registry ?"); @@ -940,7 +949,7 @@ gst_scheduler_factory_make (const gchar *name, GstElement *parent) * Set the default schedulerfactory name. */ void -gst_scheduler_factory_set_default_name (const gchar* name) +gst_scheduler_factory_set_default_name (const gchar * name) { g_free (_default_name); @@ -954,7 +963,7 @@ gst_scheduler_factory_set_default_name (const gchar* name) * * Returns: the name of the default scheduler. */ -const gchar* +const gchar * gst_scheduler_factory_get_default_name (void) { return _default_name; diff --git a/gst/gstscheduler.h b/gst/gstscheduler.h index 9233c526c..70f678167 100644 --- a/gst/gstscheduler.h +++ b/gst/gstscheduler.h @@ -29,20 +29,19 @@ #include G_BEGIN_DECLS - #define GST_TYPE_SCHEDULER (gst_scheduler_get_type ()) #define GST_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SCHEDULER, GstScheduler)) #define GST_IS_SCHEDULER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SCHEDULER)) #define GST_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SCHEDULER,GstSchedulerClass)) #define GST_IS_SCHEDULER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SCHEDULER)) #define GST_SCHEDULER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SCHEDULER, GstSchedulerClass)) - -typedef enum { + typedef enum +{ /* this scheduler works with a fixed clock */ - GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST, + GST_SCHEDULER_FLAG_FIXED_CLOCK = GST_OBJECT_FLAG_LAST, /* padding */ - GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 + GST_SCHEDULER_FLAG_LAST = GST_OBJECT_FLAG_LAST + 4 } GstSchedulerFlags; #define GST_SCHEDULER_PARENT(sched) ((sched)->parent) @@ -50,93 +49,102 @@ typedef enum { /*typedef struct _GstScheduler GstScheduler; */ /*typedef struct _GstSchedulerClass GstSchedulerClass; */ -typedef enum { +typedef enum +{ GST_SCHEDULER_STATE_NONE, GST_SCHEDULER_STATE_RUNNING, GST_SCHEDULER_STATE_STOPPED, GST_SCHEDULER_STATE_ERROR } GstSchedulerState; -struct _GstScheduler { - GstObject object; +struct _GstScheduler +{ + GstObject object; - GstElement *parent; - GstScheduler *parent_sched; + GstElement *parent; + GstScheduler *parent_sched; - GstSchedulerState state; - GstClock *clock; - GstClock *current_clock; + GstSchedulerState state; + GstClock *clock; + GstClock *current_clock; - GList *clock_providers; - GList *clock_receivers; + GList *clock_providers; + GList *clock_receivers; - GList *schedulers; + GList *schedulers; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstSchedulerClass { +struct _GstSchedulerClass +{ GstObjectClass parent_class; /* virtual methods */ - void (*setup) (GstScheduler *sched); - void (*reset) (GstScheduler *sched); - void (*add_element) (GstScheduler *sched, GstElement *element); - void (*remove_element) (GstScheduler *sched, GstElement *element); - void (*add_scheduler) (GstScheduler *sched, GstScheduler *sched2); - void (*remove_scheduler) (GstScheduler *sched, GstScheduler *sched2); - GstElementStateReturn (*state_transition) (GstScheduler *sched, GstElement *element, gint transition); - void (*scheduling_change) (GstScheduler *sched, GstElement *element); - void (*lock_element) (GstScheduler *sched, GstElement *element); - void (*unlock_element) (GstScheduler *sched, GstElement *element); - gboolean (*yield) (GstScheduler *sched, GstElement *element); - gboolean (*interrupt) (GstScheduler *sched, GstElement *element); - void (*error) (GstScheduler *sched, GstElement *element); - void (*pad_link) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); - void (*pad_unlink) (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); - void (*pad_select) (GstScheduler *sched, GList *padlist); - GstClockReturn (*clock_wait) (GstScheduler *sched, GstElement *element, - GstClockID id, GstClockTimeDiff *jitter); - GstSchedulerState (*iterate) (GstScheduler *sched); + void (*setup) (GstScheduler * sched); + void (*reset) (GstScheduler * sched); + void (*add_element) (GstScheduler * sched, GstElement * element); + void (*remove_element) (GstScheduler * sched, GstElement * element); + void (*add_scheduler) (GstScheduler * sched, GstScheduler * sched2); + void (*remove_scheduler) (GstScheduler * sched, GstScheduler * sched2); + GstElementStateReturn (*state_transition) (GstScheduler * sched, + GstElement * element, gint transition); + void (*scheduling_change) (GstScheduler * sched, GstElement * element); + void (*lock_element) (GstScheduler * sched, GstElement * element); + void (*unlock_element) (GstScheduler * sched, GstElement * element); + gboolean (*yield) (GstScheduler * sched, GstElement * element); + gboolean (*interrupt) (GstScheduler * sched, GstElement * element); + void (*error) (GstScheduler * sched, GstElement * element); + void (*pad_link) (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad); + void (*pad_unlink) (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad); + void (*pad_select) (GstScheduler * sched, GList * padlist); + GstClockReturn (*clock_wait) (GstScheduler * sched, GstElement * element, + GstClockID id, GstClockTimeDiff * jitter); + GstSchedulerState (*iterate) (GstScheduler * sched); /* for debugging */ - void (*show) (GstScheduler *sched); + void (*show) (GstScheduler * sched); /* signals */ - void (*object_sync) (GstScheduler *sched, GstClock *clock, GstObject *object, - GstClockID id); + void (*object_sync) (GstScheduler * sched, GstClock * clock, + GstObject * object, GstClockID id); gpointer _gst_reserved[GST_PADDING]; }; -GType gst_scheduler_get_type (void); - - -void gst_scheduler_setup (GstScheduler *sched); -void gst_scheduler_reset (GstScheduler *sched); -void gst_scheduler_add_element (GstScheduler *sched, GstElement *element); -void gst_scheduler_remove_element (GstScheduler *sched, GstElement *element); -void gst_scheduler_add_scheduler (GstScheduler *sched, GstScheduler *sched2); -void gst_scheduler_remove_scheduler (GstScheduler *sched, GstScheduler *sched2); -GstElementStateReturn gst_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition); -void gst_scheduler_scheduling_change (GstScheduler *sched, GstElement *element); -void gst_scheduler_lock_element (GstScheduler *sched, GstElement *element); -void gst_scheduler_unlock_element (GstScheduler *sched, GstElement *element); -gboolean gst_scheduler_yield (GstScheduler *sched, GstElement *element); -gboolean gst_scheduler_interrupt (GstScheduler *sched, GstElement *element); -void gst_scheduler_error (GstScheduler *sched, GstElement *element); -void gst_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); -void gst_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); -GstPad* gst_scheduler_pad_select (GstScheduler *sched, GList *padlist); -GstClockReturn gst_scheduler_clock_wait (GstScheduler *sched, GstElement *element, - GstClockID id, GstClockTimeDiff *jitter); -gboolean gst_scheduler_iterate (GstScheduler *sched); - -void gst_scheduler_use_clock (GstScheduler *sched, GstClock *clock); -void gst_scheduler_set_clock (GstScheduler *sched, GstClock *clock); -GstClock* gst_scheduler_get_clock (GstScheduler *sched); -void gst_scheduler_auto_clock (GstScheduler *sched); - -void gst_scheduler_show (GstScheduler *sched); +GType gst_scheduler_get_type (void); + + +void gst_scheduler_setup (GstScheduler * sched); +void gst_scheduler_reset (GstScheduler * sched); +void gst_scheduler_add_element (GstScheduler * sched, GstElement * element); +void gst_scheduler_remove_element (GstScheduler * sched, GstElement * element); +void gst_scheduler_add_scheduler (GstScheduler * sched, GstScheduler * sched2); +void gst_scheduler_remove_scheduler (GstScheduler * sched, + GstScheduler * sched2); +GstElementStateReturn gst_scheduler_state_transition (GstScheduler * sched, + GstElement * element, gint transition); +void gst_scheduler_scheduling_change (GstScheduler * sched, + GstElement * element); +void gst_scheduler_lock_element (GstScheduler * sched, GstElement * element); +void gst_scheduler_unlock_element (GstScheduler * sched, GstElement * element); +gboolean gst_scheduler_yield (GstScheduler * sched, GstElement * element); +gboolean gst_scheduler_interrupt (GstScheduler * sched, GstElement * element); +void gst_scheduler_error (GstScheduler * sched, GstElement * element); +void gst_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad); +void gst_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad); +GstPad *gst_scheduler_pad_select (GstScheduler * sched, GList * padlist); +GstClockReturn gst_scheduler_clock_wait (GstScheduler * sched, + GstElement * element, GstClockID id, GstClockTimeDiff * jitter); +gboolean gst_scheduler_iterate (GstScheduler * sched); + +void gst_scheduler_use_clock (GstScheduler * sched, GstClock * clock); +void gst_scheduler_set_clock (GstScheduler * sched, GstClock * clock); +GstClock *gst_scheduler_get_clock (GstScheduler * sched); +void gst_scheduler_auto_clock (GstScheduler * sched); + +void gst_scheduler_show (GstScheduler * sched); /* * creating schedulers @@ -155,35 +163,39 @@ void gst_scheduler_show (GstScheduler *sched); typedef struct _GstSchedulerFactory GstSchedulerFactory; typedef struct _GstSchedulerFactoryClass GstSchedulerFactoryClass; -struct _GstSchedulerFactory { +struct _GstSchedulerFactory +{ GstPluginFeature feature; - gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */ - GType type; /* unique GType of the scheduler */ + gchar *longdesc; /* long description of the scheduler (well, don't overdo it..) */ + GType type; /* unique GType of the scheduler */ gpointer _gst_reserved[GST_PADDING]; }; -struct _GstSchedulerFactoryClass { +struct _GstSchedulerFactoryClass +{ GstPluginFeatureClass parent; gpointer _gst_reserved[GST_PADDING]; }; -GType gst_scheduler_factory_get_type (void); +GType gst_scheduler_factory_get_type (void); -GstSchedulerFactory* gst_scheduler_factory_new (const gchar *name, const gchar *longdesc, GType type); -void gst_scheduler_factory_destroy (GstSchedulerFactory *factory); +GstSchedulerFactory *gst_scheduler_factory_new (const gchar * name, + const gchar * longdesc, GType type); +void gst_scheduler_factory_destroy (GstSchedulerFactory * factory); -GstSchedulerFactory* gst_scheduler_factory_find (const gchar *name); +GstSchedulerFactory *gst_scheduler_factory_find (const gchar * name); -GstScheduler* gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent); -GstScheduler* gst_scheduler_factory_make (const gchar *name, GstElement *parent); +GstScheduler *gst_scheduler_factory_create (GstSchedulerFactory * factory, + GstElement * parent); +GstScheduler *gst_scheduler_factory_make (const gchar * name, + GstElement * parent); -void gst_scheduler_factory_set_default_name (const gchar* name); -G_CONST_RETURN gchar* gst_scheduler_factory_get_default_name (void); +void gst_scheduler_factory_set_default_name (const gchar * name); +G_CONST_RETURN gchar *gst_scheduler_factory_get_default_name (void); G_END_DECLS - #endif /* __GST_SCHEDULER_H__ */ diff --git a/gst/gststructure.c b/gst/gststructure.c index 025ee4a1b..dc9e9d833 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -30,7 +30,8 @@ typedef struct _GstStructureField GstStructureField; -struct _GstStructureField { +struct _GstStructureField +{ GQuark name; GValue value; }; @@ -38,36 +39,34 @@ struct _GstStructureField { #define GST_STRUCTURE_FIELD(structure, index) \ &g_array_index((structure)->fields, GstStructureField, (index)) -static void gst_structure_set_field (GstStructure *structure, - GstStructureField *field); -static GstStructureField * gst_structure_get_field (const GstStructure *structure, - const gchar *fieldname); -static GstStructureField * gst_structure_id_get_field (const GstStructure *structure, - GQuark field); -static void gst_structure_transform_to_string (const GValue *src_value, - GValue *dest_value); -static GstStructure * gst_structure_copy_conditional (const GstStructure *structure); -static gboolean gst_structure_parse_value (gchar *str, - gchar **after, - GValue *value, - GType default_type); -static gboolean gst_structure_parse_simple_string (gchar *s, - gchar **end); +static void gst_structure_set_field (GstStructure * structure, + GstStructureField * field); +static GstStructureField *gst_structure_get_field (const GstStructure * + structure, const gchar * fieldname); +static GstStructureField *gst_structure_id_get_field (const GstStructure * + structure, GQuark field); +static void gst_structure_transform_to_string (const GValue * src_value, + GValue * dest_value); +static GstStructure *gst_structure_copy_conditional (const GstStructure * + structure); +static gboolean gst_structure_parse_value (gchar * str, gchar ** after, + GValue * value, GType default_type); +static gboolean gst_structure_parse_simple_string (gchar * s, gchar ** end); GType -gst_structure_get_type(void) +gst_structure_get_type (void) { static GType gst_structure_type; if (!gst_structure_type) { - gst_structure_type = g_boxed_type_register_static("GstStructure", - (GBoxedCopyFunc) gst_structure_copy_conditional, - (GBoxedFreeFunc) gst_structure_free); - - g_value_register_transform_func(gst_structure_type, G_TYPE_STRING, - gst_structure_transform_to_string); + gst_structure_type = g_boxed_type_register_static ("GstStructure", + (GBoxedCopyFunc) gst_structure_copy_conditional, + (GBoxedFreeFunc) gst_structure_free); + + g_value_register_transform_func (gst_structure_type, G_TYPE_STRING, + gst_structure_transform_to_string); } - + return gst_structure_type; } @@ -84,11 +83,11 @@ gst_structure_id_empty_new (GQuark quark) { GstStructure *structure; - g_return_val_if_fail(quark != 0, NULL); + g_return_val_if_fail (quark != 0, NULL); - structure = g_new0(GstStructure, 1); + structure = g_new0 (GstStructure, 1); structure->name = quark; - structure->fields = g_array_new(FALSE,TRUE,sizeof(GstStructureField)); + structure->fields = g_array_new (FALSE, TRUE, sizeof (GstStructureField)); return structure; } @@ -102,15 +101,15 @@ gst_structure_id_empty_new (GQuark quark) * Returns: a new, empty #GstStructure */ GstStructure * -gst_structure_empty_new (const gchar *name) +gst_structure_empty_new (const gchar * name) { GstStructure *structure; - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); - structure = g_new0(GstStructure, 1); - structure->name = g_quark_from_string(name); - structure->fields = g_array_new(FALSE,TRUE,sizeof(GstStructureField)); + structure = g_new0 (GstStructure, 1); + structure->name = g_quark_from_string (name); + structure->fields = g_array_new (FALSE, TRUE, sizeof (GstStructureField)); return structure; } @@ -128,19 +127,19 @@ gst_structure_empty_new (const gchar *name) * * Returns: a new #GstStructure */ -GstStructure *gst_structure_new(const gchar *name, - const gchar *firstfield, ...) +GstStructure * +gst_structure_new (const gchar * name, const gchar * firstfield, ...) { GstStructure *structure; va_list varargs; - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); - va_start(varargs, firstfield); + va_start (varargs, firstfield); - structure = gst_structure_new_valist(name,firstfield,varargs); + structure = gst_structure_new_valist (name, firstfield, varargs); - va_end(varargs); + va_end (varargs); return structure; } @@ -158,16 +157,15 @@ GstStructure *gst_structure_new(const gchar *name, * Returns: a new #GstStructure */ GstStructure * -gst_structure_new_valist (const gchar *name, - const gchar *firstfield, - va_list varargs) +gst_structure_new_valist (const gchar * name, + const gchar * firstfield, va_list varargs) { GstStructure *structure; - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); - structure = gst_structure_empty_new(name); - gst_structure_set_valist(structure, firstfield, varargs); + structure = gst_structure_empty_new (name); + gst_structure_set_valist (structure, firstfield, varargs); return structure; } @@ -181,25 +179,25 @@ gst_structure_new_valist (const gchar *name, * Returns: a new #GstStructure. */ GstStructure * -gst_structure_copy (const GstStructure *structure) +gst_structure_copy (const GstStructure * structure) { GstStructure *new_structure; GstStructureField *field; int i; - g_return_val_if_fail(structure != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); - new_structure = gst_structure_empty_new(g_quark_to_string(structure->name)); + new_structure = gst_structure_empty_new (g_quark_to_string (structure->name)); new_structure->name = structure->name; - for(i=0;ifields->len;i++){ + for (i = 0; i < structure->fields->len; i++) { GstStructureField new_field = { 0 }; - field = GST_STRUCTURE_FIELD(structure, i); + field = GST_STRUCTURE_FIELD (structure, i); new_field.name = field->name; gst_value_init_and_copy (&new_field.value, &field->value); - g_array_append_val(new_structure->fields, new_field); + g_array_append_val (new_structure->fields, new_field); } return new_structure; @@ -212,24 +210,24 @@ gst_structure_copy (const GstStructure *structure) * Frees a #GstStructure and all its fields and values. */ void -gst_structure_free (GstStructure *structure) +gst_structure_free (GstStructure * structure) { GstStructureField *field; int i; - g_return_if_fail(structure != NULL); + g_return_if_fail (structure != NULL); - for(i=0;ifields->len;i++){ - field = GST_STRUCTURE_FIELD(structure, i); + for (i = 0; i < structure->fields->len; i++) { + field = GST_STRUCTURE_FIELD (structure, i); - if(G_IS_VALUE(&field->value)){ - g_value_unset(&field->value); + if (G_IS_VALUE (&field->value)) { + g_value_unset (&field->value); } } #ifdef USE_POISONING - memset (structure, 0xff, sizeof(GstStructure)); + memset (structure, 0xff, sizeof (GstStructure)); #endif - g_free(structure); + g_free (structure); } /** @@ -241,11 +239,11 @@ gst_structure_free (GstStructure *structure) * Returns: the name of the structure. */ const gchar * -gst_structure_get_name (const GstStructure *structure) +gst_structure_get_name (const GstStructure * structure) { - g_return_val_if_fail(structure != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); - return g_quark_to_string(structure->name); + return g_quark_to_string (structure->name); } /** @@ -257,12 +255,12 @@ gst_structure_get_name (const GstStructure *structure) * provided is copied before being used. */ void -gst_structure_set_name (GstStructure *structure, const gchar *name) +gst_structure_set_name (GstStructure * structure, const gchar * name) { - g_return_if_fail(structure != NULL); - g_return_if_fail(name != NULL); + g_return_if_fail (structure != NULL); + g_return_if_fail (name != NULL); - structure->name = g_quark_from_string(name); + structure->name = g_quark_from_string (name); } /** @@ -276,19 +274,18 @@ gst_structure_set_name (GstStructure *structure, const gchar *name) * value is freed. */ void -gst_structure_id_set_value(GstStructure *structure, - GQuark field, - const GValue *value) +gst_structure_id_set_value (GstStructure * structure, + GQuark field, const GValue * value) { - GstStructureField gsfield = { 0, { 0, } }; + GstStructureField gsfield = { 0, {0,} }; - g_return_if_fail(structure != NULL); - g_return_if_fail(G_IS_VALUE(value)); + g_return_if_fail (structure != NULL); + g_return_if_fail (G_IS_VALUE (value)); gsfield.name = field; gst_value_init_and_copy (&gsfield.value, value); - gst_structure_set_field(structure, &gsfield); + gst_structure_set_field (structure, &gsfield); } /** @@ -302,15 +299,15 @@ gst_structure_id_set_value(GstStructure *structure, * value is freed. */ void -gst_structure_set_value(GstStructure *structure, - const gchar *fieldname, - const GValue *value) +gst_structure_set_value (GstStructure * structure, + const gchar * fieldname, const GValue * value) { - g_return_if_fail(structure != NULL); - g_return_if_fail(fieldname != NULL); - g_return_if_fail(G_IS_VALUE(value)); + g_return_if_fail (structure != NULL); + g_return_if_fail (fieldname != NULL); + g_return_if_fail (G_IS_VALUE (value)); - gst_structure_id_set_value(structure, g_quark_from_string(fieldname), value); + gst_structure_id_set_value (structure, g_quark_from_string (fieldname), + value); } /** @@ -324,18 +321,17 @@ gst_structure_set_value(GstStructure *structure, * (as a GType), value. The last variable argument should be NULL. */ void -gst_structure_set(GstStructure *structure, - const gchar *field, ...) +gst_structure_set (GstStructure * structure, const gchar * field, ...) { va_list varargs; - g_return_if_fail(structure != NULL); + g_return_if_fail (structure != NULL); - va_start(varargs, field); + va_start (varargs, field); - gst_structure_set_valist(structure,field,varargs); + gst_structure_set_valist (structure, field, varargs); - va_end(varargs); + va_end (varargs); } /** @@ -347,70 +343,76 @@ gst_structure_set(GstStructure *structure, * va_list form of #gst_structure_set. */ void -gst_structure_set_valist(GstStructure *structure, - const gchar *fieldname, - va_list varargs) +gst_structure_set_valist (GstStructure * structure, + const gchar * fieldname, va_list varargs) { GType type; int i; double d; char *s; - g_return_if_fail(structure != NULL); + g_return_if_fail (structure != NULL); - while(fieldname){ + while (fieldname) { GstStructureField field = { 0 }; - field.name = g_quark_from_string(fieldname); + field.name = g_quark_from_string (fieldname); - type = va_arg (varargs, GType); + type = va_arg (varargs, GType); - switch(type){ + switch (type) { case G_TYPE_INT: - i = va_arg(varargs, int); - g_value_init(&field.value, G_TYPE_INT); - g_value_set_int(&field.value, i); + i = va_arg (varargs, int); + + g_value_init (&field.value, G_TYPE_INT); + g_value_set_int (&field.value, i); break; case G_TYPE_DOUBLE: - d = va_arg(varargs, double); - g_value_init(&field.value, G_TYPE_DOUBLE); - g_value_set_double(&field.value, d); + d = va_arg (varargs, double); + + g_value_init (&field.value, G_TYPE_DOUBLE); + g_value_set_double (&field.value, d); break; case G_TYPE_BOOLEAN: - i = va_arg(varargs, int); - g_value_init(&field.value, G_TYPE_BOOLEAN); - g_value_set_boolean(&field.value, i); + i = va_arg (varargs, int); + + g_value_init (&field.value, G_TYPE_BOOLEAN); + g_value_set_boolean (&field.value, i); break; case G_TYPE_STRING: - s = va_arg(varargs, char *); - g_value_init(&field.value, G_TYPE_STRING); - g_value_set_string(&field.value, s); + s = va_arg (varargs, char *); + + g_value_init (&field.value, G_TYPE_STRING); + g_value_set_string (&field.value, s); break; default: - if(type == GST_TYPE_FOURCC){ - i = va_arg(varargs, int); - g_value_init(&field.value, GST_TYPE_FOURCC); - gst_value_set_fourcc(&field.value, i); - } else if (type == GST_TYPE_INT_RANGE){ - int min, max; - min = va_arg(varargs, int); - max = va_arg(varargs, int); - g_value_init(&field.value, GST_TYPE_INT_RANGE); - gst_value_set_int_range(&field.value, min, max); - } else if (type == GST_TYPE_DOUBLE_RANGE){ - double min, max; - min = va_arg(varargs, double); - max = va_arg(varargs, double); - g_value_init(&field.value, GST_TYPE_DOUBLE_RANGE); - gst_value_set_double_range(&field.value, min, max); + if (type == GST_TYPE_FOURCC) { + i = va_arg (varargs, int); + + g_value_init (&field.value, GST_TYPE_FOURCC); + gst_value_set_fourcc (&field.value, i); + } else if (type == GST_TYPE_INT_RANGE) { + int min, max; + min = va_arg (varargs, int); + max = va_arg (varargs, int); + + g_value_init (&field.value, GST_TYPE_INT_RANGE); + gst_value_set_int_range (&field.value, min, max); + } else if (type == GST_TYPE_DOUBLE_RANGE) { + double min, max; + min = va_arg (varargs, double); + max = va_arg (varargs, double); + + g_value_init (&field.value, GST_TYPE_DOUBLE_RANGE); + gst_value_set_double_range (&field.value, min, max); } else { - g_critical("unimplemented vararg field type %d\n", (int)type); - return; + g_critical ("unimplemented vararg field type %d\n", (int) type); + return; } break; } - gst_structure_set_field(structure, &field); + gst_structure_set_field (structure, &field); fieldname = va_arg (varargs, gchar *); } @@ -430,23 +432,22 @@ gst_structure_set_valist(GstStructure *structure, * #gst_structure_set() is recommended instead of this one. */ static void -gst_structure_set_field(GstStructure *structure, - GstStructureField *field) +gst_structure_set_field (GstStructure * structure, GstStructureField * field) { GstStructureField *f; int i; - for(i=0;ifields->len;i++){ - f = GST_STRUCTURE_FIELD(structure, i); + for (i = 0; i < structure->fields->len; i++) { + f = GST_STRUCTURE_FIELD (structure, i); - if(f->name == field->name){ - g_value_unset(&f->value); - memcpy(f,field,sizeof(GstStructureField)); + if (f->name == field->name) { + g_value_unset (&f->value); + memcpy (f, field, sizeof (GstStructureField)); return; } } - g_array_append_val(structure->fields, *field); + g_array_append_val (structure->fields, *field); } /* FIXME: is this private ? if so remove gtk-doc @@ -460,18 +461,18 @@ gst_structure_set_field(GstStructure *structure, * Returns: the #GstStructureField with the given ID */ static GstStructureField * -gst_structure_id_get_field(const GstStructure *structure, - GQuark field_id) +gst_structure_id_get_field (const GstStructure * structure, GQuark field_id) { GstStructureField *field; int i; - g_return_val_if_fail(structure != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); - for(i=0;ifields->len;i++){ - field = GST_STRUCTURE_FIELD(structure, i); + for (i = 0; i < structure->fields->len; i++) { + field = GST_STRUCTURE_FIELD (structure, i); - if(field->name == field_id) return field; + if (field->name == field_id) + return field; } return NULL; @@ -488,14 +489,14 @@ gst_structure_id_get_field(const GstStructure *structure, * Returns: the #GstStructureField with the given name */ static GstStructureField * -gst_structure_get_field(const GstStructure *structure, - const gchar *fieldname) +gst_structure_get_field (const GstStructure * structure, + const gchar * fieldname) { - g_return_val_if_fail(structure != NULL, NULL); - g_return_val_if_fail(fieldname != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); + g_return_val_if_fail (fieldname != NULL, NULL); - return gst_structure_id_get_field(structure, - g_quark_from_string(fieldname)); + return gst_structure_id_get_field (structure, + g_quark_from_string (fieldname)); } /** @@ -508,16 +509,17 @@ gst_structure_get_field(const GstStructure *structure, * Returns: the #GValue corresponding to the field with the given name. */ const GValue * -gst_structure_get_value(const GstStructure *structure, - const gchar *fieldname) +gst_structure_get_value (const GstStructure * structure, + const gchar * fieldname) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, NULL); - g_return_val_if_fail(fieldname != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); + g_return_val_if_fail (fieldname != NULL, NULL); - field = gst_structure_get_field(structure, fieldname); - if(field == NULL) return NULL; + field = gst_structure_get_field (structure, fieldname); + if (field == NULL) + return NULL; return &field->value; } @@ -533,14 +535,15 @@ gst_structure_get_value(const GstStructure *structure, * identifier. */ const GValue * -gst_structure_id_get_value(const GstStructure *structure, GQuark field) +gst_structure_id_get_value (const GstStructure * structure, GQuark field) { GstStructureField *gsfield; - g_return_val_if_fail(structure != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); - gsfield = gst_structure_id_get_field(structure, field); - if(gsfield == NULL) return NULL; + gsfield = gst_structure_id_get_field (structure, field); + if (gsfield == NULL) + return NULL; return &gsfield->value; } @@ -554,26 +557,25 @@ gst_structure_id_get_value(const GstStructure *structure, GQuark field) * name does not exist, the structure is unchanged. */ void -gst_structure_remove_field(GstStructure *structure, - const gchar *fieldname) +gst_structure_remove_field (GstStructure * structure, const gchar * fieldname) { GstStructureField *field; GQuark id; int i; - g_return_if_fail(structure != NULL); - g_return_if_fail(fieldname != NULL); + g_return_if_fail (structure != NULL); + g_return_if_fail (fieldname != NULL); - id = g_quark_from_string(fieldname); + id = g_quark_from_string (fieldname); - for(i=0;ifields->len;i++){ - field = GST_STRUCTURE_FIELD(structure, i); + for (i = 0; i < structure->fields->len; i++) { + field = GST_STRUCTURE_FIELD (structure, i); - if(field->name == id){ - if(G_IS_VALUE(&field->value)){ - g_value_unset(&field->value); + if (field->name == id) { + if (G_IS_VALUE (&field->value)) { + g_value_unset (&field->value); } - structure->fields = g_array_remove_index(structure->fields, i); + structure->fields = g_array_remove_index (structure->fields, i); return; } } @@ -588,20 +590,20 @@ gst_structure_remove_field(GstStructure *structure, * Removes the field with the given names. If a field does not exist, the * argument is ignored. */ -void -gst_structure_remove_fields(GstStructure *structure, - const gchar *fieldname, ...) +void +gst_structure_remove_fields (GstStructure * structure, + const gchar * fieldname, ...) { va_list varargs; g_return_if_fail (structure != NULL); g_return_if_fail (fieldname != NULL); - va_start(varargs, fieldname); + va_start (varargs, fieldname); gst_structure_remove_fields_valist (structure, fieldname, varargs); - va_end(varargs); + va_end (varargs); } /** @@ -613,18 +615,18 @@ gst_structure_remove_fields(GstStructure *structure, * Removes the field with the given names. If a field does not exist, the * argument is ignored. */ -void -gst_structure_remove_fields_valist (GstStructure *structure, - const gchar *fieldname, - va_list varargs) +void +gst_structure_remove_fields_valist (GstStructure * structure, + const gchar * fieldname, va_list varargs) { gchar *field = (gchar *) fieldname; + g_return_if_fail (structure != NULL); g_return_if_fail (fieldname != NULL); while (field) { gst_structure_remove_field (structure, field); - field = va_arg (varargs, char *); + field = va_arg (varargs, char *); } } @@ -635,18 +637,18 @@ gst_structure_remove_fields_valist (GstStructure *structure, * Removes all fields in a GstStructure. */ void -gst_structure_remove_all_fields (GstStructure *structure) +gst_structure_remove_all_fields (GstStructure * structure) { GstStructureField *field; int i; - g_return_if_fail(structure != NULL); + g_return_if_fail (structure != NULL); - for (i = structure->fields->len - 1; i >= 0; i-- ) { - field = GST_STRUCTURE_FIELD(structure, i); + for (i = structure->fields->len - 1; i >= 0; i--) { + field = GST_STRUCTURE_FIELD (structure, i); if (G_IS_VALUE (&field->value)) { - g_value_unset(&field->value); + g_value_unset (&field->value); } structure->fields = g_array_remove_index (structure->fields, i); } @@ -664,18 +666,19 @@ gst_structure_remove_all_fields (GstStructure *structure) * Returns: the #GValue of the field */ GType -gst_structure_get_field_type (const GstStructure *structure, - const gchar *fieldname) +gst_structure_get_field_type (const GstStructure * structure, + const gchar * fieldname) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, G_TYPE_INVALID); - g_return_val_if_fail(fieldname != NULL, G_TYPE_INVALID); + g_return_val_if_fail (structure != NULL, G_TYPE_INVALID); + g_return_val_if_fail (fieldname != NULL, G_TYPE_INVALID); - field = gst_structure_get_field(structure, fieldname); - if(field == NULL) return G_TYPE_INVALID; + field = gst_structure_get_field (structure, fieldname); + if (field == NULL) + return G_TYPE_INVALID; - return G_VALUE_TYPE(&field->value); + return G_VALUE_TYPE (&field->value); } /** @@ -687,9 +690,9 @@ gst_structure_get_field_type (const GstStructure *structure, * Returns: the number of fields in the structure */ gint -gst_structure_n_fields (const GstStructure *structure) +gst_structure_n_fields (const GstStructure * structure) { - g_return_val_if_fail(structure != NULL, 0); + g_return_val_if_fail (structure != NULL, 0); return structure->fields->len; } @@ -706,19 +709,19 @@ gst_structure_n_fields (const GstStructure *structure) * FALSE otherwise. */ gboolean -gst_structure_foreach (GstStructure *structure, - GstStructureForeachFunc func, - gpointer user_data) +gst_structure_foreach (GstStructure * structure, + GstStructureForeachFunc func, gpointer user_data) { int i; GstStructureField *field; gboolean ret; - for(i=0;ifields->len;i++){ - field = GST_STRUCTURE_FIELD(structure, i); + for (i = 0; i < structure->fields->len; i++) { + field = GST_STRUCTURE_FIELD (structure, i); ret = func (field->name, &field->value, user_data); - if (!ret) return FALSE; + if (!ret) + return FALSE; } return TRUE; @@ -734,15 +737,15 @@ gst_structure_foreach (GstStructure *structure, * Returns: TRUE if the structure contains a field with the given name */ gboolean -gst_structure_has_field(const GstStructure *structure, - const gchar *fieldname) +gst_structure_has_field (const GstStructure * structure, + const gchar * fieldname) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, 0); - g_return_val_if_fail(fieldname != NULL, 0); + g_return_val_if_fail (structure != NULL, 0); + g_return_val_if_fail (fieldname != NULL, 0); - field = gst_structure_get_field(structure, fieldname); + field = gst_structure_get_field (structure, fieldname); return (field != NULL); } @@ -758,18 +761,19 @@ gst_structure_has_field(const GstStructure *structure, * Returns: TRUE if the structure contains a field with the given name and type */ gboolean -gst_structure_has_field_typed(const GstStructure *structure, const gchar *fieldname, - GType type) +gst_structure_has_field_typed (const GstStructure * structure, + const gchar * fieldname, GType type) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, 0); - g_return_val_if_fail(fieldname != NULL, 0); + g_return_val_if_fail (structure != NULL, 0); + g_return_val_if_fail (fieldname != NULL, 0); - field = gst_structure_get_field(structure, fieldname); - if(field == NULL) return FALSE; + field = gst_structure_get_field (structure, fieldname); + if (field == NULL) + return FALSE; - return (G_VALUE_TYPE(&field->value) == type); + return (G_VALUE_TYPE (&field->value) == type); } @@ -788,21 +792,22 @@ gst_structure_has_field_typed(const GstStructure *structure, const gchar *fieldn * Returns: TRUE if the value could be set correctly */ gboolean -gst_structure_get_boolean(const GstStructure *structure, - const gchar *fieldname, - gboolean *value) +gst_structure_get_boolean (const GstStructure * structure, + const gchar * fieldname, gboolean * value) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, FALSE); - g_return_val_if_fail(fieldname != NULL, FALSE); + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); - field = gst_structure_get_field(structure, fieldname); + field = gst_structure_get_field (structure, fieldname); - if(field == NULL) return FALSE; - if(!G_VALUE_HOLDS_BOOLEAN(&field->value))return FALSE; + if (field == NULL) + return FALSE; + if (!G_VALUE_HOLDS_BOOLEAN (&field->value)) + return FALSE; - *value = g_value_get_boolean(&field->value); + *value = g_value_get_boolean (&field->value); return TRUE; } @@ -820,22 +825,23 @@ gst_structure_get_boolean(const GstStructure *structure, * Returns: TRUE if the value could be set correctly */ gboolean -gst_structure_get_int(const GstStructure *structure, - const gchar *fieldname, - gint *value) +gst_structure_get_int (const GstStructure * structure, + const gchar * fieldname, gint * value) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, FALSE); - g_return_val_if_fail(fieldname != NULL, FALSE); - g_return_val_if_fail(value != NULL, FALSE); + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); - field = gst_structure_get_field(structure, fieldname); + field = gst_structure_get_field (structure, fieldname); - if(field == NULL) return FALSE; - if(!G_VALUE_HOLDS_INT(&field->value))return FALSE; + if (field == NULL) + return FALSE; + if (!G_VALUE_HOLDS_INT (&field->value)) + return FALSE; - *value = g_value_get_int(&field->value); + *value = g_value_get_int (&field->value); return TRUE; } @@ -853,20 +859,21 @@ gst_structure_get_int(const GstStructure *structure, * Returns: TRUE if the value could be set correctly */ gboolean -gst_structure_get_fourcc(const GstStructure *structure, - const gchar *fieldname, - guint32 *value) +gst_structure_get_fourcc (const GstStructure * structure, + const gchar * fieldname, guint32 * value) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, FALSE); - g_return_val_if_fail(fieldname != NULL, FALSE); - g_return_val_if_fail(value != NULL, FALSE); + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); - field = gst_structure_get_field(structure, fieldname); + field = gst_structure_get_field (structure, fieldname); - if(field == NULL) return FALSE; - if(!GST_VALUE_HOLDS_FOURCC(&field->value))return FALSE; + if (field == NULL) + return FALSE; + if (!GST_VALUE_HOLDS_FOURCC (&field->value)) + return FALSE; *value = gst_value_get_fourcc (&field->value); @@ -886,22 +893,23 @@ gst_structure_get_fourcc(const GstStructure *structure, * Returns: TRUE if the value could be set correctly */ gboolean -gst_structure_get_double(const GstStructure *structure, - const gchar *fieldname, - gdouble *value) +gst_structure_get_double (const GstStructure * structure, + const gchar * fieldname, gdouble * value) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, FALSE); - g_return_val_if_fail(fieldname != NULL, FALSE); - g_return_val_if_fail(value != NULL, FALSE); + g_return_val_if_fail (structure != NULL, FALSE); + g_return_val_if_fail (fieldname != NULL, FALSE); + g_return_val_if_fail (value != NULL, FALSE); - field = gst_structure_get_field(structure, fieldname); + field = gst_structure_get_field (structure, fieldname); - if(field == NULL) return FALSE; - if(!G_VALUE_HOLDS_DOUBLE(&field->value))return FALSE; + if (field == NULL) + return FALSE; + if (!G_VALUE_HOLDS_DOUBLE (&field->value)) + return FALSE; - *value = g_value_get_double(&field->value); + *value = g_value_get_double (&field->value); return TRUE; } @@ -921,41 +929,44 @@ gst_structure_get_double(const GstStructure *structure, * Returns: a pointer to the string */ const gchar * -gst_structure_get_string (const GstStructure *structure, - const gchar *fieldname) +gst_structure_get_string (const GstStructure * structure, + const gchar * fieldname) { GstStructureField *field; - g_return_val_if_fail(structure != NULL, NULL); - g_return_val_if_fail(fieldname != NULL, NULL); + g_return_val_if_fail (structure != NULL, NULL); + g_return_val_if_fail (fieldname != NULL, NULL); - field = gst_structure_get_field(structure, fieldname); + field = gst_structure_get_field (structure, fieldname); - if(field == NULL) return FALSE; - if(!G_VALUE_HOLDS_STRING(&field->value))return FALSE; + if (field == NULL) + return FALSE; + if (!G_VALUE_HOLDS_STRING (&field->value)) + return FALSE; - return g_value_get_string(&field->value); + return g_value_get_string (&field->value); } -typedef struct _GstStructureAbbreviation { +typedef struct _GstStructureAbbreviation +{ char *type_name; GType type; } GstStructureAbbreviation; static GstStructureAbbreviation gst_structure_abbrs[] = { - { "int", G_TYPE_INT }, - { "i", G_TYPE_INT }, - { "float", G_TYPE_FLOAT }, - { "f", G_TYPE_FLOAT }, - { "double", G_TYPE_DOUBLE }, - { "d", G_TYPE_DOUBLE }, -//{ "fourcc", GST_TYPE_FOURCC }, - { "boolean", G_TYPE_BOOLEAN }, - { "bool", G_TYPE_BOOLEAN }, - { "b", G_TYPE_BOOLEAN }, - { "string", G_TYPE_STRING }, - { "str", G_TYPE_STRING }, - { "s", G_TYPE_STRING } + {"int", G_TYPE_INT}, + {"i", G_TYPE_INT}, + {"float", G_TYPE_FLOAT}, + {"f", G_TYPE_FLOAT}, + {"double", G_TYPE_DOUBLE}, + {"d", G_TYPE_DOUBLE}, +//{ "fourcc", GST_TYPE_FOURCC }, + {"boolean", G_TYPE_BOOLEAN}, + {"bool", G_TYPE_BOOLEAN}, + {"b", G_TYPE_BOOLEAN}, + {"string", G_TYPE_STRING}, + {"str", G_TYPE_STRING}, + {"s", G_TYPE_STRING} }; static GType @@ -963,16 +974,16 @@ gst_structure_from_abbr (const char *type_name) { int i; - g_return_val_if_fail(type_name != NULL, G_TYPE_INVALID); + g_return_val_if_fail (type_name != NULL, G_TYPE_INVALID); - for(i=0;iname)); - for(i=0;ifields->len;i++) { + g_string_append_printf (s, "%s", g_quark_to_string (structure->name)); + for (i = 0; i < structure->fields->len; i++) { char *t; GType type; - field = GST_STRUCTURE_FIELD(structure, i); + field = GST_STRUCTURE_FIELD (structure, i); t = gst_value_serialize (&field->value); type = G_VALUE_TYPE (&field->value); if (type == GST_TYPE_LIST) { GArray *array = g_value_peek_pointer (&field->value); - if (array->len > 0){ - GValue *value = &g_array_index (array, GValue, 0); + + if (array->len > 0) { + GValue *value = &g_array_index (array, GValue, 0); type = G_VALUE_TYPE (value); } else { type = G_TYPE_INT; } - } else if (G_VALUE_TYPE(&field->value) == GST_TYPE_INT_RANGE) { + } else if (G_VALUE_TYPE (&field->value) == GST_TYPE_INT_RANGE) { type = G_TYPE_INT; - } else if (G_VALUE_TYPE(&field->value) == GST_TYPE_DOUBLE_RANGE) { + } else if (G_VALUE_TYPE (&field->value) == GST_TYPE_DOUBLE_RANGE) { type = G_TYPE_DOUBLE; } - g_string_append_printf(s, ", %s=(%s)%s", g_quark_to_string(field->name), - gst_structure_to_abbr(type), t); - g_free(t); + g_string_append_printf (s, ", %s=(%s)%s", g_quark_to_string (field->name), + gst_structure_to_abbr (type), t); + g_free (t); } - return g_string_free(s, FALSE); + return g_string_free (s, FALSE); } /* @@ -1068,11 +1080,12 @@ gst_structure_to_string (const GstStructure *structure) * THIS FUNCTION MODIFIES THE STRING AND DETECTS INSIDE A NONTERMINATED STRING */ static gboolean -gst_structure_parse_string (gchar *s, gchar **end, gchar **next) +gst_structure_parse_string (gchar * s, gchar ** end, gchar ** next) { gchar *w; - if (*s == 0) return FALSE; + if (*s == 0) + return FALSE; if (*s != '"') { int ret; @@ -1086,7 +1099,8 @@ gst_structure_parse_string (gchar *s, gchar **end, gchar **next) w = s; s++; while (*s != '"') { - if (*s == 0) return FALSE; + if (*s == 0) + return FALSE; if (*s == '\\') { s++; @@ -1105,7 +1119,8 @@ gst_structure_parse_string (gchar *s, gchar **end, gchar **next) } static gboolean -gst_structure_parse_range (gchar *s, gchar **after, GValue *value, GType type) +gst_structure_parse_range (gchar * s, gchar ** after, GValue * value, + GType type) { GValue value1 = { 0 }; GValue value2 = { 0 }; @@ -1113,29 +1128,38 @@ gst_structure_parse_range (gchar *s, gchar **after, GValue *value, GType type) gboolean ret; - if (*s != '[') return FALSE; + if (*s != '[') + return FALSE; s++; - ret = gst_structure_parse_value(s, &s, &value1, type); - if (ret == FALSE) return FALSE; + ret = gst_structure_parse_value (s, &s, &value1, type); + if (ret == FALSE) + return FALSE; - while (g_ascii_isspace (*s)) s++; - - if (*s != ',') return FALSE; + while (g_ascii_isspace (*s)) + s++; + + if (*s != ',') + return FALSE; s++; - while (g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; - ret = gst_structure_parse_value(s, &s, &value2, type); - if (ret == FALSE) return FALSE; + ret = gst_structure_parse_value (s, &s, &value2, type); + if (ret == FALSE) + return FALSE; - while (g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; - if (*s != ']') return FALSE; + if (*s != ']') + return FALSE; s++; - if (G_VALUE_TYPE (&value1) != G_VALUE_TYPE (&value2)) return FALSE; - + if (G_VALUE_TYPE (&value1) != G_VALUE_TYPE (&value2)) + return FALSE; + if (G_VALUE_TYPE (&value1) == G_TYPE_DOUBLE) { range_type = GST_TYPE_DOUBLE_RANGE; } else if (G_VALUE_TYPE (&value1) == G_TYPE_INT) { @@ -1144,13 +1168,13 @@ gst_structure_parse_range (gchar *s, gchar **after, GValue *value, GType type) return FALSE; } - g_value_init(value, range_type); + g_value_init (value, range_type); if (range_type == GST_TYPE_DOUBLE_RANGE) { - gst_value_set_double_range(value, g_value_get_double(&value1), - g_value_get_double(&value2)); + gst_value_set_double_range (value, g_value_get_double (&value1), + g_value_get_double (&value2)); } else { - gst_value_set_int_range(value, g_value_get_int(&value1), - g_value_get_int(&value2)); + gst_value_set_int_range (value, g_value_get_int (&value1), + g_value_get_int (&value2)); } *after = s; @@ -1158,44 +1182,52 @@ gst_structure_parse_range (gchar *s, gchar **after, GValue *value, GType type) } static gboolean -gst_structure_parse_list (gchar *s, gchar **after, GValue *value, GType type) +gst_structure_parse_list (gchar * s, gchar ** after, GValue * value, GType type) { GValue list_value = { 0 }; gboolean ret; GArray *array; - g_value_init(value, GST_TYPE_LIST); + g_value_init (value, GST_TYPE_LIST); array = g_value_peek_pointer (value); - if (*s != '{') return FALSE; + if (*s != '{') + return FALSE; s++; - while (g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; if (*s == '}') { s++; *after = s; return TRUE; } - ret = gst_structure_parse_value(s, &s, &list_value, type); - if (ret == FALSE) return FALSE; - + ret = gst_structure_parse_value (s, &s, &list_value, type); + if (ret == FALSE) + return FALSE; + g_array_append_val (array, list_value); - while (g_ascii_isspace (*s)) s++; - + while (g_ascii_isspace (*s)) + s++; + while (*s != '}') { - if (*s != ',') return FALSE; + if (*s != ',') + return FALSE; s++; - while (g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; memset (&list_value, 0, sizeof (list_value)); - ret = gst_structure_parse_value(s, &s, &list_value, type); - if (ret == FALSE) return FALSE; + ret = gst_structure_parse_value (s, &s, &list_value, type); + if (ret == FALSE) + return FALSE; g_array_append_val (array, list_value); - while (g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; } s++; @@ -1205,11 +1237,11 @@ gst_structure_parse_list (gchar *s, gchar **after, GValue *value, GType type) } static gboolean -gst_structure_parse_simple_string (gchar *str, gchar **end) +gst_structure_parse_simple_string (gchar * str, gchar ** end) { char *s = str; - while(GST_ASCII_IS_STRING(*s)){ + while (GST_ASCII_IS_STRING (*s)) { s++; } @@ -1219,9 +1251,8 @@ gst_structure_parse_simple_string (gchar *str, gchar **end) } static gboolean -gst_structure_parse_field (gchar *str, - gchar **after, - GstStructureField *field) +gst_structure_parse_field (gchar * str, + gchar ** after, GstStructureField * field) { gchar *name; gchar *name_end; @@ -1230,14 +1261,18 @@ gst_structure_parse_field (gchar *str, s = str; - while(g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; name = s; - if (!gst_structure_parse_simple_string (s, &name_end)) return FALSE; + if (!gst_structure_parse_simple_string (s, &name_end)) + return FALSE; s = name_end; - while(g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; - if (*s != '=') return FALSE; + if (*s != '=') + return FALSE; s++; c = *name_end; @@ -1253,10 +1288,8 @@ gst_structure_parse_field (gchar *str, } static gboolean -gst_structure_parse_value (gchar *str, - gchar **after, - GValue *value, - GType default_type) +gst_structure_parse_value (gchar * str, + gchar ** after, GValue * value, GType default_type) { gchar *type_name; gchar *type_end; @@ -1269,38 +1302,47 @@ gst_structure_parse_value (gchar *str, s = str; - while(g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; type_name = NULL; if (*s == '(') { type = G_TYPE_INVALID; s++; - while(g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; type_name = s; - if (!gst_structure_parse_simple_string (s, &type_end)) return FALSE; + if (!gst_structure_parse_simple_string (s, &type_end)) + return FALSE; s = type_end; - while(g_ascii_isspace (*s)) s++; - if (*s != ')') return FALSE; + while (g_ascii_isspace (*s)) + s++; + if (*s != ')') + return FALSE; s++; - while(g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; c = *type_end; *type_end = 0; - type = gst_structure_from_abbr(type_name); + type = gst_structure_from_abbr (type_name); *type_end = c; - if (type == G_TYPE_INVALID) return FALSE; + if (type == G_TYPE_INVALID) + return FALSE; } - while(g_ascii_isspace (*s)) s++; + while (g_ascii_isspace (*s)) + s++; if (*s == '[') { ret = gst_structure_parse_range (s, &s, value, type); } else if (*s == '{') { ret = gst_structure_parse_list (s, &s, value, type); } else { value_s = s; - if (!gst_structure_parse_string (s, &value_end, &s)) return FALSE; + if (!gst_structure_parse_string (s, &value_end, &s)) + return FALSE; c = *value_end; *value_end = 0; @@ -1308,20 +1350,21 @@ gst_structure_parse_value (gchar *str, GType try_types[] = { G_TYPE_INT, G_TYPE_DOUBLE, G_TYPE_STRING }; int i; - for(i=0;i<3;i++) { - g_value_init(value, try_types[i]); + for (i = 0; i < 3; i++) { + g_value_init (value, try_types[i]); ret = gst_value_deserialize (value, value_s); - if (ret) break; - g_value_unset(value); + if (ret) + break; + g_value_unset (value); } } else { - g_value_init(value, type); + g_value_init (value, type); ret = gst_value_deserialize (value, value_s); } *value_end = c; } - + *after = s; return ret; @@ -1337,8 +1380,7 @@ gst_structure_parse_value (gchar *str, * Returns: a new #GstStructure */ GstStructure * -gst_structure_from_string (const gchar *string, - gchar **end) +gst_structure_from_string (const gchar * string, gchar ** end) { char *name; char *copy; @@ -1348,37 +1390,42 @@ gst_structure_from_string (const gchar *string, GstStructure *structure = NULL; GstStructureField field = { 0 }; - g_return_val_if_fail(string != NULL, NULL); + g_return_val_if_fail (string != NULL, NULL); - copy = g_strdup(string); + copy = g_strdup (string); r = copy; name = r; if (!gst_structure_parse_string (r, &w, &r)) goto error; - - while (g_ascii_isspace(*r)) r++; - if(*r != 0 && *r != ';' && *r != ',') goto error; + + while (g_ascii_isspace (*r)) + r++; + if (*r != 0 && *r != ';' && *r != ',') + goto error; save = *w; *w = 0; - structure = gst_structure_empty_new(name); + structure = gst_structure_empty_new (name); *w = save; - while (*r && (*r != ';')){ - if(*r != ',') + while (*r && (*r != ';')) { + if (*r != ',') goto error; r++; - while (*r && g_ascii_isspace(*r)) r++; + while (*r && g_ascii_isspace (*r)) + r++; - memset(&field,0,sizeof(field)); + memset (&field, 0, sizeof (field)); if (!gst_structure_parse_field (r, &r, &field)) goto error; - gst_structure_set_field(structure, &field); - while (*r && g_ascii_isspace(*r)) r++; + gst_structure_set_field (structure, &field); + while (*r && g_ascii_isspace (*r)) + r++; } - if (end) *end = (char *)string + (r - copy); + if (end) + *end = (char *) string + (r - copy); g_free (copy); return structure; @@ -1391,20 +1438,20 @@ error: } static void -gst_structure_transform_to_string(const GValue *src_value, - GValue *dest_value) +gst_structure_transform_to_string (const GValue * src_value, + GValue * dest_value) { - g_return_if_fail(src_value != NULL); - g_return_if_fail(dest_value != NULL); + g_return_if_fail (src_value != NULL); + g_return_if_fail (dest_value != NULL); dest_value->data[0].v_pointer = - gst_structure_to_string (src_value->data[0].v_pointer); + gst_structure_to_string (src_value->data[0].v_pointer); } static GstStructure * -gst_structure_copy_conditional (const GstStructure *structure) +gst_structure_copy_conditional (const GstStructure * structure) { - if (structure) return gst_structure_copy (structure); + if (structure) + return gst_structure_copy (structure); return NULL; } - diff --git a/gst/gststructure.h b/gst/gststructure.h index 99eb0ae6b..22861e429 100644 --- a/gst/gststructure.h +++ b/gst/gststructure.h @@ -24,18 +24,16 @@ #include G_BEGIN_DECLS - #define GST_TYPE_STRUCTURE (gst_structure_get_type ()) #define GST_STRUCTURE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GST_TYPE_STRUCTURE, GstStructure)) #define GST_IS_STRUCTURE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GST_TYPE_STRUCTURE)) - typedef struct _GstStructure GstStructure; -typedef gboolean (*GstStructureForeachFunc) (GQuark field_id, - GValue * value, - gpointer user_data); +typedef gboolean (*GstStructureForeachFunc) (GQuark field_id, + GValue * value, gpointer user_data); -struct _GstStructure { +struct _GstStructure +{ GType type; GQuark name; @@ -43,82 +41,68 @@ struct _GstStructure { GArray *fields; }; -GType gst_structure_get_type (void) G_GNUC_CONST; - -GstStructure * gst_structure_empty_new (const gchar * name); -GstStructure * gst_structure_id_empty_new (GQuark quark); -GstStructure * gst_structure_new (const gchar * name, - const gchar * firstfield, - ...); -GstStructure * gst_structure_new_valist (const gchar * name, - const gchar * firstfield, - va_list varargs); -GstStructure * gst_structure_copy (const GstStructure *structure); -void gst_structure_free (GstStructure *structure); - -G_CONST_RETURN gchar * gst_structure_get_name (const GstStructure *structure); -void gst_structure_set_name (GstStructure *structure, - const gchar *name); - -void gst_structure_id_set_value (GstStructure *structure, - GQuark field, - const GValue *value); -void gst_structure_set_value (GstStructure *structure, - const gchar *fieldname, - const GValue *value); -void gst_structure_set (GstStructure *structure, - const gchar *fieldname, - ...); -void gst_structure_set_valist (GstStructure *structure, - const gchar *fieldname, - va_list varargs); -G_CONST_RETURN GValue * gst_structure_id_get_value (const GstStructure *structure, - GQuark field); -G_CONST_RETURN GValue * gst_structure_get_value (const GstStructure *structure, - const gchar *fieldname); -void gst_structure_remove_field (GstStructure *structure, - const gchar *fieldname); -void gst_structure_remove_fields (GstStructure *structure, - const gchar *fieldname, - ...); -void gst_structure_remove_fields_valist (GstStructure *structure, - const gchar *fieldname, - va_list varargs); -void gst_structure_remove_all_fields (GstStructure *structure); - -GType gst_structure_get_field_type (const GstStructure *structure, - const gchar *fieldname); -gboolean gst_structure_foreach (GstStructure *structure, - GstStructureForeachFunc func, - gpointer user_data); -gint gst_structure_n_fields (const GstStructure *structure); -gboolean gst_structure_has_field (const GstStructure *structure, - const gchar *fieldname); -gboolean gst_structure_has_field_typed (const GstStructure *structure, - const gchar *fieldname, - GType type); +GType +gst_structure_get_type (void) + G_GNUC_CONST; + + GstStructure *gst_structure_empty_new (const gchar * name); + GstStructure *gst_structure_id_empty_new (GQuark quark); + GstStructure *gst_structure_new (const gchar * name, + const gchar * firstfield, ...); + GstStructure *gst_structure_new_valist (const gchar * name, + const gchar * firstfield, va_list varargs); + GstStructure *gst_structure_copy (const GstStructure * structure); + void gst_structure_free (GstStructure * structure); + + G_CONST_RETURN gchar *gst_structure_get_name (const GstStructure * + structure); + void gst_structure_set_name (GstStructure * structure, const gchar * name); + + void gst_structure_id_set_value (GstStructure * structure, + GQuark field, const GValue * value); + void gst_structure_set_value (GstStructure * structure, + const gchar * fieldname, const GValue * value); + void gst_structure_set (GstStructure * structure, + const gchar * fieldname, ...); + void gst_structure_set_valist (GstStructure * structure, + const gchar * fieldname, va_list varargs); + G_CONST_RETURN GValue *gst_structure_id_get_value (const GstStructure * + structure, GQuark field); + G_CONST_RETURN GValue *gst_structure_get_value (const GstStructure * + structure, const gchar * fieldname); + void gst_structure_remove_field (GstStructure * structure, + const gchar * fieldname); + void gst_structure_remove_fields (GstStructure * structure, + const gchar * fieldname, ...); + void gst_structure_remove_fields_valist (GstStructure * structure, + const gchar * fieldname, va_list varargs); + void gst_structure_remove_all_fields (GstStructure * structure); + + GType gst_structure_get_field_type (const GstStructure * structure, + const gchar * fieldname); + gboolean gst_structure_foreach (GstStructure * structure, + GstStructureForeachFunc func, gpointer user_data); + gint gst_structure_n_fields (const GstStructure * structure); + gboolean gst_structure_has_field (const GstStructure * structure, + const gchar * fieldname); + gboolean gst_structure_has_field_typed (const GstStructure * structure, + const gchar * fieldname, GType type); /* utility functions */ -gboolean gst_structure_get_boolean (const GstStructure *structure, - const gchar *fieldname, - gboolean *value); -gboolean gst_structure_get_int (const GstStructure *structure, - const gchar *fieldname, - gint *value); -gboolean gst_structure_get_fourcc (const GstStructure *structure, - const gchar *fieldname, - guint32 *value); -gboolean gst_structure_get_double (const GstStructure *structure, - const gchar *fieldname, - gdouble *value); -G_CONST_RETURN gchar * gst_structure_get_string (const GstStructure *structure, - const gchar *fieldname); - -gchar * gst_structure_to_string (const GstStructure *structure); -GstStructure * gst_structure_from_string (const gchar *string, - gchar **end); + gboolean gst_structure_get_boolean (const GstStructure * structure, + const gchar * fieldname, gboolean * value); + gboolean gst_structure_get_int (const GstStructure * structure, + const gchar * fieldname, gint * value); + gboolean gst_structure_get_fourcc (const GstStructure * structure, + const gchar * fieldname, guint32 * value); + gboolean gst_structure_get_double (const GstStructure * structure, + const gchar * fieldname, gdouble * value); + G_CONST_RETURN gchar *gst_structure_get_string (const GstStructure * + structure, const gchar * fieldname); + + gchar *gst_structure_to_string (const GstStructure * structure); + GstStructure *gst_structure_from_string (const gchar * string, + gchar ** end); G_END_DECLS - #endif - diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index cd64e3c95..486f96aab 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -29,18 +29,20 @@ static GstClock *_the_system_clock = NULL; -static void gst_system_clock_class_init (GstSystemClockClass *klass); -static void gst_system_clock_init (GstSystemClock *clock); -static void gst_system_clock_dispose (GObject *object); +static void gst_system_clock_class_init (GstSystemClockClass * klass); +static void gst_system_clock_init (GstSystemClock * clock); +static void gst_system_clock_dispose (GObject * object); -static GstClockTime gst_system_clock_get_internal_time (GstClock *clock); -static guint64 gst_system_clock_get_resolution (GstClock *clock); -static GstClockEntryStatus gst_system_clock_wait (GstClock *clock, GstClockEntry *entry); -static void gst_system_clock_unlock (GstClock *clock, GstClockEntry *entry); +static GstClockTime gst_system_clock_get_internal_time (GstClock * clock); +static guint64 gst_system_clock_get_resolution (GstClock * clock); +static GstClockEntryStatus gst_system_clock_wait (GstClock * clock, + GstClockEntry * entry); +static void gst_system_clock_unlock (GstClock * clock, GstClockEntry * entry); static GStaticMutex _gst_sysclock_mutex = G_STATIC_MUTEX_INIT; static GstClockClass *parent_class = NULL; + /* static guint gst_system_clock_signals[LAST_SIGNAL] = { 0 }; */ GType @@ -61,42 +63,42 @@ gst_system_clock_get_type (void) (GInstanceInitFunc) gst_system_clock_init, NULL }; - clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock", - &clock_info, 0); + clock_type = g_type_register_static (GST_TYPE_CLOCK, "GstSystemClock", + &clock_info, 0); } return clock_type; } static void -gst_system_clock_class_init (GstSystemClockClass *klass) +gst_system_clock_class_init (GstSystemClockClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; GstClockClass *gstclock_class; - gobject_class = (GObjectClass*) klass; - gstobject_class = (GstObjectClass*) klass; - gstclock_class = (GstClockClass*) klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstclock_class = (GstClockClass *) klass; parent_class = g_type_class_ref (GST_TYPE_CLOCK); - gobject_class->dispose = gst_system_clock_dispose; + gobject_class->dispose = gst_system_clock_dispose; - gstclock_class->get_internal_time = gst_system_clock_get_internal_time; - gstclock_class->get_resolution = gst_system_clock_get_resolution; - gstclock_class->wait = gst_system_clock_wait; - gstclock_class->unlock = gst_system_clock_unlock; + gstclock_class->get_internal_time = gst_system_clock_get_internal_time; + gstclock_class->get_resolution = gst_system_clock_get_resolution; + gstclock_class->wait = gst_system_clock_wait; + gstclock_class->unlock = gst_system_clock_unlock; } static void -gst_system_clock_init (GstSystemClock *clock) +gst_system_clock_init (GstSystemClock * clock) { - clock->mutex = g_mutex_new(); + clock->mutex = g_mutex_new (); clock->cond = g_cond_new (); } static void -gst_system_clock_dispose (GObject *object) +gst_system_clock_dispose (GObject * object) { GstClock *clock = (GstClock *) object; GstSystemClock *sysclock = (GstSystemClock *) object; @@ -122,7 +124,7 @@ gst_system_clock_dispose (GObject *object) * * Returns: the default clock. */ -GstClock* +GstClock * gst_system_clock_obtain (void) { GstClock *clock = _the_system_clock; @@ -134,9 +136,9 @@ gst_system_clock_obtain (void) g_static_mutex_unlock (&_gst_sysclock_mutex); goto have_clock; } - + clock = GST_CLOCK (g_object_new (GST_TYPE_SYSTEM_CLOCK, NULL)); - + gst_object_set_name (GST_OBJECT (clock), "GstSystemClock"); gst_object_ref (GST_OBJECT (clock)); @@ -152,23 +154,23 @@ have_clock: } static GstClockTime -gst_system_clock_get_internal_time (GstClock *clock) +gst_system_clock_get_internal_time (GstClock * clock) { GTimeVal timeval; g_get_current_time (&timeval); - + return GST_TIMEVAL_TO_TIME (timeval); } static guint64 -gst_system_clock_get_resolution (GstClock *clock) +gst_system_clock_get_resolution (GstClock * clock) { return 1 * GST_USECOND; } static GstClockEntryStatus -gst_system_clock_wait (GstClock *clock, GstClockEntry *entry) +gst_system_clock_wait (GstClock * clock, GstClockEntry * entry) { GstClockEntryStatus res; GstClockTime current, target; @@ -183,15 +185,14 @@ gst_system_clock_wait (GstClock *clock, GstClockEntry *entry) "s (max allowed is %" G_GINT64_FORMAT "s", -diff, clock->max_diff); return GST_CLOCK_ENTRY_EARLY; } - + target = gst_system_clock_get_internal_time (clock) + diff; GST_CAT_DEBUG (GST_CAT_CLOCK, "real_target %" G_GUINT64_FORMAT - " target %" G_GUINT64_FORMAT - " now %" G_GUINT64_FORMAT, - target, GST_CLOCK_ENTRY_TIME (entry), current); + " target %" G_GUINT64_FORMAT + " now %" G_GUINT64_FORMAT, target, GST_CLOCK_ENTRY_TIME (entry), current); - if (((gint64)target) > 0) { + if (((gint64) target) > 0) { GTimeVal tv; GST_TIME_TO_TIMEVAL (target, tv); @@ -199,15 +200,14 @@ gst_system_clock_wait (GstClock *clock, GstClockEntry *entry) g_cond_timed_wait (sysclock->cond, sysclock->mutex, &tv); g_mutex_unlock (sysclock->mutex); res = entry->status; - } - else { + } else { res = GST_CLOCK_ENTRY_EARLY; } return res; } static void -gst_system_clock_unlock (GstClock *clock, GstClockEntry *entry) +gst_system_clock_unlock (GstClock * clock, GstClockEntry * entry) { GstSystemClock *sysclock = GST_SYSTEM_CLOCK (clock); diff --git a/gst/gstsystemclock.h b/gst/gstsystemclock.h index 33c03533b..d85bb7747 100644 --- a/gst/gstsystemclock.h +++ b/gst/gstsystemclock.h @@ -27,37 +27,35 @@ #include G_BEGIN_DECLS - #define GST_TYPE_SYSTEM_CLOCK (gst_system_clock_get_type ()) #define GST_SYSTEM_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_SYSTEM_CLOCK, GstSystemClock)) #define GST_IS_SYSTEM_CLOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_SYSTEM_CLOCK)) #define GST_SYSTEM_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_SYSTEM_CLOCK, GstSystemClockClass)) #define GST_IS_SYSTEM_CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_SYSTEM_CLOCK)) #define GST_SYSTEM_CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_SYSTEM_CLOCK, GstSystemClockClass)) - - typedef struct _GstSystemClock GstSystemClock; typedef struct _GstSystemClockClass GstSystemClockClass; -struct _GstSystemClock { - GstClock clock; +struct _GstSystemClock +{ + GstClock clock; - GMutex * mutex; - GCond * cond; + GMutex *mutex; + GCond *cond; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstSystemClockClass { - GstClockClass parent_class; +struct _GstSystemClockClass +{ + GstClockClass parent_class; gpointer _gst_reserved[GST_PADDING]; }; -GType gst_system_clock_get_type (void); +GType gst_system_clock_get_type (void); -GstClock* gst_system_clock_obtain (void); +GstClock *gst_system_clock_obtain (void); G_END_DECLS - #endif /* __GST_SYSTEM_CLOCK_H__ */ diff --git a/gst/gsttag.c b/gst/gsttag.c index 439da9727..88c632364 100644 --- a/gst/gsttag.c +++ b/gst/gsttag.c @@ -34,20 +34,22 @@ #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL) -typedef struct { - GType type; /* type the data is in */ +typedef struct +{ + GType type; /* type the data is in */ - gchar * nick; /* translated name */ - gchar * blurb; /* translated description of type */ + gchar *nick; /* translated name */ + gchar *blurb; /* translated description of type */ - GstTagMergeFunc merge_func; /* functions to merge the values */ - GstTagFlag flag; /* type of tag */ + GstTagMergeFunc merge_func; /* functions to merge the values */ + GstTagFlag flag; /* type of tag */ } GstTagInfo; #define TAGLIST "taglist" static GQuark gst_tag_list_quark; static GMutex *__tag_mutex; static GHashTable *__tags; + #define TAG_LOCK g_mutex_lock (__tag_mutex) #define TAG_UNLOCK g_mutex_unlock (__tag_mutex) @@ -58,12 +60,11 @@ gst_tag_list_get_type (void) if (_gst_tag_list_type == 0) { _gst_tag_list_type = g_boxed_type_register_static ("GstTagList", - (GBoxedCopyFunc) gst_tag_list_copy, - (GBoxedFreeFunc) gst_tag_list_free); + (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free); #if 0 - g_value_register_transform_func(_gst_tag_list_type, G_TYPE_STRING, - _gst_structure_transform_to_string); + g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING, + _gst_structure_transform_to_string); #endif } @@ -77,176 +78,117 @@ _gst_tag_initialize (void) __tag_mutex = g_mutex_new (); __tags = g_hash_table_new (g_direct_hash, g_direct_equal); gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("title"), - _("commonly used title"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("artist"), - _("person(s) responsible for the recording"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("artist"), + _("person(s) responsible for the recording"), + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("album"), - _("album containing this data"), - gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, - G_TYPE_UINT, /* FIXME: own data type for dates? */ - _("date"), - _("date the data was created (in Julian calendar days)"), - NULL); + G_TYPE_STRING, + _("album"), + _("album containing this data"), gst_tag_merge_strings_with_comma); + gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */ + _("date"), + _("date the data was created (in Julian calendar days)"), NULL); gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("genre"), - _("genre this data belongs to"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("genre"), + _("genre this data belongs to"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("comment"), - _("free text commenting the data"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("comment"), + _("free text commenting the data"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("track number"), - _("track number inside a collection"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("track number"), + _("track number inside a collection"), gst_tag_merge_use_first); gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("track count"), - _("count of tracks inside collection this track belongs to"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("track count"), + _("count of tracks inside collection this track belongs to"), + gst_tag_merge_use_first); gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("disc number"), - _("disc number inside a collection"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("disc number"), + _("disc number inside a collection"), gst_tag_merge_use_first); gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("disc count"), - _("count of discs inside collection this disc belongs to"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("disc count"), + _("count of discs inside collection this disc belongs to"), + gst_tag_merge_use_first); gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("location"), - _("original location of file as a URI"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("location"), + _("original location of file as a URI"), + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("description"), - _("short text describing the content of the data"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("description"), + _("short text describing the content of the data"), + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("version"), - _("version of this data"), - NULL); + G_TYPE_STRING, _("version"), _("version of this data"), NULL); gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("ISRC"), - _("International Standard Recording Code - see http://www.ifpi.org/isrc/"), - NULL); - gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("organization"), - _("organization"), /* FIXME */ - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("ISRC"), + _ + ("International Standard Recording Code - see http://www.ifpi.org/isrc/"), + NULL); + gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */ + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("copyright"), - _("copyright notice of the data"), - NULL); + G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL); gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("contact"), - _("contact information"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("contact"), _("contact information"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("license"), - _("license of data"), - NULL); + G_TYPE_STRING, _("license"), _("license of data"), NULL); gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("performer"), - _("person(s) performing"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("performer"), + _("person(s) performing"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED, - G_TYPE_UINT64, - _("duration"), - _("length in GStreamer time units (nanoseconds)"), - NULL); + G_TYPE_UINT64, + _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL); gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("codec"), - _("codec the data is stored in"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("codec"), + _("codec the data is stored in"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("video codec"), - _("codec the video data is stored in"), - NULL); + G_TYPE_STRING, + _("video codec"), _("codec the video data is stored in"), NULL); gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("audio codec"), - _("codec the audio data is stored in"), - NULL); + G_TYPE_STRING, + _("audio codec"), _("codec the audio data is stored in"), NULL); gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("bitrate"), - _("exact or average bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("nominal bitrate"), - _("nominal bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("minimum bitrate"), - _("minimum bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("maximum bitrate"), - _("maximum bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("encoder"), - _("encoder used to encode this stream"), - NULL); + G_TYPE_STRING, + _("encoder"), _("encoder used to encode this stream"), NULL); gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("encoder version"), - _("version of the encoder used to encode this stream"), - NULL); + G_TYPE_UINT, + _("encoder version"), + _("version of the encoder used to encode this stream"), NULL); gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("serial"), - _("serial number of track"), - NULL); + G_TYPE_UINT, _("serial"), _("serial number of track"), NULL); gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain track gain"), - _("track gain in db"), - NULL); + G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL); gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain track peak"), - _("peak of the track"), - NULL); + G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL); gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain album gain"), - _("album gain in db"), - NULL); + G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL); gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain album peak"), - _("peak of the album"), - NULL); + G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL); } + /** * gst_tag_merge_use_first: * @dest: uninitialized GValue to store result in @@ -256,13 +198,14 @@ _gst_tag_initialize (void) * It creates a copy of the first value from the list. */ void -gst_tag_merge_use_first (GValue *dest, const GValue *src) +gst_tag_merge_use_first (GValue * dest, const GValue * src) { const GValue *ret = gst_value_list_get_value (src, 0); g_value_init (dest, G_VALUE_TYPE (ret)); g_value_copy (ret, dest); } + /** * gst_tag_merge_strings_with_comma: * @dest: uninitialized GValue to store result in @@ -273,7 +216,7 @@ gst_tag_merge_use_first (GValue *dest, const GValue *src) * as a G_TYPE_STRING or this function will fail. */ void -gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src) +gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src) { GString *str; gint i, count; @@ -283,7 +226,9 @@ gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src) for (i = 1; i < count; i++) { /* seperator between two string */ str = g_string_append (str, _(", ")); - str = g_string_append (str, g_value_get_string (gst_value_list_get_value (src, 1))); + str = + g_string_append (str, g_value_get_string (gst_value_list_get_value (src, + 1))); } g_value_init (dest, G_TYPE_STRING); @@ -294,13 +239,14 @@ static GstTagInfo * gst_tag_lookup (GQuark entry) { GstTagInfo *ret; - + TAG_LOCK; ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry)); TAG_UNLOCK; return ret; } + /** * gst_tag_register: * @name: the name or identifier string @@ -317,8 +263,8 @@ gst_tag_lookup (GQuark entry) * This function takes ownership of all supplied variables. */ void -gst_tag_register (gchar *name, GstTagFlag flag, GType type, - gchar *nick, gchar *blurb, GstTagMergeFunc func) +gst_tag_register (gchar * name, GstTagFlag flag, GType type, + gchar * nick, gchar * blurb, GstTagMergeFunc func) { GQuark key; GstTagInfo *info; @@ -327,22 +273,23 @@ gst_tag_register (gchar *name, GstTagFlag flag, GType type, g_return_if_fail (nick != NULL); g_return_if_fail (blurb != NULL); g_return_if_fail (type != 0 && type != GST_TYPE_LIST); - + key = g_quark_from_string (name); info = gst_tag_lookup (key); g_return_if_fail (info == NULL); - + info = g_new (GstTagInfo, 1); info->flag = flag; info->type = type; info->nick = nick; info->blurb = blurb; info->merge_func = func; - + TAG_LOCK; g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info); TAG_UNLOCK; } + /** * gst_tag_exists: * @tag: name of the tag @@ -352,12 +299,13 @@ gst_tag_register (gchar *name, GstTagFlag flag, GType type, * Returns: TRUE if the type is already registered */ gboolean -gst_tag_exists (const gchar *tag) +gst_tag_exists (const gchar * tag) { g_return_val_if_fail (tag != NULL, FALSE); - + return gst_tag_lookup (g_quark_from_string (tag)) != NULL; } + /** * gst_tag_get_type: * @tag: the tag @@ -367,16 +315,17 @@ gst_tag_exists (const gchar *tag) * Returns: the #GType of this tag */ GType -gst_tag_get_type (const gchar *tag) +gst_tag_get_type (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, 0); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, 0); - + return info->type; } + /** * gst_tag_get_nick * @tag: the tag @@ -387,16 +336,17 @@ gst_tag_get_type (const gchar *tag) * Returns: the human-readable name of this tag */ const gchar * -gst_tag_get_nick (const gchar *tag) +gst_tag_get_nick (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, NULL); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, NULL); - + return info->nick; } + /** * gst_tag_get_description: * @tag: the tag @@ -407,14 +357,14 @@ gst_tag_get_nick (const gchar *tag) * Return the human-readable description of this tag */ const gchar * -gst_tag_get_description (const gchar *tag) +gst_tag_get_description (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, NULL); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, NULL); - + return info->blurb; } @@ -425,7 +375,7 @@ gst_tag_get_description (const gchar *tag) * Returns the flag of this tag. */ GstTagFlag -gst_tag_get_flag (const gchar *tag) +gst_tag_get_flag (const gchar * tag) { GstTagInfo *info; @@ -446,16 +396,17 @@ gst_tag_get_flag (const gchar *tag) * Returns: TRUE, if the given tag is fixed. */ gboolean -gst_tag_is_fixed (const gchar *tag) +gst_tag_is_fixed (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, FALSE); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, FALSE); - + return info->merge_func == NULL; } + /** * gst_tag_list_new: * @@ -468,6 +419,7 @@ gst_tag_list_new (void) { return GST_TAG_LIST (gst_structure_new (TAGLIST, NULL)); } + /** * gst_is_tag_list: * @p: Object that might be a taglist @@ -479,23 +431,26 @@ gst_tag_list_new (void) gboolean gst_is_tag_list (gconstpointer p) { - g_return_val_if_fail (p != NULL, FALSE); + g_return_val_if_fail (p != NULL, FALSE); return ((GstStructure *) p)->name == gst_tag_list_quark; } -typedef struct { - GstStructure * list; - GstTagMergeMode mode; +typedef struct +{ + GstStructure *list; + GstTagMergeMode mode; } GstTagCopyData; static void -gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value) +gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode, + GQuark tag, GValue * value) { GstTagInfo *info = gst_tag_lookup (tag); const GValue *value2; - + g_assert (info != NULL); - if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) { + if (info->merge_func + && (value2 = gst_structure_id_get_value (list, tag)) != NULL) { GValue dest = { 0, }; switch (mode) { case GST_TAG_MERGE_REPLACE_ALL: @@ -540,7 +495,7 @@ gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuar } } static gboolean -gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data) +gst_tag_list_copy_foreach (GQuark tag, GValue * value, gpointer user_data) { GstTagCopyData *copy = (GstTagCopyData *) user_data; @@ -548,6 +503,7 @@ gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data) return TRUE; } + /** * gst_tag_list_insert: * @into: list to merge into @@ -557,10 +513,11 @@ gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data) * Inserts the tags of the second list into the first list using the given mode. */ void -gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode mode) +gst_tag_list_insert (GstTagList * into, const GstTagList * from, + GstTagMergeMode mode) { GstTagCopyData data; - + g_return_if_fail (GST_IS_TAG_LIST (into)); g_return_if_fail (GST_IS_TAG_LIST (from)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); @@ -570,8 +527,10 @@ gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode m if (mode == GST_TAG_MERGE_REPLACE_ALL) { gst_structure_remove_all_fields (data.list); } - gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data); + gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, + &data); } + /** * gst_tag_list_copy: * @list: list to copy @@ -581,12 +540,13 @@ gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode m * Returns: copy of the given list */ GstTagList * -gst_tag_list_copy (const GstTagList *list) +gst_tag_list_copy (const GstTagList * list) { g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); - + return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list)); } + /** * gst_tag_list_merge: * @list1: first list to merge @@ -599,7 +559,8 @@ gst_tag_list_copy (const GstTagList *list) * Returns: the new list */ GstTagList * -gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMergeMode mode) +gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2, + GstTagMergeMode mode) { g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL); g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL); @@ -619,6 +580,7 @@ gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMerg return ret; } } + /** * gst_tag_list_free: * @list: the list to free @@ -626,11 +588,12 @@ gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMerg * Frees the given list and all associated values. */ void -gst_tag_list_free (GstTagList *list) +gst_tag_list_free (GstTagList * list) { g_return_if_fail (GST_IS_TAG_LIST (list)); gst_structure_free ((GstStructure *) list); } + /** * gst_tag_list_get_tag_size: * @list: a taglist @@ -641,7 +604,7 @@ gst_tag_list_free (GstTagList *list) * Returns: The number of tags stored */ guint -gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag) +gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag) { const GValue *value; @@ -655,6 +618,7 @@ gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag) return gst_value_list_get_size (value); } + /** * gst_tag_list_add: * @list: list to set tags in @@ -665,18 +629,20 @@ gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag) * Sets the values for the given tags using the specified mode. */ void -gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag, + ...) { va_list args; g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + va_start (args, tag); gst_tag_list_add_valist (list, mode, tag, args); va_end (args); } + /** * gst_tag_list_add_values: * @list: list to set tags in @@ -687,18 +653,20 @@ gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) * Sets the GValues for the given tags using the specified mode. */ void -gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode, + const gchar * tag, ...) { va_list args; g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + va_start (args, tag); gst_tag_list_add_valist_values (list, mode, tag, args); va_end (args); } + /** * gst_tag_list_add_valist: * @list: list to set tags in @@ -709,16 +677,17 @@ gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *ta * Sets the values for the given tags using the specified mode. */ void -gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagInfo *info; GQuark quark; gchar *error = NULL; - + g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + while (tag != NULL) { GValue value = { 0, }; quark = g_quark_from_string (tag); @@ -741,6 +710,7 @@ gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *ta tag = va_arg (var_args, gchar *); } } + /** * gst_tag_list_add_valist_values: * @list: list to set tags in @@ -751,23 +721,26 @@ gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *ta * Sets the GValues for the given tags using the specified mode. */ void -gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagInfo *info; GQuark quark; - + g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + while (tag != NULL) { quark = g_quark_from_string (tag); info = gst_tag_lookup (quark); g_return_if_fail (info != NULL); - gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *)); + gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, + GValue *)); tag = va_arg (var_args, gchar *); } } + /** * gst_tag_list_remove_tag: * @list: list to remove tag from @@ -776,26 +749,28 @@ gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gc * Removes the goven tag from the taglist. */ void -gst_tag_list_remove_tag (GstTagList *list, const gchar *tag) +gst_tag_list_remove_tag (GstTagList * list, const gchar * tag) { g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (tag != NULL); gst_structure_remove_field ((GstStructure *) list, tag); } -typedef struct { - GstTagForeachFunc func; - GstTagList * tag_list; - gpointer data; +typedef struct +{ + GstTagForeachFunc func; + GstTagList *tag_list; + gpointer data; } TagForeachData; static int -structure_foreach_wrapper (GQuark field_id, - GValue *value, gpointer user_data) +structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data) { TagForeachData *data = (TagForeachData *) user_data; + data->func (data->tag_list, g_quark_to_string (field_id), data->data); return TRUE; } + /** * gst_tag_list_foreach: * @list: list to iterate over @@ -806,17 +781,19 @@ structure_foreach_wrapper (GQuark field_id, * is no tag, the function won't be called at all. */ void -gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_data) +gst_tag_list_foreach (GstTagList * list, GstTagForeachFunc func, + gpointer user_data) { TagForeachData data; g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (func != NULL); - + data.func = func; data.tag_list = list; data.data = user_data; - gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data); + gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, + &data); } /***** tag events *****/ @@ -830,19 +807,20 @@ gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_da * Returns: a new tag event */ GstEvent * -gst_event_new_tag (GstTagList *list) +gst_event_new_tag (GstTagList * list) { GstEvent *ret; - + g_return_val_if_fail (list == NULL || GST_IS_TAG_LIST (list), NULL); ret = gst_event_new (GST_EVENT_TAG); if (!list) list = gst_tag_list_new (); ret->event_data.structure.structure = (GstStructure *) list; - + return ret; } + /** * get_event_tag_get_list: * @tag_event: a tagging #GstEvent @@ -852,7 +830,7 @@ gst_event_new_tag (GstTagList *list) * Returns: The #GstTagList of the event */ GstTagList * -gst_event_tag_get_list (GstEvent *tag_event) +gst_event_tag_get_list (GstEvent * tag_event) { g_return_val_if_fail (GST_IS_EVENT (tag_event), NULL); g_return_val_if_fail (GST_EVENT_TYPE (tag_event) == GST_EVENT_TAG, NULL); @@ -873,21 +851,25 @@ gst_event_tag_get_list (GstEvent *tag_event) * or the tag doesn't have as many entries */ G_CONST_RETURN GValue * -gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint index) +gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag, + guint index) { const GValue *value; g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); g_return_val_if_fail (tag != NULL, NULL); - + value = gst_structure_get_value ((GstStructure *) list, tag); - if (value == NULL) return NULL; - + if (value == NULL) + return NULL; + if (GST_VALUE_HOLDS_LIST (value)) { - if (index >= gst_value_list_get_size (value)) return NULL; + if (index >= gst_value_list_get_size (value)) + return NULL; return gst_value_list_get_value (value, index); } else { - if (index > 0) return NULL; + if (index > 0) + return NULL; return value; } } @@ -906,20 +888,23 @@ gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint in * given list. */ gboolean -gst_tag_list_copy_value (GValue *dest, const GstTagList *list, const gchar *tag) +gst_tag_list_copy_value (GValue * dest, const GstTagList * list, + const gchar * tag) { const GValue *src; - + g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); g_return_val_if_fail (tag != NULL, FALSE); g_return_val_if_fail (dest != NULL, FALSE); g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE); - + src = gst_structure_get_value ((GstStructure *) list, tag); - if (!src) return FALSE; - - if (G_VALUE_TYPE (src) == GST_TYPE_LIST) { + if (!src) + return FALSE; + + if (G_VALUE_TYPE (src) == GST_TYPE_LIST) { GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag)); + /* must be there or lists aren't allowed */ g_assert (info->merge_func); info->merge_func (dest, src); @@ -979,6 +964,5 @@ TAG_MERGE_FUNCS (uint64, guint64) TAG_MERGE_FUNCS (float, gfloat) TAG_MERGE_FUNCS (double, gdouble) #undef COPY_FUNC - #define COPY_FUNC g_strdup TAG_MERGE_FUNCS (string, gchar *) diff --git a/gst/gsttag.h b/gst/gsttag.h index a91ab8f90..71581ecec 100644 --- a/gst/gsttag.h +++ b/gst/gsttag.h @@ -26,9 +26,8 @@ #include #include -G_BEGIN_DECLS - -typedef enum { +G_BEGIN_DECLS typedef enum +{ GST_TAG_MERGE_UNDEFINED, GST_TAG_MERGE_REPLACE_ALL, GST_TAG_MERGE_REPLACE, @@ -39,190 +38,133 @@ typedef enum { /* add more */ GST_TAG_MERGE_COUNT } GstTagMergeMode; + #define GST_TAG_MODE_IS_VALID(mode) (((mode) > GST_TAG_MERGE_UNDEFINED) && ((mode) < GST_TAG_MERGE_COUNT)) -typedef enum { +typedef enum +{ GST_TAG_FLAG_UNDEFINED, GST_TAG_FLAG_META, GST_TAG_FLAG_ENCODED, GST_TAG_FLAG_DECODED, GST_TAG_FLAG_COUNT } GstTagFlag; + #define GST_TAG_FLAG_IS_VALID(flag) (((flag) > GST_TAG_FLAG_UNDEFINED) && ((flag) < GST_TAG_FLAG_COUNT)) typedef GstStructure GstTagList; + #define GST_TAG_LIST(x) ((GstTagList *) (x)) #define GST_IS_TAG_LIST(x) (gst_is_tag_list (GST_TAG_LIST (x))) #define GST_TYPE_TAG_LIST (gst_tag_list_get_type ()) -typedef void (* GstTagForeachFunc) (const GstTagList *list, const gchar *tag, gpointer user_data); -typedef void (* GstTagMergeFunc) (GValue *dest, const GValue *src); +typedef void (*GstTagForeachFunc) (const GstTagList * list, const gchar * tag, + gpointer user_data); +typedef void (*GstTagMergeFunc) (GValue * dest, const GValue * src); /* initialize tagging system */ -void _gst_tag_initialize (void); -GType gst_tag_list_get_type (void); +void _gst_tag_initialize (void); +GType gst_tag_list_get_type (void); -void gst_tag_register (gchar * name, - GstTagFlag flag, - GType type, - gchar * nick, - gchar * blurb, - GstTagMergeFunc func); +void gst_tag_register (gchar * name, + GstTagFlag flag, + GType type, gchar * nick, gchar * blurb, GstTagMergeFunc func); /* some default merging functions */ -void gst_tag_merge_use_first (GValue * dest, - const GValue * src); -void gst_tag_merge_strings_with_comma (GValue * dest, - const GValue * src); +void gst_tag_merge_use_first (GValue * dest, const GValue * src); +void gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src); /* basic tag support */ -gboolean gst_tag_exists (const gchar * tag); -GType gst_tag_get_type (const gchar * tag); -G_CONST_RETURN gchar * - gst_tag_get_nick (const gchar * tag); -G_CONST_RETURN gchar * - gst_tag_get_description (const gchar * tag); -GstTagFlag gst_tag_get_flag (const gchar * tag); -gboolean gst_tag_is_fixed (const gchar * tag); +gboolean gst_tag_exists (const gchar * tag); +GType gst_tag_get_type (const gchar * tag); +G_CONST_RETURN gchar *gst_tag_get_nick (const gchar * tag); +G_CONST_RETURN gchar *gst_tag_get_description (const gchar * tag); +GstTagFlag gst_tag_get_flag (const gchar * tag); +gboolean gst_tag_is_fixed (const gchar * tag); /* tag lists */ -GstTagList * gst_tag_list_new (void); -gboolean gst_is_tag_list (gconstpointer p); -GstTagList * gst_tag_list_copy (const GstTagList * list); -void gst_tag_list_insert (GstTagList * into, - const GstTagList * from, - GstTagMergeMode mode); -GstTagList * gst_tag_list_merge (const GstTagList * list1, - const GstTagList * list2, - GstTagMergeMode mode); -void gst_tag_list_free (GstTagList * list); -guint gst_tag_list_get_tag_size (const GstTagList * list, - const gchar * tag); -void gst_tag_list_add (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - ...); -void gst_tag_list_add_values (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - ...); -void gst_tag_list_add_valist (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); -void gst_tag_list_add_valist_values (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); -void gst_tag_list_remove_tag (GstTagList * list, - const gchar * tag); -void gst_tag_list_foreach (GstTagList * list, - GstTagForeachFunc func, - gpointer user_data); - -G_CONST_RETURN GValue * - gst_tag_list_get_value_index (const GstTagList * list, - const gchar * tag, - guint index); -gboolean gst_tag_list_copy_value (GValue * dest, - const GstTagList * list, - const gchar * tag); +GstTagList *gst_tag_list_new (void); +gboolean gst_is_tag_list (gconstpointer p); +GstTagList *gst_tag_list_copy (const GstTagList * list); +void gst_tag_list_insert (GstTagList * into, + const GstTagList * from, GstTagMergeMode mode); +GstTagList *gst_tag_list_merge (const GstTagList * list1, + const GstTagList * list2, GstTagMergeMode mode); +void gst_tag_list_free (GstTagList * list); +guint gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag); +void gst_tag_list_add (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, ...); +void gst_tag_list_add_values (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, ...); +void gst_tag_list_add_valist (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, va_list var_args); +void gst_tag_list_add_valist_values (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, va_list var_args); +void gst_tag_list_remove_tag (GstTagList * list, const gchar * tag); +void gst_tag_list_foreach (GstTagList * list, + GstTagForeachFunc func, gpointer user_data); + +G_CONST_RETURN GValue *gst_tag_list_get_value_index (const GstTagList * list, + const gchar * tag, guint index); +gboolean gst_tag_list_copy_value (GValue * dest, + const GstTagList * list, const gchar * tag); /* simplifications (FIXME: do we want them?) */ -gboolean gst_tag_list_get_char (const GstTagList * list, - const gchar * tag, - gchar * value); -gboolean gst_tag_list_get_char_index (const GstTagList * list, - const gchar * tag, - guint index, - gchar * value); -gboolean gst_tag_list_get_uchar (const GstTagList * list, - const gchar * tag, - guchar * value); -gboolean gst_tag_list_get_uchar_index (const GstTagList * list, - const gchar * tag, - guint index, - guchar * value); -gboolean gst_tag_list_get_boolean (const GstTagList * list, - const gchar * tag, - gboolean * value); -gboolean gst_tag_list_get_boolean_index (const GstTagList * list, - const gchar * tag, - guint index, - gboolean * value); -gboolean gst_tag_list_get_int (const GstTagList * list, - const gchar * tag, - gint * value); -gboolean gst_tag_list_get_int_index (const GstTagList * list, - const gchar * tag, - guint index, - gint * value); -gboolean gst_tag_list_get_uint (const GstTagList * list, - const gchar * tag, - guint * value); -gboolean gst_tag_list_get_uint_index (const GstTagList * list, - const gchar * tag, - guint index, - guint * value); -gboolean gst_tag_list_get_long (const GstTagList * list, - const gchar * tag, - glong * value); -gboolean gst_tag_list_get_long_index (const GstTagList * list, - const gchar * tag, - guint index, - glong * value); -gboolean gst_tag_list_get_ulong (const GstTagList * list, - const gchar * tag, - gulong * value); -gboolean gst_tag_list_get_ulong_index (const GstTagList * list, - const gchar * tag, - guint index, - gulong * value); -gboolean gst_tag_list_get_int64 (const GstTagList * list, - const gchar * tag, - gint64 * value); -gboolean gst_tag_list_get_int64_index (const GstTagList * list, - const gchar * tag, - guint index, - gint64 * value); -gboolean gst_tag_list_get_uint64 (const GstTagList * list, - const gchar * tag, - guint64 * value); -gboolean gst_tag_list_get_uint64_index (const GstTagList * list, - const gchar * tag, - guint index, - guint64 * value); -gboolean gst_tag_list_get_float (const GstTagList * list, - const gchar * tag, - gfloat * value); -gboolean gst_tag_list_get_float_index (const GstTagList * list, - const gchar * tag, - guint index, - gfloat * value); -gboolean gst_tag_list_get_double (const GstTagList * list, - const gchar * tag, - gdouble * value); -gboolean gst_tag_list_get_double_index (const GstTagList * list, - const gchar * tag, - guint index, - gdouble * value); -gboolean gst_tag_list_get_string (const GstTagList * list, - const gchar * tag, - gchar ** value); -gboolean gst_tag_list_get_string_index (const GstTagList * list, - const gchar * tag, - guint index, - gchar ** value); -gboolean gst_tag_list_get_pointer (const GstTagList * list, - const gchar * tag, - gpointer * value); -gboolean gst_tag_list_get_pointer_index (const GstTagList * list, - const gchar * tag, - guint index, - gpointer * value); +gboolean gst_tag_list_get_char (const GstTagList * list, + const gchar * tag, gchar * value); +gboolean gst_tag_list_get_char_index (const GstTagList * list, + const gchar * tag, guint index, gchar * value); +gboolean gst_tag_list_get_uchar (const GstTagList * list, + const gchar * tag, guchar * value); +gboolean gst_tag_list_get_uchar_index (const GstTagList * list, + const gchar * tag, guint index, guchar * value); +gboolean gst_tag_list_get_boolean (const GstTagList * list, + const gchar * tag, gboolean * value); +gboolean gst_tag_list_get_boolean_index (const GstTagList * list, + const gchar * tag, guint index, gboolean * value); +gboolean gst_tag_list_get_int (const GstTagList * list, + const gchar * tag, gint * value); +gboolean gst_tag_list_get_int_index (const GstTagList * list, + const gchar * tag, guint index, gint * value); +gboolean gst_tag_list_get_uint (const GstTagList * list, + const gchar * tag, guint * value); +gboolean gst_tag_list_get_uint_index (const GstTagList * list, + const gchar * tag, guint index, guint * value); +gboolean gst_tag_list_get_long (const GstTagList * list, + const gchar * tag, glong * value); +gboolean gst_tag_list_get_long_index (const GstTagList * list, + const gchar * tag, guint index, glong * value); +gboolean gst_tag_list_get_ulong (const GstTagList * list, + const gchar * tag, gulong * value); +gboolean gst_tag_list_get_ulong_index (const GstTagList * list, + const gchar * tag, guint index, gulong * value); +gboolean gst_tag_list_get_int64 (const GstTagList * list, + const gchar * tag, gint64 * value); +gboolean gst_tag_list_get_int64_index (const GstTagList * list, + const gchar * tag, guint index, gint64 * value); +gboolean gst_tag_list_get_uint64 (const GstTagList * list, + const gchar * tag, guint64 * value); +gboolean gst_tag_list_get_uint64_index (const GstTagList * list, + const gchar * tag, guint index, guint64 * value); +gboolean gst_tag_list_get_float (const GstTagList * list, + const gchar * tag, gfloat * value); +gboolean gst_tag_list_get_float_index (const GstTagList * list, + const gchar * tag, guint index, gfloat * value); +gboolean gst_tag_list_get_double (const GstTagList * list, + const gchar * tag, gdouble * value); +gboolean gst_tag_list_get_double_index (const GstTagList * list, + const gchar * tag, guint index, gdouble * value); +gboolean gst_tag_list_get_string (const GstTagList * list, + const gchar * tag, gchar ** value); +gboolean gst_tag_list_get_string_index (const GstTagList * list, + const gchar * tag, guint index, gchar ** value); +gboolean gst_tag_list_get_pointer (const GstTagList * list, + const gchar * tag, gpointer * value); +gboolean gst_tag_list_get_pointer_index (const GstTagList * list, + const gchar * tag, guint index, gpointer * value); /* tag events */ -GstEvent * gst_event_new_tag (GstTagList * list); -GstTagList * gst_event_tag_get_list (GstEvent * tag_event); +GstEvent *gst_event_new_tag (GstTagList * list); +GstTagList *gst_event_tag_get_list (GstEvent * tag_event); /* GStreamer core tags (need to be discussed) */ @@ -262,5 +204,4 @@ GstTagList * gst_event_tag_get_list (GstEvent * tag_event); #define GST_TAG_ALBUM_PEAK "replaygain-album-peak" G_END_DECLS - #endif /* __GST_EVENT_H__ */ diff --git a/gst/gsttaginterface.c b/gst/gsttaginterface.c index a396f9dfc..0f855b68c 100644 --- a/gst/gsttaginterface.c +++ b/gst/gsttaginterface.c @@ -33,40 +33,42 @@ GST_DEBUG_CATEGORY_STATIC (gst_tag_interface_debug); static GQuark gst_tag_key; -typedef struct { - GstTagMergeMode mode; - GstTagList * list; +typedef struct +{ + GstTagMergeMode mode; + GstTagList *list; } GstTagData; GType gst_tag_setter_get_type (void) { static GType tag_setter_type = 0; - - if (! tag_setter_type) { + + if (!tag_setter_type) { static const GTypeInfo tag_setter_info = { - sizeof (GstTagSetterIFace), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ + sizeof (GstTagSetterIFace), /* class_size */ + NULL, /* base_init */ + NULL, /* base_finalize */ NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ + NULL, /* class_finalize */ + NULL, /* class_data */ 0, 0, NULL }; - - GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, "interfaces for tagging"); - + + GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, + "interfaces for tagging"); + tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter", - &tag_setter_info, 0); - + &tag_setter_info, 0); + g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT); gst_tag_key = g_quark_from_static_string ("GST_TAG_SETTER"); } - - return tag_setter_type; + + return tag_setter_type; } static void gst_tag_data_free (gpointer p) @@ -79,7 +81,7 @@ gst_tag_data_free (gpointer p) g_free (data); } static GstTagData * -gst_tag_setter_get_data (GstTagSetter *setter) +gst_tag_setter_get_data (GstTagSetter * setter) { GstTagData *data; @@ -88,11 +90,13 @@ gst_tag_setter_get_data (GstTagSetter *setter) data = g_new (GstTagData, 1); data->list = NULL; data->mode = GST_TAG_MERGE_KEEP; - g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, gst_tag_data_free); + g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, + gst_tag_data_free); } - + return data; } + /** * gst_tag_setter_merge: * @setter: a #GstTagSetter @@ -102,7 +106,8 @@ gst_tag_setter_get_data (GstTagSetter *setter) * Merges the given list into the setter's list using the given mode. */ void -gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeMode mode) +gst_tag_setter_merge (GstTagSetter * setter, const GstTagList * list, + GstTagMergeMode mode) { GstTagData *data; @@ -116,6 +121,7 @@ gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeM gst_tag_list_merge (data->list, list, mode); } } + /** * gst_tag_setter_add: * @setter: a #GstTagSetter @@ -127,7 +133,8 @@ gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeM * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_setter_add (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, ...) { va_list args; @@ -138,6 +145,7 @@ gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag gst_tag_setter_add_valist (setter, mode, tag, args); va_end (args); } + /** * gst_tag_setter_add_values: * @setter: a #GstTagSetter @@ -149,7 +157,8 @@ gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_setter_add_values (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, ...) { va_list args; @@ -160,6 +169,7 @@ gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gch gst_tag_setter_add_valist_values (setter, mode, tag, args); va_end (args); } + /** * gst_tag_setter_add_valist: * @setter: a #GstTagSetter @@ -171,19 +181,21 @@ gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gch * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_setter_add_valist (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagData *data; - + g_return_if_fail (GST_IS_TAG_SETTER (setter)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); data = gst_tag_setter_get_data (setter); if (!data->list) data->list = gst_tag_list_new (); - + gst_tag_list_add_valist (data->list, mode, tag, var_args); } + /** * gst_tag_setter_add_valist_values: * @setter: a #GstTagSetter @@ -195,19 +207,21 @@ gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gch * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_setter_add_valist_values (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagData *data; - + g_return_if_fail (GST_IS_TAG_SETTER (setter)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); data = gst_tag_setter_get_data (setter); if (!data->list) data->list = gst_tag_list_new (); - + gst_tag_list_add_valist_values (data->list, mode, tag, var_args); } + /** * gst_tag_setter_get_list: * @setter: a #GstTagSetter @@ -218,13 +232,14 @@ gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, co * Returns: a current snapshot of the taglist used in the setter * or NULL if none is used. */ -const GstTagList * -gst_tag_setter_get_list (GstTagSetter *setter) +const GstTagList * +gst_tag_setter_get_list (GstTagSetter * setter) { g_return_val_if_fail (GST_IS_TAG_SETTER (setter), NULL); return gst_tag_setter_get_data (setter)->list; } + /** * gst_tag_setter_set_merge_mode: * @setter: a #GstTagSetter @@ -235,13 +250,14 @@ gst_tag_setter_get_list (GstTagSetter *setter) * the tags by this interface and discards tags from events. */ void -gst_tag_setter_set_merge_mode (GstTagSetter *setter, GstTagMergeMode mode) +gst_tag_setter_set_merge_mode (GstTagSetter * setter, GstTagMergeMode mode) { g_return_if_fail (GST_IS_TAG_SETTER (setter)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); gst_tag_setter_get_data (setter)->mode = mode; } + /** * gst_tag_setter_get_merge_mode: * @setter: a #GstTagSetter @@ -252,7 +268,7 @@ gst_tag_setter_set_merge_mode (GstTagSetter *setter, GstTagMergeMode mode) * Returns: the merge mode used inside the element. */ GstTagMergeMode -gst_tag_setter_get_merge_mode (GstTagSetter *setter) +gst_tag_setter_get_merge_mode (GstTagSetter * setter) { g_return_val_if_fail (GST_IS_TAG_SETTER (setter), FALSE); diff --git a/gst/gsttaginterface.h b/gst/gsttaginterface.h index f28f431c1..8ec407ead 100644 --- a/gst/gsttaginterface.h +++ b/gst/gsttaginterface.h @@ -25,15 +25,13 @@ #include G_BEGIN_DECLS - #define GST_TYPE_TAG_SETTER (gst_tag_setter_get_type ()) #define GST_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter)) #define GST_TAG_SETTER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter)) #define GST_IS_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TAG_SETTER)) #define GST_TAG_SETTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_TAG_SETTER, GstTagSetterIFace)) - -typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */ -typedef struct _GstTagSetterIFace GstTagSetterIFace; +typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */ +typedef struct _GstTagSetterIFace GstTagSetterIFace; /* use an empty interface here to allow detection of elements using user-set tags */ @@ -46,38 +44,29 @@ struct _GstTagSetterIFace /* virtual table */ }; -GType gst_tag_setter_get_type (void) G_GNUC_CONST; +GType +gst_tag_setter_get_type (void) + G_GNUC_CONST; -void gst_tag_setter_merge (GstTagSetter * setter, - const GstTagList * list, - GstTagMergeMode mode); -void gst_tag_setter_add (GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - ...); + void gst_tag_setter_merge (GstTagSetter * setter, + const GstTagList * list, GstTagMergeMode mode); + void gst_tag_setter_add (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, ...); -void gst_tag_setter_add_values (GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - ...); + void gst_tag_setter_add_values (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, ...); -void gst_tag_setter_add_valist (GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); + void gst_tag_setter_add_valist (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, va_list var_args); -void gst_tag_setter_add_valist_values(GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); + void gst_tag_setter_add_valist_values (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, va_list var_args); -G_CONST_RETURN GstTagList * - gst_tag_setter_get_list (GstTagSetter * setter); + G_CONST_RETURN GstTagList *gst_tag_setter_get_list (GstTagSetter * setter); -void gst_tag_setter_set_merge_mode (GstTagSetter * setter, - GstTagMergeMode mode); -GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter); + void gst_tag_setter_set_merge_mode (GstTagSetter * setter, + GstTagMergeMode mode); + GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter); G_END_DECLS - #endif /* __GST_TAG_INTERFACE_H__ */ diff --git a/gst/gsttaglist.c b/gst/gsttaglist.c index 439da9727..88c632364 100644 --- a/gst/gsttaglist.c +++ b/gst/gsttaglist.c @@ -34,20 +34,22 @@ #define GST_TAG_IS_VALID(tag) (gst_tag_get_info (tag) != NULL) -typedef struct { - GType type; /* type the data is in */ +typedef struct +{ + GType type; /* type the data is in */ - gchar * nick; /* translated name */ - gchar * blurb; /* translated description of type */ + gchar *nick; /* translated name */ + gchar *blurb; /* translated description of type */ - GstTagMergeFunc merge_func; /* functions to merge the values */ - GstTagFlag flag; /* type of tag */ + GstTagMergeFunc merge_func; /* functions to merge the values */ + GstTagFlag flag; /* type of tag */ } GstTagInfo; #define TAGLIST "taglist" static GQuark gst_tag_list_quark; static GMutex *__tag_mutex; static GHashTable *__tags; + #define TAG_LOCK g_mutex_lock (__tag_mutex) #define TAG_UNLOCK g_mutex_unlock (__tag_mutex) @@ -58,12 +60,11 @@ gst_tag_list_get_type (void) if (_gst_tag_list_type == 0) { _gst_tag_list_type = g_boxed_type_register_static ("GstTagList", - (GBoxedCopyFunc) gst_tag_list_copy, - (GBoxedFreeFunc) gst_tag_list_free); + (GBoxedCopyFunc) gst_tag_list_copy, (GBoxedFreeFunc) gst_tag_list_free); #if 0 - g_value_register_transform_func(_gst_tag_list_type, G_TYPE_STRING, - _gst_structure_transform_to_string); + g_value_register_transform_func (_gst_tag_list_type, G_TYPE_STRING, + _gst_structure_transform_to_string); #endif } @@ -77,176 +78,117 @@ _gst_tag_initialize (void) __tag_mutex = g_mutex_new (); __tags = g_hash_table_new (g_direct_hash, g_direct_equal); gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("title"), - _("commonly used title"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("title"), _("commonly used title"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_ARTIST, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("artist"), - _("person(s) responsible for the recording"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("artist"), + _("person(s) responsible for the recording"), + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_ALBUM, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("album"), - _("album containing this data"), - gst_tag_merge_strings_with_comma); - gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, - G_TYPE_UINT, /* FIXME: own data type for dates? */ - _("date"), - _("date the data was created (in Julian calendar days)"), - NULL); + G_TYPE_STRING, + _("album"), + _("album containing this data"), gst_tag_merge_strings_with_comma); + gst_tag_register (GST_TAG_DATE, GST_TAG_FLAG_META, G_TYPE_UINT, /* FIXME: own data type for dates? */ + _("date"), + _("date the data was created (in Julian calendar days)"), NULL); gst_tag_register (GST_TAG_GENRE, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("genre"), - _("genre this data belongs to"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("genre"), + _("genre this data belongs to"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_COMMENT, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("comment"), - _("free text commenting the data"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("comment"), + _("free text commenting the data"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_TRACK_NUMBER, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("track number"), - _("track number inside a collection"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("track number"), + _("track number inside a collection"), gst_tag_merge_use_first); gst_tag_register (GST_TAG_TRACK_COUNT, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("track count"), - _("count of tracks inside collection this track belongs to"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("track count"), + _("count of tracks inside collection this track belongs to"), + gst_tag_merge_use_first); gst_tag_register (GST_TAG_ALBUM_VOLUME_NUMBER, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("disc number"), - _("disc number inside a collection"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("disc number"), + _("disc number inside a collection"), gst_tag_merge_use_first); gst_tag_register (GST_TAG_ALBUM_VOLUME_COUNT, GST_TAG_FLAG_META, - G_TYPE_UINT, - _("disc count"), - _("count of discs inside collection this disc belongs to"), - gst_tag_merge_use_first); + G_TYPE_UINT, + _("disc count"), + _("count of discs inside collection this disc belongs to"), + gst_tag_merge_use_first); gst_tag_register (GST_TAG_LOCATION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("location"), - _("original location of file as a URI"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("location"), + _("original location of file as a URI"), + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_DESCRIPTION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("description"), - _("short text describing the content of the data"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("description"), + _("short text describing the content of the data"), + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_VERSION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("version"), - _("version of this data"), - NULL); + G_TYPE_STRING, _("version"), _("version of this data"), NULL); gst_tag_register (GST_TAG_ISRC, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("ISRC"), - _("International Standard Recording Code - see http://www.ifpi.org/isrc/"), - NULL); - gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("organization"), - _("organization"), /* FIXME */ - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("ISRC"), + _ + ("International Standard Recording Code - see http://www.ifpi.org/isrc/"), + NULL); + gst_tag_register (GST_TAG_ORGANIZATION, GST_TAG_FLAG_META, G_TYPE_STRING, _("organization"), _("organization"), /* FIXME */ + gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_COPYRIGHT, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("copyright"), - _("copyright notice of the data"), - NULL); + G_TYPE_STRING, _("copyright"), _("copyright notice of the data"), NULL); gst_tag_register (GST_TAG_CONTACT, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("contact"), - _("contact information"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("contact"), _("contact information"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_LICENSE, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("license"), - _("license of data"), - NULL); + G_TYPE_STRING, _("license"), _("license of data"), NULL); gst_tag_register (GST_TAG_PERFORMER, GST_TAG_FLAG_META, - G_TYPE_STRING, - _("performer"), - _("person(s) performing"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("performer"), + _("person(s) performing"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_DURATION, GST_TAG_FLAG_DECODED, - G_TYPE_UINT64, - _("duration"), - _("length in GStreamer time units (nanoseconds)"), - NULL); + G_TYPE_UINT64, + _("duration"), _("length in GStreamer time units (nanoseconds)"), NULL); gst_tag_register (GST_TAG_CODEC, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("codec"), - _("codec the data is stored in"), - gst_tag_merge_strings_with_comma); + G_TYPE_STRING, + _("codec"), + _("codec the data is stored in"), gst_tag_merge_strings_with_comma); gst_tag_register (GST_TAG_VIDEO_CODEC, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("video codec"), - _("codec the video data is stored in"), - NULL); + G_TYPE_STRING, + _("video codec"), _("codec the video data is stored in"), NULL); gst_tag_register (GST_TAG_AUDIO_CODEC, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("audio codec"), - _("codec the audio data is stored in"), - NULL); + G_TYPE_STRING, + _("audio codec"), _("codec the audio data is stored in"), NULL); gst_tag_register (GST_TAG_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("bitrate"), - _("exact or average bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("bitrate"), _("exact or average bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_NOMINAL_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("nominal bitrate"), - _("nominal bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("nominal bitrate"), _("nominal bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_MINIMUM_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("minimum bitrate"), - _("minimum bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("minimum bitrate"), _("minimum bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_MAXIMUM_BITRATE, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("maximum bitrate"), - _("maximum bitrate in bits/s"), - NULL); + G_TYPE_UINT, _("maximum bitrate"), _("maximum bitrate in bits/s"), NULL); gst_tag_register (GST_TAG_ENCODER, GST_TAG_FLAG_ENCODED, - G_TYPE_STRING, - _("encoder"), - _("encoder used to encode this stream"), - NULL); + G_TYPE_STRING, + _("encoder"), _("encoder used to encode this stream"), NULL); gst_tag_register (GST_TAG_ENCODER_VERSION, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("encoder version"), - _("version of the encoder used to encode this stream"), - NULL); + G_TYPE_UINT, + _("encoder version"), + _("version of the encoder used to encode this stream"), NULL); gst_tag_register (GST_TAG_SERIAL, GST_TAG_FLAG_ENCODED, - G_TYPE_UINT, - _("serial"), - _("serial number of track"), - NULL); + G_TYPE_UINT, _("serial"), _("serial number of track"), NULL); gst_tag_register (GST_TAG_TRACK_GAIN, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain track gain"), - _("track gain in db"), - NULL); + G_TYPE_DOUBLE, _("replaygain track gain"), _("track gain in db"), NULL); gst_tag_register (GST_TAG_TRACK_PEAK, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain track peak"), - _("peak of the track"), - NULL); + G_TYPE_DOUBLE, _("replaygain track peak"), _("peak of the track"), NULL); gst_tag_register (GST_TAG_ALBUM_GAIN, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain album gain"), - _("album gain in db"), - NULL); + G_TYPE_DOUBLE, _("replaygain album gain"), _("album gain in db"), NULL); gst_tag_register (GST_TAG_ALBUM_PEAK, GST_TAG_FLAG_META, - G_TYPE_DOUBLE, - _("replaygain album peak"), - _("peak of the album"), - NULL); + G_TYPE_DOUBLE, _("replaygain album peak"), _("peak of the album"), NULL); } + /** * gst_tag_merge_use_first: * @dest: uninitialized GValue to store result in @@ -256,13 +198,14 @@ _gst_tag_initialize (void) * It creates a copy of the first value from the list. */ void -gst_tag_merge_use_first (GValue *dest, const GValue *src) +gst_tag_merge_use_first (GValue * dest, const GValue * src) { const GValue *ret = gst_value_list_get_value (src, 0); g_value_init (dest, G_VALUE_TYPE (ret)); g_value_copy (ret, dest); } + /** * gst_tag_merge_strings_with_comma: * @dest: uninitialized GValue to store result in @@ -273,7 +216,7 @@ gst_tag_merge_use_first (GValue *dest, const GValue *src) * as a G_TYPE_STRING or this function will fail. */ void -gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src) +gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src) { GString *str; gint i, count; @@ -283,7 +226,9 @@ gst_tag_merge_strings_with_comma (GValue *dest, const GValue *src) for (i = 1; i < count; i++) { /* seperator between two string */ str = g_string_append (str, _(", ")); - str = g_string_append (str, g_value_get_string (gst_value_list_get_value (src, 1))); + str = + g_string_append (str, g_value_get_string (gst_value_list_get_value (src, + 1))); } g_value_init (dest, G_TYPE_STRING); @@ -294,13 +239,14 @@ static GstTagInfo * gst_tag_lookup (GQuark entry) { GstTagInfo *ret; - + TAG_LOCK; ret = g_hash_table_lookup (__tags, GUINT_TO_POINTER (entry)); TAG_UNLOCK; return ret; } + /** * gst_tag_register: * @name: the name or identifier string @@ -317,8 +263,8 @@ gst_tag_lookup (GQuark entry) * This function takes ownership of all supplied variables. */ void -gst_tag_register (gchar *name, GstTagFlag flag, GType type, - gchar *nick, gchar *blurb, GstTagMergeFunc func) +gst_tag_register (gchar * name, GstTagFlag flag, GType type, + gchar * nick, gchar * blurb, GstTagMergeFunc func) { GQuark key; GstTagInfo *info; @@ -327,22 +273,23 @@ gst_tag_register (gchar *name, GstTagFlag flag, GType type, g_return_if_fail (nick != NULL); g_return_if_fail (blurb != NULL); g_return_if_fail (type != 0 && type != GST_TYPE_LIST); - + key = g_quark_from_string (name); info = gst_tag_lookup (key); g_return_if_fail (info == NULL); - + info = g_new (GstTagInfo, 1); info->flag = flag; info->type = type; info->nick = nick; info->blurb = blurb; info->merge_func = func; - + TAG_LOCK; g_hash_table_insert (__tags, GUINT_TO_POINTER (key), info); TAG_UNLOCK; } + /** * gst_tag_exists: * @tag: name of the tag @@ -352,12 +299,13 @@ gst_tag_register (gchar *name, GstTagFlag flag, GType type, * Returns: TRUE if the type is already registered */ gboolean -gst_tag_exists (const gchar *tag) +gst_tag_exists (const gchar * tag) { g_return_val_if_fail (tag != NULL, FALSE); - + return gst_tag_lookup (g_quark_from_string (tag)) != NULL; } + /** * gst_tag_get_type: * @tag: the tag @@ -367,16 +315,17 @@ gst_tag_exists (const gchar *tag) * Returns: the #GType of this tag */ GType -gst_tag_get_type (const gchar *tag) +gst_tag_get_type (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, 0); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, 0); - + return info->type; } + /** * gst_tag_get_nick * @tag: the tag @@ -387,16 +336,17 @@ gst_tag_get_type (const gchar *tag) * Returns: the human-readable name of this tag */ const gchar * -gst_tag_get_nick (const gchar *tag) +gst_tag_get_nick (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, NULL); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, NULL); - + return info->nick; } + /** * gst_tag_get_description: * @tag: the tag @@ -407,14 +357,14 @@ gst_tag_get_nick (const gchar *tag) * Return the human-readable description of this tag */ const gchar * -gst_tag_get_description (const gchar *tag) +gst_tag_get_description (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, NULL); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, NULL); - + return info->blurb; } @@ -425,7 +375,7 @@ gst_tag_get_description (const gchar *tag) * Returns the flag of this tag. */ GstTagFlag -gst_tag_get_flag (const gchar *tag) +gst_tag_get_flag (const gchar * tag) { GstTagInfo *info; @@ -446,16 +396,17 @@ gst_tag_get_flag (const gchar *tag) * Returns: TRUE, if the given tag is fixed. */ gboolean -gst_tag_is_fixed (const gchar *tag) +gst_tag_is_fixed (const gchar * tag) { GstTagInfo *info; - + g_return_val_if_fail (tag != NULL, FALSE); info = gst_tag_lookup (g_quark_from_string (tag)); g_return_val_if_fail (info != NULL, FALSE); - + return info->merge_func == NULL; } + /** * gst_tag_list_new: * @@ -468,6 +419,7 @@ gst_tag_list_new (void) { return GST_TAG_LIST (gst_structure_new (TAGLIST, NULL)); } + /** * gst_is_tag_list: * @p: Object that might be a taglist @@ -479,23 +431,26 @@ gst_tag_list_new (void) gboolean gst_is_tag_list (gconstpointer p) { - g_return_val_if_fail (p != NULL, FALSE); + g_return_val_if_fail (p != NULL, FALSE); return ((GstStructure *) p)->name == gst_tag_list_quark; } -typedef struct { - GstStructure * list; - GstTagMergeMode mode; +typedef struct +{ + GstStructure *list; + GstTagMergeMode mode; } GstTagCopyData; static void -gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuark tag, GValue *value) +gst_tag_list_add_value_internal (GstStructure * list, GstTagMergeMode mode, + GQuark tag, GValue * value) { GstTagInfo *info = gst_tag_lookup (tag); const GValue *value2; - + g_assert (info != NULL); - if (info->merge_func && (value2 = gst_structure_id_get_value (list, tag)) != NULL) { + if (info->merge_func + && (value2 = gst_structure_id_get_value (list, tag)) != NULL) { GValue dest = { 0, }; switch (mode) { case GST_TAG_MERGE_REPLACE_ALL: @@ -540,7 +495,7 @@ gst_tag_list_add_value_internal (GstStructure *list, GstTagMergeMode mode, GQuar } } static gboolean -gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data) +gst_tag_list_copy_foreach (GQuark tag, GValue * value, gpointer user_data) { GstTagCopyData *copy = (GstTagCopyData *) user_data; @@ -548,6 +503,7 @@ gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data) return TRUE; } + /** * gst_tag_list_insert: * @into: list to merge into @@ -557,10 +513,11 @@ gst_tag_list_copy_foreach (GQuark tag, GValue *value, gpointer user_data) * Inserts the tags of the second list into the first list using the given mode. */ void -gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode mode) +gst_tag_list_insert (GstTagList * into, const GstTagList * from, + GstTagMergeMode mode) { GstTagCopyData data; - + g_return_if_fail (GST_IS_TAG_LIST (into)); g_return_if_fail (GST_IS_TAG_LIST (from)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); @@ -570,8 +527,10 @@ gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode m if (mode == GST_TAG_MERGE_REPLACE_ALL) { gst_structure_remove_all_fields (data.list); } - gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, &data); + gst_structure_foreach ((GstStructure *) from, gst_tag_list_copy_foreach, + &data); } + /** * gst_tag_list_copy: * @list: list to copy @@ -581,12 +540,13 @@ gst_tag_list_insert (GstTagList *into, const GstTagList *from, GstTagMergeMode m * Returns: copy of the given list */ GstTagList * -gst_tag_list_copy (const GstTagList *list) +gst_tag_list_copy (const GstTagList * list) { g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); - + return GST_TAG_LIST (gst_structure_copy ((GstStructure *) list)); } + /** * gst_tag_list_merge: * @list1: first list to merge @@ -599,7 +559,8 @@ gst_tag_list_copy (const GstTagList *list) * Returns: the new list */ GstTagList * -gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMergeMode mode) +gst_tag_list_merge (const GstTagList * list1, const GstTagList * list2, + GstTagMergeMode mode) { g_return_val_if_fail (list1 == NULL || GST_IS_TAG_LIST (list1), NULL); g_return_val_if_fail (list2 == NULL || GST_IS_TAG_LIST (list2), NULL); @@ -619,6 +580,7 @@ gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMerg return ret; } } + /** * gst_tag_list_free: * @list: the list to free @@ -626,11 +588,12 @@ gst_tag_list_merge (const GstTagList *list1, const GstTagList *list2, GstTagMerg * Frees the given list and all associated values. */ void -gst_tag_list_free (GstTagList *list) +gst_tag_list_free (GstTagList * list) { g_return_if_fail (GST_IS_TAG_LIST (list)); gst_structure_free ((GstStructure *) list); } + /** * gst_tag_list_get_tag_size: * @list: a taglist @@ -641,7 +604,7 @@ gst_tag_list_free (GstTagList *list) * Returns: The number of tags stored */ guint -gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag) +gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag) { const GValue *value; @@ -655,6 +618,7 @@ gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag) return gst_value_list_get_size (value); } + /** * gst_tag_list_add: * @list: list to set tags in @@ -665,18 +629,20 @@ gst_tag_list_get_tag_size (const GstTagList *list, const gchar *tag) * Sets the values for the given tags using the specified mode. */ void -gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_list_add (GstTagList * list, GstTagMergeMode mode, const gchar * tag, + ...) { va_list args; g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + va_start (args, tag); gst_tag_list_add_valist (list, mode, tag, args); va_end (args); } + /** * gst_tag_list_add_values: * @list: list to set tags in @@ -687,18 +653,20 @@ gst_tag_list_add (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) * Sets the GValues for the given tags using the specified mode. */ void -gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_list_add_values (GstTagList * list, GstTagMergeMode mode, + const gchar * tag, ...) { va_list args; g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + va_start (args, tag); gst_tag_list_add_valist_values (list, mode, tag, args); va_end (args); } + /** * gst_tag_list_add_valist: * @list: list to set tags in @@ -709,16 +677,17 @@ gst_tag_list_add_values (GstTagList *list, GstTagMergeMode mode, const gchar *ta * Sets the values for the given tags using the specified mode. */ void -gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_list_add_valist (GstTagList * list, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagInfo *info; GQuark quark; gchar *error = NULL; - + g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + while (tag != NULL) { GValue value = { 0, }; quark = g_quark_from_string (tag); @@ -741,6 +710,7 @@ gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *ta tag = va_arg (var_args, gchar *); } } + /** * gst_tag_list_add_valist_values: * @list: list to set tags in @@ -751,23 +721,26 @@ gst_tag_list_add_valist (GstTagList *list, GstTagMergeMode mode, const gchar *ta * Sets the GValues for the given tags using the specified mode. */ void -gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_list_add_valist_values (GstTagList * list, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagInfo *info; GQuark quark; - + g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); g_return_if_fail (tag != NULL); - + while (tag != NULL) { quark = g_quark_from_string (tag); info = gst_tag_lookup (quark); g_return_if_fail (info != NULL); - gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, GValue *)); + gst_tag_list_add_value_internal (list, mode, quark, va_arg (var_args, + GValue *)); tag = va_arg (var_args, gchar *); } } + /** * gst_tag_list_remove_tag: * @list: list to remove tag from @@ -776,26 +749,28 @@ gst_tag_list_add_valist_values (GstTagList *list, GstTagMergeMode mode, const gc * Removes the goven tag from the taglist. */ void -gst_tag_list_remove_tag (GstTagList *list, const gchar *tag) +gst_tag_list_remove_tag (GstTagList * list, const gchar * tag) { g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (tag != NULL); gst_structure_remove_field ((GstStructure *) list, tag); } -typedef struct { - GstTagForeachFunc func; - GstTagList * tag_list; - gpointer data; +typedef struct +{ + GstTagForeachFunc func; + GstTagList *tag_list; + gpointer data; } TagForeachData; static int -structure_foreach_wrapper (GQuark field_id, - GValue *value, gpointer user_data) +structure_foreach_wrapper (GQuark field_id, GValue * value, gpointer user_data) { TagForeachData *data = (TagForeachData *) user_data; + data->func (data->tag_list, g_quark_to_string (field_id), data->data); return TRUE; } + /** * gst_tag_list_foreach: * @list: list to iterate over @@ -806,17 +781,19 @@ structure_foreach_wrapper (GQuark field_id, * is no tag, the function won't be called at all. */ void -gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_data) +gst_tag_list_foreach (GstTagList * list, GstTagForeachFunc func, + gpointer user_data) { TagForeachData data; g_return_if_fail (GST_IS_TAG_LIST (list)); g_return_if_fail (func != NULL); - + data.func = func; data.tag_list = list; data.data = user_data; - gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, &data); + gst_structure_foreach ((GstStructure *) list, structure_foreach_wrapper, + &data); } /***** tag events *****/ @@ -830,19 +807,20 @@ gst_tag_list_foreach (GstTagList *list, GstTagForeachFunc func, gpointer user_da * Returns: a new tag event */ GstEvent * -gst_event_new_tag (GstTagList *list) +gst_event_new_tag (GstTagList * list) { GstEvent *ret; - + g_return_val_if_fail (list == NULL || GST_IS_TAG_LIST (list), NULL); ret = gst_event_new (GST_EVENT_TAG); if (!list) list = gst_tag_list_new (); ret->event_data.structure.structure = (GstStructure *) list; - + return ret; } + /** * get_event_tag_get_list: * @tag_event: a tagging #GstEvent @@ -852,7 +830,7 @@ gst_event_new_tag (GstTagList *list) * Returns: The #GstTagList of the event */ GstTagList * -gst_event_tag_get_list (GstEvent *tag_event) +gst_event_tag_get_list (GstEvent * tag_event) { g_return_val_if_fail (GST_IS_EVENT (tag_event), NULL); g_return_val_if_fail (GST_EVENT_TYPE (tag_event) == GST_EVENT_TAG, NULL); @@ -873,21 +851,25 @@ gst_event_tag_get_list (GstEvent *tag_event) * or the tag doesn't have as many entries */ G_CONST_RETURN GValue * -gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint index) +gst_tag_list_get_value_index (const GstTagList * list, const gchar * tag, + guint index) { const GValue *value; g_return_val_if_fail (GST_IS_TAG_LIST (list), NULL); g_return_val_if_fail (tag != NULL, NULL); - + value = gst_structure_get_value ((GstStructure *) list, tag); - if (value == NULL) return NULL; - + if (value == NULL) + return NULL; + if (GST_VALUE_HOLDS_LIST (value)) { - if (index >= gst_value_list_get_size (value)) return NULL; + if (index >= gst_value_list_get_size (value)) + return NULL; return gst_value_list_get_value (value, index); } else { - if (index > 0) return NULL; + if (index > 0) + return NULL; return value; } } @@ -906,20 +888,23 @@ gst_tag_list_get_value_index (const GstTagList *list, const gchar *tag, guint in * given list. */ gboolean -gst_tag_list_copy_value (GValue *dest, const GstTagList *list, const gchar *tag) +gst_tag_list_copy_value (GValue * dest, const GstTagList * list, + const gchar * tag) { const GValue *src; - + g_return_val_if_fail (GST_IS_TAG_LIST (list), FALSE); g_return_val_if_fail (tag != NULL, FALSE); g_return_val_if_fail (dest != NULL, FALSE); g_return_val_if_fail (G_VALUE_TYPE (dest) == 0, FALSE); - + src = gst_structure_get_value ((GstStructure *) list, tag); - if (!src) return FALSE; - - if (G_VALUE_TYPE (src) == GST_TYPE_LIST) { + if (!src) + return FALSE; + + if (G_VALUE_TYPE (src) == GST_TYPE_LIST) { GstTagInfo *info = gst_tag_lookup (g_quark_from_string (tag)); + /* must be there or lists aren't allowed */ g_assert (info->merge_func); info->merge_func (dest, src); @@ -979,6 +964,5 @@ TAG_MERGE_FUNCS (uint64, guint64) TAG_MERGE_FUNCS (float, gfloat) TAG_MERGE_FUNCS (double, gdouble) #undef COPY_FUNC - #define COPY_FUNC g_strdup TAG_MERGE_FUNCS (string, gchar *) diff --git a/gst/gsttaglist.h b/gst/gsttaglist.h index a91ab8f90..71581ecec 100644 --- a/gst/gsttaglist.h +++ b/gst/gsttaglist.h @@ -26,9 +26,8 @@ #include #include -G_BEGIN_DECLS - -typedef enum { +G_BEGIN_DECLS typedef enum +{ GST_TAG_MERGE_UNDEFINED, GST_TAG_MERGE_REPLACE_ALL, GST_TAG_MERGE_REPLACE, @@ -39,190 +38,133 @@ typedef enum { /* add more */ GST_TAG_MERGE_COUNT } GstTagMergeMode; + #define GST_TAG_MODE_IS_VALID(mode) (((mode) > GST_TAG_MERGE_UNDEFINED) && ((mode) < GST_TAG_MERGE_COUNT)) -typedef enum { +typedef enum +{ GST_TAG_FLAG_UNDEFINED, GST_TAG_FLAG_META, GST_TAG_FLAG_ENCODED, GST_TAG_FLAG_DECODED, GST_TAG_FLAG_COUNT } GstTagFlag; + #define GST_TAG_FLAG_IS_VALID(flag) (((flag) > GST_TAG_FLAG_UNDEFINED) && ((flag) < GST_TAG_FLAG_COUNT)) typedef GstStructure GstTagList; + #define GST_TAG_LIST(x) ((GstTagList *) (x)) #define GST_IS_TAG_LIST(x) (gst_is_tag_list (GST_TAG_LIST (x))) #define GST_TYPE_TAG_LIST (gst_tag_list_get_type ()) -typedef void (* GstTagForeachFunc) (const GstTagList *list, const gchar *tag, gpointer user_data); -typedef void (* GstTagMergeFunc) (GValue *dest, const GValue *src); +typedef void (*GstTagForeachFunc) (const GstTagList * list, const gchar * tag, + gpointer user_data); +typedef void (*GstTagMergeFunc) (GValue * dest, const GValue * src); /* initialize tagging system */ -void _gst_tag_initialize (void); -GType gst_tag_list_get_type (void); +void _gst_tag_initialize (void); +GType gst_tag_list_get_type (void); -void gst_tag_register (gchar * name, - GstTagFlag flag, - GType type, - gchar * nick, - gchar * blurb, - GstTagMergeFunc func); +void gst_tag_register (gchar * name, + GstTagFlag flag, + GType type, gchar * nick, gchar * blurb, GstTagMergeFunc func); /* some default merging functions */ -void gst_tag_merge_use_first (GValue * dest, - const GValue * src); -void gst_tag_merge_strings_with_comma (GValue * dest, - const GValue * src); +void gst_tag_merge_use_first (GValue * dest, const GValue * src); +void gst_tag_merge_strings_with_comma (GValue * dest, const GValue * src); /* basic tag support */ -gboolean gst_tag_exists (const gchar * tag); -GType gst_tag_get_type (const gchar * tag); -G_CONST_RETURN gchar * - gst_tag_get_nick (const gchar * tag); -G_CONST_RETURN gchar * - gst_tag_get_description (const gchar * tag); -GstTagFlag gst_tag_get_flag (const gchar * tag); -gboolean gst_tag_is_fixed (const gchar * tag); +gboolean gst_tag_exists (const gchar * tag); +GType gst_tag_get_type (const gchar * tag); +G_CONST_RETURN gchar *gst_tag_get_nick (const gchar * tag); +G_CONST_RETURN gchar *gst_tag_get_description (const gchar * tag); +GstTagFlag gst_tag_get_flag (const gchar * tag); +gboolean gst_tag_is_fixed (const gchar * tag); /* tag lists */ -GstTagList * gst_tag_list_new (void); -gboolean gst_is_tag_list (gconstpointer p); -GstTagList * gst_tag_list_copy (const GstTagList * list); -void gst_tag_list_insert (GstTagList * into, - const GstTagList * from, - GstTagMergeMode mode); -GstTagList * gst_tag_list_merge (const GstTagList * list1, - const GstTagList * list2, - GstTagMergeMode mode); -void gst_tag_list_free (GstTagList * list); -guint gst_tag_list_get_tag_size (const GstTagList * list, - const gchar * tag); -void gst_tag_list_add (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - ...); -void gst_tag_list_add_values (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - ...); -void gst_tag_list_add_valist (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); -void gst_tag_list_add_valist_values (GstTagList * list, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); -void gst_tag_list_remove_tag (GstTagList * list, - const gchar * tag); -void gst_tag_list_foreach (GstTagList * list, - GstTagForeachFunc func, - gpointer user_data); - -G_CONST_RETURN GValue * - gst_tag_list_get_value_index (const GstTagList * list, - const gchar * tag, - guint index); -gboolean gst_tag_list_copy_value (GValue * dest, - const GstTagList * list, - const gchar * tag); +GstTagList *gst_tag_list_new (void); +gboolean gst_is_tag_list (gconstpointer p); +GstTagList *gst_tag_list_copy (const GstTagList * list); +void gst_tag_list_insert (GstTagList * into, + const GstTagList * from, GstTagMergeMode mode); +GstTagList *gst_tag_list_merge (const GstTagList * list1, + const GstTagList * list2, GstTagMergeMode mode); +void gst_tag_list_free (GstTagList * list); +guint gst_tag_list_get_tag_size (const GstTagList * list, const gchar * tag); +void gst_tag_list_add (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, ...); +void gst_tag_list_add_values (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, ...); +void gst_tag_list_add_valist (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, va_list var_args); +void gst_tag_list_add_valist_values (GstTagList * list, + GstTagMergeMode mode, const gchar * tag, va_list var_args); +void gst_tag_list_remove_tag (GstTagList * list, const gchar * tag); +void gst_tag_list_foreach (GstTagList * list, + GstTagForeachFunc func, gpointer user_data); + +G_CONST_RETURN GValue *gst_tag_list_get_value_index (const GstTagList * list, + const gchar * tag, guint index); +gboolean gst_tag_list_copy_value (GValue * dest, + const GstTagList * list, const gchar * tag); /* simplifications (FIXME: do we want them?) */ -gboolean gst_tag_list_get_char (const GstTagList * list, - const gchar * tag, - gchar * value); -gboolean gst_tag_list_get_char_index (const GstTagList * list, - const gchar * tag, - guint index, - gchar * value); -gboolean gst_tag_list_get_uchar (const GstTagList * list, - const gchar * tag, - guchar * value); -gboolean gst_tag_list_get_uchar_index (const GstTagList * list, - const gchar * tag, - guint index, - guchar * value); -gboolean gst_tag_list_get_boolean (const GstTagList * list, - const gchar * tag, - gboolean * value); -gboolean gst_tag_list_get_boolean_index (const GstTagList * list, - const gchar * tag, - guint index, - gboolean * value); -gboolean gst_tag_list_get_int (const GstTagList * list, - const gchar * tag, - gint * value); -gboolean gst_tag_list_get_int_index (const GstTagList * list, - const gchar * tag, - guint index, - gint * value); -gboolean gst_tag_list_get_uint (const GstTagList * list, - const gchar * tag, - guint * value); -gboolean gst_tag_list_get_uint_index (const GstTagList * list, - const gchar * tag, - guint index, - guint * value); -gboolean gst_tag_list_get_long (const GstTagList * list, - const gchar * tag, - glong * value); -gboolean gst_tag_list_get_long_index (const GstTagList * list, - const gchar * tag, - guint index, - glong * value); -gboolean gst_tag_list_get_ulong (const GstTagList * list, - const gchar * tag, - gulong * value); -gboolean gst_tag_list_get_ulong_index (const GstTagList * list, - const gchar * tag, - guint index, - gulong * value); -gboolean gst_tag_list_get_int64 (const GstTagList * list, - const gchar * tag, - gint64 * value); -gboolean gst_tag_list_get_int64_index (const GstTagList * list, - const gchar * tag, - guint index, - gint64 * value); -gboolean gst_tag_list_get_uint64 (const GstTagList * list, - const gchar * tag, - guint64 * value); -gboolean gst_tag_list_get_uint64_index (const GstTagList * list, - const gchar * tag, - guint index, - guint64 * value); -gboolean gst_tag_list_get_float (const GstTagList * list, - const gchar * tag, - gfloat * value); -gboolean gst_tag_list_get_float_index (const GstTagList * list, - const gchar * tag, - guint index, - gfloat * value); -gboolean gst_tag_list_get_double (const GstTagList * list, - const gchar * tag, - gdouble * value); -gboolean gst_tag_list_get_double_index (const GstTagList * list, - const gchar * tag, - guint index, - gdouble * value); -gboolean gst_tag_list_get_string (const GstTagList * list, - const gchar * tag, - gchar ** value); -gboolean gst_tag_list_get_string_index (const GstTagList * list, - const gchar * tag, - guint index, - gchar ** value); -gboolean gst_tag_list_get_pointer (const GstTagList * list, - const gchar * tag, - gpointer * value); -gboolean gst_tag_list_get_pointer_index (const GstTagList * list, - const gchar * tag, - guint index, - gpointer * value); +gboolean gst_tag_list_get_char (const GstTagList * list, + const gchar * tag, gchar * value); +gboolean gst_tag_list_get_char_index (const GstTagList * list, + const gchar * tag, guint index, gchar * value); +gboolean gst_tag_list_get_uchar (const GstTagList * list, + const gchar * tag, guchar * value); +gboolean gst_tag_list_get_uchar_index (const GstTagList * list, + const gchar * tag, guint index, guchar * value); +gboolean gst_tag_list_get_boolean (const GstTagList * list, + const gchar * tag, gboolean * value); +gboolean gst_tag_list_get_boolean_index (const GstTagList * list, + const gchar * tag, guint index, gboolean * value); +gboolean gst_tag_list_get_int (const GstTagList * list, + const gchar * tag, gint * value); +gboolean gst_tag_list_get_int_index (const GstTagList * list, + const gchar * tag, guint index, gint * value); +gboolean gst_tag_list_get_uint (const GstTagList * list, + const gchar * tag, guint * value); +gboolean gst_tag_list_get_uint_index (const GstTagList * list, + const gchar * tag, guint index, guint * value); +gboolean gst_tag_list_get_long (const GstTagList * list, + const gchar * tag, glong * value); +gboolean gst_tag_list_get_long_index (const GstTagList * list, + const gchar * tag, guint index, glong * value); +gboolean gst_tag_list_get_ulong (const GstTagList * list, + const gchar * tag, gulong * value); +gboolean gst_tag_list_get_ulong_index (const GstTagList * list, + const gchar * tag, guint index, gulong * value); +gboolean gst_tag_list_get_int64 (const GstTagList * list, + const gchar * tag, gint64 * value); +gboolean gst_tag_list_get_int64_index (const GstTagList * list, + const gchar * tag, guint index, gint64 * value); +gboolean gst_tag_list_get_uint64 (const GstTagList * list, + const gchar * tag, guint64 * value); +gboolean gst_tag_list_get_uint64_index (const GstTagList * list, + const gchar * tag, guint index, guint64 * value); +gboolean gst_tag_list_get_float (const GstTagList * list, + const gchar * tag, gfloat * value); +gboolean gst_tag_list_get_float_index (const GstTagList * list, + const gchar * tag, guint index, gfloat * value); +gboolean gst_tag_list_get_double (const GstTagList * list, + const gchar * tag, gdouble * value); +gboolean gst_tag_list_get_double_index (const GstTagList * list, + const gchar * tag, guint index, gdouble * value); +gboolean gst_tag_list_get_string (const GstTagList * list, + const gchar * tag, gchar ** value); +gboolean gst_tag_list_get_string_index (const GstTagList * list, + const gchar * tag, guint index, gchar ** value); +gboolean gst_tag_list_get_pointer (const GstTagList * list, + const gchar * tag, gpointer * value); +gboolean gst_tag_list_get_pointer_index (const GstTagList * list, + const gchar * tag, guint index, gpointer * value); /* tag events */ -GstEvent * gst_event_new_tag (GstTagList * list); -GstTagList * gst_event_tag_get_list (GstEvent * tag_event); +GstEvent *gst_event_new_tag (GstTagList * list); +GstTagList *gst_event_tag_get_list (GstEvent * tag_event); /* GStreamer core tags (need to be discussed) */ @@ -262,5 +204,4 @@ GstTagList * gst_event_tag_get_list (GstEvent * tag_event); #define GST_TAG_ALBUM_PEAK "replaygain-album-peak" G_END_DECLS - #endif /* __GST_EVENT_H__ */ diff --git a/gst/gsttagsetter.c b/gst/gsttagsetter.c index a396f9dfc..0f855b68c 100644 --- a/gst/gsttagsetter.c +++ b/gst/gsttagsetter.c @@ -33,40 +33,42 @@ GST_DEBUG_CATEGORY_STATIC (gst_tag_interface_debug); static GQuark gst_tag_key; -typedef struct { - GstTagMergeMode mode; - GstTagList * list; +typedef struct +{ + GstTagMergeMode mode; + GstTagList *list; } GstTagData; GType gst_tag_setter_get_type (void) { static GType tag_setter_type = 0; - - if (! tag_setter_type) { + + if (!tag_setter_type) { static const GTypeInfo tag_setter_info = { - sizeof (GstTagSetterIFace), /* class_size */ - NULL, /* base_init */ - NULL, /* base_finalize */ + sizeof (GstTagSetterIFace), /* class_size */ + NULL, /* base_init */ + NULL, /* base_finalize */ NULL, - NULL, /* class_finalize */ - NULL, /* class_data */ + NULL, /* class_finalize */ + NULL, /* class_data */ 0, 0, NULL }; - - GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, "interfaces for tagging"); - + + GST_DEBUG_CATEGORY_INIT (gst_tag_interface_debug, "GstTagInterface", 0, + "interfaces for tagging"); + tag_setter_type = g_type_register_static (G_TYPE_INTERFACE, "GstTagSetter", - &tag_setter_info, 0); - + &tag_setter_info, 0); + g_type_interface_add_prerequisite (tag_setter_type, GST_TYPE_ELEMENT); gst_tag_key = g_quark_from_static_string ("GST_TAG_SETTER"); } - - return tag_setter_type; + + return tag_setter_type; } static void gst_tag_data_free (gpointer p) @@ -79,7 +81,7 @@ gst_tag_data_free (gpointer p) g_free (data); } static GstTagData * -gst_tag_setter_get_data (GstTagSetter *setter) +gst_tag_setter_get_data (GstTagSetter * setter) { GstTagData *data; @@ -88,11 +90,13 @@ gst_tag_setter_get_data (GstTagSetter *setter) data = g_new (GstTagData, 1); data->list = NULL; data->mode = GST_TAG_MERGE_KEEP; - g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, gst_tag_data_free); + g_object_set_qdata_full (G_OBJECT (setter), gst_tag_key, data, + gst_tag_data_free); } - + return data; } + /** * gst_tag_setter_merge: * @setter: a #GstTagSetter @@ -102,7 +106,8 @@ gst_tag_setter_get_data (GstTagSetter *setter) * Merges the given list into the setter's list using the given mode. */ void -gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeMode mode) +gst_tag_setter_merge (GstTagSetter * setter, const GstTagList * list, + GstTagMergeMode mode) { GstTagData *data; @@ -116,6 +121,7 @@ gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeM gst_tag_list_merge (data->list, list, mode); } } + /** * gst_tag_setter_add: * @setter: a #GstTagSetter @@ -127,7 +133,8 @@ gst_tag_setter_merge (GstTagSetter *setter, const GstTagList *list, GstTagMergeM * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_setter_add (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, ...) { va_list args; @@ -138,6 +145,7 @@ gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag gst_tag_setter_add_valist (setter, mode, tag, args); va_end (args); } + /** * gst_tag_setter_add_values: * @setter: a #GstTagSetter @@ -149,7 +157,8 @@ gst_tag_setter_add (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, ...) +gst_tag_setter_add_values (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, ...) { va_list args; @@ -160,6 +169,7 @@ gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gch gst_tag_setter_add_valist_values (setter, mode, tag, args); va_end (args); } + /** * gst_tag_setter_add_valist: * @setter: a #GstTagSetter @@ -171,19 +181,21 @@ gst_tag_setter_add_values (GstTagSetter *setter, GstTagMergeMode mode, const gch * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_setter_add_valist (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagData *data; - + g_return_if_fail (GST_IS_TAG_SETTER (setter)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); data = gst_tag_setter_get_data (setter); if (!data->list) data->list = gst_tag_list_new (); - + gst_tag_list_add_valist (data->list, mode, tag, var_args); } + /** * gst_tag_setter_add_valist_values: * @setter: a #GstTagSetter @@ -195,19 +207,21 @@ gst_tag_setter_add_valist (GstTagSetter *setter, GstTagMergeMode mode, const gch * The list must be terminated with GST_TAG_INVALID. */ void -gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, const gchar *tag, va_list var_args) +gst_tag_setter_add_valist_values (GstTagSetter * setter, GstTagMergeMode mode, + const gchar * tag, va_list var_args) { GstTagData *data; - + g_return_if_fail (GST_IS_TAG_SETTER (setter)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); data = gst_tag_setter_get_data (setter); if (!data->list) data->list = gst_tag_list_new (); - + gst_tag_list_add_valist_values (data->list, mode, tag, var_args); } + /** * gst_tag_setter_get_list: * @setter: a #GstTagSetter @@ -218,13 +232,14 @@ gst_tag_setter_add_valist_values (GstTagSetter *setter, GstTagMergeMode mode, co * Returns: a current snapshot of the taglist used in the setter * or NULL if none is used. */ -const GstTagList * -gst_tag_setter_get_list (GstTagSetter *setter) +const GstTagList * +gst_tag_setter_get_list (GstTagSetter * setter) { g_return_val_if_fail (GST_IS_TAG_SETTER (setter), NULL); return gst_tag_setter_get_data (setter)->list; } + /** * gst_tag_setter_set_merge_mode: * @setter: a #GstTagSetter @@ -235,13 +250,14 @@ gst_tag_setter_get_list (GstTagSetter *setter) * the tags by this interface and discards tags from events. */ void -gst_tag_setter_set_merge_mode (GstTagSetter *setter, GstTagMergeMode mode) +gst_tag_setter_set_merge_mode (GstTagSetter * setter, GstTagMergeMode mode) { g_return_if_fail (GST_IS_TAG_SETTER (setter)); g_return_if_fail (GST_TAG_MODE_IS_VALID (mode)); gst_tag_setter_get_data (setter)->mode = mode; } + /** * gst_tag_setter_get_merge_mode: * @setter: a #GstTagSetter @@ -252,7 +268,7 @@ gst_tag_setter_set_merge_mode (GstTagSetter *setter, GstTagMergeMode mode) * Returns: the merge mode used inside the element. */ GstTagMergeMode -gst_tag_setter_get_merge_mode (GstTagSetter *setter) +gst_tag_setter_get_merge_mode (GstTagSetter * setter) { g_return_val_if_fail (GST_IS_TAG_SETTER (setter), FALSE); diff --git a/gst/gsttagsetter.h b/gst/gsttagsetter.h index f28f431c1..8ec407ead 100644 --- a/gst/gsttagsetter.h +++ b/gst/gsttagsetter.h @@ -25,15 +25,13 @@ #include G_BEGIN_DECLS - #define GST_TYPE_TAG_SETTER (gst_tag_setter_get_type ()) #define GST_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter)) #define GST_TAG_SETTER_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GST_TYPE_TAG_SETTER, GstTagSetter)) #define GST_IS_TAG_SETTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TAG_SETTER)) #define GST_TAG_SETTER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_TAG_SETTER, GstTagSetterIFace)) - -typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */ -typedef struct _GstTagSetterIFace GstTagSetterIFace; +typedef struct _GstTagSetter GstTagSetter; /* Dummy typedef */ +typedef struct _GstTagSetterIFace GstTagSetterIFace; /* use an empty interface here to allow detection of elements using user-set tags */ @@ -46,38 +44,29 @@ struct _GstTagSetterIFace /* virtual table */ }; -GType gst_tag_setter_get_type (void) G_GNUC_CONST; +GType +gst_tag_setter_get_type (void) + G_GNUC_CONST; -void gst_tag_setter_merge (GstTagSetter * setter, - const GstTagList * list, - GstTagMergeMode mode); -void gst_tag_setter_add (GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - ...); + void gst_tag_setter_merge (GstTagSetter * setter, + const GstTagList * list, GstTagMergeMode mode); + void gst_tag_setter_add (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, ...); -void gst_tag_setter_add_values (GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - ...); + void gst_tag_setter_add_values (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, ...); -void gst_tag_setter_add_valist (GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); + void gst_tag_setter_add_valist (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, va_list var_args); -void gst_tag_setter_add_valist_values(GstTagSetter * setter, - GstTagMergeMode mode, - const gchar * tag, - va_list var_args); + void gst_tag_setter_add_valist_values (GstTagSetter * setter, + GstTagMergeMode mode, const gchar * tag, va_list var_args); -G_CONST_RETURN GstTagList * - gst_tag_setter_get_list (GstTagSetter * setter); + G_CONST_RETURN GstTagList *gst_tag_setter_get_list (GstTagSetter * setter); -void gst_tag_setter_set_merge_mode (GstTagSetter * setter, - GstTagMergeMode mode); -GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter); + void gst_tag_setter_set_merge_mode (GstTagSetter * setter, + GstTagMergeMode mode); + GstTagMergeMode gst_tag_setter_get_merge_mode (GstTagSetter * setter); G_END_DECLS - #endif /* __GST_TAG_INTERFACE_H__ */ diff --git a/gst/gstthread.c b/gst/gstthread.c index b0eac6289..1a66685a9 100644 --- a/gst/gstthread.c +++ b/gst/gstthread.c @@ -32,74 +32,75 @@ #define GST_CAT_DEFAULT GST_CAT_THREAD #define STACK_SIZE 0x200000 -static GstElementDetails gst_thread_details = GST_ELEMENT_DETAILS ( - "Threaded container", - "Generic/Bin", - "Container that creates/manages a thread", - "Erik Walthinsen , " - "Benjamin Otte , " + "Benjamin Otte dispose = gst_thread_dispose; + gobject_class->dispose = gst_thread_dispose; #ifndef GST_DISABLE_LOADSAVE - gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_thread_save_thyself); - gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_thread_restore_thyself); + gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_thread_save_thyself); + gstobject_class->restore_thyself = + GST_DEBUG_FUNCPTR (gst_thread_restore_thyself); #endif - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_thread_change_state); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_thread_change_state); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_thread_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_thread_get_property); - gstbin_class->child_state_change = GST_DEBUG_FUNCPTR (gst_thread_child_state_change); + gstbin_class->child_state_change = + GST_DEBUG_FUNCPTR (gst_thread_child_state_change); } static void -gst_thread_init (GTypeInstance *instance, gpointer g_class) +gst_thread_init (GTypeInstance * instance, gpointer g_class) { GstScheduler *scheduler; GstThread *thread = GST_THREAD (instance); @@ -198,12 +207,12 @@ gst_thread_init (GTypeInstance *instance, gpointer g_class) thread->lock = g_mutex_new (); thread->cond = g_cond_new (); - thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */ + thread->thread_id = (GThread *) NULL; /* set in NULL -> READY */ thread->priority = G_THREAD_PRIORITY_NORMAL; } static void -gst_thread_dispose (GObject *object) +gst_thread_dispose (GObject * object) { GstThread *thread = GST_THREAD (object); @@ -216,7 +225,7 @@ gst_thread_dispose (GObject *object) g_mutex_free (thread->lock); g_cond_free (thread->cond); - gst_object_replace ((GstObject **)&GST_ELEMENT_SCHED (thread), NULL); + gst_object_replace ((GstObject **) & GST_ELEMENT_SCHED (thread), NULL); } /** @@ -227,7 +236,7 @@ gst_thread_dispose (GObject *object) * change the thread's priority */ void -gst_thread_set_priority (GstThread *thread, GThreadPriority priority) +gst_thread_set_priority (GstThread * thread, GThreadPriority priority) { g_return_if_fail (GST_IS_THREAD (thread)); @@ -235,7 +244,8 @@ gst_thread_set_priority (GstThread *thread, GThreadPriority priority) } static void -gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_thread_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstThread *thread; @@ -252,7 +262,8 @@ gst_thread_set_property (GObject *object, guint prop_id, const GValue *value, GP } static void -gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_thread_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstThread *thread; @@ -277,8 +288,8 @@ gst_thread_get_property (GObject *object, guint prop_id, GValue *value, GParamSp * * Returns: The new thread */ -GstElement* -gst_thread_new (const gchar *name) +GstElement * +gst_thread_new (const gchar * name) { return gst_element_factory_make ("thread", name); } @@ -298,7 +309,7 @@ gst_thread_get_current (void) } static inline void -gst_thread_release_children_locks (GstThread *thread) +gst_thread_release_children_locks (GstThread * thread) { GstRealPad *peer = NULL; GstElement *peerelement; @@ -309,17 +320,19 @@ gst_thread_release_children_locks (GstThread *thread) GList *pads; g_assert (element); - GST_DEBUG_OBJECT (thread, "waking element \"%s\"", GST_ELEMENT_NAME (element)); + GST_DEBUG_OBJECT (thread, "waking element \"%s\"", + GST_ELEMENT_NAME (element)); elements = g_list_next (elements); if (!gst_element_release_locks (element)) - g_warning ("element %s could not release locks", GST_ELEMENT_NAME (element)); + g_warning ("element %s could not release locks", + GST_ELEMENT_NAME (element)); pads = GST_ELEMENT_PADS (element); while (pads) { if (GST_PAD_PEER (pads->data)) { - peer = GST_REAL_PAD (GST_PAD_PEER (pads->data)); + peer = GST_REAL_PAD (GST_PAD_PEER (pads->data)); pads = g_list_next (pads); } else { pads = g_list_next (pads); @@ -327,27 +340,32 @@ gst_thread_release_children_locks (GstThread *thread) } if (!peer) - continue; + continue; peerelement = GST_PAD_PARENT (peer); if (!peerelement) - continue; /* FIXME: deal with case where there's no peer */ + continue; /* FIXME: deal with case where there's no peer */ if (GST_ELEMENT_SCHED (peerelement) != GST_ELEMENT_SCHED (thread)) { - GST_LOG_OBJECT (thread, "element \"%s\" has pad cross sched boundary", GST_ELEMENT_NAME (element)); - GST_LOG_OBJECT (thread, "waking element \"%s\"", GST_ELEMENT_NAME (peerelement)); - if (!gst_element_release_locks (peerelement)) - g_warning ("element %s could not release locks", GST_ELEMENT_NAME (peerelement)); + GST_LOG_OBJECT (thread, "element \"%s\" has pad cross sched boundary", + GST_ELEMENT_NAME (element)); + GST_LOG_OBJECT (thread, "waking element \"%s\"", + GST_ELEMENT_NAME (peerelement)); + if (!gst_element_release_locks (peerelement)) + g_warning ("element %s could not release locks", + GST_ELEMENT_NAME (peerelement)); } } } } + /* stops the main thread, if there is one and grabs the thread's mutex */ static void -gst_thread_catch (GstThread *thread) +gst_thread_catch (GstThread * thread) { gboolean wait; - if (thread == gst_thread_get_current()) { + + if (thread == gst_thread_get_current ()) { /* we're trying to catch ourself */ if (!GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) { g_mutex_lock (thread->lock); @@ -361,12 +379,13 @@ gst_thread_catch (GstThread *thread) wait = !GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING); while (!wait) { GTimeVal tv; + GST_LOG_OBJECT (thread, "catching thread..."); GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING); g_cond_signal (thread->cond); gst_thread_release_children_locks (thread); g_get_current_time (&tv); - g_time_val_add (&tv, 1000); /* wait a millisecond to catch the thread */ + g_time_val_add (&tv, 1000); /* wait a millisecond to catch the thread */ wait = g_cond_timed_wait (thread->cond, thread->lock, &tv); } GST_LOG_OBJECT (thread, "caught thread"); @@ -375,16 +394,16 @@ gst_thread_catch (GstThread *thread) } static void -gst_thread_release (GstThread *thread) +gst_thread_release (GstThread * thread) { - if (thread != gst_thread_get_current()) { + if (thread != gst_thread_get_current ()) { g_cond_signal (thread->cond); g_mutex_unlock (thread->lock); } } static GstElementStateReturn -gst_thread_change_state (GstElement *element) +gst_thread_change_state (GstElement * element) { GstThread *thread; GstElementStateReturn ret; @@ -396,8 +415,8 @@ gst_thread_change_state (GstElement *element) thread = GST_THREAD (element); GST_DEBUG_OBJECT (element, "changing state from %s to %s", - gst_element_state_get_name (GST_STATE (element)), - gst_element_state_get_name (GST_STATE_PENDING (element))); + gst_element_state_get_name (GST_STATE (element)), + gst_element_state_get_name (GST_STATE_PENDING (element))); gst_thread_catch (thread); @@ -412,12 +431,11 @@ gst_thread_change_state (GstElement *element) case GST_STATE_NULL_TO_READY: /* create the thread */ GST_FLAG_UNSET (thread, GST_THREAD_STATE_REAPING); - thread->thread_id = g_thread_create_full(gst_thread_main_loop, - thread, STACK_SIZE, FALSE, TRUE, thread->priority, - NULL); - if (!thread->thread_id){ - GST_ERROR_OBJECT (element, "g_thread_create_full failed"); - goto error_out; + thread->thread_id = g_thread_create_full (gst_thread_main_loop, + thread, STACK_SIZE, FALSE, TRUE, thread->priority, NULL); + if (!thread->thread_id) { + GST_ERROR_OBJECT (element, "g_thread_create_full failed"); + goto error_out; } GST_LOG_OBJECT (element, "GThread created"); @@ -430,21 +448,25 @@ gst_thread_change_state (GstElement *element) { /* FIXME: recurse into sub-bins */ GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread)); + while (elements) { - gst_element_enable_threadsafe_properties ((GstElement*)elements->data); - elements = g_list_next (elements); + gst_element_enable_threadsafe_properties ((GstElement *) elements-> + data); + elements = g_list_next (elements); } /* reset self to spinning */ - if (thread == gst_thread_get_current()) - GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING); + if (thread == gst_thread_get_current ()) + GST_FLAG_SET (thread, GST_THREAD_STATE_SPINNING); break; } case GST_STATE_PLAYING_TO_PAUSED: { GList *elements = (GList *) gst_bin_get_list (GST_BIN (thread)); + while (elements) { - gst_element_disable_threadsafe_properties ((GstElement*)elements->data); - elements = g_list_next (elements); + gst_element_disable_threadsafe_properties ((GstElement *) elements-> + data); + elements = g_list_next (elements); } break; } @@ -456,19 +478,21 @@ gst_thread_change_state (GstElement *element) GST_LOG_OBJECT (thread, "destroying GThread %p", thread->thread_id); GST_FLAG_SET (thread, GST_THREAD_STATE_REAPING); thread->thread_id = NULL; - if (thread == gst_thread_get_current()) { - /* or should we continue? */ - g_warning ("Thread %s is destroying itself. Function call will not return!", GST_ELEMENT_NAME (thread)); - gst_scheduler_reset (GST_ELEMENT_SCHED (thread)); - - /* unlock and signal - we are out */ - gst_thread_release (thread); + if (thread == gst_thread_get_current ()) { + /* or should we continue? */ + g_warning + ("Thread %s is destroying itself. Function call will not return!", + GST_ELEMENT_NAME (thread)); + gst_scheduler_reset (GST_ELEMENT_SCHED (thread)); - GST_INFO_OBJECT (thread, "GThread %p is exiting", g_thread_self()); + /* unlock and signal - we are out */ + gst_thread_release (thread); - g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0); + GST_INFO_OBJECT (thread, "GThread %p is exiting", g_thread_self ()); - g_thread_exit (NULL); + g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0); + + g_thread_exit (NULL); } /* now wait for the thread to destroy itself */ g_cond_signal (thread->cond); @@ -476,13 +500,14 @@ gst_thread_change_state (GstElement *element) /* it should be dead now */ break; default: - GST_ERROR_OBJECT (element, "unhandled state change! %x", - GST_STATE_TRANSITION (element)); - g_warning ("thread %s: UNHANDLED STATE CHANGE! %x", - GST_STR_NULL (GST_OBJECT_NAME (element)), GST_STATE_TRANSITION (element)); + GST_ERROR_OBJECT (element, "unhandled state change! %x", + GST_STATE_TRANSITION (element)); + g_warning ("thread %s: UNHANDLED STATE CHANGE! %x", + GST_STR_NULL (GST_OBJECT_NAME (element)), + GST_STATE_TRANSITION (element)); /* FIXME: not doable with current threading mess: - g_assert_not_reached (); - */ + g_assert_not_reached (); + */ break; } @@ -494,12 +519,12 @@ gst_thread_change_state (GstElement *element) gst_thread_release (thread); return ret; - + error_out: GST_CAT_DEBUG (GST_CAT_STATES, "changing state from %s to %s failed for %s", - gst_element_state_get_name (GST_STATE (element)), - gst_element_state_get_name (GST_STATE_PENDING (element)), - GST_ELEMENT_NAME (element)); + gst_element_state_get_name (GST_STATE (element)), + gst_element_state_get_name (GST_STATE_PENDING (element)), + GST_ELEMENT_NAME (element)); gst_thread_release (thread); return GST_STATE_FAILURE; } @@ -508,13 +533,14 @@ error_out: spinning (via gst_thread_catch) - then we change the state. After that the thread may spin on. */ static void -gst_thread_child_state_change (GstBin *bin, GstElementState oldstate, - GstElementState newstate, GstElement *element) +gst_thread_child_state_change (GstBin * bin, GstElementState oldstate, + GstElementState newstate, GstElement * element) { GST_LOG_OBJECT (bin, "(from thread %s) child %s changed state from %s to %s", - gst_thread_get_current() ? GST_ELEMENT_NAME (gst_thread_get_current()) : "(none)", - GST_ELEMENT_NAME (element), gst_element_state_get_name (oldstate), - gst_element_state_get_name (newstate)); + gst_thread_get_current ()? GST_ELEMENT_NAME (gst_thread_get_current ()) : + "(none)", GST_ELEMENT_NAME (element), + gst_element_state_get_name (oldstate), + gst_element_state_get_name (newstate)); if (parent_class->child_state_change) parent_class->child_state_change (bin, oldstate, newstate, element); /* We'll wake up the main thread now. Note that we can't lock the thread here, @@ -523,6 +549,7 @@ gst_thread_child_state_change (GstBin *bin, GstElementState oldstate, if (newstate == GST_STATE_PLAYING) g_cond_signal (GST_THREAD (bin)->cond); } + /** * gst_thread_main_loop: * @arg: the thread to start @@ -554,12 +581,12 @@ gst_thread_main_loop (void *arg) status = TRUE; GST_LOG_OBJECT (thread, "starting to iterate"); while (status && GST_FLAG_IS_SET (thread, GST_THREAD_STATE_SPINNING)) { - g_mutex_unlock (thread->lock); - status = gst_bin_iterate (GST_BIN (thread)); - if (GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) { + g_mutex_unlock (thread->lock); + status = gst_bin_iterate (GST_BIN (thread)); + if (GST_FLAG_IS_SET (thread, GST_THREAD_MUTEX_LOCKED)) { GST_FLAG_UNSET (thread, GST_THREAD_MUTEX_LOCKED); } else { - g_mutex_lock (thread->lock); + g_mutex_lock (thread->lock); } } GST_FLAG_UNSET (thread, GST_THREAD_STATE_SPINNING); @@ -579,8 +606,8 @@ gst_thread_main_loop (void *arg) g_signal_emit (G_OBJECT (thread), gst_thread_signals[SHUTDOWN], 0); /* unlock and signal - we are out */ - - GST_LOG_OBJECT (thread, "Thread %p exits main loop", g_thread_self()); + + GST_LOG_OBJECT (thread, "Thread %p exits main loop", g_thread_self ()); g_cond_signal (thread->cond); g_mutex_unlock (thread->lock); /* don't assume the GstThread object exists anymore now */ @@ -590,8 +617,7 @@ gst_thread_main_loop (void *arg) #ifndef GST_DISABLE_LOADSAVE static xmlNodePtr -gst_thread_save_thyself (GstObject *object, - xmlNodePtr self) +gst_thread_save_thyself (GstObject * object, xmlNodePtr self) { if (GST_OBJECT_CLASS (parent_class)->save_thyself) GST_OBJECT_CLASS (parent_class)->save_thyself (object, self); @@ -599,8 +625,7 @@ gst_thread_save_thyself (GstObject *object, } static void -gst_thread_restore_thyself (GstObject *object, - xmlNodePtr self) +gst_thread_restore_thyself (GstObject * object, xmlNodePtr self) { GST_LOG_OBJECT (object, "restoring"); diff --git a/gst/gstthread.h b/gst/gstthread.h index 62142bce0..3b7cd3b9f 100644 --- a/gst/gstthread.h +++ b/gst/gstthread.h @@ -29,19 +29,18 @@ #include -G_BEGIN_DECLS +G_BEGIN_DECLS extern GPrivate *gst_thread_current; -extern GPrivate *gst_thread_current; - -typedef enum { - GST_THREAD_STATE_SPINNING = GST_BIN_FLAG_LAST, +typedef enum +{ + GST_THREAD_STATE_SPINNING = GST_BIN_FLAG_LAST, GST_THREAD_STATE_REAPING, /* when iterating with mutex locked (special cases) may only be set by thread itself */ GST_THREAD_MUTEX_LOCKED, /* padding */ - GST_THREAD_FLAG_LAST = GST_BIN_FLAG_LAST + 4 + GST_THREAD_FLAG_LAST = GST_BIN_FLAG_LAST + 4 } GstThreadState; #define GST_TYPE_THREAD (gst_thread_get_type()) @@ -51,38 +50,38 @@ typedef enum { #define GST_IS_THREAD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_THREAD)) #define GST_THREAD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_THREAD, GstThreadClass)) -typedef struct _GstThread GstThread; -typedef struct _GstThreadClass GstThreadClass; +typedef struct _GstThread GstThread; +typedef struct _GstThreadClass GstThreadClass; -struct _GstThread { - GstBin bin; +struct _GstThread +{ + GstBin bin; - GThread *thread_id; /* id of the thread, if any */ + GThread *thread_id; /* id of the thread, if any */ GThreadPriority priority; - GMutex *lock; /* thread lock/condititon pairs */ - GCond *cond; /* used to control the thread */ + GMutex *lock; /* thread lock/condititon pairs */ + GCond *cond; /* used to control the thread */ gpointer _gst_reserved[GST_PADDING]; }; -struct _GstThreadClass { +struct _GstThreadClass +{ GstBinClass parent_class; /* signals */ - void (*shutdown) (GstThread *thread); + void (*shutdown) (GstThread * thread); gpointer _gst_reserved[GST_PADDING]; }; -GType gst_thread_get_type (void); +GType gst_thread_get_type (void); -GstElement* gst_thread_new (const gchar *name); +GstElement *gst_thread_new (const gchar * name); -void gst_thread_set_priority (GstThread *thread, GThreadPriority priority); -GstThread * gst_thread_get_current (void); +void gst_thread_set_priority (GstThread * thread, GThreadPriority priority); +GstThread *gst_thread_get_current (void); G_END_DECLS - - #endif /* __GST_THREAD_H__ */ diff --git a/gst/gstthreaddummy.c b/gst/gstthreaddummy.c index 1f32dd2ee..fedbd589c 100644 --- a/gst/gstthreaddummy.c +++ b/gst/gstthreaddummy.c @@ -23,10 +23,10 @@ #include "gstlog.h" static GMutex *mutex = NULL; -static GCond *cond = NULL; +static GCond *cond = NULL; -static GMutex* -gst_mutex_new_dummy_impl (void) +static GMutex * +gst_mutex_new_dummy_impl (void) { if (!mutex) mutex = g_malloc (8); @@ -34,16 +34,19 @@ gst_mutex_new_dummy_impl (void) return mutex; } -static void gst_mutex_dummy_impl (GMutex *mutex) { /* NOP */ } +static void +gst_mutex_dummy_impl (GMutex * mutex) +{ /* NOP */ +} static gboolean -gst_mutex_trylock_dummy_impl (GMutex *mutex) +gst_mutex_trylock_dummy_impl (GMutex * mutex) { return TRUE; } -static GCond* -gst_cond_new_dummy_impl (void) +static GCond * +gst_cond_new_dummy_impl (void) { if (!cond) cond = g_malloc (8); @@ -52,16 +55,19 @@ gst_cond_new_dummy_impl (void) } static void -gst_cond_dummy_impl (GCond *cond) { /* NOP */ } +gst_cond_dummy_impl (GCond * cond) +{ /* NOP */ +} static gboolean -gst_cond_timed_wait_dummy_impl (GCond *cond, GMutex *mutex, GTimeVal *end_time) +gst_cond_timed_wait_dummy_impl (GCond * cond, GMutex * mutex, + GTimeVal * end_time) { struct timeval tvtarget; GTimeVal tvnow; guint64 now, target; gint64 diff; - + target = end_time->tv_sec * 1000000 + end_time->tv_usec; g_get_current_time (&tvnow); @@ -72,13 +78,13 @@ gst_cond_timed_wait_dummy_impl (GCond *cond, GMutex *mutex, GTimeVal *end_time) tvtarget.tv_usec = diff % 1000000; tvtarget.tv_sec = diff / 1000000; - select(0, NULL, NULL, NULL, &tvtarget); + select (0, NULL, NULL, NULL, &tvtarget); } - + return TRUE; } -static GPrivate* +static GPrivate * gst_private_new_dummy_impl (GDestroyNotify destructor) { gpointer data; @@ -89,35 +95,41 @@ gst_private_new_dummy_impl (GDestroyNotify destructor) } static gpointer -gst_private_get_dummy_impl (GPrivate *private_key) +gst_private_get_dummy_impl (GPrivate * private_key) { gpointer *data = (gpointer) private_key; - + return *data; } static void -gst_private_set_dummy_impl (GPrivate *private_key, gpointer data) +gst_private_set_dummy_impl (GPrivate * private_key, gpointer data) { - *((gpointer*)private_key) = data; + *((gpointer *) private_key) = data; } static void -gst_thread_create_dummy_impl (GThreadFunc func, gpointer data, gulong stack_size, - gboolean joinable, gboolean bound, GThreadPriority priority, - gpointer thread, GError **error) +gst_thread_create_dummy_impl (GThreadFunc func, gpointer data, + gulong stack_size, gboolean joinable, gboolean bound, + GThreadPriority priority, gpointer thread, GError ** error) { g_warning ("GStreamer configured to not use threads"); } static void -gst_thread_dummy_impl (void) { /* NOP */ } +gst_thread_dummy_impl (void) +{ /* NOP */ +} static void -gst_thread_dummy_impl_1 (gpointer thread) { /* NOP */ } +gst_thread_dummy_impl_1 (gpointer thread) +{ /* NOP */ +} static void -gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority) { /* NOP */ } +gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority) +{ /* NOP */ +} static gboolean gst_thread_equal_dummy_impl (gpointer thread1, gpointer thread2) @@ -125,29 +137,24 @@ gst_thread_equal_dummy_impl (gpointer thread1, gpointer thread2) return (thread1 == thread2); } -GThreadFunctions -gst_thread_dummy_functions = -{ - gst_mutex_new_dummy_impl, - (void (*)(GMutex *)) gst_mutex_dummy_impl, - gst_mutex_trylock_dummy_impl, - (void (*)(GMutex *)) gst_mutex_dummy_impl, - gst_mutex_dummy_impl, - gst_cond_new_dummy_impl, - (void (*)(GCond *)) gst_cond_dummy_impl, - (void (*)(GCond *)) gst_cond_dummy_impl, - (void (*)(GCond *, GMutex *)) gst_cond_dummy_impl, - gst_cond_timed_wait_dummy_impl, - gst_cond_dummy_impl, - gst_private_new_dummy_impl, - gst_private_get_dummy_impl, - gst_private_set_dummy_impl, - gst_thread_create_dummy_impl, - gst_thread_dummy_impl, - gst_thread_dummy_impl_1, - gst_thread_dummy_impl, - gst_thread_set_priority_dummy_impl, - gst_thread_dummy_impl_1, - gst_thread_equal_dummy_impl -}; - +GThreadFunctions gst_thread_dummy_functions = { +gst_mutex_new_dummy_impl, + (void (*)(GMutex *)) gst_mutex_dummy_impl, + gst_mutex_trylock_dummy_impl, + (void (*)(GMutex *)) gst_mutex_dummy_impl, + gst_mutex_dummy_impl, + gst_cond_new_dummy_impl, + (void (*)(GCond *)) gst_cond_dummy_impl, + (void (*)(GCond *)) gst_cond_dummy_impl, + (void (*)(GCond *, GMutex *)) gst_cond_dummy_impl, + gst_cond_timed_wait_dummy_impl, + gst_cond_dummy_impl, + gst_private_new_dummy_impl, + gst_private_get_dummy_impl, + gst_private_set_dummy_impl, + gst_thread_create_dummy_impl, + gst_thread_dummy_impl, + gst_thread_dummy_impl_1, + gst_thread_dummy_impl, + gst_thread_set_priority_dummy_impl, + gst_thread_dummy_impl_1, gst_thread_equal_dummy_impl}; diff --git a/gst/gsttrace.c b/gst/gsttrace.c index 0c9ed7990..abda8f99e 100644 --- a/gst/gsttrace.c +++ b/gst/gsttrace.c @@ -33,11 +33,11 @@ #include "gstlog.h" #include "gsttrace.h" -static +static #ifdef __inline__ -__inline__ + __inline__ #endif -void + void read_tsc (gint64 * dst) { #ifdef HAVE_RDTSC @@ -67,7 +67,8 @@ gst_trace_new (gchar * filename, gint size) g_return_val_if_fail (trace != NULL, NULL); trace->filename = g_strdup (filename); g_print ("opening '%s'\n", trace->filename); - trace->fd = open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); + trace->fd = + open (trace->filename, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); perror ("opening trace file"); g_return_val_if_fail (trace->fd > 0, NULL); trace->buf = g_malloc (size * sizeof (GstTraceEntry)); @@ -108,6 +109,7 @@ void gst_trace_text_flush (GstTrace * trace) { int i; + #define STRSIZE (20 + 1 + 10 + 1 + 10 + 1 + 112 + 1 + 1) char str[STRSIZE]; @@ -119,8 +121,8 @@ gst_trace_text_flush (GstTrace * trace) for (i = 0; i < trace->bufoffset; i++) { snprintf (str, STRSIZE, "%20" G_GINT64_FORMAT " %10d %10d %s\n", - trace->buf[i].timestamp, - trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message); + trace->buf[i].timestamp, + trace->buf[i].sequence, trace->buf[i].data, trace->buf[i].message); write (trace->fd, str, strlen (str)); } trace->bufoffset = 0; @@ -158,6 +160,7 @@ _gst_trace_add_entry (GstTrace * trace, guint32 seq, guint32 data, gchar * msg) /* global flags */ static GstAllocTraceFlags _gst_trace_flags = 0; + /* list of registered tracers */ static GList *_gst_alloc_tracers = NULL; @@ -188,8 +191,8 @@ gst_alloc_trace_available (void) * * Returns: A handle to a GstAllocTrace. */ -GstAllocTrace* -_gst_alloc_trace_register (const gchar *name) +GstAllocTrace * +_gst_alloc_trace_register (const gchar * name) { GstAllocTrace *trace; @@ -213,7 +216,7 @@ _gst_alloc_trace_register (const gchar *name) * * Returns: a GList of GstAllocTrace objects. */ -const GList* +const GList * gst_alloc_trace_list (void) { return _gst_alloc_tracers; @@ -229,7 +232,7 @@ gst_alloc_trace_live_all (void) { GList *walk = _gst_alloc_tracers; int num = 0; - + while (walk) { GstAllocTrace *trace = (GstAllocTrace *) walk->data; @@ -250,7 +253,7 @@ void gst_alloc_trace_print_all (void) { GList *walk = _gst_alloc_tracers; - + while (walk) { GstAllocTrace *trace = (GstAllocTrace *) walk->data; @@ -292,8 +295,8 @@ gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags) * Returns: a GstAllocTrace with the given name or NULL when * no alloc tracer was registered with that name. */ -GstAllocTrace* -gst_alloc_trace_get (const gchar *name) +GstAllocTrace * +gst_alloc_trace_get (const gchar * name) { GList *walk = _gst_alloc_tracers; @@ -317,7 +320,7 @@ gst_alloc_trace_get (const gchar *name) * Print the status of the given GstAllocTrace. */ void -gst_alloc_trace_print (const GstAllocTrace *trace) +gst_alloc_trace_print (const GstAllocTrace * trace) { GSList *mem_live; @@ -333,13 +336,12 @@ gst_alloc_trace_print (const GstAllocTrace *trace) if (!mem_live) { g_print (", no live memory"); - } - else { + } else { g_print (", dumping live memory: "); while (mem_live) { - g_print ("%p ", mem_live->data); - mem_live = g_slist_next (mem_live); + g_print ("%p ", mem_live->data); + mem_live = g_slist_next (mem_live); } g_print ("\ntotal %d", g_slist_length (trace->mem_live)); } @@ -355,7 +357,7 @@ gst_alloc_trace_print (const GstAllocTrace *trace) * Enable the given features on the given GstAllocTrace object. */ void -gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags) +gst_alloc_trace_set_flags (GstAllocTrace * trace, GstAllocTraceFlags flags) { g_return_if_fail (trace != NULL); diff --git a/gst/gsttrace.h b/gst/gsttrace.h index 4e0e9ab85..9b37035e3 100644 --- a/gst/gsttrace.h +++ b/gst/gsttrace.h @@ -28,12 +28,11 @@ #include -G_BEGIN_DECLS +G_BEGIN_DECLS typedef struct _GstTrace GstTrace; +typedef struct _GstTraceEntry GstTraceEntry; -typedef struct _GstTrace GstTrace; -typedef struct _GstTraceEntry GstTraceEntry; - -struct _GstTrace { +struct _GstTrace +{ /* where this trace is going */ gchar *filename; int fd; @@ -44,7 +43,8 @@ struct _GstTrace { gint bufoffset; }; -struct _GstTraceEntry { +struct _GstTraceEntry +{ gint64 timestamp; guint32 sequence; guint32 data; @@ -53,49 +53,52 @@ struct _GstTraceEntry { -GstTrace* gst_trace_new (gchar *filename, gint size); +GstTrace *gst_trace_new (gchar * filename, gint size); + +void gst_trace_destroy (GstTrace * trace); +void gst_trace_flush (GstTrace * trace); +void gst_trace_text_flush (GstTrace * trace); -void gst_trace_destroy (GstTrace *trace); -void gst_trace_flush (GstTrace *trace); -void gst_trace_text_flush (GstTrace *trace); #define gst_trace_get_size(trace) ((trace)->bufsize) #define gst_trace_get_offset(trace) ((trace)->bufoffset) #define gst_trace_get_remaining(trace) ((trace)->bufsize - (trace)->bufoffset) -void gst_trace_set_default (GstTrace *trace); +void gst_trace_set_default (GstTrace * trace); -void _gst_trace_add_entry (GstTrace *trace, guint32 seq, - guint32 data, gchar *msg); +void _gst_trace_add_entry (GstTrace * trace, guint32 seq, + guint32 data, gchar * msg); -void gst_trace_read_tsc (gint64 *dst); +void gst_trace_read_tsc (gint64 * dst); typedef enum { - GST_ALLOC_TRACE_LIVE = (1 << 0), - GST_ALLOC_TRACE_MEM_LIVE = (1 << 1) + GST_ALLOC_TRACE_LIVE = (1 << 0), + GST_ALLOC_TRACE_MEM_LIVE = (1 << 1) } GstAllocTraceFlags; -typedef struct _GstAllocTrace GstAllocTrace; +typedef struct _GstAllocTrace GstAllocTrace; -struct _GstAllocTrace { - gchar *name; - gint flags; +struct _GstAllocTrace +{ + gchar *name; + gint flags; - gint live; - GSList *mem_live; + gint live; + GSList *mem_live; }; -gboolean gst_alloc_trace_available (void); -G_CONST_RETURN GList* gst_alloc_trace_list (void); -GstAllocTrace* _gst_alloc_trace_register (const gchar *name); +gboolean gst_alloc_trace_available (void); +G_CONST_RETURN GList *gst_alloc_trace_list (void); +GstAllocTrace *_gst_alloc_trace_register (const gchar * name); -int gst_alloc_trace_live_all (void); -void gst_alloc_trace_print_all (void); -void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags); +int gst_alloc_trace_live_all (void); +void gst_alloc_trace_print_all (void); +void gst_alloc_trace_set_flags_all (GstAllocTraceFlags flags); -GstAllocTrace* gst_alloc_trace_get (const gchar *name); -void gst_alloc_trace_print (const GstAllocTrace *trace); -void gst_alloc_trace_set_flags (GstAllocTrace *trace, GstAllocTraceFlags flags); +GstAllocTrace *gst_alloc_trace_get (const gchar * name); +void gst_alloc_trace_print (const GstAllocTrace * trace); +void gst_alloc_trace_set_flags (GstAllocTrace * trace, + GstAllocTraceFlags flags); #ifndef GST_DISABLE_ALLOC_TRACE @@ -127,6 +130,7 @@ G_STMT_START { \ #ifndef GST_DISABLE_TRACE extern gint _gst_trace_on; + #define gst_trace_add_entry(trace,seq,data,msg) \ if (_gst_trace_on) { \ _gst_trace_add_entry(trace,(guint32)seq,(guint32)data,msg); \ @@ -137,7 +141,7 @@ extern gint _gst_trace_on; #else /* GST_DISABLE_TRACE */ -#pragma GCC poison gst_trace_new +#pragma GCC poison gst_trace_new #pragma GCC poison gst_trace_destroy #pragma GCC poison gst_trace_flush #pragma GCC poison gst_trace_text_flush @@ -150,16 +154,16 @@ extern gint _gst_trace_on; #pragma GCC poison gst_trace_add_entry #define gst_alloc_trace_register(name) -#define gst_alloc_trace_new(trace, mem) +#define gst_alloc_trace_new(trace, mem) #define gst_alloc_trace_free(trace, mem) #define gst_alloc_trace_available() (FALSE) #define gst_alloc_trace_list() (NULL) #define _gst_alloc_trace_register(name) (NULL) - -#define gst_alloc_trace_print_all() + +#define gst_alloc_trace_print_all() #define gst_alloc_trace_set_flags_all(flags) - + #define gst_alloc_trace_get(name) (NULL) #define gst_alloc_trace_print(trace) #define gst_alloc_trace_set_flags(trace,flags) @@ -168,5 +172,4 @@ extern gint _gst_trace_on; #endif /* GST_DISABLE_TRACE */ G_END_DECLS - #endif /* __GST_TRACE_H__ */ diff --git a/gst/gsttrashstack.c b/gst/gsttrashstack.c index 66cf8309b..8254281ef 100644 --- a/gst/gsttrashstack.c +++ b/gst/gsttrashstack.c @@ -21,4 +21,3 @@ #define __GST_TRASH_STACK_C__ #include "gsttrashstack.h" - diff --git a/gst/gsttrashstack.h b/gst/gsttrashstack.h index 8915168c3..f28202374 100644 --- a/gst/gsttrashstack.h +++ b/gst/gsttrashstack.h @@ -23,35 +23,35 @@ #include #include "gstmacros.h" -G_BEGIN_DECLS - -typedef struct _GstTrashStack GstTrashStack; +G_BEGIN_DECLS typedef struct _GstTrashStack GstTrashStack; typedef struct _GstTrashStackElement GstTrashStackElement; -struct _GstTrashStackElement { +struct _GstTrashStackElement +{ GstTrashStackElement *next; }; -typedef volatile gpointer gst_vgpointer;/* gtk-doc volatile workaround */ -typedef volatile gulong gst_vgulong; /* gtk-doc volatile workaround */ - -struct _GstTrashStack { - gst_vgpointer head; - gst_vgulong count; /* for the ABA problem */ - GMutex *lock; /* lock for C fallback */ +typedef volatile gpointer gst_vgpointer; /* gtk-doc volatile workaround */ +typedef volatile gulong gst_vgulong; /* gtk-doc volatile workaround */ + +struct _GstTrashStack +{ + gst_vgpointer head; + gst_vgulong count; /* for the ABA problem */ + GMutex *lock; /* lock for C fallback */ }; -GST_INLINE_FUNC GstTrashStack* gst_trash_stack_new (void); -GST_INLINE_FUNC void gst_trash_stack_init (GstTrashStack *stack); -GST_INLINE_FUNC void gst_trash_stack_destroy (GstTrashStack *stack); -GST_INLINE_FUNC void gst_trash_stack_free (GstTrashStack *stack); +GST_INLINE_FUNC GstTrashStack *gst_trash_stack_new (void); +GST_INLINE_FUNC void gst_trash_stack_init (GstTrashStack * stack); +GST_INLINE_FUNC void gst_trash_stack_destroy (GstTrashStack * stack); +GST_INLINE_FUNC void gst_trash_stack_free (GstTrashStack * stack); -GST_INLINE_FUNC void gst_trash_stack_push (GstTrashStack *stack, gpointer mem); -GST_INLINE_FUNC gpointer gst_trash_stack_pop (GstTrashStack *stack); +GST_INLINE_FUNC void gst_trash_stack_push (GstTrashStack * stack, gpointer mem); +GST_INLINE_FUNC gpointer gst_trash_stack_pop (GstTrashStack * stack); #if defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__) -#if defined (USE_FAST_STACK_TRASH) && defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 +#if defined (USE_FAST_STACK_TRASH) && defined (__i386__) && defined (__GNUC__) && __GNUC__ >= 2 #ifdef GST_CONFIG_NO_SMP #define SMP_LOCK "" @@ -63,34 +63,29 @@ GST_INLINE_FUNC gpointer gst_trash_stack_pop (GstTrashStack *stack); * intel ia32 optimized lockfree implementations */ GST_INLINE_FUNC void -gst_trash_stack_init (GstTrashStack *stack) +gst_trash_stack_init (GstTrashStack * stack) { stack->head = NULL; stack->count = 0; } GST_INLINE_FUNC void -gst_trash_stack_destroy (GstTrashStack *stack) +gst_trash_stack_destroy (GstTrashStack * stack) { } GST_INLINE_FUNC void -gst_trash_stack_push (GstTrashStack *stack, gpointer mem) +gst_trash_stack_push (GstTrashStack * stack, gpointer mem) { - __asm__ __volatile__ ( - "1: \n\t" - " movl %2, (%1); \n\t" /* mem->next == stack->head */ - SMP_LOCK "cmpxchg %1, %0; \n\t" /* if head unchanged, move mem into it */ - " jnz 1b; \n" /* head changed, retry */ - : - : "m" (*stack), - "r" (mem), - "a" (stack->head) - ); + __asm__ __volatile__ ("1: \n\t" " movl %2, (%1); \n\t" /* mem->next == stack->head */ + SMP_LOCK "cmpxchg %1, %0; \n\t" /* if head unchanged, move mem into it */ + " jnz 1b; \n" /* head changed, retry */ + ::"m" (*stack), "r" (mem), "a" (stack->head) + ); } GST_INLINE_FUNC gpointer -gst_trash_stack_pop (GstTrashStack *stack) +gst_trash_stack_pop (GstTrashStack * stack) { GstTrashStackElement *head; @@ -100,23 +95,16 @@ gst_trash_stack_pop (GstTrashStack *stack) * into place. This is usually solved using a counter which makes it highly * inlikely that we manage to grab the wrong head->next value. */ - __asm__ __volatile__ ( - " testl %%eax, %%eax; \n\t" /* if (head == NULL) return */ - " jz 20f; \n\t" - "10: \n\t" - " movl (%%eax), %%ebx; \n\t" /* take value pointed to by head (head->next) */ - " movl %%edx, %%ecx; \n\t" /* take counter */ - " incl %%ecx; \n\t" /* and increment */ - SMP_LOCK "cmpxchg8b %1; \n\t" /* if eax:edx == *stack, move ebx:ecx to *stack, + __asm__ __volatile__ (" testl %%eax, %%eax; \n\t" /* if (head == NULL) return */ + " jz 20f; \n\t" "10: \n\t" " movl (%%eax), %%ebx; \n\t" /* take value pointed to by head (head->next) */ + " movl %%edx, %%ecx; \n\t" /* take counter */ + " incl %%ecx; \n\t" /* and increment */ + SMP_LOCK "cmpxchg8b %1; \n\t" /* if eax:edx == *stack, move ebx:ecx to *stack, * else *stack is moved into eax:edx again... */ - " jnz 10b; \n\t" /* ... and we retry */ - "20: \n" - : "=a" (head) - : "m" (*stack), - "a" (stack->head), - "d" (stack->count) - : "ecx", "ebx" - ); + " jnz 10b; \n\t" /* ... and we retry */ + "20: \n":"=a" (head) + :"m" (*stack), "a" (stack->head), "d" (stack->count) + :"ecx", "ebx"); return head; } @@ -127,20 +115,20 @@ gst_trash_stack_pop (GstTrashStack *stack) * generic implementation */ GST_INLINE_FUNC void -gst_trash_stack_init (GstTrashStack *stack) +gst_trash_stack_init (GstTrashStack * stack) { stack->head = NULL; - stack->lock = g_mutex_new(); + stack->lock = g_mutex_new (); } GST_INLINE_FUNC void -gst_trash_stack_destroy (GstTrashStack *stack) +gst_trash_stack_destroy (GstTrashStack * stack) { g_mutex_free (stack->lock); } GST_INLINE_FUNC void -gst_trash_stack_push (GstTrashStack *stack, gpointer mem) +gst_trash_stack_push (GstTrashStack * stack, gpointer mem) { GstTrashStackElement *elem = (GstTrashStackElement *) mem; @@ -151,10 +139,10 @@ gst_trash_stack_push (GstTrashStack *stack, gpointer mem) } GST_INLINE_FUNC gpointer -gst_trash_stack_pop (GstTrashStack *stack) +gst_trash_stack_pop (GstTrashStack * stack) { GstTrashStackElement *head; - + g_mutex_lock (stack->lock); head = (GstTrashStackElement *) stack->head; if (head) @@ -169,7 +157,7 @@ gst_trash_stack_pop (GstTrashStack *stack) /* * common functions */ -GST_INLINE_FUNC GstTrashStack* +GST_INLINE_FUNC GstTrashStack * gst_trash_stack_new (void) { GstTrashStack *stack; @@ -181,14 +169,13 @@ gst_trash_stack_new (void) } GST_INLINE_FUNC void -gst_trash_stack_free (GstTrashStack *stack) +gst_trash_stack_free (GstTrashStack * stack) { gst_trash_stack_destroy (stack); g_free (stack); } -#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)*/ +#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__) */ G_END_DECLS - #endif /* __GST_TRASH_STACK_H__ */ diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 1b326afe3..0380a4f92 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -26,16 +26,15 @@ GST_DEBUG_CATEGORY_STATIC (gst_type_find_debug); #define GST_CAT_DEFAULT gst_type_find_debug -static void gst_type_find_factory_class_init (gpointer g_class, - gpointer class_data); -static void gst_type_find_factory_init (GTypeInstance * instance, - gpointer g_class); -static void gst_type_find_factory_dispose (GObject * object); +static void gst_type_find_factory_class_init (gpointer g_class, + gpointer class_data); +static void gst_type_find_factory_init (GTypeInstance * instance, + gpointer g_class); +static void gst_type_find_factory_dispose (GObject * object); -static void gst_type_find_factory_unload_thyself (GstPluginFeature * feature); +static void gst_type_find_factory_unload_thyself (GstPluginFeature * feature); -static void gst_type_find_load_plugin (GstTypeFind * find, - gpointer data); +static void gst_type_find_load_plugin (GstTypeFind * find, gpointer data); static GstPluginFeatureClass *parent_class = NULL; @@ -43,7 +42,7 @@ GType gst_type_find_factory_get_type (void) { static GType typefind_type = 0; - + if (!typefind_type) { static const GTypeInfo typefind_info = { sizeof (GstTypeFindFactoryClass), @@ -58,10 +57,9 @@ gst_type_find_factory_get_type (void) NULL }; typefind_type = g_type_register_static (GST_TYPE_PLUGIN_FEATURE, - "GstTypeFindFactory", - &typefind_info, 0); - GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND", - GST_DEBUG_FG_GREEN, "typefinding subsystem"); + "GstTypeFindFactory", &typefind_info, 0); + GST_DEBUG_CATEGORY_INIT (gst_type_find_debug, "GST_TYPEFIND", + GST_DEBUG_FG_GREEN, "typefinding subsystem"); } return typefind_type; @@ -69,17 +67,19 @@ gst_type_find_factory_get_type (void) static void gst_type_find_factory_class_init (gpointer g_class, gpointer class_data) { - GstPluginFeatureClass *gstpluginfeature_class = GST_PLUGIN_FEATURE_CLASS (g_class); + GstPluginFeatureClass *gstpluginfeature_class = + GST_PLUGIN_FEATURE_CLASS (g_class); GObjectClass *object_class = G_OBJECT_CLASS (g_class); - + parent_class = g_type_class_peek_parent (g_class); - + object_class->dispose = gst_type_find_factory_dispose; - - gstpluginfeature_class->unload_thyself = GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself); + + gstpluginfeature_class->unload_thyself = + GST_DEBUG_FUNCPTR (gst_type_find_factory_unload_thyself); } static void -gst_type_find_factory_init (GTypeInstance *instance, gpointer g_class) +gst_type_find_factory_init (GTypeInstance * instance, gpointer g_class) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (instance); @@ -87,7 +87,7 @@ gst_type_find_factory_init (GTypeInstance *instance, gpointer g_class) factory->function = gst_type_find_load_plugin; } static void -gst_type_find_factory_dispose (GObject *object) +gst_type_find_factory_dispose (GObject * object) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (object); @@ -101,7 +101,7 @@ gst_type_find_factory_dispose (GObject *object) } } static void -gst_type_find_factory_unload_thyself (GstPluginFeature *feature) +gst_type_find_factory_unload_thyself (GstPluginFeature * feature) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature); @@ -109,22 +109,25 @@ gst_type_find_factory_unload_thyself (GstPluginFeature *feature) factory->user_data = factory; } static void -gst_type_find_load_plugin (GstTypeFind *find, gpointer data) +gst_type_find_load_plugin (GstTypeFind * find, gpointer data) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (data); - GST_DEBUG_OBJECT (factory, "need to load typefind function %s", GST_PLUGIN_FEATURE_NAME (factory)); - + GST_DEBUG_OBJECT (factory, "need to load typefind function %s", + GST_PLUGIN_FEATURE_NAME (factory)); + if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) { if (factory->function == gst_type_find_load_plugin) { /* looks like we didn't get a real typefind function */ - g_warning ("could not load valid typefind function for feature '%s'\n", GST_PLUGIN_FEATURE_NAME (factory)); + g_warning ("could not load valid typefind function for feature '%s'\n", + GST_PLUGIN_FEATURE_NAME (factory)); } else { g_assert (factory->function); gst_type_find_factory_call_function (factory, find); } } } + /** * gst_type_find_factory_get_list: * @@ -138,6 +141,7 @@ gst_type_find_factory_get_list (void) { return gst_registry_pool_feature_list (GST_TYPE_TYPE_FIND_FACTORY); } + /** * gst_type_find_factory_get_caps: * @factory: a factory @@ -147,12 +151,13 @@ gst_type_find_factory_get_list (void) * Returns: the #GstCaps associated with this factory */ const GstCaps * -gst_type_find_factory_get_caps (const GstTypeFindFactory *factory) +gst_type_find_factory_get_caps (const GstTypeFindFactory * factory) { g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL); return factory->caps; } + /** * gst_type_find_factory_get_extensions: * @factory: a factory @@ -165,12 +170,13 @@ gst_type_find_factory_get_caps (const GstTypeFindFactory *factory) * Returns: a NULL-terminated array of extensions associated with this factory */ gchar ** -gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory) +gst_type_find_factory_get_extensions (const GstTypeFindFactory * factory) { g_return_val_if_fail (GST_IS_TYPE_FIND_FACTORY (factory), NULL); return factory->extensions; } + /** * gst_type_find_factory_call_function: * @factory: a factory @@ -180,7 +186,8 @@ gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory) * Calls the typefinding function associated with this factory. */ void -gst_type_find_factory_call_function (const GstTypeFindFactory *factory, GstTypeFind *find) +gst_type_find_factory_call_function (const GstTypeFindFactory * factory, + GstTypeFind * find) { g_return_if_fail (GST_IS_TYPE_FIND_FACTORY (factory)); g_return_if_fail (find != NULL); @@ -192,6 +199,7 @@ gst_type_find_factory_call_function (const GstTypeFindFactory *factory, GstTypeF factory->function (find, factory->user_data); } + /** * gst_type_find_register: * @plugin: the GstPlugin to register with @@ -210,18 +218,20 @@ gst_type_find_factory_call_function (const GstTypeFindFactory *factory, GstTypeF * Returns: TRUE on success, FALSE otherwise */ gboolean -gst_type_find_register (GstPlugin *plugin, const gchar *name, guint rank, - GstTypeFindFunction func, gchar **extensions, - const GstCaps *possible_caps, gpointer data) +gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank, + GstTypeFindFunction func, gchar ** extensions, + const GstCaps * possible_caps, gpointer data) { GstTypeFindFactory *factory; - + g_return_val_if_fail (plugin != NULL, FALSE); g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (func != NULL, FALSE); GST_INFO ("registering typefind function for %s", name); - factory = GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name, GST_TYPE_TYPE_FIND_FACTORY)); + factory = + GST_TYPE_FIND_FACTORY (gst_registry_pool_find_feature (name, + GST_TYPE_TYPE_FIND_FACTORY)); if (!factory) { factory = g_object_new (GST_TYPE_TYPE_FIND_FACTORY, NULL); GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name); @@ -236,7 +246,7 @@ gst_type_find_register (GstPlugin *plugin, const gchar *name, guint rank, g_strfreev (factory->extensions); factory->extensions = g_strdupv (extensions); - gst_caps_replace (&factory->caps, gst_caps_copy(possible_caps)); + gst_caps_replace (&factory->caps, gst_caps_copy (possible_caps)); factory->function = func; factory->user_data = data; @@ -263,12 +273,13 @@ gst_type_find_register (GstPlugin *plugin, const gchar *name, guint rank, * Returns: the requested data or NULL if that data is not available. */ guint8 * -gst_type_find_peek (GstTypeFind *find, gint64 offset, guint size) +gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size) { g_return_val_if_fail (find->peek != NULL, NULL); return find->peek (find->data, offset, size); } + /** * gst_type_find_suggest: * @find: the find object the function was called with @@ -281,7 +292,8 @@ gst_type_find_peek (GstTypeFind *find, gint64 offset, guint size) * It is up to the caller of the typefind function to interpret these values. */ void -gst_type_find_suggest (GstTypeFind *find, guint probability, const GstCaps *caps) +gst_type_find_suggest (GstTypeFind * find, guint probability, + const GstCaps * caps) { g_return_if_fail (find->suggest != NULL); g_return_if_fail (probability <= 100); @@ -290,6 +302,7 @@ gst_type_find_suggest (GstTypeFind *find, guint probability, const GstCaps *caps find->suggest (find->data, probability, caps); } + /** * gst_type_find_get_length: * @find: the find object the function was called with @@ -299,11 +312,10 @@ gst_type_find_suggest (GstTypeFind *find, guint probability, const GstCaps *caps * Returns: the length of the data stream or 0 if it is not available. */ guint64 -gst_type_find_get_length (GstTypeFind *find) +gst_type_find_get_length (GstTypeFind * find) { if (find->get_length == NULL) return 0; - return find->get_length(find->data); + return find->get_length (find->data); } - diff --git a/gst/gsttypefind.h b/gst/gsttypefind.h index 77f7dc7e7..956cd9460 100644 --- a/gst/gsttypefind.h +++ b/gst/gsttypefind.h @@ -30,21 +30,20 @@ #include G_BEGIN_DECLS - #define GST_TYPE_TYPE_FIND_FACTORY (gst_type_find_factory_get_type()) #define GST_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactory)) #define GST_IS_TYPE_FIND_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_FACTORY)) #define GST_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass)) #define GST_IS_TYPE_FIND_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_FACTORY)) #define GST_TYPE_FIND_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_FACTORY, GstTypeFindFactoryClass)) - typedef struct _GstTypeFind GstTypeFind; typedef struct _GstTypeFindFactory GstTypeFindFactory; typedef struct _GstTypeFindFactoryClass GstTypeFindFactoryClass; -typedef void (* GstTypeFindFunction) (GstTypeFind *find, gpointer data); +typedef void (*GstTypeFindFunction) (GstTypeFind * find, gpointer data); -typedef enum { +typedef enum +{ GST_TYPE_FIND_MINIMUM = 1, GST_TYPE_FIND_POSSIBLE = 50, GST_TYPE_FIND_LIKELY = 80, @@ -52,74 +51,69 @@ typedef enum { GST_TYPE_FIND_MAXIMUM = 100, } GstTypeFindProbability; -struct _GstTypeFind { +struct _GstTypeFind +{ /* private to the caller of the typefind function */ - guint8 * (* peek) (gpointer data, - gint64 offset, - guint size); - void (* suggest) (gpointer data, - guint probability, - const GstCaps * caps); - - gpointer data; - + guint8 *(*peek) (gpointer data, gint64 offset, guint size); + void (*suggest) (gpointer data, guint probability, const GstCaps * caps); + + gpointer data; + /* optional */ - guint64 (* get_length) (gpointer data); + guint64 (*get_length) (gpointer data); /* */ gpointer _gst_reserved[GST_PADDING]; }; -struct _GstTypeFindFactory { - GstPluginFeature feature; +struct _GstTypeFindFactory +{ + GstPluginFeature feature; /* */ - GstTypeFindFunction function; - gchar ** extensions; - GstCaps * caps; /* FIXME: not yet saved in registry */ - - gpointer user_data; - + GstTypeFindFunction function; + gchar **extensions; + GstCaps *caps; /* FIXME: not yet saved in registry */ + + gpointer user_data; + gpointer _gst_reserved[GST_PADDING]; }; - -struct _GstTypeFindFactoryClass { - GstPluginFeatureClass parent; + +struct _GstTypeFindFactoryClass +{ + GstPluginFeatureClass parent; /* */ - + gpointer _gst_reserved[GST_PADDING]; }; /* typefind function interface */ -guint8 * gst_type_find_peek (GstTypeFind * find, - gint64 offset, - guint size); -void gst_type_find_suggest (GstTypeFind * find, - guint probability, - const GstCaps * caps); -guint64 gst_type_find_get_length (GstTypeFind * find); +guint8 *gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size); +void gst_type_find_suggest (GstTypeFind * find, + guint probability, const GstCaps * caps); +guint64 gst_type_find_get_length (GstTypeFind * find); /* registration interface */ -gboolean gst_type_find_register (GstPlugin * plugin, - const gchar * name, - guint rank, - GstTypeFindFunction func, - gchar ** extensions, - const GstCaps * possible_caps, - gpointer data); +gboolean gst_type_find_register (GstPlugin * plugin, + const gchar * name, + guint rank, + GstTypeFindFunction func, + gchar ** extensions, const GstCaps * possible_caps, gpointer data); /* typefinding interface */ -GType gst_type_find_factory_get_type (void); - -GList * gst_type_find_factory_get_list (void); +GType gst_type_find_factory_get_type (void); -gchar ** gst_type_find_factory_get_extensions (const GstTypeFindFactory *factory); -const GstCaps * gst_type_find_factory_get_caps (const GstTypeFindFactory *factory); -void gst_type_find_factory_call_function (const GstTypeFindFactory *factory, - GstTypeFind *find); +GList *gst_type_find_factory_get_list (void); +gchar **gst_type_find_factory_get_extensions (const GstTypeFindFactory * + factory); +const GstCaps *gst_type_find_factory_get_caps (const GstTypeFindFactory * + factory); +void gst_type_find_factory_call_function (const GstTypeFindFactory * factory, + GstTypeFind * find); -G_END_DECLS +G_END_DECLS #endif /* __GST_TYPE_FIND_H__ */ diff --git a/gst/gsttypes.h b/gst/gsttypes.h index b9e8fb196..b081f0be2 100644 --- a/gst/gsttypes.h +++ b/gst/gsttypes.h @@ -22,9 +22,7 @@ #include -G_BEGIN_DECLS - -typedef struct _GstObject GstObject; +G_BEGIN_DECLS typedef struct _GstObject GstObject; typedef struct _GstObjectClass GstObjectClass; typedef struct _GstPad GstPad; typedef struct _GstPadClass GstPadClass; @@ -38,21 +36,24 @@ typedef struct _GstScheduler GstScheduler; typedef struct _GstSchedulerClass GstSchedulerClass; typedef struct _GstEvent GstEvent; -typedef enum { - GST_STATE_VOID_PENDING = 0, - GST_STATE_NULL = (1 << 0), - GST_STATE_READY = (1 << 1), - GST_STATE_PAUSED = (1 << 2), - GST_STATE_PLAYING = (1 << 3) +typedef enum +{ + GST_STATE_VOID_PENDING = 0, + GST_STATE_NULL = (1 << 0), + GST_STATE_READY = (1 << 1), + GST_STATE_PAUSED = (1 << 2), + GST_STATE_PLAYING = (1 << 3) } GstElementState; -typedef enum { - GST_STATE_FAILURE = 0, - GST_STATE_SUCCESS = 1, - GST_STATE_ASYNC = 2 +typedef enum +{ + GST_STATE_FAILURE = 0, + GST_STATE_SUCCESS = 1, + GST_STATE_ASYNC = 2 } GstElementStateReturn; -typedef enum { +typedef enum +{ GST_RESULT_OK, GST_RESULT_NOK, GST_RESULT_NOT_IMPL @@ -67,5 +68,4 @@ typedef enum { #define GST_PADDING_INIT { 0 } G_END_DECLS - #endif /* __GST_TYPES_H__ */ diff --git a/gst/gsturi.c b/gst/gsturi.c index ef9e030c1..d795cd312 100644 --- a/gst/gsturi.c +++ b/gst/gsturi.c @@ -34,7 +34,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_uri_handler_debug); #define GST_CAT_DEFAULT gst_uri_handler_debug -static void gst_uri_handler_base_init (gpointer g_class); +static void gst_uri_handler_base_init (gpointer g_class); GType gst_uri_handler_get_type (void) @@ -55,9 +55,10 @@ gst_uri_handler_get_type (void) NULL }; urihandler_type = g_type_register_static (G_TYPE_INTERFACE, - "GstURIHandler", &urihandler_info, 0); + "GstURIHandler", &urihandler_info, 0); - GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD, "handling of URIs"); + GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD, + "handling of URIs"); } return urihandler_type; } @@ -68,27 +69,29 @@ gst_uri_handler_base_init (gpointer g_class) if (!initialized) { g_signal_new ("new-uri", GST_TYPE_URI_HANDLER, G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL, - gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL, + gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); initialized = TRUE; } } static void -gst_uri_protocol_check_internal (const gchar *uri, gchar **endptr) +gst_uri_protocol_check_internal (const gchar * uri, gchar ** endptr) { gchar *check = (gchar *) uri; - + g_assert (uri != NULL); g_assert (endptr != NULL); if (g_ascii_isalpha (*check)) { check++; - while (g_ascii_isalnum (*check)) check++; + while (g_ascii_isalnum (*check)) + check++; } *endptr = check; } + /** * gst_uri_protocol_is_valid: * @protocol: string to check @@ -99,16 +102,17 @@ gst_uri_protocol_check_internal (const gchar *uri, gchar **endptr) * Returns: TRUE if the string is a valid protocol identifier */ gboolean -gst_uri_protocol_is_valid (const gchar *protocol) +gst_uri_protocol_is_valid (const gchar * protocol) { gchar *endptr; - + g_return_val_if_fail (protocol != NULL, FALSE); - + gst_uri_protocol_check_internal (protocol, &endptr); return *endptr == '\0' && endptr != protocol; } + /** * gst_uri_is_valid: * @protocol: string to check @@ -119,18 +123,17 @@ gst_uri_protocol_is_valid (const gchar *protocol) * Returns: TRUE if the string is a valid URI */ gboolean -gst_uri_is_valid (const gchar *uri) +gst_uri_is_valid (const gchar * uri) { gchar *endptr; - + g_return_val_if_fail (uri != NULL, FALSE); - + gst_uri_protocol_check_internal (uri, &endptr); - return (*endptr == ':' && - *(endptr + 1) == '/' && - *(endptr + 2) == '/'); + return (*endptr == ':' && *(endptr + 1) == '/' && *(endptr + 2) == '/'); } + /** * gst_uri_get_protocol: * @uri: URI to get protocol from @@ -141,10 +144,10 @@ gst_uri_is_valid (const gchar *uri) * Returns: The protocol for this URI. */ gchar * -gst_uri_get_protocol (const gchar *uri) +gst_uri_get_protocol (const gchar * uri) { gchar *colon; - + g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (gst_uri_is_valid (uri), NULL); @@ -152,6 +155,7 @@ gst_uri_get_protocol (const gchar *uri) return g_strndup (uri, colon - uri); } + /** * gst_uri_get_location: * @uri: URI to get the location from @@ -163,10 +167,10 @@ gst_uri_get_protocol (const gchar *uri) * Returns: The location for this URI. */ gchar * -gst_uri_get_location (const gchar *uri) +gst_uri_get_location (const gchar * uri) { gchar *colon; - + g_return_val_if_fail (uri != NULL, NULL); g_return_val_if_fail (gst_uri_is_valid (uri), NULL); @@ -174,6 +178,7 @@ gst_uri_get_location (const gchar *uri) return g_strdup (colon + 3); } + /** * gst_uri_construct: * @protocol: protocol for URI @@ -184,19 +189,20 @@ gst_uri_get_location (const gchar *uri) * Returns: a new string for this URI */ gchar * -gst_uri_construct (const gchar *protocol, const gchar *location) +gst_uri_construct (const gchar * protocol, const gchar * location) { g_return_val_if_fail (gst_uri_protocol_is_valid (protocol), NULL); g_return_val_if_fail (location != NULL, NULL); return g_strdup_printf ("%s://%s", protocol, location); } -typedef struct{ - GstURIType type; - gchar * protocol; +typedef struct +{ + GstURIType type; + gchar *protocol; } SearchEntry; static gboolean -search_by_entry (GstPluginFeature *feature, gpointer search_entry) +search_by_entry (GstPluginFeature * feature, gpointer search_entry) { gchar **protocols; GstElementFactory *factory; @@ -208,7 +214,7 @@ search_by_entry (GstPluginFeature *feature, gpointer search_entry) if (gst_element_factory_get_uri_type (factory) != entry->type) return FALSE; - + protocols = gst_element_factory_get_uri_protocols (factory); /* must be set when uri type is valid */ g_assert (protocols); @@ -219,14 +225,17 @@ search_by_entry (GstPluginFeature *feature, gpointer search_entry) } return FALSE; } + static gint sort_by_rank (gconstpointer a, gconstpointer b) { GstPluginFeature *first = GST_PLUGIN_FEATURE (a); GstPluginFeature *second = GST_PLUGIN_FEATURE (b); - return gst_plugin_feature_get_rank (second) - gst_plugin_feature_get_rank (first); + return gst_plugin_feature_get_rank (second) - + gst_plugin_feature_get_rank (first); } + /** * gst_element_make_from_uri: * @type: wether to create a source or a sink @@ -238,7 +247,8 @@ sort_by_rank (gconstpointer a, gconstpointer b) * Returns: a new element or NULL if none could be created */ GstElement * -gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar *elementname) +gst_element_make_from_uri (const GstURIType type, const gchar * uri, + const gchar * elementname) { GList *possibilities, *walk; SearchEntry entry; @@ -249,20 +259,23 @@ gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar entry.type = type; entry.protocol = gst_uri_get_protocol (uri); - possibilities = gst_registry_pool_feature_filter (search_by_entry, FALSE, &entry); + possibilities = + gst_registry_pool_feature_filter (search_by_entry, FALSE, &entry); g_free (entry.protocol); if (!possibilities) { - GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source", uri); + GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source", + uri); return NULL; } - + possibilities = g_list_sort (possibilities, sort_by_rank); walk = possibilities; while (walk) { - if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data), - elementname)) != NULL) { + if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data), + elementname)) != NULL) { GstURIHandler *handler = GST_URI_HANDLER (ret); + if (gst_uri_handler_set_uri (handler, uri)) break; g_object_unref (ret); @@ -271,9 +284,11 @@ gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar } g_list_free (possibilities); - GST_LOG_OBJECT (ret, "created %s for URL '%s'", type == GST_URI_SINK ? "sink" : "source", uri); + GST_LOG_OBJECT (ret, "created %s for URL '%s'", + type == GST_URI_SINK ? "sink" : "source", uri); return ret; } + /** * gst_uri_handler_get_uri_type: * @handler: Handler to query type of @@ -283,11 +298,11 @@ gst_element_make_from_uri (const GstURIType type, const gchar *uri, const gchar * Returns: the type of the URI handler */ guint -gst_uri_handler_get_uri_type (GstURIHandler *handler) +gst_uri_handler_get_uri_type (GstURIHandler * handler) { GstURIHandlerInterface *iface; guint ret; - + g_return_val_if_fail (GST_IS_URI_HANDLER (handler), GST_URI_UNKNOWN); iface = GST_URI_HANDLER_GET_INTERFACE (handler); @@ -298,6 +313,7 @@ gst_uri_handler_get_uri_type (GstURIHandler *handler) return ret; } + /** * gst_uri_handler_get_protocols: * @handler: Handler to get protocols for @@ -308,11 +324,11 @@ gst_uri_handler_get_uri_type (GstURIHandler *handler) * Returns: the supported protocols */ gchar ** -gst_uri_handler_get_protocols (GstURIHandler *handler) +gst_uri_handler_get_protocols (GstURIHandler * handler) { GstURIHandlerInterface *iface; gchar **ret; - + g_return_val_if_fail (GST_IS_URI_HANDLER (handler), NULL); iface = GST_URI_HANDLER_GET_INTERFACE (handler); @@ -323,6 +339,7 @@ gst_uri_handler_get_protocols (GstURIHandler *handler) return ret; } + /** * gst_uri_handler_get_uri: * @handler: handler to query URI of @@ -332,11 +349,11 @@ gst_uri_handler_get_protocols (GstURIHandler *handler) * Returns: the URI */ G_CONST_RETURN gchar * -gst_uri_handler_get_uri (GstURIHandler *handler) +gst_uri_handler_get_uri (GstURIHandler * handler) { GstURIHandlerInterface *iface; const gchar *ret; - + g_return_val_if_fail (GST_IS_URI_HANDLER (handler), NULL); iface = GST_URI_HANDLER_GET_INTERFACE (handler); @@ -345,9 +362,10 @@ gst_uri_handler_get_uri (GstURIHandler *handler) ret = iface->get_uri (handler); if (ret != NULL) g_return_val_if_fail (gst_uri_is_valid (ret), NULL); - + return ret; } + /** * gst_uri_handler_set_uri: * @handler: handler to set URI of @@ -358,10 +376,10 @@ gst_uri_handler_get_uri (GstURIHandler *handler) * Returns: TRUE, if the URI was set successfully */ gboolean -gst_uri_handler_set_uri (GstURIHandler *handler, const gchar *uri) +gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri) { GstURIHandlerInterface *iface; - + g_return_val_if_fail (GST_IS_URI_HANDLER (handler), FALSE); g_return_val_if_fail (gst_uri_is_valid (uri), FALSE); @@ -370,6 +388,7 @@ gst_uri_handler_set_uri (GstURIHandler *handler, const gchar *uri) g_return_val_if_fail (iface->set_uri != NULL, FALSE); return iface->set_uri (handler, uri); } + /** * gst_uri_handler_new_uri: * @handler: handler with a new URI @@ -379,7 +398,7 @@ gst_uri_handler_set_uri (GstURIHandler *handler, const gchar *uri) * This function should only be called by URI handlers themselves. */ void -gst_uri_handler_new_uri (GstURIHandler *handler, const gchar *uri) +gst_uri_handler_new_uri (GstURIHandler * handler, const gchar * uri) { g_return_if_fail (GST_IS_URI_HANDLER (handler)); diff --git a/gst/gsturi.h b/gst/gsturi.h index 20118abbb..0867aa153 100644 --- a/gst/gsturi.h +++ b/gst/gsturi.h @@ -28,9 +28,8 @@ #include #include -G_BEGIN_DECLS - -typedef enum { +G_BEGIN_DECLS typedef enum +{ GST_URI_UNKNOWN, GST_URI_SINK, GST_URI_SRC @@ -48,29 +47,28 @@ typedef enum { typedef struct _GstURIHandler GstURIHandler; typedef struct _GstURIHandlerInterface GstURIHandlerInterface; -struct _GstURIHandlerInterface { - GTypeInterface parent; +struct _GstURIHandlerInterface +{ + GTypeInterface parent; /* signals */ - void (* new_uri) (GstURIHandler * handler, - const gchar * uri); + void (*new_uri) (GstURIHandler * handler, const gchar * uri); /* idea for the future ? - gboolean (* require_password) (GstURIHandler * handler, - gchar ** username, - gchar ** password); + gboolean (* require_password) (GstURIHandler * handler, + gchar ** username, + gchar ** password); */ /* vtable */ /* querying capabilities */ - GstURIType (* get_type) (void); - gchar ** (* get_protocols) (void); + GstURIType (*get_type) (void); + gchar **(*get_protocols) (void); /* using the interface */ - G_CONST_RETURN gchar *(* get_uri) (GstURIHandler * handler); - gboolean (* set_uri) (GstURIHandler * handler, - const gchar * uri); - + G_CONST_RETURN gchar *(*get_uri) (GstURIHandler * handler); + gboolean (*set_uri) (GstURIHandler * handler, const gchar * uri); + /* we might want to add functions here to query features, someone with gnome-vfs knowledge go ahead */ gpointer _gst_reserved[GST_PADDING]; @@ -78,28 +76,23 @@ struct _GstURIHandlerInterface { /* general URI functions */ -gboolean gst_uri_protocol_is_valid (const gchar * protocol); -gboolean gst_uri_is_valid (const gchar * uri); -gchar * gst_uri_get_protocol (const gchar * uri); -gchar * gst_uri_get_location (const gchar * uri); -gchar * gst_uri_construct (const gchar * protocol, - const gchar * location); +gboolean gst_uri_protocol_is_valid (const gchar * protocol); +gboolean gst_uri_is_valid (const gchar * uri); +gchar *gst_uri_get_protocol (const gchar * uri); +gchar *gst_uri_get_location (const gchar * uri); +gchar *gst_uri_construct (const gchar * protocol, const gchar * location); -GstElement * gst_element_make_from_uri (const GstURIType type, - const gchar * uri, - const gchar * elementname); +GstElement *gst_element_make_from_uri (const GstURIType type, + const gchar * uri, const gchar * elementname); /* accessing the interface */ -GType gst_uri_handler_get_type (void); +GType gst_uri_handler_get_type (void); -guint gst_uri_handler_get_uri_type (GstURIHandler * handler); -gchar ** gst_uri_handler_get_protocols (GstURIHandler * handler); -G_CONST_RETURN gchar * gst_uri_handler_get_uri (GstURIHandler * handler); -gboolean gst_uri_handler_set_uri (GstURIHandler * handler, - const gchar * uri); -void gst_uri_handler_new_uri (GstURIHandler * handler, - const gchar * uri); +guint gst_uri_handler_get_uri_type (GstURIHandler * handler); +gchar **gst_uri_handler_get_protocols (GstURIHandler * handler); +G_CONST_RETURN gchar *gst_uri_handler_get_uri (GstURIHandler * handler); +gboolean gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri); +void gst_uri_handler_new_uri (GstURIHandler * handler, const gchar * uri); G_END_DECLS - #endif /* __GST_URI_H__ */ diff --git a/gst/gsturitype.h b/gst/gsturitype.h index 8a48ecf3e..76aba4f6f 100644 --- a/gst/gsturitype.h +++ b/gst/gsturitype.h @@ -27,11 +27,9 @@ #include G_BEGIN_DECLS - /* a static type for making uri element properties */ #define GST_TYPE_URI (gst_uri_get_uri_type()) -GType gst_uri_get_uri_type (void); + GType gst_uri_get_uri_type (void); G_END_DECLS - #endif /* __GST_URI_TYPE_H */ diff --git a/gst/gstutils.c b/gst/gstutils.c index 2b2460445..b0938d342 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -36,7 +36,7 @@ * Dumps the memory block into a hex representation. Useful for debugging. */ void -gst_util_dump_mem (guchar *mem, guint size) +gst_util_dump_mem (guchar * mem, guint size) { guint i, j; GString *string = g_string_sized_new (50); @@ -46,7 +46,7 @@ gst_util_dump_mem (guchar *mem, guint size) while (i < size) { if (g_ascii_isprint (mem[i])) g_string_append_printf (chars, "%c", mem[i]); - else + else g_string_append_printf (chars, "."); g_string_append_printf (string, "%02x ", mem[i]); @@ -55,7 +55,8 @@ gst_util_dump_mem (guchar *mem, guint size) i++; if (j == 16 || i == size) { - g_print ("%08x (%p): %-48.48s %-16.16s\n", i-j, mem+i-j, string->str, chars->str); + g_print ("%08x (%p): %-48.48s %-16.16s\n", i - j, mem + i - j, + string->str, chars->str); g_string_set_size (string, 0); g_string_set_size (chars, 0); j = 0; @@ -75,76 +76,87 @@ gst_util_dump_mem (guchar *mem, guint size) * sets the value with it. */ void -gst_util_set_value_from_string(GValue *value, const gchar *value_str) +gst_util_set_value_from_string (GValue * value, const gchar * value_str) { - g_return_if_fail(value != NULL); - g_return_if_fail(value_str != NULL); - - GST_CAT_DEBUG (GST_CAT_PARAMS, "parsing '%s' to type %s", value_str, g_type_name(G_VALUE_TYPE(value))); - - switch (G_VALUE_TYPE(value)) { - case G_TYPE_STRING: - g_value_set_string(value, g_strdup(value_str)); - break; - case G_TYPE_ENUM: - case G_TYPE_INT: { - gint i; - sscanf (value_str, "%d", &i); - g_value_set_int(value, i); - break; - } - case G_TYPE_UINT: { - guint i; - sscanf (value_str, "%u", &i); - g_value_set_uint(value, i); - break; - } - case G_TYPE_LONG: { - glong i; - sscanf (value_str, "%ld", &i); - g_value_set_long(value, i); - break; - } - case G_TYPE_ULONG: { - gulong i; - sscanf (value_str, "%lu", &i); - g_value_set_ulong(value, i); - break; - } - case G_TYPE_BOOLEAN: { - gboolean i = FALSE; - if (!strncmp ("true", value_str, 4)) i = TRUE; - g_value_set_boolean(value, i); - break; - } - case G_TYPE_CHAR: { - gchar i; - sscanf (value_str, "%c", &i); - g_value_set_char(value, i); - break; - } - case G_TYPE_UCHAR: { - guchar i; - sscanf (value_str, "%c", &i); - g_value_set_uchar(value, i); - break; - } - case G_TYPE_FLOAT: { - gfloat i; - sscanf (value_str, "%f", &i); - g_value_set_float(value, i); - break; - } - case G_TYPE_DOUBLE: { - gfloat i; - sscanf (value_str, "%g", &i); - g_value_set_double(value, (gdouble)i); - break; - } - default: - break; - } + g_return_if_fail (value != NULL); + g_return_if_fail (value_str != NULL); + + GST_CAT_DEBUG (GST_CAT_PARAMS, "parsing '%s' to type %s", value_str, + g_type_name (G_VALUE_TYPE (value))); + + switch (G_VALUE_TYPE (value)) { + case G_TYPE_STRING: + g_value_set_string (value, g_strdup (value_str)); + break; + case G_TYPE_ENUM: + case G_TYPE_INT:{ + gint i; + + sscanf (value_str, "%d", &i); + g_value_set_int (value, i); + break; + } + case G_TYPE_UINT:{ + guint i; + + sscanf (value_str, "%u", &i); + g_value_set_uint (value, i); + break; + } + case G_TYPE_LONG:{ + glong i; + + sscanf (value_str, "%ld", &i); + g_value_set_long (value, i); + break; + } + case G_TYPE_ULONG:{ + gulong i; + + sscanf (value_str, "%lu", &i); + g_value_set_ulong (value, i); + break; + } + case G_TYPE_BOOLEAN:{ + gboolean i = FALSE; + + if (!strncmp ("true", value_str, 4)) + i = TRUE; + g_value_set_boolean (value, i); + break; + } + case G_TYPE_CHAR:{ + gchar i; + + sscanf (value_str, "%c", &i); + g_value_set_char (value, i); + break; + } + case G_TYPE_UCHAR:{ + guchar i; + + sscanf (value_str, "%c", &i); + g_value_set_uchar (value, i); + break; + } + case G_TYPE_FLOAT:{ + gfloat i; + + sscanf (value_str, "%f", &i); + g_value_set_float (value, i); + break; + } + case G_TYPE_DOUBLE:{ + gfloat i; + + sscanf (value_str, "%g", &i); + g_value_set_double (value, (gdouble) i); + break; + } + default: + break; + } } /** @@ -157,19 +169,21 @@ gst_util_set_value_from_string(GValue *value, const gchar *value_str) * sets the argument with it. */ void -gst_util_set_object_arg (GObject * object, const gchar * name, const gchar * value) +gst_util_set_object_arg (GObject * object, const gchar * name, + const gchar * value) { if (name && value) { GParamSpec *paramspec; - paramspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); + paramspec = + g_object_class_find_property (G_OBJECT_GET_CLASS (object), name); if (!paramspec) { return; } - GST_DEBUG ( "paramspec->flags is %d, paramspec->value_type is %d", - paramspec->flags, (gint) paramspec->value_type); + GST_DEBUG ("paramspec->flags is %d, paramspec->value_type is %d", + paramspec->flags, (gint) paramspec->value_type); if (paramspec->flags & G_PARAM_WRITABLE) { switch (paramspec->value_type) { @@ -247,8 +261,7 @@ gst_util_set_object_arg (GObject * object, const gchar * name, const gchar * val sscanf (value, "%d", &i); g_object_set (G_OBJECT (object), name, i, NULL); - } - else if (paramspec->value_type == GST_TYPE_URI) { + } else if (paramspec->value_type == GST_TYPE_URI) { g_object_set (G_OBJECT (object), name, value, NULL); } break; @@ -294,14 +307,14 @@ gst_print_pad_caps (GString * buf, gint indent, GstPad * pad) if (!caps) { string_append_indent (buf, indent); - g_string_printf (buf, "%s:%s has no capabilities", GST_DEBUG_PAD_NAME (pad)); - } - else { + g_string_printf (buf, "%s:%s has no capabilities", + GST_DEBUG_PAD_NAME (pad)); + } else { char *s; - s = gst_caps_to_string(caps); - g_string_append(buf, s); - g_free(s); + s = gst_caps_to_string (caps); + g_string_append (buf, s); + g_free (s); } } @@ -318,12 +331,12 @@ void gst_print_element_args (GString * buf, gint indent, GstElement * element) { guint width; - GValue value = { 0, }; /* the important thing is that value.type = 0 */ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ gchar *str = 0; GParamSpec *spec, **specs, **walk; specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element), NULL); - + width = 0; for (walk = specs; *walk; walk++) { spec = *walk; @@ -333,12 +346,12 @@ gst_print_element_args (GString * buf, gint indent, GstElement * element) for (walk = specs; *walk; walk++) { spec = *walk; - + if (spec->flags & G_PARAM_READABLE) { - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (spec)); + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (spec)); g_object_get_property (G_OBJECT (element), spec->name, &value); str = g_strdup_value_contents (&value); - g_value_unset(&value); + g_value_unset (&value); } else { str = g_strdup ("Parameter not readable."); } @@ -348,7 +361,7 @@ gst_print_element_args (GString * buf, gint indent, GstElement * element) string_append_indent (buf, 2 + width - strlen (spec->name)); g_string_append (buf, str); g_string_append_c (buf, '\n'); - + g_free (str); } diff --git a/gst/gstutils.h b/gst/gstutils.h index c3f5e9c4a..bb613f27f 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -28,14 +28,15 @@ #include G_BEGIN_DECLS + void gst_util_set_value_from_string (GValue * value, + const gchar * value_str); +void gst_util_set_object_arg (GObject * object, const gchar * name, + const gchar * value); -void gst_util_set_value_from_string (GValue *value, const gchar *value_str); -void gst_util_set_object_arg (GObject *object, const gchar *name, const gchar *value); - -void gst_util_dump_mem (guchar *mem, guint size); +void gst_util_dump_mem (guchar * mem, guint size); -void gst_print_pad_caps (GString *buf, gint indent, GstPad *pad); -void gst_print_element_args (GString *buf, gint indent, GstElement *element); +void gst_print_pad_caps (GString * buf, gint indent, GstPad * pad); +void gst_print_element_args (GString * buf, gint indent, GstElement * element); /* Macros for defining classes. Ideas taken from Bonobo, which took theirs @@ -105,5 +106,4 @@ type_as_function ## _get_type (void) \ G_END_DECLS - #endif /* __GST_UTILS_H__ */ diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 5678a34f4..d704643a0 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -28,14 +28,16 @@ typedef struct _GstValueUnionInfo GstValueUnionInfo; -struct _GstValueUnionInfo { +struct _GstValueUnionInfo +{ GType type1; GType type2; GstValueUnionFunc func; }; typedef struct _GstValueIntersectInfo GstValueIntersectInfo; -struct _GstValueIntersectInfo { +struct _GstValueIntersectInfo +{ GType type1; GType type2; GstValueIntersectFunc func; @@ -54,75 +56,78 @@ static GArray *gst_value_intersect_funcs; /* list */ static void -gst_value_init_list (GValue *value) +gst_value_init_list (GValue * value) { - value->data[0].v_pointer = g_array_new (FALSE, TRUE, sizeof(GValue)); + value->data[0].v_pointer = g_array_new (FALSE, TRUE, sizeof (GValue)); } static GArray * -gst_value_list_array_copy (const GArray *src) +gst_value_list_array_copy (const GArray * src) { GArray *dest; gint i; - - dest = g_array_sized_new (FALSE, TRUE, sizeof(GValue), src->len); + + dest = g_array_sized_new (FALSE, TRUE, sizeof (GValue), src->len); g_array_set_size (dest, src->len); for (i = 0; i < src->len; i++) { - gst_value_init_and_copy (&g_array_index(dest, GValue, i), - &g_array_index(src, GValue, i)); + gst_value_init_and_copy (&g_array_index (dest, GValue, i), + &g_array_index (src, GValue, i)); } return dest; } static void -gst_value_copy_list (const GValue *src_value, GValue *dest_value) +gst_value_copy_list (const GValue * src_value, GValue * dest_value) { - dest_value->data[0].v_pointer = gst_value_list_array_copy ((GArray *) src_value->data[0].v_pointer); + dest_value->data[0].v_pointer = + gst_value_list_array_copy ((GArray *) src_value->data[0].v_pointer); } static void -gst_value_free_list (GValue *value) +gst_value_free_list (GValue * value) { gint i; GArray *src = (GArray *) value->data[0].v_pointer; - + if ((value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS) == 0) { for (i = 0; i < src->len; i++) { - g_value_unset (&g_array_index(src, GValue, i)); + g_value_unset (&g_array_index (src, GValue, i)); } g_array_free (src, TRUE); } } static gpointer -gst_value_list_peek_pointer (const GValue *value) +gst_value_list_peek_pointer (const GValue * value) { return value->data[0].v_pointer; } static gchar * -gst_value_collect_list (GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_collect_list (GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { if (collect_flags & G_VALUE_NOCOPY_CONTENTS) { value->data[0].v_pointer = collect_values[0].v_pointer; value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; } else { - value->data[0].v_pointer = gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer); + value->data[0].v_pointer = + gst_value_list_array_copy ((GArray *) collect_values[0].v_pointer); } return NULL; } static gchar * -gst_value_lcopy_list (const GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_lcopy_list (const GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { GArray **dest = collect_values[0].v_pointer; + if (!dest) return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value)); - if (!value->data[0].v_pointer) + if (!value->data[0].v_pointer) return g_strdup_printf ("invalid value given for `%s'", G_VALUE_TYPE_NAME (value)); if (collect_flags & G_VALUE_NOCOPY_CONTENTS) { @@ -137,8 +142,8 @@ gst_value_lcopy_list (const GValue *value, guint n_collect_values, * gst_value_list_prepend_value: * */ -void -gst_value_list_prepend_value (GValue *value, const GValue *prepend_value) +void +gst_value_list_prepend_value (GValue * value, const GValue * prepend_value) { g_return_if_fail (GST_VALUE_HOLDS_LIST (value)); @@ -149,8 +154,8 @@ gst_value_list_prepend_value (GValue *value, const GValue *prepend_value) * gst_value_list_append_value: * */ -void -gst_value_list_append_value (GValue *value, const GValue *append_value) +void +gst_value_list_append_value (GValue * value, const GValue * append_value) { g_return_if_fail (GST_VALUE_HOLDS_LIST (value)); @@ -161,8 +166,8 @@ gst_value_list_append_value (GValue *value, const GValue *append_value) * gst_value_list_get_size: * */ -guint -gst_value_list_get_size (const GValue *value) +guint +gst_value_list_get_size (const GValue * value) { g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), 0); @@ -174,12 +179,13 @@ gst_value_list_get_size (const GValue *value) * */ const GValue * -gst_value_list_get_value (const GValue *value, guint index) +gst_value_list_get_value (const GValue * value, guint index) { g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value), NULL); g_return_val_if_fail (index < gst_value_list_get_size (value), NULL); - return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer, GValue, index); + return (const GValue *) &g_array_index ((GArray *) value->data[0].v_pointer, + GValue, index); } /** @@ -192,7 +198,8 @@ gst_value_list_get_value (const GValue *value, guint index) * initialized to the type GST_TYPE_LIST. */ void -gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2) +gst_value_list_concat (GValue * dest, const GValue * value1, + const GValue * value2) { guint i, value1_length, value2_length; GArray *array; @@ -201,36 +208,37 @@ gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2) g_return_if_fail (G_VALUE_TYPE (dest) == 0); g_return_if_fail (G_IS_VALUE (value1)); g_return_if_fail (G_IS_VALUE (value2)); - - value1_length = (GST_VALUE_HOLDS_LIST (value1) ? gst_value_list_get_size (value1) : 1); - value2_length = (GST_VALUE_HOLDS_LIST (value2) ? gst_value_list_get_size (value2) : 1); + + value1_length = + (GST_VALUE_HOLDS_LIST (value1) ? gst_value_list_get_size (value1) : 1); + value2_length = + (GST_VALUE_HOLDS_LIST (value2) ? gst_value_list_get_size (value2) : 1); g_value_init (dest, GST_TYPE_LIST); array = (GArray *) dest->data[0].v_pointer; g_array_set_size (array, value1_length + value2_length); - + if (GST_VALUE_HOLDS_LIST (value1)) { for (i = 0; i < value1_length; i++) { - gst_value_init_and_copy (&g_array_index(array, GValue, i), - gst_value_list_get_value (value1, i)); + gst_value_init_and_copy (&g_array_index (array, GValue, i), + gst_value_list_get_value (value1, i)); } } else { - gst_value_init_and_copy (&g_array_index(array, GValue, 0), value1); + gst_value_init_and_copy (&g_array_index (array, GValue, 0), value1); } - + if (GST_VALUE_HOLDS_LIST (value2)) { for (i = 0; i < value2_length; i++) { - gst_value_init_and_copy (&g_array_index(array, GValue, i + value1_length), - gst_value_list_get_value (value2, i)); + gst_value_init_and_copy (&g_array_index (array, GValue, + i + value1_length), gst_value_list_get_value (value2, i)); } } else { - gst_value_init_and_copy (&g_array_index(array, GValue, value1_length), - value2); + gst_value_init_and_copy (&g_array_index (array, GValue, value1_length), + value2); } } static void -gst_value_transform_list_string (const GValue *src_value, - GValue *dest_value) +gst_value_transform_list_string (const GValue * src_value, GValue * dest_value) { GValue *list_value; GArray *array; @@ -240,9 +248,9 @@ gst_value_transform_list_string (const GValue *src_value, array = src_value->data[0].v_pointer; - s = g_string_new("{ "); - for(i=0;ilen;i++){ - list_value = &g_array_index(array, GValue, i); + s = g_string_new ("{ "); + for (i = 0; i < array->len; i++) { + list_value = &g_array_index (array, GValue, i); if (i != 0) { g_string_append (s, ", "); @@ -257,23 +265,25 @@ gst_value_transform_list_string (const GValue *src_value, } static int -gst_value_compare_list (const GValue *value1, const GValue *value2) +gst_value_compare_list (const GValue * value1, const GValue * value2) { - int i,j; + int i, j; GArray *array1 = value1->data[0].v_pointer; GArray *array2 = value2->data[0].v_pointer; GValue *v1; GValue *v2; - if (array1->len != array2->len) return GST_VALUE_UNORDERED; + if (array1->len != array2->len) + return GST_VALUE_UNORDERED; - for(i=0;ilen;i++){ + for (i = 0; i < array1->len; i++) { v1 = &g_array_index (array1, GValue, i); - for(j=0;jlen;j++){ + for (j = 0; j < array1->len; j++) { v2 = &g_array_index (array2, GValue, j); - if (gst_value_compare(v1, v2) == GST_VALUE_EQUAL) break; + if (gst_value_compare (v1, v2) == GST_VALUE_EQUAL) + break; } - if (j==array1->len) { + if (j == array1->len) { return GST_VALUE_UNORDERED; } } @@ -282,7 +292,7 @@ gst_value_compare_list (const GValue *value1, const GValue *value2) } static char * -gst_value_serialize_list (const GValue *value) +gst_value_serialize_list (const GValue * value) { int i; GArray *array = value->data[0].v_pointer; @@ -290,13 +300,13 @@ gst_value_serialize_list (const GValue *value) GValue *v; gchar *s_val; - s = g_string_new("{ "); - for(i=0;ilen;i++){ + s = g_string_new ("{ "); + for (i = 0; i < array->len; i++) { v = &g_array_index (array, GValue, i); s_val = gst_value_serialize (v); g_string_append (s, s_val); g_free (s_val); - if (ilen - 1) { + if (i < array->len - 1) { g_string_append (s, ", "); } } @@ -305,30 +315,30 @@ gst_value_serialize_list (const GValue *value) } static gboolean -gst_value_deserialize_list (GValue *dest, const char *s) +gst_value_deserialize_list (GValue * dest, const char *s) { - g_warning("unimplemented"); + g_warning ("unimplemented"); return FALSE; } /*************************************/ /* fourcc */ -static void -gst_value_init_fourcc (GValue *value) +static void +gst_value_init_fourcc (GValue * value) { value->data[0].v_int = 0; } static void -gst_value_copy_fourcc (const GValue *src_value, GValue *dest_value) +gst_value_copy_fourcc (const GValue * src_value, GValue * dest_value) { dest_value->data[0].v_int = src_value->data[0].v_int; } static gchar * -gst_value_collect_fourcc (GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_collect_fourcc (GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { value->data[0].v_int = collect_values[0].v_int; @@ -336,8 +346,8 @@ gst_value_collect_fourcc (GValue *value, guint n_collect_values, } static gchar * -gst_value_lcopy_fourcc (const GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_lcopy_fourcc (const GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { guint32 *fourcc_p = collect_values[0].v_pointer; @@ -355,7 +365,7 @@ gst_value_lcopy_fourcc (const GValue *value, guint n_collect_values, * */ void -gst_value_set_fourcc (GValue *value, guint32 fourcc) +gst_value_set_fourcc (GValue * value, guint32 fourcc) { g_return_if_fail (GST_VALUE_HOLDS_FOURCC (value)); @@ -367,7 +377,7 @@ gst_value_set_fourcc (GValue *value, guint32 fourcc) * */ guint32 -gst_value_get_fourcc (const GValue *value) +gst_value_get_fourcc (const GValue * value) { g_return_val_if_fail (GST_VALUE_HOLDS_FOURCC (value), 0); @@ -375,53 +385,54 @@ gst_value_get_fourcc (const GValue *value) } static void -gst_value_transform_fourcc_string (const GValue *src_value, - GValue *dest_value) +gst_value_transform_fourcc_string (const GValue * src_value, + GValue * dest_value) { guint32 fourcc = src_value->data[0].v_int; - if (g_ascii_isprint ((fourcc>>0) & 0xff) && - g_ascii_isprint ((fourcc>>8) & 0xff) && - g_ascii_isprint ((fourcc>>16) & 0xff) && - g_ascii_isprint ((fourcc>>24) & 0xff)){ - dest_value->data[0].v_pointer = g_strdup_printf( - GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc)); + if (g_ascii_isprint ((fourcc >> 0) & 0xff) && + g_ascii_isprint ((fourcc >> 8) & 0xff) && + g_ascii_isprint ((fourcc >> 16) & 0xff) && + g_ascii_isprint ((fourcc >> 24) & 0xff)) { + dest_value->data[0].v_pointer = + g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc)); } else { - dest_value->data[0].v_pointer = g_strdup_printf("0x%08x", fourcc); + dest_value->data[0].v_pointer = g_strdup_printf ("0x%08x", fourcc); } } static int -gst_value_compare_fourcc (const GValue *value1, const GValue *value2) +gst_value_compare_fourcc (const GValue * value1, const GValue * value2) { - if (value2->data[0].v_int == value1->data[0].v_int) return GST_VALUE_EQUAL; + if (value2->data[0].v_int == value1->data[0].v_int) + return GST_VALUE_EQUAL; return GST_VALUE_UNORDERED; } static char * -gst_value_serialize_fourcc (const GValue *value) +gst_value_serialize_fourcc (const GValue * value) { guint32 fourcc = value->data[0].v_int; - if (g_ascii_isalnum ((fourcc>>0) & 0xff) && - g_ascii_isalnum ((fourcc>>8) & 0xff) && - g_ascii_isalnum ((fourcc>>16) & 0xff) && - g_ascii_isalnum ((fourcc>>24) & 0xff)){ - return g_strdup_printf(GST_FOURCC_FORMAT, GST_FOURCC_ARGS(fourcc)); + if (g_ascii_isalnum ((fourcc >> 0) & 0xff) && + g_ascii_isalnum ((fourcc >> 8) & 0xff) && + g_ascii_isalnum ((fourcc >> 16) & 0xff) && + g_ascii_isalnum ((fourcc >> 24) & 0xff)) { + return g_strdup_printf (GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc)); } else { - return g_strdup_printf("0x%08x", fourcc); + return g_strdup_printf ("0x%08x", fourcc); } } static gboolean -gst_value_deserialize_fourcc (GValue *dest, const char *s) +gst_value_deserialize_fourcc (GValue * dest, const char *s) { gboolean ret = FALSE; guint32 fourcc = 0; char *end; - if (strlen(s) == 4) { - fourcc = GST_MAKE_FOURCC(s[0], s[1], s[2], s[3]); + if (strlen (s) == 4) { + fourcc = GST_MAKE_FOURCC (s[0], s[1], s[2], s[3]); ret = TRUE; } else if (g_ascii_isdigit (*s)) { fourcc = strtoul (s, &end, 0); @@ -437,23 +448,23 @@ gst_value_deserialize_fourcc (GValue *dest, const char *s) /*************************************/ /* int range */ -static void -gst_value_init_int_range (GValue *value) +static void +gst_value_init_int_range (GValue * value) { value->data[0].v_int = 0; value->data[1].v_int = 0; } static void -gst_value_copy_int_range (const GValue *src_value, GValue *dest_value) +gst_value_copy_int_range (const GValue * src_value, GValue * dest_value) { dest_value->data[0].v_int = src_value->data[0].v_int; dest_value->data[1].v_int = src_value->data[1].v_int; } static gchar * -gst_value_collect_int_range (GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_collect_int_range (GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { /* FIXME */ value->data[0].v_int = collect_values[0].v_int; @@ -463,8 +474,8 @@ gst_value_collect_int_range (GValue *value, guint n_collect_values, } static gchar * -gst_value_lcopy_int_range (const GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_lcopy_int_range (const GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { guint32 *int_range_start = collect_values[0].v_pointer; guint32 *int_range_end = collect_values[1].v_pointer; @@ -487,7 +498,7 @@ gst_value_lcopy_int_range (const GValue *value, guint n_collect_values, * */ void -gst_value_set_int_range (GValue *value, int start, int end) +gst_value_set_int_range (GValue * value, int start, int end) { g_return_if_fail (GST_VALUE_HOLDS_INT_RANGE (value)); @@ -500,7 +511,7 @@ gst_value_set_int_range (GValue *value, int start, int end) * */ int -gst_value_get_int_range_min (const GValue *value) +gst_value_get_int_range_min (const GValue * value) { g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0); @@ -512,7 +523,7 @@ gst_value_get_int_range_min (const GValue *value) * */ int -gst_value_get_int_range_max (const GValue *value) +gst_value_get_int_range_max (const GValue * value) { g_return_val_if_fail (GST_VALUE_HOLDS_INT_RANGE (value), 0); @@ -520,55 +531,56 @@ gst_value_get_int_range_max (const GValue *value) } static void -gst_value_transform_int_range_string (const GValue *src_value, - GValue *dest_value) +gst_value_transform_int_range_string (const GValue * src_value, + GValue * dest_value) { - dest_value->data[0].v_pointer = g_strdup_printf("[%d,%d]", - (int)src_value->data[0].v_int, (int)src_value->data[1].v_int); + dest_value->data[0].v_pointer = g_strdup_printf ("[%d,%d]", + (int) src_value->data[0].v_int, (int) src_value->data[1].v_int); } static int -gst_value_compare_int_range (const GValue *value1, const GValue *value2) +gst_value_compare_int_range (const GValue * value1, const GValue * value2) { if (value2->data[0].v_int == value1->data[0].v_int && - value2->data[0].v_int == value1->data[0].v_int) return GST_VALUE_EQUAL; + value2->data[0].v_int == value1->data[0].v_int) + return GST_VALUE_EQUAL; return GST_VALUE_UNORDERED; } static char * -gst_value_serialize_int_range (const GValue *value) +gst_value_serialize_int_range (const GValue * value) { return g_strdup_printf ("[ %d, %d ]", value->data[0].v_int, value->data[1].v_int); } static gboolean -gst_value_deserialize_int_range (GValue *dest, const char *s) +gst_value_deserialize_int_range (GValue * dest, const char *s) { - g_warning("unimplemented"); + g_warning ("unimplemented"); return FALSE; } /*************************************/ /* double range */ -static void -gst_value_init_double_range (GValue *value) +static void +gst_value_init_double_range (GValue * value) { value->data[0].v_double = 0; value->data[1].v_double = 0; } static void -gst_value_copy_double_range (const GValue *src_value, GValue *dest_value) +gst_value_copy_double_range (const GValue * src_value, GValue * dest_value) { dest_value->data[0].v_double = src_value->data[0].v_double; dest_value->data[1].v_double = src_value->data[1].v_double; } static gchar * -gst_value_collect_double_range (GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_collect_double_range (GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { value->data[0].v_double = collect_values[0].v_double; value->data[1].v_double = collect_values[1].v_double; @@ -577,8 +589,8 @@ gst_value_collect_double_range (GValue *value, guint n_collect_values, } static gchar * -gst_value_lcopy_double_range (const GValue *value, guint n_collect_values, - GTypeCValue *collect_values, guint collect_flags) +gst_value_lcopy_double_range (const GValue * value, guint n_collect_values, + GTypeCValue * collect_values, guint collect_flags) { gdouble *double_range_start = collect_values[0].v_pointer; gdouble *double_range_end = collect_values[1].v_pointer; @@ -601,7 +613,7 @@ gst_value_lcopy_double_range (const GValue *value, guint n_collect_values, * */ void -gst_value_set_double_range (GValue *value, double start, double end) +gst_value_set_double_range (GValue * value, double start, double end) { g_return_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value)); @@ -614,7 +626,7 @@ gst_value_set_double_range (GValue *value, double start, double end) * */ double -gst_value_get_double_range_min (const GValue *value) +gst_value_get_double_range_min (const GValue * value) { g_return_val_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value), 0); @@ -626,7 +638,7 @@ gst_value_get_double_range_min (const GValue *value) * */ double -gst_value_get_double_range_max (const GValue *value) +gst_value_get_double_range_max (const GValue * value) { g_return_val_if_fail (GST_VALUE_HOLDS_DOUBLE_RANGE (value), 0); @@ -634,20 +646,20 @@ gst_value_get_double_range_max (const GValue *value) } static void -gst_value_transform_double_range_string (const GValue *src_value, - GValue *dest_value) +gst_value_transform_double_range_string (const GValue * src_value, + GValue * dest_value) { - char s1[G_ASCII_DTOSTR_BUF_SIZE],s2[G_ASCII_DTOSTR_BUF_SIZE]; + char s1[G_ASCII_DTOSTR_BUF_SIZE], s2[G_ASCII_DTOSTR_BUF_SIZE]; - dest_value->data[0].v_pointer = g_strdup_printf("[%s,%s]", + dest_value->data[0].v_pointer = g_strdup_printf ("[%s,%s]", g_ascii_dtostr (s1, G_ASCII_DTOSTR_BUF_SIZE, - src_value->data[0].v_double), + src_value->data[0].v_double), g_ascii_dtostr (s2, G_ASCII_DTOSTR_BUF_SIZE, - src_value->data[1].v_double)); + src_value->data[1].v_double)); } static int -gst_value_compare_double_range (const GValue *value1, const GValue *value2) +gst_value_compare_double_range (const GValue * value1, const GValue * value2) { if (value2->data[0].v_double == value1->data[0].v_double && value2->data[0].v_double == value1->data[0].v_double) @@ -656,19 +668,20 @@ gst_value_compare_double_range (const GValue *value1, const GValue *value2) } static char * -gst_value_serialize_double_range (const GValue *value) +gst_value_serialize_double_range (const GValue * value) { char d1[G_ASCII_DTOSTR_BUF_SIZE]; char d2[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(d1, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double); - g_ascii_dtostr(d2, G_ASCII_DTOSTR_BUF_SIZE, value->data[1].v_double); + + g_ascii_dtostr (d1, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double); + g_ascii_dtostr (d2, G_ASCII_DTOSTR_BUF_SIZE, value->data[1].v_double); return g_strdup_printf ("[ %s, %s ]", d1, d2); } static gboolean -gst_value_deserialize_double_range (GValue *dest, const char *s) +gst_value_deserialize_double_range (GValue * dest, const char *s) { - g_warning("unimplemented"); + g_warning ("unimplemented"); return FALSE; } @@ -680,7 +693,7 @@ gst_value_deserialize_double_range (GValue *dest, const char *s) * */ void -gst_value_set_caps (GValue *value, const GstCaps *caps) +gst_value_set_caps (GValue * value, const GstCaps * caps) { g_return_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS); @@ -692,7 +705,7 @@ gst_value_set_caps (GValue *value, const GstCaps *caps) * */ const GstCaps * -gst_value_get_caps (const GValue *value) +gst_value_get_caps (const GValue * value) { g_return_val_if_fail (G_VALUE_TYPE (value) == GST_TYPE_CAPS, NULL); @@ -703,15 +716,15 @@ gst_value_get_caps (const GValue *value) /* boolean */ static int -gst_value_compare_boolean (const GValue *value1, const GValue *value2) +gst_value_compare_boolean (const GValue * value1, const GValue * value2) { - if ((value1->data[0].v_int!=0) == (value2->data[0].v_int!=0)) + if ((value1->data[0].v_int != 0) == (value2->data[0].v_int != 0)) return GST_VALUE_EQUAL; return GST_VALUE_UNORDERED; } static char * -gst_value_serialize_boolean (const GValue *value) +gst_value_serialize_boolean (const GValue * value) { if (value->data[0].v_int) { return g_strdup ("true"); @@ -720,24 +733,22 @@ gst_value_serialize_boolean (const GValue *value) } static gboolean -gst_value_deserialize_boolean (GValue *dest, const char *s) +gst_value_deserialize_boolean (GValue * dest, const char *s) { gboolean ret = FALSE; if (g_ascii_strcasecmp (s, "true") == 0 || g_ascii_strcasecmp (s, "yes") == 0 || - g_ascii_strcasecmp (s, "t") == 0 || - strcmp (s, "1") == 0) { + g_ascii_strcasecmp (s, "t") == 0 || strcmp (s, "1") == 0) { g_value_set_boolean (dest, TRUE); ret = TRUE; } else if (g_ascii_strcasecmp (s, "false") == 0 || g_ascii_strcasecmp (s, "no") == 0 || - g_ascii_strcasecmp (s, "f") == 0 || - strcmp (s, "0") == 0) { + g_ascii_strcasecmp (s, "f") == 0 || strcmp (s, "0") == 0) { g_value_set_boolean (dest, FALSE); ret = TRUE; } - + return ret; } @@ -745,7 +756,7 @@ gst_value_deserialize_boolean (GValue *dest, const char *s) /* int */ static int -gst_value_compare_int (const GValue *value1, const GValue *value2) +gst_value_compare_int (const GValue * value1, const GValue * value2) { if (value1->data[0].v_int > value2->data[0].v_int) return GST_VALUE_GREATER_THAN; @@ -755,7 +766,7 @@ gst_value_compare_int (const GValue *value1, const GValue *value2) } static char * -gst_value_serialize_int (const GValue *value) +gst_value_serialize_int (const GValue * value) { return g_strdup_printf ("%d", value->data[0].v_int); } @@ -766,7 +777,7 @@ gst_strtoi (const char *s, char **end, int base) int i; if (s[0] == '-') { - i = - (int) strtoul (s + 1, end, base); + i = -(int) strtoul (s + 1, end, base); } else { i = strtoul (s, end, base); } @@ -775,7 +786,7 @@ gst_strtoi (const char *s, char **end, int base) } static gboolean -gst_value_deserialize_int (GValue *dest, const char *s) +gst_value_deserialize_int (GValue * dest, const char *s) { int x; char *end; @@ -812,7 +823,7 @@ gst_value_deserialize_int (GValue *dest, const char *s) /* double */ static int -gst_value_compare_double (const GValue *value1, const GValue *value2) +gst_value_compare_double (const GValue * value1, const GValue * value2) { if (value1->data[0].v_double > value2->data[0].v_double) return GST_VALUE_GREATER_THAN; @@ -824,15 +835,16 @@ gst_value_compare_double (const GValue *value1, const GValue *value2) } static char * -gst_value_serialize_double (const GValue *value) +gst_value_serialize_double (const GValue * value) { char d[G_ASCII_DTOSTR_BUF_SIZE]; - g_ascii_dtostr(d, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double); + + g_ascii_dtostr (d, G_ASCII_DTOSTR_BUF_SIZE, value->data[0].v_double); return g_strdup (d); } static gboolean -gst_value_deserialize_double (GValue *dest, const char *s) +gst_value_deserialize_double (GValue * dest, const char *s) { double x; gboolean ret = FALSE; @@ -860,11 +872,14 @@ gst_value_deserialize_double (GValue *dest, const char *s) /* string */ static int -gst_value_compare_string (const GValue *value1, const GValue *value2) +gst_value_compare_string (const GValue * value1, const GValue * value2) { - int x = strcmp(value1->data[0].v_pointer, value2->data[0].v_pointer); - if(x<0) return GST_VALUE_LESS_THAN; - if(x>0) return GST_VALUE_GREATER_THAN; + int x = strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer); + + if (x < 0) + return GST_VALUE_LESS_THAN; + if (x > 0) + return GST_VALUE_GREATER_THAN; return GST_VALUE_EQUAL; } @@ -883,9 +898,9 @@ gst_string_wrap (const char *s) len = 0; t = s; while (*t) { - if(GST_ASCII_IS_STRING(*t)) { + if (GST_ASCII_IS_STRING (*t)) { len++; - } else if(*t < 0x20 || *t >= 0x7f) { + } else if (*t < 0x20 || *t >= 0x7f) { wrap = TRUE; len += 4; } else { @@ -895,20 +910,21 @@ gst_string_wrap (const char *s) t++; } - if (!wrap) return strdup (s); + if (!wrap) + return strdup (s); - e = d = g_malloc(len + 3); + e = d = g_malloc (len + 3); *e++ = '\"'; t = s; while (*t) { - if(GST_ASCII_IS_STRING(*t)) { + if (GST_ASCII_IS_STRING (*t)) { *e++ = *t++; - } else if(*t < 0x20 || *t >= 0x7f) { + } else if (*t < 0x20 || *t >= 0x7f) { *e++ = '\\'; - *e++ = '0' + ((*t)>>6); - *e++ = '0' + (((*t)>>3)&0x7); - *e++ = '0' + ((*t++)&0x7); + *e++ = '0' + ((*t) >> 6); + *e++ = '0' + (((*t) >> 3) & 0x7); + *e++ = '0' + ((*t++) & 0x7); } else { *e++ = '\\'; *e++ = *t++; @@ -921,13 +937,13 @@ gst_string_wrap (const char *s) } static char * -gst_value_serialize_string (const GValue *value) +gst_value_serialize_string (const GValue * value) { return gst_string_wrap (value->data[0].v_pointer); } static gboolean -gst_value_deserialize_string (GValue *dest, const char *s) +gst_value_deserialize_string (GValue * dest, const char *s) { g_value_set_string (dest, s); @@ -941,14 +957,14 @@ gst_value_deserialize_string (GValue *dest, const char *s) /* intersection */ static gboolean -gst_value_intersect_int_int_range (GValue *dest, const GValue *src1, - const GValue *src2) +gst_value_intersect_int_int_range (GValue * dest, const GValue * src1, + const GValue * src2) { - g_return_val_if_fail(G_VALUE_TYPE(src1) == G_TYPE_INT, FALSE); - g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_INT_RANGE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src1) == G_TYPE_INT, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_INT_RANGE, FALSE); if (src2->data[0].v_int <= src1->data[0].v_int && - src2->data[1].v_int >= src1->data[0].v_int){ + src2->data[1].v_int >= src1->data[0].v_int) { gst_value_init_and_copy (dest, src1); return TRUE; } @@ -957,26 +973,26 @@ gst_value_intersect_int_int_range (GValue *dest, const GValue *src1, } static gboolean -gst_value_intersect_int_range_int_range (GValue *dest, const GValue *src1, - const GValue *src2) +gst_value_intersect_int_range_int_range (GValue * dest, const GValue * src1, + const GValue * src2) { int min; int max; - g_return_val_if_fail(G_VALUE_TYPE(src1) == GST_TYPE_INT_RANGE, FALSE); - g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_INT_RANGE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src1) == GST_TYPE_INT_RANGE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_INT_RANGE, FALSE); - min = MAX(src1->data[0].v_int, src2->data[0].v_int); - max = MIN(src1->data[1].v_int, src2->data[1].v_int); + min = MAX (src1->data[0].v_int, src2->data[0].v_int); + max = MIN (src1->data[1].v_int, src2->data[1].v_int); - if(min < max){ - g_value_init(dest, GST_TYPE_INT_RANGE); - gst_value_set_int_range(dest, min, max); + if (min < max) { + g_value_init (dest, GST_TYPE_INT_RANGE); + gst_value_set_int_range (dest, min, max); return TRUE; } - if(min == max){ - g_value_init(dest, G_TYPE_INT); - g_value_set_int(dest, min); + if (min == max) { + g_value_init (dest, G_TYPE_INT); + g_value_set_int (dest, min); return TRUE; } @@ -984,14 +1000,14 @@ gst_value_intersect_int_range_int_range (GValue *dest, const GValue *src1, } static gboolean -gst_value_intersect_double_double_range (GValue *dest, const GValue *src1, - const GValue *src2) +gst_value_intersect_double_double_range (GValue * dest, const GValue * src1, + const GValue * src2) { - g_return_val_if_fail(G_VALUE_TYPE(src1) == G_TYPE_DOUBLE, FALSE); - g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_DOUBLE_RANGE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src1) == G_TYPE_DOUBLE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_DOUBLE_RANGE, FALSE); if (src2->data[0].v_double <= src1->data[0].v_double && - src2->data[1].v_double >= src1->data[0].v_double){ + src2->data[1].v_double >= src1->data[0].v_double) { gst_value_init_and_copy (dest, src1); return TRUE; } @@ -1000,26 +1016,26 @@ gst_value_intersect_double_double_range (GValue *dest, const GValue *src1, } static gboolean -gst_value_intersect_double_range_double_range (GValue *dest, const GValue *src1, - const GValue *src2) +gst_value_intersect_double_range_double_range (GValue * dest, + const GValue * src1, const GValue * src2) { double min; double max; - g_return_val_if_fail(G_VALUE_TYPE(src1) == GST_TYPE_DOUBLE_RANGE, FALSE); - g_return_val_if_fail(G_VALUE_TYPE(src2) == GST_TYPE_DOUBLE_RANGE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src1) == GST_TYPE_DOUBLE_RANGE, FALSE); + g_return_val_if_fail (G_VALUE_TYPE (src2) == GST_TYPE_DOUBLE_RANGE, FALSE); - min = MAX(src1->data[0].v_double, src2->data[0].v_double); - max = MIN(src1->data[1].v_double, src2->data[1].v_double); + min = MAX (src1->data[0].v_double, src2->data[0].v_double); + max = MIN (src1->data[1].v_double, src2->data[1].v_double); - if(min < max){ - g_value_init(dest, GST_TYPE_DOUBLE_RANGE); - gst_value_set_double_range(dest, min, max); + if (min < max) { + g_value_init (dest, GST_TYPE_DOUBLE_RANGE); + gst_value_set_double_range (dest, min, max); return TRUE; } - if(min == max){ - g_value_init(dest, G_TYPE_DOUBLE); - g_value_set_int(dest, min); + if (min == max) { + g_value_init (dest, G_TYPE_DOUBLE); + g_value_set_int (dest, min); return TRUE; } @@ -1027,12 +1043,13 @@ gst_value_intersect_double_range_double_range (GValue *dest, const GValue *src1, } static gboolean -gst_value_intersect_list (GValue *dest, const GValue *value1, const GValue *value2) +gst_value_intersect_list (GValue * dest, const GValue * value1, + const GValue * value2) { guint i, size; GValue intersection = { 0, }; gboolean ret = FALSE; - + g_return_val_if_fail (GST_VALUE_HOLDS_LIST (value1), FALSE); size = gst_value_list_get_size (value1); @@ -1047,7 +1064,7 @@ gst_value_intersect_list (GValue *dest, const GValue *value1, const GValue *valu } else if (GST_VALUE_HOLDS_LIST (dest)) { gst_value_list_append_value (dest, &intersection); } else { - GValue temp = {0, }; + GValue temp = { 0, }; gst_value_init_and_copy (&temp, dest); g_value_unset (dest); @@ -1068,16 +1085,17 @@ gst_value_intersect_list (GValue *dest, const GValue *value1, const GValue *valu * */ gboolean -gst_value_can_compare (const GValue *value1, const GValue *value2) +gst_value_can_compare (const GValue * value1, const GValue * value2) { GstValueTable *table; int i; - if(G_VALUE_TYPE(value1) != G_VALUE_TYPE(value2))return FALSE; - for(i=0;ilen;i++){ - table = &g_array_index(gst_value_table, GstValueTable, i); - if(table->type == G_VALUE_TYPE(value1) && - table->compare) return TRUE; + if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2)) + return FALSE; + for (i = 0; i < gst_value_table->len; i++) { + table = &g_array_index (gst_value_table, GstValueTable, i); + if (table->type == G_VALUE_TYPE (value1) && table->compare) + return TRUE; } return FALSE; @@ -1088,22 +1106,23 @@ gst_value_can_compare (const GValue *value1, const GValue *value2) * */ int -gst_value_compare (const GValue *value1, const GValue *value2) +gst_value_compare (const GValue * value1, const GValue * value2) { GstValueTable *table; int i; - if (G_VALUE_TYPE(value1) != G_VALUE_TYPE(value2)) return GST_VALUE_UNORDERED; + if (G_VALUE_TYPE (value1) != G_VALUE_TYPE (value2)) + return GST_VALUE_UNORDERED; - for(i=0;ilen;i++){ - table = &g_array_index(gst_value_table, GstValueTable, i); - if(table->type != G_VALUE_TYPE(value1) || - table->compare == NULL) continue; + for (i = 0; i < gst_value_table->len; i++) { + table = &g_array_index (gst_value_table, GstValueTable, i); + if (table->type != G_VALUE_TYPE (value1) || table->compare == NULL) + continue; - return table->compare(value1, value2); + return table->compare (value1, value2); } - g_critical("unable to compare values of type %s\n", + g_critical ("unable to compare values of type %s\n", g_type_name (G_VALUE_TYPE (value1))); return GST_VALUE_UNORDERED; } @@ -1115,15 +1134,16 @@ gst_value_compare (const GValue *value1, const GValue *value2) * */ gboolean -gst_value_can_union (const GValue *value1, const GValue *value2) +gst_value_can_union (const GValue * value1, const GValue * value2) { GstValueUnionInfo *union_info; int i; - for(i=0;ilen;i++){ - union_info = &g_array_index(gst_value_union_funcs, GstValueUnionInfo, i); - if(union_info->type1 == G_VALUE_TYPE(value1) && - union_info->type2 == G_VALUE_TYPE(value2)) return TRUE; + for (i = 0; i < gst_value_union_funcs->len; i++) { + union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); + if (union_info->type1 == G_VALUE_TYPE (value1) && + union_info->type2 == G_VALUE_TYPE (value2)) + return TRUE; } return FALSE; @@ -1134,19 +1154,19 @@ gst_value_can_union (const GValue *value1, const GValue *value2) * */ gboolean -gst_value_union (GValue *dest, const GValue *value1, const GValue *value2) +gst_value_union (GValue * dest, const GValue * value1, const GValue * value2) { GstValueUnionInfo *union_info; int i; - for(i=0;ilen;i++){ - union_info = &g_array_index(gst_value_union_funcs, GstValueUnionInfo, i); - if(union_info->type1 == G_VALUE_TYPE(value1) && - union_info->type2 == G_VALUE_TYPE(value2)) { - return union_info->func(dest, value1, value2); + for (i = 0; i < gst_value_union_funcs->len; i++) { + union_info = &g_array_index (gst_value_union_funcs, GstValueUnionInfo, i); + if (union_info->type1 == G_VALUE_TYPE (value1) && + union_info->type2 == G_VALUE_TYPE (value2)) { + return union_info->func (dest, value1, value2); } } - + gst_value_list_concat (dest, value1, value2); return TRUE; } @@ -1164,7 +1184,7 @@ gst_value_register_union_func (GType type1, GType type2, GstValueUnionFunc func) union_info.type2 = type2; union_info.func = func; - g_array_append_val(gst_value_union_funcs, union_info); + g_array_append_val (gst_value_union_funcs, union_info); } /* intersection */ @@ -1174,21 +1194,21 @@ gst_value_register_union_func (GType type1, GType type2, GstValueUnionFunc func) * */ gboolean -gst_value_can_intersect (const GValue *value1, const GValue *value2) +gst_value_can_intersect (const GValue * value1, const GValue * value2) { GstValueIntersectInfo *intersect_info; int i; /* special cases */ - if (GST_VALUE_HOLDS_LIST (value1) || - GST_VALUE_HOLDS_LIST (value2)) + if (GST_VALUE_HOLDS_LIST (value1) || GST_VALUE_HOLDS_LIST (value2)) return TRUE; - for(i=0;ilen;i++){ - intersect_info = &g_array_index(gst_value_intersect_funcs, + for (i = 0; i < gst_value_intersect_funcs->len; i++) { + intersect_info = &g_array_index (gst_value_intersect_funcs, GstValueIntersectInfo, i); - if(intersect_info->type1 == G_VALUE_TYPE(value1) && - intersect_info->type2 == G_VALUE_TYPE(value2)) return TRUE; + if (intersect_info->type1 == G_VALUE_TYPE (value1) && + intersect_info->type2 == G_VALUE_TYPE (value2)) + return TRUE; } return gst_value_can_compare (value1, value2); @@ -1199,7 +1219,8 @@ gst_value_can_intersect (const GValue *value1, const GValue *value2) * */ gboolean -gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2) +gst_value_intersect (GValue * dest, const GValue * value1, + const GValue * value2) { GstValueIntersectInfo *intersect_info; int i; @@ -1210,23 +1231,23 @@ gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2) return gst_value_intersect_list (dest, value1, value2); if (GST_VALUE_HOLDS_LIST (value2)) return gst_value_intersect_list (dest, value2, value1); - - for(i=0;ilen;i++){ - intersect_info = &g_array_index(gst_value_intersect_funcs, + + for (i = 0; i < gst_value_intersect_funcs->len; i++) { + intersect_info = &g_array_index (gst_value_intersect_funcs, GstValueIntersectInfo, i); - if(intersect_info->type1 == G_VALUE_TYPE(value1) && - intersect_info->type2 == G_VALUE_TYPE(value2)) { - ret = intersect_info->func(dest, value1, value2); + if (intersect_info->type1 == G_VALUE_TYPE (value1) && + intersect_info->type2 == G_VALUE_TYPE (value2)) { + ret = intersect_info->func (dest, value1, value2); return ret; } - if(intersect_info->type1 == G_VALUE_TYPE(value2) && - intersect_info->type2 == G_VALUE_TYPE(value1)) { - ret = intersect_info->func(dest, value2, value1); + if (intersect_info->type1 == G_VALUE_TYPE (value2) && + intersect_info->type2 == G_VALUE_TYPE (value1)) { + ret = intersect_info->func (dest, value2, value1); return ret; } } - if(gst_value_compare(value1, value2) == GST_VALUE_EQUAL){ + if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL) { gst_value_init_and_copy (dest, value1); ret = TRUE; } @@ -1248,7 +1269,7 @@ gst_value_register_intersect_func (GType type1, GType type2, intersect_info.type2 = type2; intersect_info.func = func; - g_array_append_val(gst_value_intersect_funcs, intersect_info); + g_array_append_val (gst_value_intersect_funcs, intersect_info); } /** @@ -1256,9 +1277,9 @@ gst_value_register_intersect_func (GType type1, GType type2, * */ void -gst_value_register (const GstValueTable *table) +gst_value_register (const GstValueTable * table) { - g_array_append_val(gst_value_table, *table); + g_array_append_val (gst_value_table, *table); } /** @@ -1266,9 +1287,9 @@ gst_value_register (const GstValueTable *table) * */ void -gst_value_init_and_copy (GValue *dest, const GValue *src) +gst_value_init_and_copy (GValue * dest, const GValue * src) { - g_value_init (dest, G_VALUE_TYPE(src)); + g_value_init (dest, G_VALUE_TYPE (src)); g_value_copy (src, dest); } @@ -1277,19 +1298,19 @@ gst_value_init_and_copy (GValue *dest, const GValue *src) * */ gchar * -gst_value_serialize (const GValue *value) +gst_value_serialize (const GValue * value) { int i; GValue s_val = { 0 }; GstValueTable *table; char *s; - for(i=0;ilen;i++){ - table = &g_array_index(gst_value_table, GstValueTable, i); - if(table->type != G_VALUE_TYPE(value) || - table->serialize == NULL) continue; + for (i = 0; i < gst_value_table->len; i++) { + table = &g_array_index (gst_value_table, GstValueTable, i); + if (table->type != G_VALUE_TYPE (value) || table->serialize == NULL) + continue; - return table->serialize(value); + return table->serialize (value); } g_value_init (&s_val, G_TYPE_STRING); @@ -1305,17 +1326,17 @@ gst_value_serialize (const GValue *value) * */ gboolean -gst_value_deserialize (GValue *dest, const gchar *src) +gst_value_deserialize (GValue * dest, const gchar * src) { GstValueTable *table; int i; - for(i=0;ilen;i++){ - table = &g_array_index(gst_value_table, GstValueTable, i); - if(table->type != G_VALUE_TYPE(dest) || - table->deserialize == NULL) continue; + for (i = 0; i < gst_value_table->len; i++) { + table = &g_array_index (gst_value_table, GstValueTable, i); + if (table->type != G_VALUE_TYPE (dest) || table->deserialize == NULL) + continue; - return table->deserialize(dest, src); + return table->deserialize (dest, src); } return FALSE; @@ -1338,11 +1359,11 @@ _gst_value_initialize (void) }; //const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, }; - gst_value_table = g_array_new(FALSE, FALSE, sizeof(GstValueTable)); - gst_value_union_funcs = g_array_new(FALSE, FALSE, - sizeof(GstValueUnionInfo)); - gst_value_intersect_funcs = g_array_new(FALSE, FALSE, - sizeof(GstValueIntersectInfo)); + gst_value_table = g_array_new (FALSE, FALSE, sizeof (GstValueTable)); + gst_value_union_funcs = g_array_new (FALSE, FALSE, + sizeof (GstValueUnionInfo)); + gst_value_intersect_funcs = g_array_new (FALSE, FALSE, + sizeof (GstValueIntersectInfo)); { static const GTypeValueTable value_table = { @@ -1362,7 +1383,8 @@ _gst_value_initialize (void) gst_value_deserialize_fourcc, }; info.value_table = &value_table; - gst_type_fourcc = g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0); + gst_type_fourcc = + g_type_register_static (G_TYPE_BOXED, "GstFourcc", &info, 0); gst_value.type = gst_type_fourcc; gst_value_register (&gst_value); } @@ -1385,7 +1407,8 @@ _gst_value_initialize (void) gst_value_deserialize_int_range, }; info.value_table = &value_table; - gst_type_int_range = g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0); + gst_type_int_range = + g_type_register_static (G_TYPE_BOXED, "GstIntRange", &info, 0); gst_value.type = gst_type_int_range; gst_value_register (&gst_value); } @@ -1408,11 +1431,12 @@ _gst_value_initialize (void) gst_value_deserialize_double_range, }; info.value_table = &value_table; - gst_type_double_range = g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0); + gst_type_double_range = + g_type_register_static (G_TYPE_BOXED, "GstDoubleRange", &info, 0); gst_value.type = gst_type_double_range; gst_value_register (&gst_value); } - + { static const GTypeValueTable value_table = { gst_value_init_list, @@ -1431,7 +1455,8 @@ _gst_value_initialize (void) gst_value_deserialize_list, }; info.value_table = &value_table; - gst_type_list = g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0); + gst_type_list = + g_type_register_static (G_TYPE_BOXED, "GstValueList", &info, 0); gst_value.type = gst_type_list; gst_value_register (&gst_value); } @@ -1491,8 +1516,6 @@ _gst_value_initialize (void) gst_value_intersect_int_range_int_range); gst_value_register_intersect_func (G_TYPE_DOUBLE, GST_TYPE_DOUBLE_RANGE, gst_value_intersect_double_double_range); - gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE, GST_TYPE_DOUBLE_RANGE, - gst_value_intersect_double_range_double_range); + gst_value_register_intersect_func (GST_TYPE_DOUBLE_RANGE, + GST_TYPE_DOUBLE_RANGE, gst_value_intersect_double_range_double_range); } - - diff --git a/gst/gstvalue.h b/gst/gstvalue.h index 6493ab598..1253eef3f 100644 --- a/gst/gstvalue.h +++ b/gst/gstvalue.h @@ -24,24 +24,24 @@ #include G_BEGIN_DECLS - -typedef int (* GstValueCompareFunc) (const GValue *value1, - const GValue *value2); -typedef char * (* GstValueSerializeFunc) (const GValue *value1); -typedef gboolean (* GstValueDeserializeFunc) (GValue *dest, const char *s); -typedef int (* GstValueUnionFunc) (GValue *dest, const GValue *value1, - const GValue *value2); -typedef int (* GstValueIntersectFunc) (GValue *dest, const GValue *value1, - const GValue *value2); + typedef int (*GstValueCompareFunc) (const GValue * value1, + const GValue * value2); +typedef char *(*GstValueSerializeFunc) (const GValue * value1); +typedef gboolean (*GstValueDeserializeFunc) (GValue * dest, const char *s); +typedef int (*GstValueUnionFunc) (GValue * dest, const GValue * value1, + const GValue * value2); +typedef int (*GstValueIntersectFunc) (GValue * dest, const GValue * value1, + const GValue * value2); typedef struct _GstValueTable GstValueTable; -struct _GstValueTable { +struct _GstValueTable +{ GType type; GstValueCompareFunc compare; GstValueSerializeFunc serialize; GstValueDeserializeFunc deserialize; - void *_gst_reserved [GST_PADDING]; + void *_gst_reserved[GST_PADDING]; }; @@ -78,62 +78,66 @@ extern GType gst_type_list; /* list */ -void gst_value_list_prepend_value (GValue *value, const GValue *prepend_value); -void gst_value_list_append_value (GValue *value, const GValue *append_value); -guint gst_value_list_get_size (const GValue *value); -G_CONST_RETURN GValue *gst_value_list_get_value (const GValue *value, guint index); -void gst_value_list_concat (GValue *dest, const GValue *value1, const GValue *value2); +void gst_value_list_prepend_value (GValue * value, + const GValue * prepend_value); +void gst_value_list_append_value (GValue * value, const GValue * append_value); +guint gst_value_list_get_size (const GValue * value); +G_CONST_RETURN GValue *gst_value_list_get_value (const GValue * value, + guint index); +void gst_value_list_concat (GValue * dest, const GValue * value1, + const GValue * value2); /* fourcc */ -void gst_value_set_fourcc (GValue *value, guint32 fourcc); -guint32 gst_value_get_fourcc (const GValue *value); +void gst_value_set_fourcc (GValue * value, guint32 fourcc); +guint32 gst_value_get_fourcc (const GValue * value); /* int range */ -void gst_value_set_int_range (GValue *value, int start, int end); -int gst_value_get_int_range_min (const GValue *value); -int gst_value_get_int_range_max (const GValue *value); +void gst_value_set_int_range (GValue * value, int start, int end); +int gst_value_get_int_range_min (const GValue * value); +int gst_value_get_int_range_max (const GValue * value); /* double range */ -void gst_value_set_double_range (GValue *value, double start, double end); -double gst_value_get_double_range_min (const GValue *value); -double gst_value_get_double_range_max (const GValue *value); +void gst_value_set_double_range (GValue * value, double start, double end); +double gst_value_get_double_range_min (const GValue * value); +double gst_value_get_double_range_max (const GValue * value); /* caps */ -G_CONST_RETURN GstCaps *gst_value_get_caps (const GValue *value); -void gst_value_set_caps (GValue *value, const GstCaps *caps); +G_CONST_RETURN GstCaps *gst_value_get_caps (const GValue * value); +void gst_value_set_caps (GValue * value, const GstCaps * caps); /* compare */ -gboolean gst_value_can_compare (const GValue *value1, const GValue *value2); -int gst_value_compare (const GValue *value1, const GValue *value2); +gboolean gst_value_can_compare (const GValue * value1, const GValue * value2); +int gst_value_compare (const GValue * value1, const GValue * value2); /* union */ -gboolean gst_value_can_union (const GValue *value1, const GValue *value2); -gboolean gst_value_union (GValue *dest, const GValue *value1, const GValue *value2); -void gst_value_register_union_func (GType type1, GType type2, GstValueUnionFunc func); +gboolean gst_value_can_union (const GValue * value1, const GValue * value2); +gboolean gst_value_union (GValue * dest, const GValue * value1, + const GValue * value2); +void gst_value_register_union_func (GType type1, GType type2, + GstValueUnionFunc func); /* intersection */ -gboolean gst_value_can_intersect (const GValue *value1, const GValue *value2); -gboolean gst_value_intersect (GValue *dest, const GValue *value1, const GValue *value2); -void gst_value_register_intersect_func (GType type1, GType type2, GstValueIntersectFunc func); +gboolean gst_value_can_intersect (const GValue * value1, const GValue * value2); +gboolean gst_value_intersect (GValue * dest, const GValue * value1, + const GValue * value2); +void gst_value_register_intersect_func (GType type1, GType type2, + GstValueIntersectFunc func); /* */ -void gst_value_register (const GstValueTable *table); -void gst_value_init_and_copy (GValue *dest, const GValue *src); +void gst_value_register (const GstValueTable * table); +void gst_value_init_and_copy (GValue * dest, const GValue * src); void _gst_value_initialize (void); -gchar * gst_value_serialize (const GValue *value); -gboolean gst_value_deserialize (GValue *dest, const gchar *src); +gchar *gst_value_serialize (const GValue * value); +gboolean gst_value_deserialize (GValue * dest, const gchar * src); G_END_DECLS - #endif - - diff --git a/gst/gstxml.c b/gst/gstxml.c index 35b940710..9fbd22494 100644 --- a/gst/gstxml.c +++ b/gst/gstxml.c @@ -27,35 +27,37 @@ #include "gstinfo.h" #include "gstbin.h" -enum { +enum +{ OBJECT_LOADED, LAST_SIGNAL }; -static void gst_xml_class_init (GstXMLClass *klass); -static void gst_xml_init (GstXML *xml); +static void gst_xml_class_init (GstXMLClass * klass); +static void gst_xml_init (GstXML * xml); -static void gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data); +static void gst_xml_object_loaded (GstObject * private, GstObject * object, + xmlNodePtr self, gpointer data); static GstObjectClass *parent_class = NULL; static guint gst_xml_signals[LAST_SIGNAL] = { 0 }; GType -gst_xml_get_type(void) +gst_xml_get_type (void) { static GType xml_type = 0; if (!xml_type) { static const GTypeInfo xml_info = { - sizeof(GstXMLClass), + sizeof (GstXMLClass), NULL, NULL, - (GClassInitFunc)gst_xml_class_init, + (GClassInitFunc) gst_xml_class_init, NULL, NULL, - sizeof(GstXML), + sizeof (GstXML), 0, - (GInstanceInitFunc)gst_xml_init, + (GInstanceInitFunc) gst_xml_init, NULL }; xml_type = g_type_register_static (GST_TYPE_OBJECT, "GstXML", &xml_info, 0); @@ -64,25 +66,25 @@ gst_xml_get_type(void) } static void -gst_xml_class_init (GstXMLClass *klass) +gst_xml_class_init (GstXMLClass * klass) { GObjectClass *gobject_class; - gobject_class = (GObjectClass *)klass; + gobject_class = (GObjectClass *) klass; parent_class = g_type_class_ref (GST_TYPE_OBJECT); /* FIXME G_TYPE_POINTER should be GType of xmlNodePtr */ gst_xml_signals[OBJECT_LOADED] = - g_signal_new ("object-loaded", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstXMLClass, object_loaded), NULL, NULL, - gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, - GST_TYPE_OBJECT, G_TYPE_POINTER); + g_signal_new ("object-loaded", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstXMLClass, object_loaded), NULL, + NULL, gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, GST_TYPE_OBJECT, + G_TYPE_POINTER); } static void -gst_xml_init(GstXML *xml) +gst_xml_init (GstXML * xml) { xml->topelements = NULL; } @@ -94,10 +96,10 @@ gst_xml_init(GstXML *xml) * * Returns: a pointer to a new GstXML object. */ -GstXML* +GstXML * gst_xml_new (void) { - return GST_XML (g_object_new(GST_TYPE_XML,NULL)); + return GST_XML (g_object_new (GST_TYPE_XML, NULL)); } /** @@ -109,7 +111,7 @@ gst_xml_new (void) * Returns: a pointer to an XML document */ xmlDocPtr -gst_xml_write (GstElement *element) +gst_xml_write (GstElement * element) { xmlDocPtr doc; xmlNodePtr elementnode; @@ -118,9 +120,10 @@ gst_xml_write (GstElement *element) doc = xmlNewDoc ("1.0"); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "gstreamer", NULL); - - gst_ns = xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst"); - + + gst_ns = + xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst"); + elementnode = xmlNewChild (doc->xmlRootNode, gst_ns, "element", NULL); gst_object_save_thyself (GST_OBJECT (element), elementnode); @@ -139,54 +142,56 @@ gst_xml_write (GstElement *element) * Returns: number of bytes written on success, -1 otherwise. */ gint -gst_xml_write_file (GstElement *element, FILE *out) +gst_xml_write_file (GstElement * element, FILE * out) { xmlDocPtr cur; + #ifdef HAVE_LIBXML2 xmlOutputBufferPtr buf; #endif - const char * encoding; + const char *encoding; xmlCharEncodingHandlerPtr handler = NULL; int indent; gboolean ret; - + cur = gst_xml_write (element); - if (!cur) return -1; - + if (!cur) + return -1; + #ifdef HAVE_LIBXML2 encoding = (const char *) cur->encoding; - + if (encoding != NULL) { xmlCharEncoding enc; - + enc = xmlParseCharEncoding (encoding); - + if (cur->charset != XML_CHAR_ENCODING_UTF8) { xmlGenericError (xmlGenericErrorContext, - "xmlDocDump: document not in UTF8\n"); + "xmlDocDump: document not in UTF8\n"); return -1; } if (enc != XML_CHAR_ENCODING_UTF8) { handler = xmlFindCharEncodingHandler (encoding); if (handler == NULL) { - xmlFree ((char *) cur->encoding); - cur->encoding = NULL; + xmlFree ((char *) cur->encoding); + cur->encoding = NULL; } } } - + buf = xmlOutputBufferCreateFile (out, handler); - + indent = xmlIndentTreeOutput; xmlIndentTreeOutput = 1; - ret = xmlSaveFormatFileTo(buf, cur, NULL, 1); + ret = xmlSaveFormatFileTo (buf, cur, NULL, 1); xmlIndentTreeOutput = indent; #else /* apparently this doesn't return anything in libxml1 */ xmlDocDump (out, cur); ret = 1; #endif - + return ret; } @@ -202,35 +207,35 @@ gst_xml_write_file (GstElement *element, FILE *out) * Returns: TRUE on success, FALSE otherwise */ gboolean -gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root) +gst_xml_parse_doc (GstXML * xml, xmlDocPtr doc, const guchar * root) { xmlNodePtr field, cur; xmlNsPtr ns; - cur = xmlDocGetRootElement(doc); + cur = xmlDocGetRootElement (doc); if (cur == NULL) { - g_warning("gstxml: empty document\n"); - return FALSE ; + g_warning ("gstxml: empty document\n"); + return FALSE; } - ns = xmlSearchNsByHref(doc, cur, "http://gstreamer.net/gst-core/1.0/"); + ns = xmlSearchNsByHref (doc, cur, "http://gstreamer.net/gst-core/1.0/"); if (ns == NULL) { - g_warning("gstxml: document of wrong type, core namespace not found\n"); + g_warning ("gstxml: document of wrong type, core namespace not found\n"); return FALSE; } - if (strcmp(cur->name, "gstreamer")) { - g_warning("gstxml: XML file is in wrong format\n"); + if (strcmp (cur->name, "gstreamer")) { + g_warning ("gstxml: XML file is in wrong format\n"); return FALSE; } - gst_class_signal_connect (GST_OBJECT_CLASS (G_OBJECT_GET_CLASS(xml)), - "object_loaded", gst_xml_object_loaded, xml); + gst_class_signal_connect (GST_OBJECT_CLASS (G_OBJECT_GET_CLASS (xml)), + "object_loaded", gst_xml_object_loaded, xml); xml->ns = ns; field = cur->xmlChildrenNode; while (field) { - if (!strcmp(field->name, "element") && (field->ns == xml->ns)) { + if (!strcmp (field->name, "element") && (field->ns == xml->ns)) { GstElement *element; element = gst_xml_make_element (field, NULL); @@ -263,16 +268,16 @@ gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root) * Returns: TRUE on success, FALSE otherwise */ gboolean -gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root) +gst_xml_parse_file (GstXML * xml, const guchar * fname, const guchar * root) { xmlDocPtr doc; - g_return_val_if_fail(fname != NULL, FALSE); + g_return_val_if_fail (fname != NULL, FALSE); - doc = xmlParseFile(fname); + doc = xmlParseFile (fname); if (!doc) { - g_warning("gstxml: XML file \"%s\" could not be read\n", fname); + g_warning ("gstxml: XML file \"%s\" could not be read\n", fname); return FALSE; } @@ -292,11 +297,12 @@ gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root) * Returns: TRUE on success */ gboolean -gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root) +gst_xml_parse_memory (GstXML * xml, guchar * buffer, guint size, + const gchar * root) { xmlDocPtr doc; - g_return_val_if_fail(buffer != NULL, FALSE); + g_return_val_if_fail (buffer != NULL, FALSE); doc = xmlParseMemory (buffer, size); @@ -304,12 +310,14 @@ gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root } static void -gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data) +gst_xml_object_loaded (GstObject * private, GstObject * object, xmlNodePtr self, + gpointer data) { GstXML *xml = GST_XML (data); - /* FIXME check that this element was created from the same xmlDocPtr...*/ - g_signal_emit (G_OBJECT (xml), gst_xml_signals[OBJECT_LOADED], 0, object, self); + /* FIXME check that this element was created from the same xmlDocPtr... */ + g_signal_emit (G_OBJECT (xml), gst_xml_signals[OBJECT_LOADED], 0, object, + self); } /** @@ -320,8 +328,8 @@ gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, g * * Returns: a GList of elements */ -GList* -gst_xml_get_topelements (GstXML *xml) +GList * +gst_xml_get_topelements (GstXML * xml) { g_return_val_if_fail (xml != NULL, NULL); @@ -339,14 +347,14 @@ gst_xml_get_topelements (GstXML *xml) * * Returns: a pointer to a new GstElement */ -GstElement* -gst_xml_get_element (GstXML *xml, const guchar *name) +GstElement * +gst_xml_get_element (GstXML * xml, const guchar * name) { GstElement *element; GList *topelements; - g_return_val_if_fail(xml != NULL, NULL); - g_return_val_if_fail(name != NULL, NULL); + g_return_val_if_fail (xml != NULL, NULL); + g_return_val_if_fail (name != NULL, NULL); GST_DEBUG ("gstxml: getting element \"%s\"", name); @@ -358,13 +366,12 @@ gst_xml_get_element (GstXML *xml, const guchar *name) GST_DEBUG ("gstxml: getting element \"%s\"", name); if (!strcmp (GST_ELEMENT_NAME (top), name)) { return top; - } - else { + } else { if (GST_IS_BIN (top)) { - element = gst_bin_get_by_name (GST_BIN (top), name); + element = gst_bin_get_by_name (GST_BIN (top), name); if (element) - return element; + return element; } } topelements = g_list_next (topelements); @@ -381,8 +388,8 @@ gst_xml_get_element (GstXML *xml, const guchar *name) * * Returns: the new element */ -GstElement* -gst_xml_make_element (xmlNodePtr cur, GstObject *parent) +GstElement * +gst_xml_make_element (xmlNodePtr cur, GstObject * parent) { xmlNodePtr children = cur->xmlChildrenNode; GstElement *element; @@ -401,7 +408,7 @@ gst_xml_make_element (xmlNodePtr cur, GstObject *parent) g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (type != NULL, NULL); - GST_CAT_INFO (GST_CAT_XML,"loading \"%s\" of type \"%s\"", name, type); + GST_CAT_INFO (GST_CAT_XML, "loading \"%s\" of type \"%s\"", name, type); element = gst_element_factory_make (type, name); @@ -411,8 +418,8 @@ gst_xml_make_element (xmlNodePtr cur, GstObject *parent) /* will go through the hierarchy to link to their peers */ if (parent) gst_object_set_parent (GST_OBJECT (element), parent); - + gst_object_restore_thyself (GST_OBJECT (element), cur); - + return element; } diff --git a/gst/gstxml.h b/gst/gstxml.h index 6c12c3e18..5e0da1bb7 100644 --- a/gst/gstxml.h +++ b/gst/gstxml.h @@ -30,22 +30,20 @@ #include G_BEGIN_DECLS - #define GST_TYPE_XML (gst_xml_get_type ()) #define GST_XML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XML, GstXML)) #define GST_IS_XML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XML)) #define GST_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_XML, GstXMLClass)) #define GST_IS_XML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_XML)) - #define GST_XML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XML, GstXMLClass)) - typedef struct _GstXML GstXML; typedef struct _GstXMLClass GstXMLClass; -struct _GstXML { +struct _GstXML +{ GstObject object; - GList *topelements; + GList *topelements; xmlNsPtr ns; @@ -54,39 +52,41 @@ struct _GstXML { typedef struct _GstXMLNs GstXMLNs; -struct _GstXMLClass { +struct _GstXMLClass +{ GstObjectClass parent_class; /* signal callbacks */ - void (*object_loaded) (GstXML *xml, GstObject *object, xmlNodePtr self); - void (*object_saved) (GstXML *xml, GstObject *object, xmlNodePtr self); + void (*object_loaded) (GstXML * xml, GstObject * object, xmlNodePtr self); + void (*object_saved) (GstXML * xml, GstObject * object, xmlNodePtr self); gpointer _gst_reserved[GST_PADDING]; }; -GType gst_xml_get_type (void); +GType gst_xml_get_type (void); /* create an XML document out of a pipeline */ -xmlDocPtr gst_xml_write (GstElement *element); +xmlDocPtr gst_xml_write (GstElement * element); /* write a formatted representation of a pipeline to an open file */ -gint gst_xml_write_file (GstElement *element, FILE *out); +gint gst_xml_write_file (GstElement * element, FILE * out); -GstXML* gst_xml_new (void); +GstXML *gst_xml_new (void); -gboolean gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root); -gboolean gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root); -gboolean gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root); +gboolean gst_xml_parse_doc (GstXML * xml, xmlDocPtr doc, const guchar * root); +gboolean gst_xml_parse_file (GstXML * xml, const guchar * fname, + const guchar * root); +gboolean gst_xml_parse_memory (GstXML * xml, guchar * buffer, guint size, + const gchar * root); -GstElement* gst_xml_get_element (GstXML *xml, const guchar *name); -GList* gst_xml_get_topelements (GstXML *xml); +GstElement *gst_xml_get_element (GstXML * xml, const guchar * name); +GList *gst_xml_get_topelements (GstXML * xml); -GstElement* gst_xml_make_element (xmlNodePtr cur, GstObject *parent); +GstElement *gst_xml_make_element (xmlNodePtr cur, GstObject * parent); G_END_DECLS - #else /* GST_DISABLE_LOADSAVE */ #pragma GCC poison gst_xml_write diff --git a/gst/indexers/gstfileindex.c b/gst/indexers/gstfileindex.c index ccb969e78..56a09e38b 100644 --- a/gst/indexers/gstfileindex.c +++ b/gst/indexers/gstfileindex.c @@ -37,7 +37,7 @@ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FILE_INDEX)) #define GST_IS_FILE_INDEX_CLASS(obj) \ (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FILE_INDEX)) - + #ifndef __FUNCTION__ #define __FUNCTION__ "Unavailable" #endif @@ -71,12 +71,13 @@ /* * Each array element is (32bits flags, nformats * 64bits) */ -typedef struct { - gint id; - gchar *id_desc; - gint nformats; - GstFormat *format; - GArray *array; +typedef struct +{ + gint id; + gchar *id_desc; + gint nformats; + GstFormat *format; + GArray *array; } GstFileIndexId; typedef struct _GstFileIndex GstFileIndex; @@ -93,118 +94,118 @@ typedef struct _GstFileIndexClass GstFileIndexClass; #define ARRAY_ROW_VALUE(_row,_vx) \ (*(gint64*) (((gchar*)(_row)) + sizeof (gint32) + (_vx) * sizeof (gint64))) -GST_DEBUG_CATEGORY_STATIC(DC); +GST_DEBUG_CATEGORY_STATIC (DC); -struct _GstFileIndex { - GstIndex parent; +struct _GstFileIndex +{ + GstIndex parent; - gchar *location; - gboolean is_loaded; - GSList *unresolved; - gint next_id; - GHashTable *id_index; + gchar *location; + gboolean is_loaded; + GSList *unresolved; + gint next_id; + GHashTable *id_index; - GstIndexEntry *ret_entry; /* hack to avoid leaking memory */ + GstIndexEntry *ret_entry; /* hack to avoid leaking memory */ }; -struct _GstFileIndexClass { +struct _GstFileIndexClass +{ GstIndexClass parent_class; }; -enum { +enum +{ ARG_0, ARG_LOCATION, }; -static void gst_file_index_class_init (GstFileIndexClass *klass); -static void gst_file_index_init (GstFileIndex *index); -static void gst_file_index_dispose (GObject *object); +static void gst_file_index_class_init (GstFileIndexClass * klass); +static void gst_file_index_init (GstFileIndex * index); +static void gst_file_index_dispose (GObject * object); static void -gst_file_index_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); +gst_file_index_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); static void -gst_file_index_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); +gst_file_index_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); static gboolean -gst_file_index_get_writer_id (GstIndex *_index, gint *id, gchar *writer_string); +gst_file_index_get_writer_id (GstIndex * _index, gint * id, + gchar * writer_string); -static void gst_file_index_commit (GstIndex *index, gint writer_id); -static void gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry); -static GstIndexEntry* gst_file_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, - GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data); +static void gst_file_index_commit (GstIndex * index, gint writer_id); +static void gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry); +static GstIndexEntry *gst_file_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, + GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data); #define CLASS(file_index) GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index)) static GstIndex *parent_class = NULL; GType -gst_file_index_get_type(void) { +gst_file_index_get_type (void) +{ static GType file_index_type = 0; if (!file_index_type) { static const GTypeInfo file_index_info = { - sizeof(GstFileIndexClass), + sizeof (GstFileIndexClass), NULL, NULL, - (GClassInitFunc)gst_file_index_class_init, + (GClassInitFunc) gst_file_index_class_init, NULL, NULL, - sizeof(GstFileIndex), + sizeof (GstFileIndex), 1, - (GInstanceInitFunc)gst_file_index_init, + (GInstanceInitFunc) gst_file_index_init, NULL }; - file_index_type = g_type_register_static(GST_TYPE_INDEX, "GstFileIndex", &file_index_info, 0); + file_index_type = + g_type_register_static (GST_TYPE_INDEX, "GstFileIndex", + &file_index_info, 0); } return file_index_type; } static void -gst_file_index_class_init (GstFileIndexClass *klass) +gst_file_index_class_init (GstFileIndexClass * klass) { GObjectClass *gobject_class; GstIndexClass *gstindex_class; - gobject_class = (GObjectClass*)klass; - gstindex_class = (GstIndexClass*)klass; + gobject_class = (GObjectClass *) klass; + gstindex_class = (GstIndexClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_INDEX); + parent_class = g_type_class_ref (GST_TYPE_INDEX); - gobject_class->dispose = gst_file_index_dispose; - gobject_class->set_property = gst_file_index_set_property; - gobject_class->get_property = gst_file_index_get_property; + gobject_class->dispose = gst_file_index_dispose; + gobject_class->set_property = gst_file_index_set_property; + gobject_class->get_property = gst_file_index_get_property; - gstindex_class->add_entry = gst_file_index_add_entry; + gstindex_class->add_entry = gst_file_index_add_entry; gstindex_class->get_assoc_entry = gst_file_index_get_assoc_entry; - gstindex_class->commit = gst_file_index_commit; - gstindex_class->get_writer_id = gst_file_index_get_writer_id ; + gstindex_class->commit = gst_file_index_commit; + gstindex_class->get_writer_id = gst_file_index_get_writer_id; g_object_class_install_property (gobject_class, ARG_LOCATION, - g_param_spec_string ("location", "File Location", - "Location of the index file", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("location", "File Location", + "Location of the index file", NULL, G_PARAM_READWRITE)); } static void -gst_file_index_init (GstFileIndex *index) +gst_file_index_init (GstFileIndex * index) { - GST_DEBUG ( "created new file index"); + GST_DEBUG ("created new file index"); index->id_index = g_hash_table_new (g_int_hash, g_int_equal); } static void -_file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped) +_file_index_id_free (GstFileIndexId * index_id, gboolean is_mmapped) { if (index_id->id_desc) g_free (index_id->id_desc); @@ -212,22 +213,22 @@ _file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped) g_free (index_id->format); if (index_id->array) { if (is_mmapped) - munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id)); + munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id)); g_array_free (index_id->array, !is_mmapped); } g_free (index_id); } static gboolean -_id_index_free_helper (gpointer _key, GstFileIndexId *index_id, - GstFileIndex *index) +_id_index_free_helper (gpointer _key, GstFileIndexId * index_id, + GstFileIndex * index) { _file_index_id_free (index_id, index->is_loaded); return TRUE; } static void -gst_file_index_dispose (GObject *object) +gst_file_index_dispose (GObject * object) { GstFileIndex *index = GST_FILE_INDEX (object); @@ -238,23 +239,25 @@ gst_file_index_dispose (GObject *object) { GSList *elem; + for (elem = index->unresolved; elem; elem = g_slist_next (elem)) _file_index_id_free (elem->data, index->is_loaded); g_slist_free (index->unresolved); index->unresolved = NULL; } - + g_hash_table_foreach_steal (index->id_index, - (GHRFunc) _id_index_free_helper, index); + (GHRFunc) _id_index_free_helper, index); g_hash_table_destroy (index->id_index); index->id_index = NULL; - gst_index_entry_free (index->ret_entry); /* hack */ + gst_index_entry_free (index->ret_entry); /* hack */ G_OBJECT_CLASS (parent_class)->dispose (object); } -struct fi_find_writer_context { +struct fi_find_writer_context +{ const gchar *writer_string; GstFileIndexId *ii; }; @@ -264,13 +267,14 @@ _fi_find_writer (gpointer key, gpointer val, gpointer data) { struct fi_find_writer_context *cx = data; GstFileIndexId *ii = val; + if (strcmp (ii->id_desc, cx->writer_string) == 0) cx->ii = ii; } static gboolean -gst_file_index_get_writer_id (GstIndex *_index, - gint *id, gchar *writer_string) +gst_file_index_get_writer_id (GstIndex * _index, + gint * id, gchar * writer_string) { GstFileIndex *index = GST_FILE_INDEX (_index); GSList *pending = index->unresolved; @@ -287,14 +291,15 @@ gst_file_index_get_writer_id (GstIndex *_index, for (elem = pending; elem; elem = g_slist_next (elem)) { GstFileIndexId *ii = elem->data; + if (strcmp (ii->id_desc, writer_string) != 0) { index->unresolved = g_slist_prepend (index->unresolved, ii); continue; } - + if (match) { GST_CAT_WARNING_OBJECT (DC, index, "Duplicate matches for writer '%s'", - writer_string); + writer_string); continue; } @@ -307,6 +312,7 @@ gst_file_index_get_writer_id (GstIndex *_index, if (!match) { struct fi_find_writer_context cx; + cx.writer_string = writer_string; cx.ii = NULL; g_hash_table_foreach (index->id_index, _fi_find_writer, &cx); @@ -314,26 +320,25 @@ gst_file_index_get_writer_id (GstIndex *_index, if (cx.ii) { match = TRUE; GST_CAT_DEBUG_OBJECT (DC, index, "Resolved writer '%s' again", - writer_string); - } - else + writer_string); + } else GST_CAT_WARNING_OBJECT (DC, index, "Can't resolve writer '%s'", - writer_string); + writer_string); } return match; } static void -_fc_alloc_array (GstFileIndexId *id_index) +_fc_alloc_array (GstFileIndexId * id_index) { g_assert (!id_index->array); id_index->array = - g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0); + g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0); } static void -gst_file_index_load (GstFileIndex *index) +gst_file_index_load (GstFileIndex * index) { xmlDocPtr doc; xmlNodePtr root, part; @@ -347,6 +352,7 @@ gst_file_index_load (GstFileIndex *index) GError *err = NULL; gchar *buf; gsize len; + g_file_get_contents (path, &buf, &len, &err); g_free (path); if (err) { @@ -365,7 +371,7 @@ gst_file_index_load (GstFileIndex *index) GST_CAT_ERROR_OBJECT (DC, index, "root node isn't a gstfileindex"); return; } - + val = xmlGetProp (root, "version"); if (!val || atoi (val) != 1) { GST_CAT_ERROR_OBJECT (DC, index, "version != 1"); @@ -376,6 +382,7 @@ gst_file_index_load (GstFileIndex *index) for (part = root->children; part; part = part->next) { if (strcmp (part->name, "writers") == 0) { xmlNodePtr writer; + for (writer = part->children; writer; writer = writer->next) { xmlChar *datafile = xmlGetProp (writer, "datafile"); gchar *path = g_strdup_printf ("%s/%s", index->location, datafile); @@ -391,7 +398,7 @@ gst_file_index_load (GstFileIndex *index) g_free (path); if (fd < 0) { GST_CAT_ERROR_OBJECT (DC, index, - "Can't open '%s': %s", path, strerror (errno)); + "Can't open '%s': %s", path, strerror (errno)); continue; } @@ -401,7 +408,7 @@ gst_file_index_load (GstFileIndex *index) for (wpart = writer->children; wpart; wpart = wpart->next) { if (strcmp (wpart->name, "formats") == 0) { xmlChar *count_str = xmlGetProp (wpart, "count"); - gint fx=0; + gint fx = 0; xmlNodePtr format; id_index->nformats = atoi (count_str); @@ -409,13 +416,12 @@ gst_file_index_load (GstFileIndex *index) id_index->format = g_new (GstFormat, id_index->nformats); - for (format = wpart->children; - format; format = format->next) { + for (format = wpart->children; format; format = format->next) { xmlChar *nick = xmlGetProp (format, "nick"); GstFormat fmt = gst_format_get_by_nick (nick); + if (fmt == GST_FORMAT_UNDEFINED) - GST_CAT_ERROR_OBJECT (DC, index, - "format '%s' undefined", nick); + GST_CAT_ERROR_OBJECT (DC, index, "format '%s' undefined", nick); g_assert (fx < id_index->nformats); id_index->format[fx++] = fmt; free (nick); @@ -426,18 +432,19 @@ gst_file_index_load (GstFileIndex *index) g_assert (id_index->nformats > 0); _fc_alloc_array (id_index); - g_assert (id_index->array->data == NULL); /* little bit risky */ + g_assert (id_index->array->data == NULL); /* little bit risky */ entries_str = xmlGetProp (writer, "entries"); id_index->array->len = atoi (entries_str); free (entries_str); array_data = - mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, 0); + mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, + 0); close (fd); if (array_data == MAP_FAILED) { GST_CAT_ERROR_OBJECT (DC, index, - "mmap %s failed: %s", path, strerror (errno)); + "mmap %s failed: %s", path, strerror (errno)); continue; } @@ -457,49 +464,45 @@ gst_file_index_load (GstFileIndex *index) } static void -gst_file_index_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +gst_file_index_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) { GstFileIndex *index = GST_FILE_INDEX (object); switch (prop_id) { - case ARG_LOCATION: - if (index->location) - g_free (index->location); - index->location = g_value_dup_string (value); + case ARG_LOCATION: + if (index->location) + g_free (index->location); + index->location = g_value_dup_string (value); - if (index->location && !g_hash_table_size (index->id_index)) - gst_file_index_load (index); - break; + if (index->location && !g_hash_table_size (index->id_index)) + gst_file_index_load (index); + break; } } static void -gst_file_index_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gst_file_index_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) { GstFileIndex *index = GST_FILE_INDEX (object); - + switch (prop_id) { - case ARG_LOCATION: - g_value_set_string (value, index->location); - break; + case ARG_LOCATION: + g_value_set_string (value, index->location); + break; } } static void -_file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers) +_file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers) { const gint bufsize = 16; gchar buf[bufsize]; xmlNodePtr writer; xmlNodePtr formats; gint xx; - + if (!ii->array) { GST_INFO ("Index for %s is empty", ii->id_desc); return; @@ -509,17 +512,17 @@ _file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers) xmlSetProp (writer, "id", ii->id_desc); g_snprintf (buf, bufsize, "%d", ii->array->len); xmlSetProp (writer, "entries", buf); - g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */ + g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */ xmlSetProp (writer, "datafile", buf); formats = xmlNewChild (writer, NULL, "formats", NULL); g_snprintf (buf, bufsize, "%d", ii->nformats); xmlSetProp (formats, "count", buf); - for (xx=0; xx < ii->nformats; xx++) { + for (xx = 0; xx < ii->nformats; xx++) { xmlNodePtr format = xmlNewChild (formats, NULL, "format", NULL); - const GstFormatDefinition* def = - gst_format_get_details (ii->format[xx]); + const GstFormatDefinition *def = gst_format_get_details (ii->format[xx]); + xmlSetProp (format, "nick", def->nick); } } @@ -531,9 +534,8 @@ _file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers) padding since the page size isn't fixed. */ static void -_file_index_id_save_entries (gpointer *_key, - GstFileIndexId *ii, - gchar *prefix) +_file_index_id_save_entries (gpointer * _key, + GstFileIndexId * ii, gchar * prefix) { GError *err; gchar *path; @@ -546,25 +548,26 @@ _file_index_id_save_entries (gpointer *_key, path = g_strdup_printf ("%s/%d", prefix, ii->id); chan = g_io_channel_new_file (path, "w", &err); g_free (path); - if (err) goto fail; - + if (err) + goto fail; + g_io_channel_set_encoding (chan, NULL, &err); - if (err) goto fail; + if (err) + goto fail; g_io_channel_write_chars (chan, - ii->array->data, - ARRAY_TOTAL_SIZE (ii), - NULL, - &err); - if (err) goto fail; + ii->array->data, ARRAY_TOTAL_SIZE (ii), NULL, &err); + if (err) + goto fail; g_io_channel_shutdown (chan, TRUE, &err); - if (err) goto fail; + if (err) + goto fail; g_io_channel_unref (chan); return; - fail: +fail: GST_CAT_ERROR (DC, "%s", err->message); } @@ -577,7 +580,7 @@ _file_index_id_save_entries (gpointer *_key, gst_index_commit (index, -1); */ static void -gst_file_index_commit (GstIndex *_index, gint _writer_id) +gst_file_index_commit (GstIndex * _index, gint _writer_id) { GstFileIndex *index = GST_FILE_INDEX (_index); xmlDocPtr doc; @@ -597,18 +600,16 @@ gst_file_index_commit (GstIndex *_index, gint _writer_id) writers = xmlNewChild (doc->xmlRootNode, NULL, "writers", NULL); g_hash_table_foreach (index->id_index, - (GHFunc) _file_index_id_save_xml, writers); + (GHFunc) _file_index_id_save_xml, writers); - if (mkdir (index->location, 0777) && - errno != EEXIST) { + if (mkdir (index->location, 0777) && errno != EEXIST) { GST_CAT_ERROR_OBJECT (DC, index, - "mkdir %s: %s", index->location, strerror (errno)); + "mkdir %s: %s", index->location, strerror (errno)); return; } path = g_strdup_printf ("%s/gstindex.xml", index->location); - tocfile = - g_io_channel_new_file (path, "w", &err); + tocfile = g_io_channel_new_file (path, "w", &err); g_free (path); if (err) { GST_CAT_ERROR_OBJECT (DC, index, "%s", err->message); @@ -624,6 +625,7 @@ gst_file_index_commit (GstIndex *_index, gint _writer_id) { xmlChar *xmlmem; int xmlsize; + xmlDocDumpMemory (doc, &xmlmem, &xmlsize); g_io_channel_write_chars (tocfile, xmlmem, xmlsize, NULL, &err); if (err) { @@ -643,12 +645,11 @@ gst_file_index_commit (GstIndex *_index, gint _writer_id) g_io_channel_unref (tocfile); g_hash_table_foreach (index->id_index, - (GHFunc) _file_index_id_save_entries, - index->location); + (GHFunc) _file_index_id_save_entries, index->location); } static void -gst_file_index_add_id (GstIndex *index, GstIndexEntry *entry) +gst_file_index_add_id (GstIndex * index, GstIndexEntry * entry) { GstFileIndex *fileindex = GST_FILE_INDEX (index); GstFileIndexId *id_index; @@ -672,12 +673,10 @@ gst_file_index_add_id (GstIndex *index, GstIndexEntry *entry) of non-exact matches. */ static gboolean -_fc_bsearch (GArray * ary, - gint stride, - gint * ret, - GCompareDataFunc compare, - gconstpointer sample, - gpointer user_data) +_fc_bsearch (GArray * ary, + gint stride, + gint * ret, + GCompareDataFunc compare, gconstpointer sample, gpointer user_data) { gint first, last; gint mid; @@ -687,67 +686,63 @@ _fc_bsearch (GArray * ary, g_return_val_if_fail (compare, FALSE); - if (!ary->len) - { - if (ret) *ret = 0; - return FALSE; - } + if (!ary->len) { + if (ret) + *ret = 0; + return FALSE; + } first = 0; last = ary->len - 1; midsize = last - first; - + while (midsize > 1) { mid = first + midsize / 2; - - cmp = (*compare) (sample, ary->data + mid*stride, user_data); - - if (cmp == 0) - { - /* if there are multiple matches then scan for the first match */ - while (mid > 0 && - (*compare) (sample, - ary->data + (mid - 1) * stride, - user_data) == 0) - --mid; - - if (ret) *ret = mid; - return TRUE; - } - + + cmp = (*compare) (sample, ary->data + mid * stride, user_data); + + if (cmp == 0) { + /* if there are multiple matches then scan for the first match */ + while (mid > 0 && + (*compare) (sample, ary->data + (mid - 1) * stride, user_data) == 0) + --mid; + + if (ret) + *ret = mid; + return TRUE; + } + if (cmp < 0) - last = mid-1; + last = mid - 1; else - first = mid+1; - + first = mid + 1; + midsize = last - first; } - for (tx = first; tx <= last; tx++) - { - cmp = (*compare) (sample, ary->data + tx*stride, user_data); + for (tx = first; tx <= last; tx++) { + cmp = (*compare) (sample, ary->data + tx * stride, user_data); - if (cmp < 0) - { - if (ret) *ret = tx; - return FALSE; - } - if (cmp == 0) - { - if (ret) *ret = tx; - return TRUE; - } + if (cmp < 0) { + if (ret) + *ret = tx; + return FALSE; } + if (cmp == 0) { + if (ret) + *ret = tx; + return TRUE; + } + } - if (ret) *ret = last+1; + if (ret) + *ret = last + 1; return FALSE; } static gint -file_index_compare (gconstpointer sample, - gconstpointer row, - gpointer user_data) +file_index_compare (gconstpointer sample, gconstpointer row, gpointer user_data) { //GstFileIndexId *id_index = user_data; const GstIndexAssociation *ca = sample; @@ -755,11 +750,12 @@ file_index_compare (gconstpointer sample, gint64 val2_be = ARRAY_ROW_VALUE (row, ca->format); gint64 val2 = GINT64_FROM_BE (val2_be); gint64 diff = val2 - val1; + return (diff == 0 ? 0 : (diff < 0 ? 1 : -1)); } static void -gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) +gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry) { GstFileIndex *fileindex = GST_FILE_INDEX (index); GstFileIndexId *id_index; @@ -773,25 +769,26 @@ gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) if (!id_index->nformats) { gint fx; + id_index->nformats = GST_INDEX_NASSOCS (entry); GST_CAT_LOG_OBJECT (DC, fileindex, "creating %d formats for %d", - id_index->nformats, entry->id); + id_index->nformats, entry->id); id_index->format = g_new (GstFormat, id_index->nformats); - for (fx=0; fx < id_index->nformats; fx++) + for (fx = 0; fx < id_index->nformats; fx++) id_index->format[fx] = GST_INDEX_ASSOC_FORMAT (entry, fx); _fc_alloc_array (id_index); } else { /* only sanity checking */ if (id_index->nformats != GST_INDEX_NASSOCS (entry)) GST_CAT_WARNING_OBJECT (DC, fileindex, "arity change %d -> %d", - id_index->nformats, GST_INDEX_NASSOCS (entry)); + id_index->nformats, GST_INDEX_NASSOCS (entry)); else { gint fx; - for (fx=0; fx < id_index->nformats; fx++) + + for (fx = 0; fx < id_index->nformats; fx++) if (id_index->format[fx] != GST_INDEX_ASSOC_FORMAT (entry, fx)) GST_CAT_WARNING_OBJECT (DC, fileindex, "format[%d] changed %d -> %d", - fx, id_index->format[fx], - GST_INDEX_ASSOC_FORMAT (entry, fx)); + fx, id_index->format[fx], GST_INDEX_ASSOC_FORMAT (entry, fx)); } } @@ -800,15 +797,14 @@ gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) sample.value = GST_INDEX_ASSOC_VALUE (entry, 0); exact = - _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index), - &mx, file_index_compare, - &sample, id_index); + _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index), + &mx, file_index_compare, &sample, id_index); if (exact) { /* maybe overwrite instead? */ GST_CAT_DEBUG_OBJECT (DC, index, - "Ignoring duplicate index association at %lld", - GST_INDEX_ASSOC_VALUE (entry, 0)); + "Ignoring duplicate index association at %lld", + GST_INDEX_ASSOC_VALUE (entry, 0)); return; } @@ -817,10 +813,12 @@ gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) gint fx; gint32 flags_host = GST_INDEX_ASSOC_FLAGS (entry); + ARRAY_ROW_FLAGS (row_data) = GINT32_TO_BE (flags_host); for (fx = 0; fx < id_index->nformats; fx++) { gint64 val_host = GST_INDEX_ASSOC_VALUE (entry, fx); + ARRAY_ROW_VALUE (row_data, fx) = GINT64_TO_BE (val_host); } @@ -861,43 +859,41 @@ show_entry (GstIndexEntry *entry) */ static void -gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry) +gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry) { GST_LOG_OBJECT (index, "adding this entry"); - switch (entry->type){ - case GST_INDEX_ENTRY_ID: - gst_file_index_add_id (index, entry); - break; - case GST_INDEX_ENTRY_ASSOCIATION: - gst_file_index_add_association (index, entry); - break; - case GST_INDEX_ENTRY_OBJECT: - GST_CAT_ERROR_OBJECT (DC, index, - "gst_file_index_add_object not implemented"); - break; - case GST_INDEX_ENTRY_FORMAT: - /* - We infer the formats from the entry itself so this type of - GST_INDEX_ENTRY_* can probably go away. + switch (entry->type) { + case GST_INDEX_ENTRY_ID: + gst_file_index_add_id (index, entry); + break; + case GST_INDEX_ENTRY_ASSOCIATION: + gst_file_index_add_association (index, entry); + break; + case GST_INDEX_ENTRY_OBJECT: + GST_CAT_ERROR_OBJECT (DC, index, + "gst_file_index_add_object not implemented"); + break; + case GST_INDEX_ENTRY_FORMAT: + /* + We infer the formats from the entry itself so this type of + GST_INDEX_ENTRY_* can probably go away. */ - GST_CAT_DEBUG_OBJECT (DC, index, - "gst_file_index_add_format not implemented"); - break; - default: - break; + GST_CAT_DEBUG_OBJECT (DC, index, + "gst_file_index_add_format not implemented"); + break; + default: + break; } } -static GstIndexEntry* -gst_file_index_get_assoc_entry (GstIndex *index, - gint id, - GstIndexLookupMethod method, - GstAssocFlags flags, - GstFormat format, - gint64 value, - GCompareDataFunc _ignore_func, - gpointer _ignore_user_data) +static GstIndexEntry * +gst_file_index_get_assoc_entry (GstIndex * index, + gint id, + GstIndexLookupMethod method, + GstAssocFlags flags, + GstFormat format, + gint64 value, GCompareDataFunc _ignore_func, gpointer _ignore_user_data) { GstFileIndex *fileindex = GST_FILE_INDEX (index); GstFileIndexId *id_index; @@ -918,13 +914,15 @@ gst_file_index_get_assoc_entry (GstIndex *index, return NULL; } - for (fx=0; fx < id_index->nformats; fx++) - if (id_index->format[fx] == format) - { formatx = fx; break; } + for (fx = 0; fx < id_index->nformats; fx++) + if (id_index->format[fx] == format) { + formatx = fx; + break; + } if (formatx == -1) { GST_CAT_WARNING_OBJECT (DC, fileindex, - "%s, format %d not available", __FUNCTION__, format); + "%s, format %d not available", __FUNCTION__, format); return NULL; } @@ -933,7 +931,7 @@ gst_file_index_get_assoc_entry (GstIndex *index, sample.value = value; exact = _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index), - &mx, file_index_compare, &sample, id_index); + &mx, file_index_compare, &sample, id_index); if (!exact) { if (method == GST_INDEX_LOOKUP_EXACT) @@ -974,39 +972,37 @@ gst_file_index_get_assoc_entry (GstIndex *index, entry->type = GST_INDEX_ENTRY_ASSOCIATION; GST_INDEX_NASSOCS (entry) = id_index->nformats; - entry->data.assoc.assocs = - g_new (GstIndexAssociation, id_index->nformats); + entry->data.assoc.assocs = g_new (GstIndexAssociation, id_index->nformats); { gint32 flags_be = ARRAY_ROW_FLAGS (row_data); + GST_INDEX_ASSOC_FLAGS (entry) = GINT32_FROM_BE (flags_be); - for (xx=0; xx < id_index->nformats; xx++) - { - gint64 val_be = ARRAY_ROW_VALUE (row_data, xx); - GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx]; - GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be); - } + for (xx = 0; xx < id_index->nformats; xx++) { + gint64 val_be = ARRAY_ROW_VALUE (row_data, xx); + + GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx]; + GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be); + } } return entry; } gboolean -gst_file_index_plugin_init (GstPlugin *plugin) +gst_file_index_plugin_init (GstPlugin * plugin) { GstIndexFactory *factory; - GST_DEBUG_CATEGORY_INIT(DC, "GST_FILEINDEX", 0, NULL); + GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL); factory = gst_index_factory_new ("fileindex", - "A index that stores entries in file", - gst_file_index_get_type()); + "A index that stores entries in file", gst_file_index_get_type ()); if (factory != NULL) { gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } - else { + } else { GST_CAT_ERROR (DC, "could not register fileindex"); } return TRUE; diff --git a/gst/indexers/gstindexers.c b/gst/indexers/gstindexers.c index 5d4c4afff..2e45116f4 100644 --- a/gst/indexers/gstindexers.c +++ b/gst/indexers/gstindexers.c @@ -21,30 +21,22 @@ #include #include -extern gboolean gst_mem_index_plugin_init (GstPlugin *plugin); -extern gboolean gst_file_index_plugin_init (GstPlugin *plugin); +extern gboolean gst_mem_index_plugin_init (GstPlugin * plugin); +extern gboolean gst_file_index_plugin_init (GstPlugin * plugin); static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { gboolean res = TRUE; res &= gst_mem_index_plugin_init (plugin); res &= gst_file_index_plugin_init (plugin); - + return res; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstindexers", - "GStreamer core indexers", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) - - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstindexers", + "GStreamer core indexers", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/gst/indexers/gstmemindex.c b/gst/indexers/gstmemindex.c index bc5f210d9..5880cca9f 100644 --- a/gst/indexers/gstmemindex.c +++ b/gst/indexers/gstmemindex.c @@ -29,7 +29,7 @@ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX)) #define GST_IS_MEM_INDEX_CLASS(obj) \ (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX)) - + /* * Object model: * @@ -61,108 +61,116 @@ * then do a lookup in the Tree to get the required value. */ -typedef struct { - GstFormat format; - gint offset; - GTree *tree; +typedef struct +{ + GstFormat format; + gint offset; + GTree *tree; } GstMemIndexFormatIndex; -typedef struct { - gint id; - GHashTable *format_index; +typedef struct +{ + gint id; + GHashTable *format_index; } GstMemIndexId; typedef struct _GstMemIndex GstMemIndex; typedef struct _GstMemIndexClass GstMemIndexClass; -struct _GstMemIndex { - GstIndex parent; +struct _GstMemIndex +{ + GstIndex parent; - GList *associations; + GList *associations; - GHashTable *id_index; + GHashTable *id_index; }; -struct _GstMemIndexClass { +struct _GstMemIndexClass +{ GstIndexClass parent_class; }; /* Index signals and args */ -enum { +enum +{ LAST_SIGNAL }; -enum { +enum +{ ARG_0, /* FILL ME */ }; -static void gst_mem_index_class_init (GstMemIndexClass *klass); -static void gst_mem_index_init (GstMemIndex *index); -static void gst_mem_index_dispose (GObject *object); +static void gst_mem_index_class_init (GstMemIndexClass * klass); +static void gst_mem_index_init (GstMemIndex * index); +static void gst_mem_index_dispose (GObject * object); -static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry); -static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data); +static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry); +static GstIndexEntry *gst_mem_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data); #define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index)) static GstIndex *parent_class = NULL; + /*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */ GType -gst_mem_index_get_type(void) { +gst_mem_index_get_type (void) +{ static GType mem_index_type = 0; if (!mem_index_type) { static const GTypeInfo mem_index_info = { - sizeof(GstMemIndexClass), + sizeof (GstMemIndexClass), NULL, NULL, - (GClassInitFunc)gst_mem_index_class_init, + (GClassInitFunc) gst_mem_index_class_init, NULL, NULL, - sizeof(GstMemIndex), + sizeof (GstMemIndex), 1, - (GInstanceInitFunc)gst_mem_index_init, + (GInstanceInitFunc) gst_mem_index_init, NULL }; - mem_index_type = g_type_register_static(GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, 0); + mem_index_type = + g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, + 0); } return mem_index_type; } static void -gst_mem_index_class_init (GstMemIndexClass *klass) +gst_mem_index_class_init (GstMemIndexClass * klass) { GObjectClass *gobject_class; GstIndexClass *gstindex_class; - gobject_class = (GObjectClass*)klass; - gstindex_class = (GstIndexClass*)klass; + gobject_class = (GObjectClass *) klass; + gstindex_class = (GstIndexClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_INDEX); + parent_class = g_type_class_ref (GST_TYPE_INDEX); gobject_class->dispose = gst_mem_index_dispose; - gstindex_class->add_entry = gst_mem_index_add_entry; + gstindex_class->add_entry = gst_mem_index_add_entry; gstindex_class->get_assoc_entry = gst_mem_index_get_assoc_entry; } static void -gst_mem_index_init (GstMemIndex *index) +gst_mem_index_init (GstMemIndex * index) { - GST_DEBUG ( "created new mem index"); + GST_DEBUG ("created new mem index"); index->associations = NULL; index->id_index = g_hash_table_new (g_int_hash, g_int_equal); } static void -gst_mem_index_dispose (GObject *object) +gst_mem_index_dispose (GObject * object) { //GstMemIndex *memindex = GST_MEM_INDEX (object); @@ -170,7 +178,7 @@ gst_mem_index_dispose (GObject *object) } static void -gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_id (GstIndex * index, GstIndexEntry * entry) { GstMemIndex *memindex = GST_MEM_INDEX (index); GstMemIndexId *id_index; @@ -187,24 +195,23 @@ gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry) } static gint -mem_index_compare (gconstpointer a, - gconstpointer b, - gpointer user_data) +mem_index_compare (gconstpointer a, gconstpointer b, gpointer user_data) { GstMemIndexFormatIndex *index = user_data; gint64 val1, val2; gint64 diff; - val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset); - val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)b), index->offset); - + val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset); + val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) b), index->offset); + diff = (val2 - val1); return (diff == 0 ? 0 : (diff > 0 ? 1 : -1)); } static void -gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint assoc) +gst_mem_index_index_format (GstMemIndexId * id_index, GstIndexEntry * entry, + gint assoc) { GstMemIndexFormatIndex *index; GstFormat *format; @@ -227,7 +234,7 @@ gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint } static void -gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_association (GstIndex * index, GstIndexEntry * entry) { GstMemIndex *memindex = GST_MEM_INDEX (index); GstMemIndexId *id_index; @@ -245,60 +252,60 @@ gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry) } static void -gst_mem_index_add_object (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_object (GstIndex * index, GstIndexEntry * entry) { } static void -gst_mem_index_add_format (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_format (GstIndex * index, GstIndexEntry * entry) { } static void -gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry) { GST_LOG_OBJECT (index, "added this entry"); - switch (entry->type){ - case GST_INDEX_ENTRY_ID: - gst_mem_index_add_id (index, entry); - break; - case GST_INDEX_ENTRY_ASSOCIATION: - gst_mem_index_add_association (index, entry); - break; - case GST_INDEX_ENTRY_OBJECT: - gst_mem_index_add_object (index, entry); - break; - case GST_INDEX_ENTRY_FORMAT: - gst_mem_index_add_format (index, entry); - break; - default: - break; + switch (entry->type) { + case GST_INDEX_ENTRY_ID: + gst_mem_index_add_id (index, entry); + break; + case GST_INDEX_ENTRY_ASSOCIATION: + gst_mem_index_add_association (index, entry); + break; + case GST_INDEX_ENTRY_OBJECT: + gst_mem_index_add_object (index, entry); + break; + case GST_INDEX_ENTRY_FORMAT: + gst_mem_index_add_format (index, entry); + break; + default: + break; } } -typedef struct { - gint64 value; +typedef struct +{ + gint64 value; GstMemIndexFormatIndex *index; - gboolean exact; - GstIndexEntry *lower; - gint64 low_diff; - GstIndexEntry *higher; - gint64 high_diff; + gboolean exact; + GstIndexEntry *lower; + gint64 low_diff; + GstIndexEntry *higher; + gint64 high_diff; } GstMemIndexSearchData; static gint -mem_index_search (gconstpointer a, - gconstpointer b) +mem_index_search (gconstpointer a, gconstpointer b) { GstMemIndexSearchData *data = (GstMemIndexSearchData *) b; GstMemIndexFormatIndex *index = data->index; gint64 val1, val2; gint64 diff; - val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset); + val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset); val2 = data->value; - + diff = (val1 - val2); if (diff == 0) return 0; @@ -313,8 +320,7 @@ mem_index_search (gconstpointer a, data->lower = (GstIndexEntry *) a; } diff = -1; - } - else { + } else { if (diff < data->high_diff) { data->high_diff = diff; data->higher = (GstIndexEntry *) a; @@ -325,13 +331,11 @@ mem_index_search (gconstpointer a, return diff; } -static GstIndexEntry* -gst_mem_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, - GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data) +static GstIndexEntry * +gst_mem_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, + GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data) { GstMemIndex *memindex = GST_MEM_INDEX (index); GstMemIndexId *id_index; @@ -363,7 +367,7 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id, entry = g_tree_search (format_index->tree, mem_index_search, &data); /* get the low/high values if we're not exact */ - if (entry == NULL && !data.exact) { + if (entry == NULL && !data.exact) { if (method == GST_INDEX_LOOKUP_BEFORE) entry = data.lower; else if (method == GST_INDEX_LOOKUP_AFTER) { @@ -380,15 +384,14 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id, while (l_entry) { entry = (GstIndexEntry *) l_entry->data; - if (entry->id == id && - (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags) - break; + if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags) + break; - if (method == GST_INDEX_LOOKUP_BEFORE) - l_entry = g_list_next (l_entry); - else if (method == GST_INDEX_LOOKUP_AFTER) { - l_entry = g_list_previous (l_entry); - } + if (method == GST_INDEX_LOOKUP_BEFORE) + l_entry = g_list_next (l_entry); + else if (method == GST_INDEX_LOOKUP_AFTER) { + l_entry = g_list_previous (l_entry); + } } } } @@ -397,18 +400,16 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id, } gboolean -gst_mem_index_plugin_init (GstPlugin *plugin) +gst_mem_index_plugin_init (GstPlugin * plugin) { GstIndexFactory *factory; factory = gst_index_factory_new ("memindex", - "A index that stores entries in memory", - gst_mem_index_get_type()); + "A index that stores entries in memory", gst_mem_index_get_type ()); if (factory != NULL) { gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } - else { + } else { g_warning ("could not register memindex"); } return TRUE; diff --git a/gst/parse/types.h b/gst/parse/types.h index 3fa3588de..0b688c48c 100644 --- a/gst/parse/types.h +++ b/gst/parse/types.h @@ -8,7 +8,8 @@ # include "config.h" #endif -typedef struct { +typedef struct +{ GstElement *src; GstElement *sink; gchar *src_name; @@ -18,7 +19,8 @@ typedef struct { GstCaps *caps; } link_t; -typedef struct { +typedef struct +{ GSList *elements; GstElement *first; GstElement *last; @@ -27,8 +29,9 @@ typedef struct { } chain_t; typedef struct _graph_t graph_t; -struct _graph_t { - chain_t *chain; /* links are supposed to be done now */ +struct _graph_t +{ + chain_t *chain; /* links are supposed to be done now */ GSList *links; GError **error; }; @@ -45,12 +48,13 @@ struct _graph_t { #endif #ifdef __GST_PARSE_TRACE -gchar *__gst_parse_strdup (gchar *org); -void __gst_parse_strfree (gchar *str); +gchar *__gst_parse_strdup (gchar * org); +void __gst_parse_strfree (gchar * str); link_t *__gst_parse_link_new (); -void __gst_parse_link_free (link_t *data); +void __gst_parse_link_free (link_t * data); chain_t *__gst_parse_chain_new (); -void __gst_parse_chain_free (chain_t *data); +void __gst_parse_chain_free (chain_t * data); + # define gst_parse_strdup __gst_parse_strdup # define gst_parse_strfree __gst_parse_strfree # define gst_parse_link_new __gst_parse_link_new @@ -67,14 +71,14 @@ void __gst_parse_chain_free (chain_t *data); #endif /* __GST_PARSE_TRACE */ static inline void -gst_parse_unescape (gchar *str) +gst_parse_unescape (gchar * str) { gchar *walk; - + g_return_if_fail (str != NULL); - + walk = str; - + while (*walk) { if (*walk == '\\') walk++; diff --git a/gst/registries/gstxmlregistry.c b/gst/registries/gstxmlregistry.c index b7870fbbb..a805f1af4 100644 --- a/gst/registries/gstxmlregistry.c +++ b/gst/registries/gstxmlregistry.c @@ -46,81 +46,67 @@ #define CLASS(registry) GST_XML_REGISTRY_CLASS (G_OBJECT_GET_CLASS (registry)) -enum +enum { PROP_0, PROP_LOCATION }; -static void gst_xml_registry_class_init (GstXMLRegistryClass *klass); -static void gst_xml_registry_init (GstXMLRegistry *registry); - -static void gst_xml_registry_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec); -static void gst_xml_registry_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec); - -static gboolean gst_xml_registry_load (GstRegistry *registry); -static gboolean gst_xml_registry_save (GstRegistry *registry); -static gboolean gst_xml_registry_rebuild (GstRegistry *registry); - -static void gst_xml_registry_get_perms_func (GstXMLRegistry *registry); -static void gst_xml_registry_add_path_list_func (GstXMLRegistry *registry); -static gboolean gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode); -static gboolean gst_xml_registry_load_func (GstXMLRegistry *registry, gchar *data, gssize *size); -static gboolean gst_xml_registry_save_func (GstXMLRegistry *registry, gchar *format, ...); -static gboolean gst_xml_registry_close_func (GstXMLRegistry *registry); - -static GstRegistryReturn gst_xml_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin); - -static void gst_xml_registry_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error); -static void gst_xml_registry_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error); -static void gst_xml_registry_text (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error); -static void gst_xml_registry_passthrough (GMarkupParseContext *context, - const gchar *passthrough_text, - gsize text_len, - gpointer user_data, - GError **error); -static void gst_xml_registry_error (GMarkupParseContext *context, - GError *error, - gpointer user_data); - - -static void gst_xml_registry_paths_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error); -static void gst_xml_registry_paths_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error); -static void gst_xml_registry_paths_text (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error); +static void gst_xml_registry_class_init (GstXMLRegistryClass * klass); +static void gst_xml_registry_init (GstXMLRegistry * registry); + +static void gst_xml_registry_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_xml_registry_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static gboolean gst_xml_registry_load (GstRegistry * registry); +static gboolean gst_xml_registry_save (GstRegistry * registry); +static gboolean gst_xml_registry_rebuild (GstRegistry * registry); + +static void gst_xml_registry_get_perms_func (GstXMLRegistry * registry); +static void gst_xml_registry_add_path_list_func (GstXMLRegistry * registry); +static gboolean gst_xml_registry_open_func (GstXMLRegistry * registry, + GstXMLRegistryMode mode); +static gboolean gst_xml_registry_load_func (GstXMLRegistry * registry, + gchar * data, gssize * size); +static gboolean gst_xml_registry_save_func (GstXMLRegistry * registry, + gchar * format, ...); +static gboolean gst_xml_registry_close_func (GstXMLRegistry * registry); + +static GstRegistryReturn gst_xml_registry_load_plugin (GstRegistry * registry, + GstPlugin * plugin); + +static void gst_xml_registry_start_element (GMarkupParseContext * context, + const gchar * element_name, + const gchar ** attribute_names, + const gchar ** attribute_values, gpointer user_data, GError ** error); +static void gst_xml_registry_end_element (GMarkupParseContext * context, + const gchar * element_name, gpointer user_data, GError ** error); +static void gst_xml_registry_text (GMarkupParseContext * context, + const gchar * text, gsize text_len, gpointer user_data, GError ** error); +static void gst_xml_registry_passthrough (GMarkupParseContext * context, + const gchar * passthrough_text, + gsize text_len, gpointer user_data, GError ** error); +static void gst_xml_registry_error (GMarkupParseContext * context, + GError * error, gpointer user_data); + + +static void gst_xml_registry_paths_start_element (GMarkupParseContext * context, + const gchar * element_name, + const gchar ** attribute_names, + const gchar ** attribute_values, gpointer user_data, GError ** error); +static void gst_xml_registry_paths_end_element (GMarkupParseContext * context, + const gchar * element_name, gpointer user_data, GError ** error); +static void gst_xml_registry_paths_text (GMarkupParseContext * context, + const gchar * text, gsize text_len, gpointer user_data, GError ** error); static GstRegistryClass *parent_class = NULL; + /* static guint gst_xml_registry_signals[LAST_SIGNAL] = { 0 }; */ -static const GMarkupParser -gst_xml_registry_parser = -{ +static const GMarkupParser gst_xml_registry_parser = { gst_xml_registry_start_element, gst_xml_registry_end_element, gst_xml_registry_text, @@ -128,9 +114,7 @@ gst_xml_registry_parser = gst_xml_registry_error, }; -static const GMarkupParser -gst_xml_registry_paths_parser = -{ +static const GMarkupParser gst_xml_registry_paths_parser = { gst_xml_registry_paths_start_element, gst_xml_registry_paths_end_element, gst_xml_registry_paths_text, @@ -139,8 +123,8 @@ gst_xml_registry_paths_parser = }; -GType -gst_xml_registry_get_type (void) +GType +gst_xml_registry_get_type (void) { static GType xml_registry_type = 0; @@ -152,53 +136,62 @@ gst_xml_registry_get_type (void) (GClassInitFunc) gst_xml_registry_class_init, NULL, NULL, - sizeof(GstXMLRegistry), + sizeof (GstXMLRegistry), 0, (GInstanceInitFunc) gst_xml_registry_init, NULL }; - xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY, - "GstXMLRegistry", &xml_registry_info, 0); + xml_registry_type = g_type_register_static (GST_TYPE_REGISTRY, + "GstXMLRegistry", &xml_registry_info, 0); } return xml_registry_type; } static void -gst_xml_registry_class_init (GstXMLRegistryClass *klass) +gst_xml_registry_class_init (GstXMLRegistryClass * klass) { GObjectClass *gobject_class; GstRegistryClass *gstregistry_class; GstXMLRegistryClass *gstxmlregistry_class; - gobject_class = (GObjectClass*)klass; - gstregistry_class = (GstRegistryClass*)klass; - gstxmlregistry_class = (GstXMLRegistryClass*)klass; + gobject_class = (GObjectClass *) klass; + gstregistry_class = (GstRegistryClass *) klass; + gstxmlregistry_class = (GstXMLRegistryClass *) klass; parent_class = g_type_class_ref (GST_TYPE_REGISTRY); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_xml_registry_get_property); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_xml_registry_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_xml_registry_get_property); + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_xml_registry_set_property); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_LOCATION, - g_param_spec_string ("location", "Location", "Location of the registry file", - NULL, G_PARAM_READWRITE)); - - gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load); - gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save); - gstregistry_class->rebuild = GST_DEBUG_FUNCPTR (gst_xml_registry_rebuild); - - gstregistry_class->load_plugin = GST_DEBUG_FUNCPTR (gst_xml_registry_load_plugin); - - gstxmlregistry_class->get_perms_func = GST_DEBUG_FUNCPTR (gst_xml_registry_get_perms_func); - gstxmlregistry_class->add_path_list_func = GST_DEBUG_FUNCPTR (gst_xml_registry_add_path_list_func); - gstxmlregistry_class->open_func = GST_DEBUG_FUNCPTR (gst_xml_registry_open_func); - gstxmlregistry_class->load_func = GST_DEBUG_FUNCPTR (gst_xml_registry_load_func); - gstxmlregistry_class->save_func = GST_DEBUG_FUNCPTR (gst_xml_registry_save_func); - gstxmlregistry_class->close_func = GST_DEBUG_FUNCPTR (gst_xml_registry_close_func); + g_param_spec_string ("location", "Location", + "Location of the registry file", NULL, G_PARAM_READWRITE)); + + gstregistry_class->load = GST_DEBUG_FUNCPTR (gst_xml_registry_load); + gstregistry_class->save = GST_DEBUG_FUNCPTR (gst_xml_registry_save); + gstregistry_class->rebuild = GST_DEBUG_FUNCPTR (gst_xml_registry_rebuild); + + gstregistry_class->load_plugin = + GST_DEBUG_FUNCPTR (gst_xml_registry_load_plugin); + + gstxmlregistry_class->get_perms_func = + GST_DEBUG_FUNCPTR (gst_xml_registry_get_perms_func); + gstxmlregistry_class->add_path_list_func = + GST_DEBUG_FUNCPTR (gst_xml_registry_add_path_list_func); + gstxmlregistry_class->open_func = + GST_DEBUG_FUNCPTR (gst_xml_registry_open_func); + gstxmlregistry_class->load_func = + GST_DEBUG_FUNCPTR (gst_xml_registry_load_func); + gstxmlregistry_class->save_func = + GST_DEBUG_FUNCPTR (gst_xml_registry_save_func); + gstxmlregistry_class->close_func = + GST_DEBUG_FUNCPTR (gst_xml_registry_close_func); } static void -gst_xml_registry_init (GstXMLRegistry *registry) +gst_xml_registry_init (GstXMLRegistry * registry) { registry->location = NULL; registry->context = NULL; @@ -217,13 +210,13 @@ gst_xml_registry_init (GstXMLRegistry *registry) * * Returns: a new GstXMLRegistry with the given name an location. */ -GstRegistry* -gst_xml_registry_new (const gchar *name, const gchar *location) +GstRegistry * +gst_xml_registry_new (const gchar * name, const gchar * location) { GstXMLRegistry *xmlregistry; - + xmlregistry = GST_XML_REGISTRY (g_object_new (GST_TYPE_XML_REGISTRY, NULL)); - + g_object_set (G_OBJECT (xmlregistry), "location", location, NULL); GST_REGISTRY (xmlregistry)->name = g_strdup (name); @@ -232,31 +225,31 @@ gst_xml_registry_new (const gchar *name, const gchar *location) } static void -gst_xml_registry_set_property (GObject* object, guint prop_id, - const GValue* value, GParamSpec* pspec) +gst_xml_registry_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstXMLRegistry *registry; - + registry = GST_XML_REGISTRY (object); switch (prop_id) { case PROP_LOCATION: if (registry->open) { - CLASS (object)->close_func (registry); - g_return_if_fail (registry->open == FALSE); + CLASS (object)->close_func (registry); + g_return_if_fail (registry->open == FALSE); } - + if (registry->location) - g_free (registry->location); - + g_free (registry->location); + registry->location = g_strdup (g_value_get_string (value)); GST_REGISTRY (registry)->flags = 0x0; if (CLASS (object)->get_perms_func) - CLASS (object)->get_perms_func (registry); + CLASS (object)->get_perms_func (registry); if (CLASS (object)->add_path_list_func) - CLASS (object)->add_path_list_func (registry); + CLASS (object)->add_path_list_func (registry); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -265,11 +258,11 @@ gst_xml_registry_set_property (GObject* object, guint prop_id, } static void -gst_xml_registry_get_property (GObject* object, guint prop_id, - GValue* value, GParamSpec* pspec) +gst_xml_registry_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstXMLRegistry *registry; - + registry = GST_XML_REGISTRY (object); switch (prop_id) { @@ -288,11 +281,14 @@ gst_xml_registry_get_property (GObject* object, guint prop_id, * so this function returns the last time *anything* changed to this path */ static time_t -get_time(const char * path) +get_time (const char *path) { struct stat statbuf; - if (stat(path, &statbuf)) return 0; - if (statbuf.st_mtime > statbuf.st_ctime) return statbuf.st_mtime; + + if (stat (path, &statbuf)) + return 0; + if (statbuf.st_mtime > statbuf.st_ctime) + return statbuf.st_mtime; return statbuf.st_ctime; } @@ -301,34 +297,34 @@ get_time(const char * path) (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) static gboolean -make_dir (gchar *filename) +make_dir (gchar * filename) { struct stat dirstat; gchar *dirname; if (strrchr (filename, '/') == NULL) return FALSE; - - dirname = g_strndup(filename, strrchr(filename, '/') - filename); + + dirname = g_strndup (filename, strrchr (filename, '/') - filename); if (stat (dirname, &dirstat) == -1 && errno == ENOENT) { if (mkdir (dirname, dirmode) != 0) { if (make_dir (dirname) != TRUE) { - g_free(dirname); - return FALSE; + g_free (dirname); + return FALSE; } else { - if (mkdir (dirname, dirmode) != 0) - return FALSE; + if (mkdir (dirname, dirmode) != 0) + return FALSE; } } } - g_free(dirname); + g_free (dirname); return TRUE; } static void -gst_xml_registry_get_perms_func (GstXMLRegistry *registry) +gst_xml_registry_get_perms_func (GstXMLRegistry * registry) { time_t mod_time = 0; FILE *temp; @@ -337,19 +333,19 @@ gst_xml_registry_get_perms_func (GstXMLRegistry *registry) if the file can be appended to, it's writable. if it can then be read, it's readable. After that check if it exists. */ - + if (make_dir (registry->location) != TRUE) { /* we can't do anything with it, leave flags as 0x0 */ return; } - + mod_time = get_time (registry->location); - + if ((temp = fopen (registry->location, "a"))) { GST_REGISTRY (registry)->flags |= GST_REGISTRY_WRITABLE; fclose (temp); } - + if ((temp = fopen (registry->location, "r"))) { GST_REGISTRY (registry)->flags |= GST_REGISTRY_READABLE; fclose (temp); @@ -361,7 +357,7 @@ gst_xml_registry_get_perms_func (GstXMLRegistry *registry) if (mod_time) { struct utimbuf utime_buf; - + /* set the modification time back to its previous value */ utime_buf.actime = mod_time; utime_buf.modtime = mod_time; @@ -371,9 +367,9 @@ gst_xml_registry_get_perms_func (GstXMLRegistry *registry) unlink (registry->location); } } - + static void -gst_xml_registry_add_path_list_func (GstXMLRegistry *registry) +gst_xml_registry_add_path_list_func (GstXMLRegistry * registry) { FILE *reg = NULL; GMarkupParseContext *context; @@ -381,10 +377,10 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry) gssize size; GError *error = NULL; - context = g_markup_parse_context_new (&gst_xml_registry_paths_parser, 0, - registry, NULL); + context = g_markup_parse_context_new (&gst_xml_registry_paths_parser, 0, + registry, NULL); - if (! (reg = fopen (registry->location, "r"))) { + if (!(reg = fopen (registry->location, "r"))) { goto finished; } @@ -397,8 +393,8 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry) g_markup_parse_context_parse (context, text, size, &error); if (error) { - GST_ERROR ("parsing registry %s: %s\n", - registry->location, error->message); + GST_ERROR ("parsing registry %s: %s\n", + registry->location, error->message); goto finished; } @@ -408,7 +404,7 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry) size = fread (text, 1, BLOCK_SIZE, reg); } - finished: +finished: g_markup_parse_context_free (context); @@ -419,42 +415,42 @@ gst_xml_registry_add_path_list_func (GstXMLRegistry *registry) } static gboolean -plugin_times_older_than_recurse(gchar *path, time_t regtime) +plugin_times_older_than_recurse (gchar * path, time_t regtime) { DIR *dir; struct dirent *dirent; gchar *pluginname; - time_t pathtime = get_time(path); + time_t pathtime = get_time (path); if (pathtime > regtime) { GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, - "time for %s was %ld; more recent than registry time of %ld\n", - path, (long)pathtime, (long)regtime); + "time for %s was %ld; more recent than registry time of %ld\n", + path, (long) pathtime, (long) regtime); return FALSE; } - dir = opendir(path); + dir = opendir (path); if (dir) { - while ((dirent = readdir(dir))) { + while ((dirent = readdir (dir))) { /* don't want to recurse in place or backwards */ - if (strcmp(dirent->d_name,".") && strcmp(dirent->d_name,"..")) { - pluginname = g_strjoin("/",path,dirent->d_name,NULL); - if (!plugin_times_older_than_recurse(pluginname , regtime)) { - g_free (pluginname); - closedir(dir); - return FALSE; - } - g_free (pluginname); + if (strcmp (dirent->d_name, ".") && strcmp (dirent->d_name, "..")) { + pluginname = g_strjoin ("/", path, dirent->d_name, NULL); + if (!plugin_times_older_than_recurse (pluginname, regtime)) { + g_free (pluginname); + closedir (dir); + return FALSE; + } + g_free (pluginname); } } - closedir(dir); + closedir (dir); } return TRUE; } static gboolean -plugin_times_older_than(GList *paths, time_t regtime) +plugin_times_older_than (GList * paths, time_t regtime) { /* return true iff regtime is more recent than the times of all the files * in the plugin dirs. @@ -462,17 +458,17 @@ plugin_times_older_than(GList *paths, time_t regtime) while (paths) { GST_CAT_LOG (GST_CAT_PLUGIN_LOADING, - "comparing plugin times from %s with %ld", - (gchar *)paths->data, (long) regtime); - if(!plugin_times_older_than_recurse(paths->data, regtime)) + "comparing plugin times from %s with %ld", + (gchar *) paths->data, (long) regtime); + if (!plugin_times_older_than_recurse (paths->data, regtime)) return FALSE; - paths = g_list_next(paths); + paths = g_list_next (paths); } return TRUE; } static gboolean -gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode) +gst_xml_registry_open_func (GstXMLRegistry * registry, GstXMLRegistryMode mode) { GstRegistry *gst_registry; GList *paths; @@ -486,20 +482,18 @@ gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode) * if it's not readable, return false * if it's out of date, rebuild it */ if (mode == GST_XML_REGISTRY_READ) { - if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) - { + if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) { /* if it's not writable, then don't bother */ - if (!(gst_registry->flags & GST_REGISTRY_WRITABLE)) - { - GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable"); + if (!(gst_registry->flags & GST_REGISTRY_WRITABLE)) { + GST_CAT_INFO (GST_CAT_GST_INIT, "Registry isn't writable"); return FALSE; } - GST_CAT_INFO (GST_CAT_GST_INIT, "Registry doesn't exist, trying to build..."); + GST_CAT_INFO (GST_CAT_GST_INIT, + "Registry doesn't exist, trying to build..."); gst_registry_rebuild (gst_registry); gst_registry_save (gst_registry); /* FIXME: verify that the flags actually get updated ! */ - if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) - { + if (!(gst_registry->flags & GST_REGISTRY_EXISTS)) { return FALSE; } } @@ -508,26 +502,26 @@ gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode) if (!plugin_times_older_than (paths, get_time (registry->location))) { if (gst_registry->flags & GST_REGISTRY_WRITABLE) { - GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding..."); - - gst_registry_rebuild (gst_registry); + GST_CAT_INFO (GST_CAT_GST_INIT, "Registry out of date, rebuilding..."); + + gst_registry_rebuild (gst_registry); - gst_registry_save (gst_registry); + gst_registry_save (gst_registry); - if (!plugin_times_older_than (paths, get_time (registry->location))) { - GST_CAT_INFO (GST_CAT_GST_INIT, "Registry still out of date, something is wrong..."); - return FALSE; - } + if (!plugin_times_older_than (paths, get_time (registry->location))) { + GST_CAT_INFO (GST_CAT_GST_INIT, + "Registry still out of date, something is wrong..."); + return FALSE; + } } else { - GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Can't write to this registry and it's out of date, ignoring it"); - return FALSE; + GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, + "Can't write to this registry and it's out of date, ignoring it"); + return FALSE; } } - + registry->regfile = fopen (registry->location, "r"); - } - else if (mode == GST_XML_REGISTRY_WRITE) - { + } else if (mode == GST_XML_REGISTRY_WRITE) { g_return_val_if_fail (gst_registry->flags & GST_REGISTRY_WRITABLE, FALSE); registry->regfile = fopen (registry->location, "w"); @@ -542,15 +536,16 @@ gst_xml_registry_open_func (GstXMLRegistry *registry, GstXMLRegistryMode mode) } static gboolean -gst_xml_registry_load_func (GstXMLRegistry *registry, gchar *data, gssize *size) +gst_xml_registry_load_func (GstXMLRegistry * registry, gchar * data, + gssize * size) { *size = fread (data, 1, *size, registry->regfile); - + return TRUE; } static gboolean -gst_xml_registry_save_func (GstXMLRegistry *registry, gchar *format, ...) +gst_xml_registry_save_func (GstXMLRegistry * registry, gchar * format, ...) { va_list var_args; @@ -564,7 +559,7 @@ gst_xml_registry_save_func (GstXMLRegistry *registry, gchar *format, ...) } static gboolean -gst_xml_registry_close_func (GstXMLRegistry *registry) +gst_xml_registry_close_func (GstXMLRegistry * registry) { fclose (registry->regfile); @@ -574,7 +569,7 @@ gst_xml_registry_close_func (GstXMLRegistry *registry) } static gboolean -gst_xml_registry_load (GstRegistry *registry) +gst_xml_registry_load (GstRegistry * registry) { GstXMLRegistry *xmlregistry; gchar *text; @@ -585,9 +580,10 @@ gst_xml_registry_load (GstRegistry *registry) xmlregistry = GST_XML_REGISTRY (registry); - timer = g_timer_new(); - - xmlregistry->context = g_markup_parse_context_new (&gst_xml_registry_parser, 0, registry, NULL); + timer = g_timer_new (); + + xmlregistry->context = + g_markup_parse_context_new (&gst_xml_registry_parser, 0, registry, NULL); if (!CLASS (xmlregistry)->open_func (xmlregistry, GST_XML_REGISTRY_READ)) { g_timer_destroy (timer); @@ -621,17 +617,17 @@ gst_xml_registry_load (GstRegistry *registry) seconds = g_timer_elapsed (timer, NULL); g_timer_destroy (timer); - GST_INFO ("loaded %s in %f seconds (%s)", - registry->name, seconds, xmlregistry->location); + GST_INFO ("loaded %s in %f seconds (%s)", + registry->name, seconds, xmlregistry->location); CLASS (xmlregistry)->close_func (xmlregistry); - + return TRUE; } -static GstRegistryReturn -gst_xml_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin) +static GstRegistryReturn +gst_xml_registry_load_plugin (GstRegistry * registry, GstPlugin * plugin) { GError *error = NULL; GstPlugin *loaded_plugin; @@ -640,7 +636,8 @@ gst_xml_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin) loaded_plugin = gst_plugin_load_file (plugin->filename, &error); if (!plugin) { if (error) { - g_warning ("could not load plugin %s: %s", plugin->desc.name, error->message); + g_warning ("could not load plugin %s: %s", plugin->desc.name, + error->message); } return GST_REGISTRY_PLUGIN_LOAD_ERROR; } else if (loaded_plugin != plugin) { @@ -651,46 +648,42 @@ gst_xml_registry_load_plugin (GstRegistry *registry, GstPlugin *plugin) } static gboolean -gst_xml_registry_parse_plugin (GMarkupParseContext *context, const gchar *tag, const gchar *text, - gsize text_len, GstXMLRegistry *registry, GError **error) +gst_xml_registry_parse_plugin (GMarkupParseContext * context, const gchar * tag, + const gchar * text, gsize text_len, GstXMLRegistry * registry, + GError ** error) { GstPlugin *plugin = registry->current_plugin; - + if (!strcmp (tag, "name")) { plugin->desc.name = g_strndup (text, text_len); - } - else if (!strcmp (tag, "description")) { + } else if (!strcmp (tag, "description")) { plugin->desc.description = g_strndup (text, text_len); - } - else if (!strcmp (tag, "filename")) { + } else if (!strcmp (tag, "filename")) { plugin->filename = g_strndup (text, text_len); - } - else if (!strcmp (tag, "version")) { + } else if (!strcmp (tag, "version")) { plugin->desc.version = g_strndup (text, text_len); - } - else if (!strcmp (tag, "license")) { + } else if (!strcmp (tag, "license")) { plugin->desc.license = g_strndup (text, text_len); - } - else if (!strcmp (tag, "package")) { + } else if (!strcmp (tag, "package")) { plugin->desc.package = g_strndup (text, text_len); - } - else if (!strcmp (tag, "origin")) { + } else if (!strcmp (tag, "origin")) { plugin->desc.origin = g_strndup (text, text_len); } - + return TRUE; } static void -add_to_char_array (gchar ***array, gchar *value) +add_to_char_array (gchar *** array, gchar * value) { gchar **new; gchar **old = *array; gint i = 0; - + /* expensive, but cycles are cheap... */ if (old) - while (old[i]) i++; + while (old[i]) + i++; new = g_new0 (gchar *, i + 2); new[i] = value; while (i > 0) { @@ -702,39 +695,36 @@ add_to_char_array (gchar ***array, gchar *value) } static gboolean -gst_xml_registry_parse_element_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text, - gsize text_len, GstXMLRegistry *registry, GError **error) +gst_xml_registry_parse_element_factory (GMarkupParseContext * context, + const gchar * tag, const gchar * text, gsize text_len, + GstXMLRegistry * registry, GError ** error) { GstElementFactory *factory = GST_ELEMENT_FACTORY (registry->current_feature); if (!strcmp (tag, "name")) { gchar *name = g_strndup (text, text_len); + gst_plugin_feature_set_name (registry->current_feature, name); g_free (name); - } - else if (!strcmp (tag, "longname")) { + } else if (!strcmp (tag, "longname")) { g_free (factory->details.longname); factory->details.longname = g_strndup (text, text_len); - } - else if (!strcmp(tag, "class")) { + } else if (!strcmp (tag, "class")) { g_free (factory->details.klass); factory->details.klass = g_strndup (text, text_len); - } - else if (!strcmp(tag, "description")) { + } else if (!strcmp (tag, "description")) { g_free (factory->details.description); factory->details.description = g_strndup (text, text_len); - } - else if (!strcmp(tag, "author")) { + } else if (!strcmp (tag, "author")) { g_free (factory->details.author); factory->details.author = g_strndup (text, text_len); - } - else if (!strcmp(tag, "rank")) { + } else if (!strcmp (tag, "rank")) { gint rank; gchar *ret; - + rank = strtol (text, &ret, 0); if (ret == text + text_len) { - gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); + gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); } } else if (!strcmp (tag, "uri_type")) { if (strncasecmp (text, "sink", 4) == 0) { @@ -744,9 +734,9 @@ gst_xml_registry_parse_element_factory (GMarkupParseContext *context, const gcha } } else if (!strcmp (tag, "uri_protocol")) { add_to_char_array (&factory->uri_protocols, g_strndup (text, text_len)); - } - else if (!strcmp(tag, "interface")) { + } else if (!strcmp (tag, "interface")) { gchar *tmp = g_strndup (text, text_len); + __gst_element_factory_add_interface (factory, tmp); g_free (tmp); } @@ -755,27 +745,29 @@ gst_xml_registry_parse_element_factory (GMarkupParseContext *context, const gcha } static gboolean -gst_xml_registry_parse_type_find_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text, - gsize text_len, GstXMLRegistry *registry, GError **error) +gst_xml_registry_parse_type_find_factory (GMarkupParseContext * context, + const gchar * tag, const gchar * text, gsize text_len, + GstXMLRegistry * registry, GError ** error) { - GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (registry->current_feature); + GstTypeFindFactory *factory = + GST_TYPE_FIND_FACTORY (registry->current_feature); if (!strcmp (tag, "name")) { registry->current_feature->name = g_strndup (text, text_len); - } - else if (!strcmp(tag, "rank")) { + } else if (!strcmp (tag, "rank")) { glong rank; gchar *ret; - rank = strtol (text, &ret, 0); + + rank = strtol (text, &ret, 0); if (ret == text + text_len) { - gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); + gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); } } /* FIXME!! - else if (!strcmp (tag, "caps")) { - factory->caps = g_strndup (text, text_len); - }*/ - else if (!strcmp(tag, "extension")) { + else if (!strcmp (tag, "caps")) { + factory->caps = g_strndup (text, text_len); + } */ + else if (!strcmp (tag, "extension")) { add_to_char_array (&factory->extensions, g_strndup (text, text_len)); } @@ -783,87 +775,83 @@ gst_xml_registry_parse_type_find_factory (GMarkupParseContext *context, const gc } static gboolean -gst_xml_registry_parse_scheduler_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text, - gsize text_len, GstXMLRegistry *registry, GError **error) +gst_xml_registry_parse_scheduler_factory (GMarkupParseContext * context, + const gchar * tag, const gchar * text, gsize text_len, + GstXMLRegistry * registry, GError ** error) { - GstSchedulerFactory *factory = GST_SCHEDULER_FACTORY (registry->current_feature); + GstSchedulerFactory *factory = + GST_SCHEDULER_FACTORY (registry->current_feature); if (!strcmp (tag, "name")) { registry->current_feature->name = g_strndup (text, text_len); - } - else if (!strcmp (tag, "longdesc")) { + } else if (!strcmp (tag, "longdesc")) { factory->longdesc = g_strndup (text, text_len); } return TRUE; } static gboolean -gst_xml_registry_parse_index_factory (GMarkupParseContext *context, const gchar *tag, const gchar *text, - gsize text_len, GstXMLRegistry *registry, GError **error) +gst_xml_registry_parse_index_factory (GMarkupParseContext * context, + const gchar * tag, const gchar * text, gsize text_len, + GstXMLRegistry * registry, GError ** error) { GstIndexFactory *factory = GST_INDEX_FACTORY (registry->current_feature); if (!strcmp (tag, "name")) { registry->current_feature->name = g_strndup (text, text_len); - } - else if (!strcmp (tag, "longdesc")) { + } else if (!strcmp (tag, "longdesc")) { factory->longdesc = g_strndup (text, text_len); } return TRUE; } static gboolean -gst_xml_registry_parse_padtemplate (GMarkupParseContext *context, const gchar *tag, const gchar *text, - gsize text_len, GstXMLRegistry *registry, GError **error) +gst_xml_registry_parse_padtemplate (GMarkupParseContext * context, + const gchar * tag, const gchar * text, gsize text_len, + GstXMLRegistry * registry, GError ** error) { if (!strcmp (tag, "nametemplate")) { registry->name_template = g_strndup (text, text_len); - } - else if (!strcmp (tag, "direction")) { - if (!strncmp(text, "sink", text_len)) { + } else if (!strcmp (tag, "direction")) { + if (!strncmp (text, "sink", text_len)) { registry->direction = GST_PAD_SINK; - } - else if (!strncmp(text, "src", text_len)) { + } else if (!strncmp (text, "src", text_len)) { registry->direction = GST_PAD_SRC; } - } - else if (!strcmp (tag, "presence")) { - if (!strncmp(text, "always", text_len)) { + } else if (!strcmp (tag, "presence")) { + if (!strncmp (text, "always", text_len)) { registry->presence = GST_PAD_ALWAYS; - } - else if (!strncmp(text, "sometimes", text_len)) { + } else if (!strncmp (text, "sometimes", text_len)) { registry->presence = GST_PAD_SOMETIMES; - } - else if (!strncmp(text, "request", text_len)) { + } else if (!strncmp (text, "request", text_len)) { registry->presence = GST_PAD_REQUEST; } - } - else if (!strncmp (tag, "caps", 4)) { + } else if (!strncmp (tag, "caps", 4)) { char *s; s = g_strndup (text, text_len); g_assert (registry->caps == NULL); registry->caps = gst_caps_from_string (s); if (registry->caps == NULL) { - g_critical ("Could not parse caps: length %d, content: %*s\n", text_len, text_len, text); + g_critical ("Could not parse caps: length %d, content: %*s\n", text_len, + text_len, text); } - g_free(s); + g_free (s); return TRUE; } return TRUE; } static void -gst_xml_registry_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, GError **error) +gst_xml_registry_start_element (GMarkupParseContext * context, + const gchar * element_name, + const gchar ** attribute_names, + const gchar ** attribute_values, gpointer user_data, GError ** error) { GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data); - xmlregistry->open_tags = g_list_prepend (xmlregistry->open_tags, - g_strdup (element_name)); + xmlregistry->open_tags = g_list_prepend (xmlregistry->open_tags, + g_strdup (element_name)); switch (xmlregistry->state) { case GST_XML_REGISTRY_NONE: @@ -882,15 +870,17 @@ gst_xml_registry_start_element (GMarkupParseContext *context, if (!strncmp (element_name, "feature", 7)) { gint i = 0; GstPluginFeature *feature = NULL; - + xmlregistry->state = GST_XML_REGISTRY_FEATURE; while (attribute_names[i]) { - if (!strncmp (attribute_names[i], "typename", 8)) { - feature = GST_PLUGIN_FEATURE (g_object_new (g_type_from_name (attribute_values[i]), NULL)); + if (!strncmp (attribute_names[i], "typename", 8)) { + feature = + GST_PLUGIN_FEATURE (g_object_new (g_type_from_name + (attribute_values[i]), NULL)); break; } - i++; + i++; } if (feature) { xmlregistry->current_feature = feature; @@ -901,19 +891,15 @@ gst_xml_registry_start_element (GMarkupParseContext *context, factory->padtemplates = NULL; xmlregistry->parser = gst_xml_registry_parse_element_factory; break; - } - else if (GST_IS_TYPE_FIND_FACTORY (feature)) { + } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { xmlregistry->parser = gst_xml_registry_parse_type_find_factory; - } - else if (GST_IS_SCHEDULER_FACTORY (feature)) { + } else if (GST_IS_SCHEDULER_FACTORY (feature)) { xmlregistry->parser = gst_xml_registry_parse_scheduler_factory; - GST_SCHEDULER_FACTORY (feature)->type = 0; - } - else if (GST_IS_INDEX_FACTORY (feature)) { + GST_SCHEDULER_FACTORY (feature)->type = 0; + } else if (GST_IS_INDEX_FACTORY (feature)) { xmlregistry->parser = gst_xml_registry_parse_index_factory; - } - else { - g_warning ("unknown feature type"); + } else { + g_warning ("unknown feature type"); } } } @@ -934,12 +920,11 @@ gst_xml_registry_start_element (GMarkupParseContext *context, } static void -gst_xml_registry_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, GError **error) +gst_xml_registry_end_element (GMarkupParseContext * context, + const gchar * element_name, gpointer user_data, GError ** error) { GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data); - gchar *open_tag = (gchar *)xmlregistry->open_tags->data; + gchar *open_tag = (gchar *) xmlregistry->open_tags->data; xmlregistry->open_tags = g_list_remove (xmlregistry->open_tags, open_tag); g_free (open_tag); @@ -954,14 +939,16 @@ gst_xml_registry_end_element (GMarkupParseContext *context, if (!strcmp (element_name, "plugin")) { xmlregistry->state = GST_XML_REGISTRY_TOP; xmlregistry->parser = NULL; - gst_registry_add_plugin (GST_REGISTRY (xmlregistry), xmlregistry->current_plugin); + gst_registry_add_plugin (GST_REGISTRY (xmlregistry), + xmlregistry->current_plugin); } break; case GST_XML_REGISTRY_FEATURE: if (!strcmp (element_name, "feature")) { xmlregistry->state = GST_XML_REGISTRY_PLUGIN; xmlregistry->parser = gst_xml_registry_parse_plugin; - gst_plugin_add_feature (xmlregistry->current_plugin, xmlregistry->current_feature); + gst_plugin_add_feature (xmlregistry->current_plugin, + xmlregistry->current_feature); xmlregistry->current_feature = NULL; } break; @@ -969,17 +956,15 @@ gst_xml_registry_end_element (GMarkupParseContext *context, if (!strcmp (element_name, "padtemplate")) { GstPadTemplate *template; - template = gst_pad_template_new (xmlregistry->name_template, - xmlregistry->direction, - xmlregistry->presence, - xmlregistry->caps); + template = gst_pad_template_new (xmlregistry->name_template, + xmlregistry->direction, xmlregistry->presence, xmlregistry->caps); g_free (xmlregistry->name_template); xmlregistry->name_template = NULL; xmlregistry->caps = NULL; - __gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY (xmlregistry->current_feature), - template); + __gst_element_factory_add_pad_template (GST_ELEMENT_FACTORY + (xmlregistry->current_feature), template); xmlregistry->state = GST_XML_REGISTRY_FEATURE; xmlregistry->parser = gst_xml_registry_parse_element_factory; } @@ -990,43 +975,43 @@ gst_xml_registry_end_element (GMarkupParseContext *context, } static void -gst_xml_registry_text (GMarkupParseContext *context, const gchar *text, - gsize text_len, gpointer user_data, GError **error) +gst_xml_registry_text (GMarkupParseContext * context, const gchar * text, + gsize text_len, gpointer user_data, GError ** error) { GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data); gchar *open_tag; - + if (xmlregistry->open_tags) { - open_tag = (gchar *)xmlregistry->open_tags->data; + open_tag = (gchar *) xmlregistry->open_tags->data; if (!strcmp (open_tag, "plugin-path")) { //gst_plugin_add_path (g_strndup (text, text_len)); - } - else if (xmlregistry->parser) { - xmlregistry->parser (context, open_tag, text, text_len, xmlregistry, error); + } else if (xmlregistry->parser) { + xmlregistry->parser (context, open_tag, text, text_len, xmlregistry, + error); } } } static void -gst_xml_registry_passthrough (GMarkupParseContext *context, const gchar *passthrough_text, - gsize text_len, gpointer user_data, GError **error) +gst_xml_registry_passthrough (GMarkupParseContext * context, + const gchar * passthrough_text, gsize text_len, gpointer user_data, + GError ** error) { } static void -gst_xml_registry_error (GMarkupParseContext *context, GError *error, - gpointer user_data) +gst_xml_registry_error (GMarkupParseContext * context, GError * error, + gpointer user_data) { GST_ERROR ("%s\n", error->message); } static void -gst_xml_registry_paths_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, GError **error) +gst_xml_registry_paths_start_element (GMarkupParseContext * context, + const gchar * element_name, + const gchar ** attribute_names, + const gchar ** attribute_values, gpointer user_data, GError ** error) { GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data); @@ -1052,9 +1037,8 @@ gst_xml_registry_paths_start_element (GMarkupParseContext *context, } static void -gst_xml_registry_paths_end_element (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, GError **error) +gst_xml_registry_paths_end_element (GMarkupParseContext * context, + const gchar * element_name, gpointer user_data, GError ** error) { GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data); @@ -1075,13 +1059,14 @@ gst_xml_registry_paths_end_element (GMarkupParseContext *context, } static void -gst_xml_registry_paths_text (GMarkupParseContext *context, const gchar *text, - gsize text_len, gpointer user_data, GError **error) +gst_xml_registry_paths_text (GMarkupParseContext * context, const gchar * text, + gsize text_len, gpointer user_data, GError ** error) { GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (user_data); - + if (xmlregistry->state == GST_XML_REGISTRY_PATH) - gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text, text_len)); + gst_registry_add_path (GST_REGISTRY (xmlregistry), g_strndup (text, + text_len)); } /* @@ -1105,21 +1090,24 @@ G_STMT_START{ \ static gboolean -gst_xml_registry_save_caps (GstXMLRegistry *xmlregistry, const GstCaps *caps) +gst_xml_registry_save_caps (GstXMLRegistry * xmlregistry, const GstCaps * caps) { char *s = gst_caps_to_string (caps); + PUT_ESCAPED ("caps", s); g_free (s); return TRUE; } static gboolean -gst_xml_registry_save_pad_template (GstXMLRegistry *xmlregistry, GstPadTemplate *template) +gst_xml_registry_save_pad_template (GstXMLRegistry * xmlregistry, + GstPadTemplate * template) { gchar *presence; - + PUT_ESCAPED ("nametemplate", template->name_template); - CLASS (xmlregistry)->save_func (xmlregistry, "%s\n", (template->direction == GST_PAD_SINK? "sink":"src")); + CLASS (xmlregistry)->save_func (xmlregistry, "%s\n", + (template->direction == GST_PAD_SINK ? "sink" : "src")); switch (template->presence) { case GST_PAD_ALWAYS: @@ -1135,7 +1123,8 @@ gst_xml_registry_save_pad_template (GstXMLRegistry *xmlregistry, GstPadTemplate presence = "unknown"; break; } - CLASS (xmlregistry)->save_func (xmlregistry, "%s\n", presence); + CLASS (xmlregistry)->save_func (xmlregistry, "%s\n", + presence); if (GST_PAD_TEMPLATE_CAPS (template)) { gst_xml_registry_save_caps (xmlregistry, GST_PAD_TEMPLATE_CAPS (template)); @@ -1144,15 +1133,17 @@ gst_xml_registry_save_pad_template (GstXMLRegistry *xmlregistry, GstPadTemplate } static gboolean -gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *feature) +gst_xml_registry_save_feature (GstXMLRegistry * xmlregistry, + GstPluginFeature * feature) { PUT_ESCAPED ("name", feature->name); if (feature->rank > 0) { gint rank = feature->rank; + CLASS (xmlregistry)->save_func (xmlregistry, "%d\n", rank); - } - + } + if (GST_IS_ELEMENT_FACTORY (feature)) { GstElementFactory *factory = GST_ELEMENT_FACTORY (feature); GList *walk; @@ -1161,7 +1152,7 @@ gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *fe PUT_ESCAPED ("class", factory->details.klass); PUT_ESCAPED ("description", factory->details.description); PUT_ESCAPED ("author", factory->details.author); - + walk = factory->padtemplates; while (walk) { @@ -1170,7 +1161,7 @@ gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *fe CLASS (xmlregistry)->save_func (xmlregistry, "\n"); gst_xml_registry_save_pad_template (xmlregistry, template); CLASS (xmlregistry)->save_func (xmlregistry, "\n"); - + walk = g_list_next (walk); } @@ -1182,8 +1173,9 @@ gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *fe if (GST_URI_TYPE_IS_VALID (factory->uri_type)) { gchar **protocol; - - PUT_ESCAPED ("uri_type", factory->uri_type == GST_URI_SINK ? "sink" : "source"); + + PUT_ESCAPED ("uri_type", + factory->uri_type == GST_URI_SINK ? "sink" : "source"); g_assert (factory->uri_protocols); protocol = factory->uri_protocols; while (*protocol) { @@ -1191,34 +1183,32 @@ gst_xml_registry_save_feature (GstXMLRegistry *xmlregistry, GstPluginFeature *fe protocol++; } } - } - else if (GST_IS_TYPE_FIND_FACTORY (feature)) { + } else if (GST_IS_TYPE_FIND_FACTORY (feature)) { GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature); gint i = 0; + if (factory->caps) { gst_xml_registry_save_caps (xmlregistry, factory->caps); } if (factory->extensions) { while (factory->extensions[i]) { - PUT_ESCAPED ("extension", factory->extensions[i]); - i++; + PUT_ESCAPED ("extension", factory->extensions[i]); + i++; } } - } - else if (GST_IS_SCHEDULER_FACTORY (feature)) { + } else if (GST_IS_SCHEDULER_FACTORY (feature)) { PUT_ESCAPED ("longdesc", GST_SCHEDULER_FACTORY (feature)->longdesc); - } - else if (GST_IS_INDEX_FACTORY (feature)) { + } else if (GST_IS_INDEX_FACTORY (feature)) { PUT_ESCAPED ("longdesc", GST_INDEX_FACTORY (feature)->longdesc); } return TRUE; } static gboolean -gst_xml_registry_save_plugin (GstXMLRegistry *xmlregistry, GstPlugin *plugin) +gst_xml_registry_save_plugin (GstXMLRegistry * xmlregistry, GstPlugin * plugin) { GList *walk; - + PUT_ESCAPED ("name", plugin->desc.name); PUT_ESCAPED ("description", plugin->desc.description); PUT_ESCAPED ("filename", plugin->filename); @@ -1232,10 +1222,11 @@ gst_xml_registry_save_plugin (GstXMLRegistry *xmlregistry, GstPlugin *plugin) while (walk) { GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data); - CLASS (xmlregistry)->save_func (xmlregistry, "\n", g_type_name (G_OBJECT_TYPE (feature))); + CLASS (xmlregistry)->save_func (xmlregistry, "\n", + g_type_name (G_OBJECT_TYPE (feature))); gst_xml_registry_save_feature (xmlregistry, feature); CLASS (xmlregistry)->save_func (xmlregistry, "\n"); - + walk = g_list_next (walk); } return TRUE; @@ -1243,14 +1234,14 @@ gst_xml_registry_save_plugin (GstXMLRegistry *xmlregistry, GstPlugin *plugin) static gboolean -gst_xml_registry_save (GstRegistry *registry) +gst_xml_registry_save (GstRegistry * registry) { GList *walk; GstXMLRegistry *xmlregistry; - + g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE); g_return_val_if_fail (registry->flags & GST_REGISTRY_WRITABLE, FALSE); - + xmlregistry = GST_XML_REGISTRY (registry); if (!CLASS (xmlregistry)->open_func (xmlregistry, GST_XML_REGISTRY_WRITE)) { @@ -1259,13 +1250,13 @@ gst_xml_registry_save (GstRegistry *registry) CLASS (xmlregistry)->save_func (xmlregistry, "\n"); CLASS (xmlregistry)->save_func (xmlregistry, "\n"); - + walk = g_list_last (gst_registry_get_path_list (GST_REGISTRY (registry))); - + CLASS (xmlregistry)->save_func (xmlregistry, "\n"); while (walk) { CLASS (xmlregistry)->save_func (xmlregistry, ""); - CLASS (xmlregistry)->save_func (xmlregistry, (gchar*)walk->data); + CLASS (xmlregistry)->save_func (xmlregistry, (gchar *) walk->data); CLASS (xmlregistry)->save_func (xmlregistry, "\n"); walk = g_list_previous (walk); } @@ -1279,7 +1270,7 @@ gst_xml_registry_save (GstRegistry *registry) CLASS (xmlregistry)->save_func (xmlregistry, "\n"); gst_xml_registry_save_plugin (xmlregistry, plugin); CLASS (xmlregistry)->save_func (xmlregistry, "\n"); - + walk = g_list_previous (walk); } CLASS (xmlregistry)->save_func (xmlregistry, "\n"); @@ -1289,9 +1280,9 @@ gst_xml_registry_save (GstRegistry *registry) return TRUE; } -static GList* -gst_xml_registry_rebuild_recurse (GstXMLRegistry *registry, - const gchar *directory) +static GList * +gst_xml_registry_rebuild_recurse (GstXMLRegistry * registry, + const gchar * directory) { GDir *dir; gchar *temp; @@ -1304,20 +1295,22 @@ gst_xml_registry_rebuild_recurse (GstXMLRegistry *registry, while ((dirent = g_dir_read_name (dir))) { gchar *dirname; - + if (*dirent == '=') { - /* =build, =inst, etc. -- automake distcheck directories */ - continue; + /* =build, =inst, etc. -- automake distcheck directories */ + continue; } - + dirname = g_strjoin ("/", directory, dirent, NULL); - ret = g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry, dirname)); - g_free(dirname); + ret = + g_list_concat (ret, gst_xml_registry_rebuild_recurse (registry, + dirname)); + g_free (dirname); } g_dir_close (dir); } else { if ((temp = strstr (directory, G_MODULE_SUFFIX)) && - (!strcmp (temp, G_MODULE_SUFFIX))) { + (!strcmp (temp, G_MODULE_SUFFIX))) { ret = g_list_prepend (ret, g_strdup (directory)); } } @@ -1326,29 +1319,28 @@ gst_xml_registry_rebuild_recurse (GstXMLRegistry *registry, } static gboolean -gst_xml_registry_rebuild (GstRegistry *registry) +gst_xml_registry_rebuild (GstRegistry * registry) { GList *walk = NULL, *plugins = NULL, *prune = NULL; GError *error = NULL; guint length; GstPlugin *plugin; GstXMLRegistry *xmlregistry = GST_XML_REGISTRY (registry); - + walk = registry->paths; while (walk) { gchar *path = (gchar *) walk->data; - - GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, - "Rebuilding registry %p in directory %s...", registry, path); - plugins = g_list_concat (plugins, - gst_xml_registry_rebuild_recurse (xmlregistry, - path)); + GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, + "Rebuilding registry %p in directory %s...", registry, path); + + plugins = g_list_concat (plugins, + gst_xml_registry_rebuild_recurse (xmlregistry, path)); walk = g_list_next (walk); } - + plugins = g_list_reverse (plugins); do { @@ -1359,8 +1351,8 @@ gst_xml_registry_rebuild (GstRegistry *registry) g_assert (walk->data); plugin = gst_plugin_load_file ((gchar *) walk->data, NULL); if (plugin) { - prune = g_list_prepend (prune, walk->data); - gst_registry_add_plugin (registry, plugin); + prune = g_list_prepend (prune, walk->data); + gst_registry_add_plugin (registry, plugin); } walk = g_list_next (walk); @@ -1375,22 +1367,22 @@ gst_xml_registry_rebuild (GstRegistry *registry) g_list_free (prune); prune = NULL; } while (g_list_length (plugins) != length); - + walk = plugins; while (walk) { if ((plugin = gst_plugin_load_file ((gchar *) walk->data, &error))) { - g_warning ("Bizarre behavior: plugin %s actually loaded", - (gchar *) walk->data); + g_warning ("Bizarre behavior: plugin %s actually loaded", + (gchar *) walk->data); gst_registry_add_plugin (registry, plugin); } else { - GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s", - (gchar *) walk->data, error->message); + GST_CAT_INFO (GST_CAT_PLUGIN_LOADING, "Plugin %s failed to load: %s", + (gchar *) walk->data, error->message); g_free (walk->data); g_error_free (error); error = NULL; } - + walk = g_list_next (walk); } return TRUE; diff --git a/gst/registries/gstxmlregistry.h b/gst/registries/gstxmlregistry.h index bf1d6a10b..b4fc55d54 100644 --- a/gst/registries/gstxmlregistry.h +++ b/gst/registries/gstxmlregistry.h @@ -27,7 +27,6 @@ #include G_BEGIN_DECLS - #define GST_TYPE_XML_REGISTRY \ (gst_xml_registry_get_type()) #define GST_XML_REGISTRY(obj) \ @@ -38,11 +37,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_XML_REGISTRY)) #define GST_IS_XML_REGISTRY_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_XML_REGISTRY)) - typedef struct _GstXMLRegistry GstXMLRegistry; typedef struct _GstXMLRegistryClass GstXMLRegistryClass; -typedef enum { +typedef enum +{ GST_XML_REGISTRY_NONE, GST_XML_REGISTRY_TOP, GST_XML_REGISTRY_PATHS, @@ -56,78 +55,75 @@ typedef enum { GST_XML_REGISTRY_PROPERTIES } GstXMLRegistryState; -typedef enum { +typedef enum +{ GST_XML_REGISTRY_READ, GST_XML_REGISTRY_WRITE } GstXMLRegistryMode; -typedef void (*GstXMLRegistryGetPerms) (GstXMLRegistry *registry); -typedef void (*GstXMLRegistryAddPathList) (GstXMLRegistry *registry); -typedef gboolean (*GstXMLRegistryParser) (GMarkupParseContext *context, - const gchar *tag, - const gchar *text, - gsize text_len, - GstXMLRegistry *registry, - GError **error); - -typedef gboolean (*GstXMLRegistryOpen) (GstXMLRegistry *registry, - GstXMLRegistryMode mode); -typedef gboolean (*GstXMLRegistryLoad) (GstXMLRegistry *registry, - gchar *dest, - gssize *size); -typedef gboolean (*GstXMLRegistrySave) (GstXMLRegistry *registry, - gchar *format, - ...); -typedef gboolean (*GstXMLRegistryClose) (GstXMLRegistry *registry); - -struct _GstXMLRegistry { - GstRegistry object; - - gchar *location; - gboolean open; - - FILE *regfile; - gchar *buffer; - - GMarkupParseContext *context; - GList *open_tags; - GstXMLRegistryState state; - GstXMLRegistryParser parser; - - GstPlugin *current_plugin; - GstPluginFeature *current_feature; - - gchar *name_template; - GstPadDirection direction; - GstPadPresence presence; - GstCaps *caps; - - gchar *caps_name; - gchar *structure_name; - - gboolean in_list; - GList *entry_list; - gchar *list_name; +typedef void (*GstXMLRegistryGetPerms) (GstXMLRegistry * registry); +typedef void (*GstXMLRegistryAddPathList) (GstXMLRegistry * registry); +typedef gboolean (*GstXMLRegistryParser) (GMarkupParseContext * context, + const gchar * tag, + const gchar * text, + gsize text_len, GstXMLRegistry * registry, GError ** error); + +typedef gboolean (*GstXMLRegistryOpen) (GstXMLRegistry * registry, + GstXMLRegistryMode mode); +typedef gboolean (*GstXMLRegistryLoad) (GstXMLRegistry * registry, + gchar * dest, gssize * size); +typedef gboolean (*GstXMLRegistrySave) (GstXMLRegistry * registry, + gchar * format, ...); +typedef gboolean (*GstXMLRegistryClose) (GstXMLRegistry * registry); + +struct _GstXMLRegistry +{ + GstRegistry object; + + gchar *location; + gboolean open; + + FILE *regfile; + gchar *buffer; + + GMarkupParseContext *context; + GList *open_tags; + GstXMLRegistryState state; + GstXMLRegistryParser parser; + + GstPlugin *current_plugin; + GstPluginFeature *current_feature; + + gchar *name_template; + GstPadDirection direction; + GstPadPresence presence; + GstCaps *caps; + + gchar *caps_name; + gchar *structure_name; + + gboolean in_list; + GList *entry_list; + gchar *list_name; }; -struct _GstXMLRegistryClass { - GstRegistryClass parent_class; +struct _GstXMLRegistryClass +{ + GstRegistryClass parent_class; GstXMLRegistryGetPerms get_perms_func; GstXMLRegistryAddPathList add_path_list_func; - GstXMLRegistryOpen open_func; - GstXMLRegistryLoad load_func; - GstXMLRegistrySave save_func; - GstXMLRegistryClose close_func; + GstXMLRegistryOpen open_func; + GstXMLRegistryLoad load_func; + GstXMLRegistrySave save_func; + GstXMLRegistryClose close_func; }; /* normal GObject stuff */ -GType gst_xml_registry_get_type (void); +GType gst_xml_registry_get_type (void); -GstRegistry* gst_xml_registry_new (const gchar *name, const gchar *location); +GstRegistry *gst_xml_registry_new (const gchar * name, const gchar * location); G_END_DECLS - #endif /* __GST_XML_REGISTRY_H__ */ - diff --git a/gst/registries/registrytest.c b/gst/registries/registrytest.c index 352ae44ce..27b11d0fe 100644 --- a/gst/registries/registrytest.c +++ b/gst/registries/registrytest.c @@ -3,17 +3,17 @@ #include "gstxmlregistry.h" gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstRegistry *registry; - + gst_init (&argc, &argv); registry = gst_xml_registry_new ("test", "reg.xml"); gst_registry_load (registry); - + return 0; - + } diff --git a/gst/schedulers/cothreads_compat.h b/gst/schedulers/cothreads_compat.h index 3f4e5e992..52669c12d 100644 --- a/gst/schedulers/cothreads_compat.h +++ b/gst/schedulers/cothreads_compat.h @@ -22,7 +22,7 @@ /* use the old cothreads implementation in gst/cothreads.[ch] */ #if defined(_COTHREADS_OMEGA) - + #include "../cothreads.h" /* the name of this cothreads type */ @@ -38,7 +38,7 @@ typedef cothread_state cothread; /* define functions * the macros are prepended with "do_" */ -#define do_cothreads_init(x) /* NOP */ +#define do_cothreads_init(x) /* NOP */ #define do_cothreads_stackquery(stack,size) cothread_stackquery(stack,size) @@ -54,27 +54,27 @@ typedef cothread_state cothread; #define do_cothread_setfunc(cothread, context, func, argc, argv) \ cothread_setfunc ((cothread), (func), (argc), (argv)) - + #define do_cothread_destroy(cothread) cothread_free(cothread) #define do_cothread_context_init() (cothread_context_init ()) #define do_cothread_context_destroy(context) cothread_context_free (context) - + #define do_cothread_lock(cothread) cothread_lock(cothread) #define do_cothread_unlock(cothread) cothread_unlock(cothread) #define do_cothread_get_current(context) (cothread_current()) #define do_cothread_get_main(context) (cothread_current_main()) - - - - + + + + /* use the gthread-based cothreads implementation */ #elif defined(_COTHREADS_GTHREAD) #include "gthread-cothreads.h" - - + + /* bail out with an error if no cothreads package is defined */ #else #error "No cothreads package defined" diff --git a/gst/schedulers/gstbasicscheduler.c b/gst/schedulers/gstbasicscheduler.c index 730ba8c32..92968049f 100644 --- a/gst/schedulers/gstbasicscheduler.c +++ b/gst/schedulers/gstbasicscheduler.c @@ -28,8 +28,8 @@ #include "cothreads_compat.h" -GST_DEBUG_CATEGORY_STATIC(debug_dataflow); -GST_DEBUG_CATEGORY_STATIC(debug_scheduler); +GST_DEBUG_CATEGORY_STATIC (debug_dataflow); +GST_DEBUG_CATEGORY_STATIC (debug_scheduler); #define GST_CAT_DEFAULT debug_scheduler typedef struct _GstSchedulerChain GstSchedulerChain; @@ -49,7 +49,8 @@ typedef struct _GstBasicSchedulerClass GstBasicSchedulerClass; # define _SCHEDULER_NAME "basic" #endif -struct _GstSchedulerChain { +struct _GstSchedulerChain +{ GstBasicScheduler *sched; GList *disabled; @@ -76,19 +77,22 @@ struct _GstSchedulerChain { #define SCHED(element) GST_BASIC_SCHEDULER (GST_ELEMENT_SCHED (element)) -typedef enum { +typedef enum +{ GST_BASIC_SCHEDULER_STATE_NONE, GST_BASIC_SCHEDULER_STATE_STOPPED, GST_BASIC_SCHEDULER_STATE_ERROR, GST_BASIC_SCHEDULER_STATE_RUNNING, } GstBasicSchedulerState; -typedef enum { +typedef enum +{ /* something important has changed inside the scheduler */ - GST_BASIC_SCHEDULER_CHANGE = GST_SCHEDULER_FLAG_LAST, + GST_BASIC_SCHEDULER_CHANGE = GST_SCHEDULER_FLAG_LAST, } GstBasicSchedulerFlags; -struct _GstBasicScheduler { +struct _GstBasicScheduler +{ GstScheduler parent; GList *elements; @@ -98,43 +102,50 @@ struct _GstBasicScheduler { gint num_chains; GstBasicSchedulerState state; - + cothread_context *context; GstElement *current; }; -struct _GstBasicSchedulerClass { +struct _GstBasicSchedulerClass +{ GstSchedulerClass parent_class; }; static GType _gst_basic_scheduler_type = 0; -static void gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass); -static void gst_basic_scheduler_init (GstBasicScheduler * scheduler); - -static void gst_basic_scheduler_dispose (GObject *object); - -static void gst_basic_scheduler_setup (GstScheduler *sched); -static void gst_basic_scheduler_reset (GstScheduler *sched); -static void gst_basic_scheduler_add_element (GstScheduler *sched, GstElement *element); -static void gst_basic_scheduler_remove_element (GstScheduler *sched, GstElement *element); -static GstElementStateReturn - gst_basic_scheduler_state_transition (GstScheduler *sched, GstElement *element, - gint transition); -static void gst_basic_scheduler_lock_element (GstScheduler *sched, GstElement *element); -static void gst_basic_scheduler_unlock_element (GstScheduler *sched, GstElement *element); -static gboolean gst_basic_scheduler_yield (GstScheduler *sched, GstElement *element); -static gboolean gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element); -static void gst_basic_scheduler_error (GstScheduler *sched, GstElement *element); -static void gst_basic_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, - GstPad *sinkpad); -static void gst_basic_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, - GstPad *sinkpad); -static void gst_basic_scheduler_pad_select (GstScheduler *sched, GList *padlist); -static GstSchedulerState - gst_basic_scheduler_iterate (GstScheduler *sched); - -static void gst_basic_scheduler_show (GstScheduler *sched); +static void gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass); +static void gst_basic_scheduler_init (GstBasicScheduler * scheduler); + +static void gst_basic_scheduler_dispose (GObject * object); + +static void gst_basic_scheduler_setup (GstScheduler * sched); +static void gst_basic_scheduler_reset (GstScheduler * sched); +static void gst_basic_scheduler_add_element (GstScheduler * sched, + GstElement * element); +static void gst_basic_scheduler_remove_element (GstScheduler * sched, + GstElement * element); +static GstElementStateReturn gst_basic_scheduler_state_transition (GstScheduler + * sched, GstElement * element, gint transition); +static void gst_basic_scheduler_lock_element (GstScheduler * sched, + GstElement * element); +static void gst_basic_scheduler_unlock_element (GstScheduler * sched, + GstElement * element); +static gboolean gst_basic_scheduler_yield (GstScheduler * sched, + GstElement * element); +static gboolean gst_basic_scheduler_interrupt (GstScheduler * sched, + GstElement * element); +static void gst_basic_scheduler_error (GstScheduler * sched, + GstElement * element); +static void gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad); +static void gst_basic_scheduler_pad_unlink (GstScheduler * sched, + GstPad * srcpad, GstPad * sinkpad); +static void gst_basic_scheduler_pad_select (GstScheduler * sched, + GList * padlist); +static GstSchedulerState gst_basic_scheduler_iterate (GstScheduler * sched); + +static void gst_basic_scheduler_show (GstScheduler * sched); static GstSchedulerClass *parent_class = NULL; @@ -186,7 +197,9 @@ gst_basic_scheduler_get_type (void) NULL }; - _gst_basic_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER, "Gst"COTHREADS_NAME_CAPITAL"Scheduler", &scheduler_info, 0); + _gst_basic_scheduler_type = + g_type_register_static (GST_TYPE_SCHEDULER, + "Gst" COTHREADS_NAME_CAPITAL "Scheduler", &scheduler_info, 0); } return _gst_basic_scheduler_type; } @@ -198,37 +211,46 @@ gst_basic_scheduler_class_init (GstBasicSchedulerClass * klass) GstObjectClass *gstobject_class; GstSchedulerClass *gstscheduler_class; - gobject_class = (GObjectClass*)klass; - gstobject_class = (GstObjectClass*)klass; - gstscheduler_class = (GstSchedulerClass*)klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstscheduler_class = (GstSchedulerClass *) klass; parent_class = g_type_class_ref (GST_TYPE_SCHEDULER); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose); - - gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup); - gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset); - gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element); - gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element); - gstscheduler_class->state_transition = GST_DEBUG_FUNCPTR (gst_basic_scheduler_state_transition); - gstscheduler_class->lock_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_lock_element); - gstscheduler_class->unlock_element = GST_DEBUG_FUNCPTR (gst_basic_scheduler_unlock_element); - gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_basic_scheduler_yield); - gstscheduler_class->interrupt = GST_DEBUG_FUNCPTR (gst_basic_scheduler_interrupt); - gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_basic_scheduler_error); - gstscheduler_class->pad_link = GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_link); - gstscheduler_class->pad_unlink = GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_unlink); - gstscheduler_class->pad_select = GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_select); - gstscheduler_class->clock_wait = NULL; - gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_basic_scheduler_iterate); - - gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_basic_scheduler_show); - - do_cothreads_init(NULL); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_basic_scheduler_dispose); + + gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_basic_scheduler_setup); + gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_basic_scheduler_reset); + gstscheduler_class->add_element = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_add_element); + gstscheduler_class->remove_element = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_remove_element); + gstscheduler_class->state_transition = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_state_transition); + gstscheduler_class->lock_element = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_lock_element); + gstscheduler_class->unlock_element = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_unlock_element); + gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_basic_scheduler_yield); + gstscheduler_class->interrupt = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_interrupt); + gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_basic_scheduler_error); + gstscheduler_class->pad_link = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_link); + gstscheduler_class->pad_unlink = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_unlink); + gstscheduler_class->pad_select = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_pad_select); + gstscheduler_class->clock_wait = NULL; + gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_basic_scheduler_iterate); + + gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_basic_scheduler_show); + + do_cothreads_init (NULL); } static void -gst_basic_scheduler_init (GstBasicScheduler *scheduler) +gst_basic_scheduler_init (GstBasicScheduler * scheduler) { scheduler->elements = NULL; scheduler->num_elements = 0; @@ -237,55 +259,50 @@ gst_basic_scheduler_init (GstBasicScheduler *scheduler) } static void -gst_basic_scheduler_dispose (GObject *object) +gst_basic_scheduler_dispose (GObject * object) { G_OBJECT_CLASS (parent_class)->dispose (object); } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { GstSchedulerFactory *factory; - GST_DEBUG_CATEGORY_INIT (debug_dataflow, "dataflow", 0, "basic scheduler dataflow"); - GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0, "basic scheduler general information"); + GST_DEBUG_CATEGORY_INIT (debug_dataflow, "dataflow", 0, + "basic scheduler dataflow"); + GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0, + "basic scheduler general information"); - factory = gst_scheduler_factory_new ("basic"COTHREADS_NAME, - "A basic scheduler using "COTHREADS_NAME" cothreads", - gst_basic_scheduler_get_type()); + factory = gst_scheduler_factory_new ("basic" COTHREADS_NAME, + "A basic scheduler using " COTHREADS_NAME " cothreads", + gst_basic_scheduler_get_type ()); if (factory != NULL) { gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); } else { - g_warning ("could not register scheduler: "COTHREADS_NAME); + g_warning ("could not register scheduler: " COTHREADS_NAME); } return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstbasic"COTHREADS_NAME"scheduler", - "a basic scheduler using "COTHREADS_NAME" cothreads", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstbasic" COTHREADS_NAME "scheduler", + "a basic scheduler using " COTHREADS_NAME " cothreads", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) -static int -gst_basic_scheduler_loopfunc_wrapper (int argc, char **argv) + static int gst_basic_scheduler_loopfunc_wrapper (int argc, char **argv) { GstElement *element = GST_ELEMENT (argv); G_GNUC_UNUSED const gchar *name = GST_ELEMENT_NAME (element); - GST_DEBUG("entering loopfunc wrapper of %s", name); + GST_DEBUG ("entering loopfunc wrapper of %s", name); gst_object_ref (GST_OBJECT (element)); do { GST_CAT_DEBUG (debug_dataflow, "calling loopfunc %s for element %s", - GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name); + GST_DEBUG_FUNCPTR_NAME (element->loopfunc), name); (element->loopfunc) (element); GST_CAT_DEBUG (debug_dataflow, "element %s ended loop function", name); @@ -301,7 +318,7 @@ gst_basic_scheduler_loopfunc_wrapper (int argc, char **argv) SCHED (element)->current = NULL; } - GST_DEBUG("leaving loopfunc wrapper of %s", name); + GST_DEBUG ("leaving loopfunc wrapper of %s", name); gst_object_unref (GST_OBJECT (element)); return 0; @@ -321,6 +338,7 @@ gst_basic_scheduler_chain_wrapper (int argc, char **argv) gst_object_ref (GST_OBJECT (element)); do { GList *pads; + do { pads = element->pads; @@ -333,24 +351,24 @@ gst_basic_scheduler_chain_wrapper (int argc, char **argv) realpad = GST_REAL_PAD (pad); - if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK && - GST_PAD_IS_LINKED (realpad) && + if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SINK && + GST_PAD_IS_LINKED (realpad) && g_slist_find (already_iterated, pad) == NULL) { GstData *data; - GST_CAT_DEBUG (debug_dataflow, "pulling data from %s:%s", name, - GST_PAD_NAME (pad)); + GST_CAT_DEBUG (debug_dataflow, "pulling data from %s:%s", name, + GST_PAD_NAME (pad)); data = gst_pad_pull (pad); if (data) { if (GST_IS_EVENT (data) && !GST_ELEMENT_IS_EVENT_AWARE (element)) { gst_pad_send_event (pad, GST_EVENT (data)); - } - else { - GST_CAT_DEBUG (debug_dataflow, "calling chain function of %s:%s %p", - name, GST_PAD_NAME (pad), data); + } else { + GST_CAT_DEBUG (debug_dataflow, + "calling chain function of %s:%s %p", name, + GST_PAD_NAME (pad), data); GST_RPAD_CHAINFUNC (realpad) (pad, data); - GST_CAT_DEBUG (debug_dataflow, - "calling chain function of element %s done", name); + GST_CAT_DEBUG (debug_dataflow, + "calling chain function of element %s done", name); } } already_iterated = g_slist_prepend (already_iterated, pad); @@ -401,13 +419,15 @@ gst_basic_scheduler_src_wrapper (int argc, char **argv) realpad = GST_REAL_PAD (pads->data); pads = g_list_next (pads); - if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC && GST_PAD_IS_USABLE (realpad)) { - GST_CAT_DEBUG (debug_dataflow, "calling _getfunc for %s:%s", GST_DEBUG_PAD_NAME (realpad)); + if (GST_RPAD_DIRECTION (realpad) == GST_PAD_SRC + && GST_PAD_IS_USABLE (realpad)) { + GST_CAT_DEBUG (debug_dataflow, "calling _getfunc for %s:%s", + GST_DEBUG_PAD_NAME (realpad)); g_return_val_if_fail (GST_RPAD_GETFUNC (realpad) != NULL, 0); data = GST_RPAD_GETFUNC (realpad) (GST_PAD (realpad)); if (data) { GST_CAT_DEBUG (debug_dataflow, "calling gst_pad_push on pad %s:%s %p", - GST_DEBUG_PAD_NAME (realpad), data); + GST_DEBUG_PAD_NAME (realpad), data); gst_pad_push (GST_PAD (realpad), data); } } @@ -438,15 +458,15 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstData * data) peer = GST_RPAD_PEER (pad); GST_DEBUG ("entered chainhandler proxy of %s:%s", GST_DEBUG_PAD_NAME (pad)); - GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer \"%s:%s\"'s pen", data, - GST_DEBUG_PAD_NAME (peer)); + GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer \"%s:%s\"'s pen", + data, GST_DEBUG_PAD_NAME (peer)); /* * loop until the bufferpen is empty so we can fill it up again */ while (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) != NULL && --loop_count) { GST_CAT_DEBUG (debug_dataflow, "switching to %p to empty bufpen %d", - GST_ELEMENT_THREADSTATE (parent), loop_count); + GST_ELEMENT_THREADSTATE (parent), loop_count); do_element_switch (parent); @@ -461,7 +481,7 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstData * data) if (loop_count == 0) { GST_ELEMENT_ERROR (parent, CORE, SCHEDULER, (NULL), - ("(internal error) basic: maximum number of switches exceeded")); + ("(internal error) basic: maximum number of switches exceeded")); return; } @@ -470,7 +490,7 @@ gst_basic_scheduler_chainhandler_proxy (GstPad * pad, GstData * data) /* now fill the bufferpen and switch so it can be consumed */ GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = data; GST_CAT_DEBUG (debug_dataflow, "switching to %p to consume buffer %p", - GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)), data); + GST_ELEMENT_THREADSTATE (GST_PAD_PARENT (pad)), data); do_element_switch (parent); @@ -481,22 +501,22 @@ static void gst_basic_scheduler_select_proxy (GstPad * pad, GstData * data) { GstElement *parent; - + parent = GST_PAD_PARENT (pad); - GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer's pen of pad %s:%s", - data, GST_DEBUG_PAD_NAME (pad)); + GST_CAT_DEBUG (debug_dataflow, "putting buffer %p in peer's pen of pad %s:%s", + data, GST_DEBUG_PAD_NAME (pad)); g_assert (GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) == NULL); /* now fill the bufferpen and switch so it can be consumed */ GST_RPAD_BUFPEN (GST_RPAD_PEER (pad)) = data; GST_CAT_DEBUG (debug_dataflow, "switching to %p", - GST_ELEMENT_THREADSTATE (parent)); + GST_ELEMENT_THREADSTATE (parent)); /* FIXME temporarily diabled */ /* parent->select_pad = pad; */ do_element_switch (parent); - + GST_CAT_DEBUG (debug_dataflow, "done switching"); } @@ -518,8 +538,7 @@ gst_basic_scheduler_gethandler_proxy (GstPad * pad) while (GST_RPAD_BUFPEN (pad) == NULL) { GST_CAT_DEBUG (debug_dataflow, "switching to \"%s\": %p to fill bufpen", - GST_ELEMENT_NAME (parent), - GST_ELEMENT_THREADSTATE (parent)); + GST_ELEMENT_NAME (parent), GST_ELEMENT_THREADSTATE (parent)); do_element_switch (parent); @@ -546,12 +565,12 @@ gst_basic_scheduler_gethandler_proxy (GstPad * pad) } static gboolean -gst_basic_scheduler_eventhandler_proxy (GstPad *srcpad, GstEvent *event) +gst_basic_scheduler_eventhandler_proxy (GstPad * srcpad, GstEvent * event) { gboolean flush; GST_INFO ("intercepting event %d on pad %s:%s", - GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad)); + GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad)); /* figure out if we need to flush */ switch (GST_EVENT_TYPE (event)) { @@ -574,7 +593,7 @@ gst_basic_scheduler_eventhandler_proxy (GstPad *srcpad, GstEvent *event) if (data) { GST_INFO ("need to clear some buffers"); - + gst_data_unref (data); GST_RPAD_BUFPEN (srcpad) = NULL; } @@ -610,25 +629,25 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain) /* if the element has a loopfunc... */ if (element->loopfunc != NULL) { - wrapper_function = GST_DEBUG_FUNCPTR (gst_basic_scheduler_loopfunc_wrapper); - GST_DEBUG ("element '%s' is a loop-based", - GST_ELEMENT_NAME (element)); - } - else { + wrapper_function = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_loopfunc_wrapper); + GST_DEBUG ("element '%s' is a loop-based", GST_ELEMENT_NAME (element)); + } else { /* otherwise we need to decide what kind of cothread * if it's not DECOUPLED, we decide based on * whether it's a source or not */ if (!decoupled) { /* if it doesn't have any sinks, it must be a source (duh) */ if (element->numsinkpads == 0) { - wrapper_function = GST_DEBUG_FUNCPTR (gst_basic_scheduler_src_wrapper); + wrapper_function = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_src_wrapper); GST_DEBUG ("element '%s' is a source, using _src_wrapper", - GST_ELEMENT_NAME (element)); - } - else { - wrapper_function = GST_DEBUG_FUNCPTR (gst_basic_scheduler_chain_wrapper); + GST_ELEMENT_NAME (element)); + } else { + wrapper_function = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_chain_wrapper); GST_DEBUG ("element '%s' is a filter, using _chain_wrapper", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); } } } @@ -643,25 +662,26 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain) if (!GST_IS_REAL_PAD (pad)) continue; - + peerpad = GST_PAD_PEER (pad); if (peerpad) { GstElement *peerelement = GST_ELEMENT (GST_PAD_PARENT (peerpad)); - gboolean different_sched = (peerelement->sched != GST_SCHEDULER (chain->sched)); - gboolean peer_decoupled = GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED); + gboolean different_sched = + (peerelement->sched != GST_SCHEDULER (chain->sched)); + gboolean peer_decoupled = + GST_FLAG_IS_SET (peerelement, GST_ELEMENT_DECOUPLED); - GST_DEBUG ("inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad)); + GST_DEBUG ("inspecting pad %s:%s", GST_DEBUG_PAD_NAME (peerpad)); /* we don't need to check this for decoupled elements */ if (!decoupled) { /* if the peer element is in another schedule, * it's not decoupled and we are not decoupled * either, we have an error */ - if (different_sched && !peer_decoupled) - { - GST_ELEMENT_ERROR (element, CORE, SCHEDULER, (NULL), - ("element \"%s\" is not decoupled but has pads in different schedulers", - GST_ELEMENT_NAME (element))); + if (different_sched && !peer_decoupled) { + GST_ELEMENT_ERROR (element, CORE, SCHEDULER, (NULL), + ("element \"%s\" is not decoupled but has pads in different schedulers", + GST_ELEMENT_NAME (element))); return FALSE; } /* ok, the peer is in a different scheduler and is decoupled, @@ -670,12 +690,11 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain) else if (different_sched) { if (GST_RPAD_DIRECTION (peerpad) == GST_PAD_SINK) { GST_DEBUG ("copying chain func into push proxy for peer %s:%s", - GST_DEBUG_PAD_NAME (peerpad)); + GST_DEBUG_PAD_NAME (peerpad)); GST_RPAD_CHAINHANDLER (peerpad) = GST_RPAD_CHAINFUNC (peerpad); - } - else { + } else { GST_DEBUG ("copying get func into pull proxy for peer %s:%s", - GST_DEBUG_PAD_NAME (peerpad)); + GST_DEBUG_PAD_NAME (peerpad)); GST_RPAD_GETHANDLER (peerpad) = GST_RPAD_GETFUNC (peerpad); } } @@ -689,12 +708,11 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain) /* set the chain proxies */ if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { GST_DEBUG ("copying chain function into push proxy for %s:%s", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); GST_RPAD_CHAINHANDLER (pad) = GST_RPAD_CHAINFUNC (pad); - } - else { + } else { GST_DEBUG ("copying get function into pull proxy for %s:%s", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); GST_RPAD_GETHANDLER (pad) = GST_RPAD_GETFUNC (pad); } } @@ -702,17 +720,19 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain) else { if (GST_RPAD_DIRECTION (pad) == GST_PAD_SINK) { GST_DEBUG ("setting cothreaded push proxy for sinkpad %s:%s", - GST_DEBUG_PAD_NAME (pad)); - GST_RPAD_CHAINHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy); - GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad); - } - else { + GST_DEBUG_PAD_NAME (pad)); + GST_RPAD_CHAINHANDLER (pad) = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_chainhandler_proxy); + GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad); + } else { GST_DEBUG ("setting cothreaded pull proxy for srcpad %s:%s", - GST_DEBUG_PAD_NAME (pad)); - GST_RPAD_GETHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_gethandler_proxy); + GST_DEBUG_PAD_NAME (pad)); + GST_RPAD_GETHANDLER (pad) = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_gethandler_proxy); /* the gethandler proxy function can queue a buffer in the bufpen, we need * to remove this buffer when a flush event is sent on the pad */ - GST_RPAD_EVENTHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_eventhandler_proxy); + GST_RPAD_EVENTHANDLER (pad) = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_eventhandler_proxy); } } } @@ -721,30 +741,28 @@ gst_basic_scheduler_cothreaded_chain (GstBin * bin, GstSchedulerChain * chain) if (wrapper_function != NULL) { if (GST_ELEMENT_THREADSTATE (element) == NULL) { GST_DEBUG ("about to create a cothread, wrapper for '%s' is &%s", - GST_ELEMENT_NAME (element), - GST_DEBUG_FUNCPTR_NAME (wrapper_function)); - do_cothread_create (GST_ELEMENT_THREADSTATE (element), - chain->sched->context, - wrapper_function, 0, (char **) element); + GST_ELEMENT_NAME (element), + GST_DEBUG_FUNCPTR_NAME (wrapper_function)); + do_cothread_create (GST_ELEMENT_THREADSTATE (element), + chain->sched->context, wrapper_function, 0, (char **) element); if (GST_ELEMENT_THREADSTATE (element) == NULL) { - GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY, (NULL), ("could not create cothread for \"%s\"", - GST_ELEMENT_NAME (element))); + GST_ELEMENT_ERROR (element, RESOURCE, TOO_LAZY, (NULL), + ("could not create cothread for \"%s\"", + GST_ELEMENT_NAME (element))); return FALSE; } - GST_DEBUG ("created cothread %p for '%s'", - GST_ELEMENT_THREADSTATE (element), - GST_ELEMENT_NAME (element)); + GST_DEBUG ("created cothread %p for '%s'", + GST_ELEMENT_THREADSTATE (element), GST_ELEMENT_NAME (element)); } else { /* set the cothread wrapper function */ GST_DEBUG ("about to set the wrapper function for '%s' to &%s", - GST_ELEMENT_NAME (element), - GST_DEBUG_FUNCPTR_NAME (wrapper_function)); - do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), - chain->sched->context, - wrapper_function, 0, (char **) element); + GST_ELEMENT_NAME (element), + GST_DEBUG_FUNCPTR_NAME (wrapper_function)); + do_cothread_setfunc (GST_ELEMENT_THREADSTATE (element), + chain->sched->context, wrapper_function, 0, (char **) element); GST_DEBUG ("set wrapper function for '%s' to &%s", - GST_ELEMENT_NAME (element), - GST_DEBUG_FUNCPTR_NAME (wrapper_function)); + GST_ELEMENT_NAME (element), + GST_DEBUG_FUNCPTR_NAME (wrapper_function)); } } } @@ -771,10 +789,10 @@ gst_basic_scheduler_chain_new (GstBasicScheduler * sched) sched->num_chains++; /* notify the scheduler that something changed */ - GST_FLAG_SET(sched, GST_BASIC_SCHEDULER_CHANGE); + GST_FLAG_SET (sched, GST_BASIC_SCHEDULER_CHANGE); GST_INFO ("created new chain %p, now are %d chains in sched %p", - chain, sched->num_chains, sched); + chain, sched->num_chains, sched); return chain; } @@ -790,43 +808,46 @@ gst_basic_scheduler_chain_destroy (GstSchedulerChain * chain) /* destroy the chain */ g_list_free (chain->disabled); /* should be empty... */ - g_list_free (chain->elements); /* ditto */ + g_list_free (chain->elements); /* ditto */ GST_INFO ("destroyed chain %p, now are %d chains in sched %p", chain, - sched->num_chains, sched); + sched->num_chains, sched); g_free (chain); /* notify the scheduler that something changed */ - GST_FLAG_SET(sched, GST_BASIC_SCHEDULER_CHANGE); + GST_FLAG_SET (sched, GST_BASIC_SCHEDULER_CHANGE); } static void -gst_basic_scheduler_chain_add_element (GstSchedulerChain * chain, GstElement * element) +gst_basic_scheduler_chain_add_element (GstSchedulerChain * chain, + GstElement * element) { /* set the sched pointer for the element */ element->sched = GST_SCHEDULER (chain->sched); /* add the element to either the main list or the disabled list */ - if (GST_STATE(element) == GST_STATE_PLAYING) { - GST_INFO ("adding element \"%s\" to chain %p enabled", GST_ELEMENT_NAME (element),chain); + if (GST_STATE (element) == GST_STATE_PLAYING) { + GST_INFO ("adding element \"%s\" to chain %p enabled", + GST_ELEMENT_NAME (element), chain); chain->elements = g_list_prepend (chain->elements, element); } else { - GST_INFO ("adding element \"%s\" to chain %p disabled", GST_ELEMENT_NAME (element),chain); + GST_INFO ("adding element \"%s\" to chain %p disabled", + GST_ELEMENT_NAME (element), chain); chain->disabled = g_list_prepend (chain->disabled, element); } chain->num_elements++; /* notify the scheduler that something changed */ - GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE); + GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE); } static gboolean -gst_basic_scheduler_chain_enable_element (GstSchedulerChain * chain, - GstElement * element) +gst_basic_scheduler_chain_enable_element (GstSchedulerChain * chain, + GstElement * element) { - GST_INFO ("enabling element \"%s\" in chain %p", - GST_ELEMENT_NAME (element), chain); + GST_INFO ("enabling element \"%s\" in chain %p", + GST_ELEMENT_NAME (element), chain); /* remove from disabled list */ chain->disabled = g_list_remove (chain->disabled, element); @@ -835,19 +856,20 @@ gst_basic_scheduler_chain_enable_element (GstSchedulerChain * chain, chain->elements = g_list_prepend (chain->elements, element); /* notify the scheduler that something changed */ - GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE); + GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE); /* GST_FLAG_UNSET(element, GST_ELEMENT_COTHREAD_STOPPING); */ /* reschedule the chain */ - return gst_basic_scheduler_cothreaded_chain (GST_BIN (GST_SCHEDULER (chain->sched)->parent), chain); + return gst_basic_scheduler_cothreaded_chain (GST_BIN (GST_SCHEDULER (chain-> + sched)->parent), chain); } static void -gst_basic_scheduler_chain_disable_element (GstSchedulerChain * chain, - GstElement * element) +gst_basic_scheduler_chain_disable_element (GstSchedulerChain * chain, + GstElement * element) { - GST_INFO ("disabling element \"%s\" in chain %p", - GST_ELEMENT_NAME (element), chain); + GST_INFO ("disabling element \"%s\" in chain %p", + GST_ELEMENT_NAME (element), chain); /* remove from elements list */ chain->elements = g_list_remove (chain->elements, element); @@ -856,8 +878,8 @@ gst_basic_scheduler_chain_disable_element (GstSchedulerChain * chain, chain->disabled = g_list_prepend (chain->disabled, element); /* notify the scheduler that something changed */ - GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE); - GST_FLAG_SET(element, GST_ELEMENT_COTHREAD_STOPPING); + GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE); + GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); /* reschedule the chain */ /* FIXME this should be done only if manager state != NULL */ @@ -865,10 +887,11 @@ gst_basic_scheduler_chain_disable_element (GstSchedulerChain * chain, } static void -gst_basic_scheduler_chain_remove_element (GstSchedulerChain * chain, GstElement * element) +gst_basic_scheduler_chain_remove_element (GstSchedulerChain * chain, + GstElement * element) { GST_INFO ("removing element \"%s\" from chain %p", GST_ELEMENT_NAME (element), - chain); + chain); /* if it's active, deactivate it */ if (g_list_find (chain->elements, element)) { @@ -885,7 +908,7 @@ gst_basic_scheduler_chain_remove_element (GstSchedulerChain * chain, GstElement chain->num_elements--; /* notify the scheduler that something changed */ - GST_FLAG_SET(chain->sched, GST_BASIC_SCHEDULER_CHANGE); + GST_FLAG_SET (chain->sched, GST_BASIC_SCHEDULER_CHANGE); /* if there are no more elements in the chain, destroy the chain */ if (chain->num_elements == 0) @@ -894,7 +917,8 @@ gst_basic_scheduler_chain_remove_element (GstSchedulerChain * chain, GstElement } static void -gst_basic_scheduler_chain_elements (GstBasicScheduler * sched, GstElement * element1, GstElement * element2) +gst_basic_scheduler_chain_elements (GstBasicScheduler * sched, + GstElement * element1, GstElement * element2) { GList *chains; GstSchedulerChain *chain; @@ -934,12 +958,13 @@ gst_basic_scheduler_chain_elements (GstBasicScheduler * sched, GstElement * elem /* gst_basic_scheduler_cothreaded_chain(chain->sched->parent,chain); */ /* otherwise if both have chains already, join them */ - } - else if ((chain1 != NULL) && (chain2 != NULL)) { + } else if ((chain1 != NULL) && (chain2 != NULL)) { GST_INFO ("merging chain %p into chain %p", chain2, chain1); /* take the contents of chain2 and merge them into chain1 */ - chain1->disabled = g_list_concat (chain1->disabled, g_list_copy (chain2->disabled)); - chain1->elements = g_list_concat (chain1->elements, g_list_copy (chain2->elements)); + chain1->disabled = + g_list_concat (chain1->disabled, g_list_copy (chain2->disabled)); + chain1->elements = + g_list_concat (chain1->elements, g_list_copy (chain2->elements)); chain1->num_elements += chain2->num_elements; /* FIXME chain changed here */ /* gst_basic_scheduler_cothreaded_chain(chain->sched->parent,chain); */ @@ -947,8 +972,7 @@ gst_basic_scheduler_chain_elements (GstBasicScheduler * sched, GstElement * elem gst_basic_scheduler_chain_destroy (chain2); /* otherwise one has a chain already, the other doesn't */ - } - else { + } else { /* pick out which one has the chain, and which doesn't */ if (chain1 != NULL) chain = chain1, element = element2; @@ -972,7 +996,7 @@ gst_basic_scheduler_find_chain (GstBasicScheduler * sched, GstElement * element) GstSchedulerChain *chain; GST_INFO ("searching for element \"%s\" in chains", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); chains = sched->chains; while (chains) { @@ -989,7 +1013,8 @@ gst_basic_scheduler_find_chain (GstBasicScheduler * sched, GstElement * element) } static void -gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement * element, gboolean remove) +gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, + GstElement * element, gboolean remove) { GList *pads; GstPad *pad; @@ -1017,15 +1042,16 @@ gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement * pads = g_list_next (pads); GST_DEBUG ("have pad %s:%s, checking for valid peer", - GST_DEBUG_PAD_NAME (pad)); + GST_DEBUG_PAD_NAME (pad)); /* if the peer exists and could be in the same chain */ if (GST_PAD_PEER (pad)) { GST_DEBUG ("has peer %s:%s", GST_DEBUG_PAD_NAME (GST_PAD_PEER (pad))); peerelement = GST_PAD_PARENT (GST_PAD_PEER (pad)); - if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) == GST_ELEMENT_SCHED (peerelement)) { - GST_DEBUG ("peer \"%s\" is valid for same chain", - GST_ELEMENT_NAME (peerelement)); - gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove); + if (GST_ELEMENT_SCHED (GST_PAD_PARENT (pad)) == + GST_ELEMENT_SCHED (peerelement)) { + GST_DEBUG ("peer \"%s\" is valid for same chain", + GST_ELEMENT_NAME (peerelement)); + gst_basic_scheduler_chain_recursive_add (chain, peerelement, remove); } } } @@ -1035,7 +1061,7 @@ gst_basic_scheduler_chain_recursive_add (GstSchedulerChain * chain, GstElement * * Entry points for this scheduler. */ static void -gst_basic_scheduler_setup (GstScheduler *sched) +gst_basic_scheduler_setup (GstScheduler * sched) { /* first create thread context */ if (GST_BASIC_SCHEDULER (sched)->context == NULL) { @@ -1045,24 +1071,25 @@ gst_basic_scheduler_setup (GstScheduler *sched) } static void -gst_basic_scheduler_reset (GstScheduler *sched) +gst_basic_scheduler_reset (GstScheduler * sched) { cothread_context *ctx; GList *elements = GST_BASIC_SCHEDULER (sched)->elements; while (elements) { GstElement *element = GST_ELEMENT (elements->data); + if (GST_ELEMENT_THREADSTATE (element)) { do_cothread_destroy (GST_ELEMENT_THREADSTATE (element)); GST_ELEMENT_THREADSTATE (element) = NULL; } elements = g_list_next (elements); } - + ctx = GST_BASIC_SCHEDULER (sched)->context; do_cothread_context_destroy (ctx); - + GST_BASIC_SCHEDULER (sched)->context = NULL; } @@ -1076,7 +1103,8 @@ gst_basic_scheduler_add_element (GstScheduler * sched, GstElement * element) /* only deal with elements after this point, not bins */ /* exception is made for Bin's that are schedulable, like the autoplugger */ - if (GST_IS_BIN (element) && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE)) + if (GST_IS_BIN (element) + && !GST_FLAG_IS_SET (element, GST_BIN_SELF_SCHEDULABLE)) return; /* first add it to the list of elements that are to be scheduled */ @@ -1096,14 +1124,14 @@ gst_basic_scheduler_remove_element (GstScheduler * sched, GstElement * element) if (g_list_find (bsched->elements, element)) { GST_INFO ("removing element \"%s\" from scheduler", - GST_ELEMENT_NAME (element)); + GST_ELEMENT_NAME (element)); /* if we are removing the currently scheduled element */ if (bsched->current == element) { - GST_FLAG_SET(element, GST_ELEMENT_COTHREAD_STOPPING); - if (element->post_run_func) - element->post_run_func (element); - bsched->current = NULL; + GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); + if (element->post_run_func) + element->post_run_func (element); + bsched->current = NULL; } /* find what chain the element is in */ chain = gst_basic_scheduler_find_chain (bsched, element); @@ -1112,7 +1140,7 @@ gst_basic_scheduler_remove_element (GstScheduler * sched, GstElement * element) if (chain != NULL) { gst_basic_scheduler_chain_remove_element (chain, element); } - + /* remove it from the list of elements */ bsched->elements = g_list_remove (bsched->elements, element); bsched->num_elements--; @@ -1122,7 +1150,8 @@ gst_basic_scheduler_remove_element (GstScheduler * sched, GstElement * element) } static GstElementStateReturn -gst_basic_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition) +gst_basic_scheduler_state_transition (GstScheduler * sched, + GstElement * element, gint transition) { GstSchedulerChain *chain; GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched); @@ -1133,36 +1162,31 @@ gst_basic_scheduler_state_transition (GstScheduler *sched, GstElement *element, if (transition == GST_STATE_PLAYING_TO_PAUSED) { GST_INFO ("setting scheduler state to stopped"); GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_STOPPED; - } - else if (transition == GST_STATE_PAUSED_TO_PLAYING) { + } else if (transition == GST_STATE_PAUSED_TO_PLAYING) { GST_INFO ("setting scheduler state to running"); GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_RUNNING; - } - else { + } else { GST_INFO ("no interesting state change, doing nothing"); } - } - else if (transition == GST_STATE_PLAYING_TO_PAUSED || - transition == GST_STATE_PAUSED_TO_PLAYING) { + } else if (transition == GST_STATE_PLAYING_TO_PAUSED || + transition == GST_STATE_PAUSED_TO_PLAYING) { /* find the chain the element is in */ chain = gst_basic_scheduler_find_chain (bsched, element); /* remove it from the chain */ if (chain) { if (transition == GST_STATE_PLAYING_TO_PAUSED) { - gst_basic_scheduler_chain_disable_element (chain, element); - } - else if (transition == GST_STATE_PAUSED_TO_PLAYING) { - if (!gst_basic_scheduler_chain_enable_element (chain, element)) { - GST_INFO ("could not enable element \"%s\"", - GST_ELEMENT_NAME (element)); - return GST_STATE_FAILURE; - } + gst_basic_scheduler_chain_disable_element (chain, element); + } else if (transition == GST_STATE_PAUSED_TO_PLAYING) { + if (!gst_basic_scheduler_chain_enable_element (chain, element)) { + GST_INFO ("could not enable element \"%s\"", + GST_ELEMENT_NAME (element)); + return GST_STATE_FAILURE; + } } - } - else { - GST_INFO ("element \"%s\" not found in any chain, no state change", - GST_ELEMENT_NAME (element)); + } else { + GST_INFO ("element \"%s\" not found in any chain, no state change", + GST_ELEMENT_NAME (element)); } } @@ -1184,19 +1208,19 @@ gst_basic_scheduler_unlock_element (GstScheduler * sched, GstElement * element) } static gboolean -gst_basic_scheduler_yield (GstScheduler *sched, GstElement *element) +gst_basic_scheduler_yield (GstScheduler * sched, GstElement * element) { if (GST_ELEMENT_IS_COTHREAD_STOPPING (element)) { do_switch_to_main (sched); - + /* no need to do a pre_run, the cothread is stopping */ } return FALSE; } static gboolean -gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element) +gst_basic_scheduler_interrupt (GstScheduler * sched, GstElement * element) { GST_FLAG_SET (element, GST_ELEMENT_COTHREAD_STOPPING); @@ -1206,13 +1230,13 @@ gst_basic_scheduler_interrupt (GstScheduler *sched, GstElement *element) } static void -gst_basic_scheduler_error (GstScheduler *sched, GstElement *element) +gst_basic_scheduler_error (GstScheduler * sched, GstElement * element) { GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched); if (GST_ELEMENT_THREADSTATE (element)) { GstSchedulerChain *chain; - + chain = gst_basic_scheduler_find_chain (bsched, element); if (chain) gst_basic_scheduler_chain_disable_element (chain, element); @@ -1224,7 +1248,8 @@ gst_basic_scheduler_error (GstScheduler *sched, GstElement *element) } static void -gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad *srcpad, GstPad *sinkpad) +gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad) { GstElement *srcelement, *sinkelement; GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched); @@ -1235,26 +1260,27 @@ gst_basic_scheduler_pad_link (GstScheduler * sched, GstPad *srcpad, GstPad *sink g_return_if_fail (sinkelement != NULL); GST_INFO ("have pad linked callback on %s:%s to %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); GST_DEBUG ("srcpad sched is %p, sinkpad sched is %p", - GST_ELEMENT_SCHED (srcelement), GST_ELEMENT_SCHED (sinkelement)); + GST_ELEMENT_SCHED (srcelement), GST_ELEMENT_SCHED (sinkelement)); if (GST_ELEMENT_SCHED (srcelement) == GST_ELEMENT_SCHED (sinkelement)) { GST_INFO ("peer %s:%s is in same scheduler, chaining together", - GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (sinkpad)); gst_basic_scheduler_chain_elements (bsched, srcelement, sinkelement); } } static void -gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, GstPad * sinkpad) +gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad) { GstElement *element1, *element2; GstSchedulerChain *chain1, *chain2; GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched); GST_INFO ("unlinking pads %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); /* we need to have the parent elements of each pad */ element1 = GST_ELEMENT (GST_PAD_PARENT (srcpad)); @@ -1295,7 +1321,6 @@ gst_basic_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, GstPad * chain2 = gst_basic_scheduler_chain_new (bsched); gst_basic_scheduler_chain_recursive_add (chain2, element2, FALSE); } - #else /* if they're both in the same chain, move second set of elements to a new chain */ @@ -1326,7 +1351,8 @@ gst_basic_scheduler_pad_select (GstScheduler * sched, GList * padlist) while (padlist) { pad = GST_PAD (padlist->data); - GST_RPAD_CHAINHANDLER (pad) = GST_DEBUG_FUNCPTR (gst_basic_scheduler_select_proxy); + GST_RPAD_CHAINHANDLER (pad) = + GST_DEBUG_FUNCPTR (gst_basic_scheduler_select_proxy); padlist = g_list_next (padlist); } @@ -1336,7 +1362,7 @@ gst_basic_scheduler_pad_select (GstScheduler * sched, GList * padlist) do_element_switch (GST_PAD_PARENT (peer)); /* FIXME disabled for now */ - /* pad = GST_ELEMENT (GST_PAD_PARENT (pad))->select_pad;*/ + /* pad = GST_ELEMENT (GST_PAD_PARENT (pad))->select_pad; */ g_assert (pad != NULL); } @@ -1352,13 +1378,12 @@ gst_basic_scheduler_iterate (GstScheduler * sched) gint scheduled = 0; GstBasicScheduler *bsched = GST_BASIC_SCHEDULER (sched); - GST_CAT_LOG_OBJECT (debug_dataflow, sched, - "starting iteration in bin %s", - GST_ELEMENT_NAME (sched->parent)); + GST_CAT_LOG_OBJECT (debug_dataflow, sched, + "starting iteration in bin %s", GST_ELEMENT_NAME (sched->parent)); /* clear the changes flag */ - GST_FLAG_UNSET(bsched, GST_BASIC_SCHEDULER_CHANGE); - + GST_FLAG_UNSET (bsched, GST_BASIC_SCHEDULER_CHANGE); + /* step through all the chains */ chains = bsched->chains; @@ -1369,13 +1394,13 @@ gst_basic_scheduler_iterate (GstScheduler * sched) chain = (GstSchedulerChain *) (chains->data); chains = g_list_next (chains); - /* all we really have to do is switch to the first child */ + /* all we really have to do is switch to the first child */ /* FIXME this should be lots more intelligent about where to start */ - GST_CAT_DEBUG (debug_dataflow, "starting iteration via cothreads using %s scheduler", - _SCHEDULER_NAME); + GST_CAT_DEBUG (debug_dataflow, + "starting iteration via cothreads using %s scheduler", _SCHEDULER_NAME); if (chain->elements) { - entry = NULL; /*MattH ADDED?*/ + entry = NULL; /*MattH ADDED? */ GST_DEBUG ("there are %d elements in this chain", chain->num_elements); elements = chain->elements; while (elements) { @@ -1383,36 +1408,35 @@ gst_basic_scheduler_iterate (GstScheduler * sched) elements = g_list_next (elements); if (GST_FLAG_IS_SET (entry, GST_ELEMENT_DECOUPLED)) { GST_DEBUG ("entry \"%s\" is DECOUPLED, skipping", - GST_ELEMENT_NAME (entry)); + GST_ELEMENT_NAME (entry)); entry = NULL; - } - else if (GST_FLAG_IS_SET (entry, GST_ELEMENT_INFINITE_LOOP)) { + } else if (GST_FLAG_IS_SET (entry, GST_ELEMENT_INFINITE_LOOP)) { GST_DEBUG ("entry \"%s\" is not valid, skipping", - GST_ELEMENT_NAME (entry)); + GST_ELEMENT_NAME (entry)); entry = NULL; - } - else + } else break; } if (entry) { GstSchedulerState state; - + GST_FLAG_SET (entry, GST_ELEMENT_COTHREAD_STOPPING); - GST_CAT_DEBUG (debug_dataflow, "set COTHREAD_STOPPING flag on \"%s\"(@%p)", - GST_ELEMENT_NAME (entry), entry); + GST_CAT_DEBUG (debug_dataflow, + "set COTHREAD_STOPPING flag on \"%s\"(@%p)", + GST_ELEMENT_NAME (entry), entry); if (GST_ELEMENT_THREADSTATE (entry)) { - do_switch_from_main (entry); + do_switch_from_main (entry); state = GST_SCHEDULER_STATE (sched); /* if something changed, return - go on else */ - if (GST_FLAG_IS_SET(bsched, GST_BASIC_SCHEDULER_CHANGE) && + if (GST_FLAG_IS_SET (bsched, GST_BASIC_SCHEDULER_CHANGE) && state != GST_SCHEDULER_STATE_ERROR) return GST_SCHEDULER_STATE_RUNNING; - } - else { - GST_CAT_DEBUG (debug_dataflow, "cothread switch not possible, element has no threadstate"); + } else { + GST_CAT_DEBUG (debug_dataflow, + "cothread switch not possible, element has no threadstate"); return GST_SCHEDULER_STATE_ERROR; } @@ -1425,28 +1449,28 @@ gst_basic_scheduler_iterate (GstScheduler * sched) GST_CAT_DEBUG (debug_dataflow, "cothread switch ended or interrupted"); if (state != GST_SCHEDULER_STATE_RUNNING) { - GST_CAT_INFO (debug_dataflow, "scheduler is not running, in state %d", state); + GST_CAT_INFO (debug_dataflow, "scheduler is not running, in state %d", + state); return state; } scheduled++; + } else { + GST_CAT_INFO (debug_dataflow, + "no entry in this chain, trying the next one"); } - else { - GST_CAT_INFO (debug_dataflow, "no entry in this chain, trying the next one"); - } - } - else { - GST_CAT_INFO (debug_dataflow, "no enabled elements in this chain, trying the next one"); + } else { + GST_CAT_INFO (debug_dataflow, + "no enabled elements in this chain, trying the next one"); } } GST_CAT_LOG_OBJECT (debug_dataflow, sched, "leaving (%s)", - GST_ELEMENT_NAME (sched->parent)); + GST_ELEMENT_NAME (sched->parent)); if (scheduled == 0) { GST_CAT_INFO (debug_dataflow, "nothing was scheduled, return STOPPED"); return GST_SCHEDULER_STATE_STOPPED; - } - else { + } else { GST_CAT_INFO (debug_dataflow, "scheduler still running, return RUNNING"); return GST_SCHEDULER_STATE_RUNNING; } @@ -1468,7 +1492,8 @@ gst_basic_scheduler_show (GstScheduler * sched) g_return_if_fail (GST_IS_SCHEDULER (sched)); - g_print ("SCHEDULER DUMP FOR MANAGING BIN \"%s\"\n", GST_ELEMENT_NAME (sched->parent)); + g_print ("SCHEDULER DUMP FOR MANAGING BIN \"%s\"\n", + GST_ELEMENT_NAME (sched->parent)); g_print ("scheduler has %d elements in it: ", bsched->num_elements); elements = bsched->elements; diff --git a/gst/schedulers/gstoptimalscheduler.c b/gst/schedulers/gstoptimalscheduler.c index 22a53d12f..514f881b3 100644 --- a/gst/schedulers/gstoptimalscheduler.c +++ b/gst/schedulers/gstoptimalscheduler.c @@ -26,7 +26,7 @@ #include -GST_DEBUG_CATEGORY_STATIC(debug_scheduler); +GST_DEBUG_CATEGORY_STATIC (debug_scheduler); #define GST_CAT_DEFAULT debug_scheduler #ifdef USE_COTHREADS @@ -59,7 +59,8 @@ typedef struct _GstOptSchedulerClass GstOptSchedulerClass; #define GST_IS_OPT_SCHEDULER_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPT_SCHEDULER)) -typedef enum { +typedef enum +{ GST_OPT_SCHEDULER_STATE_NONE, GST_OPT_SCHEDULER_STATE_STOPPED, GST_OPT_SCHEDULER_STATE_ERROR, @@ -67,35 +68,38 @@ typedef enum { GST_OPT_SCHEDULER_STATE_INTERRUPTED } GstOptSchedulerState; -struct _GstOptScheduler { - GstScheduler parent; +struct _GstOptScheduler +{ + GstScheduler parent; - GstOptSchedulerState state; + GstOptSchedulerState state; #ifdef USE_COTHREADS - cothread_context *context; + cothread_context *context; #endif - gint iterations; + gint iterations; - GSList *elements; - GSList *chains; + GSList *elements; + GSList *chains; - GList *runqueue; - gint recursion; + GList *runqueue; + gint recursion; - gint max_recursion; + gint max_recursion; }; -struct _GstOptSchedulerClass { +struct _GstOptSchedulerClass +{ GstSchedulerClass parent_class; }; static GType _gst_opt_scheduler_type = 0; -typedef enum { - GST_OPT_SCHEDULER_CHAIN_DIRTY = (1 << 1), - GST_OPT_SCHEDULER_CHAIN_DISABLED = (1 << 2), - GST_OPT_SCHEDULER_CHAIN_RUNNING = (1 << 3), +typedef enum +{ + GST_OPT_SCHEDULER_CHAIN_DIRTY = (1 << 1), + GST_OPT_SCHEDULER_CHAIN_DISABLED = (1 << 2), + GST_OPT_SCHEDULER_CHAIN_RUNNING = (1 << 3), } GstOptSchedulerChainFlags; #define GST_OPT_SCHEDULER_CHAIN_DISABLE(chain) ((chain)->flags |= GST_OPT_SCHEDULER_CHAIN_DISABLED) @@ -104,33 +108,36 @@ typedef enum { typedef struct _GstOptSchedulerChain GstOptSchedulerChain; -struct _GstOptSchedulerChain { - gint refcount; - - GstOptScheduler *sched; +struct _GstOptSchedulerChain +{ + gint refcount; + + GstOptScheduler *sched; + + GstOptSchedulerChainFlags flags; - GstOptSchedulerChainFlags flags; - - GSList *groups; /* the groups in this chain */ - gint num_groups; - gint num_enabled; + GSList *groups; /* the groups in this chain */ + gint num_groups; + gint num_enabled; }; /* * elements that are scheduled in one cothread */ -typedef enum { - GST_OPT_SCHEDULER_GROUP_DIRTY = (1 << 1), /* this group has been modified */ - GST_OPT_SCHEDULER_GROUP_COTHREAD_STOPPING = (1 << 2), /* the group's cothread stops after one iteration */ - GST_OPT_SCHEDULER_GROUP_DISABLED = (1 << 3), /* this group is disabled */ - GST_OPT_SCHEDULER_GROUP_RUNNING = (1 << 4), /* this group is running */ - GST_OPT_SCHEDULER_GROUP_SCHEDULABLE = (1 << 5), /* this group is schedulable */ - GST_OPT_SCHEDULER_GROUP_VISITED = (1 << 6), /* this group is visited when finding links */ +typedef enum +{ + GST_OPT_SCHEDULER_GROUP_DIRTY = (1 << 1), /* this group has been modified */ + GST_OPT_SCHEDULER_GROUP_COTHREAD_STOPPING = (1 << 2), /* the group's cothread stops after one iteration */ + GST_OPT_SCHEDULER_GROUP_DISABLED = (1 << 3), /* this group is disabled */ + GST_OPT_SCHEDULER_GROUP_RUNNING = (1 << 4), /* this group is running */ + GST_OPT_SCHEDULER_GROUP_SCHEDULABLE = (1 << 5), /* this group is schedulable */ + GST_OPT_SCHEDULER_GROUP_VISITED = (1 << 6), /* this group is visited when finding links */ } GstOptSchedulerGroupFlags; -typedef enum { - GST_OPT_SCHEDULER_GROUP_GET = 1, - GST_OPT_SCHEDULER_GROUP_LOOP = 2, +typedef enum +{ + GST_OPT_SCHEDULER_GROUP_GET = 1, + GST_OPT_SCHEDULER_GROUP_LOOP = 2, } GstOptSchedulerGroupType; #define GST_OPT_SCHEDULER_GROUP_SET_FLAG(group,flag) ((group)->flags |= (flag)) @@ -147,39 +154,41 @@ typedef struct _GstOptSchedulerGroup GstOptSchedulerGroup; typedef struct _GstOptSchedulerGroupLink GstOptSchedulerGroupLink; /* used to keep track of links with other groups */ -struct _GstOptSchedulerGroupLink { - GstOptSchedulerGroup *group1; /* the group we are linked with */ - GstOptSchedulerGroup *group2; /* the group we are linked with */ - gint count; /* the number of links with the group */ +struct _GstOptSchedulerGroupLink +{ + GstOptSchedulerGroup *group1; /* the group we are linked with */ + GstOptSchedulerGroup *group2; /* the group we are linked with */ + gint count; /* the number of links with the group */ }; #define IS_GROUP_LINK(link, group1, group2) ((link->group1 == group1 && link->group2 == group2) || \ (link->group2 == group1 && link->group1 == group2)) #define OTHER_GROUP_LINK(link, group) (link->group1 == group ? link->group2 : link->group1) -typedef int (*GroupScheduleFunction) (int argc, char *argv[]); +typedef int (*GroupScheduleFunction) (int argc, char *argv[]); -struct _GstOptSchedulerGroup { - GstOptSchedulerChain *chain; /* the chain this group belongs to */ - GstOptSchedulerGroupFlags flags; /* flags for this group */ - GstOptSchedulerGroupType type; /* flags for this group */ +struct _GstOptSchedulerGroup +{ + GstOptSchedulerChain *chain; /* the chain this group belongs to */ + GstOptSchedulerGroupFlags flags; /* flags for this group */ + GstOptSchedulerGroupType type; /* flags for this group */ - gint refcount; + gint refcount; - GSList *elements; /* elements of this group */ - gint num_elements; - gint num_enabled; - GstElement *entry; /* the group's entry point */ + GSList *elements; /* elements of this group */ + gint num_elements; + gint num_enabled; + GstElement *entry; /* the group's entry point */ - GSList *group_links; /* other groups that are linked with this group */ + GSList *group_links; /* other groups that are linked with this group */ #ifdef USE_COTHREADS - cothread *cothread; /* the cothread of this group */ + cothread *cothread; /* the cothread of this group */ #else - GroupScheduleFunction schedulefunc; + GroupScheduleFunction schedulefunc; #endif - int argc; - char **argv; + int argc; + char **argv; }; @@ -187,65 +196,62 @@ struct _GstOptSchedulerGroup { * A group is a set of elements through which data can flow without switching * cothreads or without invoking the scheduler's run queue. */ -static GstOptSchedulerGroup* ref_group (GstOptSchedulerGroup *group); -static GstOptSchedulerGroup* unref_group (GstOptSchedulerGroup *group); -static GstOptSchedulerGroup* create_group (GstOptSchedulerChain *chain, - GstElement *element, - GstOptSchedulerGroupType type); -static void destroy_group (GstOptSchedulerGroup *group); -static GstOptSchedulerGroup* add_to_group (GstOptSchedulerGroup *group, - GstElement *element); -static GstOptSchedulerGroup* remove_from_group (GstOptSchedulerGroup *group, - GstElement *element); -static GstOptSchedulerGroup* merge_groups (GstOptSchedulerGroup *group1, - GstOptSchedulerGroup *group2); -static void setup_group_scheduler (GstOptScheduler *osched, - GstOptSchedulerGroup *group); -static void destroy_group_scheduler (GstOptSchedulerGroup *group); -static void group_error_handler (GstOptSchedulerGroup *group); -static void group_element_set_enabled (GstOptSchedulerGroup *group, - GstElement *element, - gboolean enabled); -static gboolean schedule_group (GstOptSchedulerGroup *group); +static GstOptSchedulerGroup *ref_group (GstOptSchedulerGroup * group); +static GstOptSchedulerGroup *unref_group (GstOptSchedulerGroup * group); +static GstOptSchedulerGroup *create_group (GstOptSchedulerChain * chain, + GstElement * element, GstOptSchedulerGroupType type); +static void destroy_group (GstOptSchedulerGroup * group); +static GstOptSchedulerGroup *add_to_group (GstOptSchedulerGroup * group, + GstElement * element); +static GstOptSchedulerGroup *remove_from_group (GstOptSchedulerGroup * group, + GstElement * element); +static GstOptSchedulerGroup *merge_groups (GstOptSchedulerGroup * group1, + GstOptSchedulerGroup * group2); +static void setup_group_scheduler (GstOptScheduler * osched, + GstOptSchedulerGroup * group); +static void destroy_group_scheduler (GstOptSchedulerGroup * group); +static void group_error_handler (GstOptSchedulerGroup * group); +static void group_element_set_enabled (GstOptSchedulerGroup * group, + GstElement * element, gboolean enabled); +static gboolean schedule_group (GstOptSchedulerGroup * group); /* * A chain is a set of groups that are linked to each other. */ -static void destroy_chain (GstOptSchedulerChain *chain); -static GstOptSchedulerChain* create_chain (GstOptScheduler *osched); -static GstOptSchedulerChain* ref_chain (GstOptSchedulerChain *chain); -static GstOptSchedulerChain* unref_chain (GstOptSchedulerChain *chain); -static GstOptSchedulerChain* add_to_chain (GstOptSchedulerChain *chain, - GstOptSchedulerGroup *group); -static GstOptSchedulerChain* remove_from_chain (GstOptSchedulerChain *chain, - GstOptSchedulerGroup *group); -static GstOptSchedulerChain* merge_chains (GstOptSchedulerChain *chain1, - GstOptSchedulerChain *chain2); -static void chain_recursively_migrate_group (GstOptSchedulerChain *chain, - GstOptSchedulerGroup *group); -static void chain_group_set_enabled (GstOptSchedulerChain *chain, - GstOptSchedulerGroup *group, - gboolean enabled); -static void schedule_chain (GstOptSchedulerChain *chain); +static void destroy_chain (GstOptSchedulerChain * chain); +static GstOptSchedulerChain *create_chain (GstOptScheduler * osched); +static GstOptSchedulerChain *ref_chain (GstOptSchedulerChain * chain); +static GstOptSchedulerChain *unref_chain (GstOptSchedulerChain * chain); +static GstOptSchedulerChain *add_to_chain (GstOptSchedulerChain * chain, + GstOptSchedulerGroup * group); +static GstOptSchedulerChain *remove_from_chain (GstOptSchedulerChain * chain, + GstOptSchedulerGroup * group); +static GstOptSchedulerChain *merge_chains (GstOptSchedulerChain * chain1, + GstOptSchedulerChain * chain2); +static void chain_recursively_migrate_group (GstOptSchedulerChain * chain, + GstOptSchedulerGroup * group); +static void chain_group_set_enabled (GstOptSchedulerChain * chain, + GstOptSchedulerGroup * group, gboolean enabled); +static void schedule_chain (GstOptSchedulerChain * chain); /* * The schedule functions are the entry points for cothreads, or called directly * by gst_opt_scheduler_schedule_run_queue */ -static int get_group_schedule_function (int argc, char *argv[]); -static int loop_group_schedule_function (int argc, char *argv[]); -static int unknown_group_schedule_function (int argc, char *argv[]); +static int get_group_schedule_function (int argc, char *argv[]); +static int loop_group_schedule_function (int argc, char *argv[]); +static int unknown_group_schedule_function (int argc, char *argv[]); /* * These wrappers are set on the pads as the chain handler (what happens when * gst_pad_push is called) or get handler (for gst_pad_pull). */ -static void gst_opt_scheduler_loop_wrapper (GstPad *sinkpad, GstData *data); -static GstData* gst_opt_scheduler_get_wrapper (GstPad *srcpad); -static void gst_opt_scheduler_chain_wrapper (GstPad *sinkpad, GstData *data); +static void gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data); +static GstData *gst_opt_scheduler_get_wrapper (GstPad * srcpad); +static void gst_opt_scheduler_chain_wrapper (GstPad * sinkpad, GstData * data); /* @@ -254,7 +260,7 @@ static void gst_opt_scheduler_chain_wrapper (GstPad *sinkpad, GstData *data); * instead of relying on cothreads to do the switch for us. */ #ifndef USE_COTHREADS -static void gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched); +static void gst_opt_scheduler_schedule_run_queue (GstOptScheduler * osched); #endif @@ -263,17 +269,19 @@ static void gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched); */ typedef struct _GstOptSchedulerCtx GstOptSchedulerCtx; -typedef enum { - GST_OPT_SCHEDULER_CTX_DISABLED = (1 << 1), /* the element is disabled */ +typedef enum +{ + GST_OPT_SCHEDULER_CTX_DISABLED = (1 << 1), /* the element is disabled */ } GstOptSchedulerCtxFlags; -struct _GstOptSchedulerCtx { - GstOptSchedulerGroup *group; /* the group this element belongs to */ +struct _GstOptSchedulerCtx +{ + GstOptSchedulerGroup *group; /* the group this element belongs to */ - GstOptSchedulerCtxFlags flags; /* flags for this element */ + GstOptSchedulerCtxFlags flags; /* flags for this element */ }; - + /* * Implementation of GstScheduler */ @@ -284,35 +292,45 @@ enum ARG_MAX_RECURSION, }; -static void gst_opt_scheduler_class_init (GstOptSchedulerClass *klass); -static void gst_opt_scheduler_init (GstOptScheduler *scheduler); - -static void gst_opt_scheduler_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_opt_scheduler_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); - -static void gst_opt_scheduler_dispose (GObject *object); - -static void gst_opt_scheduler_setup (GstScheduler *sched); -static void gst_opt_scheduler_reset (GstScheduler *sched); -static void gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element); -static void gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element); -static GstElementStateReturn - gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition); -static void gst_opt_scheduler_scheduling_change (GstScheduler *sched, GstElement *element); -static void gst_opt_scheduler_lock_element (GstScheduler *sched, GstElement *element); -static void gst_opt_scheduler_unlock_element (GstScheduler *sched, GstElement *element); -static gboolean gst_opt_scheduler_yield (GstScheduler *sched, GstElement *element); -static gboolean gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element); -static void gst_opt_scheduler_error (GstScheduler *sched, GstElement *element); -static void gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); -static void gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad); -static void gst_opt_scheduler_pad_select (GstScheduler *sched, GList *padlist); -static GstSchedulerState - gst_opt_scheduler_iterate (GstScheduler *sched); - -static void gst_opt_scheduler_show (GstScheduler *sched); +static void gst_opt_scheduler_class_init (GstOptSchedulerClass * klass); +static void gst_opt_scheduler_init (GstOptScheduler * scheduler); + +static void gst_opt_scheduler_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_opt_scheduler_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static void gst_opt_scheduler_dispose (GObject * object); + +static void gst_opt_scheduler_setup (GstScheduler * sched); +static void gst_opt_scheduler_reset (GstScheduler * sched); +static void gst_opt_scheduler_add_element (GstScheduler * sched, + GstElement * element); +static void gst_opt_scheduler_remove_element (GstScheduler * sched, + GstElement * element); +static GstElementStateReturn gst_opt_scheduler_state_transition (GstScheduler * + sched, GstElement * element, gint transition); +static void gst_opt_scheduler_scheduling_change (GstScheduler * sched, + GstElement * element); +static void gst_opt_scheduler_lock_element (GstScheduler * sched, + GstElement * element); +static void gst_opt_scheduler_unlock_element (GstScheduler * sched, + GstElement * element); +static gboolean gst_opt_scheduler_yield (GstScheduler * sched, + GstElement * element); +static gboolean gst_opt_scheduler_interrupt (GstScheduler * sched, + GstElement * element); +static void gst_opt_scheduler_error (GstScheduler * sched, + GstElement * element); +static void gst_opt_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad); +static void gst_opt_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad); +static void gst_opt_scheduler_pad_select (GstScheduler * sched, + GList * padlist); +static GstSchedulerState gst_opt_scheduler_iterate (GstScheduler * sched); + +static void gst_opt_scheduler_show (GstScheduler * sched); static GstSchedulerClass *parent_class = NULL; @@ -333,65 +351,75 @@ gst_opt_scheduler_get_type (void) NULL }; - _gst_opt_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER, - "GstOpt"COTHREADS_NAME_CAPITAL"Scheduler", &scheduler_info, 0); + _gst_opt_scheduler_type = g_type_register_static (GST_TYPE_SCHEDULER, + "GstOpt" COTHREADS_NAME_CAPITAL "Scheduler", &scheduler_info, 0); } return _gst_opt_scheduler_type; } static void -gst_opt_scheduler_class_init (GstOptSchedulerClass *klass) +gst_opt_scheduler_class_init (GstOptSchedulerClass * klass) { GObjectClass *gobject_class; GstObjectClass *gstobject_class; GstSchedulerClass *gstscheduler_class; - gobject_class = (GObjectClass*)klass; - gstobject_class = (GstObjectClass*)klass; - gstscheduler_class = (GstSchedulerClass*)klass; + gobject_class = (GObjectClass *) klass; + gstobject_class = (GstObjectClass *) klass; + gstscheduler_class = (GstSchedulerClass *) klass; parent_class = g_type_class_ref (GST_TYPE_SCHEDULER); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_opt_scheduler_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_opt_scheduler_get_property); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_opt_scheduler_dispose); + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_get_property); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_opt_scheduler_dispose); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ITERATIONS, - g_param_spec_int ("iterations", "Iterations", - "Number of groups to schedule in one iteration (-1 == until EOS/error)", - -1, G_MAXINT, 1, G_PARAM_READWRITE)); + g_param_spec_int ("iterations", "Iterations", + "Number of groups to schedule in one iteration (-1 == until EOS/error)", + -1, G_MAXINT, 1, G_PARAM_READWRITE)); #ifndef USE_COTHREADS g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MAX_RECURSION, - g_param_spec_int ("max_recursion", "Max recursion", - "Maximum number of recursions", - 1, G_MAXINT, 100, G_PARAM_READWRITE)); + g_param_spec_int ("max_recursion", "Max recursion", + "Maximum number of recursions", 1, G_MAXINT, 100, G_PARAM_READWRITE)); #endif - gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_opt_scheduler_setup); - gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_opt_scheduler_reset); - gstscheduler_class->add_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_add_element); - gstscheduler_class->remove_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_remove_element); - gstscheduler_class->state_transition = GST_DEBUG_FUNCPTR (gst_opt_scheduler_state_transition); - gstscheduler_class->scheduling_change = GST_DEBUG_FUNCPTR (gst_opt_scheduler_scheduling_change); - gstscheduler_class->lock_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_lock_element); - gstscheduler_class->unlock_element = GST_DEBUG_FUNCPTR (gst_opt_scheduler_unlock_element); - gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_opt_scheduler_yield); - gstscheduler_class->interrupt = GST_DEBUG_FUNCPTR (gst_opt_scheduler_interrupt); - gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_opt_scheduler_error); - gstscheduler_class->pad_link = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_link); - gstscheduler_class->pad_unlink = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_unlink); - gstscheduler_class->pad_select = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_select); - gstscheduler_class->clock_wait = NULL; - gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_opt_scheduler_iterate); - gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_opt_scheduler_show); - + gstscheduler_class->setup = GST_DEBUG_FUNCPTR (gst_opt_scheduler_setup); + gstscheduler_class->reset = GST_DEBUG_FUNCPTR (gst_opt_scheduler_reset); + gstscheduler_class->add_element = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_add_element); + gstscheduler_class->remove_element = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_remove_element); + gstscheduler_class->state_transition = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_state_transition); + gstscheduler_class->scheduling_change = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_scheduling_change); + gstscheduler_class->lock_element = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_lock_element); + gstscheduler_class->unlock_element = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_unlock_element); + gstscheduler_class->yield = GST_DEBUG_FUNCPTR (gst_opt_scheduler_yield); + gstscheduler_class->interrupt = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_interrupt); + gstscheduler_class->error = GST_DEBUG_FUNCPTR (gst_opt_scheduler_error); + gstscheduler_class->pad_link = GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_link); + gstscheduler_class->pad_unlink = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_unlink); + gstscheduler_class->pad_select = + GST_DEBUG_FUNCPTR (gst_opt_scheduler_pad_select); + gstscheduler_class->clock_wait = NULL; + gstscheduler_class->iterate = GST_DEBUG_FUNCPTR (gst_opt_scheduler_iterate); + gstscheduler_class->show = GST_DEBUG_FUNCPTR (gst_opt_scheduler_show); + #ifdef USE_COTHREADS - do_cothreads_init(NULL); + do_cothreads_init (NULL); #endif } static void -gst_opt_scheduler_init (GstOptScheduler *scheduler) +gst_opt_scheduler_init (GstOptScheduler * scheduler) { scheduler->elements = NULL; scheduler->iterations = 1; @@ -399,65 +427,57 @@ gst_opt_scheduler_init (GstOptScheduler *scheduler) } static void -gst_opt_scheduler_dispose (GObject *object) +gst_opt_scheduler_dispose (GObject * object) { G_OBJECT_CLASS (parent_class)->dispose (object); } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { GstSchedulerFactory *factory; - GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0, "optimal scheduler"); + GST_DEBUG_CATEGORY_INIT (debug_scheduler, "scheduler", 0, + "optimal scheduler"); #ifdef USE_COTHREADS - factory = gst_scheduler_factory_new ("opt"COTHREADS_NAME, - "An optimal scheduler using "COTHREADS_NAME" cothreads", - gst_opt_scheduler_get_type()); + factory = gst_scheduler_factory_new ("opt" COTHREADS_NAME, + "An optimal scheduler using " COTHREADS_NAME " cothreads", + gst_opt_scheduler_get_type ()); #else factory = gst_scheduler_factory_new ("opt", - "An optimal scheduler using no cothreads", - gst_opt_scheduler_get_type()); + "An optimal scheduler using no cothreads", gst_opt_scheduler_get_type ()); #endif if (factory != NULL) { gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } - else { + } else { g_warning ("could not register scheduler: optimal"); } return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstopt"COTHREADS_NAME"scheduler", - "An optimal scheduler using "COTHREADS_NAME" cothreads", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstopt" COTHREADS_NAME "scheduler", + "An optimal scheduler using " COTHREADS_NAME " cothreads", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); -static GstOptSchedulerChain* -ref_chain (GstOptSchedulerChain *chain) +static GstOptSchedulerChain * +ref_chain (GstOptSchedulerChain * chain) { - GST_LOG ("ref chain %p %d->%d", chain, - chain->refcount, chain->refcount+1); + GST_LOG ("ref chain %p %d->%d", chain, chain->refcount, chain->refcount + 1); chain->refcount++; return chain; } -static GstOptSchedulerChain* -unref_chain (GstOptSchedulerChain *chain) +static GstOptSchedulerChain * +unref_chain (GstOptSchedulerChain * chain) { - GST_LOG ("unref chain %p %d->%d", chain, - chain->refcount, chain->refcount-1); + GST_LOG ("unref chain %p %d->%d", chain, + chain->refcount, chain->refcount - 1); if (--chain->refcount == 0) { destroy_chain (chain); @@ -467,8 +487,8 @@ unref_chain (GstOptSchedulerChain *chain) return chain; } -static GstOptSchedulerChain* -create_chain (GstOptScheduler *osched) +static GstOptSchedulerChain * +create_chain (GstOptScheduler * osched) { GstOptSchedulerChain *chain; @@ -480,17 +500,17 @@ create_chain (GstOptScheduler *osched) gst_object_ref (GST_OBJECT (osched)); osched->chains = g_slist_prepend (osched->chains, chain); - GST_LOG ( "new chain %p", chain); + GST_LOG ("new chain %p", chain); return chain; } static void -destroy_chain (GstOptSchedulerChain *chain) +destroy_chain (GstOptSchedulerChain * chain) { GstOptScheduler *osched; - - GST_LOG ( "destroy chain %p", chain); + + GST_LOG ("destroy chain %p", chain); g_assert (chain->num_groups == 0); g_assert (chain->groups == NULL); @@ -503,8 +523,8 @@ destroy_chain (GstOptSchedulerChain *chain) g_free (chain); } -static GstOptSchedulerChain* -add_to_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group) +static GstOptSchedulerChain * +add_to_chain (GstOptSchedulerChain * chain, GstOptSchedulerGroup * group) { GST_LOG ("adding group %p to chain %p", group, chain); @@ -523,7 +543,7 @@ add_to_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group) chain->groups = g_slist_prepend (chain->groups, group); else chain->groups = g_slist_append (chain->groups, group); - + chain->num_groups++; if (GST_OPT_SCHEDULER_GROUP_IS_ENABLED (group)) { @@ -533,8 +553,8 @@ add_to_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group) return chain; } -static GstOptSchedulerChain* -remove_from_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group) +static GstOptSchedulerChain * +remove_from_chain (GstOptSchedulerChain * chain, GstOptSchedulerGroup * group) { GST_LOG ("removing group %p from chain %p", group, chain); @@ -549,22 +569,22 @@ remove_from_chain (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group) chain->num_groups--; unref_group (group); - if (chain->num_groups == 0) + if (chain->num_groups == 0) chain = unref_chain (chain); chain = unref_chain (chain); return chain; } -static GstOptSchedulerChain* -merge_chains (GstOptSchedulerChain *chain1, GstOptSchedulerChain *chain2) +static GstOptSchedulerChain * +merge_chains (GstOptSchedulerChain * chain1, GstOptSchedulerChain * chain2) { GSList *walk; g_assert (chain1 != NULL); - + GST_LOG ("merging chain %p and %p", chain1, chain2); - + /* FIXME: document how chain2 can be NULL */ if (chain1 == chain2 || chain2 == NULL) return chain1; @@ -572,6 +592,7 @@ merge_chains (GstOptSchedulerChain *chain1, GstOptSchedulerChain *chain2) /* switch if it's more efficient */ if (chain1->num_groups < chain2->num_groups) { GstOptSchedulerChain *tmp = chain2; + chain2 = chain1; chain1 = tmp; } @@ -579,13 +600,13 @@ merge_chains (GstOptSchedulerChain *chain1, GstOptSchedulerChain *chain2) walk = chain2->groups; while (walk) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) walk->data; + walk = g_slist_next (walk); - GST_LOG ("reparenting group %p from chain %p to %p", - group, chain2, chain1); + GST_LOG ("reparenting group %p from chain %p to %p", group, chain2, chain1); ref_group (group); - + remove_from_chain (chain2, group); add_to_chain (chain1, group); @@ -598,25 +619,27 @@ merge_chains (GstOptSchedulerChain *chain1, GstOptSchedulerChain *chain2) } static void -chain_group_set_enabled (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group, gboolean enabled) +chain_group_set_enabled (GstOptSchedulerChain * chain, + GstOptSchedulerGroup * group, gboolean enabled) { g_assert (group != NULL); g_assert (chain != NULL); - GST_LOG ("request to %d group %p in chain %p, have %d groups enabled out of %d", - enabled, group, chain, chain->num_enabled, chain->num_groups); + GST_LOG + ("request to %d group %p in chain %p, have %d groups enabled out of %d", + enabled, group, chain, chain->num_enabled, chain->num_groups); if (enabled) GST_OPT_SCHEDULER_GROUP_ENABLE (group); - else + else GST_OPT_SCHEDULER_GROUP_DISABLE (group); if (enabled) { if (chain->num_enabled < chain->num_groups) chain->num_enabled++; - GST_DEBUG ("enable group %p in chain %p, now %d groups enabled out of %d", group, chain, - chain->num_enabled, chain->num_groups); + GST_DEBUG ("enable group %p in chain %p, now %d groups enabled out of %d", + group, chain, chain->num_enabled, chain->num_groups); /* OK to call even if the scheduler (cothread context / schedulerfunc) was setup already -- will get destroyed when the group is destroyed */ @@ -626,13 +649,12 @@ chain_group_set_enabled (GstOptSchedulerChain *chain, GstOptSchedulerGroup *grou GST_DEBUG ("enable chain %p", chain); GST_OPT_SCHEDULER_CHAIN_ENABLE (chain); } - } - else { + } else { if (chain->num_enabled > 0) chain->num_enabled--; - GST_DEBUG ("disable group %p in chain %p, now %d groups enabled out of %d", group, chain, - chain->num_enabled, chain->num_groups); + GST_DEBUG ("disable group %p in chain %p, now %d groups enabled out of %d", + group, chain, chain->num_enabled, chain->num_groups); if (chain->num_enabled == 0) { GST_DEBUG ("disable chain %p", chain); @@ -643,10 +665,11 @@ chain_group_set_enabled (GstOptSchedulerChain *chain, GstOptSchedulerGroup *grou /* recursively migrate the group and all connected groups into the new chain */ static void -chain_recursively_migrate_group (GstOptSchedulerChain *chain, GstOptSchedulerGroup *group) +chain_recursively_migrate_group (GstOptSchedulerChain * chain, + GstOptSchedulerGroup * group) { GSList *links; - + /* group already in chain */ if (group->chain == chain) return; @@ -660,28 +683,29 @@ chain_recursively_migrate_group (GstOptSchedulerChain *chain, GstOptSchedulerGro links = group->group_links; while (links) { GstOptSchedulerGroupLink *link = (GstOptSchedulerGroupLink *) links->data; + links = g_slist_next (links); - chain_recursively_migrate_group (chain, (link->group1 == group ? link->group2 : link->group1)); + chain_recursively_migrate_group (chain, + (link->group1 == group ? link->group2 : link->group1)); } } -static GstOptSchedulerGroup* -ref_group (GstOptSchedulerGroup *group) +static GstOptSchedulerGroup * +ref_group (GstOptSchedulerGroup * group) { - GST_LOG ("ref group %p %d->%d", group, - group->refcount, group->refcount+1); + GST_LOG ("ref group %p %d->%d", group, group->refcount, group->refcount + 1); group->refcount++; return group; } -static GstOptSchedulerGroup* -unref_group (GstOptSchedulerGroup *group) +static GstOptSchedulerGroup * +unref_group (GstOptSchedulerGroup * group) { - GST_LOG ("unref group %p %d->%d", group, - group->refcount, group->refcount-1); + GST_LOG ("unref group %p %d->%d", group, + group->refcount, group->refcount - 1); if (--group->refcount == 0) { destroy_group (group); @@ -691,29 +715,29 @@ unref_group (GstOptSchedulerGroup *group) return group; } -static GstOptSchedulerGroup* -create_group (GstOptSchedulerChain *chain, GstElement *element, - GstOptSchedulerGroupType type) +static GstOptSchedulerGroup * +create_group (GstOptSchedulerChain * chain, GstElement * element, + GstOptSchedulerGroupType type) { GstOptSchedulerGroup *group; group = g_new0 (GstOptSchedulerGroup, 1); GST_LOG ("new group %p", group); - group->refcount = 1; /* float... */ + group->refcount = 1; /* float... */ group->flags = GST_OPT_SCHEDULER_GROUP_DISABLED; group->type = type; add_to_group (group, element); add_to_chain (chain, group); - group = unref_group (group); /* ...and sink. */ + group = unref_group (group); /* ...and sink. */ /* group's refcount is now 2 (one for the element, one for the chain) */ - + return group; } static void -destroy_group (GstOptSchedulerGroup *group) +destroy_group (GstOptSchedulerGroup * group) { GST_LOG ("destroy group %p", group); @@ -728,17 +752,18 @@ destroy_group (GstOptSchedulerGroup *group) g_free (group); } -static GstOptSchedulerGroup* -add_to_group (GstOptSchedulerGroup *group, GstElement *element) +static GstOptSchedulerGroup * +add_to_group (GstOptSchedulerGroup * group, GstElement * element) { g_assert (group != NULL); g_assert (element != NULL); - GST_DEBUG ("adding element \"%s\" to group %p", GST_ELEMENT_NAME (element), group); + GST_DEBUG ("adding element \"%s\" to group %p", GST_ELEMENT_NAME (element), + group); if (GST_ELEMENT_IS_DECOUPLED (element)) { - GST_DEBUG ("element \"%s\" is decoupled, not adding to group %p", - GST_ELEMENT_NAME (element), group); + GST_DEBUG ("element \"%s\" is decoupled, not adding to group %p", + GST_ELEMENT_NAME (element), group); return group; } @@ -760,10 +785,11 @@ add_to_group (GstOptSchedulerGroup *group, GstElement *element) /* if the element is linked to elements from other groups, you must decrement the link count prior to calling this function */ -static GstOptSchedulerGroup* -remove_from_group (GstOptSchedulerGroup *group, GstElement *element) +static GstOptSchedulerGroup * +remove_from_group (GstOptSchedulerGroup * group, GstElement * element) { - GST_DEBUG ("removing element \"%s\" from group %p", GST_ELEMENT_NAME (element), group); + GST_DEBUG ("removing element \"%s\" from group %p", + GST_ELEMENT_NAME (element), group); g_assert (group != NULL); g_assert (element != NULL); @@ -798,31 +824,31 @@ remove_from_group (GstOptSchedulerGroup *group, GstElement *element) /* FIXME need to check if the groups are of the same type -- otherwise need to setup the scheduler again, if it is setup */ -static GstOptSchedulerGroup* -merge_groups (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) +static GstOptSchedulerGroup * +merge_groups (GstOptSchedulerGroup * group1, GstOptSchedulerGroup * group2) { g_assert (group1 != NULL); GST_DEBUG ("merging groups %p and %p", group1, group2); - + if (group1 == group2 || group2 == NULL) return group1; while (group2 && group2->elements) { - GstElement *element = (GstElement *)group2->elements->data; + GstElement *element = (GstElement *) group2->elements->data; group2 = remove_from_group (group2, element); add_to_group (group1, element); } - + return group1; } /* setup the scheduler context for a group. The right schedule function * is selected based on the group type and cothreads are created if * needed */ -static void -setup_group_scheduler (GstOptScheduler *osched, GstOptSchedulerGroup *group) +static void +setup_group_scheduler (GstOptScheduler * osched, GstOptSchedulerGroup * group) { GroupScheduleFunction wrapper; @@ -833,15 +859,14 @@ setup_group_scheduler (GstOptScheduler *osched, GstOptSchedulerGroup *group) wrapper = get_group_schedule_function; else if (group->type == GST_OPT_SCHEDULER_GROUP_LOOP) wrapper = loop_group_schedule_function; - + #ifdef USE_COTHREADS if (!(group->flags & GST_OPT_SCHEDULER_GROUP_SCHEDULABLE)) { do_cothread_create (group->cothread, osched->context, - (cothread_func) wrapper, 0, (char **) group); - } - else { + (cothread_func) wrapper, 0, (char **) group); + } else { do_cothread_setfunc (group->cothread, osched->context, - (cothread_func) wrapper, 0, (char **) group); + (cothread_func) wrapper, 0, (char **) group); } #else group->schedulefunc = wrapper; @@ -851,8 +876,8 @@ setup_group_scheduler (GstOptScheduler *osched, GstOptSchedulerGroup *group) group->flags |= GST_OPT_SCHEDULER_GROUP_SCHEDULABLE; } -static void -destroy_group_scheduler (GstOptSchedulerGroup *group) +static void +destroy_group_scheduler (GstOptSchedulerGroup * group) { g_assert (group); @@ -874,7 +899,7 @@ destroy_group_scheduler (GstOptSchedulerGroup *group) } static void -group_error_handler (GstOptSchedulerGroup *group) +group_error_handler (GstOptSchedulerGroup * group) { GST_DEBUG ("group %p has errored", group); @@ -886,13 +911,16 @@ group_error_handler (GstOptSchedulerGroup *group) * and tells the chain that the group is enabled if all elements inside the group are * enabled */ static void -group_element_set_enabled (GstOptSchedulerGroup *group, GstElement *element, gboolean enabled) +group_element_set_enabled (GstOptSchedulerGroup * group, GstElement * element, + gboolean enabled) { g_assert (group != NULL); g_assert (element != NULL); - GST_LOG ("request to %d element %s in group %p, have %d elements enabled out of %d", - enabled, GST_ELEMENT_NAME (element), group, group->num_enabled, group->num_elements); + GST_LOG + ("request to %d element %s in group %p, have %d elements enabled out of %d", + enabled, GST_ELEMENT_NAME (element), group, group->num_enabled, + group->num_elements); /* Note that if an unlinked PLAYING element is added to a bin, we have to create a new group to hold the element, and this function will be called @@ -903,33 +931,36 @@ group_element_set_enabled (GstOptSchedulerGroup *group, GstElement *element, gbo if (group->num_enabled < group->num_elements) group->num_enabled++; - GST_DEBUG ("enable element %s in group %p, now %d elements enabled out of %d", - GST_ELEMENT_NAME (element), group, group->num_enabled, group->num_elements); + GST_DEBUG + ("enable element %s in group %p, now %d elements enabled out of %d", + GST_ELEMENT_NAME (element), group, group->num_enabled, + group->num_elements); if (group->num_enabled == group->num_elements) { if (!group->chain) { - GST_DEBUG ("enable chainless group %p", group); - GST_OPT_SCHEDULER_GROUP_ENABLE (group); + GST_DEBUG ("enable chainless group %p", group); + GST_OPT_SCHEDULER_GROUP_ENABLE (group); } else { - GST_LOG ("enable group %p", group); - chain_group_set_enabled (group->chain, group, TRUE); + GST_LOG ("enable group %p", group); + chain_group_set_enabled (group->chain, group, TRUE); } } - } - else { + } else { if (group->num_enabled > 0) group->num_enabled--; - GST_DEBUG ("disable element %s in group %p, now %d elements enabled out of %d", - GST_ELEMENT_NAME (element), group, group->num_enabled, group->num_elements); + GST_DEBUG + ("disable element %s in group %p, now %d elements enabled out of %d", + GST_ELEMENT_NAME (element), group, group->num_enabled, + group->num_elements); if (group->num_enabled == 0) { if (!group->chain) { - GST_DEBUG ("disable chainless group %p", group); - GST_OPT_SCHEDULER_GROUP_DISABLE (group); + GST_DEBUG ("disable chainless group %p", group); + GST_OPT_SCHEDULER_GROUP_DISABLE (group); } else { - GST_LOG ("disable group %p", group); - chain_group_set_enabled (group->chain, group, FALSE); + GST_LOG ("disable group %p", group); + chain_group_set_enabled (group->chain, group, FALSE); } } } @@ -939,14 +970,13 @@ group_element_set_enabled (GstOptSchedulerGroup *group, GstElement *element, gbo * by calling the schedule function. In the non-cothread case * we cannot run already running groups so we return FALSE here * to indicate this to the caller */ -static gboolean -schedule_group (GstOptSchedulerGroup *group) +static gboolean +schedule_group (GstOptSchedulerGroup * group) { if (!group->entry) { GST_INFO ("not scheduling group %p without entry", group); return FALSE; } - #ifdef USE_COTHREADS if (group->cothread) do_cothread_switch (group->cothread); @@ -962,18 +992,20 @@ schedule_group (GstOptSchedulerGroup *group) } else { GSList *l; - for (l=group->elements; l; l=l->next) { - GstElement *e = (GstElement*)l->data; + for (l = group->elements; l; l = l->next) { + GstElement *e = (GstElement *) l->data; + if (e->pre_run_func) - e->pre_run_func (e); + e->pre_run_func (e); } group->schedulefunc (group->argc, group->argv); - for (l=group->elements; l; l=l->next) { - GstElement *e = (GstElement*)l->data; + for (l = group->elements; l; l = l->next) { + GstElement *e = (GstElement *) l->data; + if (e->post_run_func) - e->post_run_func (e); + e->post_run_func (e); } } @@ -983,11 +1015,11 @@ schedule_group (GstOptSchedulerGroup *group) #ifndef USE_COTHREADS static void -gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched) +gst_opt_scheduler_schedule_run_queue (GstOptScheduler * osched) { GST_LOG_OBJECT (osched, "running queue: %d groups, recursed %d times", - g_list_length (osched->runqueue), - osched->recursion, g_list_length (osched->runqueue)); + g_list_length (osched->runqueue), + osched->recursion, g_list_length (osched->runqueue)); /* note that we have a ref on each group on the queue (unref after running) */ @@ -1002,7 +1034,7 @@ gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched) while (osched->runqueue) { GstOptSchedulerGroup *group; gboolean res; - + group = (GstOptSchedulerGroup *) osched->runqueue->data; /* runqueue holds refcount to group */ @@ -1012,16 +1044,16 @@ gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched) res = schedule_group (group); if (!res) { - g_warning ("error scheduling group %p", group); + g_warning ("error scheduling group %p", group); group_error_handler (group); - } - else { + } else { GST_LOG_OBJECT (osched, "done scheduling group %p", group); } unref_group (group); } - GST_LOG_OBJECT (osched, "run queue length after scheduling %d", g_list_length (osched->runqueue)); + GST_LOG_OBJECT (osched, "run queue length after scheduling %d", + g_list_length (osched->runqueue)); osched->recursion--; } @@ -1029,7 +1061,7 @@ gst_opt_scheduler_schedule_run_queue (GstOptScheduler *osched) /* a chain is scheduled by picking the first active group and scheduling it */ static void -schedule_chain (GstOptSchedulerChain *chain) +schedule_chain (GstOptSchedulerChain * chain) { GSList *groups; GstOptScheduler *osched; @@ -1042,23 +1074,20 @@ schedule_chain (GstOptSchedulerChain *chain) if (!GST_OPT_SCHEDULER_GROUP_IS_DISABLED (group)) { ref_group (group); - GST_LOG ("scheduling group %p in chain %p", - group, chain); + GST_LOG ("scheduling group %p in chain %p", group, chain); #ifdef USE_COTHREADS schedule_group (group); #else osched->recursion = 0; - if (!g_list_find (osched->runqueue, group)) - { - ref_group (group); - osched->runqueue = g_list_append (osched->runqueue, group); + if (!g_list_find (osched->runqueue, group)) { + ref_group (group); + osched->runqueue = g_list_append (osched->runqueue, group); } gst_opt_scheduler_schedule_run_queue (osched); #endif - GST_LOG ("done scheduling group %p in chain %p", - group, chain); + GST_LOG ("done scheduling group %p in chain %p", group, chain); unref_group (group); break; } @@ -1085,14 +1114,15 @@ get_group_schedule_function (int argc, char *argv[]) while (pads) { GstData *data; GstPad *pad = GST_PAD (pads->data); + pads = g_list_next (pads); /* skip sinks and ghostpads */ if (!GST_PAD_IS_SRC (pad) || !GST_IS_REAL_PAD (pad)) continue; - GST_DEBUG ("doing get and push on pad \"%s:%s\" in group %p", - GST_DEBUG_PAD_NAME (pad), group); + GST_DEBUG ("doing get and push on pad \"%s:%s\" in group %p", + GST_DEBUG_PAD_NAME (pad), group); data = GST_RPAD_GETFUNC (pad) (pad); if (data) { @@ -1123,13 +1153,13 @@ loop_group_schedule_function (int argc, char *argv[]) group->flags |= GST_OPT_SCHEDULER_GROUP_RUNNING; - GST_DEBUG ("calling loopfunc of element %s in group %p", - GST_ELEMENT_NAME (entry), group); + GST_DEBUG ("calling loopfunc of element %s in group %p", + GST_ELEMENT_NAME (entry), group); entry->loopfunc (entry); - GST_LOG ("loopfunc ended of element %s in group %p", - GST_ELEMENT_NAME (entry), group); + GST_LOG ("loopfunc ended of element %s in group %p", + GST_ELEMENT_NAME (entry), group); group->flags &= ~GST_OPT_SCHEDULER_GROUP_RUNNING; @@ -1143,7 +1173,8 @@ unknown_group_schedule_function (int argc, char *argv[]) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) argv; - g_warning ("(internal error) unknown group type %d, disabling\n", group->type); + g_warning ("(internal error) unknown group type %d, disabling\n", + group->type); group_error_handler (group); return 0; @@ -1153,7 +1184,7 @@ unknown_group_schedule_function (int argc, char *argv[]) * link performs a push to the loop element. We then schedule the * group with the loop-based element until the bufpen is empty */ static void -gst_opt_scheduler_loop_wrapper (GstPad *sinkpad, GstData *data) +gst_opt_scheduler_loop_wrapper (GstPad * sinkpad, GstData * data) { GstOptSchedulerGroup *group; GstOptScheduler *osched; @@ -1169,49 +1200,47 @@ gst_opt_scheduler_loop_wrapper (GstPad *sinkpad, GstData *data) if (GST_PAD_BUFLIST (peer)) { g_warning ("deadlock detected, disabling group %p", group); group_error_handler (group); - } - else { + } else { GST_LOG ("queueing data %p on %s:%s's bufpen", data, - GST_DEBUG_PAD_NAME (peer)); + GST_DEBUG_PAD_NAME (peer)); GST_PAD_BUFLIST (peer) = g_list_append (GST_PAD_BUFLIST (peer), data); schedule_group (group); } #else GST_LOG ("queueing data %p on %s:%s's bufpen", data, - GST_DEBUG_PAD_NAME (peer)); + GST_DEBUG_PAD_NAME (peer)); GST_PAD_BUFLIST (peer) = g_list_append (GST_PAD_BUFLIST (peer), data); if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { GST_LOG ("adding group %p to runqueue", group); - if (!g_list_find (osched->runqueue, group)) - { + if (!g_list_find (osched->runqueue, group)) { ref_group (group); osched->runqueue = g_list_append (osched->runqueue, group); } } #endif - + GST_LOG ("%d buffers left on %s:%s's bufpen after chain handler", - g_list_length (GST_PAD_BUFLIST (peer))); + g_list_length (GST_PAD_BUFLIST (peer))); } /* this function is called by a loop based element that performs a * pull on a sinkpad. We schedule the peer group until the bufpen * is filled with the buffer so that this function can return */ -static GstData* -gst_opt_scheduler_get_wrapper (GstPad *srcpad) +static GstData * +gst_opt_scheduler_get_wrapper (GstPad * srcpad) { GstData *data; GstOptSchedulerGroup *group; GstOptScheduler *osched; gboolean disabled; - + GST_LOG ("get handler for %" GST_PTR_FORMAT, srcpad); /* first try to grab a queued buffer */ if (GST_PAD_BUFLIST (srcpad)) { data = GST_PAD_BUFLIST (srcpad)->data; GST_PAD_BUFLIST (srcpad) = g_list_remove (GST_PAD_BUFLIST (srcpad), data); - + GST_LOG ("returning popped queued data %p", data); return data; @@ -1231,10 +1260,9 @@ gst_opt_scheduler_get_wrapper (GstPad *srcpad) if (!(group->flags & GST_OPT_SCHEDULER_GROUP_RUNNING)) { ref_group (group); - if (!g_list_find (osched->runqueue, group)) - { - ref_group (group); - osched->runqueue = g_list_append (osched->runqueue, group); + if (!g_list_find (osched->runqueue, group)) { + ref_group (group); + osched->runqueue = g_list_append (osched->runqueue, group); } GST_LOG ("recursing into scheduler group %p", group); @@ -1249,8 +1277,7 @@ gst_opt_scheduler_get_wrapper (GstPad *srcpad) /* if the group was gone we also might have to break out of the loop */ disabled = TRUE; } - } - else { + } else { /* in this case, the group was running and we wanted to swtich to it, * this is not allowed in the optimal scheduler (yet) */ g_warning ("deadlock detected, disabling group %p", group); @@ -1263,22 +1290,21 @@ gst_opt_scheduler_get_wrapper (GstPad *srcpad) if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) { GST_INFO ("scheduler interrupted, return interrupt event"); data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); - } - else { + } else { if (GST_PAD_BUFLIST (srcpad)) { - data = GST_PAD_BUFLIST (srcpad)->data; - GST_PAD_BUFLIST (srcpad) = g_list_remove (GST_PAD_BUFLIST (srcpad), data); - } - else if (disabled) { - /* no buffer in queue and peer group was disabled */ - data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + data = GST_PAD_BUFLIST (srcpad)->data; + GST_PAD_BUFLIST (srcpad) = + g_list_remove (GST_PAD_BUFLIST (srcpad), data); + } else if (disabled) { + /* no buffer in queue and peer group was disabled */ + data = GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); } } } while (data == NULL); GST_LOG ("get handler, returning data %p, queue length %d", - data, g_list_length (GST_PAD_BUFLIST (srcpad))); + data, g_list_length (GST_PAD_BUFLIST (srcpad))); return data; } @@ -1286,24 +1312,23 @@ gst_opt_scheduler_get_wrapper (GstPad *srcpad) /* this function is a chain wrapper for non-event-aware plugins, * it'll simply dispatch the events to the (default) event handler */ static void -gst_opt_scheduler_chain_wrapper (GstPad *sinkpad, GstData *data) +gst_opt_scheduler_chain_wrapper (GstPad * sinkpad, GstData * data) { if (GST_IS_EVENT (data)) { gst_pad_send_event (sinkpad, GST_EVENT (data)); - } - else { + } else { GST_RPAD_CHAINFUNC (sinkpad) (sinkpad, data); } } static void -clear_queued (GstData *data, gpointer user_data) +clear_queued (GstData * data, gpointer user_data) { gst_data_unref (data); } static void -pad_clear_queued (GstPad *srcpad, gpointer user_data) +pad_clear_queued (GstPad * srcpad, gpointer user_data) { GList *buflist = GST_PAD_BUFLIST (srcpad); @@ -1316,13 +1341,13 @@ pad_clear_queued (GstPad *srcpad, gpointer user_data) } static gboolean -gst_opt_scheduler_event_wrapper (GstPad *srcpad, GstEvent *event) +gst_opt_scheduler_event_wrapper (GstPad * srcpad, GstEvent * event) { gboolean flush; - GST_DEBUG ("intercepting event %d on pad %s:%s", - GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad)); - + GST_DEBUG ("intercepting event %d on pad %s:%s", + GST_EVENT_TYPE (event), GST_DEBUG_PAD_NAME (srcpad)); + /* figure out if this is a flush event */ switch (GST_EVENT_TYPE (event)) { case GST_EVENT_FLUSH: @@ -1346,12 +1371,14 @@ gst_opt_scheduler_event_wrapper (GstPad *srcpad, GstEvent *event) } static GstElementStateReturn -gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gint transition) +gst_opt_scheduler_state_transition (GstScheduler * sched, GstElement * element, + gint transition) { GstOptSchedulerGroup *group; GstElementStateReturn res = GST_STATE_SUCCESS; - - GST_DEBUG ("element \"%s\" state change %d", GST_ELEMENT_NAME (element), transition); + + GST_DEBUG ("element \"%s\" state change %d", GST_ELEMENT_NAME (element), + transition); /* we check the state of the managing pipeline here */ if (GST_IS_BIN (element)) { @@ -1359,16 +1386,16 @@ gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gi GST_LOG ("parent \"%s\" changed state", GST_ELEMENT_NAME (element)); switch (transition) { - case GST_STATE_PLAYING_TO_PAUSED: - GST_INFO ("setting scheduler state to stopped"); - GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_STOPPED; - break; - case GST_STATE_PAUSED_TO_PLAYING: - GST_INFO ("setting scheduler state to running"); - GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_RUNNING; + case GST_STATE_PLAYING_TO_PAUSED: + GST_INFO ("setting scheduler state to stopped"); + GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_STOPPED; break; - default: - GST_LOG ("no interesting state change, doing nothing"); + case GST_STATE_PAUSED_TO_PLAYING: + GST_INFO ("setting scheduler state to running"); + GST_SCHEDULER_STATE (sched) = GST_SCHEDULER_STATE_RUNNING; + break; + default: + GST_LOG ("no interesting state change, doing nothing"); } } return res; @@ -1386,21 +1413,21 @@ gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gi /* an element withut a group has to be an unlinked src, sink * filter element */ if (!group) { - GST_INFO ("element \"%s\" has no group", GST_ELEMENT_NAME (element)); + GST_INFO ("element \"%s\" has no group", GST_ELEMENT_NAME (element)); res = GST_STATE_FAILURE; } /* else construct the scheduling context of this group and enable it */ else { - group_element_set_enabled (group, element, TRUE); + group_element_set_enabled (group, element, TRUE); } break; case GST_STATE_PLAYING_TO_PAUSED: /* if the element still has a group, we disable it */ - if (group) - group_element_set_enabled (group, element, FALSE); + if (group) + group_element_set_enabled (group, element, FALSE); break; case GST_STATE_PAUSED_TO_READY: - { + { GList *pads = (GList *) gst_element_get_pad_list (element); g_list_foreach (pads, (GFunc) pad_clear_queued, NULL); @@ -1414,19 +1441,20 @@ gst_opt_scheduler_state_transition (GstScheduler *sched, GstElement *element, gi } static void -gst_opt_scheduler_scheduling_change (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_scheduling_change (GstScheduler * sched, GstElement * element) { g_warning ("scheduling change, implement me"); } static void -get_group (GstElement *element, GstOptSchedulerGroup **group) +get_group (GstElement * element, GstOptSchedulerGroup ** group) { GstOptSchedulerCtx *ctx; - /*GList *pads;*/ + + /*GList *pads; */ ctx = GST_ELEMENT_SCHED_CONTEXT (element); - if (ctx) + if (ctx) *group = ctx->group; else *group = NULL; @@ -1441,22 +1469,22 @@ get_group (GstElement *element, GstOptSchedulerGroup **group) * - if both of the elements have a group, we merge the groups, which * will also merge the chains. */ -static GstOptSchedulerGroup* -group_elements (GstOptScheduler *osched, GstElement *element1, GstElement *element2, - GstOptSchedulerGroupType type) +static GstOptSchedulerGroup * +group_elements (GstOptScheduler * osched, GstElement * element1, + GstElement * element2, GstOptSchedulerGroupType type) { GstOptSchedulerGroup *group1, *group2, *group = NULL; - + get_group (element1, &group1); get_group (element2, &group2); - + /* none of the elements is added to a group, create a new group * and chain to add the elements to */ if (!group1 && !group2) { GstOptSchedulerChain *chain; - GST_DEBUG ("creating new group to hold \"%s\" and \"%s\"", - GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2)); + GST_DEBUG ("creating new group to hold \"%s\" and \"%s\"", + GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2)); chain = create_chain (osched); group = create_group (chain, element1, type); @@ -1464,8 +1492,8 @@ group_elements (GstOptScheduler *osched, GstElement *element1, GstElement *eleme } /* the first element has a group */ else if (group1) { - GST_DEBUG ("adding \"%s\" to \"%s\"'s group", - GST_ELEMENT_NAME (element2), GST_ELEMENT_NAME (element1)); + GST_DEBUG ("adding \"%s\" to \"%s\"'s group", + GST_ELEMENT_NAME (element2), GST_ELEMENT_NAME (element1)); /* the second element also has a group, merge */ if (group2) @@ -1480,8 +1508,8 @@ group_elements (GstOptScheduler *osched, GstElement *element1, GstElement *eleme /* element1 has no group, element2 does. Add element1 to the * group of element2 */ else { - GST_DEBUG ("adding \"%s\" to \"%s\"'s group", - GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2)); + GST_DEBUG ("adding \"%s\" to \"%s\"'s group", + GST_ELEMENT_NAME (element1), GST_ELEMENT_NAME (element2)); add_to_group (group2, element1); group = group2; } @@ -1492,7 +1520,7 @@ group_elements (GstOptScheduler *osched, GstElement *element1, GstElement *eleme * increment link counts between groups */ static void -group_inc_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) +group_inc_link (GstOptSchedulerGroup * group1, GstOptSchedulerGroup * group2) { GSList *links = group1->group_links; gboolean done = FALSE; @@ -1502,12 +1530,12 @@ group_inc_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) while (links && !done) { link = (GstOptSchedulerGroupLink *) links->data; links = g_slist_next (links); - + if (IS_GROUP_LINK (link, group1, group2)) { /* we found a link to this group, increment the link count */ link->count++; - GST_LOG ("incremented group link count between %p and %p to %d", - group1, group2, link->count); + GST_LOG ("incremented group link count between %p and %p to %d", + group1, group2, link->count); done = TRUE; } } @@ -1522,8 +1550,7 @@ group_inc_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) group1->group_links = g_slist_prepend (group1->group_links, link); group2->group_links = g_slist_prepend (group2->group_links, link); - GST_DEBUG ("added group link between %p and %p", - group1, group2); + GST_DEBUG ("added group link between %p and %p", group1, group2); } } @@ -1531,7 +1558,7 @@ group_inc_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) * decrement link counts between groups, returns TRUE if the link count reaches 0 */ static gboolean -group_dec_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) +group_dec_link (GstOptSchedulerGroup * group1, GstOptSchedulerGroup * group2) { GSList *links = group1->group_links; gboolean res = FALSE; @@ -1540,17 +1567,16 @@ group_dec_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) while (links) { link = (GstOptSchedulerGroupLink *) links->data; links = g_slist_next (links); - + if (IS_GROUP_LINK (link, group1, group2)) { link->count--; - GST_LOG ("link count between %p and %p is now %d", - group1, group2, link->count); + GST_LOG ("link count between %p and %p is now %d", + group1, group2, link->count); if (link->count == 0) { group1->group_links = g_slist_remove (group1->group_links, link); group2->group_links = g_slist_remove (group2->group_links, link); g_free (link); - GST_DEBUG ("removed group link between %p and %p", - group1, group2); + GST_DEBUG ("removed group link between %p and %p", group1, group2); res = TRUE; } break; @@ -1560,7 +1586,8 @@ group_dec_link (GstOptSchedulerGroup *group1, GstOptSchedulerGroup *group2) } -typedef enum { +typedef enum +{ GST_OPT_INVALID, GST_OPT_GET_TO_CHAIN, GST_OPT_LOOP_TO_CHAIN, @@ -1574,22 +1601,22 @@ typedef enum { * Entry points for this scheduler. */ static void -gst_opt_scheduler_setup (GstScheduler *sched) -{ +gst_opt_scheduler_setup (GstScheduler * sched) +{ #ifdef USE_COTHREADS GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); - + /* first create thread context */ if (osched->context == NULL) { GST_DEBUG ("initializing cothread context"); osched->context = do_cothread_context_init (); } #endif -} - -static void -gst_opt_scheduler_reset (GstScheduler *sched) -{ +} + +static void +gst_opt_scheduler_reset (GstScheduler * sched) +{ #ifdef USE_COTHREADS GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); GSList *chains = osched->chains; @@ -1606,19 +1633,19 @@ gst_opt_scheduler_reset (GstScheduler *sched) } chains = chains->next; } - + if (osched->context) { do_cothread_context_destroy (osched->context); - osched->context = NULL; + osched->context = NULL; } #endif -} +} static void -gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_add_element (GstScheduler * sched, GstElement * element) { GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); GstOptSchedulerCtx *ctx; - const GList *pads; + const GList *pads; GST_DEBUG_OBJECT (sched, "adding element \"%s\"", GST_OBJECT_NAME (element)); @@ -1637,9 +1664,11 @@ gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element) pads = gst_element_get_pad_list (element); while (pads) { GstPad *pad = GST_PAD (pads->data); + pads = g_list_next (pads); - if (!GST_IS_REAL_PAD (pad)) continue; + if (!GST_IS_REAL_PAD (pad)) + continue; GST_RPAD_EVENTHANDLER (pad) = GST_RPAD_EVENTFUNC (pad); } @@ -1654,16 +1683,18 @@ gst_opt_scheduler_add_element (GstScheduler *sched, GstElement *element) group = create_group (chain, element, GST_OPT_SCHEDULER_GROUP_LOOP); group->entry = element; - GST_LOG ("added element \"%s\" as loop based entry", GST_ELEMENT_NAME (element)); + GST_LOG ("added element \"%s\" as loop based entry", + GST_ELEMENT_NAME (element)); } } static void -gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_remove_element (GstScheduler * sched, GstElement * element) { GstOptSchedulerGroup *group; - GST_DEBUG_OBJECT (sched, "removing element \"%s\"", GST_OBJECT_NAME (element)); + GST_DEBUG_OBJECT (sched, "removing element \"%s\"", + GST_OBJECT_NAME (element)); /* decoupled elements are not added to the scheduler lists and should therefore * no be removed */ @@ -1681,51 +1712,53 @@ gst_opt_scheduler_remove_element (GstScheduler *sched, GstElement *element) } static void -gst_opt_scheduler_lock_element (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_lock_element (GstScheduler * sched, GstElement * element) { //GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); g_warning ("lock element, implement me"); } static void -gst_opt_scheduler_unlock_element (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_unlock_element (GstScheduler * sched, GstElement * element) { //GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); g_warning ("unlock element, implement me"); } static gboolean -gst_opt_scheduler_yield (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_yield (GstScheduler * sched, GstElement * element) { #ifdef USE_COTHREADS /* yield hands control to the main cothread context if the requesting * element is the entry point of the group */ GstOptSchedulerGroup *group; + get_group (element, &group); if (group && group->entry == element) - do_cothread_switch (do_cothread_get_main (((GstOptScheduler*)sched)->context)); + do_cothread_switch (do_cothread_get_main (((GstOptScheduler *) sched)-> + context)); return FALSE; #else - g_warning ("element %s performs a yield, please fix the element", - GST_ELEMENT_NAME (element)); + g_warning ("element %s performs a yield, please fix the element", + GST_ELEMENT_NAME (element)); return TRUE; #endif } static gboolean -gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_interrupt (GstScheduler * sched, GstElement * element) { - GST_INFO ("interrupt from \"%s\"", - GST_OBJECT_NAME (element)); + GST_INFO ("interrupt from \"%s\"", GST_OBJECT_NAME (element)); #ifdef USE_COTHREADS - do_cothread_switch (do_cothread_get_main (((GstOptScheduler*)sched)->context)); + do_cothread_switch (do_cothread_get_main (((GstOptScheduler *) sched)-> + context)); return FALSE; #else { GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); - + GST_INFO ("scheduler set interrupted state"); osched->state = GST_OPT_SCHEDULER_STATE_INTERRUPTED; } @@ -1734,10 +1767,11 @@ gst_opt_scheduler_interrupt (GstScheduler *sched, GstElement *element) } static void -gst_opt_scheduler_error (GstScheduler *sched, GstElement *element) +gst_opt_scheduler_error (GstScheduler * sched, GstElement * element) { GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); GstOptSchedulerGroup *group; + get_group (element, &group); if (group) group_error_handler (group); @@ -1747,14 +1781,15 @@ gst_opt_scheduler_error (GstScheduler *sched, GstElement *element) /* link pads, merge groups and chains */ static void -gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) +gst_opt_scheduler_pad_link (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad) { GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); LinkType type = GST_OPT_INVALID; GstElement *element1, *element2; - GST_INFO ("scheduling link between %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_INFO ("scheduling link between %s:%s and %s:%s", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); element1 = GST_PAD_PARENT (srcpad); element2 = GST_PAD_PARENT (sinkpad); @@ -1766,58 +1801,54 @@ gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad else { if (element1->loopfunc) { if (GST_RPAD_CHAINFUNC (sinkpad)) - type = GST_OPT_LOOP_TO_CHAIN; - } - else if (element2->loopfunc) { + type = GST_OPT_LOOP_TO_CHAIN; + } else if (element2->loopfunc) { if (GST_RPAD_GETFUNC (srcpad)) { - type = GST_OPT_GET_TO_LOOP; + type = GST_OPT_GET_TO_LOOP; /* this could be tricky, the get based source could * already be part of a loop based group in another pad, * we assert on that for now */ if (GST_ELEMENT_SCHED_CONTEXT (element1) != NULL && - GST_ELEMENT_SCHED_GROUP (element1) != NULL) - { - GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1); + GST_ELEMENT_SCHED_GROUP (element1) != NULL) { + GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1); /* if the loop based element is the entry point we're ok, if it * isn't then we have multiple loop based elements in this group */ if (group->entry != element2) { - g_error ("internal error: cannot schedule get to loop in multi-loop based group"); + g_error + ("internal error: cannot schedule get to loop in multi-loop based group"); return; } } - } - else - type = GST_OPT_CHAIN_TO_LOOP; - } - else { + } else + type = GST_OPT_CHAIN_TO_LOOP; + } else { if (GST_RPAD_GETFUNC (srcpad) && GST_RPAD_CHAINFUNC (sinkpad)) { - type = GST_OPT_GET_TO_CHAIN; + type = GST_OPT_GET_TO_CHAIN; /* the get based source could already be part of a loop * based group in another pad, we assert on that for now */ if (GST_ELEMENT_SCHED_CONTEXT (element1) != NULL && - GST_ELEMENT_SCHED_GROUP (element1) != NULL) - { - GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1); + GST_ELEMENT_SCHED_GROUP (element1) != NULL) { + GstOptSchedulerGroup *group = GST_ELEMENT_SCHED_GROUP (element1); /* if the get based element is the entry point we're ok, if it * isn't then we have a mixed loop/chain based group */ if (group->entry != element1) { - g_error ("internal error: cannot schedule get to chain with mixed loop/chain based group"); + g_error + ("internal error: cannot schedule get to chain with mixed loop/chain based group"); return; } } - } - else - type = GST_OPT_CHAIN_TO_CHAIN; + } else + type = GST_OPT_CHAIN_TO_CHAIN; } } - + /* since we can't set event handlers on pad creation after addition, it is * best we set all of them again to the default before linking */ GST_RPAD_EVENTHANDLER (srcpad) = GST_RPAD_EVENTFUNC (srcpad); GST_RPAD_EVENTHANDLER (sinkpad) = GST_RPAD_EVENTFUNC (sinkpad); - + /* for each link type, perform specific actions */ switch (type) { case GST_OPT_GET_TO_CHAIN: @@ -1829,22 +1860,22 @@ gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad /* setup get/chain handlers */ GST_RPAD_GETHANDLER (srcpad) = GST_RPAD_GETFUNC (srcpad); if (GST_ELEMENT_IS_EVENT_AWARE (element2)) - GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad); + GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad); else - GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper; + GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper; /* the two elements should be put into the same group, * this also means that they are in the same chain automatically */ group = group_elements (osched, element1, element2, - GST_OPT_SCHEDULER_GROUP_GET); + GST_OPT_SCHEDULER_GROUP_GET); /* if there is not yet an entry in the group, select the source * element as the entry point */ if (!group->entry) { - group->entry = element1; + group->entry = element1; - GST_DEBUG ("setting \"%s\" as entry point of _get-based group %p", - GST_ELEMENT_NAME (element1), group); + GST_DEBUG ("setting \"%s\" as entry point of _get-based group %p", + GST_ELEMENT_NAME (element1), group); } break; } @@ -1853,9 +1884,9 @@ gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad GST_LOG ("loop/chain to chain based link"); if (GST_ELEMENT_IS_EVENT_AWARE (element2)) - GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad); + GST_RPAD_CHAINHANDLER (sinkpad) = GST_RPAD_CHAINFUNC (sinkpad); else - GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper; + GST_RPAD_CHAINHANDLER (sinkpad) = gst_opt_scheduler_chain_wrapper; /* the two elements should be put into the same group, * this also means that they are in the same chain automatically, @@ -1897,14 +1928,15 @@ gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad if (!group1) { /* create a new group for element1 as it cannot be merged into another group * here. we create the group in the same chain as the loop-based element. */ - GST_DEBUG ("creating new group for element %s", GST_ELEMENT_NAME (element1)); - group1 = create_group (group2->chain, element1, - GST_OPT_SCHEDULER_GROUP_LOOP); - } - else { + GST_DEBUG ("creating new group for element %s", + GST_ELEMENT_NAME (element1)); + group1 = + create_group (group2->chain, element1, + GST_OPT_SCHEDULER_GROUP_LOOP); + } else { /* both elements are already in a group, make sure they are added to * the same chain */ - merge_chains (group1->chain, group2->chain); + merge_chains (group1->chain, group2->chain); } group_inc_link (group1, group2); break; @@ -1920,7 +1952,8 @@ gst_opt_scheduler_pad_link (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad * no checking is done on the brokenpad arg */ static gboolean -element_has_link_with_group (GstElement *element, GstOptSchedulerGroup *group, GstPad *brokenpad) +element_has_link_with_group (GstElement * element, GstOptSchedulerGroup * group, + GstPad * brokenpad) { gboolean linked = FALSE; const GList *pads; @@ -1929,6 +1962,7 @@ element_has_link_with_group (GstElement *element, GstOptSchedulerGroup *group, G pads = gst_element_get_pad_list (element); while (pads && !linked) { GstPad *pad = GST_PAD (pads->data); + pads = g_list_next (pads); /* we only operate on real pads and on the pad that is not broken */ @@ -1944,17 +1978,16 @@ element_has_link_with_group (GstElement *element, GstOptSchedulerGroup *group, G /* links with decoupled elements are valid */ if (GST_ELEMENT_IS_DECOUPLED (parent)) { - linked = TRUE; - } - else { + linked = TRUE; + } else { /* for non-decoupled elements we need to check the group */ - get_group (parent, &parentgroup); + get_group (parent, &parentgroup); - /* if it's in the same group, we're still linked */ - if (parentgroup == group) - linked = TRUE; + /* if it's in the same group, we're still linked */ + if (parentgroup == group) + linked = TRUE; } - } + } } return linked; } @@ -1964,13 +1997,13 @@ element_has_link_with_group (GstElement *element, GstOptSchedulerGroup *group, G * group link into account. */ static gboolean -group_can_reach_group (GstOptSchedulerGroup *group, GstOptSchedulerGroup *target) +group_can_reach_group (GstOptSchedulerGroup * group, + GstOptSchedulerGroup * target) { gboolean reachable = FALSE; const GSList *links = group->group_links; - GST_LOG ("checking if group %p can reach %p", - group, target); + GST_LOG ("checking if group %p can reach %p", group, target); /* seems like we found the target element */ if (group == target) { @@ -1979,7 +2012,8 @@ group_can_reach_group (GstOptSchedulerGroup *group, GstOptSchedulerGroup *target } /* if the group is marked as visited, we don't need to check here */ - if (GST_OPT_SCHEDULER_GROUP_IS_FLAG_SET (group, GST_OPT_SCHEDULER_GROUP_VISITED)) { + if (GST_OPT_SCHEDULER_GROUP_IS_FLAG_SET (group, + GST_OPT_SCHEDULER_GROUP_VISITED)) { GST_LOG ("already visited %p", group); return FALSE; } @@ -1996,8 +2030,7 @@ group_can_reach_group (GstOptSchedulerGroup *group, GstOptSchedulerGroup *target /* find other group in this link */ other = OTHER_GROUP_LINK (link, group); - GST_LOG ("found link from %p to %p, count %d", - group, other, link->count); + GST_LOG ("found link from %p to %p, count %d", group, other, link->count); /* check if we can reach the target recursiveley */ reachable = group_can_reach_group (other, target); @@ -2008,20 +2041,20 @@ group_can_reach_group (GstOptSchedulerGroup *group, GstOptSchedulerGroup *target * all groups are checked. */ GST_OPT_SCHEDULER_GROUP_UNSET_FLAG (group, GST_OPT_SCHEDULER_GROUP_VISITED); - GST_LOG ("leaving group %p with %s", group, (reachable ? "TRUE":"FALSE")); + GST_LOG ("leaving group %p with %s", group, (reachable ? "TRUE" : "FALSE")); return reachable; } static void -group_dec_links_for_element (GstOptSchedulerGroup* group, GstElement *element) +group_dec_links_for_element (GstOptSchedulerGroup * group, GstElement * element) { GList *l; GstPad *pad; GstOptSchedulerGroup *peer_group; - - for (l=GST_ELEMENT_PADS(element); l; l=l->next) { - pad = (GstPad*)l->data; + + for (l = GST_ELEMENT_PADS (element); l; l = l->next) { + pad = (GstPad *) l->data; if (GST_IS_REAL_PAD (pad) && GST_PAD_PEER (pad)) { get_group (GST_PAD_PARENT (GST_PAD_PEER (pad)), &peer_group); if (peer_group && peer_group != group) @@ -2031,18 +2064,19 @@ group_dec_links_for_element (GstOptSchedulerGroup* group, GstElement *element) } static void -gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkpad) +gst_opt_scheduler_pad_unlink (GstScheduler * sched, GstPad * srcpad, + GstPad * sinkpad) { GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); GstElement *element1, *element2; GstOptSchedulerGroup *group1, *group2; - GST_INFO ("unscheduling link between %s:%s and %s:%s", - GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); + GST_INFO ("unscheduling link between %s:%s and %s:%s", + GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad)); element1 = GST_PAD_PARENT (srcpad); element2 = GST_PAD_PARENT (sinkpad); - + get_group (element1, &group1); get_group (element2, &group2); @@ -2058,7 +2092,8 @@ gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkp /* if one the elements has no group (anymore) we don't really care * about the link */ if (!group1 || !group2) { - GST_LOG ("one (or both) of the elements is not in a group, not interesting"); + GST_LOG + ("one (or both) of the elements is not in a group, not interesting"); return; } @@ -2080,25 +2115,26 @@ gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkp /* see if group1 and group2 are still connected in any indirect way */ still_link = group_can_reach_group (group1, group2); - GST_DEBUG ("group %p %s reach group %p", group1, (still_link ? "can":"can't"), group2); + GST_DEBUG ("group %p %s reach group %p", group1, + (still_link ? "can" : "can't"), group2); if (!still_link) { /* groups are really disconnected, migrate one group to a new chain */ - chain = create_chain (osched); - chain_recursively_migrate_group (chain, group1); + chain = create_chain (osched); + chain_recursively_migrate_group (chain, group1); - GST_DEBUG ("migrated group %p to new chain %p", group1, chain); + GST_DEBUG ("migrated group %p to new chain %p", group1, chain); } - } - else { - GST_DEBUG ("group %p still has direct link with group %p", group1, group2); + } else { + GST_DEBUG ("group %p still has direct link with group %p", group1, + group2); } } /* hard part, groups are equal */ else { gboolean still_link1, still_link2; GstOptSchedulerGroup *group; - GstElement *element = NULL; /* shut up gcc */ - + GstElement *element = NULL; /* shut up gcc */ + /* since group1 == group2, it doesn't matter which group we take */ group = group1; @@ -2117,15 +2153,15 @@ gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkp GSList *l; GList *m;; int linkcount; - - GST_LOG ( "elements still have links with other elements in the group"); - + + GST_LOG ("elements still have links with other elements in the group"); + while (group->elements) - for (l = group->elements; l && l->data; l = l->next) { - element = (GstElement*)l->data; + for (l = group->elements; l && l->data; l = l->next) { + element = (GstElement *) l->data; if (GST_ELEMENT_IS_DECOUPLED (element)) continue; - + linkcount = 0; GST_LOG ("Examining %s\n", GST_ELEMENT_NAME (element)); for (m = GST_ELEMENT_PADS (element); m; m = m->next) { @@ -2133,78 +2169,76 @@ gst_opt_scheduler_pad_unlink (GstScheduler *sched, GstPad *srcpad, GstPad *sinkp GstElement *parent; GstOptSchedulerGroup *peer_group; - pad = (GstPad*)m->data; + pad = (GstPad *) m->data; if (!pad || !GST_IS_REAL_PAD (pad)) continue; peer = GST_PAD_PEER (pad); if (!peer || !GST_IS_REAL_PAD (peer)) continue; - + parent = GST_PAD_PARENT (GST_PAD_PEER (pad)); get_group (parent, &peer_group); if (peer_group && peer_group != group) { GST_LOG ("pad %s is linked with %s\n", - GST_PAD_NAME (pad), - GST_ELEMENT_NAME (parent)); + GST_PAD_NAME (pad), GST_ELEMENT_NAME (parent)); linkcount++; } } if (linkcount < 2) { - group_dec_links_for_element (group, element); + group_dec_links_for_element (group, element); remove_from_group (group, element); } /* if linkcount == 2, it will be unlinked later on */ else if (linkcount > 2) { - g_warning ("opt: Can't handle element %s with 3 or more links, aborting", - GST_ELEMENT_NAME (element)); + g_warning + ("opt: Can't handle element %s with 3 or more links, aborting", + GST_ELEMENT_NAME (element)); return; } - } + } /* Peer element will be catched during next iteration */ return; } if (!still_link1 && !still_link2) return; - + /* now check which one of the elements we can remove from the group */ if (still_link1) { element = element2; - } - else if (still_link2) { + } else if (still_link2) { element = element1; } /* we only remove elements that are not the entry point of a loop based * group and are not decoupled */ if (!(group->entry == element && - group->type == GST_OPT_SCHEDULER_GROUP_LOOP) && - !GST_ELEMENT_IS_DECOUPLED (element)) { + group->type == GST_OPT_SCHEDULER_GROUP_LOOP) && + !GST_ELEMENT_IS_DECOUPLED (element)) { GST_LOG ("element is separated from the group"); - + /* have to decrement links to other groups from other pads */ - group_dec_links_for_element (group, element); + group_dec_links_for_element (group, element); remove_from_group (group, element); - } - else { + } else { GST_LOG ("element is decoupled or entry in loop based group"); } } } static void -gst_opt_scheduler_pad_select (GstScheduler *sched, GList *padlist) +gst_opt_scheduler_pad_select (GstScheduler * sched, GList * padlist) { //GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); - + g_warning ("pad select, implement me"); } /* a scheduler iteration is done by looping and scheduling the active chains */ static GstSchedulerState -gst_opt_scheduler_iterate (GstScheduler *sched) +gst_opt_scheduler_iterate (GstScheduler * sched) { GstSchedulerState state = GST_SCHEDULER_STATE_STOPPED; GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); @@ -2226,19 +2260,18 @@ gst_opt_scheduler_iterate (GstScheduler *sched) ref_chain (chain); /* if the chain is not disabled, schedule it */ if (!GST_OPT_SCHEDULER_CHAIN_IS_DISABLED (chain)) { - GST_LOG ("scheduling chain %p", chain); - schedule_chain (chain); - scheduled = TRUE; + GST_LOG ("scheduling chain %p", chain); + schedule_chain (chain); + scheduled = TRUE; } /* don't schedule any more chains when in error */ if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) { - GST_ERROR_OBJECT (sched, "in error state"); - break; - } - else if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) { - GST_DEBUG_OBJECT (osched, "got interrupted, continue with next chain"); - osched->state = GST_OPT_SCHEDULER_STATE_RUNNING; + GST_ERROR_OBJECT (sched, "in error state"); + break; + } else if (osched->state == GST_OPT_SCHEDULER_STATE_INTERRUPTED) { + GST_DEBUG_OBJECT (osched, "got interrupted, continue with next chain"); + osched->state = GST_OPT_SCHEDULER_STATE_RUNNING; } chains = g_slist_next (chains); @@ -2250,15 +2283,14 @@ gst_opt_scheduler_iterate (GstScheduler *sched) if (osched->state == GST_OPT_SCHEDULER_STATE_ERROR) { state = GST_SCHEDULER_STATE_ERROR; break; - } - else { + } else { /* if chains were scheduled, return our current state */ if (scheduled) - state = GST_SCHEDULER_STATE (sched); + state = GST_SCHEDULER_STATE (sched); /* if no chains were scheduled, we say we are stopped */ else { - state = GST_SCHEDULER_STATE_STOPPED; - break; + state = GST_SCHEDULER_STATE_STOPPED; + break; } } if (iterations > 0) @@ -2270,7 +2302,7 @@ gst_opt_scheduler_iterate (GstScheduler *sched) static void -gst_opt_scheduler_show (GstScheduler *sched) +gst_opt_scheduler_show (GstScheduler * sched) { GstOptScheduler *osched = GST_OPT_SCHEDULER (sched); GSList *chains; @@ -2282,37 +2314,44 @@ gst_opt_scheduler_show (GstScheduler *sched) while (chains) { GstOptSchedulerChain *chain = (GstOptSchedulerChain *) chains->data; GSList *groups = chain->groups; + chains = g_slist_next (chains); - g_print ("+- chain %p: refcount %d, %d groups, %d enabled, flags %d\n", - chain, chain->refcount, chain->num_groups, chain->num_enabled, chain->flags); + g_print ("+- chain %p: refcount %d, %d groups, %d enabled, flags %d\n", + chain, chain->refcount, chain->num_groups, chain->num_enabled, + chain->flags); while (groups) { GstOptSchedulerGroup *group = (GstOptSchedulerGroup *) groups->data; GSList *elements = group->elements; + groups = g_slist_next (groups); - g_print (" +- group %p: refcount %d, %d elements, %d enabled, flags %d, entry %s, %s\n", - group, group->refcount, group->num_elements, group->num_enabled, group->flags, - (group->entry ? GST_ELEMENT_NAME (group->entry): "(none)"), - (group->type == GST_OPT_SCHEDULER_GROUP_GET ? "get-based" : "loop-based") ); + g_print + (" +- group %p: refcount %d, %d elements, %d enabled, flags %d, entry %s, %s\n", + group, group->refcount, group->num_elements, group->num_enabled, + group->flags, + (group->entry ? GST_ELEMENT_NAME (group->entry) : "(none)"), + (group->type == + GST_OPT_SCHEDULER_GROUP_GET ? "get-based" : "loop-based")); while (elements) { - GstElement *element = (GstElement *) elements->data; - elements = g_slist_next (elements); + GstElement *element = (GstElement *) elements->data; - g_print (" +- element %s\n", GST_ELEMENT_NAME (element)); + elements = g_slist_next (elements); + + g_print (" +- element %s\n", GST_ELEMENT_NAME (element)); } } } } static void -gst_opt_scheduler_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +gst_opt_scheduler_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstOptScheduler *osched; - + g_return_if_fail (GST_IS_OPT_SCHEDULER (object)); osched = GST_OPT_SCHEDULER (object); @@ -2331,11 +2370,11 @@ gst_opt_scheduler_get_property (GObject *object, guint prop_id, } static void -gst_opt_scheduler_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_opt_scheduler_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstOptScheduler *osched; - + g_return_if_fail (GST_IS_OPT_SCHEDULER (object)); osched = GST_OPT_SCHEDULER (object); diff --git a/gst/schedulers/gthread-cothreads.h b/gst/schedulers/gthread-cothreads.h index 32b721ed6..483bad186 100644 --- a/gst/schedulers/gthread-cothreads.h +++ b/gst/schedulers/gthread-cothreads.h @@ -40,55 +40,54 @@ typedef int (*cothread_func) (int, char **); typedef struct _cothread cothread; typedef struct _cothread_context cothread_context; -struct _cothread_context { - GSList * cothreads; /* contains all threads but main */ - cothread * main; - cothread * current; - GMutex * mutex; - GstThread * gst_thread; /* the GstThread we're running from */ +struct _cothread_context +{ + GSList *cothreads; /* contains all threads but main */ + cothread *main; + cothread *current; + GMutex *mutex; + GstThread *gst_thread; /* the GstThread we're running from */ }; -struct _cothread { - GThread * thread; - GCond * cond; - cothread_func run; - int argc; - char ** argv; - cothread * creator; - gboolean die; - cothread_context * context; +struct _cothread +{ + GThread *thread; + GCond *cond; + cothread_func run; + int argc; + char **argv; + cothread *creator; + gboolean die; + cothread_context *context; }; /* define functions * Functions starting with "do_" are used by the scheduler. */ -static void do_cothreads_init (void *unused); -static cothread_context *do_cothread_context_init (void); -static void do_cothread_context_destroy (cothread_context *context); -static cothread * cothread_create (cothread_context *context, - cothread_func func, - int argc, - char **argv); +static void do_cothreads_init (void *unused); +static cothread_context *do_cothread_context_init (void); +static void do_cothread_context_destroy (cothread_context * context); +static cothread *cothread_create (cothread_context * context, + cothread_func func, int argc, char **argv); #define do_cothread_create(new_cothread, context, func, argc, argv) \ G_STMT_START{ \ new_cothread = cothread_create ((context), (func), argc, (char**) (argv)); \ }G_STMT_END -static void do_cothread_switch (cothread *to); -static void do_cothread_setfunc (cothread *thread, - cothread_context *context, - cothread_func func, - int argc, - char **argv); -static void do_cothread_destroy (cothread *thread); -#define do_cothread_lock(cothread) /* FIXME */ -#define do_cothread_unlock(cothread) /* FIXME */ +static void do_cothread_switch (cothread * to); +static void do_cothread_setfunc (cothread * thread, + cothread_context * context, cothread_func func, int argc, char **argv); +static void do_cothread_destroy (cothread * thread); + +#define do_cothread_lock(cothread) /* FIXME */ +#define do_cothread_unlock(cothread) /* FIXME */ #define do_cothread_get_current(context) ((context)->current) #define do_cothread_get_main(context) ((context)->main) static void do_cothreads_init (void *unused) { - if (!g_thread_supported ()) g_thread_init (NULL); + if (!g_thread_supported ()) + g_thread_init (NULL); } static cothread_context * do_cothread_context_init (void) @@ -103,37 +102,40 @@ do_cothread_context_init (void) ret->mutex = g_mutex_new (); ret->cothreads = NULL; ret->current = ret->main; - ret->gst_thread = gst_thread_get_current(); + ret->gst_thread = gst_thread_get_current (); g_mutex_lock (ret->mutex); - + return ret; } static void -do_cothread_context_destroy (cothread_context *context) +do_cothread_context_destroy (cothread_context * context) { - g_assert (g_thread_self() == context->main->thread); - + g_assert (g_thread_self () == context->main->thread); + while (context->cothreads) { do_cothread_destroy ((cothread *) context->cothreads->data); } g_mutex_unlock (context->mutex); g_mutex_free (context->mutex); - + g_free (context); } static void -die (cothread *to_die) { +die (cothread * to_die) +{ g_cond_free (to_die->cond); - to_die->context->cothreads = g_slist_remove (to_die->context->cothreads, to_die); + to_die->context->cothreads = + g_slist_remove (to_die->context->cothreads, to_die); g_free (to_die); g_thread_exit (to_die); /* don't unlock the mutex here, the thread waiting for us to die is gonna take it */ } + static gpointer run_new_thread (gpointer data) { cothread *self = (cothread *) data; - + g_mutex_lock (self->context->mutex); g_private_set (gst_thread_current, self->context->gst_thread); g_cond_signal (self->creator->cond); @@ -149,10 +151,11 @@ run_new_thread (gpointer data) return NULL; } static cothread * -cothread_create (cothread_context *context, cothread_func func, int argc, char **argv) +cothread_create (cothread_context * context, cothread_func func, int argc, + char **argv) { cothread *ret; - + if ((ret = g_new (cothread, 1)) == NULL) { goto out1; } @@ -162,10 +165,11 @@ cothread_create (cothread_context *context, cothread_func func, int argc, char * ret->argv = argv; ret->creator = do_cothread_get_current (context); ret->die = FALSE; - ret->context = context; - context->cothreads = g_slist_prepend (context->cothreads, ret); + ret->context = context; + context->cothreads = g_slist_prepend (context->cothreads, ret); ret->thread = g_thread_create (run_new_thread, ret, TRUE, NULL); - if (ret->thread == NULL) goto out2; + if (ret->thread == NULL) + goto out2; g_cond_wait (do_cothread_get_current (context)->cond, context->mutex); return ret; @@ -176,10 +180,11 @@ out1: return NULL; } -static void do_cothread_switch (cothread *to) +static void +do_cothread_switch (cothread * to) { - cothread *self = do_cothread_get_current(to->context); - + cothread *self = do_cothread_get_current (to->context); + if (self == to) { g_warning ("trying to switch to the same cothread, not allowed"); } else { @@ -192,21 +197,22 @@ static void do_cothread_switch (cothread *to) } static void -do_cothread_setfunc (cothread *thread, cothread_context *context, - cothread_func func, int argc, char **argv) +do_cothread_setfunc (cothread * thread, cothread_context * context, + cothread_func func, int argc, char **argv) { thread->run = func; thread->argc = argc; thread->argv = argv; } static void -do_cothread_destroy (cothread *thread) +do_cothread_destroy (cothread * thread) { GThread *join; cothread_context *context; + g_return_if_fail (thread != thread->context->main); g_return_if_fail (thread != thread->context->current); - + thread->die = TRUE; join = thread->thread; context = thread->context; @@ -215,9 +221,9 @@ do_cothread_destroy (cothread *thread) g_thread_join (join); /* the mutex was locked by the thread that we joined, no need to lock again */ } - -#define do_cothread_lock(cothread) /* FIXME */ -#define do_cothread_unlock(cothread) /* FIXME */ + +#define do_cothread_lock(cothread) /* FIXME */ +#define do_cothread_unlock(cothread) /* FIXME */ #define do_cothread_get_current(context) ((context)->current) #define do_cothread_get_main(context) ((context)->main) diff --git a/include/mmx.h b/include/mmx.h index 2b8aff8e7..0c4a52ec0 100644 --- a/include/mmx.h +++ b/include/mmx.h @@ -83,16 +83,17 @@ by LL and unsigned long long values by ULL, lest they be truncated by the compiler) */ -typedef union { - long long q; /* Quadword (64-bit) value */ - unsigned long long uq; /* Unsigned Quadword */ - int d[2]; /* 2 Doubleword (32-bit) values */ - unsigned int ud[2]; /* 2 Unsigned Doubleword */ - short w[4]; /* 4 Word (16-bit) values */ - unsigned short uw[4]; /* 4 Unsigned Word */ - char b[8]; /* 8 Byte (8-bit) values */ - unsigned char ub[8]; /* 8 Unsigned Byte */ - float s[2]; /* Single-precision (32-bit) value */ +typedef union +{ + long long q; /* Quadword (64-bit) value */ + unsigned long long uq; /* Unsigned Quadword */ + int d[2]; /* 2 Doubleword (32-bit) values */ + unsigned int ud[2]; /* 2 Unsigned Doubleword */ + short w[4]; /* 4 Word (16-bit) values */ + unsigned short uw[4]; /* 4 Unsigned Word */ + char b[8]; /* 8 Byte (8-bit) values */ + unsigned char ub[8]; /* 8 Unsigned Byte */ + float s[2]; /* Single-precision (32-bit) value */ } mmx_t; @@ -100,163 +101,107 @@ typedef union { /* Function to test if multimedia instructions are supported... */ inline extern int -mm_support(void) +mm_support (void) { - /* Returns 1 if MMX instructions are supported, - 3 if Cyrix MMX and Extended MMX instructions are supported - 5 if AMD MMX and 3DNow! instructions are supported - 0 if hardware does not support any of these - */ - register int rval = 0; - - __asm__ __volatile__ ( - /* See if CPUID instruction is supported ... */ - /* ... Get copies of EFLAGS into eax and ecx */ - "pushf\n\t" - "popl %%eax\n\t" - "movl %%eax, %%ecx\n\t" - - /* ... Toggle the ID bit in one copy and store */ - /* to the EFLAGS reg */ - "xorl $0x200000, %%eax\n\t" - "push %%eax\n\t" - "popf\n\t" - - /* ... Get the (hopefully modified) EFLAGS */ - "pushf\n\t" - "popl %%eax\n\t" - - /* ... Compare and test result */ - "xorl %%eax, %%ecx\n\t" - "testl $0x200000, %%ecx\n\t" - "jz NotSupported1\n\t" /* Nothing supported */ - - - /* Get standard CPUID information, and - go to a specific vendor section */ - "movl $0, %%eax\n\t" - "cpuid\n\t" - - /* Check for Intel */ - "cmpl $0x756e6547, %%ebx\n\t" - "jne TryAMD\n\t" - "cmpl $0x49656e69, %%edx\n\t" - "jne TryAMD\n\t" - "cmpl $0x6c65746e, %%ecx\n" - "jne TryAMD\n\t" - "jmp Intel\n\t" - - /* Check for AMD */ - "\nTryAMD:\n\t" - "cmpl $0x68747541, %%ebx\n\t" - "jne TryCyrix\n\t" - "cmpl $0x69746e65, %%edx\n\t" - "jne TryCyrix\n\t" - "cmpl $0x444d4163, %%ecx\n" - "jne TryCyrix\n\t" - "jmp AMD\n\t" - - /* Check for Cyrix */ - "\nTryCyrix:\n\t" - "cmpl $0x69727943, %%ebx\n\t" - "jne NotSupported2\n\t" - "cmpl $0x736e4978, %%edx\n\t" - "jne NotSupported3\n\t" - "cmpl $0x64616574, %%ecx\n\t" - "jne NotSupported4\n\t" - /* Drop through to Cyrix... */ - - - /* Cyrix Section */ - /* See if extended CPUID is supported */ - "movl $0x80000000, %%eax\n\t" - "cpuid\n\t" - "cmpl $0x80000000, %%eax\n\t" - "jl MMXtest\n\t" /* Try standard CPUID instead */ - - /* Extended CPUID supported, so get extended features */ - "movl $0x80000001, %%eax\n\t" - "cpuid\n\t" - "testl $0x00800000, %%eax\n\t" /* Test for MMX */ - "jz NotSupported5\n\t" /* MMX not supported */ - "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ - "jnz EMMXSupported\n\t" - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\n" - "EMMXSupported:\n\t" - "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ - "jmp Return\n\t" - - - /* AMD Section */ - "AMD:\n\t" - - /* See if extended CPUID is supported */ - "movl $0x80000000, %%eax\n\t" - "cpuid\n\t" - "cmpl $0x80000000, %%eax\n\t" - "jl MMXtest\n\t" /* Try standard CPUID instead */ - - /* Extended CPUID supported, so get extended features */ - "movl $0x80000001, %%eax\n\t" - "cpuid\n\t" - "testl $0x00800000, %%edx\n\t" /* Test for MMX */ - "jz NotSupported6\n\t" /* MMX not supported */ - "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ - "jnz ThreeDNowSupported\n\t" - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\n" - "ThreeDNowSupported:\n\t" - "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ - "jmp Return\n\t" - - - /* Intel Section */ - "Intel:\n\t" - - /* Check for MMX */ - "MMXtest:\n\t" - "movl $1, %%eax\n\t" - "cpuid\n\t" - "testl $0x00800000, %%edx\n\t" /* Test for MMX */ - "jz NotSupported7\n\t" /* MMX Not supported */ - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\t" - - /* Nothing supported */ - "\nNotSupported1:\n\t" - "#movl $101, %0:\n\n\t" - "\nNotSupported2:\n\t" - "#movl $102, %0:\n\n\t" - "\nNotSupported3:\n\t" - "#movl $103, %0:\n\n\t" - "\nNotSupported4:\n\t" - "#movl $104, %0:\n\n\t" - "\nNotSupported5:\n\t" - "#movl $105, %0:\n\n\t" - "\nNotSupported6:\n\t" - "#movl $106, %0:\n\n\t" - "\nNotSupported7:\n\t" - "#movl $107, %0:\n\n\t" - "movl $0, %0:\n\n\t" - - "Return:\n\t" - : "=a" (rval) - : /* no input */ - : "eax", "ebx", "ecx", "edx" - ); - - /* Return */ - return(rval); + /* Returns 1 if MMX instructions are supported, + 3 if Cyrix MMX and Extended MMX instructions are supported + 5 if AMD MMX and 3DNow! instructions are supported + 0 if hardware does not support any of these + */ + register int rval = 0; + + __asm__ __volatile__ ( + /* See if CPUID instruction is supported ... */ + /* ... Get copies of EFLAGS into eax and ecx */ + "pushf\n\t" "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" + /* ... Toggle the ID bit in one copy and store */ + /* to the EFLAGS reg */ + "xorl $0x200000, %%eax\n\t" "push %%eax\n\t" "popf\n\t" + /* ... Get the (hopefully modified) EFLAGS */ + "pushf\n\t" "popl %%eax\n\t" + /* ... Compare and test result */ + "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* Nothing supported */ + /* Get standard CPUID information, and + go to a specific vendor section */ + "movl $0, %%eax\n\t" "cpuid\n\t" + /* Check for Intel */ + "cmpl $0x756e6547, %%ebx\n\t" + "jne TryAMD\n\t" + "cmpl $0x49656e69, %%edx\n\t" + "jne TryAMD\n\t" + "cmpl $0x6c65746e, %%ecx\n" "jne TryAMD\n\t" "jmp Intel\n\t" + /* Check for AMD */ + "\nTryAMD:\n\t" + "cmpl $0x68747541, %%ebx\n\t" + "jne TryCyrix\n\t" + "cmpl $0x69746e65, %%edx\n\t" + "jne TryCyrix\n\t" + "cmpl $0x444d4163, %%ecx\n" "jne TryCyrix\n\t" "jmp AMD\n\t" + /* Check for Cyrix */ + "\nTryCyrix:\n\t" + "cmpl $0x69727943, %%ebx\n\t" + "jne NotSupported2\n\t" + "cmpl $0x736e4978, %%edx\n\t" + "jne NotSupported3\n\t" + "cmpl $0x64616574, %%ecx\n\t" "jne NotSupported4\n\t" + /* Drop through to Cyrix... */ + /* Cyrix Section */ + /* See if extended CPUID is supported */ + "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Try standard CPUID instead */ + /* Extended CPUID supported, so get extended features */ + "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */ + "jz NotSupported5\n\t" /* MMX not supported */ + "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ + "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ + "jmp Return\n\t" + /* AMD Section */ + "AMD:\n\t" + /* See if extended CPUID is supported */ + "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Try standard CPUID instead */ + /* Extended CPUID supported, so get extended features */ + "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ + "jz NotSupported6\n\t" /* MMX not supported */ + "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ + "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ + "jmp Return\n\t" + /* Intel Section */ + "Intel:\n\t" + /* Check for MMX */ + "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ + "jz NotSupported7\n\t" /* MMX Not supported */ + "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\t" + /* Nothing supported */ + "\nNotSupported1:\n\t" + "#movl $101, %0:\n\n\t" + "\nNotSupported2:\n\t" + "#movl $102, %0:\n\n\t" + "\nNotSupported3:\n\t" + "#movl $103, %0:\n\n\t" + "\nNotSupported4:\n\t" + "#movl $104, %0:\n\n\t" + "\nNotSupported5:\n\t" + "#movl $105, %0:\n\n\t" + "\nNotSupported6:\n\t" + "#movl $106, %0:\n\n\t" + "\nNotSupported7:\n\t" + "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a" (rval) + : /* no input */ + :"eax", "ebx", "ecx", "edx"); + + /* Return */ + return (rval); } /* Function to test if mmx instructions are supported... */ inline extern int -mmx_ok(void) +mmx_ok (void) { - /* Returns 1 if MMX instructions are supported, 0 otherwise */ - return ( mm_support() & 0x1 ); + /* Returns 1 if MMX instructions are supported, 0 otherwise */ + return (mm_support () & 0x1); } @@ -722,4 +667,3 @@ mmx_ok(void) #endif #endif - diff --git a/include/sse.h b/include/sse.h index 67cf825b8..0e03bd849 100644 --- a/include/sse.h +++ b/include/sse.h @@ -43,8 +43,9 @@ by LL and unsigned long long values by ULL, lest they be truncated by the compiler) */ -typedef union { - float sf[4]; /* Single-precision (32-bit) value */ +typedef union +{ + float sf[4]; /* Single-precision (32-bit) value */ } __attribute__ ((aligned (16))) sse_t; /* On a 16 byte (128-bit) boundary */ @@ -52,179 +53,121 @@ typedef union { /* Function to test if multimedia instructions are supported... */ inline extern int -mm_support(void) +mm_support (void) { - /* Returns 1 if MMX instructions are supported, - 3 if Cyrix MMX and Extended MMX instructions are supported - 5 if AMD MMX and 3DNow! instructions are supported - 9 if MMX and SSE instructions are supported - 0 if hardware does not support any of these - */ - register int rval = 0; - - __asm__ __volatile__ ( - /* See if CPUID instruction is supported ... */ - /* ... Get copies of EFLAGS into eax and ecx */ - "pushf\n\t" - "popl %%eax\n\t" - "movl %%eax, %%ecx\n\t" - - /* ... Toggle the ID bit in one copy and store */ - /* to the EFLAGS reg */ - "xorl $0x200000, %%eax\n\t" - "push %%eax\n\t" - "popf\n\t" - - /* ... Get the (hopefully modified) EFLAGS */ - "pushf\n\t" - "popl %%eax\n\t" - - /* ... Compare and test result */ - "xorl %%eax, %%ecx\n\t" - "testl $0x200000, %%ecx\n\t" - "jz NotSupported1\n\t" /* CPUID not supported */ - - - /* Get standard CPUID information, and - go to a specific vendor section */ - "movl $0, %%eax\n\t" - "cpuid\n\t" - - /* Check for Intel */ - "cmpl $0x756e6547, %%ebx\n\t" - "jne TryAMD\n\t" - "cmpl $0x49656e69, %%edx\n\t" - "jne TryAMD\n\t" - "cmpl $0x6c65746e, %%ecx\n" - "jne TryAMD\n\t" - "jmp Intel\n\t" - - /* Check for AMD */ - "\nTryAMD:\n\t" - "cmpl $0x68747541, %%ebx\n\t" - "jne TryCyrix\n\t" - "cmpl $0x69746e65, %%edx\n\t" - "jne TryCyrix\n\t" - "cmpl $0x444d4163, %%ecx\n" - "jne TryCyrix\n\t" - "jmp AMD\n\t" - - /* Check for Cyrix */ - "\nTryCyrix:\n\t" - "cmpl $0x69727943, %%ebx\n\t" - "jne NotSupported2\n\t" - "cmpl $0x736e4978, %%edx\n\t" - "jne NotSupported3\n\t" - "cmpl $0x64616574, %%ecx\n\t" - "jne NotSupported4\n\t" - /* Drop through to Cyrix... */ - - - /* Cyrix Section */ - /* See if extended CPUID level 80000001 is supported */ - /* The value of CPUID/80000001 for the 6x86MX is undefined - according to the Cyrix CPU Detection Guide (Preliminary - Rev. 1.01 table 1), so we'll check the value of eax for - CPUID/0 to see if standard CPUID level 2 is supported. - According to the table, the only CPU which supports level - 2 is also the only one which supports extended CPUID levels. - */ - "cmpl $0x2, %%eax\n\t" - "jne MMXtest\n\t" /* Use standard CPUID instead */ - - /* Extended CPUID supported (in theory), so get extended - features */ - "movl $0x80000001, %%eax\n\t" - "cpuid\n\t" - "testl $0x00800000, %%eax\n\t" /* Test for MMX */ - "jz NotSupported5\n\t" /* MMX not supported */ - "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ - "jnz EMMXSupported\n\t" - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\n" - "EMMXSupported:\n\t" - "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ - "jmp Return\n\t" - - - /* AMD Section */ - "AMD:\n\t" - - /* See if extended CPUID is supported */ - "movl $0x80000000, %%eax\n\t" - "cpuid\n\t" - "cmpl $0x80000000, %%eax\n\t" - "jl MMXtest\n\t" /* Use standard CPUID instead */ - - /* Extended CPUID supported, so get extended features */ - "movl $0x80000001, %%eax\n\t" - "cpuid\n\t" - "testl $0x00800000, %%edx\n\t" /* Test for MMX */ - "jz NotSupported6\n\t" /* MMX not supported */ - "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ - "jnz ThreeDNowSupported\n\t" - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\n" - "ThreeDNowSupported:\n\t" - "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ - "jmp Return\n\t" - - - /* Intel Section */ - "Intel:\n\t" - - /* Check for SSE */ - "SSEtest:\n\t" - "movl $1, %%eax\n\t" - "cpuid\n\t" - "testl $0x02000000, %%edx\n\t" /* Test for SSE */ - "jz MMXtest\n\t" /* SSE Not supported */ - "movl $9, %0:\n\n\t" /* SSE Supported */ - "jmp Return\n\t" - - /* Check for MMX */ - "MMXtest:\n\t" - "movl $1, %%eax\n\t" - "cpuid\n\t" - "testl $0x00800000, %%edx\n\t" /* Test for MMX */ - "jz NotSupported7\n\t" /* MMX Not supported */ - "movl $1, %0:\n\n\t" /* MMX Supported */ - "jmp Return\n\t" - - /* Nothing supported */ - "\nNotSupported1:\n\t" - "#movl $101, %0:\n\n\t" - "\nNotSupported2:\n\t" - "#movl $102, %0:\n\n\t" - "\nNotSupported3:\n\t" - "#movl $103, %0:\n\n\t" - "\nNotSupported4:\n\t" - "#movl $104, %0:\n\n\t" - "\nNotSupported5:\n\t" - "#movl $105, %0:\n\n\t" - "\nNotSupported6:\n\t" - "#movl $106, %0:\n\n\t" - "\nNotSupported7:\n\t" - "#movl $107, %0:\n\n\t" - "movl $0, %0:\n\n\t" - - "Return:\n\t" - : "=a" (rval) - : /* no input */ - : "eax", "ebx", "ecx", "edx" - ); - - /* Return */ - return(rval); + /* Returns 1 if MMX instructions are supported, + 3 if Cyrix MMX and Extended MMX instructions are supported + 5 if AMD MMX and 3DNow! instructions are supported + 9 if MMX and SSE instructions are supported + 0 if hardware does not support any of these + */ + register int rval = 0; + + __asm__ __volatile__ ( + /* See if CPUID instruction is supported ... */ + /* ... Get copies of EFLAGS into eax and ecx */ + "pushf\n\t" "popl %%eax\n\t" "movl %%eax, %%ecx\n\t" + /* ... Toggle the ID bit in one copy and store */ + /* to the EFLAGS reg */ + "xorl $0x200000, %%eax\n\t" "push %%eax\n\t" "popf\n\t" + /* ... Get the (hopefully modified) EFLAGS */ + "pushf\n\t" "popl %%eax\n\t" + /* ... Compare and test result */ + "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */ + /* Get standard CPUID information, and + go to a specific vendor section */ + "movl $0, %%eax\n\t" "cpuid\n\t" + /* Check for Intel */ + "cmpl $0x756e6547, %%ebx\n\t" + "jne TryAMD\n\t" + "cmpl $0x49656e69, %%edx\n\t" + "jne TryAMD\n\t" + "cmpl $0x6c65746e, %%ecx\n" "jne TryAMD\n\t" "jmp Intel\n\t" + /* Check for AMD */ + "\nTryAMD:\n\t" + "cmpl $0x68747541, %%ebx\n\t" + "jne TryCyrix\n\t" + "cmpl $0x69746e65, %%edx\n\t" + "jne TryCyrix\n\t" + "cmpl $0x444d4163, %%ecx\n" "jne TryCyrix\n\t" "jmp AMD\n\t" + /* Check for Cyrix */ + "\nTryCyrix:\n\t" + "cmpl $0x69727943, %%ebx\n\t" + "jne NotSupported2\n\t" + "cmpl $0x736e4978, %%edx\n\t" + "jne NotSupported3\n\t" + "cmpl $0x64616574, %%ecx\n\t" "jne NotSupported4\n\t" + /* Drop through to Cyrix... */ + /* Cyrix Section */ + /* See if extended CPUID level 80000001 is supported */ + /* The value of CPUID/80000001 for the 6x86MX is undefined + according to the Cyrix CPU Detection Guide (Preliminary + Rev. 1.01 table 1), so we'll check the value of eax for + CPUID/0 to see if standard CPUID level 2 is supported. + According to the table, the only CPU which supports level + 2 is also the only one which supports extended CPUID levels. + */ + "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */ + /* Extended CPUID supported (in theory), so get extended + features */ + "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */ + "jz NotSupported5\n\t" /* MMX not supported */ + "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */ + "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */ + "jmp Return\n\t" + /* AMD Section */ + "AMD:\n\t" + /* See if extended CPUID is supported */ + "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */ + /* Extended CPUID supported, so get extended features */ + "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ + "jz NotSupported6\n\t" /* MMX not supported */ + "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */ + "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */ + "jmp Return\n\t" + /* Intel Section */ + "Intel:\n\t" + /* Check for SSE */ + "SSEtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x02000000, %%edx\n\t" /* Test for SSE */ + "jz MMXtest\n\t" /* SSE Not supported */ + "movl $9, %0:\n\n\t" /* SSE Supported */ + "jmp Return\n\t" + /* Check for MMX */ + "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */ + "jz NotSupported7\n\t" /* MMX Not supported */ + "movl $1, %0:\n\n\t" /* MMX Supported */ + "jmp Return\n\t" + /* Nothing supported */ + "\nNotSupported1:\n\t" + "#movl $101, %0:\n\n\t" + "\nNotSupported2:\n\t" + "#movl $102, %0:\n\n\t" + "\nNotSupported3:\n\t" + "#movl $103, %0:\n\n\t" + "\nNotSupported4:\n\t" + "#movl $104, %0:\n\n\t" + "\nNotSupported5:\n\t" + "#movl $105, %0:\n\n\t" + "\nNotSupported6:\n\t" + "#movl $106, %0:\n\n\t" + "\nNotSupported7:\n\t" + "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a" (rval) + : /* no input */ + :"eax", "ebx", "ecx", "edx"); + + /* Return */ + return (rval); } /* Function to test if sse instructions are supported... */ inline extern int -sse_ok(void) +sse_ok (void) { - /* Returns 1 if SSE instructions are supported, 0 otherwise */ - return ( (mm_support() & 0x8) >> 3 ); + /* Returns 1 if SSE instructions are supported, 0 otherwise */ + return ((mm_support () & 0x8) >> 3); } #endif @@ -541,13 +484,13 @@ sse_ok(void) /* MOVe MaSK from Packed Single-fp */ #ifdef SSE_TRACE - #define movmskps(xmmreg, reg) \ +#define movmskps(xmmreg, reg) \ { \ fprintf(stderr, "movmskps()\n"); \ __asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg) \ } #else - #define movmskps(xmmreg, reg) \ +#define movmskps(xmmreg, reg) \ __asm__ __volatile__ ("movmskps %" #xmmreg ", %" #reg) #endif @@ -555,13 +498,13 @@ sse_ok(void) /* Parallel MOVe MaSK from mmx reg to 32-bit reg */ #ifdef SSE_TRACE - #define pmovmskb(mmreg, reg) \ +#define pmovmskb(mmreg, reg) \ { \ fprintf(stderr, "movmskps()\n"); \ __asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg) \ } #else - #define pmovmskb(mmreg, reg) \ +#define pmovmskb(mmreg, reg) \ __asm__ __volatile__ ("movmskps %" #mmreg ", %" #reg) #endif @@ -884,7 +827,7 @@ sse_ok(void) /* Fp and mmX ReSTORe state */ #ifdef SSE_TRACE - #define fxrstor(mem) \ +#define fxrstor(mem) \ { \ fprintf(stderr, "fxrstor()\n"); \ __asm__ __volatile__ ("fxrstor %0" \ @@ -892,7 +835,7 @@ sse_ok(void) : "X" (mem)) \ } #else - #define fxrstor(mem) \ +#define fxrstor(mem) \ __asm__ __volatile__ ("fxrstor %0" \ : /* nothing */ \ : "X" (mem)) @@ -902,7 +845,7 @@ sse_ok(void) /* Fp and mmX SAVE state */ #ifdef SSE_TRACE - #define fxsave(mem) \ +#define fxsave(mem) \ { \ fprintf(stderr, "fxsave()\n"); \ __asm__ __volatile__ ("fxsave %0" \ @@ -910,7 +853,7 @@ sse_ok(void) : "X" (mem)) \ } #else - #define fxsave(mem) \ +#define fxsave(mem) \ __asm__ __volatile__ ("fxsave %0" \ : /* nothing */ \ : "X" (mem)) @@ -920,7 +863,7 @@ sse_ok(void) /* STore streaMing simd eXtensions Control/Status Register */ #ifdef SSE_TRACE - #define stmxcsr(mem) \ +#define stmxcsr(mem) \ { \ fprintf(stderr, "stmxcsr()\n"); \ __asm__ __volatile__ ("stmxcsr %0" \ @@ -928,7 +871,7 @@ sse_ok(void) : "X" (mem)) \ } #else - #define stmxcsr(mem) \ +#define stmxcsr(mem) \ __asm__ __volatile__ ("stmxcsr %0" \ : /* nothing */ \ : "X" (mem)) @@ -938,7 +881,7 @@ sse_ok(void) /* LoaD streaMing simd eXtensions Control/Status Register */ #ifdef SSE_TRACE - #define ldmxcsr(mem) \ +#define ldmxcsr(mem) \ { \ fprintf(stderr, "ldmxcsr()\n"); \ __asm__ __volatile__ ("ldmxcsr %0" \ @@ -946,7 +889,7 @@ sse_ok(void) : "X" (mem)) \ } #else - #define ldmxcsr(mem) \ +#define ldmxcsr(mem) \ __asm__ __volatile__ ("ldmxcsr %0" \ : /* nothing */ \ : "X" (mem)) @@ -957,13 +900,13 @@ sse_ok(void) occuring after fence in source code. */ #ifdef SSE_TRACE - #define sfence() \ +#define sfence() \ { \ fprintf(stderr, "sfence()\n"); \ __asm__ __volatile__ ("sfence\n\t") \ } #else - #define sfence() \ +#define sfence() \ __asm__ __volatile__ ("sfence\n\t") #endif @@ -976,18 +919,17 @@ sse_ok(void) */ #ifdef SSE_TRACE #else - #define prefetch(mem, hint) \ +#define prefetch(mem, hint) \ __asm__ __volatile__ ("prefetch" #hint " %0" \ : /* nothing */ \ : "X" (mem)) - #define prefetcht0(mem) prefetch(mem, t0) - #define prefetcht1(mem) prefetch(mem, t1) - #define prefetcht2(mem) prefetch(mem, t2) - #define prefetchnta(mem) prefetch(mem, nta) +#define prefetcht0(mem) prefetch(mem, t0) +#define prefetcht1(mem) prefetch(mem, t1) +#define prefetcht2(mem) prefetch(mem, t2) +#define prefetchnta(mem) prefetch(mem, nta) #endif #endif - diff --git a/libs/gst/bytestream/bytestream.c b/libs/gst/bytestream/bytestream.c index 1da70e29c..222281275 100644 --- a/libs/gst/bytestream/bytestream.c +++ b/libs/gst/bytestream/bytestream.c @@ -32,13 +32,13 @@ #include #include "bytestream.h" -GST_DEBUG_CATEGORY_STATIC(debug_bs); +GST_DEBUG_CATEGORY_STATIC (debug_bs); #define GST_CAT_DEFAULT debug_bs static guint8 *gst_bytestream_assemble (GstByteStream * bs, guint32 len); static inline void -gst_bytestream_init (GstByteStream *bs) +gst_bytestream_init (GstByteStream * bs) { bs->event = NULL; bs->buflist = NULL; @@ -49,13 +49,13 @@ gst_bytestream_init (GstByteStream *bs) bs->in_seek = FALSE; } static inline void -gst_bytestream_exit (GstByteStream *bs) +gst_bytestream_exit (GstByteStream * bs) { GSList *walk; if (bs->event) gst_event_unref (bs->event); - + walk = bs->buflist; while (walk) { gst_buffer_unref (GST_BUFFER (walk->data)); @@ -65,6 +65,7 @@ gst_bytestream_exit (GstByteStream *bs) g_free (bs->assembled); } + /** * gst_bytestream_new: * @pad: the pad to attach the bytestream to @@ -96,14 +97,16 @@ gst_bytestream_destroy (GstByteStream * bs) gst_bytestream_exit (bs); g_free (bs); } + void -gst_bytestream_reset (GstByteStream *bs) +gst_bytestream_reset (GstByteStream * bs) { /* free all data */ gst_bytestream_exit (bs); /* reset data to clean state */ gst_bytestream_init (bs); } + /* HOW THIS WORKS: * * The fundamental structure is a singly-linked list of buffers. The @@ -140,7 +143,7 @@ gst_bytestream_reset (GstByteStream *bs) * else add it onto the head of the */ static gboolean -gst_bytestream_get_next_buf (GstByteStream *bs) +gst_bytestream_get_next_buf (GstByteStream * bs) { GstBuffer *nextbuf, *lastbuf, *headbuf; GSList *end; @@ -190,8 +193,7 @@ gst_bytestream_get_next_buf (GstByteStream *bs) gst_buffer_unref (nextbuf); /* if we can't, we just append this buffer */ - } - else { + } else { GST_DEBUG ("get_next_buf: adding new buffer to the end of the list"); end = g_slist_append (end, nextbuf); /* also need to increment length of list and buffer count */ @@ -199,8 +201,7 @@ gst_bytestream_get_next_buf (GstByteStream *bs) } /* if there are no buffers in the list */ - } - else { + } else { GST_DEBUG ("get_next_buf: buflist is empty, adding new buffer to list"); /* put this on the end of the list */ bs->buflist = g_slist_append (bs->buflist, nextbuf); @@ -210,21 +211,22 @@ gst_bytestream_get_next_buf (GstByteStream *bs) bs->headbufavail = GST_BUFFER_SIZE (nextbuf); } - /* a zero offset is a indication that we might need to set the timestamp */ - if (bs->offset == 0LL){ + /* a zero offset is a indication that we might need to set the timestamp */ + if (bs->offset == 0LL) { headbuf = GST_BUFFER (bs->buflist->data); - bs->offset = GST_BUFFER_OFFSET(headbuf); + bs->offset = GST_BUFFER_OFFSET (headbuf); } - + return TRUE; } static gboolean -gst_bytestream_fill_bytes (GstByteStream *bs, guint32 len) +gst_bytestream_fill_bytes (GstByteStream * bs, guint32 len) { /* as long as we don't have enough, we get more buffers */ while (bs->listavail < len) { - GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d", bs->listavail, len); + GST_DEBUG ("fill_bytes: there are %d bytes in the list, we need %d", + bs->listavail, len); if (!gst_bytestream_get_next_buf (bs)) return FALSE; } @@ -247,13 +249,13 @@ gst_bytestream_fill_bytes (GstByteStream *bs, guint32 len) * Returns: The number of bytes successfully peeked. */ guint32 -gst_bytestream_peek (GstByteStream *bs, GstBuffer **buf, guint32 len) +gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len) { GstBuffer *headbuf, *retbuf = NULL; g_return_val_if_fail (bs != NULL, 0); g_return_val_if_fail (buf != NULL, 0); - + if (len == 0) return 0; @@ -265,13 +267,12 @@ gst_bytestream_peek (GstByteStream *bs, GstBuffer **buf, guint32 len) if (!gst_bytestream_fill_bytes (bs, len)) { /* we must have an event coming up */ if (bs->listavail > 0) { - /* we have some data left, len will be shrunk to the amount of data available */ - len = bs->listavail; - } - else { - /* there is no data */ - *buf = retbuf; - return 0; + /* we have some data left, len will be shrunk to the amount of data available */ + len = bs->listavail; + } else { + /* there is no data */ + *buf = retbuf; + return 0; } } GST_DEBUG ("peek: there are now %d bytes in the list", bs->listavail); @@ -284,10 +285,15 @@ gst_bytestream_peek (GstByteStream *bs, GstBuffer **buf, guint32 len) /* if the requested bytes are in the current buffer */ GST_DEBUG ("peek: headbufavail is %d", bs->headbufavail); if (len <= bs->headbufavail) { - GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)", len, bs->headbufavail); + GST_DEBUG ("peek: there are enough bytes in headbuf (need %d, have %d)", + len, bs->headbufavail); /* create a sub-buffer of the headbuf */ - retbuf = gst_buffer_create_sub (headbuf, GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len); - GST_BUFFER_OFFSET (retbuf) = GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) - bs->headbufavail; + retbuf = + gst_buffer_create_sub (headbuf, + GST_BUFFER_SIZE (headbuf) - bs->headbufavail, len); + GST_BUFFER_OFFSET (retbuf) = + GST_BUFFER_OFFSET (headbuf) + GST_BUFFER_SIZE (headbuf) - + bs->headbufavail; } /* otherwise we need to figure out how to assemble one */ @@ -321,7 +327,7 @@ gst_bytestream_peek (GstByteStream *bs, GstBuffer **buf, guint32 len) * Returns: The number of bytes successfully peeked. */ guint32 -gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len) +gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data, guint32 len) { GstBuffer *headbuf; @@ -342,16 +348,15 @@ gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len) /* make sure we have enough */ GST_DEBUG ("peek_bytes: there are %d bytes in the list", bs->listavail); if (len > bs->listavail) { - if (!gst_bytestream_fill_bytes (bs, len)){ + if (!gst_bytestream_fill_bytes (bs, len)) { /* we must have an event coming up */ - if (bs->listavail > 0){ - /* we have some data left, len will be shrunk to the amount of data available */ - len = bs->listavail; - } - else { - /* there is no data */ - *data = NULL; - return 0; + if (bs->listavail > 0) { + /* we have some data left, len will be shrunk to the amount of data available */ + len = bs->listavail; + } else { + /* there is no data */ + *data = NULL; + return 0; } } GST_DEBUG ("peek_bytes: there are now %d bytes in the list", bs->listavail); @@ -364,9 +369,13 @@ gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len) /* if the requested bytes are in the current buffer */ GST_DEBUG ("peek_bytes: headbufavail is %d", bs->headbufavail); if (len <= bs->headbufavail) { - GST_DEBUG ("peek_bytes: there are enough bytes in headbuf (need %d, have %d)", len, bs->headbufavail); + GST_DEBUG + ("peek_bytes: there are enough bytes in headbuf (need %d, have %d)", + len, bs->headbufavail); /* create a sub-buffer of the headbuf */ - *data = GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) - bs->headbufavail); + *data = + GST_BUFFER_DATA (headbuf) + (GST_BUFFER_SIZE (headbuf) - + bs->headbufavail); } /* otherwise we need to figure out how to assemble one */ @@ -381,8 +390,8 @@ gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len) return len; } -static guint8* -gst_bytestream_assemble (GstByteStream *bs, guint32 len) +static guint8 * +gst_bytestream_assemble (GstByteStream * bs, guint32 len) { guint8 *data = g_malloc (len); GSList *walk; @@ -391,9 +400,11 @@ gst_bytestream_assemble (GstByteStream *bs, guint32 len) /* copy the data from the curbuf */ buf = GST_BUFFER (bs->buflist->data); - GST_DEBUG ("assemble: copying %d bytes from curbuf at %d to *data", bs->headbufavail, - GST_BUFFER_SIZE (buf) - bs->headbufavail); - memcpy (data, GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf) - bs->headbufavail, bs->headbufavail); + GST_DEBUG ("assemble: copying %d bytes from curbuf at %d to *data", + bs->headbufavail, GST_BUFFER_SIZE (buf) - bs->headbufavail); + memcpy (data, + GST_BUFFER_DATA (buf) + GST_BUFFER_SIZE (buf) - bs->headbufavail, + bs->headbufavail); copied += bs->headbufavail; /* asumption is made that the buffers all exist in the list */ @@ -401,12 +412,13 @@ gst_bytestream_assemble (GstByteStream *bs, guint32 len) while (copied < len) { buf = GST_BUFFER (walk->data); if (GST_BUFFER_SIZE (buf) < (len - copied)) { - GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", GST_BUFFER_SIZE (buf), copied); + GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", + GST_BUFFER_SIZE (buf), copied); memcpy (data + copied, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); copied += GST_BUFFER_SIZE (buf); - } - else { - GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", len - copied, copied); + } else { + GST_DEBUG ("assemble: copying %d bytes from buf to output offset %d", + len - copied, copied); memcpy (data + copied, GST_BUFFER_DATA (buf), len - copied); copied = len; } @@ -430,7 +442,7 @@ gst_bytestream_assemble (GstByteStream *bs, guint32 len) * Returns: TRUE if the number of bytes could be flushed. */ gboolean -gst_bytestream_flush (GstByteStream *bs, guint32 len) +gst_bytestream_flush (GstByteStream * bs, guint32 len) { GST_DEBUG ("flush: flushing %d bytes", len); @@ -462,13 +474,13 @@ gst_bytestream_flush (GstByteStream *bs, guint32 len) * with gst_bytestream_peek() or gst_bytestream_peek_bytes(). */ void -gst_bytestream_flush_fast (GstByteStream *bs, guint32 len) +gst_bytestream_flush_fast (GstByteStream * bs, guint32 len) { GstBuffer *headbuf; if (len == 0) return; - + g_assert (len <= bs->listavail); if (bs->assembled) { @@ -483,8 +495,9 @@ gst_bytestream_flush_fast (GstByteStream *bs, guint32 len) while (len > 0) { headbuf = GST_BUFFER (bs->buflist->data); - GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %" G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf), - GST_BUFFER_OFFSET (headbuf)); + GST_DEBUG ("flush: analyzing buffer that's %d bytes long, offset %" + G_GUINT64_FORMAT, GST_BUFFER_SIZE (headbuf), + GST_BUFFER_OFFSET (headbuf)); /* if there's enough to complete the flush */ if (bs->headbufavail > len) { @@ -495,8 +508,7 @@ gst_bytestream_flush_fast (GstByteStream *bs, guint32 len) len = 0; /* otherwise we have to trim the whole buffer */ - } - else { + } else { GST_DEBUG ("flush: removing head buffer completely"); /* remove it from the list */ bs->buflist = g_slist_delete_link (bs->buflist, bs->buflist); @@ -511,8 +523,7 @@ gst_bytestream_flush_fast (GstByteStream *bs, guint32 len) if (bs->buflist) { bs->headbufavail = GST_BUFFER_SIZE (GST_BUFFER (bs->buflist->data)); GST_DEBUG ("flush: next headbuf is %d bytes", bs->headbufavail); - } - else { + } else { GST_DEBUG ("flush: no more bytes at all"); } } @@ -536,27 +547,24 @@ gst_bytestream_flush_fast (GstByteStream *bs, guint32 len) * Returns: TRUE when the seek succeeded. */ gboolean -gst_bytestream_seek (GstByteStream *bs, gint64 offset, GstSeekType method) +gst_bytestream_seek (GstByteStream * bs, gint64 offset, GstSeekType method) { GstRealPad *peer; - + g_return_val_if_fail (bs != NULL, FALSE); - + peer = GST_RPAD_PEER (bs->pad); GST_DEBUG ("bs: send event\n"); - if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek ( - GST_FORMAT_BYTES | - (method & GST_SEEK_METHOD_MASK) | - GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, - offset))) - { + if (gst_pad_send_event (GST_PAD (peer), gst_event_new_seek (GST_FORMAT_BYTES | + (method & GST_SEEK_METHOD_MASK) | + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, offset))) { gst_bytestream_flush_fast (bs, bs->listavail); /* we set the seek flag here. We cannot pull the pad here * bacause a seek might occur outisde of the pads cothread context */ bs->in_seek = TRUE; - + return TRUE; } GST_DEBUG ("bs: send event failed\n"); @@ -572,19 +580,20 @@ gst_bytestream_seek (GstByteStream *bs, gint64 offset, GstSeekType method) * Returns: the offset or -1 on error. */ guint64 -gst_bytestream_tell (GstByteStream *bs) +gst_bytestream_tell (GstByteStream * bs) { GstFormat format; gint64 value; - + g_return_val_if_fail (bs != NULL, -1); format = GST_FORMAT_BYTES; - if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format, &value)) { + if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_POSITION, &format, + &value)) { return value - bs->listavail; } - + return -1; } @@ -597,18 +606,18 @@ gst_bytestream_tell (GstByteStream *bs) * Returns: the total length or -1 on error. */ guint64 -gst_bytestream_length (GstByteStream *bs) +gst_bytestream_length (GstByteStream * bs) { GstFormat format; gint64 value; - + g_return_val_if_fail (bs != NULL, -1); format = GST_FORMAT_BYTES; - if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_TOTAL, &format, &value)) + if (gst_pad_query (GST_PAD_PEER (bs->pad), GST_QUERY_TOTAL, &format, &value)) return value; - + return -1; } @@ -627,12 +636,12 @@ gst_bytestream_length (GstByteStream *bs) * Returns: The number of bytes successfully read. */ guint32 -gst_bytestream_read (GstByteStream *bs, GstBuffer** buf, guint32 len) +gst_bytestream_read (GstByteStream * bs, GstBuffer ** buf, guint32 len) { guint32 len_peeked; g_return_val_if_fail (bs != NULL, -1); - + len_peeked = gst_bytestream_peek (bs, buf, len); if (len_peeked == 0) return 0; @@ -654,7 +663,7 @@ gst_bytestream_read (GstByteStream *bs, GstBuffer** buf, guint32 len) * Returns: TRUE if the hint was accepted */ gboolean -gst_bytestream_size_hint (GstByteStream *bs, guint32 size) +gst_bytestream_size_hint (GstByteStream * bs, guint32 size) { GstEvent *event; @@ -676,9 +685,8 @@ gst_bytestream_size_hint (GstByteStream *bs, guint32 size) * before reading more bytes from the stream. */ void -gst_bytestream_get_status (GstByteStream *bs, - guint32 *avail_out, - GstEvent **event_out) +gst_bytestream_get_status (GstByteStream * bs, + guint32 * avail_out, GstEvent ** event_out) { if (avail_out) *avail_out = bs->listavail; @@ -703,7 +711,7 @@ gst_bytestream_get_status (GstByteStream *bs, * Returns: a timestamp */ guint64 -gst_bytestream_get_timestamp (GstByteStream *bs) +gst_bytestream_get_timestamp (GstByteStream * bs) { GstBuffer *headbuf; @@ -744,27 +752,22 @@ gst_bytestream_print_status (GstByteStream * bs) buf = GST_BUFFER (walk->data); walk = g_slist_next (walk); - GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT " and is %d bytes long", - GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf)); + GST_DEBUG ("STATUS: buffer starts at %" G_GUINT64_FORMAT + " and is %d bytes long", GST_BUFFER_OFFSET (buf), + GST_BUFFER_SIZE (buf)); } } static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { GST_DEBUG_CATEGORY_INIT (debug_bs, "bytestream", 0, "bytestream library"); return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstbytestream", - "a byte-oriented layer on top of buffer-passing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstbytestream", + "a byte-oriented layer on top of buffer-passing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/libs/gst/bytestream/bytestream.h b/libs/gst/bytestream/bytestream.h index 08ae068a3..eea507a0e 100644 --- a/libs/gst/bytestream/bytestream.h +++ b/libs/gst/bytestream/bytestream.h @@ -24,51 +24,52 @@ #include #include -G_BEGIN_DECLS +G_BEGIN_DECLS typedef struct _GstByteStream GstByteStream; -typedef struct _GstByteStream GstByteStream; +struct _GstByteStream +{ + GstPad *pad; -struct _GstByteStream { - GstPad *pad; + GstEvent *event; - GstEvent *event; - - GSList *buflist; - guint32 headbufavail; - guint32 listavail; + GSList *buflist; + guint32 headbufavail; + guint32 listavail; /* we keep state of assembled pieces */ - guint8 *assembled; - guint32 assembled_len; /* only valid when assembled != NULL */ + guint8 *assembled; + guint32 assembled_len; /* only valid when assembled != NULL */ /* this is needed for gst_bytestream_tell */ - guint64 offset; - guint64 last_ts; + guint64 offset; + guint64 last_ts; /* if we are in the seek state (waiting for DISCONT) */ - gboolean in_seek; + gboolean in_seek; gpointer _gst_reserved[GST_PADDING]; }; -GstByteStream* gst_bytestream_new (GstPad *pad); -void gst_bytestream_destroy (GstByteStream *bs); - -void gst_bytestream_reset (GstByteStream *bs); -guint32 gst_bytestream_read (GstByteStream *bs, GstBuffer** buf, guint32 len); -guint64 gst_bytestream_tell (GstByteStream *bs); -guint64 gst_bytestream_length (GstByteStream *bs); -gboolean gst_bytestream_size_hint (GstByteStream *bs, guint32 size); -gboolean gst_bytestream_seek (GstByteStream *bs, gint64 offset, GstSeekType type); -guint32 gst_bytestream_peek (GstByteStream *bs, GstBuffer** buf, guint32 len); -guint32 gst_bytestream_peek_bytes (GstByteStream *bs, guint8** data, guint32 len); -gboolean gst_bytestream_flush (GstByteStream *bs, guint32 len); -void gst_bytestream_flush_fast (GstByteStream *bs, guint32 len); -void gst_bytestream_get_status (GstByteStream *bs, guint32 *avail_out, GstEvent **event_out); -guint64 gst_bytestream_get_timestamp (GstByteStream *bs); - -void gst_bytestream_print_status (GstByteStream *bs); +GstByteStream *gst_bytestream_new (GstPad * pad); +void gst_bytestream_destroy (GstByteStream * bs); + +void gst_bytestream_reset (GstByteStream * bs); +guint32 gst_bytestream_read (GstByteStream * bs, GstBuffer ** buf, guint32 len); +guint64 gst_bytestream_tell (GstByteStream * bs); +guint64 gst_bytestream_length (GstByteStream * bs); +gboolean gst_bytestream_size_hint (GstByteStream * bs, guint32 size); +gboolean gst_bytestream_seek (GstByteStream * bs, gint64 offset, + GstSeekType type); +guint32 gst_bytestream_peek (GstByteStream * bs, GstBuffer ** buf, guint32 len); +guint32 gst_bytestream_peek_bytes (GstByteStream * bs, guint8 ** data, + guint32 len); +gboolean gst_bytestream_flush (GstByteStream * bs, guint32 len); +void gst_bytestream_flush_fast (GstByteStream * bs, guint32 len); +void gst_bytestream_get_status (GstByteStream * bs, guint32 * avail_out, + GstEvent ** event_out); +guint64 gst_bytestream_get_timestamp (GstByteStream * bs); + +void gst_bytestream_print_status (GstByteStream * bs); G_END_DECLS - #endif /* __GST_BYTESTREAM_H__ */ diff --git a/libs/gst/control/control.c b/libs/gst/control/control.c index a7073b612..cf678b8b2 100644 --- a/libs/gst/control/control.c +++ b/libs/gst/control/control.c @@ -18,16 +18,17 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - + #include #include "control.h" -GST_DEBUG_CATEGORY(_gst_control_debug); +GST_DEBUG_CATEGORY (_gst_control_debug); void -gst_control_init (int *argc, char **argv[]) { - GST_DEBUG_CATEGORY_INIT (_gst_control_debug, "control", 0, "libgstcontrol"); - _gst_dpman_initialize (); - _gst_unitconv_initialize (); +gst_control_init (int *argc, char **argv[]) +{ + GST_DEBUG_CATEGORY_INIT (_gst_control_debug, "control", 0, "libgstcontrol"); + _gst_dpman_initialize (); + _gst_unitconv_initialize (); } diff --git a/libs/gst/control/control.h b/libs/gst/control/control.h index 048918245..bea0fa0d6 100644 --- a/libs/gst/control/control.h +++ b/libs/gst/control/control.h @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - + #ifndef __GST_CONTROL_H__ #define __GST_CONTROL_H__ @@ -28,10 +28,7 @@ #include #include -G_BEGIN_DECLS - -void gst_control_init (int *argc, char **argv[]); +G_BEGIN_DECLS void gst_control_init (int *argc, char **argv[]); G_END_DECLS - #endif /* __GST_CONTROL_H__ */ diff --git a/libs/gst/control/dparam.c b/libs/gst/control/dparam.c index 9c07adbd2..ed43a2c24 100644 --- a/libs/gst/control/dparam.c +++ b/libs/gst/control/dparam.c @@ -31,100 +31,106 @@ #include "dparammanager.h" #include -GST_DEBUG_CATEGORY_EXTERN(_gst_control_debug); - -static void gst_dparam_class_init (GstDParamClass *klass); -static void gst_dparam_init (GstDParam *dparam); -static void gst_dparam_dispose (GObject *object); -static void gst_dparam_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gst_dparam_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); - -enum { - ARG_0, - ARG_VALUE_FLOAT, - ARG_VALUE_DOUBLE, - ARG_VALUE_INT, - ARG_VALUE_INT64, +GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug); + +static void gst_dparam_class_init (GstDParamClass * klass); +static void gst_dparam_init (GstDParam * dparam); +static void gst_dparam_dispose (GObject * object); +static void gst_dparam_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_dparam_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); + +enum +{ + ARG_0, + ARG_VALUE_FLOAT, + ARG_VALUE_DOUBLE, + ARG_VALUE_INT, + ARG_VALUE_INT64, }; -enum { +enum +{ VALUE_CHANGED, LAST_SIGNAL }; static guint gst_dparam_signals[LAST_SIGNAL] = { 0 }; -GType -gst_dparam_get_type(void) { - static GType dparam_type = 0; - - if (!dparam_type) { - static const GTypeInfo dparam_info = { - sizeof(GstDParamClass), - NULL, - NULL, - (GClassInitFunc)gst_dparam_class_init, - NULL, - NULL, - sizeof(GstDParam), - 0, - (GInstanceInitFunc)gst_dparam_init, - }; - dparam_type = g_type_register_static(GST_TYPE_OBJECT, "GstDParam", &dparam_info, 0); - } - return dparam_type; +GType +gst_dparam_get_type (void) +{ + static GType dparam_type = 0; + + if (!dparam_type) { + static const GTypeInfo dparam_info = { + sizeof (GstDParamClass), + NULL, + NULL, + (GClassInitFunc) gst_dparam_class_init, + NULL, + NULL, + sizeof (GstDParam), + 0, + (GInstanceInitFunc) gst_dparam_init, + }; + dparam_type = + g_type_register_static (GST_TYPE_OBJECT, "GstDParam", &dparam_info, 0); + } + return dparam_type; } static void -gst_dparam_class_init (GstDParamClass *klass) +gst_dparam_class_init (GstDParamClass * klass) { - GObjectClass *gobject_class; - GstDParamClass *dparam_class; - GstObjectClass *gstobject_class; - - gobject_class = (GObjectClass*)klass; - dparam_class = (GstDParamClass*)klass; - gstobject_class = (GstObjectClass*) klass; - - gobject_class->get_property = gst_dparam_get_property; - gobject_class->set_property = gst_dparam_set_property; - - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_FLOAT, - g_param_spec_float("value_float","Float Value", - "The value that should be changed if gfloat is the type", - -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_DOUBLE, - g_param_spec_double("value_double","Double Value", - "The value that should be changed if gdouble is the type", - -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_INT, - g_param_spec_int("value_int","Integer Value", - "The value that should be changed if gint is the type", - G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VALUE_INT64, - g_param_spec_int64("value_int64","64 bit Integer Value", - "The value that should be changed if gint64 is the type", - G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE)); - - gobject_class->dispose = gst_dparam_dispose; - - gst_dparam_signals[VALUE_CHANGED] = - g_signal_new ("value-changed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstDParamClass, value_changed), NULL, NULL, - gst_marshal_VOID__VOID, G_TYPE_NONE, 0); - /*gstobject_class->save_thyself = gst_dparam_save_thyself; */ + GObjectClass *gobject_class; + GstDParamClass *dparam_class; + GstObjectClass *gstobject_class; + + gobject_class = (GObjectClass *) klass; + dparam_class = (GstDParamClass *) klass; + gstobject_class = (GstObjectClass *) klass; + + gobject_class->get_property = gst_dparam_get_property; + gobject_class->set_property = gst_dparam_set_property; + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_FLOAT, + g_param_spec_float ("value_float", "Float Value", + "The value that should be changed if gfloat is the type", + -G_MAXFLOAT, G_MAXFLOAT, 0.0F, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_DOUBLE, + g_param_spec_double ("value_double", "Double Value", + "The value that should be changed if gdouble is the type", + -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT, + g_param_spec_int ("value_int", "Integer Value", + "The value that should be changed if gint is the type", + G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VALUE_INT64, + g_param_spec_int64 ("value_int64", "64 bit Integer Value", + "The value that should be changed if gint64 is the type", + G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE)); + + gobject_class->dispose = gst_dparam_dispose; + + gst_dparam_signals[VALUE_CHANGED] = + g_signal_new ("value-changed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamClass, value_changed), NULL, + NULL, gst_marshal_VOID__VOID, G_TYPE_NONE, 0); + /*gstobject_class->save_thyself = gst_dparam_save_thyself; */ } static void -gst_dparam_init (GstDParam *dparam) +gst_dparam_init (GstDParam * dparam) { - g_return_if_fail (dparam != NULL); - GST_DPARAM_TYPE(dparam) = 0; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam)=0LL; - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam)=0LL; - GST_DPARAM_READY_FOR_UPDATE(dparam)=FALSE; - dparam->lock = g_mutex_new (); + g_return_if_fail (dparam != NULL); + GST_DPARAM_TYPE (dparam) = 0; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL; + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = 0LL; + GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE; + dparam->lock = g_mutex_new (); } /** @@ -133,147 +139,156 @@ gst_dparam_init (GstDParam *dparam) * * Returns: a new instance of GstDParam */ -GstDParam* +GstDParam * gst_dparam_new (GType type) { - GstDParam *dparam; + GstDParam *dparam; - dparam = g_object_new (gst_dparam_get_type (), NULL); - dparam->do_update_func = gst_dparam_do_update_default; + dparam = g_object_new (gst_dparam_get_type (), NULL); + dparam->do_update_func = gst_dparam_do_update_default; - GST_DPARAM_TYPE(dparam) = type; - - return dparam; + GST_DPARAM_TYPE (dparam) = type; + + return dparam; } -static void -gst_dparam_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_dparam_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { - GstDParam *dparam; - g_return_if_fail(GST_IS_DPARAM(object)); - dparam = GST_DPARAM(object); - - switch (prop_id) { - case ARG_VALUE_FLOAT: - g_value_set_float (value, dparam->value_float); - break; - - case ARG_VALUE_DOUBLE: - g_value_set_double (value, dparam->value_double); - break; - - case ARG_VALUE_INT: - g_value_set_int (value, dparam->value_int); - break; - - case ARG_VALUE_INT64: - g_value_set_int64 (value, dparam->value_int64); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + GstDParam *dparam; + + g_return_if_fail (GST_IS_DPARAM (object)); + dparam = GST_DPARAM (object); + + switch (prop_id) { + case ARG_VALUE_FLOAT: + g_value_set_float (value, dparam->value_float); + break; + + case ARG_VALUE_DOUBLE: + g_value_set_double (value, dparam->value_double); + break; + + case ARG_VALUE_INT: + g_value_set_int (value, dparam->value_int); + break; + + case ARG_VALUE_INT64: + g_value_set_int64 (value, dparam->value_int64); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } -static void -gst_dparam_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_dparam_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { - GstDParam *dparam; - g_return_if_fail(GST_IS_DPARAM(object)); - dparam = GST_DPARAM(object); - GST_DPARAM_LOCK(dparam); - - switch (prop_id) { - case ARG_VALUE_FLOAT: - GST_DEBUG ("setting value from %g to %g", dparam->value_float, g_value_get_float (value)); - dparam->value_float = g_value_get_float (value); - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - case ARG_VALUE_DOUBLE: - GST_DEBUG ("setting value from %g to %g", - dparam->value_double, g_value_get_double (value)); - dparam->value_double = g_value_get_double (value); - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - case ARG_VALUE_INT: - GST_DEBUG ("setting value from %d to %d", dparam->value_int, g_value_get_int (value)); - dparam->value_int = g_value_get_int (value); - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - case ARG_VALUE_INT64: - GST_DEBUG ("setting value from %" - G_GINT64_FORMAT " to %" - G_GINT64_FORMAT, - dparam->value_int64, g_value_get_int64 (value)); - dparam->value_int64 = g_value_get_int64 (value); - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - default: - break; - } - - /* note that this signal is sent while we still have the lock. */ - g_signal_emit (G_OBJECT (dparam), gst_dparam_signals[VALUE_CHANGED], 0); - GST_DPARAM_UNLOCK(dparam); + GstDParam *dparam; + + g_return_if_fail (GST_IS_DPARAM (object)); + dparam = GST_DPARAM (object); + GST_DPARAM_LOCK (dparam); + + switch (prop_id) { + case ARG_VALUE_FLOAT: + GST_DEBUG ("setting value from %g to %g", dparam->value_float, + g_value_get_float (value)); + dparam->value_float = g_value_get_float (value); + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + case ARG_VALUE_DOUBLE: + GST_DEBUG ("setting value from %g to %g", + dparam->value_double, g_value_get_double (value)); + dparam->value_double = g_value_get_double (value); + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + case ARG_VALUE_INT: + GST_DEBUG ("setting value from %d to %d", dparam->value_int, + g_value_get_int (value)); + dparam->value_int = g_value_get_int (value); + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + case ARG_VALUE_INT64: + GST_DEBUG ("setting value from %" + G_GINT64_FORMAT " to %" + G_GINT64_FORMAT, dparam->value_int64, g_value_get_int64 (value)); + dparam->value_int64 = g_value_get_int64 (value); + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + default: + break; + } + + /* note that this signal is sent while we still have the lock. */ + g_signal_emit (G_OBJECT (dparam), gst_dparam_signals[VALUE_CHANGED], 0); + GST_DPARAM_UNLOCK (dparam); } void -gst_dparam_do_update_default (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info) +gst_dparam_do_update_default (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info) { - GST_DPARAM_LOCK(dparam); - - g_return_if_fail (G_VALUE_TYPE(value) == GST_DPARAM_TYPE(dparam)); - GST_DEBUG ("updating value for %s(%p)",GST_DPARAM_NAME (dparam),dparam); - - switch (G_VALUE_TYPE(value)) { - case G_TYPE_FLOAT: - g_value_set_float(value, dparam->value_float); - break; - - case G_TYPE_DOUBLE: - g_value_set_double(value, dparam->value_double); - break; - - case G_TYPE_INT: - g_value_set_int(value, dparam->value_int); - break; - - case G_TYPE_INT64: - g_value_set_int64(value, dparam->value_int64); - break; - - default: - break; - } - - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp; - GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE; - - GST_DPARAM_UNLOCK(dparam); + GST_DPARAM_LOCK (dparam); + + g_return_if_fail (G_VALUE_TYPE (value) == GST_DPARAM_TYPE (dparam)); + GST_DEBUG ("updating value for %s(%p)", GST_DPARAM_NAME (dparam), dparam); + + switch (G_VALUE_TYPE (value)) { + case G_TYPE_FLOAT: + g_value_set_float (value, dparam->value_float); + break; + + case G_TYPE_DOUBLE: + g_value_set_double (value, dparam->value_double); + break; + + case G_TYPE_INT: + g_value_set_int (value, dparam->value_int); + break; + + case G_TYPE_INT64: + g_value_set_int64 (value, dparam->value_int64); + break; + + default: + break; + } + + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = timestamp; + GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE; + + GST_DPARAM_UNLOCK (dparam); } static void -gst_dparam_dispose (GObject *object) +gst_dparam_dispose (GObject * object) { - GstDParam *dparam = GST_DPARAM(object); - gchar *dparam_name = g_strdup(GST_DPARAM_NAME(dparam)); - - GST_DEBUG ("disposing of %s", dparam_name); - if (GST_DPARAM_MANAGER(dparam)){ - gst_dpman_detach_dparam(GST_DPARAM_MANAGER(dparam), dparam_name); - } - g_free(dparam_name); + GstDParam *dparam = GST_DPARAM (object); + gchar *dparam_name = g_strdup (GST_DPARAM_NAME (dparam)); + + GST_DEBUG ("disposing of %s", dparam_name); + if (GST_DPARAM_MANAGER (dparam)) { + gst_dpman_detach_dparam (GST_DPARAM_MANAGER (dparam), dparam_name); + } + g_free (dparam_name); } /** @@ -283,24 +298,26 @@ gst_dparam_dispose (GObject *object) * */ void -gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GParamSpec *param_spec, gchar *unit_name) +gst_dparam_attach (GstDParam * dparam, GstDParamManager * manager, + GParamSpec * param_spec, gchar * unit_name) { - - g_return_if_fail (dparam != NULL); - g_return_if_fail (GST_IS_DPARAM (dparam)); - g_return_if_fail (manager != NULL); - g_return_if_fail (GST_IS_DPMAN (manager)); - g_return_if_fail (param_spec != NULL); - g_return_if_fail (unit_name != NULL); - g_return_if_fail (G_IS_PARAM_SPEC (param_spec)); - g_return_if_fail (G_PARAM_SPEC_VALUE_TYPE (param_spec) == GST_DPARAM_TYPE(dparam)); - - GST_DPARAM_NAME(dparam) = g_param_spec_get_name(param_spec); - GST_DPARAM_PARAM_SPEC(dparam) = param_spec; - GST_DPARAM_MANAGER(dparam) = manager; - GST_DPARAM_UNIT_NAME(dparam) = unit_name; - GST_DPARAM_IS_LOG(dparam) = gst_unitconv_unit_is_logarithmic(unit_name); - GST_DEBUG ("attaching %s to dparam %p",GST_DPARAM_NAME (dparam),dparam); + + g_return_if_fail (dparam != NULL); + g_return_if_fail (GST_IS_DPARAM (dparam)); + g_return_if_fail (manager != NULL); + g_return_if_fail (GST_IS_DPMAN (manager)); + g_return_if_fail (param_spec != NULL); + g_return_if_fail (unit_name != NULL); + g_return_if_fail (G_IS_PARAM_SPEC (param_spec)); + g_return_if_fail (G_PARAM_SPEC_VALUE_TYPE (param_spec) == + GST_DPARAM_TYPE (dparam)); + + GST_DPARAM_NAME (dparam) = g_param_spec_get_name (param_spec); + GST_DPARAM_PARAM_SPEC (dparam) = param_spec; + GST_DPARAM_MANAGER (dparam) = manager; + GST_DPARAM_UNIT_NAME (dparam) = unit_name; + GST_DPARAM_IS_LOG (dparam) = gst_unitconv_unit_is_logarithmic (unit_name); + GST_DEBUG ("attaching %s to dparam %p", GST_DPARAM_NAME (dparam), dparam); } @@ -311,15 +328,15 @@ gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GParamSpec *par * */ void -gst_dparam_detach (GstDParam *dparam) +gst_dparam_detach (GstDParam * dparam) { - - g_return_if_fail (dparam != NULL); - g_return_if_fail (GST_IS_DPARAM (dparam)); - - GST_DEBUG ("detaching %s from dparam %p",GST_DPARAM_NAME (dparam),dparam); - - GST_DPARAM_NAME(dparam) = NULL; - GST_DPARAM_PARAM_SPEC(dparam) = NULL; - GST_DPARAM_MANAGER(dparam) = NULL; + + g_return_if_fail (dparam != NULL); + g_return_if_fail (GST_IS_DPARAM (dparam)); + + GST_DEBUG ("detaching %s from dparam %p", GST_DPARAM_NAME (dparam), dparam); + + GST_DPARAM_NAME (dparam) = NULL; + GST_DPARAM_PARAM_SPEC (dparam) = NULL; + GST_DPARAM_MANAGER (dparam) = NULL; } diff --git a/libs/gst/control/dparam.h b/libs/gst/control/dparam.h index cf0a2c141..0f51092f3 100644 --- a/libs/gst/control/dparam.h +++ b/libs/gst/control/dparam.h @@ -26,13 +26,11 @@ #include "dparamcommon.h" G_BEGIN_DECLS - #define GST_TYPE_DPARAM (gst_dparam_get_type ()) #define GST_DPARAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPARAM,GstDParam)) #define GST_DPARAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPARAM,GstDParam)) #define GST_IS_DPARAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPARAM)) #define GST_IS_DPARAM_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPARAM)) - #define GST_DPARAM_NAME(dparam) (GST_OBJECT_NAME(dparam)) #define GST_DPARAM_PARENT(dparam) (GST_OBJECT_PARENT(dparam)) #define GST_DPARAM_CHANGE_VALUE(dparam) ((dparam)->change_value) @@ -45,65 +43,67 @@ G_BEGIN_DECLS #define GST_DPARAM_META_PARAM_SPECS(dparam) ((dparam)->meta_param_specs) #define GST_DPARAM_LOCK(dparam) (g_mutex_lock((dparam)->lock)) #define GST_DPARAM_UNLOCK(dparam) (g_mutex_unlock((dparam)->lock)) - #define GST_DPARAM_READY_FOR_UPDATE(dparam) ((dparam)->ready_for_update) #define GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) ((dparam)->next_update_timestamp) #define GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) ((dparam)->last_update_timestamp) - #define GST_DPARAM_DO_UPDATE(dparam, timestamp, value, update_info) \ ((dparam->do_update_func)(dparam, timestamp, value, update_info)) - typedef struct _GstDParamClass GstDParamClass; -typedef enum { +typedef enum +{ GST_DPARAM_UPDATE_FIRST, GST_DPARAM_UPDATE_NORMAL, } GstDParamUpdateInfo; -typedef void (*GstDParamDoUpdateFunction) (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info); +typedef void (*GstDParamDoUpdateFunction) (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info); + +struct _GstDParam +{ + GstObject object; -struct _GstDParam { - GstObject object; + GstDParamDoUpdateFunction do_update_func; - GstDParamDoUpdateFunction do_update_func; - - GMutex *lock; + GMutex *lock; - gfloat value_float; - gdouble value_double; - gint value_int; - gint64 value_int64; - - GstDParamManager *manager; - GParamSpec *param_spec; - GType type; - gboolean ready_for_update; + gfloat value_float; + gdouble value_double; + gint value_int; + gint64 value_int64; - gint64 next_update_timestamp; - gint64 last_update_timestamp; - gchar *unit_name; - gboolean is_log; + GstDParamManager *manager; + GParamSpec *param_spec; + GType type; + gboolean ready_for_update; - gpointer _gst_reserved[GST_PADDING]; + gint64 next_update_timestamp; + gint64 last_update_timestamp; + gchar *unit_name; + gboolean is_log; + + gpointer _gst_reserved[GST_PADDING]; }; -struct _GstDParamClass { - GstObjectClass parent_class; +struct _GstDParamClass +{ + GstObjectClass parent_class; - /* signal callbacks */ - void (*value_changed) (GstDParam *dparam); + /* signal callbacks */ + void (*value_changed) (GstDParam * dparam); - gpointer _gst_reserved[GST_PADDING]; + gpointer _gst_reserved[GST_PADDING]; }; GType gst_dparam_get_type (void); -GstDParam* gst_dparam_new (GType type); -void gst_dparam_attach (GstDParam *dparam, GstDParamManager *manager, GParamSpec *param_spec, gchar *unit_name); -void gst_dparam_detach (GstDParam *dparam); -void gst_dparam_do_update_default (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info); +GstDParam *gst_dparam_new (GType type); +void gst_dparam_attach (GstDParam * dparam, GstDParamManager * manager, + GParamSpec * param_spec, gchar * unit_name); +void gst_dparam_detach (GstDParam * dparam); +void gst_dparam_do_update_default (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info); G_END_DECLS - #endif /* __GST_DPARAM_H__ */ diff --git a/libs/gst/control/dparam_smooth.c b/libs/gst/control/dparam_smooth.c index 3d5af321f..cf0d3384c 100644 --- a/libs/gst/control/dparam_smooth.c +++ b/libs/gst/control/dparam_smooth.c @@ -30,94 +30,102 @@ #include "dparam_smooth.h" #include "dparammanager.h" -GST_DEBUG_CATEGORY_EXTERN(_gst_control_debug); - -static void gst_dpsmooth_class_init (GstDParamSmoothClass *klass); -static void gst_dpsmooth_init (GstDParamSmooth *dparam); -static void gst_dpsmooth_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_dpsmooth_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gst_dpsmooth_do_update_float (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info); -static void gst_dpsmooth_value_changed_float (GstDParam *dparam); -static void gst_dpsmooth_do_update_double (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info); -static void gst_dpsmooth_value_changed_double (GstDParam *dparam); - -enum { - ARG_0, - ARG_UPDATE_PERIOD, - ARG_SLOPE_TIME, - ARG_SLOPE_DELTA_FLOAT, - ARG_SLOPE_DELTA_DOUBLE, - ARG_SLOPE_DELTA_INT, - ARG_SLOPE_DELTA_INT64, +GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug); + +static void gst_dpsmooth_class_init (GstDParamSmoothClass * klass); +static void gst_dpsmooth_init (GstDParamSmooth * dparam); +static void gst_dpsmooth_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_dpsmooth_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static void gst_dpsmooth_do_update_float (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info); +static void gst_dpsmooth_value_changed_float (GstDParam * dparam); +static void gst_dpsmooth_do_update_double (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info); +static void gst_dpsmooth_value_changed_double (GstDParam * dparam); + +enum +{ + ARG_0, + ARG_UPDATE_PERIOD, + ARG_SLOPE_TIME, + ARG_SLOPE_DELTA_FLOAT, + ARG_SLOPE_DELTA_DOUBLE, + ARG_SLOPE_DELTA_INT, + ARG_SLOPE_DELTA_INT64, }; -GType -gst_dpsmooth_get_type(void) { - static GType dpsmooth_type = 0; - - if (!dpsmooth_type) { - static const GTypeInfo dpsmooth_info = { - sizeof(GstDParamSmoothClass), - NULL, - NULL, - (GClassInitFunc)gst_dpsmooth_class_init, - NULL, - NULL, - sizeof(GstDParamSmooth), - 0, - (GInstanceInitFunc)gst_dpsmooth_init, - }; - dpsmooth_type = g_type_register_static(GST_TYPE_DPARAM, "GstDParamSmooth", &dpsmooth_info, 0); - } - return dpsmooth_type; +GType +gst_dpsmooth_get_type (void) +{ + static GType dpsmooth_type = 0; + + if (!dpsmooth_type) { + static const GTypeInfo dpsmooth_info = { + sizeof (GstDParamSmoothClass), + NULL, + NULL, + (GClassInitFunc) gst_dpsmooth_class_init, + NULL, + NULL, + sizeof (GstDParamSmooth), + 0, + (GInstanceInitFunc) gst_dpsmooth_init, + }; + dpsmooth_type = + g_type_register_static (GST_TYPE_DPARAM, "GstDParamSmooth", + &dpsmooth_info, 0); + } + return dpsmooth_type; } static void -gst_dpsmooth_class_init (GstDParamSmoothClass *klass) +gst_dpsmooth_class_init (GstDParamSmoothClass * klass) { - GObjectClass *gobject_class; - GstDParamSmoothClass *dpsmooth_class; - GstObjectClass *gstobject_class; - - gobject_class = (GObjectClass*)klass; - dpsmooth_class = (GstDParamSmoothClass*)klass; - gstobject_class = (GstObjectClass*) klass; - - gobject_class->get_property = gst_dpsmooth_get_property; - gobject_class->set_property = gst_dpsmooth_set_property; - - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_UPDATE_PERIOD, - g_param_spec_int64("update_period", - "Update Period (nanoseconds)", - "Number of nanoseconds between updates", - 0LL, G_MAXINT64, 2000000LL, G_PARAM_READWRITE)); - - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SLOPE_TIME, - g_param_spec_int64("slope_time", - "Slope Time (nanoseconds)", - "The time period to define slope_delta by", - 0LL, G_MAXINT64, 10000000LL, G_PARAM_READWRITE)); - - g_object_class_install_property(G_OBJECT_CLASS(klass), - ARG_SLOPE_DELTA_FLOAT, - g_param_spec_float("slope_delta_float", "Slope Delta float", - "The amount a float value can change for a given slope_time", - 0.0F, G_MAXFLOAT, 0.2F, G_PARAM_READWRITE)); - - g_object_class_install_property(G_OBJECT_CLASS(klass), - ARG_SLOPE_DELTA_DOUBLE, - g_param_spec_double("slope_delta_double", "Slope Delta double", - "The amount a double value can change for a given slope_time", - 0.0, G_MAXDOUBLE, 0.2, G_PARAM_READWRITE)); - - /*gstobject_class->save_thyself = gst_dparam_save_thyself; */ + GObjectClass *gobject_class; + GstDParamSmoothClass *dpsmooth_class; + GstObjectClass *gstobject_class; + + gobject_class = (GObjectClass *) klass; + dpsmooth_class = (GstDParamSmoothClass *) klass; + gstobject_class = (GstObjectClass *) klass; + + gobject_class->get_property = gst_dpsmooth_get_property; + gobject_class->set_property = gst_dpsmooth_set_property; + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_PERIOD, + g_param_spec_int64 ("update_period", + "Update Period (nanoseconds)", + "Number of nanoseconds between updates", + 0LL, G_MAXINT64, 2000000LL, G_PARAM_READWRITE)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLOPE_TIME, + g_param_spec_int64 ("slope_time", + "Slope Time (nanoseconds)", + "The time period to define slope_delta by", + 0LL, G_MAXINT64, 10000000LL, G_PARAM_READWRITE)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_SLOPE_DELTA_FLOAT, + g_param_spec_float ("slope_delta_float", "Slope Delta float", + "The amount a float value can change for a given slope_time", + 0.0F, G_MAXFLOAT, 0.2F, G_PARAM_READWRITE)); + + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_SLOPE_DELTA_DOUBLE, + g_param_spec_double ("slope_delta_double", "Slope Delta double", + "The amount a double value can change for a given slope_time", + 0.0, G_MAXDOUBLE, 0.2, G_PARAM_READWRITE)); + + /*gstobject_class->save_thyself = gst_dparam_save_thyself; */ } static void -gst_dpsmooth_init (GstDParamSmooth *dpsmooth) +gst_dpsmooth_init (GstDParamSmooth * dpsmooth) { - g_return_if_fail (dpsmooth != NULL); + g_return_if_fail (dpsmooth != NULL); } /** @@ -126,311 +134,330 @@ gst_dpsmooth_init (GstDParamSmooth *dpsmooth) * * Returns: a new instance of GstDParam */ -GstDParam* +GstDParam * gst_dpsmooth_new (GType type) { - GstDParam *dparam; - GstDParamSmooth *dpsmooth; - - dpsmooth =g_object_new (gst_dpsmooth_get_type (), NULL); - dparam = GST_DPARAM(dpsmooth); - - GST_DPARAM_TYPE(dparam) = type; - - switch (type){ - case G_TYPE_FLOAT: { - dparam->do_update_func = gst_dpsmooth_do_update_float; - g_signal_connect (G_OBJECT (dpsmooth), "value_changed", - G_CALLBACK (gst_dpsmooth_value_changed_float), NULL); - break; - } - case G_TYPE_DOUBLE: { - dparam->do_update_func = gst_dpsmooth_do_update_double; - g_signal_connect (G_OBJECT (dpsmooth), "value_changed", - G_CALLBACK (gst_dpsmooth_value_changed_double), NULL); - break; - } - default: - /* we don't support this type here */ - dparam->do_update_func = gst_dparam_do_update_default; - break; - } - return dparam; + GstDParam *dparam; + GstDParamSmooth *dpsmooth; + + dpsmooth = g_object_new (gst_dpsmooth_get_type (), NULL); + dparam = GST_DPARAM (dpsmooth); + + GST_DPARAM_TYPE (dparam) = type; + + switch (type) { + case G_TYPE_FLOAT:{ + dparam->do_update_func = gst_dpsmooth_do_update_float; + g_signal_connect (G_OBJECT (dpsmooth), "value_changed", + G_CALLBACK (gst_dpsmooth_value_changed_float), NULL); + break; + } + case G_TYPE_DOUBLE:{ + dparam->do_update_func = gst_dpsmooth_do_update_double; + g_signal_connect (G_OBJECT (dpsmooth), "value_changed", + G_CALLBACK (gst_dpsmooth_value_changed_double), NULL); + break; + } + default: + /* we don't support this type here */ + dparam->do_update_func = gst_dparam_do_update_default; + break; + } + return dparam; } -static void -gst_dpsmooth_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_dpsmooth_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { - GstDParam *dparam; - GstDParamSmooth *dpsmooth; - - g_return_if_fail(GST_IS_DPSMOOTH(object)); - - dpsmooth = GST_DPSMOOTH(object); - dparam = GST_DPARAM(object); - - GST_DPARAM_LOCK(dparam); - - switch (prop_id) { - case ARG_UPDATE_PERIOD: - dpsmooth->update_period = g_value_get_int64 (value); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - case ARG_SLOPE_TIME: - dpsmooth->slope_time = g_value_get_int64 (value); - GST_DEBUG ("dpsmooth->slope_time:%" - G_GINT64_FORMAT, - dpsmooth->slope_time); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - case ARG_SLOPE_DELTA_FLOAT: - dpsmooth->slope_delta_float = g_value_get_float (value); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - case ARG_SLOPE_DELTA_DOUBLE: - dpsmooth->slope_delta_double = g_value_get_double (value); - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - break; - - default: - break; - } - GST_DPARAM_UNLOCK(dparam); + GstDParam *dparam; + GstDParamSmooth *dpsmooth; + + g_return_if_fail (GST_IS_DPSMOOTH (object)); + + dpsmooth = GST_DPSMOOTH (object); + dparam = GST_DPARAM (object); + + GST_DPARAM_LOCK (dparam); + + switch (prop_id) { + case ARG_UPDATE_PERIOD: + dpsmooth->update_period = g_value_get_int64 (value); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + case ARG_SLOPE_TIME: + dpsmooth->slope_time = g_value_get_int64 (value); + GST_DEBUG ("dpsmooth->slope_time:%" + G_GINT64_FORMAT, dpsmooth->slope_time); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + case ARG_SLOPE_DELTA_FLOAT: + dpsmooth->slope_delta_float = g_value_get_float (value); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + case ARG_SLOPE_DELTA_DOUBLE: + dpsmooth->slope_delta_double = g_value_get_double (value); + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + break; + + default: + break; + } + GST_DPARAM_UNLOCK (dparam); } -static void -gst_dpsmooth_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_dpsmooth_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { - GstDParam *dparam; - GstDParamSmooth *dpsmooth; - - g_return_if_fail(GST_IS_DPSMOOTH(object)); - - dpsmooth = GST_DPSMOOTH(object); - dparam = GST_DPARAM(object); - - switch (prop_id) { - case ARG_UPDATE_PERIOD: - g_value_set_int64(value, dpsmooth->update_period); - break; - case ARG_SLOPE_TIME: - g_value_set_int64(value, dpsmooth->slope_time); - break; - case ARG_SLOPE_DELTA_FLOAT: - g_value_set_float (value, dpsmooth->slope_delta_float); - break; - case ARG_SLOPE_DELTA_DOUBLE: - g_value_set_double (value, dpsmooth->slope_delta_double); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + GstDParam *dparam; + GstDParamSmooth *dpsmooth; + + g_return_if_fail (GST_IS_DPSMOOTH (object)); + + dpsmooth = GST_DPSMOOTH (object); + dparam = GST_DPARAM (object); + + switch (prop_id) { + case ARG_UPDATE_PERIOD: + g_value_set_int64 (value, dpsmooth->update_period); + break; + case ARG_SLOPE_TIME: + g_value_set_int64 (value, dpsmooth->slope_time); + break; + case ARG_SLOPE_DELTA_FLOAT: + g_value_set_float (value, dpsmooth->slope_delta_float); + break; + case ARG_SLOPE_DELTA_DOUBLE: + g_value_set_double (value, dpsmooth->slope_delta_double); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } -static void -gst_dpsmooth_value_changed_float (GstDParam *dparam) +static void +gst_dpsmooth_value_changed_float (GstDParam * dparam) { - GstDParamSmooth *dpsmooth; - gfloat time_ratio; + GstDParamSmooth *dpsmooth; + gfloat time_ratio; - g_return_if_fail(GST_IS_DPSMOOTH(dparam)); - dpsmooth = GST_DPSMOOTH(dparam); + g_return_if_fail (GST_IS_DPSMOOTH (dparam)); + dpsmooth = GST_DPSMOOTH (dparam); - if (GST_DPARAM_IS_LOG(dparam)){ - dparam->value_float = log(dparam->value_float); - } - dpsmooth->start_float = dpsmooth->current_float; - dpsmooth->diff_float = dparam->value_float - dpsmooth->start_float; + if (GST_DPARAM_IS_LOG (dparam)) { + dparam->value_float = log (dparam->value_float); + } + dpsmooth->start_float = dpsmooth->current_float; + dpsmooth->diff_float = dparam->value_float - dpsmooth->start_float; - time_ratio = ABS(dpsmooth->diff_float) / dpsmooth->slope_delta_float; - dpsmooth->duration_interp = (gint64)(time_ratio * (gfloat)dpsmooth->slope_time); + time_ratio = ABS (dpsmooth->diff_float) / dpsmooth->slope_delta_float; + dpsmooth->duration_interp = + (gint64) (time_ratio * (gfloat) dpsmooth->slope_time); - dpsmooth->need_interp_times = TRUE; + dpsmooth->need_interp_times = TRUE; - GST_DEBUG ("%f to %f ratio:%f duration:%" - G_GINT64_FORMAT "\n", - dpsmooth->start_float, dparam->value_float, time_ratio, dpsmooth->duration_interp); + GST_DEBUG ("%f to %f ratio:%f duration:%" + G_GINT64_FORMAT "\n", + dpsmooth->start_float, dparam->value_float, time_ratio, + dpsmooth->duration_interp); } static void -gst_dpsmooth_do_update_float (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info) +gst_dpsmooth_do_update_float (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info) { - gfloat time_ratio; - GstDParamSmooth *dpsmooth = GST_DPSMOOTH(dparam); - - GST_DPARAM_LOCK(dparam); - - if (dpsmooth->need_interp_times){ - dpsmooth->start_interp = timestamp; - dpsmooth->end_interp = timestamp + dpsmooth->duration_interp; - dpsmooth->need_interp_times = FALSE; - } - - if ((update_info == GST_DPARAM_UPDATE_FIRST) || (timestamp >= dpsmooth->end_interp)){ - if (GST_DPARAM_IS_LOG(dparam)){ - g_value_set_float(value, exp(dparam->value_float)); - } - else { - g_value_set_float(value, dparam->value_float); - } - dpsmooth->current_float = dparam->value_float; - - GST_DEBUG ("interp finished at %" - G_GINT64_FORMAT, timestamp); - - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp; - - GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE; - GST_DPARAM_UNLOCK(dparam); - return; - } - - if (timestamp <= dpsmooth->start_interp){ - if (GST_DPARAM_IS_LOG(dparam)){ - g_value_set_float(value, exp(dpsmooth->start_float)); - } - else { - g_value_set_float(value, dpsmooth->start_float); - } - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->start_interp + dpsmooth->update_period; - - GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp); - - GST_DPARAM_UNLOCK(dparam); - return; - - } - - time_ratio = (gfloat)(timestamp - dpsmooth->start_interp) / (gfloat)dpsmooth->duration_interp; - - GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp, dpsmooth->end_interp, time_ratio); - GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_float, dpsmooth->current_float, dparam->value_float); - - dpsmooth->current_float = dpsmooth->start_float + (dpsmooth->diff_float * time_ratio); - - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp + dpsmooth->update_period; - if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) > dpsmooth->end_interp){ - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->end_interp; - } - - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - - if (GST_DPARAM_IS_LOG(dparam)){ - g_value_set_float(value, exp(dpsmooth->current_float)); - } - else { - g_value_set_float(value, dpsmooth->current_float); - } - - GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_float, dpsmooth->current_float, dparam->value_float); - - GST_DPARAM_UNLOCK(dparam); + gfloat time_ratio; + GstDParamSmooth *dpsmooth = GST_DPSMOOTH (dparam); + + GST_DPARAM_LOCK (dparam); + + if (dpsmooth->need_interp_times) { + dpsmooth->start_interp = timestamp; + dpsmooth->end_interp = timestamp + dpsmooth->duration_interp; + dpsmooth->need_interp_times = FALSE; + } + + if ((update_info == GST_DPARAM_UPDATE_FIRST) + || (timestamp >= dpsmooth->end_interp)) { + if (GST_DPARAM_IS_LOG (dparam)) { + g_value_set_float (value, exp (dparam->value_float)); + } else { + g_value_set_float (value, dparam->value_float); + } + dpsmooth->current_float = dparam->value_float; + + GST_DEBUG ("interp finished at %" G_GINT64_FORMAT, timestamp); + + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = timestamp; + + GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE; + GST_DPARAM_UNLOCK (dparam); + return; + } + + if (timestamp <= dpsmooth->start_interp) { + if (GST_DPARAM_IS_LOG (dparam)) { + g_value_set_float (value, exp (dpsmooth->start_float)); + } else { + g_value_set_float (value, dpsmooth->start_float); + } + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + dpsmooth->start_interp + dpsmooth->update_period; + + GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp); + + GST_DPARAM_UNLOCK (dparam); + return; + + } + + time_ratio = + (gfloat) (timestamp - + dpsmooth->start_interp) / (gfloat) dpsmooth->duration_interp; + + GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%" + G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp, + dpsmooth->end_interp, time_ratio); + GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_float, + dpsmooth->current_float, dparam->value_float); + + dpsmooth->current_float = + dpsmooth->start_float + (dpsmooth->diff_float * time_ratio); + + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + timestamp + dpsmooth->update_period; + if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) > dpsmooth->end_interp) { + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = dpsmooth->end_interp; + } + + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + + if (GST_DPARAM_IS_LOG (dparam)) { + g_value_set_float (value, exp (dpsmooth->current_float)); + } else { + g_value_set_float (value, dpsmooth->current_float); + } + + GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_float, + dpsmooth->current_float, dparam->value_float); + + GST_DPARAM_UNLOCK (dparam); } -static void -gst_dpsmooth_value_changed_double (GstDParam *dparam) +static void +gst_dpsmooth_value_changed_double (GstDParam * dparam) { - GstDParamSmooth *dpsmooth; - gdouble time_ratio; + GstDParamSmooth *dpsmooth; + gdouble time_ratio; - g_return_if_fail(GST_IS_DPSMOOTH(dparam)); - dpsmooth = GST_DPSMOOTH(dparam); + g_return_if_fail (GST_IS_DPSMOOTH (dparam)); + dpsmooth = GST_DPSMOOTH (dparam); - if (GST_DPARAM_IS_LOG(dparam)){ - dparam->value_double = log(dparam->value_double); - } - dpsmooth->start_double = dpsmooth->current_double; - dpsmooth->diff_double = dparam->value_double - dpsmooth->start_double; + if (GST_DPARAM_IS_LOG (dparam)) { + dparam->value_double = log (dparam->value_double); + } + dpsmooth->start_double = dpsmooth->current_double; + dpsmooth->diff_double = dparam->value_double - dpsmooth->start_double; - time_ratio = ABS(dpsmooth->diff_double) / dpsmooth->slope_delta_double; - dpsmooth->duration_interp = (gint64)(time_ratio * (gdouble)dpsmooth->slope_time); + time_ratio = ABS (dpsmooth->diff_double) / dpsmooth->slope_delta_double; + dpsmooth->duration_interp = + (gint64) (time_ratio * (gdouble) dpsmooth->slope_time); - dpsmooth->need_interp_times = TRUE; + dpsmooth->need_interp_times = TRUE; - GST_DEBUG ("%f to %f ratio:%f duration:%" - G_GINT64_FORMAT "\n", - dpsmooth->start_double, dparam->value_double, time_ratio, dpsmooth->duration_interp); + GST_DEBUG ("%f to %f ratio:%f duration:%" + G_GINT64_FORMAT "\n", + dpsmooth->start_double, dparam->value_double, time_ratio, + dpsmooth->duration_interp); } static void -gst_dpsmooth_do_update_double (GstDParam *dparam, gint64 timestamp, GValue *value, GstDParamUpdateInfo update_info) +gst_dpsmooth_do_update_double (GstDParam * dparam, gint64 timestamp, + GValue * value, GstDParamUpdateInfo update_info) { - gdouble time_ratio; - GstDParamSmooth *dpsmooth = GST_DPSMOOTH(dparam); - - GST_DPARAM_LOCK(dparam); - - if (dpsmooth->need_interp_times){ - dpsmooth->start_interp = timestamp; - dpsmooth->end_interp = timestamp + dpsmooth->duration_interp; - dpsmooth->need_interp_times = FALSE; - } - - if ((update_info == GST_DPARAM_UPDATE_FIRST) || (timestamp >= dpsmooth->end_interp)){ - if (GST_DPARAM_IS_LOG(dparam)){ - g_value_set_double(value, exp(dparam->value_double)); - } - else { - g_value_set_double(value, dparam->value_double); - } - dpsmooth->current_double = dparam->value_double; - - GST_DEBUG ("interp finished at %" - G_GINT64_FORMAT, timestamp); - - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp; - - GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE; - GST_DPARAM_UNLOCK(dparam); - return; - } - - if (timestamp <= dpsmooth->start_interp){ - if (GST_DPARAM_IS_LOG(dparam)){ - g_value_set_double(value, exp(dpsmooth->start_double)); - } - else { - g_value_set_double(value, dpsmooth->start_double); - } - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->start_interp + dpsmooth->update_period; - - GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp); - - GST_DPARAM_UNLOCK(dparam); - return; - - } - - time_ratio = (gdouble)(timestamp - dpsmooth->start_interp) / (gdouble)dpsmooth->duration_interp; - - GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%" G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp, dpsmooth->end_interp, time_ratio); - GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_double, dpsmooth->current_double, dparam->value_double); - - dpsmooth->current_double = dpsmooth->start_double + (dpsmooth->diff_double * time_ratio); - - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = timestamp + dpsmooth->update_period; - if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) > dpsmooth->end_interp){ - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = dpsmooth->end_interp; - } - - GST_DPARAM_LAST_UPDATE_TIMESTAMP(dparam) = timestamp; - - if (GST_DPARAM_IS_LOG(dparam)){ - g_value_set_double(value, exp(dpsmooth->current_double)); - } - else { - g_value_set_double(value, dpsmooth->current_double); - } - - GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_double, dpsmooth->current_double, dparam->value_double); - - GST_DPARAM_UNLOCK(dparam); + gdouble time_ratio; + GstDParamSmooth *dpsmooth = GST_DPSMOOTH (dparam); + + GST_DPARAM_LOCK (dparam); + + if (dpsmooth->need_interp_times) { + dpsmooth->start_interp = timestamp; + dpsmooth->end_interp = timestamp + dpsmooth->duration_interp; + dpsmooth->need_interp_times = FALSE; + } + + if ((update_info == GST_DPARAM_UPDATE_FIRST) + || (timestamp >= dpsmooth->end_interp)) { + if (GST_DPARAM_IS_LOG (dparam)) { + g_value_set_double (value, exp (dparam->value_double)); + } else { + g_value_set_double (value, dparam->value_double); + } + dpsmooth->current_double = dparam->value_double; + + GST_DEBUG ("interp finished at %" G_GINT64_FORMAT, timestamp); + + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = timestamp; + + GST_DPARAM_READY_FOR_UPDATE (dparam) = FALSE; + GST_DPARAM_UNLOCK (dparam); + return; + } + + if (timestamp <= dpsmooth->start_interp) { + if (GST_DPARAM_IS_LOG (dparam)) { + g_value_set_double (value, exp (dpsmooth->start_double)); + } else { + g_value_set_double (value, dpsmooth->start_double); + } + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + dpsmooth->start_interp + dpsmooth->update_period; + + GST_DEBUG ("interp started at %" G_GINT64_FORMAT, timestamp); + + GST_DPARAM_UNLOCK (dparam); + return; + + } + + time_ratio = + (gdouble) (timestamp - + dpsmooth->start_interp) / (gdouble) dpsmooth->duration_interp; + + GST_DEBUG ("start:%" G_GINT64_FORMAT " current:%" G_GINT64_FORMAT " end:%" + G_GINT64_FORMAT " ratio%f", dpsmooth->start_interp, timestamp, + dpsmooth->end_interp, time_ratio); + GST_DEBUG ("pre start:%f current:%f target:%f", dpsmooth->start_double, + dpsmooth->current_double, dparam->value_double); + + dpsmooth->current_double = + dpsmooth->start_double + (dpsmooth->diff_double * time_ratio); + + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = + timestamp + dpsmooth->update_period; + if (GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) > dpsmooth->end_interp) { + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = dpsmooth->end_interp; + } + + GST_DPARAM_LAST_UPDATE_TIMESTAMP (dparam) = timestamp; + + if (GST_DPARAM_IS_LOG (dparam)) { + g_value_set_double (value, exp (dpsmooth->current_double)); + } else { + g_value_set_double (value, dpsmooth->current_double); + } + + GST_DEBUG ("post start:%f current:%f target:%f", dpsmooth->start_double, + dpsmooth->current_double, dparam->value_double); + + GST_DPARAM_UNLOCK (dparam); } diff --git a/libs/gst/control/dparam_smooth.h b/libs/gst/control/dparam_smooth.h index 3731e9e5a..16d78b112 100644 --- a/libs/gst/control/dparam_smooth.h +++ b/libs/gst/control/dparam_smooth.h @@ -25,51 +25,50 @@ #include "dparam.h" G_BEGIN_DECLS - #define GST_TYPE_DPSMOOTH (gst_dpsmooth_get_type ()) #define GST_DPSMOOTH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPSMOOTH,GstDParamSmooth)) #define GST_DPSMOOTH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPSMOOTH,GstDParamSmooth)) #define GST_IS_DPSMOOTH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPSMOOTH)) #define GST_IS_DPSMOOTH_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPSMOOTH)) - typedef struct _GstDParamSmoothClass GstDParamSmoothClass; typedef struct _GstDParamSmooth GstDParamSmooth; -struct _GstDParamSmooth { - GstDParam dparam; +struct _GstDParamSmooth +{ + GstDParam dparam; - gint64 start_interp; - gint64 end_interp; - gint64 duration_interp; + gint64 start_interp; + gint64 end_interp; + gint64 duration_interp; - gfloat start_float; - gfloat diff_float; - gfloat current_float; - gdouble start_double; - gdouble diff_double; - gdouble current_double; + gfloat start_float; + gfloat diff_float; + gfloat current_float; + gdouble start_double; + gdouble diff_double; + gdouble current_double; - gint64 update_period; - gint64 slope_time; - gfloat slope_delta_float; - gdouble slope_delta_double; + gint64 update_period; + gint64 slope_time; + gfloat slope_delta_float; + gdouble slope_delta_double; - gboolean need_interp_times; + gboolean need_interp_times; - gpointer _gst_reserved[GST_PADDING]; + gpointer _gst_reserved[GST_PADDING]; }; -struct _GstDParamSmoothClass { - GstDParamClass parent_class; +struct _GstDParamSmoothClass +{ + GstDParamClass parent_class; - /* signal callbacks */ - gpointer _gst_reserved[GST_PADDING]; + /* signal callbacks */ + gpointer _gst_reserved[GST_PADDING]; }; GType gst_dpsmooth_get_type (void); -GstDParam* gst_dpsmooth_new (GType type); +GstDParam *gst_dpsmooth_new (GType type); G_END_DECLS - #endif /* __GST_DPSMOOTH_H__ */ diff --git a/libs/gst/control/dparamcommon.h b/libs/gst/control/dparamcommon.h index 05e1e9fb3..7231f40f8 100644 --- a/libs/gst/control/dparamcommon.h +++ b/libs/gst/control/dparamcommon.h @@ -22,11 +22,8 @@ #ifndef __GST_DPCOMMON_H__ #define __GST_DPCOMMON_H__ -G_BEGIN_DECLS - -typedef struct _GstDParam GstDParam; +G_BEGIN_DECLS typedef struct _GstDParam GstDParam; typedef struct _GstDParamManager GstDParamManager; G_END_DECLS - #endif /* __GST_DPCOMMON_H__ */ diff --git a/libs/gst/control/dparammanager.c b/libs/gst/control/dparammanager.c index 6393522b9..407f44e83 100644 --- a/libs/gst/control/dparammanager.c +++ b/libs/gst/control/dparammanager.c @@ -24,110 +24,123 @@ #include #include -GST_DEBUG_CATEGORY_EXTERN(_gst_control_debug); +GST_DEBUG_CATEGORY_EXTERN (_gst_control_debug); static GHashTable *_element_registry = NULL; static gboolean _gst_dpman_init_done = FALSE; -enum { +enum +{ NEW_REQUIRED_DPARAM, LAST_SIGNAL }; -static void gst_dpman_class_init (GstDParamManagerClass *klass); -static void gst_dpman_init (GstDParamManager *dpman); -static void gst_dpman_dispose (GObject *object); -static GstDParamWrapper* gst_dpman_new_wrapper(GstDParamManager *dpman, GParamSpec *param_spec, gchar *unit_name, GstDPMUpdateMethod update_method); -static GstDParamWrapper* gst_dpman_get_wrapper(GstDParamManager *dpman, gchar *dparam_name); -static void gst_dpman_state_change (GstElement *element, gint old_state, gint new_state, GstDParamManager *dpman); -static gboolean gst_dpman_preprocess_synchronous(GstDParamManager *dpman, guint frames, gint64 timestamp); -static gboolean gst_dpman_preprocess_asynchronous(GstDParamManager *dpman, guint frames, gint64 timestamp); -static gboolean gst_dpman_process_asynchronous(GstDParamManager *dpman, guint frame_count); -static gboolean gst_dpman_preprocess_noop(GstDParamManager *dpman, guint frames, gint64 timestamp); -static gboolean gst_dpman_process_noop(GstDParamManager *dpman, guint frame_count); -static void gst_dpman_setup_synchronous(GstDParamManager *dpman); -static void gst_dpman_setup_asynchronous(GstDParamManager *dpman); -static void gst_dpman_setup_disabled(GstDParamManager *dpman); -static void gst_dpman_teardown_synchronous(GstDParamManager *dpman); -static void gst_dpman_teardown_asynchronous(GstDParamManager *dpman); -static void gst_dpman_teardown_disabled(GstDParamManager *dpman); +static void gst_dpman_class_init (GstDParamManagerClass * klass); +static void gst_dpman_init (GstDParamManager * dpman); +static void gst_dpman_dispose (GObject * object); +static GstDParamWrapper *gst_dpman_new_wrapper (GstDParamManager * dpman, + GParamSpec * param_spec, gchar * unit_name, + GstDPMUpdateMethod update_method); +static GstDParamWrapper *gst_dpman_get_wrapper (GstDParamManager * dpman, + gchar * dparam_name); +static void gst_dpman_state_change (GstElement * element, gint old_state, + gint new_state, GstDParamManager * dpman); +static gboolean gst_dpman_preprocess_synchronous (GstDParamManager * dpman, + guint frames, gint64 timestamp); +static gboolean gst_dpman_preprocess_asynchronous (GstDParamManager * dpman, + guint frames, gint64 timestamp); +static gboolean gst_dpman_process_asynchronous (GstDParamManager * dpman, + guint frame_count); +static gboolean gst_dpman_preprocess_noop (GstDParamManager * dpman, + guint frames, gint64 timestamp); +static gboolean gst_dpman_process_noop (GstDParamManager * dpman, + guint frame_count); +static void gst_dpman_setup_synchronous (GstDParamManager * dpman); +static void gst_dpman_setup_asynchronous (GstDParamManager * dpman); +static void gst_dpman_setup_disabled (GstDParamManager * dpman); +static void gst_dpman_teardown_synchronous (GstDParamManager * dpman); +static void gst_dpman_teardown_asynchronous (GstDParamManager * dpman); +static void gst_dpman_teardown_disabled (GstDParamManager * dpman); static GObjectClass *parent_class; static guint gst_dpman_signals[LAST_SIGNAL] = { 0 }; -void -_gst_dpman_initialize() +void +_gst_dpman_initialize () { - if (_gst_dpman_init_done) return; - - _gst_dpman_init_done = TRUE; - _element_registry = g_hash_table_new(NULL,NULL); + if (_gst_dpman_init_done) + return; + + _gst_dpman_init_done = TRUE; + _element_registry = g_hash_table_new (NULL, NULL); } GType gst_dpman_get_type (void) { - static GType dpman_type = 0; - - if (!dpman_type) { - static const GTypeInfo dpman_info = { - sizeof(GstDParamManagerClass), - NULL, - NULL, - (GClassInitFunc)gst_dpman_class_init, - NULL, - NULL, - sizeof(GstDParamManager), - 0, - (GInstanceInitFunc)gst_dpman_init, - }; - dpman_type = g_type_register_static(GST_TYPE_OBJECT, "GstDParamManager", &dpman_info, 0); - } - return dpman_type; + static GType dpman_type = 0; + + if (!dpman_type) { + static const GTypeInfo dpman_info = { + sizeof (GstDParamManagerClass), + NULL, + NULL, + (GClassInitFunc) gst_dpman_class_init, + NULL, + NULL, + sizeof (GstDParamManager), + 0, + (GInstanceInitFunc) gst_dpman_init, + }; + dpman_type = + g_type_register_static (GST_TYPE_OBJECT, "GstDParamManager", + &dpman_info, 0); + } + return dpman_type; } static void -gst_dpman_class_init (GstDParamManagerClass *klass) +gst_dpman_class_init (GstDParamManagerClass * klass) { - GstObjectClass *gstobject_class; - GObjectClass *gobject_class; + GstObjectClass *gstobject_class; + GObjectClass *gobject_class; - parent_class = g_type_class_peek_parent (klass); + parent_class = g_type_class_peek_parent (klass); - gstobject_class = (GstObjectClass*) klass; - gobject_class = (GObjectClass*) klass; - gobject_class->dispose = gst_dpman_dispose; + gstobject_class = (GstObjectClass *) klass; + gobject_class = (GObjectClass *) klass; + gobject_class->dispose = gst_dpman_dispose; - klass->modes = g_hash_table_new(g_str_hash,g_str_equal); + klass->modes = g_hash_table_new (g_str_hash, g_str_equal); - gst_dpman_register_mode (klass, "synchronous", - gst_dpman_preprocess_synchronous, gst_dpman_process_noop, - gst_dpman_setup_synchronous, gst_dpman_teardown_synchronous); - gst_dpman_register_mode (klass, "asynchronous", - gst_dpman_preprocess_asynchronous, gst_dpman_process_asynchronous, - gst_dpman_setup_asynchronous, gst_dpman_teardown_asynchronous); - gst_dpman_register_mode (klass, "disabled", - gst_dpman_preprocess_noop, gst_dpman_process_noop, - gst_dpman_setup_disabled, gst_dpman_teardown_disabled); + gst_dpman_register_mode (klass, "synchronous", + gst_dpman_preprocess_synchronous, gst_dpman_process_noop, + gst_dpman_setup_synchronous, gst_dpman_teardown_synchronous); + gst_dpman_register_mode (klass, "asynchronous", + gst_dpman_preprocess_asynchronous, gst_dpman_process_asynchronous, + gst_dpman_setup_asynchronous, gst_dpman_teardown_asynchronous); + gst_dpman_register_mode (klass, "disabled", + gst_dpman_preprocess_noop, gst_dpman_process_noop, + gst_dpman_setup_disabled, gst_dpman_teardown_disabled); - gst_dpman_signals[NEW_REQUIRED_DPARAM] = - g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstDParamManagerClass, new_required_dparam), NULL, NULL, - gst_marshal_VOID__STRING, G_TYPE_NONE, 1, - G_TYPE_STRING); + gst_dpman_signals[NEW_REQUIRED_DPARAM] = + g_signal_new ("new-required-dparam", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstDParamManagerClass, + new_required_dparam), NULL, NULL, gst_marshal_VOID__STRING, + G_TYPE_NONE, 1, G_TYPE_STRING); } static void -gst_dpman_init (GstDParamManager *dpman) +gst_dpman_init (GstDParamManager * dpman) { - GST_DPMAN_DPARAMS(dpman) = g_hash_table_new(g_str_hash,g_str_equal); - GST_DPMAN_DPARAMS_LIST(dpman) = NULL; - GST_DPMAN_NAME(dpman) = NULL; - GST_DPMAN_PARENT(dpman) = NULL; - GST_DPMAN_MODE_NAME(dpman) = NULL; - GST_DPMAN_MODE(dpman) = NULL; - GST_DPMAN_RATE(dpman) = 0; + GST_DPMAN_DPARAMS (dpman) = g_hash_table_new (g_str_hash, g_str_equal); + GST_DPMAN_DPARAMS_LIST (dpman) = NULL; + GST_DPMAN_NAME (dpman) = NULL; + GST_DPMAN_PARENT (dpman) = NULL; + GST_DPMAN_MODE_NAME (dpman) = NULL; + GST_DPMAN_MODE (dpman) = NULL; + GST_DPMAN_RATE (dpman) = 0; } /** @@ -137,29 +150,29 @@ gst_dpman_init (GstDParamManager *dpman) * * Returns: a new instance of GstDParamManager */ -GstDParamManager* -gst_dpman_new (gchar *name, GstElement *parent) +GstDParamManager * +gst_dpman_new (gchar * name, GstElement * parent) { - GstDParamManager *dpman; - - g_return_val_if_fail (name != NULL, NULL); + GstDParamManager *dpman; + + g_return_val_if_fail (name != NULL, NULL); - dpman = g_object_new (gst_dpman_get_type (), NULL); - gst_object_set_name (GST_OBJECT (dpman), name); - gst_dpman_set_parent(dpman, parent); + dpman = g_object_new (gst_dpman_get_type (), NULL); + gst_object_set_name (GST_OBJECT (dpman), name); + gst_dpman_set_parent (dpman, parent); - gst_dpman_set_mode(dpman, "disabled"); + gst_dpman_set_mode (dpman, "disabled"); - return dpman; + return dpman; } static void -gst_dpman_dispose (GObject *object) +gst_dpman_dispose (GObject * object) { /* GstDParamManager *dpman = GST_DPMAN(object); */ - G_OBJECT_CLASS (parent_class)->dispose (object); + G_OBJECT_CLASS (parent_class)->dispose (object); } /** @@ -170,31 +183,32 @@ gst_dpman_dispose (GObject *object) * * Returns: true if it was successfully added */ -gboolean -gst_dpman_add_required_dparam_callback (GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - GstDPMUpdateFunction update_func, - gpointer update_data) +gboolean +gst_dpman_add_required_dparam_callback (GstDParamManager * dpman, + GParamSpec * param_spec, + gchar * unit_name, GstDPMUpdateFunction update_func, gpointer update_data) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; - g_return_val_if_fail (dpman != NULL, FALSE); - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - g_return_val_if_fail (update_func != NULL, FALSE); + g_return_val_if_fail (dpman != NULL, FALSE); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + g_return_val_if_fail (update_func != NULL, FALSE); - dpwrap = gst_dpman_new_wrapper(dpman, param_spec, unit_name, GST_DPMAN_CALLBACK); + dpwrap = + gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_CALLBACK); - g_return_val_if_fail (dpwrap != NULL, FALSE); + g_return_val_if_fail (dpwrap != NULL, FALSE); - GST_DEBUG ("adding required callback dparam '%s'", g_param_spec_get_name(param_spec)); + GST_DEBUG ("adding required callback dparam '%s'", + g_param_spec_get_name (param_spec)); - dpwrap->update_func = update_func; - dpwrap->update_data = update_data; - - g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, g_param_spec_get_name(param_spec)); + dpwrap->update_func = update_func; + dpwrap->update_data = update_data; - return TRUE; + g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, + g_param_spec_get_name (param_spec)); + + return TRUE; } /** @@ -204,29 +218,30 @@ gst_dpman_add_required_dparam_callback (GstDParamManager *dpman, * * Returns: true if it was successfully added */ -gboolean -gst_dpman_add_required_dparam_direct (GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - gpointer update_data) +gboolean +gst_dpman_add_required_dparam_direct (GstDParamManager * dpman, + GParamSpec * param_spec, gchar * unit_name, gpointer update_data) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; - g_return_val_if_fail (dpman != NULL, FALSE); - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - g_return_val_if_fail (update_data != NULL, FALSE); + g_return_val_if_fail (dpman != NULL, FALSE); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + g_return_val_if_fail (update_data != NULL, FALSE); - dpwrap = gst_dpman_new_wrapper(dpman, param_spec, unit_name, GST_DPMAN_DIRECT); + dpwrap = + gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_DIRECT); - g_return_val_if_fail (dpwrap != NULL, FALSE); + g_return_val_if_fail (dpwrap != NULL, FALSE); - GST_DEBUG ("adding required direct dparam '%s'", g_param_spec_get_name(param_spec)); + GST_DEBUG ("adding required direct dparam '%s'", + g_param_spec_get_name (param_spec)); - dpwrap->update_data = update_data; + dpwrap->update_data = update_data; - g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, g_param_spec_get_name(param_spec)); + g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, + g_param_spec_get_name (param_spec)); - return TRUE; + return TRUE; } /** @@ -237,29 +252,30 @@ gst_dpman_add_required_dparam_direct (GstDParamManager *dpman, * * Returns: true if it was successfully added */ -gboolean -gst_dpman_add_required_dparam_array (GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - gpointer update_data) +gboolean +gst_dpman_add_required_dparam_array (GstDParamManager * dpman, + GParamSpec * param_spec, gchar * unit_name, gpointer update_data) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; - g_return_val_if_fail (dpman != NULL, FALSE); - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - g_return_val_if_fail (update_data != NULL, FALSE); + g_return_val_if_fail (dpman != NULL, FALSE); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + g_return_val_if_fail (update_data != NULL, FALSE); - dpwrap = gst_dpman_new_wrapper(dpman, param_spec, unit_name, GST_DPMAN_ARRAY); + dpwrap = + gst_dpman_new_wrapper (dpman, param_spec, unit_name, GST_DPMAN_ARRAY); - g_return_val_if_fail (dpwrap != NULL, FALSE); + g_return_val_if_fail (dpwrap != NULL, FALSE); - GST_DEBUG ("adding required array dparam '%s'", g_param_spec_get_name(param_spec)); + GST_DEBUG ("adding required array dparam '%s'", + g_param_spec_get_name (param_spec)); - dpwrap->update_data = update_data; + dpwrap->update_data = update_data; - g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, g_param_spec_get_name(param_spec)); + g_signal_emit (G_OBJECT (dpman), gst_dpman_signals[NEW_REQUIRED_DPARAM], 0, + g_param_spec_get_name (param_spec)); - return TRUE; + return TRUE; } /** @@ -268,27 +284,28 @@ gst_dpman_add_required_dparam_array (GstDParamManager *dpman, * @dparam_name: the name of an existing parameter * */ -void -gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name) +void +gst_dpman_remove_required_dparam (GstDParamManager * dpman, gchar * dparam_name) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; - g_return_if_fail (dpman != NULL); - g_return_if_fail (GST_IS_DPMAN (dpman)); - g_return_if_fail (dparam_name != NULL); + g_return_if_fail (dpman != NULL); + g_return_if_fail (GST_IS_DPMAN (dpman)); + g_return_if_fail (dparam_name != NULL); - dpwrap = gst_dpman_get_wrapper(dpman, dparam_name); - - g_return_if_fail(dpwrap != NULL); - g_return_if_fail(dpwrap->dparam == NULL); + dpwrap = gst_dpman_get_wrapper (dpman, dparam_name); - GST_DEBUG ("removing required dparam: %s", dparam_name); - - g_hash_table_remove(GST_DPMAN_DPARAMS(dpman), dparam_name); - GST_DPMAN_DPARAMS_LIST(dpman) = g_list_remove(GST_DPMAN_DPARAMS_LIST(dpman), dpwrap); + g_return_if_fail (dpwrap != NULL); + g_return_if_fail (dpwrap->dparam == NULL); - g_free(dpwrap->value); - g_free(dpwrap); + GST_DEBUG ("removing required dparam: %s", dparam_name); + + g_hash_table_remove (GST_DPMAN_DPARAMS (dpman), dparam_name); + GST_DPMAN_DPARAMS_LIST (dpman) = + g_list_remove (GST_DPMAN_DPARAMS_LIST (dpman), dpwrap); + + g_free (dpwrap->value); + g_free (dpwrap); } /** @@ -299,28 +316,30 @@ gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name) * * Returns: true if it was successfully attached */ -gboolean -gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam *dparam) +gboolean +gst_dpman_attach_dparam (GstDParamManager * dpman, gchar * dparam_name, + GstDParam * dparam) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; - g_return_val_if_fail (dpman != NULL, FALSE); - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - g_return_val_if_fail (dparam_name != NULL, FALSE); - g_return_val_if_fail (dparam != NULL, FALSE); - g_return_val_if_fail (GST_IS_DPARAM (dparam), FALSE); - g_return_val_if_fail (dparam != NULL, FALSE); + g_return_val_if_fail (dpman != NULL, FALSE); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + g_return_val_if_fail (dparam_name != NULL, FALSE); + g_return_val_if_fail (dparam != NULL, FALSE); + g_return_val_if_fail (GST_IS_DPARAM (dparam), FALSE); + g_return_val_if_fail (dparam != NULL, FALSE); - dpwrap = gst_dpman_get_wrapper(dpman, dparam_name); + dpwrap = gst_dpman_get_wrapper (dpman, dparam_name); - g_return_val_if_fail (dpwrap != NULL, FALSE); - g_return_val_if_fail (dpwrap->value != NULL, FALSE); - g_return_val_if_fail (G_PARAM_SPEC_VALUE_TYPE (dpwrap->param_spec) == GST_DPARAM_TYPE(dparam), FALSE); + g_return_val_if_fail (dpwrap != NULL, FALSE); + g_return_val_if_fail (dpwrap->value != NULL, FALSE); + g_return_val_if_fail (G_PARAM_SPEC_VALUE_TYPE (dpwrap->param_spec) == + GST_DPARAM_TYPE (dparam), FALSE); - dpwrap->dparam = dparam; - gst_dparam_attach(dparam, dpman, dpwrap->param_spec, dpwrap->unit_name); + dpwrap->dparam = dparam; + gst_dparam_attach (dparam, dpman, dpwrap->param_spec, dpwrap->unit_name); - return TRUE; + return TRUE; } /** @@ -329,22 +348,22 @@ gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam * @dparam_name: the name of a parameter with a previously attached GstDParam * */ -void -gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name) +void +gst_dpman_detach_dparam (GstDParamManager * dpman, gchar * dparam_name) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; + + g_return_if_fail (dpman != NULL); + g_return_if_fail (GST_IS_DPMAN (dpman)); + g_return_if_fail (dparam_name != NULL); + + dpwrap = gst_dpman_get_wrapper (dpman, dparam_name); + + g_return_if_fail (dpwrap); - g_return_if_fail (dpman != NULL); - g_return_if_fail (GST_IS_DPMAN (dpman)); - g_return_if_fail (dparam_name != NULL); - - dpwrap = gst_dpman_get_wrapper(dpman, dparam_name); + gst_dparam_detach (dpwrap->dparam); + dpwrap->dparam = NULL; - g_return_if_fail(dpwrap); - - gst_dparam_detach(dpwrap->dparam); - dpwrap->dparam = NULL; - } /** @@ -355,18 +374,18 @@ gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name) * Returns: the dparam with the given name - or NULL otherwise */ GstDParam * -gst_dpman_get_dparam (GstDParamManager *dpman, gchar *name) +gst_dpman_get_dparam (GstDParamManager * dpman, gchar * name) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; - g_return_val_if_fail (dpman != NULL, NULL); - g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); - g_return_val_if_fail (name != NULL, NULL); - - dpwrap = g_hash_table_lookup(GST_DPMAN_DPARAMS(dpman), name); - g_return_val_if_fail (dpwrap != NULL, NULL); - - return dpwrap->dparam; + g_return_val_if_fail (dpman != NULL, NULL); + g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); + g_return_val_if_fail (name != NULL, NULL); + + dpwrap = g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), name); + g_return_val_if_fail (dpwrap != NULL, NULL); + + return dpwrap->dparam; } /** @@ -377,61 +396,61 @@ gst_dpman_get_dparam (GstDParamManager *dpman, gchar *name) * Returns: the type that this dparam requires/uses */ GType -gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name) -{ - GstDParamWrapper* dpwrap; - - g_return_val_if_fail (dpman != NULL, 0); - g_return_val_if_fail (GST_IS_DPMAN (dpman), 0); - g_return_val_if_fail (name != NULL, 0); - - dpwrap = g_hash_table_lookup(GST_DPMAN_DPARAMS(dpman), name); - g_return_val_if_fail (dpwrap != NULL, 0); - - return G_VALUE_TYPE(dpwrap->value); -} - -GParamSpec** -gst_dpman_list_dparam_specs(GstDParamManager *dpman) -{ - GstDParamWrapper* dpwrap; - GList *dwraps; - GParamSpec** param_specs; - guint x = 0; - - g_return_val_if_fail (dpman != NULL, NULL); - g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); - - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - - param_specs = g_new0(GParamSpec*, g_list_length(dwraps) + 1); - - while (dwraps){ - dpwrap = (GstDParamWrapper*)dwraps->data; - param_specs[x++] = dpwrap->param_spec; - dwraps = g_list_next(dwraps); - } - return param_specs; +gst_dpman_get_dparam_type (GstDParamManager * dpman, gchar * name) +{ + GstDParamWrapper *dpwrap; + + g_return_val_if_fail (dpman != NULL, 0); + g_return_val_if_fail (GST_IS_DPMAN (dpman), 0); + g_return_val_if_fail (name != NULL, 0); + + dpwrap = g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), name); + g_return_val_if_fail (dpwrap != NULL, 0); + + return G_VALUE_TYPE (dpwrap->value); } -GParamSpec* -gst_dpman_get_param_spec (GstDParamManager *dpman, gchar *dparam_name) +GParamSpec ** +gst_dpman_list_dparam_specs (GstDParamManager * dpman) { - GstDParamWrapper* dpwrap; + GstDParamWrapper *dpwrap; + GList *dwraps; + GParamSpec **param_specs; + guint x = 0; + + g_return_val_if_fail (dpman != NULL, NULL); + g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); + + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); - g_return_val_if_fail (dpman != NULL, NULL); - g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); - g_return_val_if_fail (dparam_name != NULL, NULL); + param_specs = g_new0 (GParamSpec *, g_list_length (dwraps) + 1); - dpwrap = gst_dpman_get_wrapper(dpman, dparam_name); - return dpwrap->param_spec; + while (dwraps) { + dpwrap = (GstDParamWrapper *) dwraps->data; + param_specs[x++] = dpwrap->param_spec; + dwraps = g_list_next (dwraps); + } + return param_specs; +} + +GParamSpec * +gst_dpman_get_param_spec (GstDParamManager * dpman, gchar * dparam_name) +{ + GstDParamWrapper *dpwrap; + + g_return_val_if_fail (dpman != NULL, NULL); + g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); + g_return_val_if_fail (dparam_name != NULL, NULL); + + dpwrap = gst_dpman_get_wrapper (dpman, dparam_name); + return dpwrap->param_spec; } void -gst_dpman_set_rate (GstDParamManager *dpman, gint rate) +gst_dpman_set_rate (GstDParamManager * dpman, gint rate) { - g_return_if_fail (GST_IS_DPMAN (dpman)); - GST_DPMAN_RATE(dpman) = rate; + g_return_if_fail (GST_IS_DPMAN (dpman)); + GST_DPMAN_RATE (dpman) = rate; } /** @@ -445,27 +464,26 @@ gst_dpman_set_rate (GstDParamManager *dpman, gint rate) * */ void -gst_dpman_register_mode (GstDParamManagerClass *klass, - gchar *modename, - GstDPMModePreProcessFunction preprocessfunc, - GstDPMModeProcessFunction processfunc, - GstDPMModeSetupFunction setupfunc, - GstDPMModeTeardownFunction teardownfunc) +gst_dpman_register_mode (GstDParamManagerClass * klass, + gchar * modename, + GstDPMModePreProcessFunction preprocessfunc, + GstDPMModeProcessFunction processfunc, + GstDPMModeSetupFunction setupfunc, GstDPMModeTeardownFunction teardownfunc) { - GstDPMMode *mode; + GstDPMMode *mode; + + g_return_if_fail (klass != NULL); + g_return_if_fail (modename != NULL); + g_return_if_fail (GST_IS_DPMAN_CLASS (klass)); + + mode = g_new0 (GstDPMMode, 1); - g_return_if_fail (klass != NULL); - g_return_if_fail (modename != NULL); - g_return_if_fail (GST_IS_DPMAN_CLASS (klass)); - - mode = g_new0(GstDPMMode,1); + mode->preprocessfunc = preprocessfunc; + mode->processfunc = processfunc; + mode->setupfunc = setupfunc; + mode->teardownfunc = teardownfunc; - mode->preprocessfunc = preprocessfunc; - mode->processfunc = processfunc; - mode->setupfunc = setupfunc; - mode->teardownfunc = teardownfunc; - - g_hash_table_insert(klass->modes, modename, mode); + g_hash_table_insert (klass->modes, modename, mode); } /** @@ -476,37 +494,37 @@ gst_dpman_register_mode (GstDParamManagerClass *klass, * Returns: TRUE if the mode was set, FALSE otherwise */ gboolean -gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename) -{ - GstDPMMode *mode=NULL; - GstDParamManagerClass *oclass; - - g_return_val_if_fail (dpman != NULL, FALSE); - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - g_return_val_if_fail (modename != NULL, FALSE); - - oclass = (GstDParamManagerClass*)(G_OBJECT_GET_CLASS(dpman)); - - mode = g_hash_table_lookup(oclass->modes, modename); - g_return_val_if_fail (mode != NULL, FALSE); - - if (GST_DPMAN_MODE(dpman) == mode) { - GST_DEBUG ("mode %s already set", modename); - return TRUE; - } - - GST_DEBUG ("setting mode to %s", modename); - if (GST_DPMAN_MODE(dpman) && GST_DPMAN_TEARDOWNFUNC(dpman)){ - GST_DPMAN_TEARDOWNFUNC(dpman)(dpman); - } - - GST_DPMAN_MODE(dpman) = mode; +gst_dpman_set_mode (GstDParamManager * dpman, gchar * modename) +{ + GstDPMMode *mode = NULL; + GstDParamManagerClass *oclass; - if (GST_DPMAN_SETUPFUNC(dpman)){ - GST_DPMAN_SETUPFUNC(dpman)(dpman); - } - - return TRUE; + g_return_val_if_fail (dpman != NULL, FALSE); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + g_return_val_if_fail (modename != NULL, FALSE); + + oclass = (GstDParamManagerClass *) (G_OBJECT_GET_CLASS (dpman)); + + mode = g_hash_table_lookup (oclass->modes, modename); + g_return_val_if_fail (mode != NULL, FALSE); + + if (GST_DPMAN_MODE (dpman) == mode) { + GST_DEBUG ("mode %s already set", modename); + return TRUE; + } + + GST_DEBUG ("setting mode to %s", modename); + if (GST_DPMAN_MODE (dpman) && GST_DPMAN_TEARDOWNFUNC (dpman)) { + GST_DPMAN_TEARDOWNFUNC (dpman) (dpman); + } + + GST_DPMAN_MODE (dpman) = mode; + + if (GST_DPMAN_SETUPFUNC (dpman)) { + GST_DPMAN_SETUPFUNC (dpman) (dpman); + } + + return TRUE; } /** @@ -516,17 +534,17 @@ gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename) * */ void -gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent) +gst_dpman_set_parent (GstDParamManager * dpman, GstElement * parent) { - g_return_if_fail (dpman != NULL); - g_return_if_fail (GST_IS_DPMAN (dpman)); - g_return_if_fail (parent != NULL); - g_return_if_fail (GST_IS_ELEMENT (parent)); - - g_hash_table_insert(_element_registry, parent, dpman); - gst_object_set_parent (GST_OBJECT (dpman), GST_OBJECT(parent)); - g_signal_connect(G_OBJECT(parent), "state_change", - G_CALLBACK (gst_dpman_state_change), dpman); + g_return_if_fail (dpman != NULL); + g_return_if_fail (GST_IS_DPMAN (dpman)); + g_return_if_fail (parent != NULL); + g_return_if_fail (GST_IS_ELEMENT (parent)); + + g_hash_table_insert (_element_registry, parent, dpman); + gst_object_set_parent (GST_OBJECT (dpman), GST_OBJECT (parent)); + g_signal_connect (G_OBJECT (parent), "state_change", + G_CALLBACK (gst_dpman_state_change), dpman); } /** @@ -537,14 +555,15 @@ gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent) * if it doesn't exist */ GstDParamManager * -gst_dpman_get_manager (GstElement *parent) +gst_dpman_get_manager (GstElement * parent) { - GstDParamManager *dpman; - g_return_val_if_fail (parent != NULL, NULL); - g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL); - - dpman = (GstDParamManager*)g_hash_table_lookup(_element_registry, parent); - return dpman; + GstDParamManager *dpman; + + g_return_val_if_fail (parent != NULL, NULL); + g_return_val_if_fail (GST_IS_ELEMENT (parent), NULL); + + dpman = (GstDParamManager *) g_hash_table_lookup (_element_registry, parent); + return dpman; } /** @@ -558,422 +577,450 @@ gst_dpman_get_manager (GstElement *parent) * */ void -gst_dpman_bypass_dparam(GstDParamManager *dpman, gchar *dparam_name) -{ - GstDParamWrapper* dpwrap; - - g_return_if_fail (dpman != NULL); - g_return_if_fail (GST_IS_DPMAN (dpman)); - g_return_if_fail (dparam_name != NULL); - - dpwrap = gst_dpman_get_wrapper(dpman, dparam_name); - g_return_if_fail (dpwrap != NULL); - - if (dpwrap->dparam != NULL){ - g_warning("Bypassing attached dparam '%s'. It will be detached", dparam_name); - gst_dpman_detach_dparam(dpman, dparam_name); - } -} +gst_dpman_bypass_dparam (GstDParamManager * dpman, gchar * dparam_name) +{ + GstDParamWrapper *dpwrap; -static GstDParamWrapper* -gst_dpman_get_wrapper(GstDParamManager *dpman, gchar *dparam_name) -{ - g_return_val_if_fail (dpman != NULL, NULL); - g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); - g_return_val_if_fail (dparam_name != NULL, NULL); - - return g_hash_table_lookup(GST_DPMAN_DPARAMS(dpman), dparam_name); -} - -static GstDParamWrapper* -gst_dpman_new_wrapper(GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - GstDPMUpdateMethod update_method) -{ - GstDParamWrapper* dpwrap; - gchar *dparam_name; - - g_return_val_if_fail (dpman != NULL, NULL); - g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); - g_return_val_if_fail (param_spec != NULL, NULL); - g_return_val_if_fail (gst_unitconv_unit_exists(unit_name), NULL); - - dparam_name = g_strdup(g_param_spec_get_name(param_spec)); - g_return_val_if_fail(gst_dpman_get_wrapper(dpman, dparam_name) == NULL, NULL); - - dpwrap = g_new0(GstDParamWrapper,1); - dpwrap->update_method = update_method; - dpwrap->value = g_new0(GValue,1); - g_value_init(dpwrap->value, G_PARAM_SPEC_VALUE_TYPE(param_spec)); - dpwrap->param_spec = param_spec; - dpwrap->unit_name = unit_name; - - g_hash_table_insert(GST_DPMAN_DPARAMS(dpman), dparam_name, dpwrap); - GST_DPMAN_DPARAMS_LIST(dpman) = g_list_append(GST_DPMAN_DPARAMS_LIST(dpman), dpwrap); - - return dpwrap; -} - - -static void -gst_dpman_state_change (GstElement *element, gint old_state, gint new_state, GstDParamManager *dpman) -{ - GList *dwraps; - GstDParam *dparam; - GstDParamWrapper *dpwrap; - - g_return_if_fail (dpman != NULL); - g_return_if_fail (GST_IS_DPMAN (dpman)); - - if (new_state == GST_STATE_PLAYING){ - GST_DEBUG ("initialising params"); - - - /* force all params to be updated */ - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - while (dwraps){ - dpwrap = (GstDParamWrapper*)dwraps->data; - dparam = dpwrap->dparam; - - if (dparam){ - GST_DPARAM_READY_FOR_UPDATE(dparam) = TRUE; - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dparam) = 0LL; - } - /* some dparams treat the first update after the pipeline starts differently */ - dpwrap->update_info = GST_DPARAM_UPDATE_FIRST; - dwraps = g_list_next(dwraps); - } - } + g_return_if_fail (dpman != NULL); + g_return_if_fail (GST_IS_DPMAN (dpman)); + g_return_if_fail (dparam_name != NULL); + + dpwrap = gst_dpman_get_wrapper (dpman, dparam_name); + g_return_if_fail (dpwrap != NULL); + + if (dpwrap->dparam != NULL) { + g_warning ("Bypassing attached dparam '%s'. It will be detached", + dparam_name); + gst_dpman_detach_dparam (dpman, dparam_name); + } } -static inline void -gst_dpman_inline_direct_update(GValue *value, gpointer data){ - switch (G_VALUE_TYPE(value)){ - case G_TYPE_INT: - *(gint*)data = g_value_get_int(value); - break; - case G_TYPE_INT64: - *(gint64*)data = g_value_get_int64(value); - break; - case G_TYPE_FLOAT: - *(gfloat*)data = g_value_get_float(value); - break; - case G_TYPE_DOUBLE: - *(double*)data = g_value_get_double(value); - break; - default: - break; - } +static GstDParamWrapper * +gst_dpman_get_wrapper (GstDParamManager * dpman, gchar * dparam_name) +{ + g_return_val_if_fail (dpman != NULL, NULL); + g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); + g_return_val_if_fail (dparam_name != NULL, NULL); + + return g_hash_table_lookup (GST_DPMAN_DPARAMS (dpman), dparam_name); } -static gboolean -gst_dpman_preprocess_synchronous(GstDParamManager *dpman, guint frames, gint64 timestamp) -{ - GList *dwraps; - GstDParamWrapper *dpwrap; - - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - - /* this basically means don't call GST_DPMAN_PREPROCESS at all */ - dpman->next_update_frame = frames; - dpman->frames_to_process = frames; - - /* now check whether any dparams are ready for an update */ - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - while (dwraps){ - dpwrap = (GstDParamWrapper*)dwraps->data; - - if (dpwrap->dparam && - GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam) && - GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam) <= timestamp){ - - switch (dpwrap->update_method) { - - /* direct method - set the value directly in the struct of the element */ - case GST_DPMAN_DIRECT: - GST_DPARAM_DO_UPDATE(dpwrap->dparam, timestamp, dpwrap->value, dpwrap->update_info); - GST_DEBUG ("doing direct update"); - - gst_dpman_inline_direct_update(dpwrap->value, dpwrap->update_data); - break; - - /* callback method - call the element's callback so it can do what it likes */ - case GST_DPMAN_CALLBACK: - GST_DPARAM_DO_UPDATE(dpwrap->dparam, timestamp, dpwrap->value, dpwrap->update_info); - GST_DEBUG ("doing callback update"); - - GST_DPMAN_CALLBACK_UPDATE(dpwrap, dpwrap->value); - break; - - case GST_DPMAN_ARRAY: - /* FIXME do array method checking here */ - break; - default: - break; - } - - if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST){ - /* it is not the first update anymore */ - dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL; - } - } - dwraps = g_list_next(dwraps); - } +static GstDParamWrapper * +gst_dpman_new_wrapper (GstDParamManager * dpman, + GParamSpec * param_spec, + gchar * unit_name, GstDPMUpdateMethod update_method) +{ + GstDParamWrapper *dpwrap; + gchar *dparam_name; + + g_return_val_if_fail (dpman != NULL, NULL); + g_return_val_if_fail (GST_IS_DPMAN (dpman), NULL); + g_return_val_if_fail (param_spec != NULL, NULL); + g_return_val_if_fail (gst_unitconv_unit_exists (unit_name), NULL); + + dparam_name = g_strdup (g_param_spec_get_name (param_spec)); + g_return_val_if_fail (gst_dpman_get_wrapper (dpman, dparam_name) == NULL, + NULL); + + dpwrap = g_new0 (GstDParamWrapper, 1); + dpwrap->update_method = update_method; + dpwrap->value = g_new0 (GValue, 1); + g_value_init (dpwrap->value, G_PARAM_SPEC_VALUE_TYPE (param_spec)); + dpwrap->param_spec = param_spec; + dpwrap->unit_name = unit_name; + + g_hash_table_insert (GST_DPMAN_DPARAMS (dpman), dparam_name, dpwrap); + GST_DPMAN_DPARAMS_LIST (dpman) = + g_list_append (GST_DPMAN_DPARAMS_LIST (dpman), dpwrap); + + return dpwrap; +} - return FALSE; +static void +gst_dpman_state_change (GstElement * element, gint old_state, gint new_state, + GstDParamManager * dpman) +{ + GList *dwraps; + GstDParam *dparam; + GstDParamWrapper *dpwrap; + + g_return_if_fail (dpman != NULL); + g_return_if_fail (GST_IS_DPMAN (dpman)); + + if (new_state == GST_STATE_PLAYING) { + GST_DEBUG ("initialising params"); + + + /* force all params to be updated */ + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); + while (dwraps) { + dpwrap = (GstDParamWrapper *) dwraps->data; + dparam = dpwrap->dparam; + + if (dparam) { + GST_DPARAM_READY_FOR_UPDATE (dparam) = TRUE; + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dparam) = 0LL; + } + /* some dparams treat the first update after the pipeline starts differently */ + dpwrap->update_info = GST_DPARAM_UPDATE_FIRST; + dwraps = g_list_next (dwraps); + } + } } -static gint -gst_dpman_dpwrap_compare (const GstDParamWrapper *a, const GstDParamWrapper *b) +static inline void +gst_dpman_inline_direct_update (GValue * value, gpointer data) { - if (a->next_update_frame > b->next_update_frame) return 1; - return (a->next_update_frame < b->next_update_frame) ? -1 : 0; + switch (G_VALUE_TYPE (value)) { + case G_TYPE_INT: + *(gint *) data = g_value_get_int (value); + break; + case G_TYPE_INT64: + *(gint64 *) data = g_value_get_int64 (value); + break; + case G_TYPE_FLOAT: + *(gfloat *) data = g_value_get_float (value); + break; + case G_TYPE_DOUBLE: + *(double *) data = g_value_get_double (value); + break; + default: + break; + } } -static gboolean -gst_dpman_preprocess_asynchronous(GstDParamManager *dpman, guint frames, gint64 timestamp) +static gboolean +gst_dpman_preprocess_synchronous (GstDParamManager * dpman, guint frames, + gint64 timestamp) { - GList *dwraps; - GstDParamWrapper *dpwrap; - gint64 current_time; - gboolean updates_pending; + GList *dwraps; + GstDParamWrapper *dpwrap; - g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); + /* this basically means don't call GST_DPMAN_PREPROCESS at all */ + dpman->next_update_frame = frames; + dpman->frames_to_process = frames; - if (GST_DPMAN_RATE(dpman) == 0){ - g_warning("The element hasn't given GstDParamManager a frame rate"); - return FALSE; - } - dpman->rate_ratio = (guint)(1000000000LL / (gint64)GST_DPMAN_RATE(dpman)); - - dpman->time_buffer_starts = timestamp; - dpman->time_buffer_ends = timestamp + ((gint64)frames * (gint64)dpman->rate_ratio); - dpman->num_frames = frames; - - updates_pending = FALSE; - - /* now check whether any dparams are ready for an update */ - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - while (dwraps){ - dpwrap = (GstDParamWrapper*)dwraps->data; - - dpwrap->next_update_frame = frames; - - if (dpwrap->dparam && - GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam)){ - - current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam); - if (current_time > dpman->time_buffer_ends){ - /* not due for an update in this buffer */ - dwraps = g_list_next(dwraps); - continue; - } - if (current_time < timestamp){ - current_time = timestamp; - } - - if (current_time == timestamp){ - /* we are overdue for an update. lets do it now */ - - GST_DPARAM_DO_UPDATE(dpwrap->dparam, current_time, dpwrap->value, dpwrap->update_info); - - if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST){ - /* it is not the first update anymore */ - dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL; - } - - switch (dpwrap->update_method) { - - /* direct method - set the value directly in the struct of the element */ - case GST_DPMAN_DIRECT: - GST_DEBUG ("doing direct update"); - gst_dpman_inline_direct_update(dpwrap->value, dpwrap->update_data); - break; - - /* callback method - call the element's callback so it can do what it likes */ - case GST_DPMAN_CALLBACK: - GST_DEBUG ("doing callback update"); - GST_DPMAN_CALLBACK_UPDATE(dpwrap, dpwrap->value); - break; - default: - break; - } - - current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam); - - if (!GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam) || - current_time > dpman->time_buffer_ends){ - /* not due for an update in this buffer */ - dwraps = g_list_next(dwraps); - continue; - } - } - - dpwrap->next_update_frame = (guint)(current_time - timestamp) / dpman->rate_ratio; - updates_pending = TRUE; - - GST_DEBUG ("timestamp start: %" - G_GINT64_FORMAT " end: %" - G_GINT64_FORMAT " current: %" - G_GINT64_FORMAT, - timestamp, dpman->time_buffer_ends, current_time); - - } - dwraps = g_list_next(dwraps); - } - if (updates_pending){ - GST_DPMAN_DPARAMS_LIST(dpman) = g_list_sort(GST_DPMAN_DPARAMS_LIST(dpman), (GCompareFunc)gst_dpman_dpwrap_compare); - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - dpwrap = (GstDParamWrapper*)dwraps->data; + /* now check whether any dparams are ready for an update */ + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); + while (dwraps) { + dpwrap = (GstDParamWrapper *) dwraps->data; - dpman->next_update_frame = dpwrap->next_update_frame; - dpman->frames_to_process = dpman->next_update_frame; + if (dpwrap->dparam && + GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) && + GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam) <= timestamp) { - GST_DEBUG ("next update frame %u, frames to process %u", dpman->next_update_frame, dpman->frames_to_process); - return TRUE; - } - - dpman->next_update_frame = frames; - dpman->frames_to_process = frames; - return FALSE; + switch (dpwrap->update_method) { + + /* direct method - set the value directly in the struct of the element */ + case GST_DPMAN_DIRECT: + GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value, + dpwrap->update_info); + GST_DEBUG ("doing direct update"); + + gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data); + break; + + /* callback method - call the element's callback so it can do what it likes */ + case GST_DPMAN_CALLBACK: + GST_DPARAM_DO_UPDATE (dpwrap->dparam, timestamp, dpwrap->value, + dpwrap->update_info); + GST_DEBUG ("doing callback update"); + + GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value); + break; + + case GST_DPMAN_ARRAY: + /* FIXME do array method checking here */ + break; + default: + break; + } + + if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) { + /* it is not the first update anymore */ + dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL; + } + } + dwraps = g_list_next (dwraps); + } + + + return FALSE; } -static gboolean -gst_dpman_process_asynchronous(GstDParamManager *dpman, guint frame_count) +static gint +gst_dpman_dpwrap_compare (const GstDParamWrapper * a, + const GstDParamWrapper * b) { - GstDParamWrapper *dpwrap; - GList *dwraps; - gint64 current_time; - gboolean needs_resort = FALSE; + if (a->next_update_frame > b->next_update_frame) + return 1; + return (a->next_update_frame < b->next_update_frame) ? -1 : 0; +} - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - dpwrap = (GstDParamWrapper*)dwraps->data; +static gboolean +gst_dpman_preprocess_asynchronous (GstDParamManager * dpman, guint frames, + gint64 timestamp) +{ + GList *dwraps; + GstDParamWrapper *dpwrap; + gint64 current_time; + gboolean updates_pending; - GST_DEBUG ("in gst_dpman_process_asynchronous"); + g_return_val_if_fail (GST_IS_DPMAN (dpman), FALSE); - if (frame_count >= dpman->num_frames){ - g_warning("there is no more buffer to process"); - dpman->next_update_frame = dpman->num_frames; - dpman->frames_to_process = 0; - return FALSE; - } - if (frame_count != dpwrap->next_update_frame){ - g_warning("frame count %u does not match update frame %u", - frame_count, dpwrap->next_update_frame); - } + if (GST_DPMAN_RATE (dpman) == 0) { + g_warning ("The element hasn't given GstDParamManager a frame rate"); + return FALSE; + } + dpman->rate_ratio = (guint) (1000000000LL / (gint64) GST_DPMAN_RATE (dpman)); - while (dpwrap){ - - current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam); - GST_DPARAM_DO_UPDATE(dpwrap->dparam, current_time, dpwrap->value, dpwrap->update_info); - switch (dpwrap->update_method) { - - /* direct method - set the value directly in the struct of the element */ - case GST_DPMAN_DIRECT: - GST_DEBUG ("doing direct update"); - gst_dpman_inline_direct_update(dpwrap->value, dpwrap->update_data); - break; - - /* callback method - call the element's callback so it can do what it likes */ - case GST_DPMAN_CALLBACK: - GST_DEBUG ("doing callback update"); - GST_DPMAN_CALLBACK_UPDATE(dpwrap, dpwrap->value); - break; - default: - break; - } - - dpwrap->next_update_frame = dpman->num_frames; - needs_resort = TRUE; - - if(GST_DPARAM_READY_FOR_UPDATE(dpwrap->dparam)){ - current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP(dpwrap->dparam); - if (current_time <= dpman->time_buffer_ends){ - dpwrap->next_update_frame = (guint)(current_time - dpman->time_buffer_starts) / dpman->rate_ratio; - } - } - - if ((dwraps = g_list_next(dwraps))){ - dpwrap = (GstDParamWrapper*)dwraps->data; - if (frame_count == dpwrap->next_update_frame){ - continue; - } - } - dpwrap = NULL; - } + dpman->time_buffer_starts = timestamp; + dpman->time_buffer_ends = + timestamp + ((gint64) frames * (gint64) dpman->rate_ratio); + dpman->num_frames = frames; + + updates_pending = FALSE; + + /* now check whether any dparams are ready for an update */ + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); + while (dwraps) { + dpwrap = (GstDParamWrapper *) dwraps->data; + + dpwrap->next_update_frame = frames; + + if (dpwrap->dparam && GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) { + + current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); + if (current_time > dpman->time_buffer_ends) { + /* not due for an update in this buffer */ + dwraps = g_list_next (dwraps); + continue; + } + if (current_time < timestamp) { + current_time = timestamp; + } + + if (current_time == timestamp) { + /* we are overdue for an update. lets do it now */ - if (needs_resort && g_list_length(GST_DPMAN_DPARAMS_LIST(dpman)) > 1){ - GST_DPMAN_DPARAMS_LIST(dpman) = g_list_sort(GST_DPMAN_DPARAMS_LIST(dpman), (GCompareFunc)gst_dpman_dpwrap_compare); + GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value, + dpwrap->update_info); + + if (dpwrap->update_info == GST_DPARAM_UPDATE_FIRST) { + /* it is not the first update anymore */ + dpwrap->update_info = GST_DPARAM_UPDATE_NORMAL; } - - dwraps = GST_DPMAN_DPARAMS_LIST(dpman); - dpwrap = (GstDParamWrapper*)dwraps->data; - - if (dpwrap->next_update_frame == dpman->num_frames){ - dpman->next_update_frame = dpman->num_frames; - dpman->frames_to_process = dpman->num_frames - frame_count; - GST_DEBUG ("no more updates, frames to process %u", dpman->frames_to_process); + + switch (dpwrap->update_method) { + + /* direct method - set the value directly in the struct of the element */ + case GST_DPMAN_DIRECT: + GST_DEBUG ("doing direct update"); + gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data); + break; + + /* callback method - call the element's callback so it can do what it likes */ + case GST_DPMAN_CALLBACK: + GST_DEBUG ("doing callback update"); + GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value); + break; + default: + break; } - else { - dpman->next_update_frame = dpwrap->next_update_frame; - dpman->frames_to_process = dpman->next_update_frame - frame_count; - GST_DEBUG ("next update frame %u, frames to process %u", dpman->next_update_frame, dpman->frames_to_process); + + current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); + + if (!GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam) || + current_time > dpman->time_buffer_ends) { + /* not due for an update in this buffer */ + dwraps = g_list_next (dwraps); + continue; } + } + + dpwrap->next_update_frame = + (guint) (current_time - timestamp) / dpman->rate_ratio; + updates_pending = TRUE; + + GST_DEBUG ("timestamp start: %" + G_GINT64_FORMAT " end: %" + G_GINT64_FORMAT " current: %" + G_GINT64_FORMAT, timestamp, dpman->time_buffer_ends, current_time); + + } + dwraps = g_list_next (dwraps); + } + if (updates_pending) { + GST_DPMAN_DPARAMS_LIST (dpman) = + g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman), + (GCompareFunc) gst_dpman_dpwrap_compare); + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); + dpwrap = (GstDParamWrapper *) dwraps->data; + + dpman->next_update_frame = dpwrap->next_update_frame; + dpman->frames_to_process = dpman->next_update_frame; + + GST_DEBUG ("next update frame %u, frames to process %u", + dpman->next_update_frame, dpman->frames_to_process); + return TRUE; + } + + dpman->next_update_frame = frames; + dpman->frames_to_process = frames; + return FALSE; +} - return TRUE; +static gboolean +gst_dpman_process_asynchronous (GstDParamManager * dpman, guint frame_count) +{ + GstDParamWrapper *dpwrap; + GList *dwraps; + gint64 current_time; + gboolean needs_resort = FALSE; + + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); + dpwrap = (GstDParamWrapper *) dwraps->data; + + GST_DEBUG ("in gst_dpman_process_asynchronous"); + + if (frame_count >= dpman->num_frames) { + g_warning ("there is no more buffer to process"); + dpman->next_update_frame = dpman->num_frames; + dpman->frames_to_process = 0; + return FALSE; + } + + if (frame_count != dpwrap->next_update_frame) { + g_warning ("frame count %u does not match update frame %u", + frame_count, dpwrap->next_update_frame); + } + + while (dpwrap) { + + current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); + GST_DPARAM_DO_UPDATE (dpwrap->dparam, current_time, dpwrap->value, + dpwrap->update_info); + switch (dpwrap->update_method) { + + /* direct method - set the value directly in the struct of the element */ + case GST_DPMAN_DIRECT: + GST_DEBUG ("doing direct update"); + gst_dpman_inline_direct_update (dpwrap->value, dpwrap->update_data); + break; + + /* callback method - call the element's callback so it can do what it likes */ + case GST_DPMAN_CALLBACK: + GST_DEBUG ("doing callback update"); + GST_DPMAN_CALLBACK_UPDATE (dpwrap, dpwrap->value); + break; + default: + break; + } + + dpwrap->next_update_frame = dpman->num_frames; + needs_resort = TRUE; + + if (GST_DPARAM_READY_FOR_UPDATE (dpwrap->dparam)) { + current_time = GST_DPARAM_NEXT_UPDATE_TIMESTAMP (dpwrap->dparam); + if (current_time <= dpman->time_buffer_ends) { + dpwrap->next_update_frame = + (guint) (current_time - + dpman->time_buffer_starts) / dpman->rate_ratio; + } + } + + if ((dwraps = g_list_next (dwraps))) { + dpwrap = (GstDParamWrapper *) dwraps->data; + if (frame_count == dpwrap->next_update_frame) { + continue; + } + } + dpwrap = NULL; + } + + if (needs_resort && g_list_length (GST_DPMAN_DPARAMS_LIST (dpman)) > 1) { + GST_DPMAN_DPARAMS_LIST (dpman) = + g_list_sort (GST_DPMAN_DPARAMS_LIST (dpman), + (GCompareFunc) gst_dpman_dpwrap_compare); + } + + dwraps = GST_DPMAN_DPARAMS_LIST (dpman); + dpwrap = (GstDParamWrapper *) dwraps->data; + + if (dpwrap->next_update_frame == dpman->num_frames) { + dpman->next_update_frame = dpman->num_frames; + dpman->frames_to_process = dpman->num_frames - frame_count; + GST_DEBUG ("no more updates, frames to process %u", + dpman->frames_to_process); + } else { + dpman->next_update_frame = dpwrap->next_update_frame; + dpman->frames_to_process = dpman->next_update_frame - frame_count; + GST_DEBUG ("next update frame %u, frames to process %u", + dpman->next_update_frame, dpman->frames_to_process); + } + + return TRUE; } -static gboolean -gst_dpman_preprocess_noop(GstDParamManager *dpman, guint frames, gint64 timestamp) +static gboolean +gst_dpman_preprocess_noop (GstDParamManager * dpman, guint frames, + gint64 timestamp) { - dpman->next_update_frame = frames; - dpman->frames_to_process = frames; - return FALSE; + dpman->next_update_frame = frames; + dpman->frames_to_process = frames; + return FALSE; } -static gboolean -gst_dpman_process_noop(GstDParamManager *dpman, guint frame_count) +static gboolean +gst_dpman_process_noop (GstDParamManager * dpman, guint frame_count) { - g_warning("gst_dpman_process_noop should never be called - something might be wrong with your processing loop"); - return FALSE; + g_warning + ("gst_dpman_process_noop should never be called - something might be wrong with your processing loop"); + return FALSE; } -static void -gst_dpman_setup_synchronous(GstDParamManager *dpman){ - g_return_if_fail (GST_IS_DPMAN (dpman)); +static void +gst_dpman_setup_synchronous (GstDParamManager * dpman) +{ + g_return_if_fail (GST_IS_DPMAN (dpman)); } -static void -gst_dpman_setup_asynchronous(GstDParamManager *dpman){ - g_return_if_fail (GST_IS_DPMAN (dpman)); +static void +gst_dpman_setup_asynchronous (GstDParamManager * dpman) +{ + g_return_if_fail (GST_IS_DPMAN (dpman)); } -static void -gst_dpman_setup_disabled(GstDParamManager *dpman){ - g_return_if_fail (GST_IS_DPMAN (dpman)); +static void +gst_dpman_setup_disabled (GstDParamManager * dpman) +{ + g_return_if_fail (GST_IS_DPMAN (dpman)); } -static void -gst_dpman_teardown_synchronous(GstDParamManager *dpman){ - g_return_if_fail (GST_IS_DPMAN (dpman)); +static void +gst_dpman_teardown_synchronous (GstDParamManager * dpman) +{ + g_return_if_fail (GST_IS_DPMAN (dpman)); } -static void -gst_dpman_teardown_asynchronous(GstDParamManager *dpman){ - g_return_if_fail (GST_IS_DPMAN (dpman)); - +static void +gst_dpman_teardown_asynchronous (GstDParamManager * dpman) +{ + g_return_if_fail (GST_IS_DPMAN (dpman)); + } -static void -gst_dpman_teardown_disabled(GstDParamManager *dpman){ - g_return_if_fail (GST_IS_DPMAN (dpman)); +static void +gst_dpman_teardown_disabled (GstDParamManager * dpman) +{ + g_return_if_fail (GST_IS_DPMAN (dpman)); } diff --git a/libs/gst/control/dparammanager.h b/libs/gst/control/dparammanager.h index 72dedbc09..280af672d 100644 --- a/libs/gst/control/dparammanager.h +++ b/libs/gst/control/dparammanager.h @@ -28,25 +28,22 @@ #include G_BEGIN_DECLS - #define GST_TYPE_DPMAN (gst_dpman_get_type ()) #define GST_DPMAN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DPMAN,GstDParamManager)) #define GST_DPMAN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DPMAN,GstDParamManager)) #define GST_IS_DPMAN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPMAN)) #define GST_IS_DPMAN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPMAN)) - #define GST_DPMAN_NAME(dpman) (GST_OBJECT_NAME(dpman)) #define GST_DPMAN_PARENT(dpman) (GST_OBJECT_PARENT(dpman)) #define GST_DPMAN_DPARAMS(dpman) ((dpman)->dparams) #define GST_DPMAN_DPARAMS_LIST(dpman) ((dpman)->dparams_list) - #define GST_DPMAN_MODE_NAME(dpman) ((dpman)->mode_name) #define GST_DPMAN_MODE(dpman) ((dpman)->mode) #define GST_DPMAN_RATE(dpman) ((dpman)->rate) #define GST_DPMAN_FRAMES_TO_PROCESS(dpman) ((dpman)->frames_to_process) #define GST_DPMAN_NEXT_UPDATE_FRAME(dpman) ((dpman)->next_update_frame) - -typedef enum { + typedef enum +{ GST_DPMAN_CALLBACK, GST_DPMAN_DIRECT, GST_DPMAN_ARRAY, @@ -57,68 +54,75 @@ typedef struct _GstDPMMode GstDPMMode; typedef struct _GstDParamWrapper GstDParamWrapper; typedef struct _GstDParamAsyncToUpdate GstDParamAsyncToUpdate; -typedef gboolean (*GstDPMModePreProcessFunction) (GstDParamManager *dpman, guint frames, gint64 timestamp); -typedef gboolean (*GstDPMModeProcessFunction) (GstDParamManager *dpman, guint frame_count); -typedef void (*GstDPMModeSetupFunction) (GstDParamManager *dpman); -typedef void (*GstDPMModeTeardownFunction) (GstDParamManager *dpman); +typedef gboolean (*GstDPMModePreProcessFunction) (GstDParamManager * dpman, + guint frames, gint64 timestamp); +typedef gboolean (*GstDPMModeProcessFunction) (GstDParamManager * dpman, + guint frame_count); +typedef void (*GstDPMModeSetupFunction) (GstDParamManager * dpman); +typedef void (*GstDPMModeTeardownFunction) (GstDParamManager * dpman); + +typedef void (*GstDPMUpdateFunction) (const GValue * value, gpointer data); -typedef void (*GstDPMUpdateFunction) (const GValue *value, gpointer data); +struct _GstDParamManager +{ + GstObject object; -struct _GstDParamManager { - GstObject object; + GHashTable *dparams; + GList *dparams_list; - GHashTable *dparams; - GList *dparams_list; + /* mode state */ + GstDPMMode *mode; + gchar *mode_name; - /* mode state */ - GstDPMMode* mode; - gchar *mode_name; - - guint frames_to_process; /* the number of frames in the current buffer */ - guint next_update_frame; /* the frame when the next update is required */ + guint frames_to_process; /* the number of frames in the current buffer */ + guint next_update_frame; /* the frame when the next update is required */ - /* the following data is only used for async mode */ - guint rate; /* the frame/sample rate - */ - guint rate_ratio; /* number used to convert between samples and time */ - guint num_frames; /* the number of frames in the current buffer */ + /* the following data is only used for async mode */ + guint rate; /* the frame/sample rate - */ + guint rate_ratio; /* number used to convert between samples and time */ + guint num_frames; /* the number of frames in the current buffer */ - gint64 time_buffer_ends; - gint64 time_buffer_starts; + gint64 time_buffer_ends; + gint64 time_buffer_starts; }; -struct _GstDParamManagerClass { - GstObjectClass parent_class; - GHashTable *modes; - /* signal callbacks */ - void (*new_required_dparam) (GstDParamManager *dpman, gchar* dparam_name); +struct _GstDParamManagerClass +{ + GstObjectClass parent_class; + GHashTable *modes; + /* signal callbacks */ + void (*new_required_dparam) (GstDParamManager * dpman, gchar * dparam_name); }; -struct _GstDPMMode { - GstDPMModePreProcessFunction preprocessfunc; - GstDPMModeProcessFunction processfunc; - GstDPMModeSetupFunction setupfunc; - GstDPMModeTeardownFunction teardownfunc; +struct _GstDPMMode +{ + GstDPMModePreProcessFunction preprocessfunc; + GstDPMModeProcessFunction processfunc; + GstDPMModeSetupFunction setupfunc; + GstDPMModeTeardownFunction teardownfunc; }; -struct _GstDParamWrapper { - GParamSpec* param_spec; - GValue *value; - GstDParam *dparam; - - guint next_update_frame; - - GstDPMUpdateMethod update_method; - gpointer update_data; - GstDPMUpdateFunction update_func; - - gchar *unit_name; - GstDParamUpdateInfo update_info; +struct _GstDParamWrapper +{ + GParamSpec *param_spec; + GValue *value; + GstDParam *dparam; + + guint next_update_frame; + + GstDPMUpdateMethod update_method; + gpointer update_data; + GstDPMUpdateFunction update_func; + + gchar *unit_name; + GstDParamUpdateInfo update_info; }; -struct _GstDParamAsyncToUpdate { - guint frame; - GValue *value; - GstDParamWrapper *dpwrap; +struct _GstDParamAsyncToUpdate +{ + guint frame; + GValue *value; + GstDParamWrapper *dpwrap; }; #define GST_DPMAN_PREPROCESSFUNC(dpman) (((dpman)->mode)->preprocessfunc) @@ -135,48 +139,44 @@ struct _GstDParamAsyncToUpdate { #define GST_DPMAN_CALLBACK_UPDATE(dpwrap, value) ((dpwrap->update_func)(value, dpwrap->update_data)) -void _gst_dpman_initialize(void); +void _gst_dpman_initialize (void); GType gst_dpman_get_type (void); -GstDParamManager* gst_dpman_new (gchar *name, GstElement *parent); -void gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent); -GstDParamManager* gst_dpman_get_manager (GstElement *parent); - -gboolean gst_dpman_add_required_dparam_callback (GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - GstDPMUpdateFunction update_func, - gpointer update_data); -gboolean gst_dpman_add_required_dparam_direct (GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - gpointer update_data); - -gboolean gst_dpman_add_required_dparam_array (GstDParamManager *dpman, - GParamSpec *param_spec, - gchar *unit_name, - gpointer update_data); - -void gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name); -gboolean gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam *dparam); -void gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name); -GstDParam* gst_dpman_get_dparam(GstDParamManager *dpman, gchar *name); -GType gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name); - -GParamSpec** gst_dpman_list_dparam_specs(GstDParamManager *dpman); -GParamSpec* gst_dpman_get_param_spec (GstDParamManager *dpman, gchar *dparam_name); -void gst_dpman_dparam_spec_has_changed (GstDParamManager *dpman, gchar *dparam_name); - -void gst_dpman_set_rate(GstDParamManager *dpman, gint rate); -void gst_dpman_bypass_dparam(GstDParamManager *dpman, gchar *dparam_name); - -gboolean gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename); -void gst_dpman_register_mode (GstDParamManagerClass *klass, - gchar *modename, - GstDPMModePreProcessFunction preprocessfunc, - GstDPMModeProcessFunction processfunc, - GstDPMModeSetupFunction setupfunc, - GstDPMModeTeardownFunction teardownfunc); +GstDParamManager *gst_dpman_new (gchar * name, GstElement * parent); +void gst_dpman_set_parent (GstDParamManager * dpman, GstElement * parent); +GstDParamManager *gst_dpman_get_manager (GstElement * parent); + +gboolean gst_dpman_add_required_dparam_callback (GstDParamManager * dpman, + GParamSpec * param_spec, + gchar * unit_name, GstDPMUpdateFunction update_func, gpointer update_data); +gboolean gst_dpman_add_required_dparam_direct (GstDParamManager * dpman, + GParamSpec * param_spec, gchar * unit_name, gpointer update_data); + +gboolean gst_dpman_add_required_dparam_array (GstDParamManager * dpman, + GParamSpec * param_spec, gchar * unit_name, gpointer update_data); + +void gst_dpman_remove_required_dparam (GstDParamManager * dpman, + gchar * dparam_name); +gboolean gst_dpman_attach_dparam (GstDParamManager * dpman, gchar * dparam_name, + GstDParam * dparam); +void gst_dpman_detach_dparam (GstDParamManager * dpman, gchar * dparam_name); +GstDParam *gst_dpman_get_dparam (GstDParamManager * dpman, gchar * name); +GType gst_dpman_get_dparam_type (GstDParamManager * dpman, gchar * name); + +GParamSpec **gst_dpman_list_dparam_specs (GstDParamManager * dpman); +GParamSpec *gst_dpman_get_param_spec (GstDParamManager * dpman, + gchar * dparam_name); +void gst_dpman_dparam_spec_has_changed (GstDParamManager * dpman, + gchar * dparam_name); + +void gst_dpman_set_rate (GstDParamManager * dpman, gint rate); +void gst_dpman_bypass_dparam (GstDParamManager * dpman, gchar * dparam_name); + +gboolean gst_dpman_set_mode (GstDParamManager * dpman, gchar * modename); +void gst_dpman_register_mode (GstDParamManagerClass * klass, + gchar * modename, + GstDPMModePreProcessFunction preprocessfunc, + GstDPMModeProcessFunction processfunc, + GstDPMModeSetupFunction setupfunc, GstDPMModeTeardownFunction teardownfunc); G_END_DECLS - #endif /* __GST_DPMAN_H__ */ diff --git a/libs/gst/control/dplinearinterp.c b/libs/gst/control/dplinearinterp.c index 53bdd7c9b..606dd22e5 100644 --- a/libs/gst/control/dplinearinterp.c +++ b/libs/gst/control/dplinearinterp.c @@ -21,47 +21,50 @@ #include "dplinearinterp.h" -static void gst_dp_linint_class_init (GstDParamClass *klass); -static void gst_dp_linint_base_class_init (GstDParamClass *klass); -static void gst_dp_linint_init (GstDParam *dp_linint); +static void gst_dp_linint_class_init (GstDParamClass * klass); +static void gst_dp_linint_base_class_init (GstDParamClass * klass); +static void gst_dp_linint_init (GstDParam * dp_linint); -GType -gst_dp_linint_get_type(void) { - static GType dp_linint_type = 0; +GType +gst_dp_linint_get_type (void) +{ + static GType dp_linint_type = 0; - if (!dp_linint_type) { - static const GTypeInfo dp_linint_info = { - sizeof(GstDParamClass), - (GBaseInitFunc)gst_dp_linint_base_class_init, - NULL, - (GClassInitFunc)gst_dp_linint_class_init, - NULL, - NULL, - sizeof(GstDParam), - 0, - (GInstanceInitFunc)gst_dp_linint_init, - }; - dp_linint_type = g_type_register_static(GST_TYPE_DPARAM, "GstDParamLinInterp", &dp_linint_info, 0); - } - return dp_linint_type; + if (!dp_linint_type) { + static const GTypeInfo dp_linint_info = { + sizeof (GstDParamClass), + (GBaseInitFunc) gst_dp_linint_base_class_init, + NULL, + (GClassInitFunc) gst_dp_linint_class_init, + NULL, + NULL, + sizeof (GstDParam), + 0, + (GInstanceInitFunc) gst_dp_linint_init, + }; + dp_linint_type = + g_type_register_static (GST_TYPE_DPARAM, "GstDParamLinInterp", + &dp_linint_info, 0); + } + return dp_linint_type; } static void -gst_dp_linint_base_class_init (GstDParamClass *klass) +gst_dp_linint_base_class_init (GstDParamClass * klass) { } static void -gst_dp_linint_class_init (GstDParamClass *klass) +gst_dp_linint_class_init (GstDParamClass * klass) { } static void -gst_dp_linint_init (GstDParam *dp_linint) +gst_dp_linint_init (GstDParam * dp_linint) { - g_return_if_fail (dp_linint != NULL); + g_return_if_fail (dp_linint != NULL); } /** @@ -70,14 +73,14 @@ gst_dp_linint_init (GstDParam *dp_linint) * * Returns: a new instance of GstDParam */ -GstDParam* +GstDParam * gst_dp_linint_new (GType type) { - GstDParam *dparam; - GstDParamLinInterp *dp_linint; + GstDParam *dparam; + GstDParamLinInterp *dp_linint; + + dp_linint = g_object_new (gst_dp_linint_get_type (), NULL); + dparam = GST_DPARAM (dp_linint); - dp_linint = g_object_new (gst_dp_linint_get_type (), NULL); - dparam = GST_DPARAM(dp_linint); - - return dparam; + return dparam; } diff --git a/libs/gst/control/dplinearinterp.h b/libs/gst/control/dplinearinterp.h index 322891240..85068eca6 100644 --- a/libs/gst/control/dplinearinterp.h +++ b/libs/gst/control/dplinearinterp.h @@ -27,30 +27,29 @@ #include "dparam.h" G_BEGIN_DECLS - #define GST_TYPE_DP_LININT (gst_dp_linint_get_type ()) #define GST_DP_LININT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DP_LININT,GstDParamLinInterp)) #define GST_DP_LININT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DP_LININT,GstDParamLinInterp)) #define GST_IS_DP_LININT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DP_LININT)) #define GST_IS_DP_LININT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DP_LININT)) - typedef struct _GstDParamLinInterp GstDParamLinInterp; typedef struct _GstDParamLinInterpClass GstDParamLinInterpClass; -struct _GstDParamLinInterp { - GstDParam dparam; +struct _GstDParamLinInterp +{ + GstDParam dparam; }; -struct _GstDParamLinInterpClass { - GstDParamClass parent_class; +struct _GstDParamLinInterpClass +{ + GstDParamClass parent_class; - /* signal callbacks */ + /* signal callbacks */ }; GType gst_dp_linint_get_type (void); -GstDParam* gst_dp_linint_new (GType type); +GstDParam *gst_dp_linint_new (GType type); G_END_DECLS - #endif /* __GST_DP_LININT_H__ */ diff --git a/libs/gst/control/unitconvert.c b/libs/gst/control/unitconvert.c index 1b9bc50d1..38d1dc433 100644 --- a/libs/gst/control/unitconvert.c +++ b/libs/gst/control/unitconvert.c @@ -32,398 +32,424 @@ static gboolean _gst_unitconv_init_done = FALSE; typedef struct _GstUnit GstUnit; -struct _GstUnit { - GParamSpec *unit_spec; - const gchar *domain_name; - gboolean domain_default; - gboolean logarithmic; - GHashTable *convert_to_funcs; - GSList *convert_paramspecs; +struct _GstUnit +{ + GParamSpec *unit_spec; + const gchar *domain_name; + gboolean domain_default; + gboolean logarithmic; + GHashTable *convert_to_funcs; + GSList *convert_paramspecs; }; -static void gst_unitconv_add_core_converters(void); - -static void gst_unitconv_class_init (GstUnitConvertClass *klass); -static void gst_unitconv_init (GstUnitConvert *unitconv); -static void gst_unitconv_dispose (GObject *object); - -GType -gst_unitconv_get_type(void) { - static GType unitconv_type = 0; - - if (!unitconv_type) { - static const GTypeInfo unitconv_info = { - sizeof(GstUnitConvertClass), - NULL, - NULL, - (GClassInitFunc)gst_unitconv_class_init, - NULL, - NULL, - sizeof(GstUnitConvert), - 0, - (GInstanceInitFunc)gst_unitconv_init, - }; - unitconv_type = g_type_register_static(GST_TYPE_OBJECT, "GstUnitConvert", &unitconv_info, 0); - } - return unitconv_type; +static void gst_unitconv_add_core_converters (void); + +static void gst_unitconv_class_init (GstUnitConvertClass * klass); +static void gst_unitconv_init (GstUnitConvert * unitconv); +static void gst_unitconv_dispose (GObject * object); + +GType +gst_unitconv_get_type (void) +{ + static GType unitconv_type = 0; + + if (!unitconv_type) { + static const GTypeInfo unitconv_info = { + sizeof (GstUnitConvertClass), + NULL, + NULL, + (GClassInitFunc) gst_unitconv_class_init, + NULL, + NULL, + sizeof (GstUnitConvert), + 0, + (GInstanceInitFunc) gst_unitconv_init, + }; + unitconv_type = + g_type_register_static (GST_TYPE_OBJECT, "GstUnitConvert", + &unitconv_info, 0); + } + return unitconv_type; } static void -gst_unitconv_class_init (GstUnitConvertClass *klass) +gst_unitconv_class_init (GstUnitConvertClass * klass) { - GObjectClass *gobject_class; - GstUnitConvertClass *unitconv_class; - GstObjectClass *gstobject_class; + GObjectClass *gobject_class; + GstUnitConvertClass *unitconv_class; + GstObjectClass *gstobject_class; + + gobject_class = (GObjectClass *) klass; + unitconv_class = (GstUnitConvertClass *) klass; + gstobject_class = (GstObjectClass *) klass; - gobject_class = (GObjectClass*)klass; - unitconv_class = (GstUnitConvertClass*)klass; - gstobject_class = (GstObjectClass*) klass; + gobject_class->dispose = gst_unitconv_dispose; - gobject_class->dispose = gst_unitconv_dispose; - } static void -gst_unitconv_init (GstUnitConvert *unitconv) +gst_unitconv_init (GstUnitConvert * unitconv) { - g_return_if_fail (unitconv != NULL); - - unitconv->convert_func_chain = NULL; - unitconv->convert_params = g_hash_table_new(g_str_hash,g_str_equal); + g_return_if_fail (unitconv != NULL); + + unitconv->convert_func_chain = NULL; + unitconv->convert_params = g_hash_table_new (g_str_hash, g_str_equal); } -GstUnitConvert* +GstUnitConvert * gst_unitconv_new () { - GstUnitConvert *unitconv; + GstUnitConvert *unitconv; + + unitconv = g_object_new (gst_unitconv_get_type (), NULL); - unitconv = g_object_new (gst_unitconv_get_type (), NULL); - - return unitconv; + return unitconv; } static void -gst_unitconv_init_for_change_state(GstUnitConvert *unitconv){ - unitconv->convert_func_chain = NULL; +gst_unitconv_init_for_change_state (GstUnitConvert * unitconv) +{ + unitconv->convert_func_chain = NULL; } -gboolean -gst_unitconv_set_convert_units(GstUnitConvert *unitconv, gchar *from_unit_named, gchar *to_unit_named) +gboolean +gst_unitconv_set_convert_units (GstUnitConvert * unitconv, + gchar * from_unit_named, gchar * to_unit_named) { - GHashTable *convert_funcs; - GstUnit *from_unit, *to_unit; - GstUnitConvertFunc convert_func; - - g_return_val_if_fail (unitconv != NULL, FALSE); - g_return_val_if_fail (from_unit_named != NULL, FALSE); - g_return_val_if_fail (to_unit_named != NULL, FALSE); - g_return_val_if_fail (GST_IS_UNIT_CONVERT(unitconv), FALSE); - - from_unit = g_hash_table_lookup(_gst_units, from_unit_named); - to_unit = g_hash_table_lookup(_gst_units, to_unit_named); - - g_return_val_if_fail (from_unit != NULL, FALSE); - g_return_val_if_fail (to_unit != NULL, FALSE); - - convert_funcs = from_unit->convert_to_funcs; - - convert_func = g_hash_table_lookup(convert_funcs, to_unit); - if (convert_func == NULL){ - g_warning("cannot convert from %s to %s", from_unit_named, to_unit_named); - } - - gst_unitconv_init_for_change_state(unitconv); - - unitconv->convert_func_chain = g_slist_append(unitconv->convert_func_chain, convert_func); - - - return TRUE; + GHashTable *convert_funcs; + GstUnit *from_unit, *to_unit; + GstUnitConvertFunc convert_func; + + g_return_val_if_fail (unitconv != NULL, FALSE); + g_return_val_if_fail (from_unit_named != NULL, FALSE); + g_return_val_if_fail (to_unit_named != NULL, FALSE); + g_return_val_if_fail (GST_IS_UNIT_CONVERT (unitconv), FALSE); + + from_unit = g_hash_table_lookup (_gst_units, from_unit_named); + to_unit = g_hash_table_lookup (_gst_units, to_unit_named); + + g_return_val_if_fail (from_unit != NULL, FALSE); + g_return_val_if_fail (to_unit != NULL, FALSE); + + convert_funcs = from_unit->convert_to_funcs; + + convert_func = g_hash_table_lookup (convert_funcs, to_unit); + if (convert_func == NULL) { + g_warning ("cannot convert from %s to %s", from_unit_named, to_unit_named); + } + + gst_unitconv_init_for_change_state (unitconv); + + unitconv->convert_func_chain = + g_slist_append (unitconv->convert_func_chain, convert_func); + + + return TRUE; } -gboolean -gst_unitconv_convert_value(GstUnitConvert *unitconv, GValue *from_value, GValue *to_value) +gboolean +gst_unitconv_convert_value (GstUnitConvert * unitconv, GValue * from_value, + GValue * to_value) { - GstUnitConvertFunc convert_func; - GSList *convert_func_chain; - - g_return_val_if_fail (unitconv->convert_func_chain != NULL, FALSE); - - /* only do this until we can chain convert funcs */ - g_return_val_if_fail (g_slist_length(unitconv->convert_func_chain) == 1, FALSE); - - convert_func_chain = unitconv->convert_func_chain; - - convert_func = (GstUnitConvertFunc)(convert_func_chain); - convert_func(unitconv, from_value, to_value); - - return TRUE; + GstUnitConvertFunc convert_func; + GSList *convert_func_chain; + + g_return_val_if_fail (unitconv->convert_func_chain != NULL, FALSE); + + /* only do this until we can chain convert funcs */ + g_return_val_if_fail (g_slist_length (unitconv->convert_func_chain) == 1, + FALSE); + + convert_func_chain = unitconv->convert_func_chain; + + convert_func = (GstUnitConvertFunc) (convert_func_chain); + convert_func (unitconv, from_value, to_value); + + return TRUE; } gboolean -gst_unitconv_unit_exists(gchar *unit_name) +gst_unitconv_unit_exists (gchar * unit_name) { - g_return_val_if_fail (unit_name != NULL, FALSE); - return (g_hash_table_lookup(_gst_units, unit_name) != NULL); + g_return_val_if_fail (unit_name != NULL, FALSE); + return (g_hash_table_lookup (_gst_units, unit_name) != NULL); } gboolean -gst_unitconv_unit_is_logarithmic(gchar *unit_name) +gst_unitconv_unit_is_logarithmic (gchar * unit_name) { - GstUnit *unit; - g_return_val_if_fail (unit_name != NULL, FALSE); - - unit = g_hash_table_lookup(_gst_units, unit_name); - g_return_val_if_fail (unit != NULL, FALSE); - - return unit->logarithmic; + GstUnit *unit; + + g_return_val_if_fail (unit_name != NULL, FALSE); + + unit = g_hash_table_lookup (_gst_units, unit_name); + g_return_val_if_fail (unit != NULL, FALSE); + + return unit->logarithmic; } -GParamSpec* -gst_unitconv_unit_spec(gchar *unit_name) +GParamSpec * +gst_unitconv_unit_spec (gchar * unit_name) { - GstUnit *unit; - g_return_val_if_fail (unit_name != NULL, FALSE); - - unit = g_hash_table_lookup(_gst_units, unit_name); - g_return_val_if_fail (unit != NULL, FALSE); - - return unit->unit_spec; + GstUnit *unit; + + g_return_val_if_fail (unit_name != NULL, FALSE); + + unit = g_hash_table_lookup (_gst_units, unit_name); + g_return_val_if_fail (unit != NULL, FALSE); + + return unit->unit_spec; } static void -gst_unitconv_dispose (GObject *object) +gst_unitconv_dispose (GObject * object) { } -void +void _gst_unitconv_initialize (void) { - if (_gst_unitconv_init_done) return; - - _gst_unitconv_init_done = TRUE; - - _gst_units = g_hash_table_new(g_str_hash,g_str_equal); - _gst_unit_domain_defaults = g_hash_table_new(g_str_hash,g_str_equal); - - /* frequency based units */ - - gst_unitconv_register_unit("frequency", TRUE, TRUE, - g_param_spec_float("hertz", "Hz", "Frequency in hertz", - 0, G_MAXFLOAT, 0, 0)); - - gst_unitconv_register_unit("frequency", FALSE, TRUE, - g_param_spec_float("hertz-rate-bound", "Hz", "Frequency in hertz, bound by the sample rate", - 0.0, G_MAXFLOAT, 0.0, 0)); - - gst_unitconv_register_unit("frequency", FALSE, FALSE, - g_param_spec_string("twelve-tone-scale", "note", "Name of the note from the western twelve tone scale", - "C", 0)); - - gst_unitconv_register_unit("frequency", FALSE, FALSE, - g_param_spec_int("midi-note", "midi note", "MIDI note value of the frequency", - 1, 127, 1, 0)); - - /* time based units */ - gst_unitconv_register_unit("time", TRUE, FALSE, - g_param_spec_float("seconds", "s", "Time in seconds", - -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); - - gst_unitconv_register_unit("time", FALSE, FALSE, - g_param_spec_int64("nanoseconds", "ns", "Time in nanoseconds", - G_MININT64, G_MAXINT64, 0, 0)); - - gst_unitconv_register_unit("time", FALSE, FALSE, - g_param_spec_int64("samples", "samples", "Time in number of samples", - G_MININT64, G_MAXINT64, 0, 0)); - - gst_unitconv_register_convert_property("samples", - g_param_spec_int("samplerate","samplerate","samplerate", - 0, G_MAXINT,0,G_PARAM_READWRITE)); - - - /* magnitude based units */ - gst_unitconv_register_unit("magnitude", TRUE, FALSE, - g_param_spec_float("scalar", "scalar", "Magnitude as a scalar", - -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); - - gst_unitconv_register_unit("magnitude", FALSE, FALSE, - g_param_spec_int("scalar-int", "scalar int", "Magnitude as an integer scalar", - G_MININT, G_MAXINT, 0, 0)); - - gst_unitconv_register_unit("magnitude", FALSE, TRUE, - g_param_spec_float("decibel", "dB", "Magnitude in decibels", - -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); - - gst_unitconv_register_unit("magnitude", FALSE, FALSE, - g_param_spec_float("percent", "%", "Magnitude in percent", - -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); - - /* generic units */ - gst_unitconv_register_unit("float_default", TRUE, FALSE, - g_param_spec_float("float", "float", "Float value", - -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); - - gst_unitconv_register_unit("int_default", TRUE, FALSE, - g_param_spec_int("int", "int", "Integer value", - G_MININT, G_MAXINT, 0, 0)); - - gst_unitconv_register_unit("int64_default", TRUE, FALSE, - g_param_spec_int64("int64", "int64", "64 bit integer value", - G_MININT, G_MAXINT, 0, 0)); - - - gst_unitconv_add_core_converters(); + if (_gst_unitconv_init_done) + return; + + _gst_unitconv_init_done = TRUE; + + _gst_units = g_hash_table_new (g_str_hash, g_str_equal); + _gst_unit_domain_defaults = g_hash_table_new (g_str_hash, g_str_equal); + + /* frequency based units */ + + gst_unitconv_register_unit ("frequency", TRUE, TRUE, + g_param_spec_float ("hertz", "Hz", "Frequency in hertz", + 0, G_MAXFLOAT, 0, 0)); + + gst_unitconv_register_unit ("frequency", FALSE, TRUE, + g_param_spec_float ("hertz-rate-bound", "Hz", + "Frequency in hertz, bound by the sample rate", 0.0, G_MAXFLOAT, 0.0, + 0)); + + gst_unitconv_register_unit ("frequency", FALSE, FALSE, + g_param_spec_string ("twelve-tone-scale", "note", + "Name of the note from the western twelve tone scale", "C", 0)); + + gst_unitconv_register_unit ("frequency", FALSE, FALSE, + g_param_spec_int ("midi-note", "midi note", + "MIDI note value of the frequency", 1, 127, 1, 0)); + + /* time based units */ + gst_unitconv_register_unit ("time", TRUE, FALSE, + g_param_spec_float ("seconds", "s", "Time in seconds", + -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); + + gst_unitconv_register_unit ("time", FALSE, FALSE, + g_param_spec_int64 ("nanoseconds", "ns", "Time in nanoseconds", + G_MININT64, G_MAXINT64, 0, 0)); + + gst_unitconv_register_unit ("time", FALSE, FALSE, + g_param_spec_int64 ("samples", "samples", "Time in number of samples", + G_MININT64, G_MAXINT64, 0, 0)); + + gst_unitconv_register_convert_property ("samples", + g_param_spec_int ("samplerate", "samplerate", "samplerate", + 0, G_MAXINT, 0, G_PARAM_READWRITE)); + + + /* magnitude based units */ + gst_unitconv_register_unit ("magnitude", TRUE, FALSE, + g_param_spec_float ("scalar", "scalar", "Magnitude as a scalar", + -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); + + gst_unitconv_register_unit ("magnitude", FALSE, FALSE, + g_param_spec_int ("scalar-int", "scalar int", + "Magnitude as an integer scalar", G_MININT, G_MAXINT, 0, 0)); + + gst_unitconv_register_unit ("magnitude", FALSE, TRUE, + g_param_spec_float ("decibel", "dB", "Magnitude in decibels", + -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); + + gst_unitconv_register_unit ("magnitude", FALSE, FALSE, + g_param_spec_float ("percent", "%", "Magnitude in percent", + -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); + + /* generic units */ + gst_unitconv_register_unit ("float_default", TRUE, FALSE, + g_param_spec_float ("float", "float", "Float value", + -G_MAXFLOAT, G_MAXFLOAT, 0, 0)); + + gst_unitconv_register_unit ("int_default", TRUE, FALSE, + g_param_spec_int ("int", "int", "Integer value", + G_MININT, G_MAXINT, 0, 0)); + + gst_unitconv_register_unit ("int64_default", TRUE, FALSE, + g_param_spec_int64 ("int64", "int64", "64 bit integer value", + G_MININT, G_MAXINT, 0, 0)); + + + gst_unitconv_add_core_converters (); } gboolean -gst_unitconv_register_unit(const gchar *domain_name, - gboolean is_domain_default, - gboolean is_logarithmic, - GParamSpec *unit_spec) +gst_unitconv_register_unit (const gchar * domain_name, + gboolean is_domain_default, gboolean is_logarithmic, GParamSpec * unit_spec) { - GstUnit* unit; - gchar *unit_name; + GstUnit *unit; + gchar *unit_name; - g_return_val_if_fail (unit_spec != NULL, FALSE); - g_return_val_if_fail (G_IS_PARAM_SPEC(unit_spec), FALSE); - g_return_val_if_fail (domain_name != NULL, FALSE); + g_return_val_if_fail (unit_spec != NULL, FALSE); + g_return_val_if_fail (G_IS_PARAM_SPEC (unit_spec), FALSE); + g_return_val_if_fail (domain_name != NULL, FALSE); - unit_name = g_strdup(g_param_spec_get_name(unit_spec)); + unit_name = g_strdup (g_param_spec_get_name (unit_spec)); - /* check if this unit name already exists */ - if (g_hash_table_lookup (_gst_units, unit_name) != NULL) - { - g_free (unit_name); - return FALSE; - } - if (is_domain_default){ - /* check if an default unit already exists for this domain */ - g_return_val_if_fail ( - g_hash_table_lookup(_gst_unit_domain_defaults, domain_name) == NULL, FALSE); - } + /* check if this unit name already exists */ + if (g_hash_table_lookup (_gst_units, unit_name) != NULL) { + g_free (unit_name); + return FALSE; + } + if (is_domain_default) { + /* check if an default unit already exists for this domain */ + g_return_val_if_fail (g_hash_table_lookup (_gst_unit_domain_defaults, + domain_name) == NULL, FALSE); + } - GST_DEBUG ("creating unit: %s", unit_name); + GST_DEBUG ("creating unit: %s", unit_name); - unit = g_new0(GstUnit,1); + unit = g_new0 (GstUnit, 1); - unit->unit_spec = unit_spec; - unit->domain_name = domain_name; - unit->domain_default = is_domain_default; - unit->logarithmic = is_logarithmic; - unit->convert_to_funcs = g_hash_table_new(NULL,NULL); - /* unit->convert_properties = g_hash_table_new(g_str_hash,g_str_equal); */ + unit->unit_spec = unit_spec; + unit->domain_name = domain_name; + unit->domain_default = is_domain_default; + unit->logarithmic = is_logarithmic; + unit->convert_to_funcs = g_hash_table_new (NULL, NULL); + /* unit->convert_properties = g_hash_table_new(g_str_hash,g_str_equal); */ - g_hash_table_insert(_gst_units, unit_name, unit); + g_hash_table_insert (_gst_units, unit_name, unit); - if (is_domain_default){ - g_hash_table_insert(_gst_unit_domain_defaults, g_strdup(domain_name), unit); - } + if (is_domain_default) { + g_hash_table_insert (_gst_unit_domain_defaults, g_strdup (domain_name), + unit); + } - return TRUE; + return TRUE; } gboolean -gst_unitconv_register_convert_func(gchar *from_unit_named, gchar *to_unit_named, GstUnitConvertFunc convert_func) +gst_unitconv_register_convert_func (gchar * from_unit_named, + gchar * to_unit_named, GstUnitConvertFunc convert_func) { - GHashTable *convert_funcs; - GstUnit *from_unit, *to_unit; - - g_return_val_if_fail (from_unit_named != NULL, FALSE); - g_return_val_if_fail (to_unit_named != NULL, FALSE); - - from_unit = g_hash_table_lookup(_gst_units, from_unit_named); - to_unit = g_hash_table_lookup(_gst_units, to_unit_named); - - g_return_val_if_fail (from_unit != NULL, FALSE); - g_return_val_if_fail (to_unit != NULL, FALSE); - - convert_funcs = from_unit->convert_to_funcs; - - g_return_val_if_fail ( - g_hash_table_lookup(convert_funcs, to_unit) == NULL, FALSE); - - GST_DEBUG ("adding unit converter from %s to %s\n", - g_param_spec_get_name(from_unit->unit_spec), - g_param_spec_get_name(to_unit->unit_spec)); - - g_hash_table_insert(convert_funcs, to_unit, convert_func); - - return TRUE; + GHashTable *convert_funcs; + GstUnit *from_unit, *to_unit; + + g_return_val_if_fail (from_unit_named != NULL, FALSE); + g_return_val_if_fail (to_unit_named != NULL, FALSE); + + from_unit = g_hash_table_lookup (_gst_units, from_unit_named); + to_unit = g_hash_table_lookup (_gst_units, to_unit_named); + + g_return_val_if_fail (from_unit != NULL, FALSE); + g_return_val_if_fail (to_unit != NULL, FALSE); + + convert_funcs = from_unit->convert_to_funcs; + + g_return_val_if_fail (g_hash_table_lookup (convert_funcs, to_unit) == NULL, + FALSE); + + GST_DEBUG ("adding unit converter from %s to %s\n", + g_param_spec_get_name (from_unit->unit_spec), + g_param_spec_get_name (to_unit->unit_spec)); + + g_hash_table_insert (convert_funcs, to_unit, convert_func); + + return TRUE; } gboolean -gst_unitconv_register_convert_property(gchar *unit_name, GParamSpec *convert_prop_spec) +gst_unitconv_register_convert_property (gchar * unit_name, + GParamSpec * convert_prop_spec) { - GstUnit *unit; - g_return_val_if_fail (unit_name != NULL, FALSE); - g_return_val_if_fail (convert_prop_spec != NULL, FALSE); - unit = g_hash_table_lookup(_gst_units, unit_name); - - g_return_val_if_fail (unit != NULL, FALSE); - - unit->convert_paramspecs = g_slist_append(unit->convert_paramspecs, convert_prop_spec); - - return TRUE; + GstUnit *unit; + + g_return_val_if_fail (unit_name != NULL, FALSE); + g_return_val_if_fail (convert_prop_spec != NULL, FALSE); + unit = g_hash_table_lookup (_gst_units, unit_name); + + g_return_val_if_fail (unit != NULL, FALSE); + + unit->convert_paramspecs = + g_slist_append (unit->convert_paramspecs, convert_prop_spec); + + return TRUE; } static void -gst_unitconv_time_seconds_to_nanoseconds(GstUnitConvert *unitconv, GValue *seconds_val, GValue *nanos_val) +gst_unitconv_time_seconds_to_nanoseconds (GstUnitConvert * unitconv, + GValue * seconds_val, GValue * nanos_val) { - g_value_set_int64(nanos_val, - (gint64)(g_value_get_float(seconds_val) * 1000000000.0)); + g_value_set_int64 (nanos_val, + (gint64) (g_value_get_float (seconds_val) * 1000000000.0)); } static void -gst_unitconv_time_nanoseconds_to_seconds(GstUnitConvert *unitconv, GValue *nanos_val, GValue *seconds_val) +gst_unitconv_time_nanoseconds_to_seconds (GstUnitConvert * unitconv, + GValue * nanos_val, GValue * seconds_val) { - g_value_set_float(seconds_val, - ((gfloat)g_value_get_int64(nanos_val)) / 1000000000.0); + g_value_set_float (seconds_val, + ((gfloat) g_value_get_int64 (nanos_val)) / 1000000000.0); } static void -gst_unitconv_time_seconds_to_samples(GstUnitConvert *unitconv, GValue *seconds_val, GValue *samples_val) -{ - /* GValue *samplerate; - GValue *samplerate = g_hash_table_lookup(unitconv->currentToUnit->convert_properties, "samplerate"); - g_value_set_int64(samples_val, - (gint64)(g_value_get_float(seconds_val) * (gfloat)g_value_get_int(samplerate))); */ +gst_unitconv_time_seconds_to_samples (GstUnitConvert * unitconv, + GValue * seconds_val, GValue * samples_val) +{ + /* GValue *samplerate; + GValue *samplerate = g_hash_table_lookup(unitconv->currentToUnit->convert_properties, "samplerate"); + g_value_set_int64(samples_val, + (gint64)(g_value_get_float(seconds_val) * (gfloat)g_value_get_int(samplerate))); */ } static void -gst_unitconv_time_samples_to_seconds(GstUnitConvert *unitconv, GValue *samples_val, GValue *seconds_val) -{ - /* GValue *samplerate; - GValue *samplerate = g_hash_table_lookup(unitconv->currentFromUnit->convert_properties, "samplerate"); - g_value_set_float(seconds_val, - ((gfloat)g_value_get_int64(samples_val)) / (gfloat)g_value_get_int(samplerate));*/ +gst_unitconv_time_samples_to_seconds (GstUnitConvert * unitconv, + GValue * samples_val, GValue * seconds_val) +{ + /* GValue *samplerate; + GValue *samplerate = g_hash_table_lookup(unitconv->currentFromUnit->convert_properties, "samplerate"); + g_value_set_float(seconds_val, + ((gfloat)g_value_get_int64(samples_val)) / (gfloat)g_value_get_int(samplerate)); */ } static void -gst_unitconv_magnitude_scalar_to_percent(GstUnitConvert *unitconv, GValue *scalar_val, GValue *percent_val) -{ - g_value_set_float(percent_val, - g_value_get_float(scalar_val) * 100.0); +gst_unitconv_magnitude_scalar_to_percent (GstUnitConvert * unitconv, + GValue * scalar_val, GValue * percent_val) +{ + g_value_set_float (percent_val, g_value_get_float (scalar_val) * 100.0); } static void -gst_unitconv_magnitude_percent_to_scalar(GstUnitConvert *unitconv, GValue *percent_val, GValue *scalar_val) -{ - g_value_set_float(scalar_val, - g_value_get_float(percent_val) / 100.0); +gst_unitconv_magnitude_percent_to_scalar (GstUnitConvert * unitconv, + GValue * percent_val, GValue * scalar_val) +{ + g_value_set_float (scalar_val, g_value_get_float (percent_val) / 100.0); } static void -gst_unitconv_add_core_converters(void){ - - gst_unitconv_register_convert_func("nanoseconds", "seconds", gst_unitconv_time_nanoseconds_to_seconds); - gst_unitconv_register_convert_func("seconds", "nanoseconds", gst_unitconv_time_seconds_to_nanoseconds); - gst_unitconv_register_convert_func("seconds", "samples", gst_unitconv_time_seconds_to_samples); - gst_unitconv_register_convert_func("samples", "seconds", gst_unitconv_time_samples_to_seconds); - - gst_unitconv_register_convert_func("scalar", "percent", gst_unitconv_magnitude_scalar_to_percent); - gst_unitconv_register_convert_func("percent", "scalar", gst_unitconv_magnitude_percent_to_scalar); +gst_unitconv_add_core_converters (void) +{ + + gst_unitconv_register_convert_func ("nanoseconds", "seconds", + gst_unitconv_time_nanoseconds_to_seconds); + gst_unitconv_register_convert_func ("seconds", "nanoseconds", + gst_unitconv_time_seconds_to_nanoseconds); + gst_unitconv_register_convert_func ("seconds", "samples", + gst_unitconv_time_seconds_to_samples); + gst_unitconv_register_convert_func ("samples", "seconds", + gst_unitconv_time_samples_to_seconds); + + gst_unitconv_register_convert_func ("scalar", "percent", + gst_unitconv_magnitude_scalar_to_percent); + gst_unitconv_register_convert_func ("percent", "scalar", + gst_unitconv_magnitude_percent_to_scalar); } diff --git a/libs/gst/control/unitconvert.h b/libs/gst/control/unitconvert.h index 1f23ade3c..3b52a4e90 100644 --- a/libs/gst/control/unitconvert.h +++ b/libs/gst/control/unitconvert.h @@ -25,55 +25,57 @@ #include G_BEGIN_DECLS - #define GST_TYPE_UNIT_CONVERT (gst_unitconv_get_type ()) #define GST_UNIT_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_UNIT_CONVERT,GstUnitConvert)) #define GST_UNIT_CONVERT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_UNIT_CONVERT,GstUnitConvert)) #define GST_IS_UNIT_CONVERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_UNIT_CONVERT)) #define GST_IS_UNIT_CONVERT_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_UNIT_CONVERT)) - #define GST_UNIT_CONVERT_NAME(unitconv) (GST_OBJECT_NAME(unitconv)) #define GST_UNIT_CONVERT_PARENT(unitconv) (GST_OBJECT_PARENT(unitconv)) - typedef struct _GstUnitConvertClass GstUnitConvertClass; typedef struct _GstUnitConvert GstUnitConvert; -typedef void (*GstUnitConvertFunc) (GstUnitConvert *unitconv, GValue *from_val, GValue *to_val); +typedef void (*GstUnitConvertFunc) (GstUnitConvert * unitconv, + GValue * from_val, GValue * to_val); -struct _GstUnitConvert { - GstObject object; +struct _GstUnitConvert +{ + GstObject object; - GHashTable *convert_params; - GSList *convert_func_chain; - GSList *temp_gvalues; + GHashTable *convert_params; + GSList *convert_func_chain; + GSList *temp_gvalues; }; -struct _GstUnitConvertClass { - GstObjectClass parent_class; +struct _GstUnitConvertClass +{ + GstObjectClass parent_class; - /* signal callbacks */ + /* signal callbacks */ }; GType gst_unitconv_get_type (void); -GstUnitConvert* gst_unitconv_new (void); +GstUnitConvert *gst_unitconv_new (void); void _gst_unitconv_initialize (void); -gboolean gst_unitconv_set_convert_units(GstUnitConvert *unitconv, gchar *from_unit_named, gchar *to_unit_named); -gboolean gst_unitconv_convert_value(GstUnitConvert *unitconv, GValue *from_value, GValue *to_value); +gboolean gst_unitconv_set_convert_units (GstUnitConvert * unitconv, + gchar * from_unit_named, gchar * to_unit_named); +gboolean gst_unitconv_convert_value (GstUnitConvert * unitconv, + GValue * from_value, GValue * to_value); -GParamSpec* gst_unitconv_unit_spec(gchar *unit_name); -gboolean gst_unitconv_unit_exists(gchar *unit_name); -gboolean gst_unitconv_unit_is_logarithmic(gchar *unit_name); +GParamSpec *gst_unitconv_unit_spec (gchar * unit_name); +gboolean gst_unitconv_unit_exists (gchar * unit_name); +gboolean gst_unitconv_unit_is_logarithmic (gchar * unit_name); -gboolean gst_unitconv_register_unit(const gchar *domain_name, - gboolean is_domain_default, - gboolean is_logarithmic, - GParamSpec *unit_spec); +gboolean gst_unitconv_register_unit (const gchar * domain_name, + gboolean is_domain_default, + gboolean is_logarithmic, GParamSpec * unit_spec); -gboolean gst_unitconv_register_convert_func(gchar *from_unit_named, gchar *to_unit_named, GstUnitConvertFunc convert_func); -gboolean gst_unitconv_register_convert_property(gchar *unit_name, GParamSpec *convert_prop_spec); +gboolean gst_unitconv_register_convert_func (gchar * from_unit_named, + gchar * to_unit_named, GstUnitConvertFunc convert_func); +gboolean gst_unitconv_register_convert_property (gchar * unit_name, + GParamSpec * convert_prop_spec); G_END_DECLS - #endif /* __GST_UNITCONVERT_H__ */ diff --git a/libs/gst/getbits/gbtest.c b/libs/gst/getbits/gbtest.c index 0d1f629f6..99210557a 100644 --- a/libs/gst/getbits/gbtest.c +++ b/libs/gst/getbits/gbtest.c @@ -1,94 +1,100 @@ #include #include "gstgetbits.h" -char *print_bits(unsigned long bits,int size) { - char *ret = (char *)malloc(size+1); +char * +print_bits (unsigned long bits, int size) +{ + char *ret = (char *) malloc (size + 1); int i; + ret[size] = 0; - for (i=0;i 00000011 %lu\n",bits, gb.bits); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000022 %lu\n",bits, gb.bits); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000044 %lu\n",bits, gb.bits); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000088 %lu\n",bits, gb.bits); - bits = gst_getbits6(&gb); - printf("%08x <-> 00000033 %lu\n",bits, gb.bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000011 %lu\n", bits, gb.bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000022 %lu\n", bits, gb.bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000044 %lu\n", bits, gb.bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000088 %lu\n", bits, gb.bits); + bits = gst_getbits6 (&gb); + printf ("%08x <-> 00000033 %lu\n", bits, gb.bits); - gst_backbitsn(&gb, 16); + gst_backbitsn (&gb, 16); - bits = gst_getbits10(&gb); - printf("%08x <-> 00000088 \n",bits); + bits = gst_getbits10 (&gb); + printf ("%08x <-> 00000088 \n", bits); - gst_getbits_newbuf(&gb,(unsigned char *)testbuffer, 7); + gst_getbits_newbuf (&gb, (unsigned char *) testbuffer, 7); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000011 \n",bits); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000022 \n",bits); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000044 \n",bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000011 \n", bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000022 \n", bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000044 \n", bits); - bits = gst_getbits6(&gb); - printf("%08x <-> 00000022 \n",bits); + bits = gst_getbits6 (&gb); + printf ("%08x <-> 00000022 \n", bits); - gst_backbitsn(&gb, 19); + gst_backbitsn (&gb, 19); - bits = gst_getbits19(&gb); - printf("%08x <-> 00009122 \n",bits); + bits = gst_getbits19 (&gb); + printf ("%08x <-> 00009122 \n", bits); - bits = gst_getbits10(&gb); - printf("%08x <-> 000000cc \n",bits); + bits = gst_getbits10 (&gb); + printf ("%08x <-> 000000cc \n", bits); - gst_backbitsn(&gb, 8); + gst_backbitsn (&gb, 8); - gst_backbitsn(&gb, 19); + gst_backbitsn (&gb, 19); - gst_backbitsn(&gb, 8); + gst_backbitsn (&gb, 8); - bits = gst_getbits19(&gb); - printf("%08x <-> 00012244 \n",bits); - bits = gst_getbits8(&gb); - printf("%08x <-> 00000088 \n",bits); + bits = gst_getbits19 (&gb); + printf ("%08x <-> 00012244 \n", bits); + bits = gst_getbits8 (&gb); + printf ("%08x <-> 00000088 \n", bits); return 0; } diff --git a/libs/gst/getbits/getbits.c b/libs/gst/getbits/getbits.c index adf4522d6..db899172a 100644 --- a/libs/gst/getbits/getbits.c +++ b/libs/gst/getbits/getbits.c @@ -3,24 +3,28 @@ #include "getbits.h" /* Defined in gstgetbits_i386.s */ -extern unsigned long _gst_get1bit_i386(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_getbits_i386(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_getbits_fast_i386(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_showbits_i386(gst_getbits_t *gb, unsigned long bits); -extern void _gst_flushbits_i386(gst_getbits_t *gb, unsigned long bits); -extern void _gst_getbits_back_i386(gst_getbits_t *gb, unsigned long bits); +extern unsigned long _gst_get1bit_i386 (gst_getbits_t * gb, unsigned long bits); +extern unsigned long _gst_getbits_i386 (gst_getbits_t * gb, unsigned long bits); +extern unsigned long _gst_getbits_fast_i386 (gst_getbits_t * gb, + unsigned long bits); +extern unsigned long _gst_showbits_i386 (gst_getbits_t * gb, + unsigned long bits); +extern void _gst_flushbits_i386 (gst_getbits_t * gb, unsigned long bits); +extern void _gst_getbits_back_i386 (gst_getbits_t * gb, unsigned long bits); /* Defined in gstgetbits_generic.c */ -extern unsigned long _gst_getbits_int_cb(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_get1bit_int(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_getbits_int(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_getbits_fast_int(gst_getbits_t *gb, unsigned long bits); -extern unsigned long _gst_showbits_int(gst_getbits_t *gb, unsigned long bits); -extern void _gst_flushbits_int(gst_getbits_t *gb, unsigned long bits); -extern void _gst_getbits_back_int(gst_getbits_t *gb, unsigned long bits); - - -unsigned long gst_getbits_nBitMask[] = { +extern unsigned long _gst_getbits_int_cb (gst_getbits_t * gb, + unsigned long bits); +extern unsigned long _gst_get1bit_int (gst_getbits_t * gb, unsigned long bits); +extern unsigned long _gst_getbits_int (gst_getbits_t * gb, unsigned long bits); +extern unsigned long _gst_getbits_fast_int (gst_getbits_t * gb, + unsigned long bits); +extern unsigned long _gst_showbits_int (gst_getbits_t * gb, unsigned long bits); +extern void _gst_flushbits_int (gst_getbits_t * gb, unsigned long bits); +extern void _gst_getbits_back_int (gst_getbits_t * gb, unsigned long bits); + + +unsigned long gst_getbits_nBitMask[] = { 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, @@ -28,7 +32,8 @@ unsigned long gst_getbits_nBitMask[] = { 0xffff0000, 0xffff8000, 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, - 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe}; + 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe +}; unsigned long _getbits_masks[] = { 0x00000000, @@ -44,9 +49,12 @@ unsigned long _getbits_masks[] = { #ifdef unused unsigned long _getbits_64_minus_index[] = { - 64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41, - 40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17, - 16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1 }; + 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, + 45, 44, 43, 42, 41, + 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, + 21, 20, 19, 18, 17, + 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 +}; /* this routine taken from Intel AppNote AP-527: "Using MMX[tm] Instructions to Get Bits From a Data Stream" @@ -54,7 +62,9 @@ unsigned long _getbits_64_minus_index[] = { this isn't as cycle-efficient, due to the simple fact that I must call emms() at the end. all state must be kept in *gb, not in registers */ -unsigned long _gst_getbits_mmx(gst_getbits_t *gb,unsigned long bits) { +unsigned long +_gst_getbits_mmx (gst_getbits_t * gb, unsigned long bits) +{ signed long remaining; unsigned long result; @@ -65,16 +75,16 @@ unsigned long _gst_getbits_mmx(gst_getbits_t *gb,unsigned long bits) { symbolically in this C code. gcc is probably going to lose horribly, I'll do an inline asm version later. I've a point to prove ;-) */ /* find the right shift value, put it in mm3 */ - movd_m2r(_getbits_64_minus_index[bits],mm3); + movd_m2r (_getbits_64_minus_index[bits], mm3); /* load the current quadword into mm0 */ - movq_m2r(gb->qword,mm0); + movq_m2r (gb->qword, mm0); /* copy it to mm2 */ - movq_r2r(mm0,mm2); + movq_r2r (mm0, mm2); remaining = gb->bits - bits; if (remaining <= 0) { - unsigned long dword1,dword2; + unsigned long dword1, dword2; /* shift the pointer by 64 bits (8 bytes) */ gb->ptr += 8; @@ -82,79 +92,83 @@ unsigned long _gst_getbits_mmx(gst_getbits_t *gb,unsigned long bits) { remaining += 64; /* grab the first 32 bits from the buffer and swap them around */ - dword1 = swab32(*(gb->ptr-8)); + dword1 = swab32 (*(gb->ptr - 8)); /* grab the second 32 bits, swap */ - dword2 = swab32(*(gb->ptr-4)); + dword2 = swab32 (*(gb->ptr - 4)); /* put second dword in mm4 */ - movd_m2r(dword2,mm4); + movd_m2r (dword2, mm4); /* shift mm2 over to make room for new bits */ - psrlq_r2r(mm3,mm2); + psrlq_r2r (mm3, mm2); /* put first dword in mm1 */ - movd_m2r(dword1,mm1); + movd_m2r (dword1, mm1); /* shift second dword up 32 bits */ - psrlq_i2r(32,mm4); + psrlq_i2r (32, mm4); /* put the shift counter in mm3 */ - movd_m2r(remaining,mm3); + movd_m2r (remaining, mm3); /* combine the swapped data in mm4 */ - por_r2r(mm1,mm4); + por_r2r (mm1, mm4); /* save off the bits in mm4 to mm0 */ - movq_r2r(mm4,mm0); + movq_r2r (mm4, mm0); /* get the new low-order bits in mm4, shifted by 'mm3' */ - psrlq_r2r(mm3,mm4); + psrlq_r2r (mm3, mm4); /* save off new remaining bits */ gb->bits = remaining; /* combine bits into mm2 */ - por_r2r(mm2,mm4); + por_r2r (mm2, mm4); /* save off the result */ - movd_r2m(mm2,result); + movd_r2m (mm2, result); /* get rid of the bits we just read */ - psllq_r2r(mm1,mm0); + psllq_r2r (mm1, mm0); /* save off mm0 */ - movq_r2m(mm0,gb->qword); + movq_r2m (mm0, gb->qword); /* finished with MMX */ - emms(); + emms (); /* we have what we came for */ - return(result); + return (result); } else { /* load the number of bits requested into mm1 */ - movd_m2r(bits,mm1); + movd_m2r (bits, mm1); /* shift the quadword in mm2 by 'mm3' bits */ - psrlq_r2r(mm3,mm2); + psrlq_r2r (mm3, mm2); /* update the number of valid bits */ gb->bits = remaining; /* save off the remaining bits */ - movd_r2m(mm2,result); + movd_r2m (mm2, result); /* discard those bits in mm0 */ - psllq_r2r(mm1,mm0); + psllq_r2r (mm1, mm0); /* save off mm0 */ - movq_r2m(mm0,gb->qword); + movq_r2m (mm0, gb->qword); /* finished with MMX */ - emms(); + emms (); /* we have what we came for */ - return(result); + return (result); } } #endif /* HAVE_LIBMMX */ -unsigned long _gst_getbyte(gst_getbits_t *gb, unsigned long bits) { +unsigned long +_gst_getbyte (gst_getbits_t * gb, unsigned long bits) +{ return *gb->ptr++; } /* initialize the getbits structure with the proper getbits func */ -void gst_getbits_init(gst_getbits_t *gb, GstGetbitsCallback callback, void *data) { +void +gst_getbits_init (gst_getbits_t * gb, GstGetbitsCallback callback, void *data) +{ gb->ptr = NULL; gb->bits = 0; gb->callback = callback; @@ -175,8 +189,7 @@ void gst_getbits_init(gst_getbits_t *gb, GstGetbitsCallback callback, void *data gb->flushbits = _gst_flushbits_int; gb->backbits = _gst_getbits_back_int; /* printf("gstgetbits: using callback versions\n"); */ - } - else { + } else { #ifdef HAVE_CPU_I386 gb->get1bit = _gst_get1bit_i386; gb->getbits = _gst_getbits_i386; @@ -203,9 +216,12 @@ void gst_getbits_init(gst_getbits_t *gb, GstGetbitsCallback callback, void *data } /* set up the getbits structure with a new buffer */ -void gst_getbits_newbuf(gst_getbits_t *gb,unsigned char *buffer, unsigned long len) { +void +gst_getbits_newbuf (gst_getbits_t * gb, unsigned char *buffer, + unsigned long len) +{ gb->ptr = buffer; - gb->endptr = buffer+len; + gb->endptr = buffer + len; gb->bits = 0; #ifdef unused /* gb->qword = 0; */ @@ -214,20 +230,13 @@ void gst_getbits_newbuf(gst_getbits_t *gb,unsigned char *buffer, unsigned long l static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstgetbits", - "Accelerated routines for getting bits from a data stream", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstgetbits", + "Accelerated routines for getting bits from a data stream", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/libs/gst/getbits/getbits.h b/libs/gst/getbits/getbits.h index c07093929..af4c7bb60 100644 --- a/libs/gst/getbits/getbits.h +++ b/libs/gst/getbits/getbits.h @@ -10,30 +10,31 @@ #define swab32(x) GUINT32_FROM_BE(x) typedef struct _gst_getbits_t gst_getbits_t; -typedef void (*GstGetbitsCallback) (gst_getbits_t *gb, void *data); +typedef void (*GstGetbitsCallback) (gst_getbits_t * gb, void *data); /* breaks in structure show alignment on quadword boundaries */ /* FIXME: need to find out how to force GCC to align this to octwords */ -struct _gst_getbits_t { - unsigned char *ptr; +struct _gst_getbits_t +{ + unsigned char *ptr; unsigned long *longptr; unsigned char *endptr; unsigned long length; - long bits; + long bits; unsigned long dword; unsigned long temp; GstGetbitsCallback callback; void *data; - unsigned long (*get1bit)(gst_getbits_t *gb, unsigned long bits); - unsigned long (*getbits)(gst_getbits_t *gb, unsigned long bits); - unsigned long (*getbits_fast)(gst_getbits_t *gb, unsigned long bits); - unsigned long (*getbyte)(gst_getbits_t *gb, unsigned long bits); - unsigned long (*show1bit)(gst_getbits_t *gb, unsigned long bits); - unsigned long (*showbits)(gst_getbits_t *gb, unsigned long bits); - void (*flushbits)(gst_getbits_t *gb, unsigned long bits); - void (*backbits)(gst_getbits_t *gb, unsigned long bits); + unsigned long (*get1bit) (gst_getbits_t * gb, unsigned long bits); + unsigned long (*getbits) (gst_getbits_t * gb, unsigned long bits); + unsigned long (*getbits_fast) (gst_getbits_t * gb, unsigned long bits); + unsigned long (*getbyte) (gst_getbits_t * gb, unsigned long bits); + unsigned long (*show1bit) (gst_getbits_t * gb, unsigned long bits); + unsigned long (*showbits) (gst_getbits_t * gb, unsigned long bits); + void (*flushbits) (gst_getbits_t * gb, unsigned long bits); + void (*backbits) (gst_getbits_t * gb, unsigned long bits); }; @@ -41,19 +42,21 @@ struct _gst_getbits_t { #include "gstgetbits_inl.h" #else -void gst_getbits_init(gst_getbits_t *gb, GstGetbitsCallback callback, void *data); -void gst_getbits_newbuf(gst_getbits_t *gb, unsigned char *buffer, unsigned long len); +void gst_getbits_init (gst_getbits_t * gb, GstGetbitsCallback callback, + void *data); +void gst_getbits_newbuf (gst_getbits_t * gb, unsigned char *buffer, + unsigned long len); #define gst_getbits_bitoffset(gb) \ ( \ (-(gb)->bits)&0x7 \ ) -#define gst_getbits_align_byte(gb) +#define gst_getbits_align_byte(gb) #define gst_getbits_bufferpos(gb) ((gb)->ptr) -#define gst_getbits_bytesleft(gb) ((gb)->endptr - (gb)->ptr) +#define gst_getbits_bytesleft(gb) ((gb)->endptr - (gb)->ptr) #define gst_getbits_bitsleft(gb) (((gb)->endptr - (gb)->ptr)*8 - ((-(gb)->bits)&0x7)) diff --git a/libs/gst/getbits/gstgetbits_generic.c b/libs/gst/getbits/gstgetbits_generic.c index f1b01a6ad..8b54b15bf 100644 --- a/libs/gst/getbits/gstgetbits_generic.c +++ b/libs/gst/getbits/gstgetbits_generic.c @@ -1,116 +1,132 @@ #include "getbits.h" -unsigned long _gst_getbits_int_cb(gst_getbits_t *gb, unsigned long bits); -unsigned long _gst_get1bit_int(gst_getbits_t *gb, unsigned long bits); -unsigned long _gst_getbits_int(gst_getbits_t *gb, unsigned long bits); -unsigned long _gst_getbits_fast_int(gst_getbits_t *gb, unsigned long bits); -unsigned long _gst_showbits_int(gst_getbits_t *gb, unsigned long bits); -void _gst_flushbits_int(gst_getbits_t *gb, unsigned long bits); -void _gst_getbits_back_int(gst_getbits_t *gb, unsigned long bits); - - -unsigned long _gst_getbits_int_cb(gst_getbits_t *gb, unsigned long bits) { +unsigned long _gst_getbits_int_cb (gst_getbits_t * gb, unsigned long bits); +unsigned long _gst_get1bit_int (gst_getbits_t * gb, unsigned long bits); +unsigned long _gst_getbits_int (gst_getbits_t * gb, unsigned long bits); +unsigned long _gst_getbits_fast_int (gst_getbits_t * gb, unsigned long bits); +unsigned long _gst_showbits_int (gst_getbits_t * gb, unsigned long bits); +void _gst_flushbits_int (gst_getbits_t * gb, unsigned long bits); +void _gst_getbits_back_int (gst_getbits_t * gb, unsigned long bits); + + +unsigned long +_gst_getbits_int_cb (gst_getbits_t * gb, unsigned long bits) +{ int result; int bitsleft; /*printf("gst_getbits%lu %ld %p %08x\n", bits, gb->bits, gb->ptr, gb->dword); */ - if (!bits) return 0; + if (!bits) + return 0; gb->bits -= bits; - result = gb->dword >> (32-bits); + result = gb->dword >> (32 - bits); if (gb->bits < 0) { - + gb->ptr += 4; - bitsleft = (gb->endptr - gb->ptr)*8; + bitsleft = (gb->endptr - gb->ptr) * 8; bits = -gb->bits; - gb->bits += (bitsleft>32? 32 : bitsleft); - + gb->bits += (bitsleft > 32 ? 32 : bitsleft); + if (gb->endptr <= gb->ptr) { - (gb->callback)(gb, gb->data); + (gb->callback) (gb, gb->data); gb->bits -= bits; } - gb->dword = swab32(*((unsigned long *)(gb->ptr))); + gb->dword = swab32 (*((unsigned long *) (gb->ptr))); - result |= (gb->dword >> (32-bits)); + result |= (gb->dword >> (32 - bits)); } gb->dword <<= bits; return result; } -unsigned long _gst_get1bit_int(gst_getbits_t *gb, unsigned long bits) { +unsigned long +_gst_get1bit_int (gst_getbits_t * gb, unsigned long bits) +{ unsigned char rval; rval = *gb->ptr << gb->bits; gb->bits++; - gb->ptr += (gb->bits>>3); + gb->ptr += (gb->bits >> 3); gb->bits &= 0x7; GST_DEBUG ("getbits%ld, %08x", bits, rval); - return rval>>7; + return rval >> 7; } -unsigned long _gst_getbits_int(gst_getbits_t *gb, unsigned long bits) { +unsigned long +_gst_getbits_int (gst_getbits_t * gb, unsigned long bits) +{ unsigned long rval; - if (bits == 0) return 0; + if (bits == 0) + return 0; - rval = swab32(*((unsigned long *)(gb->ptr))); + rval = swab32 (*((unsigned long *) (gb->ptr))); rval <<= gb->bits; gb->bits += bits; - rval >>= (32-bits); - gb->ptr += (gb->bits>>3); + rval >>= (32 - bits); + gb->ptr += (gb->bits >> 3); gb->bits &= 0x7; GST_DEBUG ("getbits%ld, %08lx", bits, rval); return rval; } -unsigned long _gst_getbits_fast_int(gst_getbits_t *gb, unsigned long bits) { +unsigned long +_gst_getbits_fast_int (gst_getbits_t * gb, unsigned long bits) +{ unsigned long rval; rval = (unsigned char) (gb->ptr[0] << gb->bits); - rval |= ((unsigned int) gb->ptr[1] << gb->bits)>>8; + rval |= ((unsigned int) gb->ptr[1] << gb->bits) >> 8; rval <<= bits; rval >>= 8; gb->bits += bits; - gb->ptr += (gb->bits>>3); + gb->ptr += (gb->bits >> 3); gb->bits &= 0x7; GST_DEBUG ("getbits%ld, %08lx", bits, rval); return rval; } -unsigned long _gst_showbits_int(gst_getbits_t *gb, unsigned long bits) { +unsigned long +_gst_showbits_int (gst_getbits_t * gb, unsigned long bits) +{ unsigned long rval; - if (bits == 0) return 0; + if (bits == 0) + return 0; - rval = swab32(*((unsigned long *)(gb->ptr))); + rval = swab32 (*((unsigned long *) (gb->ptr))); rval <<= gb->bits; - rval >>= (32-bits); + rval >>= (32 - bits); GST_DEBUG ("showbits%ld, %08lx", bits, rval); return rval; } -void _gst_flushbits_int(gst_getbits_t *gb, unsigned long bits) { +void +_gst_flushbits_int (gst_getbits_t * gb, unsigned long bits) +{ gb->bits += bits; - gb->ptr += (gb->bits>>3); + gb->ptr += (gb->bits >> 3); gb->bits &= 0x7; GST_DEBUG ("flushbits%ld", bits); } -void _gst_getbits_back_int(gst_getbits_t *gb, unsigned long bits) { +void +_gst_getbits_back_int (gst_getbits_t * gb, unsigned long bits) +{ gb->bits -= bits; - gb->ptr += (gb->bits>>3); + gb->ptr += (gb->bits >> 3); gb->bits &= 0x7; } - diff --git a/libs/gst/getbits/gstgetbits_inl.h b/libs/gst/getbits/gstgetbits_inl.h index 32c5b2aa6..3b22500a1 100644 --- a/libs/gst/getbits/gstgetbits_inl.h +++ b/libs/gst/getbits/gstgetbits_inl.h @@ -97,7 +97,7 @@ extern unsigned long gst_getbits_nBitMask[]; #define gst_getbits_bufferpos(gb) ((gb)->longptr) -#define gst_getbits_bytesleft(gb) ((gb)->endptr - (unsigned char*)(gb)->longptr) +#define gst_getbits_bytesleft(gb) ((gb)->endptr - (unsigned char*)(gb)->longptr) #define gst_getbits_bitsleft(gb) (((gb)->endptr - (unsigned char*)(gb)->longptr)*8 - (gb)->bits) diff --git a/plugins/elements/gstaggregator.c b/plugins/elements/gstaggregator.c index b4945b8a0..1ad3b2a98 100644 --- a/plugins/elements/gstaggregator.c +++ b/plugins/elements/gstaggregator.c @@ -29,20 +29,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_aggregator_debug); #define GST_CAT_DEFAULT gst_aggregator_debug -GstElementDetails gst_aggregator_details = GST_ELEMENT_DETAILS ( - "Aggregator pipe fitting", - "Generic", - "N-to-1 pipe fitting", - "Wim Taymans " -); +GstElementDetails gst_aggregator_details = +GST_ELEMENT_DETAILS ("Aggregator pipe fitting", + "Generic", + "N-to-1 pipe fitting", + "Wim Taymans "); /* Aggregator signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_NUM_PADS, ARG_SILENT, @@ -51,12 +52,11 @@ enum { /* FILL ME */ }; -GstStaticPadTemplate aggregator_src_template = GST_STATIC_PAD_TEMPLATE ( - "sink%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate aggregator_src_template = +GST_STATIC_PAD_TEMPLATE ("sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_AGGREGATOR_SCHED (gst_aggregator_sched_get_type()) static GType @@ -64,75 +64,80 @@ gst_aggregator_sched_get_type (void) { static GType aggregator_sched_type = 0; static GEnumValue aggregator_sched[] = { - { AGGREGATOR_LOOP, "1", "Loop Based"}, - { AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"}, - { AGGREGATOR_CHAIN, "4", "Chain Based"}, + {AGGREGATOR_LOOP, "1", "Loop Based"}, + {AGGREGATOR_LOOP_SELECT, "3", "Loop Based Select"}, + {AGGREGATOR_CHAIN, "4", "Chain Based"}, {0, NULL, NULL}, }; if (!aggregator_sched_type) { - aggregator_sched_type = g_enum_register_static ("GstAggregatorSched", aggregator_sched); + aggregator_sched_type = + g_enum_register_static ("GstAggregatorSched", aggregator_sched); } return aggregator_sched_type; } #define AGGREGATOR_IS_LOOP_BASED(ag) ((ag)->sched != AGGREGATOR_CHAIN) -static GstPad* gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *temp, const - gchar *unused); -static void gst_aggregator_update_functions (GstAggregator *aggregator); +static GstPad *gst_aggregator_request_new_pad (GstElement * element, + GstPadTemplate * temp, const gchar * unused); +static void gst_aggregator_update_functions (GstAggregator * aggregator); -static void gst_aggregator_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_aggregator_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_aggregator_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_aggregator_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_aggregator_chain (GstPad *pad, GstData *_data); -static void gst_aggregator_loop (GstElement *element); +static void gst_aggregator_chain (GstPad * pad, GstData * _data); +static void gst_aggregator_loop (GstElement * element); #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_aggregator_debug, "aggregator", 0, "aggregator element"); -GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstAggregator, gst_aggregator, GstElement, + GST_TYPE_ELEMENT, _do_init); static void gst_aggregator_base_init (gpointer g_class) { - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&aggregator_src_template)); gst_element_class_set_details (gstelement_class, &gst_aggregator_details); } static void -gst_aggregator_class_init (GstAggregatorClass *klass) +gst_aggregator_class_init (GstAggregatorClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*) klass; - gstelement_class = (GstElementClass*) klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, - g_param_spec_int ("num_pads", "Num pads", "The number of source pads", - 0, G_MAXINT, 0, G_PARAM_READABLE)); + g_param_spec_int ("num_pads", "Num pads", "The number of source pads", + 0, G_MAXINT, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "Silent", "Don't produce messages", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "Silent", "Don't produce messages", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SCHED, - g_param_spec_enum ("sched", "Scheduling", "The type of scheduling this element should use", - GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE)); + g_param_spec_enum ("sched", "Scheduling", + "The type of scheduling this element should use", + GST_TYPE_AGGREGATOR_SCHED, AGGREGATOR_CHAIN, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last_message", "Last message", "The current state of the element", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last_message", "Last message", + "The current state of the element", NULL, G_PARAM_READABLE)); - gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_aggregator_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_aggregator_get_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_aggregator_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_aggregator_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_aggregator_request_new_pad); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad); } -static void -gst_aggregator_init (GstAggregator *aggregator) +static void +gst_aggregator_init (GstAggregator * aggregator) { aggregator->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_getcaps_function (aggregator->srcpad, gst_pad_proxy_getcaps); @@ -146,8 +151,9 @@ gst_aggregator_init (GstAggregator *aggregator) gst_aggregator_update_functions (aggregator); } -static GstPad* -gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_aggregator_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *sinkpad; @@ -162,43 +168,42 @@ gst_aggregator_request_new_pad (GstElement *element, GstPadTemplate *templ, cons aggregator = GST_AGGREGATOR (element); - name = g_strdup_printf ("sink%d",aggregator->numsinkpads); - + name = g_strdup_printf ("sink%d", aggregator->numsinkpads); + sinkpad = gst_pad_new_from_template (templ, name); g_free (name); - + if (!AGGREGATOR_IS_LOOP_BASED (aggregator)) { gst_pad_set_chain_function (sinkpad, gst_aggregator_chain); } gst_pad_set_getcaps_function (sinkpad, gst_pad_proxy_getcaps); gst_element_add_pad (GST_ELEMENT (aggregator), sinkpad); - + aggregator->sinkpads = g_list_prepend (aggregator->sinkpads, sinkpad); aggregator->numsinkpads++; - + return sinkpad; } static void -gst_aggregator_update_functions (GstAggregator *aggregator) +gst_aggregator_update_functions (GstAggregator * aggregator) { GList *pads; if (AGGREGATOR_IS_LOOP_BASED (aggregator)) { - gst_element_set_loop_function (GST_ELEMENT (aggregator), GST_DEBUG_FUNCPTR (gst_aggregator_loop)); - } - else { + gst_element_set_loop_function (GST_ELEMENT (aggregator), + GST_DEBUG_FUNCPTR (gst_aggregator_loop)); + } else { gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL); } pads = aggregator->sinkpads; while (pads) { GstPad *pad = GST_PAD (pads->data); - + if (AGGREGATOR_IS_LOOP_BASED (aggregator)) { gst_pad_set_get_function (pad, NULL); - } - else { + } else { gst_element_set_loop_function (GST_ELEMENT (aggregator), NULL); } pads = g_list_next (pads); @@ -206,7 +211,8 @@ gst_aggregator_update_functions (GstAggregator *aggregator) } static void -gst_aggregator_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_aggregator_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstAggregator *aggregator; @@ -229,7 +235,8 @@ gst_aggregator_set_property (GObject *object, guint prop_id, const GValue *value } static void -gst_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_aggregator_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstAggregator *aggregator; @@ -256,15 +263,17 @@ gst_aggregator_get_property (GObject *object, guint prop_id, GValue *value, GPar } } -static void -gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guchar *debug) +static void +gst_aggregator_push (GstAggregator * aggregator, GstPad * pad, GstBuffer * buf, + guchar * debug) { if (!aggregator->silent) { g_free (aggregator->last_message); - aggregator->last_message = g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %" - G_GUINT64_FORMAT ")", - debug, GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); + aggregator->last_message = + g_strdup_printf ("%10.10s ******* (%s:%s)a (%d bytes, %" + G_GUINT64_FORMAT ")", debug, GST_DEBUG_PAD_NAME (pad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (aggregator), "last_message"); } @@ -272,8 +281,8 @@ gst_aggregator_push (GstAggregator *aggregator, GstPad *pad, GstBuffer *buf, guc gst_pad_push (aggregator->srcpad, GST_DATA (buf)); } -static void -gst_aggregator_loop (GstElement *element) +static void +gst_aggregator_loop (GstElement * element) { GstAggregator *aggregator; GstBuffer *buf; @@ -288,6 +297,7 @@ gst_aggregator_loop (GstElement *element) * active ones */ while (pads) { GstPad *pad = GST_PAD (pads->data); + pads = g_list_next (pads); /* we need to check is the pad is usable. IS_USABLE will check @@ -296,15 +306,14 @@ gst_aggregator_loop (GstElement *element) * and that the peer pad is also enabled. */ if (GST_PAD_IS_USABLE (pad)) { - buf = GST_BUFFER (gst_pad_pull (pad)); - debug = "loop"; + buf = GST_BUFFER (gst_pad_pull (pad)); + debug = "loop"; /* then push it forward */ - gst_aggregator_push (aggregator, pad, buf, debug); + gst_aggregator_push (aggregator, pad, buf, debug); } } - } - else { + } else { if (aggregator->sched == AGGREGATOR_LOOP_SELECT) { GstPad *pad; @@ -314,8 +323,7 @@ gst_aggregator_loop (GstElement *element) buf = GST_BUFFER (gst_pad_pull (pad)); gst_aggregator_push (aggregator, pad, buf, debug); - } - else { + } else { g_assert_not_reached (); } } @@ -328,8 +336,8 @@ gst_aggregator_loop (GstElement *element) * * Chain a buffer on a pad. */ -static void -gst_aggregator_chain (GstPad *pad, GstData *_data) +static void +gst_aggregator_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstAggregator *aggregator; @@ -343,4 +351,3 @@ gst_aggregator_chain (GstPad *pad, GstData *_data) gst_aggregator_push (aggregator, pad, buf, "chain"); } - diff --git a/plugins/elements/gstaggregator.h b/plugins/elements/gstaggregator.h index 7e6105bf0..e0e9261a4 100644 --- a/plugins/elements/gstaggregator.h +++ b/plugins/elements/gstaggregator.h @@ -26,11 +26,9 @@ #include -G_BEGIN_DECLS - - -typedef enum { - AGGREGATOR_LOOP = 1, +G_BEGIN_DECLS typedef enum +{ + AGGREGATOR_LOOP = 1, AGGREGATOR_LOOP_SELECT, AGGREGATOR_CHAIN } GstAggregatorSchedType; @@ -46,10 +44,11 @@ typedef enum { #define GST_IS_AGGREGATOR_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AGGREGATOR)) -typedef struct _GstAggregator GstAggregator; -typedef struct _GstAggregatorClass GstAggregatorClass; +typedef struct _GstAggregator GstAggregator; +typedef struct _GstAggregatorClass GstAggregatorClass; -struct _GstAggregator { +struct _GstAggregator +{ GstElement element; GstPad *srcpad; @@ -63,14 +62,14 @@ struct _GstAggregator { gchar *last_message; }; -struct _GstAggregatorClass { +struct _GstAggregatorClass +{ GstElementClass parent_class; }; -GType gst_aggregator_get_type (void); +GType gst_aggregator_get_type (void); -gboolean gst_aggregator_factory_init (GstElementFactory *factory); +gboolean gst_aggregator_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_AGGREGATOR_H__ */ diff --git a/plugins/elements/gstbufferstore.c b/plugins/elements/gstbufferstore.c index cb433f41b..a942f78d2 100644 --- a/plugins/elements/gstbufferstore.c +++ b/plugins/elements/gstbufferstore.c @@ -29,47 +29,53 @@ GST_DEBUG_CATEGORY_STATIC (gst_buffer_store_debug); #define GST_CAT_DEFAULT gst_buffer_store_debug -enum { +enum +{ CLEARED, BUFFER_ADDED, LAST_SIGNAL }; -enum { +enum +{ ARG_0 }; -static void gst_buffer_store_dispose (GObject * object); +static void gst_buffer_store_dispose (GObject * object); + +static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store, + GstBuffer * buffer); +static void gst_buffer_store_cleared_func (GstBufferStore * store); -static gboolean gst_buffer_store_add_buffer_func (GstBufferStore * store, - GstBuffer * buffer); -static void gst_buffer_store_cleared_func (GstBufferStore * store); - static guint gst_buffer_store_signals[LAST_SIGNAL] = { 0 }; #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_buffer_store_debug, "GstBufferStore", 0, "buffer store helper"); -GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT, _do_init); +GST_BOILERPLATE_FULL (GstBufferStore, gst_buffer_store, GObject, G_TYPE_OBJECT, + _do_init); G_GNUC_UNUSED static void -debug_buffers (GstBufferStore *store) +debug_buffers (GstBufferStore * store) { GList *walk = store->buffers; - + g_printerr ("BUFFERS in store:\n"); while (walk) { - g_print ("%15"G_GUINT64_FORMAT" - %7u\n", GST_BUFFER_OFFSET (walk->data), GST_BUFFER_SIZE (walk->data)); + g_print ("%15" G_GUINT64_FORMAT " - %7u\n", GST_BUFFER_OFFSET (walk->data), + GST_BUFFER_SIZE (walk->data)); walk = g_list_next (walk); } g_printerr ("\n"); } + static gboolean -continue_accu (GSignalInvocationHint *ihint, GValue *return_accu, - const GValue *handler_return, gpointer data) +continue_accu (GSignalInvocationHint * ihint, GValue * return_accu, + const GValue * handler_return, gpointer data) { gboolean do_continue = g_value_get_boolean (handler_return); + g_value_set_boolean (return_accu, do_continue); return do_continue; @@ -79,31 +85,31 @@ gst_buffer_store_base_init (gpointer g_class) { } static void -gst_buffer_store_class_init (GstBufferStoreClass *store_class) +gst_buffer_store_class_init (GstBufferStoreClass * store_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (store_class); gobject_class->dispose = gst_buffer_store_dispose; - - gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared", - G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL, - gst_marshal_VOID__VOID, G_TYPE_NONE, 0); - gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added", - G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL, - gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER); + + gst_buffer_store_signals[CLEARED] = g_signal_new ("cleared", + G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstBufferStoreClass, cleared), NULL, NULL, + gst_marshal_VOID__VOID, G_TYPE_NONE, 0); + gst_buffer_store_signals[BUFFER_ADDED] = g_signal_new ("buffer-added", + G_TYPE_FROM_CLASS (store_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstBufferStoreClass, buffer_added), continue_accu, NULL, + gst_marshal_BOOLEAN__POINTER, G_TYPE_BOOLEAN, 1, GST_TYPE_BUFFER); store_class->cleared = gst_buffer_store_cleared_func; store_class->buffer_added = gst_buffer_store_add_buffer_func; } static void -gst_buffer_store_init (GstBufferStore *store) +gst_buffer_store_init (GstBufferStore * store) { store->buffers = NULL; } static void -gst_buffer_store_dispose (GObject *object) +gst_buffer_store_dispose (GObject * object) { GstBufferStore *store = GST_BUFFER_STORE (object); @@ -111,22 +117,24 @@ gst_buffer_store_dispose (GObject *object) parent_class->dispose (object); } + static gboolean -gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) +gst_buffer_store_add_buffer_func (GstBufferStore * store, GstBuffer * buffer) { g_assert (buffer != NULL); - + if (!GST_BUFFER_OFFSET_IS_VALID (buffer) && - store->buffers && - GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { + store->buffers && GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { /* we assumed valid offsets, but suddenly they are not anymore */ - GST_DEBUG_OBJECT (store, "attempting to add buffer %p with invalid offset to store with valid offset, abort", - buffer); + GST_DEBUG_OBJECT (store, + "attempting to add buffer %p with invalid offset to store with valid offset, abort", + buffer); return FALSE; - } else if (!store->buffers || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { + } else if (!store->buffers + || !GST_BUFFER_OFFSET_IS_VALID (store->buffers->data)) { /* the starting buffer had an invalid offset, in that case we assume continuous buffers */ GST_LOG_OBJECT (store, "adding buffer %p with invalid offset and size %u", - buffer, GST_BUFFER_SIZE (buffer)); + buffer, GST_BUFFER_SIZE (buffer)); gst_data_ref (GST_DATA (buffer)); store->buffers = g_list_append (store->buffers, buffer); return TRUE; @@ -134,10 +142,12 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) /* both list and buffer have valid offsets, we can really go wild */ GList *walk, *current_list = NULL; GstBuffer *current; - + g_assert (GST_BUFFER_OFFSET_IS_VALID (buffer)); - GST_LOG_OBJECT (store, "attempting to add buffer %p with offset %"G_GUINT64_FORMAT" and size %u", - buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + GST_LOG_OBJECT (store, + "attempting to add buffer %p with offset %" G_GUINT64_FORMAT + " and size %u", buffer, GST_BUFFER_OFFSET (buffer), + GST_BUFFER_SIZE (buffer)); /* we keep a sorted list of non-overlapping buffers */ walk = store->buffers; while (walk) { @@ -148,9 +158,10 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) continue; } else if (GST_BUFFER_OFFSET (current) == GST_BUFFER_OFFSET (buffer)) { guint needed_size; + if (walk) { - needed_size = MIN (GST_BUFFER_SIZE (buffer), - GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current)); + needed_size = MIN (GST_BUFFER_SIZE (buffer), + GST_BUFFER_OFFSET (walk->data) - GST_BUFFER_OFFSET (current)); } else { needed_size = GST_BUFFER_SIZE (buffer); } @@ -161,14 +172,17 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) if (needed_size < GST_BUFFER_SIZE (buffer)) { /* need to create subbuffer to not have overlapping data */ GstBuffer *sub = gst_buffer_create_sub (buffer, 0, needed_size); + g_assert (sub); buffer = sub; } else { gst_data_ref (GST_DATA (buffer)); } /* replace current buffer with new one */ - GST_INFO_OBJECT (store, "replacing buffer %p with buffer %p with offset %"G_GINT64_FORMAT" and size %u", - current_list->data, buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + GST_INFO_OBJECT (store, + "replacing buffer %p with buffer %p with offset %" G_GINT64_FORMAT + " and size %u", current_list->data, buffer, + GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); gst_data_unref (GST_DATA (current_list->data)); current_list->data = buffer; buffer = NULL; @@ -176,8 +190,9 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } } else if (GST_BUFFER_OFFSET (current) > GST_BUFFER_OFFSET (buffer)) { GList *previous = g_list_previous (current_list); - guint64 start_offset = previous ? - GST_BUFFER_OFFSET (previous->data) + GST_BUFFER_SIZE (previous->data) : 0; + guint64 start_offset = previous ? + GST_BUFFER_OFFSET (previous->data) + + GST_BUFFER_SIZE (previous->data) : 0; if (start_offset == GST_BUFFER_OFFSET (current)) { buffer = NULL; @@ -185,23 +200,28 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } else { /* we have data to insert */ if (start_offset > GST_BUFFER_OFFSET (buffer) || - GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > GST_BUFFER_OFFSET (current)) { + GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) > + GST_BUFFER_OFFSET (current)) { GstBuffer *sub; /* need a subbuffer */ - start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 : - start_offset - GST_BUFFER_OFFSET (buffer); + start_offset = GST_BUFFER_OFFSET (buffer) > start_offset ? 0 : + start_offset - GST_BUFFER_OFFSET (buffer); sub = gst_buffer_create_sub (buffer, start_offset, - MIN (GST_BUFFER_SIZE (buffer), GST_BUFFER_OFFSET (current) - start_offset - GST_BUFFER_OFFSET (buffer))); + MIN (GST_BUFFER_SIZE (buffer), + GST_BUFFER_OFFSET (current) - start_offset - + GST_BUFFER_OFFSET (buffer))); g_assert (sub); GST_BUFFER_OFFSET (sub) = start_offset + GST_BUFFER_OFFSET (buffer); buffer = sub; } else { gst_data_ref (GST_DATA (buffer)); } - GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u", - buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); - store->buffers = g_list_insert_before (store->buffers, current_list, buffer); + GST_INFO_OBJECT (store, + "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", + buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + store->buffers = + g_list_insert_before (store->buffers, current_list, buffer); buffer = NULL; break; } @@ -209,8 +229,9 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } if (buffer) { gst_data_ref (GST_DATA (buffer)); - GST_INFO_OBJECT (store, "adding buffer %p with offset %"G_GINT64_FORMAT" and size %u", - buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); + GST_INFO_OBJECT (store, + "adding buffer %p with offset %" G_GINT64_FORMAT " and size %u", + buffer, GST_BUFFER_OFFSET (buffer), GST_BUFFER_SIZE (buffer)); if (current_list) { g_list_append (current_list, buffer); } else { @@ -222,12 +243,13 @@ gst_buffer_store_add_buffer_func (GstBufferStore *store, GstBuffer *buffer) } } static void -gst_buffer_store_cleared_func (GstBufferStore *store) +gst_buffer_store_cleared_func (GstBufferStore * store) { g_list_foreach (store->buffers, (GFunc) gst_data_unref, NULL); g_list_free (store->buffers); store->buffers = NULL; } + /** * gst_buffer_store_new: * @@ -240,6 +262,7 @@ gst_buffer_store_new (void) { return GST_BUFFER_STORE (g_object_new (GST_TYPE_BUFFER_STORE, NULL)); } + /** * gst_buffer_store_clear: * @store: a bufferstore @@ -249,12 +272,13 @@ gst_buffer_store_new (void) */ /* FIXME: call this function _reset ? */ void -gst_buffer_store_clear (GstBufferStore *store) +gst_buffer_store_clear (GstBufferStore * store) { g_return_if_fail (GST_IS_BUFFER_STORE (store)); - - g_signal_emit (store, gst_buffer_store_signals [CLEARED], 0, NULL); + + g_signal_emit (store, gst_buffer_store_signals[CLEARED], 0, NULL); } + /** * gst_buffer_store_add_buffer: * @store: a bufferstore @@ -265,10 +289,10 @@ gst_buffer_store_clear (GstBufferStore *store) * Returns: TRUE, if the buffer was added, FALSE if an error occured. */ gboolean -gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer) +gst_buffer_store_add_buffer (GstBufferStore * store, GstBuffer * buffer) { gboolean ret; - + g_return_val_if_fail (GST_IS_BUFFER_STORE (store), FALSE); g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); @@ -276,11 +300,13 @@ gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer) GST_BUFFER_OFFSET_IS_VALID (store->buffers->data) && !GST_BUFFER_OFFSET_IS_VALID (buffer)) return FALSE; - - g_signal_emit (store, gst_buffer_store_signals [BUFFER_ADDED], 0, buffer, &ret); - + + g_signal_emit (store, gst_buffer_store_signals[BUFFER_ADDED], 0, buffer, + &ret); + return ret; } + /** * gst_buffer_store_get_buffer: * @store: a bufferstore @@ -295,7 +321,7 @@ gst_buffer_store_add_buffer (GstBufferStore *store, GstBuffer *buffer) * available. */ GstBuffer * -gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size) +gst_buffer_store_get_buffer (GstBufferStore * store, guint64 offset, guint size) { GstBuffer *current; GList *walk; @@ -324,38 +350,39 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size) if (cur_offset > offset) { /* #include do_nothing_loop (); */ - } else if (cur_offset == offset && - GST_BUFFER_SIZE (current) == size) { - GST_LOG_OBJECT (store, "found matching buffer %p for offset %"G_GUINT64_FORMAT" and size %u", - current, offset, size); + } else if (cur_offset == offset && GST_BUFFER_SIZE (current) == size) { + GST_LOG_OBJECT (store, + "found matching buffer %p for offset %" G_GUINT64_FORMAT + " and size %u", current, offset, size); ret = current; gst_data_ref (GST_DATA (ret)); - GST_LOG_OBJECT (store, "refcount %d", - GST_DATA_REFCOUNT_VALUE(ret)); + GST_LOG_OBJECT (store, "refcount %d", GST_DATA_REFCOUNT_VALUE (ret)); break; } else if (cur_offset + GST_BUFFER_SIZE (current) > offset) { if (cur_offset + GST_BUFFER_SIZE (current) >= offset + size) { ret = gst_buffer_create_sub (current, offset - cur_offset, size); - GST_LOG_OBJECT (store, "created subbuffer %p from buffer %p for offset %llu and size %u", - ret, current, offset, size); + GST_LOG_OBJECT (store, + "created subbuffer %p from buffer %p for offset %llu and size %u", + ret, current, offset, size); break; } /* uh, the requested data spans some buffers */ ret = gst_buffer_new_and_alloc (size); - GST_LOG_OBJECT (store, "created buffer %p for offset %"G_GUINT64_FORMAT - " and size %u, will fill with data now", - ret, offset, size); + GST_LOG_OBJECT (store, "created buffer %p for offset %" G_GUINT64_FORMAT + " and size %u, will fill with data now", ret, offset, size); data = GST_BUFFER_DATA (ret); tmp = GST_BUFFER_SIZE (current) - offset + cur_offset; memcpy (data, GST_BUFFER_DATA (current) + offset - cur_offset, tmp); data += tmp; size -= tmp; while (size) { - if (walk == NULL || - (have_offset && - GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data))) { - GST_DEBUG_OBJECT (store, "not all data for offset %"G_GUINT64_FORMAT" and remaining size %u available, aborting", - offset, size); + if (walk == NULL || + (have_offset && + GST_BUFFER_OFFSET (current) + GST_BUFFER_SIZE (current) != + GST_BUFFER_OFFSET (walk->data))) { + GST_DEBUG_OBJECT (store, + "not all data for offset %" G_GUINT64_FORMAT + " and remaining size %u available, aborting", offset, size); gst_data_unref (GST_DATA (ret)); ret = NULL; goto out; @@ -373,9 +400,10 @@ gst_buffer_store_get_buffer (GstBufferStore *store, guint64 offset, guint size) } } out: - + return ret; } + /** * gst_buffer_store_get_size: * @store: a bufferstore @@ -388,7 +416,7 @@ out: * offset. */ guint -gst_buffer_store_get_size (GstBufferStore *store, guint64 offset) +gst_buffer_store_get_size (GstBufferStore * store, guint64 offset) { GList *walk; gboolean have_offset; @@ -408,8 +436,9 @@ gst_buffer_store_get_size (GstBufferStore *store, guint64 offset) have_offset = FALSE; } while (walk) { - if (have_offset && counting && - cur_offset + GST_BUFFER_SIZE (current) != GST_BUFFER_OFFSET (walk->data)) { + if (have_offset && counting && + cur_offset + GST_BUFFER_SIZE (current) != + GST_BUFFER_OFFSET (walk->data)) { break; } current = GST_BUFFER (walk->data); @@ -432,6 +461,6 @@ gst_buffer_store_get_size (GstBufferStore *store, guint64 offset) cur_offset += GST_BUFFER_SIZE (current); } } - + return ret; } diff --git a/plugins/elements/gstbufferstore.h b/plugins/elements/gstbufferstore.h index 15fff8e6a..09dc4c59f 100644 --- a/plugins/elements/gstbufferstore.h +++ b/plugins/elements/gstbufferstore.h @@ -28,46 +28,42 @@ #include G_BEGIN_DECLS - #define GST_TYPE_BUFFER_STORE (gst_buffer_store_get_type ()) #define GST_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_STORE, GstBufferStore)) #define GST_IS_BUFFER_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_STORE)) #define GST_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_STORE, GstBufferStoreClass)) #define GST_IS_BUFFER_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_STORE)) #define GST_BUFFER_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_STORE, GstBufferStoreClass)) +typedef struct _GstBufferStore GstBufferStore; +typedef struct _GstBufferStoreClass GstBufferStoreClass; -typedef struct _GstBufferStore GstBufferStore; -typedef struct _GstBufferStoreClass GstBufferStoreClass; - -struct _GstBufferStore { - GObject object; +struct _GstBufferStore +{ + GObject object; - GList * buffers; + GList *buffers; }; -struct _GstBufferStoreClass { - GObjectClass parent_class; +struct _GstBufferStoreClass +{ + GObjectClass parent_class; /* signals */ - void (* cleared) (GstBufferStore * store); - gboolean (* buffer_added) (GstBufferStore * store, - GstBuffer * buffer); + void (*cleared) (GstBufferStore * store); + gboolean (*buffer_added) (GstBufferStore * store, GstBuffer * buffer); }; -GType gst_buffer_store_get_type (void); +GType gst_buffer_store_get_type (void); -GstBufferStore * gst_buffer_store_new (void); -void gst_buffer_store_clear (GstBufferStore * store); +GstBufferStore *gst_buffer_store_new (void); +void gst_buffer_store_clear (GstBufferStore * store); -gboolean gst_buffer_store_add_buffer (GstBufferStore * store, - GstBuffer * buffer); +gboolean gst_buffer_store_add_buffer (GstBufferStore * store, + GstBuffer * buffer); -GstBuffer * gst_buffer_store_get_buffer (GstBufferStore * store, - guint64 offset, - guint size); -guint gst_buffer_store_get_size (GstBufferStore * store, - guint64 offset); +GstBuffer *gst_buffer_store_get_buffer (GstBufferStore * store, + guint64 offset, guint size); +guint gst_buffer_store_get_size (GstBufferStore * store, guint64 offset); G_END_DECLS - #endif /* __GST_BUFFER_STORE_H__ */ diff --git a/plugins/elements/gstelements.c b/plugins/elements/gstelements.c index 42e068589..12e19d4c7 100644 --- a/plugins/elements/gstelements.c +++ b/plugins/elements/gstelements.c @@ -44,42 +44,44 @@ #include "gsttypefind.h" -struct _elements_entry { +struct _elements_entry +{ gchar *name; guint rank; - GType (*type) (void); + GType (*type) (void); }; -extern GType gst_filesrc_get_type(void); +extern GType gst_filesrc_get_type (void); extern GstElementDetails gst_filesrc_details; static struct _elements_entry _elements[] = { - { "aggregator", GST_RANK_NONE, gst_aggregator_get_type }, - { "fakesrc", GST_RANK_NONE, gst_fakesrc_get_type }, - { "fakesink", GST_RANK_NONE, gst_fakesink_get_type }, - { "fdsink", GST_RANK_NONE, gst_fdsink_get_type }, - { "fdsrc", GST_RANK_NONE, gst_fdsrc_get_type }, - { "filesrc", GST_RANK_NONE, gst_filesrc_get_type }, - { "filesink", GST_RANK_NONE, gst_filesink_get_type }, - { "identity", GST_RANK_NONE, gst_identity_get_type }, - { "md5sink", GST_RANK_NONE, gst_md5sink_get_type }, - { "multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type }, - { "pipefilter", GST_RANK_NONE, gst_pipefilter_get_type }, - { "shaper", GST_RANK_NONE, gst_shaper_get_type }, - { "statistics", GST_RANK_NONE, gst_statistics_get_type }, - { "tee", GST_RANK_NONE, gst_tee_get_type }, - { "typefind", GST_RANK_NONE, gst_type_find_element_get_type }, - { NULL, 0 }, + {"aggregator", GST_RANK_NONE, gst_aggregator_get_type}, + {"fakesrc", GST_RANK_NONE, gst_fakesrc_get_type}, + {"fakesink", GST_RANK_NONE, gst_fakesink_get_type}, + {"fdsink", GST_RANK_NONE, gst_fdsink_get_type}, + {"fdsrc", GST_RANK_NONE, gst_fdsrc_get_type}, + {"filesrc", GST_RANK_NONE, gst_filesrc_get_type}, + {"filesink", GST_RANK_NONE, gst_filesink_get_type}, + {"identity", GST_RANK_NONE, gst_identity_get_type}, + {"md5sink", GST_RANK_NONE, gst_md5sink_get_type}, + {"multifilesrc", GST_RANK_NONE, gst_multifilesrc_get_type}, + {"pipefilter", GST_RANK_NONE, gst_pipefilter_get_type}, + {"shaper", GST_RANK_NONE, gst_shaper_get_type}, + {"statistics", GST_RANK_NONE, gst_statistics_get_type}, + {"tee", GST_RANK_NONE, gst_tee_get_type}, + {"typefind", GST_RANK_NONE, gst_type_find_element_get_type}, + {NULL, 0}, }; static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { struct _elements_entry *my_elements = _elements; - - while ((*my_elements).name) { - if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, ((*my_elements).type) ())) + + while ((*my_elements).name) { + if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, + ((*my_elements).type) ())) return FALSE; my_elements++; } @@ -87,15 +89,8 @@ plugin_init (GstPlugin *plugin) return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstelements", - "standard GStreamer elements", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstelements", + "standard GStreamer elements", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index 4541f6274..78ecac6cf 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -31,22 +31,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_fakesink_debug); #define GST_CAT_DEFAULT gst_fakesink_debug -GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS ( - "Fake Sink", - "Sink", - "Black hole for data", - "Erik Walthinsen " -); +GstElementDetails gst_fakesink_details = GST_ELEMENT_DETAILS ("Fake Sink", + "Sink", + "Black hole for data", + "Erik Walthinsen "); /* FakeSink signals and args */ -enum { +enum +{ /* FILL ME */ SIGNAL_HANDOFF, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_STATE_ERROR, ARG_NUM_SINKS, @@ -57,12 +57,10 @@ enum { ARG_LAST_MESSAGE, }; -GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate fakesink_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_FAKESINK_STATE_ERROR (gst_fakesink_state_error_get_type()) static GType @@ -70,17 +68,24 @@ gst_fakesink_state_error_get_type (void) { static GType fakesink_state_error_type = 0; static GEnumValue fakesink_state_error[] = { - { FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"}, - { FAKESINK_STATE_ERROR_NULL_READY, "1", "Fail state change from NULL to READY"}, - { FAKESINK_STATE_ERROR_READY_PAUSED, "2", "Fail state change from READY to PAUSED"}, - { FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", "Fail state change from PAUSED to PLAYING"}, - { FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", "Fail state change from PLAYING to PAUSED"}, - { FAKESINK_STATE_ERROR_PAUSED_READY , "5", "Fail state change from PAUSED to READY"}, - { FAKESINK_STATE_ERROR_READY_NULL , "6", "Fail state change from READY to NULL"}, + {FAKESINK_STATE_ERROR_NONE, "0", "No state change errors"}, + {FAKESINK_STATE_ERROR_NULL_READY, "1", + "Fail state change from NULL to READY"}, + {FAKESINK_STATE_ERROR_READY_PAUSED, "2", + "Fail state change from READY to PAUSED"}, + {FAKESINK_STATE_ERROR_PAUSED_PLAYING, "3", + "Fail state change from PAUSED to PLAYING"}, + {FAKESINK_STATE_ERROR_PLAYING_PAUSED, "4", + "Fail state change from PLAYING to PAUSED"}, + {FAKESINK_STATE_ERROR_PAUSED_READY, "5", + "Fail state change from PAUSED to READY"}, + {FAKESINK_STATE_ERROR_READY_NULL, "6", + "Fail state change from READY to NULL"}, {0, NULL, NULL}, }; if (!fakesink_state_error_type) { - fakesink_state_error_type = g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error); + fakesink_state_error_type = + g_enum_register_static ("GstFakeSinkStateError", fakesink_state_error); } return fakesink_state_error_type; } @@ -88,82 +93,86 @@ gst_fakesink_state_error_get_type (void) #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fakesink_debug, "fakesink", 0, "fakesink element"); -GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFakeSink, gst_fakesink, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_fakesink_set_clock (GstElement *element, GstClock *clock); -static GstPad* gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const - gchar *unused); +static void gst_fakesink_set_clock (GstElement * element, GstClock * clock); +static GstPad *gst_fakesink_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * unused); -static void gst_fakesink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fakesink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_fakesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fakesink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstElementStateReturn - gst_fakesink_change_state (GstElement *element); +static GstElementStateReturn gst_fakesink_change_state (GstElement * element); -static void gst_fakesink_chain (GstPad *pad, GstData *_data); +static void gst_fakesink_chain (GstPad * pad, GstData * _data); static guint gst_fakesink_signals[LAST_SIGNAL] = { 0 }; static void gst_fakesink_base_init (gpointer g_class) { - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + gst_element_class_set_details (gstelement_class, &gst_fakesink_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&fakesink_sink_template)); } static void -gst_fakesink_class_init (GstFakeSinkClass *klass) +gst_fakesink_class_init (GstFakeSinkClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SINKS, - g_param_spec_int ("num_sinks", "Number of sinks", "The number of sinkpads", - 1, G_MAXINT, 1, G_PARAM_READABLE)); + g_param_spec_int ("num_sinks", "Number of sinks", + "The number of sinkpads", 1, G_MAXINT, 1, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_STATE_ERROR, - g_param_spec_enum ("state_error", "State Error", "Generate a state change error", - GST_TYPE_FAKESINK_STATE_ERROR, FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE)); + g_param_spec_enum ("state_error", "State Error", + "Generate a state change error", GST_TYPE_FAKESINK_STATE_ERROR, + FAKESINK_STATE_ERROR_NONE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last_message", "Last Message", "The message describing current status", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last_message", "Last Message", + "The message describing current status", NULL, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC, - g_param_spec_boolean ("sync", "Sync", "Sync on the clock", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("sync", "Sync", "Sync on the clock", FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, - g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before unreffing the buffer", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("signal-handoffs", "Signal handoffs", + "Send a signal before unreffing the buffer", FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "Silent", + "Don't produce last_message events", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, - g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("dump", "Dump", "Dump received bytes to stdout", + FALSE, G_PARAM_READWRITE)); gst_fakesink_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, - gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, - GST_TYPE_BUFFER, GST_TYPE_PAD); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, + gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, + GST_TYPE_BUFFER, GST_TYPE_PAD); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesink_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesink_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad); - gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesink_change_state); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_fakesink_request_new_pad); + gstelement_class->set_clock = GST_DEBUG_FUNCPTR (gst_fakesink_set_clock); + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_fakesink_change_state); } -static void -gst_fakesink_init (GstFakeSink *fakesink) +static void +gst_fakesink_init (GstFakeSink * fakesink) { GstPad *pad; @@ -182,17 +191,18 @@ gst_fakesink_init (GstFakeSink *fakesink) } static void -gst_fakesink_set_clock (GstElement *element, GstClock *clock) -{ +gst_fakesink_set_clock (GstElement * element, GstClock * clock) +{ GstFakeSink *sink; sink = GST_FAKESINK (element); sink->clock = clock; -} +} -static GstPad* -gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_fakesink_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *sinkpad; @@ -212,14 +222,15 @@ gst_fakesink_request_new_pad (GstElement *element, GstPadTemplate *templ, const sinkpad = gst_pad_new_from_template (templ, name); g_free (name); gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_fakesink_chain)); - + gst_element_add_pad (GST_ELEMENT (fakesink), sinkpad); return sinkpad; } static void -gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_fakesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstFakeSink *sink; @@ -247,16 +258,17 @@ gst_fakesink_set_property (GObject *object, guint prop_id, const GValue *value, } } -static void -gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fakesink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFakeSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FAKESINK (object)); - + sink = GST_FAKESINK (object); - + switch (prop_id) { case ARG_NUM_SINKS: g_value_set_int (value, GST_ELEMENT (sink)->numsinkpads); @@ -285,8 +297,8 @@ gst_fakesink_get_property (GObject *object, guint prop_id, GValue *value, GParam } } -static void -gst_fakesink_chain (GstPad *pad, GstData *_data) +static void +gst_fakesink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstFakeSink *fakesink; @@ -299,51 +311,52 @@ gst_fakesink_chain (GstPad *pad, GstData *_data) if (GST_IS_EVENT (buf)) { GstEvent *event = GST_EVENT (buf); - - if (!fakesink->silent) { + + if (!fakesink->silent) { g_free (fakesink->last_message); - fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p", - GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event); - + fakesink->last_message = + g_strdup_printf ("chain ******* (%s:%s)E (type: %d) %p", + GST_DEBUG_PAD_NAME (pad), GST_EVENT_TYPE (event), event); + g_object_notify (G_OBJECT (fakesink), "last_message"); } - + switch (GST_EVENT_TYPE (event)) { case GST_EVENT_DISCONTINUOUS: - if (fakesink->sync && fakesink->clock) { - gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value; - gst_element_set_time (GST_ELEMENT (fakesink), value); + if (fakesink->sync && fakesink->clock) { + gint64 value = GST_EVENT_DISCONT_OFFSET (event, 0).value; + + gst_element_set_time (GST_ELEMENT (fakesink), value); } default: gst_pad_event_default (pad, event); - break; + break; } return; } - if (fakesink->sync && fakesink->clock) { + if (fakesink->sync && fakesink->clock) { gst_element_wait (GST_ELEMENT (fakesink), GST_BUFFER_TIMESTAMP (buf)); } - if (!fakesink->silent) { + if (!fakesink->silent) { g_free (fakesink->last_message); - fakesink->last_message = g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %" - G_GINT64_FORMAT ", duration: %" - G_GINT64_FORMAT ", offset: %" - G_GINT64_FORMAT ", flags: %d) %p", - GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), - GST_BUFFER_TIMESTAMP (buf), - GST_BUFFER_DURATION (buf), - GST_BUFFER_OFFSET (buf), - GST_BUFFER_FLAGS (buf), buf); - + fakesink->last_message = + g_strdup_printf ("chain ******* (%s:%s)< (%d bytes, timestamp: %" + G_GINT64_FORMAT ", duration: %" G_GINT64_FORMAT ", offset: %" + G_GINT64_FORMAT ", flags: %d) %p", GST_DEBUG_PAD_NAME (pad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), + GST_BUFFER_DURATION (buf), GST_BUFFER_OFFSET (buf), + GST_BUFFER_FLAGS (buf), buf); + g_object_notify (G_OBJECT (fakesink), "last_message"); } if (fakesink->signal_handoffs) - g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, buf, pad); + g_signal_emit (G_OBJECT (fakesink), gst_fakesink_signals[SIGNAL_HANDOFF], 0, + buf, pad); if (fakesink->dump) { gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); @@ -353,7 +366,7 @@ gst_fakesink_chain (GstPad *pad, GstData *_data) } static GstElementStateReturn -gst_fakesink_change_state (GstElement *element) +gst_fakesink_change_state (GstElement * element) { GstFakeSink *fakesink = GST_FAKESINK (element); @@ -395,4 +408,3 @@ error: GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), (NULL)); return GST_STATE_FAILURE; } - diff --git a/plugins/elements/gstfakesink.h b/plugins/elements/gstfakesink.h index a8e7cd067..2c0e2812d 100644 --- a/plugins/elements/gstfakesink.h +++ b/plugins/elements/gstfakesink.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FAKESINK \ (gst_fakesink_get_type()) #define GST_FAKESINK(obj) \ @@ -39,8 +37,8 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FAKESINK)) #define GST_IS_FAKESINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FAKESINK)) - -typedef enum { + typedef enum +{ FAKESINK_STATE_ERROR_NONE = 0, FAKESINK_STATE_ERROR_NULL_READY, FAKESINK_STATE_ERROR_READY_PAUSED, @@ -53,30 +51,31 @@ typedef enum { typedef struct _GstFakeSink GstFakeSink; typedef struct _GstFakeSinkClass GstFakeSinkClass; -struct _GstFakeSink { - GstElement element; +struct _GstFakeSink +{ + GstElement element; - gboolean silent; - gboolean dump; - gboolean sync; - gboolean signal_handoffs; - GstClock *clock; + gboolean silent; + gboolean dump; + gboolean sync; + gboolean signal_handoffs; + GstClock *clock; GstFakeSinkStateError state_error; - gchar *last_message; + gchar *last_message; }; -struct _GstFakeSinkClass { +struct _GstFakeSinkClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); + void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad); }; -GType gst_fakesink_get_type(void); +GType gst_fakesink_get_type (void); -gboolean gst_fakesink_factory_init (GstElementFactory *factory); +gboolean gst_fakesink_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_FAKESINK_H__ */ diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index 1fb082a54..2443b8132 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -38,23 +38,23 @@ GST_DEBUG_CATEGORY_STATIC (gst_fakesrc_debug); #define GST_CAT_DEFAULT gst_fakesrc_debug -GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS ( - "Fake Source", - "Source", - "Push empty (no data) buffers around", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_fakesrc_details = GST_ELEMENT_DETAILS ("Fake Source", + "Source", + "Push empty (no data) buffers around", + "Erik Walthinsen , " + "Wim Taymans "); /* FakeSrc signals and args */ -enum { +enum +{ /* FILL ME */ SIGNAL_HANDOFF, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_NUM_SOURCES, ARG_LOOP_BASED, @@ -74,43 +74,42 @@ enum { ARG_LAST_MESSAGE, }; -GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE ( - "src%d", - GST_PAD_SRC, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate fakesrc_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_FAKESRC_OUTPUT (gst_fakesrc_output_get_type()) static GType -gst_fakesrc_output_get_type (void) +gst_fakesrc_output_get_type (void) { static GType fakesrc_output_type = 0; static GEnumValue fakesrc_output[] = { - { FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"}, - { FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"}, - { FAKESRC_PING_PONG, "3", "Ping-Pong"}, - { FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"}, - { FAKESRC_RANDOM, "5", "Random"}, - { FAKESRC_PATTERN_LOOP, "6", "Patttern loop"}, - { FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"}, - { FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"}, + {FAKESRC_FIRST_LAST_LOOP, "1", "First-Last loop"}, + {FAKESRC_LAST_FIRST_LOOP, "2", "Last-First loop"}, + {FAKESRC_PING_PONG, "3", "Ping-Pong"}, + {FAKESRC_ORDERED_RANDOM, "4", "Ordered Random"}, + {FAKESRC_RANDOM, "5", "Random"}, + {FAKESRC_PATTERN_LOOP, "6", "Patttern loop"}, + {FAKESRC_PING_PONG_PATTERN, "7", "Ping-Pong Pattern"}, + {FAKESRC_GET_ALWAYS_SUCEEDS, "8", "'_get' Always succeeds"}, {0, NULL, NULL}, }; if (!fakesrc_output_type) { - fakesrc_output_type = g_enum_register_static ("GstFakeSrcOutput", fakesrc_output); + fakesrc_output_type = + g_enum_register_static ("GstFakeSrcOutput", fakesrc_output); } return fakesrc_output_type; } #define GST_TYPE_FAKESRC_DATA (gst_fakesrc_data_get_type()) static GType -gst_fakesrc_data_get_type (void) +gst_fakesrc_data_get_type (void) { static GType fakesrc_data_type = 0; static GEnumValue fakesrc_data[] = { - { FAKESRC_DATA_ALLOCATE, "1", "Allocate data"}, - { FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"}, + {FAKESRC_DATA_ALLOCATE, "1", "Allocate data"}, + {FAKESRC_DATA_SUBBUFFER, "2", "Subbuffer data"}, {0, NULL, NULL}, }; if (!fakesrc_data_type) { @@ -121,36 +120,40 @@ gst_fakesrc_data_get_type (void) #define GST_TYPE_FAKESRC_SIZETYPE (gst_fakesrc_sizetype_get_type()) static GType -gst_fakesrc_sizetype_get_type (void) +gst_fakesrc_sizetype_get_type (void) { static GType fakesrc_sizetype_type = 0; static GEnumValue fakesrc_sizetype[] = { - { FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"}, - { FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"}, - { FAKESRC_SIZETYPE_RANDOM, "3", "Random sized buffers (sizemin <= size <= sizemax)"}, + {FAKESRC_SIZETYPE_NULL, "1", "Send empty buffers"}, + {FAKESRC_SIZETYPE_FIXED, "2", "Fixed size buffers (sizemax sized)"}, + {FAKESRC_SIZETYPE_RANDOM, "3", + "Random sized buffers (sizemin <= size <= sizemax)"}, {0, NULL, NULL}, }; if (!fakesrc_sizetype_type) { - fakesrc_sizetype_type = g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype); + fakesrc_sizetype_type = + g_enum_register_static ("GstFakeSrcSizeType", fakesrc_sizetype); } return fakesrc_sizetype_type; } #define GST_TYPE_FAKESRC_FILLTYPE (gst_fakesrc_filltype_get_type()) static GType -gst_fakesrc_filltype_get_type (void) +gst_fakesrc_filltype_get_type (void) { static GType fakesrc_filltype_type = 0; static GEnumValue fakesrc_filltype[] = { - { FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"}, - { FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"}, - { FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"}, - { FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"}, - { FAKESRC_FILLTYPE_PATTERN_CONT, "5", "Fill buffers with pattern 0x00 -> 0xff that spans buffers"}, + {FAKESRC_FILLTYPE_NOTHING, "1", "Leave data as malloced"}, + {FAKESRC_FILLTYPE_NULL, "2", "Fill buffers with zeros"}, + {FAKESRC_FILLTYPE_RANDOM, "3", "Fill buffers with random crap"}, + {FAKESRC_FILLTYPE_PATTERN, "4", "Fill buffers with pattern 0x00 -> 0xff"}, + {FAKESRC_FILLTYPE_PATTERN_CONT, "5", + "Fill buffers with pattern 0x00 -> 0xff that spans buffers"}, {0, NULL, NULL}, }; if (!fakesrc_filltype_type) { - fakesrc_filltype_type = g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype); + fakesrc_filltype_type = + g_enum_register_static ("GstFakeSrcFillType", fakesrc_filltype); } return fakesrc_filltype_type; } @@ -158,106 +161,113 @@ gst_fakesrc_filltype_get_type (void) #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fakesrc_debug, "fakesrc", 0, "fakesrc element"); -GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFakeSrc, gst_fakesrc, GstElement, GST_TYPE_ELEMENT, + _do_init); -static GstPad* gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ,const gchar *unused); -static void gst_fakesrc_update_functions (GstFakeSrc *src); -static void gst_fakesrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fakesrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static GstPad *gst_fakesrc_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * unused); +static void gst_fakesrc_update_functions (GstFakeSrc * src); +static void gst_fakesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fakesrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstElementStateReturn gst_fakesrc_change_state (GstElement *element); +static GstElementStateReturn gst_fakesrc_change_state (GstElement * element); -static GstData* gst_fakesrc_get (GstPad *pad); -static void gst_fakesrc_loop (GstElement *element); +static GstData *gst_fakesrc_get (GstPad * pad); +static void gst_fakesrc_loop (GstElement * element); static guint gst_fakesrc_signals[LAST_SIGNAL] = { 0 }; static void gst_fakesrc_base_init (gpointer g_class) { - GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); + gst_element_class_set_details (gstelement_class, &gst_fakesrc_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&fakesrc_src_template)); } static void -gst_fakesrc_class_init (GstFakeSrcClass *klass) +gst_fakesrc_class_init (GstFakeSrcClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_SOURCES, - g_param_spec_int ("num-sources", "num-sources", "Number of sources", - 1, G_MAXINT, 1, G_PARAM_READABLE)); + g_param_spec_int ("num-sources", "num-sources", "Number of sources", + 1, G_MAXINT, 1, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, - g_param_spec_boolean ("loop-based", "loop-based", "Enable loop-based operation", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("loop-based", "loop-based", + "Enable loop-based operation", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_OUTPUT, - g_param_spec_enum ("output", "output", "Output method (currently unused)", - GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE)); + g_param_spec_enum ("output", "output", "Output method (currently unused)", + GST_TYPE_FAKESRC_OUTPUT, FAKESRC_FIRST_LAST_LOOP, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DATA, - g_param_spec_enum ("data", "data", "Data allocation method", - GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE)); + g_param_spec_enum ("data", "data", "Data allocation method", + GST_TYPE_FAKESRC_DATA, FAKESRC_DATA_ALLOCATE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZETYPE, - g_param_spec_enum ("sizetype", "sizetype", "How to determine buffer sizes", - GST_TYPE_FAKESRC_SIZETYPE, FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); + g_param_spec_enum ("sizetype", "sizetype", + "How to determine buffer sizes", GST_TYPE_FAKESRC_SIZETYPE, + FAKESRC_SIZETYPE_NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, - g_param_spec_int ("sizemin","sizemin","Minimum buffer size", - 0, G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE)); + g_param_spec_int ("sizemin", "sizemin", "Minimum buffer size", 0, + G_MAXINT, DEFAULT_SIZEMIN, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, - g_param_spec_int ("sizemax","sizemax","Maximum buffer size", - 0, G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE)); + g_param_spec_int ("sizemax", "sizemax", "Maximum buffer size", 0, + G_MAXINT, DEFAULT_SIZEMAX, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PARENTSIZE, - g_param_spec_int ("parentsize","parentsize","Size of parent buffer for sub-buffered allocation", - 0, G_MAXINT, DEFAULT_PARENTSIZE, G_PARAM_READWRITE)); + g_param_spec_int ("parentsize", "parentsize", + "Size of parent buffer for sub-buffered allocation", 0, G_MAXINT, + DEFAULT_PARENTSIZE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILLTYPE, - g_param_spec_enum ("filltype", "filltype", "How to fill the buffer, if at all", - GST_TYPE_FAKESRC_FILLTYPE, FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); + g_param_spec_enum ("filltype", "filltype", + "How to fill the buffer, if at all", GST_TYPE_FAKESRC_FILLTYPE, + FAKESRC_FILLTYPE_NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PATTERN, - g_param_spec_string ("pattern", "pattern", "pattern", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("pattern", "pattern", "pattern", NULL, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_BUFFERS, - g_param_spec_int ("num-buffers", "num-buffers", "Number of buffers to output before sending EOS", - G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); + g_param_spec_int ("num-buffers", "num-buffers", + "Number of buffers to output before sending EOS", G_MININT, G_MAXINT, + 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EOS, - g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("eos", "eos", "Send out the EOS event?", TRUE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last-message", "last-message", "The last status message", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last-message", "last-message", + "The last status message", NULL, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "Silent", "Don't produce last_message events", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "Silent", + "Don't produce last_message events", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIGNAL_HANDOFFS, - g_param_spec_boolean ("signal-handoffs", "Signal handoffs", "Send a signal before pushing the buffer", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("signal-handoffs", "Signal handoffs", + "Send a signal before pushing the buffer", FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, - g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("dump", "Dump", "Dump produced bytes to stdout", + FALSE, G_PARAM_READWRITE)); gst_fakesrc_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL, - gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, - GST_TYPE_BUFFER, GST_TYPE_PAD); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFakeSrcClass, handoff), NULL, NULL, + gst_marshal_VOID__POINTER_OBJECT, G_TYPE_NONE, 2, + GST_TYPE_BUFFER, GST_TYPE_PAD); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fakesrc_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fakesrc_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_fakesrc_request_new_pad); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_fakesrc_change_state); } -static void -gst_fakesrc_init (GstFakeSrc *fakesrc) +static void +gst_fakesrc_init (GstFakeSrc * fakesrc) { GstPad *pad; @@ -289,8 +299,9 @@ gst_fakesrc_init (GstFakeSrc *fakesrc) fakesrc->last_message = NULL; } -static GstPad* -gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_fakesrc_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *srcpad; @@ -317,7 +328,7 @@ gst_fakesrc_request_new_pad (GstElement *element, GstPadTemplate *templ, const g } static const GstFormat * -gst_fakesrc_get_formats (GstPad *pad) +gst_fakesrc_get_formats (GstPad * pad) { static const GstFormat formats[] = { GST_FORMAT_DEFAULT, @@ -327,7 +338,7 @@ gst_fakesrc_get_formats (GstPad *pad) } static const GstQueryType * -gst_fakesrc_get_query_types (GstPad *pad) +gst_fakesrc_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -340,8 +351,8 @@ gst_fakesrc_get_query_types (GstPad *pad) } static gboolean -gst_fakesrc_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_fakesrc_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFakeSrc *src = GST_FAKESRC (GST_PAD_PARENT (pad)); @@ -360,24 +371,24 @@ gst_fakesrc_query (GstPad *pad, GstQueryType type, break; default: return FALSE; - } + } return TRUE; } static const GstEventMask * -gst_fakesrc_get_event_mask (GstPad *pad) +gst_fakesrc_get_event_mask (GstPad * pad) { static const GstEventMask masks[] = { - { GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH }, - { GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP }, - { GST_EVENT_FLUSH, 0 }, - { 0, 0 }, + {GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH}, + {GST_EVENT_SEEK_SEGMENT, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP}, + {GST_EVENT_FLUSH, 0}, + {0, 0}, }; return masks; } static gboolean -gst_fakesrc_event_handler (GstPad *pad, GstEvent *event) +gst_fakesrc_event_handler (GstPad * pad, GstEvent * event) { GstFakeSrc *src; @@ -388,14 +399,15 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event) src->buffer_count = GST_EVENT_SEEK_OFFSET (event); if (!GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { - break; + break; } /* else we do a flush too */ case GST_EVENT_SEEK_SEGMENT: src->segment_start = GST_EVENT_SEEK_OFFSET (event); src->segment_end = GST_EVENT_SEEK_ENDOFFSET (event); src->buffer_count = src->segment_start; - src->segment_loop = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP; + src->segment_loop = + GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_SEGMENT_LOOP; break; case GST_EVENT_FLUSH: src->need_flush = TRUE; @@ -409,14 +421,14 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event) } static void -gst_fakesrc_update_functions (GstFakeSrc *src) +gst_fakesrc_update_functions (GstFakeSrc * src) { GList *pads; if (src->loop_based) { - gst_element_set_loop_function (GST_ELEMENT (src), GST_DEBUG_FUNCPTR (gst_fakesrc_loop)); - } - else { + gst_element_set_loop_function (GST_ELEMENT (src), + GST_DEBUG_FUNCPTR (gst_fakesrc_loop)); + } else { gst_element_set_loop_function (GST_ELEMENT (src), NULL); } @@ -426,8 +438,7 @@ gst_fakesrc_update_functions (GstFakeSrc *src) if (src->loop_based) { gst_pad_set_get_function (pad, NULL); - } - else { + } else { gst_pad_set_get_function (pad, GST_DEBUG_FUNCPTR (gst_fakesrc_get)); } @@ -441,7 +452,7 @@ gst_fakesrc_update_functions (GstFakeSrc *src) } static void -gst_fakesrc_alloc_parent (GstFakeSrc *src) +gst_fakesrc_alloc_parent (GstFakeSrc * src) { GstBuffer *buf; @@ -454,13 +465,14 @@ gst_fakesrc_alloc_parent (GstFakeSrc *src) } static void -gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_fakesrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFakeSrc *src; /* it's not null if we got it, but it might not be ours */ src = GST_FAKESRC (object); - + switch (prop_id) { case ARG_LOOP_BASED: src->loop_based = g_value_get_boolean (value); @@ -473,13 +485,13 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G src->data = g_value_get_enum (value); if (src->data == FAKESRC_DATA_SUBBUFFER) { - if (!src->parent) - gst_fakesrc_alloc_parent (src); + if (!src->parent) + gst_fakesrc_alloc_parent (src); } else { - if (src->parent) { - gst_buffer_unref (src->parent); - src->parent = NULL; - } + if (src->parent) { + gst_buffer_unref (src->parent); + src->parent = NULL; + } } break; case ARG_SIZETYPE: @@ -504,7 +516,7 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G break; case ARG_EOS: src->eos = g_value_get_boolean (value); - GST_INFO ( "will EOS on next buffer"); + GST_INFO ("will EOS on next buffer"); break; case ARG_SILENT: src->silent = g_value_get_boolean (value); @@ -520,16 +532,17 @@ gst_fakesrc_set_property (GObject *object, guint prop_id, const GValue *value, G } } -static void -gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fakesrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFakeSrc *src; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FAKESRC (object)); - + src = GST_FAKESRC (object); - + switch (prop_id) { case ARG_NUM_SOURCES: g_value_set_int (value, GST_ELEMENT (src)->numsrcpads); @@ -586,9 +599,9 @@ gst_fakesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS } static void -gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf) +gst_fakesrc_prepare_buffer (GstFakeSrc * src, GstBuffer * buf) { - if (GST_BUFFER_SIZE (buf) == 0) + if (GST_BUFFER_SIZE (buf) == 0) return; switch (src->filltype) { @@ -601,7 +614,7 @@ gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf) guint8 *ptr = GST_BUFFER_DATA (buf); for (i = GST_BUFFER_SIZE (buf); i; i--) { - *ptr++ = (gint8)((255.0)*rand()/(RAND_MAX)); + *ptr++ = (gint8) ((255.0) * rand () / (RAND_MAX)); } break; } @@ -623,29 +636,29 @@ gst_fakesrc_prepare_buffer (GstFakeSrc *src, GstBuffer *buf) } } -static GstBuffer* -gst_fakesrc_alloc_buffer (GstFakeSrc *src, guint size) +static GstBuffer * +gst_fakesrc_alloc_buffer (GstFakeSrc * src, guint size) { GstBuffer *buf; buf = gst_buffer_new (); - GST_BUFFER_SIZE(buf) = size; + GST_BUFFER_SIZE (buf) = size; - if (size != 0) { + if (size != 0) { switch (src->filltype) { case FAKESRC_FILLTYPE_NOTHING: - GST_BUFFER_DATA(buf) = g_malloc (size); - break; + GST_BUFFER_DATA (buf) = g_malloc (size); + break; case FAKESRC_FILLTYPE_NULL: - GST_BUFFER_DATA(buf) = g_malloc0 (size); - break; + GST_BUFFER_DATA (buf) = g_malloc0 (size); + break; case FAKESRC_FILLTYPE_RANDOM: case FAKESRC_FILLTYPE_PATTERN: case FAKESRC_FILLTYPE_PATTERN_CONT: default: - GST_BUFFER_DATA(buf) = g_malloc (size); - gst_fakesrc_prepare_buffer (src, buf); - break; + GST_BUFFER_DATA (buf) = g_malloc (size); + gst_fakesrc_prepare_buffer (src, buf); + break; } } @@ -653,7 +666,7 @@ gst_fakesrc_alloc_buffer (GstFakeSrc *src, guint size) } static guint -gst_fakesrc_get_size (GstFakeSrc *src) +gst_fakesrc_get_size (GstFakeSrc * src) { guint size; @@ -662,11 +675,14 @@ gst_fakesrc_get_size (GstFakeSrc *src) size = src->sizemax; break; case FAKESRC_SIZETYPE_RANDOM: - size = src->sizemin + (guint8)(((gfloat)src->sizemax)*rand()/(RAND_MAX + (gfloat)src->sizemin)); + size = + src->sizemin + + (guint8) (((gfloat) src->sizemax) * rand () / (RAND_MAX + + (gfloat) src->sizemin)); break; case FAKESRC_SIZETYPE_NULL: default: - size = 0; + size = 0; break; } @@ -674,7 +690,7 @@ gst_fakesrc_get_size (GstFakeSrc *src) } static GstBuffer * -gst_fakesrc_create_buffer (GstFakeSrc *src) +gst_fakesrc_create_buffer (GstFakeSrc * src) { GstBuffer *buf; guint size; @@ -682,7 +698,7 @@ gst_fakesrc_create_buffer (GstFakeSrc *src) size = gst_fakesrc_get_size (src); if (size == 0) - return gst_buffer_new(); + return gst_buffer_new (); switch (src->data) { case FAKESRC_DATA_ALLOCATE: @@ -696,21 +712,20 @@ gst_fakesrc_create_buffer (GstFakeSrc *src) } /* see if it's large enough */ if ((GST_BUFFER_SIZE (src->parent) - src->parentoffset) >= size) { - buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); - src->parentoffset += size; - } - else { + buf = gst_buffer_create_sub (src->parent, src->parentoffset, size); + src->parentoffset += size; + } else { /* the parent is useless now */ gst_buffer_unref (src->parent); src->parent = NULL; /* try again (this will allocate a new parent) */ - return gst_fakesrc_create_buffer (src); + return gst_fakesrc_create_buffer (src); } gst_fakesrc_prepare_buffer (src, buf); break; default: g_warning ("fakesrc: dunno how to allocate buffers !"); - buf = gst_buffer_new(); + buf = gst_buffer_new (); break; } if (dump) { @@ -721,7 +736,7 @@ gst_fakesrc_create_buffer (GstFakeSrc *src) } static GstData * -gst_fakesrc_get(GstPad *pad) +gst_fakesrc_get (GstPad * pad) { GstFakeSrc *src; GstBuffer *buf; @@ -734,31 +749,29 @@ gst_fakesrc_get(GstPad *pad) if (src->need_flush) { src->need_flush = FALSE; - return GST_DATA(gst_event_new (GST_EVENT_FLUSH)); + return GST_DATA (gst_event_new (GST_EVENT_FLUSH)); } if (src->buffer_count == src->segment_end) { if (src->segment_loop) { - return GST_DATA(gst_event_new (GST_EVENT_SEGMENT_DONE)); - } - else { + return GST_DATA (gst_event_new (GST_EVENT_SEGMENT_DONE)); + } else { gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); + return GST_DATA (gst_event_new (GST_EVENT_EOS)); } } if (src->rt_num_buffers == 0) { gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); - } - else { + return GST_DATA (gst_event_new (GST_EVENT_EOS)); + } else { if (src->rt_num_buffers > 0) src->rt_num_buffers--; } if (src->eos) { - GST_INFO ( "fakesrc is setting eos on pad"); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); + GST_INFO ("fakesrc is setting eos on pad"); + return GST_DATA (gst_event_new (GST_EVENT_EOS)); } buf = gst_fakesrc_create_buffer (src); @@ -767,9 +780,10 @@ gst_fakesrc_get(GstPad *pad) if (!src->silent) { g_free (src->last_message); - src->last_message = g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %" - G_GUINT64_FORMAT " ) %p", - GST_DEBUG_PAD_NAME (pad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); + src->last_message = + g_strdup_printf ("get ******* (%s:%s)> (%d bytes, %" + G_GUINT64_FORMAT " ) %p", GST_DEBUG_PAD_NAME (pad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); g_object_notify (G_OBJECT (src), "last_message"); } @@ -777,7 +791,7 @@ gst_fakesrc_get(GstPad *pad) if (src->signal_handoffs) { GST_LOG_OBJECT (src, "pre handoff emit"); g_signal_emit (G_OBJECT (src), gst_fakesrc_signals[SIGNAL_HANDOFF], 0, - buf, pad); + buf, pad); GST_LOG_OBJECT (src, "post handoff emit"); } @@ -791,13 +805,13 @@ gst_fakesrc_get(GstPad *pad) * generate an empty buffer and push it to the next element. */ static void -gst_fakesrc_loop(GstElement *element) +gst_fakesrc_loop (GstElement * element) { GstFakeSrc *src; const GList *pads; - g_return_if_fail(element != NULL); - g_return_if_fail(GST_IS_FAKESRC(element)); + g_return_if_fail (element != NULL); + g_return_if_fail (GST_IS_FAKESRC (element)); src = GST_FAKESRC (element); @@ -819,7 +833,7 @@ gst_fakesrc_loop(GstElement *element) } static GstElementStateReturn -gst_fakesrc_change_state (GstElement *element) +gst_fakesrc_change_state (GstElement * element) { GstFakeSrc *fakesrc; @@ -842,8 +856,8 @@ gst_fakesrc_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_READY: if (fakesrc->parent) { - gst_buffer_unref (fakesrc->parent); - fakesrc->parent = NULL; + gst_buffer_unref (fakesrc->parent); + fakesrc->parent = NULL; } g_free (fakesrc->last_message); fakesrc->last_message = NULL; @@ -860,4 +874,3 @@ gst_fakesrc_change_state (GstElement *element) return GST_STATE_SUCCESS; } - diff --git a/plugins/elements/gstfakesrc.h b/plugins/elements/gstfakesrc.h index e7880b201..cee8e1a95 100644 --- a/plugins/elements/gstfakesrc.h +++ b/plugins/elements/gstfakesrc.h @@ -26,10 +26,8 @@ #include -G_BEGIN_DECLS - - -typedef enum { +G_BEGIN_DECLS typedef enum +{ FAKESRC_FIRST_LAST_LOOP = 1, FAKESRC_LAST_FIRST_LOOP, FAKESRC_PING_PONG, @@ -40,18 +38,21 @@ typedef enum { FAKESRC_GET_ALWAYS_SUCEEDS } GstFakeSrcOutputType; -typedef enum { +typedef enum +{ FAKESRC_DATA_ALLOCATE = 1, FAKESRC_DATA_SUBBUFFER, } GstFakeSrcDataType; -typedef enum { +typedef enum +{ FAKESRC_SIZETYPE_NULL = 1, FAKESRC_SIZETYPE_FIXED, FAKESRC_SIZETYPE_RANDOM } GstFakeSrcSizeType; -typedef enum { +typedef enum +{ FAKESRC_FILLTYPE_NOTHING = 1, FAKESRC_FILLTYPE_NULL, FAKESRC_FILLTYPE_RANDOM, @@ -73,50 +74,51 @@ typedef enum { typedef struct _GstFakeSrc GstFakeSrc; typedef struct _GstFakeSrcClass GstFakeSrcClass; -struct _GstFakeSrc { - GstElement element; +struct _GstFakeSrc +{ + GstElement element; - gboolean loop_based; - gboolean eos; + gboolean loop_based; + gboolean eos; GstFakeSrcOutputType output; - GstFakeSrcDataType data; - GstFakeSrcSizeType sizetype; - GstFakeSrcFillType filltype; - - guint sizemin; - guint sizemax; - GstBuffer *parent; - guint parentsize; - guint parentoffset; - guint8 pattern_byte; - gchar *pattern; - GList *patternlist; - gint64 segment_start; - gint64 segment_end; - gboolean segment_loop; - gint num_buffers; - gint rt_num_buffers; /* we are going to change this at runtime */ - guint64 buffer_count; - gboolean silent; - gboolean signal_handoffs; - gboolean dump; - gboolean need_flush; - - gchar *last_message; + GstFakeSrcDataType data; + GstFakeSrcSizeType sizetype; + GstFakeSrcFillType filltype; + + guint sizemin; + guint sizemax; + GstBuffer *parent; + guint parentsize; + guint parentoffset; + guint8 pattern_byte; + gchar *pattern; + GList *patternlist; + gint64 segment_start; + gint64 segment_end; + gboolean segment_loop; + gint num_buffers; + gint rt_num_buffers; /* we are going to change this at runtime */ + guint64 buffer_count; + gboolean silent; + gboolean signal_handoffs; + gboolean dump; + gboolean need_flush; + + gchar *last_message; }; -struct _GstFakeSrcClass { +struct _GstFakeSrcClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstBuffer *buf, GstPad *pad); + void (*handoff) (GstElement * element, GstBuffer * buf, GstPad * pad); }; -GType gst_fakesrc_get_type(void); +GType gst_fakesrc_get_type (void); -gboolean gst_fakesrc_factory_init (GstElementFactory *factory); +gboolean gst_fakesrc_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_FAKESRC_H__ */ diff --git a/plugins/elements/gstfdsink.c b/plugins/elements/gstfdsink.c index 70f358669..707b66dca 100644 --- a/plugins/elements/gstfdsink.c +++ b/plugins/elements/gstfdsink.c @@ -30,21 +30,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_fdsink_debug); #define GST_CAT_DEFAULT gst_fdsink_debug -GstElementDetails gst_fdsink_details = GST_ELEMENT_DETAILS ( - "Filedescriptor Sink", - "Sink/File", - "Write data to a file descriptor", - "Erik Walthinsen " -); +GstElementDetails gst_fdsink_details = +GST_ELEMENT_DETAILS ("Filedescriptor Sink", + "Sink/File", + "Write data to a file descriptor", + "Erik Walthinsen "); /* FdSink signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_FD }; @@ -53,25 +54,26 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fdsink_debug, "fdsink", 0, "fdsink element"); -GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFdSink, gst_fdsink, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_fdsink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fdsink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_fdsink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fdsink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_fdsink_chain (GstPad *pad,GstData *_data); +static void gst_fdsink_chain (GstPad * pad, GstData * _data); static void gst_fdsink_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_fdsink_details); } static void -gst_fdsink_class_init (GstFdSinkClass *klass) +gst_fdsink_class_init (GstFdSinkClass * klass) { GObjectClass *gobject_class; @@ -79,15 +81,15 @@ gst_fdsink_class_init (GstFdSinkClass *klass) g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, - g_param_spec_int ("fd", "fd", "An open file descriptor to write to", - 0, G_MAXINT, 1, G_PARAM_READWRITE)); + g_param_spec_int ("fd", "fd", "An open file descriptor to write to", + 0, G_MAXINT, 1, G_PARAM_READWRITE)); gobject_class->set_property = gst_fdsink_set_property; gobject_class->get_property = gst_fdsink_get_property; } -static void -gst_fdsink_init (GstFdSink *fdsink) +static void +gst_fdsink_init (GstFdSink * fdsink) { fdsink->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (fdsink), fdsink->sinkpad); @@ -96,8 +98,8 @@ gst_fdsink_init (GstFdSink *fdsink) fdsink->fd = 1; } -static void -gst_fdsink_chain (GstPad *pad, GstData *_data) +static void +gst_fdsink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstFdSink *fdsink; @@ -107,25 +109,27 @@ gst_fdsink_chain (GstPad *pad, GstData *_data) g_return_if_fail (buf != NULL); fdsink = GST_FDSINK (gst_pad_get_parent (pad)); - + g_return_if_fail (fdsink->fd >= 0); - + if (GST_BUFFER_DATA (buf)) { - GST_DEBUG ("writing %d bytes to file descriptor %d",GST_BUFFER_SIZE (buf), fdsink->fd); + GST_DEBUG ("writing %d bytes to file descriptor %d", GST_BUFFER_SIZE (buf), + fdsink->fd); write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); } - + gst_buffer_unref (buf); } -static void -gst_fdsink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_fdsink_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFdSink *fdsink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSINK (object)); - + fdsink = GST_FDSINK (object); switch (prop_id) { @@ -137,14 +141,15 @@ gst_fdsink_set_property (GObject *object, guint prop_id, const GValue *value, GP } } -static void -gst_fdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fdsink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFdSink *fdsink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSINK (object)); - + fdsink = GST_FDSINK (object); switch (prop_id) { diff --git a/plugins/elements/gstfdsink.h b/plugins/elements/gstfdsink.h index 838705a72..9a495d3c3 100644 --- a/plugins/elements/gstfdsink.h +++ b/plugins/elements/gstfdsink.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FDSINK \ (gst_fdsink_get_type()) #define GST_FDSINK(obj) \ @@ -39,11 +37,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSINK)) #define GST_IS_FDSINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSINK)) - typedef struct _GstFdSink GstFdSink; typedef struct _GstFdSinkClass GstFdSinkClass; -struct _GstFdSink { +struct _GstFdSink +{ GstElement element; GstPad *sinkpad; @@ -51,12 +49,12 @@ struct _GstFdSink { int fd; }; -struct _GstFdSinkClass { +struct _GstFdSinkClass +{ GstElementClass parent_class; }; -GType gst_fdsink_get_type(void); +GType gst_fdsink_get_type (void); G_END_DECLS - #endif /* __GST_FDSINK_H__ */ diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c index e7337705e..18984cf69 100644 --- a/plugins/elements/gstfdsrc.c +++ b/plugins/elements/gstfdsrc.c @@ -39,21 +39,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_fdsrc_debug); #define GST_CAT_DEFAULT gst_fdsrc_debug -GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ( - "Disk Source", - "Source/File", - "Synchronous read from a file", - "Erik Walthinsen " -); +GstElementDetails gst_fdsrc_details = GST_ELEMENT_DETAILS ("Disk Source", + "Source/File", + "Synchronous read from a file", + "Erik Walthinsen "); /* FdSrc signals and args */ -enum { +enum +{ SIGNAL_TIMEOUT, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_FD, ARG_BLOCKSIZE, @@ -65,52 +65,56 @@ static guint gst_fdsrc_signals[LAST_SIGNAL] = { 0 }; #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_fdsrc_debug, "fdsrc", 0, "fdsrc element"); -GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstFdSrc, gst_fdsrc, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_fdsrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_fdsrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_fdsrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_fdsrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstData * gst_fdsrc_get (GstPad *pad); +static GstData *gst_fdsrc_get (GstPad * pad); static void gst_fdsrc_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_fdsrc_details); } static void -gst_fdsrc_class_init (GstFdSrcClass *klass) +gst_fdsrc_class_init (GstFdSrcClass * klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, - g_param_spec_int ("fd", "fd", "An open file descriptor to read from", - 0, G_MAXINT, 0, G_PARAM_READWRITE)); + g_param_spec_int ("fd", "fd", "An open file descriptor to read from", + 0, G_MAXINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, - g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer", - 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE)); + g_param_spec_ulong ("blocksize", "Block size", + "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TIMEOUT, - g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds", - 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); + g_param_spec_uint64 ("timeout", "Timeout", "Read timeout in nanoseconds", + 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); gst_fdsrc_signals[SIGNAL_TIMEOUT] = - g_signal_new ("timeout", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("timeout", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFdSrcClass, timeout), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gobject_class->set_property = gst_fdsrc_set_property; gobject_class->get_property = gst_fdsrc_get_property; } -static void gst_fdsrc_init(GstFdSrc *fdsrc) { +static void +gst_fdsrc_init (GstFdSrc * fdsrc) +{ fdsrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - + gst_pad_set_get_function (fdsrc->srcpad, gst_fdsrc_get); gst_element_add_pad (GST_ELEMENT (fdsrc), fdsrc->srcpad); @@ -122,14 +126,15 @@ static void gst_fdsrc_init(GstFdSrc *fdsrc) { } -static void -gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_fdsrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFdSrc *src; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSRC (object)); - + src = GST_FDSRC (object); switch (prop_id) { @@ -147,14 +152,15 @@ gst_fdsrc_set_property (GObject *object, guint prop_id, const GValue *value, GPa } } -static void -gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_fdsrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFdSrc *src; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FDSRC (object)); - + src = GST_FDSRC (object); switch (prop_id) { @@ -174,7 +180,7 @@ gst_fdsrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpe } static GstData * -gst_fdsrc_get(GstPad *pad) +gst_fdsrc_get (GstPad * pad) { GstFdSrc *src; GstBuffer *buf; @@ -191,38 +197,31 @@ gst_fdsrc_get(GstPad *pad) FD_ZERO (&readfds); FD_SET (src->fd, &readfds); - if (src->timeout != 0) - { + if (src->timeout != 0) { GST_TIME_TO_TIMEVAL (src->timeout, t); - } - else + } else tp = NULL; - do - { + do { retval = select (1, &readfds, NULL, NULL, tp); - } while (retval == -1 && errno == EINTR); /* retry if interrupted */ + } while (retval == -1 && errno == EINTR); /* retry if interrupted */ - if (retval == -1) - { - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("select on file descriptor: %s.", g_strerror(errno))); + if (retval == -1) { + GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), + ("select on file descriptor: %s.", g_strerror (errno))); gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); - } - else if (retval == 0) - { + } else if (retval == 0) { g_signal_emit (G_OBJECT (src), gst_fdsrc_signals[SIGNAL_TIMEOUT], 0); gst_element_set_eos (GST_ELEMENT (src)); - return GST_DATA(gst_event_new (GST_EVENT_EOS)); + return GST_DATA (gst_event_new (GST_EVENT_EOS)); } - do - { + do { readbytes = read (src->fd, GST_BUFFER_DATA (buf), src->blocksize); - } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ + } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ - if (readbytes > 0) - { + if (readbytes > 0) { GST_BUFFER_OFFSET (buf) = src->curoffset; GST_BUFFER_SIZE (buf) = readbytes; GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE; @@ -230,15 +229,12 @@ gst_fdsrc_get(GstPad *pad) /* we're done, return the buffer */ return GST_DATA (buf); - } - else if (readbytes == 0) - { + } else if (readbytes == 0) { gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); - } - else - { - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("read on file descriptor: %s.", g_strerror(errno))); + } else { + GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), + ("read on file descriptor: %s.", g_strerror (errno))); gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); } diff --git a/plugins/elements/gstfdsrc.h b/plugins/elements/gstfdsrc.h index 3bb9e7812..f300352cd 100644 --- a/plugins/elements/gstfdsrc.h +++ b/plugins/elements/gstfdsrc.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FDSRC \ (gst_fdsrc_get_type()) #define GST_FDSRC(obj) \ @@ -39,12 +37,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FDSRC)) #define GST_IS_FDSRC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FDSRC)) - - typedef struct _GstFdSrc GstFdSrc; typedef struct _GstFdSrcClass GstFdSrcClass; -struct _GstFdSrc { +struct _GstFdSrc +{ GstElement element; /* pads */ GstPad *srcpad; @@ -52,22 +49,22 @@ struct _GstFdSrc { /* fd */ gint fd; - gulong curoffset; /* current offset in file */ - gulong blocksize; /* bytes per read */ - guint64 timeout; /* read timeout, in nanoseconds */ - - gulong seq; /* buffer sequence number */ + gulong curoffset; /* current offset in file */ + gulong blocksize; /* bytes per read */ + guint64 timeout; /* read timeout, in nanoseconds */ + + gulong seq; /* buffer sequence number */ }; -struct _GstFdSrcClass { +struct _GstFdSrcClass +{ GstElementClass parent_class; /* signals */ - void (*timeout) (GstElement *element); + void (*timeout) (GstElement * element); }; -GType gst_fdsrc_get_type(void); +GType gst_fdsrc_get_type (void); G_END_DECLS - #endif /* __GST_FDSRC_H__ */ diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c index fb575cdc6..e52eb80fe 100644 --- a/plugins/elements/gstfilesink.c +++ b/plugins/elements/gstfilesink.c @@ -39,28 +39,28 @@ GST_DEBUG_CATEGORY_STATIC (gst_filesink_debug); #define GST_CAT_DEFAULT gst_filesink_debug -GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS ( - "File Sink", - "Sink/File", - "Write stream to a file", - "Thomas " -); +GstElementDetails gst_filesink_details = GST_ELEMENT_DETAILS ("File Sink", + "Sink/File", + "Write stream to a file", + "Thomas "); /* FileSink signals and args */ -enum { +enum +{ /* FILL ME */ SIGNAL_HANDOFF, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATION }; static const GstFormat * -gst_filesink_get_formats (GstPad *pad) +gst_filesink_get_formats (GstPad * pad) { static const GstFormat formats[] = { GST_FORMAT_BYTES, @@ -70,7 +70,7 @@ gst_filesink_get_formats (GstPad *pad) } static const GstQueryType * -gst_filesink_get_query_types (GstPad *pad) +gst_filesink_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -80,24 +80,25 @@ gst_filesink_get_query_types (GstPad *pad) return types; } -static void gst_filesink_dispose (GObject *object); +static void gst_filesink_dispose (GObject * object); + +static void gst_filesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_filesink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_filesink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_filesink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static gboolean gst_filesink_open_file (GstFileSink * sink); +static void gst_filesink_close_file (GstFileSink * sink); -static gboolean gst_filesink_open_file (GstFileSink *sink); -static void gst_filesink_close_file (GstFileSink *sink); +static gboolean gst_filesink_handle_event (GstPad * pad, GstEvent * event); +static gboolean gst_filesink_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); +static void gst_filesink_chain (GstPad * pad, GstData * _data); -static gboolean gst_filesink_handle_event (GstPad *pad, GstEvent *event); -static gboolean gst_filesink_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); -static void gst_filesink_chain (GstPad *pad,GstData *_data); +static void gst_filesink_uri_handler_init (gpointer g_iface, + gpointer iface_data); -static void gst_filesink_uri_handler_init (gpointer g_iface, gpointer iface_data); - -static GstElementStateReturn gst_filesink_change_state (GstElement *element); +static GstElementStateReturn gst_filesink_change_state (GstElement * element); static guint gst_filesink_signals[LAST_SIGNAL] = { 0 }; @@ -109,12 +110,15 @@ _do_init (GType filesink_type) NULL, NULL }; - g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, &urihandler_info); - GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, "filesink element"); + g_type_add_interface_static (filesink_type, GST_TYPE_URI_HANDLER, + &urihandler_info); + GST_DEBUG_CATEGORY_INIT (gst_filesink_debug, "filesink", 0, + "filesink element"); } -GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT, _do_init); - +GST_BOILERPLATE_FULL (GstFileSink, gst_filesink, GstElement, GST_TYPE_ELEMENT, + _do_init); + static void gst_filesink_base_init (gpointer g_class) @@ -125,26 +129,26 @@ gst_filesink_base_init (gpointer g_class) gst_element_class_set_details (gstelement_class, &gst_filesink_details); } static void -gst_filesink_class_init (GstFileSinkClass *klass) +gst_filesink_class_init (GstFileSinkClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, - g_param_spec_string ("location", "File Location", "Location of the file to write", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("location", "File Location", + "Location of the file to write", NULL, G_PARAM_READWRITE)); gst_filesink_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstFileSinkClass, handoff), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gobject_class->set_property = gst_filesink_set_property; gobject_class->get_property = gst_filesink_get_property; - gobject_class->dispose = gst_filesink_dispose; + gobject_class->dispose = gst_filesink_dispose; } -static void -gst_filesink_init (GstFileSink *filesink) +static void +gst_filesink_init (GstFileSink * filesink) { GstPad *pad; @@ -152,7 +156,7 @@ gst_filesink_init (GstFileSink *filesink) gst_element_add_pad (GST_ELEMENT (filesink), pad); gst_pad_set_chain_function (pad, gst_filesink_chain); - GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE); + GST_FLAG_SET (GST_ELEMENT (filesink), GST_ELEMENT_EVENT_AWARE); gst_pad_set_query_function (pad, gst_filesink_pad_query); gst_pad_set_query_type_function (pad, gst_filesink_get_query_types); @@ -162,19 +166,20 @@ gst_filesink_init (GstFileSink *filesink) filesink->file = NULL; } static void -gst_filesink_dispose (GObject *object) +gst_filesink_dispose (GObject * object) { GstFileSink *sink = GST_FILESINK (object); G_OBJECT_CLASS (parent_class)->dispose (object); - + g_free (sink->uri); sink->uri = NULL; g_free (sink->filename); sink->filename = NULL; } + static gboolean -gst_filesink_set_location (GstFileSink *sink, const gchar *location) +gst_filesink_set_location (GstFileSink * sink, const gchar * location) { /* the element must be stopped or paused in order to do this */ if (GST_STATE (sink) > GST_STATE_PAUSED) @@ -192,14 +197,15 @@ gst_filesink_set_location (GstFileSink *sink, const gchar *location) sink->filename = NULL; sink->uri = NULL; } - + if (GST_STATE (sink) == GST_STATE_PAUSED) gst_filesink_open_file (sink); return TRUE; } static void -gst_filesink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_filesink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstFileSink *sink; @@ -216,16 +222,17 @@ gst_filesink_set_property (GObject *object, guint prop_id, const GValue *value, } } -static void -gst_filesink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_filesink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFileSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_FILESINK (object)); - + sink = GST_FILESINK (object); - + switch (prop_id) { case ARG_LOCATION: g_value_set_string (value, sink->filename); @@ -237,23 +244,22 @@ gst_filesink_get_property (GObject *object, guint prop_id, GValue *value, GParam } static gboolean -gst_filesink_open_file (GstFileSink *sink) +gst_filesink_open_file (GstFileSink * sink) { g_return_val_if_fail (!GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN), FALSE); /* open the file */ - if (sink->filename == NULL || sink->filename[0] == '\0') - { + if (sink->filename == NULL || sink->filename[0] == '\0') { GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND, - (_("No file name specified for writing.")), (NULL)); + (_("No file name specified for writing.")), (NULL)); return FALSE; } sink->file = fopen (sink->filename, "w"); if (sink->file == NULL) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (_("Could not open file \"%s\" for writing."), sink->filename), - GST_ERROR_SYSTEM); + (_("Could not open file \"%s\" for writing."), sink->filename), + GST_ERROR_SYSTEM); return FALSE; } @@ -265,24 +271,21 @@ gst_filesink_open_file (GstFileSink *sink) } static void -gst_filesink_close_file (GstFileSink *sink) +gst_filesink_close_file (GstFileSink * sink) { g_return_if_fail (GST_FLAG_IS_SET (sink, GST_FILESINK_OPEN)); - if (fclose (sink->file) != 0) - { + if (fclose (sink->file) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Error closing file \"%s\"."), sink->filename), - GST_ERROR_SYSTEM); - } - else { + (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM); + } else { GST_FLAG_UNSET (sink, GST_FILESINK_OPEN); } } static gboolean -gst_filesink_pad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_filesink_pad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFileSink *sink = GST_FILESINK (GST_PAD_PARENT (pad)); @@ -290,23 +293,23 @@ gst_filesink_pad_query (GstPad *pad, GstQueryType type, case GST_QUERY_TOTAL: switch (*format) { case GST_FORMAT_BYTES: - if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) { - *value = sink->data_written; /* FIXME - doesn't the kernel provide - such a function? */ - break; - } - default: + if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { + *value = sink->data_written; /* FIXME - doesn't the kernel provide + such a function? */ + break; + } + default: return FALSE; } break; case GST_QUERY_POSITION: switch (*format) { case GST_FORMAT_BYTES: - if (GST_FLAG_IS_SET (GST_ELEMENT(sink), GST_FILESINK_OPEN)) { - *value = ftell (sink->file); - break; - } - default: + if (GST_FLAG_IS_SET (GST_ELEMENT (sink), GST_FILESINK_OPEN)) { + *value = ftell (sink->file); + break; + } + default: return FALSE; } break; @@ -319,60 +322,58 @@ gst_filesink_pad_query (GstPad *pad, GstQueryType type, /* handle events (search) */ static gboolean -gst_filesink_handle_event (GstPad *pad, GstEvent *event) +gst_filesink_handle_event (GstPad * pad, GstEvent * event) { GstEventType type; GstFileSink *filesink; filesink = GST_FILESINK (gst_pad_get_parent (pad)); - g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN), - FALSE); + g_return_val_if_fail (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN), FALSE); type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN; switch (type) { case GST_EVENT_SEEK: g_return_val_if_fail (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES, - FALSE); + FALSE); if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) - if (fflush (filesink->file)) - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - GST_ERROR_SYSTEM); - - switch (GST_EVENT_SEEK_METHOD(event)) - { - case GST_SEEK_METHOD_SET: - fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET); - break; - case GST_SEEK_METHOD_CUR: - fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR); - break; - case GST_SEEK_METHOD_END: - fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END); - break; - default: - g_warning ("unknown seek method!"); - break; + if (fflush (filesink->file)) + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + GST_ERROR_SYSTEM); + + switch (GST_EVENT_SEEK_METHOD (event)) { + case GST_SEEK_METHOD_SET: + fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_SET); + break; + case GST_SEEK_METHOD_CUR: + fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_CUR); + break; + case GST_SEEK_METHOD_END: + fseek (filesink->file, GST_EVENT_SEEK_OFFSET (event), SEEK_END); + break; + default: + g_warning ("unknown seek method!"); + break; } break; case GST_EVENT_DISCONTINUOUS: { gint64 offset; - + if (gst_event_discont_get_value (event, GST_FORMAT_BYTES, &offset)) - fseek (filesink->file, offset, SEEK_SET); + fseek (filesink->file, offset, SEEK_SET); gst_event_unref (event); break; } case GST_EVENT_FLUSH: if (fflush (filesink->file)) { - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - GST_ERROR_SYSTEM); + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + GST_ERROR_SYSTEM); } break; case GST_EVENT_EOS: @@ -394,8 +395,8 @@ gst_filesink_handle_event (GstPad *pad, GstEvent *event) * * take the buffer from the pad and write to file if it's open */ -static void -gst_filesink_chain (GstPad *pad, GstData *_data) +static void +gst_filesink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstFileSink *filesink; @@ -406,27 +407,26 @@ gst_filesink_chain (GstPad *pad, GstData *_data) filesink = GST_FILESINK (gst_pad_get_parent (pad)); - if (GST_IS_EVENT(buf)) - { - gst_filesink_handle_event(pad, GST_EVENT(buf)); + if (GST_IS_EVENT (buf)) { + gst_filesink_handle_event (pad, GST_EVENT (buf)); return; } - if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) - { + if (GST_FLAG_IS_SET (filesink, GST_FILESINK_OPEN)) { guint bytes_written = 0, back_pending = 0; - if (ftell(filesink->file) < filesink->data_written) - back_pending = filesink->data_written - ftell(filesink->file); + + if (ftell (filesink->file) < filesink->data_written) + back_pending = filesink->data_written - ftell (filesink->file); while (bytes_written < GST_BUFFER_SIZE (buf)) { size_t wrote = fwrite (GST_BUFFER_DATA (buf) + bytes_written, 1, - GST_BUFFER_SIZE (buf) - bytes_written, - filesink->file); + GST_BUFFER_SIZE (buf) - bytes_written, + filesink->file); + if (wrote <= 0) { - GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, - (_("Error while writing to file \"%s\"."), filesink->filename), - ("Only %d of %d bytes written: %s", - bytes_written, GST_BUFFER_SIZE (buf), - strerror (errno))); + GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE, + (_("Error while writing to file \"%s\"."), filesink->filename), + ("Only %d of %d bytes written: %s", + bytes_written, GST_BUFFER_SIZE (buf), strerror (errno))); break; } bytes_written += wrote; @@ -438,25 +438,24 @@ gst_filesink_chain (GstPad *pad, GstData *_data) gst_buffer_unref (buf); g_signal_emit (G_OBJECT (filesink), - gst_filesink_signals[SIGNAL_HANDOFF], 0, - filesink); + gst_filesink_signals[SIGNAL_HANDOFF], 0, filesink); } static GstElementStateReturn -gst_filesink_change_state (GstElement *element) +gst_filesink_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_FILESINK (element), GST_STATE_FAILURE); switch (GST_STATE_TRANSITION (element)) { case GST_STATE_PAUSED_TO_READY: if (GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) - gst_filesink_close_file (GST_FILESINK (element)); + gst_filesink_close_file (GST_FILESINK (element)); break; case GST_STATE_READY_TO_PAUSED: if (!GST_FLAG_IS_SET (element, GST_FILESINK_OPEN)) { - if (!gst_filesink_open_file (GST_FILESINK (element))) - return GST_STATE_FAILURE; + if (!gst_filesink_open_file (GST_FILESINK (element))) + return GST_STATE_FAILURE; } break; } @@ -475,20 +474,21 @@ gst_filesink_uri_get_type (void) return GST_URI_SINK; } static gchar ** -gst_filesink_uri_get_protocols(void) +gst_filesink_uri_get_protocols (void) { - static gchar *protocols[] = {"file", NULL}; + static gchar *protocols[] = { "file", NULL }; return protocols; } static const gchar * -gst_filesink_uri_get_uri (GstURIHandler *handler) +gst_filesink_uri_get_uri (GstURIHandler * handler) { GstFileSink *sink = GST_FILESINK (handler); - + return sink->uri; } + static gboolean -gst_filesink_uri_set_uri (GstURIHandler *handler, const gchar *uri) +gst_filesink_uri_set_uri (GstURIHandler * handler, const gchar * uri) { gchar *protocol, *location; gboolean ret; diff --git a/plugins/elements/gstfilesink.h b/plugins/elements/gstfilesink.h index bd85a1d01..5a06f3e06 100644 --- a/plugins/elements/gstfilesink.h +++ b/plugins/elements/gstfilesink.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FILESINK \ (gst_filesink_get_type()) #define GST_FILESINK(obj) \ @@ -39,17 +37,18 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESINK)) #define GST_IS_FILESINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESINK)) - typedef struct _GstFileSink GstFileSink; typedef struct _GstFileSinkClass GstFileSinkClass; -typedef enum { - GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST, +typedef enum +{ + GST_FILESINK_OPEN = GST_ELEMENT_FLAG_LAST, - GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 + GST_FILESINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstFileSinkFlags; -struct _GstFileSink { +struct _GstFileSink +{ GstElement element; gchar *filename; @@ -59,15 +58,15 @@ struct _GstFileSink { guint64 data_written; }; -struct _GstFileSinkClass { +struct _GstFileSinkClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstPad *pad); + void (*handoff) (GstElement * element, GstPad * pad); }; -GType gst_filesink_get_type(void); +GType gst_filesink_get_type (void); G_END_DECLS - #endif /* __GST_FILESINK_H__ */ diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index 7882e9866..1f7ae1ed8 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -77,23 +77,23 @@ GST_DEBUG_CATEGORY_STATIC (gst_filesrc_debug); #define GST_CAT_DEFAULT gst_filesrc_debug -GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS ( - "File Source", - "Source/File", - "Read from arbitrary point in a file", - "Erik Walthinsen " -); +GstElementDetails gst_filesrc_details = GST_ELEMENT_DETAILS ("File Source", + "Source/File", + "Read from arbitrary point in a file", + "Erik Walthinsen "); #define DEFAULT_BLOCKSIZE 4*1024 #define DEFAULT_MMAPSIZE 4*1024*1024 /* FileSrc signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATION, ARG_FD, @@ -103,22 +103,20 @@ enum { }; static const GstEventMask * -gst_filesrc_get_event_mask (GstPad *pad) +gst_filesrc_get_event_mask (GstPad * pad) { static const GstEventMask masks[] = { - { GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | - GST_SEEK_METHOD_SET | - GST_SEEK_METHOD_END | - GST_SEEK_FLAG_FLUSH }, - { GST_EVENT_FLUSH, 0 }, - { GST_EVENT_SIZE, 0 }, - { 0, 0 } + {GST_EVENT_SEEK, GST_SEEK_METHOD_CUR | + GST_SEEK_METHOD_SET | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH}, + {GST_EVENT_FLUSH, 0}, + {GST_EVENT_SIZE, 0}, + {0, 0} }; return masks; } static const GstQueryType * -gst_filesrc_get_query_types (GstPad *pad) +gst_filesrc_get_query_types (GstPad * pad) { static const GstQueryType types[] = { GST_QUERY_TOTAL, @@ -129,7 +127,7 @@ gst_filesrc_get_query_types (GstPad *pad) } static const GstFormat * -gst_filesrc_get_formats (GstPad *pad) +gst_filesrc_get_formats (GstPad * pad) { static const GstFormat formats[] = { GST_FORMAT_BYTES, @@ -138,22 +136,23 @@ gst_filesrc_get_formats (GstPad *pad) return formats; } -static void gst_filesrc_dispose (GObject *object); +static void gst_filesrc_dispose (GObject * object); -static void gst_filesrc_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_filesrc_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_filesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_filesrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static gboolean gst_filesrc_check_filesize (GstFileSrc *src); -static GstData * gst_filesrc_get (GstPad *pad); -static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event); -static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value); +static gboolean gst_filesrc_check_filesize (GstFileSrc * src); +static GstData *gst_filesrc_get (GstPad * pad); +static gboolean gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event); +static gboolean gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value); -static GstElementStateReturn gst_filesrc_change_state (GstElement *element); +static GstElementStateReturn gst_filesrc_change_state (GstElement * element); -static void gst_filesrc_uri_handler_init (gpointer g_iface, gpointer iface_data); +static void gst_filesrc_uri_handler_init (gpointer g_iface, + gpointer iface_data); static void _do_init (GType filesrc_type) @@ -163,12 +162,14 @@ _do_init (GType filesrc_type) NULL, NULL }; - g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, &urihandler_info); + g_type_add_interface_static (filesrc_type, GST_TYPE_URI_HANDLER, + &urihandler_info); GST_DEBUG_CATEGORY_INIT (gst_filesrc_debug, "filesrc", 0, "filesrc element"); } -GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT, _do_init); - +GST_BOILERPLATE_FULL (GstFileSrc, gst_filesrc, GstElement, GST_TYPE_ELEMENT, + _do_init); + static void gst_filesrc_base_init (gpointer g_class) { @@ -177,41 +178,42 @@ gst_filesrc_base_init (gpointer g_class) gst_element_class_set_details (gstelement_class, &gst_filesrc_details); } static void -gst_filesrc_class_init (GstFileSrcClass *klass) +gst_filesrc_class_init (GstFileSrcClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); - gobject_class = (GObjectClass*)klass; + gobject_class = (GObjectClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FD, - g_param_spec_int ("fd", "File-descriptor", "File-descriptor for the file being mmap()d", - 0, G_MAXINT, 0, G_PARAM_READABLE)); + g_param_spec_int ("fd", "File-descriptor", + "File-descriptor for the file being mmap()d", 0, G_MAXINT, 0, + G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATION, - g_param_spec_string ("location", "File Location", "Location of the file to read", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("location", "File Location", + "Location of the file to read", NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BLOCKSIZE, - g_param_spec_ulong ("blocksize", "Block size", "Size in bytes to read per buffer", - 1, G_MAXULONG, DEFAULT_BLOCKSIZE, G_PARAM_READWRITE)); + g_param_spec_ulong ("blocksize", "Block size", + "Size in bytes to read per buffer", 1, G_MAXULONG, DEFAULT_BLOCKSIZE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MMAPSIZE, - g_param_spec_ulong ("mmapsize", "mmap() Block Size", - "Size in bytes of mmap()d regions", - 0, G_MAXULONG, DEFAULT_MMAPSIZE, G_PARAM_READWRITE)); + g_param_spec_ulong ("mmapsize", "mmap() Block Size", + "Size in bytes of mmap()d regions", 0, G_MAXULONG, DEFAULT_MMAPSIZE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOUCH, - g_param_spec_boolean ("touch", "Touch read data", - "Touch data to force disk read", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("touch", "Touch read data", + "Touch data to force disk read", FALSE, G_PARAM_READWRITE)); - gobject_class->dispose = gst_filesrc_dispose; - gobject_class->set_property = gst_filesrc_set_property; - gobject_class->get_property = gst_filesrc_get_property; + gobject_class->dispose = gst_filesrc_dispose; + gobject_class->set_property = gst_filesrc_set_property; + gobject_class->get_property = gst_filesrc_get_property; gstelement_class->change_state = gst_filesrc_change_state; } static void -gst_filesrc_init (GstFileSrc *src) +gst_filesrc_init (GstFileSrc * src) { src->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_get_function (src->srcpad, gst_filesrc_get); @@ -222,7 +224,7 @@ gst_filesrc_init (GstFileSrc *src) gst_pad_set_formats_function (src->srcpad, gst_filesrc_get_formats); gst_element_add_pad (GST_ELEMENT (src), src->srcpad); - src->pagesize = getpagesize(); + src->pagesize = getpagesize (); src->filename = NULL; src->fd = 0; @@ -233,13 +235,13 @@ gst_filesrc_init (GstFileSrc *src) src->touch = FALSE; src->mapbuf = NULL; - src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */ + src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */ src->seek_happened = FALSE; } static void -gst_filesrc_dispose (GObject *object) +gst_filesrc_dispose (GObject * object) { GstFileSrc *src; @@ -254,15 +256,16 @@ gst_filesrc_dispose (GObject *object) } static gboolean -gst_filesrc_set_location (GstFileSrc *src, const gchar *location) +gst_filesrc_set_location (GstFileSrc * src, const gchar * location) { /* the element must be stopped in order to do this */ - if (GST_STATE (src) != GST_STATE_READY && - GST_STATE (src) != GST_STATE_NULL) + if (GST_STATE (src) != GST_STATE_READY && GST_STATE (src) != GST_STATE_NULL) return FALSE; - if (src->filename) g_free (src->filename); - if (src->uri) g_free (src->uri); + if (src->filename) + g_free (src->filename); + if (src->uri) + g_free (src->uri); /* clear the filename if we get a NULL (is that possible?) */ if (location == NULL) { src->filename = NULL; @@ -278,7 +281,8 @@ gst_filesrc_set_location (GstFileSrc *src, const gchar *location) } static void -gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_filesrc_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstFileSrc *src; @@ -297,11 +301,12 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G break; case ARG_MMAPSIZE: if ((src->mapsize % src->pagesize) == 0) { - src->mapsize = g_value_get_ulong (value); - g_object_notify (G_OBJECT (src), "mmapsize"); + src->mapsize = g_value_get_ulong (value); + g_object_notify (G_OBJECT (src), "mmapsize"); } else { - GST_INFO_OBJECT (src, "invalid mapsize, must be a multiple of pagesize, which is %d", - src->pagesize); + GST_INFO_OBJECT (src, + "invalid mapsize, must be a multiple of pagesize, which is %d", + src->pagesize); } break; case ARG_TOUCH: @@ -314,7 +319,8 @@ gst_filesrc_set_property (GObject *object, guint prop_id, const GValue *value, G } static void -gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_filesrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstFileSrc *src; @@ -346,9 +352,9 @@ gst_filesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamS } static void -gst_filesrc_free_parent_mmap (GstBuffer *buf) +gst_filesrc_free_parent_mmap (GstBuffer * buf) { - GST_LOG ("freeing mmap()d buffer at %"G_GUINT64_FORMAT"+%u", + GST_LOG ("freeing mmap()d buffer at %" G_GUINT64_FORMAT "+%u", GST_BUFFER_OFFSET (buf), GST_BUFFER_SIZE (buf)); #ifdef MADV_DONTNEED @@ -359,16 +365,15 @@ gst_filesrc_free_parent_mmap (GstBuffer *buf) munmap (GST_BUFFER_DATA (buf), GST_BUFFER_MAXSIZE (buf)); /* cast to unsigned long, since there's no gportable way to print * guint64 as hex */ - GST_LOG ("unmapped region %08lx+%08lx at %p", + GST_LOG ("unmapped region %08lx+%08lx at %p", (unsigned long) GST_BUFFER_OFFSET (buf), - (unsigned long) GST_BUFFER_MAXSIZE (buf), - GST_BUFFER_DATA (buf)); + (unsigned long) GST_BUFFER_MAXSIZE (buf), GST_BUFFER_DATA (buf)); GST_BUFFER_DATA (buf) = NULL; } static GstBuffer * -gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) +gst_filesrc_map_region (GstFileSrc * src, off_t offset, size_t size) { GstBuffer *buf; gint retval; @@ -376,20 +381,20 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) g_return_val_if_fail (offset >= 0, NULL); - GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory",offset,(unsigned long)size); + GST_LOG_OBJECT (src, "mapping region %08llx+%08lx from file into memory", + offset, (unsigned long) size); mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset); if (mmapregion == NULL) { GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), ("mmap call failed.")); return NULL; - } - else if (mmapregion == MAP_FAILED) { + } else if (mmapregion == MAP_FAILED) { GST_WARNING_OBJECT (src, "mmap (0x%08lx, %d, 0x%llx) failed: %s", - (unsigned long)size, src->fd, offset, strerror (errno)); + (unsigned long) size, src->fd, offset, strerror (errno)); return NULL; } - GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p", - (unsigned long)offset, (unsigned long)size, mmapregion); + GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p", + (unsigned long) offset, (unsigned long) size, mmapregion); /* time to allocate a new mapbuf */ buf = gst_buffer_new (); @@ -398,7 +403,8 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) #ifdef MADV_SEQUENTIAL /* madvise to tell the kernel what to do with it */ - retval = madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL); + retval = + madvise (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), MADV_SEQUENTIAL); #endif /* fill in the rest of the fields */ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_READONLY); @@ -415,7 +421,7 @@ gst_filesrc_map_region (GstFileSrc *src, off_t offset, size_t size) } static GstBuffer * -gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) +gst_filesrc_map_small_region (GstFileSrc * src, off_t offset, size_t size) { size_t mapsize; off_t mod, mapbase; @@ -428,9 +434,10 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) GstBuffer *ret; mapbase = offset - mod; - mapsize = ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize; + mapsize = + ((size + mod + src->pagesize - 1) / src->pagesize) * src->pagesize; /* printf("not on page boundaries, resizing map to %d+%d\n",mapbase,mapsize);*/ - map = gst_filesrc_map_region(src, mapbase, mapsize); + map = gst_filesrc_map_region (src, mapbase, mapsize); if (map == NULL) return NULL; @@ -442,7 +449,7 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) return ret; } - return gst_filesrc_map_region(src,offset,size); + return gst_filesrc_map_region (src, offset, size); } /** @@ -452,19 +459,19 @@ gst_filesrc_map_small_region (GstFileSrc *src, off_t offset, size_t size) * Push a new buffer from the filesrc at the current offset. */ static GstBuffer * -gst_filesrc_get_mmap (GstFileSrc *src) +gst_filesrc_get_mmap (GstFileSrc * src) { GstBuffer *buf = NULL; size_t readsize, mapsize; - off_t readend,mapstart,mapend; + off_t readend, mapstart, mapend; int i; /* calculate end pointers so we don't have to do so repeatedly later */ readsize = src->block_size; - readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */ + readend = src->curoffset + src->block_size; /* note this is the byte *after* the read */ mapstart = GST_BUFFER_OFFSET (src->mapbuf); mapsize = GST_BUFFER_SIZE (src->mapbuf); - mapend = mapstart + mapsize; /* note this is the byte *after* the map */ + mapend = mapstart + mapsize; /* note this is the byte *after* the map */ /* check to see if we're going to overflow the end of the file */ if (readend > src->filelen) { @@ -474,40 +481,46 @@ gst_filesrc_get_mmap (GstFileSrc *src) } } - GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx", - (unsigned long)readsize, (unsigned long)readend, - (unsigned long)mapstart, (unsigned long)mapend); + GST_LOG ("attempting to read %08lx, %08lx, %08lx, %08lx", + (unsigned long) readsize, (unsigned long) readend, + (unsigned long) mapstart, (unsigned long) mapend); /* if the start is past the mapstart */ if (src->curoffset >= mapstart) { /* if the end is before the mapend, the buffer is in current mmap region... */ /* ('cause by definition if readend is in the buffer, so's readstart) */ if (readend <= mapend) { - GST_LOG_OBJECT (src, "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf", - src->curoffset, (int)readsize, mapstart, mapsize); - buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, - readsize); + GST_LOG_OBJECT (src, + "read buf %llu+%d lives in current mapbuf %lld+%d, creating subbuffer of mapbuf", + src->curoffset, (int) readsize, mapstart, mapsize); + buf = + gst_buffer_create_sub (src->mapbuf, src->curoffset - mapstart, + readsize); GST_BUFFER_OFFSET (buf) = src->curoffset; - /* if the start actually is within the current mmap region, map an overlap buffer */ + /* if the start actually is within the current mmap region, map an overlap buffer */ } else if (src->curoffset < mapend) { - GST_LOG_OBJECT (src, "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap", - (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize); + GST_LOG_OBJECT (src, + "read buf %llu+%d starts in mapbuf %d+%d but ends outside, creating new mmap", + (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, + (gint) mapsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); if (buf == NULL) - return NULL; + return NULL; } /* the only other option is that buffer is totally outside, which means we search for it */ - /* now we can assume that the start is *before* the current mmap region */ - /* if the readend is past mapstart, we have two options */ + /* now we can assume that the start is *before* the current mmap region */ + /* if the readend is past mapstart, we have two options */ } else if (readend >= mapstart) { /* either the read buffer overlaps the start of the mmap region */ /* or the read buffer fully contains the current mmap region */ - /* either way, it's really not relevant, we just create a new region anyway*/ - GST_LOG_OBJECT (src, "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it", - (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, (gint) mapsize); + /* either way, it's really not relevant, we just create a new region anyway */ + GST_LOG_OBJECT (src, + "read buf %llu+%d starts before mapbuf %d+%d, but overlaps it", + (unsigned long long) src->curoffset, (gint) readsize, (gint) mapstart, + (gint) mapsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); if (buf == NULL) return NULL; @@ -517,32 +530,35 @@ gst_filesrc_get_mmap (GstFileSrc *src) if (buf == NULL) { /* first check to see if there's a map that covers the right region already */ GST_LOG_OBJECT (src, "searching for mapbuf to cover %llu+%d", - src->curoffset,(int)readsize); - + src->curoffset, (int) readsize); + /* if the read buffer crosses a mmap region boundary, create a one-off region */ if ((src->curoffset / src->mapsize) != (readend / src->mapsize)) { - GST_LOG_OBJECT (src, "read buf %llu+%d crosses a %d-byte boundary, creating a one-off", - src->curoffset,(int)readsize,(int)src->mapsize); + GST_LOG_OBJECT (src, + "read buf %llu+%d crosses a %d-byte boundary, creating a one-off", + src->curoffset, (int) readsize, (int) src->mapsize); buf = gst_filesrc_map_small_region (src, src->curoffset, readsize); if (buf == NULL) return NULL; - /* otherwise we will create a new mmap region and set it to the default */ + /* otherwise we will create a new mmap region and set it to the default */ } else { size_t mapsize; off_t nextmap = src->curoffset - (src->curoffset % src->mapsize); - GST_LOG_OBJECT (src, "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering", - src->curoffset, readsize, nextmap, src->mapsize); + + GST_LOG_OBJECT (src, + "read buf %llu+%d in new mapbuf at %llu+%d, mapping and subbuffering", + src->curoffset, readsize, nextmap, src->mapsize); /* first, we're done with the old mapbuf */ - gst_buffer_unref(src->mapbuf); + gst_buffer_unref (src->mapbuf); mapsize = src->mapsize; /* double the mapsize as long as the readsize is smaller */ while (readsize - (src->curoffset - nextmap) > mapsize) { GST_LOG_OBJECT (src, "readsize smaller then mapsize %08x %d", - readsize, (int)mapsize); - mapsize <<=1; + readsize, (int) mapsize); + mapsize <<= 1; } /* create a new one */ src->mapbuf = gst_filesrc_map_region (src, nextmap, mapsize); @@ -550,8 +566,11 @@ gst_filesrc_get_mmap (GstFileSrc *src) return NULL; /* subbuffer it */ - buf = gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, readsize); - GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap; + buf = + gst_buffer_create_sub (src->mapbuf, src->curoffset - nextmap, + readsize); + GST_BUFFER_OFFSET (buf) = + GST_BUFFER_OFFSET (src->mapbuf) + src->curoffset - nextmap; } } @@ -559,18 +578,18 @@ gst_filesrc_get_mmap (GstFileSrc *src) if (src->touch) { volatile guchar *p = GST_BUFFER_DATA (buf), c; - for (i=0; i < GST_BUFFER_SIZE (buf); i += src->pagesize) + for (i = 0; i < GST_BUFFER_SIZE (buf); i += src->pagesize) c = p[i]; } /* we're done, return the buffer */ g_assert (src->curoffset == GST_BUFFER_OFFSET (buf)); - src->curoffset += GST_BUFFER_SIZE(buf); + src->curoffset += GST_BUFFER_SIZE (buf); return buf; } static GstBuffer * -gst_filesrc_get_read (GstFileSrc *src) +gst_filesrc_get_read (GstFileSrc * src) { GstBuffer *buf = NULL; size_t readsize; @@ -578,7 +597,8 @@ gst_filesrc_get_read (GstFileSrc *src) readsize = src->block_size; if (src->curoffset + readsize > src->filelen) { - if (!gst_filesrc_check_filesize (src) || src->curoffset + readsize > src->filelen) { + if (!gst_filesrc_check_filesize (src) + || src->curoffset + readsize > src->filelen) { readsize = src->filelen - src->curoffset; } } @@ -587,12 +607,13 @@ gst_filesrc_get_read (GstFileSrc *src) g_return_val_if_fail (buf != NULL, NULL); ret = read (src->fd, GST_BUFFER_DATA (buf), readsize); - if (ret < 0){ + if (ret < 0) { GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM); return NULL; } if (ret < readsize) { - GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("unexpected end of file.")); + GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), + ("unexpected end of file.")); return NULL; } @@ -606,7 +627,7 @@ gst_filesrc_get_read (GstFileSrc *src) } static GstData * -gst_filesrc_get (GstPad *pad) +gst_filesrc_get (GstPad * pad) { GstFileSrc *src; @@ -626,7 +647,9 @@ gst_filesrc_get (GstPad *pad) src->seek_happened = FALSE; GST_DEBUG_OBJECT (src, "sending discont"); - event = gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, NULL); + event = + gst_event_new_discontinuous (FALSE, GST_FORMAT_BYTES, src->curoffset, + NULL); return GST_DATA (event); } @@ -634,77 +657,76 @@ gst_filesrc_get (GstPad *pad) g_assert (src->curoffset <= src->filelen); if (src->curoffset == src->filelen) { if (!gst_filesrc_check_filesize (src) || src->curoffset >= src->filelen) { - GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT" %" G_GINT64_FORMAT, - src->curoffset, src->filelen); + GST_DEBUG_OBJECT (src, "eos %" G_GINT64_FORMAT " %" G_GINT64_FORMAT, + src->curoffset, src->filelen); gst_element_set_eos (GST_ELEMENT (src)); return GST_DATA (gst_event_new (GST_EVENT_EOS)); } } - if (src->using_mmap){ + if (src->using_mmap) { return GST_DATA (gst_filesrc_get_mmap (src)); - }else{ + } else { return GST_DATA (gst_filesrc_get_read (src)); } } /* TRUE if the filesize of the file was updated */ static gboolean -gst_filesrc_check_filesize (GstFileSrc *src) +gst_filesrc_check_filesize (GstFileSrc * src) { struct stat stat_results; - - g_return_val_if_fail (GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE); - fstat(src->fd, &stat_results); - GST_DEBUG_OBJECT (src, "checked filesize on %s (was %"G_GUINT64_FORMAT", is %"G_GUINT64_FORMAT")", - src->filename, src->filelen, (guint64) stat_results.st_size); + g_return_val_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE); + + fstat (src->fd, &stat_results); + GST_DEBUG_OBJECT (src, + "checked filesize on %s (was %" G_GUINT64_FORMAT ", is %" G_GUINT64_FORMAT + ")", src->filename, src->filelen, (guint64) stat_results.st_size); if (src->filelen == (guint64) stat_results.st_size) return FALSE; src->filelen = stat_results.st_size; return TRUE; } + /* open the file and mmap it, necessary to go to READY state */ static gboolean -gst_filesrc_open_file (GstFileSrc *src) +gst_filesrc_open_file (GstFileSrc * src) { - g_return_val_if_fail (!GST_FLAG_IS_SET (src ,GST_FILESRC_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_FILESRC_OPEN), FALSE); - if (src->filename == NULL || src->filename[0] == '\0') - { + if (src->filename == NULL || src->filename[0] == '\0') { GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, - (_("No file name specified for reading.")), (NULL)); + (_("No file name specified for reading.")), (NULL)); return FALSE; } - GST_INFO_OBJECT (src, "opening file %s",src->filename); + GST_INFO_OBJECT (src, "opening file %s", src->filename); /* open the file */ src->fd = open (src->filename, O_RDONLY); - if (src->fd < 0) - { + if (src->fd < 0) { if (errno == ENOENT) GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, (NULL), (NULL)); else GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, - (_("Could not open file \"%s\" for reading."), src->filename), - GST_ERROR_SYSTEM); + (_("Could not open file \"%s\" for reading."), src->filename), + GST_ERROR_SYSTEM); return FALSE; } else { /* check if it is a regular file, otherwise bail out */ struct stat stat_results; - fstat(src->fd, &stat_results); + fstat (src->fd, &stat_results); - if (!S_ISREG(stat_results.st_mode)) { + if (!S_ISREG (stat_results.st_mode)) { GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, - (_("File \"%s\" isn't a regular file."), src->filename), - (NULL)); - close(src->fd); + (_("File \"%s\" isn't a regular file."), src->filename), (NULL)); + close (src->fd); return FALSE; } - + /* find the file length */ src->filelen = stat_results.st_size; @@ -712,7 +734,7 @@ gst_filesrc_open_file (GstFileSrc *src) src->mapbuf = gst_filesrc_map_region (src, 0, src->mapsize); if (src->mapbuf == NULL) { src->using_mmap = FALSE; - }else{ + } else { src->using_mmap = TRUE; } @@ -725,7 +747,7 @@ gst_filesrc_open_file (GstFileSrc *src) /* unmap and close the file */ static void -gst_filesrc_close_file (GstFileSrc *src) +gst_filesrc_close_file (GstFileSrc * src) { g_return_if_fail (GST_FLAG_IS_SET (src, GST_FILESRC_OPEN)); @@ -747,9 +769,9 @@ gst_filesrc_close_file (GstFileSrc *src) static GstElementStateReturn -gst_filesrc_change_state (GstElement *element) +gst_filesrc_change_state (GstElement * element) { - GstFileSrc *src = GST_FILESRC(element); + GstFileSrc *src = GST_FILESRC (element); switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: @@ -758,13 +780,13 @@ gst_filesrc_change_state (GstElement *element) break; case GST_STATE_READY_TO_PAUSED: if (!GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) { - if (!gst_filesrc_open_file (GST_FILESRC (element))) - return GST_STATE_FAILURE; + if (!gst_filesrc_open_file (GST_FILESRC (element))) + return GST_STATE_FAILURE; } break; case GST_STATE_PAUSED_TO_READY: if (GST_FLAG_IS_SET (element, GST_FILESRC_OPEN)) - gst_filesrc_close_file (GST_FILESRC (element)); + gst_filesrc_close_file (GST_FILESRC (element)); src->seek_happened = TRUE; break; default: @@ -778,8 +800,8 @@ gst_filesrc_change_state (GstElement *element) } static gboolean -gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, - GstFormat *format, gint64 *value) +gst_filesrc_srcpad_query (GstPad * pad, GstQueryType type, + GstFormat * format, gint64 * value) { GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad)); @@ -794,14 +816,14 @@ gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, case GST_QUERY_POSITION: switch (*format) { case GST_FORMAT_BYTES: - *value = src->curoffset; - break; + *value = src->curoffset; + break; case GST_FORMAT_PERCENT: if (src->filelen == 0) return FALSE; - *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen; - break; - default: + *value = src->curoffset * GST_FORMAT_PERCENT_MAX / src->filelen; + break; + default: return FALSE; } break; @@ -813,7 +835,7 @@ gst_filesrc_srcpad_query (GstPad *pad, GstQueryType type, } static gboolean -gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event) +gst_filesrc_srcpad_event (GstPad * pad, GstEvent * event) { GstFileSrc *src = GST_FILESRC (GST_PAD_PARENT (pad)); @@ -831,35 +853,41 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event) offset = GST_EVENT_SEEK_OFFSET (event); switch (GST_EVENT_SEEK_METHOD (event)) { - case GST_SEEK_METHOD_SET: - if (offset > src->filelen && (!gst_filesrc_check_filesize (src) || offset > src->filelen)) { - goto error; + case GST_SEEK_METHOD_SET: + if (offset > src->filelen && (!gst_filesrc_check_filesize (src) + || offset > src->filelen)) { + goto error; } - src->curoffset = offset; - GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, src->curoffset); + src->curoffset = offset; + GST_DEBUG_OBJECT (src, "seek set pending to %" G_GINT64_FORMAT, + src->curoffset); break; - case GST_SEEK_METHOD_CUR: - if (offset + src->curoffset > src->filelen) - if (!gst_filesrc_check_filesize (src) || offset + src->curoffset > src->filelen) + case GST_SEEK_METHOD_CUR: + if (offset + src->curoffset > src->filelen) + if (!gst_filesrc_check_filesize (src) + || offset + src->curoffset > src->filelen) goto error; - src->curoffset += offset; - GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, src->curoffset); + src->curoffset += offset; + GST_DEBUG_OBJECT (src, "seek cur pending to %" G_GINT64_FORMAT, + src->curoffset); break; - case GST_SEEK_METHOD_END: - if (ABS (offset) > src->filelen) { - if (!gst_filesrc_check_filesize (src) || ABS (offset) > src->filelen) + case GST_SEEK_METHOD_END: + if (ABS (offset) > src->filelen) { + if (!gst_filesrc_check_filesize (src) + || ABS (offset) > src->filelen) goto error; goto error; } - src->curoffset = src->filelen - ABS (offset); - GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, src->curoffset); + src->curoffset = src->filelen - ABS (offset); + GST_DEBUG_OBJECT (src, "seek end pending to %" G_GINT64_FORMAT, + src->curoffset); break; default: - goto error; + goto error; break; } src->seek_happened = TRUE; - src->need_flush = GST_EVENT_SEEK_FLAGS(event) & GST_SEEK_FLAG_FLUSH; + src->need_flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; break; } case GST_EVENT_SIZE: @@ -867,7 +895,7 @@ gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event) goto error; } src->block_size = GST_EVENT_SIZE_VALUE (event); - g_object_notify (G_OBJECT (src), "blocksize"); + g_object_notify (G_OBJECT (src), "blocksize"); break; case GST_EVENT_FLUSH: src->need_flush = TRUE; @@ -892,20 +920,21 @@ gst_filesrc_uri_get_type (void) return GST_URI_SRC; } static gchar ** -gst_filesrc_uri_get_protocols(void) +gst_filesrc_uri_get_protocols (void) { - static gchar *protocols[] = {"file", NULL}; + static gchar *protocols[] = { "file", NULL }; return protocols; } static const gchar * -gst_filesrc_uri_get_uri (GstURIHandler *handler) +gst_filesrc_uri_get_uri (GstURIHandler * handler) { GstFileSrc *src = GST_FILESRC (handler); - + return src->uri; } + static gboolean -gst_filesrc_uri_set_uri (GstURIHandler *handler, const gchar *uri) +gst_filesrc_uri_set_uri (GstURIHandler * handler, const gchar * uri) { gchar *protocol, *location; gboolean ret; diff --git a/plugins/elements/gstfilesrc.h b/plugins/elements/gstfilesrc.h index 8ebda1e5c..b37ce9c36 100644 --- a/plugins/elements/gstfilesrc.h +++ b/plugins/elements/gstfilesrc.h @@ -29,21 +29,19 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_FILESRC \ (gst_filesrc_get_type()) #define GST_FILESRC(obj) \ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FILESRC,GstFileSrc)) #define GST_FILESRC_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass)) + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FILESRC,GstFileSrcClass)) #define GST_IS_FILESRC(obj) \ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILESRC)) #define GST_IS_FILESRC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILESRC)) - -typedef enum { - GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST, + typedef enum +{ + GST_FILESRC_OPEN = GST_ELEMENT_FLAG_LAST, GST_FILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstFileSrcFlags; @@ -51,20 +49,21 @@ typedef enum { typedef struct _GstFileSrc GstFileSrc; typedef struct _GstFileSrcClass GstFileSrcClass; -struct _GstFileSrc { +struct _GstFileSrc +{ GstElement element; GstPad *srcpad; - guint pagesize; /* system page size*/ - - gchar *filename; /* filename */ - gchar *uri; /* caching the URI */ - gint fd; /* open file descriptor*/ - off_t filelen; /* what's the file length?*/ + guint pagesize; /* system page size */ - off_t curoffset; /* current offset in file*/ - off_t block_size; /* bytes per read */ - gboolean touch; /* whether to touch every page */ + gchar *filename; /* filename */ + gchar *uri; /* caching the URI */ + gint fd; /* open file descriptor */ + off_t filelen; /* what's the file length? */ + + off_t curoffset; /* current offset in file */ + off_t block_size; /* bytes per read */ + gboolean touch; /* whether to touch every page */ gboolean using_mmap; GstBuffer *mapbuf; @@ -74,12 +73,12 @@ struct _GstFileSrc { gboolean need_flush; }; -struct _GstFileSrcClass { +struct _GstFileSrcClass +{ GstElementClass parent_class; }; -GType gst_filesrc_get_type(void); +GType gst_filesrc_get_type (void); G_END_DECLS - #endif /* __GST_FILESRC_H__ */ diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 6fd3e755a..832f33d74 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -34,22 +34,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_identity_debug); #define GST_CAT_DEFAULT gst_identity_debug -GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS ( - "Identity", - "Generic", - "Pass data without modification", - "Erik Walthinsen " -); +GstElementDetails gst_identity_details = GST_ELEMENT_DETAILS ("Identity", + "Generic", + "Pass data without modification", + "Erik Walthinsen "); /* Identity signals and args */ -enum { +enum +{ SIGNAL_HANDOFF, /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOOP_BASED, ARG_SLEEP_TIME, @@ -65,12 +65,15 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_identity_debug, "identity", 0, "identity element"); -GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_identity_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_identity_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_identity_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_identity_chain (GstPad *pad, GstData *_data); +static void gst_identity_chain (GstPad * pad, GstData * _data); static guint gst_identity_signals[LAST_SIGNAL] = { 0 }; @@ -78,11 +81,11 @@ static void gst_identity_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_identity_details); } -static void -gst_identity_class_init (GstIdentityClass *klass) +static void +gst_identity_class_init (GstIdentityClass * klass) { GObjectClass *gobject_class; @@ -90,50 +93,52 @@ gst_identity_class_init (GstIdentityClass *klass) g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOOP_BASED, - g_param_spec_boolean ("loop-based", "Loop-based", - "Set to TRUE to use loop-based rather than chain-based scheduling", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("loop-based", "Loop-based", + "Set to TRUE to use loop-based rather than chain-based scheduling", + TRUE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SLEEP_TIME, - g_param_spec_uint ("sleep-time", "Sleep time", "Microseconds to sleep between processing", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("sleep-time", "Sleep time", + "Microseconds to sleep between processing", 0, G_MAXUINT, 0, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUPLICATE, - g_param_spec_uint ("duplicate", "Duplicate Buffers", "Push the buffers N times", - 0, G_MAXUINT, 1, G_PARAM_READWRITE)); + g_param_spec_uint ("duplicate", "Duplicate Buffers", + "Push the buffers N times", 0, G_MAXUINT, 1, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_AFTER, - g_param_spec_int ("error_after", "Error After", "Error after N buffers", - G_MININT, G_MAXINT, -1, G_PARAM_READWRITE)); + g_param_spec_int ("error_after", "Error After", "Error after N buffers", + G_MININT, G_MAXINT, -1, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DROP_PROBABILITY, - g_param_spec_float ("drop_probability", "Drop Probability", "The Probability a buffer is dropped", - 0.0, 1.0, 0.0, G_PARAM_READWRITE)); + g_param_spec_float ("drop_probability", "Drop Probability", + "The Probability a buffer is dropped", 0.0, 1.0, 0.0, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", FALSE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last-message", "last-message", "last-message", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last-message", "last-message", "last-message", NULL, + G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DUMP, - g_param_spec_boolean("dump", "Dump", "Dump buffer contents", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("dump", "Dump", "Dump buffer contents", FALSE, + G_PARAM_READWRITE)); gst_identity_signals[SIGNAL_HANDOFF] = - g_signal_new ("handoff", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL, - gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, - GST_TYPE_BUFFER); + g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL, + gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_BUFFER); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property); } -static void -gst_identity_init (GstIdentity *identity) +static void +gst_identity_init (GstIdentity * identity) { identity->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad); - gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain)); + gst_pad_set_chain_function (identity->sinkpad, + GST_DEBUG_FUNCPTR (gst_identity_chain)); gst_pad_set_link_function (identity->sinkpad, gst_pad_proxy_pad_link); gst_pad_set_getcaps_function (identity->sinkpad, gst_pad_proxy_getcaps); - + identity->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad); gst_pad_set_link_function (identity->srcpad, gst_pad_proxy_pad_link); @@ -150,8 +155,8 @@ gst_identity_init (GstIdentity *identity) identity->srccaps = NULL; } -static void -gst_identity_chain (GstPad *pad, GstData *_data) +static void +gst_identity_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstIdentity *identity; @@ -168,20 +173,20 @@ gst_identity_chain (GstPad *pad, GstData *_data) if (identity->error_after == 0) { gst_buffer_unref (buf); GST_ELEMENT_ERROR (identity, CORE, FAILED, - (_("Failed after iterations as requested.")), - (NULL)); + (_("Failed after iterations as requested.")), (NULL)); return; } } if (identity->drop_probability > 0.0) { - if ((gfloat)(1.0*rand()/(RAND_MAX)) < identity->drop_probability) { + if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) { if (identity->last_message != NULL) { g_free (identity->last_message); } - identity->last_message = g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %" - G_GINT64_FORMAT ")", - GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); + identity->last_message = + g_strdup_printf ("dropping ******* (%s:%s)i (%d bytes, %" + G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); gst_buffer_unref (buf); return; @@ -194,16 +199,17 @@ gst_identity_chain (GstPad *pad, GstData *_data) for (i = identity->duplicate; i; i--) { if (!identity->silent) { g_free (identity->last_message); - identity->last_message = g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %" - G_GINT64_FORMAT ")", - GST_DEBUG_PAD_NAME (identity->sinkpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); + identity->last_message = + g_strdup_printf ("chain ******* (%s:%s)i (%d bytes, %" + G_GINT64_FORMAT ")", GST_DEBUG_PAD_NAME (identity->sinkpad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf)); g_object_notify (G_OBJECT (identity), "last-message"); } g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0, - buf); + buf); - if (i>1) + if (i > 1) gst_buffer_ref (buf); gst_pad_push (identity->srcpad, GST_DATA (buf)); @@ -213,8 +219,8 @@ gst_identity_chain (GstPad *pad, GstData *_data) } } -static void -gst_identity_loop (GstElement *element) +static void +gst_identity_loop (GstElement * element) { GstIdentity *identity; GstBuffer *buf; @@ -223,43 +229,42 @@ gst_identity_loop (GstElement *element) g_return_if_fail (GST_IS_IDENTITY (element)); identity = GST_IDENTITY (element); - + buf = GST_BUFFER (gst_pad_pull (identity->sinkpad)); if (GST_IS_EVENT (buf)) { GstEvent *event = GST_EVENT (buf); if (GST_EVENT_IS_INTERRUPT (event)) { gst_event_unref (event); - } - else { + } else { gst_pad_event_default (identity->sinkpad, event); } - } - else { + } else { gst_identity_chain (identity->sinkpad, GST_DATA (buf)); } } -static void -gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_identity_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstIdentity *identity; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_IDENTITY (object)); - + identity = GST_IDENTITY (object); switch (prop_id) { case ARG_LOOP_BASED: identity->loop_based = g_value_get_boolean (value); if (identity->loop_based) { - gst_element_set_loop_function (GST_ELEMENT (identity), gst_identity_loop); - gst_pad_set_chain_function (identity->sinkpad, NULL); - } - else { - gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); - gst_element_set_loop_function (GST_ELEMENT (identity), NULL); + gst_element_set_loop_function (GST_ELEMENT (identity), + gst_identity_loop); + gst_pad_set_chain_function (identity->sinkpad, NULL); + } else { + gst_pad_set_chain_function (identity->sinkpad, gst_identity_chain); + gst_element_set_loop_function (GST_ELEMENT (identity), NULL); } break; case ARG_SLEEP_TIME: @@ -285,12 +290,15 @@ gst_identity_set_property (GObject *object, guint prop_id, const GValue *value, } } -static void gst_identity_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { +static void +gst_identity_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ GstIdentity *identity; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_IDENTITY (object)); - + identity = GST_IDENTITY (object); switch (prop_id) { diff --git a/plugins/elements/gstidentity.h b/plugins/elements/gstidentity.h index 00dffdfc5..36097f8d0 100644 --- a/plugins/elements/gstidentity.h +++ b/plugins/elements/gstidentity.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_IDENTITY \ (gst_identity_get_type()) #define GST_IDENTITY(obj) \ @@ -40,36 +38,36 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IDENTITY)) #define GST_IS_IDENTITY_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IDENTITY)) - typedef struct _GstIdentity GstIdentity; typedef struct _GstIdentityClass GstIdentityClass; -struct _GstIdentity { - GstElement element; - - GstPad *sinkpad; - GstPad *srcpad; - - gboolean loop_based; - guint duplicate; - gint error_after; - gfloat drop_probability; - guint sleep_time; - gboolean silent; - gboolean dump; - gchar *last_message; - GstCaps *srccaps; +struct _GstIdentity +{ + GstElement element; + + GstPad *sinkpad; + GstPad *srcpad; + + gboolean loop_based; + guint duplicate; + gint error_after; + gfloat drop_probability; + guint sleep_time; + gboolean silent; + gboolean dump; + gchar *last_message; + GstCaps *srccaps; }; -struct _GstIdentityClass { +struct _GstIdentityClass +{ GstElementClass parent_class; /* signals */ - void (*handoff) (GstElement *element, GstBuffer *buf); + void (*handoff) (GstElement * element, GstBuffer * buf); }; -GType gst_identity_get_type(void); +GType gst_identity_get_type (void); G_END_DECLS - #endif /* __GST_IDENTITY_H__ */ diff --git a/plugins/elements/gstmd5sink.c b/plugins/elements/gstmd5sink.c index a75ea075e..72e6f3b46 100644 --- a/plugins/elements/gstmd5sink.c +++ b/plugins/elements/gstmd5sink.c @@ -35,63 +35,64 @@ GST_DEBUG_CATEGORY_STATIC (gst_md5sink_debug); #define GST_CAT_DEFAULT gst_md5sink_debug -GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS ( - "MD5 Sink", - "Sink", - "compute MD5 for incoming data", - "Benjamin Otte " -); +GstElementDetails gst_md5sink_details = GST_ELEMENT_DETAILS ("MD5 Sink", + "Sink", + "compute MD5 for incoming data", + "Benjamin Otte "); /* MD5Sink signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_MD5, /* FILL ME */ }; -GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate md5_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_md5sink_debug, "md5sink", 0, "md5sink element"); -GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstMD5Sink, gst_md5sink, GstElement, GST_TYPE_ELEMENT, + _do_init); /* GObject stuff */ /*static void gst_md5sink_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);*/ -static void gst_md5sink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_md5sink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_md5sink_chain (GstPad *pad, GstData *_data); -static GstElementStateReturn gst_md5sink_change_state (GstElement *element); +static void gst_md5sink_chain (GstPad * pad, GstData * _data); +static GstElementStateReturn gst_md5sink_change_state (GstElement * element); /* MD5 stuff */ -static void md5_init_ctx (GstMD5Sink *ctx); -static gpointer md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf); -static gpointer md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf); -static void md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx); -static void md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx); +static void md5_init_ctx (GstMD5Sink * ctx); +static gpointer md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf); +static gpointer md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf); +static void md5_process_bytes (const void *buffer, size_t len, + GstMD5Sink * ctx); +static void md5_process_block (const void *buffer, size_t len, + GstMD5Sink * ctx); /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. (RFC 1321, 3.1: Step 1) */ -static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; +static const guchar fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* MD5 functions */ /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ static void -md5_init_ctx (GstMD5Sink *ctx) +md5_init_ctx (GstMD5Sink * ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; @@ -101,13 +102,14 @@ md5_init_ctx (GstMD5Sink *ctx) ctx->total[0] = ctx->total[1] = 0; ctx->buflen = 0; } + /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to RESBUF. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ static gpointer -md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf) +md5_finish_ctx (GstMD5Sink * ctx, gpointer resbuf) { /* Take yet unprocessed bytes into account. */ guint32 bytes = ctx->buflen; @@ -122,22 +124,23 @@ md5_finish_ctx (GstMD5Sink *ctx, gpointer resbuf) memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(guint32 *) &ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3); - *(guint32 *) &ctx->buffer[bytes + pad + 4] = GUINT32_TO_LE ((ctx->total[1] << 3) | - (ctx->total[0] >> 29)); + *(guint32 *) & ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3); + *(guint32 *) & ctx->buffer[bytes + pad + 4] = + GUINT32_TO_LE ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ md5_process_block (ctx->buffer, bytes + pad + 8, ctx); return md5_read_ctx (ctx, resbuf); } + /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ static gpointer -md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf) +md5_read_ctx (GstMD5Sink * ctx, gpointer resbuf) { ((guint32 *) resbuf)[0] = GUINT32_TO_LE (ctx->A); ((guint32 *) resbuf)[1] = GUINT32_TO_LE (ctx->B); @@ -148,66 +151,60 @@ md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf) } static void -md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx) +md5_process_bytes (const void *buffer, size_t len, GstMD5Sink * ctx) { /*const void aligned_buffer = buffer; */ /* When we already have some bits in our internal buffer concatenate both inputs first. */ - if (ctx->buflen != 0) - { - size_t left_over = ctx->buflen; - size_t add = 128 - left_over > len ? len : 128 - left_over; - - /* Only put full words in the buffer. */ - /* Forcing alignment here appears to be only an optimization. - * The glibc source uses __alignof__, which seems to be a - * gratuitous usage of a GCC extension, when sizeof() will - * work fine. (And don't question the sanity of using - * sizeof(guint32) instead of 4. */ - /* add -= add % __alignof__ (guint32); */ - add -= add % sizeof(guint32); - - memcpy (&ctx->buffer[left_over], buffer, add); - ctx->buflen += add; - - if (ctx->buflen > 64) - { - md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); - - ctx->buflen &= 63; - /* The regions in the following copy operation cannot overlap. */ - memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], - ctx->buflen); - } - - buffer = (const char *) buffer + add; - len -= add; + if (ctx->buflen != 0) { + size_t left_over = ctx->buflen; + size_t add = 128 - left_over > len ? len : 128 - left_over; + + /* Only put full words in the buffer. */ + /* Forcing alignment here appears to be only an optimization. + * The glibc source uses __alignof__, which seems to be a + * gratuitous usage of a GCC extension, when sizeof() will + * work fine. (And don't question the sanity of using + * sizeof(guint32) instead of 4. */ + /* add -= add % __alignof__ (guint32); */ + add -= add % sizeof (guint32); + + memcpy (&ctx->buffer[left_over], buffer, add); + ctx->buflen += add; + + if (ctx->buflen > 64) { + md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx); + + ctx->buflen &= 63; + /* The regions in the following copy operation cannot overlap. */ + memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); } + buffer = (const char *) buffer + add; + len -= add; + } + /* Process available complete blocks. */ - if (len > 64) - { - md5_process_block (buffer, len & ~63, ctx); - buffer = (const char *) buffer + (len & ~63); - len &= 63; - } + if (len > 64) { + md5_process_block (buffer, len & ~63, ctx); + buffer = (const char *) buffer + (len & ~63); + len &= 63; + } /* Move remaining bytes in internal buffer. */ - if (len > 0) - { - size_t left_over = ctx->buflen; - - memcpy (&ctx->buffer[left_over], buffer, len); - left_over += len; - if (left_over >= 64) - { - md5_process_block (ctx->buffer, 64, ctx); - left_over -= 64; - memcpy (ctx->buffer, &ctx->buffer[64], left_over); - } - ctx->buflen = left_over; + if (len > 0) { + size_t left_over = ctx->buflen; + + memcpy (&ctx->buffer[left_over], buffer, len); + left_over += len; + if (left_over >= 64) { + md5_process_block (ctx->buffer, 64, ctx); + left_over -= 64; + memcpy (ctx->buffer, &ctx->buffer[64], left_over); } + ctx->buflen = left_over; + } } @@ -223,7 +220,7 @@ md5_process_bytes (const void *buffer, size_t len, GstMD5Sink *ctx) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ static void -md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) +md5_process_block (const void *buffer, size_t len, GstMD5Sink * ctx) { guint32 correct_words[16]; const guint32 *words = buffer; @@ -243,20 +240,19 @@ md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) /* Process all bytes in the buffer with 64 bytes in each round of the loop. */ - while (words < endp) - { - guint32 *cwp = correct_words; - guint32 A_save = A; - guint32 B_save = B; - guint32 C_save = C; - guint32 D_save = D; - - /* First round: using the given function, the context and a constant - the next context is computed. Because the algorithms processing - unit is a 32-bit word and it is determined to work on words in - little endian byte order we perhaps have to change the byte order - before the computation. To reduce the work for the next steps - we store the swapped words in the array CORRECT_WORDS. */ + while (words < endp) { + guint32 *cwp = correct_words; + guint32 A_save = A; + guint32 B_save = B; + guint32 C_save = C; + guint32 D_save = D; + + /* First round: using the given function, the context and a constant + the next context is computed. Because the algorithms processing + unit is a 32-bit word and it is determined to work on words in + little endian byte order we perhaps have to change the byte order + before the computation. To reduce the work for the next steps + we store the swapped words in the array CORRECT_WORDS. */ #define OP(a, b, c, d, s, T) \ do \ @@ -268,37 +264,37 @@ md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) } \ while (0) - /* It is unfortunate that C does not provide an operator for - cyclic rotation. Hope the C compiler is smart enough. */ + /* It is unfortunate that C does not provide an operator for + cyclic rotation. Hope the C compiler is smart enough. */ #define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s))) - /* Before we start, one word to the strange constants. - They are defined in RFC 1321 as - - T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 - */ - - /* Round 1. */ - OP (A, B, C, D, 7, 0xd76aa478); - OP (D, A, B, C, 12, 0xe8c7b756); - OP (C, D, A, B, 17, 0x242070db); - OP (B, C, D, A, 22, 0xc1bdceee); - OP (A, B, C, D, 7, 0xf57c0faf); - OP (D, A, B, C, 12, 0x4787c62a); - OP (C, D, A, B, 17, 0xa8304613); - OP (B, C, D, A, 22, 0xfd469501); - OP (A, B, C, D, 7, 0x698098d8); - OP (D, A, B, C, 12, 0x8b44f7af); - OP (C, D, A, B, 17, 0xffff5bb1); - OP (B, C, D, A, 22, 0x895cd7be); - OP (A, B, C, D, 7, 0x6b901122); - OP (D, A, B, C, 12, 0xfd987193); - OP (C, D, A, B, 17, 0xa679438e); - OP (B, C, D, A, 22, 0x49b40821); - - /* For the second to fourth round we have the possibly swapped words - in CORRECT_WORDS. Redefine the macro to take an additional first - argument specifying the function to use. */ + /* Before we start, one word to the strange constants. + They are defined in RFC 1321 as + + T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64 + */ + + /* Round 1. */ + OP (A, B, C, D, 7, 0xd76aa478); + OP (D, A, B, C, 12, 0xe8c7b756); + OP (C, D, A, B, 17, 0x242070db); + OP (B, C, D, A, 22, 0xc1bdceee); + OP (A, B, C, D, 7, 0xf57c0faf); + OP (D, A, B, C, 12, 0x4787c62a); + OP (C, D, A, B, 17, 0xa8304613); + OP (B, C, D, A, 22, 0xfd469501); + OP (A, B, C, D, 7, 0x698098d8); + OP (D, A, B, C, 12, 0x8b44f7af); + OP (C, D, A, B, 17, 0xffff5bb1); + OP (B, C, D, A, 22, 0x895cd7be); + OP (A, B, C, D, 7, 0x6b901122); + OP (D, A, B, C, 12, 0xfd987193); + OP (C, D, A, B, 17, 0xa679438e); + OP (B, C, D, A, 22, 0x49b40821); + + /* For the second to fourth round we have the possibly swapped words + in CORRECT_WORDS. Redefine the macro to take an additional first + argument specifying the function to use. */ #undef OP #define OP(f, a, b, c, d, k, s, T) \ do \ @@ -309,66 +305,66 @@ md5_process_block (const void *buffer, size_t len, GstMD5Sink *ctx) } \ while (0) - /* Round 2. */ - OP (FG, A, B, C, D, 1, 5, 0xf61e2562); - OP (FG, D, A, B, C, 6, 9, 0xc040b340); - OP (FG, C, D, A, B, 11, 14, 0x265e5a51); - OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); - OP (FG, A, B, C, D, 5, 5, 0xd62f105d); - OP (FG, D, A, B, C, 10, 9, 0x02441453); - OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); - OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); - OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); - OP (FG, D, A, B, C, 14, 9, 0xc33707d6); - OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); - OP (FG, B, C, D, A, 8, 20, 0x455a14ed); - OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); - OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); - OP (FG, C, D, A, B, 7, 14, 0x676f02d9); - OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); - - /* Round 3. */ - OP (FH, A, B, C, D, 5, 4, 0xfffa3942); - OP (FH, D, A, B, C, 8, 11, 0x8771f681); - OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); - OP (FH, B, C, D, A, 14, 23, 0xfde5380c); - OP (FH, A, B, C, D, 1, 4, 0xa4beea44); - OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); - OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); - OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); - OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); - OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); - OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); - OP (FH, B, C, D, A, 6, 23, 0x04881d05); - OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); - OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); - OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); - OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); - - /* Round 4. */ - OP (FI, A, B, C, D, 0, 6, 0xf4292244); - OP (FI, D, A, B, C, 7, 10, 0x432aff97); - OP (FI, C, D, A, B, 14, 15, 0xab9423a7); - OP (FI, B, C, D, A, 5, 21, 0xfc93a039); - OP (FI, A, B, C, D, 12, 6, 0x655b59c3); - OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); - OP (FI, C, D, A, B, 10, 15, 0xffeff47d); - OP (FI, B, C, D, A, 1, 21, 0x85845dd1); - OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); - OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); - OP (FI, C, D, A, B, 6, 15, 0xa3014314); - OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); - OP (FI, A, B, C, D, 4, 6, 0xf7537e82); - OP (FI, D, A, B, C, 11, 10, 0xbd3af235); - OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); - OP (FI, B, C, D, A, 9, 21, 0xeb86d391); - - /* Add the starting values of the context. */ - A += A_save; - B += B_save; - C += C_save; - D += D_save; - } + /* Round 2. */ + OP (FG, A, B, C, D, 1, 5, 0xf61e2562); + OP (FG, D, A, B, C, 6, 9, 0xc040b340); + OP (FG, C, D, A, B, 11, 14, 0x265e5a51); + OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa); + OP (FG, A, B, C, D, 5, 5, 0xd62f105d); + OP (FG, D, A, B, C, 10, 9, 0x02441453); + OP (FG, C, D, A, B, 15, 14, 0xd8a1e681); + OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8); + OP (FG, A, B, C, D, 9, 5, 0x21e1cde6); + OP (FG, D, A, B, C, 14, 9, 0xc33707d6); + OP (FG, C, D, A, B, 3, 14, 0xf4d50d87); + OP (FG, B, C, D, A, 8, 20, 0x455a14ed); + OP (FG, A, B, C, D, 13, 5, 0xa9e3e905); + OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8); + OP (FG, C, D, A, B, 7, 14, 0x676f02d9); + OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a); + + /* Round 3. */ + OP (FH, A, B, C, D, 5, 4, 0xfffa3942); + OP (FH, D, A, B, C, 8, 11, 0x8771f681); + OP (FH, C, D, A, B, 11, 16, 0x6d9d6122); + OP (FH, B, C, D, A, 14, 23, 0xfde5380c); + OP (FH, A, B, C, D, 1, 4, 0xa4beea44); + OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9); + OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60); + OP (FH, B, C, D, A, 10, 23, 0xbebfbc70); + OP (FH, A, B, C, D, 13, 4, 0x289b7ec6); + OP (FH, D, A, B, C, 0, 11, 0xeaa127fa); + OP (FH, C, D, A, B, 3, 16, 0xd4ef3085); + OP (FH, B, C, D, A, 6, 23, 0x04881d05); + OP (FH, A, B, C, D, 9, 4, 0xd9d4d039); + OP (FH, D, A, B, C, 12, 11, 0xe6db99e5); + OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8); + OP (FH, B, C, D, A, 2, 23, 0xc4ac5665); + + /* Round 4. */ + OP (FI, A, B, C, D, 0, 6, 0xf4292244); + OP (FI, D, A, B, C, 7, 10, 0x432aff97); + OP (FI, C, D, A, B, 14, 15, 0xab9423a7); + OP (FI, B, C, D, A, 5, 21, 0xfc93a039); + OP (FI, A, B, C, D, 12, 6, 0x655b59c3); + OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92); + OP (FI, C, D, A, B, 10, 15, 0xffeff47d); + OP (FI, B, C, D, A, 1, 21, 0x85845dd1); + OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f); + OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0); + OP (FI, C, D, A, B, 6, 15, 0xa3014314); + OP (FI, B, C, D, A, 13, 21, 0x4e0811a1); + OP (FI, A, B, C, D, 4, 6, 0xf7537e82); + OP (FI, D, A, B, C, 11, 10, 0xbd3af235); + OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb); + OP (FI, B, C, D, A, 9, 21, 0xeb86d391); + + /* Add the starting values of the context. */ + A += A_save; + B += B_save; + C += C_save; + D += D_save; + } /* Put checksum in context given as argument. */ ctx->A = A; @@ -381,14 +377,14 @@ static void gst_md5sink_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_md5sink_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&md5_sink_template)); } static void -gst_md5sink_class_init (GstMD5SinkClass *klass) +gst_md5sink_class_init (GstMD5SinkClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; @@ -400,18 +396,20 @@ gst_md5sink_class_init (GstMD5SinkClass *klass) gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_md5sink_get_property); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MD5, - g_param_spec_string ("md5", "md5", "current value of the md5 sum", - "", G_PARAM_READABLE)); + g_param_spec_string ("md5", "md5", "current value of the md5 sum", + "", G_PARAM_READABLE)); - gstelement_class->change_state = GST_DEBUG_FUNCPTR(gst_md5sink_change_state); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_md5sink_change_state); } -static void -gst_md5sink_init (GstMD5Sink *md5sink) +static void +gst_md5sink_init (GstMD5Sink * md5sink) { GstPad *pad; - pad = gst_pad_new_from_template (gst_static_pad_template_get ( - &md5_sink_template), "sink"); + + pad = + gst_pad_new_from_template (gst_static_pad_template_get + (&md5_sink_template), "sink"); gst_element_add_pad (GST_ELEMENT (md5sink), pad); gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (gst_md5sink_chain)); @@ -419,15 +417,15 @@ gst_md5sink_init (GstMD5Sink *md5sink) } static GstElementStateReturn -gst_md5sink_change_state (GstElement *element) +gst_md5sink_change_state (GstElement * element) { GstMD5Sink *sink; - + /* element check */ sink = GST_MD5SINK (element); g_return_val_if_fail (GST_IS_MD5SINK (sink), GST_STATE_FAILURE); - + switch (GST_STATE_TRANSITION (element)) { case GST_STATE_READY_TO_PAUSED: md5_init_ctx (sink); @@ -440,38 +438,39 @@ gst_md5sink_change_state (GstElement *element) default: break; } - + if ((GST_ELEMENT_CLASS (parent_class)->change_state)) return GST_ELEMENT_CLASS (parent_class)->change_state (element); - + return GST_STATE_SUCCESS; } -static void -gst_md5sink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static void +gst_md5sink_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstMD5Sink *sink; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_MD5SINK (object)); - + sink = GST_MD5SINK (object); - + switch (prop_id) { case ARG_MD5: - { - /* you could actually get a value for the current md5. - * This is currently disabled. - * md5_read_ctx (sink, sink->md5); */ - /* md5 is a guchar[16] */ - int i; - guchar *md5string = g_malloc0 (33); - - for (i = 0; i < 16; ++i) - sprintf (md5string + i * 2, "%02x", sink->md5[i]); - g_value_set_string (value, md5string); - g_free (md5string); - } + { + /* you could actually get a value for the current md5. + * This is currently disabled. + * md5_read_ctx (sink, sink->md5); */ + /* md5 is a guchar[16] */ + int i; + guchar *md5string = g_malloc0 (33); + + for (i = 0; i < 16; ++i) + sprintf (md5string + i * 2, "%02x", sink->md5[i]); + g_value_set_string (value, md5string); + g_free (md5string); + } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -479,8 +478,8 @@ gst_md5sink_get_property (GObject *object, guint prop_id, GValue *value, GParamS } } -static void -gst_md5sink_chain (GstPad *pad, GstData *_data) +static void +gst_md5sink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstMD5Sink *md5sink; @@ -491,11 +490,9 @@ gst_md5sink_chain (GstPad *pad, GstData *_data) md5sink = GST_MD5SINK (gst_pad_get_parent (pad)); - if (GST_IS_BUFFER (buf)) - { + if (GST_IS_BUFFER (buf)) { md5_process_bytes (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), md5sink); } - + gst_buffer_unref (buf); } - diff --git a/plugins/elements/gstmd5sink.h b/plugins/elements/gstmd5sink.h index fc847b2a2..8a35d1a41 100644 --- a/plugins/elements/gstmd5sink.h +++ b/plugins/elements/gstmd5sink.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_MD5SINK \ (gst_md5sink_get_type()) #define GST_MD5SINK(obj) \ @@ -40,11 +38,11 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MD5SINK)) #define GST_IS_MD5SINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MD5SINK)) - typedef struct _GstMD5Sink GstMD5Sink; typedef struct _GstMD5SinkClass GstMD5SinkClass; -struct _GstMD5Sink { +struct _GstMD5Sink +{ GstElement element; /* md5 information */ @@ -56,21 +54,21 @@ struct _GstMD5Sink { guint32 total[2]; guint32 buflen; gchar buffer[128]; - + /* latest md5 */ guchar md5[16]; - + }; -struct _GstMD5SinkClass { +struct _GstMD5SinkClass +{ GstElementClass parent_class; }; -GType gst_md5sink_get_type (void); +GType gst_md5sink_get_type (void); -gboolean gst_md5sink_factory_init (GstElementFactory *factory); +gboolean gst_md5sink_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_MD5SINK_H__ */ diff --git a/plugins/elements/gstmultifilesrc.c b/plugins/elements/gstmultifilesrc.c index b24fca98f..d819c3e4e 100644 --- a/plugins/elements/gstmultifilesrc.c +++ b/plugins/elements/gstmultifilesrc.c @@ -40,20 +40,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_multifilesrc_debug); #define GST_CAT_DEFAULT gst_multifilesrc_debug -GstElementDetails gst_multifilesrc_details = GST_ELEMENT_DETAILS ( - "Multi File Source", - "Source/File", - "Read from multiple files in order", - "Dominic Ludlam " -); +GstElementDetails gst_multifilesrc_details = +GST_ELEMENT_DETAILS ("Multi File Source", + "Source/File", + "Read from multiple files in order", + "Dominic Ludlam "); /* FileSrc signals and args */ -enum { +enum +{ NEW_FILE, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_LOCATIONS }; @@ -61,18 +62,24 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_multifilesrc_debug, "multifilesrc", 0, "multifilesrc element"); -GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstMultiFileSrc, gst_multifilesrc, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_multifilesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_multifilesrc_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static GstData *gst_multifilesrc_get (GstPad * pad); -static GstData * gst_multifilesrc_get (GstPad *pad); /*static GstBuffer * gst_multifilesrc_get_region (GstPad *pad,GstRegionType type,guint64 offset,guint64 len);*/ -static GstElementStateReturn gst_multifilesrc_change_state (GstElement *element); +static GstElementStateReturn gst_multifilesrc_change_state (GstElement * + element); -static gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad); -static void gst_multifilesrc_close_file (GstMultiFileSrc *src); +static gboolean gst_multifilesrc_open_file (GstMultiFileSrc * src, + GstPad * srcpad); +static void gst_multifilesrc_close_file (GstMultiFileSrc * src); static guint gst_multifilesrc_signals[LAST_SIGNAL] = { 0 }; @@ -80,28 +87,25 @@ static void gst_multifilesrc_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_multifilesrc_details); } static void -gst_multifilesrc_class_init (GstMultiFileSrcClass *klass) +gst_multifilesrc_class_init (GstMultiFileSrcClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; gst_multifilesrc_signals[NEW_FILE] = - g_signal_new ("new-file", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, - g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, - G_TYPE_STRING); + g_signal_new ("new-file", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstMultiFileSrcClass, new_file), NULL, NULL, + g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_LOCATIONS, - g_param_spec_pointer("locations","locations","locations", - G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LOCATIONS, g_param_spec_pointer ("locations", "locations", "locations", G_PARAM_READWRITE)); /* CHECKME */ gobject_class->set_property = gst_multifilesrc_set_property; gobject_class->get_property = gst_multifilesrc_get_property; @@ -110,12 +114,12 @@ gst_multifilesrc_class_init (GstMultiFileSrcClass *klass) } static void -gst_multifilesrc_init (GstMultiFileSrc *multifilesrc) +gst_multifilesrc_init (GstMultiFileSrc * multifilesrc) { /* GST_FLAG_SET (filesrc, GST_SRC_); */ multifilesrc->srcpad = gst_pad_new ("src", GST_PAD_SRC); - gst_pad_set_get_function (multifilesrc->srcpad,gst_multifilesrc_get); + gst_pad_set_get_function (multifilesrc->srcpad, gst_multifilesrc_get); /* gst_pad_set_getregion_function (multifilesrc->srcpad,gst_multifilesrc_get_region); */ gst_element_add_pad (GST_ELEMENT (multifilesrc), multifilesrc->srcpad); @@ -128,7 +132,8 @@ gst_multifilesrc_init (GstMultiFileSrc *multifilesrc) } static void -gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_multifilesrc_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstMultiFileSrc *src; @@ -144,11 +149,11 @@ gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *val /* clear the filename if we get a NULL */ if (g_value_get_pointer (value) == NULL) { - gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); - src->listptr = NULL; - /* otherwise set the new filenames */ + gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); + src->listptr = NULL; + /* otherwise set the new filenames */ } else { - src->listptr = g_value_get_pointer (value); + src->listptr = g_value_get_pointer (value); } break; default: @@ -157,7 +162,8 @@ gst_multifilesrc_set_property (GObject *object, guint prop_id, const GValue *val } static void -gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_multifilesrc_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstMultiFileSrc *src; @@ -183,7 +189,7 @@ gst_multifilesrc_get_property (GObject *object, guint prop_id, GValue *value, GP * Push a new buffer from the filesrc at the current offset. */ static GstData * -gst_multifilesrc_get (GstPad *pad) +gst_multifilesrc_get (GstPad * pad) { GstMultiFileSrc *src; GstBuffer *buf; @@ -193,7 +199,7 @@ gst_multifilesrc_get (GstPad *pad) src = GST_MULTIFILESRC (gst_pad_get_parent (pad)); if (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN)) - gst_multifilesrc_close_file(src); + gst_multifilesrc_close_file (src); if (!src->listptr) { return GST_DATA (gst_event_new (GST_EVENT_EOS)); @@ -203,11 +209,11 @@ gst_multifilesrc_get (GstPad *pad) src->currentfilename = (gchar *) list->data; src->listptr = src->listptr->next; - if (!gst_multifilesrc_open_file(src, pad)) - return NULL; + if (!gst_multifilesrc_open_file (src, pad)) + return NULL; - /* emitted after the open, as the user may free the list and string from here*/ - g_signal_emit(G_OBJECT(src), gst_multifilesrc_signals[NEW_FILE], 0, list); + /* emitted after the open, as the user may free the list and string from here */ + g_signal_emit (G_OBJECT (src), gst_multifilesrc_signals[NEW_FILE], 0, list); /* create the buffer */ /* FIXME: should eventually use a bufferpool for this */ @@ -231,24 +237,23 @@ gst_multifilesrc_get (GstPad *pad) } /* open the file and mmap it, necessary to go to READY state */ -static -gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad) +static gboolean +gst_multifilesrc_open_file (GstMultiFileSrc * src, GstPad * srcpad) { g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN), FALSE); - if (src->currentfilename == NULL || src->currentfilename[0] == '\0') - { + if (src->currentfilename == NULL || src->currentfilename[0] == '\0') { GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, - (_("No file name specified for reading.")), (NULL)); + (_("No file name specified for reading.")), (NULL)); return FALSE; } /* open the file */ src->fd = open ((const char *) src->currentfilename, O_RDONLY); if (src->fd < 0) { - GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, - (_("Could not open file \"%s\" for reading."), src->currentfilename), - GST_ERROR_SYSTEM); + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, + (_("Could not open file \"%s\" for reading."), src->currentfilename), + GST_ERROR_SYSTEM); return FALSE; } else { @@ -257,12 +262,12 @@ gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad) lseek (src->fd, 0, SEEK_SET); /* map the file into memory */ src->map = mmap (NULL, src->size, PROT_READ, MAP_SHARED, src->fd, 0); - madvise (src->map,src->size, 2); + madvise (src->map, src->size, 2); /* collapse state if that failed */ if (src->map == NULL) { close (src->fd); GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), - ("mmap call failed.")); + ("mmap call failed.")); return FALSE; } GST_FLAG_SET (src, GST_MULTIFILESRC_OPEN); @@ -273,7 +278,7 @@ gboolean gst_multifilesrc_open_file (GstMultiFileSrc *src, GstPad *srcpad) /* unmap and close the file */ static void -gst_multifilesrc_close_file (GstMultiFileSrc *src) +gst_multifilesrc_close_file (GstMultiFileSrc * src) { g_return_if_fail (GST_FLAG_IS_SET (src, GST_MULTIFILESRC_OPEN)); @@ -291,7 +296,7 @@ gst_multifilesrc_close_file (GstMultiFileSrc *src) } static GstElementStateReturn -gst_multifilesrc_change_state (GstElement *element) +gst_multifilesrc_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_MULTIFILESRC (element), GST_STATE_FAILURE); diff --git a/plugins/elements/gstmultifilesrc.h b/plugins/elements/gstmultifilesrc.h index 6e1b6eba2..463123b5d 100644 --- a/plugins/elements/gstmultifilesrc.h +++ b/plugins/elements/gstmultifilesrc.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_MULTIFILESRC \ (gst_multifilesrc_get_type()) #define GST_MULTIFILESRC(obj) \ @@ -39,41 +37,42 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIFILESRC)) #define GST_IS_MULTIFILESRC_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIFILESRC)) + typedef enum +{ + GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST, -typedef enum { - GST_MULTIFILESRC_OPEN = GST_ELEMENT_FLAG_LAST, - - GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 + GST_MULTIFILESRC_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstMultiFileSrcFlags; typedef struct _GstMultiFileSrc GstMultiFileSrc; typedef struct _GstMultiFileSrcClass GstMultiFileSrcClass; -struct _GstMultiFileSrc { +struct _GstMultiFileSrc +{ GstElement element; /* pads */ GstPad *srcpad; /* current file details */ - gchar *currentfilename; + gchar *currentfilename; GSList *listptr; /* mapping parameters */ gint fd; - gulong size; /* how long is the file? */ - guchar *map; /* where the file is mapped to */ + gulong size; /* how long is the file? */ + guchar *map; /* where the file is mapped to */ gboolean new_seek; }; -struct _GstMultiFileSrcClass { +struct _GstMultiFileSrcClass +{ GstElementClass parent_class; - void (*new_file) (GstMultiFileSrc *multifilesrc, gchar *newfilename); + void (*new_file) (GstMultiFileSrc * multifilesrc, gchar * newfilename); }; -GType gst_multifilesrc_get_type(void); +GType gst_multifilesrc_get_type (void); G_END_DECLS - #endif /* __GST_MULTIFILESRC_H__ */ diff --git a/plugins/elements/gstpipefilter.c b/plugins/elements/gstpipefilter.c index 1dfc1c384..0ba8bfc9d 100644 --- a/plugins/elements/gstpipefilter.c +++ b/plugins/elements/gstpipefilter.c @@ -40,22 +40,22 @@ GST_DEBUG_CATEGORY_STATIC (gst_pipefilter_debug); #define GST_CAT_DEFAULT gst_pipefilter_debug -GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS ( - "Pipefilter", - "Filter", - "Interoperate with an external program using stdin and stdout", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_pipefilter_details = GST_ELEMENT_DETAILS ("Pipefilter", + "Filter", + "Interoperate with an external program using stdin and stdout", + "Erik Walthinsen , " + "Wim Taymans "); /* Pipefilter signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_COMMAND }; @@ -64,46 +64,47 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_pipefilter_debug, "pipefilter", 0, "pipefilter element"); -GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstPipefilter, gst_pipefilter, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_pipefilter_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_pipefilter_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstData* gst_pipefilter_get (GstPad *pad); -static void gst_pipefilter_chain (GstPad *pad, GstData *_data); -static gboolean gst_pipefilter_handle_event (GstPad *pad, GstEvent *event); +static GstData *gst_pipefilter_get (GstPad * pad); +static void gst_pipefilter_chain (GstPad * pad, GstData * _data); +static gboolean gst_pipefilter_handle_event (GstPad * pad, GstEvent * event); -static GstElementStateReturn gst_pipefilter_change_state (GstElement *element); +static GstElementStateReturn gst_pipefilter_change_state (GstElement * element); static void gst_pipefilter_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_pipefilter_details); } -static void -gst_pipefilter_class_init (GstPipefilterClass *klass) +static void +gst_pipefilter_class_init (GstPipefilterClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; - gobject_class->set_property = gst_pipefilter_set_property; + gobject_class->set_property = gst_pipefilter_set_property; gobject_class->get_property = gst_pipefilter_get_property; - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_COMMAND, - g_param_spec_string("command","command","command", - NULL, G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COMMAND, g_param_spec_string ("command", "command", "command", NULL, G_PARAM_READWRITE)); /* CHECKME */ gstelement_class->change_state = gst_pipefilter_change_state; } static void -gst_pipefilter_init (GstPipefilter *pipefilter) +gst_pipefilter_init (GstPipefilter * pipefilter) { GST_FLAG_SET (pipefilter, GST_ELEMENT_DECOUPLED); @@ -122,7 +123,7 @@ gst_pipefilter_init (GstPipefilter *pipefilter) } static gboolean -gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) +gst_pipefilter_handle_event (GstPad * pad, GstEvent * event) { GstPipefilter *pipefilter; @@ -133,9 +134,9 @@ gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: if (close (pipefilter->fdin[1]) < 0) - perror("close"); + perror ("close"); if (close (pipefilter->fdout[0]) < 0) - perror("close"); + perror ("close"); break; default: break; @@ -146,8 +147,8 @@ gst_pipefilter_handle_event (GstPad *pad, GstEvent *event) return TRUE; } -static GstData* -gst_pipefilter_get (GstPad *pad) +static GstData * +gst_pipefilter_get (GstPad * pad) { GstPipefilter *pipefilter; GstBuffer *newbuf; @@ -157,16 +158,18 @@ gst_pipefilter_get (GstPad *pad) /* create the buffer */ /* FIXME: should eventually use a bufferpool for this */ - newbuf = gst_buffer_new(); - g_return_val_if_fail(newbuf, NULL); + newbuf = gst_buffer_new (); + g_return_val_if_fail (newbuf, NULL); /* allocate the space for the buffer data */ - GST_BUFFER_DATA(newbuf) = g_malloc(pipefilter->bytes_per_read); - g_return_val_if_fail(GST_BUFFER_DATA(newbuf) != NULL, NULL); + GST_BUFFER_DATA (newbuf) = g_malloc (pipefilter->bytes_per_read); + g_return_val_if_fail (GST_BUFFER_DATA (newbuf) != NULL, NULL); /* read it in from the file */ GST_DEBUG ("attemting to read %ld bytes", pipefilter->bytes_per_read); - readbytes = read(pipefilter->fdout[0], GST_BUFFER_DATA(newbuf), pipefilter->bytes_per_read); + readbytes = + read (pipefilter->fdout[0], GST_BUFFER_DATA (newbuf), + pipefilter->bytes_per_read); GST_DEBUG ("read %ld bytes", readbytes); if (readbytes < 0) { GST_ELEMENT_ERROR (pipefilter, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM); @@ -178,15 +181,15 @@ gst_pipefilter_get (GstPad *pad) } - GST_BUFFER_OFFSET(newbuf) = pipefilter->curoffset; - GST_BUFFER_SIZE(newbuf) = readbytes; + GST_BUFFER_OFFSET (newbuf) = pipefilter->curoffset; + GST_BUFFER_SIZE (newbuf) = readbytes; pipefilter->curoffset += readbytes; return GST_DATA (newbuf); } static void -gst_pipefilter_chain (GstPad *pad,GstData *_data) +gst_pipefilter_chain (GstPad * pad, GstData * _data) { GstBuffer *buf; GstPipefilter *pipefilter; @@ -194,8 +197,8 @@ gst_pipefilter_chain (GstPad *pad,GstData *_data) guchar *data; gulong size; - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); if (GST_IS_EVENT (_data)) { gst_pipefilter_handle_event (pad, GST_EVENT (_data)); @@ -205,32 +208,33 @@ gst_pipefilter_chain (GstPad *pad,GstData *_data) pipefilter = GST_PIPEFILTER (gst_pad_get_parent (pad)); buf = GST_BUFFER (_data); - data = GST_BUFFER_DATA(buf); - size = GST_BUFFER_SIZE(buf); + data = GST_BUFFER_DATA (buf); + size = GST_BUFFER_SIZE (buf); GST_DEBUG ("attemting to write %ld bytes", size); - writebytes = write(pipefilter->fdin[1],data,size); + writebytes = write (pipefilter->fdin[1], data, size); GST_DEBUG ("written %ld bytes", writebytes); if (writebytes < 0) { GST_ELEMENT_ERROR (pipefilter, RESOURCE, WRITE, (NULL), GST_ERROR_SYSTEM); return; } - gst_buffer_unref(buf); + gst_buffer_unref (buf); } static void -gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_pipefilter_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstPipefilter *pipefilter; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_PIPEFILTER(object)); - pipefilter = GST_PIPEFILTER(object); + g_return_if_fail (GST_IS_PIPEFILTER (object)); + pipefilter = GST_PIPEFILTER (object); switch (prop_id) { case ARG_COMMAND: - pipefilter->orig_command = g_strdup(g_value_get_string (value)); - pipefilter->command = g_strsplit(g_value_get_string (value), " ", 0); + pipefilter->orig_command = g_strdup (g_value_get_string (value)); + pipefilter->command = g_strsplit (g_value_get_string (value), " ", 0); break; default: break; @@ -238,13 +242,14 @@ gst_pipefilter_set_property (GObject *object, guint prop_id, const GValue *value } static void -gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_pipefilter_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstPipefilter *pipefilter; /* it's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_PIPEFILTER(object)); - pipefilter = GST_PIPEFILTER(object); + g_return_if_fail (GST_IS_PIPEFILTER (object)); + pipefilter = GST_PIPEFILTER (object); switch (prop_id) { case ARG_COMMAND: @@ -258,78 +263,75 @@ gst_pipefilter_get_property (GObject *object, guint prop_id, GValue *value, GPar /* open the file, necessary to go to RUNNING state */ static gboolean -gst_pipefilter_open_file (GstPipefilter *src) +gst_pipefilter_open_file (GstPipefilter * src) { - g_return_val_if_fail(!GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN), FALSE); - pipe(src->fdin); - pipe(src->fdout); + pipe (src->fdin); + pipe (src->fdout); - if((src->childpid = fork()) == -1) - { + if ((src->childpid = fork ()) == -1) { GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM); return FALSE; } - if(src->childpid == 0) - { - close(src->fdin[1]); - close(src->fdout[0]); + if (src->childpid == 0) { + close (src->fdin[1]); + close (src->fdout[0]); /* child */ - dup2(src->fdin[0], STDIN_FILENO); /* set the childs input stream */ - dup2(src->fdout[1], STDOUT_FILENO); /* set the childs output stream */ - execvp(src->command[0], &src->command[0]); + dup2 (src->fdin[0], STDIN_FILENO); /* set the childs input stream */ + dup2 (src->fdout[1], STDOUT_FILENO); /* set the childs output stream */ + execvp (src->command[0], &src->command[0]); /* will only be reached if execvp has an error */ GST_ELEMENT_ERROR (src, RESOURCE, TOO_LAZY, (NULL), GST_ERROR_SYSTEM); return FALSE; - - } - else { - close(src->fdin[0]); - close(src->fdout[1]); + + } else { + close (src->fdin[0]); + close (src->fdout[1]); } - - GST_FLAG_SET(src,GST_PIPEFILTER_OPEN); + + GST_FLAG_SET (src, GST_PIPEFILTER_OPEN); return TRUE; } /* close the file */ static void -gst_pipefilter_close_file (GstPipefilter *src) +gst_pipefilter_close_file (GstPipefilter * src) { - g_return_if_fail(GST_FLAG_IS_SET(src,GST_PIPEFILTER_OPEN)); + g_return_if_fail (GST_FLAG_IS_SET (src, GST_PIPEFILTER_OPEN)); /* close the file */ - close(src->fdout[0]); - close(src->fdout[1]); - close(src->fdin[0]); - close(src->fdin[1]); + close (src->fdout[0]); + close (src->fdout[1]); + close (src->fdin[0]); + close (src->fdin[1]); /* zero out a lot of our state */ src->curoffset = 0; src->seq = 0; - GST_FLAG_UNSET(src,GST_PIPEFILTER_OPEN); + GST_FLAG_UNSET (src, GST_PIPEFILTER_OPEN); } static GstElementStateReturn -gst_pipefilter_change_state (GstElement *element) +gst_pipefilter_change_state (GstElement * element) { - g_return_val_if_fail(GST_IS_PIPEFILTER(element), FALSE); + g_return_val_if_fail (GST_IS_PIPEFILTER (element), FALSE); - /* if going down into NULL state, close the file if it's open */ - if (GST_STATE_PENDING(element) == GST_STATE_NULL) { - if (GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN)) - gst_pipefilter_close_file(GST_PIPEFILTER(element)); - /* otherwise (READY or higher) we need to open the file */ + /* if going down into NULL state, close the file if it's open */ + if (GST_STATE_PENDING (element) == GST_STATE_NULL) { + if (GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) + gst_pipefilter_close_file (GST_PIPEFILTER (element)); + /* otherwise (READY or higher) we need to open the file */ } else { - if (!GST_FLAG_IS_SET(element,GST_PIPEFILTER_OPEN)) { - if (!gst_pipefilter_open_file(GST_PIPEFILTER(element))) - return GST_STATE_FAILURE; + if (!GST_FLAG_IS_SET (element, GST_PIPEFILTER_OPEN)) { + if (!gst_pipefilter_open_file (GST_PIPEFILTER (element))) + return GST_STATE_FAILURE; } } - - if (GST_ELEMENT_CLASS(parent_class)->change_state) - return GST_ELEMENT_CLASS(parent_class)->change_state(element); + + if (GST_ELEMENT_CLASS (parent_class)->change_state) + return GST_ELEMENT_CLASS (parent_class)->change_state (element); return GST_STATE_SUCCESS; } diff --git a/plugins/elements/gstpipefilter.h b/plugins/elements/gstpipefilter.h index 08c3a4718..73af81f78 100644 --- a/plugins/elements/gstpipefilter.h +++ b/plugins/elements/gstpipefilter.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_PIPEFILTER \ (gst_pipefilter_get_type()) #define GST_PIPEFILTER(obj) \ @@ -40,17 +38,18 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PIPEFILTER)) #define GST_IS_PIPEFILTER_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PIPEFILTER)) + typedef enum +{ + GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST, -typedef enum { - GST_PIPEFILTER_OPEN = GST_ELEMENT_FLAG_LAST, - - GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 + GST_PIPEFILTER_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2 } GstPipeFilterFlags; typedef struct _GstPipefilter GstPipefilter; typedef struct _GstPipefilterClass GstPipefilterClass; -struct _GstPipefilter { +struct _GstPipefilter +{ GstElement element; GstPad *sinkpad; @@ -62,20 +61,20 @@ struct _GstPipefilter { /* fd */ gint fdout[2]; gint fdin[2]; - pid_t childpid; + pid_t childpid; - gulong curoffset; /* current offset in file */ - gulong bytes_per_read; /* bytes per read */ + gulong curoffset; /* current offset in file */ + gulong bytes_per_read; /* bytes per read */ - gulong seq; /* buffer sequence number */ + gulong seq; /* buffer sequence number */ }; -struct _GstPipefilterClass { +struct _GstPipefilterClass +{ GstElementClass parent_class; }; -GType gst_pipefilter_get_type(void); +GType gst_pipefilter_get_type (void); G_END_DECLS - #endif /* __GST_PIPEFILTER_H__ */ diff --git a/plugins/elements/gstqueue.c b/plugins/elements/gstqueue.c index 8dfd62f4d..03f1131c9 100644 --- a/plugins/elements/gstqueue.c +++ b/plugins/elements/gstqueue.c @@ -30,23 +30,23 @@ #include "gstinfo.h" #include "gsterror.h" -static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ( - "Queue", - "Generic", - "Simple data queue", - "Erik Walthinsen " -); +static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ("Queue", + "Generic", + "Simple data queue", + "Erik Walthinsen "); /* Queue signals and args */ -enum { +enum +{ SIGNAL_UNDERRUN, SIGNAL_RUNNING, SIGNAL_OVERRUN, LAST_SIGNAL }; -enum { +enum +{ ARG_0, /* FIXME: don't we have another way of doing this * "Gstreamer format" (frame/byte/time) queries? */ @@ -62,46 +62,38 @@ enum { ARG_LEAKY, ARG_MAY_DEADLOCK, ARG_BLOCK_TIMEOUT - /* FILL ME */ + /* FILL ME */ }; -typedef struct _GstQueueEventResponse { +typedef struct _GstQueueEventResponse +{ GstEvent *event; gboolean ret, handled; } GstQueueEventResponse; -static void gst_queue_base_init (GstQueueClass *klass); -static void gst_queue_class_init (GstQueueClass *klass); -static void gst_queue_init (GstQueue *queue); -static void gst_queue_dispose (GObject *object); - -static void gst_queue_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gst_queue_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gst_queue_chain (GstPad *pad, - GstData *data); -static GstData *gst_queue_get (GstPad *pad); - -static gboolean gst_queue_handle_src_event (GstPad *pad, - GstEvent *event); - -static GstCaps *gst_queue_getcaps (GstPad *pad); -static GstPadLinkReturn - gst_queue_link (GstPad *pad, - const GstCaps *caps); -static void gst_queue_locked_flush (GstQueue *queue); +static void gst_queue_base_init (GstQueueClass * klass); +static void gst_queue_class_init (GstQueueClass * klass); +static void gst_queue_init (GstQueue * queue); +static void gst_queue_dispose (GObject * object); + +static void gst_queue_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void gst_queue_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); + +static void gst_queue_chain (GstPad * pad, GstData * data); +static GstData *gst_queue_get (GstPad * pad); + +static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event); + +static GstCaps *gst_queue_getcaps (GstPad * pad); +static GstPadLinkReturn gst_queue_link (GstPad * pad, const GstCaps * caps); +static void gst_queue_locked_flush (GstQueue * queue); + +static GstElementStateReturn gst_queue_change_state (GstElement * element); +static gboolean gst_queue_release_locks (GstElement * element); -static GstElementStateReturn - gst_queue_change_state (GstElement *element); -static gboolean gst_queue_release_locks (GstElement *element); - #define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ()) static GType @@ -109,13 +101,13 @@ queue_leaky_get_type (void) { static GType queue_leaky_type = 0; static GEnumValue queue_leaky[] = { - { GST_QUEUE_NO_LEAK, "0", "Not Leaky" }, - { GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream" }, - { GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream" }, - { 0, NULL, NULL }, + {GST_QUEUE_NO_LEAK, "0", "Not Leaky"}, + {GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream"}, + {GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"}, + {0, NULL, NULL}, }; if (!queue_leaky_type) { - queue_leaky_type = g_enum_register_static("GstQueueLeaky", queue_leaky); + queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky); } return queue_leaky_type; } @@ -124,7 +116,7 @@ static GstElementClass *parent_class = NULL; static guint gst_queue_signals[LAST_SIGNAL] = { 0 }; GType -gst_queue_get_type (void) +gst_queue_get_type (void) { static GType queue_type = 0; @@ -143,14 +135,14 @@ gst_queue_get_type (void) }; queue_type = g_type_register_static (GST_TYPE_ELEMENT, - "GstQueue", &queue_info, 0); + "GstQueue", &queue_info, 0); } return queue_type; } static void -gst_queue_base_init (GstQueueClass *klass) +gst_queue_base_init (GstQueueClass * klass) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); @@ -158,7 +150,7 @@ gst_queue_base_init (GstQueueClass *klass) } static void -gst_queue_class_init (GstQueueClass *klass) +gst_queue_class_init (GstQueueClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); @@ -167,112 +159,117 @@ gst_queue_class_init (GstQueueClass *klass) /* signals */ gst_queue_signals[SIGNAL_UNDERRUN] = - g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gst_queue_signals[SIGNAL_RUNNING] = - g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gst_queue_signals[SIGNAL_OVERRUN] = - g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /* properties */ g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES, - g_param_spec_uint ("current-level-bytes", "Current level (kB)", - "Current amount of data in the queue (bytes)", - 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_param_spec_uint ("current-level-bytes", "Current level (kB)", + "Current amount of data in the queue (bytes)", + 0, G_MAXUINT, 0, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS, - g_param_spec_uint ("current-level-buffers", "Current level (buffers)", - "Current number of buffers in the queue", - 0, G_MAXUINT, 0, G_PARAM_READABLE)); + g_param_spec_uint ("current-level-buffers", "Current level (buffers)", + "Current number of buffers in the queue", + 0, G_MAXUINT, 0, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME, - g_param_spec_uint64 ("current-level-time", "Current level (ns)", - "Current amount of data in the queue (in ns)", - 0, G_MAXUINT64, 0, G_PARAM_READABLE)); + g_param_spec_uint64 ("current-level-time", "Current level (ns)", + "Current amount of data in the queue (in ns)", + 0, G_MAXUINT64, 0, G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES, - g_param_spec_uint ("max-size-bytes", "Max. size (kB)", - "Max. amount of data in the queue (bytes, 0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("max-size-bytes", "Max. size (kB)", + "Max. amount of data in the queue (bytes, 0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS, - g_param_spec_uint ("max-size-buffers", "Max. size (buffers)", - "Max. number of buffers in the queue (0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("max-size-buffers", "Max. size (buffers)", + "Max. number of buffers in the queue (0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME, - g_param_spec_uint64 ("max-size-time", "Max. size (ns)", - "Max. amount of data in the queue (in ns, 0=disable)", - 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); + g_param_spec_uint64 ("max-size-time", "Max. size (ns)", + "Max. amount of data in the queue (in ns, 0=disable)", + 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES, - g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)", - "Min. amount of data in the queue to allow reading (bytes, 0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)", + "Min. amount of data in the queue to allow reading (bytes, 0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS, - g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)", - "Min. number of buffers in the queue to allow reading (0=disable)", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)", + "Min. number of buffers in the queue to allow reading (0=disable)", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME, - g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)", - "Min. amount of data in the queue to allow reading (in ns, 0=disable)", - 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); + g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)", + "Min. amount of data in the queue to allow reading (in ns, 0=disable)", + 0, G_MAXUINT64, 0, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_LEAKY, - g_param_spec_enum ("leaky", "Leaky", - "Where the queue leaks, if at all", - GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE)); + g_param_spec_enum ("leaky", "Leaky", + "Where the queue leaks, if at all", + GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK, - g_param_spec_boolean ("may_deadlock", "May Deadlock", - "The queue may deadlock if it's full and not PLAYING", - TRUE, G_PARAM_READWRITE)); + g_param_spec_boolean ("may_deadlock", "May Deadlock", + "The queue may deadlock if it's full and not PLAYING", + TRUE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT, - g_param_spec_uint64 ("block_timeout", "Timeout for Block", - "Nanoseconds until blocked queue times out and returns filler event. " - "Value of -1 disables timeout", - 0, G_MAXUINT64, -1, G_PARAM_READWRITE)); + g_param_spec_uint64 ("block_timeout", "Timeout for Block", + "Nanoseconds until blocked queue times out and returns filler event. " + "Value of -1 disables timeout", + 0, G_MAXUINT64, -1, G_PARAM_READWRITE)); /* set several parent class virtual functions */ - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_queue_dispose); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property); - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state); + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state); gstelement_class->release_locks = GST_DEBUG_FUNCPTR (gst_queue_release_locks); } static void -gst_queue_init (GstQueue *queue) +gst_queue_init (GstQueue * queue) { /* scheduling on this kind of element is, well, interesting */ GST_FLAG_SET (queue, GST_ELEMENT_DECOUPLED); GST_FLAG_SET (queue, GST_ELEMENT_EVENT_AWARE); queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); - gst_pad_set_chain_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_chain)); + gst_pad_set_chain_function (queue->sinkpad, + GST_DEBUG_FUNCPTR (gst_queue_chain)); gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad); - gst_pad_set_link_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_link)); - gst_pad_set_getcaps_function (queue->sinkpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps)); + gst_pad_set_link_function (queue->sinkpad, + GST_DEBUG_FUNCPTR (gst_queue_link)); + gst_pad_set_getcaps_function (queue->sinkpad, + GST_DEBUG_FUNCPTR (gst_queue_getcaps)); gst_pad_set_active (queue->sinkpad, TRUE); queue->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_pad_set_get_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_get)); gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad); gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_link)); - gst_pad_set_getcaps_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_getcaps)); - gst_pad_set_event_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); + gst_pad_set_getcaps_function (queue->srcpad, + GST_DEBUG_FUNCPTR (gst_queue_getcaps)); + gst_pad_set_event_function (queue->srcpad, + GST_DEBUG_FUNCPTR (gst_queue_handle_src_event)); gst_pad_set_active (queue->srcpad, TRUE); - queue->cur_level.buffers = 0; /* no content */ - queue->cur_level.bytes = 0; /* no content */ - queue->cur_level.time = 0; /* no content */ - queue->max_size.buffers = 100; /* 100 buffers */ - queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */ - queue->max_size.time = GST_SECOND; /* 1 s. */ - queue->min_threshold.buffers = 0; /* no threshold */ - queue->min_threshold.bytes = 0; /* no threshold */ - queue->min_threshold.time = 0; /* no threshold */ + queue->cur_level.buffers = 0; /* no content */ + queue->cur_level.bytes = 0; /* no content */ + queue->cur_level.time = 0; /* no content */ + queue->max_size.buffers = 100; /* 100 buffers */ + queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */ + queue->max_size.time = GST_SECOND; /* 1 s. */ + queue->min_threshold.buffers = 0; /* no threshold */ + queue->min_threshold.bytes = 0; /* no threshold */ + queue->min_threshold.time = 0; /* no threshold */ queue->leaky = GST_QUEUE_NO_LEAK; queue->may_deadlock = TRUE; @@ -288,11 +285,11 @@ gst_queue_init (GstQueue *queue) queue->queue = g_queue_new (); GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue, - "initialized queue's not_empty & not_full conditions"); + "initialized queue's not_empty & not_full conditions"); } static void -gst_queue_dispose (GObject *object) +gst_queue_dispose (GObject * object) { GstQueue *queue = GST_QUEUE (object); @@ -300,6 +297,7 @@ gst_queue_dispose (GObject *object) while (!g_queue_is_empty (queue->queue)) { GstData *data = g_queue_pop_head (queue->queue); + gst_data_unref (data); } g_queue_free (queue->queue); @@ -309,6 +307,7 @@ gst_queue_dispose (GObject *object) g_cond_free (queue->event_done); while (!g_queue_is_empty (queue->events)) { GstEvent *event = g_queue_pop_head (queue->events); + gst_event_unref (event); } @@ -317,7 +316,7 @@ gst_queue_dispose (GObject *object) } static GstCaps * -gst_queue_getcaps (GstPad *pad) +gst_queue_getcaps (GstPad * pad) { GstQueue *queue; @@ -331,7 +330,7 @@ gst_queue_getcaps (GstPad *pad) } static GstPadLinkReturn -gst_queue_link (GstPad *pad, const GstCaps *caps) +gst_queue_link (GstPad * pad, const GstCaps * caps) { GstQueue *queue; GstPadLinkReturn link_ret; @@ -357,10 +356,11 @@ gst_queue_link (GstPad *pad, const GstCaps *caps) } static void -gst_queue_locked_flush (GstQueue *queue) +gst_queue_locked_flush (GstQueue * queue) { while (!g_queue_is_empty (queue->queue)) { GstData *data = g_queue_pop_head (queue->queue); + /* First loose the reference we added when putting that data in the queue */ gst_data_unref (data); /* Then loose another reference because we are supposed to destroy that @@ -380,11 +380,12 @@ gst_queue_locked_flush (GstQueue *queue) } static void -gst_queue_handle_pending_events (GstQueue *queue) +gst_queue_handle_pending_events (GstQueue * queue) { /* check for events to send upstream */ - while (!g_queue_is_empty (queue->events)){ + while (!g_queue_is_empty (queue->events)) { GstQueueEventResponse *er = g_queue_pop_head (queue->events); + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "sending event upstream"); er->ret = gst_pad_event_default (queue->srcpad, er->event); er->handled = TRUE; @@ -411,8 +412,7 @@ gst_queue_handle_pending_events (GstQueue *queue) queue->queue->length) static void -gst_queue_chain (GstPad *pad, - GstData *data) +gst_queue_chain (GstPad * pad, GstData * data) { GstQueue *queue; @@ -421,10 +421,11 @@ gst_queue_chain (GstPad *pad, g_return_if_fail (data != NULL); queue = GST_QUEUE (GST_OBJECT_PARENT (pad)); - + restart: /* we have to lock the queue since we span threads */ - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p", g_thread_self ()); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locking t:%p", + g_thread_self ()); g_mutex_lock (queue->qlock); GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ()); @@ -432,170 +433,167 @@ restart: /* assume don't need to flush this buffer when the queue is filled */ queue->flush = FALSE; - + if (GST_IS_EVENT (data)) { switch (GST_EVENT_TYPE (data)) { case GST_EVENT_FLUSH: - STATUS (queue, "received flush event"); - gst_queue_locked_flush (queue); - STATUS (queue, "after flush"); + STATUS (queue, "received flush event"); + gst_queue_locked_flush (queue); + STATUS (queue, "after flush"); break; case GST_EVENT_EOS: STATUS (queue, "received EOS"); break; default: /* we put the event in the queue, we don't have to act ourselves */ - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "adding event %p of type %d", - data, GST_EVENT_TYPE (data)); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, + "adding event %p of type %d", data, GST_EVENT_TYPE (data)); break; } } - + if (GST_IS_BUFFER (data)) - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "adding buffer %p of size %d", - data, GST_BUFFER_SIZE (data)); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, + "adding buffer %p of size %d", data, GST_BUFFER_SIZE (data)); /* We make space available if we're "full" according to whatever * the user defined as "full". Note that this only applies to buffers. * We always handle events and they don't count in our statistics. */ if (GST_IS_BUFFER (data) && ((queue->max_size.buffers > 0 && - queue->cur_level.buffers >= queue->max_size.buffers) || - (queue->max_size.bytes > 0 && - queue->cur_level.bytes >= queue->max_size.bytes) || - (queue->max_size.time > 0 && - queue->cur_level.time >= queue->max_size.time))) { + queue->cur_level.buffers >= queue->max_size.buffers) || + (queue->max_size.bytes > 0 && + queue->cur_level.bytes >= queue->max_size.bytes) || + (queue->max_size.time > 0 && + queue->cur_level.time >= queue->max_size.time))) { g_mutex_unlock (queue->qlock); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0); g_mutex_lock (queue->qlock); /* how are we going to make space for this buffer? */ switch (queue->leaky) { - /* leak current buffer */ + /* leak current buffer */ case GST_QUEUE_LEAK_UPSTREAM: - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "queue is full, leaking buffer on upstream end"); - /* now we can clean up and exit right away */ - g_mutex_unlock (queue->qlock); - goto out_unref; - - /* leak first buffer in the queue */ - case GST_QUEUE_LEAK_DOWNSTREAM: { - /* this is a bit hacky. We'll manually iterate the list - * and find the first buffer from the head on. We'll - * unref that and "fix up" the GQueue object... */ - GList *item; - GstData *leak = NULL; - - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "queue is full, leaking buffer on downstream end"); - - for (item = queue->queue->head; item != NULL; item = item->next) { - if (GST_IS_BUFFER (item->data)) { - leak = item->data; - break; - } - } - - /* if we didn't find anything, it means we have no buffers - * in here. That cannot happen, since we had >= 1 bufs */ - g_assert (leak); - - /* Now remove it from the list, fixing up the GQueue - * CHECKME: is a queue->head the first or the last item? */ - item = g_list_delete_link (queue->queue->head, item); - queue->queue->head = g_list_first (item); - queue->queue->tail = g_list_last (item); - queue->queue->length--; - - /* and unref the data at the end. Twice, because we keep a ref - * to make things read-only. Also keep our list uptodate. */ - queue->cur_level.bytes -= GST_BUFFER_SIZE (data); - queue->cur_level.buffers --; - if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) - queue->cur_level.time -= GST_BUFFER_DURATION (data); - - gst_data_unref (data); - gst_data_unref (data); - break; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "queue is full, leaking buffer on upstream end"); + /* now we can clean up and exit right away */ + g_mutex_unlock (queue->qlock); + goto out_unref; + + /* leak first buffer in the queue */ + case GST_QUEUE_LEAK_DOWNSTREAM:{ + /* this is a bit hacky. We'll manually iterate the list + * and find the first buffer from the head on. We'll + * unref that and "fix up" the GQueue object... */ + GList *item; + GstData *leak = NULL; + + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "queue is full, leaking buffer on downstream end"); + + for (item = queue->queue->head; item != NULL; item = item->next) { + if (GST_IS_BUFFER (item->data)) { + leak = item->data; + break; + } + } + + /* if we didn't find anything, it means we have no buffers + * in here. That cannot happen, since we had >= 1 bufs */ + g_assert (leak); + + /* Now remove it from the list, fixing up the GQueue + * CHECKME: is a queue->head the first or the last item? */ + item = g_list_delete_link (queue->queue->head, item); + queue->queue->head = g_list_first (item); + queue->queue->tail = g_list_last (item); + queue->queue->length--; + + /* and unref the data at the end. Twice, because we keep a ref + * to make things read-only. Also keep our list uptodate. */ + queue->cur_level.bytes -= GST_BUFFER_SIZE (data); + queue->cur_level.buffers--; + if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE) + queue->cur_level.time -= GST_BUFFER_DURATION (data); + + gst_data_unref (data); + gst_data_unref (data); + break; } default: - g_warning ("Unknown leaky type, using default"); - /* fall-through */ + g_warning ("Unknown leaky type, using default"); + /* fall-through */ - /* don't leak. Instead, wait for space to be available */ + /* don't leak. Instead, wait for space to be available */ case GST_QUEUE_NO_LEAK: - STATUS (queue, "pre-full wait"); - - while ((queue->max_size.buffers > 0 && - queue->cur_level.buffers >= queue->max_size.buffers) || - (queue->max_size.bytes > 0 && - queue->cur_level.bytes >= queue->max_size.bytes) || - (queue->max_size.time > 0 && - queue->cur_level.time >= queue->max_size.time)) { - /* if there's a pending state change for this queue - * or its manager, switch back to iterator so bottom - * half of state change executes */ - if (queue->interrupt) { - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); - g_mutex_unlock (queue->qlock); - if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), - GST_ELEMENT (queue))) { - goto out_unref; - } + STATUS (queue, "pre-full wait"); + + while ((queue->max_size.buffers > 0 && + queue->cur_level.buffers >= queue->max_size.buffers) || + (queue->max_size.bytes > 0 && + queue->cur_level.bytes >= queue->max_size.bytes) || + (queue->max_size.time > 0 && + queue->cur_level.time >= queue->max_size.time)) { + /* if there's a pending state change for this queue + * or its manager, switch back to iterator so bottom + * half of state change executes */ + if (queue->interrupt) { + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); + g_mutex_unlock (queue->qlock); + if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->sinkpad), + GST_ELEMENT (queue))) { + goto out_unref; + } /* if we got here because we were unlocked after a - * flush, we don't need to add the buffer to the - * queue again */ + * flush, we don't need to add the buffer to the + * queue again */ if (queue->flush) { - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "not adding pending buffer after flush"); + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "not adding pending buffer after flush"); goto out_unref; } - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "adding pending buffer after interrupt"); + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "adding pending buffer after interrupt"); goto restart; - } + } - if (GST_STATE (queue) != GST_STATE_PLAYING) { + if (GST_STATE (queue) != GST_STATE_PLAYING) { /* this means the other end is shut down. Try to - * signal to resolve the error */ + * signal to resolve the error */ if (!queue->may_deadlock) { - g_mutex_unlock (queue->qlock); - gst_data_unref (data); - GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), - ("deadlock found, shutting down source pad elements")); + g_mutex_unlock (queue->qlock); + gst_data_unref (data); + GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), + ("deadlock found, shutting down source pad elements")); /* we don't go to out_unref here, since we want to - * unref the buffer *before* calling GST_ELEMENT_ERROR */ + * unref the buffer *before* calling GST_ELEMENT_ERROR */ return; } else { - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "%s: waiting for the app to restart " - "source pad elements", - GST_ELEMENT_NAME (queue)); + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, + "%s: waiting for the app to restart " + "source pad elements", GST_ELEMENT_NAME (queue)); } - } - - /* OK, we've got a serious issue here. Imagine the situation - * where the puller (next element) is sending an event here, - * so it cannot pull events from the queue, and we cannot - * push data further because the queue is 'full' and therefore, - * we wait here (and do not handle events): deadlock! to solve - * that, we handle pending upstream events here, too. */ - gst_queue_handle_pending_events (queue); - - STATUS (queue, "waiting for item_del signal"); - g_cond_wait (queue->item_del, queue->qlock); - STATUS (queue, "received item_del signal"); - } - - STATUS (queue, "post-full wait"); - g_mutex_unlock (queue->qlock); - g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0); - g_mutex_lock (queue->qlock); - break; + } + + /* OK, we've got a serious issue here. Imagine the situation + * where the puller (next element) is sending an event here, + * so it cannot pull events from the queue, and we cannot + * push data further because the queue is 'full' and therefore, + * we wait here (and do not handle events): deadlock! to solve + * that, we handle pending upstream events here, too. */ + gst_queue_handle_pending_events (queue); + + STATUS (queue, "waiting for item_del signal"); + g_cond_wait (queue->item_del, queue->qlock); + STATUS (queue, "received item_del signal"); + } + + STATUS (queue, "post-full wait"); + g_mutex_unlock (queue->qlock); + g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0); + g_mutex_lock (queue->qlock); + break; } } @@ -628,7 +626,7 @@ out_unref: } static GstData * -gst_queue_get (GstPad *pad) +gst_queue_get (GstPad * pad) { GstQueue *queue; GstData *data; @@ -641,70 +639,69 @@ gst_queue_get (GstPad *pad) restart: /* have to lock for thread-safety */ GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "locking t:%p", g_thread_self ()); + "locking t:%p", g_thread_self ()); g_mutex_lock (queue->qlock); - GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "locked t:%p", g_thread_self ()); + GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, "locked t:%p", g_thread_self ()); if (queue->queue->length == 0 || (queue->min_threshold.buffers > 0 && - queue->cur_level.buffers < queue->min_threshold.buffers) || + queue->cur_level.buffers < queue->min_threshold.buffers) || (queue->min_threshold.bytes > 0 && - queue->cur_level.bytes < queue->min_threshold.bytes) || + queue->cur_level.bytes < queue->min_threshold.bytes) || (queue->min_threshold.time > 0 && - queue->cur_level.time < queue->min_threshold.time)) { + queue->cur_level.time < queue->min_threshold.time)) { g_mutex_unlock (queue->qlock); g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0); g_mutex_lock (queue->qlock); STATUS (queue, "pre-empty wait"); while (queue->queue->length == 0 || - (queue->min_threshold.buffers > 0 && - queue->cur_level.buffers < queue->min_threshold.buffers) || - (queue->min_threshold.bytes > 0 && - queue->cur_level.bytes < queue->min_threshold.bytes) || - (queue->min_threshold.time > 0 && - queue->cur_level.time < queue->min_threshold.time)) { + (queue->min_threshold.buffers > 0 && + queue->cur_level.buffers < queue->min_threshold.buffers) || + (queue->min_threshold.bytes > 0 && + queue->cur_level.bytes < queue->min_threshold.bytes) || + (queue->min_threshold.time > 0 && + queue->cur_level.time < queue->min_threshold.time)) { /* if there's a pending state change for this queue or its * manager, switch back to iterator so bottom half of state * change executes. */ if (queue->interrupt) { - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); - g_mutex_unlock (queue->qlock); - if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), - GST_ELEMENT (queue))) - return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); - goto restart; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, "interrupted"); + g_mutex_unlock (queue->qlock); + if (gst_scheduler_interrupt (gst_pad_get_scheduler (queue->srcpad), + GST_ELEMENT (queue))) + return GST_DATA (gst_event_new (GST_EVENT_INTERRUPT)); + goto restart; } if (GST_STATE (queue) != GST_STATE_PLAYING) { - /* this means the other end is shut down */ - if (!queue->may_deadlock) { - g_mutex_unlock (queue->qlock); - GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), - ("deadlock found, shutting down sink pad elements")); - goto restart; - } else { - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "%s: waiting for the app to restart " - "source pad elements", - GST_ELEMENT_NAME (queue)); - } + /* this means the other end is shut down */ + if (!queue->may_deadlock) { + g_mutex_unlock (queue->qlock); + GST_ELEMENT_ERROR (queue, CORE, THREAD, (NULL), + ("deadlock found, shutting down sink pad elements")); + goto restart; + } else { + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, + "%s: waiting for the app to restart " + "source pad elements", GST_ELEMENT_NAME (queue)); + } } STATUS (queue, "waiting for item_add"); - + if (queue->block_timeout != GST_CLOCK_TIME_NONE) { - GTimeVal timeout; - g_get_current_time (&timeout); - g_time_val_add (&timeout, queue->block_timeout / 1000); - if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)){ - g_mutex_unlock (queue->qlock); + GTimeVal timeout; + + g_get_current_time (&timeout); + g_time_val_add (&timeout, queue->block_timeout / 1000); + if (!g_cond_timed_wait (queue->item_add, queue->qlock, &timeout)) { + g_mutex_unlock (queue->qlock); GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "Sending filler event"); - return GST_DATA (gst_event_new_filler ()); - } + "Sending filler event"); + return GST_DATA (gst_event_new_filler ()); + } } else { - g_cond_wait (queue->item_add, queue->qlock); + g_cond_wait (queue->item_add, queue->qlock); } STATUS (queue, "got item_add signal"); } @@ -718,8 +715,8 @@ restart: /* There's something in the list now, whatever it is */ data = g_queue_pop_head (queue->queue); GST_CAT_LOG_OBJECT (GST_CAT_DATAFLOW, queue, - "retrieved data %p from queue", data); - + "retrieved data %p from queue", data); + if (data == NULL) return NULL; @@ -746,15 +743,15 @@ restart: * locked too so it'd cause a deadlock. */ if (GST_IS_EVENT (data)) { GstEvent *event = GST_EVENT (data); + switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "queue \"%s\" eos", - GST_ELEMENT_NAME (queue)); - gst_element_set_eos (GST_ELEMENT (queue)); - break; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "queue \"%s\" eos", GST_ELEMENT_NAME (queue)); + gst_element_set_eos (GST_ELEMENT (queue)); + break; default: - break; + break; } } @@ -763,8 +760,7 @@ restart: static gboolean -gst_queue_handle_src_event (GstPad *pad, - GstEvent *event) +gst_queue_handle_src_event (GstPad * pad, GstEvent * event) { GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad)); gboolean res; @@ -779,45 +775,45 @@ gst_queue_handle_src_event (GstPad *pad, er.handled = FALSE; g_queue_push_tail (queue->events, &er); GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "Preparing for loop for event handler"); + "Preparing for loop for event handler"); /* see the chain function on why this is here - it prevents a deadlock */ g_cond_signal (queue->item_del); while (!er.handled) { GTimeVal timeout; + g_get_current_time (&timeout); - g_time_val_add (&timeout, 500 * 1000); /* half a second */ + g_time_val_add (&timeout, 500 * 1000); /* half a second */ if (!g_cond_timed_wait (queue->event_done, queue->qlock, &timeout) && - !er.handled) { - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "timeout in upstream event handling"); - /* remove ourselves from the pending list. Since we're - * locked, others cannot reference this anymore. */ - queue->queue->head = g_list_remove (queue->queue->head, &er); - queue->queue->head = g_list_first (queue->queue->head); - queue->queue->tail = g_list_last (queue->queue->head); - queue->queue->length--; - res = FALSE; - goto handled; + !er.handled) { + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, + "timeout in upstream event handling"); + /* remove ourselves from the pending list. Since we're + * locked, others cannot reference this anymore. */ + queue->queue->head = g_list_remove (queue->queue->head, &er); + queue->queue->head = g_list_first (queue->queue->head); + queue->queue->tail = g_list_last (queue->queue->head); + queue->queue->length--; + res = FALSE; + goto handled; } } - GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, - "Event handled"); + GST_CAT_WARNING_OBJECT (GST_CAT_DATAFLOW, queue, "Event handled"); res = er.ret; } else { - res = gst_pad_event_default (pad, event); + res = gst_pad_event_default (pad, event); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_FLUSH: - GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, - "FLUSH event, flushing queue\n"); - gst_queue_locked_flush (queue); - break; + GST_CAT_DEBUG_OBJECT (GST_CAT_DATAFLOW, queue, + "FLUSH event, flushing queue\n"); + gst_queue_locked_flush (queue); + break; case GST_EVENT_SEEK: - if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { - gst_queue_locked_flush (queue); - } + if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) { + gst_queue_locked_flush (queue); + } default: - break; + break; } } handled: @@ -827,7 +823,7 @@ handled: } static gboolean -gst_queue_release_locks (GstElement *element) +gst_queue_release_locks (GstElement * element) { GstQueue *queue; @@ -843,7 +839,7 @@ gst_queue_release_locks (GstElement *element) } static GstElementStateReturn -gst_queue_change_state (GstElement *element) +gst_queue_change_state (GstElement * element) { GstQueue *queue; GstElementStateReturn ret = GST_STATE_SUCCESS; @@ -863,31 +859,30 @@ gst_queue_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_PLAYING: if (!GST_PAD_IS_LINKED (queue->sinkpad)) { - GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, - "queue %s is not linked", - GST_ELEMENT_NAME (queue)); - /* FIXME can this be? */ - g_cond_signal (queue->item_add); - - ret = GST_STATE_FAILURE; - goto error; + GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, + "queue %s is not linked", GST_ELEMENT_NAME (queue)); + /* FIXME can this be? */ + g_cond_signal (queue->item_add); + + ret = GST_STATE_FAILURE; + goto error; } else { - GstScheduler *src_sched, *sink_sched; - - src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad)); - sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad)); + GstScheduler *src_sched, *sink_sched; + + src_sched = gst_pad_get_scheduler (GST_PAD (queue->srcpad)); + sink_sched = gst_pad_get_scheduler (GST_PAD (queue->sinkpad)); - if (src_sched == sink_sched) { - GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, - "queue %s does not connect different schedulers", - GST_ELEMENT_NAME (queue)); + if (src_sched == sink_sched) { + GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, queue, + "queue %s does not connect different schedulers", + GST_ELEMENT_NAME (queue)); g_warning ("queue %s does not connect different schedulers", - GST_ELEMENT_NAME (queue)); + GST_ELEMENT_NAME (queue)); ret = GST_STATE_FAILURE; goto error; - } + } } queue->interrupt = FALSE; break; @@ -917,10 +912,8 @@ error: static void -gst_queue_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +gst_queue_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) { GstQueue *queue = GST_QUEUE (object); @@ -965,10 +958,8 @@ gst_queue_set_property (GObject *object, } static void -gst_queue_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gst_queue_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) { GstQueue *queue = GST_QUEUE (object); diff --git a/plugins/elements/gstqueue.h b/plugins/elements/gstqueue.h index d4ce60244..c999fc46e 100644 --- a/plugins/elements/gstqueue.h +++ b/plugins/elements/gstqueue.h @@ -29,7 +29,6 @@ G_BEGIN_DECLS - #define GST_TYPE_QUEUE \ (gst_queue_get_type()) #define GST_QUEUE(obj) \ @@ -40,17 +39,18 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE)) #define GST_IS_QUEUE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE)) - -enum { - GST_QUEUE_NO_LEAK = 0, - GST_QUEUE_LEAK_UPSTREAM = 1, - GST_QUEUE_LEAK_DOWNSTREAM = 2 + enum +{ + GST_QUEUE_NO_LEAK = 0, + GST_QUEUE_LEAK_UPSTREAM = 1, + GST_QUEUE_LEAK_DOWNSTREAM = 2 }; typedef struct _GstQueue GstQueue; typedef struct _GstQueueClass GstQueueClass; -struct _GstQueue { +struct _GstQueue +{ GstElement element; GstPad *sinkpad; @@ -59,13 +59,14 @@ struct _GstQueue { /* the queue of data we're keeping our grubby hands on */ GQueue *queue; - struct { - guint buffers; /* no. of buffers */ - guint bytes; /* no. of bytes */ - guint64 time; /* amount of time */ - } cur_level, /* currently in the queue */ - max_size, /* max. amount of data allowed in the queue */ - min_threshold; /* min. amount of data required to wake reader */ + struct + { + guint buffers; /* no. of buffers */ + guint bytes; /* no. of bytes */ + guint64 time; /* amount of time */ + } cur_level, /* currently in the queue */ + max_size, /* max. amount of data allowed in the queue */ + min_threshold; /* min. amount of data required to wake reader */ /* whether we leak data, and at which end */ gint leaky; @@ -80,27 +81,28 @@ struct _GstQueue { gboolean interrupt; gboolean flush; - GMutex *qlock; /* lock for queue (vs object lock) */ - GCond *item_add; /* signals buffers now available for reading */ - GCond *item_del; /* signals space now available for writing */ - GCond *event_done; /* upstream event signaller */ + GMutex *qlock; /* lock for queue (vs object lock) */ + GCond *item_add; /* signals buffers now available for reading */ + GCond *item_del; /* signals space now available for writing */ + GCond *event_done; /* upstream event signaller */ - GTimeVal *timeval; /* the timeout for the queue locking */ - GQueue *events; /* upstream events get decoupled here */ + GTimeVal *timeval; /* the timeout for the queue locking */ + GQueue *events; /* upstream events get decoupled here */ GstCaps *negotiated_caps; gpointer _gst_reserved[GST_PADDING]; }; -struct _GstQueueClass { +struct _GstQueueClass +{ GstElementClass parent_class; /* signals - 'running' is called from both sides * which might make it sort of non-useful... */ - void (*underrun) (GstQueue *queue); - void (*running) (GstQueue *queue); - void (*overrun) (GstQueue *queue); + void (*underrun) (GstQueue * queue); + void (*running) (GstQueue * queue); + void (*overrun) (GstQueue * queue); gpointer _gst_reserved[GST_PADDING]; }; @@ -108,6 +110,4 @@ struct _GstQueueClass { GType gst_queue_get_type (void); G_END_DECLS - - #endif /* __GST_QUEUE_H__ */ diff --git a/plugins/elements/gstshaper.c b/plugins/elements/gstshaper.c index 34301f1a6..afa1666bc 100644 --- a/plugins/elements/gstshaper.c +++ b/plugins/elements/gstshaper.c @@ -32,21 +32,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_shaper_debug); #define GST_CAT_DEFAULT gst_shaper_debug -GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS ( - "Shaper", - "Generic", - "Synchronizes streams on different pads", - "Wim Taymans " -); +GstElementDetails gst_shaper_details = GST_ELEMENT_DETAILS ("Shaper", + "Generic", + "Synchronizes streams on different pads", + "Wim Taymans "); /* Shaper signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_POLICY, ARG_SILENT, @@ -55,24 +55,20 @@ enum { typedef struct { - GstPad *sinkpad; - GstPad *srcpad; - GstBuffer *buffer; + GstPad *sinkpad; + GstPad *srcpad; + GstBuffer *buffer; } GstShaperConnection; -GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ( - "src%d", - GST_PAD_SRC, - GST_PAD_SOMETIMES, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate shaper_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS_ANY); -GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink%d", - GST_PAD_SINK, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate shaper_sink_template = GST_STATIC_PAD_TEMPLATE ("sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define GST_TYPE_SHAPER_POLICY (gst_shaper_policy_get_type()) static GType @@ -80,12 +76,13 @@ gst_shaper_policy_get_type (void) { static GType shaper_policy_type = 0; static GEnumValue shaper_policy[] = { - { SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"}, - { SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"}, + {SHAPER_POLICY_TIMESTAMPS, "1", "sync on timestamps"}, + {SHAPER_POLICY_BUFFERSIZE, "2", "sync on buffer size"}, {0, NULL, NULL}, }; if (!shaper_policy_type) { - shaper_policy_type = g_enum_register_static ("GstShaperPolicy", shaper_policy); + shaper_policy_type = + g_enum_register_static ("GstShaperPolicy", shaper_policy); } return shaper_policy_type; } @@ -93,24 +90,25 @@ gst_shaper_policy_get_type (void) #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_shaper_debug, "shaper", 0, "shaper element"); -GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstShaper, gst_shaper, GstElement, GST_TYPE_ELEMENT, + _do_init); -static void gst_shaper_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_shaper_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_shaper_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_shaper_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstPad* gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, - const gchar *unused); +static GstPad *gst_shaper_request_new_pad (GstElement * element, + GstPadTemplate * templ, const gchar * unused); -static void gst_shaper_loop (GstElement *element); +static void gst_shaper_loop (GstElement * element); static void gst_shaper_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_shaper_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&shaper_src_template)); @@ -118,41 +116,43 @@ gst_shaper_base_init (gpointer g_class) gst_static_pad_template_get (&shaper_sink_template)); } -static void -gst_shaper_class_init (GstShaperClass *klass) +static void +gst_shaper_class_init (GstShaperClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*) klass; - gstelement_class = (GstElementClass*) klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_POLICY, - g_param_spec_enum ("policy", "Policy", "Shaper policy", - GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE)); + g_param_spec_enum ("policy", "Policy", "Shaper policy", + GST_TYPE_SHAPER_POLICY, SHAPER_POLICY_TIMESTAMPS, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last-message", "last-message", "last-message", - NULL, G_PARAM_READABLE)); + g_param_spec_string ("last-message", "last-message", "last-message", + NULL, G_PARAM_READABLE)); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_shaper_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_shaper_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_shaper_request_new_pad); } -static GstCaps* -gst_shaper_getcaps (GstPad *pad) +static GstCaps * +gst_shaper_getcaps (GstPad * pad) { GstPad *otherpad; GstShaperConnection *connection; connection = gst_pad_get_element_private (pad); - otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); + otherpad = + (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); if (GST_PAD_PEER (otherpad)) { return gst_pad_get_caps (GST_PAD_PEER (otherpad)); @@ -161,8 +161,8 @@ gst_shaper_getcaps (GstPad *pad) } } -static GList* -gst_shaper_get_internal_link (GstPad *pad) +static GList * +gst_shaper_get_internal_link (GstPad * pad) { GList *res = NULL; GstShaperConnection *connection; @@ -170,7 +170,8 @@ gst_shaper_get_internal_link (GstPad *pad) connection = gst_pad_get_element_private (pad); - otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); + otherpad = + (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); res = g_list_prepend (res, otherpad); @@ -178,20 +179,21 @@ gst_shaper_get_internal_link (GstPad *pad) } static GstPadLinkReturn -gst_shaper_link (GstPad *pad, const GstCaps *caps) +gst_shaper_link (GstPad * pad, const GstCaps * caps) { GstPad *otherpad; GstShaperConnection *connection; connection = gst_pad_get_element_private (pad); - otherpad = (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); + otherpad = + (pad == connection->srcpad ? connection->sinkpad : connection->srcpad); return gst_pad_try_set_caps (otherpad, caps); } -static GstShaperConnection* -gst_shaper_create_connection (GstShaper *shaper) +static GstShaperConnection * +gst_shaper_create_connection (GstShaper * shaper) { GstShaperConnection *connection; gchar *padname; @@ -201,21 +203,25 @@ gst_shaper_create_connection (GstShaper *shaper) connection = g_new0 (GstShaperConnection, 1); padname = g_strdup_printf ("sink%d", shaper->nconnections); - connection->sinkpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&shaper_sink_template), padname); + connection->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&shaper_sink_template), padname); g_free (padname); gst_pad_set_getcaps_function (connection->sinkpad, gst_shaper_getcaps); - gst_pad_set_internal_link_function (connection->sinkpad, gst_shaper_get_internal_link); + gst_pad_set_internal_link_function (connection->sinkpad, + gst_shaper_get_internal_link); gst_pad_set_link_function (connection->sinkpad, gst_shaper_link); gst_pad_set_element_private (connection->sinkpad, connection); gst_element_add_pad (GST_ELEMENT (shaper), connection->sinkpad); padname = g_strdup_printf ("src%d", shaper->nconnections); - connection->srcpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&shaper_src_template), padname); + connection->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get + (&shaper_src_template), padname); g_free (padname); gst_pad_set_getcaps_function (connection->srcpad, gst_shaper_getcaps); - gst_pad_set_internal_link_function (connection->srcpad, gst_shaper_get_internal_link); + gst_pad_set_internal_link_function (connection->srcpad, + gst_shaper_get_internal_link); gst_pad_set_link_function (connection->srcpad, gst_shaper_link); gst_pad_set_element_private (connection->srcpad, connection); gst_element_add_pad (GST_ELEMENT (shaper), connection->srcpad); @@ -225,8 +231,9 @@ gst_shaper_create_connection (GstShaper *shaper) return connection; } -static GstPad* -gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_shaper_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { GstShaper *shaper = GST_SHAPER (element); GstShaperConnection *connection; @@ -236,8 +243,8 @@ gst_shaper_request_new_pad (GstElement *element, GstPadTemplate *templ, const gc return connection->sinkpad; } -static void -gst_shaper_init (GstShaper *shaper) +static void +gst_shaper_init (GstShaper * shaper) { gst_element_set_loop_function (GST_ELEMENT (shaper), gst_shaper_loop); @@ -248,8 +255,8 @@ gst_shaper_init (GstShaper *shaper) shaper->last_message = NULL; } -static void -gst_shaper_loop (GstElement *element) +static void +gst_shaper_loop (GstElement * element) { GstShaper *shaper; GSList *connections; @@ -278,16 +285,15 @@ gst_shaper_loop (GstElement *element) gst_pad_push (connection->srcpad, GST_DATA (buffer)); switch (type) { - /* on EOS we disable the pad so that we don't pull on - * it again and never get more data */ - case GST_EVENT_EOS: + /* on EOS we disable the pad so that we don't pull on + * it again and never get more data */ + case GST_EVENT_EOS: gst_pad_set_active (connection->sinkpad, FALSE); break; default: break; } - } - else { + } else { /* we store the buffer */ connection->buffer = buffer; } @@ -295,9 +301,8 @@ gst_shaper_loop (GstElement *element) /* FIXME policy stuff goes here */ /* find connection with lowest timestamp */ if (min == NULL || (connection->buffer != NULL && - (GST_BUFFER_TIMESTAMP (connection->buffer) < - GST_BUFFER_TIMESTAMP (min->buffer)))) - { + (GST_BUFFER_TIMESTAMP (connection->buffer) < + GST_BUFFER_TIMESTAMP (min->buffer)))) { min = connection; } connections = g_slist_next (connections); @@ -309,20 +314,21 @@ gst_shaper_loop (GstElement *element) /* since we pushed a buffer, it's not EOS */ eos = FALSE; } - + if (eos) { gst_element_set_eos (element); } } -static void -gst_shaper_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_shaper_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstShaper *shaper; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_SHAPER (object)); - + shaper = GST_SHAPER (object); switch (prop_id) { @@ -338,12 +344,15 @@ gst_shaper_set_property (GObject *object, guint prop_id, const GValue *value, GP } } -static void gst_shaper_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { +static void +gst_shaper_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ GstShaper *shaper; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_SHAPER (object)); - + shaper = GST_SHAPER (object); switch (prop_id) { @@ -361,4 +370,3 @@ static void gst_shaper_get_property(GObject *object, guint prop_id, GValue *valu break; } } - diff --git a/plugins/elements/gstshaper.h b/plugins/elements/gstshaper.h index 2cbaf5336..07f1eb83c 100644 --- a/plugins/elements/gstshaper.h +++ b/plugins/elements/gstshaper.h @@ -28,8 +28,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_SHAPER \ (gst_shaper_get_type()) #define GST_SHAPER(obj) \ @@ -40,8 +38,8 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SHAPER)) #define GST_IS_SHAPER_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SHAPER)) - -typedef enum { + typedef enum +{ SHAPER_POLICY_TIMESTAMPS = 1, SHAPER_POLICY_BUFFERSIZE } GstShaperPolicyType; @@ -49,26 +47,27 @@ typedef enum { typedef struct _GstShaper GstShaper; typedef struct _GstShaperClass GstShaperClass; -struct _GstShaper { - GstElement element; +struct _GstShaper +{ + GstElement element; - GSList *connections; - gint nconnections; + GSList *connections; + gint nconnections; - GstShaperPolicyType policy; + GstShaperPolicyType policy; - gboolean silent; - gchar *last_message; + gboolean silent; + gchar *last_message; }; -struct _GstShaperClass { +struct _GstShaperClass +{ GstElementClass parent_class; }; -GType gst_shaper_get_type (void); -gboolean gst_shaper_factory_init (GstElementFactory *factory); +GType gst_shaper_get_type (void); +gboolean gst_shaper_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_SHAPER_H__ */ diff --git a/plugins/elements/gststatistics.c b/plugins/elements/gststatistics.c index 65e578b25..73f656fb3 100644 --- a/plugins/elements/gststatistics.c +++ b/plugins/elements/gststatistics.c @@ -30,21 +30,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_statistics_debug); #define GST_CAT_DEFAULT gst_statistics_debug -GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS ( - "Statistics", - "Generic", - "Statistics on buffers/bytes/events", - "David I. Lehn " -); +GstElementDetails gst_statistics_details = GST_ELEMENT_DETAILS ("Statistics", + "Generic", + "Statistics on buffers/bytes/events", + "David I. Lehn "); /* Statistics signals and args */ -enum { +enum +{ SIGNAL_UPDATE, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_BUFFERS, ARG_BYTES, @@ -61,14 +61,17 @@ enum { #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_statistics_debug, "statistics", 0, "statistics element"); -GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstStatistics, gst_statistics, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void gst_statistics_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); +static void gst_statistics_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_statistics_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_statistics_chain (GstPad *pad, GstData *_data); -static void gst_statistics_reset (GstStatistics *statistics); -static void gst_statistics_print (GstStatistics *statistics); +static void gst_statistics_chain (GstPad * pad, GstData * _data); +static void gst_statistics_reset (GstStatistics * statistics); +static void gst_statistics_print (GstStatistics * statistics); static guint gst_statistics_signals[LAST_SIGNAL] = { 0, }; @@ -79,71 +82,75 @@ static void gst_statistics_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_statistics_details); } -static void -gst_statistics_class_init (GstStatisticsClass *klass) +static void +gst_statistics_class_init (GstStatisticsClass * klass) { GObjectClass *gobject_class; - + gobject_class = G_OBJECT_CLASS (klass); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFERS, - g_param_spec_int64 ("buffers", "buffers", "total buffers count", - 0, G_MAXINT64, 0, G_PARAM_READABLE)); + g_param_spec_int64 ("buffers", "buffers", "total buffers count", + 0, G_MAXINT64, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES, - g_param_spec_int64 ("bytes", "bytes", "total bytes count", - 0, G_MAXINT64, 0, G_PARAM_READABLE)); + g_param_spec_int64 ("bytes", "bytes", "total bytes count", + 0, G_MAXINT64, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENTS, - g_param_spec_int64 ("events", "events", "total event count", - 0, G_MAXINT64, 0, G_PARAM_READABLE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFER_UPDATE_FREQ, - g_param_spec_int64 ("buffer_update_freq", "buffer update freq", "buffer update frequency", - 0, G_MAXINT64, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BYTES_UPDATE_FREQ, - g_param_spec_int64 ("bytes_update_freq", "bytes update freq", "bytes update frequency", - 0, G_MAXINT64, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EVENT_UPDATE_FREQ, - g_param_spec_int64 ("event_update_freq", "event update freq", "event update frequency", - 0, G_MAXINT64, 0, G_PARAM_READWRITE)); + g_param_spec_int64 ("events", "events", "total event count", + 0, G_MAXINT64, 0, G_PARAM_READABLE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_BUFFER_UPDATE_FREQ, g_param_spec_int64 ("buffer_update_freq", + "buffer update freq", "buffer update frequency", 0, G_MAXINT64, 0, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_BYTES_UPDATE_FREQ, g_param_spec_int64 ("bytes_update_freq", + "bytes update freq", "bytes update frequency", 0, G_MAXINT64, 0, + G_PARAM_READWRITE)); + g_object_class_install_property (G_OBJECT_CLASS (klass), + ARG_EVENT_UPDATE_FREQ, g_param_spec_int64 ("event_update_freq", + "event update freq", "event update frequency", 0, G_MAXINT64, 0, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE_ON_EOS, - g_param_spec_boolean ("update_on_eos", "update on EOS", "update on EOS event", - TRUE,G_PARAM_READWRITE)); + g_param_spec_boolean ("update_on_eos", "update on EOS", + "update on EOS event", TRUE, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_UPDATE, - g_param_spec_boolean ("update", "update", "update", - TRUE,G_PARAM_READWRITE)); + g_param_spec_boolean ("update", "update", "update", TRUE, + G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - TRUE,G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", TRUE, + G_PARAM_READWRITE)); gst_statistics_signals[SIGNAL_UPDATE] = - g_signal_new ("update", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL, - g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + g_signal_new ("update", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstStatisticsClass, update), NULL, NULL, + g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_statistics_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_statistics_get_property); } -static void -gst_statistics_init (GstStatistics *statistics) +static void +gst_statistics_init (GstStatistics * statistics) { statistics->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (statistics), statistics->sinkpad); - gst_pad_set_chain_function (statistics->sinkpad, GST_DEBUG_FUNCPTR (gst_statistics_chain)); - + gst_pad_set_chain_function (statistics->sinkpad, + GST_DEBUG_FUNCPTR (gst_statistics_chain)); + statistics->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (statistics), statistics->srcpad); statistics->timer = NULL; statistics->last_timer = NULL; - gst_statistics_reset(statistics); + gst_statistics_reset (statistics); } static void -gst_statistics_reset (GstStatistics *statistics) +gst_statistics_reset (GstStatistics * statistics) { g_return_if_fail (statistics != NULL); g_return_if_fail (GST_IS_STATISTICS (statistics)); @@ -169,15 +176,16 @@ gst_statistics_reset (GstStatistics *statistics) statistics->silent = FALSE; if (!statistics->timer) { - statistics->timer = g_timer_new(); + statistics->timer = g_timer_new (); } if (!statistics->last_timer) { - statistics->last_timer = g_timer_new(); + statistics->last_timer = g_timer_new (); } } static void -print_stats(gboolean first, const gchar *name, const gchar *type, stats *base, stats *final, double time) +print_stats (gboolean first, const gchar * name, const gchar * type, + stats * base, stats * final, double time) { const gchar *header0 = "statistics"; const gchar *headerN = " "; @@ -187,25 +195,21 @@ print_stats(gboolean first, const gchar *name, const gchar *type, stats *base, s delta.bytes = final->bytes - base->bytes; delta.events = final->events - base->events; - g_print("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT - " bytes:%" G_GINT64_FORMAT - " events:%" G_GINT64_FORMAT "\n", - first ? header0 : headerN, - name, type, time, - final->buffers, - final->bytes, - final->events); - g_print("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n", - headerN, - name, type, - delta.buffers/time, - delta.bytes/time, - delta.events/time, - ((double)delta.bytes/(double)delta.buffers)); + g_print ("%s: (%s) %s: s:%g buffers:%" G_GINT64_FORMAT + " bytes:%" G_GINT64_FORMAT + " events:%" G_GINT64_FORMAT "\n", + first ? header0 : headerN, + name, type, time, final->buffers, final->bytes, final->events); + g_print ("%s: (%s) %s: buf/s:%g B/s:%g e/s:%g B/buf:%g\n", + headerN, + name, type, + delta.buffers / time, + delta.bytes / time, + delta.events / time, ((double) delta.bytes / (double) delta.buffers)); } static void -gst_statistics_print (GstStatistics *statistics) +gst_statistics_print (GstStatistics * statistics) { const gchar *name; double elapsed; @@ -214,22 +218,23 @@ gst_statistics_print (GstStatistics *statistics) g_return_if_fail (statistics != NULL); g_return_if_fail (GST_IS_STATISTICS (statistics)); - name = gst_object_get_name(GST_OBJECT(statistics)); + name = gst_object_get_name (GST_OBJECT (statistics)); if (!name) { name = ""; } - elapsed = g_timer_elapsed(statistics->timer, NULL); - last_elapsed = g_timer_elapsed(statistics->last_timer, NULL); + elapsed = g_timer_elapsed (statistics->timer, NULL); + last_elapsed = g_timer_elapsed (statistics->last_timer, NULL); - print_stats(1, name, "total", &zero_stats, &statistics->stats, elapsed); - print_stats(0, name, "last", &statistics->last_stats, &statistics->stats, last_elapsed); + print_stats (1, name, "total", &zero_stats, &statistics->stats, elapsed); + print_stats (0, name, "last", &statistics->last_stats, &statistics->stats, + last_elapsed); statistics->last_stats = statistics->stats; - g_timer_reset(statistics->last_timer); + g_timer_reset (statistics->last_timer); } -static void -gst_statistics_chain (GstPad *pad, GstData *_data) +static void +gst_statistics_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstStatistics *statistics; @@ -241,20 +246,21 @@ gst_statistics_chain (GstPad *pad, GstData *_data) statistics = GST_STATISTICS (gst_pad_get_parent (pad)); - if (GST_IS_EVENT(buf)) { + if (GST_IS_EVENT (buf)) { GstEvent *event = GST_EVENT (buf); + statistics->stats.events += 1; - if (GST_EVENT_TYPE(event) == GST_EVENT_EOS) { + if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) { gst_element_set_eos (GST_ELEMENT (statistics)); if (statistics->update_on_eos) { - update = TRUE; + update = TRUE; } } if (statistics->update_freq.events) { statistics->update_count.events += 1; if (statistics->update_count.events == statistics->update_freq.events) { - statistics->update_count.events = 0; - update = TRUE; + statistics->update_count.events = 0; + update = TRUE; } } } else { @@ -262,17 +268,17 @@ gst_statistics_chain (GstPad *pad, GstData *_data) if (statistics->update_freq.buffers) { statistics->update_count.buffers += 1; if (statistics->update_count.buffers == statistics->update_freq.buffers) { - statistics->update_count.buffers = 0; - update = TRUE; + statistics->update_count.buffers = 0; + update = TRUE; } } - statistics->stats.bytes += GST_BUFFER_SIZE(buf); + statistics->stats.bytes += GST_BUFFER_SIZE (buf); if (statistics->update_freq.bytes) { - statistics->update_count.bytes += GST_BUFFER_SIZE(buf); + statistics->update_count.bytes += GST_BUFFER_SIZE (buf); if (statistics->update_count.bytes >= statistics->update_freq.bytes) { - statistics->update_count.bytes = 0; - update = TRUE; + statistics->update_count.bytes = 0; + update = TRUE; } } } @@ -280,24 +286,26 @@ gst_statistics_chain (GstPad *pad, GstData *_data) if (update) { if (statistics->update) { GST_DEBUG ("[%s]: pre update emit", GST_ELEMENT_NAME (statistics)); - g_signal_emit (G_OBJECT (statistics), gst_statistics_signals[SIGNAL_UPDATE], 0); + g_signal_emit (G_OBJECT (statistics), + gst_statistics_signals[SIGNAL_UPDATE], 0); GST_DEBUG ("[%s]: post update emit", GST_ELEMENT_NAME (statistics)); } if (!statistics->silent) { - gst_statistics_print(statistics); + gst_statistics_print (statistics); } } gst_pad_push (statistics->srcpad, GST_DATA (buf)); } -static void -gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +static void +gst_statistics_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstStatistics *statistics; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_STATISTICS (object)); - + statistics = GST_STATISTICS (object); switch (prop_id) { @@ -325,12 +333,15 @@ gst_statistics_set_property (GObject *object, guint prop_id, const GValue *value } } -static void gst_statistics_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { +static void +gst_statistics_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ GstStatistics *statistics; /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_STATISTICS (object)); - + statistics = GST_STATISTICS (object); switch (prop_id) { diff --git a/plugins/elements/gststatistics.h b/plugins/elements/gststatistics.h index 4c1ab57a3..72ad4d1e6 100644 --- a/plugins/elements/gststatistics.h +++ b/plugins/elements/gststatistics.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_STATISTICS \ (gst_statistics_get_type()) #define GST_STATISTICS(obj) \ @@ -39,19 +37,20 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_STATISTICS)) #define GST_IS_STATISTICS_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_STATISTICS)) - typedef struct _GstStatistics GstStatistics; typedef struct _GstStatisticsClass GstStatisticsClass; typedef struct _stats stats; -struct _stats { +struct _stats +{ gint64 buffers; gint64 bytes; gint64 events; }; -struct _GstStatistics { +struct _GstStatistics +{ GstElement element; GstPad *sinkpad; @@ -65,20 +64,20 @@ struct _GstStatistics { stats update_count; stats update_freq; - gboolean update_on_eos; + gboolean update_on_eos; gboolean update; gboolean silent; }; -struct _GstStatisticsClass { +struct _GstStatisticsClass +{ GstElementClass parent_class; /* signals */ - void (*update) (GstElement *element); + void (*update) (GstElement * element); }; -GType gst_statistics_get_type(void); +GType gst_statistics_get_type (void); G_END_DECLS - #endif /* __GST_STATISTICS_H__ */ diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index 0fc41588b..310a587e1 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -31,21 +31,21 @@ GST_DEBUG_CATEGORY_STATIC (gst_tee_debug); #define GST_CAT_DEFAULT gst_tee_debug -GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS ( - "Tee pipe fitting", - "Generic", - "1-to-N pipe fitting", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_tee_details = GST_ELEMENT_DETAILS ("Tee pipe fitting", + "Generic", + "1-to-N pipe fitting", + "Erik Walthinsen , " + "Wim Taymans "); /* Tee signals and args */ -enum { +enum +{ /* FILL ME */ LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_SILENT, ARG_NUM_PADS, @@ -53,89 +53,93 @@ enum { /* FILL ME */ }; -GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ( - "src%d", - GST_PAD_SRC, - GST_PAD_REQUEST, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate tee_src_template = GST_STATIC_PAD_TEMPLATE ("src%d", + GST_PAD_SRC, + GST_PAD_REQUEST, + GST_STATIC_CAPS_ANY); #define _do_init(bla) \ GST_DEBUG_CATEGORY_INIT (gst_tee_debug, "tee", 0, "tee element"); GST_BOILERPLATE_FULL (GstTee, gst_tee, GstElement, GST_TYPE_ELEMENT, _do_init); -static GstPad* gst_tee_request_new_pad (GstElement *element, GstPadTemplate *temp, const gchar *unused); +static GstPad *gst_tee_request_new_pad (GstElement * element, + GstPadTemplate * temp, const gchar * unused); -static void gst_tee_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_tee_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); +static void gst_tee_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_tee_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static void gst_tee_chain (GstPad *pad, GstData *_data); +static void gst_tee_chain (GstPad * pad, GstData * _data); static void gst_tee_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - + gst_element_class_set_details (gstelement_class, &gst_tee_details); gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&tee_src_template)); } static void -gst_tee_class_init (GstTeeClass *klass) +gst_tee_class_init (GstTeeClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_NUM_PADS, - g_param_spec_int ("num_pads", "num_pads", "num_pads", - 0, G_MAXINT, 0, G_PARAM_READABLE)); + g_param_spec_int ("num_pads", "num_pads", "num_pads", + 0, G_MAXINT, 0, G_PARAM_READABLE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", + TRUE, G_PARAM_CONSTRUCT | G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LAST_MESSAGE, - g_param_spec_string ("last_message", "last_message", "last_message", - NULL, G_PARAM_READABLE)); - + g_param_spec_string ("last_message", "last_message", "last_message", + NULL, G_PARAM_READABLE)); + - gobject_class->set_property = GST_DEBUG_FUNCPTR(gst_tee_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR(gst_tee_get_property); + gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_tee_set_property); + gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_tee_get_property); - gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_tee_request_new_pad); + gstelement_class->request_new_pad = + GST_DEBUG_FUNCPTR (gst_tee_request_new_pad); } -static void -gst_tee_init (GstTee *tee) +static void +gst_tee_init (GstTee * tee) { tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain)); - gst_pad_set_link_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); - gst_pad_set_getcaps_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); + gst_pad_set_link_function (tee->sinkpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); + gst_pad_set_getcaps_function (tee->sinkpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); tee->last_message = NULL; } /* helper compare function */ -gint name_pad_compare (gconstpointer a, gconstpointer b) +gint +name_pad_compare (gconstpointer a, gconstpointer b) { - GstPad* pad = (GstPad*) a; + GstPad *pad = (GstPad *) a; gchar *name = (gchar *) b; - + g_assert (GST_IS_PAD (pad)); - return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */ + return strcmp (name, gst_pad_get_name (pad)); /* returns 0 if match */ } -static GstPad* -gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar *unused) +static GstPad * +gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ, + const gchar * unused) { gchar *name; GstPad *srcpad; @@ -144,7 +148,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar const GList *pads; g_return_val_if_fail (GST_IS_TEE (element), NULL); - + if (templ->direction != GST_PAD_SRC) { g_warning ("gsttee: request new pad that is not a SRC pad\n"); return NULL; @@ -154,13 +158,12 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar /* try names in order and find one that's not in use atm */ pads = gst_element_get_pad_list (element); - + name = NULL; - while (!name) - { + while (!name) { name = g_strdup_printf ("src%d", i); - if (g_list_find_custom ((GList *)pads, (gconstpointer) name, name_pad_compare) != NULL) - { + if (g_list_find_custom ((GList *) pads, (gconstpointer) name, + name_pad_compare) != NULL) { /* this name is taken, use the next one */ ++i; g_free (name); @@ -172,11 +175,13 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar tee->last_message = g_strdup_printf ("new pad %s", name); g_object_notify (G_OBJECT (tee), "last_message"); } - + srcpad = gst_pad_new_from_template (templ, name); g_free (name); - gst_pad_set_link_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); - gst_pad_set_getcaps_function (srcpad, GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); + gst_pad_set_link_function (srcpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_pad_link)); + gst_pad_set_getcaps_function (srcpad, + GST_DEBUG_FUNCPTR (gst_pad_proxy_getcaps)); gst_element_add_pad (GST_ELEMENT (tee), srcpad); GST_PAD_ELEMENT_PRIVATE (srcpad) = NULL; @@ -188,7 +193,8 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar } static void -gst_tee_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_tee_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstTee *tee; @@ -209,7 +215,8 @@ gst_tee_set_property (GObject *object, guint prop_id, const GValue *value, GPara } static void -gst_tee_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_tee_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstTee *tee; @@ -241,8 +248,8 @@ gst_tee_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec * * Chain a buffer on a pad. */ -static void -gst_tee_chain (GstPad *pad, GstData *_data) +static void +gst_tee_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstTee *tee; @@ -255,11 +262,12 @@ gst_tee_chain (GstPad *pad, GstData *_data) tee = GST_TEE (gst_pad_get_parent (pad)); gst_buffer_ref_by_count (buf, GST_ELEMENT (tee)->numsrcpads - 1); - + pads = gst_element_get_pad_list (GST_ELEMENT (tee)); while (pads) { GstPad *outpad = GST_PAD (pads->data); + pads = g_list_next (pads); if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC) @@ -267,9 +275,10 @@ gst_tee_chain (GstPad *pad, GstData *_data) if (!tee->silent) { g_free (tee->last_message); - tee->last_message = g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %" - G_GUINT64_FORMAT ") %p", - GST_DEBUG_PAD_NAME (outpad), GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); + tee->last_message = + g_strdup_printf ("chain ******* (%s:%s)t (%d bytes, %" + G_GUINT64_FORMAT ") %p", GST_DEBUG_PAD_NAME (outpad), + GST_BUFFER_SIZE (buf), GST_BUFFER_TIMESTAMP (buf), buf); g_object_notify (G_OBJECT (tee), "last_message"); } @@ -279,4 +288,3 @@ gst_tee_chain (GstPad *pad, GstData *_data) gst_buffer_unref (buf); } } - diff --git a/plugins/elements/gsttee.h b/plugins/elements/gsttee.h index b58a6c031..aa6279428 100644 --- a/plugins/elements/gsttee.h +++ b/plugins/elements/gsttee.h @@ -27,8 +27,6 @@ #include G_BEGIN_DECLS - - #define GST_TYPE_TEE \ (gst_tee_get_type()) #define GST_TEE(obj) \ @@ -39,27 +37,27 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEE)) #define GST_IS_TEE_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEE)) +typedef struct _GstTee GstTee; +typedef struct _GstTeeClass GstTeeClass; -typedef struct _GstTee GstTee; -typedef struct _GstTeeClass GstTeeClass; - -struct _GstTee { +struct _GstTee +{ GstElement element; GstPad *sinkpad; gboolean silent; - gchar *last_message; + gchar *last_message; }; -struct _GstTeeClass { +struct _GstTeeClass +{ GstElementClass parent_class; }; -GType gst_tee_get_type (void); +GType gst_tee_get_type (void); -gboolean gst_tee_factory_init (GstElementFactory *factory); +gboolean gst_tee_factory_init (GstElementFactory * factory); G_END_DECLS - #endif /* __GST_TEE_H__ */ diff --git a/plugins/elements/gsttypefind.c b/plugins/elements/gsttypefind.c index dc76baac9..0e70b9889 100644 --- a/plugins/elements/gsttypefind.c +++ b/plugins/elements/gsttypefind.c @@ -49,42 +49,42 @@ GST_DEBUG_CATEGORY_STATIC (gst_type_find_element_debug); #define GST_CAT_DEFAULT gst_type_find_element_debug -GstElementDetails gst_type_find_element_details = GST_ELEMENT_DETAILS ( - "TypeFind", - "Generic", - "Finds the media type of a stream", - "Benjamin Otte " -); +GstElementDetails gst_type_find_element_details = +GST_ELEMENT_DETAILS ("TypeFind", + "Generic", + "Finds the media type of a stream", + "Benjamin Otte "); /* generic templates */ -GstStaticPadTemplate type_find_element_sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); - -GstStaticPadTemplate type_find_element_src_template = GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +GstStaticPadTemplate type_find_element_sink_template = +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); + +GstStaticPadTemplate type_find_element_src_template = +GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); /* TypeFind signals and args */ -enum { +enum +{ HAVE_TYPE, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_CAPS, ARG_MINIMUM, ARG_MAXIMUM }; -enum { - MODE_NORMAL, /* act as identity */ - MODE_TYPEFIND, /* do typefinding */ +enum +{ + MODE_NORMAL, /* act as identity */ + MODE_TYPEFIND, /* do typefinding */ }; @@ -92,32 +92,28 @@ enum { GST_DEBUG_CATEGORY_INIT (gst_type_find_element_debug, "typefind", \ GST_DEBUG_BG_YELLOW | GST_DEBUG_FG_GREEN, "type finding element"); -GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement, GST_TYPE_ELEMENT, _do_init); +GST_BOILERPLATE_FULL (GstTypeFindElement, gst_type_find_element, GstElement, + GST_TYPE_ELEMENT, _do_init); -static void gst_type_find_element_dispose (GObject * object); -static void gst_type_find_element_set_property (GObject * object, - guint prop_id, - const GValue * value, - GParamSpec * pspec); -static void gst_type_find_element_get_property (GObject * object, - guint prop_id, - GValue * value, - GParamSpec * pspec); +static void gst_type_find_element_dispose (GObject * object); +static void gst_type_find_element_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void gst_type_find_element_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); -static const GstEventMask * - gst_type_find_element_src_event_mask (GstPad * pad); -static gboolean gst_type_find_element_src_event (GstPad * pad, - GstEvent * event); +static const GstEventMask *gst_type_find_element_src_event_mask (GstPad * pad); +static gboolean gst_type_find_element_src_event (GstPad * pad, + GstEvent * event); -static void gst_type_find_element_chain (GstPad * sinkpad, - GstData * data); +static void gst_type_find_element_chain (GstPad * sinkpad, GstData * data); static GstElementStateReturn - gst_type_find_element_change_state (GstElement * element); +gst_type_find_element_change_state (GstElement * element); static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 }; static void -gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) +gst_type_find_element_have_type (GstTypeFindElement * typefind, + guint probability, const GstCaps * caps) { g_assert (typefind->caps == NULL); g_assert (caps != NULL); @@ -130,53 +126,62 @@ static void gst_type_find_element_base_init (gpointer g_class) { GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); - - gst_element_class_set_details (gstelement_class, &gst_type_find_element_details); + + gst_element_class_set_details (gstelement_class, + &gst_type_find_element_details); } static void -gst_type_find_element_class_init (GstTypeFindElementClass *typefind_class) +gst_type_find_element_class_init (GstTypeFindElementClass * typefind_class) { GObjectClass *gobject_class = G_OBJECT_CLASS (typefind_class); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (typefind_class); - gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_type_find_element_set_property); - gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_type_find_element_get_property); - gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose); + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_type_find_element_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_type_find_element_get_property); + gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_type_find_element_dispose); typefind_class->have_type = gst_type_find_element_have_type; g_object_class_install_property (gobject_class, ARG_CAPS, - g_param_spec_boxed ("caps", _("caps"), _("detected capabilities in stream"), - gst_caps_get_type(), G_PARAM_READABLE)); + g_param_spec_boxed ("caps", _("caps"), + _("detected capabilities in stream"), gst_caps_get_type (), + G_PARAM_READABLE)); g_object_class_install_property (gobject_class, ARG_MINIMUM, - g_param_spec_uint ("minimum", _("minimum"), "minimum probability required to accept caps", - GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE)); + g_param_spec_uint ("minimum", _("minimum"), + "minimum probability required to accept caps", GST_TYPE_FIND_MINIMUM, + GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MINIMUM, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_MINIMUM, - g_param_spec_uint ("maximum", _("maximum"), "probability to stop typefinding", - GST_TYPE_FIND_MINIMUM, GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE)); - - gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", - G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, - gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, - G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE); - - gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); + g_param_spec_uint ("maximum", _("maximum"), + "probability to stop typefinding", GST_TYPE_FIND_MINIMUM, + GST_TYPE_FIND_MAXIMUM, GST_TYPE_FIND_MAXIMUM, G_PARAM_READWRITE)); + + gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", + G_TYPE_FROM_CLASS (typefind_class), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, + gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, + G_TYPE_UINT, GST_TYPE_CAPS | G_SIGNAL_TYPE_STATIC_SCOPE); + + gstelement_class->change_state = + GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); } static void -gst_type_find_element_init (GstTypeFindElement *typefind) +gst_type_find_element_init (GstTypeFindElement * typefind) { /* sinkpad */ - typefind->sink = gst_pad_new_from_template ( - gst_static_pad_template_get (&type_find_element_sink_template), "sink"); - gst_pad_set_chain_function (typefind->sink, - gst_type_find_element_chain); + typefind->sink = + gst_pad_new_from_template (gst_static_pad_template_get + (&type_find_element_sink_template), "sink"); + gst_pad_set_chain_function (typefind->sink, gst_type_find_element_chain); gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink); /* srcpad */ - typefind->src = gst_pad_new_from_template ( - gst_static_pad_template_get (&type_find_element_src_template), "src"); + typefind->src = + gst_pad_new_from_template (gst_static_pad_template_get + (&type_find_element_src_template), "src"); gst_pad_set_event_function (typefind->src, gst_type_find_element_src_event); - gst_pad_set_event_mask_function (typefind->src, gst_type_find_element_src_event_mask); + gst_pad_set_event_mask_function (typefind->src, + gst_type_find_element_src_event_mask); gst_pad_use_explicit_caps (typefind->src); gst_element_add_pad (GST_ELEMENT (typefind), typefind->src); @@ -189,7 +194,7 @@ gst_type_find_element_init (GstTypeFindElement *typefind) GST_FLAG_SET (typefind, GST_ELEMENT_EVENT_AWARE); } static void -gst_type_find_element_dispose (GObject *object) +gst_type_find_element_dispose (GObject * object) { GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (object); @@ -201,8 +206,8 @@ gst_type_find_element_dispose (GObject *object) } } static void -gst_type_find_element_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +gst_type_find_element_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { GstTypeFindElement *typefind; @@ -225,8 +230,8 @@ gst_type_find_element_set_property (GObject *object, guint prop_id, } } static void -gst_type_find_element_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +gst_type_find_element_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { GstTypeFindElement *typefind; @@ -250,18 +255,21 @@ gst_type_find_element_get_property (GObject *object, guint prop_id, } } static const GstEventMask * -gst_type_find_element_src_event_mask (GstPad *pad) +gst_type_find_element_src_event_mask (GstPad * pad) { static const GstEventMask mask[] = { - { GST_EVENT_SEEK, GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | GST_SEEK_FLAG_FLUSH}, + {GST_EVENT_SEEK, + GST_SEEK_METHOD_SET | GST_SEEK_METHOD_CUR | GST_SEEK_METHOD_END | + GST_SEEK_FLAG_FLUSH}, /* add more if you want, event masks suck and need to die anyway */ - { 0, } + {0,} }; - + return mask; } -static gboolean -gst_type_find_element_src_event (GstPad *pad, GstEvent *event) + +static gboolean +gst_type_find_element_src_event (GstPad * pad, GstEvent * event) { GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); @@ -272,15 +280,16 @@ gst_type_find_element_src_event (GstPad *pad, GstEvent *event) } return gst_pad_event_default (pad, event); } -typedef struct { - GstTypeFindFactory * factory; - gint probability; - GstCaps * caps; - gint64 requested_offset; - guint requested_size; - - GList * buffers; - GstTypeFindElement * self; +typedef struct +{ + GstTypeFindFactory *factory; + gint probability; + GstCaps *caps; + gint64 requested_offset; + guint requested_size; + + GList *buffers; + GstTypeFindElement *self; } TypeFindEntry; static inline TypeFindEntry * @@ -289,42 +298,45 @@ new_entry (void) return g_new0 (TypeFindEntry, 1); } static void -free_entry_buffers (TypeFindEntry *entry) +free_entry_buffers (TypeFindEntry * entry) { g_list_foreach (entry->buffers, (GFunc) gst_data_unref, NULL); g_list_free (entry->buffers); entry->buffers = NULL; } static void -free_entry (TypeFindEntry *entry) +free_entry (TypeFindEntry * entry) { free_entry_buffers (entry); - + if (entry->caps) gst_caps_free (entry->caps); g_free (entry); } static void -start_typefinding (GstTypeFindElement *typefind) +start_typefinding (GstTypeFindElement * typefind) { g_assert (typefind->caps == NULL); g_assert (typefind->possibilities == NULL); - + GST_DEBUG_OBJECT (typefind, "starting typefinding"); - typefind->mode = MODE_TYPEFIND; - typefind->stream_length_available = TRUE; - typefind->stream_length = 0; + typefind->mode = MODE_TYPEFIND; + typefind->stream_length_available = TRUE; + typefind->stream_length = 0; } static void -stop_typefinding (GstTypeFindElement *typefind) +stop_typefinding (GstTypeFindElement * typefind) { /* stop all typefinding and set mode back to normal */ - gboolean push_cached_buffers = gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING; - - GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", push_cached_buffers ? " and pushing cached buffers" : ""); + gboolean push_cached_buffers = + gst_element_get_state (GST_ELEMENT (typefind)) == GST_STATE_PLAYING; + + GST_DEBUG_OBJECT (typefind, "stopping typefinding%s", + push_cached_buffers ? " and pushing cached buffers" : ""); if (typefind->possibilities != NULL) { /* this should only happen on PAUSED => READY or EOS */ - GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", g_list_length (typefind->possibilities)); + GST_LOG_OBJECT (typefind, "freeing remaining %u typefind functions", + g_list_length (typefind->possibilities)); g_list_foreach (typefind->possibilities, (GFunc) free_entry, NULL); g_list_free (typefind->possibilities); typefind->possibilities = NULL; @@ -336,51 +348,59 @@ stop_typefinding (GstTypeFindElement *typefind) GstBuffer *buffer; guint size = gst_buffer_store_get_size (typefind->store, 0); - if (size && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) { + if (size + && (buffer = gst_buffer_store_get_buffer (typefind->store, 0, size))) { GST_LOG_OBJECT (typefind, "pushing cached data (%u bytes)", size); gst_pad_push (typefind->src, GST_DATA (buffer)); } else { size = 0; } GST_LOG_OBJECT (typefind, "seeking back to current position %u", size); - if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink), - gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, size))) { - GST_WARNING_OBJECT (typefind, "could not seek to required position %u, hope for the best", size); + if (!gst_pad_send_event (GST_PAD_PEER (typefind->sink), + gst_event_new_seek (GST_SEEK_METHOD_SET | GST_FORMAT_BYTES, + size))) { + GST_WARNING_OBJECT (typefind, + "could not seek to required position %u, hope for the best", size); } } gst_buffer_store_clear (typefind->store); } + static guint64 find_element_get_length (gpointer data) { TypeFindEntry *entry = (TypeFindEntry *) data; GstTypeFindElement *typefind = entry->self; GstFormat format = GST_FORMAT_BYTES; - + if (!typefind->stream_length_available) { - GST_LOG_OBJECT (entry->self, "'%s' called get_length () but we know it's not available", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_LOG_OBJECT (entry->self, + "'%s' called get_length () but we know it's not available", + GST_PLUGIN_FEATURE_NAME (entry->factory)); return 0; } if (entry->self->stream_length == 0) { - typefind->stream_length_available = gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL, - &format, &entry->self->stream_length); + typefind->stream_length_available = + gst_pad_query (GST_PAD_PEER (entry->self->sink), GST_QUERY_TOTAL, + &format, &entry->self->stream_length); if (format != GST_FORMAT_BYTES) typefind->stream_length_available = FALSE; if (!typefind->stream_length_available) { - GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () but it's not available", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_DEBUG_OBJECT (entry->self, + "'%s' called get_length () but it's not available", + GST_PLUGIN_FEATURE_NAME (entry->factory)); return 0; } else { - GST_DEBUG_OBJECT (entry->self, "'%s' called get_length () and it's %"G_GUINT64_FORMAT" bytes", - GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length); + GST_DEBUG_OBJECT (entry->self, + "'%s' called get_length () and it's %" G_GUINT64_FORMAT " bytes", + GST_PLUGIN_FEATURE_NAME (entry->factory), entry->self->stream_length); } } - + return entry->self->stream_length; } static void -gst_type_find_element_handle_event (GstPad *pad, GstEvent *event) +gst_type_find_element_handle_event (GstPad * pad, GstEvent * event) { TypeFindEntry *entry; GstTypeFindElement *typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); @@ -388,20 +408,24 @@ gst_type_find_element_handle_event (GstPad *pad, GstEvent *event) if (typefind->mode == MODE_TYPEFIND) { /* need to do more? */ switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_EOS: - /* this should only happen when we got all available data */ - entry = (TypeFindEntry *) typefind->possibilities ? typefind->possibilities->data : NULL; - if (entry && entry->probability >= typefind->min_probability) { - GST_INFO_OBJECT (typefind, "'%s' is the best typefind left after we got all data, using it now (probability %u)", - GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); - g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps); - } - stop_typefinding (typefind); - gst_pad_event_default (pad, event); - break; - default: - gst_data_unref (GST_DATA (event)); - break; + case GST_EVENT_EOS: + /* this should only happen when we got all available data */ + entry = + (TypeFindEntry *) typefind->possibilities ? typefind-> + possibilities->data : NULL; + if (entry && entry->probability >= typefind->min_probability) { + GST_INFO_OBJECT (typefind, + "'%s' is the best typefind left after we got all data, using it now (probability %u)", + GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); + g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, + entry->probability, entry->caps); + } + stop_typefinding (typefind); + gst_pad_event_default (pad, event); + break; + default: + gst_data_unref (GST_DATA (event)); + break; } } else { gst_pad_event_default (pad, event); @@ -412,9 +436,9 @@ find_peek (gpointer data, gint64 offset, guint size) { GstBuffer *buf; TypeFindEntry *entry = (TypeFindEntry *) data; - - GST_LOG_OBJECT (entry->self, "'%s' called peek (%"G_GINT64_FORMAT", %u)", - GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size); + + GST_LOG_OBJECT (entry->self, "'%s' called peek (%" G_GINT64_FORMAT ", %u)", + GST_PLUGIN_FEATURE_NAME (entry->factory), offset, size); if (offset >= 0) { buf = gst_buffer_store_get_buffer (entry->self->store, offset, size); } else { @@ -424,7 +448,9 @@ find_peek (gpointer data, gint64 offset, guint size) if (length == 0) { buf = NULL; } else { - buf = gst_buffer_store_get_buffer (entry->self->store, length + offset, size); + buf = + gst_buffer_store_get_buffer (entry->self->store, length + offset, + size); } } @@ -433,8 +459,9 @@ find_peek (gpointer data, gint64 offset, guint size) return GST_BUFFER_DATA (buf); } else { if (entry->requested_size == 0) { - GST_LOG_OBJECT (entry->self, "setting requested peek (%"G_GINT64_FORMAT", %u) on '%s'", - offset, size, GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_LOG_OBJECT (entry->self, + "setting requested peek (%" G_GINT64_FORMAT ", %u) on '%s'", offset, + size, GST_PLUGIN_FEATURE_NAME (entry->factory)); entry->requested_offset = offset; entry->requested_size = size; } @@ -442,12 +469,12 @@ find_peek (gpointer data, gint64 offset, guint size) } } static void -find_suggest (gpointer data, guint probability, const GstCaps *caps) +find_suggest (gpointer data, guint probability, const GstCaps * caps) { TypeFindEntry *entry = (TypeFindEntry *) data; - - GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", - GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps); + + GST_LOG_OBJECT (entry->self, "'%s' called suggest (%u, %" GST_PTR_FORMAT ")", + GST_PLUGIN_FEATURE_NAME (entry->factory), probability, caps); if (((gint) probability) > entry->probability) { entry->probability = probability; gst_caps_replace (&entry->caps, gst_caps_copy (caps)); @@ -472,13 +499,13 @@ compare_type_find_factory (gconstpointer fac1, gconstpointer fac2) return GST_PLUGIN_FEATURE (fac1)->rank - GST_PLUGIN_FEATURE (fac2)->rank; } static void -gst_type_find_element_chain (GstPad *pad, GstData *data) +gst_type_find_element_chain (GstPad * pad, GstData * data) { GstTypeFindElement *typefind; GList *entries; TypeFindEntry *entry; GList *walk; - GstTypeFind find = {find_peek, find_suggest, NULL, find_element_get_length }; + GstTypeFind find = { find_peek, find_suggest, NULL, find_element_get_length }; typefind = GST_TYPE_FIND_ELEMENT (GST_PAD_PARENT (pad)); if (GST_IS_EVENT (data)) { @@ -489,36 +516,39 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) case MODE_NORMAL: gst_pad_push (typefind->src, data); return; - case MODE_TYPEFIND: { + case MODE_TYPEFIND:{ guint64 current_offset; - + gst_buffer_store_add_buffer (typefind->store, GST_BUFFER (data)); - current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? - GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : + current_offset = GST_BUFFER_OFFSET_IS_VALID (data) ? + GST_BUFFER_OFFSET (data) + GST_BUFFER_SIZE (data) : gst_buffer_store_get_size (typefind->store, 0); gst_data_unref (data); if (typefind->possibilities == NULL) { /* not yet started, get all typefinding functions into our "queue" */ GList *all_factories = gst_type_find_factory_get_list (); - GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", - g_list_length ((GList *) all_factories)); - + + GST_INFO_OBJECT (typefind, "starting with %u typefinding functions", + g_list_length ((GList *) all_factories)); + all_factories = g_list_sort (all_factories, compare_type_find_factory); walk = all_factories; while (all_factories) { entry = new_entry (); - + entry->factory = GST_TYPE_FIND_FACTORY (all_factories->data); entry->self = typefind; entry->probability = 0; - typefind->possibilities = g_list_prepend (typefind->possibilities, entry); + typefind->possibilities = + g_list_prepend (typefind->possibilities, entry); all_factories = g_list_next (all_factories); } g_list_free (all_factories); } /* call every typefind function once */ walk = entries = typefind->possibilities; - GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", g_list_length (entries)); + GST_INFO_OBJECT (typefind, "iterating %u typefinding functions", + g_list_length (entries)); typefind->possibilities = NULL; while (walk) { find.data = entry = (TypeFindEntry *) walk->data; @@ -529,16 +559,19 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gst_type_find_factory_call_function (entry->factory, &find); free_entry_buffers (entry); if (entry->probability == 0 && entry->requested_size == 0) { - GST_DEBUG_OBJECT (typefind, "'%s' was removed - no chance of being the right plugin", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_DEBUG_OBJECT (typefind, + "'%s' was removed - no chance of being the right plugin", + GST_PLUGIN_FEATURE_NAME (entry->factory)); free_entry (entry); } else if (entry->probability >= typefind->max_probability) { /* wooha, got caps */ GstCaps *found_caps = entry->caps; guint probability = entry->probability; - - GST_INFO_OBJECT (typefind, "'%s' returned %u/%u probability, using it NOW", - GST_PLUGIN_FEATURE_NAME (entry->factory), probability, typefind->max_probability); + + GST_INFO_OBJECT (typefind, + "'%s' returned %u/%u probability, using it NOW", + GST_PLUGIN_FEATURE_NAME (entry->factory), probability, + typefind->max_probability); while (walk) { free_entry ((TypeFindEntry *) walk->data); walk = g_list_next (walk); @@ -549,11 +582,13 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) walk = g_list_next (walk); } typefind->possibilities = NULL; - g_list_free (typefind->possibilities); - g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, probability, found_caps); + g_list_free (typefind->possibilities); + g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, + probability, found_caps); free_entry (entry); } else { - typefind->possibilities = g_list_prepend (typefind->possibilities, entry); + typefind->possibilities = + g_list_prepend (typefind->possibilities, entry); } } g_list_free (entries); @@ -564,8 +599,9 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) GST_ELEMENT_ERROR (typefind, STREAM, TYPE_NOT_FOUND, (NULL), (NULL)); } else { /* set up typefind element for next iteration */ - typefind->possibilities = g_list_sort (typefind->possibilities, compare_type_find_entry); - + typefind->possibilities = + g_list_sort (typefind->possibilities, compare_type_find_entry); + /* look for typefind functions that require data without seeking */ for (walk = typefind->possibilities; walk; walk = g_list_next (walk)) { entry = (TypeFindEntry *) walk->data; @@ -582,19 +618,27 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) gint64 seek_offset; GstEvent *event; - seek_offset = entry->requested_offset > 0 ? entry->requested_offset : - find_element_get_length (entry) + entry->requested_offset; - seek_offset += gst_buffer_store_get_size (typefind->store, seek_offset); - event = gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, seek_offset); + seek_offset = + entry->requested_offset > + 0 ? entry-> + requested_offset : find_element_get_length (entry) + + entry->requested_offset; + seek_offset += + gst_buffer_store_get_size (typefind->store, seek_offset); + event = + gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET, + seek_offset); if (gst_pad_send_event (GST_PAD_PEER (typefind->sink), event)) { /* done seeking */ - GST_DEBUG_OBJECT (typefind, "'%s' was reset - seeked to %"G_GINT64_FORMAT, - GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); + GST_DEBUG_OBJECT (typefind, + "'%s' was reset - seeked to %" G_GINT64_FORMAT, + GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); break; } else if (entry->requested_offset < 0) { /* impossible to seek */ - GST_DEBUG_OBJECT (typefind, "'%s' was reset - couldn't seek to %"G_GINT64_FORMAT, - GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); + GST_DEBUG_OBJECT (typefind, + "'%s' was reset - couldn't seek to %" G_GINT64_FORMAT, + GST_PLUGIN_FEATURE_NAME (entry->factory), seek_offset); entry->requested_size = 0; entry->requested_offset = 0; } @@ -605,21 +649,26 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) walk = g_list_next (typefind->possibilities); while (walk) { GList *cur = walk; + entry = (TypeFindEntry *) walk->data; walk = g_list_next (walk); if (entry->requested_size == 0) { - GST_DEBUG_OBJECT (typefind, "'%s' was removed - higher possibilities available", - GST_PLUGIN_FEATURE_NAME (entry->factory)); + GST_DEBUG_OBJECT (typefind, + "'%s' was removed - higher possibilities available", + GST_PLUGIN_FEATURE_NAME (entry->factory)); free_entry (entry); - typefind->possibilities = g_list_delete_link (typefind->possibilities, cur); + typefind->possibilities = + g_list_delete_link (typefind->possibilities, cur); } } if (g_list_next (typefind->possibilities) == NULL) { entry = (TypeFindEntry *) typefind->possibilities->data; if (entry->probability > typefind->min_probability) { - GST_INFO_OBJECT (typefind, "'%s' is the only typefind left, using it now (probability %u)", - GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); - g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], 0, entry->probability, entry->caps); + GST_INFO_OBJECT (typefind, + "'%s' is the only typefind left, using it now (probability %u)", + GST_PLUGIN_FEATURE_NAME (entry->factory), entry->probability); + g_signal_emit (typefind, gst_type_find_element_signals[HAVE_TYPE], + 0, entry->probability, entry->caps); free_entry (entry); g_list_free (typefind->possibilities); typefind->possibilities = NULL; @@ -635,7 +684,7 @@ gst_type_find_element_chain (GstPad *pad, GstData *data) } } static GstElementStateReturn -gst_type_find_element_change_state (GstElement *element) +gst_type_find_element_change_state (GstElement * element) { GstTypeFindElement *typefind; @@ -652,6 +701,6 @@ gst_type_find_element_change_state (GstElement *element) default: break; } - + return GST_ELEMENT_CLASS (parent_class)->change_state (element); } diff --git a/plugins/elements/gsttypefind.h b/plugins/elements/gsttypefind.h index 03eeccdcb..f2d8c7123 100644 --- a/plugins/elements/gsttypefind.h +++ b/plugins/elements/gsttypefind.h @@ -29,48 +29,44 @@ #include "gstbufferstore.h" G_BEGIN_DECLS - - - #define GST_TYPE_TYPE_FIND_ELEMENT (gst_type_find_element_get_type ()) #define GST_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElement)) #define GST_IS_TYPE_FIND_ELEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TYPE_FIND_ELEMENT)) #define GST_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass)) #define GST_IS_TYPE_FIND_ELEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TYPE_FIND_ELEMENT)) #define GST_TYPE_FIND_ELEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TYPE_FIND_ELEMENT, GstTypeFindElementClass)) +typedef struct _GstTypeFindElement GstTypeFindElement; +typedef struct _GstTypeFindElementClass GstTypeFindElementClass; -typedef struct _GstTypeFindElement GstTypeFindElement; -typedef struct _GstTypeFindElementClass GstTypeFindElementClass; +struct _GstTypeFindElement +{ + GstElement element; -struct _GstTypeFindElement { - GstElement element; + GstPad *sink; + GstPad *src; - GstPad * sink; - GstPad * src; + guint min_probability; + guint max_probability; + GstCaps *caps; - guint min_probability; - guint max_probability; - GstCaps * caps; + guint mode; + GstBufferStore *store; + guint64 stream_length; + gboolean stream_length_available; - guint mode; - GstBufferStore * store; - guint64 stream_length; - gboolean stream_length_available; - - GList * possibilities; + GList *possibilities; }; -struct _GstTypeFindElementClass { - GstElementClass parent_class; +struct _GstTypeFindElementClass +{ + GstElementClass parent_class; /* signals */ - void (*have_type) (GstTypeFindElement *element, - guint probability, - const GstCaps * caps); + void (*have_type) (GstTypeFindElement * element, + guint probability, const GstCaps * caps); }; GType gst_type_find_element_get_type (void); G_END_DECLS - #endif /* __GST_TYPE_FIND_ELEMENT_H__ */ diff --git a/plugins/indexers/gstfileindex.c b/plugins/indexers/gstfileindex.c index ccb969e78..56a09e38b 100644 --- a/plugins/indexers/gstfileindex.c +++ b/plugins/indexers/gstfileindex.c @@ -37,7 +37,7 @@ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FILE_INDEX)) #define GST_IS_FILE_INDEX_CLASS(obj) \ (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FILE_INDEX)) - + #ifndef __FUNCTION__ #define __FUNCTION__ "Unavailable" #endif @@ -71,12 +71,13 @@ /* * Each array element is (32bits flags, nformats * 64bits) */ -typedef struct { - gint id; - gchar *id_desc; - gint nformats; - GstFormat *format; - GArray *array; +typedef struct +{ + gint id; + gchar *id_desc; + gint nformats; + GstFormat *format; + GArray *array; } GstFileIndexId; typedef struct _GstFileIndex GstFileIndex; @@ -93,118 +94,118 @@ typedef struct _GstFileIndexClass GstFileIndexClass; #define ARRAY_ROW_VALUE(_row,_vx) \ (*(gint64*) (((gchar*)(_row)) + sizeof (gint32) + (_vx) * sizeof (gint64))) -GST_DEBUG_CATEGORY_STATIC(DC); +GST_DEBUG_CATEGORY_STATIC (DC); -struct _GstFileIndex { - GstIndex parent; +struct _GstFileIndex +{ + GstIndex parent; - gchar *location; - gboolean is_loaded; - GSList *unresolved; - gint next_id; - GHashTable *id_index; + gchar *location; + gboolean is_loaded; + GSList *unresolved; + gint next_id; + GHashTable *id_index; - GstIndexEntry *ret_entry; /* hack to avoid leaking memory */ + GstIndexEntry *ret_entry; /* hack to avoid leaking memory */ }; -struct _GstFileIndexClass { +struct _GstFileIndexClass +{ GstIndexClass parent_class; }; -enum { +enum +{ ARG_0, ARG_LOCATION, }; -static void gst_file_index_class_init (GstFileIndexClass *klass); -static void gst_file_index_init (GstFileIndex *index); -static void gst_file_index_dispose (GObject *object); +static void gst_file_index_class_init (GstFileIndexClass * klass); +static void gst_file_index_init (GstFileIndex * index); +static void gst_file_index_dispose (GObject * object); static void -gst_file_index_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); +gst_file_index_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); static void -gst_file_index_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); +gst_file_index_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); static gboolean -gst_file_index_get_writer_id (GstIndex *_index, gint *id, gchar *writer_string); +gst_file_index_get_writer_id (GstIndex * _index, gint * id, + gchar * writer_string); -static void gst_file_index_commit (GstIndex *index, gint writer_id); -static void gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry); -static GstIndexEntry* gst_file_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, - GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data); +static void gst_file_index_commit (GstIndex * index, gint writer_id); +static void gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry); +static GstIndexEntry *gst_file_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, + GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data); #define CLASS(file_index) GST_FILE_INDEX_CLASS (G_OBJECT_GET_CLASS (file_index)) static GstIndex *parent_class = NULL; GType -gst_file_index_get_type(void) { +gst_file_index_get_type (void) +{ static GType file_index_type = 0; if (!file_index_type) { static const GTypeInfo file_index_info = { - sizeof(GstFileIndexClass), + sizeof (GstFileIndexClass), NULL, NULL, - (GClassInitFunc)gst_file_index_class_init, + (GClassInitFunc) gst_file_index_class_init, NULL, NULL, - sizeof(GstFileIndex), + sizeof (GstFileIndex), 1, - (GInstanceInitFunc)gst_file_index_init, + (GInstanceInitFunc) gst_file_index_init, NULL }; - file_index_type = g_type_register_static(GST_TYPE_INDEX, "GstFileIndex", &file_index_info, 0); + file_index_type = + g_type_register_static (GST_TYPE_INDEX, "GstFileIndex", + &file_index_info, 0); } return file_index_type; } static void -gst_file_index_class_init (GstFileIndexClass *klass) +gst_file_index_class_init (GstFileIndexClass * klass) { GObjectClass *gobject_class; GstIndexClass *gstindex_class; - gobject_class = (GObjectClass*)klass; - gstindex_class = (GstIndexClass*)klass; + gobject_class = (GObjectClass *) klass; + gstindex_class = (GstIndexClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_INDEX); + parent_class = g_type_class_ref (GST_TYPE_INDEX); - gobject_class->dispose = gst_file_index_dispose; - gobject_class->set_property = gst_file_index_set_property; - gobject_class->get_property = gst_file_index_get_property; + gobject_class->dispose = gst_file_index_dispose; + gobject_class->set_property = gst_file_index_set_property; + gobject_class->get_property = gst_file_index_get_property; - gstindex_class->add_entry = gst_file_index_add_entry; + gstindex_class->add_entry = gst_file_index_add_entry; gstindex_class->get_assoc_entry = gst_file_index_get_assoc_entry; - gstindex_class->commit = gst_file_index_commit; - gstindex_class->get_writer_id = gst_file_index_get_writer_id ; + gstindex_class->commit = gst_file_index_commit; + gstindex_class->get_writer_id = gst_file_index_get_writer_id; g_object_class_install_property (gobject_class, ARG_LOCATION, - g_param_spec_string ("location", "File Location", - "Location of the index file", - NULL, G_PARAM_READWRITE)); + g_param_spec_string ("location", "File Location", + "Location of the index file", NULL, G_PARAM_READWRITE)); } static void -gst_file_index_init (GstFileIndex *index) +gst_file_index_init (GstFileIndex * index) { - GST_DEBUG ( "created new file index"); + GST_DEBUG ("created new file index"); index->id_index = g_hash_table_new (g_int_hash, g_int_equal); } static void -_file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped) +_file_index_id_free (GstFileIndexId * index_id, gboolean is_mmapped) { if (index_id->id_desc) g_free (index_id->id_desc); @@ -212,22 +213,22 @@ _file_index_id_free (GstFileIndexId *index_id, gboolean is_mmapped) g_free (index_id->format); if (index_id->array) { if (is_mmapped) - munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id)); + munmap (index_id->array->data, ARRAY_TOTAL_SIZE (index_id)); g_array_free (index_id->array, !is_mmapped); } g_free (index_id); } static gboolean -_id_index_free_helper (gpointer _key, GstFileIndexId *index_id, - GstFileIndex *index) +_id_index_free_helper (gpointer _key, GstFileIndexId * index_id, + GstFileIndex * index) { _file_index_id_free (index_id, index->is_loaded); return TRUE; } static void -gst_file_index_dispose (GObject *object) +gst_file_index_dispose (GObject * object) { GstFileIndex *index = GST_FILE_INDEX (object); @@ -238,23 +239,25 @@ gst_file_index_dispose (GObject *object) { GSList *elem; + for (elem = index->unresolved; elem; elem = g_slist_next (elem)) _file_index_id_free (elem->data, index->is_loaded); g_slist_free (index->unresolved); index->unresolved = NULL; } - + g_hash_table_foreach_steal (index->id_index, - (GHRFunc) _id_index_free_helper, index); + (GHRFunc) _id_index_free_helper, index); g_hash_table_destroy (index->id_index); index->id_index = NULL; - gst_index_entry_free (index->ret_entry); /* hack */ + gst_index_entry_free (index->ret_entry); /* hack */ G_OBJECT_CLASS (parent_class)->dispose (object); } -struct fi_find_writer_context { +struct fi_find_writer_context +{ const gchar *writer_string; GstFileIndexId *ii; }; @@ -264,13 +267,14 @@ _fi_find_writer (gpointer key, gpointer val, gpointer data) { struct fi_find_writer_context *cx = data; GstFileIndexId *ii = val; + if (strcmp (ii->id_desc, cx->writer_string) == 0) cx->ii = ii; } static gboolean -gst_file_index_get_writer_id (GstIndex *_index, - gint *id, gchar *writer_string) +gst_file_index_get_writer_id (GstIndex * _index, + gint * id, gchar * writer_string) { GstFileIndex *index = GST_FILE_INDEX (_index); GSList *pending = index->unresolved; @@ -287,14 +291,15 @@ gst_file_index_get_writer_id (GstIndex *_index, for (elem = pending; elem; elem = g_slist_next (elem)) { GstFileIndexId *ii = elem->data; + if (strcmp (ii->id_desc, writer_string) != 0) { index->unresolved = g_slist_prepend (index->unresolved, ii); continue; } - + if (match) { GST_CAT_WARNING_OBJECT (DC, index, "Duplicate matches for writer '%s'", - writer_string); + writer_string); continue; } @@ -307,6 +312,7 @@ gst_file_index_get_writer_id (GstIndex *_index, if (!match) { struct fi_find_writer_context cx; + cx.writer_string = writer_string; cx.ii = NULL; g_hash_table_foreach (index->id_index, _fi_find_writer, &cx); @@ -314,26 +320,25 @@ gst_file_index_get_writer_id (GstIndex *_index, if (cx.ii) { match = TRUE; GST_CAT_DEBUG_OBJECT (DC, index, "Resolved writer '%s' again", - writer_string); - } - else + writer_string); + } else GST_CAT_WARNING_OBJECT (DC, index, "Can't resolve writer '%s'", - writer_string); + writer_string); } return match; } static void -_fc_alloc_array (GstFileIndexId *id_index) +_fc_alloc_array (GstFileIndexId * id_index) { g_assert (!id_index->array); id_index->array = - g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0); + g_array_sized_new (FALSE, FALSE, ARRAY_ROW_SIZE (id_index), 0); } static void -gst_file_index_load (GstFileIndex *index) +gst_file_index_load (GstFileIndex * index) { xmlDocPtr doc; xmlNodePtr root, part; @@ -347,6 +352,7 @@ gst_file_index_load (GstFileIndex *index) GError *err = NULL; gchar *buf; gsize len; + g_file_get_contents (path, &buf, &len, &err); g_free (path); if (err) { @@ -365,7 +371,7 @@ gst_file_index_load (GstFileIndex *index) GST_CAT_ERROR_OBJECT (DC, index, "root node isn't a gstfileindex"); return; } - + val = xmlGetProp (root, "version"); if (!val || atoi (val) != 1) { GST_CAT_ERROR_OBJECT (DC, index, "version != 1"); @@ -376,6 +382,7 @@ gst_file_index_load (GstFileIndex *index) for (part = root->children; part; part = part->next) { if (strcmp (part->name, "writers") == 0) { xmlNodePtr writer; + for (writer = part->children; writer; writer = writer->next) { xmlChar *datafile = xmlGetProp (writer, "datafile"); gchar *path = g_strdup_printf ("%s/%s", index->location, datafile); @@ -391,7 +398,7 @@ gst_file_index_load (GstFileIndex *index) g_free (path); if (fd < 0) { GST_CAT_ERROR_OBJECT (DC, index, - "Can't open '%s': %s", path, strerror (errno)); + "Can't open '%s': %s", path, strerror (errno)); continue; } @@ -401,7 +408,7 @@ gst_file_index_load (GstFileIndex *index) for (wpart = writer->children; wpart; wpart = wpart->next) { if (strcmp (wpart->name, "formats") == 0) { xmlChar *count_str = xmlGetProp (wpart, "count"); - gint fx=0; + gint fx = 0; xmlNodePtr format; id_index->nformats = atoi (count_str); @@ -409,13 +416,12 @@ gst_file_index_load (GstFileIndex *index) id_index->format = g_new (GstFormat, id_index->nformats); - for (format = wpart->children; - format; format = format->next) { + for (format = wpart->children; format; format = format->next) { xmlChar *nick = xmlGetProp (format, "nick"); GstFormat fmt = gst_format_get_by_nick (nick); + if (fmt == GST_FORMAT_UNDEFINED) - GST_CAT_ERROR_OBJECT (DC, index, - "format '%s' undefined", nick); + GST_CAT_ERROR_OBJECT (DC, index, "format '%s' undefined", nick); g_assert (fx < id_index->nformats); id_index->format[fx++] = fmt; free (nick); @@ -426,18 +432,19 @@ gst_file_index_load (GstFileIndex *index) g_assert (id_index->nformats > 0); _fc_alloc_array (id_index); - g_assert (id_index->array->data == NULL); /* little bit risky */ + g_assert (id_index->array->data == NULL); /* little bit risky */ entries_str = xmlGetProp (writer, "entries"); id_index->array->len = atoi (entries_str); free (entries_str); array_data = - mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, 0); + mmap (NULL, ARRAY_TOTAL_SIZE (id_index), PROT_READ, MAP_SHARED, fd, + 0); close (fd); if (array_data == MAP_FAILED) { GST_CAT_ERROR_OBJECT (DC, index, - "mmap %s failed: %s", path, strerror (errno)); + "mmap %s failed: %s", path, strerror (errno)); continue; } @@ -457,49 +464,45 @@ gst_file_index_load (GstFileIndex *index) } static void -gst_file_index_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +gst_file_index_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec) { GstFileIndex *index = GST_FILE_INDEX (object); switch (prop_id) { - case ARG_LOCATION: - if (index->location) - g_free (index->location); - index->location = g_value_dup_string (value); + case ARG_LOCATION: + if (index->location) + g_free (index->location); + index->location = g_value_dup_string (value); - if (index->location && !g_hash_table_size (index->id_index)) - gst_file_index_load (index); - break; + if (index->location && !g_hash_table_size (index->id_index)) + gst_file_index_load (index); + break; } } static void -gst_file_index_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +gst_file_index_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec) { GstFileIndex *index = GST_FILE_INDEX (object); - + switch (prop_id) { - case ARG_LOCATION: - g_value_set_string (value, index->location); - break; + case ARG_LOCATION: + g_value_set_string (value, index->location); + break; } } static void -_file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers) +_file_index_id_save_xml (gpointer _key, GstFileIndexId * ii, xmlNodePtr writers) { const gint bufsize = 16; gchar buf[bufsize]; xmlNodePtr writer; xmlNodePtr formats; gint xx; - + if (!ii->array) { GST_INFO ("Index for %s is empty", ii->id_desc); return; @@ -509,17 +512,17 @@ _file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers) xmlSetProp (writer, "id", ii->id_desc); g_snprintf (buf, bufsize, "%d", ii->array->len); xmlSetProp (writer, "entries", buf); - g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */ + g_snprintf (buf, bufsize, "%d", ii->id); /* any unique number is OK */ xmlSetProp (writer, "datafile", buf); formats = xmlNewChild (writer, NULL, "formats", NULL); g_snprintf (buf, bufsize, "%d", ii->nformats); xmlSetProp (formats, "count", buf); - for (xx=0; xx < ii->nformats; xx++) { + for (xx = 0; xx < ii->nformats; xx++) { xmlNodePtr format = xmlNewChild (formats, NULL, "format", NULL); - const GstFormatDefinition* def = - gst_format_get_details (ii->format[xx]); + const GstFormatDefinition *def = gst_format_get_details (ii->format[xx]); + xmlSetProp (format, "nick", def->nick); } } @@ -531,9 +534,8 @@ _file_index_id_save_xml (gpointer _key, GstFileIndexId *ii, xmlNodePtr writers) padding since the page size isn't fixed. */ static void -_file_index_id_save_entries (gpointer *_key, - GstFileIndexId *ii, - gchar *prefix) +_file_index_id_save_entries (gpointer * _key, + GstFileIndexId * ii, gchar * prefix) { GError *err; gchar *path; @@ -546,25 +548,26 @@ _file_index_id_save_entries (gpointer *_key, path = g_strdup_printf ("%s/%d", prefix, ii->id); chan = g_io_channel_new_file (path, "w", &err); g_free (path); - if (err) goto fail; - + if (err) + goto fail; + g_io_channel_set_encoding (chan, NULL, &err); - if (err) goto fail; + if (err) + goto fail; g_io_channel_write_chars (chan, - ii->array->data, - ARRAY_TOTAL_SIZE (ii), - NULL, - &err); - if (err) goto fail; + ii->array->data, ARRAY_TOTAL_SIZE (ii), NULL, &err); + if (err) + goto fail; g_io_channel_shutdown (chan, TRUE, &err); - if (err) goto fail; + if (err) + goto fail; g_io_channel_unref (chan); return; - fail: +fail: GST_CAT_ERROR (DC, "%s", err->message); } @@ -577,7 +580,7 @@ _file_index_id_save_entries (gpointer *_key, gst_index_commit (index, -1); */ static void -gst_file_index_commit (GstIndex *_index, gint _writer_id) +gst_file_index_commit (GstIndex * _index, gint _writer_id) { GstFileIndex *index = GST_FILE_INDEX (_index); xmlDocPtr doc; @@ -597,18 +600,16 @@ gst_file_index_commit (GstIndex *_index, gint _writer_id) writers = xmlNewChild (doc->xmlRootNode, NULL, "writers", NULL); g_hash_table_foreach (index->id_index, - (GHFunc) _file_index_id_save_xml, writers); + (GHFunc) _file_index_id_save_xml, writers); - if (mkdir (index->location, 0777) && - errno != EEXIST) { + if (mkdir (index->location, 0777) && errno != EEXIST) { GST_CAT_ERROR_OBJECT (DC, index, - "mkdir %s: %s", index->location, strerror (errno)); + "mkdir %s: %s", index->location, strerror (errno)); return; } path = g_strdup_printf ("%s/gstindex.xml", index->location); - tocfile = - g_io_channel_new_file (path, "w", &err); + tocfile = g_io_channel_new_file (path, "w", &err); g_free (path); if (err) { GST_CAT_ERROR_OBJECT (DC, index, "%s", err->message); @@ -624,6 +625,7 @@ gst_file_index_commit (GstIndex *_index, gint _writer_id) { xmlChar *xmlmem; int xmlsize; + xmlDocDumpMemory (doc, &xmlmem, &xmlsize); g_io_channel_write_chars (tocfile, xmlmem, xmlsize, NULL, &err); if (err) { @@ -643,12 +645,11 @@ gst_file_index_commit (GstIndex *_index, gint _writer_id) g_io_channel_unref (tocfile); g_hash_table_foreach (index->id_index, - (GHFunc) _file_index_id_save_entries, - index->location); + (GHFunc) _file_index_id_save_entries, index->location); } static void -gst_file_index_add_id (GstIndex *index, GstIndexEntry *entry) +gst_file_index_add_id (GstIndex * index, GstIndexEntry * entry) { GstFileIndex *fileindex = GST_FILE_INDEX (index); GstFileIndexId *id_index; @@ -672,12 +673,10 @@ gst_file_index_add_id (GstIndex *index, GstIndexEntry *entry) of non-exact matches. */ static gboolean -_fc_bsearch (GArray * ary, - gint stride, - gint * ret, - GCompareDataFunc compare, - gconstpointer sample, - gpointer user_data) +_fc_bsearch (GArray * ary, + gint stride, + gint * ret, + GCompareDataFunc compare, gconstpointer sample, gpointer user_data) { gint first, last; gint mid; @@ -687,67 +686,63 @@ _fc_bsearch (GArray * ary, g_return_val_if_fail (compare, FALSE); - if (!ary->len) - { - if (ret) *ret = 0; - return FALSE; - } + if (!ary->len) { + if (ret) + *ret = 0; + return FALSE; + } first = 0; last = ary->len - 1; midsize = last - first; - + while (midsize > 1) { mid = first + midsize / 2; - - cmp = (*compare) (sample, ary->data + mid*stride, user_data); - - if (cmp == 0) - { - /* if there are multiple matches then scan for the first match */ - while (mid > 0 && - (*compare) (sample, - ary->data + (mid - 1) * stride, - user_data) == 0) - --mid; - - if (ret) *ret = mid; - return TRUE; - } - + + cmp = (*compare) (sample, ary->data + mid * stride, user_data); + + if (cmp == 0) { + /* if there are multiple matches then scan for the first match */ + while (mid > 0 && + (*compare) (sample, ary->data + (mid - 1) * stride, user_data) == 0) + --mid; + + if (ret) + *ret = mid; + return TRUE; + } + if (cmp < 0) - last = mid-1; + last = mid - 1; else - first = mid+1; - + first = mid + 1; + midsize = last - first; } - for (tx = first; tx <= last; tx++) - { - cmp = (*compare) (sample, ary->data + tx*stride, user_data); + for (tx = first; tx <= last; tx++) { + cmp = (*compare) (sample, ary->data + tx * stride, user_data); - if (cmp < 0) - { - if (ret) *ret = tx; - return FALSE; - } - if (cmp == 0) - { - if (ret) *ret = tx; - return TRUE; - } + if (cmp < 0) { + if (ret) + *ret = tx; + return FALSE; } + if (cmp == 0) { + if (ret) + *ret = tx; + return TRUE; + } + } - if (ret) *ret = last+1; + if (ret) + *ret = last + 1; return FALSE; } static gint -file_index_compare (gconstpointer sample, - gconstpointer row, - gpointer user_data) +file_index_compare (gconstpointer sample, gconstpointer row, gpointer user_data) { //GstFileIndexId *id_index = user_data; const GstIndexAssociation *ca = sample; @@ -755,11 +750,12 @@ file_index_compare (gconstpointer sample, gint64 val2_be = ARRAY_ROW_VALUE (row, ca->format); gint64 val2 = GINT64_FROM_BE (val2_be); gint64 diff = val2 - val1; + return (diff == 0 ? 0 : (diff < 0 ? 1 : -1)); } static void -gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) +gst_file_index_add_association (GstIndex * index, GstIndexEntry * entry) { GstFileIndex *fileindex = GST_FILE_INDEX (index); GstFileIndexId *id_index; @@ -773,25 +769,26 @@ gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) if (!id_index->nformats) { gint fx; + id_index->nformats = GST_INDEX_NASSOCS (entry); GST_CAT_LOG_OBJECT (DC, fileindex, "creating %d formats for %d", - id_index->nformats, entry->id); + id_index->nformats, entry->id); id_index->format = g_new (GstFormat, id_index->nformats); - for (fx=0; fx < id_index->nformats; fx++) + for (fx = 0; fx < id_index->nformats; fx++) id_index->format[fx] = GST_INDEX_ASSOC_FORMAT (entry, fx); _fc_alloc_array (id_index); } else { /* only sanity checking */ if (id_index->nformats != GST_INDEX_NASSOCS (entry)) GST_CAT_WARNING_OBJECT (DC, fileindex, "arity change %d -> %d", - id_index->nformats, GST_INDEX_NASSOCS (entry)); + id_index->nformats, GST_INDEX_NASSOCS (entry)); else { gint fx; - for (fx=0; fx < id_index->nformats; fx++) + + for (fx = 0; fx < id_index->nformats; fx++) if (id_index->format[fx] != GST_INDEX_ASSOC_FORMAT (entry, fx)) GST_CAT_WARNING_OBJECT (DC, fileindex, "format[%d] changed %d -> %d", - fx, id_index->format[fx], - GST_INDEX_ASSOC_FORMAT (entry, fx)); + fx, id_index->format[fx], GST_INDEX_ASSOC_FORMAT (entry, fx)); } } @@ -800,15 +797,14 @@ gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) sample.value = GST_INDEX_ASSOC_VALUE (entry, 0); exact = - _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index), - &mx, file_index_compare, - &sample, id_index); + _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index), + &mx, file_index_compare, &sample, id_index); if (exact) { /* maybe overwrite instead? */ GST_CAT_DEBUG_OBJECT (DC, index, - "Ignoring duplicate index association at %lld", - GST_INDEX_ASSOC_VALUE (entry, 0)); + "Ignoring duplicate index association at %lld", + GST_INDEX_ASSOC_VALUE (entry, 0)); return; } @@ -817,10 +813,12 @@ gst_file_index_add_association (GstIndex *index, GstIndexEntry *entry) gint fx; gint32 flags_host = GST_INDEX_ASSOC_FLAGS (entry); + ARRAY_ROW_FLAGS (row_data) = GINT32_TO_BE (flags_host); for (fx = 0; fx < id_index->nformats; fx++) { gint64 val_host = GST_INDEX_ASSOC_VALUE (entry, fx); + ARRAY_ROW_VALUE (row_data, fx) = GINT64_TO_BE (val_host); } @@ -861,43 +859,41 @@ show_entry (GstIndexEntry *entry) */ static void -gst_file_index_add_entry (GstIndex *index, GstIndexEntry *entry) +gst_file_index_add_entry (GstIndex * index, GstIndexEntry * entry) { GST_LOG_OBJECT (index, "adding this entry"); - switch (entry->type){ - case GST_INDEX_ENTRY_ID: - gst_file_index_add_id (index, entry); - break; - case GST_INDEX_ENTRY_ASSOCIATION: - gst_file_index_add_association (index, entry); - break; - case GST_INDEX_ENTRY_OBJECT: - GST_CAT_ERROR_OBJECT (DC, index, - "gst_file_index_add_object not implemented"); - break; - case GST_INDEX_ENTRY_FORMAT: - /* - We infer the formats from the entry itself so this type of - GST_INDEX_ENTRY_* can probably go away. + switch (entry->type) { + case GST_INDEX_ENTRY_ID: + gst_file_index_add_id (index, entry); + break; + case GST_INDEX_ENTRY_ASSOCIATION: + gst_file_index_add_association (index, entry); + break; + case GST_INDEX_ENTRY_OBJECT: + GST_CAT_ERROR_OBJECT (DC, index, + "gst_file_index_add_object not implemented"); + break; + case GST_INDEX_ENTRY_FORMAT: + /* + We infer the formats from the entry itself so this type of + GST_INDEX_ENTRY_* can probably go away. */ - GST_CAT_DEBUG_OBJECT (DC, index, - "gst_file_index_add_format not implemented"); - break; - default: - break; + GST_CAT_DEBUG_OBJECT (DC, index, + "gst_file_index_add_format not implemented"); + break; + default: + break; } } -static GstIndexEntry* -gst_file_index_get_assoc_entry (GstIndex *index, - gint id, - GstIndexLookupMethod method, - GstAssocFlags flags, - GstFormat format, - gint64 value, - GCompareDataFunc _ignore_func, - gpointer _ignore_user_data) +static GstIndexEntry * +gst_file_index_get_assoc_entry (GstIndex * index, + gint id, + GstIndexLookupMethod method, + GstAssocFlags flags, + GstFormat format, + gint64 value, GCompareDataFunc _ignore_func, gpointer _ignore_user_data) { GstFileIndex *fileindex = GST_FILE_INDEX (index); GstFileIndexId *id_index; @@ -918,13 +914,15 @@ gst_file_index_get_assoc_entry (GstIndex *index, return NULL; } - for (fx=0; fx < id_index->nformats; fx++) - if (id_index->format[fx] == format) - { formatx = fx; break; } + for (fx = 0; fx < id_index->nformats; fx++) + if (id_index->format[fx] == format) { + formatx = fx; + break; + } if (formatx == -1) { GST_CAT_WARNING_OBJECT (DC, fileindex, - "%s, format %d not available", __FUNCTION__, format); + "%s, format %d not available", __FUNCTION__, format); return NULL; } @@ -933,7 +931,7 @@ gst_file_index_get_assoc_entry (GstIndex *index, sample.value = value; exact = _fc_bsearch (id_index->array, ARRAY_ROW_SIZE (id_index), - &mx, file_index_compare, &sample, id_index); + &mx, file_index_compare, &sample, id_index); if (!exact) { if (method == GST_INDEX_LOOKUP_EXACT) @@ -974,39 +972,37 @@ gst_file_index_get_assoc_entry (GstIndex *index, entry->type = GST_INDEX_ENTRY_ASSOCIATION; GST_INDEX_NASSOCS (entry) = id_index->nformats; - entry->data.assoc.assocs = - g_new (GstIndexAssociation, id_index->nformats); + entry->data.assoc.assocs = g_new (GstIndexAssociation, id_index->nformats); { gint32 flags_be = ARRAY_ROW_FLAGS (row_data); + GST_INDEX_ASSOC_FLAGS (entry) = GINT32_FROM_BE (flags_be); - for (xx=0; xx < id_index->nformats; xx++) - { - gint64 val_be = ARRAY_ROW_VALUE (row_data, xx); - GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx]; - GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be); - } + for (xx = 0; xx < id_index->nformats; xx++) { + gint64 val_be = ARRAY_ROW_VALUE (row_data, xx); + + GST_INDEX_ASSOC_FORMAT (entry, xx) = id_index->format[xx]; + GST_INDEX_ASSOC_VALUE (entry, xx) = GINT64_FROM_BE (val_be); + } } return entry; } gboolean -gst_file_index_plugin_init (GstPlugin *plugin) +gst_file_index_plugin_init (GstPlugin * plugin) { GstIndexFactory *factory; - GST_DEBUG_CATEGORY_INIT(DC, "GST_FILEINDEX", 0, NULL); + GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL); factory = gst_index_factory_new ("fileindex", - "A index that stores entries in file", - gst_file_index_get_type()); + "A index that stores entries in file", gst_file_index_get_type ()); if (factory != NULL) { gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } - else { + } else { GST_CAT_ERROR (DC, "could not register fileindex"); } return TRUE; diff --git a/plugins/indexers/gstindexers.c b/plugins/indexers/gstindexers.c index 5d4c4afff..2e45116f4 100644 --- a/plugins/indexers/gstindexers.c +++ b/plugins/indexers/gstindexers.c @@ -21,30 +21,22 @@ #include #include -extern gboolean gst_mem_index_plugin_init (GstPlugin *plugin); -extern gboolean gst_file_index_plugin_init (GstPlugin *plugin); +extern gboolean gst_mem_index_plugin_init (GstPlugin * plugin); +extern gboolean gst_file_index_plugin_init (GstPlugin * plugin); static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { gboolean res = TRUE; res &= gst_mem_index_plugin_init (plugin); res &= gst_file_index_plugin_init (plugin); - + return res; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "gstindexers", - "GStreamer core indexers", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) - - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstindexers", + "GStreamer core indexers", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/plugins/indexers/gstmemindex.c b/plugins/indexers/gstmemindex.c index bc5f210d9..5880cca9f 100644 --- a/plugins/indexers/gstmemindex.c +++ b/plugins/indexers/gstmemindex.c @@ -29,7 +29,7 @@ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_MEM_INDEX)) #define GST_IS_MEM_INDEX_CLASS(obj) \ (GST_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_MEM_INDEX)) - + /* * Object model: * @@ -61,108 +61,116 @@ * then do a lookup in the Tree to get the required value. */ -typedef struct { - GstFormat format; - gint offset; - GTree *tree; +typedef struct +{ + GstFormat format; + gint offset; + GTree *tree; } GstMemIndexFormatIndex; -typedef struct { - gint id; - GHashTable *format_index; +typedef struct +{ + gint id; + GHashTable *format_index; } GstMemIndexId; typedef struct _GstMemIndex GstMemIndex; typedef struct _GstMemIndexClass GstMemIndexClass; -struct _GstMemIndex { - GstIndex parent; +struct _GstMemIndex +{ + GstIndex parent; - GList *associations; + GList *associations; - GHashTable *id_index; + GHashTable *id_index; }; -struct _GstMemIndexClass { +struct _GstMemIndexClass +{ GstIndexClass parent_class; }; /* Index signals and args */ -enum { +enum +{ LAST_SIGNAL }; -enum { +enum +{ ARG_0, /* FILL ME */ }; -static void gst_mem_index_class_init (GstMemIndexClass *klass); -static void gst_mem_index_init (GstMemIndex *index); -static void gst_mem_index_dispose (GObject *object); +static void gst_mem_index_class_init (GstMemIndexClass * klass); +static void gst_mem_index_init (GstMemIndex * index); +static void gst_mem_index_dispose (GObject * object); -static void gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry); -static GstIndexEntry* gst_mem_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data); +static void gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry); +static GstIndexEntry *gst_mem_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data); #define CLASS(mem_index) GST_MEM_INDEX_CLASS (G_OBJECT_GET_CLASS (mem_index)) static GstIndex *parent_class = NULL; + /*static guint gst_mem_index_signals[LAST_SIGNAL] = { 0 }; */ GType -gst_mem_index_get_type(void) { +gst_mem_index_get_type (void) +{ static GType mem_index_type = 0; if (!mem_index_type) { static const GTypeInfo mem_index_info = { - sizeof(GstMemIndexClass), + sizeof (GstMemIndexClass), NULL, NULL, - (GClassInitFunc)gst_mem_index_class_init, + (GClassInitFunc) gst_mem_index_class_init, NULL, NULL, - sizeof(GstMemIndex), + sizeof (GstMemIndex), 1, - (GInstanceInitFunc)gst_mem_index_init, + (GInstanceInitFunc) gst_mem_index_init, NULL }; - mem_index_type = g_type_register_static(GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, 0); + mem_index_type = + g_type_register_static (GST_TYPE_INDEX, "GstMemIndex", &mem_index_info, + 0); } return mem_index_type; } static void -gst_mem_index_class_init (GstMemIndexClass *klass) +gst_mem_index_class_init (GstMemIndexClass * klass) { GObjectClass *gobject_class; GstIndexClass *gstindex_class; - gobject_class = (GObjectClass*)klass; - gstindex_class = (GstIndexClass*)klass; + gobject_class = (GObjectClass *) klass; + gstindex_class = (GstIndexClass *) klass; - parent_class = g_type_class_ref(GST_TYPE_INDEX); + parent_class = g_type_class_ref (GST_TYPE_INDEX); gobject_class->dispose = gst_mem_index_dispose; - gstindex_class->add_entry = gst_mem_index_add_entry; + gstindex_class->add_entry = gst_mem_index_add_entry; gstindex_class->get_assoc_entry = gst_mem_index_get_assoc_entry; } static void -gst_mem_index_init (GstMemIndex *index) +gst_mem_index_init (GstMemIndex * index) { - GST_DEBUG ( "created new mem index"); + GST_DEBUG ("created new mem index"); index->associations = NULL; index->id_index = g_hash_table_new (g_int_hash, g_int_equal); } static void -gst_mem_index_dispose (GObject *object) +gst_mem_index_dispose (GObject * object) { //GstMemIndex *memindex = GST_MEM_INDEX (object); @@ -170,7 +178,7 @@ gst_mem_index_dispose (GObject *object) } static void -gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_id (GstIndex * index, GstIndexEntry * entry) { GstMemIndex *memindex = GST_MEM_INDEX (index); GstMemIndexId *id_index; @@ -187,24 +195,23 @@ gst_mem_index_add_id (GstIndex *index, GstIndexEntry *entry) } static gint -mem_index_compare (gconstpointer a, - gconstpointer b, - gpointer user_data) +mem_index_compare (gconstpointer a, gconstpointer b, gpointer user_data) { GstMemIndexFormatIndex *index = user_data; gint64 val1, val2; gint64 diff; - val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset); - val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)b), index->offset); - + val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset); + val2 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) b), index->offset); + diff = (val2 - val1); return (diff == 0 ? 0 : (diff > 0 ? 1 : -1)); } static void -gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint assoc) +gst_mem_index_index_format (GstMemIndexId * id_index, GstIndexEntry * entry, + gint assoc) { GstMemIndexFormatIndex *index; GstFormat *format; @@ -227,7 +234,7 @@ gst_mem_index_index_format (GstMemIndexId *id_index, GstIndexEntry *entry, gint } static void -gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_association (GstIndex * index, GstIndexEntry * entry) { GstMemIndex *memindex = GST_MEM_INDEX (index); GstMemIndexId *id_index; @@ -245,60 +252,60 @@ gst_mem_index_add_association (GstIndex *index, GstIndexEntry *entry) } static void -gst_mem_index_add_object (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_object (GstIndex * index, GstIndexEntry * entry) { } static void -gst_mem_index_add_format (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_format (GstIndex * index, GstIndexEntry * entry) { } static void -gst_mem_index_add_entry (GstIndex *index, GstIndexEntry *entry) +gst_mem_index_add_entry (GstIndex * index, GstIndexEntry * entry) { GST_LOG_OBJECT (index, "added this entry"); - switch (entry->type){ - case GST_INDEX_ENTRY_ID: - gst_mem_index_add_id (index, entry); - break; - case GST_INDEX_ENTRY_ASSOCIATION: - gst_mem_index_add_association (index, entry); - break; - case GST_INDEX_ENTRY_OBJECT: - gst_mem_index_add_object (index, entry); - break; - case GST_INDEX_ENTRY_FORMAT: - gst_mem_index_add_format (index, entry); - break; - default: - break; + switch (entry->type) { + case GST_INDEX_ENTRY_ID: + gst_mem_index_add_id (index, entry); + break; + case GST_INDEX_ENTRY_ASSOCIATION: + gst_mem_index_add_association (index, entry); + break; + case GST_INDEX_ENTRY_OBJECT: + gst_mem_index_add_object (index, entry); + break; + case GST_INDEX_ENTRY_FORMAT: + gst_mem_index_add_format (index, entry); + break; + default: + break; } } -typedef struct { - gint64 value; +typedef struct +{ + gint64 value; GstMemIndexFormatIndex *index; - gboolean exact; - GstIndexEntry *lower; - gint64 low_diff; - GstIndexEntry *higher; - gint64 high_diff; + gboolean exact; + GstIndexEntry *lower; + gint64 low_diff; + GstIndexEntry *higher; + gint64 high_diff; } GstMemIndexSearchData; static gint -mem_index_search (gconstpointer a, - gconstpointer b) +mem_index_search (gconstpointer a, gconstpointer b) { GstMemIndexSearchData *data = (GstMemIndexSearchData *) b; GstMemIndexFormatIndex *index = data->index; gint64 val1, val2; gint64 diff; - val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *)a), index->offset); + val1 = GST_INDEX_ASSOC_VALUE (((GstIndexEntry *) a), index->offset); val2 = data->value; - + diff = (val1 - val2); if (diff == 0) return 0; @@ -313,8 +320,7 @@ mem_index_search (gconstpointer a, data->lower = (GstIndexEntry *) a; } diff = -1; - } - else { + } else { if (diff < data->high_diff) { data->high_diff = diff; data->higher = (GstIndexEntry *) a; @@ -325,13 +331,11 @@ mem_index_search (gconstpointer a, return diff; } -static GstIndexEntry* -gst_mem_index_get_assoc_entry (GstIndex *index, gint id, - GstIndexLookupMethod method, - GstAssocFlags flags, - GstFormat format, gint64 value, - GCompareDataFunc func, - gpointer user_data) +static GstIndexEntry * +gst_mem_index_get_assoc_entry (GstIndex * index, gint id, + GstIndexLookupMethod method, + GstAssocFlags flags, + GstFormat format, gint64 value, GCompareDataFunc func, gpointer user_data) { GstMemIndex *memindex = GST_MEM_INDEX (index); GstMemIndexId *id_index; @@ -363,7 +367,7 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id, entry = g_tree_search (format_index->tree, mem_index_search, &data); /* get the low/high values if we're not exact */ - if (entry == NULL && !data.exact) { + if (entry == NULL && !data.exact) { if (method == GST_INDEX_LOOKUP_BEFORE) entry = data.lower; else if (method == GST_INDEX_LOOKUP_AFTER) { @@ -380,15 +384,14 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id, while (l_entry) { entry = (GstIndexEntry *) l_entry->data; - if (entry->id == id && - (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags) - break; + if (entry->id == id && (GST_INDEX_ASSOC_FLAGS (entry) & flags) == flags) + break; - if (method == GST_INDEX_LOOKUP_BEFORE) - l_entry = g_list_next (l_entry); - else if (method == GST_INDEX_LOOKUP_AFTER) { - l_entry = g_list_previous (l_entry); - } + if (method == GST_INDEX_LOOKUP_BEFORE) + l_entry = g_list_next (l_entry); + else if (method == GST_INDEX_LOOKUP_AFTER) { + l_entry = g_list_previous (l_entry); + } } } } @@ -397,18 +400,16 @@ gst_mem_index_get_assoc_entry (GstIndex *index, gint id, } gboolean -gst_mem_index_plugin_init (GstPlugin *plugin) +gst_mem_index_plugin_init (GstPlugin * plugin) { GstIndexFactory *factory; factory = gst_index_factory_new ("memindex", - "A index that stores entries in memory", - gst_mem_index_get_type()); + "A index that stores entries in memory", gst_mem_index_get_type ()); if (factory != NULL) { gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } - else { + } else { g_warning ("could not register memindex"); } return TRUE; diff --git a/po/sr.po b/po/sr.po index db4c72b5f..d22df9808 100644 --- a/po/sr.po +++ b/po/sr.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: gstreamer 0.7.6\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2004-03-09 16:16+0100\n" +"POT-Creation-Date: 2004-03-11 11:33+0100\n" "PO-Revision-Date: 2004-03-13 01:47+0100\n" "Last-Translator: Danilo Segan \n" "Language-Team: Serbian \n" @@ -27,16 +27,23 @@ msgid "Print available debug categories and exit" msgstr "Испиши доступне категорије за налажење грешака и заврши" #: gst/gst.c:125 -msgid "Default debug level from 1 (only error) to 5 (anything) or 0 for no output" -msgstr "Подразумевани ниво опширности од 1 (само грешке) до 5 (све) или 0 (без излаза)" +msgid "" +"Default debug level from 1 (only error) to 5 (anything) or 0 for no output" +msgstr "" +"Подразумевани ниво опширности од 1 (само грешке) до 5 (све) или 0 (без " +"излаза)" #: gst/gst.c:125 msgid "LEVEL" msgstr "НИВО" #: gst/gst.c:126 -msgid "Comma-separated list of category_name:level pairs to set specific levels for the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3" -msgstr "Запетом раздвојени списак парова име_категорије:ниво за постављање нарочитих нивоа за појединачне категорије. Пример: GST_AUTOPLUG:5,GST_ELEMENT_*:3" +msgid "" +"Comma-separated list of category_name:level pairs to set specific levels for " +"the individual categories. Example: GST_AUTOPLUG:5,GST_ELEMENT_*:3" +msgstr "" +"Запетом раздвојени списак парова име_категорије:ниво за постављање нарочитих " +"нивоа за појединачне категорије. Пример: GST_AUTOPLUG:5,GST_ELEMENT_*:3" #: gst/gst.c:126 msgid "LIST" @@ -71,8 +78,12 @@ msgid "PATHS" msgstr "ПУТАЊЕ" #: gst/gst.c:134 -msgid "Comma-separated list of plugins to preload in addition to the list stored in env variable GST_PLUGIN_PATH" -msgstr "Запетом раздвојен списак додатака који се предучитавају поред списка из променљиве окружења GST_PLUGIN_PATH" +msgid "" +"Comma-separated list of plugins to preload in addition to the list stored in " +"env variable GST_PLUGIN_PATH" +msgstr "" +"Запетом раздвојен списак додатака који се предучитавају поред списка из " +"променљиве окружења GST_PLUGIN_PATH" #: gst/gst.c:134 msgid "PLUGINS" @@ -121,8 +132,12 @@ msgid "GStreamer encountered a general core library error." msgstr "ГСтример је наишао на општу грешку у основној библиотеци." #: gst/gsterror.c:58 gst/gsterror.c:94 gst/gsterror.c:116 gst/gsterror.c:154 -msgid "GStreamer developers were too lazy to assign an error code to this error. Please file a bug." -msgstr "Програмери ГСтримера су били сувише лењи да доделе код за ову грешку. Пријавите грешку." +msgid "" +"GStreamer developers were too lazy to assign an error code to this error. " +"Please file a bug." +msgstr "" +"Програмери ГСтримера су били сувише лењи да доделе код за ову грешку. " +"Пријавите грешку." #: gst/gsterror.c:61 msgid "Internal GStreamer error: code not implemented. File a bug." @@ -130,7 +145,8 @@ msgstr "Унутрашња грешка у ГСтримеру: код није #: gst/gsterror.c:63 msgid "Internal GStreamer error: state change failed. File a bug." -msgstr "Унутрашња грешка у ГСтримеру: неуспешна промена стања. Пријавите грешку." +msgstr "" +"Унутрашња грешка у ГСтримеру: неуспешна промена стања. Пријавите грешку." #: gst/gsterror.c:65 msgid "Internal GStreamer error: pad problem. File a bug." @@ -142,24 +158,29 @@ msgstr "Унутрашња грешка у ГСтримеру: неприлик #: gst/gsterror.c:69 msgid "Internal GStreamer error: scheduler problem. File a bug." -msgstr "Унутрашња грешка у ГСтримеру: неприлика са распоређивачем. Пријавите грешку." +msgstr "" +"Унутрашња грешка у ГСтримеру: неприлика са распоређивачем. Пријавите грешку." #: gst/gsterror.c:71 msgid "Internal GStreamer error: negotiation problem. File a bug." -msgstr "Унутрашња грешка у ГСтримеру: неприлика у преговарању. Пријавите грешку." +msgstr "" +"Унутрашња грешка у ГСтримеру: неприлика у преговарању. Пријавите грешку." #: gst/gsterror.c:73 msgid "Internal GStreamer error: event problem. File a bug." -msgstr "Унутрашња грешка у ГСтримеру: неприлика са догађајем. Пријавите грешку." +msgstr "" +"Унутрашња грешка у ГСтримеру: неприлика са догађајем. Пријавите грешку." #: gst/gsterror.c:75 msgid "Internal GStreamer error: seek problem. File a bug." -msgstr "Унутрашња грешка у ГСтримеру: неприлика са тражењем. Пријавите грешку." +msgstr "" +"Унутрашња грешка у ГСтримеру: неприлика са тражењем. Пријавите грешку." # bug: is "caps" short for "capabilities"? if so, it should be spelled completely #: gst/gsterror.c:77 msgid "Internal GStreamer error: caps problem. File a bug." -msgstr "Унутрашња грешка у ГСтримеру: неприлика са могућностима. Пријавите грешку." +msgstr "" +"Унутрашња грешка у ГСтримеру: неприлика са могућностима. Пријавите грешку." #: gst/gsterror.c:79 msgid "Internal GStreamer error: tag problem. File a bug." @@ -381,7 +402,8 @@ msgstr "МСКС" #: gst/gsttag.c:147 msgid "International Standard Recording Code - see http://www.ifpi.org/isrc/" -msgstr "Међународни стандардни код за снимање — видети http://www.ifpi.org/isrc/" +msgstr "" +"Међународни стандардни код за снимање — видети http://www.ifpi.org/isrc/" #: gst/gsttag.c:151 gst/gsttag.c:152 msgid "organization" @@ -626,8 +648,10 @@ msgstr "не могу да поставим особину „%s“ у елем #: gst/parse/grammar.y:337 #, c-format -msgid "could not convert \"%s\" so that it fits property \"%s\" in element \"%s\"" -msgstr "не могу да претворим „%s“ тако да одговара особини „%s“ у елементу „%s“" +msgid "" +"could not convert \"%s\" so that it fits property \"%s\" in element \"%s\"" +msgstr "" +"не могу да претворим „%s“ тако да одговара особини „%s“ у елементу „%s“" #: gst/parse/grammar.y:525 #, c-format @@ -711,7 +735,8 @@ msgstr " ns).\n" #: tools/gst-launch.c:99 msgid "Usage: gst-xmllaunch [ element.property=value ... ]\n" -msgstr "Употреба: gst-xmllaunch <датотека.xml> [ елемент.особина=вредност ... ]\n" +msgstr "" +"Употреба: gst-xmllaunch <датотека.xml> [ елемент.особина=вредност ... ]\n" #: tools/gst-launch.c:107 #, c-format diff --git a/tests/bufspeed/gstmempool.c b/tests/bufspeed/gstmempool.c index 32e792c45..636679c63 100644 --- a/tests/bufspeed/gstmempool.c +++ b/tests/bufspeed/gstmempool.c @@ -27,7 +27,7 @@ * */ static gboolean -populate (GstMemPool *mem_pool) +populate (GstMemPool * mem_pool) { guint8 *area; gint i; @@ -37,10 +37,10 @@ populate (GstMemPool *mem_pool) area = (guint8 *) g_malloc (mem_pool->area_size); - for (i=0; i < mem_pool->area_size; i += mem_pool->pool_size) { + for (i = 0; i < mem_pool->area_size; i += mem_pool->pool_size) { guint8 *areap = area + i; - GST_MEM_POOL_AREA (areap) = (GstMemPoolElement *)area; + GST_MEM_POOL_AREA (areap) = (GstMemPoolElement *) area; if (mem_pool->alloc_func) { mem_pool->alloc_func (mem_pool, GST_MEM_POOL_DATA (areap)); @@ -53,10 +53,9 @@ populate (GstMemPool *mem_pool) } -GstMemPool* -gst_mem_pool_new (gchar* name, gint atom_size, gulong area_size, gint type, - GstMemPoolAllocFunc alloc_func, - GstMemPoolFreeFunc free_func) +GstMemPool * +gst_mem_pool_new (gchar * name, gint atom_size, gulong area_size, gint type, + GstMemPoolAllocFunc alloc_func, GstMemPoolFreeFunc free_func) { GstMemPool *mem_pool; @@ -66,7 +65,7 @@ gst_mem_pool_new (gchar* name, gint atom_size, gulong area_size, gint type, mem_pool = g_malloc (sizeof (GstMemPool)); mem_pool->pool_size = atom_size + sizeof (GstMemPoolElement); - area_size = (area_size/atom_size) * mem_pool->pool_size; + area_size = (area_size / atom_size) * mem_pool->pool_size; mem_pool->name = g_strdup (name); mem_pool->free = NULL; @@ -93,7 +92,7 @@ free_area (gpointer key, gpointer value, gpointer user_data) } void -gst_mem_pool_destroy (GstMemPool *mem_pool) +gst_mem_pool_destroy (GstMemPool * mem_pool) { GHashTable *elements = g_hash_table_new (NULL, NULL); gpointer data; @@ -104,10 +103,10 @@ gst_mem_pool_destroy (GstMemPool *mem_pool) while (data) { GstMemPoolElement *elem = GST_MEM_POOL_LINK (data); - g_hash_table_insert (elements, GST_MEM_POOL_AREA (elem), NULL); - + g_hash_table_insert (elements, GST_MEM_POOL_AREA (elem), NULL); + data = gst_mem_pool_alloc (mem_pool); - } + } g_hash_table_foreach_remove (elements, free_area, NULL); g_hash_table_destroy (elements); @@ -116,28 +115,17 @@ gst_mem_pool_destroy (GstMemPool *mem_pool) } gpointer -gst_mem_pool_alloc (GstMemPool *mem_pool) +gst_mem_pool_alloc (GstMemPool * mem_pool) { volatile GstMemPoolElement *pool = NULL; - + g_return_val_if_fail (mem_pool != NULL, NULL); again: #if defined(USE_ASM) && defined(HAVE_CPU_I386) - __asm__ __volatile__ (" testl %%eax, %%eax \n\t" - " jz 20f \n" - "10: \t" - " movl (%%eax), %%ebx \n\t" - " movl %%edx, %%ecx \n\t" - " incl %%ecx \n\t" - POOL_LOCK "cmpxchg8b %1 \n\t" - " jz 20f \n\t" - " testl %%eax, %%eax \n\t" - " jnz 10b \n" - "20:\t" - :"=a" (pool) - :"m" (*mem_pool), "a" (mem_pool->free), "d" (mem_pool->cnt) - :"ecx", "ebx"); +__asm__ __volatile__ (" testl %%eax, %%eax \n\t" " jz 20f \n" "10: \t" " movl (%%eax), %%ebx \n\t" " movl %%edx, %%ecx \n\t" " incl %%ecx \n\t" POOL_LOCK "cmpxchg8b %1 \n\t" " jz 20f \n\t" " testl %%eax, %%eax \n\t" " jnz 10b \n" "20:\t":"=a" (pool) +: "m" (*mem_pool), "a" (mem_pool->free), "d" (mem_pool->cnt) +: "ecx", "ebx"); #else g_mutex_lock (mem_pool->chunk_lock); if (mem_pool->free) { @@ -151,40 +139,39 @@ again: /*g_print ("extending\n"); */ if (populate (mem_pool)) goto again; - else + else return NULL; } return GST_MEM_POOL_DATA (pool); } gpointer -gst_mem_pool_alloc0 (GstMemPool *mem_pool) +gst_mem_pool_alloc0 (GstMemPool * mem_pool) { gpointer mem = gst_mem_pool_alloc (mem_pool); if (mem) memset (mem, 0, mem_pool->atom_size); - + return mem; } void -gst_mem_pool_free (GstMemPool *mem_pool, gpointer mem) +gst_mem_pool_free (GstMemPool * mem_pool, gpointer mem) { GstMemPoolElement *pool; - + g_return_if_fail (mem_pool != NULL); g_return_if_fail (mem != NULL); pool = GST_MEM_POOL_LINK (mem); #if defined(USE_ASM) && defined(HAVE_CPU_I386) - __asm__ __volatile__ ( "1: \t" - " movl %2, (%1) \n" - POOL_LOCK "cmpxchg %1, %0 \n\t" - " jnz 1b \n\t" - : - :"m" (*mem_pool), "r" (pool), "a" (mem_pool->free)); + __asm__ __volatile__ ("1: \t" + " movl %2, (%1) \n" + POOL_LOCK "cmpxchg %1, %0 \n\t" + " jnz 1b \n\t"::"m" + (*mem_pool), "r" (pool), "a" (mem_pool->free)); #else g_mutex_lock (mem_pool->chunk_lock); pool->link = (GstMemPoolElement *) mem_pool->free; diff --git a/tests/bufspeed/gstmempool.h b/tests/bufspeed/gstmempool.h index 307b76889..b083fae3b 100644 --- a/tests/bufspeed/gstmempool.h +++ b/tests/bufspeed/gstmempool.h @@ -3,19 +3,19 @@ typedef struct _GstMemPool GstMemPool; typedef struct _GstMemPoolElement GstMemPoolElement; -typedef void (*GstMemPoolAllocFunc) (GstMemPool *pool, gpointer data); -typedef void (*GstMemPoolFreeFunc) (GstMemPool *pool, gpointer data); +typedef void (*GstMemPoolAllocFunc) (GstMemPool * pool, gpointer data); +typedef void (*GstMemPoolFreeFunc) (GstMemPool * pool, gpointer data); struct _GstMemPoolElement { - GstMemPoolElement *link; /* next cell in the lifo */ + GstMemPoolElement *link; /* next cell in the lifo */ GstMemPoolElement *area; }; struct _GstMemPool { volatile GstMemPoolElement *free; /* the first free element */ - volatile gulong cnt; /* used to avoid ABA problem */ + volatile gulong cnt; /* used to avoid ABA problem */ gchar *name; gulong area_size; @@ -28,16 +28,13 @@ struct _GstMemPool }; -GstMemPool* gst_mem_pool_new (gchar *name, - gint atom_size, - gulong area_size, - gint type, - GstMemPoolAllocFunc alloc_func, - GstMemPoolFreeFunc free_func); +GstMemPool *gst_mem_pool_new (gchar * name, + gint atom_size, + gulong area_size, + gint type, GstMemPoolAllocFunc alloc_func, GstMemPoolFreeFunc free_func); -void gst_mem_pool_destroy (GstMemPool *mem_pool); +void gst_mem_pool_destroy (GstMemPool * mem_pool); -gpointer gst_mem_pool_alloc (GstMemPool *mem_pool); -gpointer gst_mem_pool_alloc0 (GstMemPool *mem_pool); -void gst_mem_pool_free (GstMemPool *mem_pool, - gpointer mem); +gpointer gst_mem_pool_alloc (GstMemPool * mem_pool); +gpointer gst_mem_pool_alloc0 (GstMemPool * mem_pool); +void gst_mem_pool_free (GstMemPool * mem_pool, gpointer mem); diff --git a/tests/bufspeed/test1.c b/tests/bufspeed/test1.c index 53aa61efd..fc5eb041d 100644 --- a/tests/bufspeed/test1.c +++ b/tests/bufspeed/test1.c @@ -2,15 +2,15 @@ #include "gst/gstbuffer.h" #include "gst/gstbufferpool-default.h" -int +int main (int argc, char *argv[]) { GstBuffer *buf; guint i; - + gst_init (&argc, &argv); - for (i=0; i<5000000; i++) { + for (i = 0; i < 5000000; i++) { buf = gst_buffer_new (); gst_buffer_unref (buf); } diff --git a/tests/bufspeed/test2.c b/tests/bufspeed/test2.c index 270ea9a1b..17823ec6a 100644 --- a/tests/bufspeed/test2.c +++ b/tests/bufspeed/test2.c @@ -1,14 +1,14 @@ #include -int +int main (int argc, char *argv[]) { GstBuffer *buf; guint i; - + gst_init (&argc, &argv); - for (i=0; i<5000000; i++) { + for (i = 0; i < 5000000; i++) { buf = gst_buffer_new (); gst_buffer_unref (buf); } diff --git a/tests/instantiate/create.c b/tests/instantiate/create.c index fa2376e62..a5fff4b0a 100644 --- a/tests/instantiate/create.c +++ b/tests/instantiate/create.c @@ -34,7 +34,7 @@ create_all_elements (void) /* get list of elements */ for (elements = gst_registry_pool_feature_list (GST_TYPE_ELEMENT_FACTORY); - elements != NULL; elements = elements->next) { + elements != NULL; elements = elements->next) { factory = (GstElementFactory *) elements->data; if ((element = gst_element_factory_create (factory, "test"))) { gst_object_unref (GST_OBJECT (element)); @@ -43,8 +43,7 @@ create_all_elements (void) } gint -main (gint argc, - gchar *argv[]) +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); create_all_elements (); diff --git a/tests/lat.c b/tests/lat.c index 0f7733898..501aa74fc 100644 --- a/tests/lat.c +++ b/tests/lat.c @@ -10,163 +10,180 @@ static guint print_del = 1; static guint iterations = 0; static guint mhz = 0; -void handoff_src(GstElement *src, GstBuffer *buf, gpointer user_data) { - gst_trace_read_tsc(&GST_BUFFER_TIMESTAMP(buf)); +void +handoff_src (GstElement * src, GstBuffer * buf, gpointer user_data) +{ + gst_trace_read_tsc (&GST_BUFFER_TIMESTAMP (buf)); } -void handoff_sink(GstElement *sink, GstBuffer *buf, gpointer user_data) { +void +handoff_sink (GstElement * sink, GstBuffer * buf, gpointer user_data) +{ guint64 end, d, avg; guint avg_ns; - gst_trace_read_tsc(&end); - d = end - GST_BUFFER_TIMESTAMP(buf); - if (d > max) max = d; - if (d < min) min = d; + gst_trace_read_tsc (&end); + d = end - GST_BUFFER_TIMESTAMP (buf); + if (d > max) + max = d; + if (d < min) + min = d; total += d; count++; - avg = total/count; - avg_ns = (guint)(1000.0*(double)avg/(double)mhz); - + avg = total / count; + avg_ns = (guint) (1000.0 * (double) avg / (double) mhz); + if ((count % print_del) == 0) { - g_print("%07d:%08" G_GUINT64_FORMAT " min:%08" G_GUINT64_FORMAT " max:%08" G_GUINT64_FORMAT " avg:%08" G_GUINT64_FORMAT " avg-s:0.%09d\r", - count, d, min, max, avg, avg_ns); + g_print ("%07d:%08" G_GUINT64_FORMAT " min:%08" G_GUINT64_FORMAT " max:%08" + G_GUINT64_FORMAT " avg:%08" G_GUINT64_FORMAT " avg-s:0.%09d\r", count, + d, min, max, avg, avg_ns); } } -GstElement *identity_add(GstPipeline *pipeline, GstElement *first, int count) { +GstElement * +identity_add (GstPipeline * pipeline, GstElement * first, int count) +{ GstElement *last, *ident; int i; char buf[20]; last = first; - for (i=0; imessage); exit (-1); @@ -79,6 +80,6 @@ main (gint argc, gchar *argv[]) printf ("main(): Created %d threads.\n", t); g_thread_exit (NULL); - g_mem_chunk_info(); + g_mem_chunk_info (); return 0; } diff --git a/tests/memchunk/gstmemchunk.c b/tests/memchunk/gstmemchunk.c index a8ad1f6eb..d2b5dfbd1 100644 --- a/tests/memchunk/gstmemchunk.c +++ b/tests/memchunk/gstmemchunk.c @@ -24,7 +24,7 @@ * */ static gboolean -populate (GstMemChunk *mem_chunk) +populate (GstMemChunk * mem_chunk) { guint8 *area; gint i; @@ -35,8 +35,8 @@ populate (GstMemChunk *mem_chunk) area = (guint8 *) g_malloc (mem_chunk->area_size); g_print ("alloc %p\n", area); - for (i=0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) { - GST_MEM_CHUNK_AREA (area + i) = (GstMemChunkElement *)area; + for (i = 0; i < mem_chunk->area_size; i += mem_chunk->chunk_size) { + GST_MEM_CHUNK_AREA (area + i) = (GstMemChunkElement *) area; gst_mem_chunk_free (mem_chunk, GST_MEM_CHUNK_DATA (area + i)); } @@ -44,8 +44,8 @@ populate (GstMemChunk *mem_chunk) } -GstMemChunk* -gst_mem_chunk_new (gchar* name, gint atom_size, gulong area_size, gint type) +GstMemChunk * +gst_mem_chunk_new (gchar * name, gint atom_size, gulong area_size, gint type) { GstMemChunk *mem_chunk; @@ -55,7 +55,7 @@ gst_mem_chunk_new (gchar* name, gint atom_size, gulong area_size, gint type) mem_chunk = g_malloc (sizeof (GstMemChunk)); mem_chunk->chunk_size = atom_size + sizeof (GstMemChunkElement); - area_size = (area_size/atom_size) * mem_chunk->chunk_size; + area_size = (area_size / atom_size) * mem_chunk->chunk_size; mem_chunk->name = g_strdup (name); mem_chunk->free = NULL; @@ -79,7 +79,7 @@ free_area (gpointer key, gpointer value, gpointer user_data) } void -gst_mem_chunk_destroy (GstMemChunk *mem_chunk) +gst_mem_chunk_destroy (GstMemChunk * mem_chunk) { GHashTable *elements = g_hash_table_new (NULL, NULL); gpointer data; @@ -90,10 +90,10 @@ gst_mem_chunk_destroy (GstMemChunk *mem_chunk) while (data) { GstMemChunkElement *elem = GST_MEM_CHUNK_LINK (data); - g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL); - + g_hash_table_insert (elements, GST_MEM_CHUNK_AREA (elem), NULL); + data = gst_mem_chunk_alloc (mem_chunk); - } + } g_hash_table_foreach_remove (elements, free_area, NULL); g_hash_table_destroy (elements); @@ -102,73 +102,61 @@ gst_mem_chunk_destroy (GstMemChunk *mem_chunk) } gpointer -gst_mem_chunk_alloc (GstMemChunk *mem_chunk) +gst_mem_chunk_alloc (GstMemChunk * mem_chunk) { GstMemChunkElement *chunk = NULL; - + g_return_val_if_fail (mem_chunk != NULL, NULL); again: #ifdef HAVE_I386 - __asm__ __volatile__ (" testl %%eax, %%eax \n\t" - " jz 20f \n" - "10: \t" - " movl (%%eax), %%ebx \n\t" - " movl %%edx, %%ecx \n\t" - " incl %%ecx \n\t" - CHUNK_LOCK "cmpxchg8b %1 \n\t" - " jz 20f \n\t" - " testl %%eax, %%eax \n\t" - " jnz 10b \n" - "20:\t" - :"=a" (chunk) - :"m" (*mem_chunk), "a" (mem_chunk->free), "d" (mem_chunk->cnt) - :"ecx", "ebx"); +__asm__ __volatile__ (" testl %%eax, %%eax \n\t" " jz 20f \n" "10: \t" " movl (%%eax), %%ebx \n\t" " movl %%edx, %%ecx \n\t" " incl %%ecx \n\t" CHUNK_LOCK "cmpxchg8b %1 \n\t" " jz 20f \n\t" " testl %%eax, %%eax \n\t" " jnz 10b \n" "20:\t":"=a" (chunk) +: "m" (*mem_chunk), "a" (mem_chunk->free), "d" (mem_chunk->cnt) +: "ecx", "ebx"); #else - fprintf(stderr,"This only compiles correctly on i386. Sorry\n"); - abort(); + fprintf (stderr, "This only compiles correctly on i386. Sorry\n"); + abort (); #endif if (!chunk) { /*g_print ("extending\n"); */ if (populate (mem_chunk)) goto again; - else + else return NULL; } return GST_MEM_CHUNK_DATA (chunk); } gpointer -gst_mem_chunk_alloc0 (GstMemChunk *mem_chunk) +gst_mem_chunk_alloc0 (GstMemChunk * mem_chunk) { gpointer mem = gst_mem_chunk_alloc (mem_chunk); if (mem) memset (mem, 0, mem_chunk->atom_size); - + return mem; } void -gst_mem_chunk_free (GstMemChunk *mem_chunk, gpointer mem) +gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem) { GstMemChunkElement *chunk; - + g_return_if_fail (mem_chunk != NULL); g_return_if_fail (mem != NULL); chunk = GST_MEM_CHUNK_LINK (mem); #ifdef HAVE_I386 - __asm__ __volatile__ ( "1: \t" - " movl %2, (%1) \n" - CHUNK_LOCK "cmpxchg %1, %0 \n\t" - " jnz 1b \n\t" - : - :"m" (*mem_chunk), "r" (chunk), "a" (mem_chunk->free)); + __asm__ __volatile__ ("1: \t" + " movl %2, (%1) \n" + CHUNK_LOCK "cmpxchg %1, %0 \n\t" + " jnz 1b \n\t"::"m" + (*mem_chunk), "r" (chunk), "a" (mem_chunk->free)); #else - fprintf(stderr,"This only compiles correctly on i386. Sorry\n"); - abort(); + fprintf (stderr, "This only compiles correctly on i386. Sorry\n"); + abort (); #endif } diff --git a/tests/memchunk/gstmemchunk.h b/tests/memchunk/gstmemchunk.h index c71660a56..354f14fdb 100644 --- a/tests/memchunk/gstmemchunk.h +++ b/tests/memchunk/gstmemchunk.h @@ -6,14 +6,14 @@ typedef struct _GstMemChunkElement GstMemChunkElement; struct _GstMemChunkElement { - GstMemChunkElement *link; /* next cell in the lifo */ + GstMemChunkElement *link; /* next cell in the lifo */ GstMemChunkElement *area; }; struct _GstMemChunk { volatile GstMemChunkElement *free; /* the first free element */ - volatile gulong cnt; /* used to avoid ABA problem */ + volatile gulong cnt; /* used to avoid ABA problem */ gchar *name; gulong area_size; @@ -22,13 +22,10 @@ struct _GstMemChunk gboolean cleanup; }; -GstMemChunk* gst_mem_chunk_new (gchar *name, - gint atom_size, - gulong area_size, - gint type); +GstMemChunk *gst_mem_chunk_new (gchar * name, + gint atom_size, gulong area_size, gint type); -void gst_mem_chunk_destroy (GstMemChunk *mem_chunk); +void gst_mem_chunk_destroy (GstMemChunk * mem_chunk); -gpointer gst_mem_chunk_alloc (GstMemChunk *mem_chunk); -void gst_mem_chunk_free (GstMemChunk *mem_chunk, - gpointer mem); +gpointer gst_mem_chunk_alloc (GstMemChunk * mem_chunk); +void gst_mem_chunk_free (GstMemChunk * mem_chunk, gpointer mem); diff --git a/tests/memchunk/gstmemchunktest.c b/tests/memchunk/gstmemchunktest.c index 2a6e16786..0735fbd35 100644 --- a/tests/memchunk/gstmemchunktest.c +++ b/tests/memchunk/gstmemchunktest.c @@ -10,47 +10,48 @@ static GstMemChunk *_chunks; static gint num_allocs; static gint num_threads; -static gpointer +static gpointer alloc_chunk (void) { gpointer ret; + ret = gst_mem_chunk_alloc (_chunks); return ret; } -static void +static void free_chunk (gpointer chunk) { gst_mem_chunk_free (_chunks, chunk); } -void* +void * run_test (void *threadid) { gint i; gpointer chunk; - - g_usleep(G_USEC_PER_SEC); - for (i = 0; imessage); exit (-1); @@ -73,10 +74,10 @@ main (gint argc, gchar *argv[]) } printf ("main(): Created %d threads.\n", t); - for(t=0; t < num_threads; t++) { + for (t = 0; t < num_threads; t++) { g_thread_join (threads[t]); } - g_mem_chunk_info(); + g_mem_chunk_info (); gst_mem_chunk_destroy (_chunks); diff --git a/tests/muxing/case1.c b/tests/muxing/case1.c index ca8b8f59f..27e940e27 100644 --- a/tests/muxing/case1.c +++ b/tests/muxing/case1.c @@ -4,21 +4,22 @@ gboolean playing = TRUE; static void -handoff_signal (GstElement *element, GstBuffer *buf) +handoff_signal (GstElement * element, GstBuffer * buf) { - g_print ("handoff \"%s\" %" G_GINT64_FORMAT "\n", gst_element_get_name (element), GST_BUFFER_TIMESTAMP (buf)); + g_print ("handoff \"%s\" %" G_GINT64_FORMAT "\n", + gst_element_get_name (element), GST_BUFFER_TIMESTAMP (buf)); } static void -eos_signal (GstElement *element) +eos_signal (GstElement * element) { g_print ("eos received from \"%s\"\n", gst_element_get_name (element)); playing = FALSE; } -int -main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstBin *pipeline; GstElement *src, *tee, *identity1, *identity2, *aggregator, *sink; @@ -45,23 +46,23 @@ main(int argc,char *argv[]) sink = gst_element_factory_make ("fakesink", "sink"); g_return_val_if_fail (sink != NULL, 4); - gst_bin_add_many (pipeline, src, tee, identity1, identity2, aggregator, sink, NULL); + gst_bin_add_many (pipeline, src, tee, identity1, identity2, aggregator, sink, + NULL); gst_element_link_pads (src, "src", tee, "sink"); gst_pad_link (gst_element_get_request_pad (tee, "src%d"), - gst_element_get_pad (identity1, "sink")); + gst_element_get_pad (identity1, "sink")); gst_pad_link (gst_element_get_request_pad (tee, "src%d"), - gst_element_get_pad (identity2, "sink")); + gst_element_get_pad (identity2, "sink")); gst_pad_link (gst_element_get_pad (identity1, "src"), - gst_element_get_request_pad (aggregator, "sink%d")); + gst_element_get_request_pad (aggregator, "sink%d")); gst_pad_link (gst_element_get_pad (identity2, "src"), - gst_element_get_request_pad (aggregator, "sink%d")); + gst_element_get_request_pad (aggregator, "sink%d")); gst_element_link_pads (aggregator, "src", sink, "sink"); - g_signal_connect (G_OBJECT (src), "eos", - G_CALLBACK (eos_signal), NULL); + g_signal_connect (G_OBJECT (src), "eos", G_CALLBACK (eos_signal), NULL); g_signal_connect (G_OBJECT (sink), "handoff", - G_CALLBACK (handoff_signal), NULL); + G_CALLBACK (handoff_signal), NULL); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); diff --git a/tests/negotiation/capsnego1.c b/tests/negotiation/capsnego1.c index 5a3fda694..5f6dc6f81 100644 --- a/tests/negotiation/capsnego1.c +++ b/tests/negotiation/capsnego1.c @@ -20,42 +20,38 @@ #include static void -caps_nego_failed (GstPad *pad, GstCaps *caps) +caps_nego_failed (GstPad * pad, GstCaps * caps) { gboolean res; GstPad *peer; GstCaps *allowed; - GValue v_caps = { 0, }; + GValue v_caps = { 0, }; GValue v_allowed = { 0, }; GstCaps *toset; - + peer = gst_pad_get_peer (pad); g_value_init (&v_caps, GST_TYPE_CAPS); - g_value_set_boxed (&v_caps, caps); + g_value_set_boxed (&v_caps, caps); allowed = gst_pad_get_allowed_caps (pad); g_value_init (&v_allowed, GST_TYPE_CAPS); - g_value_set_boxed (&v_allowed, allowed); + g_value_set_boxed (&v_allowed, allowed); g_print ("caps nego failed on pad %s:%s\n" - " caps: %p (%s)\n" - " allowed: %p (%s)\n", - gst_element_get_name (gst_pad_get_parent (pad)), - gst_pad_get_name (pad), - caps, - g_strdup_value_contents (&v_caps), - allowed, - g_strdup_value_contents (&v_allowed)); - - if (GST_CAPS_IS_FIXED (caps)) + " caps: %p (%s)\n" + " allowed: %p (%s)\n", + gst_element_get_name (gst_pad_get_parent (pad)), + gst_pad_get_name (pad), + caps, + g_strdup_value_contents (&v_caps), + allowed, g_strdup_value_contents (&v_allowed)); + + if (GST_CAPS_IS_FIXED (caps)) /* if the elements suggested fixed caps, we just relink that way */ toset = caps; else /* else we use our hardcoded caps as an exazmple */ - toset = GST_CAPS_NEW ( - "testcaps", - "test/test", - "prop", GST_PROPS_INT (2) - ); + toset = GST_CAPS_NEW ("testcaps", "test/test", "prop", GST_PROPS_INT (2) + ); res = gst_pad_relink_filtered (pad, peer, toset); if (!res) { @@ -63,8 +59,8 @@ caps_nego_failed (GstPad *pad, GstCaps *caps) } } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *src, *identity, *sink; @@ -78,44 +74,40 @@ main (gint argc, gchar *argv[]) g_object_set (G_OBJECT (src), "num_buffers", 4, NULL); identity = gst_element_factory_make ("identity", "identity"); g_object_set (G_OBJECT (identity), "delay_capsnego", TRUE, NULL); - + sink = gst_element_factory_make ("fakesink", "sink"); gst_bin_add_many (GST_BIN (pipeline), src, identity, sink, NULL); - + res = gst_element_link_pads_filtered (src, "src", - identity, "sink", - GST_CAPS_NEW ( - "testcaps", - "test/test", - "prop", GST_PROPS_INT (1) - )); + identity, "sink", + GST_CAPS_NEW ("testcaps", "test/test", "prop", GST_PROPS_INT (1) + )); if (!res) { g_print ("could not link src and identity\n"); return -1; } - + res = gst_element_link_pads_filtered (identity, "src", - sink, "sink", - GST_CAPS_NEW ( - "testcaps", - "test/test", - "prop", GST_PROPS_INT_RANGE (2, 3) - )); + sink, "sink", + GST_CAPS_NEW ("testcaps", "test/test", "prop", GST_PROPS_INT_RANGE (2, 3) + )); if (!res) { g_print ("could not link identity and sink\n"); return -1; } - g_signal_connect (gst_element_get_pad (identity, "src"), - "caps_nego_failed", G_CALLBACK (caps_nego_failed), NULL); + g_signal_connect (gst_element_get_pad (identity, "src"), + "caps_nego_failed", G_CALLBACK (caps_nego_failed), NULL); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); - g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), + NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); gst_element_set_state (pipeline, GST_STATE_NULL); - + return 0; } diff --git a/tests/old/examples/appreader/appreader.c b/tests/old/examples/appreader/appreader.c index f735b5131..5e8768a37 100644 --- a/tests/old/examples/appreader/appreader.c +++ b/tests/old/examples/appreader/appreader.c @@ -20,21 +20,21 @@ #include static void -fill_queue (GstElement *queue, gint level, GstBin *pipeline) +fill_queue (GstElement * queue, gint level, GstBin * pipeline) { /* this needs to iterate till something is pushed * in the queue */ gst_bin_iterate (pipeline); } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstElement *queue, *src, *pipeline; GstBuffer *buffer; gboolean done = FALSE; GstPad *pad; - + gst_init (&argc, &argv); queue = gst_element_factory_make ("queue", "queue"); @@ -50,19 +50,19 @@ main (gint argc, gchar *argv[]) gst_element_link_many (src, queue, NULL); pad = gst_element_get_pad (queue, "src"); - g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), pipeline); + g_signal_connect (G_OBJECT (queue), "low_watermark", G_CALLBACK (fill_queue), + pipeline); gst_element_set_state (pipeline, GST_STATE_PLAYING); - do { + do { /* get buffer into the app */ buffer = GST_RPAD_GETFUNC (pad) (pad); /* just exit on any event */ if (GST_IS_EVENT (buffer)) { done = TRUE; - } - else { + } else { gst_util_dump_mem (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer)); } gst_data_unref (GST_DATA (buffer)); @@ -71,6 +71,6 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (pipeline)); - + return 0; } diff --git a/tests/old/examples/cutter/cutter.c b/tests/old/examples/cutter/cutter.c index f22a44138..fb235d845 100644 --- a/tests/old/examples/cutter/cutter.c +++ b/tests/old/examples/cutter/cutter.c @@ -16,23 +16,24 @@ #define DEBUG -gboolean playing = TRUE; -gboolean cut_start_signalled = FALSE; -gboolean cut_stop_signalled = FALSE; - -int id = 0; /* increment this for each new cut */ -GstElement *main_bin; -GstElement *audiosrc; -GstElement *queue; -GstElement *thread; -GstElement *cutter; -GstElement *disksink; -GstElement *encoder; -char buffer[255]; +gboolean playing = TRUE; +gboolean cut_start_signalled = FALSE; +gboolean cut_stop_signalled = FALSE; + +int id = 0; /* increment this for each new cut */ +GstElement *main_bin; +GstElement *audiosrc; +GstElement *queue; +GstElement *thread; +GstElement *cutter; +GstElement *disksink; +GstElement *encoder; +char buffer[255]; /* signal callbacks */ -void cut_start (GstElement *element) +void +cut_start (GstElement * element) { g_print ("\nDEBUG: main: cut start\n"); /* we should pause the pipeline, unlink cutter and disksink @@ -45,12 +46,14 @@ void cut_start (GstElement *element) { time_t seconds; struct tm *ct; + time (&seconds); ct = localtime (&seconds); /* sprintf (buffer, "/news/incoming/audio/cutter.%06d.wav", id); */ - sprintf (buffer, "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav", - ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, - ct->tm_hour, ct->tm_min, ct->tm_sec); + sprintf (buffer, + "/news/incoming/audio/cutter.%04d%02d%02d.%02d%02d%02d.wav", + ct->tm_year + 1900, ct->tm_mon, ct->tm_mday, ct->tm_hour, ct->tm_min, + ct->tm_sec); } g_print ("DEBUG: cut_start: setting new location to %s\n", buffer); g_object_set (G_OBJECT (disksink), "location", buffer, NULL); @@ -62,13 +65,15 @@ void cut_start (GstElement *element) return; } -void cut_start_signal (GstElement *element) +void +cut_start_signal (GstElement * element) { g_print ("\nDEBUG: main: cut start signal\n"); cut_start_signalled = TRUE; } -void cut_stop (GstElement *element) +void +cut_stop (GstElement * element) { g_print ("\nDEBUG: main: cut stop\n"); /* we should pause the pipeline, unlink disksink, create a fake disksink, @@ -85,42 +90,41 @@ void cut_stop (GstElement *element) return; } -void cut_stop_signal (GstElement *element) +void +cut_stop_signal (GstElement * element) { g_print ("\nDEBUG: main: cut stop signal\n"); cut_stop_signalled = TRUE; } -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { /*int i, j; */ /*gboolean done; */ - + /*char buffer[20]; */ - + /*output_channel_t *channel_out; */ - + GstElement *audiosrc; - gst_init (&argc,&argv); + gst_init (&argc, &argv); /* if (argc == 1) { g_print("usage: %s <...>\n", argv[0]); exit(-1); }*/ - + /* set up input channel and main bin */ - g_print ("creating main bin\n"); + g_print ("creating main bin\n"); /* create cutter */ cutter = gst_element_factory_make ("cutter", "cutter"); - g_object_set (G_OBJECT (cutter), - "threshold_dB", -40.0, - "runlength", 0.5, - "prelength", 1.0, - NULL); + g_object_set (G_OBJECT (cutter), + "threshold_dB", -40.0, "runlength", 0.5, "prelength", 1.0, NULL); /* create an audio src */ if (!(audiosrc = gst_element_factory_make ("osssrc", "audio_src"))) @@ -128,21 +132,20 @@ int main (int argc, char *argv[]) /* set params */ - g_object_set (G_OBJECT (audiosrc), "frequency", 44100, - "channels", 1, - "format", 16, NULL); + g_object_set (G_OBJECT (audiosrc), "frequency", 44100, + "channels", 1, "format", 16, NULL); if (!(encoder = gst_element_factory_make ("passthrough", "encoder"))) g_error ("Could not create 'passthrough' element !\n"); - + if (!(disksink = gst_element_factory_make ("afsink", "disk_sink"))) g_error ("Could not create 'afsink' element !\n"); - + g_object_set (G_OBJECT (disksink), "location", "/dev/null", NULL); thread = gst_thread_new ("thread"); g_assert (thread != NULL); - + /* create main bin */ main_bin = gst_pipeline_new ("bin"); g_assert (main_bin != NULL); @@ -161,10 +164,10 @@ int main (int argc, char *argv[]) /* set signal handlers */ g_print ("setting signal handlers\n"); - g_signal_connect (G_OBJECT(cutter), "cut_start", - (GCallback)cut_start_signal, NULL); - g_signal_connect (G_OBJECT(cutter), "cut_stop", - (GCallback)cut_stop_signal, NULL); + g_signal_connect (G_OBJECT (cutter), "cut_start", + (GCallback) cut_start_signal, NULL); + g_signal_connect (G_OBJECT (cutter), "cut_stop", + (GCallback) cut_stop_signal, NULL); /* start playing */ g_print ("setting to play\n"); @@ -173,23 +176,20 @@ int main (int argc, char *argv[]) g_print ("setting thread to play\n"); gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); */ - while (playing) - { + while (playing) { /* g_print ("> "); */ - gst_bin_iterate (GST_BIN (main_bin)); + gst_bin_iterate (GST_BIN (main_bin)); /* g_print (" <"); */ - if (cut_start_signalled) - { - g_print ("\nDEBUG: main: cut_start_signalled true !\n"); - cut_start (cutter); - cut_start_signalled = FALSE; - } - if (cut_stop_signalled) - { - g_print ("\nDEBUG: main: cut_stop_signalled true !\n"); - cut_stop (cutter); - cut_stop_signalled = FALSE; - } + if (cut_start_signalled) { + g_print ("\nDEBUG: main: cut_start_signalled true !\n"); + cut_start (cutter); + cut_start_signalled = FALSE; + } + if (cut_stop_signalled) { + g_print ("\nDEBUG: main: cut_stop_signalled true !\n"); + cut_stop (cutter); + cut_stop_signalled = FALSE; + } } g_print ("we're done iterating.\n"); /* stop the bin */ @@ -199,5 +199,5 @@ int main (int argc, char *argv[]) gst_object_unref (GST_OBJECT (disksink)); gst_object_unref (GST_OBJECT (main_bin)); - exit(0); + exit (0); } diff --git a/tests/old/examples/cutter/cutter.h b/tests/old/examples/cutter/cutter.h index f7ba2d6ca..202ab33e6 100644 --- a/tests/old/examples/cutter/cutter.h +++ b/tests/old/examples/cutter/cutter.h @@ -3,12 +3,12 @@ * thomas@apestaart.org */ -typedef struct +typedef struct { GstElement *pipe; GstElement *disksink; GstElement *audiosink; - + char *location; int channel_id; } output_channel_t; diff --git a/tests/old/examples/helloworld/helloworld.c b/tests/old/examples/helloworld/helloworld.c index 95197305d..9cf72e842 100644 --- a/tests/old/examples/helloworld/helloworld.c +++ b/tests/old/examples/helloworld/helloworld.c @@ -1,7 +1,8 @@ #include #include -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *decoder, *osssink; @@ -36,7 +37,7 @@ int main (int argc, char *argv[]) /* link the elements */ gst_element_link_many (filesrc, decoder, osssink, NULL); - + /* start playing */ gst_element_set_state (bin, GST_STATE_PLAYING); @@ -47,4 +48,3 @@ int main (int argc, char *argv[]) exit (0); } - diff --git a/tests/old/examples/helloworld2/helloworld2.c b/tests/old/examples/helloworld2/helloworld2.c index 981576aed..28a32789d 100644 --- a/tests/old/examples/helloworld2/helloworld2.c +++ b/tests/old/examples/helloworld2/helloworld2.c @@ -1,7 +1,8 @@ #include static void -gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline) +gst_play_have_type (GstElement * typefind, GstCaps * caps, + GstElement * pipeline) { GstElement *osssink; GstElement *new_element; @@ -21,18 +22,15 @@ gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline) /* unlink_pads the typefind from the pipeline and remove it */ gst_element_unlink_pads (cache, "src", typefind, "sink"); gst_bin_remove (GST_BIN (autobin), typefind); - + /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); autoplug = gst_autoplug_factory_make ("staticrender"); g_assert (autoplug != NULL); - new_element = gst_autoplug_to_renderers (autoplug, - caps, - osssink, - NULL); + new_element = gst_autoplug_to_renderers (autoplug, caps, osssink, NULL); if (!new_element) { g_print ("could not autoplug, no suitable codecs found...\n"); @@ -51,7 +49,7 @@ gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline) } static void -gst_play_cache_empty (GstElement *element, GstElement *pipeline) +gst_play_cache_empty (GstElement * element, GstElement * pipeline) { GstElement *autobin; GstElement *filesrc; @@ -77,8 +75,8 @@ gst_play_cache_empty (GstElement *element, GstElement *pipeline) fprintf (stderr, "done with cache_empty\n"); } -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc; GstElement *pipeline; @@ -105,23 +103,24 @@ main (int argc, char *argv[]) autobin = gst_bin_new ("autobin"); cache = gst_element_factory_make ("autoplugcache", "cache"); - g_signal_connect (G_OBJECT (cache), "cache_empty", - G_CALLBACK (gst_play_cache_empty), pipeline); + g_signal_connect (G_OBJECT (cache), "cache_empty", + G_CALLBACK (gst_play_cache_empty), pipeline); typefind = gst_element_factory_make ("typefind", "typefind"); - g_signal_connect (G_OBJECT (typefind), "have_type", - G_CALLBACK (gst_play_have_type), pipeline); + g_signal_connect (G_OBJECT (typefind), "have_type", + G_CALLBACK (gst_play_have_type), pipeline); gst_bin_add (GST_BIN (autobin), cache); gst_bin_add (GST_BIN (autobin), typefind); gst_element_link_pads (cache, "src", typefind, "sink"); - gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), "sink"); + gst_element_add_ghost_pad (autobin, gst_element_get_pad (cache, "sink"), + "sink"); - gst_bin_add (GST_BIN( pipeline), autobin); + gst_bin_add (GST_BIN (pipeline), autobin); gst_element_link_pads (filesrc, "src", autobin, "sink"); /* start playing */ - gst_element_set_state( GST_ELEMENT (pipeline), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); @@ -130,6 +129,5 @@ main (int argc, char *argv[]) gst_object_unref (GST_OBJECT (pipeline)); - exit(0); + exit (0); } - diff --git a/tests/old/examples/launch/mp3parselaunch.c b/tests/old/examples/launch/mp3parselaunch.c index a0cb19036..a8009712f 100644 --- a/tests/old/examples/launch/mp3parselaunch.c +++ b/tests/old/examples/launch/mp3parselaunch.c @@ -2,7 +2,7 @@ #include int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *pipeline; GstElement *filesrc; @@ -15,20 +15,22 @@ main (int argc, char *argv[]) return -1; } - pipeline = (GstElement*) gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error); + pipeline = + (GstElement *) + gst_parse_launch ("filesrc name=my_filesrc ! mad ! osssink", &error); if (!pipeline) { fprintf (stderr, "Parse error: %s", error->message); exit (1); } - + filesrc = gst_bin_get_by_name (GST_BIN (pipeline), "my_filesrc"); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); - + gst_element_set_state (pipeline, GST_STATE_NULL); - + return 0; } diff --git a/tests/old/examples/mixer/mixer.c b/tests/old/examples/mixer/mixer.c index 6b27f5b94..c2990724f 100644 --- a/tests/old/examples/mixer/mixer.c +++ b/tests/old/examples/mixer/mixer.c @@ -24,88 +24,90 @@ /*#define AUTOPLUG * define if you want autoplugging of input channels * */ /* function prototypes */ -input_channel_t* create_input_channel (int id, char* location); -void destroy_input_channel (input_channel_t *pipe); -void env_register_cp (GstElement *volenv, double cp_time, double cp_level); +input_channel_t *create_input_channel (int id, char *location); +void destroy_input_channel (input_channel_t * pipe); +void env_register_cp (GstElement * volenv, double cp_time, double cp_level); gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element) +void +eos (GstElement * element) { - g_print("have eos, quitting ?\n"); + g_print ("have eos, quitting ?\n"); /* playing = FALSE; */ } -G_GNUC_UNUSED static GstCaps* -gst_play_type_find (GstBin *bin, GstElement *element) +G_GNUC_UNUSED static GstCaps * +gst_play_type_find (GstBin * bin, GstElement * element) { GstElement *typefind; GstElement *pipeline; GstCaps *caps = NULL; GST_DEBUG ("GstPipeline: typefind for element \"%s\"", - GST_ELEMENT_NAME(element)); + GST_ELEMENT_NAME (element)); pipeline = gst_pipeline_new ("autoplug_pipeline"); - + typefind = gst_element_factory_make ("typefind", "typefind"); g_return_val_if_fail (typefind != NULL, FALSE); gst_pad_link (gst_element_get_pad (element, "src"), - gst_element_get_pad (typefind, "sink")); + gst_element_get_pad (typefind, "sink")); gst_bin_add (bin, typefind); gst_bin_add (GST_BIN (pipeline), GST_ELEMENT (bin)); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); - + /* push a buffer... the have_type signal handler will set the found flag */ gst_bin_iterate (GST_BIN (pipeline)); - + gst_element_set_state (pipeline, GST_STATE_NULL); caps = gst_pad_get_caps (gst_element_get_pad (element, "src")); gst_pad_unlink (gst_element_get_pad (element, "src"), - gst_element_get_pad (typefind, "sink")); + gst_element_get_pad (typefind, "sink")); gst_bin_remove (bin, typefind); gst_bin_remove (GST_BIN (pipeline), GST_ELEMENT (bin)); gst_object_unref (GST_OBJECT (typefind)); gst_object_unref (GST_OBJECT (pipeline)); - + return caps; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { int i, j; int num_channels; - + char buffer[20]; - - GList *input_channels; /* structure holding all the input channels */ - + + GList *input_channels; /* structure holding all the input channels */ + input_channel_t *channel_in; - + GstElement *main_bin; GstElement *adder; GstElement *audiosink; - GstPad *pad; /* to request pads for the adder */ + GstPad *pad; /* to request pads for the adder */ - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc == 1) { - g_print("usage: %s <...>\n", argv[0]); - exit(-1); + g_print ("usage: %s <...>\n", argv[0]); + exit (-1); } num_channels = argc - 1; - + /* set up output channel and main bin */ - + /* create adder */ adder = gst_element_factory_make ("adder", "adderel"); @@ -113,33 +115,33 @@ int main(int argc,char *argv[]) audiosink = gst_element_factory_make ("esdsink", "play_audio"); /* create main bin */ - main_bin = gst_pipeline_new("bin"); + main_bin = gst_pipeline_new ("bin"); /* link adder and output to bin */ - GST_INFO ( "main: adding adder to bin"); - gst_bin_add (GST_BIN(main_bin), adder); - GST_INFO ( "main: adding audiosink to bin"); - gst_bin_add (GST_BIN(main_bin), audiosink); + GST_INFO ("main: adding adder to bin"); + gst_bin_add (GST_BIN (main_bin), adder); + GST_INFO ("main: adding audiosink to bin"); + gst_bin_add (GST_BIN (main_bin), audiosink); /* link adder and audiosink */ - gst_pad_link(gst_element_get_pad(adder,"src"), - gst_element_get_pad(audiosink,"sink")); - + gst_pad_link (gst_element_get_pad (adder, "src"), + gst_element_get_pad (audiosink, "sink")); + /* start looping */ input_channels = NULL; - - for (i = 1; i < argc; ++i) - { + + for (i = 1; i < argc; ++i) { printf ("Opening channel %d from file %s...\n", i, argv[i]); channel_in = create_input_channel (i, argv[i]); input_channels = g_list_append (input_channels, channel_in); - if (i > 1) gst_element_set_state (main_bin, GST_STATE_PAUSED); - gst_bin_add (GST_BIN(main_bin), channel_in->pipe); + if (i > 1) + gst_element_set_state (main_bin, GST_STATE_PAUSED); + gst_bin_add (GST_BIN (main_bin), channel_in->pipe); /* request pads and link to adder */ - GST_INFO ( "requesting pad\n"); + GST_INFO ("requesting pad\n"); pad = gst_element_get_request_pad (adder, "sink%d"); printf ("\tGot new adder sink pad %s\n", gst_pad_get_name (pad)); sprintf (buffer, "channel%d", i); @@ -155,78 +157,71 @@ int main(int argc,char *argv[]) * at a level ensuring no distortion * example for three songs : * song1 : starts at full level, plays 5 seconds, faded out at 10 seconds, - * sleep until 25, fade to end level at 30 + * sleep until 25, fade to end level at 30 * song2 : starts silent, fades in at 5 seconds, full blast at 10 seconds, - * full level until 15, faded out at 20, sleep until 25, fade to end at 30 + * full level until 15, faded out at 20, sleep until 25, fade to end at 30 * song3 : starts muted, fades in from 15, full at 20, until 25, fade to end level */ - if (i == 1) - { + if (i == 1) { /* first song gets special treatment for end style */ - env_register_cp (channel_in->volenv, 0.0, 1.0); - } - else - { - env_register_cp (channel_in->volenv, 0.0 , 0.0000001); /* start muted */ - env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */ - env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0); + env_register_cp (channel_in->volenv, 0.0, 1.0); + } else { + env_register_cp (channel_in->volenv, 0.0, 0.0000001); /* start muted */ + env_register_cp (channel_in->volenv, i * 10.0 - 15.0, 0.0000001); /* start fade in */ + env_register_cp (channel_in->volenv, i * 10.0 - 10.0, 1.0); } - env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */ + env_register_cp (channel_in->volenv, i * 10.0 - 5.0, 1.0); /* end of full level */ - if (i != num_channels) - { - env_register_cp (channel_in->volenv, i * 10.0 , 0.0000001); /* fade to black */ - env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */ - } - env_register_cp (channel_in->volenv, num_channels * 10.0 , 1.0 / num_channels); /* to end level */ + if (i != num_channels) { + env_register_cp (channel_in->volenv, i * 10.0, 0.0000001); /* fade to black */ + env_register_cp (channel_in->volenv, num_channels * 10.0 - 5.0, 0.0000001); /* start fade in */ + } + env_register_cp (channel_in->volenv, num_channels * 10.0, 1.0 / num_channels); /* to end level */ #ifndef GST_DISABLE_LOADSAVE gst_xml_write_file (GST_ELEMENT (main_bin), fopen ("mixer.xml", "w")); #endif /* start playing */ - gst_element_set_state(main_bin, GST_STATE_PLAYING); + gst_element_set_state (main_bin, GST_STATE_PLAYING); /* write out the schedule */ - gst_scheduler_show(GST_ELEMENT_SCHED(main_bin)); + gst_scheduler_show (GST_ELEMENT_SCHED (main_bin)); playing = TRUE; j = 0; /*printf ("main: start iterating from 0"); */ - while (playing && j < 100) - { + while (playing && j < 100) { /* printf ("main: iterating %d\n", j); */ - gst_bin_iterate(GST_BIN(main_bin)); - /*fprintf(stderr,"after iterate()\n"); */ + gst_bin_iterate (GST_BIN (main_bin)); + /*fprintf(stderr,"after iterate()\n"); */ ++j; } } printf ("main: all the channels are open\n"); - while (playing) - { - gst_bin_iterate(GST_BIN(main_bin)); + while (playing) { + gst_bin_iterate (GST_BIN (main_bin)); /*fprintf(stderr,"after iterate()\n"); */ } /* stop the bin */ - gst_element_set_state(main_bin, GST_STATE_NULL); + gst_element_set_state (main_bin, GST_STATE_NULL); - while (input_channels) - { + while (input_channels) { destroy_input_channel (input_channels->data); input_channels = g_list_next (input_channels); } g_list_free (input_channels); - - gst_object_unref(GST_OBJECT(audiosink)); - gst_object_unref(GST_OBJECT(main_bin)); + gst_object_unref (GST_OBJECT (audiosink)); - exit(0); + gst_object_unref (GST_OBJECT (main_bin)); + + exit (0); } -input_channel_t* -create_input_channel (int id, char* location) +input_channel_t * +create_input_channel (int id, char *location) { /* create an input channel, reading from location * return a pointer to the channel @@ -234,51 +229,48 @@ create_input_channel (int id, char* location) */ input_channel_t *channel; - - char buffer[20]; /* hold the names */ + + char buffer[20]; /* hold the names */ /* GstAutoplug *autoplug; GstCaps *srccaps; */ - GstElement *new_element; + GstElement *new_element; GstElement *decoder; - GST_DEBUG ( "c_i_p : creating channel with id %d for file %s", - id, location); - + GST_DEBUG ("c_i_p : creating channel with id %d for file %s", id, location); + /* allocate channel */ channel = (input_channel_t *) malloc (sizeof (input_channel_t)); - if (channel == NULL) - { + if (channel == NULL) { printf ("create_input_channel : could not allocate memory for channel !\n"); return NULL; } /* create channel */ - GST_DEBUG ( "c_i_p : creating pipeline"); + GST_DEBUG ("c_i_p : creating pipeline"); sprintf (buffer, "pipeline%d", id); channel->pipe = gst_bin_new (buffer); - g_assert(channel->pipe != NULL); - + g_assert (channel->pipe != NULL); + /* create elements */ - GST_DEBUG ( "c_i_p : creating filesrc"); + GST_DEBUG ("c_i_p : creating filesrc"); sprintf (buffer, "filesrc%d", id); channel->filesrc = gst_element_factory_make ("filesrc", buffer); - g_assert(channel->filesrc != NULL); + g_assert (channel->filesrc != NULL); - GST_DEBUG ( "c_i_p : setting location"); - g_object_set(G_OBJECT(channel->filesrc),"location", location, NULL); + GST_DEBUG ("c_i_p : setting location"); + g_object_set (G_OBJECT (channel->filesrc), "location", location, NULL); /* add filesrc to the bin before autoplug */ - gst_bin_add(GST_BIN(channel->pipe), channel->filesrc); + gst_bin_add (GST_BIN (channel->pipe), channel->filesrc); /* link signal to eos of filesrc */ - g_signal_connect (G_OBJECT(channel->filesrc),"eos", - G_CALLBACK(eos),NULL); + g_signal_connect (G_OBJECT (channel->filesrc), "eos", G_CALLBACK (eos), NULL); #ifdef DEBUG @@ -287,7 +279,7 @@ create_input_channel (int id, char* location) sprintf (buffer, "volenv%d", id); channel->volenv = gst_element_factory_make ("volenv", buffer); - g_assert(channel->volenv != NULL); + g_assert (channel->volenv != NULL); /* autoplug the pipe */ @@ -308,7 +300,7 @@ create_input_channel (int id, char* location) gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_NULL); gst_bin_remove (GST_BIN (pipeline), channel->pipe); - + } #endif @@ -317,7 +309,6 @@ create_input_channel (int id, char* location) g_print ("could not autoplug, unknown media type...\n"); exit (-1); } - #ifdef DEBUG printf ("DEBUG : c_i_p : creating autoplug\n"); #endif @@ -328,51 +319,49 @@ create_input_channel (int id, char* location) #ifdef DEBUG printf ("DEBUG : c_i_p : autoplugging\n"); #endif - - new_element = gst_autoplug_to_caps (autoplug, srccaps, - gst_caps_new ("audio/raw", NULL), NULL); - + + new_element = gst_autoplug_to_caps (autoplug, srccaps, + gst_caps_new ("audio/raw", NULL), NULL); + if (!new_element) { g_print ("could not autoplug, no suitable codecs found...\n"); exit (-1); } - #else new_element = gst_bin_new ("autoplug_bin"); /* static plug, use mad plugin and assume mp3 input */ printf ("using static plugging for input channel\n"); - decoder = gst_element_factory_make ("mad", "mpg123"); - if (!decoder) - { + decoder = gst_element_factory_make ("mad", "mpg123"); + if (!decoder) { fprintf (stderr, "Could not get a decoder element !\n"); exit (1); } gst_bin_add (GST_BIN (new_element), decoder); - gst_element_add_ghost_pad (new_element, - gst_element_get_pad (decoder, "sink"), "sink"); - gst_element_add_ghost_pad (new_element, - gst_element_get_pad (decoder, "src"), "src_00"); - -#endif + gst_element_add_ghost_pad (new_element, + gst_element_get_pad (decoder, "sink"), "sink"); + gst_element_add_ghost_pad (new_element, + gst_element_get_pad (decoder, "src"), "src_00"); + +#endif #ifndef GST_DISABLE_LOADSAVE gst_xml_write_file (GST_ELEMENT (new_element), fopen ("mixer.gst", "w")); -#endif +#endif - gst_bin_add (GST_BIN(channel->pipe), channel->volenv); + gst_bin_add (GST_BIN (channel->pipe), channel->volenv); gst_bin_add (GST_BIN (channel->pipe), new_element); - + gst_element_link_pads (channel->filesrc, "src", new_element, "sink"); gst_element_link_pads (new_element, "src_00", channel->volenv, "sink"); - + /* add a ghost pad */ sprintf (buffer, "channel%d", id); gst_element_add_ghost_pad (channel->pipe, - gst_element_get_pad (channel->volenv, "src"), buffer); + gst_element_get_pad (channel->volenv, "src"), buffer); + - #ifdef DEBUG printf ("DEBUG : c_i_p : end function\n"); #endif @@ -381,12 +370,12 @@ create_input_channel (int id, char* location) } void -destroy_input_channel (input_channel_t *channel) +destroy_input_channel (input_channel_t * channel) { /* * destroy an input channel */ - + #ifdef DEBUG printf ("DEBUG : d_i_p : start\n"); #endif @@ -398,11 +387,12 @@ destroy_input_channel (input_channel_t *channel) free (channel); } -void env_register_cp (GstElement *volenv, double cp_time, double cp_level) +void +env_register_cp (GstElement * volenv, double cp_time, double cp_level) { char buffer[30]; sprintf (buffer, "%f:%f", cp_time, cp_level); - g_object_set(G_OBJECT(volenv), "controlpoint", buffer, NULL); + g_object_set (G_OBJECT (volenv), "controlpoint", buffer, NULL); } diff --git a/tests/old/examples/mixer/mixer.h b/tests/old/examples/mixer/mixer.h index 4cae18e30..76e55f6ea 100644 --- a/tests/old/examples/mixer/mixer.h +++ b/tests/old/examples/mixer/mixer.h @@ -3,10 +3,10 @@ * thomas@apestaart.org */ -typedef struct +typedef struct { GstElement *pipe, *filesrc, *volenv; - + char *location; int channel_id; } input_channel_t; diff --git a/tests/old/examples/pingpong/pingpong.c b/tests/old/examples/pingpong/pingpong.c index c0cc60206..59f7be64f 100644 --- a/tests/old/examples/pingpong/pingpong.c +++ b/tests/old/examples/pingpong/pingpong.c @@ -19,7 +19,7 @@ #include -static GstElement* +static GstElement * make_bin (gint count) { GstElement *bin; @@ -42,7 +42,7 @@ make_bin (gint count) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *aggregator, *sink; @@ -53,9 +53,9 @@ main (gint argc, gchar *argv[]) gst_init (&argc, &argv); pipeline = gst_pipeline_new ("main"); - g_signal_connect (pipeline, "deep_notify", - G_CALLBACK (gst_element_default_deep_notify), NULL); - + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + aggregator = gst_element_factory_make ("aggregator", "mixer"); sink = gst_element_factory_make ("fakesink", "sink"); @@ -85,7 +85,7 @@ main (gint argc, gchar *argv[]) i = 4; while (i--) gst_bin_iterate (GST_BIN (pipeline)); - + g_print ("playing bin1\n"); gst_element_set_state (bin1, GST_STATE_PLAYING); diff --git a/tests/old/examples/plugins/example.c b/tests/old/examples/plugins/example.c index 796d33940..42144a0aa 100644 --- a/tests/old/examples/plugins/example.c +++ b/tests/old/examples/plugins/example.c @@ -27,18 +27,18 @@ * plugin, as well as author and version data. Use the GST_ELEMENT_DETAILS * macro when defining it. */ -static GstElementDetails example_details = GST_ELEMENT_DETAILS ( - "An example plugin", - "Example/FirstExample", - "Shows the basic structure of a plugin", - "your name " -); +static GstElementDetails example_details = +GST_ELEMENT_DETAILS ("An example plugin", + "Example/FirstExample", + "Shows the basic structure of a plugin", + "your name "); /* These are the signals that this element can fire. They are zero- * based because the numbers themselves are private to the object. * LAST_SIGNAL is used for initialization of the signal array. */ -enum { +enum +{ ASDF, /* FILL ME */ LAST_SIGNAL @@ -47,51 +47,46 @@ enum { /* Arguments are identified the same way, but cannot be zero, so you * must leave the ARG_0 entry in as a placeholder. */ -enum { +enum +{ ARG_0, ARG_ACTIVE - /* FILL ME */ + /* FILL ME */ }; /* The PadFactory structures describe what pads the element has or * can have. They can be quite complex, but for this example plugin * they are rather simple. */ -GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ( - "sink", /* The name of the pad */ - GST_PAD_SINK, /* Direction of the pad */ - GST_PAD_ALWAYS, /* The pad exists for every instance */ - GST_STATIC_CAPS ( - "unknown/unknown, " /* The MIME media type */ - "foo:int=1, " /* an integer property */ - "bar:boolean=true, " /* a boolean property */ - "baz:int={ 1, 3 }" /* a list of values */ - ) -); +GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", /* The name of the pad */ + GST_PAD_SINK, /* Direction of the pad */ + GST_PAD_ALWAYS, /* The pad exists for every instance */ + GST_STATIC_CAPS ("unknown/unknown, " /* The MIME media type */ + "foo:int=1, " /* an integer property */ + "bar:boolean=true, " /* a boolean property */ + "baz:int={ 1, 3 }" /* a list of values */ + ) + ); /* This factory is much simpler, and defines the source pad. */ -GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ( - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "unknown/unknown" - ) -); +GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("unknown/unknown") + ); /* A number of functon prototypes are given so we can refer to them later. */ -static void gst_example_class_init (GstExampleClass *klass); -static void gst_example_init (GstExample *example); +static void gst_example_class_init (GstExampleClass * klass); +static void gst_example_init (GstExample * example); -static void gst_example_chain (GstPad *pad, GstData *_data); +static void gst_example_chain (GstPad * pad, GstData * _data); -static void gst_example_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec); -static void gst_example_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec); -static GstElementStateReturn - gst_example_change_state (GstElement *element); +static void gst_example_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_example_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); +static GstElementStateReturn gst_example_change_state (GstElement * element); /* The parent class pointer needs to be kept around for some object * operations. @@ -109,23 +104,25 @@ static guint gst_example_signals[LAST_SIGNAL] = { 0 }; * and pointers to the various functions that define the class. */ GType -gst_example_get_type(void) +gst_example_get_type (void) { static GType example_type = 0; if (!example_type) { static const GTypeInfo example_info = { - sizeof(GstExampleClass), + sizeof (GstExampleClass), NULL, NULL, - (GClassInitFunc)gst_example_class_init, + (GClassInitFunc) gst_example_class_init, NULL, NULL, - sizeof(GstExample), + sizeof (GstExample), 0, - (GInstanceInitFunc)gst_example_init, + (GInstanceInitFunc) gst_example_init, }; - example_type = g_type_register_static(GST_TYPE_ELEMENT, "GstExample", &example_info, 0); + example_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstExample", &example_info, + 0); } return example_type; } @@ -135,7 +132,7 @@ gst_example_get_type(void) * it, based on the pointer to the function provided above. */ static void -gst_example_class_init (GstExampleClass *klass) +gst_example_class_init (GstExampleClass * klass) { /* Class pointers are needed to supply pointers to the private * implementations of parent class methods. @@ -146,27 +143,24 @@ gst_example_class_init (GstExampleClass *klass) /* Since the example class contains the parent classes, you can simply * cast the pointer to get access to the parent classes. */ - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; /* The parent class is needed for class method overrides. */ - parent_class = g_type_class_ref(GST_TYPE_ELEMENT); + parent_class = g_type_class_ref (GST_TYPE_ELEMENT); /* Here we add an argument to the object. This argument is an integer, * and can be both read and written. */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_ACTIVE, - g_param_spec_int("active","active","active", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACTIVE, g_param_spec_int ("active", "active", "active", G_MININT, G_MAXINT, 0, G_PARAM_READWRITE)); /* CHECKME */ /* Here we add a signal to the object. This is avery useless signal * called asdf. The signal will also pass a pointer to the listeners * which happens to be the example element itself */ gst_example_signals[ASDF] = - g_signal_new("asdf", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL, - g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, - GST_TYPE_EXAMPLE); + g_signal_new ("asdf", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GstExampleClass, asdf), NULL, NULL, + g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, GST_TYPE_EXAMPLE); /* The last thing is to provide the functions that implement get and set @@ -193,31 +187,33 @@ gst_example_class_init (GstExampleClass *klass) * the plugin. */ static void -gst_example_init(GstExample *example) +gst_example_init (GstExample * example) { /* First we create the sink pad, which is the input to the element. * We will use the template constructed by the factory. */ - example->sinkpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&sink_template), "sink"); + example->sinkpad = + gst_pad_new_from_template (gst_static_pad_template_get (&sink_template), + "sink"); /* Setting the chain function allows us to supply the function that will * actually be performing the work. Without this, the element would do * nothing, with undefined results (assertion failures and such). */ - gst_pad_set_chain_function(example->sinkpad,gst_example_chain); + gst_pad_set_chain_function (example->sinkpad, gst_example_chain); /* We then must add this pad to the element's list of pads. The base * element class manages the list of pads, and provides accessors to it. */ - gst_element_add_pad(GST_ELEMENT(example),example->sinkpad); + gst_element_add_pad (GST_ELEMENT (example), example->sinkpad); /* The src pad, the output of the element, is created and registered * in the same way, with the exception of the chain function. Source * pads don't have chain functions, because they can't accept buffers, * they only produce them. */ - example->srcpad = gst_pad_new_from_template ( - gst_static_pad_template_get (&src_template), "src"); - gst_element_add_pad(GST_ELEMENT(example),example->srcpad); + example->srcpad = + gst_pad_new_from_template (gst_static_pad_template_get (&src_template), + "src"); + gst_element_add_pad (GST_ELEMENT (example), example->srcpad); /* Initialization of element's private variables. */ example->active = FALSE; @@ -228,7 +224,7 @@ gst_example_init(GstExample *example) * as the buffer provided by the peer element. */ static void -gst_example_chain (GstPad *pad, GstData *_data) +gst_example_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); GstExample *example; @@ -237,34 +233,35 @@ gst_example_chain (GstPad *pad, GstData *_data) /* Some of these checks are of dubious value, since if there were not * already true, the chain function would never be called. */ - g_return_if_fail(pad != NULL); - g_return_if_fail(GST_IS_PAD(pad)); - g_return_if_fail(buf != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (GST_IS_PAD (pad)); + g_return_if_fail (buf != NULL); /* We need to get a pointer to the element this pad belogs to. */ - example = GST_EXAMPLE(gst_pad_get_parent (pad)); + example = GST_EXAMPLE (gst_pad_get_parent (pad)); /* A few more sanity checks to make sure that the element that owns * this pad is the right kind of element, in case something got confused. */ - g_return_if_fail(example != NULL); - g_return_if_fail(GST_IS_EXAMPLE(example)); + g_return_if_fail (example != NULL); + g_return_if_fail (GST_IS_EXAMPLE (example)); /* If we are supposed to be doing something, here's where it happens. */ if (example->active) { /* In this example we're going to copy the buffer to another one, * so we need to allocate a new buffer first. */ - outbuf = gst_buffer_new(); + outbuf = gst_buffer_new (); /* We need to copy the size and offset of the buffer at a minimum. */ GST_BUFFER_SIZE (outbuf) = GST_BUFFER_SIZE (buf); GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf); /* Then allocate the memory for the new buffer */ - GST_BUFFER_DATA (outbuf) = (guchar *)g_malloc (GST_BUFFER_SIZE (outbuf)); + GST_BUFFER_DATA (outbuf) = (guchar *) g_malloc (GST_BUFFER_SIZE (outbuf)); /* Then copy the data in the incoming buffer into the new buffer. */ - memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (outbuf)); + memcpy (GST_BUFFER_DATA (outbuf), GST_BUFFER_DATA (buf), + GST_BUFFER_SIZE (outbuf)); /* we don't need the incomming buffer anymore so we unref it. When we are * the last plugin with a handle to the buffer, its memory will be freed */ @@ -274,15 +271,14 @@ gst_example_chain (GstPad *pad, GstData *_data) * in the pipeline, through the element's source pad, which is stored * in the element's structure. */ - gst_pad_push(example->srcpad,GST_DATA (outbuf)); + gst_pad_push (example->srcpad, GST_DATA (outbuf)); /* For fun we'll emit our useless signal here */ - g_signal_emit(G_OBJECT (example), gst_example_signals[ASDF], 0, - example); + g_signal_emit (G_OBJECT (example), gst_example_signals[ASDF], 0, example); - /* If we're not doing something, just send the original incoming buffer. */ + /* If we're not doing something, just send the original incoming buffer. */ } else { - gst_pad_push(example->srcpad,GST_DATA (buf)); + gst_pad_push (example->srcpad, GST_DATA (buf)); } } @@ -290,15 +286,16 @@ gst_example_chain (GstPad *pad, GstData *_data) * enable the element to respond to various arguments. */ static void -gst_example_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gst_example_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstExample *example; /* It's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_EXAMPLE(object)); + g_return_if_fail (GST_IS_EXAMPLE (object)); /* Get a pointer of the right type. */ - example = GST_EXAMPLE(object); + example = GST_EXAMPLE (object); /* Check the argument id to see which argument we're setting. */ switch (prop_id) { @@ -309,7 +306,7 @@ gst_example_set_property (GObject *object, guint prop_id, const GValue *value, G * is running, if you are using threads. */ example->active = g_value_get_int (value); - g_print("example: set active to %d\n",example->active); + g_print ("example: set active to %d\n", example->active); break; default: break; @@ -318,13 +315,14 @@ gst_example_set_property (GObject *object, guint prop_id, const GValue *value, G /* The set function is simply the inverse of the get fuction. */ static void -gst_example_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gst_example_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstExample *example; /* It's not null if we got it, but it might not be ours */ - g_return_if_fail(GST_IS_EXAMPLE(object)); - example = GST_EXAMPLE(object); + g_return_if_fail (GST_IS_EXAMPLE (object)); + example = GST_EXAMPLE (object); switch (prop_id) { case ARG_ACTIVE: @@ -342,38 +340,38 @@ gst_example_get_property (GObject *object, guint prop_id, GValue *value, GParamS * in the various state transitions. */ static GstElementStateReturn -gst_example_change_state (GstElement *element) +gst_example_change_state (GstElement * element) { GstExample *example; - + /* cast to our plugin */ - example = GST_EXAMPLE(element); - + example = GST_EXAMPLE (element); + /* we perform our actions based on the state transition * of the element */ switch (GST_STATE_TRANSITION (element)) { - /* The NULL to READY transition is used to - * create threads (if any) */ + /* The NULL to READY transition is used to + * create threads (if any) */ case GST_STATE_NULL_TO_READY: break; - /* In the READY to PAUSED state, the element should - * open devices (if any) */ + /* In the READY to PAUSED state, the element should + * open devices (if any) */ case GST_STATE_READY_TO_PAUSED: break; - /* In the PAUSED to PLAYING state, the element should - * prepare itself for operation or continue after a PAUSE */ + /* In the PAUSED to PLAYING state, the element should + * prepare itself for operation or continue after a PAUSE */ case GST_STATE_PAUSED_TO_PLAYING: break; - /* In the PLAYING to PAUSED state, the element should - * PAUSE itself and make sure it can resume operation */ + /* In the PLAYING to PAUSED state, the element should + * PAUSE itself and make sure it can resume operation */ case GST_STATE_PLAYING_TO_PAUSED: break; - /* In the PAUSED to READY state, the element should reset - * its internal state and close any devices. */ + /* In the PAUSED to READY state, the element should reset + * its internal state and close any devices. */ case GST_STATE_PAUSED_TO_READY: break; - /* The element should free all resources, terminate threads - * and put itself into its initial state again */ + /* The element should free all resources, terminate threads + * and put itself into its initial state again */ case GST_STATE_READY_TO_NULL: break; } @@ -387,13 +385,14 @@ gst_example_change_state (GstElement *element) * this function is called to register everything that the plugin provides. */ static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { /* We need to register each element we provide with the plugin. This consists * of the name of the element, a rank that gives the importance of the element * when compared to similar plugins and the GType identifier. */ - if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, GST_TYPE_EXAMPLE)) + if (!gst_element_register (plugin, "example", GST_RANK_MARGINAL, + GST_TYPE_EXAMPLE)) return FALSE; /* Now we can return successfully. */ @@ -411,21 +410,19 @@ plugin_init (GstPlugin *plugin) * The symbol pointing to this structure is the only symbol looked up when * loading the plugin. */ -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, /* The major version of the core that this was built with */ - GST_VERSION_MINOR, /* The minor version of the core that this was built with */ - "example", /* The name of the plugin. This must be unique: plugins with - * the same name will be assumed to be identical, and only - * one will be loaded. */ - "an example plugin", /* a short description of the plugin in English */ - plugin_init, /* Pointer to the initialisation function for the plugin. */ - "0.1", /* The version number of the plugin */ - "LGPL", /* ieffective license the plugin can be shipped with. Must be - * valid for all libraries it links to, too. */ - "my nifty plugin package", - /* package this plugin belongs to. */ - "http://www.mydomain.com" - /* originating URL for this plugin. This is the place to look - * for updates, information and so on. */ -); - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, /* The major version of the core that this was built with */ + GST_VERSION_MINOR, /* The minor version of the core that this was built with */ + "example", /* The name of the plugin. This must be unique: plugins with + * the same name will be assumed to be identical, and only + * one will be loaded. */ + "an example plugin", /* a short description of the plugin in English */ + plugin_init, /* Pointer to the initialisation function for the plugin. */ + "0.1", /* The version number of the plugin */ + "LGPL", /* ieffective license the plugin can be shipped with. Must be + * valid for all libraries it links to, too. */ + "my nifty plugin package", + /* package this plugin belongs to. */ + "http://www.mydomain.com" + /* originating URL for this plugin. This is the place to look + * for updates, information and so on. */ + ); diff --git a/tests/old/examples/plugins/example.h b/tests/old/examples/plugins/example.h index cbb7b28ce..2e065ecf6 100644 --- a/tests/old/examples/plugins/example.h +++ b/tests/old/examples/plugins/example.h @@ -24,7 +24,6 @@ #include G_BEGIN_DECLS - /* This is the definition of the element's object structure. */ typedef struct _GstExample GstExample; @@ -33,11 +32,12 @@ typedef struct _GstExample GstExample; * the beginning of the object. This allows the element to be cast to * an Element or even an Object. */ -struct _GstExample { +struct _GstExample +{ GstElement element; /* We need to keep track of our pads, so we do so here. */ - GstPad *sinkpad,*srcpad; + GstPad *sinkpad, *srcpad; /* We'll use this to decide whether to do anything to the data we get. */ gboolean active; @@ -49,11 +49,12 @@ struct _GstExample { * structure. */ typedef struct _GstExampleClass GstExampleClass; -struct _GstExampleClass { +struct _GstExampleClass +{ GstElementClass parent_class; /* signals */ - void (*asdf) (GstElement *element, GstExample *example); + void (*asdf) (GstElement * element, GstExample * example); }; /* Five standard preprocessing macros are used in the Gtk+ object system. @@ -80,8 +81,7 @@ struct _GstExampleClass { /* This is the only prototype needed, because it is used in the above * GST_TYPE_EXAMPLE macro. */ -GType gst_example_get_type(void); +GType gst_example_get_type (void); G_END_DECLS - #endif /* __GST_EXAMPLE_H__ */ diff --git a/tests/old/examples/queue/queue.c b/tests/old/examples/queue/queue.c index 5f3a9c046..7e027839e 100644 --- a/tests/old/examples/queue/queue.c +++ b/tests/old/examples/queue/queue.c @@ -1,56 +1,56 @@ #include #include -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *parse, *decode, *queue; GstElement *bin; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - bin = gst_bin_new("bin"); - g_assert(bin != NULL); + bin = gst_bin_new ("bin"); + g_assert (bin != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); - parse = gst_element_factory_make("mp3parse", "parse"); - decode = gst_element_factory_make("mpg123", "decode"); + parse = gst_element_factory_make ("mp3parse", "parse"); + decode = gst_element_factory_make ("mpg123", "decode"); - queue = gst_element_factory_make("queue", "queue"); + queue = gst_element_factory_make ("queue", "queue"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (bin), filesrc, parse, decode, queue, NULL); - gst_bin_add(GST_BIN(thread), osssink); - gst_bin_add(GST_BIN(bin), thread); + gst_bin_add (GST_BIN (thread), osssink); + gst_bin_add (GST_BIN (bin), thread); gst_element_link_many (filesrc, parse, decode, queue, osssink, NULL); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); - while (gst_bin_iterate(GST_BIN(bin))); + while (gst_bin_iterate (GST_BIN (bin))); - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/tests/old/examples/queue2/queue2.c b/tests/old/examples/queue2/queue2.c index b6eae69d4..7d5862600 100644 --- a/tests/old/examples/queue2/queue2.c +++ b/tests/old/examples/queue2/queue2.c @@ -4,78 +4,78 @@ gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); playing = FALSE; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue; GstElement *pipeline; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - pipeline = gst_pipeline_new("pipeline"); - g_assert(pipeline != NULL); + pipeline = gst_pipeline_new ("pipeline"); + g_assert (pipeline != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect (G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); - queue = gst_element_factory_make("queue", "queue"); + queue = gst_element_factory_make ("queue", "queue"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); /* add objects to the main pipeline */ /* - gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); - gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue); + gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); + gst_pipeline_add_sink(GST_PIPELINE(pipeline), queue); - gst_bin_add(GST_BIN(thread), osssink); + gst_bin_add(GST_BIN(thread), osssink); - gst_pad_link(gst_element_get_pad(queue,"src"), - gst_element_get_pad(osssink,"sink")); + gst_pad_link(gst_element_get_pad(queue,"src"), + gst_element_get_pad(osssink,"sink")); - if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { - g_print("cannot autoplug pipeline\n"); - exit(-1); - } - */ + if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { + g_print("cannot autoplug pipeline\n"); + exit(-1); + } + */ - gst_bin_add(GST_BIN(pipeline), thread); + gst_bin_add (GST_BIN (pipeline), thread); /* make it ready */ - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); playing = TRUE; while (playing) { - gst_bin_iterate(GST_BIN(pipeline)); + gst_bin_iterate (GST_BIN (pipeline)); } - gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/tests/old/examples/queue3/queue3.c b/tests/old/examples/queue3/queue3.c index da92fcf7b..3a17854d7 100644 --- a/tests/old/examples/queue3/queue3.c +++ b/tests/old/examples/queue3/queue3.c @@ -4,73 +4,73 @@ gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); playing = FALSE; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue, *parse, *decode; GstElement *bin; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - bin = gst_bin_new("bin"); - g_assert(bin != NULL); + bin = gst_bin_new ("bin"); + g_assert (bin != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect(G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); - queue = gst_element_factory_make("queue", "queue"); + queue = gst_element_factory_make ("queue", "queue"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); - parse = gst_element_factory_make("mp3parse", "parse"); - decode = gst_element_factory_make("mpg123", "decode"); + parse = gst_element_factory_make ("mp3parse", "parse"); + decode = gst_element_factory_make ("mpg123", "decode"); /* add objects to the main bin */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), queue); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), queue); - gst_bin_add(GST_BIN(thread), parse); - gst_bin_add(GST_BIN(thread), decode); - gst_bin_add(GST_BIN(thread), osssink); + gst_bin_add (GST_BIN (thread), parse); + gst_bin_add (GST_BIN (thread), decode); + gst_bin_add (GST_BIN (thread), osssink); gst_element_link_many (filesrc, queue, parse, decode, osssink, NULL); /* make it ready */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); playing = TRUE; while (playing) { - gst_bin_iterate(GST_BIN(bin)); + gst_bin_iterate (GST_BIN (bin)); } - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/tests/old/examples/queue4/queue4.c b/tests/old/examples/queue4/queue4.c index 193b12fa3..8ea60d89e 100644 --- a/tests/old/examples/queue4/queue4.c +++ b/tests/old/examples/queue4/queue4.c @@ -4,81 +4,81 @@ gboolean playing; /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); playing = FALSE; } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue, *queue2, *parse, *decode; GstElement *bin; GstElement *thread, *thread2; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); - thread2 = gst_thread_new("thread2"); - g_assert(thread2 != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); + thread2 = gst_thread_new ("thread2"); + g_assert (thread2 != NULL); /* create a new bin to hold the elements */ - bin = gst_bin_new("bin"); - g_assert(bin != NULL); + bin = gst_bin_new ("bin"); + g_assert (bin != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect(G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); - queue = gst_element_factory_make("queue", "queue"); - queue2 = gst_element_factory_make("queue", "queue2"); + queue = gst_element_factory_make ("queue", "queue"); + queue2 = gst_element_factory_make ("queue", "queue2"); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); - parse = gst_element_factory_make("mp3parse", "parse"); - decode = gst_element_factory_make("mpg123", "decode"); + parse = gst_element_factory_make ("mp3parse", "parse"); + decode = gst_element_factory_make ("mpg123", "decode"); /* add objects to the main bin */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), queue); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), queue); - gst_bin_add(GST_BIN(thread), parse); - gst_bin_add(GST_BIN(thread), decode); - gst_bin_add(GST_BIN(thread), queue2); + gst_bin_add (GST_BIN (thread), parse); + gst_bin_add (GST_BIN (thread), decode); + gst_bin_add (GST_BIN (thread), queue2); - gst_bin_add(GST_BIN(thread2), osssink); + gst_bin_add (GST_BIN (thread2), osssink); gst_element_link_many (filesrc, queue, parse, decode, queue2, osssink, NULL); - gst_bin_add(GST_BIN(bin), thread); - gst_bin_add(GST_BIN(bin), thread2); + gst_bin_add (GST_BIN (bin), thread); + gst_bin_add (GST_BIN (bin), thread2); /* make it ready */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); playing = TRUE; while (playing) { - gst_bin_iterate(GST_BIN(bin)); + gst_bin_iterate (GST_BIN (bin)); } - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/tests/old/examples/retag/retag.c b/tests/old/examples/retag/retag.c index 8ab3fb9b0..0b10fa353 100644 --- a/tests/old/examples/retag/retag.c +++ b/tests/old/examples/retag/retag.c @@ -16,11 +16,11 @@ #include int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *tag_changer, *filesink; gchar *artist, *title, *ext, *filename; - + /* initialize GStreamer */ gst_init (&argc, &argv); @@ -36,7 +36,8 @@ main (int argc, char *argv[]) artist = argv[1]; artist = g_strdup (artist); ext = strrchr (artist, '.'); - if (ext) *ext = '\0'; + if (ext) + *ext = '\0'; title = strstr (artist, " - "); if (title == NULL) { g_print ("The format of the mp3 file is invalid.\n"); @@ -44,8 +45,8 @@ main (int argc, char *argv[]) } *title = '\0'; title += 3; - - + + /* create a new bin to hold the elements */ bin = gst_pipeline_new ("pipeline"); g_assert (bin); @@ -66,25 +67,24 @@ main (int argc, char *argv[]) g_assert (filesink); /* set the filenames */ - filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */ + filename = g_strdup_printf ("%s.temp", argv[1]); /* easy solution */ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesink), "location", filename, NULL); /* make sure the tag setter uses our stuff (though that should already be default) */ - gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_KEEP); + gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tag_changer), + GST_TAG_MERGE_KEEP); /* set the tagging information */ gst_tag_setter_add (GST_TAG_SETTER (tag_changer), GST_TAG_MERGE_REPLACE, - GST_TAG_ARTIST, artist, - GST_TAG_TITLE, title, - NULL); + GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (bin), filesrc, tag_changer, filesink, NULL); /* link the elements */ g_assert (gst_element_link_many (filesrc, tag_changer, filesink)); - + /* start playing */ gst_element_set_state (bin, GST_STATE_PLAYING); @@ -100,4 +100,3 @@ main (int argc, char *argv[]) return 0; } - diff --git a/tests/old/examples/retag/transcode.c b/tests/old/examples/retag/transcode.c index 07bd64fc1..ba0d98634 100644 --- a/tests/old/examples/retag/transcode.c +++ b/tests/old/examples/retag/transcode.c @@ -16,11 +16,11 @@ #include int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *decoder, *encoder, *filesink; gchar *artist, *title, *ext, *filename; - + /* initialize GStreamer */ gst_init (&argc, &argv); @@ -36,7 +36,8 @@ main (int argc, char *argv[]) artist = argv[1]; artist = g_strdup (artist); ext = strrchr (artist, '.'); - if (ext) *ext = '\0'; + if (ext) + *ext = '\0'; title = strstr (artist, " - "); if (title == NULL) { g_print ("The format of the mp3 file is invalid.\n"); @@ -45,8 +46,8 @@ main (int argc, char *argv[]) } *title = '\0'; title += 3; - - + + /* create a new bin to hold the elements */ bin = gst_pipeline_new ("pipeline"); g_assert (bin); @@ -68,13 +69,13 @@ main (int argc, char *argv[]) g_print ("cound not find plugin \"vorbisenc\""); return 1; } - + /* and a file writer */ filesink = gst_element_factory_make ("filesink", "filesink"); g_assert (filesink); /* set the filenames */ - filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */ + filename = g_strdup_printf ("%s.ogg", argv[1]); /* easy solution */ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesink), "location", filename, NULL); g_free (filename); @@ -84,16 +85,14 @@ main (int argc, char *argv[]) gst_tag_setter_set_merge_mode (GST_TAG_SETTER (encoder), GST_TAG_MERGE_KEEP); /* set the tagging information */ gst_tag_setter_add (GST_TAG_SETTER (encoder), GST_TAG_MERGE_REPLACE, - GST_TAG_ARTIST, artist, - GST_TAG_TITLE, title, - NULL); + GST_TAG_ARTIST, artist, GST_TAG_TITLE, title, NULL); /* add objects to the main pipeline */ gst_bin_add_many (GST_BIN (bin), filesrc, decoder, encoder, filesink, NULL); /* link the elements */ gst_element_link_many (filesrc, decoder, encoder, filesink, NULL); - + /* start playing */ gst_element_set_state (bin, GST_STATE_PLAYING); @@ -104,4 +103,3 @@ main (int argc, char *argv[]) return 0; } - diff --git a/tests/old/examples/thread/thread.c b/tests/old/examples/thread/thread.c index f47deca1d..5478da84d 100644 --- a/tests/old/examples/thread/thread.c +++ b/tests/old/examples/thread/thread.c @@ -2,73 +2,75 @@ #include /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - GstThread *thread = GST_THREAD(data); - g_print("have eos, quitting\n"); + GstThread *thread = GST_THREAD (data); + + g_print ("have eos, quitting\n"); /* stop the bin */ - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL); - gst_main_quit(); + gst_main_quit (); } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink; GstElement *pipeline; GstElement *thread; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new thread to hold the elements */ - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); /* create a new bin to hold the elements */ - pipeline = gst_pipeline_new("pipeline"); - g_assert(pipeline != NULL); + pipeline = gst_pipeline_new ("pipeline"); + g_assert (pipeline != NULL); /* create a disk reader */ - filesrc = gst_element_factory_make("filesrc", "disk_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); - g_signal_connect(G_OBJECT(filesrc),"eos", - G_CALLBACK(eos), thread); + filesrc = gst_element_factory_make ("filesrc", "disk_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); /* and an audio sink */ - osssink = gst_element_factory_make("osssink", "play_audio"); - g_assert(osssink != NULL); + osssink = gst_element_factory_make ("osssink", "play_audio"); + g_assert (osssink != NULL); /* add objects to the main pipeline */ /* - gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); - gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink); + gst_pipeline_add_src(GST_PIPELINE(pipeline), filesrc); + gst_pipeline_add_sink(GST_PIPELINE(pipeline), osssink); - if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { - g_print("unable to handle stream\n"); - exit(-1); - } - */ + if (!gst_pipeline_autoplug(GST_PIPELINE(pipeline))) { + g_print("unable to handle stream\n"); + exit(-1); + } + */ /*gst_bin_remove(GST_BIN(pipeline), filesrc); */ /*gst_bin_add(GST_BIN(thread), filesrc); */ - gst_bin_add(GST_BIN(thread), GST_ELEMENT(pipeline)); + gst_bin_add (GST_BIN (thread), GST_ELEMENT (pipeline)); /* make it ready */ - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_READY); /* start playing */ - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); - gst_main(); + gst_main (); - gst_object_unref(GST_OBJECT(thread)); + gst_object_unref (GST_OBJECT (thread)); - exit(0); + exit (0); } diff --git a/tests/old/examples/typefind/typefind.c b/tests/old/examples/typefind/typefind.c index a562306d3..1640ce29e 100644 --- a/tests/old/examples/typefind/typefind.c +++ b/tests/old/examples/typefind/typefind.c @@ -1,12 +1,12 @@ #include void -type_found (GstElement *typefind, const GstCaps * caps) +type_found (GstElement * typefind, const GstCaps * caps) { xmlDocPtr doc; xmlNodePtr parent; - - doc = xmlNewDoc ("1.0"); + + doc = xmlNewDoc ("1.0"); doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL); parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL); @@ -16,46 +16,45 @@ type_found (GstElement *typefind, const GstCaps * caps) xmlDocDump (stdout, doc); } -int -main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *filesrc, *typefind; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create a new bin to hold the elements */ - bin = gst_pipeline_new("bin"); - g_assert(bin != NULL); + bin = gst_pipeline_new ("bin"); + g_assert (bin != NULL); /* create a file reader */ - filesrc = gst_element_factory_make("filesrc", "file_source"); - g_assert(filesrc != NULL); - g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL); + filesrc = gst_element_factory_make ("filesrc", "file_source"); + g_assert (filesrc != NULL); + g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); - typefind = gst_element_factory_make("typefind", "typefind"); - g_assert(typefind != NULL); + typefind = gst_element_factory_make ("typefind", "typefind"); + g_assert (typefind != NULL); /* add objects to the main pipeline */ - gst_bin_add(GST_BIN(bin), filesrc); - gst_bin_add(GST_BIN(bin), typefind); + gst_bin_add (GST_BIN (bin), filesrc); + gst_bin_add (GST_BIN (bin), typefind); - g_signal_connect (G_OBJECT (typefind), "have_type", - G_CALLBACK (type_found), NULL); + g_signal_connect (G_OBJECT (typefind), "have_type", + G_CALLBACK (type_found), NULL); gst_element_link (filesrc, typefind); /* start playing */ - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); - gst_bin_iterate(GST_BIN(bin)); + gst_bin_iterate (GST_BIN (bin)); - gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/tests/old/examples/xml/createxml.c b/tests/old/examples/xml/createxml.c index c0c93e9a4..d1426e2d0 100644 --- a/tests/old/examples/xml/createxml.c +++ b/tests/old/examples/xml/createxml.c @@ -4,34 +4,37 @@ gboolean playing; static void -object_saved (GstObject *object, xmlNodePtr parent, gpointer data) +object_saved (GstObject * object, xmlNodePtr parent, gpointer data) { xmlNodePtr child; xmlNsPtr ns; - + /* first see if the namespace is already known */ - ns = xmlSearchNsByHref (parent->doc, parent, "http://gstreamer.net/gst-test/1.0/"); + ns = xmlSearchNsByHref (parent->doc, parent, + "http://gstreamer.net/gst-test/1.0/"); if (ns == NULL) { xmlNodePtr root = xmlDocGetRootElement (parent->doc); + /* add namespace to root node */ ns = xmlNewNs (root, "http://gstreamer.net/gst-test/1.0/", "test"); } - child = xmlNewChild(parent, ns, "comment", NULL); - - xmlNewChild(child, NULL, "text", (gchar *)data); + child = xmlNewChild (parent, ns, "comment", NULL); + + xmlNewChild (child, NULL, "text", (gchar *) data); } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink, *queue, *queue2, *decode; GstElement *pipeline; GstElement *thread, *thread2; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { - g_print("usage: %s \n", argv[0]); - exit(-1); + g_print ("usage: %s \n", argv[0]); + exit (-1); } /* create new threads to hold the elements */ @@ -42,12 +45,10 @@ int main(int argc,char *argv[]) /* these signals will allow us to save custom tags with the gst xml output */ g_signal_connect (G_OBJECT (thread), "object_saved", - G_CALLBACK (object_saved), - g_strdup ("decoder thread")); + G_CALLBACK (object_saved), g_strdup ("decoder thread")); g_signal_connect (G_OBJECT (thread2), "object_saved", - G_CALLBACK (object_saved), - g_strdup ("render thread")); - + G_CALLBACK (object_saved), g_strdup ("render thread")); + /* create a new bin to hold the elements */ pipeline = gst_pipeline_new ("pipeline"); g_assert (pipeline != NULL); @@ -89,4 +90,3 @@ int main(int argc,char *argv[]) exit (0); } - diff --git a/tests/old/examples/xml/runxml.c b/tests/old/examples/xml/runxml.c index e754d5f09..119d05ec3 100644 --- a/tests/old/examples/xml/runxml.c +++ b/tests/old/examples/xml/runxml.c @@ -5,7 +5,7 @@ gboolean playing; G_GNUC_UNUSED static void -xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data) +xml_loaded (GstXML * xml, GstObject * object, xmlNodePtr self, gpointer data) { xmlNodePtr children = self->xmlChildrenNode; @@ -14,10 +14,11 @@ xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data) xmlNodePtr nodes = children->xmlChildrenNode; while (nodes) { - if (!strcmp (nodes->name, "text")) { - gchar *name = g_strdup (xmlNodeGetContent (nodes)); - g_print ("object %s loaded with comment '%s'\n", - gst_object_get_name (object), name); + if (!strcmp (nodes->name, "text")) { + gchar *name = g_strdup (xmlNodeGetContent (nodes)); + + g_print ("object %s loaded with comment '%s'\n", + gst_object_get_name (object), name); } nodes = nodes->next; } @@ -26,13 +27,14 @@ xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data) } } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstXML *xml; GstElement *pipeline; gboolean ret; - gst_init(&argc,&argv); + gst_init (&argc, &argv); xml = gst_xml_new (); @@ -40,21 +42,20 @@ int main(int argc,char *argv[]) /* G_CALLBACK (xml_loaded), xml); */ if (argc == 2) - ret = gst_xml_parse_file(xml, argv[1], NULL); + ret = gst_xml_parse_file (xml, argv[1], NULL); else - ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL); - + ret = gst_xml_parse_file (xml, "xmlTest.gst", NULL); + g_assert (ret == TRUE); - pipeline = gst_xml_get_element(xml, "pipeline"); + pipeline = gst_xml_get_element (xml, "pipeline"); g_assert (pipeline != NULL); - gst_element_set_state(pipeline, GST_STATE_PLAYING); + gst_element_set_state (pipeline, GST_STATE_PLAYING); - while (gst_bin_iterate(GST_BIN(pipeline))); + while (gst_bin_iterate (GST_BIN (pipeline))); - gst_element_set_state(pipeline, GST_STATE_NULL); + gst_element_set_state (pipeline, GST_STATE_NULL); - exit(0); + exit (0); } - diff --git a/tests/old/testsuite/bins/interface.c b/tests/old/testsuite/bins/interface.c index 61f948d28..028b8f0b8 100644 --- a/tests/old/testsuite/bins/interface.c +++ b/tests/old/testsuite/bins/interface.c @@ -21,13 +21,13 @@ /* tests if gst_bin_get_(all_)by_interface works */ -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstBin *bin, *bin2; GList *list; GstElement *filesrc; - + gst_init (&argc, &argv); bin = GST_BIN (gst_bin_new (NULL)); @@ -37,18 +37,17 @@ main (gint argc, gchar *argv[]) g_assert (filesrc); g_assert (GST_IS_URI_HANDLER (filesrc)); gst_bin_add (bin, filesrc); - + g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); g_assert (g_list_length (list) == 1); g_assert (list->data == (gpointer) filesrc); g_list_free (list); - - gst_bin_add_many (bin, + + gst_bin_add_many (bin, gst_element_factory_make ("identity", NULL), - gst_element_factory_make ("identity", NULL), gst_element_factory_make ("identity", NULL), - NULL); + gst_element_factory_make ("identity", NULL), NULL); g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); g_assert (g_list_length (list) == 1); @@ -61,9 +60,7 @@ main (gint argc, gchar *argv[]) gst_bin_add_many (bin, gst_element_factory_make ("identity", NULL), gst_element_factory_make ("identity", NULL), - GST_ELEMENT (bin2), - gst_element_factory_make ("identity", NULL), - NULL); + GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL); g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); g_assert (g_list_length (list) == 1); diff --git a/tests/old/testsuite/bytestream/gstbstest.c b/tests/old/testsuite/bytestream/gstbstest.c index eb5a6c413..883bdbf36 100644 --- a/tests/old/testsuite/bytestream/gstbstest.c +++ b/tests/old/testsuite/bytestream/gstbstest.c @@ -46,14 +46,14 @@ struct _GstBsTest GstPad *srcpad; GstByteStream *bs; - - gchar *accesspattern; - guint num_patterns; - gchar **patterns; - guint sizemin; - guint sizemax; - gint count; - gboolean silent; + + gchar *accesspattern; + guint num_patterns; + gchar **patterns; + guint sizemin; + guint sizemax; + gint count; + gboolean silent; }; struct _GstBsTestClass @@ -64,13 +64,11 @@ struct _GstBsTestClass GType gst_bstest_get_type (void); -GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS ( - "ByteStreamTest", - "Filter", - "Test for the GstByteStream code", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS ("ByteStreamTest", + "Filter", + "Test for the GstByteStream code", + "Erik Walthinsen , " + "Wim Taymans "); /* BsTest signals and args */ @@ -91,17 +89,17 @@ enum }; -static void gst_bstest_base_init (gpointer g_class); -static void gst_bstest_class_init (GstBsTestClass * klass); -static void gst_bstest_init (GstBsTest * bstest); +static void gst_bstest_base_init (gpointer g_class); +static void gst_bstest_class_init (GstBsTestClass * klass); +static void gst_bstest_init (GstBsTest * bstest); -static void gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, - GParamSpec * pspec); -static void gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, - GParamSpec * pspec); +static void gst_bstest_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_bstest_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstElementStateReturn gst_bstest_change_state (GstElement *element); -static void gst_bstest_loop (GstElement * element); +static GstElementStateReturn gst_bstest_change_state (GstElement * element); +static void gst_bstest_loop (GstElement * element); static GstElementClass *parent_class = NULL; @@ -125,7 +123,8 @@ gst_bstest_get_type (void) (GInstanceInitFunc) gst_bstest_init, }; - bstest_type = g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0); + bstest_type = + g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0); } return bstest_type; } @@ -144,25 +143,25 @@ gst_bstest_class_init (GstBsTestClass * klass) GstElementClass *gstelement_class; gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass*)klass; + gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, - g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT, - 0, G_PARAM_READWRITE)); + g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT, + 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, - g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT, - 384, G_PARAM_READWRITE)); + g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT, + 384, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACCESSPATTERN, - g_param_spec_string ("accesspattern", "accesspattern", "accesspattern", - "r", G_PARAM_READWRITE)); + g_param_spec_string ("accesspattern", "accesspattern", "accesspattern", + "r", G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COUNT, - g_param_spec_uint ("count", "count", "count", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("count", "count", "count", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", + FALSE, G_PARAM_READWRITE)); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_bstest_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_bstest_get_property); @@ -172,7 +171,7 @@ gst_bstest_class_init (GstBsTestClass * klass) } static GstCaps * -gst_bstest_getcaps (GstPad *pad) +gst_bstest_getcaps (GstPad * pad) { GstBsTest *bstest = GST_BSTEST (gst_pad_get_parent (pad)); GstPad *otherpad; @@ -205,24 +204,25 @@ gst_bstest_init (GstBsTest * bstest) } static guint -gst_bstest_get_size (GstBsTest *bstest, gchar *sizestring, guint prevsize) +gst_bstest_get_size (GstBsTest * bstest, gchar * sizestring, guint prevsize) { guint size; if (sizestring[0] == 0) { size = bstest->sizemax; - } - else if (sizestring[0] == 'r') { - size = bstest->sizemin + (guint8)(((gfloat)bstest->sizemax)*rand()/(RAND_MAX + (gfloat)bstest->sizemin)); - } - else if (sizestring[0] == '<') { + } else if (sizestring[0] == 'r') { + size = + bstest->sizemin + + (guint8) (((gfloat) bstest->sizemax) * rand () / (RAND_MAX + + (gfloat) bstest->sizemin)); + } else if (sizestring[0] == '<') { size = prevsize; - } - else { + } else { size = atoi (sizestring); } - if (size == 0) size++; + if (size == 0) + size++; return size; } @@ -248,30 +248,31 @@ gst_bstest_loop (GstElement * element) if (bstest->patterns[i][0] == 'r') { size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size); - if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size); - gst_bytestream_read (bstest->bs, &buf, size); - } - else if (bstest->patterns[i][0] == 'f') { + if (!bstest->silent) + g_print ("bstest: ***** read %d bytes\n", size); + gst_bytestream_read (bstest->bs, &buf, size); + } else if (bstest->patterns[i][0] == 'f') { size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size); - if (!bstest->silent) g_print ("bstest: ***** flush %d bytes\n", size); - gst_bytestream_flush (bstest->bs, size); - } - else if (!strncmp (bstest->patterns[i], "pb", 2)) { + if (!bstest->silent) + g_print ("bstest: ***** flush %d bytes\n", size); + gst_bytestream_flush (bstest->bs, size); + } else if (!strncmp (bstest->patterns[i], "pb", 2)) { size = gst_bstest_get_size (bstest, &bstest->patterns[i][2], size); - if (!bstest->silent) g_print ("bstest: ***** peek bytes %d bytes\n", size); - gst_bytestream_peek_bytes (bstest->bs, &ptr, size); - } - else if (bstest->patterns[i][0] == 'p') { + if (!bstest->silent) + g_print ("bstest: ***** peek bytes %d bytes\n", size); + gst_bytestream_peek_bytes (bstest->bs, &ptr, size); + } else if (bstest->patterns[i][0] == 'p') { size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size); - if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size); - gst_bytestream_peek (bstest->bs, &buf, size); + if (!bstest->silent) + g_print ("bstest: ***** peek %d bytes\n", size); + gst_bytestream_peek (bstest->bs, &buf, size); gst_buffer_unref (buf); buf = NULL; } if (buf) - gst_pad_push (bstest->srcpad, GST_DATA (buf)); - + gst_pad_push (bstest->srcpad, GST_DATA (buf)); + i++; } /* } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); */ @@ -280,7 +281,8 @@ gst_bstest_loop (GstElement * element) } static void -gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstBsTest *bstest; @@ -302,16 +304,16 @@ gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, g_strfreev (bstest->patterns); } if (g_value_get_string (value) == NULL) { - gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); - bstest->accesspattern = NULL; - bstest->num_patterns = 0; + gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); + bstest->accesspattern = NULL; + bstest->num_patterns = 0; } else { guint i = 0; - bstest->accesspattern = g_strdup (g_value_get_string (value)); - bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0); - while (bstest->patterns[i++]); - bstest->num_patterns = i-1; + bstest->accesspattern = g_strdup (g_value_get_string (value)); + bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0); + while (bstest->patterns[i++]); + bstest->num_patterns = i - 1; } break; case ARG_COUNT: @@ -327,7 +329,8 @@ gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, } static void -gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) +gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstBsTest *bstest; @@ -359,7 +362,7 @@ gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, GParam } static GstElementStateReturn -gst_bstest_change_state (GstElement *element) +gst_bstest_change_state (GstElement * element) { GstBsTest *bstest; @@ -372,8 +375,7 @@ gst_bstest_change_state (GstElement *element) gst_bytestream_destroy (bstest->bs); bstest->bs = NULL; } - } - else { + } else { if (!bstest->bs) { bstest->bs = gst_bytestream_new (bstest->sinkpad); } @@ -392,17 +394,12 @@ plugin_init (GstPlugin * plugin) * This consists of the name of the element, the GType identifier, * and a pointer to the details structure at the top of the file. */ - return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY, GST_TYPE_BSTEST); + return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY, + GST_TYPE_BSTEST); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "bstest", - "test for the bytestream element", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "bstest", + "test for the bytestream element", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/tests/old/testsuite/bytestream/test1.c b/tests/old/testsuite/bytestream/test1.c index 4545f9d7a..088cacd0e 100644 --- a/tests/old/testsuite/bytestream/test1.c +++ b/tests/old/testsuite/bytestream/test1.c @@ -26,41 +26,41 @@ static gboolean verbose = FALSE; static gboolean dump = FALSE; static void -handoff (GstElement *element, GstBuffer *buf, GstPad *pad, gpointer data) +handoff (GstElement * element, GstBuffer * buf, GstPad * pad, gpointer data) { if (GST_IS_BUFFER (buf)) { if (integrity_check) { gint i; guint8 *ptr = GST_BUFFER_DATA (buf); - - for (i=0; isrc_sizetype == 2 ? "fixed" : "random"), - (param->src_data == 1 ? "src" : "subbuffer"), - param->bs_accesspattern); + desc = + g_strdup_printf ("%s %s, pattern %s", + (param->src_sizetype == 2 ? "fixed" : "random"), + (param->src_data == 1 ? "src" : "subbuffer"), param->bs_accesspattern); return desc; } -static gboolean -read_param_file (gchar *filename) +static gboolean +read_param_file (gchar * filename) { FILE *fp; - gchar line[MAX_CONFIG_LINE+1]; + gchar line[MAX_CONFIG_LINE + 1]; guint linenr = 0; gchar pattern[MAX_CONFIG_PATTERN]; gint data, sizetype, integrity_check; @@ -68,23 +68,23 @@ read_param_file (gchar *filename) gboolean res = TRUE; fp = fopen (filename, "r"); - if (fp == NULL) + if (fp == NULL) return FALSE; - scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN-1); - - while (fgets (line, MAX_CONFIG_LINE, fp)) { + scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN - 1); + + while (fgets (line, MAX_CONFIG_LINE, fp)) { linenr++; if (line[0] == '\n' || line[0] == '#') continue; - if (sscanf (line, scan_str, &data, &sizetype, pattern, &integrity_check) != 4) { + if (sscanf (line, scan_str, &data, &sizetype, pattern, + &integrity_check) != 4) { g_print ("error on line: %d\n", linenr); res = FALSE; break; - } - else { + } else { TestParam *param = g_malloc (sizeof (TestParam)); param->src_data = data; @@ -96,12 +96,12 @@ read_param_file (gchar *filename) } } g_free (scan_str); - + return res; } -static void -run_test (GstBin *pipeline, gint iters) +static void +run_test (GstBin * pipeline, gint iters) { gint vm = 0; gint maxiters = iters; @@ -114,28 +114,31 @@ run_test (GstBin *pipeline, gint iters) gint newvm = gst_alloc_trace_live_all (); gint percent; - percent = (gint)((maxiters-iters+1)*100.0/maxiters); + percent = (gint) ((maxiters - iters + 1) * 100.0 / maxiters); if (percent != prev_percent || newvm - vm > VM_THRES) { - g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm, percent); + g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm, + percent); prev_percent = percent; vm = newvm; } gst_bin_iterate (pipeline); - if (iters > 0) iters--; + if (iters > 0) + iters--; } gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); } -static void +static void usage (char *argv[]) { - g_print ("usage: %s [--verbose] [--dump] \n", argv[0]); + g_print ("usage: %s [--verbose] [--dump] \n", + argv[0]); } int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *src; GstElement *sink; @@ -149,7 +152,7 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); arg_walk = 1; - while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) { + while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) { if (!strncmp (argv[arg_walk], "--verbose", 9)) verbose = TRUE; else if (!strncmp (argv[arg_walk], "--dump", 6)) @@ -161,10 +164,10 @@ main (int argc, char *argv[]) arg_walk++; } if (argc - arg_walk < 2) { - usage(argv); + usage (argv); return -1; } - if (!read_param_file (argv[arg_walk])) { + if (!read_param_file (argv[arg_walk])) { g_print ("error reading file %s\n", argv[arg_walk]); usage (argv); return -1; @@ -198,21 +201,19 @@ main (int argc, char *argv[]) integrity_check = param->integrity_check; - g_print ("\n\nrunning test %d (%d iterations):\n", testnum+1, iterations); + g_print ("\n\nrunning test %d (%d iterations):\n", testnum + 1, iterations); desc = create_desc (param); g_print ("%s\n", desc); g_free (desc); - g_object_set (G_OBJECT (src), "data", param->src_data, - "sizetype", param->src_sizetype, - "filltype", (integrity_check?5:0), - "silent", !verbose, NULL); + g_object_set (G_OBJECT (src), "data", param->src_data, + "sizetype", param->src_sizetype, + "filltype", (integrity_check ? 5 : 0), "silent", !verbose, NULL); - g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern, - "silent", !verbose, NULL); + g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern, + "silent", !verbose, NULL); - g_object_set (G_OBJECT (sink), "dump", dump, - "silent", !verbose, NULL); + g_object_set (G_OBJECT (sink), "dump", dump, "silent", !verbose, NULL); run_test (GST_BIN (pipeline), iterations); diff --git a/tests/old/testsuite/caps/app_fixate.c b/tests/old/testsuite/caps/app_fixate.c index fbaea4216..6c8500d55 100644 --- a/tests/old/testsuite/caps/app_fixate.c +++ b/tests/old/testsuite/caps/app_fixate.c @@ -3,13 +3,13 @@ static GstCaps * -handler (GObject *object, GstCaps *caps, gpointer user_data) +handler (GObject * object, GstCaps * caps, gpointer user_data) { - g_print("in handler %p, %p, %p\n", object, caps, user_data); + g_print ("in handler %p, %p, %p\n", object, caps, user_data); - g_assert (GST_IS_PAD(object)); + g_assert (GST_IS_PAD (object)); - g_print("caps: %s\n", gst_caps_to_string(caps)); + g_print ("caps: %s\n", gst_caps_to_string (caps)); if (gst_caps_is_any (caps)) { return gst_caps_new_simple ("application/x-foo", @@ -28,7 +28,7 @@ main (int argc, char *argv[]) GstElement *pipeline; GstPad *pad; - gst_init(&argc, &argv); + gst_init (&argc, &argv); pipeline = gst_pipeline_new (NULL); @@ -37,16 +37,15 @@ main (int argc, char *argv[]) b = gst_element_factory_make ("fakesink", NULL); g_assert (b); - gst_bin_add_many (GST_BIN (pipeline), a,b, NULL); - gst_element_link (a,b); + gst_bin_add_many (GST_BIN (pipeline), a, b, NULL); + gst_element_link (a, b); pad = gst_element_get_pad (a, "src"); g_signal_connect (G_OBJECT (pad), "fixate", G_CALLBACK (handler), - (void *)0xdeadbeef); + (void *) 0xdeadbeef); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); return 0; } - diff --git a/tests/old/testsuite/caps/caps.c b/tests/old/testsuite/caps/caps.c index 48e9a1037..c99b0d8a2 100644 --- a/tests/old/testsuite/caps/caps.c +++ b/tests/old/testsuite/caps/caps.c @@ -2,138 +2,139 @@ #include -void test1(void) +void +test1 (void) { GstCaps *caps; GstCaps *caps2; - g_print("type is %d\n", (int)gst_caps_get_type()); + g_print ("type is %d\n", (int) gst_caps_get_type ()); - caps = gst_caps_new_empty(); - g_assert(caps != NULL); - gst_caps_free(caps); + caps = gst_caps_new_empty (); + g_assert (caps != NULL); + gst_caps_free (caps); - caps = gst_caps_new_any(); - g_assert(caps != NULL); - gst_caps_free(caps); + caps = gst_caps_new_any (); + g_assert (caps != NULL); + gst_caps_free (caps); - caps = gst_caps_new_simple("audio/raw", - "_int", G_TYPE_INT, 100, NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); - caps = gst_caps_new_simple("audio/raw", + caps = gst_caps_new_simple ("audio/raw", "_double", G_TYPE_DOUBLE, 100.0, NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", - "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC('a','b','c','d'), NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", + "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'), NULL); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", "_boolean", G_TYPE_BOOLEAN, TRUE, NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_full( - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL), - gst_structure_new("audio/raw2", "_int", G_TYPE_INT, 100, NULL), - NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE); - g_assert(gst_caps_is_fixed(caps)==FALSE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL); - g_assert(caps != NULL); - caps2 = gst_caps_copy(caps); - g_assert(caps2 != NULL); - g_assert(gst_caps_is_empty(caps2)==FALSE); - g_assert(gst_caps_is_any(caps2)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps2)==TRUE); - g_assert(gst_caps_is_fixed(caps2)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - g_print("%s\n", gst_caps_to_string(caps2)); - gst_caps_free(caps); - gst_caps_free(caps2); - - caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL); - gst_caps_append (caps, - gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 200, NULL)); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE); - g_assert(gst_caps_is_fixed(caps)==FALSE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL); - g_assert(caps != NULL); - gst_caps_append_structure (caps, - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL)); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE); - g_assert(gst_caps_is_fixed(caps)==FALSE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = + gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, + 100, NULL), gst_structure_new ("audio/raw2", "_int", G_TYPE_INT, 100, + NULL), NULL); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); + g_assert (gst_caps_is_fixed (caps) == FALSE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + g_assert (caps != NULL); + caps2 = gst_caps_copy (caps); + g_assert (caps2 != NULL); + g_assert (gst_caps_is_empty (caps2) == FALSE); + g_assert (gst_caps_is_any (caps2) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps2) == TRUE); + g_assert (gst_caps_is_fixed (caps2) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + g_print ("%s\n", gst_caps_to_string (caps2)); + gst_caps_free (caps); + gst_caps_free (caps2); + + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + gst_caps_append (caps, + gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 200, NULL)); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); + g_assert (gst_caps_is_fixed (caps) == FALSE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + g_assert (caps != NULL); + gst_caps_append_structure (caps, + gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, NULL)); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); + g_assert (gst_caps_is_fixed (caps) == FALSE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); } -void test2(void) +void +test2 (void) { GstCaps *caps1; GstCaps *caps2; GstCaps *caps; - caps1 = gst_caps_new_full( - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL), - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL), - NULL); - caps2 = gst_caps_new_full( - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL), - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 300, NULL), - NULL); - caps = gst_caps_intersect(caps1, caps2); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - gst_caps_free(caps1); - gst_caps_free(caps2); + caps1 = + gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, + 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, + NULL), NULL); + caps2 = + gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, + 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 300, + NULL), NULL); + caps = gst_caps_intersect (caps1, caps2); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + gst_caps_free (caps1); + gst_caps_free (caps2); } -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - gst_init(&argc, &argv); + gst_init (&argc, &argv); - test1(); - test2(); + test1 (); + test2 (); return 0; } - diff --git a/tests/old/testsuite/caps/compatibility.c b/tests/old/testsuite/caps/compatibility.c index 036813a81..9b24e7f7f 100644 --- a/tests/old/testsuite/caps/compatibility.c +++ b/tests/old/testsuite/caps/compatibility.c @@ -1,67 +1,38 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS( - "video/mpeg, " - "mpegtype=(int)[1,2]" -); - -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS( - "video/mpeg, " - "mpegtype=(int)1" -); - -GstStaticCaps rawcaps = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc){YV12,YUY2}, " - "width=(int)[16,4096], " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps2 = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc)YUY2, " - "height=(int)[16,256]" -); - -GstStaticCaps rawcaps3 = GST_STATIC_CAPS( - "video/raw, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)[1,2]"); + +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1"); + +GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, " "fourcc=(fourcc){YV12,YUY2}, " - "height=(int)[16,4096]" -); + "width=(int)[16,4096], " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc)YUY2, " "height=(int)[16,256]"); + +GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){YV12,YUY2}, " "height=(int)[16,4096]"); #if 0 /* these caps aren't used yet */ -GstStaticCaps rawcaps4 = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc){\"YV12\", \"YUYV\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps4 = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, " - "height=(int)[16,4096]" -); +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YV12\", \"YUYV\"}, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, " "height=(int)[16,4096]"); #endif -GstStaticCaps rawcaps6 = GST_STATIC_CAPS( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YUYV\"" -); +GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\""); -GstStaticCaps rawcaps7 = GST_STATIC_CAPS( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YV12\"" -); +GstStaticCaps rawcaps7 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\""); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { gboolean testret; gint ret = 0; @@ -72,12 +43,12 @@ main (int argc, char *argv[]) gst_static_caps_get (&rawcaps)); g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; - + testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps), gst_static_caps_get (&sinkcaps)); g_print ("4 <-> 1 == %d (valid, subset)\n", testret); ret = ret + (testret == TRUE) ? 0 : 1; - + testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps), gst_static_caps_get (&mp1parsecaps)); g_print ("1 <-> 4 == %d (invalid, superset)\n", testret); diff --git a/tests/old/testsuite/caps/fixed.c b/tests/old/testsuite/caps/fixed.c index 649bdd072..e0913d2ee 100644 --- a/tests/old/testsuite/caps/fixed.c +++ b/tests/old/testsuite/caps/fixed.c @@ -19,22 +19,19 @@ #include -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { #if 0 GstCaps *caps; - + gst_init (&argc, &argv); - caps = GST_CAPS_NEW ( - "testcaps", - "unknown/unknown", - NULL); + caps = GST_CAPS_NEW ("testcaps", "unknown/unknown", NULL); /* newly crrated caps without props is fixed */ g_assert (GST_CAPS_IS_FIXED (caps)); - + entry = gst_props_entry_new ("foo", GST_PROPS_INT (5)); /* this entry is fixed */ g_assert (gst_props_entry_is_fixed (entry)); @@ -42,7 +39,7 @@ main (gint argc, gchar *argv[]) props = gst_props_empty_new (); /* props are fixed when created */ g_assert (GST_PROPS_IS_FIXED (props)); - + gst_props_add_entry (props, entry); /* props should still be fixed */ g_assert (GST_PROPS_IS_FIXED (props)); @@ -67,7 +64,7 @@ main (gint argc, gchar *argv[]) /* caps too */ g_assert (GST_CAPS_IS_FIXED (caps)); - gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1,5)); + gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1, 5)); /* props should be variable again now */ g_assert (!GST_PROPS_IS_FIXED (props)); /* caps too */ diff --git a/tests/old/testsuite/caps/intersect2.c b/tests/old/testsuite/caps/intersect2.c index f5464dce7..f148b4ae1 100644 --- a/tests/old/testsuite/caps/intersect2.c +++ b/tests/old/testsuite/caps/intersect2.c @@ -1,49 +1,42 @@ #include -GstStaticCaps rawcaps1 = GST_STATIC_CAPS( - "video/x-raw-yuv, " +GstStaticCaps rawcaps1 = GST_STATIC_CAPS ("video/x-raw-yuv, " "fourcc:fourcc=\"YUYV\", " "height:int=640, " "width:int=480, " "framerate:float=30.0; " - "video/x-raw-yuv, " + "video/x-raw-yuv, " "fourcc:fourcc=\"I420\", " - "height:int=640, " - "width:int=480, " - "framerate:float=30.0" -); + "height:int=640, " "width:int=480, " "framerate:float=30.0"); -GstStaticCaps rawcaps2 = GST_STATIC_CAPS( - "video/x-raw-yuv" -); +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/x-raw-yuv"); -GstStaticCaps rawcaps3 = GST_STATIC_CAPS( - "video/x-raw-yuv, height=(int) [ 0, MAX ]" -); +GstStaticCaps rawcaps3 = +GST_STATIC_CAPS ("video/x-raw-yuv, height=(int) [ 0, MAX ]"); -GstStaticCaps rawcaps4 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY" -); +GstStaticCaps rawcaps4 = + GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY"); -GstStaticCaps rawcaps5 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]" -); +GstStaticCaps rawcaps5 = + GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]"); -GstStaticCaps rawcaps6 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240" -); +GstStaticCaps rawcaps6 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"); -GstStaticCaps rawcaps7 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]" -); +GstStaticCaps rawcaps7 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]"); -GstStaticCaps rawcaps8 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240" -); +GstStaticCaps rawcaps8 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstCaps *caps1; GstCaps *caps2; @@ -53,49 +46,53 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps1)); - caps2 = gst_caps_new_full (gst_structure_copy ( gst_caps_get_structure ( - gst_static_caps_get (&rawcaps1), 0)), NULL); + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps1)); + caps2 = + gst_caps_new_full (gst_structure_copy (gst_caps_get_structure + (gst_static_caps_get (&rawcaps1), 0)), NULL); #if 0 - gst_caps_set(caps1, "height", GST_PROPS_INT(640)); - gst_caps_set(caps1, "width", GST_PROPS_INT(480)); - gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT(30.0)); + gst_caps_set (caps1, "height", GST_PROPS_INT (640)); + gst_caps_set (caps1, "width", GST_PROPS_INT (480)); + gst_caps_set (caps1, "framerate", GST_PROPS_FLOAT (30.0)); #endif - caps = gst_caps_intersect(caps1, caps2); - g_print("caps %s\n", gst_caps_to_string(caps)); - if (gst_caps_is_empty (caps)) return 1; - gst_caps_free(caps1); - gst_caps_free(caps2); - - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps2)); - caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps3)); - caps = gst_caps_intersect(caps1, caps2); - g_print("caps %s\n", gst_caps_to_string(caps)); - if (gst_caps_is_empty (caps)) return 1; - gst_caps_free(caps1); - gst_caps_free(caps2); - - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps4)); - caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps5)); - caps3 = gst_caps_copy( gst_static_caps_get (&rawcaps6)); - caps4 = gst_caps_intersect(caps1, caps2); - caps = gst_caps_intersect(caps3, caps4); - g_print("caps4 %s\n", gst_caps_to_string(caps4)); - g_print("caps %s\n", gst_caps_to_string(caps)); - gst_caps_free(caps1); - gst_caps_free(caps2); - gst_caps_free(caps3); - gst_caps_free(caps4); - - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps7)); - caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps8)); - caps = gst_caps_intersect(caps1, caps2); - g_print("caps %s\n", gst_caps_to_string(caps)); - if (gst_caps_is_empty (caps)) return 1; - gst_caps_free(caps1); - gst_caps_free(caps2); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); + + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps2)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps3)); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); + + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps4)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps5)); + caps3 = gst_caps_copy (gst_static_caps_get (&rawcaps6)); + caps4 = gst_caps_intersect (caps1, caps2); + caps = gst_caps_intersect (caps3, caps4); + g_print ("caps4 %s\n", gst_caps_to_string (caps4)); + g_print ("caps %s\n", gst_caps_to_string (caps)); + gst_caps_free (caps1); + gst_caps_free (caps2); + gst_caps_free (caps3); + gst_caps_free (caps4); + + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps7)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps8)); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); return 0; } diff --git a/tests/old/testsuite/caps/intersection.c b/tests/old/testsuite/caps/intersection.c index 2e369700e..381cb7d2f 100644 --- a/tests/old/testsuite/caps/intersection.c +++ b/tests/old/testsuite/caps/intersection.c @@ -1,77 +1,50 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1, " - "foo1=(int)[20,40], " - "foo2=(int)[20,40], " - "foo3=(int)[10,20]" -); + "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]"); -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1, " - "foo1=(int)30, " - "foo2=(int)[20,30], " - "foo3=(int)[20,30]" -); - - - -GstStaticCaps rawcaps = GST_STATIC_CAPS ( - "video/raw, " - "width=(int)[16,4096], " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps2 = GST_STATIC_CAPS ( - "video/raw, " - "height=(int)[16,256], " - "depth=(int)16" -); - -GstStaticCaps rawcaps3 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YUY2\", \"YV12\" }, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps4 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps5 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps6 = GST_STATIC_CAPS ( - "video/raw, " + "foo1=(int)30, " "foo2=(int)[20,30], " "foo3=(int)[20,30]"); + + + +GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, " + "width=(int)[16,4096], " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, " + "height=(int)[16,256], " "depth=(int)16"); + +GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUY2\", \"YV12\" }, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps5 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, " "fourcc=(fourcc)\"YUYV\", " "height=(int)640, " "width=(int)480, " "framerate=(double)30.0; " - "video/raw, " + "video/raw, " "fourcc=(fourcc)\"I420\", " - "height=(int)640, " - "width=(int)480, " - "framerate=(double)30.0" -); + "height=(int)640, " "width=(int)480, " "framerate=(double)30.0"); -GstStaticCaps rawcaps7 = GST_STATIC_CAPS ( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]" -); +GstStaticCaps rawcaps7 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]"); -GstStaticCaps rawcaps8 = GST_STATIC_CAPS ( - "video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]" -); +GstStaticCaps rawcaps8 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]"); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { xmlDocPtr doc; xmlNodePtr parent; @@ -83,13 +56,13 @@ main (int argc, char *argv[]) doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL); /* - g_mem_chunk_info (); - for (i = 0; i<100000; i++) { - caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4)); - gst_caps_unref (caps); - } - g_mem_chunk_info (); - */ + g_mem_chunk_info (); + for (i = 0; i<100000; i++) { + caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4)); + gst_caps_unref (caps); + } + g_mem_chunk_info (); + */ caps = gst_caps_intersect (gst_static_caps_get (&sinkcaps), gst_static_caps_get (&mp1parsecaps)); @@ -112,16 +85,16 @@ main (int argc, char *argv[]) gst_caps_save_thyself (caps, parent); caps = gst_caps_intersect (gst_static_caps_get (&rawcaps6), - gst_caps_new_full (gst_structure_copy ( - gst_caps_get_structure (gst_static_caps_get (&rawcaps6), 0)), NULL)); + gst_caps_new_full (gst_structure_copy (gst_caps_get_structure + (gst_static_caps_get (&rawcaps6), 0)), NULL)); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL); gst_caps_save_thyself (caps, parent); caps = gst_caps_intersect (gst_static_caps_get (&rawcaps7), gst_static_caps_get (&rawcaps8)); - g_print("intersection: %s\n", gst_caps_to_string (caps)); + g_print ("intersection: %s\n", gst_caps_to_string (caps)); - xmlDocDump(stdout, doc); + xmlDocDump (stdout, doc); return 0; } diff --git a/tests/old/testsuite/caps/normalisation.c b/tests/old/testsuite/caps/normalisation.c index 89344fa3e..4d1eae395 100644 --- a/tests/old/testsuite/caps/normalisation.c +++ b/tests/old/testsuite/caps/normalisation.c @@ -1,56 +1,32 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "foo1=(int)[20,40], " - "foo2=(int)[20,40], " - "foo3=(int)[10,20]" -); + "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]"); -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ( - "video/mpeg, " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "foo4=(fourcc){\"YV12\",\"YUY2\"}" -); +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " + "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "foo4=(fourcc){\"YV12\",\"YUY2\"}"); -GstStaticCaps rawcaps = GST_STATIC_CAPS ( - "video/raw, " +GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, " "width=(int)[16,4096], " - "height=(int)[16,4096], " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}" -); + "height=(int)[16,4096], " "fourcc=(fourcc){\"YV12\",\"YUY2\"}"); -GstStaticCaps rawcaps2 = GST_STATIC_CAPS ( - "video/raw, " - "width=(int)[16,256], " - "height=(int)16; " - "video/raw, " +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, " "width=(int)[16,256], " - "height=(int)16" -); + "height=(int)16; " "video/raw, " "width=(int)[16,256], " "height=(int)16"); -GstStaticCaps rawcaps3 = GST_STATIC_CAPS ( - "video/raw, " +GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, " "width=(int)[16,256], " "height=(int)16; " - "video/raw, " + "video/raw, " "width=(int)[16,256], " "height=(int)16; " - "video/raw, " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "height=(int)[16,4096]" -); + "video/raw, " + "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]"); -GstStaticCaps rawcaps4 = GST_STATIC_CAPS ( - "x, " - "y=(int){1,2}, " - "z=(int){3,4}; " - "a, " - "b=(int){5,6}, " - "c=(int){7,8}" -); +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("x, " + "y=(int){1,2}, " "z=(int){3,4}; " "a, " "b=(int){5,6}, " "c=(int){7,8}"); /* defined, not used GST_CAPS_FACTORY (rawcaps4, @@ -79,8 +55,8 @@ GST_CAPS_FACTORY (rawcaps5, ); */ -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstCaps *caps; diff --git a/tests/old/testsuite/caps/string-conversions.c b/tests/old/testsuite/caps/string-conversions.c index 8e9e7d648..c37298dc7 100644 --- a/tests/old/testsuite/caps/string-conversions.c +++ b/tests/old/testsuite/caps/string-conversions.c @@ -1,60 +1,31 @@ #include #include -GstStaticCaps caps1 = GST_STATIC_CAPS ( - "video/mpeg, " - "mpegtype=(int){1,2}" -); - -GstStaticCaps caps2 = GST_STATIC_CAPS ( - "video/mpeg, " - "mpegtype=(int){1}" -); - -GstStaticCaps caps3 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "width=(int)[16,4096], " - "height=(int)[16,4096]" -); - -GstStaticCaps caps4 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc)\"YV12\", " - "height=(int)[16,256]" -); - -GstStaticCaps caps5 = GST_STATIC_CAPS ( - "video/raw, " +GstStaticCaps caps1 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1,2}"); + +GstStaticCaps caps2 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1}"); + +GstStaticCaps caps3 = GST_STATIC_CAPS ("video/raw, " "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps caps6 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YV12\",\"YUYV\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps caps7 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps caps8 = GST_STATIC_CAPS ( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YUYV\"" -); - -GstStaticCaps caps9 = GST_STATIC_CAPS ( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YV12\"" -); + "width=(int)[16,4096], " "height=(int)[16,4096]"); + +GstStaticCaps caps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc)\"YV12\", " "height=(int)[16,256]"); + +GstStaticCaps caps5 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]"); + +GstStaticCaps caps6 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YV12\",\"YUYV\"}, " "height=(int)[16,4096]"); + +GstStaticCaps caps7 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, " "height=(int)[16,4096]"); + +GstStaticCaps caps8 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\""); + +GstStaticCaps caps9 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\""); static gint test = 0; static gint failures = 0; @@ -70,9 +41,9 @@ static gint failures = 0; } \ }G_STMT_END static void -test_caps_func (const GstCaps *caps) +test_caps_func (const GstCaps * caps) { - gchar *str1, *str2; + gchar *str1, *str2; gboolean ret = FALSE; str1 = gst_caps_to_string (caps); @@ -90,13 +61,13 @@ test_caps_func (const GstCaps *caps) TEST_END (ret); } static void -test_caps (const GstCaps *caps) +test_caps (const GstCaps * caps) { TEST_START; test_caps_func (caps); } static void -test_string (gchar *str) +test_string (gchar * str) { GstCaps *caps; @@ -111,21 +82,22 @@ test_string (gchar *str) test_caps_func (caps); } static void -test_string_fail (gchar *str) +test_string_fail (gchar * str) { GstCaps *caps; TEST_START; g_print ("%3d, INFO : checking %s for failure\n", test, str); caps = gst_caps_from_string (str); -g_print("got %p\n", caps); + g_print ("got %p\n", caps); TEST_END (caps == NULL); } -int -main (int argc, char *argv[]) + +int +main (int argc, char *argv[]) { gst_init (&argc, &argv); -goto bla; + goto bla; bla: /* stupidity tests */ test_caps (gst_caps_new_simple ("audio/raw", NULL)); @@ -176,23 +148,29 @@ bla: test_string ("audio/raw, test=(double) [1.3, (double)2.1 ]"); test_string ("audio/raw, test =(i) [(int)1,2]"); test_string ("audio/raw, test={(int)1,2}"); - test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}"); + test_string + ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}"); test_string ("audio/raw, test= {1.0}"); test_string ("audio/raw, test= {\"hi\", \"i dig ya\", dude}"); test_string ("audio/raw, test= {(int)1,2}"); test_string ("audio/raw, test= {(int)1,2}"); - + /* prop concatenations */ test_string ("audio/raw, test=(double) [1.3, (double)2.1 ], test2= [ 1, 2 ]"); test_string ("audio/raw , test=(fourcc) \"RGB \",test2=(int)1"); - test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \""); + test_string + ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \""); test_string ("audio/raw, test= [1.3, 2.1 ] , test2= {1.0}"); - test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1"); + test_string + ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1"); /* caps concatenations */ - test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\""); - test_string ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}"); - test_string ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]"); + test_string + ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\""); + test_string + ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}"); + test_string + ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]"); /* mimes */ @@ -210,9 +188,9 @@ bla: test_string_fail ("audio/raw, test= '"); if (failures) { - g_print ("\n FAILURES : %d\n", failures); + g_print ("\n FAILURES : %d\n", failures); } else { - g_print ("\n DONE\n"); + g_print ("\n DONE\n"); } return failures; } diff --git a/tests/old/testsuite/caps/union.c b/tests/old/testsuite/caps/union.c index 557cda4d0..b229bd75a 100644 --- a/tests/old/testsuite/caps/union.c +++ b/tests/old/testsuite/caps/union.c @@ -1,24 +1,15 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype:int=1, " - "foo1:int=[20,40], " - "foo2:int=[20,40], " - "foo3:int=[10,20]" -); + "foo1:int=[20,40], " "foo2:int=[20,40], " "foo3:int=[10,20]"); -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ( - "video/mpeg, " - "mpegtype:int=1, " - "foo1:int=30, " - "foo2:int=[20,30], " - "foo3:int=[20,30]" -); +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " + "mpegtype:int=1, " "foo1:int=30, " "foo2:int=[20,30], " "foo3:int=[20,30]"); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { xmlDocPtr doc; xmlNodePtr parent; @@ -34,7 +25,7 @@ main (int argc, char *argv[]) parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL); gst_caps_save_thyself (caps, parent); - xmlDocDump(stdout, doc); + xmlDocDump (stdout, doc); return 0; } diff --git a/tests/old/testsuite/caps/value_compare.c b/tests/old/testsuite/caps/value_compare.c index 852de5197..646e333f5 100644 --- a/tests/old/testsuite/caps/value_compare.c +++ b/tests/old/testsuite/caps/value_compare.c @@ -2,63 +2,63 @@ #include #include -void test1(void) +void +test1 (void) { GValue value1 = { 0 }; GValue value2 = { 0 }; //GValue value3 = { 0 }; //gboolean ret; - g_value_init(&value1, G_TYPE_INT); - g_value_set_int(&value1, 10); - g_value_init(&value2, G_TYPE_INT); - g_value_set_int(&value2, 20); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN); - g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, G_TYPE_INT); + g_value_set_int (&value1, 10); + g_value_init (&value2, G_TYPE_INT); + g_value_set_int (&value2, 20); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN); + g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); - g_value_init(&value1, G_TYPE_DOUBLE); - g_value_set_double(&value1, 10); - g_value_init(&value2, G_TYPE_DOUBLE); - g_value_set_double(&value2, 20); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN); - g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, G_TYPE_DOUBLE); + g_value_set_double (&value1, 10); + g_value_init (&value2, G_TYPE_DOUBLE); + g_value_set_double (&value2, 20); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN); + g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); - g_value_init(&value1, G_TYPE_STRING); - g_value_set_string(&value1, "a"); - g_value_init(&value2, G_TYPE_STRING); - g_value_set_string(&value2, "b"); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN); - g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, G_TYPE_STRING); + g_value_set_string (&value1, "a"); + g_value_init (&value2, G_TYPE_STRING); + g_value_set_string (&value2, "b"); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN); + g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); - g_value_init(&value1, GST_TYPE_FOURCC); - gst_value_set_fourcc(&value1, GST_MAKE_FOURCC('a','b','c','d')); - g_value_init(&value2, GST_TYPE_FOURCC); - gst_value_set_fourcc(&value2, GST_MAKE_FOURCC('1','2','3','4')); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_UNORDERED); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, GST_TYPE_FOURCC); + gst_value_set_fourcc (&value1, GST_MAKE_FOURCC ('a', 'b', 'c', 'd')); + g_value_init (&value2, GST_TYPE_FOURCC); + gst_value_set_fourcc (&value2, GST_MAKE_FOURCC ('1', '2', '3', '4')); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); } -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - gst_init(&argc, &argv); + gst_init (&argc, &argv); - test1(); + test1 (); return 0; } - - diff --git a/tests/old/testsuite/caps/value_intersect.c b/tests/old/testsuite/caps/value_intersect.c index 94ad6797e..aebd448e4 100644 --- a/tests/old/testsuite/caps/value_intersect.c +++ b/tests/old/testsuite/caps/value_intersect.c @@ -1,23 +1,25 @@ #include -void test1(void) +void +test1 (void) { GValue dest = { 0 }; GValue src1 = { 0 }; GValue src2 = { 0 }; gboolean ret; - g_value_init(&src1, G_TYPE_INT); - g_value_set_int(&src1, 10); - g_value_init(&src2, G_TYPE_INT); - g_value_set_int(&src1, 20); - ret = gst_value_intersect(&dest, &src1, &src2); - g_assert(ret == 0); - g_print("ret = %d\n",ret); + g_value_init (&src1, G_TYPE_INT); + g_value_set_int (&src1, 10); + g_value_init (&src2, G_TYPE_INT); + g_value_set_int (&src1, 20); + ret = gst_value_intersect (&dest, &src1, &src2); + g_assert (ret == 0); + g_print ("ret = %d\n", ret); } -void test2(void) +void +test2 (void) { GValue dest = { 0 }; GValue src1 = { 0 }; @@ -25,33 +27,32 @@ void test2(void) GValue item = { 0 }; gboolean ret; - g_value_init(&src1, GST_TYPE_FOURCC); - gst_value_set_fourcc(&src1, GST_MAKE_FOURCC('Y','U','Y','2')); - g_value_init(&src2, GST_TYPE_LIST); - g_value_init(&item, GST_TYPE_FOURCC); - gst_value_set_fourcc(&item, GST_MAKE_FOURCC('Y','U','Y','2')); + g_value_init (&src1, GST_TYPE_FOURCC); + gst_value_set_fourcc (&src1, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2')); + g_value_init (&src2, GST_TYPE_LIST); + g_value_init (&item, GST_TYPE_FOURCC); + gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2')); gst_value_list_append_value (&src2, &item); - gst_value_set_fourcc(&item, GST_MAKE_FOURCC('I','4','2','0')); + gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('I', '4', '2', '0')); gst_value_list_append_value (&src2, &item); - gst_value_set_fourcc(&item, GST_MAKE_FOURCC('A','B','C','D')); + gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('A', 'B', 'C', 'D')); gst_value_list_append_value (&src2, &item); - ret = gst_value_intersect(&dest, &src1, &src2); - g_print("ret = %d\n",ret); + ret = gst_value_intersect (&dest, &src1, &src2); + g_print ("ret = %d\n", ret); - g_print("type = %s\n", g_type_name(G_VALUE_TYPE(&dest))); - g_print("value = %s\n", g_strdup_value_contents(&dest)); + g_print ("type = %s\n", g_type_name (G_VALUE_TYPE (&dest))); + g_print ("value = %s\n", g_strdup_value_contents (&dest)); } -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - gst_init(&argc, &argv); + gst_init (&argc, &argv); - test1(); - test2(); + test1 (); + test2 (); return 0; } - - diff --git a/tests/old/testsuite/cleanup/cleanup1.c b/tests/old/testsuite/cleanup/cleanup1.c index 00064ac8d..ac8ffd876 100644 --- a/tests/old/testsuite/cleanup/cleanup1.c +++ b/tests/old/testsuite/cleanup/cleanup1.c @@ -6,7 +6,7 @@ create_pipeline (void) GstElement *fakesrc, *fakesink; GstElement *pipeline; - + pipeline = gst_pipeline_new ("main_pipeline"); fakesrc = gst_element_factory_make ("fakesrc", "fakesrc"); @@ -22,13 +22,13 @@ create_pipeline (void) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; gint i = 1000; gint step = 100; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -37,7 +37,7 @@ main (gint argc, gchar *argv[]) if (i % step == 0) fprintf (stderr, "%10d\r", i); pipeline = create_pipeline (); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/tests/old/testsuite/cleanup/cleanup2.c b/tests/old/testsuite/cleanup/cleanup2.c index 91f0f5afa..53fcba77a 100644 --- a/tests/old/testsuite/cleanup/cleanup2.c +++ b/tests/old/testsuite/cleanup/cleanup2.c @@ -13,7 +13,8 @@ create_pipeline (void) bin = gst_bin_new ("bin"); fakesink = gst_element_factory_make ("fakesink", "fakesink"); gst_bin_add (GST_BIN (bin), fakesink); - gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"), "sink"); + gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"), + "sink"); gst_element_link (fakesrc, bin); @@ -25,13 +26,13 @@ create_pipeline (void) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; gint i = 1000; gint step = 100; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -41,7 +42,7 @@ main (gint argc, gchar *argv[]) if (i % step == 0) fprintf (stderr, "%10d\r", i); pipeline = create_pipeline (); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/tests/old/testsuite/cleanup/cleanup3.c b/tests/old/testsuite/cleanup/cleanup3.c index cdd102a00..c2a35fe38 100644 --- a/tests/old/testsuite/cleanup/cleanup3.c +++ b/tests/old/testsuite/cleanup/cleanup3.c @@ -15,8 +15,9 @@ create_pipeline (void) queue = gst_element_factory_make ("queue", "queue"); gst_bin_add (GST_BIN (thread), fakesink); gst_bin_add (GST_BIN (thread), queue); - gst_element_link (queue, fakesink); - gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), "sink"); + gst_element_link (queue, fakesink); + gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), + "sink"); gst_element_link (fakesrc, thread); @@ -29,13 +30,13 @@ create_pipeline (void) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; gint i = 10000; gint step = 100; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -45,7 +46,7 @@ main (gint argc, gchar *argv[]) if (i % step == 0) fprintf (stderr, "%10d\r", i); pipeline = create_pipeline (); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/tests/old/testsuite/cleanup/cleanup4.c b/tests/old/testsuite/cleanup/cleanup4.c index 236407215..ba56a1b24 100644 --- a/tests/old/testsuite/cleanup/cleanup4.c +++ b/tests/old/testsuite/cleanup/cleanup4.c @@ -1,13 +1,13 @@ #include gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *fakesrc; gint i; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -34,7 +34,7 @@ main (gint argc, gchar *argv[]) gst_bin_add (GST_BIN (bin), fakesink); gst_bin_add (GST_BIN (pipeline), bin); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/tests/old/testsuite/cleanup/cleanup5.c b/tests/old/testsuite/cleanup/cleanup5.c index e2a1b61f4..a3187b8bc 100644 --- a/tests/old/testsuite/cleanup/cleanup5.c +++ b/tests/old/testsuite/cleanup/cleanup5.c @@ -1,13 +1,14 @@ #include -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *element; gint i = 1000; gint step = 100; - - free (malloc(8)); /* -lefence */ + + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -15,15 +16,14 @@ int main(int argc,char *argv[]) bin = gst_pipeline_new ("pipeline"); - while (i--) - { + while (i--) { GstPad *pad; if (i % step == 0) fprintf (stderr, "\r%10d", i); element = gst_element_factory_make ("tee", "tee"); - if (!element) + if (!element) break; pad = gst_element_get_request_pad (element, "src%d"); diff --git a/tests/old/testsuite/clock/clock1.c b/tests/old/testsuite/clock/clock1.c index f7865d810..33cf8c440 100644 --- a/tests/old/testsuite/clock/clock1.c +++ b/tests/old/testsuite/clock/clock1.c @@ -8,12 +8,12 @@ #include void -gst_clock_debug (GstClock *clock) +gst_clock_debug (GstClock * clock) { - g_print ("Clock info: time %"G_GUINT64_FORMAT"\n", - gst_clock_get_time (clock)); + g_print ("Clock info: time %" G_GUINT64_FORMAT "\n", + gst_clock_get_time (clock)); } - + int main (int argc, char *argv[]) { @@ -22,24 +22,20 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL) - { + if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL) { g_print ("Could not create a fakesrc element !\n"); return 1; } - if ((id = gst_element_factory_make ("identity", "filter")) == NULL) - { + if ((id = gst_element_factory_make ("identity", "filter")) == NULL) { g_print ("Could not create a identity element !\n"); return 1; } - if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL) - { + if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL) { g_print ("Could not create a fakesink element !\n"); return 1; } - if ((pipeline = gst_pipeline_new ("pipeline")) == NULL) - { + if ((pipeline = gst_pipeline_new ("pipeline")) == NULL) { g_print ("Could not create a pipeline element !\n"); return 1; } diff --git a/tests/old/testsuite/clock/clock2.c b/tests/old/testsuite/clock/clock2.c index be369103b..303b9c20f 100644 --- a/tests/old/testsuite/clock/clock2.c +++ b/tests/old/testsuite/clock/clock2.c @@ -8,12 +8,13 @@ #include void -gst_clock_debug (GstClock *clock, GstElement *fakesink) +gst_clock_debug (GstClock * clock, GstElement * fakesink) { - g_print ("Clock info: time %"G_GUINT64_FORMAT" - Element info: time %"G_GUINT64_FORMAT"\n", - gst_clock_get_time (clock), gst_element_get_time (fakesink)); + g_print ("Clock info: time %" G_GUINT64_FORMAT " - Element info: time %" + G_GUINT64_FORMAT "\n", gst_clock_get_time (clock), + gst_element_get_time (fakesink)); } - + int main (int argc, char *argv[]) { @@ -35,14 +36,14 @@ main (int argc, char *argv[]) gst_bin_add_many (GST_BIN (pipeline), fakesink, fakesrc, NULL); gst_element_link (fakesrc, fakesink); gst_element_set_state (pipeline, GST_STATE_PLAYING); - + gst_clock_debug (clock, fakesink); g_usleep (G_USEC_PER_SEC); gst_clock_debug (clock, fakesink); gst_element_wait (fakesink, 2 * GST_SECOND); gst_clock_debug (clock, fakesink); - + gst_element_wait (fakesink, 5 * GST_SECOND); gst_clock_debug (clock, fakesink); diff --git a/tests/old/testsuite/debug/category.c b/tests/old/testsuite/debug/category.c index 07b3fd8d3..edc43227b 100644 --- a/tests/old/testsuite/debug/category.c +++ b/tests/old/testsuite/debug/category.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -25,46 +25,56 @@ GST_DEBUG_CATEGORY (cat); #define GST_CAT_DEFAULT cat GST_DEBUG_CATEGORY_STATIC (cat_static); -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GSList *before, *after; unsetenv ("GST_DEBUG"); gst_init (&argc, &argv); - + before = gst_debug_get_all_categories (); - GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, "default category for this test"); - GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED, - "static category for this test"); + GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, + "default category for this test"); + GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED, + "static category for this test"); after = gst_debug_get_all_categories (); g_print ("removing default log function\n"); g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); - g_print ("checking, if the two new categories are put into the category list correctly...\n"); + g_print + ("checking, if the two new categories are put into the category list correctly...\n"); g_assert (g_slist_length (after) - g_slist_length (before) == 2); /* check the _get stuff */ - g_print ("checking, if the gst_debug_category_get_* stuff works with the categories...\n"); + g_print + ("checking, if the gst_debug_category_get_* stuff works with the categories...\n"); g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0); g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN); - g_assert (strcmp (gst_debug_category_get_description (cat), "default category for this test") == 0); - g_assert (gst_debug_category_get_threshold (cat) == gst_debug_get_default_threshold()); - g_assert (strcmp (gst_debug_category_get_name (cat_static), "cat_static") == 0); + g_assert (strcmp (gst_debug_category_get_description (cat), + "default category for this test") == 0); + g_assert (gst_debug_category_get_threshold (cat) == + gst_debug_get_default_threshold ()); + g_assert (strcmp (gst_debug_category_get_name (cat_static), + "cat_static") == 0); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD); - g_assert (strcmp (gst_debug_category_get_description (cat_static), "static category for this test") == 0); - g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold()); + g_assert (strcmp (gst_debug_category_get_description (cat_static), + "static category for this test") == 0); + g_assert (gst_debug_category_get_threshold (cat_static) == + gst_debug_get_default_threshold ()); /* check if setting levels for names work */ - g_print ("checking if changing threshold for names affects existing categories...\n"); + g_print + ("checking if changing threshold for names affects existing categories...\n"); gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG); - g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); - g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold()); + g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); + g_assert (gst_debug_category_get_threshold (cat_static) == + gst_debug_get_default_threshold ()); gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO); g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO); - + g_print ("everything ok.\n"); return 0; } diff --git a/tests/old/testsuite/debug/commandline.c b/tests/old/testsuite/debug/commandline.c index 57d2173f0..1dfb38e3e 100644 --- a/tests/old/testsuite/debug/commandline.c +++ b/tests/old/testsuite/debug/commandline.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -26,46 +26,49 @@ GST_DEBUG_CATEGORY (cat); GST_DEBUG_CATEGORY_STATIC (cat_static); -static const gchar* lines[] = { +static const gchar *lines[] = { "--gst-debug-disable", "--gst-debug-no-color", "--gst-debug-level=4", "--gst-debug=cat:4,cat_*:3", - "--gst-debug-level=4 --gst-debug=cat_*:5" + "--gst-debug-level=4 --gst-debug=cat_*:5" }; static void -debug_not_reached (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, GstDebugMessage *message, - gpointer thread) +debug_not_reached (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + GstDebugMessage * message, gpointer thread) { g_assert_not_reached (); } -gint -main (gint argc, gchar *argv[]) + +gint +main (gint argc, gchar * argv[]) { if (argc == 1) { /* this is the main run that calls the others */ gint i, runs, exit; gchar *command; - + unsetenv ("GST_DEBUG"); gst_init (&argc, &argv); runs = G_N_ELEMENTS (lines); for (i = 0; i < runs; i++) { command = g_strdup_printf ("%s %s %d", argv[0], lines[i], i); g_print ("running \"%s\"\n", command); - g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit, NULL) == TRUE); + g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit, + NULL) == TRUE); g_assert (exit == 0); g_print ("\"%s\" worked as expected.\n", command); g_free (command); } - + return 0; } else { gst_init (&argc, &argv); if (argc != 2) { - g_print ("something funny happened to the command line arguments, aborting.\n"); + g_print + ("something funny happened to the command line arguments, aborting.\n"); return 1; } gst_debug_remove_log_function (gst_debug_log_default); @@ -78,7 +81,7 @@ main (gint argc, gchar *argv[]) GST_ERROR ("This will not be seen"); return 0; case '1': - return gst_debug_is_colored () ? 1 : 0; + return gst_debug_is_colored ()? 1 : 0; case '2': g_assert (gst_debug_get_default_threshold () == 4); g_assert (gst_debug_category_get_threshold (cat) == 4); @@ -98,5 +101,5 @@ main (gint argc, gchar *argv[]) return -1; } } - g_assert_not_reached (); + g_assert_not_reached (); } diff --git a/tests/old/testsuite/debug/global.c b/tests/old/testsuite/debug/global.c index f878706c9..2a397ab8e 100644 --- a/tests/old/testsuite/debug/global.c +++ b/tests/old/testsuite/debug/global.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -28,33 +28,30 @@ #define ITERATIONS 20 /* stupid logging functions */ -static void gst_debug_log_one (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - gchar * message, - gpointer thread) G_GNUC_NO_INSTRUMENT; -static void gst_debug_log_two (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - gchar * message, - gpointer thread) G_GNUC_NO_INSTRUMENT; - static void -gst_debug_log_one (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, gchar *message, - gpointer thread) +gst_debug_log_one (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, GObject * object, gchar * message, gpointer thread) + G_GNUC_NO_INSTRUMENT; + static void gst_debug_log_two (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, gchar * message, gpointer thread) G_GNUC_NO_INSTRUMENT; + + static void + gst_debug_log_one (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + gchar * message, gpointer thread) { } static void -gst_debug_log_two (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, gchar *message, - gpointer thread) +gst_debug_log_two (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + gchar * message, gpointer thread) { } @@ -69,23 +66,24 @@ thread_main (gpointer threadnum) g_print ("iteration %d of thread %d starting\n", i, num); /* do some stuff with global settings */ gst_debug_set_default_threshold (GST_LEVEL_DEBUG); - gst_debug_add_log_function (gst_debug_log_one, g_thread_self()); + gst_debug_add_log_function (gst_debug_log_one, g_thread_self ()); gst_debug_add_log_function (gst_debug_log_two, NULL); /* reset all the stuff we did */ gst_debug_set_default_threshold (GST_LEVEL_DEFAULT); - g_assert (gst_debug_remove_log_function_by_data (g_thread_self()) == 1); + g_assert (gst_debug_remove_log_function_by_data (g_thread_self ()) == 1); } - + g_print ("Thread %d is done.\n", num); return threadnum; } -gint -main (gint argc, gchar *argv[]) + +gint +main (gint argc, gchar * argv[]) { gint i; GThread *threads[THREAD_COUNT]; - + g_print ("initializing GStreamer\n"); gst_init (&argc, &argv); g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); @@ -93,10 +91,11 @@ main (gint argc, gchar *argv[]) /* some checks for defaults */ g_print ("Doing startup checks\n"); g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT); - + g_print ("creating %d threads\n", THREAD_COUNT); for (i = 0; i < THREAD_COUNT; i++) { - g_assert ((threads[i] = g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL))); + g_assert ((threads[i] = + g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL))); } g_print ("joining %d threads\n", THREAD_COUNT); for (i = 0; i < THREAD_COUNT; i++) { @@ -106,7 +105,8 @@ main (gint argc, gchar *argv[]) /* some checks if everything worked */ g_print ("Doing shutdown checks\n"); g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT); - g_assert (gst_debug_remove_log_function (gst_debug_log_two) == THREAD_COUNT * ITERATIONS); - + g_assert (gst_debug_remove_log_function (gst_debug_log_two) == + THREAD_COUNT * ITERATIONS); + return 0; } diff --git a/tests/old/testsuite/debug/output.c b/tests/old/testsuite/debug/output.c index d0ef4e5b2..50ca66839 100644 --- a/tests/old/testsuite/debug/output.c +++ b/tests/old/testsuite/debug/output.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include GST_DEBUG_CATEGORY_STATIC (cat_default); @@ -28,17 +28,18 @@ static gint count = -1; static GstElement *pipeline; static void -check_message (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, GstDebugMessage *message, - gpointer unused) +check_message (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + GstDebugMessage * message, gpointer unused) { gint temp; - + /* these checks require count to be set right. So the order in the main funtion is actually important. */ /* <0 means no checks */ - if (count < 0) return; - + if (count < 0) + return; + g_print ("expecting \"%s\"...", (gchar *) message); /* level */ temp = (count % 5) + 1; @@ -52,17 +53,19 @@ check_message (GstDebugCategory *category, GstDebugLevel level, const gchar *fil g_print ("[OK]\n"); } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); - - GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0, "default category for this test"); - GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0, "second category for this test"); + + GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0, + "default category for this test"); + GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0, + "second category for this test"); g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); - gst_debug_add_log_function (check_message, NULL); - + gst_debug_add_log_function (check_message, NULL); + count = 0; GST_ERROR ("This is an error."); ++count; @@ -96,18 +99,23 @@ main (gint argc, gchar *argv[]) ++count; GST_LOG_OBJECT (pipeline, "This is a log message with object."); ++count; - GST_CAT_ERROR_OBJECT (cat2, pipeline, "This is an error with category and object."); + GST_CAT_ERROR_OBJECT (cat2, pipeline, + "This is an error with category and object."); ++count; - GST_CAT_WARNING_OBJECT (cat2, pipeline, "This is a warning with category and object."); + GST_CAT_WARNING_OBJECT (cat2, pipeline, + "This is a warning with category and object."); ++count; - GST_CAT_INFO_OBJECT (cat2, pipeline, "This is an info message with category and object."); + GST_CAT_INFO_OBJECT (cat2, pipeline, + "This is an info message with category and object."); ++count; - GST_CAT_DEBUG_OBJECT (cat2, pipeline, "This is a debug message with category and object."); + GST_CAT_DEBUG_OBJECT (cat2, pipeline, + "This is a debug message with category and object."); ++count; - GST_CAT_LOG_OBJECT (cat2, pipeline, "This is a log message with category and object."); + GST_CAT_LOG_OBJECT (cat2, pipeline, + "This is a log message with category and object."); count = -1; - g_assert (gst_debug_remove_log_function (check_message) == 1); - + g_assert (gst_debug_remove_log_function (check_message) == 1); + return 0; } diff --git a/tests/old/testsuite/debug/printf_extension.c b/tests/old/testsuite/debug/printf_extension.c index 883268701..8cdfcccd2 100644 --- a/tests/old/testsuite/debug/printf_extension.c +++ b/tests/old/testsuite/debug/printf_extension.c @@ -15,18 +15,18 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstCaps *caps; GstElement *element; int zero = 0; gst_init (&argc, &argv); - + caps = gst_caps_from_string ("audio/x-raw-int, rate=44100"); element = gst_element_factory_make ("identity", NULL); @@ -36,6 +36,6 @@ main (gint argc, gchar *argv[]) GST_ERROR ("This should print null: %" GST_PTR_FORMAT, NULL); GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, &zero); //GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, (void *)1); - + return 0; } diff --git a/tests/old/testsuite/dynparams/dparamstest.c b/tests/old/testsuite/dynparams/dparamstest.c index db05eb2cd..0a73f4c50 100644 --- a/tests/old/testsuite/dynparams/dparamstest.c +++ b/tests/old/testsuite/dynparams/dparamstest.c @@ -45,7 +45,7 @@ struct _GstDpTest GstPad *sinkpad; GstPad *srcpad; GstDParamManager *dpman; - + gfloat float1; gfloat float2; gboolean bool1; @@ -65,15 +65,15 @@ enum }; -static void gst_dptest_base_init (gpointer g_class); -static void gst_dptest_class_init (GstDpTestClass * klass); -static void gst_dptest_init (GstDpTest * dptest); +static void gst_dptest_base_init (gpointer g_class); +static void gst_dptest_class_init (GstDpTestClass * klass); +static void gst_dptest_init (GstDpTest * dptest); -static void gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, - GParamSpec * pspec); +static void gst_dptest_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); -static GstElementStateReturn gst_dptest_change_state (GstElement *element); -static void gst_dptest_chain (GstPad *pad, GstData *buf); +static GstElementStateReturn gst_dptest_change_state (GstElement * element); +static void gst_dptest_chain (GstPad * pad, GstData * buf); static GstElementClass *parent_class = NULL; @@ -95,7 +95,8 @@ gst_dptest_get_type (void) (GInstanceInitFunc) gst_dptest_init, }; - dptest_type = g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0); + dptest_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0); } return dptest_type; } @@ -103,17 +104,15 @@ gst_dptest_get_type (void) static void gst_dptest_base_init (gpointer g_class) { - static GstElementDetails dptest_details = GST_ELEMENT_DETAILS ( - "DParamTest", - "Filter", - "Test for the GstDParam code", - "Steve Baker " - ); + static GstElementDetails dptest_details = GST_ELEMENT_DETAILS ("DParamTest", + "Filter", + "Test for the GstDParam code", + "Steve Baker "); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_set_details (element_class, &dptest_details); - g_print("got here %d\n",__LINE__); + g_print ("got here %d\n", __LINE__); } static void @@ -123,7 +122,7 @@ gst_dptest_class_init (GstDpTestClass * klass) GstElementClass *gstelement_class; gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass*)klass; + gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); @@ -139,26 +138,24 @@ gst_dptest_init (GstDpTest * dptest) dptest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (dptest), dptest->sinkpad); - gst_pad_set_chain_function(dptest->sinkpad, gst_dptest_chain); + gst_pad_set_chain_function (dptest->sinkpad, gst_dptest_chain); dptest->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (dptest), dptest->srcpad); - dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT(dptest)); + dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT (dptest)); + + gst_dpman_add_required_dparam_direct (dptest->dpman, + g_param_spec_float ("float1", "float1", "float1", + 0.0, 1.0, 0.5, G_PARAM_READWRITE), "float", &(dptest->float1) + ); - gst_dpman_add_required_dparam_direct ( - dptest->dpman, - g_param_spec_float("float1","float1","float1", - 0.0, 1.0, 0.5, G_PARAM_READWRITE), - "float", - &(dptest->float1) - ); - dptest->float1 = 0.0; } static void -gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstDpTest *dptest; @@ -175,39 +172,39 @@ gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, } static GstElementStateReturn -gst_dptest_change_state (GstElement *element) +gst_dptest_change_state (GstElement * element) { GstDpTest *dptest; g_return_val_if_fail (GST_IS_DPTEST (element), GST_STATE_FAILURE); - g_print("changing state\n"); + g_print ("changing state\n"); dptest = GST_DPTEST (element); if (GST_ELEMENT_CLASS (parent_class)->change_state) return GST_ELEMENT_CLASS (parent_class)->change_state (element); - + return GST_STATE_SUCCESS; } -static void -gst_dptest_chain (GstPad *pad, GstData *data) +static void +gst_dptest_chain (GstPad * pad, GstData * data) { GstDpTest *dptest; gint frame_countdown; - dptest = GST_DPTEST(gst_pad_get_parent (pad)); - g_assert(dptest); + dptest = GST_DPTEST (gst_pad_get_parent (pad)); + g_assert (dptest); /* we're using a made up buffer size of 64 and a timestamp of zero */ - frame_countdown = GST_DPMAN_PREPROCESS(dptest->dpman, 64, 0LL); - - while(GST_DPMAN_PROCESS(dptest->dpman, frame_countdown)); - - g_print("dp chain\n"); + frame_countdown = GST_DPMAN_PREPROCESS (dptest->dpman, 64, 0LL); + + while (GST_DPMAN_PROCESS (dptest->dpman, frame_countdown)); + + g_print ("dp chain\n"); } gboolean -gst_dptest_register_elements (GstPlugin *plugin) +gst_dptest_register_elements (GstPlugin * plugin) { return gst_element_register (plugin, "dptest", GST_RANK_NONE, GST_TYPE_DPTEST); @@ -226,7 +223,9 @@ static GstPluginDesc plugin_desc = { GST_ORIGIN }; -int main(int argc,char *argv[]) { +int +main (int argc, char *argv[]) +{ GstElement *src; GstElement *sink; @@ -235,11 +234,11 @@ int main(int argc,char *argv[]) { GstDParamManager *dpman; GstDParam *dp_float1; GValue *dp_float1_value; - - alarm(10); + + alarm (10); gst_init (&argc, &argv); - gst_control_init(&argc,&argv); + gst_control_init (&argc, &argv); _gst_plugin_register_static (&plugin_desc); @@ -262,51 +261,51 @@ int main(int argc,char *argv[]) { gst_bin_add (GST_BIN (pipeline), testelement); gst_bin_add (GST_BIN (pipeline), sink); - g_print("playing pipeline\n"); - - g_object_set (G_OBJECT (src), "num_buffers", 1, NULL); + g_print ("playing pipeline\n"); + + g_object_set (G_OBJECT (src), "num_buffers", 1, NULL); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); /* test that dparam manager is accessable */ - g_print("getting dparam manager\n"); + g_print ("getting dparam manager\n"); dpman = gst_dpman_get_manager (testelement); - gst_dpman_set_mode(dpman, "synchronous"); - - g_assert(dpman); - g_assert(GST_IS_DPMAN (dpman)); - - g_print("creating dparam for float1\n"); - dp_float1 = gst_dparam_new(G_TYPE_FLOAT);; - g_assert(dp_float1); - g_assert(GST_IS_DPARAM (dp_float1)); - - g_print("attach dparam to float1\n"); - g_assert(gst_dpman_attach_dparam (dpman, "float1", dp_float1)); - - dp_float1_value = g_new0(GValue,1); - g_value_init(dp_float1_value, G_TYPE_FLOAT); - - g_value_set_float(dp_float1_value, 0.1); - g_object_set_property(G_OBJECT(dp_float1), "value_float", dp_float1_value); - - g_print("iterate once\n"); + gst_dpman_set_mode (dpman, "synchronous"); + + g_assert (dpman); + g_assert (GST_IS_DPMAN (dpman)); + + g_print ("creating dparam for float1\n"); + dp_float1 = gst_dparam_new (G_TYPE_FLOAT);; + g_assert (dp_float1); + g_assert (GST_IS_DPARAM (dp_float1)); + + g_print ("attach dparam to float1\n"); + g_assert (gst_dpman_attach_dparam (dpman, "float1", dp_float1)); + + dp_float1_value = g_new0 (GValue, 1); + g_value_init (dp_float1_value, G_TYPE_FLOAT); + + g_value_set_float (dp_float1_value, 0.1); + g_object_set_property (G_OBJECT (dp_float1), "value_float", dp_float1_value); + + g_print ("iterate once\n"); gst_bin_iterate (GST_BIN (pipeline)); - g_print("check that value changed\n"); - g_assert(GST_DPTEST(testelement)->float1 == 0.1F); - g_assert(!GST_DPARAM_READY_FOR_UPDATE(dp_float1)); - - g_print("nulling pipeline\n"); + g_print ("check that value changed\n"); + g_assert (GST_DPTEST (testelement)->float1 == 0.1F); + g_assert (!GST_DPARAM_READY_FOR_UPDATE (dp_float1)); + + g_print ("nulling pipeline\n"); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - g_print("playing pipeline\n"); + g_print ("playing pipeline\n"); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - g_print("iterate twice\n"); + g_print ("iterate twice\n"); g_object_set (G_OBJECT (src), "num_buffers", 2, NULL); gst_bin_iterate (GST_BIN (pipeline)); - + return 0; } diff --git a/tests/old/testsuite/elements/fake.c b/tests/old/testsuite/elements/fake.c index dcf3504b7..14406b210 100644 --- a/tests/old/testsuite/elements/fake.c +++ b/tests/old/testsuite/elements/fake.c @@ -19,12 +19,10 @@ element_create (char *name, char *element) GstElement *el = NULL; el = (GstElement *) gst_element_factory_make (element, name); - if (el == NULL) - { + if (el == NULL) { fprintf (stderr, "Could not create element %s (%s) !\n", name, element); return NULL; - } - else + } else return el; } @@ -43,12 +41,15 @@ main (int argc, char *argv[]) pipeline = gst_pipeline_new ("pipeline"); g_print ("Connecting signals to pipeline\n"); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (property_change_callback), NULL); g_print ("Creating elements\n"); - if (!(src = element_create ("src", "fakesrc"))) return 1; + if (!(src = element_create ("src", "fakesrc"))) + return 1; g_object_set (G_OBJECT (src), "sizetype", 2, NULL); - if (!(sink = element_create ("sink", "fakesink"))) return 1; - + if (!(sink = element_create ("sink", "fakesink"))) + return 1; + /* add */ g_print ("Adding elements to bin\n"); gst_bin_add (GST_BIN (pipeline), src); @@ -59,22 +60,21 @@ main (int argc, char *argv[]) gst_element_set_state (pipeline, GST_STATE_PLAYING); /* we expect this to give an error */ - if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) - { - g_warning ("Iterating a bin with unlinked elements should return FALSE !\n"); + if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) { + g_warning + ("Iterating a bin with unlinked elements should return FALSE !\n"); retval = 1; } gst_pad_link (gst_element_get_pad (src, "src"), - gst_element_get_pad (sink, "sink")); + gst_element_get_pad (sink, "sink")); /* set to play */ g_print ("Doing 1 iteration\n"); gst_element_set_state (pipeline, GST_STATE_PLAYING); /* we expect this to work */ - if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) - { + if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) { g_error ("Iterating a bin with linked elements should return TRUE !\n"); retval = 1; } @@ -82,4 +82,3 @@ main (int argc, char *argv[]) g_print ("Done !\n"); return retval; } - diff --git a/tests/old/testsuite/elements/name.c b/tests/old/testsuite/elements/name.c index a9a0fa4ca..ff0d184cf 100644 --- a/tests/old/testsuite/elements/name.c +++ b/tests/old/testsuite/elements/name.c @@ -15,16 +15,14 @@ main (int argc, char *argv[]) /* init */ gst_init (&argc, &argv); - for (i = 0; i < 50; ++i) - { + for (i = 0; i < 50; ++i) { /* create element */ element = gst_element_factory_make ("identity", NULL); g_assert (GST_IS_ELEMENT (element)); g_assert (gst_element_get_name (element) != NULL); - g_print ("Created identity element with name %s\n", - gst_element_get_name (element)); + g_print ("Created identity element with name %s\n", + gst_element_get_name (element)); } g_print ("Done !\n"); return 0; } - diff --git a/tests/old/testsuite/elements/property.c b/tests/old/testsuite/elements/property.c index 2e461dde8..835df3d3e 100644 --- a/tests/old/testsuite/elements/property.c +++ b/tests/old/testsuite/elements/property.c @@ -22,12 +22,10 @@ element_create (char *name, char *element) GstElement *el = NULL; el = (GstElement *) gst_element_factory_make (element, name); - if (el == NULL) - { + if (el == NULL) { fprintf (stderr, "Could not create element %s (%s) !\n", name, element); return NULL; - } - else + } else return el; } @@ -45,54 +43,41 @@ main (int argc, char *argv[]) /* create */ g_print ("Creating element\n"); - if (!(src = element_create ("src", "fakesrc"))) return 1; - + if (!(src = element_create ("src", "fakesrc"))) + return 1; + /* set */ silent_set = TRUE; sizemin_set = 1; name_set = g_strdup_printf ("test"); - gst_element_set (src, - "name", name_set, - "sizemin", sizemin_set, - "silent", silent_set, - NULL); + gst_element_set (src, + "name", name_set, "sizemin", sizemin_set, "silent", silent_set, NULL); /* get */ gst_element_get (src, - "name", &name_get, - "sizemin", &sizemin_get, - "silent", &silent_get, - NULL); + "name", &name_get, "sizemin", &sizemin_get, "silent", &silent_get, NULL); /* compare */ - if (sizemin_set != sizemin_get) - { + if (sizemin_set != sizemin_get) { g_print ("sizemin: set value %d differs from returned value %d\n", - sizemin_set, sizemin_get); + sizemin_set, sizemin_get); retval = 1; - } - else + } else g_print ("name: set right\n"); - if (silent_set != silent_get) - { + if (silent_set != silent_get) { g_print ("silent: set value %s differs from returned value %s\n", - silent_set ? "TRUE" : "FALSE", - silent_get ? "TRUE" : "FALSE"); + silent_set ? "TRUE" : "FALSE", silent_get ? "TRUE" : "FALSE"); retval = 1; - } - else + } else g_print ("silent: set right\n"); - - if (strcmp (name_set, name_get) != 0) - { + + if (strcmp (name_set, name_get) != 0) { g_print ("name: set value %s differs from returned value %s\n", - name_set, name_get); + name_set, name_get); retval = 1; - } - else + } else g_print ("name: set right\n"); return retval; } - diff --git a/tests/old/testsuite/elements/property.h b/tests/old/testsuite/elements/property.h index a1756f1ca..873b2cc27 100644 --- a/tests/old/testsuite/elements/property.h +++ b/tests/old/testsuite/elements/property.h @@ -1,12 +1,13 @@ /* extracted from gst-launch */ static void -property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) +property_change_callback (GObject * object, GstObject * orig, + GParamSpec * pspec) { - GValue value = { 0, }; /* the important thing is that value.type = 0 */ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ gchar *str = 0; if (pspec->flags & G_PARAM_READABLE) { - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_object_get_property (G_OBJECT (orig), pspec->name, &value); /* fix current bug with g_strdup_value_contents not working with gint64 */ if (G_IS_PARAM_SPEC_INT64 (pspec)) @@ -15,9 +16,8 @@ property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) str = g_strdup_value_contents (&value); g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str); g_free (str); - g_value_unset(&value); + g_value_unset (&value); } else { g_warning ("Parameter not readable. What's up with that?"); } } - diff --git a/tests/old/testsuite/elements/tee.c b/tests/old/testsuite/elements/tee.c index 2badd3ea8..9f4a528e6 100644 --- a/tests/old/testsuite/elements/tee.c +++ b/tests/old/testsuite/elements/tee.c @@ -27,12 +27,10 @@ element_create (char *name, char *element) GstElement *el = NULL; el = (GstElement *) gst_element_factory_make (element, name); - if (el == NULL) - { + if (el == NULL) { fprintf (stderr, "Could not create element %s (%s) !\n", name, element); return NULL; - } - else + } else return el; } @@ -42,6 +40,7 @@ main (int argc, char *argv[]) GstElement *pipeline = NULL; GstElement *tee, *src, *sink1, *sink2; GstPad *tee_src1, *tee_src2; + #if 0 GstCaps *src_caps = NULL; GstCaps *sink_caps = NULL; @@ -57,15 +56,20 @@ main (int argc, char *argv[]) pipeline = gst_pipeline_new ("pipeline"); g_print ("Connecting signals to pipeline\n"); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); - + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (property_change_callback), NULL); + g_print ("Creating elements\n"); - if (!(tee = element_create ("tee", "tee"))) return 1; - if (!(src = element_create ("src", "fakesrc"))) return 1; + if (!(tee = element_create ("tee", "tee"))) + return 1; + if (!(src = element_create ("src", "fakesrc"))) + return 1; g_object_set (G_OBJECT (src), "sizetype", 2, NULL); - if (!(sink1 = element_create ("sink1", "fakesink"))) return 1; - if (!(sink2 = element_create ("sink2", "fakesink"))) return 1; - + if (!(sink1 = element_create ("sink1", "fakesink"))) + return 1; + if (!(sink2 = element_create ("sink2", "fakesink"))) + return 1; + /* add */ g_print ("Adding elements to bin\n"); gst_bin_add (GST_BIN (pipeline), src); @@ -74,8 +78,8 @@ main (int argc, char *argv[]) /* link input part */ g_print ("Linking input elements\n"); gst_pad_link (gst_element_get_pad (src, "src"), - gst_element_get_pad (tee, "sink")); - + gst_element_get_pad (tee, "sink")); + /* request one pad from tee */ g_print ("Requesting first pad\n"); tee_src1 = gst_element_get_request_pad (tee, "src%d"); @@ -93,7 +97,7 @@ main (int argc, char *argv[]) tee_src2 = gst_element_get_request_pad (tee, "src%d"); gst_bin_add (GST_BIN (pipeline), sink2); gst_pad_link (tee_src2, gst_element_get_pad (sink2, "sink")); - + /* now we have two fakesinks linked, iterate */ g_print ("Doing 1 iteration\n"); gst_element_set_state (pipeline, GST_STATE_PLAYING); @@ -118,30 +122,32 @@ main (int argc, char *argv[]) sink_caps = gst_pad_get_caps (gst_element_get_pad (sink1, "sink")); if (sink_caps && gst_caps_is_fixed (sink_caps)) { structure = gst_caps_get_structure (sink_caps, 0); - }else { + } else { structure = NULL; g_print ("sink_caps is not fixed\n"); } if (structure == NULL || !(gst_structure_has_field (structure, "rate"))) { - g_print ("Hm, rate has not been propagated to sink1.\n"); + g_print ("Hm, rate has not been propagated to sink1.\n"); return 1; } else { int rate; + gst_structure_get_int (structure, "rate", &rate); g_print ("Rate of pad on sink1 : %d\n", rate); } sink_caps = gst_pad_get_caps (gst_element_get_pad (sink2, "sink")); structure = gst_caps_get_structure (sink_caps, 0); - if (structure != NULL && ! (gst_structure_has_field (structure, "rate"))) { - g_print ("Hm, rate has not been propagated to sink2.\n"); + if (structure != NULL && !(gst_structure_has_field (structure, "rate"))) { + g_print ("Hm, rate has not been propagated to sink2.\n"); return 1; } else { int rate; + gst_structure_get_int (structure, "rate", &rate); g_print ("Rate of pad on sink2 : %d\n", rate); } #endif - + /* remove the first one, iterate */ g_print ("Removing first sink\n"); gst_element_set_state (pipeline, GST_STATE_PAUSED); @@ -158,7 +164,7 @@ main (int argc, char *argv[]) gst_element_set_state (pipeline, GST_STATE_PAUSED); /* in 0.3.2 the next statement gives an assert error */ tee_src1 = gst_element_get_request_pad (tee, "src%d"); - + gst_element_set_state (pipeline, GST_STATE_NULL); g_print ("Done !\n"); diff --git a/tests/old/testsuite/ghostpads/ghostpads.c b/tests/old/testsuite/ghostpads/ghostpads.c index 4050326df..7d87782c6 100644 --- a/tests/old/testsuite/ghostpads/ghostpads.c +++ b/tests/old/testsuite/ghostpads/ghostpads.c @@ -20,11 +20,11 @@ #include gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline, *bin; GstElement *fakesrc, *fakesink, *identity; - GstPad *sink, *src, *real = (GstPad*)0xdeadbeef; + GstPad *sink, *src, *real = (GstPad *) 0xdeadbeef; gst_init (&argc, &argv); @@ -33,32 +33,30 @@ main (gint argc, gchar *argv[]) fakesrc = gst_element_factory_make ("fakesrc", NULL); fakesink = gst_element_factory_make ("fakesink", NULL); identity = gst_element_factory_make ("identity", NULL); - + gst_bin_add_many (GST_BIN (pipeline), fakesrc, bin, fakesink, NULL); gst_bin_add (GST_BIN (bin), identity); - + sink = gst_element_add_ghost_pad (bin, - gst_element_get_pad (identity, "sink"), - "sink"); + gst_element_get_pad (identity, "sink"), "sink"); src = gst_element_add_ghost_pad (bin, - gst_element_get_pad (identity, "src"), - "src"); + gst_element_get_pad (identity, "src"), "src"); gst_element_link_many (fakesrc, bin, fakesink, NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); - + if (!gst_bin_iterate (GST_BIN (pipeline))) g_assert_not_reached (); - + gst_element_set_state (pipeline, GST_STATE_NULL); /* test the cleanup */ gst_object_ref (GST_OBJECT (sink)); - gst_object_unref ((GstObject*)pipeline); + gst_object_unref ((GstObject *) pipeline); g_object_get (sink, "real-pad", &real, NULL); g_assert (real == NULL); g_assert (G_OBJECT (sink)->ref_count == 1); gst_object_unref (GST_OBJECT (sink)); - + return 0; } diff --git a/tests/old/testsuite/indexers/cache1.c b/tests/old/testsuite/indexers/cache1.c index 0392a196c..ed2bb4d1d 100644 --- a/tests/old/testsuite/indexers/cache1.c +++ b/tests/old/testsuite/indexers/cache1.c @@ -20,70 +20,71 @@ #include static void -lookup (GstIndex *index, GstIndexLookupMethod method, - GstFormat src_format, gint64 src_value, - GstFormat dest_format, gint64 expecting) +lookup (GstIndex * index, GstIndexLookupMethod method, + GstFormat src_format, gint64 src_value, + GstFormat dest_format, gint64 expecting) { GstIndexEntry *entry; gint64 result; entry = gst_index_get_assoc_entry (index, 0, method, 0, - src_format, src_value); + src_format, src_value); if (entry) { - gst_index_entry_assoc_map (entry, dest_format, &result); + gst_index_entry_assoc_map (entry, dest_format, &result); if (result == expecting) { g_print ("OK (%lld)\n", result); } else { g_print ("FAIL - expecting %lld, got %lld\n", expecting, result); } - } - else { + } else { const GstFormatDefinition *def = gst_format_get_details (src_format); - - if (expecting == -1) + + if (expecting == -1) g_print ("OK (not found)\n"); else g_print ("FAIL - no index entry found for %lld %s, expecting %lld\n", - src_value, def->nick, expecting); + src_value, def->nick, expecting); } } typedef struct _GstIndexTestCase { - GstIndexLookupMethod method; - GstFormat src_format; - gint64 src_value; - GstFormat dest_format; - gint64 expecting; + GstIndexLookupMethod method; + GstFormat src_format; + gint64 src_value; + GstFormat dest_format; + gint64 expecting; } GstIndexTestCase; -const static GstIndexTestCase cases[] = -{ - { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000 }, - { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5 }, - { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, 99999 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 }, +const static GstIndexTestCase cases[] = { + {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000}, + {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5}, + {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, + 99999}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1}, }; -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstIndex *index; GstElement *element; gint i, id; - + gst_init (&argc, &argv); - if (argc != 2) - { g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); } + if (argc != 2) { + g_print ("usage: cache1 (memindex | fileindex)\n"); + exit (0); + } index = gst_index_factory_make (argv[1]); g_assert (index != NULL); @@ -96,15 +97,16 @@ main (gint argc, gchar *argv[]) g_print ("Building index...\n"); for (i = 0; i < 100000; i++) { - gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME, - (gint64) (i * 1000), 0); + gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64) i, + GST_FORMAT_TIME, (gint64) (i * 1000), 0); } g_print ("Testing index...\n"); for (i = 0; i < (sizeof (cases) / sizeof (GstIndexTestCase)); i++) { - lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format, cases[i].expecting); + lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, + cases[i].dest_format, cases[i].expecting); } - + return 0; } diff --git a/tests/old/testsuite/indexers/indexdump.c b/tests/old/testsuite/indexers/indexdump.c index e528e4afe..d2f168a8f 100644 --- a/tests/old/testsuite/indexers/indexdump.c +++ b/tests/old/testsuite/indexers/indexdump.c @@ -20,18 +20,20 @@ #include static void -my_resolver (GstIndex *index, GstObject *_ign, gchar **writer_string, - gpointer user_data) -{ *writer_string = user_data; } +my_resolver (GstIndex * index, GstObject * _ign, gchar ** writer_string, + gpointer user_data) +{ + *writer_string = user_data; +} -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstIndex *index; GstObject *identity; gint id; gint64 cur; - + gst_init (&argc, &argv); if (argc != 3) { @@ -45,29 +47,30 @@ main (gint argc, gchar *argv[]) g_object_set (index, "location", argv[1], NULL); gst_index_set_resolver (index, (GstIndexResolver) my_resolver, argv[2]); - identity = (GstObject*) gst_element_factory_make ("identity", "element"); + identity = (GstObject *) gst_element_factory_make ("identity", "element"); g_assert (identity); gst_index_get_writer_id (index, identity, &id); - + cur = 0; while (1) { gint fx; GstIndexEntry *entry = - gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0, - GST_FORMAT_TIME, cur); + gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0, + GST_FORMAT_TIME, cur); + if (!entry) break; g_print ("%x", GST_INDEX_ASSOC_FLAGS (entry)); - for (fx=0; fx < GST_INDEX_NASSOCS (entry); fx++) { + for (fx = 0; fx < GST_INDEX_NASSOCS (entry); fx++) { GstFormat fmt = GST_INDEX_ASSOC_FORMAT (entry, fx); - const GstFormatDefinition* def = gst_format_get_details (fmt); + const GstFormatDefinition *def = gst_format_get_details (fmt); + if (fmt == GST_FORMAT_TIME) { cur = GST_INDEX_ASSOC_VALUE (entry, fx) + 1; g_print (" time %.4f", - GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND); - } - else + GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND); + } else g_print (" %s %lld", def->nick, GST_INDEX_ASSOC_VALUE (entry, fx)); } g_print ("\n"); diff --git a/tests/old/testsuite/parse/parse1.c b/tests/old/testsuite/parse/parse1.c index debf5ff0d..8bfc50bac 100644 --- a/tests/old/testsuite/parse/parse1.c +++ b/tests/old/testsuite/parse/parse1.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -57,7 +57,7 @@ static gchar *s; gst_object_unref (GST_OBJECT (cur)); \ cur = NULL; \ g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \ -}G_STMT_END +}G_STMT_END #define TEST_RUN G_STMT_START{ \ alarm(10); \ g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \ @@ -73,7 +73,7 @@ static gchar *s; } \ g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \ alarm(0); \ -}G_STMT_END +}G_STMT_END #define PIPELINE1 "fakesrc" #define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos = yesyo data= Subbuffer\\ data" #define PIPELINE3 "fakesrc identity fakesink" @@ -87,8 +87,8 @@ static gchar *s; #define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink." -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); @@ -108,7 +108,8 @@ main (gint argc, gchar *argv[]) * - first test of escaping strings */ TEST_START (PIPELINE2); - g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, NULL); + g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, + NULL); TEST_CHECK_FAIL (strcmp (s, "donald") == 0); TEST_CHECK_FAIL (i == 27); TEST_CHECK_FAIL (b == TRUE); @@ -125,7 +126,7 @@ main (gint argc, gchar *argv[]) * - if multiple toplevel elements exist, a pipeline is returned */ TEST_START (PIPELINE3); - TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */ + TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */ TEST_CHECK_FAIL (GST_IS_PIPELINE (cur)); TEST_OK; @@ -161,7 +162,7 @@ main (gint argc, gchar *argv[]) TEST_CHECK_FAIL (strcmp (s, "john") == 0); TEST_RUN; TEST_OK; - + /** * checks: * - test request pads @@ -169,7 +170,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE7); TEST_RUN; TEST_OK; - + /** * checks: * - multiple pads on 1 link @@ -177,7 +178,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE8); TEST_RUN; TEST_OK; - + /** * checks: * - failed in grammar.y cvs version 1.17 @@ -185,7 +186,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE9); TEST_RUN; TEST_OK; - + /** * checks: * - failed in grammar.y cvs version 1.17 @@ -193,7 +194,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE10); TEST_RUN; TEST_OK; - + /** * checks: * - failed in grammar.y cvs version 1.18 diff --git a/tests/old/testsuite/parse/parse2.c b/tests/old/testsuite/parse/parse2.c index 647b3bc78..db8184f49 100644 --- a/tests/old/testsuite/parse/parse2.c +++ b/tests/old/testsuite/parse/parse2.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -88,7 +88,7 @@ static char *video_file = NULL; gst_object_unref (GST_OBJECT (cur)); \ cur = NULL; \ g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \ -}G_STMT_END +}G_STMT_END #define TEST_RUN(iters) G_STMT_START{ \ gint it = iters; \ g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \ @@ -106,7 +106,7 @@ static char *video_file = NULL; return -test; \ } \ g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \ -}G_STMT_END +}G_STMT_END #define TEST_FINISH G_STMT_START{ \ g_print("\n"); \ g_print("To run this test there are things required that you do not have. (see above)\n"); \ @@ -114,7 +114,7 @@ static char *video_file = NULL; g_print("Currently the following tests will be ignored.\n"); \ g_print("\n"); \ exit (0); \ -}G_STMT_END +}G_STMT_END #define TEST_REQUIRE(condition, error) G_STMT_START{ \ if (condition) { \ g_print ("REQUIRE line %3d OK\n", __LINE__); \ @@ -122,7 +122,7 @@ static char *video_file = NULL; g_print ("REQUIRE line %3d EXIT : %s\n", __LINE__, (error)); \ TEST_FINISH; \ } \ -}G_STMT_END +}G_STMT_END #define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \ GstElement *element = gst_element_factory_make ((element_name), NULL); \ if (element) { \ @@ -132,7 +132,7 @@ static char *video_file = NULL; g_print ("REQUIRE line %3d EXIT : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \ TEST_FINISH; \ } \ -}G_STMT_END +}G_STMT_END #define PIPELINE1 "filesrc blocksize =8192 location=%s ! mad ! osssink" #define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvideosink" @@ -144,12 +144,12 @@ static char *video_file = NULL; #define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_%%02d ! mad ! osssink" */ -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); -goto here; + goto here; here: /** @@ -158,7 +158,8 @@ here: * - unsigned parameters */ audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL); - TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mp3 file music.mp3 in your home directory."); + TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), + "The following tests requires a valid mp3 file music.mp3 in your home directory."); TEST_REQUIRE_ELEMENT ("mad"); TEST_REQUIRE_ELEMENT ("osssink"); TEST_START (PIPELINE1, audio_file); @@ -171,7 +172,8 @@ here: * - SOMETIMES pads */ video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL); - TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mpeg file video.mpeg in your home directory."); + TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), + "The following tests requires a valid mpeg file video.mpeg in your home directory."); TEST_REQUIRE_ELEMENT ("mpegdemux"); TEST_REQUIRE_ELEMENT ("mpeg2dec"); TEST_REQUIRE_ELEMENT ("xvideosink"); diff --git a/tests/old/testsuite/plugin/dynamic.c b/tests/old/testsuite/plugin/dynamic.c index 07c376d6b..2c6c19208 100644 --- a/tests/old/testsuite/plugin/dynamic.c +++ b/tests/old/testsuite/plugin/dynamic.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,14 +11,13 @@ main (int argc, char *argv[]) plugin = gst_plugin_load_file (".libs/libtestplugin.so", &error); g_assert (plugin != NULL); - if (error) - { + if (error) { g_print ("ERROR loading plug-in: %s\n", error->message); g_free (error); return 1; } - g_print ("testplugin: %s\n", gst_plugin_get_name(plugin)); + g_print ("testplugin: %s\n", gst_plugin_get_name (plugin)); return 0; } diff --git a/tests/old/testsuite/plugin/linked.c b/tests/old/testsuite/plugin/linked.c index 24e7d9ebc..368d3415c 100644 --- a/tests/old/testsuite/plugin/linked.c +++ b/tests/old/testsuite/plugin/linked.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,12 +11,12 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin)); plugin = gst_registry_pool_find_plugin ("testplugin2"); g_assert (plugin != NULL); - g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin)); return 0; } diff --git a/tests/old/testsuite/plugin/loading.c b/tests/old/testsuite/plugin/loading.c index 0ed5a9cef..11d34a298 100644 --- a/tests/old/testsuite/plugin/loading.c +++ b/tests/old/testsuite/plugin/loading.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -17,12 +17,14 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin))); + g_print ("%d features in plugin\n", + g_list_length (gst_plugin_get_feature_list (plugin))); - g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false")); - - loaded = gst_plugin_load (gst_plugin_get_name(plugin)); + g_print ("testplugin: %p loaded: %s\n", plugin, + (gst_plugin_is_loaded (plugin) ? "true" : "false")); + + loaded = gst_plugin_load (gst_plugin_get_name (plugin)); g_assert (loaded == TRUE); numplugins = g_list_length (gst_registry_pool_plugin_list ()); @@ -32,23 +34,27 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false")); + g_print ("testplugin: %p loaded: %s\n", plugin, + (gst_plugin_is_loaded (plugin) ? "true" : "false")); - g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin))); + g_print ("%d features in plugin\n", + g_list_length (gst_plugin_get_feature_list (plugin))); - loaded = gst_plugin_load (gst_plugin_get_name(plugin)); + loaded = gst_plugin_load (gst_plugin_get_name (plugin)); g_assert (loaded == TRUE); numplugins = g_list_length (gst_registry_pool_plugin_list ()); g_print ("%d plugins loaded\n", numplugins); - g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin))); + g_print ("%d features in plugin\n", + g_list_length (gst_plugin_get_feature_list (plugin))); g_mem_chunk_info (); plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false")); + g_print ("testplugin: %p loaded: %s\n", plugin, + (gst_plugin_is_loaded (plugin) ? "true" : "false")); return 0; } diff --git a/tests/old/testsuite/plugin/registry.c b/tests/old/testsuite/plugin/registry.c index 95fb56a7c..85a76e2f8 100644 --- a/tests/old/testsuite/plugin/registry.c +++ b/tests/old/testsuite/plugin/registry.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,7 +11,7 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %s\n", gst_plugin_get_name(plugin)); + g_print ("testplugin: %s\n", gst_plugin_get_name (plugin)); return 0; } diff --git a/tests/old/testsuite/plugin/static.c b/tests/old/testsuite/plugin/static.c index 9aab9d1af..368d3415c 100644 --- a/tests/old/testsuite/plugin/static.c +++ b/tests/old/testsuite/plugin/static.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,13 +11,12 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin)); plugin = gst_registry_pool_find_plugin ("testplugin2"); g_assert (plugin != NULL); - g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin)); return 0; } - diff --git a/tests/old/testsuite/plugin/static2.c b/tests/old/testsuite/plugin/static2.c index a19551b4a..1ab30d0f3 100644 --- a/tests/old/testsuite/plugin/static2.c +++ b/tests/old/testsuite/plugin/static2.c @@ -5,42 +5,30 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE_STATIC ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin", - "a plugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin", + "a plugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); static gboolean -plugin2_init (GstPlugin *plugin) +plugin2_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE_STATIC ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin2", - "a second plugin for testing", - plugin2_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); - -int +GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin2", + "a second plugin for testing", + plugin2_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); + +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -50,12 +38,12 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin)); plugin = gst_registry_pool_find_plugin ("testplugin2"); g_assert (plugin != NULL); - g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin)); return 0; } diff --git a/tests/old/testsuite/plugin/testplugin.c b/tests/old/testsuite/plugin/testplugin.c index 24e861405..d2ee604b9 100644 --- a/tests/old/testsuite/plugin/testplugin.c +++ b/tests/old/testsuite/plugin/testplugin.c @@ -6,19 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin", - "a plugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin", + "a plugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); diff --git a/tests/old/testsuite/plugin/testplugin2.c b/tests/old/testsuite/plugin/testplugin2.c index 69c71d8e1..47d2ad37d 100644 --- a/tests/old/testsuite/plugin/testplugin2.c +++ b/tests/old/testsuite/plugin/testplugin2.c @@ -6,20 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin2", - "another testplugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin2", + "another testplugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); diff --git a/tests/old/testsuite/plugin/testplugin2_s.c b/tests/old/testsuite/plugin/testplugin2_s.c index 154c2768e..00c47d8f8 100644 --- a/tests/old/testsuite/plugin/testplugin2_s.c +++ b/tests/old/testsuite/plugin/testplugin2_s.c @@ -6,21 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE_STATIC ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin2", - "another testplugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_COPYRIGHT, - GST_PACKAGE, - GST_ORIGIN -); - +GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin2", + "another testplugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN); diff --git a/tests/old/testsuite/plugin/testplugin_s.c b/tests/old/testsuite/plugin/testplugin_s.c index e834c8eed..b17605d5b 100644 --- a/tests/old/testsuite/plugin/testplugin_s.c +++ b/tests/old/testsuite/plugin/testplugin_s.c @@ -6,20 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin", - "a plugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_COPYRIGHT, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin", + "a plugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN); diff --git a/tests/old/testsuite/refcounting/bin.c b/tests/old/testsuite/refcounting/bin.c index 81c867180..df5d76aef 100644 --- a/tests/old/testsuite/refcounting/bin.c +++ b/tests/old/testsuite/refcounting/bin.c @@ -3,7 +3,7 @@ #define ITERS 100 #include -static GstElement* +static GstElement * create_bin (void) { GstElement *bin; @@ -20,7 +20,7 @@ create_bin (void) return bin; } -static GstElement* +static GstElement * create_bin_ghostpads (void) { GstElement *bin; @@ -32,7 +32,8 @@ create_bin_ghostpads (void) element2 = gst_element_factory_make ("fakesink", NULL); gst_bin_add (GST_BIN (bin), element2); gst_element_link_pads (element1, "src", element2, "sink"); - gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"), "ghost_sink"); + gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"), + "ghost_sink"); return bin; } @@ -132,7 +133,7 @@ add_remove_test4 (void) #endif int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstElement *bin; int usage1; @@ -155,13 +156,14 @@ main (int argc, gchar *argv[]) bin = gst_bin_new ("somebin"); gst_object_unref (GST_OBJECT (bin)); - g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1); + g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all () - usage1); - for (i=0; i int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstElement *element; int usage1; @@ -24,13 +24,15 @@ main (int argc, gchar *argv[]) element = gst_element_factory_make ("fakesrc", NULL); gst_object_unref (GST_OBJECT (element)); - g_print ("create/unref new element %d\n", gst_alloc_trace_live_all ()-usage1); + g_print ("create/unref new element %d\n", + gst_alloc_trace_live_all () - usage1); - for (i=0; i #include -int vmsize() { - int pid,fd,size,i,mem; +int +vmsize () +{ + int pid, fd, size, i, mem; char filename[17], buf[256], *ptr, *end; - pid = getpid(); - snprintf(filename,17,"/proc/%d/stat",pid); - fd = open(filename,O_RDONLY); - size = read(fd,buf,240); + pid = getpid (); + snprintf (filename, 17, "/proc/%d/stat", pid); + fd = open (filename, O_RDONLY); + size = read (fd, buf, 240); ptr = buf; - for (i=0;i<22;i++) - ptr = (char *)strchr(ptr,' ') + 1; - end = (char *)strchr(ptr,' '); + for (i = 0; i < 22; i++) + ptr = (char *) strchr (ptr, ' ') + 1; + end = (char *) strchr (ptr, ' '); *end = 0; - sscanf(ptr,"%d",&mem); - close(fd); + sscanf (ptr, "%d", &mem); + close (fd); return mem; } diff --git a/tests/old/testsuite/refcounting/mem.h b/tests/old/testsuite/refcounting/mem.h index 28999db2c..c019611d3 100644 --- a/tests/old/testsuite/refcounting/mem.h +++ b/tests/old/testsuite/refcounting/mem.h @@ -1 +1 @@ -int vmsize(); +int vmsize (); diff --git a/tests/old/testsuite/refcounting/object.c b/tests/old/testsuite/refcounting/object.c index 82ab7f4a6..5646f71ef 100644 --- a/tests/old/testsuite/refcounting/object.c +++ b/tests/old/testsuite/refcounting/object.c @@ -5,7 +5,7 @@ #include "mem.h" int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstObject *object, *object2; long usage1; @@ -19,17 +19,17 @@ main (int argc, gchar *argv[]) iters = ITERS; g_print ("starting test with %d iterations\n", iters); - usage1 = vmsize(); + usage1 = vmsize (); object = gst_object_new (); gst_object_unref (object); - g_print ("create/unref new object %ld\n", vmsize()-usage1); + g_print ("create/unref new object %ld\n", vmsize () - usage1); - for (i=0; i #include "mem.h" -static GstElement* +static GstElement * create_thread (void) { GstElement *thread; @@ -21,7 +21,7 @@ create_thread (void) return thread; } -static GstElement* +static GstElement * create_thread_ghostpads (void) { GstElement *thread; @@ -37,7 +37,8 @@ create_thread_ghostpads (void) gst_element_add_pad (element2, gst_pad_new ("sink1", GST_PAD_SINK)); gst_bin_add (GST_BIN (thread), element2); gst_element_link (element1, "src1", element2, "sink1"); - gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), "sink1"); + gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), + "sink1"); return thread; } @@ -129,7 +130,7 @@ add_remove_test4 (void) } int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstElement *thread, *element; long usage1; @@ -143,17 +144,17 @@ main (int argc, gchar *argv[]) iters = ITERS; g_print ("starting test\n"); - usage1 = vmsize(); + usage1 = vmsize (); thread = gst_thread_new ("somethread"); gst_object_unref (GST_OBJECT (thread)); - g_print ("create/unref new thread %ld\n", vmsize()-usage1); + g_print ("create/unref new thread %ld\n", vmsize () - usage1); - for (i=0; i gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; - GstElement *fakesrc1, *fakesink1; - GstElement *fakesrc2, *fakesink2; + GstElement *fakesrc1, *fakesink1; + GstElement *fakesrc2, *fakesink2; gst_init (&argc, &argv); pipeline = gst_pipeline_new ("pipeline"); - + fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1"); g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL); fakesink1 = gst_element_factory_make ("fakesink", "fakesink1"); - + gst_bin_add_many (GST_BIN (pipeline), fakesrc1, fakesink1, NULL); gst_element_link_pads (fakesrc1, "src", fakesink1, "sink"); @@ -44,7 +44,8 @@ main (gint argc, gchar *argv[]) gst_bin_add_many (GST_BIN (pipeline), fakesrc2, fakesink2, NULL); gst_element_link_pads (fakesrc2, "src", fakesink2, "sink"); - g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (G_OBJECT (pipeline), "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE); GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE); @@ -63,6 +64,6 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (pipeline)); - + return 0; } diff --git a/tests/old/testsuite/tags/merge.c b/tests/old/testsuite/tags/merge.c index 0a806a62b..8b243afb1 100644 --- a/tests/old/testsuite/tags/merge.c +++ b/tests/old/testsuite/tags/merge.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -39,7 +39,7 @@ /* checks that a tag contains the given values and not more values */ static void -check (const GstTagList *list, const gchar *tag, gchar *value, ...) +check (const GstTagList * list, const gchar * tag, gchar * value, ...) { va_list args; gchar *str; @@ -50,13 +50,14 @@ check (const GstTagList *list, const gchar *tag, gchar *value, ...) g_assert (gst_tag_list_get_string_index (list, tag, i, &str)); g_assert (strcmp (value, str) == 0); g_free (str); - + value = va_arg (args, gchar *); i++; } g_assert (i == gst_tag_list_get_tag_size (list, tag)); va_end (args); } + #define NEW_LIST_FIXED(mode) G_STMT_START{ \ if (list) gst_tag_list_free (list);\ list = gst_tag_list_new (); \ @@ -87,11 +88,11 @@ check (const GstTagList *list, const gchar *tag, gchar *value, ...) if (merge) gst_tag_list_free (merge);\ merge = gst_tag_list_merge (list, list2, mode); \ }G_STMT_END -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstTagList *list = NULL, *list2 = NULL, *merge = NULL; - + gst_init (&argc, &argv); /* make sure the assumptions work */ @@ -100,7 +101,7 @@ main (gint argc, gchar *argv[]) /* we check string here only */ g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING); g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING); - + /* check additions */ /* unfixed */ NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL); @@ -128,9 +129,9 @@ main (gint argc, gchar *argv[]) check (list, FTAG, FIXED1, NULL); NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL); check (list, FTAG, NULL); - + /* check merging */ - /* unfixed */ + /* unfixed */ NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL); check (merge, UTAG, UNFIXED3, UNFIXED4, NULL); NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE); @@ -143,7 +144,7 @@ main (gint argc, gchar *argv[]) check (merge, UTAG, UNFIXED1, UNFIXED2, NULL); NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL); check (merge, UTAG, UNFIXED1, UNFIXED2, NULL); - /* fixed */ + /* fixed */ NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL); check (merge, FTAG, FIXED3, NULL); NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE); @@ -156,6 +157,6 @@ main (gint argc, gchar *argv[]) check (merge, FTAG, FIXED1, NULL); NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL); check (merge, FTAG, FIXED1, NULL); - + return 0; } diff --git a/tests/old/testsuite/test_gst_init.c b/tests/old/testsuite/test_gst_init.c index 174932850..3331c3def 100644 --- a/tests/old/testsuite/test_gst_init.c +++ b/tests/old/testsuite/test_gst_init.c @@ -6,8 +6,8 @@ int main (int argc, char *argv[]) { - gst_init(NULL, NULL); - gst_init(&argc, &argv); + gst_init (NULL, NULL); + gst_init (&argc, &argv); return 0; } diff --git a/tests/old/testsuite/threads/queue.c b/tests/old/testsuite/threads/queue.c index 191ae43f0..b95911a55 100644 --- a/tests/old/testsuite/threads/queue.c +++ b/tests/old/testsuite/threads/queue.c @@ -12,20 +12,20 @@ static gint handoff_count = 0; /* handoff callback */ static void -handoff (GstElement *element, gpointer data) +handoff (GstElement * element, gpointer data) { ++handoff_count; g_print ("handoff (%d) ", handoff_count); } static void -construct_pipeline (GstElement *pipeline, GstElement *thread) +construct_pipeline (GstElement * pipeline, GstElement * thread) { GstElement *src, *sink, *queue; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", "sink"); - queue = gst_element_factory_make ("queue", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", "sink"); + queue = gst_element_factory_make ("queue", NULL); gst_bin_add_many (GST_BIN (thread), queue, sink, NULL); gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL); @@ -39,17 +39,17 @@ construct_pipeline (GstElement *pipeline, GstElement *thread) } void -change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline) +change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline) { gst_element_set_state (pipeline, GST_STATE_NULL); } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *thread = NULL; - + gst_init (&argc, &argv); pipeline = gst_thread_new ("main_pipeline"); @@ -64,15 +64,15 @@ main (gint argc, gchar *argv[]) g_print ("Pipeline done. Resetting to NULL.\n"); gst_element_set_state (pipeline, GST_STATE_NULL); - if (handoff_count == 0) - { + if (handoff_count == 0) { g_print ("ERROR: no buffers have passed\n"); return -1; } handoff_count = 0; - g_print ("Second run: setting consumer thread to playing, then complete pipeline\n"); + g_print + ("Second run: setting consumer thread to playing, then complete pipeline\n"); gst_element_set_state (thread, GST_STATE_PLAYING); g_print ("SLEEPING 1 sec\n"); sleep (1); @@ -80,11 +80,10 @@ main (gint argc, gchar *argv[]) g_print ("SLEEPING 2 sec\n"); sleep (2); - if (handoff_count == 0) - { + if (handoff_count == 0) { g_print ("ERROR: no buffers have passed\n"); return -1; } - + return 0; } diff --git a/tests/old/testsuite/threads/thread.c b/tests/old/testsuite/threads/thread.c index 2054986f2..cc01d9134 100644 --- a/tests/old/testsuite/threads/thread.c +++ b/tests/old/testsuite/threads/thread.c @@ -10,24 +10,24 @@ void usage (void) { g_print ("compile this test with TESTNUM defined.\n" - " available TESTNUMs: \n" - " 1: stress test state change \n" - " 2: iterate once \n" - " 3: iterate twice \n" - " 4: state change while running \n" - " 5: state change in thread context\n"); + " available TESTNUMs: \n" + " 1: stress test state change \n" + " 2: iterate once \n" + " 3: iterate twice \n" + " 4: state change while running \n" + " 5: state change in thread context\n"); } static void -construct_pipeline (GstElement *pipeline) +construct_pipeline (GstElement * pipeline) { GstElement *src, *sink, *queue, *identity, *thread; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", "sink"); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", "sink"); identity = gst_element_factory_make ("identity", NULL); - queue = gst_element_factory_make ("queue", NULL); - thread = gst_element_factory_make ("thread", NULL); + queue = gst_element_factory_make ("queue", NULL); + thread = gst_element_factory_make ("thread", NULL); gst_element_link_many (src, queue, identity, sink, NULL); @@ -39,16 +39,16 @@ construct_pipeline (GstElement *pipeline) } void -change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline) +change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline) { gst_element_set_state (pipeline, GST_STATE_NULL); } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; - + gst_init (&argc, &argv); #ifndef TESTNUM @@ -112,13 +112,13 @@ main (gint argc, gchar *argv[]) sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); g_assert (sink); - g_signal_connect (G_OBJECT (sink), "handoff", - G_CALLBACK (change_state), pipeline); + g_signal_connect (G_OBJECT (sink), "handoff", + G_CALLBACK (change_state), pipeline); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_print ("running ...\n"); while (gst_bin_iterate (GST_BIN (pipeline))); gst_element_set_state (pipeline, GST_STATE_NULL); } - + return 0; } diff --git a/tests/old/testsuite/threads/threadb.c b/tests/old/testsuite/threads/threadb.c index 9a05af47a..ded7d9c79 100644 --- a/tests/old/testsuite/threads/threadb.c +++ b/tests/old/testsuite/threads/threadb.c @@ -10,13 +10,13 @@ gboolean running = FALSE; static void -construct_pipeline (GstElement *pipeline) +construct_pipeline (GstElement * pipeline) { GstElement *src, *sink, *identity; - src = gst_element_factory_make ("fakesrc", NULL); + src = gst_element_factory_make ("fakesrc", NULL); identity = gst_element_factory_make ("identity", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (identity); g_assert (sink); @@ -29,14 +29,14 @@ construct_pipeline (GstElement *pipeline) } void -state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) +state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data) { GstElementState state = gst_element_get_state (el); - - g_print ("element %s has changed state to %s\n", - GST_ELEMENT_NAME (el), - gst_element_state_get_name (state)); - if (state == GST_STATE_PLAYING) running = TRUE; + + g_print ("element %s has changed state to %s\n", + GST_ELEMENT_NAME (el), gst_element_state_get_name (state)); + if (state == GST_STATE_PLAYING) + running = TRUE; /* if we move from PLAYING to PAUSED, we're done */ if (state == GST_STATE_PAUSED && running) { running = FALSE; @@ -45,30 +45,29 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = 100; int i; gulong id; GstElement *thread; - + gst_init (&argc, &argv); - for (i = 0; i < runs; ++i) - { + for (i = 0; i < runs; ++i) { thread = gst_thread_new ("main_thread"); g_assert (thread); /* connect state change signal */ - id = g_signal_connect (G_OBJECT (thread), "state_change", - G_CALLBACK (state_changed), NULL); + id = g_signal_connect (G_OBJECT (thread), "state_change", + G_CALLBACK (state_changed), NULL); construct_pipeline (thread); g_print ("Setting thread to play\n"); gst_element_set_state (thread, GST_STATE_PLAYING); g_print ("Going into the main GStreamer loop\n"); - gst_main (); + gst_main (); g_print ("Coming out of the main GStreamer loop\n"); g_signal_handler_disconnect (G_OBJECT (thread), id); gst_element_set_state (thread, GST_STATE_NULL); diff --git a/tests/old/testsuite/threads/threadc.c b/tests/old/testsuite/threads/threadc.c index bcbb2705b..c1bf2541e 100644 --- a/tests/old/testsuite/threads/threadc.c +++ b/tests/old/testsuite/threads/threadc.c @@ -8,7 +8,7 @@ gboolean running = FALSE; gboolean can_quit = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink; GstElement *identity = NULL; @@ -16,15 +16,14 @@ construct_pipeline (GstElement *pipeline, gint identities) int i; identity = NULL; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -37,18 +36,17 @@ construct_pipeline (GstElement *pipeline, gint identities) } void -state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) +state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data) { GstElementState state = gst_element_get_state (el); g_print ("element %s has changed state to %s\n", - GST_ELEMENT_NAME (el), - gst_element_state_get_name (state)); - if (state == GST_STATE_PLAYING) running = TRUE; + GST_ELEMENT_NAME (el), gst_element_state_get_name (state)); + if (state == GST_STATE_PLAYING) + running = TRUE; /* if we move from PLAYING to PAUSED, we're done */ - if (state == GST_STATE_PAUSED && running) - { - while (!can_quit) ; + if (state == GST_STATE_PAUSED && running) { + while (!can_quit); can_quit = FALSE; g_print ("quitting main loop\n"); gst_main_quit (); @@ -56,7 +54,7 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = 290; int i; @@ -65,23 +63,21 @@ main (gint argc, gchar *argv[]) gst_init (&argc, &argv); - for (i = 90; i < runs; ++i) - { + for (i = 90; i < runs; ++i) { thread = gst_thread_new ("main_thread"); g_assert (thread); /* connect state change signal */ id = g_signal_connect (G_OBJECT (thread), "state_change", - G_CALLBACK (state_changed), NULL); + G_CALLBACK (state_changed), NULL); construct_pipeline (thread, i / 10 + 1); g_print ("Setting thread to play with %d identities\n", i / 10 + 1); if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) { g_error ("Failed setting thread to play\n"); - } - else { + } else { g_print ("Going into the main GStreamer loop\n"); - can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */ + can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */ gst_main (); } running = FALSE; @@ -94,4 +90,3 @@ main (gint argc, gchar *argv[]) return 0; } - diff --git a/tests/old/testsuite/threads/threadd.c b/tests/old/testsuite/threads/threadd.c index e9ff75360..25a521cf6 100644 --- a/tests/old/testsuite/threads/threadd.c +++ b/tests/old/testsuite/threads/threadd.c @@ -12,21 +12,20 @@ gboolean running = FALSE; gboolean done = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink, *identity = NULL; GstElement *from; int i; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -39,50 +38,49 @@ construct_pipeline (GstElement *pipeline, gint identities) } void -state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) +state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data) { GstElementState state = gst_element_get_state (el); - - g_print ("element %s has changed state to %s\n", - GST_ELEMENT_NAME (el), - gst_element_state_get_name (state)); - if (state == GST_STATE_PLAYING) running = TRUE; + + g_print ("element %s has changed state to %s\n", + GST_ELEMENT_NAME (el), gst_element_state_get_name (state)); + if (state == GST_STATE_PLAYING) + running = TRUE; /* if we move from PLAYING to PAUSED, we're done */ - if (state == GST_STATE_PAUSED && running) + if (state == GST_STATE_PAUSED && running) done = TRUE; } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY; int i; gulong id; GstElement *thread; - - alarm(10); + + alarm (10); gst_init (&argc, &argv); - for (i = 0; i < runs; ++i) - { + for (i = 0; i < runs; ++i) { thread = gst_thread_new ("main_thread"); g_assert (thread); /* connect state change signal */ - id = g_signal_connect (G_OBJECT (thread), "state_change", - G_CALLBACK (state_changed), NULL); + id = g_signal_connect (G_OBJECT (thread), "state_change", + G_CALLBACK (state_changed), NULL); construct_pipeline (thread, i / RUNS_PER_IDENTITY + 1); - g_print ("Setting thread to play with %d identities\n", - i / RUNS_PER_IDENTITY + 1); + g_print ("Setting thread to play with %d identities\n", + i / RUNS_PER_IDENTITY + 1); done = FALSE; if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) { g_warning ("failed to go to PLAYING"); - } - else { + } else { g_print ("Waiting for thread PLAYING->PAUSED\n"); - while (!done) /* do nothing */; + while (!done) /* do nothing */ + ; } running = FALSE; g_print ("Coming out of the main GStreamer loop\n"); @@ -94,4 +92,3 @@ main (gint argc, gchar *argv[]) return 0; } - diff --git a/tests/old/testsuite/threads/threade.c b/tests/old/testsuite/threads/threade.c index 98b15dd3c..169c53813 100644 --- a/tests/old/testsuite/threads/threade.c +++ b/tests/old/testsuite/threads/threade.c @@ -12,21 +12,20 @@ gboolean running = FALSE; gboolean done = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink, *identity = NULL; GstElement *from; int i; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -39,29 +38,29 @@ construct_pipeline (GstElement *pipeline, gint identities) } static void -iterator (GstElement *bin) +iterator (GstElement * bin) { gst_element_set_state (bin, GST_STATE_PLAYING); - while (gst_bin_iterate (GST_BIN (bin))) g_print ("+"); + while (gst_bin_iterate (GST_BIN (bin))) + g_print ("+"); gst_element_set_state (bin, GST_STATE_NULL); g_print ("\n"); done = TRUE; } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY; int i; GstElement *pipeline; - alarm(10); + alarm (10); g_thread_init (NULL); gst_init (&argc, &argv); - for (i = 0; i < runs; ++i) - { + for (i = 0; i < runs; ++i) { pipeline = gst_pipeline_new ("main_pipeline"); g_assert (pipeline); @@ -73,7 +72,8 @@ main (gint argc, gchar *argv[]) g_print ("Created GThread\n"); g_print ("Waiting for thread PLAYING->PAUSED\n"); - while (!done) /* do nothing */; + while (!done) /* do nothing */ + ; running = FALSE; g_print ("Unreffing pipeline\n"); g_object_unref (G_OBJECT (pipeline)); @@ -81,4 +81,3 @@ main (gint argc, gchar *argv[]) return 0; } - diff --git a/tests/old/testsuite/threads/threadf.c b/tests/old/testsuite/threads/threadf.c index e5e0ab886..f04f76db1 100644 --- a/tests/old/testsuite/threads/threadf.c +++ b/tests/old/testsuite/threads/threadf.c @@ -14,7 +14,7 @@ gboolean running = FALSE; gboolean done = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink; GstElement *identity = NULL; @@ -22,15 +22,14 @@ construct_pipeline (GstElement *pipeline, gint identities) int i; identity = NULL; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -50,8 +49,7 @@ thread (void) int i; GstElement *pipeline; - for (i = 30; i < runs; ++i) - { + for (i = 30; i < runs; ++i) { pipeline = gst_pipeline_new ("main_pipeline"); g_assert (pipeline); @@ -69,7 +67,7 @@ thread (void) } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { done = FALSE; @@ -78,8 +76,8 @@ main (gint argc, gchar *argv[]) g_thread_create ((GThreadFunc) thread, NULL, FALSE, NULL); g_print ("main: created GThread\n"); - while (!done) g_usleep (G_USEC_PER_SEC); + while (!done) + g_usleep (G_USEC_PER_SEC); g_print ("main: done\n"); return 0; } - diff --git a/tests/probes/probetest.c b/tests/probes/probetest.c index dc1880819..e171e1cbd 100644 --- a/tests/probes/probetest.c +++ b/tests/probes/probetest.c @@ -4,18 +4,18 @@ static GstElement *src1, *src2, *sink, *pipeline, *bin; static gint state = 0; static gboolean -notify (GstProbe *probe, GstData **data, gpointer user_data) +notify (GstProbe * probe, GstData ** data, gpointer user_data) { switch (state) { case 0: if (GST_BUFFER_TIMESTAMP (*data) == 10) { - gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); - gst_element_unlink_pads (GST_ELEMENT (src1), "src", sink, "sink"); - gst_bin_add (GST_BIN (bin), src2); - gst_bin_remove (GST_BIN (bin), src1); - gst_element_link_pads (GST_ELEMENT (src2), "src", sink, "sink"); - gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); + gst_element_unlink_pads (GST_ELEMENT (src1), "src", sink, "sink"); + gst_bin_add (GST_BIN (bin), src2); + gst_bin_remove (GST_BIN (bin), src1); + gst_element_link_pads (GST_ELEMENT (src2), "src", sink, "sink"); + gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING); state++; gst_data_unref (*data); return FALSE; @@ -26,7 +26,7 @@ notify (GstProbe *probe, GstData **data, gpointer user_data) if (GST_BUFFER_TIMESTAMP (*data) == 20) { gst_data_unref (*data); *data = GST_DATA (gst_event_new (GST_EVENT_EOS)); - gst_element_set_state (src2, GST_STATE_PAUSED); + gst_element_set_state (src2, GST_STATE_PAUSED); return TRUE; } break; @@ -38,7 +38,7 @@ notify (GstProbe *probe, GstData **data, gpointer user_data) } int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { gst_init (&argc, &argv); @@ -56,18 +56,16 @@ main (int argc, gchar *argv[]) gst_element_link_pads (GST_ELEMENT (src1), "src", sink, "sink"); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); - g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL); - - gst_pad_add_probe (gst_element_get_pad (src1, "src"), - gst_probe_new (FALSE, - notify, - NULL)); - - gst_pad_add_probe (gst_element_get_pad (src2, "src"), - gst_probe_new (FALSE, - notify, - NULL)); + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), + NULL); + + gst_pad_add_probe (gst_element_get_pad (src1, "src"), + gst_probe_new (FALSE, notify, NULL)); + + gst_pad_add_probe (gst_element_get_pad (src2, "src"), + gst_probe_new (FALSE, notify, NULL)); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); diff --git a/tests/sched/dynamic-pipeline.c b/tests/sched/dynamic-pipeline.c index de30ff17f..46b25c792 100644 --- a/tests/sched/dynamic-pipeline.c +++ b/tests/sched/dynamic-pipeline.c @@ -5,60 +5,59 @@ * cothreading that is fixed in the newer cothreads package. */ -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { - GstElement *fakesrc, *fakesink1, *fakesink2, *pipe1, *pipe2; - - gst_init(&argc, &argv); - - if (argc!=1) { - g_print("usage: %s\n", argv[0]); - exit(-1); - } - - fakesrc = gst_element_factory_make("fakesrc", "fakesrc"); - fakesink1 = gst_element_factory_make("fakesink", "fakesink1"); - fakesink2 = gst_element_factory_make("fakesink", "fakesink2"); + GstElement *fakesrc, *fakesink1, *fakesink2, *pipe1, *pipe2; - /* a crucial part of this test (and one that the old cothreads fails on) is - having two active pipelines in the same thread. */ - pipe1 = gst_pipeline_new("pipe1"); - pipe2 = gst_pipeline_new("pipe2"); - - /* make the first pipeline */ - gst_bin_add (GST_BIN(pipe1), fakesrc); - gst_bin_add (GST_BIN(pipe1), fakesink1); - gst_element_link_pads (fakesrc, "src", fakesink1, "sink"); - - /* initialize cothreads */ - gst_element_set_state(pipe1, GST_STATE_PLAYING); - gst_bin_iterate (GST_BIN (pipe1)); - gst_element_set_state(pipe1, GST_STATE_READY); - - /* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */ - gst_element_unlink_pads (fakesrc, "src", fakesink1, "sink"); - gst_object_ref(GST_OBJECT(fakesrc)); - gst_bin_remove(GST_BIN(pipe1), fakesrc); - gst_bin_remove(GST_BIN(pipe1), fakesink1); + gst_init (&argc, &argv); - gst_object_unref (GST_OBJECT (pipe1)); - - /* make a new pipeline */ - gst_bin_add (GST_BIN(pipe2), fakesink2); - - /* don't change the new pipeline's state, it should change on the bin_add */ - gst_bin_add (GST_BIN(pipe2), fakesrc); - gst_element_link_pads (fakesrc, "src", fakesink2, "sink"); - - /* show the pipeline state */ - gst_xml_write_file (GST_ELEMENT (pipe2), stdout); - - /* try to iterate the pipeline */ - gst_element_set_state(pipe2, GST_STATE_PLAYING); - gst_bin_iterate(GST_BIN(pipe2)); - gst_element_set_state(pipe2, GST_STATE_NULL); - - return 0; -} + if (argc != 1) { + g_print ("usage: %s\n", argv[0]); + exit (-1); + } + + fakesrc = gst_element_factory_make ("fakesrc", "fakesrc"); + fakesink1 = gst_element_factory_make ("fakesink", "fakesink1"); + fakesink2 = gst_element_factory_make ("fakesink", "fakesink2"); + + /* a crucial part of this test (and one that the old cothreads fails on) is + having two active pipelines in the same thread. */ + pipe1 = gst_pipeline_new ("pipe1"); + pipe2 = gst_pipeline_new ("pipe2"); + + /* make the first pipeline */ + gst_bin_add (GST_BIN (pipe1), fakesrc); + gst_bin_add (GST_BIN (pipe1), fakesink1); + gst_element_link_pads (fakesrc, "src", fakesink1, "sink"); + + /* initialize cothreads */ + gst_element_set_state (pipe1, GST_STATE_PLAYING); + gst_bin_iterate (GST_BIN (pipe1)); + gst_element_set_state (pipe1, GST_STATE_READY); + + /* destroy the fakesink, but keep fakesrc (its state is GST_STATE_READY) */ + gst_element_unlink_pads (fakesrc, "src", fakesink1, "sink"); + gst_object_ref (GST_OBJECT (fakesrc)); + gst_bin_remove (GST_BIN (pipe1), fakesrc); + gst_bin_remove (GST_BIN (pipe1), fakesink1); - + gst_object_unref (GST_OBJECT (pipe1)); + + /* make a new pipeline */ + gst_bin_add (GST_BIN (pipe2), fakesink2); + + /* don't change the new pipeline's state, it should change on the bin_add */ + gst_bin_add (GST_BIN (pipe2), fakesrc); + gst_element_link_pads (fakesrc, "src", fakesink2, "sink"); + + /* show the pipeline state */ + gst_xml_write_file (GST_ELEMENT (pipe2), stdout); + + /* try to iterate the pipeline */ + gst_element_set_state (pipe2, GST_STATE_PLAYING); + gst_bin_iterate (GST_BIN (pipe2)); + gst_element_set_state (pipe2, GST_STATE_NULL); + + return 0; +} diff --git a/tests/sched/interrupt1.c b/tests/sched/interrupt1.c index 2fae69af4..e33df4304 100644 --- a/tests/sched/interrupt1.c +++ b/tests/sched/interrupt1.c @@ -1,22 +1,23 @@ #include -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *pipeline, *thread, *queue, *src, *sink; gst_init (&argc, &argv); - free (malloc (8)); /* -lefence */ + free (malloc (8)); /* -lefence */ pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); thread = gst_thread_new ("thread"); - + queue = gst_element_factory_make ("queue", "queue"); sink = gst_element_factory_make ("fakesink", "sink"); - + gst_bin_add (GST_BIN (thread), queue); gst_bin_add (GST_BIN (thread), sink); gst_bin_add (GST_BIN (pipeline), thread); diff --git a/tests/sched/interrupt2.c b/tests/sched/interrupt2.c index 4e2551bfc..df2b97929 100644 --- a/tests/sched/interrupt2.c +++ b/tests/sched/interrupt2.c @@ -1,24 +1,25 @@ #include -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *pipeline, *thread, *queue, *src, *identity, *sink; gst_init (&argc, &argv); - free (malloc (8)); /* -lefence */ + free (malloc (8)); /* -lefence */ pipeline = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "src"); thread = gst_thread_new ("thread"); - + queue = gst_element_factory_make ("queue", "queue"); identity = gst_element_factory_make ("identity", "identity"); g_object_set (G_OBJECT (identity), "loop_based", TRUE, NULL); sink = gst_element_factory_make ("fakesink", "sink"); - + gst_bin_add (GST_BIN (thread), queue); gst_bin_add (GST_BIN (thread), identity); gst_bin_add (GST_BIN (thread), sink); diff --git a/tests/sched/interrupt3.c b/tests/sched/interrupt3.c index 38f06e518..937b1fd6a 100644 --- a/tests/sched/interrupt3.c +++ b/tests/sched/interrupt3.c @@ -1,13 +1,14 @@ #include -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *pipeline, *thread, *queue, *src, *adder, *sink; GstPad *sinkpad; gst_init (&argc, &argv); - free (malloc (8)); /* -lefence */ + free (malloc (8)); /* -lefence */ pipeline = gst_pipeline_new ("pipeline"); @@ -15,11 +16,11 @@ int main (int argc, char *argv[]) g_object_set (G_OBJECT (src), "sizetype", 2, NULL); thread = gst_thread_new ("thread"); - + queue = gst_element_factory_make ("queue", "queue"); adder = gst_element_factory_make ("adder", "adder"); sink = gst_element_factory_make ("fakesink", "sink"); - + gst_bin_add (GST_BIN (thread), queue); gst_bin_add (GST_BIN (thread), adder); gst_bin_add (GST_BIN (thread), sink); diff --git a/tests/sched/runxml.c b/tests/sched/runxml.c index d1b2a6dfe..753490761 100644 --- a/tests/sched/runxml.c +++ b/tests/sched/runxml.c @@ -5,34 +5,36 @@ static guint outcount, incount; static void -buffer_handoff_sink (GstElement *src, GstBuffer *buf, GstElement *bin) +buffer_handoff_sink (GstElement * src, GstBuffer * buf, GstElement * bin) { g_print ("\n\n *** buffer arrived in sink ***\n\n"); - gst_element_set_state(bin, GST_STATE_NULL); + gst_element_set_state (bin, GST_STATE_NULL); outcount++; } static void -buffer_handoff_src (GstElement *src, GstBuffer *buf, GstElement *bin) +buffer_handoff_src (GstElement * src, GstBuffer * buf, GstElement * bin) { g_print ("\n\n *** buffer started in src ***\n\n"); incount++; } /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { - g_print("have eos, quitting\n"); + g_print ("have eos, quitting\n"); } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstXML *xml; GList *toplevelelements; gint i = 1; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc < 2) { g_print ("usage: %s \n", argv[0]); @@ -41,48 +43,45 @@ int main(int argc,char *argv[]) g_print ("\n *** using testfile %s\n", argv[1]); - xml = gst_xml_new(); + xml = gst_xml_new (); gst_xml_parse_file (xml, argv[1], NULL); toplevelelements = gst_xml_get_topelements (xml); while (toplevelelements) { - GstElement *bin = (GstElement *)toplevelelements->data; + GstElement *bin = (GstElement *) toplevelelements->data; GstElement *src, *sink; g_print ("\n ***** testcase %d\n", i++); src = gst_bin_get_by_name (GST_BIN (bin), "fakesrc"); if (src) { - g_signal_connect (G_OBJECT(src), "handoff", - G_CALLBACK(buffer_handoff_src), bin); - } - else { + g_signal_connect (G_OBJECT (src), "handoff", + G_CALLBACK (buffer_handoff_src), bin); + } else { g_print ("could not find src element\n"); - exit(-1); + exit (-1); } - + sink = gst_bin_get_by_name (GST_BIN (bin), "fakesink"); if (sink) { - g_signal_connect (G_OBJECT(sink), "handoff", - G_CALLBACK(buffer_handoff_sink), bin); - } - else { + g_signal_connect (G_OBJECT (sink), "handoff", + G_CALLBACK (buffer_handoff_sink), bin); + } else { g_print ("could not find sink element\n"); - exit(-1); + exit (-1); } incount = 0; outcount = 0; /* gst_element_set_state(bin, GST_STATE_READY); */ - gst_element_set_state(bin, GST_STATE_PLAYING); + gst_element_set_state (bin, GST_STATE_PLAYING); if (GST_IS_THREAD (bin)) { g_usleep (G_USEC_PER_SEC); - } - else { - gst_bin_iterate(GST_BIN(bin)); + } else { + gst_bin_iterate (GST_BIN (bin)); } if (outcount != 1 && incount != 1) { @@ -93,5 +92,5 @@ int main(int argc,char *argv[]) toplevelelements = g_list_next (toplevelelements); } - exit(0); + exit (0); } diff --git a/tests/sched/sched-stress.c b/tests/sched/sched-stress.c index 28cccc6b5..34981598f 100644 --- a/tests/sched/sched-stress.c +++ b/tests/sched/sched-stress.c @@ -2,17 +2,17 @@ #define TAILLE 100 -int main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *src, *dec, *sink; int i, j; gst_init (&argc, &argv); - free (malloc (8)); /* -lefence */ + free (malloc (8)); /* -lefence */ - for(i = 0; i < TAILLE; i++) - { + for (i = 0; i < TAILLE; i++) { bin = gst_pipeline_new ("pipeline"); src = gst_element_factory_make ("fakesrc", "source"); dec = gst_element_factory_make ("identity", "decoder"); @@ -20,11 +20,10 @@ int main (int argc, char *argv[]) gst_bin_add_many (GST_BIN (bin), src, dec, sink, NULL); gst_element_link_many (src, dec, sink, NULL); gst_element_set_state (bin, GST_STATE_PLAYING); - for(j = 0; j < 30; j++) - gst_bin_iterate(GST_BIN(bin)); + for (j = 0; j < 30; j++) + gst_bin_iterate (GST_BIN (bin)); gst_element_set_state (bin, GST_STATE_PAUSED); } return 0; } - diff --git a/tests/seeking/seeking1.c b/tests/seeking/seeking1.c index af20fbf41..0e27a3ff4 100644 --- a/tests/seeking/seeking1.c +++ b/tests/seeking/seeking1.c @@ -5,34 +5,31 @@ static GstEvent *event; static GstPad *pad; static void -event_received (GObject *object, GstEvent *event, GstElement *pipeline) +event_received (GObject * object, GstEvent * event, GstElement * pipeline) { if (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT_DONE) { g_print ("segment done\n"); if (--looping == 1) { event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, 20, 25); - } - else { + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 20, 25); + } else { event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH | - GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); } gst_pad_send_event (pad, event); } } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *fakesrc; GstElement *fakesink; guint64 value; GstFormat format; - + gst_init (&argc, &argv); pipeline = gst_pipeline_new ("pipeline"); @@ -48,14 +45,13 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_READY); - pad = gst_element_get_pad (fakesrc, "src"); - + pad = gst_element_get_pad (fakesrc, "src"); + g_print ("doing segment seek from 5 to 10\n"); gst_pad_send_event (pad, - gst_event_new_segment_seek (GST_FORMAT_DEFAULT | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, 5, 10)); + gst_event_new_segment_seek (GST_FORMAT_DEFAULT | + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5, 10)); format = GST_FORMAT_DEFAULT; @@ -67,20 +63,22 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_PLAYING); - g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (G_OBJECT (pipeline), "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); while (gst_bin_iterate (GST_BIN (pipeline))); - g_print ("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n"); + g_print + ("doing segment seek from 50 to 55 with looping (2 times), then 20 to 25 without looping\n"); looping = 3; event = gst_event_new_segment_seek (GST_FORMAT_DEFAULT | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH | - GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); + GST_SEEK_METHOD_SET | + GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT_LOOP, 50, 55); gst_pad_send_event (pad, event); - g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")), "event_received", G_CALLBACK (event_received), event); + g_signal_connect (G_OBJECT (gst_element_get_pad (fakesink, "sink")), + "event_received", G_CALLBACK (event_received), event); gst_pad_query (pad, GST_QUERY_START, &format, &value); g_print ("configured for start %" G_GINT64_FORMAT "\n", value); @@ -90,8 +88,8 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); - + gst_element_set_state (pipeline, GST_STATE_NULL); - + return 0; } diff --git a/tests/threadstate/test1.c b/tests/threadstate/test1.c index 0ad0a2edf..e4478be59 100644 --- a/tests/threadstate/test1.c +++ b/tests/threadstate/test1.c @@ -22,11 +22,11 @@ typedef struct { GMutex *mutex; - GCond *cond; - gint var; + GCond *cond; + gint var; } ThreadInfo; -static void* +static void * thread_loop (void *arg) { ThreadInfo *info = (ThreadInfo *) arg; @@ -50,8 +50,8 @@ thread_loop (void *arg) return NULL; } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { ThreadInfo *info; GThread *thread; @@ -65,14 +65,11 @@ main (gint argc, gchar *argv[]) info->mutex = g_mutex_new (); info->cond = g_cond_new (); info->var = 0; - + g_print ("main: lock\n"); g_mutex_lock (info->mutex); - thread = g_thread_create (thread_loop, - info, - TRUE, - &error); + thread = g_thread_create (thread_loop, info, TRUE, &error); if (error != NULL) { g_print ("Unable to start thread: %s\n", error->message); @@ -91,7 +88,7 @@ main (gint argc, gchar *argv[]) g_cond_wait (info->cond, info->mutex); g_print ("main: var == %d\n", info->var); - if (info->var != 1) + if (info->var != 1) g_print ("main: !!error!! expected var == 1, got %d\n", info->var); g_mutex_unlock (info->mutex); @@ -105,4 +102,3 @@ done: return res; } - diff --git a/tests/threadstate/test2.c b/tests/threadstate/test2.c index b8714a6d0..4841cddc2 100644 --- a/tests/threadstate/test2.c +++ b/tests/threadstate/test2.c @@ -22,12 +22,12 @@ typedef struct { GMutex *mutex; - GCond *cond_t; - GCond *cond_p; - gint var; + GCond *cond_t; + GCond *cond_p; + gint var; } ThreadInfo; -static void* +static void * thread_loop (void *arg) { ThreadInfo *info = (ThreadInfo *) arg; @@ -51,8 +51,8 @@ thread_loop (void *arg) return NULL; } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { ThreadInfo *info; GThread *thread; @@ -67,14 +67,11 @@ main (gint argc, gchar *argv[]) info->cond_t = g_cond_new (); info->cond_p = g_cond_new (); info->var = 0; - + g_print ("main: lock\n"); g_mutex_lock (info->mutex); - thread = g_thread_create (thread_loop, - info, - TRUE, - &error); + thread = g_thread_create (thread_loop, info, TRUE, &error); if (error != NULL) { g_print ("Unable to start thread: %s\n", error->message); @@ -109,4 +106,3 @@ done: return res; } - diff --git a/tests/threadstate/threadstate1.c b/tests/threadstate/threadstate1.c index 309bf37a0..2b1e5faab 100644 --- a/tests/threadstate/threadstate1.c +++ b/tests/threadstate/threadstate1.c @@ -6,35 +6,36 @@ */ -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *fakesrc, *fakesink; GstElement *thread; gint x; - gst_init(&argc,&argv); + gst_init (&argc, &argv); - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); - fakesrc = gst_element_factory_make("fakesrc", "fake_source"); - g_assert(fakesrc != NULL); + fakesrc = gst_element_factory_make ("fakesrc", "fake_source"); + g_assert (fakesrc != NULL); - fakesink = gst_element_factory_make("fakesink", "fake_sink"); - g_assert(fakesink != NULL); + fakesink = gst_element_factory_make ("fakesink", "fake_sink"); + g_assert (fakesink != NULL); - gst_bin_add_many (GST_BIN(thread), fakesrc, fakesink, NULL); + gst_bin_add_many (GST_BIN (thread), fakesrc, fakesink, NULL); gst_element_link (fakesrc, fakesink); - for (x = 0 ; x < 10 ; x++){ - g_print("playing %d\n", x); - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING); + for (x = 0; x < 10; x++) { + g_print ("playing %d\n", x); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); g_usleep (G_USEC_PER_SEC); - g_print("pausing %d\n", x); - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PAUSED); + g_print ("pausing %d\n", x); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PAUSED); g_usleep (G_USEC_PER_SEC); } - exit(0); + exit (0); } diff --git a/tests/threadstate/threadstate2.c b/tests/threadstate/threadstate2.c index ca5fd003f..15827dbdb 100644 --- a/tests/threadstate/threadstate2.c +++ b/tests/threadstate/threadstate2.c @@ -6,25 +6,28 @@ */ /* eos will be called when the src element has an end of stream */ -void eos(GstElement *element, gpointer data) +void +eos (GstElement * element, gpointer data) { GstThread *thread = GST_THREAD (data); - g_print("have eos, quitting\n"); + + g_print ("have eos, quitting\n"); /* stop the bin */ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL); - gst_main_quit(); + gst_main_quit (); } -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *filesrc, *osssink; GstElement *thread; GstElement *mad; gint x; - gst_init(&argc,&argv); + gst_init (&argc, &argv); if (argc != 2) { g_print ("usage: %s \n", argv[0]); @@ -39,8 +42,7 @@ int main(int argc,char *argv[]) filesrc = gst_element_factory_make ("filesrc", "disk_source"); g_assert (filesrc != NULL); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); - g_signal_connect (G_OBJECT (filesrc), "eos", - G_CALLBACK (eos), thread); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (eos), thread); /* and an audio sink */ osssink = gst_element_factory_make ("osssink", "play_audio"); @@ -53,7 +55,7 @@ int main(int argc,char *argv[]) gst_bin_add_many (GST_BIN (thread), filesrc, mad, osssink, NULL); gst_element_link_many (filesrc, mad, osssink, NULL); - for (x = 0 ; x < 10 ; x++){ + for (x = 0; x < 10; x++) { g_print ("playing %d\n", x); gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); g_usleep (G_USEC_PER_SEC * 2); diff --git a/tests/threadstate/threadstate3.c b/tests/threadstate/threadstate3.c index 21a8ab6f8..cfabbb376 100644 --- a/tests/threadstate/threadstate3.c +++ b/tests/threadstate/threadstate3.c @@ -5,39 +5,40 @@ * { { fakesrc ! fakesink } } */ -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *fakesrc, *fakesink; GstElement *thread, *thread2; gint x; - gst_init(&argc,&argv); + gst_init (&argc, &argv); - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); - thread2 = gst_thread_new("thread2"); - g_assert(thread2 != NULL); + thread2 = gst_thread_new ("thread2"); + g_assert (thread2 != NULL); - gst_bin_add(GST_BIN(thread), GST_ELEMENT(thread2)); + gst_bin_add (GST_BIN (thread), GST_ELEMENT (thread2)); - fakesrc = gst_element_factory_make("fakesrc", "fake_source"); - g_assert(fakesrc != NULL); + fakesrc = gst_element_factory_make ("fakesrc", "fake_source"); + g_assert (fakesrc != NULL); - fakesink = gst_element_factory_make("fakesink", "fake_sink"); - g_assert(fakesink != NULL); + fakesink = gst_element_factory_make ("fakesink", "fake_sink"); + g_assert (fakesink != NULL); - gst_bin_add_many (GST_BIN(thread2), fakesrc, fakesink, NULL); + gst_bin_add_many (GST_BIN (thread2), fakesrc, fakesink, NULL); gst_element_link (fakesrc, fakesink); - for (x = 0 ; x < 10 ; x++){ - g_print("playing %d\n", x); - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING); + for (x = 0; x < 10; x++) { + g_print ("playing %d\n", x); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); g_usleep (G_USEC_PER_SEC); - g_print("nulling %d\n", x); - gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL); + g_print ("nulling %d\n", x); + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL); g_usleep (G_USEC_PER_SEC); } - exit(0); + exit (0); } diff --git a/tests/threadstate/threadstate4.c b/tests/threadstate/threadstate4.c index 6776e49a6..f96f90ba1 100644 --- a/tests/threadstate/threadstate4.c +++ b/tests/threadstate/threadstate4.c @@ -5,46 +5,48 @@ * { { fakesrc } ! queue ! fakesink } */ -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *fakesrc, *fakesink; GstElement *thread, *thread2; GstElement *queue; gint x; - gst_init(&argc,&argv); + gst_init (&argc, &argv); - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); - thread2 = gst_thread_new("thread"); - g_assert(thread2 != NULL); + thread2 = gst_thread_new ("thread"); + g_assert (thread2 != NULL); - queue = gst_element_factory_make("queue", "the_queue"); - g_assert(queue != NULL); + queue = gst_element_factory_make ("queue", "the_queue"); + g_assert (queue != NULL); - fakesrc = gst_element_factory_make("fakesrc", "fake_source"); - g_assert(fakesrc != NULL); + fakesrc = gst_element_factory_make ("fakesrc", "fake_source"); + g_assert (fakesrc != NULL); - fakesink = gst_element_factory_make("fakesink", "fake_sink"); - g_assert(fakesink != NULL); + fakesink = gst_element_factory_make ("fakesink", "fake_sink"); + g_assert (fakesink != NULL); - gst_bin_add_many (GST_BIN(thread), thread2, queue, fakesink, NULL); + gst_bin_add_many (GST_BIN (thread), thread2, queue, fakesink, NULL); - gst_bin_add(GST_BIN(thread2), fakesrc); - gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"), "src"); + gst_bin_add (GST_BIN (thread2), fakesrc); + gst_element_add_ghost_pad (thread2, gst_element_get_pad (fakesrc, "src"), + "src"); gst_element_link_many (thread2, queue, fakesink, NULL); - for (x = 0 ; x < 10 ; x++){ - g_print("playing %d\n", x); - gst_element_set_state(thread, GST_STATE_PLAYING); + for (x = 0; x < 10; x++) { + g_print ("playing %d\n", x); + gst_element_set_state (thread, GST_STATE_PLAYING); g_usleep (G_USEC_PER_SEC); - g_print("nulling %d\n", x); - gst_element_set_state(thread, GST_STATE_NULL); + g_print ("nulling %d\n", x); + gst_element_set_state (thread, GST_STATE_NULL); g_usleep (G_USEC_PER_SEC); } - exit(0); + exit (0); } diff --git a/tests/threadstate/threadstate5.c b/tests/threadstate/threadstate5.c index f9953b76c..e544d073d 100644 --- a/tests/threadstate/threadstate5.c +++ b/tests/threadstate/threadstate5.c @@ -5,46 +5,48 @@ * { fakesrc ! { queue ! fakesink } } */ -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *fakesrc, *fakesink; GstElement *thread, *thread2; GstElement *queue; gint x; - gst_init(&argc,&argv); + gst_init (&argc, &argv); - thread = gst_thread_new("thread"); - g_assert(thread != NULL); + thread = gst_thread_new ("thread"); + g_assert (thread != NULL); - thread2 = gst_thread_new("thread"); - g_assert(thread2 != NULL); + thread2 = gst_thread_new ("thread"); + g_assert (thread2 != NULL); - queue = gst_element_factory_make("queue", "the_queue"); - g_assert(queue != NULL); + queue = gst_element_factory_make ("queue", "the_queue"); + g_assert (queue != NULL); - fakesrc = gst_element_factory_make("fakesrc", "fake_source"); - g_assert(fakesrc != NULL); + fakesrc = gst_element_factory_make ("fakesrc", "fake_source"); + g_assert (fakesrc != NULL); - fakesink = gst_element_factory_make("fakesink", "fake_sink"); - g_assert(fakesink != NULL); + fakesink = gst_element_factory_make ("fakesink", "fake_sink"); + g_assert (fakesink != NULL); - gst_bin_add_many (GST_BIN(thread), fakesrc, thread2, NULL); - gst_bin_add_many (GST_BIN(thread2), queue, fakesink, NULL); + gst_bin_add_many (GST_BIN (thread), fakesrc, thread2, NULL); + gst_bin_add_many (GST_BIN (thread2), queue, fakesink, NULL); - gst_element_add_ghost_pad (thread2, gst_element_get_pad (queue, "sink"), "sink"); + gst_element_add_ghost_pad (thread2, gst_element_get_pad (queue, "sink"), + "sink"); gst_element_link_many (queue, fakesink, NULL); gst_element_link_many (fakesrc, thread2, NULL); - for (x = 0 ; x < 10 ; x++){ - g_print("playing %d\n", x); - gst_element_set_state(thread, GST_STATE_PLAYING); + for (x = 0; x < 10; x++) { + g_print ("playing %d\n", x); + gst_element_set_state (thread, GST_STATE_PLAYING); g_usleep (G_USEC_PER_SEC); - g_print("nulling %d\n", x); - gst_element_set_state(thread, GST_STATE_NULL); + g_print ("nulling %d\n", x); + gst_element_set_state (thread, GST_STATE_NULL); g_usleep (G_USEC_PER_SEC); } - exit(0); + exit (0); } diff --git a/testsuite/bins/interface.c b/testsuite/bins/interface.c index 61f948d28..028b8f0b8 100644 --- a/testsuite/bins/interface.c +++ b/testsuite/bins/interface.c @@ -21,13 +21,13 @@ /* tests if gst_bin_get_(all_)by_interface works */ -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstBin *bin, *bin2; GList *list; GstElement *filesrc; - + gst_init (&argc, &argv); bin = GST_BIN (gst_bin_new (NULL)); @@ -37,18 +37,17 @@ main (gint argc, gchar *argv[]) g_assert (filesrc); g_assert (GST_IS_URI_HANDLER (filesrc)); gst_bin_add (bin, filesrc); - + g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); g_assert (g_list_length (list) == 1); g_assert (list->data == (gpointer) filesrc); g_list_free (list); - - gst_bin_add_many (bin, + + gst_bin_add_many (bin, gst_element_factory_make ("identity", NULL), - gst_element_factory_make ("identity", NULL), gst_element_factory_make ("identity", NULL), - NULL); + gst_element_factory_make ("identity", NULL), NULL); g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); g_assert (g_list_length (list) == 1); @@ -61,9 +60,7 @@ main (gint argc, gchar *argv[]) gst_bin_add_many (bin, gst_element_factory_make ("identity", NULL), gst_element_factory_make ("identity", NULL), - GST_ELEMENT (bin2), - gst_element_factory_make ("identity", NULL), - NULL); + GST_ELEMENT (bin2), gst_element_factory_make ("identity", NULL), NULL); g_assert (gst_bin_get_by_interface (bin, GST_TYPE_URI_HANDLER) == filesrc); list = gst_bin_get_all_by_interface (bin, GST_TYPE_URI_HANDLER); g_assert (g_list_length (list) == 1); diff --git a/testsuite/bytestream/gstbstest.c b/testsuite/bytestream/gstbstest.c index eb5a6c413..883bdbf36 100644 --- a/testsuite/bytestream/gstbstest.c +++ b/testsuite/bytestream/gstbstest.c @@ -46,14 +46,14 @@ struct _GstBsTest GstPad *srcpad; GstByteStream *bs; - - gchar *accesspattern; - guint num_patterns; - gchar **patterns; - guint sizemin; - guint sizemax; - gint count; - gboolean silent; + + gchar *accesspattern; + guint num_patterns; + gchar **patterns; + guint sizemin; + guint sizemax; + gint count; + gboolean silent; }; struct _GstBsTestClass @@ -64,13 +64,11 @@ struct _GstBsTestClass GType gst_bstest_get_type (void); -GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS ( - "ByteStreamTest", - "Filter", - "Test for the GstByteStream code", - "Erik Walthinsen , " - "Wim Taymans " -); +GstElementDetails gst_bstest_details = GST_ELEMENT_DETAILS ("ByteStreamTest", + "Filter", + "Test for the GstByteStream code", + "Erik Walthinsen , " + "Wim Taymans "); /* BsTest signals and args */ @@ -91,17 +89,17 @@ enum }; -static void gst_bstest_base_init (gpointer g_class); -static void gst_bstest_class_init (GstBsTestClass * klass); -static void gst_bstest_init (GstBsTest * bstest); +static void gst_bstest_base_init (gpointer g_class); +static void gst_bstest_class_init (GstBsTestClass * klass); +static void gst_bstest_init (GstBsTest * bstest); -static void gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, - GParamSpec * pspec); -static void gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, - GParamSpec * pspec); +static void gst_bstest_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_bstest_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); -static GstElementStateReturn gst_bstest_change_state (GstElement *element); -static void gst_bstest_loop (GstElement * element); +static GstElementStateReturn gst_bstest_change_state (GstElement * element); +static void gst_bstest_loop (GstElement * element); static GstElementClass *parent_class = NULL; @@ -125,7 +123,8 @@ gst_bstest_get_type (void) (GInstanceInitFunc) gst_bstest_init, }; - bstest_type = g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0); + bstest_type = + g_type_register_static (GST_TYPE_ELEMENT, "BSTest", &bstest_info, 0); } return bstest_type; } @@ -144,25 +143,25 @@ gst_bstest_class_init (GstBsTestClass * klass) GstElementClass *gstelement_class; gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass*)klass; + gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMIN, - g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT, - 0, G_PARAM_READWRITE)); + g_param_spec_int ("sizemin", "sizemin", "sizemin", 0, G_MAXINT, + 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SIZEMAX, - g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT, - 384, G_PARAM_READWRITE)); + g_param_spec_int ("sizemax", "sizemax", "sizemax", 0, G_MAXINT, + 384, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ACCESSPATTERN, - g_param_spec_string ("accesspattern", "accesspattern", "accesspattern", - "r", G_PARAM_READWRITE)); + g_param_spec_string ("accesspattern", "accesspattern", "accesspattern", + "r", G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COUNT, - g_param_spec_uint ("count", "count", "count", - 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_param_spec_uint ("count", "count", "count", + 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SILENT, - g_param_spec_boolean ("silent", "silent", "silent", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("silent", "silent", "silent", + FALSE, G_PARAM_READWRITE)); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_bstest_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_bstest_get_property); @@ -172,7 +171,7 @@ gst_bstest_class_init (GstBsTestClass * klass) } static GstCaps * -gst_bstest_getcaps (GstPad *pad) +gst_bstest_getcaps (GstPad * pad) { GstBsTest *bstest = GST_BSTEST (gst_pad_get_parent (pad)); GstPad *otherpad; @@ -205,24 +204,25 @@ gst_bstest_init (GstBsTest * bstest) } static guint -gst_bstest_get_size (GstBsTest *bstest, gchar *sizestring, guint prevsize) +gst_bstest_get_size (GstBsTest * bstest, gchar * sizestring, guint prevsize) { guint size; if (sizestring[0] == 0) { size = bstest->sizemax; - } - else if (sizestring[0] == 'r') { - size = bstest->sizemin + (guint8)(((gfloat)bstest->sizemax)*rand()/(RAND_MAX + (gfloat)bstest->sizemin)); - } - else if (sizestring[0] == '<') { + } else if (sizestring[0] == 'r') { + size = + bstest->sizemin + + (guint8) (((gfloat) bstest->sizemax) * rand () / (RAND_MAX + + (gfloat) bstest->sizemin)); + } else if (sizestring[0] == '<') { size = prevsize; - } - else { + } else { size = atoi (sizestring); } - if (size == 0) size++; + if (size == 0) + size++; return size; } @@ -248,30 +248,31 @@ gst_bstest_loop (GstElement * element) if (bstest->patterns[i][0] == 'r') { size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size); - if (!bstest->silent) g_print ("bstest: ***** read %d bytes\n", size); - gst_bytestream_read (bstest->bs, &buf, size); - } - else if (bstest->patterns[i][0] == 'f') { + if (!bstest->silent) + g_print ("bstest: ***** read %d bytes\n", size); + gst_bytestream_read (bstest->bs, &buf, size); + } else if (bstest->patterns[i][0] == 'f') { size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size); - if (!bstest->silent) g_print ("bstest: ***** flush %d bytes\n", size); - gst_bytestream_flush (bstest->bs, size); - } - else if (!strncmp (bstest->patterns[i], "pb", 2)) { + if (!bstest->silent) + g_print ("bstest: ***** flush %d bytes\n", size); + gst_bytestream_flush (bstest->bs, size); + } else if (!strncmp (bstest->patterns[i], "pb", 2)) { size = gst_bstest_get_size (bstest, &bstest->patterns[i][2], size); - if (!bstest->silent) g_print ("bstest: ***** peek bytes %d bytes\n", size); - gst_bytestream_peek_bytes (bstest->bs, &ptr, size); - } - else if (bstest->patterns[i][0] == 'p') { + if (!bstest->silent) + g_print ("bstest: ***** peek bytes %d bytes\n", size); + gst_bytestream_peek_bytes (bstest->bs, &ptr, size); + } else if (bstest->patterns[i][0] == 'p') { size = gst_bstest_get_size (bstest, &bstest->patterns[i][1], size); - if (!bstest->silent) g_print ("bstest: ***** peek %d bytes\n", size); - gst_bytestream_peek (bstest->bs, &buf, size); + if (!bstest->silent) + g_print ("bstest: ***** peek %d bytes\n", size); + gst_bytestream_peek (bstest->bs, &buf, size); gst_buffer_unref (buf); buf = NULL; } if (buf) - gst_pad_push (bstest->srcpad, GST_DATA (buf)); - + gst_pad_push (bstest->srcpad, GST_DATA (buf)); + i++; } /* } while (!GST_ELEMENT_IS_COTHREAD_STOPPING (element)); */ @@ -280,7 +281,8 @@ gst_bstest_loop (GstElement * element) } static void -gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstBsTest *bstest; @@ -302,16 +304,16 @@ gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, g_strfreev (bstest->patterns); } if (g_value_get_string (value) == NULL) { - gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); - bstest->accesspattern = NULL; - bstest->num_patterns = 0; + gst_element_set_state (GST_ELEMENT (object), GST_STATE_NULL); + bstest->accesspattern = NULL; + bstest->num_patterns = 0; } else { guint i = 0; - bstest->accesspattern = g_strdup (g_value_get_string (value)); - bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0); - while (bstest->patterns[i++]); - bstest->num_patterns = i-1; + bstest->accesspattern = g_strdup (g_value_get_string (value)); + bstest->patterns = g_strsplit (bstest->accesspattern, ":", 0); + while (bstest->patterns[i++]); + bstest->num_patterns = i - 1; } break; case ARG_COUNT: @@ -327,7 +329,8 @@ gst_bstest_set_property (GObject * object, guint prop_id, const GValue * value, } static void -gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) +gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) { GstBsTest *bstest; @@ -359,7 +362,7 @@ gst_bstest_get_property (GObject * object, guint prop_id, GValue * value, GParam } static GstElementStateReturn -gst_bstest_change_state (GstElement *element) +gst_bstest_change_state (GstElement * element) { GstBsTest *bstest; @@ -372,8 +375,7 @@ gst_bstest_change_state (GstElement *element) gst_bytestream_destroy (bstest->bs); bstest->bs = NULL; } - } - else { + } else { if (!bstest->bs) { bstest->bs = gst_bytestream_new (bstest->sinkpad); } @@ -392,17 +394,12 @@ plugin_init (GstPlugin * plugin) * This consists of the name of the element, the GType identifier, * and a pointer to the details structure at the top of the file. */ - return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY, GST_TYPE_BSTEST); + return gst_element_register (plugin, "bstest", GST_RANK_PRIMARY, + GST_TYPE_BSTEST); } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "bstest", - "test for the bytestream element", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "bstest", + "test for the bytestream element", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/testsuite/bytestream/test1.c b/testsuite/bytestream/test1.c index 4545f9d7a..088cacd0e 100644 --- a/testsuite/bytestream/test1.c +++ b/testsuite/bytestream/test1.c @@ -26,41 +26,41 @@ static gboolean verbose = FALSE; static gboolean dump = FALSE; static void -handoff (GstElement *element, GstBuffer *buf, GstPad *pad, gpointer data) +handoff (GstElement * element, GstBuffer * buf, GstPad * pad, gpointer data) { if (GST_IS_BUFFER (buf)) { if (integrity_check) { gint i; guint8 *ptr = GST_BUFFER_DATA (buf); - - for (i=0; isrc_sizetype == 2 ? "fixed" : "random"), - (param->src_data == 1 ? "src" : "subbuffer"), - param->bs_accesspattern); + desc = + g_strdup_printf ("%s %s, pattern %s", + (param->src_sizetype == 2 ? "fixed" : "random"), + (param->src_data == 1 ? "src" : "subbuffer"), param->bs_accesspattern); return desc; } -static gboolean -read_param_file (gchar *filename) +static gboolean +read_param_file (gchar * filename) { FILE *fp; - gchar line[MAX_CONFIG_LINE+1]; + gchar line[MAX_CONFIG_LINE + 1]; guint linenr = 0; gchar pattern[MAX_CONFIG_PATTERN]; gint data, sizetype, integrity_check; @@ -68,23 +68,23 @@ read_param_file (gchar *filename) gboolean res = TRUE; fp = fopen (filename, "r"); - if (fp == NULL) + if (fp == NULL) return FALSE; - scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN-1); - - while (fgets (line, MAX_CONFIG_LINE, fp)) { + scan_str = g_strdup_printf ("%%d %%d %%%ds %%d", MAX_CONFIG_PATTERN - 1); + + while (fgets (line, MAX_CONFIG_LINE, fp)) { linenr++; if (line[0] == '\n' || line[0] == '#') continue; - if (sscanf (line, scan_str, &data, &sizetype, pattern, &integrity_check) != 4) { + if (sscanf (line, scan_str, &data, &sizetype, pattern, + &integrity_check) != 4) { g_print ("error on line: %d\n", linenr); res = FALSE; break; - } - else { + } else { TestParam *param = g_malloc (sizeof (TestParam)); param->src_data = data; @@ -96,12 +96,12 @@ read_param_file (gchar *filename) } } g_free (scan_str); - + return res; } -static void -run_test (GstBin *pipeline, gint iters) +static void +run_test (GstBin * pipeline, gint iters) { gint vm = 0; gint maxiters = iters; @@ -114,28 +114,31 @@ run_test (GstBin *pipeline, gint iters) gint newvm = gst_alloc_trace_live_all (); gint percent; - percent = (gint)((maxiters-iters+1)*100.0/maxiters); + percent = (gint) ((maxiters - iters + 1) * 100.0 / maxiters); if (percent != prev_percent || newvm - vm > VM_THRES) { - g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm, percent); + g_print ("\r%d (delta %d) %.3d%% ", newvm, newvm - vm, + percent); prev_percent = percent; vm = newvm; } gst_bin_iterate (pipeline); - if (iters > 0) iters--; + if (iters > 0) + iters--; } gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); } -static void +static void usage (char *argv[]) { - g_print ("usage: %s [--verbose] [--dump] \n", argv[0]); + g_print ("usage: %s [--verbose] [--dump] \n", + argv[0]); } int -main (int argc, char *argv[]) +main (int argc, char *argv[]) { GstElement *src; GstElement *sink; @@ -149,7 +152,7 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); arg_walk = 1; - while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) { + while ((arg_walk < argc) && (argv[arg_walk][0] == '-')) { if (!strncmp (argv[arg_walk], "--verbose", 9)) verbose = TRUE; else if (!strncmp (argv[arg_walk], "--dump", 6)) @@ -161,10 +164,10 @@ main (int argc, char *argv[]) arg_walk++; } if (argc - arg_walk < 2) { - usage(argv); + usage (argv); return -1; } - if (!read_param_file (argv[arg_walk])) { + if (!read_param_file (argv[arg_walk])) { g_print ("error reading file %s\n", argv[arg_walk]); usage (argv); return -1; @@ -198,21 +201,19 @@ main (int argc, char *argv[]) integrity_check = param->integrity_check; - g_print ("\n\nrunning test %d (%d iterations):\n", testnum+1, iterations); + g_print ("\n\nrunning test %d (%d iterations):\n", testnum + 1, iterations); desc = create_desc (param); g_print ("%s\n", desc); g_free (desc); - g_object_set (G_OBJECT (src), "data", param->src_data, - "sizetype", param->src_sizetype, - "filltype", (integrity_check?5:0), - "silent", !verbose, NULL); + g_object_set (G_OBJECT (src), "data", param->src_data, + "sizetype", param->src_sizetype, + "filltype", (integrity_check ? 5 : 0), "silent", !verbose, NULL); - g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern, - "silent", !verbose, NULL); + g_object_set (G_OBJECT (bs), "accesspattern", param->bs_accesspattern, + "silent", !verbose, NULL); - g_object_set (G_OBJECT (sink), "dump", dump, - "silent", !verbose, NULL); + g_object_set (G_OBJECT (sink), "dump", dump, "silent", !verbose, NULL); run_test (GST_BIN (pipeline), iterations); diff --git a/testsuite/caps/app_fixate.c b/testsuite/caps/app_fixate.c index fbaea4216..6c8500d55 100644 --- a/testsuite/caps/app_fixate.c +++ b/testsuite/caps/app_fixate.c @@ -3,13 +3,13 @@ static GstCaps * -handler (GObject *object, GstCaps *caps, gpointer user_data) +handler (GObject * object, GstCaps * caps, gpointer user_data) { - g_print("in handler %p, %p, %p\n", object, caps, user_data); + g_print ("in handler %p, %p, %p\n", object, caps, user_data); - g_assert (GST_IS_PAD(object)); + g_assert (GST_IS_PAD (object)); - g_print("caps: %s\n", gst_caps_to_string(caps)); + g_print ("caps: %s\n", gst_caps_to_string (caps)); if (gst_caps_is_any (caps)) { return gst_caps_new_simple ("application/x-foo", @@ -28,7 +28,7 @@ main (int argc, char *argv[]) GstElement *pipeline; GstPad *pad; - gst_init(&argc, &argv); + gst_init (&argc, &argv); pipeline = gst_pipeline_new (NULL); @@ -37,16 +37,15 @@ main (int argc, char *argv[]) b = gst_element_factory_make ("fakesink", NULL); g_assert (b); - gst_bin_add_many (GST_BIN (pipeline), a,b, NULL); - gst_element_link (a,b); + gst_bin_add_many (GST_BIN (pipeline), a, b, NULL); + gst_element_link (a, b); pad = gst_element_get_pad (a, "src"); g_signal_connect (G_OBJECT (pad), "fixate", G_CALLBACK (handler), - (void *)0xdeadbeef); + (void *) 0xdeadbeef); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); return 0; } - diff --git a/testsuite/caps/caps.c b/testsuite/caps/caps.c index 48e9a1037..c99b0d8a2 100644 --- a/testsuite/caps/caps.c +++ b/testsuite/caps/caps.c @@ -2,138 +2,139 @@ #include -void test1(void) +void +test1 (void) { GstCaps *caps; GstCaps *caps2; - g_print("type is %d\n", (int)gst_caps_get_type()); + g_print ("type is %d\n", (int) gst_caps_get_type ()); - caps = gst_caps_new_empty(); - g_assert(caps != NULL); - gst_caps_free(caps); + caps = gst_caps_new_empty (); + g_assert (caps != NULL); + gst_caps_free (caps); - caps = gst_caps_new_any(); - g_assert(caps != NULL); - gst_caps_free(caps); + caps = gst_caps_new_any (); + g_assert (caps != NULL); + gst_caps_free (caps); - caps = gst_caps_new_simple("audio/raw", - "_int", G_TYPE_INT, 100, NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); - caps = gst_caps_new_simple("audio/raw", + caps = gst_caps_new_simple ("audio/raw", "_double", G_TYPE_DOUBLE, 100.0, NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", - "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC('a','b','c','d'), NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", + "_fourcc", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('a', 'b', 'c', 'd'), NULL); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", "_boolean", G_TYPE_BOOLEAN, TRUE, NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==TRUE); - g_assert(gst_caps_is_fixed(caps)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_full( - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL), - gst_structure_new("audio/raw2", "_int", G_TYPE_INT, 100, NULL), - NULL); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE); - g_assert(gst_caps_is_fixed(caps)==FALSE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL); - g_assert(caps != NULL); - caps2 = gst_caps_copy(caps); - g_assert(caps2 != NULL); - g_assert(gst_caps_is_empty(caps2)==FALSE); - g_assert(gst_caps_is_any(caps2)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps2)==TRUE); - g_assert(gst_caps_is_fixed(caps2)==TRUE); - g_print("%s\n", gst_caps_to_string(caps)); - g_print("%s\n", gst_caps_to_string(caps2)); - gst_caps_free(caps); - gst_caps_free(caps2); - - caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL); - gst_caps_append (caps, - gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 200, NULL)); - g_assert(caps != NULL); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE); - g_assert(gst_caps_is_fixed(caps)==FALSE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - - caps = gst_caps_new_simple("audio/raw", "_int", G_TYPE_INT, 100, NULL); - g_assert(caps != NULL); - gst_caps_append_structure (caps, - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL)); - g_assert(gst_caps_is_empty(caps)==FALSE); - g_assert(gst_caps_is_any(caps)==FALSE); - g_assert(GST_CAPS_IS_SIMPLE(caps)==FALSE); - g_assert(gst_caps_is_fixed(caps)==FALSE); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == TRUE); + g_assert (gst_caps_is_fixed (caps) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = + gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, + 100, NULL), gst_structure_new ("audio/raw2", "_int", G_TYPE_INT, 100, + NULL), NULL); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); + g_assert (gst_caps_is_fixed (caps) == FALSE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + g_assert (caps != NULL); + caps2 = gst_caps_copy (caps); + g_assert (caps2 != NULL); + g_assert (gst_caps_is_empty (caps2) == FALSE); + g_assert (gst_caps_is_any (caps2) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps2) == TRUE); + g_assert (gst_caps_is_fixed (caps2) == TRUE); + g_print ("%s\n", gst_caps_to_string (caps)); + g_print ("%s\n", gst_caps_to_string (caps2)); + gst_caps_free (caps); + gst_caps_free (caps2); + + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + gst_caps_append (caps, + gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 200, NULL)); + g_assert (caps != NULL); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); + g_assert (gst_caps_is_fixed (caps) == FALSE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + + caps = gst_caps_new_simple ("audio/raw", "_int", G_TYPE_INT, 100, NULL); + g_assert (caps != NULL); + gst_caps_append_structure (caps, + gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, NULL)); + g_assert (gst_caps_is_empty (caps) == FALSE); + g_assert (gst_caps_is_any (caps) == FALSE); + g_assert (GST_CAPS_IS_SIMPLE (caps) == FALSE); + g_assert (gst_caps_is_fixed (caps) == FALSE); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); } -void test2(void) +void +test2 (void) { GstCaps *caps1; GstCaps *caps2; GstCaps *caps; - caps1 = gst_caps_new_full( - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL), - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 200, NULL), - NULL); - caps2 = gst_caps_new_full( - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 100, NULL), - gst_structure_new("audio/raw", "_int", G_TYPE_INT, 300, NULL), - NULL); - caps = gst_caps_intersect(caps1, caps2); - g_print("%s\n", gst_caps_to_string(caps)); - gst_caps_free(caps); - gst_caps_free(caps1); - gst_caps_free(caps2); + caps1 = + gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, + 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 200, + NULL), NULL); + caps2 = + gst_caps_new_full (gst_structure_new ("audio/raw", "_int", G_TYPE_INT, + 100, NULL), gst_structure_new ("audio/raw", "_int", G_TYPE_INT, 300, + NULL), NULL); + caps = gst_caps_intersect (caps1, caps2); + g_print ("%s\n", gst_caps_to_string (caps)); + gst_caps_free (caps); + gst_caps_free (caps1); + gst_caps_free (caps2); } -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - gst_init(&argc, &argv); + gst_init (&argc, &argv); - test1(); - test2(); + test1 (); + test2 (); return 0; } - diff --git a/testsuite/caps/compatibility.c b/testsuite/caps/compatibility.c index 036813a81..9b24e7f7f 100644 --- a/testsuite/caps/compatibility.c +++ b/testsuite/caps/compatibility.c @@ -1,67 +1,38 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS( - "video/mpeg, " - "mpegtype=(int)[1,2]" -); - -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS( - "video/mpeg, " - "mpegtype=(int)1" -); - -GstStaticCaps rawcaps = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc){YV12,YUY2}, " - "width=(int)[16,4096], " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps2 = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc)YUY2, " - "height=(int)[16,256]" -); - -GstStaticCaps rawcaps3 = GST_STATIC_CAPS( - "video/raw, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)[1,2]"); + +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1"); + +GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, " "fourcc=(fourcc){YV12,YUY2}, " - "height=(int)[16,4096]" -); + "width=(int)[16,4096], " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc)YUY2, " "height=(int)[16,256]"); + +GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){YV12,YUY2}, " "height=(int)[16,4096]"); #if 0 /* these caps aren't used yet */ -GstStaticCaps rawcaps4 = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc){\"YV12\", \"YUYV\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps4 = GST_STATIC_CAPS( - "video/raw, " - "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, " - "height=(int)[16,4096]" -); +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YV12\", \"YUYV\"}, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUYV\", \"YUY2\"}, " "height=(int)[16,4096]"); #endif -GstStaticCaps rawcaps6 = GST_STATIC_CAPS( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YUYV\"" -); +GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\""); -GstStaticCaps rawcaps7 = GST_STATIC_CAPS( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YV12\"" -); +GstStaticCaps rawcaps7 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\""); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { gboolean testret; gint ret = 0; @@ -72,12 +43,12 @@ main (int argc, char *argv[]) gst_static_caps_get (&rawcaps)); g_print ("4 <-> 2 == %d (invalid, wrong major type)\n", testret); ret = ret + (testret == FALSE) ? 0 : 1; - + testret = gst_caps_is_always_compatible (gst_static_caps_get (&mp1parsecaps), gst_static_caps_get (&sinkcaps)); g_print ("4 <-> 1 == %d (valid, subset)\n", testret); ret = ret + (testret == TRUE) ? 0 : 1; - + testret = gst_caps_is_always_compatible (gst_static_caps_get (&sinkcaps), gst_static_caps_get (&mp1parsecaps)); g_print ("1 <-> 4 == %d (invalid, superset)\n", testret); diff --git a/testsuite/caps/fixed.c b/testsuite/caps/fixed.c index 649bdd072..e0913d2ee 100644 --- a/testsuite/caps/fixed.c +++ b/testsuite/caps/fixed.c @@ -19,22 +19,19 @@ #include -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { #if 0 GstCaps *caps; - + gst_init (&argc, &argv); - caps = GST_CAPS_NEW ( - "testcaps", - "unknown/unknown", - NULL); + caps = GST_CAPS_NEW ("testcaps", "unknown/unknown", NULL); /* newly crrated caps without props is fixed */ g_assert (GST_CAPS_IS_FIXED (caps)); - + entry = gst_props_entry_new ("foo", GST_PROPS_INT (5)); /* this entry is fixed */ g_assert (gst_props_entry_is_fixed (entry)); @@ -42,7 +39,7 @@ main (gint argc, gchar *argv[]) props = gst_props_empty_new (); /* props are fixed when created */ g_assert (GST_PROPS_IS_FIXED (props)); - + gst_props_add_entry (props, entry); /* props should still be fixed */ g_assert (GST_PROPS_IS_FIXED (props)); @@ -67,7 +64,7 @@ main (gint argc, gchar *argv[]) /* caps too */ g_assert (GST_CAPS_IS_FIXED (caps)); - gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1,5)); + gst_props_set (props, "foo", GST_PROPS_INT_RANGE (1, 5)); /* props should be variable again now */ g_assert (!GST_PROPS_IS_FIXED (props)); /* caps too */ diff --git a/testsuite/caps/intersect2.c b/testsuite/caps/intersect2.c index f5464dce7..f148b4ae1 100644 --- a/testsuite/caps/intersect2.c +++ b/testsuite/caps/intersect2.c @@ -1,49 +1,42 @@ #include -GstStaticCaps rawcaps1 = GST_STATIC_CAPS( - "video/x-raw-yuv, " +GstStaticCaps rawcaps1 = GST_STATIC_CAPS ("video/x-raw-yuv, " "fourcc:fourcc=\"YUYV\", " "height:int=640, " "width:int=480, " "framerate:float=30.0; " - "video/x-raw-yuv, " + "video/x-raw-yuv, " "fourcc:fourcc=\"I420\", " - "height:int=640, " - "width:int=480, " - "framerate:float=30.0" -); + "height:int=640, " "width:int=480, " "framerate:float=30.0"); -GstStaticCaps rawcaps2 = GST_STATIC_CAPS( - "video/x-raw-yuv" -); +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/x-raw-yuv"); -GstStaticCaps rawcaps3 = GST_STATIC_CAPS( - "video/x-raw-yuv, height=(int) [ 0, MAX ]" -); +GstStaticCaps rawcaps3 = +GST_STATIC_CAPS ("video/x-raw-yuv, height=(int) [ 0, MAX ]"); -GstStaticCaps rawcaps4 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY" -); +GstStaticCaps rawcaps4 = + GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2; video/x-raw-yuv, format=(fourcc)UYVY"); -GstStaticCaps rawcaps5 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]" -); +GstStaticCaps rawcaps5 = + GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]; video/x-raw-yuv, format=(fourcc)UYVY, framerate=(double)[0,1.79769e+308], width=(int)[0,2147483647], height=(int)[0,2147483647]"); -GstStaticCaps rawcaps6 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240" -); +GstStaticCaps rawcaps6 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"); -GstStaticCaps rawcaps7 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]" -); +GstStaticCaps rawcaps7 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[0,2147483647], height=(int)[0,2147483647], framerate=(double)[0,1.79769e+308]"); -GstStaticCaps rawcaps8 = GST_STATIC_CAPS( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240" -); +GstStaticCaps rawcaps8 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)320, height=(int)240"); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstCaps *caps1; GstCaps *caps2; @@ -53,49 +46,53 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps1)); - caps2 = gst_caps_new_full (gst_structure_copy ( gst_caps_get_structure ( - gst_static_caps_get (&rawcaps1), 0)), NULL); + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps1)); + caps2 = + gst_caps_new_full (gst_structure_copy (gst_caps_get_structure + (gst_static_caps_get (&rawcaps1), 0)), NULL); #if 0 - gst_caps_set(caps1, "height", GST_PROPS_INT(640)); - gst_caps_set(caps1, "width", GST_PROPS_INT(480)); - gst_caps_set(caps1, "framerate", GST_PROPS_FLOAT(30.0)); + gst_caps_set (caps1, "height", GST_PROPS_INT (640)); + gst_caps_set (caps1, "width", GST_PROPS_INT (480)); + gst_caps_set (caps1, "framerate", GST_PROPS_FLOAT (30.0)); #endif - caps = gst_caps_intersect(caps1, caps2); - g_print("caps %s\n", gst_caps_to_string(caps)); - if (gst_caps_is_empty (caps)) return 1; - gst_caps_free(caps1); - gst_caps_free(caps2); - - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps2)); - caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps3)); - caps = gst_caps_intersect(caps1, caps2); - g_print("caps %s\n", gst_caps_to_string(caps)); - if (gst_caps_is_empty (caps)) return 1; - gst_caps_free(caps1); - gst_caps_free(caps2); - - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps4)); - caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps5)); - caps3 = gst_caps_copy( gst_static_caps_get (&rawcaps6)); - caps4 = gst_caps_intersect(caps1, caps2); - caps = gst_caps_intersect(caps3, caps4); - g_print("caps4 %s\n", gst_caps_to_string(caps4)); - g_print("caps %s\n", gst_caps_to_string(caps)); - gst_caps_free(caps1); - gst_caps_free(caps2); - gst_caps_free(caps3); - gst_caps_free(caps4); - - caps1 = gst_caps_copy( gst_static_caps_get (&rawcaps7)); - caps2 = gst_caps_copy( gst_static_caps_get (&rawcaps8)); - caps = gst_caps_intersect(caps1, caps2); - g_print("caps %s\n", gst_caps_to_string(caps)); - if (gst_caps_is_empty (caps)) return 1; - gst_caps_free(caps1); - gst_caps_free(caps2); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); + + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps2)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps3)); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); + + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps4)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps5)); + caps3 = gst_caps_copy (gst_static_caps_get (&rawcaps6)); + caps4 = gst_caps_intersect (caps1, caps2); + caps = gst_caps_intersect (caps3, caps4); + g_print ("caps4 %s\n", gst_caps_to_string (caps4)); + g_print ("caps %s\n", gst_caps_to_string (caps)); + gst_caps_free (caps1); + gst_caps_free (caps2); + gst_caps_free (caps3); + gst_caps_free (caps4); + + caps1 = gst_caps_copy (gst_static_caps_get (&rawcaps7)); + caps2 = gst_caps_copy (gst_static_caps_get (&rawcaps8)); + caps = gst_caps_intersect (caps1, caps2); + g_print ("caps %s\n", gst_caps_to_string (caps)); + if (gst_caps_is_empty (caps)) + return 1; + gst_caps_free (caps1); + gst_caps_free (caps2); return 0; } diff --git a/testsuite/caps/intersection.c b/testsuite/caps/intersection.c index 2e369700e..381cb7d2f 100644 --- a/testsuite/caps/intersection.c +++ b/testsuite/caps/intersection.c @@ -1,77 +1,50 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1, " - "foo1=(int)[20,40], " - "foo2=(int)[20,40], " - "foo3=(int)[10,20]" -); + "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]"); -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int)1, " - "foo1=(int)30, " - "foo2=(int)[20,30], " - "foo3=(int)[20,30]" -); - - - -GstStaticCaps rawcaps = GST_STATIC_CAPS ( - "video/raw, " - "width=(int)[16,4096], " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps2 = GST_STATIC_CAPS ( - "video/raw, " - "height=(int)[16,256], " - "depth=(int)16" -); - -GstStaticCaps rawcaps3 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YUY2\", \"YV12\" }, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps4 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps5 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps rawcaps6 = GST_STATIC_CAPS ( - "video/raw, " + "foo1=(int)30, " "foo2=(int)[20,30], " "foo3=(int)[20,30]"); + + + +GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, " + "width=(int)[16,4096], " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, " + "height=(int)[16,256], " "depth=(int)16"); + +GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUY2\", \"YV12\" }, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUY2\",\"YV12\",\"YUYV\" }, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps5 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YUYV\",\"YUY2\"}, " "height=(int)[16,4096]"); + +GstStaticCaps rawcaps6 = GST_STATIC_CAPS ("video/raw, " "fourcc=(fourcc)\"YUYV\", " "height=(int)640, " "width=(int)480, " "framerate=(double)30.0; " - "video/raw, " + "video/raw, " "fourcc=(fourcc)\"I420\", " - "height=(int)640, " - "width=(int)480, " - "framerate=(double)30.0" -); + "height=(int)640, " "width=(int)480, " "framerate=(double)30.0"); -GstStaticCaps rawcaps7 = GST_STATIC_CAPS ( - "video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]" -); +GstStaticCaps rawcaps7 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc)YUY2, width=(int)[1,2147483647], height=(int)[1,2147483647], framerate=(double)[0,1.79769e+308]"); -GstStaticCaps rawcaps8 = GST_STATIC_CAPS ( - "video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]" -); +GstStaticCaps rawcaps8 = +GST_STATIC_CAPS + ("video/x-raw-yuv, format=(fourcc){ I420, YV12, YUY2 }, width=(int)[16,4096], height=(int)[16,4096], framerate=(double)[0,1.79769e+308]"); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { xmlDocPtr doc; xmlNodePtr parent; @@ -83,13 +56,13 @@ main (int argc, char *argv[]) doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL); /* - g_mem_chunk_info (); - for (i = 0; i<100000; i++) { - caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4)); - gst_caps_unref (caps); - } - g_mem_chunk_info (); - */ + g_mem_chunk_info (); + for (i = 0; i<100000; i++) { + caps = gst_caps_intersect (gst_static_caps_get (rawcaps3), GST_CAPS_GET (rawcaps4)); + gst_caps_unref (caps); + } + g_mem_chunk_info (); + */ caps = gst_caps_intersect (gst_static_caps_get (&sinkcaps), gst_static_caps_get (&mp1parsecaps)); @@ -112,16 +85,16 @@ main (int argc, char *argv[]) gst_caps_save_thyself (caps, parent); caps = gst_caps_intersect (gst_static_caps_get (&rawcaps6), - gst_caps_new_full (gst_structure_copy ( - gst_caps_get_structure (gst_static_caps_get (&rawcaps6), 0)), NULL)); + gst_caps_new_full (gst_structure_copy (gst_caps_get_structure + (gst_static_caps_get (&rawcaps6), 0)), NULL)); parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities5", NULL); gst_caps_save_thyself (caps, parent); caps = gst_caps_intersect (gst_static_caps_get (&rawcaps7), gst_static_caps_get (&rawcaps8)); - g_print("intersection: %s\n", gst_caps_to_string (caps)); + g_print ("intersection: %s\n", gst_caps_to_string (caps)); - xmlDocDump(stdout, doc); + xmlDocDump (stdout, doc); return 0; } diff --git a/testsuite/caps/normalisation.c b/testsuite/caps/normalisation.c index 89344fa3e..4d1eae395 100644 --- a/testsuite/caps/normalisation.c +++ b/testsuite/caps/normalisation.c @@ -1,56 +1,32 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "foo1=(int)[20,40], " - "foo2=(int)[20,40], " - "foo3=(int)[10,20]" -); + "foo1=(int)[20,40], " "foo2=(int)[20,40], " "foo3=(int)[10,20]"); -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ( - "video/mpeg, " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "foo4=(fourcc){\"YV12\",\"YUY2\"}" -); +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " + "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "foo4=(fourcc){\"YV12\",\"YUY2\"}"); -GstStaticCaps rawcaps = GST_STATIC_CAPS ( - "video/raw, " +GstStaticCaps rawcaps = GST_STATIC_CAPS ("video/raw, " "width=(int)[16,4096], " - "height=(int)[16,4096], " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}" -); + "height=(int)[16,4096], " "fourcc=(fourcc){\"YV12\",\"YUY2\"}"); -GstStaticCaps rawcaps2 = GST_STATIC_CAPS ( - "video/raw, " - "width=(int)[16,256], " - "height=(int)16; " - "video/raw, " +GstStaticCaps rawcaps2 = GST_STATIC_CAPS ("video/raw, " "width=(int)[16,256], " - "height=(int)16" -); + "height=(int)16; " "video/raw, " "width=(int)[16,256], " "height=(int)16"); -GstStaticCaps rawcaps3 = GST_STATIC_CAPS ( - "video/raw, " +GstStaticCaps rawcaps3 = GST_STATIC_CAPS ("video/raw, " "width=(int)[16,256], " "height=(int)16; " - "video/raw, " + "video/raw, " "width=(int)[16,256], " "height=(int)16; " - "video/raw, " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "height=(int)[16,4096]" -); + "video/raw, " + "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]"); -GstStaticCaps rawcaps4 = GST_STATIC_CAPS ( - "x, " - "y=(int){1,2}, " - "z=(int){3,4}; " - "a, " - "b=(int){5,6}, " - "c=(int){7,8}" -); +GstStaticCaps rawcaps4 = GST_STATIC_CAPS ("x, " + "y=(int){1,2}, " "z=(int){3,4}; " "a, " "b=(int){5,6}, " "c=(int){7,8}"); /* defined, not used GST_CAPS_FACTORY (rawcaps4, @@ -79,8 +55,8 @@ GST_CAPS_FACTORY (rawcaps5, ); */ -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { GstCaps *caps; diff --git a/testsuite/caps/string-conversions.c b/testsuite/caps/string-conversions.c index 8e9e7d648..c37298dc7 100644 --- a/testsuite/caps/string-conversions.c +++ b/testsuite/caps/string-conversions.c @@ -1,60 +1,31 @@ #include #include -GstStaticCaps caps1 = GST_STATIC_CAPS ( - "video/mpeg, " - "mpegtype=(int){1,2}" -); - -GstStaticCaps caps2 = GST_STATIC_CAPS ( - "video/mpeg, " - "mpegtype=(int){1}" -); - -GstStaticCaps caps3 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "width=(int)[16,4096], " - "height=(int)[16,4096]" -); - -GstStaticCaps caps4 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc)\"YV12\", " - "height=(int)[16,256]" -); - -GstStaticCaps caps5 = GST_STATIC_CAPS ( - "video/raw, " +GstStaticCaps caps1 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1,2}"); + +GstStaticCaps caps2 = GST_STATIC_CAPS ("video/mpeg, " "mpegtype=(int){1}"); + +GstStaticCaps caps3 = GST_STATIC_CAPS ("video/raw, " "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps caps6 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YV12\",\"YUYV\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps caps7 = GST_STATIC_CAPS ( - "video/raw, " - "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, " - "height=(int)[16,4096]" -); - -GstStaticCaps caps8 = GST_STATIC_CAPS ( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YUYV\"" -); - -GstStaticCaps caps9 = GST_STATIC_CAPS ( - "video/raw, " - "format=(fourcc)\"I420\"; " - "video/raw, " - "format=(fourcc)\"YV12\"" -); + "width=(int)[16,4096], " "height=(int)[16,4096]"); + +GstStaticCaps caps4 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc)\"YV12\", " "height=(int)[16,256]"); + +GstStaticCaps caps5 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YV12\",\"YUY2\"}, " "height=(int)[16,4096]"); + +GstStaticCaps caps6 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YV12\",\"YUYV\"}, " "height=(int)[16,4096]"); + +GstStaticCaps caps7 = GST_STATIC_CAPS ("video/raw, " + "fourcc=(fourcc){\"YVYV\",\"YUY2\"}, " "height=(int)[16,4096]"); + +GstStaticCaps caps8 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YUYV\""); + +GstStaticCaps caps9 = GST_STATIC_CAPS ("video/raw, " + "format=(fourcc)\"I420\"; " "video/raw, " "format=(fourcc)\"YV12\""); static gint test = 0; static gint failures = 0; @@ -70,9 +41,9 @@ static gint failures = 0; } \ }G_STMT_END static void -test_caps_func (const GstCaps *caps) +test_caps_func (const GstCaps * caps) { - gchar *str1, *str2; + gchar *str1, *str2; gboolean ret = FALSE; str1 = gst_caps_to_string (caps); @@ -90,13 +61,13 @@ test_caps_func (const GstCaps *caps) TEST_END (ret); } static void -test_caps (const GstCaps *caps) +test_caps (const GstCaps * caps) { TEST_START; test_caps_func (caps); } static void -test_string (gchar *str) +test_string (gchar * str) { GstCaps *caps; @@ -111,21 +82,22 @@ test_string (gchar *str) test_caps_func (caps); } static void -test_string_fail (gchar *str) +test_string_fail (gchar * str) { GstCaps *caps; TEST_START; g_print ("%3d, INFO : checking %s for failure\n", test, str); caps = gst_caps_from_string (str); -g_print("got %p\n", caps); + g_print ("got %p\n", caps); TEST_END (caps == NULL); } -int -main (int argc, char *argv[]) + +int +main (int argc, char *argv[]) { gst_init (&argc, &argv); -goto bla; + goto bla; bla: /* stupidity tests */ test_caps (gst_caps_new_simple ("audio/raw", NULL)); @@ -176,23 +148,29 @@ bla: test_string ("audio/raw, test=(double) [1.3, (double)2.1 ]"); test_string ("audio/raw, test =(i) [(int)1,2]"); test_string ("audio/raw, test={(int)1,2}"); - test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}"); + test_string + ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}"); test_string ("audio/raw, test= {1.0}"); test_string ("audio/raw, test= {\"hi\", \"i dig ya\", dude}"); test_string ("audio/raw, test= {(int)1,2}"); test_string ("audio/raw, test= {(int)1,2}"); - + /* prop concatenations */ test_string ("audio/raw, test=(double) [1.3, (double)2.1 ], test2= [ 1, 2 ]"); test_string ("audio/raw , test=(fourcc) \"RGB \",test2=(int)1"); - test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \""); + test_string + ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \""); test_string ("audio/raw, test= [1.3, 2.1 ] , test2= {1.0}"); - test_string ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1"); + test_string + ("audio/raw, test= {(int)1 ,2,3 ,(int) 4 , 5 ,6 , (int )7 ,8 , (int ) 9, 10}, test2 = [1.0, 2.5 ] , test3= (string)1 ,test4=(i)1"); /* caps concatenations */ - test_string ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\""); - test_string ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}"); - test_string ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]"); + test_string + ("audio/raw, test= [(int ) 1, 2 ] ,test2 =(fourcc) \"RGB \";\"audio/raw\""); + test_string + ("audio/raw, test =(double ) [1,2] ; audio/raw, test=(fourcc )1 ;audio/raw, test= {\"hi\", \"i dig ya\", dude}"); + test_string + ("audio/raw, test=(double) [1.3, (double)2.1 ];audio/raw, test =(i) [(int)1,2]"); /* mimes */ @@ -210,9 +188,9 @@ bla: test_string_fail ("audio/raw, test= '"); if (failures) { - g_print ("\n FAILURES : %d\n", failures); + g_print ("\n FAILURES : %d\n", failures); } else { - g_print ("\n DONE\n"); + g_print ("\n DONE\n"); } return failures; } diff --git a/testsuite/caps/union.c b/testsuite/caps/union.c index 557cda4d0..b229bd75a 100644 --- a/testsuite/caps/union.c +++ b/testsuite/caps/union.c @@ -1,24 +1,15 @@ #include /* these caps all have a non empty intersection */ -GstStaticCaps sinkcaps = GST_STATIC_CAPS ( - "video/mpeg, " +GstStaticCaps sinkcaps = GST_STATIC_CAPS ("video/mpeg, " "mpegtype:int=1, " - "foo1:int=[20,40], " - "foo2:int=[20,40], " - "foo3:int=[10,20]" -); + "foo1:int=[20,40], " "foo2:int=[20,40], " "foo3:int=[10,20]"); -GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ( - "video/mpeg, " - "mpegtype:int=1, " - "foo1:int=30, " - "foo2:int=[20,30], " - "foo3:int=[20,30]" -); +GstStaticCaps mp1parsecaps = GST_STATIC_CAPS ("video/mpeg, " + "mpegtype:int=1, " "foo1:int=30, " "foo2:int=[20,30], " "foo3:int=[20,30]"); -int -main (int argc, char *argv[]) +int +main (int argc, char *argv[]) { xmlDocPtr doc; xmlNodePtr parent; @@ -34,7 +25,7 @@ main (int argc, char *argv[]) parent = xmlNewChild (doc->xmlRootNode, NULL, "Capabilities1", NULL); gst_caps_save_thyself (caps, parent); - xmlDocDump(stdout, doc); + xmlDocDump (stdout, doc); return 0; } diff --git a/testsuite/caps/value_compare.c b/testsuite/caps/value_compare.c index 852de5197..646e333f5 100644 --- a/testsuite/caps/value_compare.c +++ b/testsuite/caps/value_compare.c @@ -2,63 +2,63 @@ #include #include -void test1(void) +void +test1 (void) { GValue value1 = { 0 }; GValue value2 = { 0 }; //GValue value3 = { 0 }; //gboolean ret; - g_value_init(&value1, G_TYPE_INT); - g_value_set_int(&value1, 10); - g_value_init(&value2, G_TYPE_INT); - g_value_set_int(&value2, 20); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN); - g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, G_TYPE_INT); + g_value_set_int (&value1, 10); + g_value_init (&value2, G_TYPE_INT); + g_value_set_int (&value2, 20); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN); + g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); - g_value_init(&value1, G_TYPE_DOUBLE); - g_value_set_double(&value1, 10); - g_value_init(&value2, G_TYPE_DOUBLE); - g_value_set_double(&value2, 20); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN); - g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, G_TYPE_DOUBLE); + g_value_set_double (&value1, 10); + g_value_init (&value2, G_TYPE_DOUBLE); + g_value_set_double (&value2, 20); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN); + g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); - g_value_init(&value1, G_TYPE_STRING); - g_value_set_string(&value1, "a"); - g_value_init(&value2, G_TYPE_STRING); - g_value_set_string(&value2, "b"); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_LESS_THAN); - g_assert(gst_value_compare(&value2, &value1) == GST_VALUE_GREATER_THAN); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, G_TYPE_STRING); + g_value_set_string (&value1, "a"); + g_value_init (&value2, G_TYPE_STRING); + g_value_set_string (&value2, "b"); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_LESS_THAN); + g_assert (gst_value_compare (&value2, &value1) == GST_VALUE_GREATER_THAN); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); - g_value_init(&value1, GST_TYPE_FOURCC); - gst_value_set_fourcc(&value1, GST_MAKE_FOURCC('a','b','c','d')); - g_value_init(&value2, GST_TYPE_FOURCC); - gst_value_set_fourcc(&value2, GST_MAKE_FOURCC('1','2','3','4')); - g_assert(gst_value_compare(&value1, &value2) == GST_VALUE_UNORDERED); - g_assert(gst_value_compare(&value1, &value1) == GST_VALUE_EQUAL); - g_value_unset(&value1); - g_value_unset(&value2); + g_value_init (&value1, GST_TYPE_FOURCC); + gst_value_set_fourcc (&value1, GST_MAKE_FOURCC ('a', 'b', 'c', 'd')); + g_value_init (&value2, GST_TYPE_FOURCC); + gst_value_set_fourcc (&value2, GST_MAKE_FOURCC ('1', '2', '3', '4')); + g_assert (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED); + g_assert (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); } -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - gst_init(&argc, &argv); + gst_init (&argc, &argv); - test1(); + test1 (); return 0; } - - diff --git a/testsuite/caps/value_intersect.c b/testsuite/caps/value_intersect.c index 94ad6797e..aebd448e4 100644 --- a/testsuite/caps/value_intersect.c +++ b/testsuite/caps/value_intersect.c @@ -1,23 +1,25 @@ #include -void test1(void) +void +test1 (void) { GValue dest = { 0 }; GValue src1 = { 0 }; GValue src2 = { 0 }; gboolean ret; - g_value_init(&src1, G_TYPE_INT); - g_value_set_int(&src1, 10); - g_value_init(&src2, G_TYPE_INT); - g_value_set_int(&src1, 20); - ret = gst_value_intersect(&dest, &src1, &src2); - g_assert(ret == 0); - g_print("ret = %d\n",ret); + g_value_init (&src1, G_TYPE_INT); + g_value_set_int (&src1, 10); + g_value_init (&src2, G_TYPE_INT); + g_value_set_int (&src1, 20); + ret = gst_value_intersect (&dest, &src1, &src2); + g_assert (ret == 0); + g_print ("ret = %d\n", ret); } -void test2(void) +void +test2 (void) { GValue dest = { 0 }; GValue src1 = { 0 }; @@ -25,33 +27,32 @@ void test2(void) GValue item = { 0 }; gboolean ret; - g_value_init(&src1, GST_TYPE_FOURCC); - gst_value_set_fourcc(&src1, GST_MAKE_FOURCC('Y','U','Y','2')); - g_value_init(&src2, GST_TYPE_LIST); - g_value_init(&item, GST_TYPE_FOURCC); - gst_value_set_fourcc(&item, GST_MAKE_FOURCC('Y','U','Y','2')); + g_value_init (&src1, GST_TYPE_FOURCC); + gst_value_set_fourcc (&src1, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2')); + g_value_init (&src2, GST_TYPE_LIST); + g_value_init (&item, GST_TYPE_FOURCC); + gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2')); gst_value_list_append_value (&src2, &item); - gst_value_set_fourcc(&item, GST_MAKE_FOURCC('I','4','2','0')); + gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('I', '4', '2', '0')); gst_value_list_append_value (&src2, &item); - gst_value_set_fourcc(&item, GST_MAKE_FOURCC('A','B','C','D')); + gst_value_set_fourcc (&item, GST_MAKE_FOURCC ('A', 'B', 'C', 'D')); gst_value_list_append_value (&src2, &item); - ret = gst_value_intersect(&dest, &src1, &src2); - g_print("ret = %d\n",ret); + ret = gst_value_intersect (&dest, &src1, &src2); + g_print ("ret = %d\n", ret); - g_print("type = %s\n", g_type_name(G_VALUE_TYPE(&dest))); - g_print("value = %s\n", g_strdup_value_contents(&dest)); + g_print ("type = %s\n", g_type_name (G_VALUE_TYPE (&dest))); + g_print ("value = %s\n", g_strdup_value_contents (&dest)); } -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - gst_init(&argc, &argv); + gst_init (&argc, &argv); - test1(); - test2(); + test1 (); + test2 (); return 0; } - - diff --git a/testsuite/cleanup/cleanup1.c b/testsuite/cleanup/cleanup1.c index 00064ac8d..ac8ffd876 100644 --- a/testsuite/cleanup/cleanup1.c +++ b/testsuite/cleanup/cleanup1.c @@ -6,7 +6,7 @@ create_pipeline (void) GstElement *fakesrc, *fakesink; GstElement *pipeline; - + pipeline = gst_pipeline_new ("main_pipeline"); fakesrc = gst_element_factory_make ("fakesrc", "fakesrc"); @@ -22,13 +22,13 @@ create_pipeline (void) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; gint i = 1000; gint step = 100; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -37,7 +37,7 @@ main (gint argc, gchar *argv[]) if (i % step == 0) fprintf (stderr, "%10d\r", i); pipeline = create_pipeline (); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/testsuite/cleanup/cleanup2.c b/testsuite/cleanup/cleanup2.c index 91f0f5afa..53fcba77a 100644 --- a/testsuite/cleanup/cleanup2.c +++ b/testsuite/cleanup/cleanup2.c @@ -13,7 +13,8 @@ create_pipeline (void) bin = gst_bin_new ("bin"); fakesink = gst_element_factory_make ("fakesink", "fakesink"); gst_bin_add (GST_BIN (bin), fakesink); - gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"), "sink"); + gst_element_add_ghost_pad (bin, gst_element_get_pad (fakesink, "sink"), + "sink"); gst_element_link (fakesrc, bin); @@ -25,13 +26,13 @@ create_pipeline (void) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; gint i = 1000; gint step = 100; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -41,7 +42,7 @@ main (gint argc, gchar *argv[]) if (i % step == 0) fprintf (stderr, "%10d\r", i); pipeline = create_pipeline (); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/testsuite/cleanup/cleanup3.c b/testsuite/cleanup/cleanup3.c index cdd102a00..c2a35fe38 100644 --- a/testsuite/cleanup/cleanup3.c +++ b/testsuite/cleanup/cleanup3.c @@ -15,8 +15,9 @@ create_pipeline (void) queue = gst_element_factory_make ("queue", "queue"); gst_bin_add (GST_BIN (thread), fakesink); gst_bin_add (GST_BIN (thread), queue); - gst_element_link (queue, fakesink); - gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), "sink"); + gst_element_link (queue, fakesink); + gst_element_add_ghost_pad (thread, gst_element_get_pad (queue, "sink"), + "sink"); gst_element_link (fakesrc, thread); @@ -29,13 +30,13 @@ create_pipeline (void) } gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; gint i = 10000; gint step = 100; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -45,7 +46,7 @@ main (gint argc, gchar *argv[]) if (i % step == 0) fprintf (stderr, "%10d\r", i); pipeline = create_pipeline (); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/testsuite/cleanup/cleanup4.c b/testsuite/cleanup/cleanup4.c index 236407215..ba56a1b24 100644 --- a/testsuite/cleanup/cleanup4.c +++ b/testsuite/cleanup/cleanup4.c @@ -1,13 +1,13 @@ #include gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *fakesrc; gint i; - free (malloc(8)); /* -lefence */ + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -34,7 +34,7 @@ main (gint argc, gchar *argv[]) gst_bin_add (GST_BIN (bin), fakesink); gst_bin_add (GST_BIN (pipeline), bin); - + gst_element_set_state (pipeline, GST_STATE_PLAYING); while (gst_bin_iterate (GST_BIN (pipeline))); diff --git a/testsuite/cleanup/cleanup5.c b/testsuite/cleanup/cleanup5.c index e2a1b61f4..a3187b8bc 100644 --- a/testsuite/cleanup/cleanup5.c +++ b/testsuite/cleanup/cleanup5.c @@ -1,13 +1,14 @@ #include -int main(int argc,char *argv[]) +int +main (int argc, char *argv[]) { GstElement *bin, *element; gint i = 1000; gint step = 100; - - free (malloc(8)); /* -lefence */ + + free (malloc (8)); /* -lefence */ gst_init (&argc, &argv); @@ -15,15 +16,14 @@ int main(int argc,char *argv[]) bin = gst_pipeline_new ("pipeline"); - while (i--) - { + while (i--) { GstPad *pad; if (i % step == 0) fprintf (stderr, "\r%10d", i); element = gst_element_factory_make ("tee", "tee"); - if (!element) + if (!element) break; pad = gst_element_get_request_pad (element, "src%d"); diff --git a/testsuite/clock/clock1.c b/testsuite/clock/clock1.c index f7865d810..33cf8c440 100644 --- a/testsuite/clock/clock1.c +++ b/testsuite/clock/clock1.c @@ -8,12 +8,12 @@ #include void -gst_clock_debug (GstClock *clock) +gst_clock_debug (GstClock * clock) { - g_print ("Clock info: time %"G_GUINT64_FORMAT"\n", - gst_clock_get_time (clock)); + g_print ("Clock info: time %" G_GUINT64_FORMAT "\n", + gst_clock_get_time (clock)); } - + int main (int argc, char *argv[]) { @@ -22,24 +22,20 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL) - { + if ((src = gst_element_factory_make ("fakesrc", "source")) == NULL) { g_print ("Could not create a fakesrc element !\n"); return 1; } - if ((id = gst_element_factory_make ("identity", "filter")) == NULL) - { + if ((id = gst_element_factory_make ("identity", "filter")) == NULL) { g_print ("Could not create a identity element !\n"); return 1; } - if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL) - { + if ((sink = gst_element_factory_make ("fakesink", "sink")) == NULL) { g_print ("Could not create a fakesink element !\n"); return 1; } - if ((pipeline = gst_pipeline_new ("pipeline")) == NULL) - { + if ((pipeline = gst_pipeline_new ("pipeline")) == NULL) { g_print ("Could not create a pipeline element !\n"); return 1; } diff --git a/testsuite/clock/clock2.c b/testsuite/clock/clock2.c index be369103b..303b9c20f 100644 --- a/testsuite/clock/clock2.c +++ b/testsuite/clock/clock2.c @@ -8,12 +8,13 @@ #include void -gst_clock_debug (GstClock *clock, GstElement *fakesink) +gst_clock_debug (GstClock * clock, GstElement * fakesink) { - g_print ("Clock info: time %"G_GUINT64_FORMAT" - Element info: time %"G_GUINT64_FORMAT"\n", - gst_clock_get_time (clock), gst_element_get_time (fakesink)); + g_print ("Clock info: time %" G_GUINT64_FORMAT " - Element info: time %" + G_GUINT64_FORMAT "\n", gst_clock_get_time (clock), + gst_element_get_time (fakesink)); } - + int main (int argc, char *argv[]) { @@ -35,14 +36,14 @@ main (int argc, char *argv[]) gst_bin_add_many (GST_BIN (pipeline), fakesink, fakesrc, NULL); gst_element_link (fakesrc, fakesink); gst_element_set_state (pipeline, GST_STATE_PLAYING); - + gst_clock_debug (clock, fakesink); g_usleep (G_USEC_PER_SEC); gst_clock_debug (clock, fakesink); gst_element_wait (fakesink, 2 * GST_SECOND); gst_clock_debug (clock, fakesink); - + gst_element_wait (fakesink, 5 * GST_SECOND); gst_clock_debug (clock, fakesink); diff --git a/testsuite/debug/category.c b/testsuite/debug/category.c index 07b3fd8d3..edc43227b 100644 --- a/testsuite/debug/category.c +++ b/testsuite/debug/category.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -25,46 +25,56 @@ GST_DEBUG_CATEGORY (cat); #define GST_CAT_DEFAULT cat GST_DEBUG_CATEGORY_STATIC (cat_static); -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GSList *before, *after; unsetenv ("GST_DEBUG"); gst_init (&argc, &argv); - + before = gst_debug_get_all_categories (); - GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, "default category for this test"); - GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static", - GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED, - "static category for this test"); + GST_DEBUG_CATEGORY_INIT (cat, "cat", GST_DEBUG_FG_GREEN, + "default category for this test"); + GST_DEBUG_CATEGORY_INIT (cat_static, "cat_static", + GST_DEBUG_BOLD | GST_DEBUG_FG_BLUE | GST_DEBUG_BG_RED, + "static category for this test"); after = gst_debug_get_all_categories (); g_print ("removing default log function\n"); g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); - g_print ("checking, if the two new categories are put into the category list correctly...\n"); + g_print + ("checking, if the two new categories are put into the category list correctly...\n"); g_assert (g_slist_length (after) - g_slist_length (before) == 2); /* check the _get stuff */ - g_print ("checking, if the gst_debug_category_get_* stuff works with the categories...\n"); + g_print + ("checking, if the gst_debug_category_get_* stuff works with the categories...\n"); g_assert (strcmp (gst_debug_category_get_name (cat), "cat") == 0); g_assert (gst_debug_category_get_color (cat) == GST_DEBUG_FG_GREEN); - g_assert (strcmp (gst_debug_category_get_description (cat), "default category for this test") == 0); - g_assert (gst_debug_category_get_threshold (cat) == gst_debug_get_default_threshold()); - g_assert (strcmp (gst_debug_category_get_name (cat_static), "cat_static") == 0); + g_assert (strcmp (gst_debug_category_get_description (cat), + "default category for this test") == 0); + g_assert (gst_debug_category_get_threshold (cat) == + gst_debug_get_default_threshold ()); + g_assert (strcmp (gst_debug_category_get_name (cat_static), + "cat_static") == 0); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_FG_GREEN); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BG_RED); g_assert (gst_debug_category_get_color (cat_static) | GST_DEBUG_BOLD); - g_assert (strcmp (gst_debug_category_get_description (cat_static), "static category for this test") == 0); - g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold()); + g_assert (strcmp (gst_debug_category_get_description (cat_static), + "static category for this test") == 0); + g_assert (gst_debug_category_get_threshold (cat_static) == + gst_debug_get_default_threshold ()); /* check if setting levels for names work */ - g_print ("checking if changing threshold for names affects existing categories...\n"); + g_print + ("checking if changing threshold for names affects existing categories...\n"); gst_debug_set_threshold_for_name ("cat", GST_LEVEL_DEBUG); - g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); - g_assert (gst_debug_category_get_threshold (cat_static) == gst_debug_get_default_threshold()); + g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); + g_assert (gst_debug_category_get_threshold (cat_static) == + gst_debug_get_default_threshold ()); gst_debug_set_threshold_for_name ("cat_static", GST_LEVEL_INFO); g_assert (gst_debug_category_get_threshold (cat) == GST_LEVEL_DEBUG); g_assert (gst_debug_category_get_threshold (cat_static) == GST_LEVEL_INFO); - + g_print ("everything ok.\n"); return 0; } diff --git a/testsuite/debug/commandline.c b/testsuite/debug/commandline.c index 57d2173f0..1dfb38e3e 100644 --- a/testsuite/debug/commandline.c +++ b/testsuite/debug/commandline.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -26,46 +26,49 @@ GST_DEBUG_CATEGORY (cat); GST_DEBUG_CATEGORY_STATIC (cat_static); -static const gchar* lines[] = { +static const gchar *lines[] = { "--gst-debug-disable", "--gst-debug-no-color", "--gst-debug-level=4", "--gst-debug=cat:4,cat_*:3", - "--gst-debug-level=4 --gst-debug=cat_*:5" + "--gst-debug-level=4 --gst-debug=cat_*:5" }; static void -debug_not_reached (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, GstDebugMessage *message, - gpointer thread) +debug_not_reached (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + GstDebugMessage * message, gpointer thread) { g_assert_not_reached (); } -gint -main (gint argc, gchar *argv[]) + +gint +main (gint argc, gchar * argv[]) { if (argc == 1) { /* this is the main run that calls the others */ gint i, runs, exit; gchar *command; - + unsetenv ("GST_DEBUG"); gst_init (&argc, &argv); runs = G_N_ELEMENTS (lines); for (i = 0; i < runs; i++) { command = g_strdup_printf ("%s %s %d", argv[0], lines[i], i); g_print ("running \"%s\"\n", command); - g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit, NULL) == TRUE); + g_assert (g_spawn_command_line_sync (command, NULL, NULL, &exit, + NULL) == TRUE); g_assert (exit == 0); g_print ("\"%s\" worked as expected.\n", command); g_free (command); } - + return 0; } else { gst_init (&argc, &argv); if (argc != 2) { - g_print ("something funny happened to the command line arguments, aborting.\n"); + g_print + ("something funny happened to the command line arguments, aborting.\n"); return 1; } gst_debug_remove_log_function (gst_debug_log_default); @@ -78,7 +81,7 @@ main (gint argc, gchar *argv[]) GST_ERROR ("This will not be seen"); return 0; case '1': - return gst_debug_is_colored () ? 1 : 0; + return gst_debug_is_colored ()? 1 : 0; case '2': g_assert (gst_debug_get_default_threshold () == 4); g_assert (gst_debug_category_get_threshold (cat) == 4); @@ -98,5 +101,5 @@ main (gint argc, gchar *argv[]) return -1; } } - g_assert_not_reached (); + g_assert_not_reached (); } diff --git a/testsuite/debug/global.c b/testsuite/debug/global.c index f878706c9..2a397ab8e 100644 --- a/testsuite/debug/global.c +++ b/testsuite/debug/global.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -28,33 +28,30 @@ #define ITERATIONS 20 /* stupid logging functions */ -static void gst_debug_log_one (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - gchar * message, - gpointer thread) G_GNUC_NO_INSTRUMENT; -static void gst_debug_log_two (GstDebugCategory * category, - GstDebugLevel level, - const gchar * file, - const gchar * function, - gint line, - GObject * object, - gchar * message, - gpointer thread) G_GNUC_NO_INSTRUMENT; - static void -gst_debug_log_one (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, gchar *message, - gpointer thread) +gst_debug_log_one (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, GObject * object, gchar * message, gpointer thread) + G_GNUC_NO_INSTRUMENT; + static void gst_debug_log_two (GstDebugCategory * category, + GstDebugLevel level, + const gchar * file, + const gchar * function, + gint line, + GObject * object, gchar * message, gpointer thread) G_GNUC_NO_INSTRUMENT; + + static void + gst_debug_log_one (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + gchar * message, gpointer thread) { } static void -gst_debug_log_two (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, gchar *message, - gpointer thread) +gst_debug_log_two (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + gchar * message, gpointer thread) { } @@ -69,23 +66,24 @@ thread_main (gpointer threadnum) g_print ("iteration %d of thread %d starting\n", i, num); /* do some stuff with global settings */ gst_debug_set_default_threshold (GST_LEVEL_DEBUG); - gst_debug_add_log_function (gst_debug_log_one, g_thread_self()); + gst_debug_add_log_function (gst_debug_log_one, g_thread_self ()); gst_debug_add_log_function (gst_debug_log_two, NULL); /* reset all the stuff we did */ gst_debug_set_default_threshold (GST_LEVEL_DEFAULT); - g_assert (gst_debug_remove_log_function_by_data (g_thread_self()) == 1); + g_assert (gst_debug_remove_log_function_by_data (g_thread_self ()) == 1); } - + g_print ("Thread %d is done.\n", num); return threadnum; } -gint -main (gint argc, gchar *argv[]) + +gint +main (gint argc, gchar * argv[]) { gint i; GThread *threads[THREAD_COUNT]; - + g_print ("initializing GStreamer\n"); gst_init (&argc, &argv); g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); @@ -93,10 +91,11 @@ main (gint argc, gchar *argv[]) /* some checks for defaults */ g_print ("Doing startup checks\n"); g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT); - + g_print ("creating %d threads\n", THREAD_COUNT); for (i = 0; i < THREAD_COUNT; i++) { - g_assert ((threads[i] = g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL))); + g_assert ((threads[i] = + g_thread_create (thread_main, GINT_TO_POINTER (i), TRUE, NULL))); } g_print ("joining %d threads\n", THREAD_COUNT); for (i = 0; i < THREAD_COUNT; i++) { @@ -106,7 +105,8 @@ main (gint argc, gchar *argv[]) /* some checks if everything worked */ g_print ("Doing shutdown checks\n"); g_assert (gst_debug_get_default_threshold () == GST_LEVEL_DEFAULT); - g_assert (gst_debug_remove_log_function (gst_debug_log_two) == THREAD_COUNT * ITERATIONS); - + g_assert (gst_debug_remove_log_function (gst_debug_log_two) == + THREAD_COUNT * ITERATIONS); + return 0; } diff --git a/testsuite/debug/output.c b/testsuite/debug/output.c index d0ef4e5b2..50ca66839 100644 --- a/testsuite/debug/output.c +++ b/testsuite/debug/output.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include GST_DEBUG_CATEGORY_STATIC (cat_default); @@ -28,17 +28,18 @@ static gint count = -1; static GstElement *pipeline; static void -check_message (GstDebugCategory *category, GstDebugLevel level, const gchar *file, - const gchar *function, gint line, GObject *object, GstDebugMessage *message, - gpointer unused) +check_message (GstDebugCategory * category, GstDebugLevel level, + const gchar * file, const gchar * function, gint line, GObject * object, + GstDebugMessage * message, gpointer unused) { gint temp; - + /* these checks require count to be set right. So the order in the main funtion is actually important. */ /* <0 means no checks */ - if (count < 0) return; - + if (count < 0) + return; + g_print ("expecting \"%s\"...", (gchar *) message); /* level */ temp = (count % 5) + 1; @@ -52,17 +53,19 @@ check_message (GstDebugCategory *category, GstDebugLevel level, const gchar *fil g_print ("[OK]\n"); } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); - - GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0, "default category for this test"); - GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0, "second category for this test"); + + GST_DEBUG_CATEGORY_INIT (cat_default, "GST_Check_default", 0, + "default category for this test"); + GST_DEBUG_CATEGORY_INIT (cat2, "GST_Check_2", 0, + "second category for this test"); g_assert (gst_debug_remove_log_function (gst_debug_log_default) == 1); - gst_debug_add_log_function (check_message, NULL); - + gst_debug_add_log_function (check_message, NULL); + count = 0; GST_ERROR ("This is an error."); ++count; @@ -96,18 +99,23 @@ main (gint argc, gchar *argv[]) ++count; GST_LOG_OBJECT (pipeline, "This is a log message with object."); ++count; - GST_CAT_ERROR_OBJECT (cat2, pipeline, "This is an error with category and object."); + GST_CAT_ERROR_OBJECT (cat2, pipeline, + "This is an error with category and object."); ++count; - GST_CAT_WARNING_OBJECT (cat2, pipeline, "This is a warning with category and object."); + GST_CAT_WARNING_OBJECT (cat2, pipeline, + "This is a warning with category and object."); ++count; - GST_CAT_INFO_OBJECT (cat2, pipeline, "This is an info message with category and object."); + GST_CAT_INFO_OBJECT (cat2, pipeline, + "This is an info message with category and object."); ++count; - GST_CAT_DEBUG_OBJECT (cat2, pipeline, "This is a debug message with category and object."); + GST_CAT_DEBUG_OBJECT (cat2, pipeline, + "This is a debug message with category and object."); ++count; - GST_CAT_LOG_OBJECT (cat2, pipeline, "This is a log message with category and object."); + GST_CAT_LOG_OBJECT (cat2, pipeline, + "This is a log message with category and object."); count = -1; - g_assert (gst_debug_remove_log_function (check_message) == 1); - + g_assert (gst_debug_remove_log_function (check_message) == 1); + return 0; } diff --git a/testsuite/debug/printf_extension.c b/testsuite/debug/printf_extension.c index 883268701..8cdfcccd2 100644 --- a/testsuite/debug/printf_extension.c +++ b/testsuite/debug/printf_extension.c @@ -15,18 +15,18 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstCaps *caps; GstElement *element; int zero = 0; gst_init (&argc, &argv); - + caps = gst_caps_from_string ("audio/x-raw-int, rate=44100"); element = gst_element_factory_make ("identity", NULL); @@ -36,6 +36,6 @@ main (gint argc, gchar *argv[]) GST_ERROR ("This should print null: %" GST_PTR_FORMAT, NULL); GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, &zero); //GST_ERROR ("This should print a pointer: %" GST_PTR_FORMAT, (void *)1); - + return 0; } diff --git a/testsuite/dynparams/dparamstest.c b/testsuite/dynparams/dparamstest.c index db05eb2cd..0a73f4c50 100644 --- a/testsuite/dynparams/dparamstest.c +++ b/testsuite/dynparams/dparamstest.c @@ -45,7 +45,7 @@ struct _GstDpTest GstPad *sinkpad; GstPad *srcpad; GstDParamManager *dpman; - + gfloat float1; gfloat float2; gboolean bool1; @@ -65,15 +65,15 @@ enum }; -static void gst_dptest_base_init (gpointer g_class); -static void gst_dptest_class_init (GstDpTestClass * klass); -static void gst_dptest_init (GstDpTest * dptest); +static void gst_dptest_base_init (gpointer g_class); +static void gst_dptest_class_init (GstDpTestClass * klass); +static void gst_dptest_init (GstDpTest * dptest); -static void gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, - GParamSpec * pspec); +static void gst_dptest_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); -static GstElementStateReturn gst_dptest_change_state (GstElement *element); -static void gst_dptest_chain (GstPad *pad, GstData *buf); +static GstElementStateReturn gst_dptest_change_state (GstElement * element); +static void gst_dptest_chain (GstPad * pad, GstData * buf); static GstElementClass *parent_class = NULL; @@ -95,7 +95,8 @@ gst_dptest_get_type (void) (GInstanceInitFunc) gst_dptest_init, }; - dptest_type = g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0); + dptest_type = + g_type_register_static (GST_TYPE_ELEMENT, "GstDpTest", &dptest_info, 0); } return dptest_type; } @@ -103,17 +104,15 @@ gst_dptest_get_type (void) static void gst_dptest_base_init (gpointer g_class) { - static GstElementDetails dptest_details = GST_ELEMENT_DETAILS ( - "DParamTest", - "Filter", - "Test for the GstDParam code", - "Steve Baker " - ); + static GstElementDetails dptest_details = GST_ELEMENT_DETAILS ("DParamTest", + "Filter", + "Test for the GstDParam code", + "Steve Baker "); GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_set_details (element_class, &dptest_details); - g_print("got here %d\n",__LINE__); + g_print ("got here %d\n", __LINE__); } static void @@ -123,7 +122,7 @@ gst_dptest_class_init (GstDpTestClass * klass) GstElementClass *gstelement_class; gobject_class = (GObjectClass *) klass; - gstelement_class = (GstElementClass*)klass; + gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); @@ -139,26 +138,24 @@ gst_dptest_init (GstDpTest * dptest) dptest->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (dptest), dptest->sinkpad); - gst_pad_set_chain_function(dptest->sinkpad, gst_dptest_chain); + gst_pad_set_chain_function (dptest->sinkpad, gst_dptest_chain); dptest->srcpad = gst_pad_new ("src", GST_PAD_SRC); gst_element_add_pad (GST_ELEMENT (dptest), dptest->srcpad); - dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT(dptest)); + dptest->dpman = gst_dpman_new ("dptest_dpman", GST_ELEMENT (dptest)); + + gst_dpman_add_required_dparam_direct (dptest->dpman, + g_param_spec_float ("float1", "float1", "float1", + 0.0, 1.0, 0.5, G_PARAM_READWRITE), "float", &(dptest->float1) + ); - gst_dpman_add_required_dparam_direct ( - dptest->dpman, - g_param_spec_float("float1","float1","float1", - 0.0, 1.0, 0.5, G_PARAM_READWRITE), - "float", - &(dptest->float1) - ); - dptest->float1 = 0.0; } static void -gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) +gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) { GstDpTest *dptest; @@ -175,39 +172,39 @@ gst_dptest_set_property (GObject * object, guint prop_id, const GValue * value, } static GstElementStateReturn -gst_dptest_change_state (GstElement *element) +gst_dptest_change_state (GstElement * element) { GstDpTest *dptest; g_return_val_if_fail (GST_IS_DPTEST (element), GST_STATE_FAILURE); - g_print("changing state\n"); + g_print ("changing state\n"); dptest = GST_DPTEST (element); if (GST_ELEMENT_CLASS (parent_class)->change_state) return GST_ELEMENT_CLASS (parent_class)->change_state (element); - + return GST_STATE_SUCCESS; } -static void -gst_dptest_chain (GstPad *pad, GstData *data) +static void +gst_dptest_chain (GstPad * pad, GstData * data) { GstDpTest *dptest; gint frame_countdown; - dptest = GST_DPTEST(gst_pad_get_parent (pad)); - g_assert(dptest); + dptest = GST_DPTEST (gst_pad_get_parent (pad)); + g_assert (dptest); /* we're using a made up buffer size of 64 and a timestamp of zero */ - frame_countdown = GST_DPMAN_PREPROCESS(dptest->dpman, 64, 0LL); - - while(GST_DPMAN_PROCESS(dptest->dpman, frame_countdown)); - - g_print("dp chain\n"); + frame_countdown = GST_DPMAN_PREPROCESS (dptest->dpman, 64, 0LL); + + while (GST_DPMAN_PROCESS (dptest->dpman, frame_countdown)); + + g_print ("dp chain\n"); } gboolean -gst_dptest_register_elements (GstPlugin *plugin) +gst_dptest_register_elements (GstPlugin * plugin) { return gst_element_register (plugin, "dptest", GST_RANK_NONE, GST_TYPE_DPTEST); @@ -226,7 +223,9 @@ static GstPluginDesc plugin_desc = { GST_ORIGIN }; -int main(int argc,char *argv[]) { +int +main (int argc, char *argv[]) +{ GstElement *src; GstElement *sink; @@ -235,11 +234,11 @@ int main(int argc,char *argv[]) { GstDParamManager *dpman; GstDParam *dp_float1; GValue *dp_float1_value; - - alarm(10); + + alarm (10); gst_init (&argc, &argv); - gst_control_init(&argc,&argv); + gst_control_init (&argc, &argv); _gst_plugin_register_static (&plugin_desc); @@ -262,51 +261,51 @@ int main(int argc,char *argv[]) { gst_bin_add (GST_BIN (pipeline), testelement); gst_bin_add (GST_BIN (pipeline), sink); - g_print("playing pipeline\n"); - - g_object_set (G_OBJECT (src), "num_buffers", 1, NULL); + g_print ("playing pipeline\n"); + + g_object_set (G_OBJECT (src), "num_buffers", 1, NULL); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); /* test that dparam manager is accessable */ - g_print("getting dparam manager\n"); + g_print ("getting dparam manager\n"); dpman = gst_dpman_get_manager (testelement); - gst_dpman_set_mode(dpman, "synchronous"); - - g_assert(dpman); - g_assert(GST_IS_DPMAN (dpman)); - - g_print("creating dparam for float1\n"); - dp_float1 = gst_dparam_new(G_TYPE_FLOAT);; - g_assert(dp_float1); - g_assert(GST_IS_DPARAM (dp_float1)); - - g_print("attach dparam to float1\n"); - g_assert(gst_dpman_attach_dparam (dpman, "float1", dp_float1)); - - dp_float1_value = g_new0(GValue,1); - g_value_init(dp_float1_value, G_TYPE_FLOAT); - - g_value_set_float(dp_float1_value, 0.1); - g_object_set_property(G_OBJECT(dp_float1), "value_float", dp_float1_value); - - g_print("iterate once\n"); + gst_dpman_set_mode (dpman, "synchronous"); + + g_assert (dpman); + g_assert (GST_IS_DPMAN (dpman)); + + g_print ("creating dparam for float1\n"); + dp_float1 = gst_dparam_new (G_TYPE_FLOAT);; + g_assert (dp_float1); + g_assert (GST_IS_DPARAM (dp_float1)); + + g_print ("attach dparam to float1\n"); + g_assert (gst_dpman_attach_dparam (dpman, "float1", dp_float1)); + + dp_float1_value = g_new0 (GValue, 1); + g_value_init (dp_float1_value, G_TYPE_FLOAT); + + g_value_set_float (dp_float1_value, 0.1); + g_object_set_property (G_OBJECT (dp_float1), "value_float", dp_float1_value); + + g_print ("iterate once\n"); gst_bin_iterate (GST_BIN (pipeline)); - g_print("check that value changed\n"); - g_assert(GST_DPTEST(testelement)->float1 == 0.1F); - g_assert(!GST_DPARAM_READY_FOR_UPDATE(dp_float1)); - - g_print("nulling pipeline\n"); + g_print ("check that value changed\n"); + g_assert (GST_DPTEST (testelement)->float1 == 0.1F); + g_assert (!GST_DPARAM_READY_FOR_UPDATE (dp_float1)); + + g_print ("nulling pipeline\n"); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); - g_print("playing pipeline\n"); + g_print ("playing pipeline\n"); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - g_print("iterate twice\n"); + g_print ("iterate twice\n"); g_object_set (G_OBJECT (src), "num_buffers", 2, NULL); gst_bin_iterate (GST_BIN (pipeline)); - + return 0; } diff --git a/testsuite/elements/fake.c b/testsuite/elements/fake.c index dcf3504b7..14406b210 100644 --- a/testsuite/elements/fake.c +++ b/testsuite/elements/fake.c @@ -19,12 +19,10 @@ element_create (char *name, char *element) GstElement *el = NULL; el = (GstElement *) gst_element_factory_make (element, name); - if (el == NULL) - { + if (el == NULL) { fprintf (stderr, "Could not create element %s (%s) !\n", name, element); return NULL; - } - else + } else return el; } @@ -43,12 +41,15 @@ main (int argc, char *argv[]) pipeline = gst_pipeline_new ("pipeline"); g_print ("Connecting signals to pipeline\n"); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (property_change_callback), NULL); g_print ("Creating elements\n"); - if (!(src = element_create ("src", "fakesrc"))) return 1; + if (!(src = element_create ("src", "fakesrc"))) + return 1; g_object_set (G_OBJECT (src), "sizetype", 2, NULL); - if (!(sink = element_create ("sink", "fakesink"))) return 1; - + if (!(sink = element_create ("sink", "fakesink"))) + return 1; + /* add */ g_print ("Adding elements to bin\n"); gst_bin_add (GST_BIN (pipeline), src); @@ -59,22 +60,21 @@ main (int argc, char *argv[]) gst_element_set_state (pipeline, GST_STATE_PLAYING); /* we expect this to give an error */ - if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) - { - g_warning ("Iterating a bin with unlinked elements should return FALSE !\n"); + if (gst_bin_iterate (GST_BIN (pipeline)) != FALSE) { + g_warning + ("Iterating a bin with unlinked elements should return FALSE !\n"); retval = 1; } gst_pad_link (gst_element_get_pad (src, "src"), - gst_element_get_pad (sink, "sink")); + gst_element_get_pad (sink, "sink")); /* set to play */ g_print ("Doing 1 iteration\n"); gst_element_set_state (pipeline, GST_STATE_PLAYING); /* we expect this to work */ - if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) - { + if (gst_bin_iterate (GST_BIN (pipeline)) != TRUE) { g_error ("Iterating a bin with linked elements should return TRUE !\n"); retval = 1; } @@ -82,4 +82,3 @@ main (int argc, char *argv[]) g_print ("Done !\n"); return retval; } - diff --git a/testsuite/elements/name.c b/testsuite/elements/name.c index a9a0fa4ca..ff0d184cf 100644 --- a/testsuite/elements/name.c +++ b/testsuite/elements/name.c @@ -15,16 +15,14 @@ main (int argc, char *argv[]) /* init */ gst_init (&argc, &argv); - for (i = 0; i < 50; ++i) - { + for (i = 0; i < 50; ++i) { /* create element */ element = gst_element_factory_make ("identity", NULL); g_assert (GST_IS_ELEMENT (element)); g_assert (gst_element_get_name (element) != NULL); - g_print ("Created identity element with name %s\n", - gst_element_get_name (element)); + g_print ("Created identity element with name %s\n", + gst_element_get_name (element)); } g_print ("Done !\n"); return 0; } - diff --git a/testsuite/elements/property.c b/testsuite/elements/property.c index 2e461dde8..835df3d3e 100644 --- a/testsuite/elements/property.c +++ b/testsuite/elements/property.c @@ -22,12 +22,10 @@ element_create (char *name, char *element) GstElement *el = NULL; el = (GstElement *) gst_element_factory_make (element, name); - if (el == NULL) - { + if (el == NULL) { fprintf (stderr, "Could not create element %s (%s) !\n", name, element); return NULL; - } - else + } else return el; } @@ -45,54 +43,41 @@ main (int argc, char *argv[]) /* create */ g_print ("Creating element\n"); - if (!(src = element_create ("src", "fakesrc"))) return 1; - + if (!(src = element_create ("src", "fakesrc"))) + return 1; + /* set */ silent_set = TRUE; sizemin_set = 1; name_set = g_strdup_printf ("test"); - gst_element_set (src, - "name", name_set, - "sizemin", sizemin_set, - "silent", silent_set, - NULL); + gst_element_set (src, + "name", name_set, "sizemin", sizemin_set, "silent", silent_set, NULL); /* get */ gst_element_get (src, - "name", &name_get, - "sizemin", &sizemin_get, - "silent", &silent_get, - NULL); + "name", &name_get, "sizemin", &sizemin_get, "silent", &silent_get, NULL); /* compare */ - if (sizemin_set != sizemin_get) - { + if (sizemin_set != sizemin_get) { g_print ("sizemin: set value %d differs from returned value %d\n", - sizemin_set, sizemin_get); + sizemin_set, sizemin_get); retval = 1; - } - else + } else g_print ("name: set right\n"); - if (silent_set != silent_get) - { + if (silent_set != silent_get) { g_print ("silent: set value %s differs from returned value %s\n", - silent_set ? "TRUE" : "FALSE", - silent_get ? "TRUE" : "FALSE"); + silent_set ? "TRUE" : "FALSE", silent_get ? "TRUE" : "FALSE"); retval = 1; - } - else + } else g_print ("silent: set right\n"); - - if (strcmp (name_set, name_get) != 0) - { + + if (strcmp (name_set, name_get) != 0) { g_print ("name: set value %s differs from returned value %s\n", - name_set, name_get); + name_set, name_get); retval = 1; - } - else + } else g_print ("name: set right\n"); return retval; } - diff --git a/testsuite/elements/property.h b/testsuite/elements/property.h index a1756f1ca..873b2cc27 100644 --- a/testsuite/elements/property.h +++ b/testsuite/elements/property.h @@ -1,12 +1,13 @@ /* extracted from gst-launch */ static void -property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) +property_change_callback (GObject * object, GstObject * orig, + GParamSpec * pspec) { - GValue value = { 0, }; /* the important thing is that value.type = 0 */ + GValue value = { 0, }; /* the important thing is that value.type = 0 */ gchar *str = 0; if (pspec->flags & G_PARAM_READABLE) { - g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (pspec)); g_object_get_property (G_OBJECT (orig), pspec->name, &value); /* fix current bug with g_strdup_value_contents not working with gint64 */ if (G_IS_PARAM_SPEC_INT64 (pspec)) @@ -15,9 +16,8 @@ property_change_callback (GObject *object, GstObject *orig, GParamSpec *pspec) str = g_strdup_value_contents (&value); g_print ("%s: %s = %s\n", GST_OBJECT_NAME (orig), pspec->name, str); g_free (str); - g_value_unset(&value); + g_value_unset (&value); } else { g_warning ("Parameter not readable. What's up with that?"); } } - diff --git a/testsuite/elements/tee.c b/testsuite/elements/tee.c index 2badd3ea8..9f4a528e6 100644 --- a/testsuite/elements/tee.c +++ b/testsuite/elements/tee.c @@ -27,12 +27,10 @@ element_create (char *name, char *element) GstElement *el = NULL; el = (GstElement *) gst_element_factory_make (element, name); - if (el == NULL) - { + if (el == NULL) { fprintf (stderr, "Could not create element %s (%s) !\n", name, element); return NULL; - } - else + } else return el; } @@ -42,6 +40,7 @@ main (int argc, char *argv[]) GstElement *pipeline = NULL; GstElement *tee, *src, *sink1, *sink2; GstPad *tee_src1, *tee_src2; + #if 0 GstCaps *src_caps = NULL; GstCaps *sink_caps = NULL; @@ -57,15 +56,20 @@ main (int argc, char *argv[]) pipeline = gst_pipeline_new ("pipeline"); g_print ("Connecting signals to pipeline\n"); - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (property_change_callback), NULL); - + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (property_change_callback), NULL); + g_print ("Creating elements\n"); - if (!(tee = element_create ("tee", "tee"))) return 1; - if (!(src = element_create ("src", "fakesrc"))) return 1; + if (!(tee = element_create ("tee", "tee"))) + return 1; + if (!(src = element_create ("src", "fakesrc"))) + return 1; g_object_set (G_OBJECT (src), "sizetype", 2, NULL); - if (!(sink1 = element_create ("sink1", "fakesink"))) return 1; - if (!(sink2 = element_create ("sink2", "fakesink"))) return 1; - + if (!(sink1 = element_create ("sink1", "fakesink"))) + return 1; + if (!(sink2 = element_create ("sink2", "fakesink"))) + return 1; + /* add */ g_print ("Adding elements to bin\n"); gst_bin_add (GST_BIN (pipeline), src); @@ -74,8 +78,8 @@ main (int argc, char *argv[]) /* link input part */ g_print ("Linking input elements\n"); gst_pad_link (gst_element_get_pad (src, "src"), - gst_element_get_pad (tee, "sink")); - + gst_element_get_pad (tee, "sink")); + /* request one pad from tee */ g_print ("Requesting first pad\n"); tee_src1 = gst_element_get_request_pad (tee, "src%d"); @@ -93,7 +97,7 @@ main (int argc, char *argv[]) tee_src2 = gst_element_get_request_pad (tee, "src%d"); gst_bin_add (GST_BIN (pipeline), sink2); gst_pad_link (tee_src2, gst_element_get_pad (sink2, "sink")); - + /* now we have two fakesinks linked, iterate */ g_print ("Doing 1 iteration\n"); gst_element_set_state (pipeline, GST_STATE_PLAYING); @@ -118,30 +122,32 @@ main (int argc, char *argv[]) sink_caps = gst_pad_get_caps (gst_element_get_pad (sink1, "sink")); if (sink_caps && gst_caps_is_fixed (sink_caps)) { structure = gst_caps_get_structure (sink_caps, 0); - }else { + } else { structure = NULL; g_print ("sink_caps is not fixed\n"); } if (structure == NULL || !(gst_structure_has_field (structure, "rate"))) { - g_print ("Hm, rate has not been propagated to sink1.\n"); + g_print ("Hm, rate has not been propagated to sink1.\n"); return 1; } else { int rate; + gst_structure_get_int (structure, "rate", &rate); g_print ("Rate of pad on sink1 : %d\n", rate); } sink_caps = gst_pad_get_caps (gst_element_get_pad (sink2, "sink")); structure = gst_caps_get_structure (sink_caps, 0); - if (structure != NULL && ! (gst_structure_has_field (structure, "rate"))) { - g_print ("Hm, rate has not been propagated to sink2.\n"); + if (structure != NULL && !(gst_structure_has_field (structure, "rate"))) { + g_print ("Hm, rate has not been propagated to sink2.\n"); return 1; } else { int rate; + gst_structure_get_int (structure, "rate", &rate); g_print ("Rate of pad on sink2 : %d\n", rate); } #endif - + /* remove the first one, iterate */ g_print ("Removing first sink\n"); gst_element_set_state (pipeline, GST_STATE_PAUSED); @@ -158,7 +164,7 @@ main (int argc, char *argv[]) gst_element_set_state (pipeline, GST_STATE_PAUSED); /* in 0.3.2 the next statement gives an assert error */ tee_src1 = gst_element_get_request_pad (tee, "src%d"); - + gst_element_set_state (pipeline, GST_STATE_NULL); g_print ("Done !\n"); diff --git a/testsuite/ghostpads/ghostpads.c b/testsuite/ghostpads/ghostpads.c index 4050326df..7d87782c6 100644 --- a/testsuite/ghostpads/ghostpads.c +++ b/testsuite/ghostpads/ghostpads.c @@ -20,11 +20,11 @@ #include gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline, *bin; GstElement *fakesrc, *fakesink, *identity; - GstPad *sink, *src, *real = (GstPad*)0xdeadbeef; + GstPad *sink, *src, *real = (GstPad *) 0xdeadbeef; gst_init (&argc, &argv); @@ -33,32 +33,30 @@ main (gint argc, gchar *argv[]) fakesrc = gst_element_factory_make ("fakesrc", NULL); fakesink = gst_element_factory_make ("fakesink", NULL); identity = gst_element_factory_make ("identity", NULL); - + gst_bin_add_many (GST_BIN (pipeline), fakesrc, bin, fakesink, NULL); gst_bin_add (GST_BIN (bin), identity); - + sink = gst_element_add_ghost_pad (bin, - gst_element_get_pad (identity, "sink"), - "sink"); + gst_element_get_pad (identity, "sink"), "sink"); src = gst_element_add_ghost_pad (bin, - gst_element_get_pad (identity, "src"), - "src"); + gst_element_get_pad (identity, "src"), "src"); gst_element_link_many (fakesrc, bin, fakesink, NULL); gst_element_set_state (pipeline, GST_STATE_PLAYING); - + if (!gst_bin_iterate (GST_BIN (pipeline))) g_assert_not_reached (); - + gst_element_set_state (pipeline, GST_STATE_NULL); /* test the cleanup */ gst_object_ref (GST_OBJECT (sink)); - gst_object_unref ((GstObject*)pipeline); + gst_object_unref ((GstObject *) pipeline); g_object_get (sink, "real-pad", &real, NULL); g_assert (real == NULL); g_assert (G_OBJECT (sink)->ref_count == 1); gst_object_unref (GST_OBJECT (sink)); - + return 0; } diff --git a/testsuite/indexers/cache1.c b/testsuite/indexers/cache1.c index 0392a196c..ed2bb4d1d 100644 --- a/testsuite/indexers/cache1.c +++ b/testsuite/indexers/cache1.c @@ -20,70 +20,71 @@ #include static void -lookup (GstIndex *index, GstIndexLookupMethod method, - GstFormat src_format, gint64 src_value, - GstFormat dest_format, gint64 expecting) +lookup (GstIndex * index, GstIndexLookupMethod method, + GstFormat src_format, gint64 src_value, + GstFormat dest_format, gint64 expecting) { GstIndexEntry *entry; gint64 result; entry = gst_index_get_assoc_entry (index, 0, method, 0, - src_format, src_value); + src_format, src_value); if (entry) { - gst_index_entry_assoc_map (entry, dest_format, &result); + gst_index_entry_assoc_map (entry, dest_format, &result); if (result == expecting) { g_print ("OK (%lld)\n", result); } else { g_print ("FAIL - expecting %lld, got %lld\n", expecting, result); } - } - else { + } else { const GstFormatDefinition *def = gst_format_get_details (src_format); - - if (expecting == -1) + + if (expecting == -1) g_print ("OK (not found)\n"); else g_print ("FAIL - no index entry found for %lld %s, expecting %lld\n", - src_value, def->nick, expecting); + src_value, def->nick, expecting); } } typedef struct _GstIndexTestCase { - GstIndexLookupMethod method; - GstFormat src_format; - gint64 src_value; - GstFormat dest_format; - gint64 expecting; + GstIndexLookupMethod method; + GstFormat src_format; + gint64 src_value; + GstFormat dest_format; + gint64 expecting; } GstIndexTestCase; -const static GstIndexTestCase cases[] = -{ - { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000 }, - { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5 }, - { GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1 }, - { GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, 99999 }, - { GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1 }, +const static GstIndexTestCase cases[] = { + {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_BYTES, 3, GST_FORMAT_TIME, 3000}, + {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5000, GST_FORMAT_BYTES, 5}, + {GST_INDEX_LOOKUP_EXACT, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, -1}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 5}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 5010, GST_FORMAT_BYTES, 6}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, 0, GST_FORMAT_BYTES, 0}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, -1, GST_FORMAT_BYTES, -1}, + {GST_INDEX_LOOKUP_BEFORE, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, + 99999}, + {GST_INDEX_LOOKUP_AFTER, GST_FORMAT_TIME, G_MAXINT64, GST_FORMAT_BYTES, -1}, }; -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstIndex *index; GstElement *element; gint i, id; - + gst_init (&argc, &argv); - if (argc != 2) - { g_print ("usage: cache1 (memindex | fileindex)\n"); exit (0); } + if (argc != 2) { + g_print ("usage: cache1 (memindex | fileindex)\n"); + exit (0); + } index = gst_index_factory_make (argv[1]); g_assert (index != NULL); @@ -96,15 +97,16 @@ main (gint argc, gchar *argv[]) g_print ("Building index...\n"); for (i = 0; i < 100000; i++) { - gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64)i, GST_FORMAT_TIME, - (gint64) (i * 1000), 0); + gst_index_add_association (index, 0, 0, GST_FORMAT_BYTES, (gint64) i, + GST_FORMAT_TIME, (gint64) (i * 1000), 0); } g_print ("Testing index...\n"); for (i = 0; i < (sizeof (cases) / sizeof (GstIndexTestCase)); i++) { - lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, cases[i].dest_format, cases[i].expecting); + lookup (index, cases[i].method, cases[i].src_format, cases[i].src_value, + cases[i].dest_format, cases[i].expecting); } - + return 0; } diff --git a/testsuite/indexers/indexdump.c b/testsuite/indexers/indexdump.c index e528e4afe..d2f168a8f 100644 --- a/testsuite/indexers/indexdump.c +++ b/testsuite/indexers/indexdump.c @@ -20,18 +20,20 @@ #include static void -my_resolver (GstIndex *index, GstObject *_ign, gchar **writer_string, - gpointer user_data) -{ *writer_string = user_data; } +my_resolver (GstIndex * index, GstObject * _ign, gchar ** writer_string, + gpointer user_data) +{ + *writer_string = user_data; +} -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstIndex *index; GstObject *identity; gint id; gint64 cur; - + gst_init (&argc, &argv); if (argc != 3) { @@ -45,29 +47,30 @@ main (gint argc, gchar *argv[]) g_object_set (index, "location", argv[1], NULL); gst_index_set_resolver (index, (GstIndexResolver) my_resolver, argv[2]); - identity = (GstObject*) gst_element_factory_make ("identity", "element"); + identity = (GstObject *) gst_element_factory_make ("identity", "element"); g_assert (identity); gst_index_get_writer_id (index, identity, &id); - + cur = 0; while (1) { gint fx; GstIndexEntry *entry = - gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0, - GST_FORMAT_TIME, cur); + gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0, + GST_FORMAT_TIME, cur); + if (!entry) break; g_print ("%x", GST_INDEX_ASSOC_FLAGS (entry)); - for (fx=0; fx < GST_INDEX_NASSOCS (entry); fx++) { + for (fx = 0; fx < GST_INDEX_NASSOCS (entry); fx++) { GstFormat fmt = GST_INDEX_ASSOC_FORMAT (entry, fx); - const GstFormatDefinition* def = gst_format_get_details (fmt); + const GstFormatDefinition *def = gst_format_get_details (fmt); + if (fmt == GST_FORMAT_TIME) { cur = GST_INDEX_ASSOC_VALUE (entry, fx) + 1; g_print (" time %.4f", - GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND); - } - else + GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND); + } else g_print (" %s %lld", def->nick, GST_INDEX_ASSOC_VALUE (entry, fx)); } g_print ("\n"); diff --git a/testsuite/parse/parse1.c b/testsuite/parse/parse1.c index debf5ff0d..8bfc50bac 100644 --- a/testsuite/parse/parse1.c +++ b/testsuite/parse/parse1.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -57,7 +57,7 @@ static gchar *s; gst_object_unref (GST_OBJECT (cur)); \ cur = NULL; \ g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \ -}G_STMT_END +}G_STMT_END #define TEST_RUN G_STMT_START{ \ alarm(10); \ g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \ @@ -73,7 +73,7 @@ static gchar *s; } \ g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \ alarm(0); \ -}G_STMT_END +}G_STMT_END #define PIPELINE1 "fakesrc" #define PIPELINE2 "fakesrc name=donald num-buffers= 27 silent =TruE sizetype = 3 eos = yesyo data= Subbuffer\\ data" #define PIPELINE3 "fakesrc identity fakesink" @@ -87,8 +87,8 @@ static gchar *s; #define PIPELINE11 "fakesink name = sink identity name=id ( fakesrc num-buffers=\"4\" ! id. ) id. ! sink." -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); @@ -108,7 +108,8 @@ main (gint argc, gchar *argv[]) * - first test of escaping strings */ TEST_START (PIPELINE2); - g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, NULL); + g_object_get (G_OBJECT (cur), "name", &s, "num-buffers", &i, "silent", &b, + NULL); TEST_CHECK_FAIL (strcmp (s, "donald") == 0); TEST_CHECK_FAIL (i == 27); TEST_CHECK_FAIL (b == TRUE); @@ -125,7 +126,7 @@ main (gint argc, gchar *argv[]) * - if multiple toplevel elements exist, a pipeline is returned */ TEST_START (PIPELINE3); - TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */ + TEST_CHECK_FAIL (GST_BIN (cur)->numchildren == 3); /* a bit hacky here */ TEST_CHECK_FAIL (GST_IS_PIPELINE (cur)); TEST_OK; @@ -161,7 +162,7 @@ main (gint argc, gchar *argv[]) TEST_CHECK_FAIL (strcmp (s, "john") == 0); TEST_RUN; TEST_OK; - + /** * checks: * - test request pads @@ -169,7 +170,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE7); TEST_RUN; TEST_OK; - + /** * checks: * - multiple pads on 1 link @@ -177,7 +178,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE8); TEST_RUN; TEST_OK; - + /** * checks: * - failed in grammar.y cvs version 1.17 @@ -185,7 +186,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE9); TEST_RUN; TEST_OK; - + /** * checks: * - failed in grammar.y cvs version 1.17 @@ -193,7 +194,7 @@ main (gint argc, gchar *argv[]) TEST_START (PIPELINE10); TEST_RUN; TEST_OK; - + /** * checks: * - failed in grammar.y cvs version 1.18 diff --git a/testsuite/parse/parse2.c b/testsuite/parse/parse2.c index 647b3bc78..db8184f49 100644 --- a/testsuite/parse/parse2.c +++ b/testsuite/parse/parse2.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -88,7 +88,7 @@ static char *video_file = NULL; gst_object_unref (GST_OBJECT (cur)); \ cur = NULL; \ g_print ("TEST %2d line %3d COMPLETE\n", test, __LINE__); \ -}G_STMT_END +}G_STMT_END #define TEST_RUN(iters) G_STMT_START{ \ gint it = iters; \ g_print ("TEST %2d line %3d RUN\n", test, __LINE__); \ @@ -106,7 +106,7 @@ static char *video_file = NULL; return -test; \ } \ g_print ("TEST %2d line %3d STOPPED : %u iterations\n", test, __LINE__, iterations); \ -}G_STMT_END +}G_STMT_END #define TEST_FINISH G_STMT_START{ \ g_print("\n"); \ g_print("To run this test there are things required that you do not have. (see above)\n"); \ @@ -114,7 +114,7 @@ static char *video_file = NULL; g_print("Currently the following tests will be ignored.\n"); \ g_print("\n"); \ exit (0); \ -}G_STMT_END +}G_STMT_END #define TEST_REQUIRE(condition, error) G_STMT_START{ \ if (condition) { \ g_print ("REQUIRE line %3d OK\n", __LINE__); \ @@ -122,7 +122,7 @@ static char *video_file = NULL; g_print ("REQUIRE line %3d EXIT : %s\n", __LINE__, (error)); \ TEST_FINISH; \ } \ -}G_STMT_END +}G_STMT_END #define TEST_REQUIRE_ELEMENT(element_name) G_STMT_START{ \ GstElement *element = gst_element_factory_make ((element_name), NULL); \ if (element) { \ @@ -132,7 +132,7 @@ static char *video_file = NULL; g_print ("REQUIRE line %3d EXIT : No element of type \"%s\" available. Exiting.\n", __LINE__, (element_name)); \ TEST_FINISH; \ } \ -}G_STMT_END +}G_STMT_END #define PIPELINE1 "filesrc blocksize =8192 location=%s ! mad ! osssink" #define PIPELINE2 "filesrc location=%s ! mpegdemux ! mpeg2dec ! xvideosink" @@ -144,12 +144,12 @@ static char *video_file = NULL; #define PIPELINE3 "filesrc location=%s ! mpegdemux name = demux ! mpeg2dec ! { queue ! xvideosink } demux.audio_%%02d ! mad ! osssink" */ -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { gst_init (&argc, &argv); -goto here; + goto here; here: /** @@ -158,7 +158,8 @@ here: * - unsigned parameters */ audio_file = g_build_filename (g_get_home_dir (), "music.mp3", NULL); - TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mp3 file music.mp3 in your home directory."); + TEST_REQUIRE (g_file_test (audio_file, G_FILE_TEST_EXISTS), + "The following tests requires a valid mp3 file music.mp3 in your home directory."); TEST_REQUIRE_ELEMENT ("mad"); TEST_REQUIRE_ELEMENT ("osssink"); TEST_START (PIPELINE1, audio_file); @@ -171,7 +172,8 @@ here: * - SOMETIMES pads */ video_file = g_build_filename (g_get_home_dir (), "video.mpeg", NULL); - TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), "The following tests requires a valid mpeg file video.mpeg in your home directory."); + TEST_REQUIRE (g_file_test (video_file, G_FILE_TEST_EXISTS), + "The following tests requires a valid mpeg file video.mpeg in your home directory."); TEST_REQUIRE_ELEMENT ("mpegdemux"); TEST_REQUIRE_ELEMENT ("mpeg2dec"); TEST_REQUIRE_ELEMENT ("xvideosink"); diff --git a/testsuite/plugin/dynamic.c b/testsuite/plugin/dynamic.c index 07c376d6b..2c6c19208 100644 --- a/testsuite/plugin/dynamic.c +++ b/testsuite/plugin/dynamic.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,14 +11,13 @@ main (int argc, char *argv[]) plugin = gst_plugin_load_file (".libs/libtestplugin.so", &error); g_assert (plugin != NULL); - if (error) - { + if (error) { g_print ("ERROR loading plug-in: %s\n", error->message); g_free (error); return 1; } - g_print ("testplugin: %s\n", gst_plugin_get_name(plugin)); + g_print ("testplugin: %s\n", gst_plugin_get_name (plugin)); return 0; } diff --git a/testsuite/plugin/linked.c b/testsuite/plugin/linked.c index 24e7d9ebc..368d3415c 100644 --- a/testsuite/plugin/linked.c +++ b/testsuite/plugin/linked.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,12 +11,12 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin)); plugin = gst_registry_pool_find_plugin ("testplugin2"); g_assert (plugin != NULL); - g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin)); return 0; } diff --git a/testsuite/plugin/loading.c b/testsuite/plugin/loading.c index 0ed5a9cef..11d34a298 100644 --- a/testsuite/plugin/loading.c +++ b/testsuite/plugin/loading.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -17,12 +17,14 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin))); + g_print ("%d features in plugin\n", + g_list_length (gst_plugin_get_feature_list (plugin))); - g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false")); - - loaded = gst_plugin_load (gst_plugin_get_name(plugin)); + g_print ("testplugin: %p loaded: %s\n", plugin, + (gst_plugin_is_loaded (plugin) ? "true" : "false")); + + loaded = gst_plugin_load (gst_plugin_get_name (plugin)); g_assert (loaded == TRUE); numplugins = g_list_length (gst_registry_pool_plugin_list ()); @@ -32,23 +34,27 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false")); + g_print ("testplugin: %p loaded: %s\n", plugin, + (gst_plugin_is_loaded (plugin) ? "true" : "false")); - g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin))); + g_print ("%d features in plugin\n", + g_list_length (gst_plugin_get_feature_list (plugin))); - loaded = gst_plugin_load (gst_plugin_get_name(plugin)); + loaded = gst_plugin_load (gst_plugin_get_name (plugin)); g_assert (loaded == TRUE); numplugins = g_list_length (gst_registry_pool_plugin_list ()); g_print ("%d plugins loaded\n", numplugins); - g_print ("%d features in plugin\n", g_list_length (gst_plugin_get_feature_list (plugin))); + g_print ("%d features in plugin\n", + g_list_length (gst_plugin_get_feature_list (plugin))); g_mem_chunk_info (); plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p loaded: %s\n", plugin, (gst_plugin_is_loaded (plugin) ? "true": "false")); + g_print ("testplugin: %p loaded: %s\n", plugin, + (gst_plugin_is_loaded (plugin) ? "true" : "false")); return 0; } diff --git a/testsuite/plugin/registry.c b/testsuite/plugin/registry.c index 95fb56a7c..85a76e2f8 100644 --- a/testsuite/plugin/registry.c +++ b/testsuite/plugin/registry.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,7 +11,7 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %s\n", gst_plugin_get_name(plugin)); + g_print ("testplugin: %s\n", gst_plugin_get_name (plugin)); return 0; } diff --git a/testsuite/plugin/static.c b/testsuite/plugin/static.c index 9aab9d1af..368d3415c 100644 --- a/testsuite/plugin/static.c +++ b/testsuite/plugin/static.c @@ -1,7 +1,7 @@ #include -int +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -11,13 +11,12 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin)); plugin = gst_registry_pool_find_plugin ("testplugin2"); g_assert (plugin != NULL); - g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin)); return 0; } - diff --git a/testsuite/plugin/static2.c b/testsuite/plugin/static2.c index a19551b4a..1ab30d0f3 100644 --- a/testsuite/plugin/static2.c +++ b/testsuite/plugin/static2.c @@ -5,42 +5,30 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE_STATIC ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin", - "a plugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin", + "a plugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); static gboolean -plugin2_init (GstPlugin *plugin) +plugin2_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE_STATIC ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin2", - "a second plugin for testing", - plugin2_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); - -int +GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin2", + "a second plugin for testing", + plugin2_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); + +int main (int argc, char *argv[]) { GstPlugin *plugin; @@ -50,12 +38,12 @@ main (int argc, char *argv[]) plugin = gst_registry_pool_find_plugin ("testplugin"); g_assert (plugin != NULL); - g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin: %p %s\n", plugin, gst_plugin_get_name (plugin)); plugin = gst_registry_pool_find_plugin ("testplugin2"); g_assert (plugin != NULL); - g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name(plugin)); + g_print ("testplugin2: %p %s\n", plugin, gst_plugin_get_name (plugin)); return 0; } diff --git a/testsuite/plugin/testplugin.c b/testsuite/plugin/testplugin.c index 24e861405..d2ee604b9 100644 --- a/testsuite/plugin/testplugin.c +++ b/testsuite/plugin/testplugin.c @@ -6,19 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin", - "a plugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin", + "a plugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); diff --git a/testsuite/plugin/testplugin2.c b/testsuite/plugin/testplugin2.c index 69c71d8e1..47d2ad37d 100644 --- a/testsuite/plugin/testplugin2.c +++ b/testsuite/plugin/testplugin2.c @@ -6,20 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin2", - "another testplugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_PACKAGE, - GST_ORIGIN -); - +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin2", + "another testplugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN); diff --git a/testsuite/plugin/testplugin2_s.c b/testsuite/plugin/testplugin2_s.c index 154c2768e..00c47d8f8 100644 --- a/testsuite/plugin/testplugin2_s.c +++ b/testsuite/plugin/testplugin2_s.c @@ -6,21 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE_STATIC ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin2", - "another testplugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_COPYRIGHT, - GST_PACKAGE, - GST_ORIGIN -); - +GST_PLUGIN_DEFINE_STATIC (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin2", + "another testplugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN); diff --git a/testsuite/plugin/testplugin_s.c b/testsuite/plugin/testplugin_s.c index e834c8eed..b17605d5b 100644 --- a/testsuite/plugin/testplugin_s.c +++ b/testsuite/plugin/testplugin_s.c @@ -6,20 +6,13 @@ #include static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "testplugin", - "a plugin for testing", - plugin_init, - VERSION, - GST_LICENSE, - GST_COPYRIGHT, - GST_PACKAGE, - GST_ORIGIN -); +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "testplugin", + "a plugin for testing", + plugin_init, VERSION, GST_LICENSE, GST_COPYRIGHT, GST_PACKAGE, GST_ORIGIN); diff --git a/testsuite/refcounting/bin.c b/testsuite/refcounting/bin.c index 81c867180..df5d76aef 100644 --- a/testsuite/refcounting/bin.c +++ b/testsuite/refcounting/bin.c @@ -3,7 +3,7 @@ #define ITERS 100 #include -static GstElement* +static GstElement * create_bin (void) { GstElement *bin; @@ -20,7 +20,7 @@ create_bin (void) return bin; } -static GstElement* +static GstElement * create_bin_ghostpads (void) { GstElement *bin; @@ -32,7 +32,8 @@ create_bin_ghostpads (void) element2 = gst_element_factory_make ("fakesink", NULL); gst_bin_add (GST_BIN (bin), element2); gst_element_link_pads (element1, "src", element2, "sink"); - gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"), "ghost_sink"); + gst_element_add_ghost_pad (bin, gst_element_get_pad (element1, "sink"), + "ghost_sink"); return bin; } @@ -132,7 +133,7 @@ add_remove_test4 (void) #endif int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstElement *bin; int usage1; @@ -155,13 +156,14 @@ main (int argc, gchar *argv[]) bin = gst_bin_new ("somebin"); gst_object_unref (GST_OBJECT (bin)); - g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all ()-usage1); + g_print ("create/unref new bin %d\n", gst_alloc_trace_live_all () - usage1); - for (i=0; i int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstElement *element; int usage1; @@ -24,13 +24,15 @@ main (int argc, gchar *argv[]) element = gst_element_factory_make ("fakesrc", NULL); gst_object_unref (GST_OBJECT (element)); - g_print ("create/unref new element %d\n", gst_alloc_trace_live_all ()-usage1); + g_print ("create/unref new element %d\n", + gst_alloc_trace_live_all () - usage1); - for (i=0; i #include -int vmsize() { - int pid,fd,size,i,mem; +int +vmsize () +{ + int pid, fd, size, i, mem; char filename[17], buf[256], *ptr, *end; - pid = getpid(); - snprintf(filename,17,"/proc/%d/stat",pid); - fd = open(filename,O_RDONLY); - size = read(fd,buf,240); + pid = getpid (); + snprintf (filename, 17, "/proc/%d/stat", pid); + fd = open (filename, O_RDONLY); + size = read (fd, buf, 240); ptr = buf; - for (i=0;i<22;i++) - ptr = (char *)strchr(ptr,' ') + 1; - end = (char *)strchr(ptr,' '); + for (i = 0; i < 22; i++) + ptr = (char *) strchr (ptr, ' ') + 1; + end = (char *) strchr (ptr, ' '); *end = 0; - sscanf(ptr,"%d",&mem); - close(fd); + sscanf (ptr, "%d", &mem); + close (fd); return mem; } diff --git a/testsuite/refcounting/mem.h b/testsuite/refcounting/mem.h index 28999db2c..c019611d3 100644 --- a/testsuite/refcounting/mem.h +++ b/testsuite/refcounting/mem.h @@ -1 +1 @@ -int vmsize(); +int vmsize (); diff --git a/testsuite/refcounting/object.c b/testsuite/refcounting/object.c index 82ab7f4a6..5646f71ef 100644 --- a/testsuite/refcounting/object.c +++ b/testsuite/refcounting/object.c @@ -5,7 +5,7 @@ #include "mem.h" int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstObject *object, *object2; long usage1; @@ -19,17 +19,17 @@ main (int argc, gchar *argv[]) iters = ITERS; g_print ("starting test with %d iterations\n", iters); - usage1 = vmsize(); + usage1 = vmsize (); object = gst_object_new (); gst_object_unref (object); - g_print ("create/unref new object %ld\n", vmsize()-usage1); + g_print ("create/unref new object %ld\n", vmsize () - usage1); - for (i=0; i #include "mem.h" -static GstElement* +static GstElement * create_thread (void) { GstElement *thread; @@ -21,7 +21,7 @@ create_thread (void) return thread; } -static GstElement* +static GstElement * create_thread_ghostpads (void) { GstElement *thread; @@ -37,7 +37,8 @@ create_thread_ghostpads (void) gst_element_add_pad (element2, gst_pad_new ("sink1", GST_PAD_SINK)); gst_bin_add (GST_BIN (thread), element2); gst_element_link (element1, "src1", element2, "sink1"); - gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), "sink1"); + gst_element_add_ghost_pad (thread, gst_element_get_pad (element2, "sink1"), + "sink1"); return thread; } @@ -129,7 +130,7 @@ add_remove_test4 (void) } int -main (int argc, gchar *argv[]) +main (int argc, gchar * argv[]) { GstElement *thread, *element; long usage1; @@ -143,17 +144,17 @@ main (int argc, gchar *argv[]) iters = ITERS; g_print ("starting test\n"); - usage1 = vmsize(); + usage1 = vmsize (); thread = gst_thread_new ("somethread"); gst_object_unref (GST_OBJECT (thread)); - g_print ("create/unref new thread %ld\n", vmsize()-usage1); + g_print ("create/unref new thread %ld\n", vmsize () - usage1); - for (i=0; i gint -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; - GstElement *fakesrc1, *fakesink1; - GstElement *fakesrc2, *fakesink2; + GstElement *fakesrc1, *fakesink1; + GstElement *fakesrc2, *fakesink2; gst_init (&argc, &argv); pipeline = gst_pipeline_new ("pipeline"); - + fakesrc1 = gst_element_factory_make ("fakesrc", "fakesrc1"); g_object_set (G_OBJECT (fakesrc1), "num_buffers", 5, NULL); fakesink1 = gst_element_factory_make ("fakesink", "fakesink1"); - + gst_bin_add_many (GST_BIN (pipeline), fakesrc1, fakesink1, NULL); gst_element_link_pads (fakesrc1, "src", fakesink1, "sink"); @@ -44,7 +44,8 @@ main (gint argc, gchar *argv[]) gst_bin_add_many (GST_BIN (pipeline), fakesrc2, fakesink2, NULL); gst_element_link_pads (fakesrc2, "src", fakesink2, "sink"); - g_signal_connect (G_OBJECT (pipeline), "deep_notify", G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (G_OBJECT (pipeline), "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); GST_FLAG_SET (fakesrc2, GST_ELEMENT_LOCKED_STATE); GST_FLAG_SET (fakesink2, GST_ELEMENT_LOCKED_STATE); @@ -63,6 +64,6 @@ main (gint argc, gchar *argv[]) gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (GST_OBJECT (pipeline)); - + return 0; } diff --git a/testsuite/tags/merge.c b/testsuite/tags/merge.c index 0a806a62b..8b243afb1 100644 --- a/testsuite/tags/merge.c +++ b/testsuite/tags/merge.c @@ -17,7 +17,7 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include #include @@ -39,7 +39,7 @@ /* checks that a tag contains the given values and not more values */ static void -check (const GstTagList *list, const gchar *tag, gchar *value, ...) +check (const GstTagList * list, const gchar * tag, gchar * value, ...) { va_list args; gchar *str; @@ -50,13 +50,14 @@ check (const GstTagList *list, const gchar *tag, gchar *value, ...) g_assert (gst_tag_list_get_string_index (list, tag, i, &str)); g_assert (strcmp (value, str) == 0); g_free (str); - + value = va_arg (args, gchar *); i++; } g_assert (i == gst_tag_list_get_tag_size (list, tag)); va_end (args); } + #define NEW_LIST_FIXED(mode) G_STMT_START{ \ if (list) gst_tag_list_free (list);\ list = gst_tag_list_new (); \ @@ -87,11 +88,11 @@ check (const GstTagList *list, const gchar *tag, gchar *value, ...) if (merge) gst_tag_list_free (merge);\ merge = gst_tag_list_merge (list, list2, mode); \ }G_STMT_END -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstTagList *list = NULL, *list2 = NULL, *merge = NULL; - + gst_init (&argc, &argv); /* make sure the assumptions work */ @@ -100,7 +101,7 @@ main (gint argc, gchar *argv[]) /* we check string here only */ g_assert (gst_tag_get_type (FTAG) == G_TYPE_STRING); g_assert (gst_tag_get_type (UTAG) == G_TYPE_STRING); - + /* check additions */ /* unfixed */ NEW_LIST_UNFIXED (GST_TAG_MERGE_REPLACE_ALL); @@ -128,9 +129,9 @@ main (gint argc, gchar *argv[]) check (list, FTAG, FIXED1, NULL); NEW_LIST_FIXED (GST_TAG_MERGE_KEEP_ALL); check (list, FTAG, NULL); - + /* check merging */ - /* unfixed */ + /* unfixed */ NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE_ALL); check (merge, UTAG, UNFIXED3, UNFIXED4, NULL); NEW_LISTS_UNFIXED (GST_TAG_MERGE_REPLACE); @@ -143,7 +144,7 @@ main (gint argc, gchar *argv[]) check (merge, UTAG, UNFIXED1, UNFIXED2, NULL); NEW_LISTS_UNFIXED (GST_TAG_MERGE_KEEP_ALL); check (merge, UTAG, UNFIXED1, UNFIXED2, NULL); - /* fixed */ + /* fixed */ NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE_ALL); check (merge, FTAG, FIXED3, NULL); NEW_LISTS_FIXED (GST_TAG_MERGE_REPLACE); @@ -156,6 +157,6 @@ main (gint argc, gchar *argv[]) check (merge, FTAG, FIXED1, NULL); NEW_LISTS_FIXED (GST_TAG_MERGE_KEEP_ALL); check (merge, FTAG, FIXED1, NULL); - + return 0; } diff --git a/testsuite/test_gst_init.c b/testsuite/test_gst_init.c index 174932850..3331c3def 100644 --- a/testsuite/test_gst_init.c +++ b/testsuite/test_gst_init.c @@ -6,8 +6,8 @@ int main (int argc, char *argv[]) { - gst_init(NULL, NULL); - gst_init(&argc, &argv); + gst_init (NULL, NULL); + gst_init (&argc, &argv); return 0; } diff --git a/testsuite/threads/queue.c b/testsuite/threads/queue.c index 191ae43f0..b95911a55 100644 --- a/testsuite/threads/queue.c +++ b/testsuite/threads/queue.c @@ -12,20 +12,20 @@ static gint handoff_count = 0; /* handoff callback */ static void -handoff (GstElement *element, gpointer data) +handoff (GstElement * element, gpointer data) { ++handoff_count; g_print ("handoff (%d) ", handoff_count); } static void -construct_pipeline (GstElement *pipeline, GstElement *thread) +construct_pipeline (GstElement * pipeline, GstElement * thread) { GstElement *src, *sink, *queue; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", "sink"); - queue = gst_element_factory_make ("queue", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", "sink"); + queue = gst_element_factory_make ("queue", NULL); gst_bin_add_many (GST_BIN (thread), queue, sink, NULL); gst_bin_add_many (GST_BIN (pipeline), src, thread, NULL); @@ -39,17 +39,17 @@ construct_pipeline (GstElement *pipeline, GstElement *thread) } void -change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline) +change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline) { gst_element_set_state (pipeline, GST_STATE_NULL); } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *thread = NULL; - + gst_init (&argc, &argv); pipeline = gst_thread_new ("main_pipeline"); @@ -64,15 +64,15 @@ main (gint argc, gchar *argv[]) g_print ("Pipeline done. Resetting to NULL.\n"); gst_element_set_state (pipeline, GST_STATE_NULL); - if (handoff_count == 0) - { + if (handoff_count == 0) { g_print ("ERROR: no buffers have passed\n"); return -1; } handoff_count = 0; - g_print ("Second run: setting consumer thread to playing, then complete pipeline\n"); + g_print + ("Second run: setting consumer thread to playing, then complete pipeline\n"); gst_element_set_state (thread, GST_STATE_PLAYING); g_print ("SLEEPING 1 sec\n"); sleep (1); @@ -80,11 +80,10 @@ main (gint argc, gchar *argv[]) g_print ("SLEEPING 2 sec\n"); sleep (2); - if (handoff_count == 0) - { + if (handoff_count == 0) { g_print ("ERROR: no buffers have passed\n"); return -1; } - + return 0; } diff --git a/testsuite/threads/thread.c b/testsuite/threads/thread.c index 2054986f2..cc01d9134 100644 --- a/testsuite/threads/thread.c +++ b/testsuite/threads/thread.c @@ -10,24 +10,24 @@ void usage (void) { g_print ("compile this test with TESTNUM defined.\n" - " available TESTNUMs: \n" - " 1: stress test state change \n" - " 2: iterate once \n" - " 3: iterate twice \n" - " 4: state change while running \n" - " 5: state change in thread context\n"); + " available TESTNUMs: \n" + " 1: stress test state change \n" + " 2: iterate once \n" + " 3: iterate twice \n" + " 4: state change while running \n" + " 5: state change in thread context\n"); } static void -construct_pipeline (GstElement *pipeline) +construct_pipeline (GstElement * pipeline) { GstElement *src, *sink, *queue, *identity, *thread; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", "sink"); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", "sink"); identity = gst_element_factory_make ("identity", NULL); - queue = gst_element_factory_make ("queue", NULL); - thread = gst_element_factory_make ("thread", NULL); + queue = gst_element_factory_make ("queue", NULL); + thread = gst_element_factory_make ("thread", NULL); gst_element_link_many (src, queue, identity, sink, NULL); @@ -39,16 +39,16 @@ construct_pipeline (GstElement *pipeline) } void -change_state (GstElement *element, GstBuffer *buf, GstElement *pipeline) +change_state (GstElement * element, GstBuffer * buf, GstElement * pipeline) { gst_element_set_state (pipeline, GST_STATE_NULL); } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { GstElement *pipeline; - + gst_init (&argc, &argv); #ifndef TESTNUM @@ -112,13 +112,13 @@ main (gint argc, gchar *argv[]) sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink"); g_assert (sink); - g_signal_connect (G_OBJECT (sink), "handoff", - G_CALLBACK (change_state), pipeline); + g_signal_connect (G_OBJECT (sink), "handoff", + G_CALLBACK (change_state), pipeline); gst_element_set_state (pipeline, GST_STATE_PLAYING); g_print ("running ...\n"); while (gst_bin_iterate (GST_BIN (pipeline))); gst_element_set_state (pipeline, GST_STATE_NULL); } - + return 0; } diff --git a/testsuite/threads/threadb.c b/testsuite/threads/threadb.c index 9a05af47a..ded7d9c79 100644 --- a/testsuite/threads/threadb.c +++ b/testsuite/threads/threadb.c @@ -10,13 +10,13 @@ gboolean running = FALSE; static void -construct_pipeline (GstElement *pipeline) +construct_pipeline (GstElement * pipeline) { GstElement *src, *sink, *identity; - src = gst_element_factory_make ("fakesrc", NULL); + src = gst_element_factory_make ("fakesrc", NULL); identity = gst_element_factory_make ("identity", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (identity); g_assert (sink); @@ -29,14 +29,14 @@ construct_pipeline (GstElement *pipeline) } void -state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) +state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data) { GstElementState state = gst_element_get_state (el); - - g_print ("element %s has changed state to %s\n", - GST_ELEMENT_NAME (el), - gst_element_state_get_name (state)); - if (state == GST_STATE_PLAYING) running = TRUE; + + g_print ("element %s has changed state to %s\n", + GST_ELEMENT_NAME (el), gst_element_state_get_name (state)); + if (state == GST_STATE_PLAYING) + running = TRUE; /* if we move from PLAYING to PAUSED, we're done */ if (state == GST_STATE_PAUSED && running) { running = FALSE; @@ -45,30 +45,29 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = 100; int i; gulong id; GstElement *thread; - + gst_init (&argc, &argv); - for (i = 0; i < runs; ++i) - { + for (i = 0; i < runs; ++i) { thread = gst_thread_new ("main_thread"); g_assert (thread); /* connect state change signal */ - id = g_signal_connect (G_OBJECT (thread), "state_change", - G_CALLBACK (state_changed), NULL); + id = g_signal_connect (G_OBJECT (thread), "state_change", + G_CALLBACK (state_changed), NULL); construct_pipeline (thread); g_print ("Setting thread to play\n"); gst_element_set_state (thread, GST_STATE_PLAYING); g_print ("Going into the main GStreamer loop\n"); - gst_main (); + gst_main (); g_print ("Coming out of the main GStreamer loop\n"); g_signal_handler_disconnect (G_OBJECT (thread), id); gst_element_set_state (thread, GST_STATE_NULL); diff --git a/testsuite/threads/threadc.c b/testsuite/threads/threadc.c index bcbb2705b..c1bf2541e 100644 --- a/testsuite/threads/threadc.c +++ b/testsuite/threads/threadc.c @@ -8,7 +8,7 @@ gboolean running = FALSE; gboolean can_quit = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink; GstElement *identity = NULL; @@ -16,15 +16,14 @@ construct_pipeline (GstElement *pipeline, gint identities) int i; identity = NULL; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -37,18 +36,17 @@ construct_pipeline (GstElement *pipeline, gint identities) } void -state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) +state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data) { GstElementState state = gst_element_get_state (el); g_print ("element %s has changed state to %s\n", - GST_ELEMENT_NAME (el), - gst_element_state_get_name (state)); - if (state == GST_STATE_PLAYING) running = TRUE; + GST_ELEMENT_NAME (el), gst_element_state_get_name (state)); + if (state == GST_STATE_PLAYING) + running = TRUE; /* if we move from PLAYING to PAUSED, we're done */ - if (state == GST_STATE_PAUSED && running) - { - while (!can_quit) ; + if (state == GST_STATE_PAUSED && running) { + while (!can_quit); can_quit = FALSE; g_print ("quitting main loop\n"); gst_main_quit (); @@ -56,7 +54,7 @@ state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = 290; int i; @@ -65,23 +63,21 @@ main (gint argc, gchar *argv[]) gst_init (&argc, &argv); - for (i = 90; i < runs; ++i) - { + for (i = 90; i < runs; ++i) { thread = gst_thread_new ("main_thread"); g_assert (thread); /* connect state change signal */ id = g_signal_connect (G_OBJECT (thread), "state_change", - G_CALLBACK (state_changed), NULL); + G_CALLBACK (state_changed), NULL); construct_pipeline (thread, i / 10 + 1); g_print ("Setting thread to play with %d identities\n", i / 10 + 1); if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) { g_error ("Failed setting thread to play\n"); - } - else { + } else { g_print ("Going into the main GStreamer loop\n"); - can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */ + can_quit = TRUE; /* we don't want gst_main_quit called before gst_main */ gst_main (); } running = FALSE; @@ -94,4 +90,3 @@ main (gint argc, gchar *argv[]) return 0; } - diff --git a/testsuite/threads/threadd.c b/testsuite/threads/threadd.c index e9ff75360..25a521cf6 100644 --- a/testsuite/threads/threadd.c +++ b/testsuite/threads/threadd.c @@ -12,21 +12,20 @@ gboolean running = FALSE; gboolean done = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink, *identity = NULL; GstElement *from; int i; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -39,50 +38,49 @@ construct_pipeline (GstElement *pipeline, gint identities) } void -state_changed (GstElement *el, gint arg1, gint arg2, gpointer user_data) +state_changed (GstElement * el, gint arg1, gint arg2, gpointer user_data) { GstElementState state = gst_element_get_state (el); - - g_print ("element %s has changed state to %s\n", - GST_ELEMENT_NAME (el), - gst_element_state_get_name (state)); - if (state == GST_STATE_PLAYING) running = TRUE; + + g_print ("element %s has changed state to %s\n", + GST_ELEMENT_NAME (el), gst_element_state_get_name (state)); + if (state == GST_STATE_PLAYING) + running = TRUE; /* if we move from PLAYING to PAUSED, we're done */ - if (state == GST_STATE_PAUSED && running) + if (state == GST_STATE_PAUSED && running) done = TRUE; } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY; int i; gulong id; GstElement *thread; - - alarm(10); + + alarm (10); gst_init (&argc, &argv); - for (i = 0; i < runs; ++i) - { + for (i = 0; i < runs; ++i) { thread = gst_thread_new ("main_thread"); g_assert (thread); /* connect state change signal */ - id = g_signal_connect (G_OBJECT (thread), "state_change", - G_CALLBACK (state_changed), NULL); + id = g_signal_connect (G_OBJECT (thread), "state_change", + G_CALLBACK (state_changed), NULL); construct_pipeline (thread, i / RUNS_PER_IDENTITY + 1); - g_print ("Setting thread to play with %d identities\n", - i / RUNS_PER_IDENTITY + 1); + g_print ("Setting thread to play with %d identities\n", + i / RUNS_PER_IDENTITY + 1); done = FALSE; if (gst_element_set_state (thread, GST_STATE_PLAYING) == GST_STATE_FAILURE) { g_warning ("failed to go to PLAYING"); - } - else { + } else { g_print ("Waiting for thread PLAYING->PAUSED\n"); - while (!done) /* do nothing */; + while (!done) /* do nothing */ + ; } running = FALSE; g_print ("Coming out of the main GStreamer loop\n"); @@ -94,4 +92,3 @@ main (gint argc, gchar *argv[]) return 0; } - diff --git a/testsuite/threads/threade.c b/testsuite/threads/threade.c index 98b15dd3c..169c53813 100644 --- a/testsuite/threads/threade.c +++ b/testsuite/threads/threade.c @@ -12,21 +12,20 @@ gboolean running = FALSE; gboolean done = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink, *identity = NULL; GstElement *from; int i; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -39,29 +38,29 @@ construct_pipeline (GstElement *pipeline, gint identities) } static void -iterator (GstElement *bin) +iterator (GstElement * bin) { gst_element_set_state (bin, GST_STATE_PLAYING); - while (gst_bin_iterate (GST_BIN (bin))) g_print ("+"); + while (gst_bin_iterate (GST_BIN (bin))) + g_print ("+"); gst_element_set_state (bin, GST_STATE_NULL); g_print ("\n"); done = TRUE; } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { int runs = MAX_IDENTITIES * RUNS_PER_IDENTITY; int i; GstElement *pipeline; - alarm(10); + alarm (10); g_thread_init (NULL); gst_init (&argc, &argv); - for (i = 0; i < runs; ++i) - { + for (i = 0; i < runs; ++i) { pipeline = gst_pipeline_new ("main_pipeline"); g_assert (pipeline); @@ -73,7 +72,8 @@ main (gint argc, gchar *argv[]) g_print ("Created GThread\n"); g_print ("Waiting for thread PLAYING->PAUSED\n"); - while (!done) /* do nothing */; + while (!done) /* do nothing */ + ; running = FALSE; g_print ("Unreffing pipeline\n"); g_object_unref (G_OBJECT (pipeline)); @@ -81,4 +81,3 @@ main (gint argc, gchar *argv[]) return 0; } - diff --git a/testsuite/threads/threadf.c b/testsuite/threads/threadf.c index e5e0ab886..f04f76db1 100644 --- a/testsuite/threads/threadf.c +++ b/testsuite/threads/threadf.c @@ -14,7 +14,7 @@ gboolean running = FALSE; gboolean done = FALSE; static void -construct_pipeline (GstElement *pipeline, gint identities) +construct_pipeline (GstElement * pipeline, gint identities) { GstElement *src, *sink; GstElement *identity = NULL; @@ -22,15 +22,14 @@ construct_pipeline (GstElement *pipeline, gint identities) int i; identity = NULL; - src = gst_element_factory_make ("fakesrc", NULL); - sink = gst_element_factory_make ("fakesink", NULL); + src = gst_element_factory_make ("fakesrc", NULL); + sink = gst_element_factory_make ("fakesink", NULL); g_assert (src); g_assert (sink); gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL); from = src; - for (i = 0; i < identities; ++i) - { + for (i = 0; i < identities; ++i) { identity = gst_element_factory_make ("identity", NULL); g_assert (identity); gst_bin_add (GST_BIN (pipeline), identity); @@ -50,8 +49,7 @@ thread (void) int i; GstElement *pipeline; - for (i = 30; i < runs; ++i) - { + for (i = 30; i < runs; ++i) { pipeline = gst_pipeline_new ("main_pipeline"); g_assert (pipeline); @@ -69,7 +67,7 @@ thread (void) } int -main (gint argc, gchar *argv[]) +main (gint argc, gchar * argv[]) { done = FALSE; @@ -78,8 +76,8 @@ main (gint argc, gchar *argv[]) g_thread_create ((GThreadFunc) thread, NULL, FALSE, NULL); g_print ("main: created GThread\n"); - while (!done) g_usleep (G_USEC_PER_SEC); + while (!done) + g_usleep (G_USEC_PER_SEC); g_print ("main: done\n"); return 0; } - diff --git a/tools/gst-complete.c b/tools/gst-complete.c index 092c60fb9..56b73fdf5 100644 --- a/tools/gst-complete.c +++ b/tools/gst-complete.c @@ -10,7 +10,8 @@ #include -typedef struct { +typedef struct +{ gchar *name; GSList *srcpads; GSList *sinkpads; @@ -19,39 +20,48 @@ typedef struct { GSList *arguments; } comp_element; -enum { +enum +{ ARG_INT, ARG_FILENAME, ARG_ENUM }; -typedef struct { +typedef struct +{ gchar *name; int type; GSList *enums; } comp_argument; -typedef struct { +typedef struct +{ gint value; gchar *nick; } enum_value; -void print_match_list (gchar *prefix, int len, GSList *wordlist) { +void +print_match_list (gchar * prefix, int len, GSList * wordlist) +{ GSList *words = wordlist; while (words) { - if (!len || !strncmp((gchar *)(words->data), prefix, len)) - printf("%s\n",(gchar *)(words->data)); + if (!len || !strncmp ((gchar *) (words->data), prefix, len)) + printf ("%s\n", (gchar *) (words->data)); words = g_slist_next (words); } } -int match_element (comp_element *element, gchar *name) { - return strcmp(element->name,name); +int +match_element (comp_element * element, gchar * name) +{ + return strcmp (element->name, name); } -int main(int argc,char *argv[]) { +int +main (int argc, char *argv[]) +{ xmlDocPtr doc; xmlNodePtr rootnode, elementnode, propnode, argnode; GList *element_list = NULL; @@ -71,23 +81,23 @@ int main(int argc,char *argv[]) { GSList *words = NULL; struct stat stat_buf; - + setlocale (LC_ALL, ""); - if(argc<4){ - fprintf(stderr,"gst-complete called with invalid arguments\n"); - exit(1); + if (argc < 4) { + fprintf (stderr, "gst-complete called with invalid arguments\n"); + exit (1); } prev_word = argv[3]; partial_word = argv[2]; - partial_len = strlen(partial_word); + partial_len = strlen (partial_word); /***** Loading the completion information from the registry *****/ - if (stat (GST_CACHE_DIR"/compreg.xml", &stat_buf) == 0) { - doc = xmlParseFile (GST_CACHE_DIR"/compreg.xml"); + if (stat (GST_CACHE_DIR "/compreg.xml", &stat_buf) == 0) { + doc = xmlParseFile (GST_CACHE_DIR "/compreg.xml"); } else { exit (1); } @@ -95,50 +105,56 @@ int main(int argc,char *argv[]) { elementnode = rootnode->xmlChildrenNode; while (elementnode) { - if (!strcmp(elementnode->name, "element")) { - element = g_new0(comp_element,1); + if (!strcmp (elementnode->name, "element")) { + element = g_new0 (comp_element, 1); propnode = elementnode->xmlChildrenNode; while (propnode) { - if (!strcmp(propnode->name, "name")) { - element->name = xmlNodeGetContent(propnode); + if (!strcmp (propnode->name, "name")) { + element->name = xmlNodeGetContent (propnode); /* fprintf(stderr,element->name); */ - } else if (!strcmp(propnode->name, "srcpad")) { - element->srcpads = g_slist_prepend(element->srcpads, xmlNodeGetContent(propnode)); + } else if (!strcmp (propnode->name, "srcpad")) { + element->srcpads = + g_slist_prepend (element->srcpads, xmlNodeGetContent (propnode)); /* fprintf(stderr,"."); */ - } else if (!strcmp(propnode->name, "sinkpad")) { - element->sinkpads = g_slist_prepend(element->sinkpads, xmlNodeGetContent(propnode)); - } else if (!strcmp(propnode->name, "srcpadtemplate")) { - element->srcpadtemplates = g_slist_prepend(element->srcpadtemplates, xmlNodeGetContent(propnode)); + } else if (!strcmp (propnode->name, "sinkpad")) { + element->sinkpads = + g_slist_prepend (element->sinkpads, xmlNodeGetContent (propnode)); + } else if (!strcmp (propnode->name, "srcpadtemplate")) { + element->srcpadtemplates = + g_slist_prepend (element->srcpadtemplates, + xmlNodeGetContent (propnode)); /* fprintf(stderr,"."); */ - } else if (!strcmp(propnode->name, "sinkpad")) { - element->sinkpadtemplates = g_slist_prepend(element->sinkpadtemplates, xmlNodeGetContent(propnode)); - } else if (!strcmp(propnode->name, "argument")) { - argument = g_new0(comp_argument,1); - argument->name = xmlNodeGetContent(propnode); - argument->type = ARG_INT; - - /* walk through the values data */ - argnode = propnode->xmlChildrenNode; - while (argnode) { - if (!strcmp(argnode->name, "filename")) { - argument->type = ARG_FILENAME; - } else if (!strcmp(argnode->name,"option")) { - argument->type = ARG_ENUM; - option = g_new0(enum_value,1); - sscanf(xmlNodeGetContent(argnode),"%d",&option->value); - argument->enums = g_slist_prepend (argument->enums, option); - } - argnode = argnode->next; - } - - element->arguments = g_slist_prepend(element->arguments, argument); - } - - propnode = propnode->next; + } else if (!strcmp (propnode->name, "sinkpad")) { + element->sinkpadtemplates = + g_slist_prepend (element->sinkpadtemplates, + xmlNodeGetContent (propnode)); + } else if (!strcmp (propnode->name, "argument")) { + argument = g_new0 (comp_argument, 1); + argument->name = xmlNodeGetContent (propnode); + argument->type = ARG_INT; + + /* walk through the values data */ + argnode = propnode->xmlChildrenNode; + while (argnode) { + if (!strcmp (argnode->name, "filename")) { + argument->type = ARG_FILENAME; + } else if (!strcmp (argnode->name, "option")) { + argument->type = ARG_ENUM; + option = g_new0 (enum_value, 1); + sscanf (xmlNodeGetContent (argnode), "%d", &option->value); + argument->enums = g_slist_prepend (argument->enums, option); + } + argnode = argnode->next; + } + + element->arguments = g_slist_prepend (element->arguments, argument); + } + + propnode = propnode->next; } - element_list = g_list_prepend(element_list, element); - element_names = g_slist_prepend(element_names, element->name); + element_list = g_list_prepend (element_list, element); + element_names = g_slist_prepend (element_names, element->name); } elementnode = elementnode->next; } @@ -150,36 +166,38 @@ int main(int argc,char *argv[]) { /* The bulk of the work is in deciding exactly which words are an option. */ /* if we're right at the beginning, with -launch in the first word */ - if (strstr(prev_word,"-launch")) { + if (strstr (prev_word, "-launch")) { /* print out only elements with no sink pad or padtemplate */ elements = element_list; while (elements) { - element = (comp_element *)(elements->data); + element = (comp_element *) (elements->data); if (!element->sinkpads && !element->sinkpadtemplates) - words = g_slist_prepend (words, element->name); - elements = g_list_next(elements); + words = g_slist_prepend (words, element->name); + elements = g_list_next (elements); } } /* if the previous word is a connection */ - if (strchr(prev_word, '!')) { + if (strchr (prev_word, '!')) { /* print out oly elements with a sink pad or template */ elements = element_list; while (elements) { - element = (comp_element *)(elements->data); + element = (comp_element *) (elements->data); if (element->sinkpads || element->sinkpadtemplates) - words = g_slist_prepend (words, element->name); + words = g_slist_prepend (words, element->name); elements = g_list_next (elements); } } /* if the partial word is an argument, and it's an enum */ - if (strchr(prev_word,'=')) { - fprintf(stderr,"it's an arg, but dunno what element yet\n"); + if (strchr (prev_word, '=')) { + fprintf (stderr, "it's an arg, but dunno what element yet\n"); } - /* if the previous word is an element, we need to list both pads and arguments*/ - if ((elements = g_list_find_custom(element_list, prev_word, (GCompareFunc)match_element))) { + /* if the previous word is an element, we need to list both pads and arguments */ + if ((elements = + g_list_find_custom (element_list, prev_word, + (GCompareFunc) match_element))) { element = elements->data; /* zero the numpads list so we can count them */ num_pads = 0; @@ -188,7 +206,9 @@ int main(int argc,char *argv[]) { pads = element->srcpads; while (pads) { num_pads++; - words = g_slist_prepend (words, g_strdup_printf("%s!",(gchar *)(pads->data))); + words = + g_slist_prepend (words, g_strdup_printf ("%s!", + (gchar *) (pads->data))); pads = g_slist_next (pads); } @@ -196,9 +216,9 @@ int main(int argc,char *argv[]) { pads = element->srcpadtemplates; while (pads) { num_pads++; - word = g_strdup_printf("%s!",(gchar *)(pads->data)); - if (!g_slist_find_custom(words,word,(GCompareFunc)strcmp)) - words = g_slist_prepend (words, word); + word = g_strdup_printf ("%s!", (gchar *) (pads->data)); + if (!g_slist_find_custom (words, word, (GCompareFunc) strcmp)) + words = g_slist_prepend (words, word); pads = g_slist_next (pads); } @@ -210,10 +230,10 @@ int main(int argc,char *argv[]) { /* arguments */ args = element->arguments; while (args) { - argument = (comp_argument *)(args->data); - word = strstr(argument->name,"::")+2; - words = g_slist_prepend (words, g_strdup_printf("%s=",word)); - words = g_slist_prepend (words, g_strdup_printf("%s=...",word)); + argument = (comp_argument *) (args->data); + word = strstr (argument->name, "::") + 2; + words = g_slist_prepend (words, g_strdup_printf ("%s=", word)); + words = g_slist_prepend (words, g_strdup_printf ("%s=...", word)); args = g_slist_next (args); } } diff --git a/tools/gst-compprep.c b/tools/gst-compprep.c index 345b11060..241ea503e 100644 --- a/tools/gst-compprep.c +++ b/tools/gst-compprep.c @@ -6,10 +6,12 @@ #include -GST_DEBUG_CATEGORY_STATIC(debug_compprep); +GST_DEBUG_CATEGORY_STATIC (debug_compprep); #define GST_CAT_DEFAULT debug_compprep -int main(int argc,char *argv[]) { +int +main (int argc, char *argv[]) +{ xmlDocPtr doc; xmlNodePtr factorynode, padnode, argnode, optionnode; GList *plugins, *features, *padtemplates; @@ -18,24 +20,25 @@ int main(int argc,char *argv[]) { GstPad *pad; GstPadTemplate *padtemplate; GParamSpec **property_specs; - guint num_properties,i; + guint num_properties, i; setlocale (LC_ALL, ""); - gst_init(&argc,&argv); - GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD, "gst-compprep application"); + gst_init (&argc, &argv); + GST_DEBUG_CATEGORY_INIT (debug_compprep, "compprep", GST_DEBUG_BOLD, + "gst-compprep application"); - doc = xmlNewDoc("1.0"); - doc->xmlRootNode = xmlNewDocNode(doc, NULL, "GST-CompletionRegistry", NULL); + doc = xmlNewDoc ("1.0"); + doc->xmlRootNode = xmlNewDocNode (doc, NULL, "GST-CompletionRegistry", NULL); - plugins = g_list_copy(gst_registry_pool_plugin_list()); + plugins = g_list_copy (gst_registry_pool_plugin_list ()); while (plugins) { GstPlugin *plugin; - plugin = (GstPlugin *)(plugins->data); + plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); - features = g_list_copy(gst_plugin_get_feature_list(plugin)); + features = g_list_copy (gst_plugin_get_feature_list (plugin)); while (features) { GstPluginFeature *feature; GstElementFactory *factory; @@ -49,67 +52,77 @@ int main(int argc,char *argv[]) { factory = GST_ELEMENT_FACTORY (feature); factorynode = xmlNewChild (doc->xmlRootNode, NULL, "element", NULL); - xmlNewChild (factorynode, NULL, "name", - GST_PLUGIN_FEATURE_NAME(factory)); + xmlNewChild (factorynode, NULL, "name", + GST_PLUGIN_FEATURE_NAME (factory)); - element = gst_element_factory_create(factory,NULL); - GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME(factory)); + element = gst_element_factory_create (factory, NULL); + GST_DEBUG ("adding factory %s", GST_PLUGIN_FEATURE_NAME (factory)); if (element == NULL) { - GST_ERROR ("couldn't construct element from factory %s\n", - gst_object_get_name (GST_OBJECT (factory))); - return 1; + GST_ERROR ("couldn't construct element from factory %s\n", + gst_object_get_name (GST_OBJECT (factory))); + return 1; } /* write out the padtemplates */ padtemplates = factory->padtemplates; while (padtemplates) { - padtemplate = (GstPadTemplate *)(padtemplates->data); - padtemplates = g_list_next (padtemplates); - - if (padtemplate->direction == GST_PAD_SRC) - padnode = xmlNewChild (factorynode, NULL, "srcpadtemplate", padtemplate->name_template); - else if (padtemplate->direction == GST_PAD_SINK) - padnode = xmlNewChild (factorynode, NULL, "sinkpadtemplate", padtemplate->name_template); + padtemplate = (GstPadTemplate *) (padtemplates->data); + padtemplates = g_list_next (padtemplates); + + if (padtemplate->direction == GST_PAD_SRC) + padnode = + xmlNewChild (factorynode, NULL, "srcpadtemplate", + padtemplate->name_template); + else if (padtemplate->direction == GST_PAD_SINK) + padnode = + xmlNewChild (factorynode, NULL, "sinkpadtemplate", + padtemplate->name_template); } pads = gst_element_get_pad_list (element); while (pads) { - pad = (GstPad *)(pads->data); - pads = g_list_next (pads); - - if (GST_PAD_DIRECTION(pad) == GST_PAD_SRC) - padnode = xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME(pad)); - else if (GST_PAD_DIRECTION(pad) == GST_PAD_SINK) - padnode = xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME(pad)); + pad = (GstPad *) (pads->data); + pads = g_list_next (pads); + + if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC) + padnode = + xmlNewChild (factorynode, NULL, "srcpad", GST_PAD_NAME (pad)); + else if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) + padnode = + xmlNewChild (factorynode, NULL, "sinkpad", GST_PAD_NAME (pad)); } /* write out the args */ - property_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element), &num_properties); - for (i=0;iname); - if (param->value_type == GST_TYPE_URI) { - xmlNewChild (argnode, NULL, "filename", NULL); - } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) { - GEnumValue *values; - gint j; - - values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; - for (j=0;values[j].value_name;j++) { - gchar *value = g_strdup_printf("%d",values[j].value); - optionnode = xmlNewChild (argnode, NULL, "option", value); - xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick); - g_free(value); - } - } + property_specs = + g_object_class_list_properties (G_OBJECT_GET_CLASS (element), + &num_properties); + for (i = 0; i < num_properties; i++) { + GParamSpec *param = property_specs[i]; + + argnode = xmlNewChild (factorynode, NULL, "argument", param->name); + if (param->value_type == GST_TYPE_URI) { + xmlNewChild (argnode, NULL, "filename", NULL); + } else if (G_IS_PARAM_SPEC_ENUM (param) == G_TYPE_ENUM) { + GEnumValue *values; + gint j; + + values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; + for (j = 0; values[j].value_name; j++) { + gchar *value = g_strdup_printf ("%d", values[j].value); + + optionnode = xmlNewChild (argnode, NULL, "option", value); + xmlNewChild (optionnode, NULL, "value_nick", values[j].value_nick); + g_free (value); + } + } } } } #ifdef HAVE_LIBXML2 - xmlSaveFormatFile(GST_CACHE_DIR "/compreg.xml",doc,1); + xmlSaveFormatFile (GST_CACHE_DIR "/compreg.xml", doc, 1); #else - xmlSaveFile(GST_CACHE_DIR "/compreg.xml",doc); + xmlSaveFile (GST_CACHE_DIR "/compreg.xml", doc); #endif return 0; diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index 8a5076c9c..807d7450d 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -34,33 +34,33 @@ #include static void -print_caps (const GstCaps *caps, const gchar *pfx) +print_caps (const GstCaps * caps, const gchar * pfx) { char *s, *tmp; char **v; s = gst_caps_to_string (caps); - + tmp = g_strdup_printf ("\n %s", pfx); v = g_strsplit (s, ", ", -1); g_free (s); s = g_strjoinv (tmp, v); g_strfreev (v); g_free (tmp); - + tmp = g_strdup_printf ("\n%s", pfx); v = g_strsplit (s, "; ", -1); g_free (s); s = g_strjoinv (tmp, v); g_free (tmp); g_strfreev (v); - + g_print ("%s%s\n", pfx, s); - g_free(s); + g_free (s); } static void -print_formats (const GstFormat *formats) +print_formats (const GstFormat * formats) { while (formats && *formats) { const GstFormatDefinition *definition; @@ -68,7 +68,7 @@ print_formats (const GstFormat *formats) definition = gst_format_get_details (*formats); if (definition) g_print ("\t\t(%d):\t%s (%s)\n", *formats, - definition->nick, definition->description); + definition->nick, definition->description); else g_print ("\t\t(%d):\tUnknown format\n", *formats); @@ -77,7 +77,7 @@ print_formats (const GstFormat *formats) } static void -print_query_types (const GstQueryType *types) +print_query_types (const GstQueryType * types) { while (types && *types) { const GstQueryTypeDefinition *definition; @@ -85,7 +85,7 @@ print_query_types (const GstQueryType *types) definition = gst_query_type_get_details (*types); if (definition) g_print ("\t\t(%d):\t%s (%s)\n", *types, - definition->nick, definition->description); + definition->nick, definition->description); else g_print ("\t\t(%d):\tUnknown query format\n", *types); @@ -94,7 +94,7 @@ print_query_types (const GstQueryType *types) } static void -print_event_masks (const GstEventMask *masks) +print_event_masks (const GstEventMask * masks) { #ifndef GST_DISABLE_ENUMTYPES GType event_type; @@ -102,7 +102,7 @@ print_event_masks (const GstEventMask *masks) GType event_flags; GFlagsClass *flags_class = NULL; - event_type = gst_event_type_get_type(); + event_type = gst_event_type_get_type (); klass = (GEnumClass *) g_type_class_ref (event_type); while (masks && masks->type) { @@ -111,12 +111,12 @@ print_event_masks (const GstEventMask *masks) switch (masks->type) { case GST_EVENT_SEEK: - flags = masks->flags; - event_flags = gst_seek_type_get_type (); - flags_class = (GFlagsClass *) g_type_class_ref (event_flags); - break; + flags = masks->flags; + event_flags = gst_seek_type_get_type (); + flags_class = (GFlagsClass *) g_type_class_ref (event_flags); + break; default: - break; + break; } value = g_enum_get_value (klass, masks->type); @@ -126,12 +126,12 @@ print_event_masks (const GstEventMask *masks) GFlagsValue *value; if (flags & 1) { - value = g_flags_get_first_value (flags_class, 1 << index); + value = g_flags_get_first_value (flags_class, 1 << index); - if (value) - g_print ("| %s ", value->value_nick); - else - g_print ("| ? "); + if (value) + g_print ("| %s ", value->value_nick); + else + g_print ("| ? "); } flags >>= 1; index++; @@ -144,7 +144,7 @@ print_event_masks (const GstEventMask *masks) } static void -output_hierarchy (GType type, gint level, gint *maxlevel) +output_hierarchy (GType type, gint level, gint * maxlevel) { GType parent; gint i; @@ -157,9 +157,9 @@ output_hierarchy (GType type, gint level, gint *maxlevel) if (parent) output_hierarchy (parent, level, maxlevel); - for (i=1; i<*maxlevel-level; i++) - g_print (" "); - if (*maxlevel-level) + for (i = 1; i < *maxlevel - level; i++) + g_print (" "); + if (*maxlevel - level) g_print (" +----"); g_print ("%s\n", g_type_name (type)); @@ -169,20 +169,21 @@ output_hierarchy (GType type, gint level, gint *maxlevel) } static void -print_element_properties (GstElement *element) +print_element_properties (GstElement * element) { GParamSpec **property_specs; - gint num_properties,i; + gint num_properties, i; gboolean readable; const char *string_val; property_specs = g_object_class_list_properties - (G_OBJECT_GET_CLASS (element), &num_properties); - g_print("\nElement Properties:\n"); + (G_OBJECT_GET_CLASS (element), &num_properties); + g_print ("\nElement Properties:\n"); for (i = 0; i < num_properties; i++) { GValue value = { 0, }; GParamSpec *param = property_specs[i]; + readable = FALSE; g_value_init (&value, param->value_type); @@ -191,175 +192,186 @@ print_element_properties (GstElement *element) readable = TRUE; } - g_print(" %-20s: %s\n", g_param_spec_get_name (param), - g_param_spec_get_blurb (param)); + g_print (" %-20s: %s\n", g_param_spec_get_name (param), + g_param_spec_get_blurb (param)); switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: - string_val = g_value_get_string (&value); - g_print ("%-23.23s String. ", ""); - if (readable) { - if (string_val == NULL) - g_print ("(Default \"\")"); - else - g_print ("(Default \"%s\")", g_value_get_string (&value)); - } - break; + string_val = g_value_get_string (&value); + g_print ("%-23.23s String. ", ""); + if (readable) { + if (string_val == NULL) + g_print ("(Default \"\")"); + else + g_print ("(Default \"%s\")", g_value_get_string (&value)); + } + break; case G_TYPE_BOOLEAN: - g_print ("%-23.23s Boolean. ", ""); - if (readable) g_print ("(Default %s)", (g_value_get_boolean (&value) ? "true" : "false")); - break; + g_print ("%-23.23s Boolean. ", ""); + if (readable) + g_print ("(Default %s)", + (g_value_get_boolean (&value) ? "true" : "false")); + break; case G_TYPE_ULONG: { - GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); - g_print("%-23.23s Unsigned Long. ", ""); - if (readable) g_print("Range: %lu - %lu (Default %lu)", - pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); - break; + GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); + + g_print ("%-23.23s Unsigned Long. ", ""); + if (readable) + g_print ("Range: %lu - %lu (Default %lu)", + pulong->minimum, pulong->maximum, g_value_get_ulong (&value)); + break; } case G_TYPE_LONG: { - GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); - g_print("%-23.23s Long. ", ""); - if (readable) g_print("Range: %ld - %ld (Default %ld)", - plong->minimum, plong->maximum, g_value_get_long (&value)); - break; + GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); + + g_print ("%-23.23s Long. ", ""); + if (readable) + g_print ("Range: %ld - %ld (Default %ld)", + plong->minimum, plong->maximum, g_value_get_long (&value)); + break; } case G_TYPE_UINT: { - GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); - g_print("%-23.23s Unsigned Integer. ", ""); - if (readable) g_print("Range: %u - %u (Default %u)", - puint->minimum, puint->maximum, g_value_get_uint (&value)); - break; + GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); + + g_print ("%-23.23s Unsigned Integer. ", ""); + if (readable) + g_print ("Range: %u - %u (Default %u)", + puint->minimum, puint->maximum, g_value_get_uint (&value)); + break; } case G_TYPE_INT: { - GParamSpecInt *pint = G_PARAM_SPEC_INT (param); - g_print("%-23.23s Integer. ", ""); - if (readable) g_print("Range: %d - %d (Default %d)", - pint->minimum, pint->maximum, g_value_get_int (&value)); - break; + GParamSpecInt *pint = G_PARAM_SPEC_INT (param); + + g_print ("%-23.23s Integer. ", ""); + if (readable) + g_print ("Range: %d - %d (Default %d)", + pint->minimum, pint->maximum, g_value_get_int (&value)); + break; } case G_TYPE_UINT64: { - GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); - g_print("%-23.23s Unsigned Integer64. ", ""); - if (readable) g_print("Range: %" G_GUINT64_FORMAT " - %" - G_GUINT64_FORMAT " (Default %" G_GUINT64_FORMAT ")", - puint64->minimum, puint64->maximum, - g_value_get_uint64 (&value)); - break; + GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); + + g_print ("%-23.23s Unsigned Integer64. ", ""); + if (readable) + g_print ("Range: %" G_GUINT64_FORMAT " - %" + G_GUINT64_FORMAT " (Default %" G_GUINT64_FORMAT ")", + puint64->minimum, puint64->maximum, g_value_get_uint64 (&value)); + break; } case G_TYPE_INT64: { - GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); - g_print("%-23.23s Integer64. ", ""); - if (readable) g_print("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " (Default %" G_GINT64_FORMAT ")", pint64->minimum, - pint64->maximum, g_value_get_int64 (&value)); - break; + GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); + + g_print ("%-23.23s Integer64. ", ""); + if (readable) + g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT + " (Default %" G_GINT64_FORMAT ")", pint64->minimum, + pint64->maximum, g_value_get_int64 (&value)); + break; } case G_TYPE_FLOAT: { - GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); - g_print("%-23.23s Float. Default: %-8.8s %15.7g\n", "", "", - g_value_get_float (&value)); - g_print("%-23.23s Range: %15.7g - %15.7g", "", - pfloat->minimum, pfloat->maximum); - break; + GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); + + g_print ("%-23.23s Float. Default: %-8.8s %15.7g\n", "", "", + g_value_get_float (&value)); + g_print ("%-23.23s Range: %15.7g - %15.7g", "", + pfloat->minimum, pfloat->maximum); + break; } case G_TYPE_DOUBLE: { - GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); - g_print("%-23.23s Double. Default: %-8.8s %15.7g\n", "", "", - g_value_get_double (&value)); - g_print("%-23.23s Range: %15.7g - %15.7g", "", - pdouble->minimum, pdouble->maximum); - break; + GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); + + g_print ("%-23.23s Double. Default: %-8.8s %15.7g\n", "", "", + g_value_get_double (&value)); + g_print ("%-23.23s Range: %15.7g - %15.7g", "", + pdouble->minimum, pdouble->maximum); + break; } default: - if (param->value_type == GST_TYPE_URI) { - g_print("%-23.23s URI", ""); - } - if (param->value_type == GST_TYPE_CAPS) { - const GstCaps *caps = gst_value_get_caps (&value); - - if (!caps) - g_print("%-23.23s Caps (NULL)", ""); - else { - print_caps (caps, " "); - } - } - else if (G_IS_PARAM_SPEC_ENUM (param)) { - GEnumValue *values; - guint j = 0; - gint enum_value; - - values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; - enum_value = g_value_get_enum (&value); - - while (values[j].value_name) { - if (values[j].value == enum_value) - break; - j++; - } - - g_print ("%-23.23s Enum \"%s\" (default %d, \"%s\")", "", - g_type_name (G_VALUE_TYPE (&value)), - enum_value, values[j].value_nick); - - j = 0; - while (values[j].value_name) { - g_print("\n%-23.23s (%d): \t%s", "", - values[j].value, values[j].value_nick); - j++; - } - /* g_type_class_unref (ec); */ - } - else if (G_IS_PARAM_SPEC_FLAGS (param)) { - GFlagsValue *values; - guint j = 0; - gint flags_value; - GString *flags = NULL; - - values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; - flags_value = g_value_get_flags (&value); - - while (values[j].value_name) { - if (values[j].value & flags_value) { - if (flags) { - g_string_append_printf (flags, " | %s", values[j].value_nick); - } - else { - flags = g_string_new (values[j].value_nick); - } - } - j++; - } - - g_print("%-23.23s Flags \"%s\" (default %d, \"%s\")", "", - g_type_name (G_VALUE_TYPE (&value)), - flags_value, (flags ? flags->str : "(none)")); - - j = 0; - while (values[j].value_name) { - g_print("\n%-23.23s (%d): \t%s", "", - values[j].value, values[j].value_nick); - j++; - } - - if (flags) - g_string_free (flags, TRUE); - } - else if (G_IS_PARAM_SPEC_OBJECT (param)) { - g_print("%-23.23s Object of type \"%s\"", "", - g_type_name(param->value_type)); - } - else { - g_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type, - g_type_name(param->value_type)); - } - break; + if (param->value_type == GST_TYPE_URI) { + g_print ("%-23.23s URI", ""); + } + if (param->value_type == GST_TYPE_CAPS) { + const GstCaps *caps = gst_value_get_caps (&value); + + if (!caps) + g_print ("%-23.23s Caps (NULL)", ""); + else { + print_caps (caps, " "); + } + } else if (G_IS_PARAM_SPEC_ENUM (param)) { + GEnumValue *values; + guint j = 0; + gint enum_value; + + values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; + enum_value = g_value_get_enum (&value); + + while (values[j].value_name) { + if (values[j].value == enum_value) + break; + j++; + } + + g_print ("%-23.23s Enum \"%s\" (default %d, \"%s\")", "", + g_type_name (G_VALUE_TYPE (&value)), + enum_value, values[j].value_nick); + + j = 0; + while (values[j].value_name) { + g_print ("\n%-23.23s (%d): \t%s", "", + values[j].value, values[j].value_nick); + j++; + } + /* g_type_class_unref (ec); */ + } else if (G_IS_PARAM_SPEC_FLAGS (param)) { + GFlagsValue *values; + guint j = 0; + gint flags_value; + GString *flags = NULL; + + values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; + flags_value = g_value_get_flags (&value); + + while (values[j].value_name) { + if (values[j].value & flags_value) { + if (flags) { + g_string_append_printf (flags, " | %s", values[j].value_nick); + } else { + flags = g_string_new (values[j].value_nick); + } + } + j++; + } + + g_print ("%-23.23s Flags \"%s\" (default %d, \"%s\")", "", + g_type_name (G_VALUE_TYPE (&value)), + flags_value, (flags ? flags->str : "(none)")); + + j = 0; + while (values[j].value_name) { + g_print ("\n%-23.23s (%d): \t%s", "", + values[j].value, values[j].value_nick); + j++; + } + + if (flags) + g_string_free (flags, TRUE); + } else if (G_IS_PARAM_SPEC_OBJECT (param)) { + g_print ("%-23.23s Object of type \"%s\"", "", + g_type_name (param->value_type)); + } else { + g_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type, + g_type_name (param->value_type)); + } + break; } if (!readable) g_print (" Write only\n"); @@ -373,7 +385,7 @@ print_element_properties (GstElement *element) static char * get_rank_name (gint rank) { - switch(rank){ + switch (rank) { case GST_RANK_NONE: return "none"; case GST_RANK_MARGINAL: @@ -388,7 +400,7 @@ get_rank_name (gint rank) } static gint -print_element_info (GstElementFactory *factory) +print_element_info (GstElementFactory * factory) { GstElement *element; GstObjectClass *gstobject_class; @@ -411,11 +423,12 @@ print_element_info (GstElementFactory *factory) gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element)); g_print ("Factory Details:\n"); - g_print (" Long name:\t%s\n", factory->details.longname); - g_print (" Class:\t%s\n", factory->details.klass); + g_print (" Long name:\t%s\n", factory->details.longname); + g_print (" Class:\t%s\n", factory->details.klass); g_print (" Description:\t%s\n", factory->details.description); - g_print (" Author(s):\t%s\n", factory->details.author); - g_print (" Rank:\t\t%s\n", get_rank_name(GST_PLUGIN_FEATURE(factory)->rank)); + g_print (" Author(s):\t%s\n", factory->details.author); + g_print (" Rank:\t\t%s\n", + get_rank_name (GST_PLUGIN_FEATURE (factory)->rank)); g_print ("\n"); output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); @@ -426,31 +439,30 @@ print_element_info (GstElementFactory *factory) pads = factory->padtemplates; while (pads) { - padtemplate = (GstPadTemplate*)(pads->data); - pads = g_list_next(pads); + padtemplate = (GstPadTemplate *) (pads->data); + pads = g_list_next (pads); if (padtemplate->direction == GST_PAD_SRC) - g_print (" SRC template: '%s'\n", padtemplate->name_template); + g_print (" SRC template: '%s'\n", padtemplate->name_template); else if (padtemplate->direction == GST_PAD_SINK) - g_print (" SINK template: '%s'\n", padtemplate->name_template); + g_print (" SINK template: '%s'\n", padtemplate->name_template); else - g_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template); + g_print (" UNKNOWN!!! template: '%s'\n", padtemplate->name_template); if (padtemplate->presence == GST_PAD_ALWAYS) - g_print (" Availability: Always\n"); + g_print (" Availability: Always\n"); else if (padtemplate->presence == GST_PAD_SOMETIMES) - g_print (" Availability: Sometimes\n"); + g_print (" Availability: Sometimes\n"); else if (padtemplate->presence == GST_PAD_REQUEST) { - g_print (" Availability: On request\n"); - g_print (" Has request_new_pad() function: %s\n", - GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad)); - } - else - g_print (" Availability: UNKNOWN!!!\n"); + g_print (" Availability: On request\n"); + g_print (" Has request_new_pad() function: %s\n", + GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad)); + } else + g_print (" Availability: UNKNOWN!!!\n"); if (padtemplate->caps) { - g_print (" Capabilities:\n"); - print_caps (padtemplate->caps, " "); + g_print (" Capabilities:\n"); + print_caps (padtemplate->caps, " "); } g_print ("\n"); @@ -474,11 +486,11 @@ print_element_info (GstElementFactory *factory) have_flags = TRUE; } if (GST_FLAG_IS_SET (element, GST_ELEMENT_EVENT_AWARE)) { - g_print(" GST_ELEMENT_EVENT_AWARE\n"); + g_print (" GST_ELEMENT_EVENT_AWARE\n"); have_flags = TRUE; } if (!have_flags) - g_print(" no flags set\n"); + g_print (" no flags set\n"); if (GST_IS_BIN (element)) { g_print ("\nBin Flags:\n"); @@ -504,17 +516,17 @@ print_element_info (GstElementFactory *factory) if (element->loopfunc) g_print (" loopfunc()-based element: %s\n", - GST_DEBUG_FUNCPTR_NAME (element->loopfunc)); + GST_DEBUG_FUNCPTR_NAME (element->loopfunc)); else g_print (" No loopfunc(), must be chain-based or not configured yet\n"); g_print (" Has change_state() function: %s\n", - GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state)); + GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state)); #ifndef GST_DISABLE_LOADSAVE g_print (" Has custom save_thyself() function: %s\n", - GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself)); + GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself)); g_print (" Has custom restore_thyself() function: %s\n", - GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself)); + GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself)); #endif have_flags = FALSE; @@ -529,7 +541,7 @@ print_element_info (GstElementFactory *factory) clock = gst_element_get_clock (element); if (clock) - g_print (" element provides a clock: %s\n", GST_OBJECT_NAME(clock)); + g_print (" element provides a clock: %s\n", GST_OBJECT_NAME (clock)); else g_print (" element is supposed to provide a clock but returned NULL\n"); have_flags = TRUE; @@ -537,13 +549,11 @@ print_element_info (GstElementFactory *factory) if (!have_flags) { g_print (" none\n"); } - #ifndef GST_DISABLE_INDEX g_print ("\nIndexing capabilities:\n"); if (gst_element_is_indexable (element)) { g_print (" element can do indexing\n"); - } - else { + } else { g_print (" none\n"); } #endif @@ -551,6 +561,7 @@ print_element_info (GstElementFactory *factory) g_print ("\nPads:\n"); if (element->numpads) { const GList *pads; + pads = gst_element_get_pad_list (element); while (pads) { pad = GST_PAD (pads->data); @@ -558,61 +569,60 @@ print_element_info (GstElementFactory *factory) realpad = GST_PAD_REALIZE (pad); if (gst_pad_get_direction (pad) == GST_PAD_SRC) - g_print (" SRC: '%s'", gst_pad_get_name (pad)); + g_print (" SRC: '%s'", gst_pad_get_name (pad)); else if (gst_pad_get_direction (pad) == GST_PAD_SINK) - g_print (" SINK: '%s'", gst_pad_get_name (pad)); + g_print (" SINK: '%s'", gst_pad_get_name (pad)); else - g_print (" UNKNOWN!!!: '%s'\n", gst_pad_get_name (pad)); + g_print (" UNKNOWN!!!: '%s'\n", gst_pad_get_name (pad)); if (GST_IS_GHOST_PAD (pad)) - g_print (", ghost of real pad %s:%s\n", GST_DEBUG_PAD_NAME (realpad)); + g_print (", ghost of real pad %s:%s\n", GST_DEBUG_PAD_NAME (realpad)); else - g_print ("\n"); + g_print ("\n"); g_print (" Implementation:\n"); if (realpad->chainfunc) - g_print (" Has chainfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc)); + g_print (" Has chainfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc)); if (realpad->getfunc) - g_print (" Has getfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (realpad->getfunc)); + g_print (" Has getfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->getfunc)); if (realpad->formatsfunc != gst_pad_get_formats_default) { - g_print (" Supports seeking/conversion/query formats:\n"); - print_formats (gst_pad_get_formats (GST_PAD (realpad))); + g_print (" Supports seeking/conversion/query formats:\n"); + print_formats (gst_pad_get_formats (GST_PAD (realpad))); } if (realpad->convertfunc != gst_pad_convert_default) - g_print (" Has custom convertfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc)); + g_print (" Has custom convertfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc)); if (realpad->eventfunc != gst_pad_event_default) - g_print (" Has custom eventfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc)); + g_print (" Has custom eventfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc)); if (realpad->eventmaskfunc != gst_pad_get_event_masks_default) { - g_print (" Provides event masks:\n"); - print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad))); + g_print (" Provides event masks:\n"); + print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad))); } if (realpad->queryfunc != gst_pad_query_default) - g_print (" Has custom queryfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc)); + g_print (" Has custom queryfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc)); if (realpad->querytypefunc != gst_pad_get_query_types_default) { - g_print (" Provides query types:\n"); - print_query_types (gst_pad_get_query_types (GST_PAD (realpad))); + g_print (" Provides query types:\n"); + print_query_types (gst_pad_get_query_types (GST_PAD (realpad))); } if (realpad->intlinkfunc != gst_pad_get_internal_links_default) - g_print (" Has custom intconnfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME(realpad->intlinkfunc)); + g_print (" Has custom intconnfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->intlinkfunc)); if (realpad->bufferallocfunc) - g_print (" Has bufferallocfunc(): %s\n", - GST_DEBUG_FUNCPTR_NAME(realpad->bufferallocfunc)); + g_print (" Has bufferallocfunc(): %s\n", + GST_DEBUG_FUNCPTR_NAME (realpad->bufferallocfunc)); if (pad->padtemplate) - g_print (" Pad Template: '%s'\n", - pad->padtemplate->name_template); + g_print (" Pad Template: '%s'\n", pad->padtemplate->name_template); if (realpad->caps) { - g_print (" Capabilities:\n"); - print_caps (realpad->caps, " "); + g_print (" Capabilities:\n"); + print_caps (realpad->caps, " "); } } } else @@ -622,51 +632,51 @@ print_element_info (GstElementFactory *factory) /* Dynamic Parameters block */ { - GstDParamManager* dpman; - GParamSpec** specs; + GstDParamManager *dpman; + GParamSpec **specs; gint x; g_print ("\nDynamic Parameters:\n"); - if((dpman = gst_dpman_get_manager (element))) { + if ((dpman = gst_dpman_get_manager (element))) { specs = gst_dpman_list_dparam_specs (dpman); for (x = 0; specs[x] != NULL; x++) { - g_print (" %-20.20s: ", g_param_spec_get_name (specs[x])); - - switch (G_PARAM_SPEC_VALUE_TYPE (specs[x])) { - case G_TYPE_INT64: - g_print ("64 Bit Integer (Default %" G_GINT64_FORMAT ", Range %" - G_GINT64_FORMAT " -> %" G_GINT64_FORMAT ")", - ((GParamSpecInt64 *) specs[x])->default_value, - ((GParamSpecInt64 *) specs[x])->minimum, - ((GParamSpecInt64 *) specs[x])->maximum); - break; - case G_TYPE_INT: - g_print ("Integer (Default %d, Range %d -> %d)", - ((GParamSpecInt *) specs[x])->default_value, - ((GParamSpecInt *) specs[x])->minimum, - ((GParamSpecInt *) specs[x])->maximum); - break; - case G_TYPE_FLOAT: - g_print ("Float. Default: %-8.8s %15.7g\n", "", - ((GParamSpecFloat *) specs[x])->default_value); - g_print ("%-23.23s Range: %15.7g - %15.7g", "", - ((GParamSpecFloat *) specs[x])->minimum, - ((GParamSpecFloat *) specs[x])->maximum); - break; - case G_TYPE_DOUBLE: - g_print ("Double. Default: %-8.8s %15.7g\n", "", - ((GParamSpecDouble *) specs[x])->default_value); - g_print ("%-23.23s Range: %15.7g - %15.7g", "", - ((GParamSpecDouble *) specs[x])->minimum, - ((GParamSpecDouble *) specs[x])->maximum); - break; - default: g_print ("unknown %ld", G_PARAM_SPEC_VALUE_TYPE (specs[x])); - } - g_print ("\n"); + g_print (" %-20.20s: ", g_param_spec_get_name (specs[x])); + + switch (G_PARAM_SPEC_VALUE_TYPE (specs[x])) { + case G_TYPE_INT64: + g_print ("64 Bit Integer (Default %" G_GINT64_FORMAT ", Range %" + G_GINT64_FORMAT " -> %" G_GINT64_FORMAT ")", + ((GParamSpecInt64 *) specs[x])->default_value, + ((GParamSpecInt64 *) specs[x])->minimum, + ((GParamSpecInt64 *) specs[x])->maximum); + break; + case G_TYPE_INT: + g_print ("Integer (Default %d, Range %d -> %d)", + ((GParamSpecInt *) specs[x])->default_value, + ((GParamSpecInt *) specs[x])->minimum, + ((GParamSpecInt *) specs[x])->maximum); + break; + case G_TYPE_FLOAT: + g_print ("Float. Default: %-8.8s %15.7g\n", "", + ((GParamSpecFloat *) specs[x])->default_value); + g_print ("%-23.23s Range: %15.7g - %15.7g", "", + ((GParamSpecFloat *) specs[x])->minimum, + ((GParamSpecFloat *) specs[x])->maximum); + break; + case G_TYPE_DOUBLE: + g_print ("Double. Default: %-8.8s %15.7g\n", "", + ((GParamSpecDouble *) specs[x])->default_value); + g_print ("%-23.23s Range: %15.7g - %15.7g", "", + ((GParamSpecDouble *) specs[x])->minimum, + ((GParamSpecDouble *) specs[x])->maximum); + break; + default: + g_print ("unknown %ld", G_PARAM_SPEC_VALUE_TYPE (specs[x])); + } + g_print ("\n"); } g_free (specs); - } - else { + } else { g_print (" none\n"); } } @@ -683,12 +693,12 @@ print_element_info (GstElementFactory *factory) gint counted = 0; if (k == 0) - g_print ("\nElement Signals:\n"); + g_print ("\nElement Signals:\n"); else - g_print ("\nElement Actions:\n"); + g_print ("\nElement Actions:\n"); - for(type = G_OBJECT_TYPE(element); type; type = g_type_parent(type)){ - signals = g_signal_list_ids (type, &nsignals); + for (type = G_OBJECT_TYPE (element); type; type = g_type_parent (type)) { + signals = g_signal_list_ids (type, &nsignals); for (i = 0; i < nsignals; i++) { gint n_params; @@ -696,21 +706,22 @@ print_element_info (GstElementFactory *factory) const GType *param_types; gint j; - query = g_new0 (GSignalQuery,1); + query = g_new0 (GSignalQuery, 1); g_signal_query (signals[i], query); if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) || - (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) { + (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) { n_params = query->n_params; return_type = query->return_type; param_types = query->param_types; g_print (" \"%s\" :\t %s user_function (%s* object", - query->signal_name, g_type_name (return_type), - g_type_name (type)); + query->signal_name, g_type_name (return_type), + g_type_name (type)); for (j = 0; j < n_params; j++) { - g_print (",\n \t\t\t\t%s arg%d", g_type_name(param_types[j]), j); + g_print (",\n \t\t\t\t%s arg%d", g_type_name (param_types[j]), + j); } if (k == 0) g_print (",\n \t\t\t\tgpointer user_data);\n"); @@ -723,7 +734,8 @@ print_element_info (GstElementFactory *factory) g_free (query); } } - if (counted == 0) g_print (" none\n"); + if (counted == 0) + g_print (" none\n"); } } @@ -735,10 +747,10 @@ print_element_info (GstElementFactory *factory) g_print (" none\n"); else { while (children) { - child = GST_ELEMENT (children->data); - children = g_list_next (children); + child = GST_ELEMENT (children->data); + children = g_list_next (children); - g_print (" %s\n", GST_ELEMENT_NAME (child)); + g_print (" %s\n", GST_ELEMENT_NAME (child)); } } } @@ -751,12 +763,12 @@ print_element_list (void) { GList *plugins; - plugins = gst_registry_pool_plugin_list(); + plugins = gst_registry_pool_plugin_list (); while (plugins) { GList *features; GstPlugin *plugin; - plugin = (GstPlugin*)(plugins->data); + plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); features = gst_plugin_get_feature_list (plugin); @@ -766,48 +778,48 @@ print_element_list (void) feature = GST_PLUGIN_FEATURE (features->data); if (GST_IS_ELEMENT_FACTORY (feature)) { - GstElementFactory *factory; + GstElementFactory *factory; - factory = GST_ELEMENT_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory) ,factory->details.longname); + factory = GST_ELEMENT_FACTORY (feature); + g_print ("%s: %s: %s\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (factory), factory->details.longname); } #ifndef GST_DISABLE_INDEX else if (GST_IS_INDEX_FACTORY (feature)) { - GstIndexFactory *factory; + GstIndexFactory *factory; - factory = GST_INDEX_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); + factory = GST_INDEX_FACTORY (feature); + g_print ("%s: %s: %s\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); } #endif else if (GST_IS_TYPE_FIND_FACTORY (feature)) { - GstTypeFindFactory *factory; + GstTypeFindFactory *factory; - factory = GST_TYPE_FIND_FACTORY (feature); - g_print ("%s: %s: ", plugin->desc.name, gst_plugin_feature_get_name (feature)); - if (factory->extensions) { + factory = GST_TYPE_FIND_FACTORY (feature); + g_print ("%s: %s: ", plugin->desc.name, + gst_plugin_feature_get_name (feature)); + if (factory->extensions) { guint i = 0; + while (factory->extensions[i]) { g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); i++; } - g_print ("\n"); + g_print ("\n"); } else { - g_print ("no extensions\n"); - } - } - else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory; - - factory = GST_SCHEDULER_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); - } - else { - g_print ("%s: %s (%s)\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (feature), - g_type_name (G_OBJECT_TYPE (feature))); + g_print ("no extensions\n"); + } + } else if (GST_IS_SCHEDULER_FACTORY (feature)) { + GstSchedulerFactory *factory; + + factory = GST_SCHEDULER_FACTORY (feature); + g_print ("%s: %s: %s\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); + } else { + g_print ("%s: %s (%s)\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (feature), + g_type_name (G_OBJECT_TYPE (feature))); } features = g_list_next (features); @@ -816,7 +828,7 @@ print_element_list (void) } static void -print_plugin_info (GstPlugin *plugin) +print_plugin_info (GstPlugin * plugin) { GList *features; gint num_features = 0; @@ -827,13 +839,13 @@ print_plugin_info (GstPlugin *plugin) gint num_other = 0; g_print ("Plugin Details:\n"); - g_print (" Name:\t\t%s\n", plugin->desc.name); - g_print (" Description:\t%s\n", plugin->desc.description); - g_print (" Filename:\t%s\n", plugin->filename); - g_print (" Version:\t%s\n", plugin->desc.version); - g_print (" License:\t%s\n", plugin->desc.license); - g_print (" Package:\t%s\n", plugin->desc.package); - g_print (" Origin URL:\t%s\n", plugin->desc.origin); + g_print (" Name:\t\t%s\n", plugin->desc.name); + g_print (" Description:\t%s\n", plugin->desc.description); + g_print (" Filename:\t%s\n", plugin->filename); + g_print (" Version:\t%s\n", plugin->desc.version); + g_print (" License:\t%s\n", plugin->desc.license); + g_print (" Package:\t%s\n", plugin->desc.package); + g_print (" Origin URL:\t%s\n", plugin->desc.origin); g_print ("\n"); features = gst_plugin_get_feature_list (plugin); @@ -848,7 +860,7 @@ print_plugin_info (GstPlugin *plugin) factory = GST_ELEMENT_FACTORY (feature); g_print (" %s: %s\n", GST_OBJECT_NAME (factory), - factory->details.longname); + factory->details.longname); num_elements++; } #ifndef GST_DISABLE_INDEX @@ -866,6 +878,7 @@ print_plugin_info (GstPlugin *plugin) factory = GST_TYPE_FIND_FACTORY (feature); if (factory->extensions) { guint i = 0; + g_print ("%s type: ", plugin->desc.name); while (factory->extensions[i]) { g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); @@ -875,17 +888,15 @@ print_plugin_info (GstPlugin *plugin) g_print ("%s type: N/A\n", plugin->desc.name); num_types++; - } - else if (GST_IS_SCHEDULER_FACTORY (feature)) { + } else if (GST_IS_SCHEDULER_FACTORY (feature)) { GstSchedulerFactory *factory; factory = GST_SCHEDULER_FACTORY (feature); g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); num_schedulers++; - } - else { + } else { g_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), - g_type_name (G_OBJECT_TYPE (feature))); + g_type_name (G_OBJECT_TYPE (feature))); num_other++; } num_features++; @@ -913,15 +924,16 @@ main (int argc, char *argv[]) GstPlugin *plugin; gchar *so; struct poptOption options[] = { - {"gst-inspect-plugin", 'p', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0, - N_("Show plugin details"), NULL}, - {"gst-inspect-scheduler", 's', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0, - N_("Show scheduler details"), NULL}, + {"gst-inspect-plugin", 'p', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, 0, + N_("Show plugin details"), NULL}, + {"gst-inspect-scheduler", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, + 0, + N_("Show scheduler details"), NULL}, POPT_TABLEEND }; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gst_init_with_popt_table (&argc, &argv, options); @@ -929,62 +941,62 @@ main (int argc, char *argv[]) /* if no arguments, print out list of elements */ if (argc == 1) { - print_element_list(); + print_element_list (); - /* else we try to get a factory */ + /* else we try to get a factory */ } else { /* first check for help */ if (strstr (argv[1], "-help")) { - g_print ("Usage: %s\t\t\tList all registered elements\n",argv[0]); - g_print (" %s element-name\tShow element details\n",argv[0]); + g_print ("Usage: %s\t\t\tList all registered elements\n", argv[0]); + g_print (" %s element-name\tShow element details\n", argv[0]); g_print (" %s plugin-name[.so]\tShow information about plugin\n", - argv[0]); + argv[0]); return 0; } /* only search for a factory if there's not a '.so' */ - if (! strstr (argv[1], ".so")) { + if (!strstr (argv[1], ".so")) { factory = gst_element_factory_find (argv[1]); /* if there's a factory, print out the info */ if (factory) - return print_element_info (factory); + return print_element_info (factory); else { - GstPluginFeature* feature; - - /* FIXME implement other pretty print function for these */ - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_SCHEDULER_FACTORY); - if (feature) { - g_print ("%s: a scheduler\n", argv[1]); - return 0; - } + GstPluginFeature *feature; + + /* FIXME implement other pretty print function for these */ + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_SCHEDULER_FACTORY); + if (feature) { + g_print ("%s: a scheduler\n", argv[1]); + return 0; + } #ifndef GST_DISABLE_INDEX - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_INDEX_FACTORY); - if (feature) { - g_print ("%s: an index\n", argv[1]); - return 0; - } + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_INDEX_FACTORY); + if (feature) { + g_print ("%s: an index\n", argv[1]); + return 0; + } #endif - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_TYPE_FIND_FACTORY); - if (feature) { - g_print ("%s: a typefind function\n", argv[1]); - return 0; - } + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_TYPE_FIND_FACTORY); + if (feature) { + g_print ("%s: a typefind function\n", argv[1]); + return 0; + } #ifndef GST_DISABLE_URI - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_URI_HANDLER); - if (feature) { - g_print ("%s: an uri handler\n", argv[1]); - return 0; - } + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_URI_HANDLER); + if (feature) { + g_print ("%s: an uri handler\n", argv[1]); + return 0; + } #endif } } else { /* strip the .so */ - so = strstr(argv[1],".so"); + so = strstr (argv[1], ".so"); so[0] = '\0'; } @@ -997,7 +1009,7 @@ main (int argc, char *argv[]) print_plugin_info (plugin); } else { - g_print("no such element or plugin '%s'\n", argv[1]); + g_print ("no such element or plugin '%s'\n", argv[1]); return -1; } } diff --git a/tools/gst-launch.c b/tools/gst-launch.c index 01466f168..86eb3eb10 100644 --- a/tools/gst-launch.c +++ b/tools/gst-launch.c @@ -30,7 +30,7 @@ #include #include #include -#include /* for LC_ALL */ +#include /* for LC_ALL */ #include "gst/gst-i18n-app.h" #include @@ -67,25 +67,27 @@ idle_func (gpointer data) iterations++; g_get_current_time (&tfnow); - diff = GST_TIMEVAL_TO_TIME (tfnow) - - GST_TIMEVAL_TO_TIME (tfthen); + diff = GST_TIMEVAL_TO_TIME (tfnow) - GST_TIMEVAL_TO_TIME (tfthen); - sum += diff; + sum += diff; min = MIN (min, diff); max = MAX (max, diff); - if (!busy || caught_intr || (max_iterations>0 && iterations>=max_iterations)) { + if (!busy || caught_intr || (max_iterations > 0 + && iterations >= max_iterations)) { gst_main_quit (); - g_print (_("Execution ended after %" G_GUINT64_FORMAT " iterations (sum %" G_GUINT64_FORMAT " ns, average %" G_GUINT64_FORMAT " ns, min %" G_GUINT64_FORMAT " ns, max %" G_GUINT64_FORMAT " ns).\n"), - iterations, sum, sum/iterations, min, max); + g_print (_("Execution ended after %" G_GUINT64_FORMAT " iterations (sum %" + G_GUINT64_FORMAT " ns, average %" G_GUINT64_FORMAT " ns, min %" + G_GUINT64_FORMAT " ns, max %" G_GUINT64_FORMAT " ns).\n"), + iterations, sum, sum / iterations, min, max); } return busy; } #ifndef GST_DISABLE_LOADSAVE -static GstElement* -xmllaunch_parse_cmdline (const gchar **argv) +static GstElement * +xmllaunch_parse_cmdline (const gchar ** argv) { GstElement *pipeline = NULL, *e; GstXML *xml; @@ -94,45 +96,50 @@ xmllaunch_parse_cmdline (const gchar **argv) gchar *element, *property, *value; GList *l; gint i = 0; - + if (!(arg = argv[0])) { - g_print (_("Usage: gst-xmllaunch [ element.property=value ... ]\n")); + g_print (_ + ("Usage: gst-xmllaunch [ element.property=value ... ]\n")); exit (1); } - + xml = gst_xml_new (); - err = gst_xml_parse_file(xml, arg, NULL); - + err = gst_xml_parse_file (xml, arg, NULL); + if (err != TRUE) { fprintf (stderr, _("ERROR: parse of xml file '%s' failed.\n"), arg); exit (1); } - + l = gst_xml_get_topelements (xml); if (!l) { - fprintf (stderr, _("ERROR: no toplevel pipeline element in file '%s'.\n"), arg); + fprintf (stderr, _("ERROR: no toplevel pipeline element in file '%s'.\n"), + arg); exit (1); } - + if (l->next) - fprintf (stderr, _("WARNING: only one toplevel element is supported at this time.")); - + fprintf (stderr, + _("WARNING: only one toplevel element is supported at this time.")); + pipeline = GST_ELEMENT (l->data); - + while ((arg = argv[++i])) { element = g_strdup (arg); property = strchr (element, '.'); value = strchr (element, '='); - + if (!(element < property && property < value)) { - fprintf (stderr, _("ERROR: could not parse command line argument %d: %s.\n"), i, element); + fprintf (stderr, + _("ERROR: could not parse command line argument %d: %s.\n"), i, + element); g_free (element); exit (1); } - + *property++ = '\0'; *value++ = '\0'; - + e = gst_bin_get_by_name (GST_BIN (pipeline), element); if (!e) { fprintf (stderr, _("WARNING: element named '%s' not found.\n"), element); @@ -141,7 +148,7 @@ xmllaunch_parse_cmdline (const gchar **argv) } g_free (element); } - + if (!l) return NULL; else @@ -150,7 +157,7 @@ xmllaunch_parse_cmdline (const gchar **argv) #endif #ifndef USE_SIGINFO -static void +static void fault_handler_sighandler (int signum) { fault_restore (); @@ -167,13 +174,13 @@ fault_handler_sighandler (int signum) break; } - fault_spin(); + fault_spin (); } #else -static void -fault_handler_sigaction (int signum, siginfo_t *si, void *misc) +static void +fault_handler_sigaction (int signum, siginfo_t * si, void *misc) { fault_restore (); @@ -191,7 +198,7 @@ fault_handler_sigaction (int signum, siginfo_t *si, void *misc) break; } - fault_spin(); + fault_spin (); } #endif @@ -207,12 +214,12 @@ fault_spin (void) /* FIXME how do we know if we were run by libtool? */ g_print ("Spinning. Please run 'gdb gst-launch %d' to continue debugging, " - "Ctrl-C to quit, or Ctrl-\\ to dump core.\n", - (gint) getpid ()); - while (spinning) g_usleep (1000000); + "Ctrl-C to quit, or Ctrl-\\ to dump core.\n", (gint) getpid ()); + while (spinning) + g_usleep (1000000); } -static void +static void fault_restore (void) { struct sigaction action; @@ -224,7 +231,7 @@ fault_restore (void) sigaction (SIGQUIT, &action, NULL); } -static void +static void fault_setup (void) { struct sigaction action; @@ -242,7 +249,7 @@ fault_setup (void) } static void -print_tag (const GstTagList *list, const gchar *tag, gpointer unused) +print_tag (const GstTagList * list, const gchar * tag, gpointer unused) { gint i, count; @@ -250,14 +257,14 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused) for (i = 0; i < count; i++) { gchar *str; - + if (gst_tag_get_type (tag) == G_TYPE_STRING) { g_assert (gst_tag_list_get_string_index (list, tag, i, &str)); } else { - str = g_strdup_value_contents ( - gst_tag_list_get_value_index (list, tag, i)); + str = + g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); } - + if (i == 0) { g_print ("%15s: %s\n", gst_tag_get_nick (tag), str); } else { @@ -268,10 +275,10 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused) } } static void -found_tag (GObject *pipeline, GstElement *source, GstTagList *tags) +found_tag (GObject * pipeline, GstElement * source, GstTagList * tags) { g_print (_("FOUND TAG : found by element \"%s\".\n"), - GST_STR_NULL (GST_ELEMENT_NAME (source))); + GST_STR_NULL (GST_ELEMENT_NAME (source))); gst_tag_list_foreach (tags, print_tag, NULL); } @@ -281,7 +288,7 @@ sigint_handler_sighandler (int signum) { g_print ("Caught interrupt.\n"); - sigint_restore(); + sigint_restore (); caught_intr = TRUE; } @@ -297,7 +304,7 @@ sigint_setup (void) sigaction (SIGINT, &action, NULL); } -static void +static void sigint_restore (void) { struct sigaction action; @@ -324,7 +331,7 @@ play_handler (int signum) } static void -play_signal_setup(void) +play_signal_setup (void) { struct sigaction action; @@ -335,9 +342,10 @@ play_signal_setup(void) } int -main(int argc, char *argv[]) +main (int argc, char *argv[]) { gint i, j; + /* options */ gboolean verbose = FALSE; gboolean tags = FALSE; @@ -346,22 +354,22 @@ main(int argc, char *argv[]) gchar *savefile = NULL; gchar *exclude_args = NULL; struct poptOption options[] = { - {"tags", 't', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &tags, 0, - N_("Output tags (also known as metadata)"), NULL}, - {"verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0, - N_("Output status information and property notifications"), NULL}, - {"exclude", 'X', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &exclude_args, 0, - N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")}, + {"tags", 't', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &tags, 0, + N_("Output tags (also known as metadata)"), NULL}, + {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0, + N_("Output status information and property notifications"), NULL}, + {"exclude", 'X', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &exclude_args, 0, + N_("Do not output status information of TYPE"), N_("TYPE1,TYPE2,...")}, #ifndef GST_DISABLE_LOADSAVE - {"output", 'o', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, &savefile, 0, - N_("Save xml representation of pipeline to FILE and exit"), N_("FILE")}, + {"output", 'o', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, &savefile, 0, + N_("Save xml representation of pipeline to FILE and exit"), N_("FILE")}, #endif - {"no-fault", 'f', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &no_fault, 0, - N_("Do not install a fault handler"), NULL}, - {"trace", 'T', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &trace, 0, - N_("Print alloc trace (if enabled at compile time)"), NULL}, - {"iterations",'i',POPT_ARG_INT|POPT_ARGFLAG_STRIP, &max_iterations, 0, - N_("Number of times to iterate pipeline"), NULL}, + {"no-fault", 'f', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &no_fault, 0, + N_("Do not install a fault handler"), NULL}, + {"trace", 'T', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &trace, 0, + N_("Print alloc trace (if enabled at compile time)"), NULL}, + {"iterations", 'i', POPT_ARG_INT | POPT_ARGFLAG_STRIP, &max_iterations, 0, + N_("Number of times to iterate pipeline"), NULL}, POPT_TABLEEND }; @@ -369,10 +377,10 @@ main(int argc, char *argv[]) GError *error = NULL; gint res = 0; - free (malloc (8)); /* -lefence */ + free (malloc (8)); /* -lefence */ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gst_alloc_trace_set_flags_all (GST_ALLOC_TRACE_LIVE); @@ -384,9 +392,10 @@ main(int argc, char *argv[]) for (i = 1; i < argc; i++) { if (*(argv[i]) == '-') { if (strlen (argv[i]) == 2) { - gchar *c = argv[i]; - c++; - if (*c == 'X' || *c == 'o') { + gchar *c = argv[i]; + + c++; + if (*c == 'X' || *c == 'o') { i++; } } @@ -398,77 +407,82 @@ main(int argc, char *argv[]) argc = j; if (!no_fault) - fault_setup(); + fault_setup (); + + sigint_setup (); + play_signal_setup (); - sigint_setup(); - play_signal_setup(); - if (trace) { - if (!gst_alloc_trace_available()) { + if (!gst_alloc_trace_available ()) { g_warning ("Trace not available (recompile with trace enabled)."); } gst_alloc_trace_print_all (); } /* make a null-terminated version of argv */ - argvn = g_new0 (char*, argc); - memcpy (argvn, argv+1, sizeof (char*) * (argc-1)); + argvn = g_new0 (char *, argc); + memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1)); #ifndef GST_DISABLE_LOADSAVE if (strstr (argv[0], "gst-xmllaunch")) { - pipeline = xmllaunch_parse_cmdline ((const gchar**)argvn); - } - else + pipeline = xmllaunch_parse_cmdline ((const gchar **) argvn); + } else #endif { - pipeline = (GstElement*) gst_parse_launchv ((const gchar**)argvn, &error); + pipeline = + (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error); } g_free (argvn); if (!pipeline) { if (error) { - fprintf(stderr, _("ERROR: pipeline could not be constructed: %s.\n"), - error->message); + fprintf (stderr, _("ERROR: pipeline could not be constructed: %s.\n"), + error->message); g_error_free (error); } else { - fprintf(stderr, _("ERROR: pipeline could not be constructed.\n")); + fprintf (stderr, _("ERROR: pipeline could not be constructed.\n")); } - exit(1); + exit (1); } else if (error) { - fprintf(stderr, _("WARNING: erroneous pipeline: %s\n"), error->message); - fprintf(stderr, _(" Trying to run anyway.\n")); + fprintf (stderr, _("WARNING: erroneous pipeline: %s\n"), error->message); + fprintf (stderr, _(" Trying to run anyway.\n")); g_error_free (error); } - + if (verbose) { - gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL; - g_signal_connect (pipeline, "deep_notify", G_CALLBACK (gst_element_default_deep_notify), exclude_list); + gchar **exclude_list = + exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL; + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), exclude_list); } if (tags) { g_signal_connect (pipeline, "found-tag", G_CALLBACK (found_tag), NULL); } - g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), NULL); - + g_signal_connect (pipeline, "error", G_CALLBACK (gst_element_default_error), + NULL); + #ifndef GST_DISABLE_LOADSAVE if (savefile) { gst_xml_write_file (GST_ELEMENT (pipeline), fopen (savefile, "w")); } #endif - + if (!savefile) { - + if (!GST_IS_BIN (pipeline)) { GstElement *real_pipeline = gst_element_factory_make ("pipeline", NULL); + if (real_pipeline == NULL) { - fprintf(stderr, _("ERROR: the 'pipeline' element wasn't found.\n")); - exit(1); + fprintf (stderr, _("ERROR: the 'pipeline' element wasn't found.\n")); + exit (1); } gst_bin_add (GST_BIN (real_pipeline), pipeline); pipeline = real_pipeline; } - fprintf(stderr, _("RUNNING pipeline ...\n")); - if (gst_element_set_state (pipeline, GST_STATE_PLAYING) == GST_STATE_FAILURE) { - fprintf(stderr, _("ERROR: pipeline doesn't want to play.\n")); + fprintf (stderr, _("RUNNING pipeline ...\n")); + if (gst_element_set_state (pipeline, + GST_STATE_PLAYING) == GST_STATE_FAILURE) { + fprintf (stderr, _("ERROR: pipeline doesn't want to play.\n")); res = -1; goto end; } @@ -476,12 +490,12 @@ main(int argc, char *argv[]) s_clock = gst_bin_get_clock (GST_BIN (pipeline)); if (!GST_FLAG_IS_SET (GST_OBJECT (pipeline), GST_BIN_SELF_SCHEDULABLE)) { - g_idle_add (idle_func, pipeline); - gst_main (); + g_idle_add (idle_func, pipeline); + gst_main (); } else { - g_print ("Waiting for the state change... "); - gst_element_wait_state_change (pipeline); - g_print ("got the state change.\n"); + g_print ("Waiting for the state change... "); + gst_element_wait_state_change (pipeline); + g_print ("got the state change.\n"); } gst_element_set_state (pipeline, GST_STATE_NULL); diff --git a/tools/gst-md5sum.c b/tools/gst-md5sum.c index 0863c9514..032e05ca3 100644 --- a/tools/gst-md5sum.c +++ b/tools/gst-md5sum.c @@ -29,19 +29,18 @@ idle_func (gpointer data) iterations++; g_get_current_time (&tfnow); - diff = GST_TIMEVAL_TO_TIME (tfnow) - - GST_TIMEVAL_TO_TIME (tfthen); + diff = GST_TIMEVAL_TO_TIME (tfnow) - GST_TIMEVAL_TO_TIME (tfthen); - sum += diff; + sum += diff; min = MIN (min, diff); max = MAX (max, diff); if (!busy) { gst_main_quit (); /* - g_print ("execution ended after %llu iterations (sum %llu ns, average %llu ns, min %llu ns, max %llu ns)\n", - iterations, sum, sum/iterations, min, max); - */ + g_print ("execution ended after %llu iterations (sum %llu ns, average %llu ns, min %llu ns, max %llu ns)\n", + iterations, sum, sum/iterations, min, max); + */ } return busy; @@ -54,8 +53,8 @@ main (int argc, char *argv[]) gboolean verbose = FALSE; gchar *exclude_args = NULL; struct poptOption options[] = { - {"verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0, - "do not output status information", NULL}, + {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0, + "do not output status information", NULL}, POPT_TABLEEND }; @@ -65,7 +64,7 @@ main (int argc, char *argv[]) GstElement *md5sink; gchar *md5string = g_malloc0 (33); - free (malloc (8)); /* -lefence */ + free (malloc (8)); /* -lefence */ setlocale (LC_ALL, ""); @@ -77,21 +76,18 @@ main (int argc, char *argv[]) /* Check if we have an element already that is called md5sink0 in the pipeline; if not, add one */ - pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error); + pipeline = (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error); if (!pipeline) { - if (error) - { + if (error) { g_warning ("pipeline could not be constructed: %s\n", error->message); g_error_free (error); - } - else + } else g_warning ("pipeline could not be constructed\n"); return 1; } md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0"); - if (md5sink == NULL) - { + if (md5sink == NULL) { g_print ("adding an md5sink element to the pipeline\n"); /* make a null-terminated version of argv with ! md5sink appended * ! is stored in argvn[argc - 1], md5sink in argvn[argc], @@ -101,41 +97,38 @@ main (int argc, char *argv[]) memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1)); argvn[argc - 1] = g_strdup_printf ("!"); argvn[argc] = g_strdup_printf ("md5sink"); - pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error); + pipeline = + (GstElement *) gst_parse_launchv ((const gchar **) argvn, &error); } if (!pipeline) { - if (error) - { + if (error) { g_warning ("pipeline could not be constructed: %s\n", error->message); g_error_free (error); - } - else + } else g_warning ("pipeline could not be constructed\n"); return 1; } - - if (verbose) - { - gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0) - : NULL; - g_signal_connect (pipeline, "deep_notify", - G_CALLBACK (gst_element_default_deep_notify), - exclude_list); + + if (verbose) { + gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0) + : NULL; + + g_signal_connect (pipeline, "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), exclude_list); } - g_signal_connect (pipeline, "error", - G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (pipeline, "error", + G_CALLBACK (gst_element_default_error), NULL); - if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) - { + if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS) { g_warning ("pipeline doesn't want to play\n"); return 0; } - + if (!GST_FLAG_IS_SET (GST_OBJECT (pipeline), GST_BIN_SELF_SCHEDULABLE)) { g_idle_add (idle_func, pipeline); gst_main (); - } else { + } else { gst_element_wait_state_change (pipeline); } diff --git a/tools/gst-register.c b/tools/gst-register.c index cca2105bf..5e6f41bb0 100644 --- a/tools/gst-register.c +++ b/tools/gst-register.c @@ -40,17 +40,18 @@ static gint num_features = 0; static gint num_plugins = 0; static void -plugin_added_func (GstRegistry *registry, GstPlugin *plugin, gpointer user_data) +plugin_added_func (GstRegistry * registry, GstPlugin * plugin, + gpointer user_data) { g_print ("added plugin %s with %d feature(s)\n", plugin->desc.name, - plugin->numfeatures); + plugin->numfeatures); num_features += plugin->numfeatures; num_plugins++; } static void -spawn_all_in_dir(const char *dirname) +spawn_all_in_dir (const char *dirname) { char *argv[2] = { NULL, NULL }; GDir *dir; @@ -59,25 +60,28 @@ spawn_all_in_dir(const char *dirname) /* g_print("spawning all in %s\n", dirname); */ dir = g_dir_open (dirname, 0, NULL); - if (dir == NULL) return; - - while( (file = g_dir_read_name (dir)) ){ - argv[0] = g_build_filename(dirname, file, NULL); - g_print("running %s\n",argv[0]); - g_spawn_sync (NULL, argv, NULL, G_SPAWN_FILE_AND_ARGV_ZERO, NULL, NULL, NULL, NULL, NULL, NULL); - g_free(argv[0]); + if (dir == NULL) + return; + + while ((file = g_dir_read_name (dir))) { + argv[0] = g_build_filename (dirname, file, NULL); + g_print ("running %s\n", argv[0]); + g_spawn_sync (NULL, argv, NULL, G_SPAWN_FILE_AND_ARGV_ZERO, NULL, NULL, + NULL, NULL, NULL, NULL); + g_free (argv[0]); } - g_dir_close(dir); + g_dir_close (dir); } -int main (int argc,char *argv[]) +int +main (int argc, char *argv[]) { GList *registries; - GList *path_spill = NULL; /* used for path spill from failing registries */ + GList *path_spill = NULL; /* used for path spill from failing registries */ - setlocale(LC_ALL, ""); + setlocale (LC_ALL, ""); - /* Init gst */ + /* Init gst */ _gst_registry_auto_load = FALSE; gst_init (&argc, &argv); @@ -90,17 +94,15 @@ int main (int argc,char *argv[]) GList *iter; char *dir; - if (path_spill) - { + if (path_spill) { GList *iter; /* add spilled paths to this registry; * since they're spilled they probably weren't loaded correctly * so we should give a lower priority registry the chance to do them */ - for (iter = path_spill; iter; iter = iter->next) - { + for (iter = path_spill; iter; iter = iter->next) { g_print ("added path %s to %s \n", - (const char *) iter->data, registry->name); + (const char *) iter->data, registry->name); gst_registry_add_path (registry, (const gchar *) iter->data); } g_list_free (path_spill); @@ -108,41 +110,42 @@ int main (int argc,char *argv[]) } g_signal_connect (G_OBJECT (registry), "plugin_added", - G_CALLBACK (plugin_added_func), NULL); + G_CALLBACK (plugin_added_func), NULL); if (registry->flags & GST_REGISTRY_WRITABLE) { char *location; + g_object_get (registry, "location", &location, NULL); g_print ("rebuilding %s (%s)\n", registry->name, location); g_free (location); gst_registry_rebuild (registry); gst_registry_save (registry); - } - else { + } else { g_print ("trying to load %s\n", registry->name); - if (!gst_registry_load (registry)) - { + if (!gst_registry_load (registry)) { g_print ("error loading %s\n", registry->name); /* move over paths from this registry to the next one */ path_spill = g_list_concat (path_spill, - gst_registry_get_path_list (registry)); + gst_registry_get_path_list (registry)); g_assert (path_spill != NULL); } /* also move over paths if the registry wasn't writable * FIXME: we should check if the paths that were loaded from this - registry get removed from the path_list so we only try to - spill paths that could not be registered */ + registry get removed from the path_list so we only try to + spill paths that could not be registered */ path_spill = g_list_concat (path_spill, - gst_registry_get_path_list (registry)); + gst_registry_get_path_list (registry)); } - dir_list = gst_registry_get_path_list(registry); - for(iter = dir_list; iter; iter = iter->next) { - dir = g_build_filename((const char *)iter->data, "register-scripts", NULL); - spawn_all_in_dir(dir); - g_free(dir); + dir_list = gst_registry_get_path_list (registry); + for (iter = dir_list; iter; iter = iter->next) { + dir = + g_build_filename ((const char *) iter->data, "register-scripts", + NULL); + spawn_all_in_dir (dir); + g_free (dir); } - g_list_free(dir_list); + g_list_free (dir_list); registries = g_list_next (registries); } @@ -151,4 +154,3 @@ int main (int argc,char *argv[]) return (0); } - diff --git a/tools/gst-run.c b/tools/gst-run.c index d9a1ed7bd..6e1fe44e5 100644 --- a/tools/gst-run.c +++ b/tools/gst-run.c @@ -40,75 +40,69 @@ enum /* global statics for option parsing */ static gboolean _print = FALSE; -static gchar * _arg_mm = NULL; +static gchar *_arg_mm = NULL; static gboolean _arg_list_mm = FALSE; /* callback to parse arguments */ static void popt_callback (poptContext context, enum poptCallbackReason reason, - const struct poptOption *option, const char *arg, void *data) + const struct poptOption *option, const char *arg, void *data) { - if (reason == POPT_CALLBACK_REASON_OPTION) - { - switch (option->val) - { + if (reason == POPT_CALLBACK_REASON_OPTION) { + switch (option->val) { case ARG_MM: - _arg_mm = g_strdup (arg); - break; + _arg_mm = g_strdup (arg); + break; case ARG_LIST_MM: - _arg_list_mm = TRUE; - break; + _arg_list_mm = TRUE; + break; case ARG_PRINT: - _print = TRUE; - break; + _print = TRUE; + break; case ARG_HELP: - poptPrintHelp (context, stdout, 0); - g_print ("\n"); - break; + poptPrintHelp (context, stdout, 0); + g_print ("\n"); + break; } - } - else - { + } else { g_print ("Unknown reason for callback\n"); } } /* popt options table for the wrapper */ -static struct poptOption wrapper_options[] = -{ - { NULL, '\0', - POPT_ARG_CALLBACK, - (void *) &popt_callback, 0, NULL, NULL }, - { "help", '\0', - POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, - NULL, ARG_HELP, ("Show help"), NULL }, - { "?", '\0', - POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH - | POPT_ARGFLAG_DOC_HIDDEN, - NULL, ARG_HELP, NULL, NULL }, +static struct poptOption wrapper_options[] = { + {NULL, '\0', + POPT_ARG_CALLBACK, + (void *) &popt_callback, 0, NULL, NULL}, + {"help", '\0', + POPT_ARG_NONE | POPT_ARGFLAG_DOC_HIDDEN, + NULL, ARG_HELP, ("Show help"), NULL}, + {"?", '\0', + POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH + | POPT_ARGFLAG_DOC_HIDDEN, + NULL, ARG_HELP, NULL, NULL}, /* We cheat by specifying -p as long "p" with onedash, so that it also gets stripped properly from our arg flags */ - { "p", '\0', - POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH - | POPT_ARGFLAG_DOC_HIDDEN, - NULL, ARG_PRINT, NULL, NULL }, - { "print", '\0', - POPT_ARG_NONE | POPT_ARGFLAG_STRIP, - NULL, ARG_PRINT, ("Print wrapped command line"), NULL }, - { "gst-mm", '\0', - POPT_ARG_STRING | POPT_ARGFLAG_STRIP, - NULL, ARG_MM, ("Force major/minor version"), NULL }, - { "gst-list-mm", '\0', - POPT_ARG_NONE | POPT_ARGFLAG_STRIP, - NULL, ARG_LIST_MM, ("List found major/minor versions"), NULL }, + {"p", '\0', + POPT_ARG_NONE | POPT_ARGFLAG_STRIP | POPT_ARGFLAG_ONEDASH + | POPT_ARGFLAG_DOC_HIDDEN, + NULL, ARG_PRINT, NULL, NULL}, + {"print", '\0', + POPT_ARG_NONE | POPT_ARGFLAG_STRIP, + NULL, ARG_PRINT, ("Print wrapped command line"), NULL}, + {"gst-mm", '\0', + POPT_ARG_STRING | POPT_ARGFLAG_STRIP, + NULL, ARG_MM, ("Force major/minor version"), NULL}, + {"gst-list-mm", '\0', + POPT_ARG_NONE | POPT_ARGFLAG_STRIP, + NULL, ARG_LIST_MM, ("List found major/minor versions"), NULL}, POPT_TABLEEND }; /* helper table including our wrapper options */ -static struct poptOption options[] = -{ - { NULL, '\0', POPT_ARG_INCLUDE_TABLE, wrapper_options, 0, - "Wrapper options:", NULL}, +static struct poptOption options[] = { + {NULL, '\0', POPT_ARG_INCLUDE_TABLE, wrapper_options, 0, + "Wrapper options:", NULL}, POPT_TABLEEND }; @@ -123,12 +117,12 @@ hash_print_key (gchar * key, gchar * value) static void find_highest_version (gchar * key, gchar * value, gchar ** highest) { - if (*highest == NULL) - { + if (*highest == NULL) { /* first value, so just set it */ *highest = key; } - if (strcmp (key, *highest) > 0) *highest = key; + if (strcmp (key, *highest) > 0) + *highest = key; } /* Libtool creates shell scripts named "base" that calls actual binaries as @@ -139,12 +133,16 @@ unmangle_libtool (gchar ** dir, gchar ** base) { gchar *new_dir, *new_base; - if (!*dir) return; - if (!*base) return; + if (!*dir) + return; + if (!*base) + return; /* we assume libtool when base starts with lt- and dir ends with .libs */ - if (!g_str_has_prefix (*base, "lt-")) return; - if (!g_str_has_suffix (*dir, ".libs")) return; + if (!g_str_has_prefix (*base, "lt-")) + return; + if (!g_str_has_suffix (*dir, ".libs")) + return; new_base = g_strdup (&((*base)[3])); new_dir = g_path_get_dirname (*dir); @@ -174,10 +172,8 @@ get_dir_of_binary (const gchar * binary) * specified which caused get_basename to return "." */ full = g_build_filename (dir, base, NULL); - if (strcmp (full, binary) != 0) - { - if (strcmp (dir, ".") != 0) - { + if (strcmp (full, binary) != 0) { + if (strcmp (dir, ".") != 0) { g_warning ("This should not happen, g_path_get_dirname () has changed."); g_free (base); g_free (dir); @@ -188,8 +184,7 @@ get_dir_of_binary (const gchar * binary) /* we know no path was specified, so search standard path for binary */ g_free (full); full = g_find_program_in_path (base); - if (!full) - { + if (!full) { g_warning ("This should not happen, %s not in standard path.", base); g_free (base); g_free (dir); @@ -237,55 +232,50 @@ get_candidates (const gchar * dir, const gchar * base) /* get all dirs from the path and prepend with given dir */ path = g_strdup_printf ("%s%c%s", - dir, G_SEARCHPATH_SEPARATOR, g_getenv ("PATH")); + dir, G_SEARCHPATH_SEPARATOR, g_getenv ("PATH")); dirs = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 0); g_free (path); /* check all of these in reverse order by winding to bottom and going up */ cur = &dirs[0]; - while (*cur) ++cur; + while (*cur) + ++cur; - while (cur != &dirs[0]) - { + while (cur != &dirs[0]) { --cur; - if (! g_file_test (*cur, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) + if (!g_file_test (*cur, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) continue; gdir = g_dir_open (*cur, 0, &error); - if (! gdir) - { + if (!gdir) { g_warning ("Could not open dir %s: %s", *cur, error->message); g_error_free (error); return NULL; } - while ((entry = g_dir_read_name (gdir))) - { - if (g_pattern_match_string (spec, entry)) - { - gchar *full; - - /* is it executable ? */ - full = g_build_filename (*cur, entry, NULL); - if (! g_file_test (full, G_FILE_TEST_IS_EXECUTABLE)) - { - g_free (full); - continue; - } - g_free (full); - - /* strip base and dash from it */ - suffix = g_strdup (&(entry[strlen (base) + 1])); - - /* stricter pattern check: check if it only contains digits or dots */ - test = g_strdup (suffix); - g_strcanon (test, "0123456789.", 'X'); - if (strstr (test, "X")) - { - g_free (test); - continue; - } - g_free (test); - g_hash_table_insert (candidates, suffix, g_strdup (*cur)); + while ((entry = g_dir_read_name (gdir))) { + if (g_pattern_match_string (spec, entry)) { + gchar *full; + + /* is it executable ? */ + full = g_build_filename (*cur, entry, NULL); + if (!g_file_test (full, G_FILE_TEST_IS_EXECUTABLE)) { + g_free (full); + continue; + } + g_free (full); + + /* strip base and dash from it */ + suffix = g_strdup (&(entry[strlen (base) + 1])); + + /* stricter pattern check: check if it only contains digits or dots */ + test = g_strdup (suffix); + g_strcanon (test, "0123456789.", 'X'); + if (strstr (test, "X")) { + g_free (test); + continue; + } + g_free (test); + g_hash_table_insert (candidates, suffix, g_strdup (*cur)); } } } @@ -295,8 +285,7 @@ get_candidates (const gchar * dir, const gchar * base) return candidates; } -int main -(int argc, char **argv) +int main (int argc, char **argv) { GHashTable *candidates; gchar *dir; @@ -311,13 +300,13 @@ int main ctx = poptGetContext ("gst-run", argc, (const char **) argv, options, 0); poptReadDefaultConfig (ctx, TRUE); while ((nextopt = poptGetNextOpt (ctx)) > 0) - /* keep looping to parse */; + /* keep looping to parse */ ; argc = poptStrippedArgv (ctx, argc, argv); argv[argc] = NULL; poptFreeContext (ctx); - /* detect stuff */ + /* detect stuff */ dir = get_dir_of_binary (argv[0]); base = g_path_get_basename (argv[0]); @@ -328,24 +317,19 @@ int main candidates = get_candidates (dir, base); g_free (dir); - if (_arg_mm) - { + if (_arg_mm) { /* if a version was forced, look it up in the hash table */ dir = g_hash_table_lookup (candidates, _arg_mm); - if (!dir) - { + if (!dir) { g_print ("ERROR: Major/minor %s of tool %s not found.\n", _arg_mm, base); return 1; } binary = g_strdup_printf ("%s-%s", base, _arg_mm); - } - else - { + } else { highest = NULL; /* otherwise, just look up the highest version */ - g_hash_table_foreach (candidates, (GHFunc) find_highest_version, - &highest); + g_hash_table_foreach (candidates, (GHFunc) find_highest_version, &highest); if (highest == NULL) { g_print ("ERROR: No version of tool %s not found.\n", base); return 1; @@ -361,8 +345,7 @@ int main /* print out list of major/minors we found if asked for */ /* FIXME: do them in order by creating a GList of keys and sort them */ - if (_arg_list_mm) - { + if (_arg_list_mm) { g_hash_table_foreach (candidates, (GHFunc) hash_print_key, NULL); g_hash_table_destroy (candidates); return 0; @@ -370,20 +353,19 @@ int main /* print out command line if asked for */ argv[0] = path; - if (_print) - { + if (_print) { int i; - for (i = 0; i < argc; ++i) - { + + for (i = 0; i < argc; ++i) { g_print ("%s", argv[i]); - if (i < argc - 1) g_print (" "); + if (i < argc - 1) + g_print (" "); } g_print ("\n"); } /* execute */ - if (execv (path, argv) == -1) - { + if (execv (path, argv) == -1) { g_warning ("Error executing %s: %s (%d)", path, g_strerror (errno), errno); } g_free (path); diff --git a/tools/gst-typefind.c b/tools/gst-typefind.c index d6ae0c867..225031967 100644 --- a/tools/gst-typefind.c +++ b/tools/gst-typefind.c @@ -15,15 +15,17 @@ gboolean FOUND = FALSE; gchar *filename = NULL; void -gst_caps_print (const char *filename, const GstCaps *caps) +gst_caps_print (const char *filename, const GstCaps * caps) { gchar *caps_str = gst_caps_to_string (caps); + g_print ("%s - %s\n", filename, caps_str); g_free (caps_str); } void -have_type_handler (GstElement *typefind, guint probability, const GstCaps *caps, gpointer unused) +have_type_handler (GstElement * typefind, guint probability, + const GstCaps * caps, gpointer unused) { gst_caps_print (filename, caps); FOUND = TRUE; @@ -40,11 +42,11 @@ main (int argc, char *argv[]) gst_init (&argc, &argv); - if (argc < 2) { + if (argc < 2) { g_print ("Please give a filename to typefind\n\n"); return 1; } - + pipeline = gst_pipeline_new (NULL); source = gst_element_factory_make ("filesrc", "source"); g_assert (GST_IS_ELEMENT (source)); @@ -52,8 +54,8 @@ main (int argc, char *argv[]) g_assert (GST_IS_ELEMENT (typefind)); gst_bin_add_many (GST_BIN (pipeline), source, typefind, NULL); gst_element_link (source, typefind); - g_signal_connect (G_OBJECT (typefind), "have-type", - G_CALLBACK (have_type_handler), NULL); + g_signal_connect (G_OBJECT (typefind), "have-type", + G_CALLBACK (have_type_handler), NULL); while (i < argc) { FOUND = FALSE; @@ -63,7 +65,7 @@ main (int argc, char *argv[]) /* set to play */ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); - while (!FOUND) { + while (!FOUND) { if (!gst_bin_iterate (GST_BIN (pipeline))) break; } diff --git a/tools/gst-xmlinspect.c b/tools/gst-xmlinspect.c index 7ebb17c22..e235c4661 100644 --- a/tools/gst-xmlinspect.c +++ b/tools/gst-xmlinspect.c @@ -46,7 +46,7 @@ G_STMT_START{ \ #endif static void -print_caps (const GstCaps *caps, gint pfx) +print_caps (const GstCaps * caps, gint pfx) { char *s; @@ -55,11 +55,11 @@ print_caps (const GstCaps *caps, gint pfx) s = gst_caps_to_string (caps); PUT_ESCAPED (pfx, "caps", s); - g_free(s); + g_free (s); } static void -print_formats (const GstFormat *formats, gint pfx) +print_formats (const GstFormat * formats, gint pfx) { while (formats && *formats) { const GstFormatDefinition *definition; @@ -67,17 +67,16 @@ print_formats (const GstFormat *formats, gint pfx) definition = gst_format_get_details (*formats); if (definition) PUT_STRING (pfx, "%s", - *formats, definition->nick, definition->description); + *formats, definition->nick, definition->description); else - PUT_STRING (pfx, "unknown", - *formats); + PUT_STRING (pfx, "unknown", *formats); formats++; } } static void -print_query_types (const GstQueryType *types, gint pfx) +print_query_types (const GstQueryType * types, gint pfx) { while (types && *types) { const GstQueryTypeDefinition *definition; @@ -85,17 +84,16 @@ print_query_types (const GstQueryType *types, gint pfx) definition = gst_query_type_get_details (*types); if (definition) PUT_STRING (pfx, "%s", - *types, definition->nick, definition->description); + *types, definition->nick, definition->description); else - PUT_STRING (pfx, "unknown", - *types); + PUT_STRING (pfx, "unknown", *types); types++; } } static void -print_event_masks (const GstEventMask *masks, gint pfx) +print_event_masks (const GstEventMask * masks, gint pfx) { #ifndef GST_DISABLE_ENUMTYPES GType event_type; @@ -103,7 +101,7 @@ print_event_masks (const GstEventMask *masks, gint pfx) GType event_flags; GFlagsClass *flags_class = NULL; - event_type = gst_event_type_get_type(); + event_type = gst_event_type_get_type (); klass = (GEnumClass *) g_type_class_ref (event_type); while (masks && masks->type) { @@ -112,28 +110,27 @@ print_event_masks (const GstEventMask *masks, gint pfx) switch (masks->type) { case GST_EVENT_SEEK: - flags = masks->flags; - event_flags = gst_seek_type_get_type (); - flags_class = (GFlagsClass *) g_type_class_ref (event_flags); - break; + flags = masks->flags; + event_flags = gst_seek_type_get_type (); + flags_class = (GFlagsClass *) g_type_class_ref (event_flags); + break; default: - break; + break; } value = g_enum_get_value (klass, masks->type); - PUT_STRING (pfx, "", - value->value_nick); + PUT_STRING (pfx, "", value->value_nick); while (flags) { GFlagsValue *value; if (flags & 1) { - value = g_flags_get_first_value (flags_class, 1 << index); + value = g_flags_get_first_value (flags_class, 1 << index); - if (value) - PUT_ESCAPED (pfx + 1, "flag", value->value_nick); - else - PUT_ESCAPED (pfx + 1, "flag", "?"); + if (value) + PUT_ESCAPED (pfx + 1, "flag", value->value_nick); + else + PUT_ESCAPED (pfx + 1, "flag", "?"); } flags >>= 1; index++; @@ -146,7 +143,7 @@ print_event_masks (const GstEventMask *masks, gint pfx) } static void -output_hierarchy (GType type, gint level, gint *maxlevel) +output_hierarchy (GType type, gint level, gint * maxlevel) { GType parent; @@ -164,20 +161,21 @@ output_hierarchy (GType type, gint level, gint *maxlevel) } static void -print_element_properties (GstElement *element, gint pfx) +print_element_properties (GstElement * element, gint pfx) { GParamSpec **property_specs; - gint num_properties,i; + gint num_properties, i; gboolean readable; property_specs = g_object_class_list_properties - (G_OBJECT_GET_CLASS (element), &num_properties); + (G_OBJECT_GET_CLASS (element), &num_properties); PUT_START_TAG (pfx, "element-properties"); for (i = 0; i < num_properties; i++) { GValue value = { 0, }; GParamSpec *param = property_specs[i]; + readable = FALSE; g_value_init (&value, param->value_type); @@ -187,145 +185,150 @@ print_element_properties (GstElement *element, gint pfx) } PUT_START_TAG (pfx + 1, "element-property"); PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (param)); - PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type)); + PUT_ESCAPED (pfx + 2, "type", g_type_name (param->value_type)); PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (param)); PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (param)); if (readable) { PUT_ESCAPED (pfx + 2, "flags", "RW"); - } - else { + } else { PUT_ESCAPED (pfx + 2, "flags", "W"); } switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; case G_TYPE_BOOLEAN: - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; case G_TYPE_ULONG: { - GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); - PUT_STRING (pfx + 2, "", - pulong->minimum, pulong->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); + + PUT_STRING (pfx + 2, "", + pulong->minimum, pulong->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_LONG: { - GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); - PUT_STRING (pfx + 2, "", - plong->minimum, plong->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); + + PUT_STRING (pfx + 2, "", + plong->minimum, plong->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_UINT: { - GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); - PUT_STRING (pfx + 2, "", - puint->minimum, puint->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); + + PUT_STRING (pfx + 2, "", + puint->minimum, puint->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_INT: { - GParamSpecInt *pint = G_PARAM_SPEC_INT (param); - PUT_STRING (pfx + 2, "", - pint->minimum, pint->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecInt *pint = G_PARAM_SPEC_INT (param); + + PUT_STRING (pfx + 2, "", + pint->minimum, pint->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_UINT64: { - GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); - PUT_STRING (pfx + 2, "", - puint64->minimum, puint64->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); + + PUT_STRING (pfx + 2, + "", puint64->minimum, puint64->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_INT64: { - GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); - PUT_STRING (pfx + 2, "", - pint64->minimum, pint64->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); + + PUT_STRING (pfx + 2, + "", pint64->minimum, pint64->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_FLOAT: { - GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); - PUT_STRING (pfx + 2, "", - pfloat->minimum, pfloat->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); + + PUT_STRING (pfx + 2, "", + pfloat->minimum, pfloat->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } case G_TYPE_DOUBLE: { - GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); - PUT_STRING (pfx + 2, "", - pdouble->minimum, pdouble->maximum); - PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); - break; + GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); + + PUT_STRING (pfx + 2, "", + pdouble->minimum, pdouble->maximum); + PUT_ESCAPED (pfx + 2, "default", g_strdup_value_contents (&value)); + break; } default: - if (param->value_type == GST_TYPE_CAPS) { - GstCaps *caps = g_value_peek_pointer (&value); - - if (!caps) - PUT_ESCAPED (pfx + 2, "default", "NULL"); - else { - print_caps (caps, 2); - } - } - else if (G_IS_PARAM_SPEC_ENUM (param)) { - GEnumValue *values; - guint j = 0; - gint enum_value; - - values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; - enum_value = g_value_get_enum (&value); - - while (values[j].value_name) { - if (values[j].value == enum_value) - break; - j++; - } - PUT_STRING (pfx + 2, "%d", values[j].value); - - PUT_START_TAG (pfx + 2, "enum-values"); - j = 0; - while (values[j].value_name) { - PUT_STRING (pfx + 3, "", - values[j].value, values[j].value_nick); - j++; - } - PUT_END_TAG (pfx + 2, "enum-values"); - } - else if (G_IS_PARAM_SPEC_FLAGS (param)) { - GFlagsValue *values; - guint j = 0; - gint flags_value; - - values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; - flags_value = g_value_get_flags (&value); - - PUT_STRING (pfx + 2, "%d", flags_value); - - PUT_START_TAG (pfx + 2, "flags"); - j = 0; - while (values[j].value_name) { - PUT_STRING (pfx + 3, "", - values[j].value, values[j].value_nick); - j++; - } - PUT_END_TAG (pfx + 2, "flags"); - } - else if (G_IS_PARAM_SPEC_OBJECT (param)) { - PUT_ESCAPED (pfx + 2, "object-type", - g_type_name(param->value_type)); - } - break; + if (param->value_type == GST_TYPE_CAPS) { + GstCaps *caps = g_value_peek_pointer (&value); + + if (!caps) + PUT_ESCAPED (pfx + 2, "default", "NULL"); + else { + print_caps (caps, 2); + } + } else if (G_IS_PARAM_SPEC_ENUM (param)) { + GEnumValue *values; + guint j = 0; + gint enum_value; + + values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; + enum_value = g_value_get_enum (&value); + + while (values[j].value_name) { + if (values[j].value == enum_value) + break; + j++; + } + PUT_STRING (pfx + 2, "%d", values[j].value); + + PUT_START_TAG (pfx + 2, "enum-values"); + j = 0; + while (values[j].value_name) { + PUT_STRING (pfx + 3, "", + values[j].value, values[j].value_nick); + j++; + } + PUT_END_TAG (pfx + 2, "enum-values"); + } else if (G_IS_PARAM_SPEC_FLAGS (param)) { + GFlagsValue *values; + guint j = 0; + gint flags_value; + + values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; + flags_value = g_value_get_flags (&value); + + PUT_STRING (pfx + 2, "%d", flags_value); + + PUT_START_TAG (pfx + 2, "flags"); + j = 0; + while (values[j].value_name) { + PUT_STRING (pfx + 3, "", + values[j].value, values[j].value_nick); + j++; + } + PUT_END_TAG (pfx + 2, "flags"); + } else if (G_IS_PARAM_SPEC_OBJECT (param)) { + PUT_ESCAPED (pfx + 2, "object-type", g_type_name (param->value_type)); + } + break; } PUT_END_TAG (pfx + 1, "element-property"); @@ -334,48 +337,49 @@ print_element_properties (GstElement *element, gint pfx) } static void -print_element_dynparamaters (GstElement *element, gint pfx) +print_element_dynparamaters (GstElement * element, gint pfx) { - GstDParamManager* dpman; - GParamSpec** specs; + GstDParamManager *dpman; + GParamSpec **specs; gint x; PUT_START_TAG (pfx, "dyn-params"); - if((dpman = gst_dpman_get_manager (element))) { + if ((dpman = gst_dpman_get_manager (element))) { specs = gst_dpman_list_dparam_specs (dpman); for (x = 0; specs[x] != NULL; x++) { PUT_START_TAG (pfx + 1, "dyn-param"); PUT_ESCAPED (pfx + 2, "name", g_param_spec_get_name (specs[x])); - PUT_ESCAPED (pfx + 2, "type", g_type_name (specs[x]->value_type)); - PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (specs[x])); - PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (specs[x])); + PUT_ESCAPED (pfx + 2, "type", g_type_name (specs[x]->value_type)); + PUT_ESCAPED (pfx + 2, "nick", g_param_spec_get_nick (specs[x])); + PUT_ESCAPED (pfx + 2, "blurb", g_param_spec_get_blurb (specs[x])); switch (G_PARAM_SPEC_VALUE_TYPE (specs[x])) { - case G_TYPE_INT64: - PUT_STRING (pfx + 2, "", - ((GParamSpecInt64 *) specs[x])->minimum, - ((GParamSpecInt64 *) specs[x])->maximum); - PUT_STRING (pfx + 2, "%"G_GINT64_FORMAT"", - ((GParamSpecInt64 *) specs[x])->default_value); - break; - case G_TYPE_INT: - PUT_STRING (pfx + 2, "", - ((GParamSpecInt *) specs[x])->minimum, - ((GParamSpecInt *) specs[x])->maximum); - PUT_STRING (pfx + 2, "%d", - ((GParamSpecInt *) specs[x])->default_value); - break; - case G_TYPE_FLOAT: - PUT_STRING (pfx + 2, "", - ((GParamSpecFloat *) specs[x])->minimum, - ((GParamSpecFloat *) specs[x])->maximum); - PUT_STRING (pfx + 2, "%f", - ((GParamSpecFloat *) specs[x])->default_value); - break; - default: - break; + case G_TYPE_INT64: + PUT_STRING (pfx + 2, + "", ((GParamSpecInt64 *) specs[x])->minimum, + ((GParamSpecInt64 *) specs[x])->maximum); + PUT_STRING (pfx + 2, "%" G_GINT64_FORMAT "", + ((GParamSpecInt64 *) specs[x])->default_value); + break; + case G_TYPE_INT: + PUT_STRING (pfx + 2, "", + ((GParamSpecInt *) specs[x])->minimum, + ((GParamSpecInt *) specs[x])->maximum); + PUT_STRING (pfx + 2, "%d", + ((GParamSpecInt *) specs[x])->default_value); + break; + case G_TYPE_FLOAT: + PUT_STRING (pfx + 2, "", + ((GParamSpecFloat *) specs[x])->minimum, + ((GParamSpecFloat *) specs[x])->maximum); + PUT_STRING (pfx + 2, "%f", + ((GParamSpecFloat *) specs[x])->default_value); + break; + default: + break; } PUT_END_TAG (pfx + 1, "dyn-param"); } @@ -385,7 +389,7 @@ print_element_dynparamaters (GstElement *element, gint pfx) } static void -print_element_signals (GstElement *element, gint pfx) +print_element_signals (GstElement * element, gint pfx) { guint *signals; guint nsignals; @@ -407,30 +411,31 @@ print_element_signals (GstElement *element, gint pfx) const GType *param_types; gint j; - query = g_new0 (GSignalQuery,1); + query = g_new0 (GSignalQuery, 1); g_signal_query (signals[i], query); if ((k == 0 && !(query->signal_flags & G_SIGNAL_ACTION)) || - (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) { - n_params = query->n_params; - return_type = query->return_type; - param_types = query->param_types; - - PUT_START_TAG (pfx + 1, "signal"); - PUT_ESCAPED (pfx + 2, "name", query->signal_name); - PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type)); - PUT_ESCAPED (pfx + 2, "object-type", g_type_name (G_OBJECT_TYPE (element))); - - PUT_START_TAG (pfx + 2, "params"); - for (j = 0; j < n_params; j++) { - PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j])); - } + (k == 1 && (query->signal_flags & G_SIGNAL_ACTION))) { + n_params = query->n_params; + return_type = query->return_type; + param_types = query->param_types; + + PUT_START_TAG (pfx + 1, "signal"); + PUT_ESCAPED (pfx + 2, "name", query->signal_name); + PUT_ESCAPED (pfx + 2, "return-type", g_type_name (return_type)); + PUT_ESCAPED (pfx + 2, "object-type", + g_type_name (G_OBJECT_TYPE (element))); + + PUT_START_TAG (pfx + 2, "params"); + for (j = 0; j < n_params; j++) { + PUT_ESCAPED (pfx + 3, "type", g_type_name (param_types[j])); + } - PUT_END_TAG (pfx + 2, "params"); + PUT_END_TAG (pfx + 2, "params"); - PUT_END_TAG (pfx + 1, "signal"); + PUT_END_TAG (pfx + 1, "signal"); - counted++; + counted++; } g_free (query); @@ -443,7 +448,7 @@ print_element_signals (GstElement *element, gint pfx) } static gint -print_element_info (GstElementFactory *factory) +print_element_info (GstElementFactory * factory) { GstElement *element; GstObjectClass *gstobject_class; @@ -468,10 +473,10 @@ print_element_info (GstElementFactory *factory) gstelement_class = GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (element)); PUT_START_TAG (1, "details"); - PUT_ESCAPED (2, "long-name", factory->details.longname); - PUT_ESCAPED (2, "class", factory->details.klass); - PUT_ESCAPED (2, "description",factory->details.description); - PUT_ESCAPED (2, "authors", factory->details.author); + PUT_ESCAPED (2, "long-name", factory->details.longname); + PUT_ESCAPED (2, "class", factory->details.klass); + PUT_ESCAPED (2, "description", factory->details.description); + PUT_ESCAPED (2, "authors", factory->details.author); PUT_END_TAG (1, "details"); output_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); @@ -480,33 +485,32 @@ print_element_info (GstElementFactory *factory) if (factory->numpadtemplates) { pads = factory->padtemplates; while (pads) { - padtemplate = (GstPadTemplate*)(pads->data); - pads = g_list_next(pads); + padtemplate = (GstPadTemplate *) (pads->data); + pads = g_list_next (pads); PUT_START_TAG (2, "pad-template"); - PUT_ESCAPED (3, "name", padtemplate->name_template); + PUT_ESCAPED (3, "name", padtemplate->name_template); if (padtemplate->direction == GST_PAD_SRC) - PUT_ESCAPED (3, "direction", "src"); + PUT_ESCAPED (3, "direction", "src"); else if (padtemplate->direction == GST_PAD_SINK) - PUT_ESCAPED (3, "direction", "sink"); + PUT_ESCAPED (3, "direction", "sink"); else - PUT_ESCAPED (3, "direction", "unkown"); + PUT_ESCAPED (3, "direction", "unkown"); if (padtemplate->presence == GST_PAD_ALWAYS) - PUT_ESCAPED (3, "presence", "always"); + PUT_ESCAPED (3, "presence", "always"); else if (padtemplate->presence == GST_PAD_SOMETIMES) - PUT_ESCAPED (3, "presence", "sometimes"); + PUT_ESCAPED (3, "presence", "sometimes"); else if (padtemplate->presence == GST_PAD_REQUEST) { - PUT_ESCAPED (3, "presence", "request"); - PUT_ESCAPED (3, "request-function", - GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad)); - } - else - PUT_ESCAPED (3, "presence", "unkown"); + PUT_ESCAPED (3, "presence", "request"); + PUT_ESCAPED (3, "request-function", + GST_DEBUG_FUNCPTR_NAME (gstelement_class->request_new_pad)); + } else + PUT_ESCAPED (3, "presence", "unkown"); if (padtemplate->caps) { - print_caps (padtemplate->caps, 3); + print_caps (padtemplate->caps, 3); } PUT_END_TAG (2, "pad-template"); } @@ -547,16 +551,16 @@ print_element_info (GstElementFactory *factory) PUT_START_TAG (1, "element-implementation"); if (element->loopfunc) PUT_STRING (2, "", - GST_DEBUG_FUNCPTR_NAME (element->loopfunc)); + GST_DEBUG_FUNCPTR_NAME (element->loopfunc)); PUT_STRING (2, "", - GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state)); + GST_DEBUG_FUNCPTR_NAME (gstelement_class->change_state)); #ifndef GST_DISABLE_LOADSAVE PUT_STRING (2, "", - GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself)); + GST_DEBUG_FUNCPTR_NAME (gstobject_class->save_thyself)); PUT_STRING (2, "", - GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself)); + GST_DEBUG_FUNCPTR_NAME (gstobject_class->restore_thyself)); #endif PUT_END_TAG (1, "element-implementation"); @@ -582,6 +586,7 @@ print_element_info (GstElementFactory *factory) PUT_START_TAG (1, "pads"); if (element->numpads) { const GList *pads; + pads = gst_element_get_pad_list (element); while (pads) { pad = GST_PAD (pads->data); @@ -589,68 +594,67 @@ print_element_info (GstElementFactory *factory) realpad = GST_PAD_REALIZE (pad); PUT_START_TAG (2, "pad"); - PUT_ESCAPED (3, "name", gst_pad_get_name (pad)); + PUT_ESCAPED (3, "name", gst_pad_get_name (pad)); if (gst_pad_get_direction (pad) == GST_PAD_SRC) - PUT_ESCAPED (3, "direction", "src"); + PUT_ESCAPED (3, "direction", "src"); else if (gst_pad_get_direction (pad) == GST_PAD_SINK) - PUT_ESCAPED (3, "direction", "sink"); + PUT_ESCAPED (3, "direction", "sink"); else - PUT_ESCAPED (3, "direction", "unkown"); + PUT_ESCAPED (3, "direction", "unkown"); if (GST_IS_GHOST_PAD (pad)) - PUT_ESCAPED (3, "ghost", gst_pad_get_name (pad)); + PUT_ESCAPED (3, "ghost", gst_pad_get_name (pad)); if (pad->padtemplate) - PUT_ESCAPED (3, "template", - pad->padtemplate->name_template); + PUT_ESCAPED (3, "template", pad->padtemplate->name_template); PUT_START_TAG (3, "implementation"); if (realpad->chainfunc) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->chainfunc)); if (realpad->getfunc) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->getfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->getfunc)); if (realpad->formatsfunc != gst_pad_get_formats_default) { - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->formatsfunc)); - print_formats (gst_pad_get_formats (GST_PAD (realpad)), 5); - PUT_END_TAG (4, "formats-function"); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->formatsfunc)); + print_formats (gst_pad_get_formats (GST_PAD (realpad)), 5); + PUT_END_TAG (4, "formats-function"); } if (realpad->convertfunc != gst_pad_convert_default) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->convertfunc)); if (realpad->eventfunc != gst_pad_event_default) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->eventfunc)); if (realpad->eventmaskfunc != gst_pad_get_event_masks_default) { - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->eventmaskfunc)); - print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)), 5); - PUT_END_TAG (4, "event-mask-func"); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->eventmaskfunc)); + print_event_masks (gst_pad_get_event_masks (GST_PAD (realpad)), 5); + PUT_END_TAG (4, "event-mask-func"); } if (realpad->queryfunc != gst_pad_query_default) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->queryfunc)); if (realpad->querytypefunc != gst_pad_get_query_types_default) { - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME (realpad->querytypefunc)); - print_query_types (gst_pad_get_query_types (GST_PAD (realpad)), 5); - PUT_END_TAG (4, "query-type-func"); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->querytypefunc)); + print_query_types (gst_pad_get_query_types (GST_PAD (realpad)), 5); + PUT_END_TAG (4, "query-type-func"); } if (realpad->intlinkfunc != gst_pad_get_internal_links_default) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME(realpad->intlinkfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->intlinkfunc)); if (realpad->bufferallocfunc) - PUT_STRING (4, "", - GST_DEBUG_FUNCPTR_NAME(realpad->bufferallocfunc)); + PUT_STRING (4, "", + GST_DEBUG_FUNCPTR_NAME (realpad->bufferallocfunc)); PUT_END_TAG (3, "implementation"); if (realpad->caps) { - print_caps (realpad->caps, 3); + print_caps (realpad->caps, 3); } PUT_END_TAG (2, "pad"); } @@ -683,12 +687,12 @@ print_element_list (void) { GList *plugins; - plugins = gst_registry_pool_plugin_list(); + plugins = gst_registry_pool_plugin_list (); while (plugins) { GList *features; GstPlugin *plugin; - plugin = (GstPlugin*)(plugins->data); + plugin = (GstPlugin *) (plugins->data); plugins = g_list_next (plugins); features = gst_plugin_get_feature_list (plugin); @@ -698,27 +702,28 @@ print_element_list (void) feature = GST_PLUGIN_FEATURE (features->data); if (GST_IS_ELEMENT_FACTORY (feature)) { - GstElementFactory *factory; + GstElementFactory *factory; - factory = GST_ELEMENT_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory) ,factory->details.longname); + factory = GST_ELEMENT_FACTORY (feature); + g_print ("%s: %s: %s\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (factory), factory->details.longname); } #ifndef GST_DISABLE_INDEX else if (GST_IS_INDEX_FACTORY (feature)) { - GstIndexFactory *factory; + GstIndexFactory *factory; - factory = GST_INDEX_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); + factory = GST_INDEX_FACTORY (feature); + g_print ("%s: %s: %s\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); } #endif else if (GST_IS_TYPE_FIND_FACTORY (feature)) { - GstTypeFindFactory *factory; + GstTypeFindFactory *factory; factory = GST_TYPE_FIND_FACTORY (feature); - if (factory->extensions) { + if (factory->extensions) { guint i = 0; + g_print ("%s type: ", plugin->desc.name); while (factory->extensions[i]) { g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); @@ -726,18 +731,16 @@ print_element_list (void) } } else g_print ("%s type: N/A\n", plugin->desc.name); - } - else if (GST_IS_SCHEDULER_FACTORY (feature)) { - GstSchedulerFactory *factory; - - factory = GST_SCHEDULER_FACTORY (feature); - g_print ("%s: %s: %s\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); - } - else { - g_print ("%s: %s (%s)\n", plugin->desc.name, - GST_PLUGIN_FEATURE_NAME (feature), - g_type_name (G_OBJECT_TYPE (feature))); + } else if (GST_IS_SCHEDULER_FACTORY (feature)) { + GstSchedulerFactory *factory; + + factory = GST_SCHEDULER_FACTORY (feature); + g_print ("%s: %s: %s\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc); + } else { + g_print ("%s: %s (%s)\n", plugin->desc.name, + GST_PLUGIN_FEATURE_NAME (feature), + g_type_name (G_OBJECT_TYPE (feature))); } features = g_list_next (features); @@ -746,7 +749,7 @@ print_element_list (void) } static void -print_plugin_info (GstPlugin *plugin) +print_plugin_info (GstPlugin * plugin) { GList *features; gint num_features = 0; @@ -758,13 +761,13 @@ print_plugin_info (GstPlugin *plugin) gint num_other = 0; g_print ("Plugin Details:\n"); - g_print (" Name:\t\t%s\n", plugin->desc.name); - g_print (" Description:\t%s\n", plugin->desc.description); - g_print (" Filename:\t%s\n", plugin->filename); - g_print (" Version:\t%s\n", plugin->desc.version); - g_print (" License:\t%s\n", plugin->desc.license); - g_print (" Package:\t%s\n", plugin->desc.package); - g_print (" Origin URL:\t%s\n", plugin->desc.origin); + g_print (" Name:\t\t%s\n", plugin->desc.name); + g_print (" Description:\t%s\n", plugin->desc.description); + g_print (" Filename:\t%s\n", plugin->filename); + g_print (" Version:\t%s\n", plugin->desc.version); + g_print (" License:\t%s\n", plugin->desc.license); + g_print (" Package:\t%s\n", plugin->desc.package); + g_print (" Origin URL:\t%s\n", plugin->desc.origin); g_print ("\n"); features = gst_plugin_get_feature_list (plugin); @@ -779,7 +782,7 @@ print_plugin_info (GstPlugin *plugin) factory = GST_ELEMENT_FACTORY (feature); g_print (" %s: %s\n", GST_OBJECT_NAME (factory), - factory->details.longname); + factory->details.longname); num_elements++; } #ifndef GST_DISABLE_INDEX @@ -797,6 +800,7 @@ print_plugin_info (GstPlugin *plugin) factory = GST_TYPE_FIND_FACTORY (feature); if (factory->extensions) { guint i = 0; + g_print ("%s type: ", plugin->desc.name); while (factory->extensions[i]) { g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]); @@ -805,17 +809,15 @@ print_plugin_info (GstPlugin *plugin) } else g_print ("%s type: N/A\n", plugin->desc.name); num_types++; - } - else if (GST_IS_SCHEDULER_FACTORY (feature)) { + } else if (GST_IS_SCHEDULER_FACTORY (feature)) { GstSchedulerFactory *factory; factory = GST_SCHEDULER_FACTORY (feature); g_print (" %s: %s\n", GST_OBJECT_NAME (factory), factory->longdesc); num_schedulers++; - } - else { + } else { g_print (" %s (%s)\n", gst_object_get_name (GST_OBJECT (feature)), - g_type_name (G_OBJECT_TYPE (feature))); + g_type_name (G_OBJECT_TYPE (feature))); num_other++; } num_features++; @@ -846,11 +848,12 @@ main (int argc, char *argv[]) GstPlugin *plugin; gchar *so; struct poptOption options[] = { - {"gst-inspect-plugin", 'p', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0, - "Show plugin details", NULL}, - {"gst-inspect-scheduler", 's', POPT_ARG_STRING|POPT_ARGFLAG_STRIP, NULL, 0, - "Show scheduler details", NULL}, - POPT_TABLEEND + {"gst-inspect-plugin", 'p', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, 0, + "Show plugin details", NULL}, + {"gst-inspect-scheduler", 's', POPT_ARG_STRING | POPT_ARGFLAG_STRIP, NULL, + 0, + "Show scheduler details", NULL}, + POPT_TABLEEND }; setlocale (LC_ALL, ""); @@ -862,62 +865,62 @@ main (int argc, char *argv[]) /* if no arguments, print out list of elements */ if (argc == 1) { - print_element_list(); + print_element_list (); - /* else we try to get a factory */ + /* else we try to get a factory */ } else { /* first check for help */ if (strstr (argv[1], "-help")) { g_print ("Usage: %s\t\t\tList all registered elements\n", argv[0]); g_print (" %s element-name\tShow element details\n", argv[0]); g_print (" %s plugin-name[.so]\tShow information about plugin\n", - argv[0]); + argv[0]); return 0; } /* only search for a factory if there's not a '.so' */ - if (! strstr (argv[1], ".so")) { + if (!strstr (argv[1], ".so")) { factory = gst_element_factory_find (argv[1]); /* if there's a factory, print out the info */ if (factory) - return print_element_info (factory); + return print_element_info (factory); else { - GstPluginFeature* feature; - - /* FIXME implement other pretty print function for these */ - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_SCHEDULER_FACTORY); - if (feature) { - g_print ("%s: a scheduler\n", argv[1]); - return 0; - } + GstPluginFeature *feature; + + /* FIXME implement other pretty print function for these */ + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_SCHEDULER_FACTORY); + if (feature) { + g_print ("%s: a scheduler\n", argv[1]); + return 0; + } #ifndef GST_DISABLE_INDEX - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_INDEX_FACTORY); - if (feature) { - g_print ("%s: an index\n", argv[1]); - return 0; - } + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_INDEX_FACTORY); + if (feature) { + g_print ("%s: an index\n", argv[1]); + return 0; + } #endif - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_TYPE_FIND_FACTORY); - if (feature) { - g_print ("%s: a type find function\n", argv[1]); - return 0; - } + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_TYPE_FIND_FACTORY); + if (feature) { + g_print ("%s: a type find function\n", argv[1]); + return 0; + } #ifndef GST_DISABLE_URI - feature = gst_registry_pool_find_feature (argv[1], - GST_TYPE_URI_HANDLER); - if (feature) { - g_print ("%s: an uri handler\n", argv[1]); - return 0; - } + feature = gst_registry_pool_find_feature (argv[1], + GST_TYPE_URI_HANDLER); + if (feature) { + g_print ("%s: an uri handler\n", argv[1]); + return 0; + } #endif } } else { /* strip the .so */ - so = strstr(argv[1],".so"); + so = strstr (argv[1], ".so"); so[0] = '\0'; } @@ -929,7 +932,7 @@ main (int argc, char *argv[]) if (plugin) { print_plugin_info (plugin); } else { - g_print("no such element or plugin '%s'\n", argv[1]); + g_print ("no such element or plugin '%s'\n", argv[1]); return -1; } } -- 2.39.2