samprat
samprat

Reputation: 2214

how to send QImages via gstreamer over udp

I am using non supported v4L camera and i need to stream video to remote Pc using gstreamer.
I have successfully stream it on host computer using Qt and QImages . earlier I have asked question here

about how to feed external frames into gstreamer .
I read blog here and tried to implement it using gstreamer 1.0 but somehow its not working as expected.
So I thought of streaming qimages via gstreamer in same network but on different workstation. I am wondering if someone can give me starting point of how to send Qimages using gstreamer 1.0. I am not asking for code but just a direction.
I am very new to this multi-media stuff so I will be grateful if you explain it in layman's language.

Thanks in advance

Upvotes: 0

Views: 1158

Answers (1)

mpr
mpr

Reputation: 3378

First you need to determine what protocol and encoding type you want to use to transmit it over UDP. I'd recommend h264 over RTP for most cases.

GStreamer offers a wide collection of plugins to do this, including a command line utility called gst-launch. Here are some basic send/receive commands:

gst-launch-1.0 videotestsrc pattern=ball ! video/x-raw,width=1280,height=720 ! videoconvert ! x264enc ! h264parse ! rtph264pay ! udpsink host=localhost port=7777

gst-launch-1.0 udpsrc port=7777 ! rtpbin ! rtph264depay ! decodebin ! videoconvert ! autovideosink

When you write applications that use a GStreamer pipeline, the simplest way to get frames to that pipeline is with an appsrc. So you might have something like this:

const char* pipeline = "appsrc name=mysrc caps=video/x-raw,width=1280,height=720,format=RGB ! videoconvert ! x264enc ! h264parse ! rtph264pay ! udpsink host=localhost port=7777";

GError* error(NULL);
GstElement* bin = gst_parse_bin_from_description(tail_pipe_s.c_str(), true, &error);
if(bin == NULL || error != NULL) {
        ...
}

GstElement* appsrc = gst_bin_get_by_name(GST_BIN(bin), "mysrc");

GstAppSrcCallbacks* appsrc_callbacks = (GstAppSrcCallbacks*)malloc(sizeof(GstAppSrcCallbacks));
memset(appsrc_callbacks, 0, sizeof(GstAppSrcCallbacks));
appsrc_callbacks->need_data = need_buffers;
appsrc_callbacks->enough_data = enough_buffers;
gst_app_src_set_callbacks(GST_APP_SRC(appsrc), appsrc_callbacks, (gpointer)your_data, free);

gst_object_unref(appsrc);

Then in a background thread you make calls to gst_app_src_push_buffer, which would involve reading the raw data from your QImage and converting it to a GstBuffer.

OR

Maybe QT has some easier way that I'm not aware of. :)

Upvotes: 2

Related Questions