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.
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.
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
}
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.
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.