KARL
KARL

Reputation: 53

RTSP Stream works but RTSPS Stream doesnt?

I am streaming RTSP in SwiftUI Using VLCMediaPlayer

Here is my code for the player:

import Foundation
import MobileVLCKit
import SwiftUI

struct VlcPlayerRepresentable: UIViewRepresentable{ //MARK: Transform from a UIView into swiftUI compatible
func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<VlcPlayerRepresentable>) {
}

func makeUIView(context: Context) -> UIView {
    return PlayerUIView(frame: .zero)
}}

class PlayerUIView: UIView, VLCMediaPlayerDelegate,ObservableObject{
let mediaPlayer : VLCMediaPlayer = VLCMediaPlayer()// You can also add options in here
override init(frame: CGRect) {
    super.init(frame: UIScreen.screens[0].bounds)
    let url = URL(string: "rtsps://stream-eu1-bravo.dropcam.com:443/sdm_live_stream/")!//replace your resource here

    let media = VLCMedia(url: url)

    media.addOptions([// Add options here
        "network-caching": 300,
        "--rtsp-frame-buffer-size":100,
        "--vout": "ios",
        "--glconv" : "glconv_cvpx",
        "--rtsp-caching=": 150,
        "--tcp-caching=": 150,
        "--realrtsp-caching=": 150,
        "--h264-fps": 20.0,
        "--mms-timeout": 60000
    ])

    mediaPlayer.media = media
    mediaPlayer.delegate = self
    mediaPlayer.drawable = self
    mediaPlayer.audio.isMuted = true

    mediaPlayer.videoAspectRatio = UnsafeMutablePointer<Int8>(mutating: ("16:9" as NSString).utf8String)
    mediaPlayer.play()}
    
    func checkConnection() -> Bool{
        let isPlaying: Bool = mediaPlayer.isPlaying
        return isPlaying
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

struct StreamsTab: View {
var body: some View {
    return VStack{
        Text("stream")
        VlcPlayerRepresentable()
    }
}}

Which works fine with the following URL: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4

However when using the URL Generated from Google API GenerateRTSPStream (https://developers.google.com/nest/device-access/use-the-api#camera) which looks something like: "rtsps://someurl.com/CjY5Y3VKaTZwR3o4Y19YbTVfMF...?auth=g.0.streamingToken" full response from api call:

{
  "results" : {
    "streamUrls" : {
      "rtspUrl" : "rtsps://someurl.com/CjY5Y3VKaTZwR3o4Y19YbTVfMF...?auth=g.0.streamingToken"
    },
    "streamExtensionToken" : "CjY5Y3VKaTZwR3o4Y19YbTVfMF...",
    "streamToken" : "g.0.streamingToken",
    "expiresAt" : "2018-01-04T18:30:00.000Z"
  }
}

The stream doesn't load. Is the Issue the fact that it uses RTSPS? If so, how do I adjust my code to stream RTSPS? If that's not the issue what is? Quite stuck here.

EDIT: It seems that VLCMediaPlayer doesn't support RTSPS, How can I stream RTSPS in iOS?

Upvotes: 2

Views: 2438

Answers (1)

Ethan
Ethan

Reputation: 136

There aren't a lot of RTSPS players out there, ffplay in ffmpeg should handle it.

Upvotes: 0

Related Questions