Search code examples
gstreamerrtsprtp

Gstreamer, rtspsrc and payload type


I'm having difficulties in retrieving rtsp stream from a specific camera, because the rtp payload type the camera is providing is 35 (unassigned) and payload types accepted by the rtph264depay plugin are in range [96-127]. The result is that gstreamer displays ann error like:

<udpsrc0> error: Internal data flow error.
<udpsrc0> error: streaming task paused, reason not-linked (-1)

Other cameras that I have tested are working because they define a good payload type.

FFmpeg, MPlayer and other tools play the stream, although they may display a warning for the unknown type, for instance in Mplayer:

rtsp_session: unsupported RTSP server. Server type is 'unknown'

Is there any way in gstreamer to fake the payload type, ignore the mismatching property, force linking between the plugins or otherwise create a workaroud to my problem?

Pipeline I am using is:

gst-launcg-0.10 rtspsrc location="..." ! rtph264depay ! capsfilter caps="video/x-h264,width=1920,height=1080,framerate=(fraction)25/1" ! h264parse ! matroskamux ! filesink location="test.mkv"

Solution

  • I figured it out and got it working. Posting an answer here in hope that it might benefit someone. There are multiple similar questions out there, but they lack proper answers.

    Following does the trick:

    GstElement* depay = gst_element_factory_make("rtph264depay", "video_demux");
    assert(depay);
    GstPad* depay_sink = gst_element_get_static_pad(depay, "sink");
    GstCaps* depay_sink_caps = gst_caps_new_simple("application/x-rtp",
            "media", G_TYPE_STRING, "video",
            "encoding-name", G_TYPE_STRING, "H264",
            NULL);
    gst_pad_use_fixed_caps(depay_sink);
    gst_pad_set_caps(depay_sink, depay_sink_caps);
    gst_object_unref(depay_sink);
    

    it overrides the rtph264depay plugin's sink pad caps to be less restrictive, now it accepts any payload type (and any clock-rate) as long as it is rtp and has H.264 encoding.

    I don't think this is possible with gst-launch.