Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GStreamer support #59

Closed
daniel-j opened this issue Oct 14, 2019 · 15 comments
Closed

Add GStreamer support #59

daniel-j opened this issue Oct 14, 2019 · 15 comments

Comments

@daniel-j
Copy link

daniel-j commented Oct 14, 2019

Add GStreamer to gintrospection. Would be nice to have for doing media players and other things with audio/video.

@StefanSalewski
Copy link
Owner

OK, will try soon...

Do you know about a small test application, in C, or maybe Python or another language that we can use for testing basic functionality then? (Testing and providing examples is often more work than adding it to gintro collection, and without not one will ever use it.)

@StefanSalewski
Copy link
Owner

I just had a first look on gstreamer. Unfortunately it differs from the other gtk related packages, documentation differs also.

To learn what gstreamer is at all, I found https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=c

One used function there is gst_bus_timed_pop_filtered () with API description https://gstreamer.freedesktop.org/documentation/gstreamer/gstbus.html?gi-language=c#gst_bus_timed_pop_filtered

There we learn that gst_message_unref() has to be used to unref the result. But that unref function is not available from gir file /usr/share/gir-1.0/Gst-1.0.gir. So we have to make decisions which unref function is needed for which gst object. For other gtk modules that was not that difficult, as for most widgets and other gtk object a plain gobject_unref() was enough.

Another issue is, that there seems to exist a few elements in gst that reports itself as objects, but have no parent. That has to be investigated.

So finally, this gst stuff seems to be not that easy, it will take more than a few hours. I will tell you when there is progress.

@StefanSalewski
Copy link
Owner

@StefanSalewski
Copy link
Owner

There is already some progress on gst, but it is hard.

gstreamer is different from core gtk modules, gst_message_unref() and gst_mini_object_unref() are not provided by introspection, and there are some root classes not based on gobject. And for the most procs I have no idea what they do at all. For the statement of E. Bassi that we should use boxed types -- well I am not sure if for example GstMessage is a boxed type at all. I think providing gst_mini_object_unref() for it manually will do. The first 8k lines of gst.nim compile already, so maybe end of this months all will compile.

But of course I don't know if it will work, and I have no idea at all what you will do with it when it will work.

@StefanSalewski
Copy link
Owner

Done.

@mantielero
Copy link

I was trying to experiment with this.

Where is the function gst_element_factory_make and gst_pipeline_new?

@StefanSalewski
Copy link
Owner

I do know nearly nothing about GStreamer and still wonder why someone wants it for Nim -- I added it because daniel-j asked for it, but he never came back.

From

https://gstreamer.freedesktop.org/documentation/gstreamer/gstelementfactory.html?gi-language=c

gst_element_factory_make is a convenient shortcut only, so maybe it is not provided by gobject-introspection. You may use the two other functions instead, if they are available. Later we can add that function manually.
Maybe next winter, but maybe I will work on the book instead.

@StefanSalewski
Copy link
Owner

But seems to exist with name make. Does it not work for you as expected?

stefan@nuc /tmp/hhh $ grep  -A5 gst_element_factory_make ~/.nimble/pkgs/gintro-0.7.2/gintro/gst.nim
proc gst_element_factory_make(factoryname: cstring; name: cstring): ptr Element00 {.
    importc, libprag.}

proc make*(factoryname: cstring; name: cstring = ""): Element =
  let gobj = gst_element_factory_make(factoryname, safeStringToCString(name))
  if gobj.isNil:
    return nil
  let qdata = g_object_get_qdata(gobj, Quark)
  if qdata != nil:
    result = cast[type(result)](qdata)

@mantielero
Copy link

The problem seems to be that it is not exported.

Regarding why Gstreamer might be useful, I think it could be used to demultiplex audio and video, applying filters and multiplexing again. Maybe it could be combined with Cairo to draw stuff on the video. So it could be useful to automate some audio/video stuff.

Regarding "why in nim", I think Nim could be a goof fit to create filters with macros.

@mantielero
Copy link

mantielero commented Apr 16, 2020

The same happens with gst_pipeline_new, which should be gst_pipeline_new*.

In general, there are many functions that looks like they should be exported.

@StefanSalewski
Copy link
Owner

No, it should not. Starting maybe a year ago we stopped exporting the low level functions, as they should be not used by users.

If you can prove that you really need the low level variant, we can of course export it.

You can use older version of gintro, maybe 0.5, that may export all low level stuff still. But wait, maybe v 0.5
had not gst support already?

Have to watch TV news now, bye.

@mantielero
Copy link

I just realized that.

Keep safe

@ITwrx
Copy link

ITwrx commented Dec 19, 2020

@StefanSalewski i just wanted to comment to tell you that i appreciate you adding gstreamer and it's one of the first things i look for when evaluating a gtk wrapper for a lang, because i already have plans for it. One example is a security cam viewing and NVR program for linux gtk desktop i already started with rust and gtk3. gtk3 didn't handle the video streams in the way i needed it to, so i had to wait on gkt4 which has a new video widget which might solve my problem . Also, i was not very productive in rust so i started learning nim. For the linux desktop (the only one i target) it's either ffmpeg or gstreamer for certain media, especially stuff like rtsp streams, and IIRC, gstreamer has fuller docs for integrating into one's project, so it's kind of important to me. I hope to make this program with nim, gtk4 and gintro when i get to it in my list o' projects.
Thanks

@arkanoid87
Copy link

gstreamer is very important for embedded programming, and so is crucial to help Nim fit into the embedded world!
I reached Nim thanks to this lib.

@StefanSalewski
Copy link
Owner

OK we have gstreamer now, and at least one tiny example. So I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@ITwrx @mantielero @daniel-j @arkanoid87 @StefanSalewski and others