[Android] [PATCH 21/24] Enable and package lua

Edward Wang edward.c.wang at compdigitec.com
Wed Aug 22 23:15:21 CEST 2012


---
 Makefile                                     |    9 +++++
 configure.sh                                 |    2 +-
 vlc-android/jni/Android.mk                   |    1 +
 vlc-android/src/org/videolan/vlc/LibVLC.java |   44 ++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 7f6e946..10a844a 100644
--- a/Makefile
+++ b/Makefile
@@ -43,6 +43,15 @@ $(VLC_APK): $(LIBVLCJNI) $(JAVA_SOURCES)
 	echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt
 	git rev-parse --short HEAD > $(SRC)/assets/revision.txt
 	./gen-env.sh $(SRC)
+	zip -9 $(SRC)/assets/luascripts \
+		vlc/share/lua/extensions/* \
+		vlc/share/lua/playlist/* \
+		vlc/share/lua/meta/art/* \
+		vlc/share/lua/meta/fetcher/* \
+		vlc/share/lua/meta/reader/* \
+		vlc/share/lua/sd/*
+#		Intentionally left out for now: HTTP, interfaces, as they are
+#		not as relevant for mobile VLC versus desktop VLC.
 	$(VERBOSE)cd $(SRC) && ant $(ANT_OPTS) $(ANT_TARGET)
 
 VLC_MODULES=`./find_modules.sh $(VLC_BUILD_DIR)`
diff --git a/configure.sh b/configure.sh
index 241ac59..090594f 100755
--- a/configure.sh
+++ b/configure.sh
@@ -61,10 +61,10 @@ sh $VLC_SOURCEDIR/configure --host=$TARGET_TUPLE --build=x86_64-unknown-linux $E
                 --enable-taglib \
                 --enable-dvbpsi \
                 --enable-iomx \
+                --enable-lua \
                 --disable-vlc --disable-shared \
                 --disable-vlm \
                 --disable-dbus \
-                --disable-lua \
                 --disable-vcd \
                 --disable-v4l2 \
                 --disable-gnomevfs \
diff --git a/vlc-android/jni/Android.mk b/vlc-android/jni/Android.mk
index 24b7d48..3b9393f 100644
--- a/vlc-android/jni/Android.mk
+++ b/vlc-android/jni/Android.mk
@@ -66,6 +66,7 @@ LOCAL_LDLIBS := -L$(VLC_CONTRIB)/lib \
 	-lspeex -lspeexdsp \
 	-lxml2 -lpng -lgnutls -lgcrypt -lgpg-error \
 	-lfreetype -liconv -lass -lfribidi \
+	-llua \
 	$(CPP_STATIC)
 
 include $(BUILD_SHARED_LIBRARY)
diff --git a/vlc-android/src/org/videolan/vlc/LibVLC.java b/vlc-android/src/org/videolan/vlc/LibVLC.java
index ef6d2a1..e71aa95 100644
--- a/vlc-android/src/org/videolan/vlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/vlc/LibVLC.java
@@ -20,7 +20,15 @@
 
 package org.videolan.vlc;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 
 import org.videolan.vlc.gui.video.VideoPlayerActivity;
 import org.videolan.vlc.LibVlcException;
@@ -86,6 +94,42 @@ public class LibVLC {
             /// FIXME Alert user
             System.exit(1);
         }
+        if(!new File("/sdcard/Android/data/org.videolan.vlc").exists()) {
+            Log.i(TAG, "unzipping lua scripts");
+            File luaDir = new File("/sdcard/Android/data/org.videolan.vlc");
+            luaDir.mkdirs();
+
+            try {
+                InputStream is = VLCApplication.getAppResources().getAssets().open("luascripts.zip");
+                ZipInputStream inputStream = new ZipInputStream(is);
+                ZipEntry entry;
+                while((entry = inputStream.getNextEntry()) != null) {
+                    // to make it compatible with the lua code, since lua
+                    // code insists on share/lua order
+                    String name = entry.getName().replace("vlc/share", "");
+
+                    if(!entry.isDirectory()) { // don't try to generate subfolders
+                        File entryDestination = new File(luaDir, name);
+                        entryDestination.getParentFile().mkdirs(); // create subfolders if needed
+                        Log.d(TAG, "Unzipping " + entryDestination.getAbsolutePath());
+
+                        BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(entryDestination));
+                        byte buf[] = new byte[1024];
+                        int readBytes = inputStream.read(buf, 0, 1024);
+                        while(readBytes >= 0) {
+                            out.write(buf, 0, readBytes);
+                            readBytes = inputStream.read(buf, 0, 1024);
+                        };
+                        out.flush();
+                        out.close();
+                    }
+                }
+                inputStream.close();
+            } catch (IOException e) {
+                Log.e(TAG, "Failed to unzip lua scripts!");
+                e.printStackTrace();
+            }
+        }
     }
 
     /**
-- 
1.7.5.4



More information about the Android mailing list