Caps of element

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Caps of element

Zmad
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

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps of element

Tim Müller
On Sat, 2017-10-28 at 09:07 +0200, Mats Lindestam wrote:

Hi Mats,

Maybe let's take a step back and tell us what you're trying to do
higher-level? Then we can try and make suggestions.

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps of element

Zmad
Hi,
Sorry for not answering earlier. I never got you answer back. Do I have to
be a subscriber to receive answers to my private-mail? It was a fluke that I
stumbled on nabble and found your answer. Anyway.

When I run a matroska file through a pipeline using a matroskademux I would
like to be able to find out the "media type" e.g. "image/jpeg",
"video/x-h264", etc.. for the video-stream in the matroskademux.

I have found a way to do what i want. I look at the caps for the
matroskademux source-pad. Here is an example of what I do:

static void find_media_type (GstMatroskaDemux * demux, char *media_type) {
  GstMatroskaTrackContext *context = g_ptr_array_index (demux->common.src,
0);
  if (context != NULL) {
    GstStructure *caps_struct = gst_caps_get_structure (context->caps, 0);
    if (caps_struct != NULL) {
      char *media_type = gst_structure_get_name (caps_struct)
    }
  }
}

Maybe there is a better way. Maybe I should get it when I get a cap_event?

BR
/Mats
 



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel