Wayland XDG remote desktop portal restore_token not working in python3

130 views Asked by At

I am working on a project based off of this example https://gitlab.gnome.org/-/snippets/39

I changed this function:

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) })

to this:

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)})

according to the XDG Docs and some browsing of the OBS Studio source code, I should be able to now get a restore token i can capture in this function:

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']))


However I am not getting a restore token. my operating system is ubuntu 23.10 amd64. I have flipped thru the OBS source code screencast-portal.c to check my work. and i tried moving the print statement to try and locate the missing token but it isnt coming up. I should be able to get in the results a value that says "restore_token"

0

There are 0 answers