Add video codecs preference. Integrate JNI code for getting list of available video codecs.
This commit is contained in:
parent
726422566e
commit
1d7b076475
6 changed files with 81 additions and 39 deletions
|
@ -1,5 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="pref_video_codec_h263_title">H263</string>
|
||||||
|
<string name="pref_video_codec_h263_key">pref_video_codec_h263_key</string>
|
||||||
|
<string name="pref_video_codec_mpeg4_title">MPEG4</string>
|
||||||
|
<string name="pref_video_codec_mpeg4_key">pref_video_codec_mpeg4_key</string>
|
||||||
|
<string name="pref_video_codec_h264_title">H264</string>
|
||||||
|
<string name="pref_video_codec_h264_key">pref_video_codec_h264_key</string>
|
||||||
|
<string name="pref_video_codecs_title">Video codecs</string>
|
||||||
|
<string name="pref_video_codecs_key">pref_video_codecs_key</string>
|
||||||
<string name="menu_videocall_back_to_dialer_title">Display dialer</string>
|
<string name="menu_videocall_back_to_dialer_title">Display dialer</string>
|
||||||
<string name="menu_videocall_change_resolution_when_low_resolution">Try High resolution</string>
|
<string name="menu_videocall_change_resolution_when_low_resolution">Try High resolution</string>
|
||||||
<string name="menu_videocall_change_resolution_when_high_resolution">Low resolution</string>
|
<string name="menu_videocall_change_resolution_when_high_resolution">Low resolution</string>
|
||||||
|
@ -44,7 +52,7 @@
|
||||||
<string name="pref_codec_speex16">speex 16 Khz</string>
|
<string name="pref_codec_speex16">speex 16 Khz</string>
|
||||||
<string name="pref_codec_speex16_key">pref_codec_speex16_key</string>
|
<string name="pref_codec_speex16_key">pref_codec_speex16_key</string>
|
||||||
<string name="pref_codec_speex32_key">pref_codec_speex32_key</string>
|
<string name="pref_codec_speex32_key">pref_codec_speex32_key</string>
|
||||||
<string name="pref_codecs">Codecs</string>
|
<string name="pref_codecs">Audio Codecs</string>
|
||||||
<string name="pref_codecs_key">pref_codecs_key</string>
|
<string name="pref_codecs_key">pref_codecs_key</string>
|
||||||
<string name="place_call_chooser">Place a call</string>
|
<string name="place_call_chooser">Place a call</string>
|
||||||
<string name="pref_debug">Debug</string>
|
<string name="pref_debug">Debug</string>
|
||||||
|
|
|
@ -39,6 +39,11 @@
|
||||||
<CheckBoxPreference android:defaultValue="true" android:title="@string/pref_video_enable_title" android:key="@string/pref_video_enable_key" />
|
<CheckBoxPreference android:defaultValue="true" android:title="@string/pref_video_enable_title" android:key="@string/pref_video_enable_key" />
|
||||||
<PreferenceScreen android:title="@string/pref_video_settings_title" android:dependency="@string/pref_video_enable_key" android:shouldDisableView="true"><CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key" android:defaultValue="false" android:title="@string/pref_video_initiate_call_with_video_title" android:summary="@string/pref_video_initiate_call_with_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
|
<PreferenceScreen android:title="@string/pref_video_settings_title" android:dependency="@string/pref_video_enable_key" android:shouldDisableView="true"><CheckBoxPreference android:key="@string/pref_video_initiate_call_with_video_key" android:defaultValue="false" android:title="@string/pref_video_initiate_call_with_video_title" android:summary="@string/pref_video_initiate_call_with_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
|
||||||
<CheckBoxPreference android:key="@string/pref_video_automatically_share_my_video_key" android:title="@string/pref_video_automatically_share_my_video_title" android:defaultValue="false" android:summary="@string/pref_video_automatically_share_my_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
|
<CheckBoxPreference android:key="@string/pref_video_automatically_share_my_video_key" android:title="@string/pref_video_automatically_share_my_video_title" android:defaultValue="false" android:summary="@string/pref_video_automatically_share_my_video" android:dependency="@string/pref_video_enable_key"></CheckBoxPreference>
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
|
<PreferenceScreen android:dependency="@string/pref_video_enable_key" android:shouldDisableView="true" android:key="@string/pref_video_codecs_key" android:title="@string/pref_video_codecs_title"><CheckBoxPreference android:key="@string/pref_video_codec_h264_key" android:title="@string/pref_video_codec_h264_title" android:defaultValue="true"></CheckBoxPreference>
|
||||||
|
<CheckBoxPreference android:key="@string/pref_video_codec_mpeg4_key" android:title="@string/pref_video_codec_mpeg4_title" android:defaultValue="true"></CheckBoxPreference>
|
||||||
|
<CheckBoxPreference android:key="@string/pref_video_codec_h263_key" android:title="@string/pref_video_codec_h263_title" android:enabled="false" android:defaultValue="false" android:selectable="false"></CheckBoxPreference>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,34 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void enableDisableAudioCodec(String codec, int rate, int key) throws LinphoneCoreException {
|
||||||
|
PayloadType pt = mLinphoneCore.findPayloadType(codec, rate);
|
||||||
|
if (pt !=null) {
|
||||||
|
boolean enable= mPref.getBoolean(getString(key),false);
|
||||||
|
mLinphoneCore.enablePayloadType(pt, enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enableDisableVideoCodecs(PayloadType videoCodec) throws LinphoneCoreException {
|
||||||
|
String mime = videoCodec.getMime();
|
||||||
|
int key;
|
||||||
|
|
||||||
|
if ("MP4V-ES".equals(mime)) {
|
||||||
|
key = R.string.pref_video_codec_mpeg4_key;
|
||||||
|
} else if ("H264".equals(mime)) {
|
||||||
|
key = R.string.pref_video_codec_h264_key;
|
||||||
|
} else if ("H263-1998".equals(mime)) {
|
||||||
|
key = R.string.pref_video_codec_h263_key;
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "Unhandled video codec " + mime);
|
||||||
|
mLinphoneCore.enablePayloadType(videoCodec, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enable= mPref.getBoolean(getString(key),false);
|
||||||
|
mLinphoneCore.enablePayloadType(videoCodec, enable);
|
||||||
|
}
|
||||||
|
|
||||||
public void initFromConf() throws LinphoneConfigException, LinphoneException {
|
public void initFromConf() throws LinphoneConfigException, LinphoneException {
|
||||||
//traces
|
//traces
|
||||||
boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false);
|
boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false);
|
||||||
|
@ -272,40 +299,16 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//codec config
|
//codec config
|
||||||
PayloadType lPt = mLinphoneCore.findPayloadType("speex", 32000);
|
enableDisableAudioCodec("speex", 32000, R.string.pref_codec_speex32_key);
|
||||||
if (lPt !=null) {
|
enableDisableAudioCodec("speex", 16000, R.string.pref_codec_speex8_key);
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex32_key),false);
|
enableDisableAudioCodec("speex", 8000, R.string.pref_codec_speex8_key);
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
enableDisableAudioCodec("iLBC", 8000, R.string.pref_codec_ilbc_key);
|
||||||
}
|
enableDisableAudioCodec("GSM", 8000, R.string.pref_codec_gsm_key);
|
||||||
lPt = mLinphoneCore.findPayloadType("speex", 16000);
|
enableDisableAudioCodec("PCMU", 8000, R.string.pref_codec_pcmu_key);
|
||||||
if (lPt !=null) {
|
enableDisableAudioCodec("PCMA", 8000, R.string.pref_codec_pcma_key);
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex16_key),false);
|
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
for (PayloadType videoCodec : mLinphoneCore.listVideoCodecs()) {
|
||||||
}
|
enableDisableVideoCodecs(videoCodec);
|
||||||
lPt = mLinphoneCore.findPayloadType("speex", 8000);
|
|
||||||
if (lPt !=null) {
|
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_speex8_key),false);
|
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
|
||||||
}
|
|
||||||
lPt = mLinphoneCore.findPayloadType("iLBC", 8000);
|
|
||||||
if (lPt !=null) {
|
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_ilbc_key),false);
|
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
|
||||||
}
|
|
||||||
lPt = mLinphoneCore.findPayloadType("GSM", 8000);
|
|
||||||
if (lPt !=null) {
|
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_gsm_key),false);
|
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
|
||||||
}
|
|
||||||
lPt = mLinphoneCore.findPayloadType("PCMU", 8000);
|
|
||||||
if (lPt !=null) {
|
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_pcmu_key),false);
|
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
|
||||||
}
|
|
||||||
lPt = mLinphoneCore.findPayloadType("PCMA", 8000);
|
|
||||||
if (lPt !=null) {
|
|
||||||
boolean enable= mPref.getBoolean(getString(R.string.pref_codec_pcma_key),false);
|
|
||||||
mLinphoneCore.enablePayloadType(lPt, enable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -398,6 +401,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected LinphoneCore getLinphoneCore() {
|
protected LinphoneCore getLinphoneCore() {
|
||||||
return mLinphoneCore;
|
return mLinphoneCore;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,10 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
private native void setDownloadBandwidth(long nativePtr, int bw);
|
private native void setDownloadBandwidth(long nativePtr, int bw);
|
||||||
private native void setPreferredVideoSize(long nativePtr, int width, int heigth);
|
private native void setPreferredVideoSize(long nativePtr, int width, int heigth);
|
||||||
private native int[] getPreferredVideoSize(long nativePtr);
|
private native int[] getPreferredVideoSize(long nativePtr);
|
||||||
|
|
||||||
private native void setRing(long nativePtr, String path);
|
private native void setRing(long nativePtr, String path);
|
||||||
private native String getRing(long nativePtr);
|
private native String getRing(long nativePtr);
|
||||||
|
private native long[] listVideoPayloadTypes(long nativePtr);
|
||||||
|
|
||||||
|
|
||||||
private static String TAG = "LinphoneCore";
|
private static String TAG = "LinphoneCore";
|
||||||
|
|
||||||
|
@ -415,4 +416,17 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PayloadType[] listVideoCodecs() {
|
||||||
|
long[] typesPtr = listVideoPayloadTypes(nativePtr);
|
||||||
|
if (typesPtr == null) return null;
|
||||||
|
|
||||||
|
PayloadType[] codecs = new PayloadType[typesPtr.length];
|
||||||
|
|
||||||
|
for (int i=0; i < codecs.length; i++) {
|
||||||
|
codecs[i] = new PayloadTypeImpl(typesPtr[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return codecs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,21 @@ class PayloadTypeImpl implements PayloadType {
|
||||||
protected final long nativePtr;
|
protected final long nativePtr;
|
||||||
|
|
||||||
private native String toString(long ptr);
|
private native String toString(long ptr);
|
||||||
|
private native String getMime(long ptr);
|
||||||
|
private native int getRate(long ptr);
|
||||||
|
|
||||||
protected PayloadTypeImpl(long aNativePtr) {
|
protected PayloadTypeImpl(long aNativePtr) {
|
||||||
nativePtr = aNativePtr;
|
nativePtr = aNativePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRate() {
|
||||||
|
return getRate(nativePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMime() {
|
||||||
|
return getMime(nativePtr);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toString(nativePtr);
|
return toString(nativePtr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 656db4fa166ceeebd3258696a9cbddfbf6a1c024
|
Subproject commit 8b3112cca81a31e4b35b0c4e9e7c6217fefb5c4c
|
Loading…
Reference in a new issue