UDP receiver doesnt work well

333 views
Skip to first unread message

Сережа Сандалов

unread,
Jul 23, 2018, 10:39:40 AM7/23/18
to gstreamer-java
Hi everyone!

I have some problems with signal reception.

I pass the video over the udp protocol as follows:

gst-launch-1.0 filesrc location = video.mp4! decodebin! x264enc! mpegtsmux! queue leaky = downstream! udpsink host = 127.0.0.1 port = 3000 buffer-size = 5000000 sync = false async = false (run from the command line)

Next, my task is to connect to the port and output the video to the swt window. I tried the following

1) Output via autovideosink
Bin bin1 = Pipeline.launch ("udpsrc port = 3000 buffer-size = 5000000! tsdemux!" +
                "h264parse! avdec_h264! autovideosink");
pipe1.addMany (bin1);
pipe1.play (); <- it works well

2) The same, only in more detail
Element udpsrc = ElementFactory.make ("udpsrc", "source");
        udpsrc.set ("port", 3000);
        udpsrc.set ("buffer-size", 5000000);
        Element tsdemuxer = ElementFactory.make ("tsdemux", "demuxer");
        Element parse = ElementFactory.make ("h264parse", "parser");
        Element dec = ElementFactory.make ("avdec_h264", "decoder");
        Element sink = ElementFactory.make ("autovideosink", "videosink");
        pipe1.addMany (udpsrc, tsdemuxer, parse, dec, sink);
        udpsrc.link (tsdemuxer);
        tsdemuxer.link (parse);
        parse.link (dec);
        dec.link (sink);
        pipe1.play ();

This option produces an error: "Internal data stream error". This seems very strange to me. In my opinion this is the same as in 1)


3) Finally, the task itself:
vc = new VideoComponent (shell, 0);
Bin bin = Pipeline.launch ("udpsrc port = 3000 buffer-size = 5000000! tsdemux!" +
                "h264parse! avdec_h264");

      
        pipe1.addMany (bin, vc.getElement ());
        bin.link (vc.getElement ());
        shell.open ();
        pipe1.play ();

The same error: Internal data stream error

Could you explain:
how 1) differs from 2) ?

how more in detail i can understand the error "Internal data stream error" ?

 and how get the video using the udp protocol and display it in the SWT window?

Thank you!

Neil C Smith

unread,
Jul 23, 2018, 10:56:51 AM7/23/18
to gstream...@googlegroups.com
Hi,

On Mon, 23 Jul 2018 at 15:39, Сережа Сандалов <sandalo...@gmail.com> wrote:
...
> 1) Output via autovideosink
> Bin bin1 = Pipeline.launch ("udpsrc port = 3000 buffer-size = 5000000! tsdemux!" +
> "h264parse! avdec_h264! autovideosink");
> pipe1.addMany (bin1);
> pipe1.play (); <- it works well

... note that this also seems incorrect - Pipeline.launch() returns a
top-level Pipeline, not just a Bin. You should probably be assigning
it directly to pipe1.

> 2) The same, only in more detail
> Element udpsrc = ElementFactory.make ("udpsrc", "source");
> udpsrc.set ("port", 3000);
> udpsrc.set ("buffer-size", 5000000);
> Element tsdemuxer = ElementFactory.make ("tsdemux", "demuxer");
> Element parse = ElementFactory.make ("h264parse", "parser");
> Element dec = ElementFactory.make ("avdec_h264", "decoder");
> Element sink = ElementFactory.make ("autovideosink", "videosink");
> pipe1.addMany (udpsrc, tsdemuxer, parse, dec, sink);
> udpsrc.link (tsdemuxer);
> tsdemuxer.link (parse);
> parse.link (dec);
> dec.link (sink);
> pipe1.play ();
>
> This option produces an error: "Internal data stream error". This seems very strange to me. In my opinion this is the same as in 1)

No, it isn't!

You need to get your head around the idea of Sometimes (dynamic) pads
in GStreamer. See
https://gstreamer.freedesktop.org/documentation/application-development/basics/pads.html#dynamic-or-sometimes-pads

The various parse launch functions automatically handle connecting
elements for you. Note that eg. tsdemux has a sometimes pad - see the
output of gst-inspect-1.0 tsdemux

This element cannot be connected until the pad is created, after the
pipe starts playing. You have to add a pad-added callback function in
which you connect the element downstream. You can see an example of
doing this on the Java side at
https://github.com/gstreamer-java/gst1-java-examples/blob/master/src/main/java/org/freedesktop/gstreamer/examples/AppSrcToAppSinkExample.java#L174

Best wishes,

Neil

--
Neil C Smith
Artist & Technologist
www.neilcsmith.net

Praxis LIVE - hybrid visual IDE for creative coding - www.praxislive.org
Reply all
Reply to author
Forward
0 new messages