Gstreamer "level" plugin

hello all,

i would like to implement a peak db meter through gstreamer (thanks to
marcin for posting his meter module) - and i’m wondering about the use
of the “level” plugin.

i see from the gstreamer documentation (
level)
that the plugin emits a message called “level” at a given interval…
unfortunately i really can’t make heads nor tails of the documentation’s
example as it’s written in C (i believe,) and i’m just a simple ruby
guy…

anyone have experience with this plugin and how to catch the messages?
i’ve watched my bus for messages after creating the plugin and adding it
to my pipeline, but don’t see any of type “level”.

plugin.messages? returns true, and plugin.get_state shows it playing,
so i assume it is correctly added to the pipeline, and sending messages

  • i just can’t figure out how to catch and parse them.

here’s a code snippet:

@pipeline = Gst::ElementFactory.make(“playbin2”)
@plugin = Gst::ElementFactory.make(“level”)
@pipeline.add(@plugin)
bus = @pipeline.bus
bus.add_watch {|bus, message|p message; true}

… truncated

then i play the pipeline - i get state changed, element, stream status,
and tag messages, but nothing that looks like “level” being regularly
emitted.

thanks in advance for any ideas,

-j

2011/3/19 J. K. [email protected]:

hello all,

Hi

anyone have experience with this plugin and how to catch the messages?
i’ve watched my bus for messages after creating the plugin and adding it
to my pipeline, but don’t see any of type “level”.

The message_handler function in C sample code shows that level message
are GST_MESSAGE_ELEMENT kind ones. Then infos are parsed from the
structure retrieved from the message.

Here is the same sample in ruby :

require ‘gst’

audiotestsrc=Gst::ElementFactory.make(“audiotestsrc”)
audioconvert=Gst::ElementFactory.make(“audioconvert”)
level=Gst::ElementFactory.make(“level”)
fakesink=Gst::ElementFactory.make(“fakesink”)
pipeline=Gst::Pipeline.new
pipeline.add(audiotestsrc, audioconvert, level, fakesink)
#pipeline.add(audiotestsrc, audioconvert, fakesink)
audiotestsrc >> audioconvert >> level >> fakesink
pipeline.ready
pipeline.bus.add_watch {|bus, message|
case message
when Gst::MessageError
puts message.parse
when Gst::MessageElement
struc=message.structure
if struc.name==“level”
p struc[“rms”][0]
struc.each{|key, val| puts “#{key}=#{val}”}
end
end
true
}

mainloop=GLib::MainLoop.new
pipeline.play
mainloop.run


Vincent C.

vincent -

i saw that the message was of element type, but didn’t know how to
catch it - greatly appreciate the translation to ruby, i’m getting the
hang of C, but it’s still a bit tricky for me to translate from C to
ruby.

going to play around and see what i come up with…

thanks again,

-jk

2011/3/20 J. K. [email protected]:

vincent -

i saw that the message was of element type, but didn’t know how to
catch it - greatly appreciate the translation to ruby, i’m getting the
hang of C, but it’s still a bit tricky for me to translate from C to
ruby.

going to play around and see what i come up with…

thanks again,

You are welcome.

Best Open Source Mac Front-Ends 2023


ruby-gnome2-devel-en mailing list
[email protected]
ruby-gnome2-devel-en List Signup and Options


Vincent C.