Wayland XDG 远程桌面门户restore_token在 python3 中不起作用

Wayland XDG remote desktop portal restore_token not working in python3

提问人:AlexiK 提问时间:9/10/2023 更新时间:9/10/2023 访问量:63

问:

我正在根据这个示例进行一个项目 https://gitlab.gnome.org/-/snippets/39

我更改了这个功能:

def on_create_session_response(response, results):
    if response != 0:
        print("Failed to create session: %d"%response)
        terminate()
        return

    global session
    session = results['session_handle']
    print("session %s created"%session)

    remote_desktop_call(portal.SelectDevices, on_select_devices_response,
                        session,
                        options={ 'types': dbus.UInt32(7) })

对此:

def on_create_session_response(response, results):
        if response != 0:
                print("Failed to create session: %d"%response)
                terminate()
                os._exit(2)
                return

        global session
        session = results['session_handle']
        #print(session)
        print("session %s created"%session)
        if restore_token is not None:
            remote_desktop_call(portal.SelectDevices, on_select_devices_response,
                                                session,
                                                options={ 'types': dbus.UInt32(3), 'restore_token': restore_token ,'persist_mode': dbus.UInt32(2)})
            x =GLib.Variant.lookup_value(results,"restore_token",GLib.VariantType("s"))
            print(x)
        else:
            remote_desktop_call(portal.SelectDevices, on_select_devices_response,
                                                session,
                                                options={ 'types': dbus.UInt32(3), 'restore_token': "NULL" ,'persist_mode': dbus.UInt32(2)})

根据 XDG 文档和对 OBS Studio 源代码的一些浏览,我现在应该能够获得可以在此函数中捕获的还原令牌:

def on_start_response(response, results):
    if response != 0:
        print("Failed to start: %s"%response)
        terminate()
        return
    print(results)
    print("streams:")
    if 'streams' in results:
        for (node_id, stream_properties) in results['streams']:
            print("stream {}".format(node_id))
            play_pipewire_stream(node_id)
    else:
        print("no screen casting")

    print("devices: {}".format(results['devices']))


但是,我没有收到还原令牌。我的操作系统是Ubuntu 23.10 amd64。我已经翻阅了 OBS 源代码 screencast-portal.c 来检查我的工作。我尝试移动 print 语句以尝试找到丢失的令牌,但它没有出现。我应该能够在结果中得到一个显示“restore_token”的值

蟒蛇 glib dbus wayland obs

评论


答: 暂无答案