简体   繁体   中英

How to check type of new added pad?

My pipeline scheme(dynamic link):

videotestsrc OR audiotestsrc ! decodebin ! queue ! autovideosink OR autoaudiosink

I trying to use this advice to check which type of data I got (video/audio), but if I use decodebin like demuxer, then I get just "src_0" instead of "audio" or "video" . How I can check my pad type for linking right element for playback? May be I can use one universal element for audio playback and video playback, like playsink(but it does not work for video)?

You can get the caps of the newly added pad and check if it contains audio or video caps (or something else).

Try with:

gst_pad_get_current_caps (pad);

or:

gst_pad_get_allowed_caps (pad);

If you are using gstreamer 0.10 (which is 3+ years obsolete an unmantained), you have:

gst_pad_get_caps_reffed (pad);

Then just check the returned caps if it is audio or video by getting the structure from the caps and checking if its name starts with video or audio.

/* There might be multiple structures depending on how you do it,
 * but usually checking one in this case is enough */
structure = gst_caps_get_structure (caps, 0);
name = gst_structure_get_name (structure);
if (g_str_has_prefix (name, "video/")) {
   ...
} else if (g_str_has_prefix (name, "audio/")) {
   ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM