Udpsrc具有一個名爲「超時」的屬性,通過設置此屬性,元件將在管道總線上發佈消息,以防在特定的時間間隔內未收到包。你的接收管道應該看起來像這樣:
gst-launch-0.10 -v udpsrc port = 5000 timeout = 2000! 「application/x-rtp,media =(string)audio,clock-rate =(int)22000,width = 16,height = 16,encoding-name =(string)L16,encoding-params =(string)1,channels =(int)1,channel-positions =(int)1,payload =(int)96「! rtpL16depay! audioconvert!然後alsasink同步=假
總線回調應該是這個樣子:
gboolean
bus_callback (GstBus * bus, GstMessage * message, gpointer data)
{
GError *error;
gchar *parsed_txt;
const GstStructure *st = gst_message_get_structure (message);
const gchar *typename = GST_MESSAGE_TYPE_NAME (message);
const gchar *srcname = GST_MESSAGE_SRC_NAME (message);
GST_LOG ("New %s message from %s: %s", typename, srcname,
st ? gst_structure_get_name(st) : "(null)");
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_INFO:
gst_message_parse_info (message, &error, &parsed_txt);
g_print ("%s\n", parsed_txt);
g_free (parsed_txt);
g_error_free (error);
break;
case GST_MESSAGE_ERROR:
gst_message_parse_error (message, &error, &parsed_txt);
GST_ERROR ("%s (%s)", error->message,
parsed_txt ? parsed_txt : "no debug info");
if (parsed_txt)
g_free (parsed_txt);
GST_DEBUG ("No error handling callback registered");
break;
case GST_MESSAGE_ELEMENT:
/* We don't care for messages other than timeouts */
if (!gst_structure_has_name (st, "GstUDPSrcTimeout"))
break;
GST_WARNING ("Timeout received from udpsrc");
gst_element_set_state(GST_ELEMENT (pipeline),GST_STATE_NULL));
break;
default:
break;
}
祝您好運!
嗨,你有沒有找到解決這個問題的辦法? –