Skip to content

RTSP: app crash because of duplicated header from ip-camera #9014

@artroman

Description

@artroman

There is non-catchable app chash when opening RTSP link from ip camera because of duplicated RTSP key "framerate".

java.lang.IllegalArgumentException: Multiple entries with same key: framerate=25 and framerate=0S
  at com.google.common.collect.RegularImmutableMap.createHashTable(RegularImmutableMap.java:104)
  at com.google.common.collect.RegularImmutableMap.create(RegularImmutableMap.java:74)
  at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:339)
  at com.google.android.exoplayer2.source.rtsp.MediaDescription$Builder.build(MediaDescription.java:198)
  at com.google.android.exoplayer2.source.rtsp.SessionDescriptionParser.addMediaDescriptionToSession(SessionDescriptionParser.java:201)
  at com.google.android.exoplayer2.source.rtsp.SessionDescriptionParser.parse(SessionDescriptionParser.java:186)
  at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onRtspMessageReceived(RtspClient.java:384)
  at com.google.android.exoplayer2.source.rtsp.RtspMessageChannel$Receiver.lambda$handleRtspMessage$0$RtspMessageChannel$Receiver(RtspMessageChannel.java:291)
  at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspMessageChannel$Receiver$HitD0FATwe-gLFkoSjlAUnzETfA.run(-.java:-1:-1)
  at android.os.Handler.handleCallback(Handler.java:755)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:154)
  at android.os.HandlerThread.run(HandlerThread.java:61)

Corresponding RTSP response is:

RTSP/1.0 200 OK
Content-Type: application/sdp
Server: H264DVR 1.0
Cseq: 1
Content-Base: rtsp://192.168.1.11:554/user=admin&password=&channel=1&stream=0.sdp/
Cache-Control: private
x-Accept-Retransmit: our-retransmit
x-Accept-Dynamic-Rate: 1
Content-Length: 412

v=0
o=- 38990265062388 38990265062388 IN IP4 192.168.1.11
s=RTSP Session
c=IN IP4 192.168.1.11
t=0 0
a=control:*
a=range:npt=0-
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000 
a=range:npt=0-
a=framerate:0S
a=fmtp:96 profile-level-id=4d0029; packetization-mode=1; sprop-parameter-sets=J00AKY1uBQBboQAAAwABAAADADKE,KO4Fcg==
a=framerate:25
a=control:trackID=3
m=audio 0 RTP/AVP 8
a=control:trackID=4

Player initialization:

val streamUrl = "rtsp://192.168.1.11:554/user=admin&password=&channel=1&stream=0.sdp"
val mediaSource = RtspMediaSource.Factory().createMediaSource(MediaItem.fromUri(streamUrl))

val player = SimpleExoPlayer.Builder(context).build()
player.repeatMode = Player.REPEAT_MODE_OFF
player.setVideoTextureView(ipcamVideoView)
player.setMediaSource(mediaSource)
player.prepare()
player.play()

Stream URL is not public available. I can do nothing with the camera, I couldn't find option to remove duplicated header.
Is there any way to filter RTSP headers before creating MediaDescription? Maybe any other suggestions to avoid crash?

One of ExoPlayer forks with RTSP support works quite good with this stream.

  • ExoPlayer 2.14.0
  • Android 7.1.2
  • TinkerBoard S

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions