How to send gstreamer buffer over ROS?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to send gstreamer buffer over ROS?

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


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); map.size );

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

        gst_buffer_unmap(buffer, &map);

        msg.header.stamp = ros::Time::now();

        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

Sent from:
gstreamer-devel mailing list
[hidden email]