[Android] LibVLC: add setUserAgent
Thomas Guillem
git at videolan.org
Mon Aug 24 17:12:29 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Aug 24 17:11:48 2015 +0200| [54bc331900a3608e69c294830b7b021614733f28] | committer: Thomas Guillem
LibVLC: add setUserAgent
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=54bc331900a3608e69c294830b7b021614733f28
---
libvlc/jni/libvlcjni.c | 26 ++++++++++++++++++++++++++
libvlc/src/org/videolan/libvlc/LibVLC.java | 12 ++++++++++++
2 files changed, 38 insertions(+)
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index e6215af..1a4639d 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -382,6 +382,32 @@ jstring Java_org_videolan_libvlc_LibVLC_changeset(JNIEnv* env, jobject thiz)
return (*env)->NewStringUTF(env, libvlc_get_changeset());
}
+void Java_org_videolan_libvlc_LibVLC_nativeSetUserAgent(JNIEnv* env,
+ jobject thiz,
+ jstring jname,
+ jstring jhttp)
+{
+ vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
+ const char *psz_name, *psz_http;
+
+ if (!p_obj)
+ return;
+
+ psz_name = jname ? (*env)->GetStringUTFChars(env, jname, 0) : NULL;
+ psz_http = jhttp ? (*env)->GetStringUTFChars(env, jhttp, 0) : NULL;
+
+ if (psz_http && psz_http)
+ libvlc_set_user_agent(p_obj->u.p_libvlc, psz_name, psz_http);
+
+ if (psz_name)
+ (*env)->ReleaseStringUTFChars(env, jname, psz_name);
+ if (psz_http)
+ (*env)->ReleaseStringUTFChars(env, jhttp, psz_http);
+
+ if (!psz_name || !psz_http)
+ throw_IllegalArgumentException(env, "name or http invalid");
+}
+
/* used by opensles module */
int aout_get_native_sample_rate(void)
{
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index bd0315a..a712c06 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -136,9 +136,21 @@ public class LibVLC extends VLCObject<LibVLC.Event> {
sOnNativeCrashListener.onNativeCrash();
}
+ /**
+ * Sets the application name. LibVLC passes this as the user agent string
+ * when a protocol requires it.
+ *
+ * @param name human-readable application name, e.g. "FooBar player 1.2.3"
+ * @param http HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"
+ */
+ public void setUserAgent(String name, String http){
+ nativeSetUserAgent(name, http);
+ }
+
/* JNI */
private native void nativeNew(String[] options);
private native void nativeRelease();
+ private native void nativeSetUserAgent(String name, String http);
/* Load library before object instantiation */
static {
More information about the Android
mailing list