Ticket #1904 (closed enhancement: fixed)

Opened 18 months ago

Last modified 11 months ago

Support for Opus codec

Reported by: ming Owned by: nanang
Priority: normal Milestone: release-2.5
Component: pjmedia Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no

Description (last modified by nanang) (diff)

Opus is a totally open, royalty-free, highly versatile audio codec. Opus is unmatched for interactive speech and music transmission over the Internet, but is also intended for storage and streaming applications. It is standardized by the Internet Engineering Task Force (IETF) as RFC 6716 which incorporated technology from Skype's SILK codec and Xiph.Org's CELT codec. (From http://www.opus-codec.org)

How to use:

  1. Download Opus source code from here (latest stable release 1.1.2 or above is recommended).
  2. Build Opus:
    1. For iOS, get the build script here or here.
    2. For Android, get the Android makefile attached in this ticket (tested with Opus 1.1.2), or check here
      • create jni folder in Opus root directory and put Android.mk from this ticket attachment in there
      • run ndk-build from Opus root directory
      • make a new folder called opus-dev-lib and create subfolders: include/opus and lib in it
      • copy Opus header files from [OPUS_ROOT_DIR]/include to opus-dev-lib/include/opus and libopus.a file from [OPUS_ROOT_DIR]/obj/local/armeabi to opus-dev-lib/lib
    3. For GNU build system, e.g: *nix, Linux, MacOS, just invoke ./configure, make, and make install.
    4. For Windows:
      • use GNU build tools such as MinGW, or
      • use VS solution & projects provided by Opus (usually in win32 dir), then modify the following line in the end of pjmedia/src/pjmedia-codec/opus.c appropriately:
         #   pragma comment(lib, "libopus.a")
        
  1. Run PJSIP's configure script with the option --with-opus=your_opus_installation_dir. For example on Android platform:
    ./configure-android --with-opus=[absolute-path-to]/opus-dev-lib
    

Opus Codec Settings

General codec settings for this codec such as VAD and PLC can be manipulated through the setting field in #pjmedia_codec_param (see the documentation of #pjmedia_codec_param for more info).

For Opus codec specific settings, such as sample rate, channel count, bit rate, complexity, and CBR, can be configured in #pjmedia_codec_opus_config. The default setting of sample rate is specified in #PJMEDIA_CODEC_OPUS_DEFAULT_SAMPLE_RATE. The default setting of bitrate is specified in #PJMEDIA_CODEC_OPUS_DEFAULT_BIT_RATE. And the default setting of complexity is specified in #PJMEDIA_CODEC_OPUS_DEFAULT_COMPLEXITY.

After modifying any of these settings, application needs to call #pjmedia_codec_opus_set_default_param(), which will generate the appropriate decoding fmtp attributes.

Here is an example of modifying the codec settings:

   pjmedia_codec_param param;
   pjmedia_codec_opus_config opus_cfg;

   pjmedia_codec_mgr_get_default_param(.., &param);
   pjmedia_codec_opus_get_config(&opus_cfg);
   ...
   // Set VAD
   param.setting.vad = 1;
   // Set PLC
   param.setting.vad = 1;
   // Set sample rate
   opus_cfg.sample_rate = 16000;
   // Set channel count
   opus_cfg.channel_cnt = 2;
   // Set bit rate
   opus_cfg.bit_rate = 20000;
   ...
   pjmedia_codec_opus_set_default_param(&opus_cfg, &param);

Attachments

Android.mk (1.0 KB) - added by nanang 13 months ago.
Android Makefile (tested with Opus 1.1.2)

Change History

comment:1 Changed 18 months ago by ming

  • Status changed from new to closed
  • Resolution set to fixed

In 5239:

Fixed #1904: Support for Opus codec

comment:2 Changed 18 months ago by ming

  • Description modified (diff)

comment:3 Changed 13 months ago by nanang

  • Description modified (diff)

Changed 13 months ago by nanang

Android Makefile (tested with Opus 1.1.2)

comment:4 Changed 11 months ago by nanang

  • Description modified (diff)
Note: See TracTickets for help on using tickets.