【问题标题】:How to check type of new added pad?如何检查新添加的焊盘类型?
【发布时间】:2015-07-26 16:54:03
【问题描述】:

我的流水线方案(动态链接):

videotestsrc 或 audiotestsrc !解码器!队列 !自动视频接收器或 自动音频接收器

我尝试使用 this advice 检查我得到的数据类型(视频/音频),但如果我使用 decodebin 之类的 demuxer,那么我只会得到 "src_0" 而不是 “音频”“视频”。如何检查我的打击垫类型以链接正确的元素以进行播放?可能我可以使用一个通用元素进行音频播放和视频播放,比如playsink(但它不适用于视频)?

【问题讨论】:

    标签: c++ audio video gstreamer glib


    【解决方案1】:

    您可以获取新添加的 pad 的 caps 并检查它是否包含音频或视频 caps(或其他内容)。

    尝试:

    gst_pad_get_current_caps (pad);
    

    或:

    gst_pad_get_allowed_caps (pad);
    

    如果您使用的是 gstreamer 0.10(已经过时 3 年以上且无人维护),您有:

    gst_pad_get_caps_reffed (pad);
    

    然后只需通过从大写字母中获取结构并检查其名称是否以视频或音频开头来检查返回的大写字母是音频还是视频。

    /* 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/")) {
       ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-13
      • 2016-05-27
      • 2017-02-24
      • 2011-12-27
      • 1970-01-01
      • 2012-08-13
      • 1970-01-01
      相关资源
      最近更新 更多