gstreamer

How can I create gstreamer caps with parenthesis in name?


I have a source element with the following capabilities:

    Capabilities:              
  image/jpeg               
              width: [ 16, 5184 ]
             height: [ 16, 3880 ]
          framerate: [ 0/1, 120/1 ]
  video/x-raw
             format: { (string)NV12, (string)NV16 }
              width: [ 16, 5184 ]
             height: [ 16, 3880 ]
          framerate: [ 0/1, 120/1 ]
  video/x-raw(memory:GBM)
             format: { (string)NV12, (string)NV16 }
              width: [ 16, 5184 ]
             height: [ 16, 3880 ]
          framerate: [ 0/1, 120/1 ]
  video/x-bayer
             format: { (string)bggr, (string)rggb, (string)gbrg, (string)grb
                bpp: { (string)8, (string)10, (string)12, (string)16 }      
              width: [ 16, 5184 ]                                           
             height: [ 16, 3880 ]                                           
          framerate: [ 0/1, 120/1 ]  

I want to create a filter for it in code to do the following (this is stolen from an actual command that does run from the command-line):

[start of chain] ! capsfilter 'video/x-raw(memory:GBM),format=NV12,width=1280,height=720,framerate=30/1' ! [rest of chain...]

However, when I make the following call, it falls at runtime due to "structure gststructure.c:333:gst_structure_validate_name: Invalid character '(' at offset 11 in structure name: video/x-raw(memory:GBM)"

GstCaps *caps = gst_caps_new_simple ("video/x-raw(memory:GBM)",
 "format", G_TYPE_STRING, "NV12",
 "framerate", GST_TYPE_FRACTION, 30, 1,
 "width", G_TYPE_INT, 1280,
 "height", G_TYPE_INT, 720,
 NULL);

How can I resolve this?


Solution

  • Have a look at GstCapFeatures, https://gstreamer.freedesktop.org/documentation/gstreamer/gstcapsfeatures.html?gi-language=c

    Examples for caps features would be the requirement of a specific GstMemory types or the requirement of having a specific GstMeta on the buffer. Features are given as a string of the format memory:GstMemoryTypeName or meta:GstMetaAPIName.