| 6 | |
| 7 | '''Opus Codec Settings''' |
| 8 | {{{ |
| 9 | #!comment |
| 10 | When 2.5 is released, provide a link to the doxygen doc instead: [http://www.pjsip.org/docs/latest/pjmedia/docs/html/group__PJMED__OPUS.htm] |
| 11 | }}} |
| 12 | |
| 13 | General codec settings for this codec such as VAD and PLC can be |
| 14 | manipulated through the setting field in #pjmedia_codec_param |
| 15 | (see the documentation of #pjmedia_codec_param for more info). |
| 16 | |
| 17 | For Opus codec specific settings, such as sample rate, |
| 18 | channel count, bit rate, complexity, and CBR, can be configured |
| 19 | in #pjmedia_codec_opus_config. |
| 20 | The default setting of sample rate is specified in |
| 21 | #PJMEDIA_CODEC_OPUS_DEFAULT_SAMPLE_RATE. The default setting of |
| 22 | bitrate is specified in #PJMEDIA_CODEC_OPUS_DEFAULT_BIT_RATE. |
| 23 | And the default setting of complexity is specified in |
| 24 | #PJMEDIA_CODEC_OPUS_DEFAULT_COMPLEXITY. |
| 25 | |
| 26 | After modifying any of these settings, application needs to call |
| 27 | #pjmedia_codec_opus_set_default_param(), which will generate the |
| 28 | appropriate decoding fmtp attributes. |
| 29 | |
| 30 | Here is an example of modifying the codec settings: |
| 31 | {{{ |
| 32 | pjmedia_codec_param param; |
| 33 | pjmedia_codec_opus_config opus_cfg; |
| 34 | |
| 35 | pjmedia_codec_mgr_get_default_param(.., ¶m); |
| 36 | pjmedia_codec_opus_get_config(&opus_cfg); |
| 37 | ... |
| 38 | // Set VAD |
| 39 | param.setting.vad = 1; |
| 40 | // Set PLC |
| 41 | param.setting.vad = 1; |
| 42 | // Set sample rate |
| 43 | opus_cfg.sample_rate = 16000; |
| 44 | // Set channel count |
| 45 | opus_cfg.channel_cnt = 2; |
| 46 | // Set bit rate |
| 47 | opus_cfg.bit_rate = 20000; |
| 48 | ... |
| 49 | pjmedia_codec_opus_set_default_param(&opus_cfg, ¶m); |
| 50 | }}} |