PJSIP library is modified to capture PCM frames from the call and stream PCM frames to the calls.
Added two classes to media.hpp and media.cpp files:
AudioMediaCapture: contains list to accumulate incoming frames, frames can be extracted withgetFrames/getFramesAsStringmethods.AudioMediaStream: contains list for outgoing frames, frames can be populated withputFrame/putFrameAsStringmethods.
Need some changes to SWIG to access those features from the Python:
- Uncomment
USE_THREADS = -threads -DSWIG_NO_EXPORT_ITERATOR_METHODSinswig/python/Makefile - Add typemaps to
swig/pjsua2.ito send/receivebytesfrom Python:
#ifdef SWIGPYTHON
%typemap(in) (char *data, size_t datasize) {
Py_ssize_t len;
PyBytes_AsStringAndSize($input, &$1, &len);
$2 = (size_t)len;
}
%typemap(in, numinputs=0) (char **data, size_t *datasize)(char *temp, size_t tempsize) {
$1 = &temp;
$2 = &tempsize;
}
%typemap(argout) (char **data, size_t *datasize) {
if(*$1) {
$result = PyBytes_FromStringAndSize(*$1, *$2);
free(*$1);
}
}
#endif
docker-compose updocker-compose exec pjsip python demo.pyDemo script dumps frames to from the call topjsip/pjsuademo/output.lpcmand streamshw.rawto the call. The recording of the call with both parties will be inasterisk_files/recordingsdirectory.