Number of threads in a typical Gstreamer pipeline
Nicolas Dufresne
nicolas at ndufresne.ca
Fri Oct 22 14:33:42 UTC 2021
Le vendredi 22 octobre 2021 à 03:48 +0000, Mohammad Sheraj via gstreamer-devel a
écrit :
> Hi,
>
> I want to improve my understanding of Gstreamer.
>
> How many threads are there in this GStreamer pipeline?
> gst-launch-1.0 autovideosrc ! queue ! fakesink
It's impossible to say which video source will be picked by autovideosrc.
Replace this magic thing with an explicit src, like videotestsrc, then you
should have 4 thread,
- source streaming thread
- queue streaming thread
- main thread (gst-launch runs a GLib main-loop, though this is optional)
- Some thread pool.
You may have more threads if you use an element that initialize GIO, those will
stay mostly idle.
>
> I want the total number and function of each thread.
> I searched online and in the documentation
> (
> https://gstreamer.freedesktop.org/documentation/application-development/advanced/threads.html?gi-language=c#
> ) but couldn't find a clear answer.
You can track GStreamer related thread in your software with the STREAM_STATUS
message. All other threads are from third party libraries, glib or you libc.
>
> My knowledge is that there is a main loop thread, an event thread (not sure)
> and two (because of queue element) buffer threads here.
> This gives a total of 4 threads for the mentioned pipeline.
>
> Am I correct? Or is there some other mechanism?
>
> **Experiments:**
>
> Running the first time gives 8 threads initially.
> / # ps -T | grep "gst"
> 3681 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3702 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3703 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3704 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3716 root 0:00 {queue0:src} gst-launch-1.0 autovideosrc ! queue !
> fakesink
> 3717 root 0:00 {fake-auto-video} gst-launch-1.0 autovideosrc ! queue !
> fakesink
> 3718 root 0:00 {gmain} gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3719 root 0:00 {pool} gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3729 root 0:00 grep gst
>
> After some time it becomes 7 threads
>
> / # ps -T | grep "gst"
> 3681 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3702 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3703 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3704 root 0:00 gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3716 root 0:00 {queue0:src} gst-launch-1.0 autovideosrc ! queue !
> fakesink
> 3717 root 0:02 {fake-auto-video} gst-launch-1.0 autovideosrc ! queue !
> fakesink
> 3718 root 0:00 {gmain} gst-launch-1.0 autovideosrc ! queue ! fakesink
> 3731 root 0:00 grep gst
>
> I did `strace -p 3681` and so on and found
>
> 3681:
> ppoll([{fd=3, events=POLLIN}, {fd=9, events=POLLIN}], 2, NULL, NULL, 0
> 3702:
> ioctl(11, BINDER_WRITE_READ
> 3703
> ioctl(11, BINDER_WRITE_READ
> 3704:
> ioctl(11, BINDER_WRITE_READ
> 3716:
> ...
> futex(0x5580a842a8, FUTEX_WAIT_PRIVATE, 11083, NULL) = 0
> 3717:
> ...
> ppoll([{fd=6, events=POLLIN|POLLPRI|POLLERR|POLLHUP|POLLNVAL}], 1, {tv_sec=0,
> tv_nsec=31373754}, NULL, 8) = 0 (Timeout)
> futex(0x5580a842a8, FUTEX_WAKE_PRIVATE, 1) = 1
> futex(0x5580a84290, FUTEX_WAKE_PRIVATE, 1) = 1
> 3718:
> ppoll([{fd=5, events=POLLIN}], 1, NULL, NULL, 0
>
> What does this mean?
There is no mainline code in GStreamer that would use Android ioctl BINDER, so I
suppose you are using some HW specific video source and then sky is the limit on
what that third party camera stack may do.
>
> Thanks and Regards,
>
> Mohammad Sheraj
> Connected Smart Systems (CSS)
> Qualcomm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20211022/1063ee4f/attachment.htm>
More information about the gstreamer-devel
mailing list