我对 RTP H264 流有相同的任务。用 C++ 编码。
我会给未来的开发者一个简短的代码sn-p。
我的烟斗是这样的。
auto source = gst_element_factory_make("udpsrc", nullptr);
auto rtpJitterBuffer = gst_element_factory_make("rtpjitterbuffer", nullptr);
auto depay = gst_element_factory_make("rtph264depay", nullptr);
auto h264parse = gst_element_factory_make("h264parse", nullptr);
auto decode = gst_element_factory_make("openh264dec", nullptr);
auto sinkV = gst_element_factory_make("glimagesink", nullptr);
我为解码器使用了探针板。
所以你需要一个
GstPadProbeCallback
喜欢
static GstPadProbeReturn pad_cb(GstPad *pad, GstPadProbeInfo *info, gpointer user_data) {
GstEvent *event = GST_PAD_PROBE_INFO_EVENT(info);
if (GST_EVENT_CAPS == GST_EVENT_TYPE(event)) {
GstCaps * caps = gst_caps_new_any();
int width, height;
gst_event_parse_caps(event, &caps);
GstStructure *s = gst_caps_get_structure(caps, 0);
gboolean res;
res = gst_structure_get_int (s, "width", &width);
res |= gst_structure_get_int (s, "height", &height);
if (!res) {
qWarning() << "no dimenions";
}
qDebug() << "GST_EVENT_CAPS" << width << height;
}
return GST_PAD_PROBE_OK;
}
您可以像这样将探针添加到您的焊盘上
auto *pad = gst_element_get_static_pad(decode, "src");
gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_EVENT_BOTH, pad_cb, &customData_, nullptr);
gst_object_unref(pad);
每次格式更改时都会调用此回调。你不需要检查两个方向,但我还是这样做了。