After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 584744 - Add libgstvideo bindings
Add libgstvideo bindings
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-sharp
git master
Other All
: Normal normal
: 0.9.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-06-03 16:56 UTC by Maarten Bosmans
Modified: 2009-09-11 08:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
First attempt for a patch (5.58 KB, patch)
2009-06-03 17:02 UTC, Maarten Bosmans
none Details | Review
Fix for parser/gapi2xml.pl (17.86 KB, patch)
2009-06-04 14:31 UTC, Maarten Bosmans
committed Details | Review
Add bindings for libgstvideo (16.77 KB, patch)
2009-06-04 14:34 UTC, Maarten Bosmans
committed Details | Review

Description Maarten Bosmans 2009-06-03 16:56:05 UTC
The video library contains useful helper functions for dealing with video caps.
Comment 1 Maarten Bosmans 2009-06-03 17:02:52 UTC
Created attachment 135890 [details] [review]
First attempt for a patch

This patch adds the following api:

namespace Gst.Video {
  public enum VideoFormat;

  public class VideoFormatUtil {
    public VideoFormatUtil ();
    public static int GetSize (VideoFormat format, int width, int height);
    public static bool HasAlpha (VideoFormat format);
    public static bool IsRgb (VideoFormat format);
    public static bool IsYuv (VideoFormat format);
    public static bool ParseCaps (Gst.Caps caps, out VideoFormat format, out int width, out int height);
    public static bool ParseCapsFramerate (Gst.Caps caps, out int fps_n, out int fps_d);
    public static bool ParseCapsInterlaced (Gst.Caps caps, out bool interlaced);
    public static bool ParseCapsPixelAspectRation (Gst.Caps caps, out int par_n, out int par_d);
  }
}

I'll probably rename VideoFormatUtil to VideoUtil and then move both VideoUtil and VideoFormat to the main Gst namespace.

I'd also like to add some more static methods, but specifying them in Gstreamer.metadata seems a bit redundant as the gapi-parser should be able to generate them automatically, right? It probably doesn't because most of functions of libgstvideo operate on VideoFormat and that is an enum.
Any suggestions?
Comment 2 Sebastian Dröge (slomo) 2009-06-03 18:24:38 UTC
Yes, the parser *should* generate them automatically :) I also had a lot of similar bugs with the parser already... if you want to fix it that'd be great ;)

If you don't have the time for that I guess the best solution would be to simply add them all to the API with the .metadata file.

And something else... I know that the C# naming conventions say that names shouldn't have more than a single upper case letter for the same "word" but I'd really prefer AYUV instead of Ayuv :)

Are you going to bind videosink/videofilter too?


Thanks for working on those library bindings but I think we should coordinate a bit more... I wanted to work on libgstvideo next after the cdda and audio library ;)
Comment 3 Maarten Bosmans 2009-06-03 19:09:05 UTC
> Yes, the parser *should* generate them automatically :) I also had a lot of
> similar bugs with the parser already... if you want to fix it that'd be great

As Enums can't have methods the best fix I can think off is to put all the functions that can't be bound in a per library Global/Util class as static methods, probably marked with hidden="1". Then enabling specific functions can be as easy as a one-line <move-node> in .metadata.

> If you don't have the time for that I guess the best solution would be to
> simply add them all to the API with the .metadata file.

Yes, that's possible, but I'm really hesitant to go the manual way, when we should be fixing the auto-generated stuff.

> And something else... I know that the C# naming conventions say that names
> shouldn't have more than a single upper case letter for the same "word" but I'd
> really prefer AYUV instead of Ayuv :)

Hmm, OK. The only objection I can find is that we have to hardcode the values in .metadata when changing the name attribute to upper case. That kind of defeats the whole auto-generation thing. Or perhaps there is some gapi-magic to uppercase all the enum values at once? The whole gapi thing seems terribly underdocumented. So I guess I'll have to "use the source, Luke".

> Are you going to bind videosink/videofilter too?
> 
> Thanks for working on those library bindings but I think we should coordinate a
> bit more... I wanted to work on libgstvideo next after the cdda and audio
> library ;)

Right now I'm just doing the stuff that I encounter in my app. I didn't come across videosink/videofilter, but will do those in a next version of the patch. Do you have any specific ideas on coördination?
Comment 4 Sebastian Dröge (slomo) 2009-06-03 19:17:57 UTC
(In reply to comment #3)
> > If you don't have the time for that I guess the best solution would be to
> > simply add them all to the API with the .metadata file.
> 
> Yes, that's possible, but I'm really hesitant to go the manual way, when we
> should be fixing the auto-generated stuff.
> 
> > And something else... I know that the C# naming conventions say that names
> > shouldn't have more than a single upper case letter for the same "word" but I'd
> > really prefer AYUV instead of Ayuv :)
> 
> Hmm, OK. The only objection I can find is that we have to hardcode the values
> in .metadata when changing the name attribute to upper case. That kind of
> defeats the whole auto-generation thing. Or perhaps there is some gapi-magic to
> uppercase all the enum values at once? The whole gapi thing seems terribly
> underdocumented. So I guess I'll have to "use the source, Luke".

gapi doesn't have anything for this... you can only override it with the .metadata files by hand for every value. We have this for many other enum values at other places too already (to set the values of the GstEventType enums, to set the Last element of a lot of enums, .....).

gapi isn't perfect and a lot manual work is needed unfortunately. I hope this gets better once gobject-introspection is completely ready and we have a code generator that uses it ;)

IMHO we shouldn't spend too much time on improving it when it is only for very special cases and instead use .metadata or hand-written code.

> > Are you going to bind videosink/videofilter too?
> > 
> > Thanks for working on those library bindings but I think we should coordinate a
> > bit more... I wanted to work on libgstvideo next after the cdda and audio
> > library ;)
> 
> Right now I'm just doing the stuff that I encounter in my app. I didn't come
> across videosink/videofilter, but will do those in a next version of the patch.
> Do you have any specific ideas on coördination?

Well, let's write a mail to each other whenever we start on a new library binding ;) I'll do cdda/audio next...

Comment 5 Maarten Bosmans 2009-06-04 14:31:04 UTC
Created attachment 135943 [details] [review]
Fix for parser/gapi2xml.pl

> Yes, the parser *should* generate them automatically :) I also had a lot of
> similar bugs with the parser already... if you want to fix it that'd be great

I found the bug. The problem was that the prefix gst_video_ wasn't recognized as matching with the namespace Gst.Video.

While at it, I also fixed the stripping for the namespace from the cname. (the ns_main stuff in the patch)  This made a lot of renaming rules in Gstreamer.metadata unnescessary.
Comment 6 Maarten Bosmans 2009-06-04 14:34:06 UTC
Created attachment 135944 [details] [review]
Add bindings for libgstvideo

This patch needs the fix from the previous attachment.

I made the VideoFormat values uppercase and added VideoSink and VideoFilter.
As far as I'm concerned, this patch is ready to go in.
Comment 7 Sebastian Dröge (slomo) 2009-06-06 05:06:41 UTC
commit b01a09a8c04fc5a11ee79337508f1d4440c27b9f
Author: Maarten Bosmans <mkbosmans@gmail.com>
Date:   Fri Jun 5 21:22:51 2009 +0200

    Add bindings for libgstvideo
    
    Fixes bug #584744.

commit 20b3829c0a9f3dfbf70c007bce2cbdb96558b37a
Author: Maarten Bosmans <mkbosmans@gmail.com>
Date:   Fri Jun 5 21:09:40 2009 +0200

    Fix gapi2xml.pl to accept nested namespaces
    
    The perl script should accept nested namespaces, like N1.N2, for outputting
    xml.  Making a Global class for static methods didn't work for functions lik
    n1_n2_function.  Another change is that N1 is stripped from the cname for th
    element name.
    
    Partially fixes bug #584744.


I'll push those changes after cleaning up some things a bit :) Thanks for the patch