Created
February 2, 2018 09:43
-
-
Save rhythmize/a26b06ac8c6a835ae2393c465d984471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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