GStreamer两条Piplines同步

时间:2015-11-23 07:17:39

标签: gstreamer

我开发了一个应用程序,它从文件中获取数据并向每个帧添加元数据,并通过rtp上的udp将数据传输到客户端。

在接收端,客户端会删除该元数据,并且必须播放该视频。

因为我在服务器端使用了

pipeline1 :: gst-launch-1.0 filesrc ! videoparse ! appsink

在appsink上添加元数据并将该缓冲区推送到appsrc。

pipeline 2 :: gst-launch-1.0 appsrc ! rtpgstpay ! udpsink

在Receivers end ::

pipeline1 :: gst-launch-1.0 udpsrc ! rtpgstdepay ! appsink

在appsink上删除元数据并将缓冲区推送到appsrc。

pipeline2 :: gst-launch-1.0 appsrc ! videoparse ! autovideoconvert ! autovideosink

问题是在接收器端,我没有得到所有帧,视频也没有正常播放。只有一帧播放和停止,再次只播放单帧。

任何人都可以提供一些解决方案或建议吗?

服务器端处理帧的

/ *代码* /

/* This is in Function which is called by g_timeout_add_seconds(0, new_sample, NULL);

g_signal_emit_by_name(sink, "pull-sample", &sample, NULL);
buf = gst_buffer_new_wrapped(&header, sizeof(header)); // header is Structure
FrameBuffer = gst_sample_get_buffer(sample);
buffer = gst_buffer_append(buf, FrameBuffer);

g_signal_emit_by_name (appsrc2, "push-buffer", buffer, &ret);

        if(ret != GST_FLOW_OK)
        {
                g_printerr("Failed to Push Buffer");
                return FALSE;
        }
        g_print("Successfully Pushed..\n");

/* Above code is for processing frame at server end. */

/ *处理接收器帧的代码END * /

//This is in Function new_sample which is called by g_timeout_add_seconds(0, new_sample, NULL);
        if(!gst_app_sink_is_eos ((GstAppSink *)sink))
        {
            GstSample *sample = NULL;
            g_signal_emit_by_name(sink, "pull-sample", &sample, NULL); 
              buf = gst_sample_get_buffer(sample);
              gst_buffer_extract(buf, 0, temp, 8);
              if(frameid != temp->FrameID)
              {
                gst_element_set_state(pipeline2, GST_STATE_PLAYING);
              g_print("Frame Header :: %d , Frame ID :: %d\n", temp->FrameHeader, temp->FrameID);
            gint size;
            size = gst_buffer_get_size(buf);
            buffer = gst_buffer_copy_region(buf, GST_BUFFER_OFFSET_NONE, 8, size-8);
            g_print("Size :: -- %d\n",size);
            g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret);
            if(ret != GST_FLOW_OK)
            {
                    g_printerr("Failed to Push Buffer");
                    return FALSE;
            }
            g_print("Successfully Pushed..\n");

0 个答案:

没有答案