|
// 根据配置文件配置视频参数
private void ApplyVideoConfig() {
ConfigEntity configEntity = ConfigService.LoadConfig(this);
if(configEntity.configMode == 1) // 自定义视频参数配置
{
// 设置本地视频编码的码率(如果码率为0,则表示使用质量优先模式)
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_BITRATECTRL, configEntity.videoBitrate);
if(configEntity.videoBitrate==0)
{
// 设置本地视频编码的质量
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_QUALITYCTRL, configEntity.videoQuality);
}
// 设置本地视频编码的帧率
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_FPSCTRL, configEntity.videoFps);
// 设置本地视频编码的关键帧间隔
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_GOPCTRL, configEntity.videoFps*4);
// 设置本地视频采集分辨率
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_WIDTHCTRL, configEntity.resolution_width);
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_HEIGHTCTRL, configEntity.resolution_height);
// 设置视频编码预设参数(值越大,编码质量越高,占用CPU资源也会越高)
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_PRESETCTRL, configEntity.videoPreset);
}
// 让视频参数生效
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_APPLYPARAM, configEntity.configMode);
// P2P设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_NETWORK_P2PPOLITIC, configEntity.enableP2P);
// 本地视频Overlay模式设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_OVERLAY, configEntity.videoOverlay);
// 回音消除设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_AUDIO_ECHOCTRL, configEntity.enableAEC);
// 平台硬件编码设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_CORESDK_USEHWCODEC, configEntity.useHWCodec);
// 视频旋转模式设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_ROTATECTRL, configEntity.videorotatemode);
// 视频采集驱动设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_CAPDRIVER, configEntity.videoCapDriver);
// 本地视频采集偏色修正设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_FIXCOLORDEVIA, configEntity.fixcolordeviation);
// 视频显示驱动设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_VIDEOSHOW_DRIVERCTRL, configEntity.videoShowDriver);
// 音频播放驱动设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_AUDIO_PLAYDRVCTRL, configEntity.audioPlayDriver);
// 音频采集驱动设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_AUDIO_RECORDDRVCTRL, configEntity.audioRecordDriver);
// 视频GPU渲染设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_VIDEOSHOW_GPUDIRECTRENDER, configEntity.videoShowGPURender);
// 本地视频自动旋转设置
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_AUTOROTATION, configEntity.videoAutoRotation);
}
public static ConfigEntity LoadConfig(Context context)
{
ConfigEntity configEntity = new ConfigEntity();
SharedPreferences share = context.getSharedPreferences("perference", Context.MODE_WORLD_WRITEABLE);
configEntity.name = share.getString("name", "");
configEntity.password = share.getString("password", "");
configEntity.IsSaveNameAndPw = share.getString("IsSaveNameAndPw", "").equals("1") ? true : false;
// configEntity.ip = share.getString("ip", "192.168.7.95");
configEntity.ip = share.getString("ip", "192.168.8.209");
// configEntity.ip = share.getString("ip", "192.168.7.115");
configEntity.port = share.getInt("port", 8906);
configEntity.configMode = share.getInt("configMode", ConfigEntity.VIDEO_MODE_SERVERCONFIG);
configEntity.resolution_width = share.getInt("resolution_width", 320);
configEntity.resolution_height = share.getInt("resolution_height", 240);
configEntity.videoBitrate = share.getInt("videoBitrate", 200*1000);
configEntity.videoFps = share.getInt("videoFps", 20);
configEntity.videoQuality = share.getInt("videoQuality", ConfigEntity.VIDEO_QUALITY_BEST);
configEntity.videoPreset = share.getInt("videoPreset", 3);
configEntity.videoOverlay = share.getInt("videoOverlay", 1);
configEntity.videorotatemode = share.getInt("VideoRotateMode", 0);
configEntity.videoCapDriver = share.getInt("VideoCapDriver", AnyChatDefine.VIDEOCAP_DRIVER_JAVA);
configEntity.fixcolordeviation = share.getInt("FixColorDeviation", 0);
configEntity.videoShowGPURender = share.getInt("videoShowGPURender", 0);
configEntity.videoAutoRotation = share.getInt("videoAutoRotation", 1);
configEntity.enableP2P = share.getInt("enableP2P", 1);
configEntity.useARMv6Lib = share.getInt("useARMv6Lib", 0);
configEntity.enableAEC = share.getInt("enableAEC", 1);
configEntity.useHWCodec = share.getInt("useHWCodec", 0);
configEntity.videoShowDriver = share.getInt("videoShowDriver", AnyChatDefine.VIDEOSHOW_DRIVER_JAVA);
configEntity.audioPlayDriver = share.getInt("audioPlayDriver", AnyChatDefine.AUDIOPLAY_DRIVER_JAVA);
configEntity.audioRecordDriver = share.getInt("audioRecordDriver", AnyChatDefine.AUDIOREC_DRIVER_JAVA);
return configEntity;
}
这是配置 |
|