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

Peter Gerten peter.gerten at googlemail.com
Tue Jul 19 21:04:35 UTC 2016


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/20160719/ceff1ca8/attachment.html>


More information about the gstreamer-devel mailing list