iosobjective-cpjsip

pjsip can't detect audio device ios


I want to start pjsip default example on iPhone(simulator). When I make a call I get this error:

12:00:29.220            pjsua_aud.c  .Set sound device: capture=-1, playback=-2, mode=0, use_default_settings=0
12:00:29.221            pjsua_aud.c  ..Error retrieving default audio device parameters: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV) [status=420006]
12:00:29.223          pjsua_media.c  .Call 0: deinitializing media..
12:00:29.223               call.cpp  pjsua_call_make_call(acc.getId(), &pj_dst_uri, param.p_opt, this, param.p_msg_data, &id) error: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV) (status=420006) [../src/pjsua2/call.cpp:701]
pjsua_call_make_call(acc.getId(), &pj_dst_uri, param.p_opt, this, param.p_msg_data, &id) error: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV)

I configured and compiled the pjsip like this

sudo make distclean

sudo make clean

export DEVPATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/

export ARCH="-arch x86_64" CFLAGS="-O2 -m32 -mios-simulator-version-min=5.0" LDFLAGS="-O2 -m32 -mios-simulator-version-min=5.0"

./configure-iphone

sudo make dep  

sudo make  

sudo make install

I tried it on my iPhone and got the same error. I find solution here, but i can’t install libasound2-dev on MacOS

I use example from pjsipproj/pjsip-apps/src/pjsua2/ios-swift-pjsua2

PJSIP version: 2.13.1 OS: MacOS Ventura 13.5 IOS: 16.4


Solution

  • If you put the complete log, I could guide you better. But in general, since I myself faced this error, it is probably because your VOIP codecs are not installed. Therefore, make sure that the codecs are installed. To do this, you can add the following piece of code to the program's main function and recompile it to find the number and name of each installed codec, although in your program, I guess it will return 0:

      unsigned codeccount = 256;
      pjsua_codec_info codecinfo[codeccount];
      pj_status_t codecnum = pjsua_enum_codecs(codecinfo, &codeccount);
      fprintf(stderr, "codec Count: %d ", codeccount);
      for (int i = 0; i < codeccount; i++)
      {
          fprintf(stderr, "id: %s ", codecinfo[i].codec_id);
      }