我有以下管道可以正常工作:
gst-launch-1.0 -v tcpclientsrc host=192.168.1.132 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink
我想写一个C程序来做同样的事情。
我将之前的管道转换为以下代码,但视频无法启动(帮助我)
#include <gst/gst.h>
int main(int argc, char *argv[]) {
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;
/* Initialize GStreamer */
gst_init (&argc, &argv);
GError *error = NULL;
GstElement *pipeline = gst_parse_launch("tcpserversrc name=src ! gdpdepay ! rtph264depay ! avdec_h264 !videoconvert ! autovideosink", &error);
if (!pipeline) {
g_print ("Parse error: %sn", error->message);
exit (1);
}
GstElement *src = gst_bin_get_by_name(GST_BIN(pipeline), "src");
g_object_set(src, "host", "192.168.1.132","port",5000, NULL);
开始玩
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.n");
gst_object_unref (pipeline);
return -1;
}else {
g_printerr("ERROR PLAYn");
}
等到错误或EOS
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
// Parse message
if (msg != NULL) {
GError *err;
gchar *debug_info;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_ERROR:
gst_message_parse_error (msg, &err, &debug_info);
g_printerr ("Error received from element %s: %sn", GST_OBJECT_NAME (msg->src), err->message);
g_printerr ("Debugging information: %sn", debug_info ? debug_info : "none");
g_clear_error (&err);
g_free (debug_info);
break;
case GST_MESSAGE_EOS:
g_print ("End-Of-Stream reached.n");
break;
default:
// We should not reach here because we only asked for ERRORs and EOS
g_printerr ("Unexpected message received.n");
break;
}
gst_message_unref (msg);
}
免费资源
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
我找不到任何明显的东西。您是否尝试过使用 GST_DEBUG="*:2" ./myapp 运行以查看是否有一些警告
gdppay/gdpdepay目前未移植到iOS 1.2库中。我已经读过它应该包含在 1.3 - 1.4 版本中。我猜这就是问题所在。