Capturing Audio to WAV File in Pjsip 2.9

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I followed https://www.pjsip.org/pjmedia/docs/html/page_pjmedia_samples_recfile_c.htm link to record call and also convert some code to swift like, 

var cpFec: pj_caching_pool?

var med_endpt: OpaquePointer?

var file_port: UnsafeMutablePointer<pjmedia_port>?

var pool: UnsafeMutablePointer<pj_pool_t>?

var snd_port: UnsafeMutablePointer<pjmedia_snd_port>?


    var status = pj_init()

    if status != PJ_SUCCESS.rawValue {

        return (false, nil)

    }

    cpFec = pjsua_data().cp

    /* Must create a pool factory before we can allocate any memory. */

    pj_caching_pool_init(&cpFec!, &pj_pool_factory_default_policy, 0)

    status = pjmedia_endpt_create(&cpFec!.factory, nil, 1, &med_endpt

    )

    if status != PJ_SUCCESS.rawValue {

        return (false, nil)

    }

    pool = pj_pool_create(&cpFec!.factory, "app", 4000, 4000, nil)

    let rec = Recording.getNewSipBlanckRecording()

    let files = FileProvider.getRecordingUrl(fileName: rec.fileName)?.path

    let fileName: pj_str_t = pj_str(convertToChar(files))

  

    /* Create WAVE file writer port. */

    let str = String(cString: fileName.ptr, encoding: .utf8)

    status = pjmedia_wav_writer_port_create(pool,

                                            str,

                                            CLOCK_RATE,

                                            NCHANNELS,

                                            SAMPLES_PER_FRAME,

                                            BITS_PER_SAMPLE,

                                            0, 0,

                                            &file_port);

    /* Create sound player port. */

    status = pjmedia_snd_port_create_rec(pool,       /* pool         */

        -1,         /* use default dev.        */

        PJMEDIA_PIA_SRATE(&file_port!.pointee.info),/* clock rate.     */

        PJMEDIA_PIA_CCNT(&file_port!.pointee.info),/* # of channels.       */

        PJMEDIA_PIA_SPF(&file_port!.pointee.info), /* samples per frame.   */

        PJMEDIA_PIA_BITS(&file_port!.pointee.info),/* bits per sample.     */

        0,      /* options      */

        &snd_port       /* returned port       */

    )

    if status != PJ_SUCCESS.rawValue {

        return (false, nil)

    }

    status = pjmedia_snd_port_connect(snd_port, file_port)



It works fine and records the call completely in simulator, but in device it does not record for more than 1 second. anybody please help me.

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux