19

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.

4
  • Why don't you use Google's ExoPlayer instead?
    – Pnemonic
    Feb 22, 2018 at 13:18
  • Doesn't help using ExoPlayer. Mar 12, 2018 at 4:44
  • have you used vlc media player ?
    – Hardy
    Apr 3, 2018 at 6:34
  • I am not sure if VLC has a player library for Android. Apr 3, 2018 at 9:03

2 Answers 2

1

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);
0

This is an old question, and it is a little unclear to me, so I will state some assumptions.

I think you are (were) writing a client (since you tagged Android) in native code (nativeSetPipeline) with C/C++.

Working with Native code can be a PITA, but if my assumptions are correct, you may use the Poco Project libraries to redirect the output of the HTTPS connection to your RTSP player. You need to establish the HTTPS connection and direct the output stream to your GStreamer library.

https://pocoproject.org/docs/Poco.Net.HTTPSClientSession.html

I'm assuming you can make a std::ostream compatible with a GStreamer stream...

// ...
HTTPResponse response;
std::istream& inputStream = session.receiveResponse(response);
StreamCopier::copyStream(inputStream, gstream);
// ...

You may want to use GStreamer with C++ as well. Here's an option (haven't used/tested this):

https://wiki.gnome.org/Projects/gstreamermm

2
  • Hi @Zahnon, Thank you for the reply, I wrote my own code to establish an HTTPS connection with the server and after I tried writing the buffer stream to a local port and tried reading that buffer stream using GStreamer but it always gives me an error PortUnreachable. I am assuming this would lead to the same issue. Aug 27, 2018 at 4:45
  • I would try using Poco too and get back to you. Aug 27, 2018 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.