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.48k stars 765 forks source link

How to restart stream in background? #1446

Closed r-nov closed 4 months ago

r-nov commented 4 months ago

Hi @pedroSG94!

I'd like to ask you about restarting stream while app in background (encoder running in service). I'm using RootEncoder 2.3.1, I know it's quite old but I tried newer versions and seems like behaviour is the same. I have no problems with restarting stream when app is in foreground (OpenGlView) with simple:

stopStream()
if (prepare())
    startStream()

but can't restart stream this way when app is in background (OffScreenGlThread).

The only way I managed it to restart is add stopPreview() after stopStream() BUT it's working only if I restarted stream this way at least once when app is in foreground.

stopStream()
stopPreview()
if (prepare())
    startStream()

I mean if I restart stream with this code at least once while app is open I can restart stream in background, but otherwise behaviour is the same as without this stopPreview().

This is logcat when I try to restart stream in background (without stopPreview, just stop -> prepare -> start):

2024-03-26 09:49:39.756  5298-5864  BaseRtpSocket                            I  wrote packet: Audio, size: 318
2024-03-26 09:49:39.778  5298-5864  CommandsManager                          I  TEARDOWN rtsp://0.0.0.0:8554/stream RTSP/1.0
                                                                             CSeq: 6
                                                                             User-Agent: com.pedro.rtsp 2.3.1
                                                                             Session: 64a74aa7c2b348a898bf21773f64ab79
2024-03-26 09:49:39.781  5298-5864  RtspClient                               I  write teardown success
2024-03-26 09:49:39.809  5298-5946  MicrophoneManager                        I  Microphone stopped
2024-03-26 09:49:39.811  5298-5946  SurfaceManager                           I  GL released
2024-03-26 09:49:39.811  5298-5298  MicrophoneManager                        I  Microphone stopped
2024-03-26 09:49:39.813  5298-5946  libEGL                                   W  EGLNativeWindowType 0x7e707cf010 disconnect failed
2024-03-26 09:49:39.814  5298-5946  SurfaceManager                           I  GL released
2024-03-26 09:49:39.815  5298-5946  SurfaceManager                           I  GL initialized
2024-03-26 09:49:39.817  5298-5298  SurfaceManager                           I  GL released
2024-03-26 09:49:39.817  5298-5298  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.819  5298-5298  SurfaceManager                           I  GL initialized
2024-03-26 09:49:39.822  5298-5892  SurfaceManager                           I  GL released
2024-03-26 09:49:39.822  5298-5892  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.824  5298-5892  SurfaceManager                           I  GL released
2024-03-26 09:49:39.825  5298-5946  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.825  5298-5946  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.825  5298-5946  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.825  5298-5298  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.825  5298-5298  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.825  5298-5298  SurfaceManager                           E  GL already released
2024-03-26 09:49:39.922  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.924  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.926  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.928  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.929  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.931  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.933  5298-5946  BufferQueueProducer                      E  [SurfaceTexture-1-5298-1](id:14b200000001,api:4,p:3821,c:5298) cancelBuffer: BufferQueue has been abandoned
2024-03-26 09:49:39.936  5298-5778  CameraManagerGlobal                      I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_IDLE for client com.n.cam API Level 2
2024-03-26 09:49:40.108  5298-5778  CameraManagerGlobal                      I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_CLOSED for client com.n.cam API Level 2
2024-03-26 09:49:40.112  5298-5946  VideoEncoder                             I  stopped
2024-03-26 09:49:40.113  5298-5848  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] signalFlush
2024-03-26 09:49:40.113  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] ExecutingState flushing now (codec owns 0/12 input, 4/4 output).
2024-03-26 09:49:40.114  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Flushing
2024-03-26 09:49:40.114  5298-5298  VideoEncoder                             I  stopped
2024-03-26 09:49:40.117  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] FlushingState onOMXEvent(0,1,0)
2024-03-26 09:49:40.120  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] FlushingState onOMXEvent(0,1,1)
2024-03-26 09:49:40.120  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Executing
2024-03-26 09:49:40.121  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Executing->Idle
2024-03-26 09:49:40.135  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Idle->Loaded
2024-03-26 09:49:40.135  5298-5849  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Loaded
2024-03-26 09:49:40.135  5298-5849  ACodec                                   I   [OMX.Exynos.HEVC.Encoder] Now kWhatShutdownCompleted event : 8312
2024-03-26 09:49:40.135  5298-5849  ACodec                                   I   [OMX.Exynos.HEVC.Encoder] Now kWhatShutdownCompleted event : 8312
2024-03-26 09:49:40.136  5298-5946  AudioEncoder                             I  stopped
2024-03-26 09:49:40.138  5298-5298  AudioEncoder                             I  stopped
2024-03-26 09:49:40.139  5298-5858  CCodec                                   I  state->set(FLUSHING)
2024-03-26 09:49:40.139  5298-5849  ACodec                                   I   [OMX.Exynos.HEVC.Encoder] Now uninitialized
2024-03-26 09:49:40.139  5298-5849  ACodec                                   I   [] Now kWhatShutdownCompleted event : 8312
2024-03-26 09:49:40.139  5298-5848  MediaCodec                               I  Codec shutdown complete
2024-03-26 09:49:40.140  5298-5858  CCodec                                   I  state->set(FLUSHED)
2024-03-26 09:49:40.141  5298-5858  CCodec                                   I  state->set(STOPPING)
2024-03-26 09:49:40.145  5298-5858  CCodec                                   I  state->set(ALLOCATED)
2024-03-26 09:49:40.146  5298-5858  CCodec                                   I  state->set(RELEASING)
2024-03-26 09:49:40.152  5298-5953  CCodec                                   I  [c2.android.aac.encoder] release(1)
2024-03-26 09:49:40.155  5298-5298  TextStreamObject                         I  finish load text
2024-03-26 09:49:40.155  5298-5953  CCodec                                   I  state->set(RELEASED)
2024-03-26 09:49:40.156  5298-5858  hw-BpHwBinder                            I  onLastStrongRef automatically unlinking death recipients
2024-03-26 09:49:40.157  5298-5858  MediaCodec                               I  Codec shutdown complete
2024-03-26 09:49:40.168  5298-5946  RtspEncoderService                       I  Video codec H265 set.
2024-03-26 09:49:40.171  5298-5946  VideoEncoder                             I  2 encoders found
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Encoder OMX.Exynos.HEVC.Encoder
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 2135033992
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 19
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 21
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 2130706449
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 16
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 2130747392
2024-03-26 09:49:40.172  5298-5946  VideoEncoder                             I  Color supported: 2130708361
2024-03-26 09:49:40.173  5298-5946  VideoEncoder                             I  Encoder selected OMX.Exynos.HEVC.Encoder
2024-03-26 09:49:40.175  5298-5946  ACodec                                   I   [] Now uninitialized
2024-03-26 09:49:40.176  5298-5955  ACodec                                   I  [] onAllocateComponent
2024-03-26 09:49:40.177  5298-5955  OMXClient                                I  IOmx service obtained
2024-03-26 09:49:40.184  5298-5955  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Loaded
2024-03-26 09:49:40.186  5298-5946  VideoEncoder                             I  Prepare video info: SURFACE, 480x640
2024-03-26 09:49:40.186  5298-5946  VideoEncoder                             I  bitrate mode CBR not supported using default mode
2024-03-26 09:49:40.188  5298-5954  MediaCodec                               I  MediaCodec will operate in async mode
2024-03-26 09:49:40.191  5298-5955  ACodec                                   I  app-pid(5298)
2024-03-26 09:49:40.193  5298-5955  OMXUtils                                 W  do not know color format 0x7f000011 = 2130706449
2024-03-26 09:49:40.194  5298-5955  OMXUtils                                 W  do not know color format 0x10 = 16
2024-03-26 09:49:40.194  5298-5955  OMXUtils                                 W  do not know color format 0x7f00a000 = 2130747392
2024-03-26 09:49:40.195  5298-5955  OMXUtils                                 W  do not know color format 0x7f000789 = 2130708361
2024-03-26 09:49:40.197  5298-5955  ACodec                                   I  app-name : com.n.cam
2024-03-26 09:49:40.197  5298-5955  ACodec                                   I  Enable drop control
2024-03-26 09:49:40.199  5298-5955  ACodec                                   I  Success set VideoMinQP(5/5/5) VideoMaxQP(50/50/50)
2024-03-26 09:49:40.200  5298-5955  ACodec                                   I  setupVideoEncoder succeeded
2024-03-26 09:49:40.201  5298-5955  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] configure, AMessage : AMessage(what = 'conf', target = 8) = {
                                                                               int32_t color-format = 2130708361
                                                                               int32_t i-frame-interval = 10
                                                                               string mime = "video/hevc"
                                                                               int32_t width = 480
                                                                               int32_t bitrate = 320000
                                                                               int32_t max-input-size = 0
                                                                               int32_t frame-rate = 3
                                                                               int32_t height = 640
                                                                               int32_t flags = 1
                                                                               int32_t encoder = 1
                                                                               int32_t vendor.sec-ext-enc-ref-pframes.number = 2
                                                                               int32_t vendor.sec-ext-enc-gpb.enable = 1
                                                                             }
2024-03-26 09:49:40.203  5298-5955  OMXUtils                                 W  do not know color format 0x7f000789 = 2130708361
2024-03-26 09:49:40.215  5298-5946  VideoEncoder                             I  prepared
2024-03-26 09:49:40.245  5298-5946  MicrophoneManager                        I  Microphone created, 32000hz, Stereo
2024-03-26 09:49:40.248  5298-5946  AudioEncoder                             I  3 encoders found
2024-03-26 09:49:40.248  5298-5946  AudioEncoder                             I  Encoder selected c2.android.aac.encoder
2024-03-26 09:49:40.251  5298-5962  CCodec                                   I  state->set(ALLOCATING)
2024-03-26 09:49:40.251  5298-5962  CCodec                                   I  allocate(c2.android.aac.encoder)
2024-03-26 09:49:40.255  5298-5962  CCodec                                   I  setting up 'default' as default (vendor) store
2024-03-26 09:49:40.261  5298-5962  CCodec                                   I  Created component [c2.android.aac.encoder]
2024-03-26 09:49:40.262  5298-5962  CCodec                                   I  state->set(ALLOCATED)
2024-03-26 09:49:40.262  5298-5962  CCodecConfig                             D  read media type: audio/mp4a-latm
2024-03-26 09:49:40.266  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: algo.buffers.max-count.values
2024-03-26 09:49:40.267  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: output.subscribed-indices.values
2024-03-26 09:49:40.268  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: input.buffers.allocator-ids.values
2024-03-26 09:49:40.268  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: output.buffers.allocator-ids.values
2024-03-26 09:49:40.269  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: algo.buffers.allocator-ids.values
2024-03-26 09:49:40.269  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: output.buffers.pool-ids.values
2024-03-26 09:49:40.270  5298-5962  ReflectedParamUpdater                    D  extent() != 1 for single value type: algo.buffers.pool-ids.values
2024-03-26 09:49:40.274  5298-5962  CCodecConfig                             I  query failed after returning 9 values (BAD_INDEX)
2024-03-26 09:49:40.274  5298-5962  CCodecConfig                             D  c2 config diff is Dict {
                                                                               c2::u32 coded.bitrate.value = 64000
                                                                               c2::u32 coded.pl.level = 0
                                                                               c2::u32 coded.pl.profile = 8192
                                                                               c2::u32 coding.aac-sbr-mode.value = 3
                                                                               c2::u32 input.buffers.max-size.value = 2048
                                                                               c2::u32 input.delay.value = 0
                                                                               string input.media-type.value = "audio/raw"
                                                                               string output.media-type.value = "audio/mp4a-latm"
                                                                               c2::u32 raw.channel-count.value = 1
                                                                               c2::u32 raw.sample-rate.value = 44100
                                                                             }
2024-03-26 09:49:40.277  5298-5962  MediaCodec                               I  MediaCodec will operate in async mode
2024-03-26 09:49:40.278  5298-5962  CCodec                                   D  [c2.android.aac.encoder] buffers are bound to CCodec for this session
2024-03-26 09:49:40.279  5298-5962  CCodec                                   D  can't get width
2024-03-26 09:49:40.279  5298-5962  CCodec                                   D  can't get height
2024-03-26 09:49:40.279  5298-5962  CCodec                                   I  appPid(5298) width(0) height(0)
2024-03-26 09:49:40.279  5298-5962  CCodecConfig                             D  no c2 equivalents for aac-profile
2024-03-26 09:49:40.279  5298-5962  CCodecConfig                             D  no c2 equivalents for flags
2024-03-26 09:49:40.279  5298-5962  CCodecConfig                             D  no c2 equivalents for encoder
2024-03-26 09:49:40.281  5298-5962  CCodecConfig                             D  c2 config diff is   c2::u32 coded.bitrate.value = 65536
                                                                               c2::u32 input.buffers.max-size.value = 4096
                                                                               c2::u32 raw.channel-count.value = 2
                                                                               c2::u32 raw.sample-rate.value = 32000
2024-03-26 09:49:40.282  5298-5962  Codec2Client                             W  query -- param skipped: index = 1107298332.
2024-03-26 09:49:40.282  5298-5962  CCodec                                   D  setup formats input: AMessage(what = 0x00000000) = {
                                                                               int32_t aac-sbr-mode = 3
                                                                               int32_t channel-count = 2
                                                                               int32_t max-input-size = 5120
                                                                               string mime = "audio/raw"
                                                                               int32_t sample-rate = 32000
                                                                             } and output: AMessage(what = 0x00000000) = {
                                                                               int32_t aac-sbr-mode = 3
                                                                               int32_t bitrate = 65536
                                                                               int32_t channel-count = 2
                                                                               int32_t level = 0
                                                                               int32_t max-bitrate = 65536
                                                                               string mime = "audio/mp4a-latm"
                                                                               int32_t profile = 2
                                                                               int32_t sample-rate = 32000
                                                                             }
2024-03-26 09:49:40.283  5298-5946  AudioEncoder                             I  prepared
2024-03-26 09:49:40.300  5298-5946  VideoEncoder                             I  started
2024-03-26 09:49:40.300  5298-5946  MediaCodec                               W  keep callback message for reclaim
2024-03-26 09:49:40.302  5298-5955  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Loaded->Idle
2024-03-26 09:49:40.331  5298-5955  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Idle->Executing
2024-03-26 09:49:40.332  5298-5954  MediaCodec                               I  setCodecState state : 0
2024-03-26 09:49:40.334  5298-5946  AudioEncoder                             I  started
2024-03-26 09:49:40.335  5298-5946  MediaCodec                               W  keep callback message for reclaim
2024-03-26 09:49:40.335  5298-5962  CCodec                                   I  state->set(STARTING)
2024-03-26 09:49:40.337  5298-5962  Codec2Client                             W  query -- param skipped: index = 1342179345.
2024-03-26 09:49:40.337  5298-5962  Codec2Client                             W  query -- param skipped: index = 2415921170.
2024-03-26 09:49:40.339  5298-5955  ACodec                                   I  [OMX.Exynos.HEVC.Encoder] Now Executing
2024-03-26 09:49:40.339  5298-5962  FMQ                                      E  grantorIdx must be less than 3
2024-03-26 09:49:40.340  5298-5962  FMQ                                      E  grantorIdx must be less than 3
2024-03-26 09:49:40.340  5298-5962  CCodecBufferChannel                      D  [c2.android.aac.encoder#95] Created input block pool with allocatorID 16 => poolID 18 - OK (0)
2024-03-26 09:49:40.343  5298-5962  CCodecBufferChannel                      I  [c2.android.aac.encoder#95] Created output block pool with allocatorID 16 => poolID 96 - OK
2024-03-26 09:49:40.344  5298-5962  CCodecBufferChannel                      D  [c2.android.aac.encoder#95] Configured output block pool ids 96 => OK
2024-03-26 09:49:40.344  5298-5962  CCodec                                   I  state->set(RUNNING)
2024-03-26 09:49:40.349  5298-5962  CCodecBufferChannel                      I  [c2.android.aac.encoder#95] 4 initial input buffers available
2024-03-26 09:49:40.362  5298-5946  Camera2ApiManager                        I  optimal resolution set to: 640x480
2024-03-26 09:49:40.362  5298-5946  m.n.cam                                  E  [SurfaceTexture-1-5298-1] setDefaultBufferSize: SurfaceTexture is abandoned!
2024-03-26 09:49:40.377  5298-5946  MicrophoneManager                        I  Microphone started
2024-03-26 09:49:40.383  5298-5879  RtspClient                               I  waiting for sps and pps
2024-03-26 09:49:40.575  5298-5962  FMQ                                      E  grantorIdx must be less than 3
2024-03-26 09:49:40.583  5298-5850  FMQ                                      E  grantorIdx must be less than 3
2024-03-26 09:49:41.163  5298-5298  TextStreamObject                         I  finish load text
2024-03-26 09:49:41.333  5298-5954  MediaCodec                               I  setCodecState state : 0

My guess is that I don't handle surface correctly, but I couldn't figure out the approach to manage it.

Thank you.

pedroSG94 commented 4 months ago

Hello,

I need more info. I need know:

r-nov commented 4 months ago

Hi,

Explain in detail the error experimented, like: when I re start, the stream never start and onConnectionStarted is not received, I always receive connection failed X, etc.

Roughly speaking it's service example from version 2.3.1. My steps are: start the stream with BackgroundActivity, hide the app to the background, restart the stream when app is in the background. To restart the stream in the background I'm using following code:

stopStream()
if (prepare()) {
    startStream(url)

With this code stream stops but doesn't start. It doesn't move further than waiting for sps and pps and there's always this error in logcat [SurfaceTexture-1-3428-1] setDefaultBufferSize: SurfaceTexture is abandoned! (probably not related?). As you recommended I don't need to stop/start preview in background (furthermore preview is stopped when app is in the background) but during my experiments I have figured out that after I call stopPreview like this:

stopStream()
stopPreview() // <-- here
if (prepare()) {
    startStream(url)

while app is in the foreground, I can restart stream in background with same code. Again, only if I call this code at least once when app is in the foreground. Don't know if it help, just mention it just in case. Let me know it there's additional info you need to know.

The code used inside that methods and all code related to debug it and reproduce the case.

To reproduce my case with same code I'd like to ask you:

Make sure that you stop stream, preview and record before prepare and start stream again. If you are using background you don't need use startPreview and stopPreview.

Checked it again, stream, preview and record stopped when I'm calling prepare() and startStream().

Are you moving from foreground to background or are you always in background?

I'm moving from foreground to background with stream running.

Let me know if I missed something and you need additional info. Thank you.

pedroSG94 commented 4 months ago

Hello,

This is the mentioned class in version 2.3.1: https://github.com/pedroSG94/RootEncoder/blob/2.3.1/app/src/main/java/com/pedro/streamer/backgroundexample/BackgroundActivity.kt

I don't understand the reason to stop and start stream again when you go to background if you can continue the current stream like in the example. Using the example you can move to foreground and background without re start stream. Try this way if it is valid for you, if not explain me the reason to find a better way.

Also, can you check onConnectionStarted callback and onConnectionFailed callback and share me the string in the callback when you re start stream?

r-nov commented 4 months ago

Sorry for misunderstanding :) Should mention it earlier, but the purpose is to control (including restart) the stream remotely through HTTP when the app is in the background. So I have added an example with coroutine and delay because it's an easy way to simulate my case with remote restart. I have no problem with moving to background and continuing the streaming, your example works just fine.

Also, can you check onConnectionStarted callback and onConnectionFailed callback and share me the string in the callback when you re start stream?

Sure. onConnectionStarted callback contains correct url rtsp://192.168.1.10:8554/stream and onConnectionFailed contains sps or pps is null.

pedroSG94 commented 4 months ago

Sorry for misunderstanding :) Should mention it earlier, but the purpose is to control (including restart) the stream remotely through HTTP when the app is in the background. So I have added an example with coroutine and delay because it's an easy way to simulate my case with remote restart.

I see, but you have betters ways to do it because the current way produce a really bad experience for the user because the stream stop fews second before it start again. You can create an api rest in the server side to notify about it using a simple http request or use a socket with socket.io for example if you want a real time result.

onConnectionStarted callback contains correct url rtsp://192.168.1.10:8554/stream and onConnectionFailed contains sps or pps is null.

I will check it because this should works but, check that you have this error in library version 2.4.4 and then I will try to fix it in the last library version. Also, make sure that you only added the code mentioned in the onSurfaceDestroyed and notify me if you have more code to modify in order to reproduce the case.

r-nov commented 4 months ago

You can create an api rest in the server side to notify about it using a simple http request

I have exactly this implementation with REST api on my side, sorry if my example was confusing, it's just for debug purposes :)

Also, make sure that you only added the code mentioned in the onSurfaceDestroyed and notify me if you have more code to modify in order to reproduce the case.

Checked it on more time, there's no other code, I've created a clean project and changed only parts that I mentioned (onSurfaceDestroyed and changed RtmpCamera2 to RtspCamera2).

check that you have this error in library version 2.4.4 and then I will try to fix it in the last library version.

Checked with last 2.4.4 version. Behaviour is the same, correct url but still sps or pps is null in onConnectionFailed.

pedroSG94 commented 4 months ago

Hello,

Error fixed here: https://github.com/pedroSG94/RootEncoder/commit/39bd2f1e89d664fedf865d0addb4e5ca96733054

You can compile the last commit using this gradle:

implementation 'com.github.pedroSG94.RootEncoder:library:39bd2f1e89'

Or wait for the release

r-nov commented 4 months ago

Thank you very much for the quick fix, works like a charm!