Set PJMEDIA codec in PJMEDIA ENDPOINT

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

 



Hi guys,

How can I enable all PJMEDIA codec (in particular PCMA codec)?

When I run the following source code in “codec_mgr” à “codec_desc” à all codec are configured as PJMEDIA_CODEC_PRIO_DISABLED except for iLBC codec (PJMEIDA_CODEC_PRIO_NORMAL).

 

       pj_pool_t *poolMc;

       pjmedia_stream **p_stream;

       pjmedia_endpt *med_endpt;

       pj_caching_pool cp;

       pj_status_t status;

       pjmedia_stream *stream = NULL;

       pjmedia_snd_port *snd_port = NULL;

       pjmedia_port *stream_port;

       pj_uint16_t local_port = 3000;

       pjmedia_codec_param codec_param;

       const pjmedia_codec_info *codec_info;

 

       pj_sockaddr_in rem_addr;

       /* Reset defined remote address */

       pj_bzero(&rem_addr, sizeof(rem_addr));

 

       char *codec_id = new char[4];

       strcpy(codec_id, "PCMA");

       //codec_id = Utils::toPj_str("PCMA")

       //codec_id = "PCMA";

 

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

       pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);

 

       /*

       * Initialize media endpoint.

       * This will implicitly initialize PJMEDIA too.

       */

       status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);

       if (status != PJ_SUCCESS) {

             return status;

       }

 

       /* Create memory pool for application purpose */

       poolMc = pj_pool_create(&cp.factory, /* pool factory */

             "app",       /* pool factory */

             4000,        /* init size */

             4000,        /* increment size */

             NULL         /* callback on error */

       );

 

       /* Register all codecs */

       pjmedia_audio_codec_config codec_cfg;

       pjmedia_audio_codec_config_default(&codec_cfg);

       /* Register all supported codecs (register all known audio codecs implemented in PJMEDA-CODEC library to the specified media endpoint) */

       status = pjmedia_codec_register_audio_codecs(med_endpt, &codec_cfg);

       if (status != PJ_SUCCESS) {

             return status;

       }

 

       //OPTIONAL

       /* Initialize and register G711 codec factory to pjmedia endpoint. This will register PCMU and PCMA codec, in that order */

       /* Use pjmedia_codec_g711_deinit( voi ) for unregister G711 codec factory from pjmedia endpoint */

       status = pjmedia_codec_g711_init(med_endpt);

       if (status != PJ_SUCCESS) {

             return status;

       }

 

       /* Find which codec to use */

       if (codec_id) {

             unsigned count = 1;

             pj_str_t str_codec_id = pj_str(codec_id); //codec_id = PCMA

             pjmedia_codec_mgr *codec_mgr = pjmedia_endpt_get_codec_mgr(med_endpt);

 

             //OPTIONAL

             /* Configure codec priority (allowed values are: PJMEDIA_CODEC_PRIO_HIGHEST, PJMEDIA_CODEC_PRIO_NEXT_HIGHEST, PJMEDIA_CODEC_PRIO_NORMAL, PJMEDIA_CODEC_PRIO_LOWEST, PJMEDIA_CODEC_PRIO_DISABLED) */

             status = pjmedia_codec_mgr_set_codec_priority(codec_mgr, &str_codec_id, PJMEDIA_CODEC_PRIO_HIGHEST);

             if (status != PJ_SUCCESS) {

                    return status;

             }

 

             status = pjmedia_codec_mgr_find_codecs_by_id(codec_mgr, &str_codec_id, &count, &codec_info, NULL);

             if (status != PJ_SUCCESS) {

                    return status;

             }

       }

       else {

             /* Default to pcmu */

             status = pjmedia_codec_mgr_get_codec_info(pjmedia_endpt_get_codec_mgr(med_endpt), 0, &codec_info);

             if (status != PJ_SUCCESS) {

                    return status;

             }

       }

 

Thanks in advice.

 

Best Regards

Ll

_______________________________________________
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