Reading an shmsink stream from an external application

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

Reading an shmsink stream from an external application

Takido
Hello,

I'm trying to feed an external application which deals sound to a special hardware with shmsink. I read all the doc I could find about shm (including the commented part of shmpipe.h) but I still don't understand they way I could get the audio stream in my external application.

How can I do that ?

Hamza
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Tristan Matthews-2
2012/7/5 Takido <[hidden email]>:
> Hello,
>
> I'm trying to feed an external application which deals sound to a special
> hardware with shmsink. I read all the doc I could find about shm (including
> the commented part of shmpipe.h) but I still don't understand they way I
> could get the audio stream in my external application.

The easiest route is to use the "shmsrc" element in your external
application, otherwise you will have to write your own shmsrc-like
client for your application.
If it's of any help, a while ago I made a minimal python example using
the shmsrc and shmsink elements that might be of some use:

https://github.com/tmatth/gst-prototypes/tree/master/shm

Best,
Tristan

--
Tristan Matthews
web: http://tristanswork.blogspot.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Olivier Crête-3
In reply to this post by Takido
Hi,

On Thu, 2012-07-05 at 08:52 -0700, Takido wrote:
> Hello,
>
> I'm trying to feed an external application which deals sound to a special
> hardware with shmsink. I read all the doc I could find about shm (including
> the commented part of shmpipe.h) but I still don't understand they way I
> could get the audio stream in my external application.
>
> How can I do that ?

Copy shmpipe.[ch] and shmalloc.[ch] into your application and use the
read API described in shmpipe.h (sp_client_* sp_close, sp_get_fd) to get
the buffers.

--
Olivier Crête
[hidden email]

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Takido
Thank you for your answers.

The easiest route is to use the "shmsrc" element in your external
application, otherwise you will have to write your own shmsrc-like
client for your application.
If it's of any help, a while ago I made a minimal python example using
the shmsrc and shmsink elements that might be of some use:

https://github.com/tmatth/gst-prototypes/tree/master/shm

Best,
Tristan
I think I'll be forced to write my own shmsrc-like (actually, if I found a way to directly send my audio stream to the application without shm, I would). Anyway, I'll try to understand your python example which seems interesting.

Copy shmpipe.[ch] and shmalloc.[ch] into your application and use the
read API described in shmpipe.h (sp_client_* sp_close, sp_get_fd) to get
the buffers.
 
I already started to try use this API. So, if I understood well, I have to :
  1. Open a client connection with the server : ShmPipe * pipe = sp_client_open(PATH);
  2. Wait for data to read : select(sp_get_fd(pipe), &rdfs, NULL, NULL, NULL);
  3. Then receive the data to read : sp_client_recv(pipe, my_buffer);
  4. And finally finish to read using : sp_client_recv_finish()

Now it seems very clear to me, however I still can't get it work : even if I send a stream to the specified path (using gst-launch audiotestsrc ! shmsink socket-path=testpath), my little program waits eternally, not seeing any incoming data.

I think I missed something really simple but I can't get it.

 
2012/7/5 Olivier Crête <[hidden email]>
Hi,

On Thu, 2012-07-05 at 08:52 -0700, Takido wrote:
> Hello,
>
> I'm trying to feed an external application which deals sound to a special
> hardware with shmsink. I read all the doc I could find about shm (including
> the commented part of shmpipe.h) but I still don't understand they way I
> could get the audio stream in my external application.
>
> How can I do that ?

Copy shmpipe.[ch] and shmalloc.[ch] into your application and use the
read API described in shmpipe.h (sp_client_* sp_close, sp_get_fd) to get
the buffers.

--
Olivier Crête
[hidden email]

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Takido
I finally understood the previous problem, but am now facing another one. Using the following code (which corrects my first problem) :

int fd = sp_get_fd(pipe);

    fd_set rfds;
    FD_ZERO(&rfds);
    FD_SET(fd, &rfds);
    select(fd+1, &rfds, NULL, NULL, NULL);

    int k = recv_to_buffer (pipe, buffer);
    sp_client_recv_finish(pipe, buf);

I get the following error :

shmTest: shmpipe.c:729: sp_client_recv_finish: Assertion `shm_area' failed.
Abandon

Looks like my pipe get no ShmArea, right ? Where could this error come from ?

Thanks.

2012/7/6 Hamza Chouh <[hidden email]>
Thank you for your answers.

The easiest route is to use the "shmsrc" element in your external
application, otherwise you will have to write your own shmsrc-like
client for your application.
If it's of any help, a while ago I made a minimal python example using
the shmsrc and shmsink elements that might be of some use:

https://github.com/tmatth/gst-prototypes/tree/master/shm

Best,
Tristan
I think I'll be forced to write my own shmsrc-like (actually, if I found a way to directly send my audio stream to the application without shm, I would). Anyway, I'll try to understand your python example which seems interesting.


Copy shmpipe.[ch] and shmalloc.[ch] into your application and use the
read API described in shmpipe.h (sp_client_* sp_close, sp_get_fd) to get
the buffers.
 
I already started to try use this API. So, if I understood well, I have to :
  1. Open a client connection with the server : ShmPipe * pipe = sp_client_open(PATH);
  2. Wait for data to read : select(sp_get_fd(pipe), &rdfs, NULL, NULL, NULL);
  3. Then receive the data to read : sp_client_recv(pipe, my_buffer);
  4. And finally finish to read using : sp_client_recv_finish()

Now it seems very clear to me, however I still can't get it work : even if I send a stream to the specified path (using gst-launch audiotestsrc ! shmsink socket-path=testpath), my little program waits eternally, not seeing any incoming data.

I think I missed something really simple but I can't get it.

 
2012/7/5 Olivier Crête <[hidden email]>
Hi,

On Thu, 2012-07-05 at 08:52 -0700, Takido wrote:
> Hello,
>
> I'm trying to feed an external application which deals sound to a special
> hardware with shmsink. I read all the doc I could find about shm (including
> the commented part of shmpipe.h) but I still don't understand they way I
> could get the audio stream in my external application.
>
> How can I do that ?

Copy shmpipe.[ch] and shmalloc.[ch] into your application and use the
read API described in shmpipe.h (sp_client_* sp_close, sp_get_fd) to get
the buffers.

--
Olivier Crête
[hidden email]

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Olivier Crête-3
In reply to this post by Takido
On Fri, 2012-07-06 at 11:37 +0200, Hamza Chouh wrote:
> I think I'll be forced to write my own shmsrc-like (actually, if I
> found a way to directly send my audio stream to the application
> without shm, I would).

You can just create a name socket and just use fdsink?

--
Olivier Crête
[hidden email]

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Todd Fischer
In reply to this post by Takido


Date: Fri, 06 Jul 2012 11:03:29 -0700
From: Olivier Cr?te <[hidden email]>
To: [hidden email]
Subject: Re: Reading an shmsink stream from an external application
Message-ID: <1341597809.30902.0.camel@TesterTop4>
Content-Type: text/plain; charset="utf-8"

On Fri, 2012-07-06 at 11:37 +0200, Hamza Chouh wrote:
I think I'll be forced to write my own shmsrc-like (actually, if I
found a way to directly send my audio stream to the application
without shm, I would).

You can just create a name socket and just use fdsink?

You can check out a similar sink, that we called ipcsink.


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Reading an shmsink stream from an external application

Takido
Thanks, I finally solved my problem which was about bad variable initializations.

I have a last question about shmsink : is it possible to get the type of the media that is streamed from the socket created by shmsink ? I mean, the mime type, mono/stereo and stuff like this ?


2012/7/6 Todd Fischer <[hidden email]>


Date: Fri, 06 Jul 2012 11:03:29 -0700
From: Olivier Cr?te <[hidden email]>
To: [hidden email]
Subject: Re: Reading an shmsink stream from an external application
Message-ID: <1341597809.30902.0.camel@TesterTop4>
Content-Type: text/plain; charset="utf-8"


On Fri, 2012-07-06 at 11:37 +0200, Hamza Chouh wrote:
I think I'll be forced to write my own shmsrc-like (actually, if I
found a way to directly send my audio stream to the application
without shm, I would).

You can just create a name socket and just use fdsink?

You can check out a similar sink, that we called ipcsink.


_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel



_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel