1.第一步
config_site中添加支持G729
#define PJMEDIA_HAS_BCG729 1
2.第二步
下载BCG729源代码到本地(git clone git://git.linphone.org/bcg729.git)
3.第三步
运行PJSIP的configure命令时设置bcg729的源代码位置,参考:https://trac.pjsip.org/repos/ticket/2029
./configure --with-bcg729
4.第四步
编译g729,参考:https://github.com/BelledonneCommunications/bcg729
cmake . -DCMAKE_INSTALL_PREFIX=/Users/xx/Documents/ThirdParty/bcg729/Output/lib
make
make install
5.第五步
复制编译好的libbcg729.a和BCG729源代码中的include中的decoder.h encoder.h到项目中就可以了
6.检查是否支持
const unsigned kCodecInfoSize = 64;
pjsua_codec_info codecInfo[kCodecInfoSize];
unsigned codecCount = kCodecInfoSize;
pj_status_t status = pjsua_enum_codecs(codecInfo, &codecCount);
if (status != PJ_SUCCESS) {
NSLog(@"Error getting list of codecs");
} else {
for (NSUInteger i = 0; i < codecCount; i++) {
NSString *codecIdentifier = [NSString stringWithPJString:codecInfo[i].codec_id];
NSLog(@"codec = %@",codecIdentifier);
}
}
+ (NSString *)stringWithPJString:(pj_str_t)pjString {
NSString *result = [[NSString alloc] initWithBytes:pjString.ptr length:(NSUInteger)pjString.slen encoding:NSUTF8StringEncoding];
return result ?: @"";
}
7.第七步 PJSIP priorityForCodec方法中添加@"G729/8000/1": @(133)