Here are the steps to integrate OpenH264 Library to any Xcode Project:
- Download or Clone OpenH264 Library from this link: https://github.com/cisco/openh264
- Create Xcode project selecting IOS Application, Objective C and other mandatory options.
- Place OpenH264 Library with all files and folders in project root directory. For example my IOS application is at directory /user/rajib/HelloApp/HelloApp.xcodeproj, and OpenH264 Library kept in /user/rajib/HelloApp/OpenH264Library .
- Now open terminal and enable root mode.
- Go to the directory where OpenH264Library was kept and make with following command: ->sudo make OS=ios ARCH=amrv7 install
- Now go to Project Build Setting and find Header Search Path attribute. Add following header paths in separate lines to that attribute.
$(inherited), "$(SRCROOT)/OpenH264Library/codec/encoder/core/inc", "$(SRCROOT)/OpenH264Library/codec/processing/interface", "$(SRCROOT)/OpenH264Library/codec/common/inc", "$(SRCROOT)/OpenH264Library/codec/api/svc",
- Now we have to integrate 3 more Xcode Projects named common.xcodeproj, processing.xcodeproj, welsenc.xcodeproj inside our HelloApp project. All these .xcodeproj files will be found inside OpenH264Library. We have to find these .xcodeproj files with that name inside OpenH264Library and just drag and drop these files inside our HelloApp project.
- Now Go to Project Build Phase and find Target Dependencies attribute. Add welsenc, processing, common project from the work place.
- Try to build this project, then these 3 project will compile and execute and we will find 3 static library in our work place.
- Now go to project Build phase again and find Link Binary with Libraries attribute. Add libwelsenc.a, libprocessing.a, libcommon.a static libraries from the workplace.
That's it... this is the procedure of building and linking openh264 library.
Now you can easily call openh264 library functions. Here I am giving a simple working code of Encoder initialization calling OpenH264 library function.
//Adding Header files
#include "codec_api.h"
#include "codec_def.h"
//Calling OpenH264 Library function to initialize Encoder
- (IBAction)EncoderTestBtn:(id)sender {
NSLog(@"Inside EncoderTestBtn");
ISVCEncoder *pEncoder = NULL;
int iRet = -1;
iRet = WelsCreateSVCEncoder(&pEncoder);
if(iRet == 0)
{
NSLog(@"Rajib_Check: Encoder Initialization SUCCESSFUL");
}
else
{
NSLog(@"Rajib_Check: ERROR--> iRet returned with = %d", iRet);
}
}