Skip to content

Allow a GMainLoop when capturing using GStreamer#18499

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
RidgeRun:optional-gstreamer-mainloop
Nov 13, 2020
Merged

Allow a GMainLoop when capturing using GStreamer#18499
opencv-pushbot merged 1 commit intoopencv:masterfrom
RidgeRun:optional-gstreamer-mainloop

Conversation

@michaelgruner
Copy link
Copy Markdown
Contributor

A running GMainLoop processes many events on the GLib/GStreamer world. While some things may work without it, many others won't. Examples of these are signals, timers and many other source events. The problem becomes more concerning by the fact that some GStreamer elements rely on signals to work. This PR allows the user to specify an OpenCV option to start a main loop, if needed. Since the loop blocks, this is done in a separate thread.

I've documented the example that motivated to push this in this wiki.

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

A running GMainLoop processes many events on the GLib/GStreamer
world. While some things may work without it, many others wont.
Examples of these are signals, timers and many other source
events. The problem becomes more concerning by the fact that
some GStreamer elements rely on signals to work.

This commit allows the user to specify an OpenCV option to
start a main loop, if needed. Since the loop blocks, this is
done in a separate thread.
@michaelgruner
Copy link
Copy Markdown
Contributor Author

Do you guys see value on absorbing this?

@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 4, 2020

Please share some simple reproducer for this problem.


Opens:

  • singleton for thread?
  • gst_bus_add_watch()?
  • also please take a look on handleMessage(GstElement * pipeline) implementation and its calls.

@AsyaPronina
Copy link
Copy Markdown
Contributor

Hi @michaelgruner, could you please point which category of GStreamer elements can't work without GMainLoop?

@asmorkalov
Copy link
Copy Markdown
Contributor

@michaelgruner Friendly reminder.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 389495f into opencv:master Nov 13, 2020
@alalek alalek mentioned this pull request Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants