Forum: Ruby-Gnome 2 gst-gi: read-metadata sample

C4a836af7263f84a4f7cc91ed6f3ae77?d=identicon&s=25 Vincent Carmona (vinc-mai)
on 2013-02-11 20:11
(Received via mailing list)
Hi all

I am working slowly on translating
http://cgit.freedesktop.org/gstreamer/gstreamer/tr...
ruby.

By the way I have commited a fix on Gst::Element#pause method.
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2013-02-12 13:35
(Received via mailing list)
Hi,

In <CAENqjqenSH7YDYTbVnKGikh350m76xC4ttW5UnoPWLO8nv-TJg@mail.gmail.com>
  "[ruby-gnome2-devel-en] gst-gi: read-metadata sample" on Mon, 11 Feb
2013 20:10:59 +0100,
  Vincent Carmona <vinc4mai@gmail.com> 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
C4a836af7263f84a4f7cc91ed6f3ae77?d=identicon&s=25 Vincent Carmona (vinc-mai)
on 2013-02-13 21:49
(Received via mailing list)
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:in
`block in load_method_info'
from ./es.rb:67:in `<main>'


code:

# encoding: utf-8

if ARGV.length < 1
puts "usage: #{$0} <filenames>"
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
@source.location=@location
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
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2013-02-15 14:33
(Received via mailing list)
Hi,

In <CAENqjqc8Tnvn=VB_wnB5RTV-VZnbCauLMSzAjjQvfU7gm0eRmA@mail.gmail.com>
  "Re: [ruby-gnome2-devel-en] gst-gi: read-metadata sample" on Wed, 13
Feb 2013 21:48:13 +0100,
  Vincent Carmona <vinc4mai@gmail.com> 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/tr...

> 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:in
> `block in load_method_info'
> from ./es.rb:67:in `<main>'

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


Thanks,
--
kou
C4a836af7263f84a4f7cc91ed6f3ae77?d=identicon&s=25 Vincent Carmona (vinc-mai)
on 2013-02-15 19:38
(Received via mailing list)
Attachment: es.rb (2 KB)
Attachment: test.mp3 (20 KB)
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
C4a836af7263f84a4f7cc91ed6f3ae77?d=identicon&s=25 Vincent Carmona (vinc-mai)
on 2013-02-15 21:17
(Received via mailing list)
>
> 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?
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2013-02-16 09:21
(Received via mailing list)
Hi,

In <CAENqjqc-01ZEsSR=XLfeHY2S9TSWvmoFGxVuuGUpOhCKefu4VQ@mail.gmail.com>
  "Re: [ruby-gnome2-devel-en] gst-gi: read-metadata sample" on Fri, 15
Feb 2013 19:38:02 +0100,
  Vincent Carmona <vinc4mai@gmail.com> 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. :-)

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

Could you try master again?

Thanks,
--
kou
C4a836af7263f84a4f7cc91ed6f3ae77?d=identicon&s=25 Vincent Carmona (vinc-mai)
on 2013-02-16 15:05
(Received via mailing list)
Hi

2013/2/16 Kouhei Sutou <kou@cozmixng.org>

> > 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. :-)
>
> 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:in `block 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
> ruby-gnome2-devel-en@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ruby-...
>


Thanks Kou for these implementations.
Ee6ffca720cc428d70247dcd7377dd48?d=identicon&s=25 Kouhei Sutou (Guest)
on 2013-02-17 03:36
(Received via mailing list)
Hi,

In <CAENqjqc1S1ceOYOZUuJ7Hy_0nFhndnXjf4KpLhrqpsScba3Q6g@mail.gmail.com>
  "Re: [ruby-gnome2-devel-en] gst-gi: read-metadata sample" on Sat, 16
Feb 2013 15:04:31 +0100,
  Vincent Carmona <vinc4mai@gmail.com> 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. :-)

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

Good. :-)

Thanks,
--
kou
C4a836af7263f84a4f7cc91ed6f3ae77?d=identicon&s=25 Vincent Carmona (vinc-mai)
on 2013-02-17 17:12
(Received via mailing list)
Attachment: read-metadata.rb (2 KB)
Attachment: es.rb (1 KB)
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 topic is locked and can not be replied to.