Skip to content

Instantly share code, notes, and snippets.

@rhythmize
Created February 2, 2018 09:43
Show Gist options
  • Save rhythmize/a26b06ac8c6a835ae2393c465d984471 to your computer and use it in GitHub Desktop.
Save rhythmize/a26b06ac8c6a835ae2393c465d984471 to your computer and use it in GitHub Desktop.
import gi
gi.require_version('Gst','1.0')
gi.require_version('GstVideo','1.0')
gi.require_version('GstRtspServer','1.0')
from gi.repository import Gst, GObject, GstRtspServer, GstRtsp
Gst.debug_set_active(True)
Gst.debug_set_default_threshold(3)
Gst.init(None)
GObject.threads_init()
context=GObject.MainContext.new()
GObject.MainContext.push_thread_default(context)
def get_server(port):
server = GstRtspServer.RTSPServer.new()
server.set_address('0.0.0.0')
server.set_service(str(port))
return server
def create():
server = get_server(5555)
source_id = server.attach(context)
return source_id
def destroy(source_id):
source=context.find_source_by_id(source_id)
source.destroy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment