@@ -683,6 +683,58 @@ GstVideoReceiver::_handleEOS(void)
683683 }
684684}
685685
686+ gboolean
687+ GstVideoReceiver::_filterParserCaps (GstElement* bin, GstPad* pad, GstElement* element, GstQuery* query, gpointer data)
688+ {
689+ Q_UNUSED (bin)
690+ Q_UNUSED (pad)
691+ Q_UNUSED (element)
692+ Q_UNUSED (data)
693+
694+ if (GST_QUERY_TYPE (query) != GST_QUERY_CAPS) {
695+ return FALSE ;
696+ }
697+
698+ GstCaps* srcCaps;
699+
700+ gst_query_parse_caps (query, &srcCaps);
701+
702+ if (srcCaps == nullptr || gst_caps_is_any (srcCaps)) {
703+ return FALSE ;
704+ }
705+
706+ GstCaps* sinkCaps = nullptr ;
707+
708+ GstCaps* filter;
709+
710+ if ((filter = gst_caps_from_string (" video/x-h264" )) != nullptr ) {
711+ if (gst_caps_can_intersect (srcCaps, filter)) {
712+ sinkCaps = gst_caps_from_string (" video/x-h264,stream-format=avc" );
713+ }
714+
715+ gst_caps_unref (filter);
716+ filter = nullptr ;
717+ } else if ((filter = gst_caps_from_string (" video/x-h265" )) != nullptr ) {
718+ if (gst_caps_can_intersect (srcCaps, filter)) {
719+ sinkCaps = gst_caps_from_string (" video/x-h265,stream-format=hvc1" );
720+ }
721+
722+ gst_caps_unref (filter);
723+ filter = nullptr ;
724+ }
725+
726+ if (sinkCaps == nullptr ) {
727+ return FALSE ;
728+ }
729+
730+ gst_query_set_caps_result (query, sinkCaps);
731+
732+ gst_caps_unref (sinkCaps);
733+ sinkCaps = nullptr ;
734+
735+ return TRUE ;
736+ }
737+
686738GstElement*
687739GstVideoReceiver::_makeSource (const QString& uri)
688740{
@@ -759,6 +811,8 @@ GstVideoReceiver::_makeSource(const QString& uri)
759811 break ;
760812 }
761813
814+ g_signal_connect (parser, " autoplug-query" , G_CALLBACK (_filterParserCaps), nullptr );
815+
762816 gst_bin_add_many (GST_BIN (bin), source, parser, nullptr );
763817
764818 // FIXME: AV: Android does not determine MPEG2-TS via parsebin - have to explicitly state which demux to use
0 commit comments