VoiSmart / pjsip-android

SIP Service for Android based on PJSIP
http://www.pjsip.org/
Apache License 2.0
290 stars 140 forks source link

[ISSUE] Remote preview lost and surfaceview turn to black when app goes to background and turns to foreground #197

Closed asimhayat67 closed 2 months ago

asimhayat67 commented 1 year ago

Describe the bug Remote preview lost and surfaceview turn to black when app goes to background and turns to foreground

Lib version 2.1

Smartphone (please complete the following information):

Additional context I have tried with surfaceview callbacks and tried to start preview again but no luck.

below is my code

remotePreviewHolder.addCallback(object : SurfaceHolder.Callback { override fun surfaceCreated(holder: SurfaceHolder) { // The surface is created. This is a good place to start your video preview or perform any drawing operations. }

  override fun surfaceChanged(
    surfaceHolder: SurfaceHolder,
    format: Int,
    width: Int,
    height: Int
  ) {
    SipServiceCommand.setupIncomingVideoFeed(
      this@CallActivity,
      SipService.mAccountID,
      SipService.mCallID,
      surfaceHolder.surface
    )

  }

  override fun surfaceDestroyed(holder: SurfaceHolder) {
     SipServiceCommand.setupIncomingVideoFeed(
       this@CallActivity, SipService.mAccountID, SipService.mCallID, holder.surface
     )
  }
})
aenonGit commented 2 months ago

maybe it's related to latest foreground service requirements? try giving it the proper ones and also check if your app is eligible to access camera in the background