0

私は正常に動作する次のパイプラインを持っています:

gst-launch-1.0 -v tcpclientsrc host=192.168.1.132 port=5000  ! gdpdepay !  rtph264depay ! avdec_h264 ! videoconvert ! autovideosink

同じことをするCプログラムを書きたいです。

以前のパイプラインを次のコードに翻訳しましたが、ビデオが開始されません (HELP ME)

#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: %s\n", 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 PLAY\n");
    }

// エラーまたは 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: %s\n", GST_OBJECT_NAME (msg->src), err->message);
                g_printerr ("Debugging information: %s\n", 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;
}
4

2 に答える 2