[lang]

Present Perfect

Personal
Projects
Packages
Patches
Presents
Linux

Picture Gallery
Present Perfect

python and GStreamer questions

Filed under: General,Python — Thomas @ 23:21

2007-09-09
23:21

Josep had a GStreamer problem last Friday and really really wanted to bug me about it because everyone else he usually bugs about them is gone :) Julien was at IBC, Andy is doing an Andy, Mike is in the US, Zaheer is in London, and Jan is in Ireland. All with varying degrees of longetivity and permanence.

Now, I've hardly done any code with GStreamer for a while, but I helped him trawl through the log file he gave me until we found a likely symptom for his problem. He went away again then came back later asking me to check his theory about the bug.

Not to bore you with details, but it boiled down to a simple question he had: does gst_buffer_create_sub() set the master buffer's caps on the subbuffers it creates or not ?

Well, first of all, I have no idea. Second, why does he ask me, he's been working here for a year now so he should be able to find his way around GStreamer - but that's a post for a different day. Third, it's likely that the answer is in the documentation.

But most of all, why don't you just give it a try ?

He looked at me, puzzled, so I fired up an ipython shell. He said "Well, I don't know Python", and I replied "then it's time you give it a try, because you're about to get the answer to the question you asked me".

I could finish of the post here and lead you to believe that it's really easy to figure out the answer using ipython, but I'm guessing there might be more people out there who need a simple example to realize the power of trying things in ipython. So here goes - I'm pasting my session verbatim, mistakes and all, with comments in italics.


[thomas@level ~]$ ipython
import Python 2.5 (r25:51908, Apr 10 2007, 10:27:40)
Type "copyright", "credits" or "license" for more information.


IPython 0.7.2 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.


In [1]: import gst

I'd like to do things with GStreamer, please.


In [2]: gst = gst.Bu

Let's hit TAB and see what pops out.


gst.Buffer gst.Bus gst.BusSyncReply
gst.BufferFlag gst.BusFlags

Let's type f, hit TAB and see what pops out.


In [2]: gst = gst.Buf
gst.Buffer gst.BufferFlag

Alright, I want a buffer.


In [2]: gst = gst.Buffer()


In [3]: caps = gst.caps_from_string('audio/x-raw-int,channels=2')

Let's make some caps to set on the buffer.
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/home/thomas/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'gst.Buffer' object has no attribute 'caps_from_string'
What, is my GStreamer copy borked again ?
In [4]: caps = gst.caps_from_string('audio/x-raw-int,channels=2')
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/home/thomas/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'gst.Buffer' object has no attribute 'caps_from_string'
Oh, God, I should have slept last night, twat that I am. I created a buffer and bound it to the 'gst' variable that was holding my module.


In [5]: import gst

Let's try this importing again, create a buffer and caps, and set caps on the buffer.

In [6]: b = gst.Buffer()


In [7]: caps = gst.caps_from_string('audio/x-raw-int,channels=2')

In [8]: b.set_caps(caps)

In [9]: b
Out[9]: <gst .Buffer 0x9980c0 of size 0>
In [10]: b.caps
Out[10]: <gstcaps at 0x927140>


In [11]: b.caps.to_string()
Out[11]: 'audio/x-raw-int, channels=(int)2'

All good so far, except... it's not going to work well to create a sub-buffer from a buffer of size 0.


In [12]: b = gst.Buffer('kakapipi')

Let's create a new buffer, and fill it with data that would make Peter proud.
In [13]: b
Out[13]: <gst .Buffer 0x998140 of size 8 and data 0x6b616b61>
Much better, a real buffer.


In [14]: b.set_caps(caps)


In [15]: c = b.create_sub(2, 4)

Now, let's create our sub buffer.
In [16]: c
Out[16]: <gst .Buffer 0x9981c0 of size 4 and data 0x6b617069>


In [17]: c.caps

Look ma, no caps!
In [18]: c.caps.to_string()
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/home/thomas/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'to_string'
Seriously, there are no caps on the subbuffer.

So there's Josep's answer. I hope this makes getting answers from GStreamer easier for some people out there.

On a slightly related note, why is it so hard to copy and paste code or output in WordPress ? I've installed the code markup plug-in, disabled the advanced editor like it asked, and it still insisted on pretending anything in angle brackets was a tag that it then had to close, explicitly, in my text.

Finally

Filed under: General — Thomas @ 17:31

2007-09-07
17:31

I have a word for that thing I do to Kristien that annoys the hell out of her (well, one of the many)

I am going to jennif you forever baby.

Art Brut

Filed under: General — Thomas @ 14:42

2007-09-06
14:42

To every girl that's ever been with me

I got over you all ! ... eventually 

"People in Love"

suid and /proc ?

Filed under: General — Thomas @ 09:54

09:54

I was writing a nagios check that checks how many fd's a process has open.  Naively I wrote it as a program that checks /proc/<pid>/fd, thinking that I could just set the program suid root and things would work.

But they don't.  Apparently something in the kernel prevents a suid program to do this - I've found some posts that mention various patches and pieces of kernel.  I'm not all that interested in the why, but can anyone suggest an alternative approach to make a check like this work ?

Question for Spanish Telefonica users

Filed under: General — Thomas @ 20:06

2007-09-05
20:06

Every few weeks, I have a series of days where my ADSL connection goes down, and comes back up with a new IP. Correlating with my IRC reconnections that I can see at work made by my home machine, this happens roughly every half hour. I have no idea why. This happens for a few days on end, and is hugely annoying, then it's gone for weeks.

Is anyone else that uses Telefonica in Spain having this problem ? What can I do ? Does it make
a difference to complain about it ? Are there forums or sites that discuss problems like these ? Please comment. Feel free to comment in Spanish if that's easier.

UPDATE: maybe I wasn't clear enough in the post.  The problem is not that I don't have a fixed IP, that's fine.  The problem is that my internet connection goes down every half hour for a few minutes, for days on end.  Hope that clears up the confusion for people suggesting I get a fixed IP :)

« Previous PageNext Page »
picture