How to create a RTSP Server that immediately starts the pipeline and reuses it in Python

Peter Gerten peter.gerten at googlemail.com
Wed Aug 3 17:38:38 UTC 2016


Does anybody have an idea on how to solve this?
Basically I need to have a pipeline that runs all the time and is (re-)used
for clients of my RTSP server.

Peter

On Tue, Jul 19, 2016 at 11:04 PM, Peter Gerten <peter.gerten at googlemail.com>
wrote:

> Hi,
>
> I have and RTP source that I want to republish using a RTSP server.
> I am using the python code below for it. The problem I have: The pipeline
> only gets created after the first client connects. But then I have an issue
> with my RTP source not being ready at the same time.
> What I want: start the pipeline immediately, even if no client is
> connected (and then reuse it; what should already be the case).
> I do not understand what actually triggers the creation of the pipeline.
> It seems to be somehow implicitly done via the RTSPMediaFactory?
>
> ------------------------------
> import gi
> gi.require_version('Gst', '1.0')
> gi.require_version('GstRtspServer', '1.0')
> from gi.repository import Gst, GObject, GstRtspServer
>
> GObject.threads_init()
> Gst.init(None)
>
>
> class RTSP_Server:
>     def __init__(self):
>         self.server = GstRtspServer.RTSPServer.new()
>         self.address = '172.17.0.4'
>         self.port = '8554'
>         self.launch_description = '( udpsrc port=6784
> caps="application/x-rtp,payload=96,config-interval=1" ! rtph264depay !
> rtph264pay name=pay0 pt=96 )'
>         self.server.set_address(self.address)
>         self.server.set_service(self.port)
>         self.server.connect("client-connected",self.client_connected)
>         self.factory = GstRtspServer.RTSPMediaFactory.new()
>         self.factory.set_launch(self.launch_description)
>         self.factory.set_shared(True)
>         self.factory.construct('/video')
>
> self.factory.set_transport_mode(GstRtspServer.RTSPTransportMode.PLAY)
>         self.mount_points = self.server.get_mount_points()
>         self.mount_points.add_factory('/video', self.factory)
>
>         self.server.attach(None)
>         print('Stream ready')
>         GObject.MainLoop().run()
>
>     def client_connected(self, arg1, arg2):
>         print('Client connected')
>
> server = RTSP_Server()
> ------------------------------
>
> Regards
>
> Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20160803/ef121e74/attachment.html>


More information about the gstreamer-devel mailing list