Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RTSP over HTTPS video streaming by GStreamer

I have a stream which is RTSP over HTTPS.

The handshake is secure (Over https) but the data after the handshake is complete is not encrypted (in RTSP).

GStreamer by default does not stream as it expects the data to be encrypted as well (in RTSPS), which is not in my case.

I have tried multiple things but nothing seems to work. e.g. after I start getting the stream I tried to write it to a local port and passed that URL to GStreamer but it doesn't play.

I am a new to this GStreamer so my knowledge regarding the player is limited. I am looking for a way to complete the handshake via GStreamer which is HTTPS(secure) and then the stream that I get is not encrypted. If someone has worked on something similar, kindly let me know any way to stream RTSP. I have tried something like

nativeSetPipeline("rtspsrc location=rtsph://<URL of the video stream> latency=100 ! rtph264depay ! avdec_h264 ! glimagesink");

The above pipeline works as by default GStreamer plays RTSP over HTTP but when I try RTSP over HTTPS something like

nativeSetPipeline("rtspsrc debug = TRUE do-rtcp=false location=\"rtspsh://<secured URL of the stream>" latency=100 do-rtsp-keep-alive=true ! rtph264depay ! avdec_h264 ! glimagesink");

this doesn't work as GStreamer expects the stream to be secured also. Any idea/code snippet or example on how to stream RTSP over HTTPS? The current version I am using is 1.10.4.

like image 635
PunK _l_ RuLz Avatar asked Aug 15 '17 09:08

PunK _l_ RuLz


People also ask

Does GStreamer support rtsp?

GStreamer - ZED RTSP Server ZED RTSP Server is a GStreamer application for Linux operating system that allows to instantiate an RTSP server from a text launch pipeline using the “gst-launch” style.

How do I stream rtsp over HTTP?

Enable the "Tunnel RTP and RTSP over HTTP" option and set the appropriate port used for the RTSP stream (PORT). After that, when using VLC as a client the streaming will be requested to be HTTP tunneled.

What is the difference between rtsp and RTP?

RTSP and RTP are often used interchangeably. But to be clear: RTSP is a presentation-layer protocol that lets end users command media servers via pause and play capabilities, whereas RTP is the transport protocol used to move said data.


1 Answers

As I could not find any way to get the GStreamer do all the work internally. I wrote a middle layer. Which acts as an interface between my server and GStreamer. I opened two socket connections. One Between my middle layer and server and another between GStreamer and my middle layer. The socket between my middle layer and GStreamer is a localhost.

            channel = ServerSocketChannel.open();
            channel.configureBlocking(false);

            InetAddress ih = InetAddress.getLocalHost();
            InetSocketAddress isa = new InetSocketAddress(inetAddress, inetPort);
            channel.socket().bind(isa);

For the communication between my middle layer and server. I have an SSL connection with something like.

            SocketFactory socketFactory = SSLSocketFactory.getDefault();
            socket = socketFactory.createSocket(serverAddress, serverPort);

            if (null == dataInputStream) {
                dataInputStream = new DataInputStream(socket.getInputStream());
            }

            if (null == inputStreamReader) {
                inputStreamReader = new InputStreamReader((socket.getInputStream()));
            }

I have two interfaces defined which transfers the data/messages. So basically I let the SSL Socket do the handshake for me with the server. I pass the data/messages that I get from the server using an interface to my middle layer and then write to GStreamer. Similarly whatever data/messages I get from the GStreamer using an interface I pass it on to my middle layer and then write it to the server. The pipeline I use for GStreamer is.

pipelineURL = String.format("playbin uri=\"%s\" ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! xvimagesink", url);
like image 148
PunK _l_ RuLz Avatar answered Oct 04 '22 00:10

PunK _l_ RuLz