How to send gstreamer buffer over ROS?

jeyp4 jaiforfriend at gmail.com
Sat Oct 5 14:42:00 UTC 2019


Hello
I am trying to build a gstreamer-Ros application which can send h.265
encoded bits over ROS network.

<http://gstreamer-devel.966125.n4.nabble.com/file/t379085/ask.jpg> 

I am avoiding RTP server method, because I think it results in high latency.
Also, I need time-stamp property of ROS msg. ( Correct me if I am wrong )

I think I would be using appsink and appsrc combination.

My publisher code look like:
static GstFlowReturn onNewBuffer (GstAppSink *appsink, gpointer userData)
    {
        videoCapture *server = reinterpret_cast<videoCapture*>(userData);
        GstMapInfo map;

        GstSample *sample;
        g_signal_emit_by_name(appsink, "pull-sample", &sample);

        GstBuffer *buffer = gst_sample_get_buffer(sample);

        sensor_msgs::CompressedImage msg;
        gst_buffer_map(buffer, &map, GST_MAP_READ);
        msg.data.resize( map.size );

        memcpy( &msg.data[0], map.data, map.size );

        gst_buffer_unmap(buffer, &map);
        gst_sample_unref(sample);

        msg.header.stamp = ros::Time::now();
        server->publish(msg);

        return GST_FLOW_OK;
    }


My subscriber code look like:
void getBuffer(const sensor_msgs::CompressedImageConstPtr &msg)
    {
            GstBuffer *buffer = gst_buffer_new_and_alloc(msg->data.size());
            gst_buffer_fill(buffer, 0, &msg->data[0], msg->data.size());
            GstFlowReturn ret;
            g_signal_emit_by_name(_source, "push-buffer", buffer, &ret);

            baseFrameRecieved = true;
    }


I am receiving error at subscriber side.
Is my approach correct?

Full code
<https://answers.ros.org/question/334608/gstreamer-appsink-and-appsrc-to-publish-and-subscribe-h265-webcam-stream-how/>  



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list