Gst-gi: read-metadata sample

Hi all

I am working slowly on translating
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/tests/examples/metadata/read-metadata.cin
ruby.

By the way I have commited a fix on Gst::Element#pause method.

Hi,

In [email protected]
“[ruby-gnome2-devel-en] gst-gi: read-metadata sample” on Mon, 11 Feb
2013 20:10:59 +0100,
Vincent C. [email protected] wrote:

I am working slowly on translatinghttp://cgit.freedesktop.org/gstreamer/
gstreamer/tree/tests/examples/metadata/read-metadata.c in ruby.

Thanks.

By the way I have commited a fix onGst::Element#pause method.

Thanks. I’ve confirmed it. (Sorry for my typo. :<)


kou

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] gst-gi: read-metadata sample” on Wed, 13
Feb 2013 21:48:13 +0100,
Vincent C. [email protected] wrote:

Linkingfilesrc anddecodebin elements in pipeline does not seems to be
enough to read a file. I get:
GStreamer encountered a general stream error.
gstbaseparse.c(3008): gst_base_parse_loop (): /GstPipeline:pipeline/
GstDecodeBin:decodebin/GstMpegAudioParse:mpegaudioparse0:
streaming stopped, reason not-linked
I do not what step in the C sample I am missing. Can I have help on that point
?

It seems that the C sample just ignores it:
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/tests/examples/metadata/read-metadata.c#n60

Gst::Message#parse_tag returnsa array.Can it return more than 1 list?If
not I believe we should change for a Gst::TagList.

Could you give me a file that has tag?

Getter methods are not aliased (:get_attr but no :attr)

get_state? “get_” isn’t removed from get_XXX that requires
one or more arguments. This is a rule of Ruby-GNOME2 packages.

Methods (at least Pipeline#get_state) can be called with more arguments than
the maximum number ofarguments.

I’ve added the number of arguments validation.

Allforeachmethods should be named each.

Callingforeach on aGst::TagList object raises
/usr/local/lib/site_ruby/1.9.1/gobject-introspection/loader.rb:256:in invoke': TODO: func callback is not supported yet. (NotImplementedError) from /usr/local/lib/site_ruby/1.9.1/gobject-introspection/loader.rb:256:inblock in load_method_info’
from ./es.rb:67:in `’

I’ll check them after I get a sample file that has tags.

Thanks,

kou

Hi

I am still figthing with this sample. The non working code can be seem
at
the end of the mail.
It is a little bit complicate (class definition) for a short sample.

Here are my findings so far:

Linking filesrc and decodebin elements in pipeline does not seems to be
enough to read a file. I get:
GStreamer encountered a general stream error.
gstbaseparse.c(3008): gst_base_parse_loop ():
/GstPipeline:pipeline/GstDecodeBin:decodebin/GstMpegAudioParse:mpegaudioparse0:
streaming stopped, reason not-linked
I do not what step in the C sample I am missing. Can I have help on that
point ?
I used playbin element to tested the tag part of the code.

Gst::Message#parse_tag returns a array. Can it return more than 1 list?
If
not I believe we should change for a Gst::TagList.

Getter methods are not aliased (:get_attr but no :attr)

Methods (at least Pipeline#get_state) can be called with more arguments
than the maximum number of arguments.

All foreach methods should be named each.

Calling foreach on a Gst::TagList object raises
/usr/local/lib/site_ruby/1.9.1/gobject-introspection/loader.rb:256:in
invoke': TODO: func callback is not supported yet. (NotImplementedError) from /usr/local/lib/site_ruby/1.9.1/gobject-introspection/loader.rb:256:inblock in load_method_info’
from ./es.rb:67:in `’

code:

encoding: utf-8

if ARGV.length < 1
puts "usage: #{$0} "
exit 1
end

require ‘gst’
Gst.init

#TODO define Exceptions
class Pipeline < Gst::Pipeline
@@new_pipe_per_file=true
#@@new_pipe_per_file=false

def self.pipeline
if @@new_pipe_per_file
new(“pipeline”)
else
@pipeline||=new(“pipeline”)
end
end

attr_reader :location

def initialize(name)
pipeline=super
@source=Gst::ElementFactory.make(“filesrc”, “source”)
raise “‘filesrc’ gstreamer plugin missing” if @source.nil?
decodebin=Gst::ElementFactory.make(“decodebin”, “decodebin”)
raise “‘decodebin’ gstreamer plugin missing” if decodebin.nil?
pipeline << @source << decodebin
@source >> decodebin
pipeline
end

def location=(file)
@location=file
@[email protected]
end

def stop
super
check_state_returned(super)
end

def pause
check_state_returned(super)
end

def bus
(@bus||=super) || raise(“Bus not found”)
end

def tags
tags=Gst::TagList.new
while message=bus.pop
#case message#Not working
case message.type
when Gst::MessageType::ERROR
puts message.parse_error
when Gst::MessageType::EOS
puts “EOS”
break
when Gst::MessageType::TAG
tags.merge(message.parse_tag.first, Gst::TagMergeMode::KEEP)#parse_tag
return a array. Why? Can it return more than 1 list. If not change
behaviour.
end
end
tags
end

private

def check_state_returned(sret)
return if sret==Gst::StateChangeReturn::SUCCESS
if sret==Gst::StateChangeReturn::ASYNC
#Gst::Pipeline#state not defined (fixme ?)
return if
get_state(5*Gst::SECOND).first==Gst::StateChangeReturn::SUCCESS#is
timeout
really the 1st arg? No check on number of arguments.
end
#raise “State failed to changed”#Commented to see the debug message
end
end

ARGV.each do |filename|
pipeline=Pipeline.pipeline
pipeline.stop
pipeline.location=filename
begin

Decodebin will only commit to PAUSED if it actually finds a type

otherwise the state change fails

pipeline.pause
tags=pipeline.tags
if tags.empty?
puts “No metadata found for #{filename}”
else
#tags.each do |tag|#TODO rename for all methods foreach. Not only for
Gst::TagList
tags.foreach do |tag|#gobject-introspection/loader.rb:256:in `invoke’:
TODO: func callback is not supported yet. (NotImplementedError)
p tag
end
end
rescue => error
puts “#{error.message} (#{filename})”
next
end
end

Hi

I have attached a sample mp3 file with tags and a ruby script using
playbin
to read the tags as I amm not able to read them with decodebin (yet). No
tag message is sent on the bus!

As stated before Gst::TagList#foreach is not impemented.
Gst::TagList#merge
does not seems to work correctly

I have committed a fix in
GObjectIntrospection::Loader#define_module_function. validate_arguments was
called with only the 1st argument.

By the way, helloworld sample is broken. Gst::ElementFactory.make
expects
2 arguments. I have a patch who fix it by aliasing and redefining the
method in a gst/elementfactory.rb. Should I push it to the git repo? Or
should we think how to define argument default value for a given list of
methods at GObjectIntrospection level?

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] gst-gi: read-metadata sample” on Fri, 15
Feb 2013 19:38:02 +0100,
Vincent C. [email protected] wrote:

I have attached a sample mp3 file with tags and a ruby script using playbin to
read the tags as I ammnot able to read them with decodebin (yet). No tag
message is sent on the bus!

As stated beforeGst::TagList#foreach is not impemented.Gst::TagList#merge
does not seems to work correctly

Thanks. I can confirm it with the file.
And I’ve implemented the callback that is used by
Gst::TagList#each. (I’ve mapped foreach to each. :slight_smile:

And #parse_tag returns Gst::TagList instead of an array of
Gst::TagList.

Could you try master again?

Thanks,

kou

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] gst-gi: read-metadata sample” on Sat, 16
Feb 2013 15:04:31 +0100,
Vincent C. [email protected] wrote:

Do we want to support conversion to an enumerator for object having an
each method ? There are very handy.
Would it ease the implementation to delegate loop and Proc gestion? Is too
hard to get an enumerator from a gobject?

I’ve implemented it. :slight_smile:

And #parse_tag returns Gst::TagList instead of an array of
Gst::TagList

Works fine.

Good. :slight_smile:

Thanks,

kou

Hi

2013/2/16 Kouhei S. [email protected]

message is sent on the bus!

As stated before Gst::TagList#foreach is not
impemented. Gst::TagList#merge
does not seems to work correctly

Thanks. I can confirm it with the file.
And I’ve implemented the callback that is used by
Gst::TagList#each. (I’ve mapped foreach to each. :slight_smile:

It works fine!
Do we want to support conversion to an enumerator for object having an
each method ? There are very handy.
Would it ease the implementation to delegate loop and Proc gestion? Is
too
hard to get an enumerator from a gobject?

[0, 1].each
=> #<Enumerator: [0, 1]:each>
my_taglist…each
=> gobject-introspection/loader.rb:278:in invoke': tried to create Proc object without a block (ArgumentError) => gobject-introspection/loader.rb:278:inblock in load_method_info’

And #parse_tag returns Gst::TagList instead of an array of
Gst::TagList

Works fine.

thought
leadership blogs to news, videos, case studies, tutorials, tech docs,
whitepapers, evaluation guides, and opinion stories. Check out the most
recent posts - join the conversation now.
http://goparallel.sourceforge.net/


ruby-gnome2-devel-en mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en

Thanks Kou for these implementations.

Hi all

I still can read tags with decodebin element (see read-metada.rb). Tag
signals are never emitted. Maybe it is due to my version of Gst. Can you
try?

Gst.version
=> [1, 0, 1, 0]

Nethertheless I am able to read tags with playbin element.
I found the TagList#each not very convenient. It does not iterate on
each
tag but gives the whole list and a tag name for each iteration.
In es.rb I redifine each method to use a hash. Original each method is
accessible via gi_each in case someone needs access to GLib::Value
objects.

What do you think?
Should I commit TagList#to_hash and TagList#each?
In that should I use strings or symbols for hash keys? Usually I
prefer symbols but here the keys are tag name

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs