0

我正在使用 Gstreamer RTSPMediaFactory ( libgstrtspserver1.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功能?我该怎么办?

4

1 回答 1

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_elementfunc,但您必须覆盖do_create_element具有 typegi.types.NativeVFunc的 。如果我与 rtsp 客户端连接到rtsp://127.0.0.1:8554/mount 它的打印输出:

in do_create_element
于 2015-09-18T07:16:17.570 回答