currently I’m building an application that will need to handle different types of streams, some of them are H264 and some other are MJPEG, thus I’m trying to build C++ code that generates the adecuate gstreamer pipeline according to each stream.
My idea is to get the type of stream sent using the gst-discoverer, so far I’ve only managed to do it through the command line using the gst-discoverer-1.0
command. Does anyone know if this feature can be used inside C++ code ?
After some back and forth, I managed to obtain almost all of the info I needed from different incoming streams, both http and rtsp. I do it by using the following lines of code:
First. we need three pointers to the following classes:
GstDiscoverer* discoverer;
GstDiscovererInfo* discoverer_info;
GstDiscovererStreamInfo* stream_info;
And then we populate them as such:
current_discoverer.discoverer = gst_discoverer_new(10 * GST_SECOND, &error);
current_discoverer.discoverer_info = gst_discoverer_discover_uri(current_discoverer.discoverer, source_video.c_str(), &error);
current_discoverer.stream_info = gst_discoverer_info_get_stream_info(current_discoverer.discoverer_info);
And finally, we can obtain the information of the final object using the following line:
if(current_discoverer.stream_info != NULL)
stream_caps_str = gst_caps_to_string(gst_discoverer_stream_info_get_caps(current_discoverer.stream_info));
This solution works for me, but it can probably be optimized or it has a better or more efficient approach, at the same time, a few http links don't work at all, neither by CLI or through code, so I guess it has something to to with the link itself and not the approach.