Skip to content

Using C bindings (on Windows) #117

@danryu

Description

@danryu

I'm attempting to incorporate lib-gst-meet-c into a simple Qt/QML C++ CMake app.
Is the C binding in need of a refresh?

There seems to be a mismatch in gstmeet_connection_new(), at least:

gstmeet.h:


JitsiConnection *gstmeet_connection_new(struct Context *context,
                                        const char *websocket_url,
                                        const char *xmpp_domain,
                                        const char *room_name,  // <-- MISSING
                                        bool tls_insecure);

lib.rs:

pub unsafe extern "C" fn gstmeet_connection_new(
  context: *mut Context,
  websocket_url: *const c_char,
  xmpp_domain: *const c_char,
  room_name: *const c_char,
  tls_insecure: bool,
) -> *mut Connection {
  let websocket_url = CStr::from_ptr(websocket_url);
  let xmpp_domain = CStr::from_ptr(xmpp_domain);
  let room_name = CStr::from_ptr(room_name);

Manually editing gstmeet_connection_new definition to include room_name allows this to proceed instead of crashing.

But how can I update the bindings safely, and without manual edits to gstmeet.h? Any help appreciated.

Additional query:

  • is there a skeletal example of how to start a simple gstmeet connection in C/C++? I'm a little confused with the required threading handling between C and Rust at the moment.

I'm currently attempting to start a conference like this:

void JitsiMeetItem::startConference()
{
    QMutexLocker locker(&m_mutex);
    if (m_connection || m_conference || m_pipeline) {
        qWarning() << "Conference already started.";
        return;
    }

    // Create and start GMainLoop thread
    // runMainLoop();

    // Ensure GMainLoop is running
    // if (!m_gMainLoop || !g_main_loop_is_running(m_gMainLoop)) {
    //     qWarning() << "GMainLoop is not running.";
    //     emit networkError("GMainLoop is not running");
    //     stopMainLoop();
    //     return;
    // }

    // Create JitsiConnection
    m_connection = gstmeet_connection_new(
        m_context,
        qtStringToByteArray(m_webSocketUrl).constData(),
        qtStringToByteArray(m_xmppDomain).constData(),
        "some_room_name",
        m_tlsInsecure
    );

    if (!m_connection) {
        qWarning() << "Failed to create JitsiConnection.";
        emit networkError("Failed to create JitsiConnection");
        stopMainLoop();
        return;
    }

    // Attempt to connect
    if (!gstmeet_connection_connect(m_context, m_connection)) {
        qWarning() << "Failed to connect to Jitsi server.";
        emit networkError("Failed to connect to Jitsi server");
        stopMainLoop();
        return;
    }
    
    ....
}

However, with or without the GMainLoop stuff, stepping through with the debugger shows that the application always hangs during gstmeet_connection_connect(), or rather fn gstmeet_connection_new() in lib-gst-meet-c/src/lib.rs. Apparently the connection attempt blocks infinitely there.

Again, any help appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions