我正在尝试构建管道,当" pad-added"收到回叫。 当我运行udpsink管道时,我没有收到任何回调,而是收到GST_MESSAGE_ERROR,并显示以下消息:内部数据流错误。
这是我的管道:
gst-launch-1.0 -vvv udpsrc port=5004 ! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! imxvpudec ! imxipuvideosink sync=false
为Gstreamer的教程3编写代码
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <gst/gst.h>
#include <sys/time.h>
#define VIDEO_CAPS "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264"
static void cb_new_pad(GstElement *element, GstPad *pad, gpointer data)
{
gchar *name;
name = gst_pad_get_name(pad);
printf("A new pad %s is created\n", name);
g_free(name);
}
gboolean bus_callback(GstBus *bus, GstMessage *msg, gpointer data)
{
switch(GST_MESSAGE_TYPE(msg))
{
case GST_MESSAGE_EOS:
break;
case GST_MESSAGE_ERROR:
{
GError *err;
gchar *debug_info;
gst_message_parse_error (msg, &err, &debug_info);
printf("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
break;
}
case GST_MESSAGE_WARNING:
{
GError *err;
gchar *debug_info;
gst_message_parse_warning(msg, &err, &debug_info);
printf("Warning received from element %s: %s", GST_OBJECT_NAME (msg->src), err->message);
break;
}
default:
break;
}
return TRUE;
}
int main(int argc, char *argv[])
{
GstCaps *caps;
GstElement *udpsrc;
GstElement *videodepay, *videoparse;
GstElement *videosink, *videodec;
GstElement *pipeline;
GstBus *bus = NULL;
guint bus_watch_id = 0;
GMainLoop *g_main_loop = NULL;
//Initialize GStreamer
gst_init(NULL, NULL);
//the pipeline to hold everything
pipeline = gst_pipeline_new(NULL);
g_assert(pipeline);
//udp source
udpsrc = gst_element_factory_make("udpsrc", "rtpsrc");
g_assert(udpsrc);
g_object_set(udpsrc,"port", 5004, NULL);
g_object_set(udpsrc,"timeout", (guint64)3000000000UL, NULL);
//set caps
caps = gst_caps_from_string(VIDEO_CAPS);
g_object_set(udpsrc, "caps", caps, NULL);
gst_caps_unref(caps);
//depayloading and decoding
videodepay = gst_element_factory_make("rtph264depay", "depay");
g_assert(videodepay);
videoparse = gst_element_factory_make("h264parse", "parse");
g_assert(videoparse);
videodec = gst_element_factory_make("imxvpudec", "dec");
g_assert(videodec);
videosink = gst_element_factory_make("imxipuvideosink", "sink");
g_object_set(videosink, "sync", FALSE, NULL);
g_assert(videosink);
gst_bin_add_many(GST_BIN(pipeline), udpsrc, videodepay, videoparse, videodec, videosink, NULL);
gst_element_link(videodepay, videoparse);
gst_element_link(videoparse, videodec);
gst_element_link(videodec, videosink);
g_signal_connect(udpsrc, "pad-added", G_CALLBACK(cb_new_pad), NULL);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_main_loop = g_main_loop_new(NULL, FALSE);
if ( NULL == g_main_loop )
{
printf("\r\nFailed in main Loop\r\n");
exit(1);
}
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
bus_watch_id = gst_bus_add_watch(bus, bus_callback, g_main_loop);
gst_object_unref(GST_OBJECT(bus));
g_main_loop_run(g_main_loop);
return 0;
}
当我收到&#34; pad-added&#34;信号φ