androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.59k stars 377 forks source link

Rtsp stream and video #766

Open nguyenhoang9497 opened 11 months ago

nguyenhoang9497 commented 11 months ago

I am working on media3 exoplayer to play video streaming and play record video. Both feature play from rtsp url and I am having 2 issues:

I'm using this code

 when (item) {
                    is CamerasAdapter.CameraItem -> {
                        mediaItem = MediaItem.fromUri(item.cameraUrl)
                        val rtspMediaSource = RtspMediaSource.Factory().setForceUseRtpTcp(true).createMediaSource(mediaItem)
                        exoPlayer?.addMediaSource(rtspMediaSource)
                    }
                    is EventsAdapter.Event -> {
                        mediaItem = MediaItem.fromUri(item.eventStreamUrl)
                        val rtspMediaSource = RtspMediaSource.Factory().createMediaSource(mediaItem)
                        exoPlayer?.addMediaSource(rtspMediaSource)
                    }
                }

Log from RtspClient

2023-10-22 07:14:26.099 21213-21213 WILD:: com.example.exoplayercodelab D onCreate 2023-10-22 07:14:26.814 21213-21213 WILD:: com.example.exoplayercodelab D onStart 2023-10-22 07:14:27.186 21213-21213 WILD:: com.example.exoplayercodelab D onResume 2023-10-22 07:14:27.191 21213-21213 WILD:: com.example.exoplayercodelab D onResume, init player 2023-10-22 07:14:27.401 21213-21290 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 0, Public: OPTIONS,DESCRIBE,SETUP,PLAY,PAUSE,TEARDOWN,ANNOUNCE,SET_PARAMETER,GET_PARAMETER, ] 2023-10-22 07:14:27.503 21213-21290 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 401 ClientUnAuthorized, CSeq: 1, WWW-Authenticate: Digest realm="e4f14c5afab9",nonce="aef38450f1a0d2f850cc03f1c8c5d10b", stale="FALSE", ] 2023-10-22 07:14:27.507 21213-21287 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 0, Public: OPTIONS,DESCRIBE,SETUP,PLAY,PAUSE,TEARDOWN,ANNOUNCE,SET_PARAMETER,GET_PARAMETER, ] 2023-10-22 07:14:27.628 21213-21287 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 401 ClientUnAuthorized, CSeq: 1, WWW-Authenticate: Digest realm="e4f14c5afab9",nonce="9f2ca0a804cf092a68786fe92c0b5695", stale="FALSE", ] 2023-10-22 07:14:27.705 21213-21290 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 2, Content-Base: rtsp://192.168.8.33/media/video1, Content-Length: 508, Content-Type: application/sdp, , v=0 o=- 1001 1 IN IP4 192.168.8.33 s=VCP IPC Realtime stream m=video 0 RTP/AVP 105 c=IN IP4 192.168.8.33 a=control:rtsp://192.168.8.33/media/video1/video a=rtpmap:105 H264/90000 a=fmtp:105 profile-level-id=64001f; packetization-mode=1; sprop-parameter-sets=Z2QAH6w7UCgC3QgAAB9AAAOphCA=,aOqPLA== a=recvonly m=application 0 RTP/AVP 107 c=IN IP4 192.168.8.33 a=control:rtsp://192.168.8.33/media/video1/metadata a=rtpmap:107 vnd.onvif.metadata/90000 a=fmtp:107 DecoderTag=h3c-v3 RTCP=0 a=recvonly] 2023-10-22 07:14:28.099 21213-21287 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 2, Content-Base: rtsp://192.168.8.33/media/video1, Content-Length: 508, Content-Type: application/sdp, , v=0 o=- 1001 1 IN IP4 192.168.8.33 s=VCP IPC Realtime stream m=video 0 RTP/AVP 105 c=IN IP4 192.168.8.33 a=control:rtsp://192.168.8.33/media/video1/video a=rtpmap:105 H264/90000 a=fmtp:105 profile-level-id=64001f; packetization-mode=1; sprop-parameter-sets=Z2QAH6w7UCgC3QgAAB9AAAOphCA=,aOqPLA== a=recvonly m=application 0 RTP/AVP 107 c=IN IP4 192.168.8.33 a=control:rtsp://192.168.8.33/media/video1/metadata a=rtpmap:107 vnd.onvif.metadata/90000 a=fmtp:107 DecoderTag=h3c-v3 RTCP=0 a=recvonly] 2023-10-22 07:14:28.128 21213-21290 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 3, Transport: RTP/AVP/TCP;unicast;interleaved=0-1;ssrc=dd43b9;mode="PLAY", Session: 495859a4495859a4436859a4495859a;timeout=60, ] 2023-10-22 07:14:28.292 21213-21290 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 4, Range: npt=0Z-, Session: 495859a4495859a4436859a4495859a, ] 2023-10-22 07:14:28.616 21213-21287 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 3, Transport: RTP/AVP/TCP;unicast;interleaved=0-1;ssrc=dd43b9;mode="PLAY", Session: eb3a9336eb3a9336e10a9336eb3a933;timeout=60, ] 2023-10-22 07:14:28.720 21213-21287 WILD:: com.example.exoplayercodelab D handleRtspMessage [RTSP/1.0 200 OK, CSeq: 4, Range: npt=0Z-, Session: eb3a9336eb3a9336e10a9336eb3a933, ]

microkatz commented 11 months ago

Hi @nguyenhoang9497

Thank you for reporting your issue. The logs you provided only shows the RTSP responses from the protocol setup. Would you be able to provide a full bug report to help us debug? Seems like you have two different scenarios so make sure to tell us the exact scenario you ran when collecting the trace. If you're unable to share bug reports publicly, please send them to android-media-github@google.com with the subject Issue #766. Please also update this issue to indicate you've done this.