pedroSG94 / RootEncoder

RootEncoder for Android (rtmp-rtsp-stream-client-java) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP, SRT and UDP with all code written in Java/Kotlin
Apache License 2.0
2.57k stars 777 forks source link

RtmpClient endpoint parser #1652

Open alexsafe opened 5 hours ago

alexsafe commented 5 hours ago

Hi,

My stream endpoint looks like this "rtmp://rtmp-auto.millicast.com:[port]/v2/pub/[stream_name]?[token]" . The main issue is with the refactored RtmpClient. Before 2.5.1 it was using a regex and it was parsing correctly. After 2.5.2 , it parses appName as "v2" , where it should be "v2/pub" and the connection is not established. I made my own RtmpClient to solve this, but maybe there is a better way?

pedroSG94 commented 4 hours ago

Hello,

Are you using the library version 2.5.4? I tested the endpoint like this:

rtmp://rtmp-auto.millicast.com:1935/v2/pub/streamName?token

And it is working as expected.

You can add a test here: https://github.com/pedroSG94/RootEncoder/blob/master/common/src/test/java/com/pedro/common/UrlParserTest.kt#L88

Like this:

      val url7 = "rtmp://rtmp-auto.millicast.com:1935/v2/pub/streamName?token"
      val urlParser7 = UrlParser.parse(url7, arrayOf("rtmp"))
      assertEquals("rtmp", urlParser7.scheme)
      assertEquals("rtmp-auto.millicast.com", urlParser7.host)
      assertEquals(1935, urlParser7.port)
      assertEquals("v2/pub", urlParser7.getAppName())
      assertEquals("streamName?token", urlParser7.getStreamName())
      assertEquals("rtmp://rtmp-auto.millicast.com:1935/v2/pub", urlParser7.getTcUrl())

And all is working fine