webrtcbin: ability to provide an external main context
Currently webrtcbin doesn't accept a main context and always run its own. It might be beneficial for a webrtcbin to be able to use another main context for an application that already have a main context.
Context: I'm developing a NodeJS library which implement JavaScript API of WebRTC using Gstreamer's webrtcbin, via node-gtk glib binding. JS requires that all code runs on main thread, including callbacks. So, when a cross-thread callback happens, node-gtk will post an event to the main (JS) context, and then block until the answer comes back. Which, for my current usecase at least, does work.
If webrtcbin accept a main context, this cross-thread callback can be avoided, as node-gtk supports the use of GLib main context. Webrtcbin can then post the events to this main context and have it run in the main thread, avoiding the cross-thread block.
BTW, I'm not sure if it is related, but I found this comment in gstwebrtcbin.c
:
/* Having the thread be the thread default GMainContext will break the
* required queue-like ordering (from W3's peerconnection spec) of re-entrant
* tasks */
Which may have implication on using main thread's context here. But to be honest I don't understand it well enough.