Caps of element

Mats Lindestam mats.lindestam at gmail.com
Sat Oct 28 07:07:34 UTC 2017


Hi,
Is there a way for an element to get the caps of a pad?

More specific, I need to know the "media-type" of the video-track in a
matroskademux.

What I have done so far is to let the user of the matroskademux extract the
caps and from the caps get the media-type, e.g. image/jpeg or video/x-h264
(see code-snippet below).
I have added a media-type property in the matroskademux that is set by the
user of the matroskademuxer.

All this is done in the context of the pad-added signal callback function.
Then I can use the media-type property, in the matroskademux, to make
certain decisions.

All this feels a bit cumbersome. What I would like to do is to make the
matroskademuxer get the media-type from its caps, but I can not seem to
figure out how to do that.

Cheers

/Mats


  /* Get the media type, e.g. image/jpeg or video/x-h264, from the demuxer
   * caps. Use the media type to set the demuxer video-encoding-format
   * property.
   */
  GstStructure *demux_caps_struct = gst_caps_get_structure (demux_caps, 0);
  if (demux_caps_struct != NULL) {
    const gchar *media_type = gst_structure_get_name (demux_caps_struct);
    if (media_type != NULL) {
      /* Dig out the matroskademux from the recordingdemuxbin. */
      GstElement *demux = gst_bin_get_by_name (GST_BIN (self),
"matroskademux");
      if (demux != NULL) {
        g_object_set (G_OBJECT (demux), "video-encoding-format",
            media_type, NULL);

        /* Clean up */
        gst_object_unref (demux);
        g_free (media_type);
      } else {
        GST_DEBUG ("could not set matroskademux video-encoding-fromat
property");
        /* Clean up */
        g_free (media_type);
      }
    }
  }


-- 
Mvh

/Mats
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20171028/47c6ef96/attachment.html>


More information about the gstreamer-devel mailing list