Gstreamer:如何在运行时更改udpsrc源中的端口?

时间:2019-04-22 13:23:52

标签: gstreamer

我想在udp流正在运行时更改udpsrc源的端口以切换到另一个流。我可以通过回调函数设置端口,但是一旦播放了流,就无法更改端口。

callback-function1正常工作(将端口设置为5006可以工作),但是callback-function2无效(流停止了,但是不再恢复播放状态)

是否可以在现有管道中更改udpsrc端口?

我的回调函数:

/* This function is called when the button1 is clicked */

static void button1_cb (GtkButton * button, GstElement * pipeline)
{
  //gst_element_set_state (pipeline, GST_STATE_READY);
GstElement *ppipeline = gst_bin_get_by_name (GST_BIN (pipeline), "myudpsrc");
g_object_set (G_OBJECT (ppipeline), "port",5006, NULL);
   gst_element_set_state (pipeline, GST_STATE_PLAYING);

}

/* This function is called when the button2 is clicked */

    static void button2_cb (GtkButton * button, GstElement * pipeline)
    {
      gst_element_set_state (pipeline, GST_STATE_READY);
    GstElement *ppipeline = gst_bin_get_by_name (GST_BIN (pipeline),"myudpsrc");
g_object_set (G_OBJECT (ppipeline), "port",5007, NULL);
   gst_element_set_state (pipeline, GST_STATE_PLAYING);
}

///在主函数中使用gst_parse_launch创建管道:

pipeline = gst_parse_launch("gst-launch-1.0 -v udpsrc name=myudpsrc multicast-group=224.0.0.0 ! tsparse ! tsdemux ! queue ! h264parse ! avdec_h264 ! autovideosink", NULL);

0 个答案:

没有答案