Commit 02e5e52c authored by Edward Wang's avatar Edward Wang

Add network caching option

Close #7792
parent a25cfd4a
......@@ -9,7 +9,8 @@ Main Application:
* Fix opening MRLs and video streaming
* Fix many crashes and warnings
* New equalizer
* Option for frame skip to improve performance
* Add an option for frame skip to improve performance
* Add an option to set network caching
Changes between 0.1.1 and 0.1.2:
......
......@@ -229,6 +229,14 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
snprintf(deblockstr, 2, "%d", deblocking);
LOGD("Using deblocking level %d", deblocking);
methodId = (*env)->GetMethodID(env, cls, "getNetworkCaching", "()I");
int networkCaching = (*env)->CallIntMethod(env, thiz, methodId);
char networkCachingstr[25] = "0";
if(networkCaching > 0) {
snprintf(networkCachingstr, 25, "--network-caching=%d", networkCaching);
LOGD("Using network caching of %d ms", networkCaching);
}
methodId = (*env)->GetMethodID(env, cls, "getChroma", "()Ljava/lang/String;");
jstring chroma = (*env)->CallObjectMethod(env, thiz, methodId);
const char *chromastr = (*env)->GetStringUTFChars(env, chroma, 0);
......@@ -261,6 +269,7 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
"--avcodec-skiploopfilter", deblockstr,
"--avcodec-skip-frame", enable_frame_skip ? "4" : "0",
"--avcodec-skip-idct", enable_frame_skip ? "4" : "0",
(networkCaching > 0) ? networkCachingstr : "",
use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
"--androidsurface-chroma", chromastr != NULL && chromastr[0] != 0 ? chromastr : "RV32",
};
......
......@@ -220,6 +220,8 @@
<string name="aout_audiotrack">AudioTrack (native)</string>
<string name="aout_audiotrack_java">AudioTrack (Java)</string>
<string name="aout_opensles">OpenSL ES</string>
<string name="network_caching">Network caching value</string>
<string name="network_caching_summary">The amount of time to buffer network media (in ms). Does not work with hardware decoding. Leave blank to reset.</string>
<string name="enable_verbose_mode">Verbose</string>
<string name="enable_verbose_mode_summary">Increase the verbosity (logcat)</string>
<string name="set_locale">Set locale</string>
......
......@@ -101,6 +101,13 @@
android:summary="@string/aout_summary"
android:title="@string/aout" />
<EditTextPreference
android:key="network_caching"
android:summary="@string/network_caching_summary"
android:title="@string/network_caching"
android:defaultValue=""
android:maxLength="5" />
<EditTextPreference
android:defaultValue=""
android:key="set_locale"
......
......@@ -64,6 +64,7 @@ public class LibVLC {
private boolean verboseMode = true;
private float[] equalizer = null;
private boolean frameSkip = false;
private int networkCaching = 0;
/** Check in libVLC already initialized otherwise crash */
private boolean mIsInitialized = false;
......@@ -313,6 +314,14 @@ public class LibVLC {
this.frameSkip = frameskip;
}
public int getNetworkCaching() {
return this.networkCaching;
}
public void setNetworkCaching(int networkcaching) {
this.networkCaching = networkcaching;
}
/**
* Initialize the libVLC class
*/
......
......@@ -138,8 +138,14 @@ public class Util {
catch(NumberFormatException nfe) {
deblocking = -1;
}
int networkCaching = pref.getInt("network_caching_value", 0);
if(networkCaching > 60000)
networkCaching = 60000;
else if(networkCaching < 0)
networkCaching = 0;
instance.setAout(aout);
instance.setDeblocking(deblocking);
instance.setNetworkCaching(networkCaching);
}
/** Print an on-screen message to alert the user */
......
......@@ -192,6 +192,24 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
return true;
}
});
// Network caching
EditTextPreference networkCachingPref = (EditTextPreference) findPreference("network_caching");
networkCachingPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(PreferencesActivity.this);
SharedPreferences.Editor editor = sharedPrefs.edit();
try {
editor.putInt("network_caching_value", Integer.parseInt((String)newValue));
} catch(NumberFormatException e) {
editor.putInt("network_caching_value", 0);
editor.putString("network_caching", "0");
}
editor.commit();
return true;
}
});
/*** SharedPreferences Listener to apply changes ***/
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
......@@ -203,11 +221,12 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
if(key.equalsIgnoreCase("enable_iomx")
|| key.equalsIgnoreCase("subtitles_text_encoding")
|| key.equalsIgnoreCase("aout")
|| key.equalsIgnoreCase("chroma_format")
|| key.equalsIgnoreCase("deblocking")
|| key.equalsIgnoreCase("enable_frame_skip")
|| key.equalsIgnoreCase("enable_time_stretching_audio")
|| key.equalsIgnoreCase("deblocking")
|| key.equalsIgnoreCase("chroma_format")
|| key.equalsIgnoreCase("enable_verbose_mode")) {
|| key.equalsIgnoreCase("enable_verbose_mode")
|| key.equalsIgnoreCase("network_caching")) {
Util.updateLibVlcSettings(sharedPreferences);
LibVLC.restart(this);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment