Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#1947 closed enhancement (fixed)

Support for OpenH264 v1.6.0 codec

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

Description (last modified by ming)

Support for the open source implementation of H.264 codec from http://www.openh264.org.

Requirement:

  • OpenH264 library version 1.6 release (download here)
  • To avoid conflict, it is recommended to cleanly remove ALL previous/other versions of OpenH264 on your machine, especially if you previously used OpenH264 version 1.0 following the ticket #1758. (If you encounter runtime error openh264.cpp .......SVC encoder Initialize failed, rc=1, it is likely caused by this issue).

Implementation features:

  • Constrained Baseline, default level=30 (0x1e)
  • packetization modes: 1, 0
  • key frame request and indication
  • obey remote's fmtp

Notes:

  • currently transmission is hard coded to use only single NAL (packetization mode 0) regardless of remote's fmtp for interop reason. The same is also done in ffmpeg wrapper.
  • whole frame for file encoding is implemented but currently doesn't work

Below are the steps to use the codec:

For GNU targets:

  1. Build the OpenH264 library and install it to a directory (with "make install"). By default it installs to /usr/local. You need to modify the Makefile to install it to different location (=prefix).
  2. Run PJSIP's configure. If you specify alternate location (prefix) to OpenH264 installation, specify the location with --with-openh264 option. E.g.:
    ./configure --with-openh264=/home/user/opt
    
  3. If you specify an alternate OpenH264 location, add the location path (the path which contains libopenh264*.dylib) to your OS dynamic library path. For example, on Mac:
    export DYLD_LIBRARY_PATH=/Users/teluu/openh264-1.6-mac/lib:$DYLD_LIBRARY_PATH
    

For Visual Studio:

  1. Build the OpenH264 library with MinGW make & gcc, and install it to a directory (with "make install"). By default it installs to /usr/local. You need to modify the Makefile to install it to different location (=prefix).
  2. Create openh264.lib from openh264.def, note that the static lib libopenh264.a outputted by MinGW gcc cannot be used by VS, so we are going to use the dynamic lib version instead:
    1. open 'Visual Studio command prompt', e.g: Win Start Menu -> MS VS 2005 -> VS Tools -> VS 2005 Command Prompt
    2. change dir to OpenH264 source root directory
    3. run "lib /def:openh264.def", this will create openh264.lib, copy this file to the OpenH264 installation directory
    4. rename or copy libopenh264.dll to openh264.dll and put it in the system path
  3. Add OpenH264 include and library installation paths to Visual Studio search path settings.
  4. Add this to your config_site.h:
    #define PJMEDIA_HAS_OPENH264_CODEC		1
    

For iOS:

  1. Modify the Makefile to install it to a custom folder (find the string PREFIX and modify the value), for example: PREFIX=ios_local. Build the OpenH264 library (example: make OS="ios" ARCH=armv7). Install it to the specified directory (example: make OS="ios" ARCH=armv7 install).
  2. Run PJSIP's configure with --with-openh264 option. E.g.:
    ./configure --with-openh264=/Users/teluu/openh264-iphone/ios_local
    
  3. Copy libopenh264.a to your XCode project directory. Create a folder ios_local/lib inside your XCode project directory (example: for our ipjsua sample app, the directory will be: (PJPROJECT_DIR)/pjsip-apps/src/pjsua/ios/ios_local/lib). Then copy OpenH264 dynamic library files to the folder. Example:
    cp openh264-iphone/ios_local/lib/libopenh264.a pjproject-iphone/pjsip-apps/src/pjsua/ios/
    cp openh264-iphone/ios_local/lib/*.dylib pjproject-iphone/pjsip-apps/src/pjsua/ios/ios_local/lib
    
  4. Add libopenh264.a and iOS-SDK's libstdc++.dylib to your application project in XCode.

For Android:

  1. Build the OpenH264 library according to the instructions provided in README.md at the OpenH264 directory. Example for arm64: make OS=android NDKROOT=/home/android-ndk-r13b TARGET=android-15 ARCH=arm64 NDKLEVEL=21 (note that due to the different compiler used (gcc/clang) and system folder structure, using newer NDK may require some changes in the OpenH264 source base). There may be a failure when building the Open264 sample app, but it can be safely ignored since the library itself must have been successfully built by that point.
  2. Modify the Makefile to install it to a different location (modify the "prefix") and run "make install". Manually copy libopenh264.so to "prefix"/lib, if necessary.
  3. Copy libopenh264.so to your Android application library directory (such as jniLibs/armeabi, or jniLibs/arm64-v8a).

Change History (7)

comment:1 Changed 8 years ago by ming

  • Description modified (diff)

comment:2 Changed 8 years ago by ming

  • Milestone set to release-2.6

comment:3 Changed 8 years ago by ming

In r5405:

Fixed #1947: Support for OpenH264 v1.6.0 codec

Thanks to Marc Etcheverry for the patch.

comment:4 Changed 8 years ago by ming

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

comment:5 Changed 8 years ago by ming

  • Description modified (diff)

comment:6 Changed 5 years ago by ming

  • Description modified (diff)

comment:7 Changed 5 years ago by ming

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