Simon
Simon

Reputation: 1

How to create a large number of outgoing calls in parallel?

I want initiate around 100 parallel calls, just with recording other side, in one process with using python3 + pjsua2. Initiating stage is fine, but recordings which were produced has squeezed sound(sound in wav 2-3x times faster than real sound), probably, problem somewhere with RTP. What could i do to fix it?

Before i used one python worker = one pjsua2 client = 10-15 calls. And this worked totally good, but heavy for RAM. That's why i trying to put everything in one process, but not sure that's even possible.

Here is my compilation and app configs for 100 parallel calls in one process.

       "-DPJSIP_T1_TIMEOUT=3000 -DPJSIP_T2_TIMEOUT=10000 \
        -DPJSUA_MAX_CALLS=150 -DPJSUA_MAX_ACC=150 \
        -DPJ_LOG_ENABLE_COLORS=1 -DPJMEDIA_CODEC_FRAME_PTIME=30 \
        -DPJSIP_MAX_TSX_COUNT=1000 -DPJSIP_MAX_DIALOG_COUNT=1000 \
        -DPJ_IOQUEUE_MAX_HANDLES=1024 -DPJMEDIA_HAS_VIDEO=0\
        -DPJSIP_UDP_SO_SNDBUF_SIZE=524288 -DPJSIP_UDP_SO_RCVBUF_SIZE=524288 \
        -DPJ_HAS_THREADS=1 -DPJ_TIMER_HEAP_SIZE=262144 \
        -DPJ_POOL_LEN=8000 -DPJ_POOL_INC=1024 \
        -DPJ_THREAD_STACK_SIZE=512*1024 -fPIC" ./configure --disable-video


class PJSIP:
    _instance = None

    def __new__(cls, *args, **kwargs):
        if cls._instance is None:
            cls._instance = super(PJSIPApp, cls).__new__(cls)
        return cls._instance

    def __init__(
        self,
    ):
        if not hasattr(self, "_initialized"):
            self.ep = Endpoint()
            self.accounts = {}
            self.calls = {}
            self.log_cfg = pj.LogConfig()
            self.log_cfg.level = settings.PJSIP_LOG_LEVEL
            self.log_cfg.msgLogging = True

            self.create_lib()
            self._initialized = True

    def create_lib(
        self,
    ):
        try:
            self.ep_cfg = pj.EpConfig()
            self.ep_cfg.uaConfig.threadCnt = 1
            self.ep_cfg.uaConfig.mainThreadOnly = False
            self.ep_cfg.uaConfig.maxCalls = 150
            self.ep_cfg.uaConfig.enableAec = False
            self.ep_cfg.medConfig.noVad = True
            self.ep_cfg.medConfig.threadCnt = 4
            self.ep_cfg.medConfig.audioFramePtime = 30
            self.ep_cfg.medConfig.ptime = 30
            self.ep_cfg.logConfig = self.log_cfg

            self.ep.libCreate()
            self.ep.libInit(self.ep_cfg)
            transport_cfg = pj.TransportConfig()
            transport_cfg.port = 0

            self.ep.transportCreate(pj.PJSIP_TRANSPORT_UDP, transport_cfg)
            self.ep.audDevManager().setNullDev()
            self.ep.libStart()

            self.configure_codecs()
        except pj.Error as e:
            logger.error(
                f"Can't initiate pjsip lib: {e.reason}", exc_info=True, stack_info=True
            )

Upvotes: 0

Views: 37

Answers (0)

Related Questions