Search code examples
pjsip

Is PJSIP (PJSUA2) usable without an audio device?


We're developing an application for some embedded hardware which doesn't have yet any audio devices. At the moment, we're simply evaluating whether PJSIP runs okay on the hardware and can send audio data over the network.

To that end, we have a client which needs to read audio data from a file, send it via PJSIP to a server, which then writes it to another file, so we can simply compare the two files (in the sense that they sound the same, not necessarily be the exact same content). So the setup would be something like:

                   +--------+
(Audio file 1) --> |_Client_|     +--------+
                   | PJSIP  | --> |_PJSIP__|
                   +--------+     | Server | --> (Audio file 2)
                                  +--------+

We have the applications compiling but, when I run the client application and try to establish a call to the server, it complains about not having any audio hardware (formatted for readability):

02:14:47.636 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:485]

I suspect the server would exhibit the same problem when accepting the call but we haven't got that far yet.

Now I know there's no audio hardware (the output of dmesg clearly shows that the ALSA device list is empty) but that's not an issue for me.

We've followed the guidelines as per sub-classing Call but it was from some other code written earlier, code that uses AudioMedia and other classes in the PJSIP libraries, which I suspect is automatically searching for devices.

As stated, I want to be able to send through one of a series of audio files read from disk so do not really care whether audio devices are available or not.

Does PJSIP have a way to do this? Does anyone know of, or have any experience in, code that performs this (seemingly) simple task?


Solution

  • Turns out you can simply configure the endpoint to use a null audio device immediately after the libInit() call:

    myEndpoint.libInit(myEndpointConfig);
    myEndpoint.audDevManager().setNullDev()
    

    That prevent the auto detection from generating its error.