我正在使用Gstreamer RTSPMediaFactory(libgstrtspserver
1.0)v 1.2.3-0。
从Python中,我派生出了MediaFactory,并覆盖了create_element
。
不幸的是,我的create_element永远不会被调用,因此RtspServer会抱怨no launch line specified
。
我打印出超级实例中声明的所有方法,并得到了这个:
[' set_buffer_size',' set_suspend_mode',' set_protocols',' construct', ' get_suspend_mode',' get_launch',' set_launch',' is_eos_shutdown', ' get_permissions',' get_address_pool',' set_shared',' is_shared', ' set_address_pool',' get_protocols',' get_buffer_size', ' set_permissions',' set_eos_shutdown']
否create_element
!
难怪,我的实现从未被调用过......但为什么没有create_element
函数?我该怎么办?
答案 0 :(得分:0)
我使用版本1.4.3。
这是我的全部测试:
from gi.repository import Gst, GObject, GstRtspServer
Gst.init(None)
rtsp_server = GstRtspServer.RTSPServer()
rtsp_server.attach(None)
class Factory(GstRtspServer.RTSPMediaFactoryURI):
def __init__(self):
super(Factory, self).__init__()
print [(x, type(y)) for x, y
in GstRtspServer.RTSPMediaFactory.__dict__.items()]
def do_create_element(self, url):
print "in do_create_element"
factory = Factory()
factory.set_uri('rtsp://camera_url')
rtsp_server.get_mount_points().add_factory('/mount', factory)
GObject.MainLoop().run()
开始时打印输出:
[('set_buffer_size', <type 'function'>), ('do_media_configure', <class 'gi.types.NativeVFunc'>),
('__module__', <type 'str'>), ('do_configure', <class 'gi.types.NativeVFunc'>),
('set_suspend_mode', <type 'function'>), ('do_media_constructed', <class 'gi.types.NativeVFunc'>),
('__info__', <type 'ObjectInfo'>), ('do_create_element', <class 'gi.types.NativeVFunc'>),
('priv', <type 'property'>), ('set_protocols', <type 'function'>),
('construct', <type 'function'>), ('get_suspend_mode', <type 'function'>),
('_gst_reserved', <type 'property'>), ('new', <type 'classmethod'>),
('__gtype__', <type 'gobject.GType'>), ('get_launch', <type 'function'>),
('__doc__', <type 'NoneType'>), ('set_launch', <type 'function'>),
('do_construct', <class 'gi.types.NativeVFunc'>), ('parent', <type 'property'>),
('is_eos_shutdown', <type 'function'>), ('get_permissions', <type 'function'>),
('get_address_pool', <type 'function'>), ('do_gen_key', <class 'gi.types.NativeVFunc'>),
('set_shared', <type 'function'>), ('create_element', <type 'function'>),
('is_shared', <type 'function'>), ('set_address_pool', <type 'function'>),
('get_protocols', <type 'function'>), ('get_buffer_size', <type 'function'>),
('get_profiles', <type 'function'>), ('set_permissions', <type 'function'>),
('set_profiles', <type 'function'>), ('set_eos_shutdown', <type 'function'>)]
如您所见,它有create_element
func,但您必须覆盖do_create_element
,
类型为gi.types.NativeVFunc
的人。
如果我将rtsp客户端连接到rtsp://127.0.0.1:8554/mount
打印输出:
in do_create_element