[Android] [PATCH] jni: Add HTTP reconnect option on LibVLC instantiation

Uwe L. Korn uwelk at xhochy.com
Sat Sep 20 17:35:59 CEST 2014


We are currently using this patch for Tomahawk-Android. An alternative
version could be that we simply support an arbitrary number of custom
attributes (i.e. an array of strings) via the LibVLC.java interface
instead of explicitly exposing each option.

Greetings to Dublin ;)

On 20/09/14 16:27, Uwe L. Korn wrote:
> ---
>  vlc-android/jni/libvlcjni.c                     | 6 ++++++
>  vlc-android/src/org/videolan/libvlc/LibVLC.java | 9 +++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
> index f621d92..df49f6e 100644
> --- a/vlc-android/jni/libvlcjni.c
> +++ b/vlc-android/jni/libvlcjni.c
> @@ -252,6 +252,9 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
>          LOGD("Using network caching of %d ms", networkCaching);
>      }
>  
> +    methodId = (*env)->GetMethodID(env, cls, "getHttpReconnect", "()Z");
> +    bool enable_http_reconnect = (*env)->CallBooleanMethod(env, thiz, methodId);
> +
>      methodId = (*env)->GetMethodID(env, cls, "getChroma", "()Ljava/lang/String;");
>      jstring chroma = (*env)->CallObjectMethod(env, thiz, methodId);
>      const char *chromastr = (*env)->GetStringUTFChars(env, chroma, 0);
> @@ -308,6 +311,9 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
>          /* XXX: we can't recover from direct rendering failure */
>          (hardwareAcceleration == HW_ACCELERATION_FULL) ? "" : "--no-mediacodec-dr",
>          (hardwareAcceleration == HW_ACCELERATION_FULL) ? "" : NO_IOMX_DR,
> +
> +        /* Reconnect on lost HTTP streams, e.g. network change */
> +        enable_http_reconnect ? "--http-reconnect" : "",
>      };
>      libvlc_instance_t *instance = libvlc_new(sizeof(argv) / sizeof(*argv), argv);
>  
> diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
> index cf1dbb5..8023e53 100644
> --- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
> +++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
> @@ -75,6 +75,7 @@ public class LibVLC {
>      private float[] equalizer = null;
>      private boolean frameSkip = false;
>      private int networkCaching = 0;
> +    private boolean httpReconnect = false;
>  
>      /** Path of application-specific cache */
>      private String mCachePath = "";
> @@ -372,6 +373,14 @@ public class LibVLC {
>          this.networkCaching = networkcaching;
>      }
>  
> +    public boolean getHttpReconnect() {
> +        return httpReconnect;
> +    }
> +
> +    public void setHttpReconnect(boolean httpReconnect) {
> +        this.httpReconnect = httpReconnect;
> +    }
> +
>      /**
>       * Initialize the libVLC class.
>       *
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.videolan.org/pipermail/android/attachments/20140920/3b6a4b91/attachment.sig>


More information about the Android mailing list