multisocketsink and Gio.Socket() issues (python)

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

multisocketsink and Gio.Socket() issues (python)

Krutskikh Ivan
Hi,

I want to create a pipeline with multisocketsink, add a socket to it and then read from it as a normal python socket.

If i do:

client_id = Gio.Socket().new_from_fd(wfile.fileno())
self.clients.append(client_id)
self.sink.emit("add", client_id)
while client_id in self.clients:
   time.sleep(1)

everything fine exept that if connection breaks on gstreamer side ( client_id gets removed by timeout), the socket just waits forever for incoming data. Adding client_id.set_timeout(1) does not help in any way

So I wanted to make a more manual approach:

client_id = Gio.Socket()
client_id.set_timeout(1)
self.clients.append(client_id)
while True:
   data = client_id.receive(1024)
   if not data:
      break
   else:
      wfile.write(data)
      wfile.flush()

But that does not work. I see socket being added to multisocket sink and removed after timeout. No data is passed to wfile. Just to be clear: I tried using python's own socket module, but I cannot even add this socket to gstreamer. :(

Thanks in advance!


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

Re: multisocketsink and Gio.Socket() issues (python)

Sebastian Dröge-3
On Mo, 2016-03-21 at 14:17 +0300, Krutskikh Ivan wrote:
> Hi,
>
> I want to create a pipeline with multisocketsink, add a socket to it
> and then read from it as a normal python socket.
> [...]

The socket you pass to multisocketsink is not supposed to be used
anymore from the application. multisocketsink handles and owns it.

You could create a socket pair though, pass one part of the pair to
multisocketsink and then read from the other part of the pair from your
Python application.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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

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

Re: multisocketsink and Gio.Socket() issues (python)

Krutskikh Ivan
Thanks!

Would this work with vanilla socket or I should stick with Gio.Socket ?

I believe I can use socketpair to connect gstreamer multisocketsink to another gstreamer chain with socketsrc, am I right?

2016-03-22 11:38 GMT+03:00 Sebastian Dröge <[hidden email]>:
On Mo, 2016-03-21 at 14:17 +0300, Krutskikh Ivan wrote:
> Hi,
>
> I want to create a pipeline with multisocketsink, add a socket to it
> and then read from it as a normal python socket.
> [...]

The socket you pass to multisocketsink is not supposed to be used
anymore from the application. multisocketsink handles and owns it.

You could create a socket pair though, pass one part of the pair to
multisocketsink and then read from the other part of the pair from your
Python application.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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



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

Re: multisocketsink and Gio.Socket() issues (python)

Sebastian Dröge-3
On Di, 2016-03-22 at 12:42 +0300, Krutskikh Ivan wrote:
> Thanks!
>
> Would this work with vanilla socket or I should stick with Gio.Socket
> ?

GSocket is just an API around normal sockets. But multisocketsink
requires sockets to be wrapped in a GSocket.

> I believe I can use socketpair to connect gstreamer multisocketsink
> to another gstreamer chain with socketsrc, am I right?

Yes that should work

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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

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

Re: multisocketsink and Gio.Socket() issues (python)

Krutskikh Ivan
GSocket is just an API around normal sockets. But multisocketsink
requires sockets to be wrapped in a GSocket.

Well, I was wondering because python has socket.socketpair element and Gio.Socket() does not. How can I wrap a socket in a GSocket then?

2016-03-22 12:50 GMT+03:00 Sebastian Dröge <[hidden email]>:
On Di, 2016-03-22 at 12:42 +0300, Krutskikh Ivan wrote:
> Thanks!
>
> Would this work with vanilla socket or I should stick with Gio.Socket
> ?

GSocket is just an API around normal sockets. But multisocketsink
requires sockets to be wrapped in a GSocket.

> I believe I can use socketpair to connect gstreamer multisocketsink
> to another gstreamer chain with socketsrc, am I right?

Yes that should work

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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



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

Re: multisocketsink and Gio.Socket() issues (python)

Krutskikh Ivan
Maybe something really stupid like:

sock = socket.socket()
client_id = Gio.Socket().new_from_fd(sock.fileno())

and so on...


2016-03-22 13:04 GMT+03:00 Krutskikh Ivan <[hidden email]>:
GSocket is just an API around normal sockets. But multisocketsink
requires sockets to be wrapped in a GSocket.

Well, I was wondering because python has socket.socketpair element and Gio.Socket() does not. How can I wrap a socket in a GSocket then?

2016-03-22 12:50 GMT+03:00 Sebastian Dröge <[hidden email]>:
On Di, 2016-03-22 at 12:42 +0300, Krutskikh Ivan wrote:
> Thanks!
>
> Would this work with vanilla socket or I should stick with Gio.Socket
> ?

GSocket is just an API around normal sockets. But multisocketsink
requires sockets to be wrapped in a GSocket.

> I believe I can use socketpair to connect gstreamer multisocketsink
> to another gstreamer chain with socketsrc, am I right?

Yes that should work

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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




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

Re: multisocketsink and Gio.Socket() issues (python)

Sebastian Dröge-3
On Di, 2016-03-22 at 13:46 +0300, Krutskikh Ivan wrote:
> Maybe something really stupid like:
>
> sock = socket.socket()
> client_id = Gio.Socket().new_from_fd(sock.fileno())
>
> and so on...

Exactly like that :)

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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

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

Re: multisocketsink and Gio.Socket() issues (python)

Krutskikh Ivan
This hurts my brain...

But thanks non the less! =)

2016-03-22 15:30 GMT+03:00 Sebastian Dröge <[hidden email]>:
On Di, 2016-03-22 at 13:46 +0300, Krutskikh Ivan wrote:
> Maybe something really stupid like:
>
> sock = socket.socket()
> client_id = Gio.Socket().new_from_fd(sock.fileno())
>
> and so on...

Exactly like that :)

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


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



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