alexeyvasilyev / rtsp-client-android

Lightweight low-latency RTSP client library for Android
Apache License 2.0
232 stars 62 forks source link

issue when MediaCodec decodes an existing surface #14

Closed OctavianIonel closed 2 years ago

OctavianIonel commented 2 years ago

Hi, I am using a TextureView component in the layout. I have an issue when putting the app to background and resuming it quite fastly: The issue is in VideoDecodeThread at line:

    decoder.configure(format, surface, null, 0)
E/BufferQueueProducer: [SurfaceTexture-0-7454-0] connect: already connected (cur=3 req=3)
E/SurfaceUtils: Failed to connect to surface 0xc3917008, err -22
E/MediaCodec: nativeWindowConnect returned an error: Invalid argument (-22)
E/MediaCodec: configure failed with err 0xffffffea, resetting...

Fatal Exception: java.lang.IllegalArgumentException
at android.media.MediaCodec.native_configure(MediaCodec.java)
at android.media.MediaCodec.configure(MediaCodec.java:2023)
at android.media.MediaCodec.configure(MediaCodec.java:1951)
at VideoDecodeThread.run(VideoDecodeThread.kt:29)

Any help is appreciated, thanks!

alexeyvasilyev commented 2 years ago

What Android device do you have? Does it happen on emulator as well? Do you have the same problem on demo app with SurfaceView?

OctavianIonel commented 2 years ago

Hi @alexeyvasilyev, in order to reproduce you can click on the overview hard button (not the back, not the home, the other one) of the samsung tablet for instance.

freespirit83xyz commented 2 years ago

Hello, I have similar issue but in a different context. I'm using your great lib on a Raspberry Pi 4 and Android 11. Your demo app works great so I decided to use it inside my project. Something is not going well. There is something wrong with color format Here the entire log

2021-11-19 08:39:23.312 3490-3490/com.motuslab.scoreboardapp D/ScoreboardApp: onRtspClientStarted 2021-11-19 08:39:23.389 3490-3562/com.motuslab.scoreboardapp D/ScoreboardApp: onRtspConnecting 2021-11-19 08:39:23.390 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: OPTIONS rtsp://192.168.1.200:1935/ RTSP/1.0 2021-11-19 08:39:23.390 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: CSeq: 1 2021-11-19 08:39:23.390 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: User-Agent: ScoreboardApp agent 2021-11-19 08:39:23.398 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: 200 OK 2021-11-19 08:39:23.398 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Status code: 200 2021-11-19 08:39:23.400 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Server: pedroSG94 Server 2021-11-19 08:39:23.401 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cseq: 1 2021-11-19 08:39:23.403 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Public: DESCRIBE,SETUP,TEARDOWN,PLAY,PAUSE 2021-11-19 08:39:23.404 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: DESCRIBE rtsp://192.168.1.200:1935/ RTSP/1.0 2021-11-19 08:39:23.404 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: Accept: application/sdp 2021-11-19 08:39:23.404 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: CSeq: 2 2021-11-19 08:39:23.404 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: User-Agent: ScoreboardApp agent 2021-11-19 08:39:23.412 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: 200 OK 2021-11-19 08:39:23.413 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Status code: 200 2021-11-19 08:39:23.414 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Server: pedroSG94 Server 2021-11-19 08:39:23.415 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cseq: 2 2021-11-19 08:39:23.417 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Content-Length: 464 2021-11-19 08:39:23.420 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Content-Base: 192.168.1.200:1935/ 2021-11-19 08:39:23.422 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Content-Type: application/sdp 2021-11-19 08:39:23.423 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: v=0 o=- 0 0 IN IP4 192.168.1.200 s=Unnamed i=N/A c=IN IP4 192.168.1.141 t=0 0 a=recvonly m=video 0 RTP/AVP 96 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0LAH6tAKALdCAAAAwAIAAADAecCAAC7gAAAXcAWsbA8UKqA,KM48gA== a=control:streamid=0 m=audio 0 RTP/AVP 97 a=rtpmap:97 MPEG4-GENERIC/32000/2 a=fmtp:97 profile-level-id=1; mode=AAC-hbr; config=1290; sizelength=13; indexlength=3; indexdeltalength=3 a=control:streamid=1 2021-11-19 08:39:23.424 3490-3562/com.motuslab.scoreboardapp I/RtspClient: Video: H264 2021-11-19 08:39:23.425 3490-3562/com.motuslab.scoreboardapp I/RtspClient: Audio: AAC LC, sample rate: 32000 Hz, channels: 2 2021-11-19 08:39:23.426 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: SETUP rtsp://192.168.1.200:1935//streamid=0 RTSP/1.0 2021-11-19 08:39:23.426 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: Transport: RTP/AVP/TCP;unicast;interleaved=0-1 2021-11-19 08:39:23.426 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: CSeq: 3 2021-11-19 08:39:23.426 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: User-Agent: ScoreboardApp agent 2021-11-19 08:39:23.435 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: 200 OK 2021-11-19 08:39:23.435 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Status code: 200 2021-11-19 08:39:23.437 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Server: pedroSG94 Server 2021-11-19 08:39:23.438 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cseq: 3 2021-11-19 08:39:23.440 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Content-Length: 0 2021-11-19 08:39:23.445 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Transport: RTP/AVP/TCP;unicast;interleaved=0-1;mode=play 2021-11-19 08:39:23.447 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Session: 1185d20035702ca 2021-11-19 08:39:23.449 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cache-Control: no-cache 2021-11-19 08:39:23.449 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: SETUP rtsp://192.168.1.200:1935//streamid=1 RTSP/1.0 2021-11-19 08:39:23.449 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: Transport: RTP/AVP/TCP;unicast;interleaved=2-3 2021-11-19 08:39:23.449 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: CSeq: 4 2021-11-19 08:39:23.449 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: User-Agent: ScoreboardApp agent 2021-11-19 08:39:23.450 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: Session: 1185d20035702ca 2021-11-19 08:39:23.458 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: 200 OK 2021-11-19 08:39:23.459 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Status code: 200 2021-11-19 08:39:23.460 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Server: pedroSG94 Server 2021-11-19 08:39:23.461 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cseq: 4 2021-11-19 08:39:23.463 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Content-Length: 0 2021-11-19 08:39:23.467 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Transport: RTP/AVP/TCP;unicast;interleaved=2-3;mode=play 2021-11-19 08:39:23.469 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Session: 1185d20035702ca 2021-11-19 08:39:23.470 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cache-Control: no-cache 2021-11-19 08:39:23.471 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: PLAY rtsp://192.168.1.200:1935/ RTSP/1.0 2021-11-19 08:39:23.471 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: Range: npt=0.000- 2021-11-19 08:39:23.471 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: CSeq: 5 2021-11-19 08:39:23.471 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: User-Agent: ScoreboardApp agent 2021-11-19 08:39:23.471 3490-3562/com.motuslab.scoreboardapp I/RtspClient DBG: Session: 1185d20035702ca 2021-11-19 08:39:23.480 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: 200 OK 2021-11-19 08:39:23.480 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Status code: 200 2021-11-19 08:39:23.483 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Server: pedroSG94 Server 2021-11-19 08:39:23.484 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Cseq: 5 2021-11-19 08:39:23.485 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Content-Length: 0 2021-11-19 08:39:23.493 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: RTP-Info: url=rtsp://192.168.1.200:1935/streamid=0;seq=1;rtptime=0,url=rtsp://192.168.1.200:1935/streamid=1;seq=1;rtptime=0 2021-11-19 08:39:23.495 3490-3562/com.motuslab.scoreboardapp D/RtspClient DBG: Session: 1185d20035702ca 2021-11-19 08:39:23.495 3490-3562/com.motuslab.scoreboardapp D/ScoreboardApp: sps size 40 pps size 8 2021-11-19 08:39:23.495 3490-3562/com.motuslab.scoreboardapp D/ScoreboardApp: onRtspClientConnected videoMimeType video/avc surfaceWidth 1691 surfaceHeight 900 2021-11-19 08:39:23.497 3490-3563/com.motuslab.scoreboardapp D/VideoDecodeThread: VideoDecodeThread started 2021-11-19 08:39:23.501 3490-3565/com.motuslab.scoreboardapp D/CCodec: allocate(c2.android.avc.decoder) 2021-11-19 08:39:23.503 3490-3565/com.motuslab.scoreboardapp I/Codec2Client: Available Codec2 services: "software" 2021-11-19 08:39:23.510 3490-3565/com.motuslab.scoreboardapp I/CCodec: Created component [c2.android.avc.decoder] 2021-11-19 08:39:23.510 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: read media type: video/avc 2021-11-19 08:39:23.513 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.max-count.values 2021-11-19 08:39:23.514 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.subscribed-indices.values 2021-11-19 08:39:23.514 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: input.buffers.allocator-ids.values 2021-11-19 08:39:23.514 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.allocator-ids.values 2021-11-19 08:39:23.515 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.allocator-ids.values 2021-11-19 08:39:23.515 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.pool-ids.values 2021-11-19 08:39:23.515 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.pool-ids.values 2021-11-19 08:39:23.517 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: ignored struct field coded.color-format.locations 2021-11-19 08:39:23.518 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: ignoring local param raw.size (0xd2001800) as it is already supported 2021-11-19 08:39:23.518 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: ignoring local param raw.color (0xd2001809) as it is already supported 2021-11-19 08:39:23.518 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: ignored struct field raw.hdr-static-info.mastering 2021-11-19 08:39:23.519 3490-3565/com.motuslab.scoreboardapp I/CCodecConfig: query failed after returning 12 values (BAD_INDEX) 2021-11-19 08:39:23.519 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: c2 config diff is Dict { c2::u32 coded.pl.level = 20496 c2::u32 coded.pl.profile = 20481 c2::u32 coded.vui.color.matrix = 0 c2::u32 coded.vui.color.primaries = 0 c2::u32 coded.vui.color.range = 2 c2::u32 coded.vui.color.transfer = 0 c2::u32 default.color.matrix = 0 c2::u32 default.color.primaries = 0 c2::u32 default.color.range = 0 c2::u32 default.color.transfer = 0 c2::u32 input.buffers.max-size.value = 2097152 c2::u32 input.delay.value = 0 string input.media-type.value = "video/avc" c2::u32 output.delay.value = 8 string output.media-type.value = "video/raw" c2::u32 raw.color.matrix = 0 c2::u32 raw.color.primaries = 0 c2::u32 raw.color.range = 2 c2::u32 raw.color.transfer = 0 c2::u32 raw.max-size.height = 240 c2::u32 raw.max-size.width = 320 c2::u32 raw.pixel-format.value = 35 c2::i32 raw.rotation.flip = 0 c2::i32 raw.rotation.value = 0 c2::u32 raw.sar.height = 1 c2::u32 raw.sar.width = 1 c2::u32 raw.size.height = 240 c2::u32 raw.size.width = 320 c2: 2021-11-19 08:39:23.520 3490-3565/com.motuslab.scoreboardapp W/ColorUtils: expected specified color aspects (2:0:0:0) 2021-11-19 08:39:23.522 3490-3564/com.motuslab.scoreboardapp D/SurfaceUtils: connecting to surface 0x77d8dfcf10, reason connectToSurface 2021-11-19 08:39:23.523 3490-3564/com.motuslab.scoreboardapp I/MediaCodec: [c2.android.avc.decoder] setting surface generation to 3573761 2021-11-19 08:39:23.523 3490-3564/com.motuslab.scoreboardapp D/SurfaceUtils: disconnecting from surface 0x77d8dfcf10, reason connectToSurface(reconnect) 2021-11-19 08:39:23.523 3490-3564/com.motuslab.scoreboardapp D/SurfaceUtils: connecting to surface 0x77d8dfcf10, reason connectToSurface(reconnect) 2021-11-19 08:39:23.524 3490-3565/com.motuslab.scoreboardapp D/CCodec: [c2.android.avc.decoder] buffers are bound to CCodec for this session 2021-11-19 08:39:23.524 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: no c2 equivalents for native-window 2021-11-19 08:39:23.524 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: no c2 equivalents for flags 2021-11-19 08:39:23.525 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: config failed => CORRUPTED 2021-11-19 08:39:23.525 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: Bad parameter value 2021-11-19 08:39:23.526 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: c2 config diff is c2::u32 raw.size.height = 900 2021-11-19 08:39:23.526 3490-3565/com.motuslab.scoreboardapp W/CCodec: failed to configure c2 params 2021-11-19 08:39:23.526 3490-3564/com.motuslab.scoreboardapp E/MediaCodec: Codec reported err 0xffffffea, actionCode 0, while in state 3 2021-11-19 08:39:23.528 3490-3564/com.motuslab.scoreboardapp D/SurfaceUtils: disconnecting from surface 0x77d8dfcf10, reason disconnectFromSurface 2021-11-19 08:39:23.528 3490-3563/com.motuslab.scoreboardapp E/MediaCodec: configure failed with err 0xffffffea, resetting... 2021-11-19 08:39:23.529 3490-3565/com.motuslab.scoreboardapp I/hw-BpHwBinder: onLastStrongRef automatically unlinking death recipients 2021-11-19 08:39:23.533 3490-3565/com.motuslab.scoreboardapp D/CCodec: allocate(c2.android.avc.decoder) 2021-11-19 08:39:23.536 3490-3565/com.motuslab.scoreboardapp I/CCodec: Created component [c2.android.avc.decoder] 2021-11-19 08:39:23.537 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: read media type: video/avc 2021-11-19 08:39:23.540 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.max-count.values 2021-11-19 08:39:23.540 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.subscribed-indices.values 2021-11-19 08:39:23.540 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: input.buffers.allocator-ids.values 2021-11-19 08:39:23.540 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.allocator-ids.values 2021-11-19 08:39:23.541 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.allocator-ids.values 2021-11-19 08:39:23.541 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: output.buffers.pool-ids.values 2021-11-19 08:39:23.541 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: extent() != 1 for single value type: algo.buffers.pool-ids.values 2021-11-19 08:39:23.542 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: ignored struct field coded.color-format.locations 2021-11-19 08:39:23.543 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: ignoring local param raw.size (0xd2001800) as it is already supported 2021-11-19 08:39:23.543 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: ignoring local param raw.color (0xd2001809) as it is already supported 2021-11-19 08:39:23.543 3490-3565/com.motuslab.scoreboardapp D/ReflectedParamUpdater: ignored struct field raw.hdr-static-info.mastering 2021-11-19 08:39:23.544 3490-3565/com.motuslab.scoreboardapp I/CCodecConfig: query failed after returning 12 values (BAD_INDEX) 2021-11-19 08:39:23.544 3490-3565/com.motuslab.scoreboardapp D/CCodecConfig: c2 config diff is Dict { c2::u32 coded.pl.level = 20496 c2::u32 coded.pl.profile = 20481 c2::u32 coded.vui.color.matrix = 0 c2::u32 coded.vui.color.primaries = 0 c2::u32 coded.vui.color.range = 2 c2::u32 coded.vui.color.transfer = 0 c2::u32 default.color.matrix = 0 c2::u32 default.color.primaries = 0 c2::u32 default.color.range = 0 c2::u32 default.color.transfer = 0 c2::u32 input.buffers.max-size.value = 2097152 c2::u32 input.delay.value = 0 string input.media-type.value = "video/avc" c2::u32 output.delay.value = 8 string output.media-type.value = "video/raw" c2::u32 raw.color.matrix = 0 c2::u32 raw.color.primaries = 0 c2::u32 raw.color.range = 2 c2::u32 raw.color.transfer = 0 c2::u32 raw.max-size.height = 240 c2::u32 raw.max-size.width = 320 c2::u32 raw.pixel-format.value = 35 c2::i32 raw.rotation.flip = 0 c2::i32 raw.rotation.value = 0 c2::u32 raw.sar.height = 1 c2::u32 raw.sar.width = 1 c2::u32 raw.size.height = 240 c2::u32 raw.size.width = 320 c2: 2021-11-19 08:39:23.545 3490-3565/com.motuslab.scoreboardapp W/ColorUtils: expected specified color aspects (2:0:0:0) 2021-11-19 08:39:23.546 3490-3563/com.motuslab.scoreboardapp W/System.err: java.lang.IllegalArgumentException 2021-11-19 08:39:23.546 3490-3563/com.motuslab.scoreboardapp W/System.err: at android.media.MediaCodec.native_configure(Native Method) 2021-11-19 08:39:23.547 3490-3563/com.motuslab.scoreboardapp W/System.err: at android.media.MediaCodec.configure(MediaCodec.java:2127) 2021-11-19 08:39:23.547 3490-3563/com.motuslab.scoreboardapp W/System.err: at android.media.MediaCodec.configure(MediaCodec.java:2043) 2021-11-19 08:39:23.547 3490-3563/com.motuslab.scoreboardapp W/System.err: at com.motuslab.scoreboardapp.live.VideoDecodeThread.run(VideoDecodeThread.kt:25)

This is the log of format: 2021-11-19 08:52:30.592 5369-5450/com.motuslab.scoreboardapp D/VideoDecodeThread: format {mime=video/avc, width=1691, height=900}

Please, can you seen what's is going wrong?

alexeyvasilyev commented 2 years ago

@freespirit83xyz Looks like the problem somewhere in config failed => CORRUPTED. Does demo app work with that RTSP camera on any Android phone (not RPi4)?

freespirit83xyz commented 2 years ago

@freespirit83xyz Looks like the problem somewhere in config failed => CORRUPTED. Does demo app work with that RTSP camera on any Android phone (not RPi4)?

The demo app works great on RPi4 and the RTSP camera is made with this https://github.com/pedroSG94/RTSP-Server

I've just wrote a new fragment (In Java) following what you have done in LiveFragment.kt

OctavianIonel commented 2 years ago

@alexeyvasilyev I have not tried with the SurfaceView, I need to use the TextureView in order to rotate also the video. I am using Samsung Galaxy Tab Active 3 with Android 10. Another issue: is there a way to make the RTSP client start faster?

alexeyvasilyev commented 2 years ago

@OctavianIonel No, I do not think it is possible to start RTSP stream quicker than currently implemented. Everything is implemented optimal IMHO.

OctavianIonel commented 2 years ago

hi @alexeyvasilyev 2 questions: a) for the control channel tcp is used? b) what about the video? it is not supposed to be over udp?

alexeyvasilyev commented 2 years ago

@OctavianIonel a) library maintains only one TCP connection which is used for control and video/audio receive. Using TCP allows secure connection via TLS. b) UDP protocol is not supported.

OctavianIonel commented 2 years ago

@alexeyvasilyev thanks for your feedback, but using tcp for the video receive will probably create buffering issues. Do you think it is a big change if udp was in place?

OctavianIonel commented 2 years ago

hi @alexeyvasilyev, @Fruchtzwerg94 @asmaamirkhan what would be the changes if I don't need TCP with TLS and I want to put in place the UDP protocol? Anybody could help by chance?

alexeyvasilyev commented 2 years ago

@OctavianIonel @freespirit83xyz I think I found root cause of the problem. The problem is that width or height of surface view is not even. mime=video/avc, width=1691, height=900

Try to use this code

    private fun getSafeSurfaceDimension(dimen: Int): Int {
        // Be sure codec width and height is even
        return if (dimen % 2 == 0)
            dimen
        else
            dimen - 1
    }

...

    val safeWidth = getSafeSurfaceDimension(width)
    val safeHeight = getSafeSurfaceDimension(height)
    val decoder = MediaCodec.createDecoderByType(mimeType)
    val format = MediaFormat.createVideoFormat(mimeType, safeWidth, safeHeight)
alexeyvasilyev commented 2 years ago

Fixed in https://github.com/alexeyvasilyev/rtsp-client-android/commit/e27d4fe7bf9f5818db7520e2d5a0f244fa4aefd0

sarimmehdi commented 1 year ago

@OctavianIonel can you maybe tell me how you are using a TextureView? I tried replacing SurfaceView with TextureView inside RtspSurfaceView but I get a few errors that I am not sure how to resolve.