tinyzimmer / go-gst

Gstreamer bindings and utilities for golang
GNU Lesser General Public License v2.1
130 stars 37 forks source link

Support to rtspsrc protocols #39

Open yengliong93 opened 2 years ago

yengliong93 commented 2 years ago

Hi, I have created a new element for rtspsrc and set the protocols to tcp. From the rtsp server logs, it is still using UDP protocol to fetch the video stream. Is the rtspsrc element supported? How can we set its protocols?

Codes:

    src, err := gst.NewElement("rtspsrc")
    if err != nil {
            return nil, err
    }
    src.Set("protocols", "tcp")

RTSP logs:

rtsp-simple-server_1 | 2022/06/10 06:35:35 INF [RTSP] [session 896969789] is reading from path 'final_new.h264', 1 track with UDP rtsp-simple-server_1 | 2022/06/10 06:35:43 INF [RTSP] [session 896969789] destroyed (teared down by 10.72.4.66:47506) rtsp-simple-server_1 | 2022/06/10 06:35:43 INF [RTSP] [conn 10.72.4.66:47506] closed (EOF)

brucekim commented 2 years ago

Hi

go-gst is a binding for gstramer in go language in which all gstramer functionalities are supported.

How does your rtsp configure with? Does it correctly set up to use tcp? ''' protocols “protocols” GstRTSPLowerTrans * Allowed lower transport protocols

Flags : Read / Write

Default value : tcp+udp-mcast+udp '''

yengliong93 commented 2 years ago

Hi, Yes, the rtsp server is supported tcp protocol. I run the gst-launch command. The command is reading the stream with TCP protocols.

gst-launch command: gst-launch-1.0 -e rtspsrc protocols=tcp location=rtsp://10.72.4.66:8554/final_new.h264 ! fakesink async=false

RTSP logs:

rtsp-simple-server_1 | 2022/06/13 00:34:07 INF [RTSP] [conn 10.72.4.66:47512] opened rtsp-simple-server_1 | 2022/06/13 00:34:07 INF [RTSP] [session 111889720] created by 10.72.4.66:47512 rtsp-simple-server_1 | 2022/06/13 00:34:08 INF [RTSP] [session 111889720] is reading from path 'final_new.h264', 1 track with TCP

In my code, I am able to set location of rtspsrc. It can connect to my rtsp server and the filename is correct. However, the set to protocols doesn't take effect.

brucekim commented 2 years ago

First of all, check the return value from Set("protocols", "tcp") in order to verify whether there is no error.

Second as alternative way, try to use SetArg() instead of Set()

yengliong93 commented 2 years ago

Thanks, the SetArg() works. The next step is I am trying to link both rtspsrc and fakesink. An error happened when I use ElementLinkMany to link them.

Error:

Error Happen: Failed to link rtspsrc0 to fakesink0

My codes:

    fakesink, err := gst.NewElement("fakesink")
    if err != nil {
            return nil, err
    }
    fakesink.SetArg("async", "false")
    anyerror := pipeline.AddMany(src, fakesink)
    if anyerror != nil {
            fmt.Println("Error Happen: ", anyerror)
    }
    anyerror = gst.ElementLinkMany(src, fakesink)
    if anyerror != nil {
            fmt.Println("Error Happen: ", anyerror)
    }

Any idea?

brucekim commented 2 years ago

Strange, Does the rtspsrc successfully be created?

I suggest you to debug logs with enable DEBUG level into gstreamer.

yengliong93 commented 2 years ago

I figure it out by connecting the rtspsrc's pad-added signal. The issue has been discussed in https://stackoverflow.com/questions/32233370/gstreamer-1-0-rtspsrc-to-rtph264depay-cannot-link

Thanks for all the advices.