1

My App is getting crash if I continuous pause and start while video calling is going I have used following code for pausing and resuming video streaming.

PJSIP version: 2.9

func pauseVideo(_ value: Bool) {
    guard let id = SIPAccount.account?.calls.last?.call_id else { return }
    let operation = value ? PJSUA_CALL_VID_STRM_STOP_TRANSMIT : PJSUA_CALL_VID_STRM_START_TRANSMIT

    var param = pjsua_call_vid_strm_op_param()
    pjsua_call_vid_strm_op_param_default(&param)
    param.med_idx = pjsua_call_get_vid_stream_idx(pjsua_call_id(id))
    param.dir = value ? PJMEDIA_DIR_NONE : PJMEDIA_DIR_ENCODING_DECODING

    pjsua_call_set_vid_strm(pjsua_call_id(id), operation, &param)
}

Logs:

PJSIP_log: in pauseVideo
pjsua_vid.c  Call 0: set video stream, op=5
vid_conf.c  .Updating render state for port id 2 (1 sources)..
vid_conf.c  .Created render state for connection 3->2
vid_conf.c  .src#0=BGRA/352x288->352x264@0,12 dst=320x240@0,0
vid_conf.c  .Port 3 (Front Camera) transmitting to port 2 (vstenc0x12c093028)
vstenc0x12c093028  .Encoder stream resumed
PJSIP_log: video pause status 0
vstenc0x12c093028 !Forcing encoder to generate keyframe
PJSIP_log: in pauseVideo
pjsua_vid.c !Call 0: set video stream, op=6
vstenc0x12c093028  .Encoder stream paused
vid_conf.c  .Cleaned up render state for connection 3->2
vid_conf.c  .Port 3 (Front Camera) stop transmitting to port 2 (vstenc0x12c093028)
PJSIP_log: video pause status 0
silencedet.c !Re-adjust threshold (in silence)to 0
PJSIP_log: in pauseVideo
pjsua_vid.c !Call 0: set video stream, op=5
strm0x12ca03228 !Jitter buffer starts returning normal frames (after 249 empty/lost)
strm0x12ca03228  Jitter buffer empty (prefetch=0), plc invoked
strm0x12ca03228  Start talksprut..
strm0x12ca03228  Starting silence
silencedet.c  Re-adjust threshold (in silence)to 0

After that pjsua_vid.c !Call 0: set video stream, op=5 app is getting hang and this 3 lines will be logged multiple times

strm0x12ca03228  Start talksprut..
strm0x12ca03228  Starting silence
silencedet.c  Re-adjust threshold (in silence)to 0
Devansh Vyas
  • 447
  • 1
  • 5
  • 8
  • 1
    Please update the question with PJSIP version, and additional logs and call stack/stack trace. – Perry Ismangil Sep 24 '19 at 11:55
  • 1
    First, make sure you are not using gcd on iOS (https://trac.pjsip.org/repos/wiki/Getting-Started/iPhone#gcd-crash). Then, provide the stack trace as well so we can know at which function exactly the crash occurred. – Sauw Ming Liong Sep 24 '19 at 13:39
  • 1
    @SauwMingLiong Using pjsua_schedule_timer2() solved my issue thanks a lot for your help. :) – Devansh Vyas Sep 25 '19 at 10:19
  • @Devansh Vyas i have same problem when start and stop tramsmit, where can i use pjsua_schedule_timer2 – Son Pham May 26 '20 at 03:43
  • 1
    @SonPham I had issue with pausing video and it get solved with this: `func pauseVideo(_ value: Bool) { let valuePointer = UnsafeMutablePointer(mutating: (value.description as NSString).utf8String) let valueRawPointer = UnsafeMutableRawPointer.init(valuePointer) pjsua_schedule_timer2(pauseCallback, valueRawPointer, 0) print("PJSIP_log: in pauseVideo") }` – Devansh Vyas May 27 '20 at 04:51
  • @DevanshVyas could you show me func pauseCallback. I have crashed when called pjsua_schedule_timer2. – Son Pham Oct 03 '21 at 16:09

1 Answers1

1

Using pjsua_schedule_timer2() solved this issue

Devansh Vyas
  • 447
  • 1
  • 5
  • 8
  • It would be great help if you could give me idea on how to implement puase and start video streaming in Android as well... am not able to impment it .. . https://stackoverflow.com/questions/63702759/how-to-pause-and-unpause-video-transmission-using-android-pjsua-2 – tomtom Sep 02 '20 at 09:55
  • I don't have much knowledge in Android, But will share this to one of the developers who can guide you. – Devansh Vyas Sep 03 '20 at 10:12
  • I had crashed when trying to answer with 200 in a video call. I had a problem with ICE. Please help me solution for answer call (https://www.spinics.net/lists/pjsip/msg20839.html) – Son Pham Oct 03 '21 at 16:13