Screen capture in GTK+ application

David Woodhouse dwmw2 at infradead.org
Tue Apr 17 15:41:28 UTC 2018


On Tue, 2018-04-17 at 07:54 -0400, Nicolas Dufresne wrote:
> Le mardi 17 avril 2018 à 11:44 +0100, David Woodhouse a écrit :
> > I tried using ximagesrc as a video source in Pidgin (which is still
> > using GTK2+, FWIW). It fell over:
> >
> >  [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
> >  [xcb] Aborting, sorry about that.
>> > Is ximagesrc just not expected to work in threaded GTK programs? That
> > might be worth mentioning in its documentation...
> 
> It's exactly what the error says. Gtk does not call XInitThreads,
> because it does not do concurrent access to the display object ...
> The "threading" support in Gtk only works for Gtk calls.

Right. That is the kind of thing which could perhaps be documented
rather than left to an error message once you try it.

> You must call this function in Pidgin, before you initialize Gtk
> and GStreamer.

Except that (theoretically, haha) I'm not actually working on Pidgin;
I'm working on a protocol plugin for libpurple, and Pidgin just happens
to be one of the GUIs which use libpurple. My plugin is loaded *much*
too late for that, and is *supposed* to be entirely UI-agnostic — it
doesn't, and shouldn't, link against Xlib.

As a very short-term solution I can of course throw all the layering
and abstraction out the window, and it does seem that calling
XInitThreads() (from the main thread) right before instantiating the
ximagesrc does seem to work¹.

I do need to fix it properly, which means having the UI program (be it
Pidgin or Adium or something else) provide libpurple with a suitable
GstElement for screen capture. And a UI to select which window/monitor
to capture, too. But I think that a GdkWindowImageSrc (with associated
widgets) probably does make most sense for that, in the long run. 

-- 
dwmw2

¹ Meaning I can now turn my attention to the fact that xvimagesink is
  hosed for the majority of image sizes :)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5213 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180417/e342bef6/attachment.bin>


More information about the gstreamer-devel mailing list