Several novice questions

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Several novice questions

Jeffrey Barish
1. I gather that I am expected to change the state of the player on EOS
(which seems strange to me as I would have thought that the player would
know to stop playing when the stream has ended).  To this end, I included
the following code:

    self.player = gst.element_factory_make('playbin', 'player')
    bus = self.player.get_bus()
    bus.add_signal_watch()
    bus.connect('message', self.on_message)

def on_message(self, bus, message):
    print "Got message", message  # nothing ever prints
    t = message.type
    if t in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
        self.player.set_state(gst.STATE_NULL)

However, on_message is never called.  Any idea what I am doing wrong?

2. get_state() returns a tuple (with 3 elements) of the Element's current
state.  Where is the documentation on the elements of the tuple?  It
appears that the second element is the actual state.  Is this observation
always true?

3. I would like to know the elapsed ratio so I tried
query_position(gst.FORMAT_PERCENT).  I get a query error.  It works to do
query_position(gst.FORMAT_TIME) and query_duration(gst.FORMAT_TIME) and
compute the ratio, but why doesn't the simpler solution work?  Is
gst.FORMAT_PERCENT a percentage (0 to 100), as the name implies, or is it
actually a ratio (0 to 1)?

In case it matters, I am using GStreamer 0.10.14 on Kubuntu 7.10 with Python
2.5.1.
--
Jeffrey Barish


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Edward Hervey
Administrator
Hi,

On Fri, 2008-01-18 at 08:28 -0700, Jeffrey Barish wrote:

> 1. I gather that I am expected to change the state of the player on EOS
> (which seems strange to me as I would have thought that the player would
> know to stop playing when the stream has ended).  To this end, I included
> the following code:
>
>     self.player = gst.element_factory_make('playbin', 'player')
>     bus = self.player.get_bus()
>     bus.add_signal_watch()
>     bus.connect('message', self.on_message)
>
> def on_message(self, bus, message):
>     print "Got message", message  # nothing ever prints
>     t = message.type
>     if t in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
>         self.player.set_state(gst.STATE_NULL)
>
> However, on_message is never called.  Any idea what I am doing wrong?

  Are you running a mainloop ? I think it won't work if you're not
runnign a mainloop.

>
> 2. get_state() returns a tuple (with 3 elements) of the Element's current
> state.  Where is the documentation on the elements of the tuple?  It
> appears that the second element is the actual state.  Is this observation
> always true?

  Look in the C API for gst_element_get_state. The returned values are
the 3 last arguments of that function.

>
> 3. I would like to know the elapsed ratio so I tried
> query_position(gst.FORMAT_PERCENT).  I get a query error.  It works to do
> query_position(gst.FORMAT_TIME) and query_duration(gst.FORMAT_TIME) and
> compute the ratio, but why doesn't the simpler solution work?  Is
> gst.FORMAT_PERCENT a percentage (0 to 100), as the name implies, or is it
> actually a ratio (0 to 1)?
>

   What are you doing that query on ? the pipeline ? the sinks ?

> In case it matters, I am using GStreamer 0.10.14 on Kubuntu 7.10 with Python
> 2.5.1.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Jeffrey Barish
Edward Hervey wrote:

> Hi,
>
> On Fri, 2008-01-18 at 08:28 -0700, Jeffrey Barish wrote:
>> 1. I gather that I am expected to change the state of the player on EOS
>> (which seems strange to me as I would have thought that the player would
>> know to stop playing when the stream has ended).  To this end, I included
>> the following code:
>>
>>     self.player = gst.element_factory_make('playbin', 'player')
>>     bus = self.player.get_bus()
>>     bus.add_signal_watch()
>>     bus.connect('message', self.on_message)
>>
>> def on_message(self, bus, message):
>>     print "Got message", message  # nothing ever prints
>>     t = message.type
>>     if t in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
>>         self.player.set_state(gst.STATE_NULL)
>>
>> However, on_message is never called.  Any idea what I am doing wrong?
>
>   Are you running a mainloop ? I think it won't work if you're not
> runnign a mainloop.

I have the impression that pygst takes care of the main loop for me.  I
don't see main_loop in the pygst documentation nor in the tutorial
examples, nor does pygst have a function main_loop or mainloop.

>> 2. get_state() returns a tuple (with 3 elements) of the Element's current
>> state.  Where is the documentation on the elements of the tuple?  It
>> appears that the second element is the actual state.  Is this observation
>> always true?
>
>   Look in the C API for gst_element_get_state. The returned values are
> the 3 last arguments of that function.

I am getting a tuple with (type GstStateChangeReturn, type GstState, type
GstState), so I guess the first element is the return value of
gst_element_get_state, the second is the current state, and the third is
the pending state.  I am interested in knowing more about how ASYNC state
changes work and when they are used.

>> 3. I would like to know the elapsed ratio so I tried
>> query_position(gst.FORMAT_PERCENT).  I get a query error.  It works to do
>> query_position(gst.FORMAT_TIME) and query_duration(gst.FORMAT_TIME) and
>> compute the ratio, but why doesn't the simpler solution work?  Is
>> gst.FORMAT_PERCENT a percentage (0 to 100), as the name implies, or is it
>> actually a ratio (0 to 1)?
>>
>
>    What are you doing that query on ? the pipeline ? the sinks ?

I am doing the query on self.player:

    ratio = self.player.query_position(gst.FORMAT_PERCENT)[0]

This works:

    position = self.player.query_position(gst.FORMAT_TIME)[0]


Thanks for your quick reply.
--
Jeffrey Barish


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Edward Hervey
Administrator

On Fri, 2008-01-18 at 09:14 -0700, Jeffrey Barish wrote:

> Edward Hervey wrote:
>
> > Hi,
> >
> > On Fri, 2008-01-18 at 08:28 -0700, Jeffrey Barish wrote:
> >> 1. I gather that I am expected to change the state of the player on EOS
> >> (which seems strange to me as I would have thought that the player would
> >> know to stop playing when the stream has ended).  To this end, I included
> >> the following code:
> >>
> >>     self.player = gst.element_factory_make('playbin', 'player')
> >>     bus = self.player.get_bus()
> >>     bus.add_signal_watch()
> >>     bus.connect('message', self.on_message)
> >>
> >> def on_message(self, bus, message):
> >>     print "Got message", message  # nothing ever prints
> >>     t = message.type
> >>     if t in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
> >>         self.player.set_state(gst.STATE_NULL)
> >>
> >> However, on_message is never called.  Any idea what I am doing wrong?
> >
> >   Are you running a mainloop ? I think it won't work if you're not
> > runnign a mainloop.
>
> I have the impression that pygst takes care of the main loop for me.  I
> don't see main_loop in the pygst documentation nor in the tutorial
> examples, nor does pygst have a function main_loop or mainloop.

  Use a standard gtk or gobject mainloop.

>
> >> 2. get_state() returns a tuple (with 3 elements) of the Element's current
> >> state.  Where is the documentation on the elements of the tuple?  It
> >> appears that the second element is the actual state.  Is this observation
> >> always true?
> >
> >   Look in the C API for gst_element_get_state. The returned values are
> > the 3 last arguments of that function.
>
> I am getting a tuple with (type GstStateChangeReturn, type GstState, type
> GstState), so I guess the first element is the return value of
> gst_element_get_state, the second is the current state, and the third is
> the pending state.  I am interested in knowing more about how ASYNC state
> changes work and when they are used.
>
> >> 3. I would like to know the elapsed ratio so I tried
> >> query_position(gst.FORMAT_PERCENT).  I get a query error.  It works to do
> >> query_position(gst.FORMAT_TIME) and query_duration(gst.FORMAT_TIME) and
> >> compute the ratio, but why doesn't the simpler solution work?  Is
> >> gst.FORMAT_PERCENT a percentage (0 to 100), as the name implies, or is it
> >> actually a ratio (0 to 1)?
> >>
> >
> >    What are you doing that query on ? the pipeline ? the sinks ?
>
> I am doing the query on self.player:
>
>     ratio = self.player.query_position(gst.FORMAT_PERCENT)[0]
>
> This works:
>
>     position = self.player.query_position(gst.FORMAT_TIME)[0]
>
>
> Thanks for your quick reply.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Jeffrey Barish
Edward Hervey wrote:

> Use a standard gtk or gobject mainloop.

Ah, if you are referring to gtk.main(), certainly I am already doing that.
Everything in my application works, including signals related to the GUI,
except for signals in GStreamer.
--
Jeffrey Barish


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Jeffrey Barish
In reply to this post by Edward Hervey
Edward Hervey wrote:

> On Fri, 2008-01-18 at 08:28 -0700, Jeffrey Barish wrote:
>> 1. I gather that I am expected to change the state of the player on EOS
>> (which seems strange to me as I would have thought that the player would
>> know to stop playing when the stream has ended).  To this end, I included
>> the following code:
>>
>> self.player = gst.element_factory_make('playbin', 'player')
>> bus = self.player.get_bus()
>> bus.add_signal_watch()
>> bus.connect('message', self.on_message)
>>
>> def on_message(self, bus, message):
>> t = message.type
>> if t in (gst.MESSAGE_EOS, gst.MESSAGE_ERROR):
>>     self.player.set_state(gst.STATE_NULL)
>>
>> However, on_message is never called.  Any idea what I am doing wrong?
>
> Are you running a mainloop ? I think it won't work if you're not
> runnign a mainloop.

It turns out that you were exactly right.  The chunk of code in which
GStreamer is running is outside the GTK main loop.  When I put the code in
a gobject mainloop, I do receive messages.  Thank you for the suggestion.

I am still wondering why query_position(gst.FORMAT_PERCENT) produces a query
error whereas query_position(gst.FORMAT_TIME) does not and whether
gst.FORMAT_PERCENT is a misnomer.
--
Jeffrey Barish


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

run time property

Vikas Patel
Hi,

I am integrating the Openmax component with Gstreamer.

I want to set some runtime property of component by calling set_config ,
but I don't find anything in Gstreamer to set property in runtime.



Regards

Vikas

-
This message is subject to Imagination Technologies' e-mail terms: http://www.imgtec.com/e-mail.htm
-


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Tim-Philipp Müller-2
In reply to this post by Jeffrey Barish
On Mon, 2008-01-21 at 00:12 -0700, Jeffrey Barish wrote:

> I am still wondering why query_position(gst.FORMAT_PERCENT) produces a
>  query error whereas query_position(gst.FORMAT_TIME) does not and
>  whether gst.FORMAT_PERCENT is a misnomer.

Hardly any element supports/implements PERCENT format queries, that's
why it fails. TIME is the best-supported format. If you want the current
position in percent you currently need to query the duration and the
position and then calculate the rest yourself.

Cheers
 -Tim



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

Lutz Müller-2
On Mon, 2008-01-21 at 09:47 +0000, Tim Müller wrote:
> Hardly any element supports/implements PERCENT format queries, that's
> why it fails.

This is why I proposed a patch to deduct the percentage from position
and duration: http://bugzilla.gnome.org/attachment.cgi?id=76355 (part of
bug 344937).

But what's percentage anyways: of bytes? of seconds? of tracks?

Regards

Lutz


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Several novice questions

David Schleef
In reply to this post by Tim-Philipp Müller-2
On Mon, Jan 21, 2008 at 09:47:34AM +0000, Tim Müller wrote:

> On Mon, 2008-01-21 at 00:12 -0700, Jeffrey Barish wrote:
>
> > I am still wondering why query_position(gst.FORMAT_PERCENT) produces a
> >  query error whereas query_position(gst.FORMAT_TIME) does not and
> >  whether gst.FORMAT_PERCENT is a misnomer.
>
> Hardly any element supports/implements PERCENT format queries, that's
> why it fails. TIME is the best-supported format. If you want the current
> position in percent you currently need to query the duration and the
> position and then calculate the rest yourself.

We should probably just deprecate GST_FORMAT_PERCENT if it's not
useful.



dave...


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel