Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid RTSP session header parser #9254

Closed
BaranovVO opened this issue Aug 4, 2021 · 4 comments
Closed

Invalid RTSP session header parser #9254

BaranovVO opened this issue Aug 4, 2021 · 4 comments
Assignees
Labels

Comments

@BaranovVO
Copy link

BaranovVO commented Aug 4, 2021

The lib version is 2.14.2.

The player can't parse a RTSP session header.

It looks like the regex SESSION_HEADER_PATTERN needs to be changed.

override fun onResume() {
    super.onResume()
    exoPlayerView.apply {
        val trackSelectionFactory = AdaptiveTrackSelection.Factory()
        val trackSelector = DefaultTrackSelector(context, trackSelectionFactory)
        val player = SimpleExoPlayer.Builder(context)
            .setTrackSelector(trackSelector)
            .build()
        this.player = player
        player.addAnalyticsListener(EventLogger(trackSelector))
        player.playWhenReady = true
        useController = false
        setKeepContentOnPlayerReset(true)
        viewModel.intercom.value?.let {
            player.setMediaItem(MediaItem.fromUri(it.videoStreamUrl))
            player.prepare()
        }
    }
}
E/EventLogger: playerFailed [eventTime=0.54, mediaPos=0.00, window=0, period=0
      com.google.android.exoplayer2.ExoPlaybackException: Source error
        at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:580)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:236)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: com.google.android.exoplayer2.source.rtsp.RtspMediaSource$RtspPlaybackException: com.google.android.exoplayer2.ParserException: 610a47a6-d902-48b2-9efb-bdd9b2ca2cfb
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:523)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$RtspClient$MessageListener(RtspClient.java:420)
        at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspClient$MessageListener$dJPB0r-FyeWq7xUwLx0FyxTnUk0.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:236) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
     Caused by: com.google.android.exoplayer2.ParserException: 610a47a6-d902-48b2-9efb-bdd9b2ca2cfb
        at com.google.android.exoplayer2.source.rtsp.RtspMessageUtil.parseSessionHeader(RtspMessageUtil.java:389)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:486)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$RtspClient$MessageListener(RtspClient.java:420) 
        at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspClient$MessageListener$dJPB0r-FyeWq7xUwLx0FyxTnUk0.run(Unknown Source:4) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:236) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
    ]
@claincly
Copy link
Contributor

claincly commented Aug 4, 2021

It's likely the server is not following the RTSP spce, to diagnose, please provide a log of RTSP messages.

Add logs at

and

private void handleRtspMessage(List<String> message) {

The easiest way is to use

Log.d("RTSP", message)

@BaranovVO
Copy link
Author

2021-08-04 14:54:39.598  D/RTSP: OPTIONS rtsp://hidden.url RTSP/1.0
    cseq: 0
    user-agent: ExoPlayerLib/2.14.2
2021-08-04 14:54:39.671  D/RTSP: RTSP/1.0 200 OK
    Server: Streamer 21.07.2
    Cache-Control: no-cache
    Cseq: 0
    Supported: play.basic, con.persistent
    Date: Wed, 04 Aug 2021 09:54:39 GMT
    Public: SETUP, TEARDOWN, ANNOUNCE, RECORD, PLAY, PAUSE, OPTIONS, DESCRIBE, GET_PARAMETER
2021-08-04 14:54:39.673  D/RTSP: DESCRIBE rtsp://hidden.url RTSP/1.0
    cseq: 1
    user-agent: ExoPlayerLib/2.14.2
2021-08-04 14:54:39.741  D/RTSP: RTSP/1.0 200 OK
    Server: Streamer 21.07.2
    Cache-Control: no-cache
    Content-Base: rtsp://hidden.url/
    Content-Length: 722
    Content-Type: application/sdp
    Cseq: 1
    Date: Wed, 04 Aug 2021 09:54:39 GMT
    Expires: Wed, 04 Aug 2021 09:54:39 GMT
    Session: 610a63df-9b57-4856-97ac-665f356e9c04
    
    v=0
    o=- 1628070879924625 1628070879924625 IN IP4 127.0.0.1
    s=Streamer 21.07.2
    c=IN IP4 0.0.0.0
    t=0 0
    a=control:*
    a=tool:Streamer 21.07.2
    a=x-qt-text-nam:Streamer 21.07.2
    a=x-qt-text-inf:h264
    a=type:broadcast
    a=range:npt=now-
    m=video 0 RTP/AVP 96
    a=control:trackID=1
    a=rtpmap:96 H264/90000
    a=cliprect:0,0,1280,720
    a=framesize:96 1280-720
    a=x-dimensions:1280,720
    a=framerate:25.0
    a=fmtp:96 packetization-mode=1;profile-level-id=4DE01F;sprop-parameter-sets=Z01AH5WgFAFumwE=,aO48gA==
    b=AS:1003
    m=audio 0 RTP/AVP 97
    a=control:trackID=2
    a=rtpmap:97 mpeg4-generic/8000/1
    a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=158856E500
    i=Transcoded_aac
    b=AS:82
2021-08-04 14:54:39.828  D/RTSP: SETUP rtsp://hidden.url/trackID=1 RTSP/1.0
    cseq: 2
    user-agent: ExoPlayerLib/2.14.2
    transport: RTP/AVP;unicast;client_port=46900-46901
2021-08-04 14:54:39.906  D/RTSP: RTSP/1.0 200 OK
    Server: Streamer 21.07.2
    Cache-Control: no-cache
    Session: 610a63df-9b57-4856-97ac-665f356e9c04
    Cseq: 2
    Date: Wed, 04 Aug 2021 09:54:39 GMT
    Expires: Wed, 04 Aug 2021 09:54:39 GMT
    Transport: RTP/AVP;unicast;client_port=46900-46901;source=217.64.140.8;server_port=18244-18245

@claincly
Copy link
Contributor

claincly commented Aug 4, 2021

Will be fixed soon

christosts pushed a commit that referenced this issue Aug 5, 2021
Issue: #9254

#minor-release

We used to allow only alphanumerical characters in session id. The spec also
allows "$", "-", "_", ".", "+" (RFC2326 Sections 3.4 and 15.1).

PiperOrigin-RevId: 388873742
@claincly claincly closed this as completed Aug 6, 2021
christosts pushed a commit that referenced this issue Aug 11, 2021
Issue: #9254

#minor-release

We used to allow only alphanumerical characters in session id. The spec also
allows "$", "-", "_", ".", "+" (RFC2326 Sections 3.4 and 15.1).

PiperOrigin-RevId: 388873742
@ekindino
Copy link

ekindino commented Sep 6, 2021

I think the original regex was supposed to parse the ";timeout=X" part at the end which some devices use. The current regex returns the timeout parameter as a part of the session id causing a mismatch and the timeout parameter is not parsed at all.

As an example "parseSessionHeader" function with the "headerValue" "45266830;timeout=5" returns "sessionId" as "45266830;timeout=5" where it should be "45266830" and returns the default timeout.

@google google locked and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants