From: Reinhard Tartler Date: Tue, 29 Jan 2019 23:08:45 +0000 (-0500) Subject: New upstream version 0.7.1+dfsg1 X-Git-Tag: archive/raspbian/1.0.1+dfsg1-4+rpi1~1^2~15^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=244fee913f8308dc10ceaacfab44fb349e3cb061;p=gpac.git New upstream version 0.7.1+dfsg1 --- diff --git a/applications/osmo4_android_studio/.gitignore b/applications/osmo4_android_studio/.gitignore deleted file mode 100644 index 769114f..0000000 --- a/applications/osmo4_android_studio/.gitignore +++ /dev/null @@ -1,41 +0,0 @@ -### Mac BS ### -.DS_Store - -### Android ### -# Built application files -*.apk -*.ap_ -captures/ - -# Files for the Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ - -# Gradle files -.gradle/ -build/ -!build/jar/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -#Log Files -*.log - - -## Intellij settings -.idea/ -*.iml - -## jimu mirror -app/mirror/ -.gradle diff --git a/applications/osmo4_android_studio/Readme.md b/applications/osmo4_android_studio/Readme.md deleted file mode 100644 index 5b68436..0000000 --- a/applications/osmo4_android_studio/Readme.md +++ /dev/null @@ -1,11 +0,0 @@ -# To compile this "to be improved" project - -Compile libgpac and its dependencies using the scripts provided in build/android - -Copy the content of applications/osmo4_android/libs into app/src/main/jniLibs - -# A problem occurred starting process 'null/ndk-build' - -Add this into your local.properties file - -ndk.dir=/path/to/Android/sdk/ndk-bundle \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/build.gradle b/applications/osmo4_android_studio/app/build.gradle deleted file mode 100644 index dcbf0f9..0000000 --- a/applications/osmo4_android_studio/app/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -apply plugin: 'com.android.application' -import org.apache.tools.ant.taskdefs.condition.Os - -android { - compileSdkVersion 23 - buildToolsVersion "23.0.3" - - defaultConfig { - applicationId "com.gpac.Osmo4" - minSdkVersion 16 - targetSdkVersion 22 - } - - sourceSets.main { - jni.srcDirs = [] // This prevents the auto generation of Android.mk - jniLibs.srcDir 'src/main/libs' // This is not necessary unless you have precompiled libraries in your project. - } - - - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' - } - } -} - -dependencies { - compile files('libs/real3d.jar') - compile 'com.android.support:recyclerview-v7:23.1.1' - compile 'com.android.support:cardview-v7:23.1.1' - compile 'com.android.support:appcompat-v7:23.1.1' - compile 'com.android.support:design:23.1.1' - -} diff --git a/applications/osmo4_android_studio/app/libs/real3d.jar b/applications/osmo4_android_studio/app/libs/real3d.jar deleted file mode 100644 index bd268d3..0000000 Binary files a/applications/osmo4_android_studio/app/libs/real3d.jar and /dev/null differ diff --git a/applications/osmo4_android_studio/app/src/main/AndroidManifest.xml b/applications/osmo4_android_studio/app/src/main/AndroidManifest.xml deleted file mode 100644 index 2bd949c..0000000 --- a/applications/osmo4_android_studio/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - android:theme="@android:style/Theme.AppCompat"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/osmo4_android_studio/app/src/main/assets/configuration.xml b/applications/osmo4_android_studio/app/src/main/assets/configuration.xml deleted file mode 100755 index d796bf9..0000000 --- a/applications/osmo4_android_studio/app/src/main/assets/configuration.xml +++ /dev/null @@ -1,171 +0,0 @@ - - -
- - Specifies the path to modules directory. The MPEG-4 Systems engine cannot be loaded without modules. This option is used by GPAC clients on all platforms. - - - Specifies location of temp files. The user must have write access to this location. Although not used by applications, this is used by several modules. - - - Specifies file to load upon startup of most clients (Osmo4/MP4Client). If not specified, no file is loaded. - - - Specifies where to output GPAC's log. By default, the logs are written to stdout. Note that GPAC may be compiled without log support. This is not used by MP4Client. - - - Specifies log level for each tool, with the following syntax:

- tool[:tool]@level:tool[:tool]@level

- By default, only errors are logged.

- Available levels are: -
    -
  • quiet : no logging is performed on the tool
  • -
  • error : only errors are logged
  • -
  • warning : warnings are also logged.
  • -
  • info : information messages are also logged
  • -
  • debug : debug messages are also logged
  • -
- Available tools are: -
    -
  • core : libgpac core
  • -
  • coding : bitstream formats (audio, video, scene)
  • -
  • container : container formats (ISO File, MPEG-2 TS, AVI, ...)
  • -
  • network : network data exept RTP trafic
  • -
  • rtp : rtp, rtcp and rtsp trafic
  • -
  • author : authoring tools (hint, import, export)
  • -
  • sync : terminal sync layer
  • -
  • codec : terminal codec messages
  • -
  • parser : scene parsers (svg, xmt, bt) and other
  • -
  • media : terminal media object management
  • -
  • scene : scene graph and scene manager
  • -
  • script : scripting engine messages
  • -
  • interact : user interaction messages
  • -
  • compose : composition engine (events, etc)
  • -
  • cache : HTTP cache
  • -
  • mmio : Audio/Video HW I/O management
  • -
  • rti : Run-time info (CPU, mem, ...)
  • -
  • smil : SMIL timing and animation
  • -
  • memory : GPAC memory tracker
  • -
  • audio : Audio renderer and mixers
  • -
  • module : used by some modules
  • -
  • mutex : mutex information
  • -
  • console : console messages, such as script alert() and error notifications
  • -
-
- - Specifies whether the presentation has to be restarted when done playing. - - - Specifies whether application messages (script, buffering, download progress) are displayed in the console or not. - - - Specifies if the player should be a single instance application or not (Osmo4-Win32 only). - - - Specifies if Osmo4 shall look for subtitle files when opening a presentation. - - - Specifies if scene dumping shall be done in XML (XMT, X3D) or in VRML-like syntax (BT, WRL). - - - Specifies the latest config panel selected by user. - - - Specifies if the player has to check for mime type when following hyperlinks, or only follow links of known extensions. - - - Indicates active playlist entry when player was last closed. Playlist backup is: -
    -
  • "gpac_pl.m3u" on win32 platforms, stored in same directory as application
  • -
  • ".gpac_pl.m3u" on other platforms, stored in user home directory
  • -
-
- - Specifies if the display area shall fill all available space on screen. WindowsMobile/Symbian only - - - Specifies if the screen backlighting shall be disabled while playing. WindowsMobile/Symbian only - - - Specifies the directory of the last local file opened. Smartphone Windows only - - - Specifies prefered browser for WWW anchors and scene graph viewing - Only used by Osmo4/wxWidgets. - -
-
- The "RecentFiles" section of the config file holds last accessed files (hardcoded to no more than 20) in the last access order. The keys are the file names and no value is used. This section is only used by GUI clients (osmo4/wxOsmo4) -
-
- - Specifies the user prefered language in readable english. This is used to select streams in case of alternate content in an audio object. - - - Specifies the user prefered language as expressed in ISO 639-2. This is used to select streams in case of alternate content in an audio object. - - - Specifies the user prefered language as expressed in ISO 639-1. This is used to select streams in case of alternate content in an audio object. - - - If set, late frames will still be drawn. If not set, the late frames are droped (or executed for systems decoders) untill the decoder output is back in sync. This is by default on to keep better testing heavy content or slow renderers, but should be set to off when needing a better sync or monitoring skipped frames. - - - One big problem with MP4 files is that the notion of "duration" has been unclear for a long time, and most content available (audio-video files) specifiy a wrong BIFS duration. In such a case the movie cannot be controled/seeked into. Another problem with ISMA streaming is that BIFS/OD don't use the same clock as audio/video, thus seeking the main timeline does not seek AV media. Setting the ForceSingleClock will handle both cases by using a single timeline for all media streams and setting the duration to the one of the longest stream - - - Specifies how media decoders are to be threaded. "Free" lets decoders decide of their threading, "Single" means that all decoders are managed in a single thread performing scheduling and priority handling and "Multi" means that each decoder runs in its own thread. - - - Specifies the priority of the decoders (priority is applied to decoder thread(s) regardless of threading mode). - - - Specifies the target maximum time (in ms) of one cycle of the media manager (the media manager will attempts to call all the active decoders within this time. Depending on the threading mode this option can be ignored. - - - Specifies whether modules should be unloaded if not used or not. Default: "yes". - - - Specifies the threshold after which late clocks are resynchronized to timestamps for OCR streams. By default, no threashold (0) is used and clocks are never resynchronized. This allows to resync clocks to the media owning the clock when the decoding is really too slow, and should only be used for debugging purposes. - - - Specifies whether the visual rendering is done in the main codec manager or in a dedicated thread. - - - Specifies which module to use by default for audio decoding. The string is the name of the module to be used (same considerations as other modules, cf introduction). - - - Specifies which module to use by default for video decoding. The string is the name of the module to be used (same considerations as other modules, cf introduction). - - - Specifies which module to use by default for image decoding. The string is the name of the module to be used (same considerations as other modules, cf introduction). - - - Allows to specify default media module (audio/video) per stream type and object type. This is useful if you have more than one decoder for a given type (ex, XviD and FFMPEG for MPEG-4 visual SP). The syntax is:

- codec_AA_BB=modulename

- where AA is the hexadecimal MPEG-4 streamType value for the codec (04=visual, 05=audio) and BB is the hexadecimal MPEG-4 objectTypeIndication of the media (0x20 = MPEG-4 video, 0x40=MPEG-4 Audio, ...). The string is the name of the module to be used (same considerations as other modules, cf introduction). -
-
-
- - Specifies the length of the decoding buffer in milliseconds. The client will wait for the buffer to be filled before starting decoding. A module may decide to use a different value based on protocol and network jitters. - -
-
- - Sets low-latency mode enabled. In low-latency mode, media data is parsed as soon as possible while segment is being downloaded. Default is no. If chunk is selected, media data is re-parsed at each HTTP 1.1 chunk end. If always is selected, media data is re-parsed as soon as HTTP data is received. - -
-
\ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/BitmapView.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/BitmapView.java deleted file mode 100644 index 522ffde..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/BitmapView.java +++ /dev/null @@ -1,93 +0,0 @@ -///** -// * Osmo on Android -// * Aug/2010 -// * NGO Van Luyen -// * -// * -// */ -//package com.gpac.Osmo4; -// -//import android.content.Context; -//import android.graphics.Bitmap; -//import android.graphics.Canvas; -//import android.util.Log; -//import android.view.View; -// -///** -// * -// * @version $Revision$ -// * -// */ -//@Deprecated -//public class BitmapView extends View { -// -// private Bitmap m_Bitmap = null; -// -// private int m_width = 100, m_height = 100; -// -// private final static String LOG_BITMAP = BitmapView.class.getSimpleName(); -// -// /** -// * Constructor -// * -// * @param context The current view's context -// */ -// public BitmapView(Context context) { -// super(context); -// } -// -// @Override -// protected void onDraw(Canvas canvas) { -// // canvas.drawColor(0xFFCCCCCC); -// m_width = canvas.getWidth(); -// m_height = canvas.getHeight(); -// if (m_Bitmap == null) { -// if (m_width < 1) -// m_width = 100; -// if (m_height < 1) -// m_height = 100; -// m_Bitmap = Bitmap.createBitmap(m_width, m_height, Bitmap.Config.ARGB_8888); -// gpacinit(); -// } -// -// GpacObject.gpacrender(m_Bitmap); -// canvas.drawBitmap(m_Bitmap, 0, 0, null); -// // force a redraw, with a different time-based pattern. -// invalidate(); -// -// } -// -// /** -// * Called to init all GPAC resources -// */ -// private void gpacinit() { -// Log.i(LOG_BITMAP, "Going to gpacinit"); //$NON-NLS-1$ -// if (m_Bitmap != null) { -// Log.e(LOG_BITMAP, "m_Bitmap != null"); //$NON-NLS-1$ -// if (m_width < 1) -// m_width = 100; -// if (m_height < 1) -// m_height = 100; -// GpacObject.gpacinit(m_Bitmap, -// null, -// m_width, -// m_height, -// Osmo4Renderer.GPAC_CFG_DIR, -// Osmo4Renderer.GPAC_MODULES_DIR, -// Osmo4Renderer.GPAC_CACHE_DIR, -// Osmo4Renderer.GPAC_FONT_DIR, -// null); -// // GpacObject.gpacconnect("/data/osmo/bifs-2D-interactivity-stringsensor.mp4"); -// GpacObject.gpacresize(m_width, m_height); -// } -// } -// -// /** -// * Called to free all GPAC resources -// */ -// public void gpacfree() { -// Log.e(LOG_BITMAP, "gpacfree()"); //$NON-NLS-1$ -// GpacObject.gpacdisconnect(); -// GpacObject.gpacfree(); -// } -// } diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GPACInstance.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GPACInstance.java deleted file mode 100644 index a78176d..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GPACInstance.java +++ /dev/null @@ -1,425 +0,0 @@ -/** - * $URL$ - * - * $LastChangedBy$ - $LastChangedDate$ - */ -package com.gpac.Osmo4; - -import java.io.File; -import java.io.PrintStream; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; - -/** - * @version $Revision$ - * - */ -public class GPACInstance implements GPACInstanceInterface { - - private final static String LOG_LIB = "LibrariesLoader"; //$NON-NLS-1$ - - private final Thread uniqueThread; - - /** - * - * a recursive method to get the directory hierarchy under root. - * - * @param sb StringBuilder object which will return the final hierarchy - * @param root root of the hierarchy - * @param inc initial number of spaces. - */ - private static void listing(StringBuilder sb, File root, int inc) { - StringBuilder increment = new StringBuilder(); - for (int i = 0; i < inc; i++) - increment.append(' '); - String incr = increment.toString(); - for (File f : root.listFiles()) { - sb.append(incr).append(f.getName()); - if (f.isDirectory()) { - sb.append(" [Directory]\n"); //$NON-NLS-1$ - listing(sb, f, inc + 2); - } else { - sb.append(" [").append(f.length() + " bytes]\n"); //$NON-NLS-1$//$NON-NLS-2$ - } - } - } - - /** - * Loads all libraries - * - * @param config - * - * @return a map of exceptions containing the library as key and the exception as value. If map is empty, no error - * - */ - - - synchronized static Map loadAllLibraries(GpacConfig config) { - if (errors != null) - return errors; - StringBuilder sb = new StringBuilder(); - final String[] toLoad = { "GLESv2", "log",//$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ - "jpegdroid", "javaenv", //$NON-NLS-1$ //$NON-NLS-2$ - "mad", "editline", "ft2", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - "js_osmo", "openjpeg", "png", "z", //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ - "stlport_shared", "stdc++", "faad", "gpac", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ - "gm_droid_cam", "gm_droid_mpegv","gm_mediacodec_dec", //$NON-NLS-1$ //$NON-NLS-2$ - "avutil", "swscale", "swresample", "avcodec", "avformat", "avfilter", - "gpacWrapper" }; // //$NON-NLS-1$ //$NON-NLS-2$ - HashMap exceptions = new HashMap(); - for (String s : toLoad) { - try { - String msg = "Loading library " + s + "...";//$NON-NLS-1$//$NON-NLS-2$ - sb.append(msg); - Log.i(LOG_LIB, msg); - System.loadLibrary(s); - } catch (UnsatisfiedLinkError e) { - sb.append("Failed to load " + s + ", error=" + e.getLocalizedMessage() + " :: " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ - + e.getClass().getSimpleName() + "\n"); //$NON-NLS-1$ - exceptions.put(s, e); - Log.e(LOG_LIB, "Failed to load library : " + s + " due to link error " + e.getLocalizedMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (SecurityException e) { - exceptions.put(s, e); - Log.e(LOG_LIB, "Failed to load library : " + s + " due to security error " + e.getLocalizedMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (Throwable e) { - exceptions.put(s, e); - Log.e(LOG_LIB, "Failed to load library : " + s + " due to Runtime error " + e.getLocalizedMessage(), e); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - if (!exceptions.isEmpty()) { - try { - PrintStream out = new PrintStream(config.getGpacLogDirectory() + "debug_libs.txt", "UTF-8"); //$NON-NLS-1$//$NON-NLS-2$ - out.println("$Revision$"); //$NON-NLS-1$ - out.println(new Date()); - out.println("\n*** Configuration\n"); //$NON-NLS-1$ - out.println(config.getConfigAsText()); - sb.append("*** Libs listing: "); //$NON-NLS-1$ - sb.append(config.getGpacLibsDirectory()); - sb.append('\n'); - listing(sb, new File(config.getGpacLibsDirectory()), 2); - sb.append("*** Modules listing: "); //$NON-NLS-1$ - sb.append(config.getGpacModulesDirectory()); - sb.append('\n'); - listing(sb, new File(config.getGpacModulesDirectory()), 2); - sb.append("*** Fonts listing: \n"); //$NON-NLS-1$ - sb.append(config.getGpacFontDirectory()); - sb.append('\n'); - listing(sb, new File(config.getGpacFontDirectory()), 2); - sb.append("*** Exceptions:\n"); //$NON-NLS-1$ - for (Map.Entry ex : exceptions.entrySet()) { - sb.append(ex.getKey()).append(": ") //$NON-NLS-1$ - .append(ex.getValue().getLocalizedMessage()) - .append('(') - .append(ex.getValue().getClass()) - .append(")\n"); //$NON-NLS-1$ - } - out.println(sb.toString()); - out.flush(); - out.close(); - } catch (Exception e) { - Log.e(LOG_LIB, "Failed to output debug info to debug file", e); //$NON-NLS-1$ - } - } - errors = Collections.unmodifiableMap(exceptions); - return errors; - } - - private static Map errors = null; - - private boolean hasToBeFreed = true; - - /** - * Constructor - * - * @param callback - * @param width - * @param height - * @param config The configuration to use for GPAC - * @param urlToOpen - * @throws GpacInstanceException - */ - public GPACInstance(GpacCallback callback, int width, int height, GpacConfig config, String urlToOpen) - throws GpacInstanceException { - StringBuilder sb = new StringBuilder(); - Map errors = loadAllLibraries(config); - if (!errors.isEmpty()) { - sb.append("Exceptions while loading libraries:"); //$NON-NLS-1$ - for (Map.Entry x : errors.entrySet()) { - sb.append('\n') - .append(x.getKey()) - .append('[') - .append(x.getValue().getClass().getSimpleName()) - .append("]: ") //$NON-NLS-1$ - .append(x.getValue().getLocalizedMessage()); - } - Log.e(LOG_LIB, sb.toString()); - } - try { - handle = createInstance(callback, - width, - height, - config.getGpacConfigDirectory(), - config.getGpacModulesDirectory(), - config.getGpacCacheDirectory(), - config.getGpacFontDirectory(), - config.getGpacGuiDirectory(), - urlToOpen); - } catch (Throwable e) { - throw new GpacInstanceException("Error while creating instance\n" + sb.toString()); //$NON-NLS-1$ - } - if (handle == 0) { - throw new GpacInstanceException("Error while creating instance, no handle created!\n" + sb.toString()); //$NON-NLS-1$ - } - synchronized (this) { - hasToBeFreed = true; - } - uniqueThread = Thread.currentThread(); - } - - /** - * This one handles the pointer to the real C object - */ - private final long handle; - - /** - * @return the handle - */ - public synchronized long getHandle() { - return handle; - } - - private void checkCurrentThread() throws RuntimeException { - if (Thread.currentThread() != uniqueThread) - throw new RuntimeException("Method called outside allowed Thread scope !"); //$NON-NLS-1$ - } - - @Override - public void disconnect() { - checkCurrentThread(); - gpacrender(); - gpacdisconnect(); - } - - @Override - public void connect(String url) { - Log.i(LOG_LIB, "connect(" + url + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - checkCurrentThread(); - gpacrender(); - gpacconnect(url); - } - - /** - * Call this method when a key has been pressed - * - * @param keyCode - * @param event - * @param pressed true if key is pressed, false if key is released - * @param unicode - */ - public void eventKey(int keyCode, KeyEvent event, boolean pressed, int unicode) { - checkCurrentThread(); - gpaceventkeypress(keyCode, event.getScanCode(), pressed ? 1 : 0, event.getFlags(), unicode); - } - - /** - * Renders the current frame - */ - public void render() { - checkCurrentThread(); - gpacrender(); - } - - /** - * Resizes the object to new dimensions - * - * @param width - * @param height - */ - public void resize(int width, int height) { - Log.i(LOG_LIB, "Resizing to " + width + "x" + height); //$NON-NLS-1$ //$NON-NLS-2$ - gpacresize(width, height); - } - - private boolean touched = false; - - /** - * Call this when a motion event occurs - * - * @param event - */ - public void motionEvent(MotionEvent event) { - checkCurrentThread(); - final float x = event.getX(); - final float y = event.getY(); - switch (event.getAction()) { - // not in 1.6 case MotionEvent.ACTION_POINTER_1_DOWN: - case MotionEvent.ACTION_DOWN: - gpaceventmousemove(x, y); - gpaceventmousedown(x, y); - touched = true; - break; - // not in 1.6 case MotionEvent.ACTION_POINTER_1_UP: - case MotionEvent.ACTION_UP: - if ( !touched ) - break; - gpaceventmouseup(x, y); - touched = false; - break; - case MotionEvent.ACTION_MOVE: - gpaceventmousemove(x, y); - if ( !touched ) { - touched = true; - //Log.i("Osmo4", "Mouse down: " + x +"," + y); - gpaceventmousedown(x, y); - } - break; - case MotionEvent.ACTION_CANCEL: - if ( !touched ) - break; - //Log.i("Osmo4", "Mouse up: " + x +"," + y); - gpaceventmouseup(x, y); - touched = false; - break; - } - } - - @Override - public void finalize() throws Throwable { - // Not sure how to do this..., destroy is supposed to be called already - // destroy(); - super.finalize(); - } - - /** - * All Native functions, those functions are binded using the handle - */ - - /** - * Opens an URL - * - * @param url The URL to open - */ - private native void gpacconnect(String url); - - /** - * Used to create the GPAC instance - * - * @param callback - * @param width - * @param height - * @param cfg_dir - * @param modules_dir - * @param cache_dir - * @param font_dir - * @param gui_dir - * @return - */ - private native long createInstance(GpacCallback callback, int width, int height, String cfg_dir, - String modules_dir, String cache_dir, String font_dir, String gui_dir, String url_to_open); - - /** - * Disconnects the currently loaded URL - */ - private native void gpacdisconnect(); - - /** - * Renders - * - * @param handle - */ - private native void gpacrender(); - - /** - * Resizes the current view - * - * @param width The new width to set - * @param height The new height to set - */ - private native void gpacresize(int width, int height); - - /** - * Free all GPAC resources - */ - private native void gpacfree(); - - /** - * To call when a key has been pressed - * - * @param keycode - * @param rawkeycode - * @param up - * @param flag - */ - private native void gpaceventkeypress(int keycode, int rawkeycode, int up, int flag, int unicode); - - /** - * To call when a mouse is down - * - * @param x Position in pixels - * @param y Position in pixels - */ - private native void gpaceventmousedown(float x, float y); - - /** - * To call when a mouse is up (released) - * - * @param x Position in pixels - * @param y Position in pixels - */ - private native void gpaceventmouseup(float x, float y); - - /** - * To call when a mouse is moving - * - * @param x Position in pixels - * @param y Position in pixels - */ - private native void gpaceventmousemove(float x, float y); - - /** - * To call when a change in orientation is returned from the sensors - * All angles are in RADIANS and positive in the COUNTER-CLOCKWISE direction - * - * @param x yaw (rotation around the -Z axis) range: [-PI, PI] - * @param y pitch (rotation around the -X axis) range: [-PI/2, PI/2] - * @param z roll (rotation around the Y axis) range: [-PI, PI] - */ - private native void gpaceventorientationchange(float x, float y, float z); - - public void onOrientationChange(float yaw, float pitch, float roll){ - gpaceventorientationchange(yaw, pitch, roll); - } - - @Override - public void destroy() { - boolean freeIt; - synchronized (this) { - freeIt = hasToBeFreed; - hasToBeFreed = false; - } - if (freeIt) { - disconnect(); - gpacfree(); - } - } - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#setGpacPreference(String, String, String) - */ - @Override - public native void setGpacPreference(String category, String name, String value); - - - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#setGpacLogs(String) - */ - @Override - public native void setGpacLogs(String tools_at_levels); -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GPACInstanceInterface.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GPACInstanceInterface.java deleted file mode 100644 index ab5adf3..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GPACInstanceInterface.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * $URL$ - * - * $LastChangedBy$ - $LastChangedDate$ - */ -package com.gpac.Osmo4; - -/** - * @copyright RTL Group 2008 - * @author RTL Group DTIT software development team (last changed by $LastChangedBy$) - * @version $Revision$ - * - */ -public interface GPACInstanceInterface { - - /** - * @version $Revision$ - * - */ - public static class GpacInstanceException extends Exception { - - /** - * - */ - private static final long serialVersionUID = 3207851655866335152L; - - /** - * Constructor - * - * @param msg - */ - public GpacInstanceException(String msg) { - super(msg); - } - - } - - /** - * Call this method to disconnect - */ - public void disconnect(); - - /** - * Call this method to connect to a given URL - * - * @param url The URL to connect to - */ - public void connect(String url); - - /** - * Destroys the current instance, you won't be able to use it anymore... - */ - public void destroy(); - - /** - * Set a GPAC preference to given value - * - * @param category - * @param name The name of preference as defined in GPAC.cfg - * @param value The value to set, if null, value will be deleted - */ - public void setGpacPreference(String category, String name, String value); - - /** - * Set a GPAC debug level for a given tool - * - * @param tools_at_levels a ":" separated debugspec with debugspec := tool@debug_level - */ - public void setGpacLogs(String tools_at_levels); -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GpacCallback.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GpacCallback.java deleted file mode 100644 index e1e24a8..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GpacCallback.java +++ /dev/null @@ -1,313 +0,0 @@ -/** - * $URL$ - * - * $LastChangedBy$ - $LastChangedDate$ - */ -package com.gpac.Osmo4; - -/** - * Interface to implement by Java Objects to listen for callbacks from GPAC native code - * - * @version $Revision$ - * - */ -public interface GpacCallback { - - /** - * GPAC Error codes - * - * @version $Revision$ - * - */ - public enum GF_Err { - - /** Message from any scripting engine used in the presentation (ECMAScript, MPEG-J, ...) (Info). */ - GF_SCRIPT_INFO(3), - /** - * Indicates an data frame has several AU packed (not MPEG-4 compliant). This is used by decoders to force - * multiple decoding of the same data frame (Info). - */ - GF_PACKED_FRAMES(2), - /** Indicates the end of a stream or of a file (Info). */ - GF_EOS(1), - /* - * ! \n\n - */ - /** Operation success (no error). */ - GF_OK(0), - /** \n */ - /** One of the input parameter is not correct or cannot be used in the current operating mode of the framework. */ - GF_BAD_PARAM(-1), - /** Memory allocation failure. */ - GF_OUT_OF_MEM(-2), - /** Input/Output failure (disk access, system call failures) */ - GF_IO_ERR(-3), - /** The desired feature or operation is not supported by the framework */ - GF_NOT_SUPPORTED(-4), - /** Input data has been corrupted */ - GF_CORRUPTED_DATA(-5), - /** A modification was attempted on a scene node which could not be found */ - GF_SG_UNKNOWN_NODE(-6), - /** The PROTO node interface does not match the nodes using it */ - GF_SG_INVALID_PROTO(-7), - /** An error occured in the scripting engine */ - GF_SCRIPT_ERROR(-8), - /** - * Buffer is too small to contain decoded data. Decoders shall use this error whenever they need to resize their - * output memory buffers - */ - GF_BUFFER_TOO_SMALL(-9), - /** Bitstream is not compliant to the specfication it refers to */ - GF_NON_COMPLIANT_BITSTREAM(-10), - /** No decoders could be found to handle the desired media type */ - GF_CODEC_NOT_FOUND(-11), - /** The URL is not properly formatted or cannot be found */ - GF_URL_ERROR(-12), - /** An service error has occured at the local side */ - GF_SERVICE_ERROR(-13), - /** A service error has occured at the remote (server) side */ - GF_REMOTE_SERVICE_ERROR(-14), - /** The desired stream could not be found in the service */ - GF_STREAM_NOT_FOUND(-15), - /** The IsoMedia file is not a valid one */ - GF_ISOM_INVALID_FILE(-20), - /** The IsoMedia file is not complete. Either the file is being downloaded, or it has been truncated */ - GF_ISOM_INCOMPLETE_FILE(-21), - /** The media in this IsoMedia track is not valid (usually due to a broken stream description) */ - GF_ISOM_INVALID_MEDIA(-22), - /** The requested operation cannot happen in the current opening mode of the IsoMedia file */ - GF_ISOM_INVALID_MODE(-23), - /** This IsoMedia track refers to media outside the file in an unknown way */ - GF_ISOM_UNKNOWN_DATA_REF(-24), - - /** An invalid MPEG-4 Object Descriptor was found */ - GF_ODF_INVALID_DESCRIPTOR(-30), - /** An MPEG-4 Object Descriptor was found or added to a forbidden descriptor */ - GF_ODF_FORBIDDEN_DESCRIPTOR(-31), - /** An invalid MPEG-4 BIFS command was detected */ - GF_ODF_INVALID_COMMAND(-32), - /** The scene has been encoded using an unknown BIFS version */ - GF_BIFS_UNKNOWN_VERSION(-33), - - /** The remote IP address could not be solved */ - GF_IP_ADDRESS_NOT_FOUND(-40), - /** The connection to the remote peer has failed */ - GF_IP_CONNECTION_FAILURE(-41), - /** The network operation has failed */ - GF_IP_NETWORK_FAILURE(-42), - /** The network connection has been closed */ - GF_IP_CONNECTION_CLOSED(-43), - /** The network operation has failed because no data is available */ - GF_IP_NETWORK_EMPTY(-44), - /** The network operation has been discarded because it would be a blocking one */ - GF_IP_SOCK_WOULD_BLOCK(-45), - /** - * UDP connection did not receive any data at all. Signaled by client services to reconfigure network if - * possible - */ - GF_IP_UDP_TIMEOUT(-46), - - /** Authentication with the remote host has failed */ - GF_AUTHENTICATION_FAILURE(-50), - /** Script not ready for playback */ - GF_SCRIPT_NOT_READY(-51), - - /** - * Unknown GPAC Error code - */ - JAVA_UNKNOWN_ERROR(-100); - - int value; - - GF_Err(int x) { - this.value = x; - } - - /** - * Get a GPAC Error code from its value - * - * @param status The int status corresponding to the error - * @return A {@link GF_Err} object - */ - public static GF_Err getError(int status) { - for (GF_Err x : values()) { - if (x.value == status) - return x; - } - return JAVA_UNKNOWN_ERROR; - } - } - - /** - * Mapping between GPAC Log Modules and Java symbols - * - * @version $Revision$ - * - */ - public enum GF_Log_Module implements Comparable { - /** Log message from the core library (init, threads, network calls, etc) */ - GF_LOG_CORE(0), - /** Log message from a raw media parser (BIFS, LASeR, A/V formats) */ - GF_LOG_CODING(1), - /** Log message from a bitstream parser (IsoMedia, MPEG-2 TS, OGG, ...) */ - GF_LOG_CONTAINER(2), - /** Log message from the network/service stack (messages & co) */ - GF_LOG_NETWORK(3), - /** Log message from the RTP/RTCP stack (TS info) and packet structure & hinting (debug) */ - GF_LOG_RTP(4), - /** Log message from authoring subsystem (file manip, import/export) */ - GF_LOG_AUTHOR(5), - /** Log message from the sync layer of the terminal */ - GF_LOG_SYNC(6), - /** Log message from a codec */ - GF_LOG_CODEC(7), - /** Log message from any XML parser (context loading, etc) */ - GF_LOG_PARSER(8), - /** Log message from the terminal/compositor, indicating media object state */ - GF_LOG_MEDIA(9), - /** Log message from the scene graph/scene manager (handling of nodes and attribute modif, DOM core) */ - GF_LOG_SCENE(10), - /** Log message from the scripting engine */ - GF_LOG_SCRIPT(11), - /** Log message from event handling */ - GF_LOG_INTERACT(12), - /** Log message from compositor */ - GF_LOG_COMPOSE(13), - /** Log for video object cache */ - GF_LOG_CACHE(14), - /** Log message from multimedia I/O devices (audio/video input/output, ...) */ - GF_LOG_MMIO(15), - /** Log for runtime info (times, memory, CPU usage) */ - GF_LOG_RTI(16), - /** Log for SMIL timing and animation */ - GF_LOG_SMIL(17), - /** Log for memory tracker */ - GF_LOG_MEMORY(18), - /** Log for audio compositor */ - GF_LOG_AUDIO(19), - /** generic Log for modules */ - GF_LOG_MODULE(20), - /** - * Log for GPAC mutexes and threads (Very verbose at DEBUG) - * - */ - GF_LOG_MUTEX(21), - /*! Log for threads and condition */ - GF_LOG_CONDITION(22), - /*! Log for all HTTP streaming */ - GF_LOG_DASH(23), - /*! Log for all messages coming from GF_Terminal or script alert()*/ - GF_LOG_CONSOLE(24), - /*! Log for all messages coming the application, not used by libgpac or the modules*/ - GF_LOG_APP(25), - /*! Log for all messages coming from the scheduler */ - GF_LOG_SCHEDULER(26), - /** - * Unknown Log subsystem - */ - GF_LOG_UNKNOWN(30); - - int value; - - /** - * Private Constructor - */ - private GF_Log_Module(int x) { - this.value = x; - } - - /** - * Finds a module from its module_code - * - * @param module_code - * @return The Module found (never null) - */ - public static GF_Log_Module getModule(int module_code) { - for (GF_Log_Module x : values()) { - if (x.value == module_code) - return x; - } - return GF_LOG_UNKNOWN; - } - } - - /** - * Display a message - * - * @param message - * @param title - * @param errorCode - */ - public void displayMessage(String message, String title, int errorCode); - - - /** - * Called when setup log file - * - * @param path - */ - public void setLogFile(String path); - - /** - * Called when logging - * - * @param level - * @param module - * @param message - */ - public void onLog(int level, int module, String message); - - /** - * Called when progress is set - * - * @param msg - * @param done - * @param total - */ - public void onProgress(String msg, int done, int total); - - /** - * Called when GPAC is ready - */ - public void onGPACReady(); - - /** - * Called when GPAC initialization fails - * - * @param e - */ - public void onGPACError(Throwable e); - - // /** - // * Returns UserName:Password for given site - // * - // * @param siteURL The URL of site requiring authorization - // * @param userName The User Name (may be null if never set) - // * @param password The password (may be null if never set) - // * @return A String formated as username:password - // */ - // public String onGPACAuthorization(String siteURL, String userName, String password); - - /** - * Set the new caption for the application - * - * @param newCaption The new caption to set for application - */ - public void setCaption(String newCaption); - - /** - * Show the virtual keyboard - * - * @param showKeyboard - */ - public void showKeyboard(boolean showKeyboard); - - /** - * Toggle Sensors on/off - * - * @param active sensor (true/false) - */ - public void sensorSwitch(boolean active); - - -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GpacConfig.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GpacConfig.java deleted file mode 100644 index 4914987..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/GpacConfig.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * $URL$ - * - * $LastChangedBy$ - $LastChangedDate$ - */ -package com.gpac.Osmo4; - -import java.io.File; -import android.content.Context; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Environment; -import android.util.Log; - -/** - * This class handles all GPAC configuration directories - * - * @author Pierre Souchay (VizionR SAS) (last changed by $LastChangedBy$) - * @version $Revision$ - * - */ - -/** - * NOTE FOR DEVELOPERS - * Whenever you add or change a path here, you MUST verify also the corresponding path in src/utils/os_config_init.c - */ -public class GpacConfig { - - private final static String LOG_GPAC_CONFIG = GpacConfig.class.getSimpleName(); - - /** - * Default Constructor - * - * @param context - */ - public GpacConfig(Context context) { - String dataDir; - try { - if (context == null || context.getPackageManager() == null) { - dataDir = Environment.getDataDirectory() + "/data/com.gpac.Osmo4/"; //$NON-NLS-1$ - Log.e(LOG_GPAC_CONFIG, "Cannot get context or PackageManager, using default directory=" + dataDir); //$NON-NLS-1$ - } else - dataDir = context.getPackageManager().getApplicationInfo(context.getPackageName(), 0).dataDir; - } catch (NameNotFoundException e) { - Log.e(LOG_GPAC_CONFIG, "This is bad, we cannot find ourself : " + context.getPackageName(), e); //$NON-NLS-1$ - throw new RuntimeException("Cannot find package " + context.getPackageName(), e); //$NON-NLS-1$ - } - gpacAppDirectory = dataDir + '/'; - Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacAppDirectory + " for osmo"); //$NON-NLS-1$ //$NON-NLS-2$ - gpacCacheDirectory = context.getCacheDir().getAbsolutePath(); - Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacCacheDirectory + " for cache"); //$NON-NLS-1$ //$NON-NLS-2$ - // - //Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacModulesDirectory + " for modules"); //$NON-NLS-1$ //$NON-NLS-2$ - gpacLibsDirectory = dataDir + "/lib/"; //$NON-NLS-1$ - Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacLibsDirectory + " for libraries"); //$NON-NLS-1$ //$NON-NLS-2$ - - gpacGuiDirectory = dataDir + "/gui/"; - Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacGuiDirectory + " for GUI"); //$NON-NLS-1$ //$NON-NLS-2$ - - gpacShaderDirectory = dataDir + "/shaders/"; - Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacShaderDirectory + " for shader files"); //$NON-NLS-1$ //$NON-NLS-2$ - - File osmo = new File(Environment.getExternalStorageDirectory(), "osmo"); //$NON-NLS-1$ - gpacLogDirectory = osmo.getAbsolutePath() + "/log/"; - Log.v(LOG_GPAC_CONFIG, "Using directory " + gpacLogDirectory + " for log files"); //$NON-NLS-1$ //$NON-NLS-2$ - - //check if GPAC.cfg exists in /sdcard/osmo - File gpac_cfg = new File(osmo.getAbsolutePath(), "GPAC.cfg"); - if (gpac_cfg.exists()) - gpacConfigDirectory = osmo.getAbsolutePath() + "/"; - else - gpacConfigDirectory = null; - } - - /** - * Ensures all directories are created - * - * @return The {@link GpacConfig} instance itself - */ - public GpacConfig ensureAllDirectoriesExist() { - for (String s : new String[] { gpacAppDirectory, gpacCacheDirectory, gpacShaderDirectory, gpacLogDirectory }) { - createDirIfNotExist(s); - } - return this; - } - - /** - * Default directory for GPAC configuration directory, ends with / - * - * @return the gpacAppDirectory - */ - public String getGpacAppDirectory() { - return gpacAppDirectory; - } - - - /** - * Default directory for GPAC configuration directory, ends with / - * - * @return the gpacConfigDirectory - */ - public String getGpacConfigDirectory() { - return gpacConfigDirectory; - } - - /** - * Directory of Android containing all fonts - * - * @return the gpacFontDirectory - */ - public String getGpacFontDirectory() { - return gpacFontDirectory; - } - - /** - * Default directory for GPAC modules directory, ends with / - * - * @return the gpacModulesDirectory - */ - public String getGpacModulesDirectory() { - // return gpacModulesDirectory; - return gpacLibsDirectory; - } - - /** - * @return the gpacLibsDirectory - */ - public String getGpacLibsDirectory() { - return gpacLibsDirectory; - } - - /** - * Default directory for cached files - * - * @return the gpacCacheDirectory - */ - public String getGpacCacheDirectory() { - return gpacCacheDirectory; - } - - /** - * Default directory for GUI files - * - * @return the gpacGuiDirectory - */ - public String getGpacGuiDirectory() { - return gpacGuiDirectory; - } - - /** - * Default directory for shader files - * - * @return the gpacShaderDirectory - */ - public String getGpacShaderDirectory() { - return gpacShaderDirectory; - } - - /** - * Default directory for log files - * - * @return the gpacLogDirectory - */ - public String getGpacLogDirectory() { - return gpacLogDirectory; - } - - private final String gpacAppDirectory; - - private final String gpacConfigDirectory; - - private final String gpacFontDirectory = "/system/fonts/"; //$NON-NLS-1$ - - // private final String gpacModulesDirectory; - - private final String gpacLibsDirectory; - - private final String gpacCacheDirectory; - - private final String gpacGuiDirectory; - - private final String gpacShaderDirectory; - - private final String gpacLogDirectory; - - /** - * Creates a given directory if it does not exist - * - * @param path - */ - private static boolean createDirIfNotExist(String path) { - File f = new File(path); - if (!f.exists()) { - if (!f.mkdirs()) { - Log.e(LOG_GPAC_CONFIG, "Failed to create directory " + path); //$NON-NLS-1$ - return false; - } else { - Log.i(LOG_GPAC_CONFIG, "Created directory " + path); //$NON-NLS-1$ - } - } - return true; - } - - /** - * Get the GPAC.cfg file - * - * @return the file - */ - public File getGpacConfigFile() { - return new File(getGpacConfigDirectory(), "GPAC.cfg"); //$NON-NLS-1$ - } - - /** - * Get the GPAC.cfg file - * - * @return the file - */ - public File getGpacLastRevFile() { - return new File(getGpacConfigDirectory(), "lastRev.txt"); //$NON-NLS-1$ - } - - /** - * Get the configuration as text - * - * @return a String with newlines representing all the configuration - */ - public String getConfigAsText() { - StringBuilder sb = new StringBuilder(); - sb.append("GpacAppDirectory=").append(getGpacAppDirectory()).append('\n'); //$NON-NLS-1$ - sb.append("GpacModulesDirectory=").append(getGpacModulesDirectory()).append('\n'); //$NON-NLS-1$ - sb.append("GpacFontDirectory=").append(getGpacFontDirectory()).append('\n'); //$NON-NLS-1$ - sb.append("GpacCacheDirectory=").append(getGpacCacheDirectory()).append('\n'); //$NON-NLS-1$ - sb.append("GpacGuiDirectory=").append(getGpacGuiDirectory()).append('\n'); //$NON-NLS-1$ - sb.append("GpacShaderDirectory=").append(getGpacShaderDirectory()).append('\n'); //$NON-NLS-1$ - return sb.toString(); - } -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/MPEGVSensor.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/MPEGVSensor.java deleted file mode 100644 index 112e566..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/MPEGVSensor.java +++ /dev/null @@ -1,503 +0,0 @@ -package com.gpac.Osmo4; - -import android.app.Activity; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.location.Location; -import android.location.LocationListener; -import android.location.LocationManager; -import android.os.Bundle; - -/** - * Handle Physical sensors - * - * @authors Ivica Arsov (ivica.arsov@it-sudparis.eu) - Pierre Souchay (last changed by $LastChangedBy$) - * @version $Revision$ - * - */ -public class MPEGVSensor implements SensorEventListener, LocationListener { - - public static Activity myAct = null; - - private native void sendData(int ptr, String data); - - private static SensorManager mySensorManager = null; - private static LocationManager myLocationManager = null; - - private static Sensor sensor = null; - - private static Sensor sensor1 = null; - - private int SensorType = -2; - - private int InternalPtr = 0; - - private Boolean run = false; - - /** - * Init the sensor Manager - * - * @param mgr The manager to set - * @return the sensor manager set - */ - public static SensorManager initSensorManager(SensorManager mgr) { - return mySensorManager = mgr; - } - - /** - * Init the location Manager - * - * @param mgr The manager to set - * @return the location manager set - */ - public static LocationManager initLocationManager(LocationManager mgr) { - return myLocationManager = mgr; - } - - /** - * Starts the given sensor and register the listener - * - * @param ptr The pointer - * @param type The type of sensor as defined in {@link Sensor} - */ - public void startSensor(int ptr, int type) { - InternalPtr = ptr; - SensorType = type; - - switch (SensorType) { - case Sensor.TYPE_ORIENTATION: { - sensor = mySensorManager - .getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_GAME)) - return; - sensor1 = mySensorManager - .getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor1, - SensorManager.SENSOR_DELAY_GAME)) - { - mySensorManager.unregisterListener(MPEGVSensor.this); - return; - } - run = true; - break; - } - case Sensor.TYPE_ACCELEROMETER: { - sensor = mySensorManager - .getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - if( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_GAME)) - return; - run = true; - break; - } - case Sensor.TYPE_GYROSCOPE: { - sensor = mySensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_GAME)) - return; - run = true; - break; - } - case Sensor.TYPE_MAGNETIC_FIELD: { - sensor = mySensorManager - .getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_GAME)) - return; - run = true; - break; - } - case Sensor.TYPE_LIGHT: { - sensor = mySensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_UI)) - return; - run = true; - break; - } - case Sensor.TYPE_PRESSURE: { - sensor = mySensorManager.getDefaultSensor(Sensor.TYPE_PRESSURE); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_UI)) - return; - run = true; - break; - } - //case Sensor.TYPE_ROTATION_VECTOR: { - case 11: { - sensor = mySensorManager - .getDefaultSensor(11); - if ( !mySensorManager.registerListener(MPEGVSensor.this, sensor, - SensorManager.SENSOR_DELAY_GAME)) - return; - run = true; - break; - } - case 100: { // Type for the GPS sensor - myAct.runOnUiThread(new Runnable() { - - @Override - public void run() { - myLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, MPEGVSensor.this); - run = true; - } - }); - } - } - } - - /** - * Stops the sensor and unregister listener - */ - public void stopSensor() { - if (SensorType == 100) - myAct.runOnUiThread(new Runnable() { - - @Override - public void run() { - - myLocationManager.removeUpdates(MPEGVSensor.this); - - } - }); - else - mySensorManager.unregisterListener(MPEGVSensor.this); - run = false; - } - - @Override - public void onAccuracyChanged(Sensor arg0, int arg1) { - // TODO Auto-generated method stub - - } - - public double azzimuth = 0; - public double pitch = 0; - public double roll = 0; - - public double x, y, z, angle; - - private float[] mGData = new float[3]; - private float[] mMData = new float[3]; - private float[] mR = new float[16]; - private float[] mI = new float[16]; - private float[] mOrientation = new float[3]; - - int buffsize = 8; - - public double[] al = new double[buffsize]; - public double[] pl = new double[buffsize]; - public double[] rl = new double[buffsize]; - int ind = 0; - - double rotangle = 0; - - @Override - public void onSensorChanged(SensorEvent event) { - - if ( !run ) - return; - - switch (SensorType) - { - case Sensor.TYPE_ORIENTATION: - { - int type = event.sensor.getType(); - if (type == Sensor.TYPE_ACCELEROMETER) { - for (int i=0 ; i<3 ; i++) - mGData[i] = event.values[i]; - - lowPass(mGData, accel); - //filterAccData(); - //Log.i("Acc: ", "" + event.values[0] + " " + event.values[1] + " " + event.values[2]); - } else if (type == Sensor.TYPE_MAGNETIC_FIELD) { - for (int i=0 ; i<3 ; i++) - mMData[i] = event.values[i]; - - lowPass(mMData, mag); - //filterMagData(); - //Log.i("Mag: ", "" + event.values[0] + " " + event.values[1] + " " + event.values[2]); - } else { - if ( event.sensor.getType() == Sensor.TYPE_ORIENTATION ) - { - azzimuth = event.values[0]; - pitch = event.values[1]; - roll = event.values[2]; - } - return; - } - - SensorManager.getRotationMatrix(mR, mI, mGData, mMData); - SensorManager.getOrientation(mR, mOrientation); - - lowPass(mOrientation, ordata); - //filterOrientationData(); - - al[ind] = mOrientation[0]; - pl[ind] = mOrientation[1]; - rl[ind] = mOrientation[2]; - - if ( ++ind == buffsize ) - ind = 0; - - double a = 0, p = 0, r = 0; - for ( int i =0; i < buffsize; i++ ) - { - a += al[i]; - p += pl[i]; - r += rl[i]; - } - - a /= buffsize; - p /= buffsize; - r /= buffsize; - - final float rad2deg = (float)(180.0f/Math.PI); - azzimuth = a*rad2deg;//mOrientation[0]*rad2deg; - pitch = p*rad2deg;//mOrientation[1]*rad2deg; - roll = r*rad2deg;//mOrientation[2]*rad2deg; - -// mOrientation[0] = (float)azzimuth; -// mOrientation[1] = (float)pitch; -// mOrientation[2] = (float)roll; -// -// filterOrientationData(); -// -// azzimuth = mOrientation[0]; -// pitch = mOrientation[1]; -// roll = mOrientation[2]; - - String res = ""; - res += azzimuth+";" + pitch + ";" + roll + ";"; - sendData(InternalPtr, res); - break; - } - case Sensor.TYPE_ACCELEROMETER: - { - for (int i=0 ; i<3 ; i++) - mGData[i] = event.values[i]; - - lowPass(mGData, accel); - - al[ind] = mGData[0]; - pl[ind] = mGData[1]; - rl[ind] = mGData[2]; - - if ( ++ind == buffsize ) - ind = 0; - - double a = 0, p = 0, r = 0; - for ( int i =0; i < buffsize; i++ ) - { - a += al[i]; - p += pl[i]; - r += rl[i]; - } - - a /= buffsize; - p /= buffsize; - r /= buffsize; - - String res = ""; - res += a+";" + p + ";" + r + ";"; - sendData(InternalPtr, res); - break; - } - case Sensor.TYPE_GYROSCOPE: - { - for (int i=0 ; i<3 ; i++) - mGData[i] = event.values[i]; - - lowPass(mGData, accel); - - al[ind] = mGData[0]; - pl[ind] = mGData[1]; - rl[ind] = mGData[2]; - - if ( ++ind == buffsize ) - ind = 0; - - double a = 0, p = 0, r = 0; - for ( int i =0; i < buffsize; i++ ) - { - a += al[i]; - p += pl[i]; - r += rl[i]; - } - - a /= buffsize; - p /= buffsize; - r /= buffsize; - - String res = ""; - res += a+";" + p + ";" + r + ";"; - sendData(InternalPtr, res); - break; - } - case Sensor.TYPE_MAGNETIC_FIELD: - { - for (int i=0 ; i<3 ; i++) - mGData[i] = event.values[i]; - - lowPass(mGData, accel); - - al[ind] = mGData[0]; - pl[ind] = mGData[1]; - rl[ind] = mGData[2]; - - if ( ++ind == buffsize ) - ind = 0; - - double a = 0, p = 0, r = 0; - for ( int i =0; i < buffsize; i++ ) - { - a += al[i]; - p += pl[i]; - r += rl[i]; - } - - a /= buffsize; - p /= buffsize; - r /= buffsize; - - String res = ""; - res += a+";" + p + ";" + r + ";"; - sendData(InternalPtr, res); - break; - } - //case Sensor.TYPE_ROTATION_VECTOR: - case 11: - { - double a = event.values[0], p = event.values[1], r = event.values[2]; - - final float rad2deg = (float)(180.0f/Math.PI); - a = a*rad2deg; - p = p*rad2deg; - r = r*rad2deg; - - String res = ""; - res += a + ";" + p + ";" + r + ";"; - sendData(InternalPtr, res); - - break; - } - case Sensor.TYPE_LIGHT: - { - String res = ""; - res += event.values[0] + ";"; - sendData(InternalPtr, res); - break; - } - case Sensor.TYPE_PRESSURE: - { - String res = ""; - res += event.values[0]+";"; - sendData(InternalPtr, res); - break; - } - } - } - - static final float ALPHA = 0.01f; - - protected float[] lowPass(float[] input, float[] output) { - if (output == null) - return input; - - for (int i = 0; i < input.length; i++) { - output[i] = output[i] + ALPHA * (input[i] - output[i]); - } - return output; - } - - Boolean accinited = false; - float[] accel = new float[3]; - - private void filterData(float[] data, float[] filter) { - float kFilteringFactor = 0.1f; - - filter[0] = data[0] * kFilteringFactor + filter[0] - * (1.0f - kFilteringFactor); - filter[1] = data[1] * kFilteringFactor + filter[1] - * (1.0f - kFilteringFactor); - filter[2] = data[2] * kFilteringFactor + filter[2] - * (1.0f - kFilteringFactor); - data[0] = data[0] - filter[0]; - data[1] = data[1] - filter[1]; - data[2] = data[2] - filter[2]; - - filter[0] = data[0]; - filter[1] = data[1]; - filter[2] = data[2]; - } - - private void filterAccData() { - if (!accinited) { - accel[0] = mGData[0]; - accel[1] = mGData[1]; - accel[2] = mGData[2]; - accinited = true; - } - filterData(mGData, accel); - } - - Boolean maginited = false; - float[] mag = new float[3]; - - private void filterMagData() { - if (!maginited) { - mag[0] = mMData[0]; - mag[1] = mMData[1]; - mag[2] = mMData[2]; - maginited = true; - } - filterData(mMData, mag); - } - - Boolean orinited = false; - float[] ordata = new float[3]; - - private void filterOrientationData() { - if (!orinited) { - ordata[0] = mOrientation[0]; - ordata[1] = mOrientation[1]; - ordata[2] = mOrientation[2]; - orinited = true; - } - filterData(mOrientation, ordata); - } - - @Override - public void onLocationChanged(Location loc) { - String res = ""; - res += loc.getLongitude() + ";" - + loc.getLatitude() + ";" - + loc.getAltitude() + ";" - + loc.getAccuracy() + ";" - + loc.getBearing() + ";"; - sendData(InternalPtr, res); - } - - @Override - public void onProviderDisabled(String arg0) { - // TODO Auto-generated method stub - - } - - @Override - public void onProviderEnabled(String arg0) { - // TODO Auto-generated method stub - - } - - @Override - public void onStatusChanged(String arg0, int arg1, Bundle arg2) { - // TODO Auto-generated method stub - - } - -} - diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4.java deleted file mode 100644 index d72b197..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4.java +++ /dev/null @@ -1,1383 +0,0 @@ -/** - * Osmo on Android - * Aug/2010 - * NGO Van Luyen - * $Id$ - * - */ -package com.gpac.Osmo4; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.HashMap; -import java.util.Set; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.ProgressDialog; -import android.content.ActivityNotFoundException; -import android.content.Context; -import android.content.DialogInterface; -import android.content.DialogInterface.OnClickListener; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.res.Configuration; -import android.hardware.SensorManager; -import android.location.LocationManager; -import android.net.Uri; -import android.os.Bundle; -import android.os.PowerManager; -import android.os.PowerManager.WakeLock; -import android.os.StrictMode; -import android.os.Vibrator; -import android.text.InputType; -import android.util.Log; -import android.view.View; -import android.view.KeyEvent; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.view.inputmethod.InputMethodManager; -import android.widget.ArrayAdapter; -import android.widget.AutoCompleteTextView; -import android.widget.LinearLayout; -import android.widget.Toast; -import android.content.res.AssetManager; -import android.os.Environment; - - -import android.os.Handler; -import android.os.Message; -import android.view.GestureDetector; -import android.view.MotionEvent; - -import com.gpac.Osmo4.Osmo4GLSurfaceView; -import com.gpac.Osmo4.Preview; -import com.gpac.Osmo4.R; -import com.gpac.Osmo4.extra.ConfigFileEditorActivity; -import com.gpac.Osmo4.extra.FileChooserActivity; -import com.gpac.Osmo4.extra.PrefsActivity; -import com.gpac.Osmo4.logs.GpacLogger; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; - -import com.lge.real3d.Real3D; -import com.lge.real3d.Real3DInfo; -/** - * The main Osmo4 activity, used to launch everything - * - * @version $Revision$ - * - */ -public class Osmo4 extends Activity implements GpacCallback { - - // private String[] m_modules_list; - private static final int INITIAL_HIDE_DELAY = 300; - - public boolean m3DLibraryLoaded = false; - private Real3D mReal3D; - private View mDecorView; - - private boolean shouldDeleteGpacConfig = false; - - /** - * @return the shouldDeleteGpacConfig - */ - public synchronized boolean isShouldDeleteGpacConfig() { - return shouldDeleteGpacConfig; - } - - /** - * @param shouldDeleteGpacConfig the shouldDeleteGpacConfig to set - */ - public synchronized void setShouldDeleteGpacConfig(boolean shouldDeleteGpacConfig) { - this.shouldDeleteGpacConfig = shouldDeleteGpacConfig; - } - - private final static String CFG_STARTUP_CATEGORY = "General"; //$NON-NLS-1$ - - private final static String CFG_STARTUP_NAME = "StartupFile"; //$NON-NLS-1$ - - private static boolean keyboardIsVisible = false; - - private final static int DEFAULT_BUFFER_SIZE = 8192; - - private static boolean uivisible; - - public static Context context; - - private GpacConfig gpacConfig; - - /** - * Activity request ID for picking a file from local file system - */ - public final static int PICK_FILE_REQUEST = 1; - - private final static String LOG_OSMO_TAG = "Osmo4"; //$NON-NLS-1$ - - /** - * List of all extensions recognized by Osmo - */ - public final static String OSMO_REGISTERED_FILE_EXTENSIONS = "*.mp4,*.bt,*.xmt,*.xml,*.ts,*.svg,*.mp3,*.m3u8,*.mpg,*.aac,*.m4a,*.jpg,*.png,*.wrl,*.mpd"; //$NON-NLS-1$ - - private PowerManager.WakeLock wl = null; - - private Osmo4GLSurfaceView mGLView; - - private GpacLogger logger; - - private ProgressDialog startupProgress; - - private LinearLayout gl_view; - - /** - * Handling of Sensors - */ - private SensorServices sensors; - - // --------------------------------------- - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - context = getApplicationContext(); - - try { - Class c = Class.forName("com.lge.real3d.Real3D"); - final String LGE_3D_DISPLAY = "lge.hardware.real3d.barrier.landscape"; - if(this.getPackageManager().hasSystemFeature(LGE_3D_DISPLAY)) - m3DLibraryLoaded = true; - } - catch (ClassNotFoundException e) { - m3DLibraryLoaded = false; - } - MPEGVSensor.myAct = this; - MPEGVSensor.initSensorManager((SensorManager) getSystemService(Context.SENSOR_SERVICE)); - MPEGVSensor.initLocationManager((LocationManager)getSystemService(Context.LOCATION_SERVICE)); - - final String toOpen; - if (Intent.ACTION_VIEW.equals(getIntent().getAction())) { - Uri uri = getIntent().getData(); - if (uri != null) { - synchronized (this) { - toOpen = uri.toString(); - } - } else - toOpen = null; - } else - toOpen = null; - if (gpacConfig == null) { - gpacConfig = new GpacConfig(this); - if (gpacConfig == null) { - Log.e(LOG_OSMO_TAG, "Failed to load GPAC config"); //$NON-NLS-1$ - displayPopup(getResources().getString(R.string.failedToLoadGPACConfig), - getResources().getString(R.string.failedToLoadGPACConfig)); - } else - gpacConfig.ensureAllDirectoriesExist(); - } - if (logger == null) - logger = new GpacLogger(gpacConfig); - logger.onCreate(); - if (startupProgress == null) { - startupProgress = new ProgressDialog(this); - startupProgress.setCancelable(false); - } - startupProgress.setMessage(getResources().getText(R.string.osmoLoading)); - startupProgress.setTitle(R.string.osmoLoading); - startupProgress.show(); - - if (mGLView != null) { - setContentView(R.layout.main); - if (toOpen != null) - openURLasync(toOpen); - // OK, it means activity has already been started - return; - } - Preview.context = this; - - setContentView(R.layout.main); - - final View contentView = (LinearLayout)findViewById(R.id.surface_gl); - mDecorView = getWindow().getDecorView(); - - mDecorView.setOnSystemUiVisibilityChangeListener - (new View.OnSystemUiVisibilityChangeListener() { - @Override - public void onSystemUiVisibilityChange(int visibility) { - if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { - uivisible = true; - } else { - uivisible = false; - } - } - }); - - contentView.setClickable(true); - final GestureDetector clickDetector = new GestureDetector(this, - new GestureDetector.SimpleOnGestureListener() { - @Override - public boolean onSingleTapUp(MotionEvent e) { - if (uivisible) { - if (Osmo4.this.keyboardIsVisible) - ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(mGLView.getWindowToken(), 0); - hideSystemUI(); - } - return true; - } - }); - contentView.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View view, MotionEvent motionEvent) { - return clickDetector.onTouchEvent(motionEvent); - } - }); - - showSystemUI(); - mGLView = new Osmo4GLSurfaceView(this); - - gl_view = (LinearLayout)findViewById(R.id.surface_gl); - - sensors = new SensorServices(this); - - if( m3DLibraryLoaded ) //should be checking wether the terminal is a LG one - { - //TryLoad3DClass(true); - mReal3D = new Real3D(mGLView.getHolder()); - mReal3D.setReal3DInfo(new Real3DInfo(true, Real3D.REAL3D_TYPE_SS, Real3D.REAL3D_ORDER_LR)); - } - service.submit(new Runnable() { - - @Override - public void run() { - // loadAllModules(); - runOnUiThread(new Runnable() { - - @Override - public void run() { - startupProgress.setIndeterminate(true); - startupProgress.setMessage(getResources().getText(R.string.gpacLoading)); - PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, LOG_OSMO_TAG); - if (wl != null) - wl.acquire(); - synchronized (Osmo4.this) { - Osmo4.this.wl = wl; - } - - Osmo4Renderer renderer = new Osmo4Renderer(Osmo4.this, gpacConfig, toOpen); - mGLView.setRenderer(renderer); - - gl_view.addView(mGLView); - - sensors.setRenderer(renderer); - } - }); - - } - }); - // creates no media files if it does not exist - service.submit(new Runnable() { - - @Override - public void run() { - for (String s : new String[] { gpacConfig.getGpacAppDirectory(), gpacConfig.getGpacCacheDirectory() }) { - File noMedia = new File(s, ".nomedia"); //$NON-NLS-1$ - if (!noMedia.exists()) { - try { - noMedia.createNewFile(); - } catch (IOException e) { - Log.w(LOG_OSMO_TAG, "Failed to create " + noMedia.getAbsolutePath(), e); //$NON-NLS-1$ - } - } - } - } - }); - - //copy GUI elements - File guiDir = new File(gpacConfig.getGpacGuiDirectory()); - if (!guiDir.isDirectory()) { - // there was a file which have the same name with GUI dir, delete it - if (guiDir.exists()) { - if (!guiDir.delete()) - Log.e(LOG_OSMO_TAG, "Failed to delete " + guiDir); - } - if (!guiDir.mkdir()) - Log.e(LOG_OSMO_TAG, "Failed to create directory " + guiDir); - copyAssets(gpacConfig, GUI_ROOT_ASSET_DIR); - } - - //copy Shaders - File shaderDir = new File(gpacConfig.getGpacShaderDirectory()); - if (!shaderDir.isDirectory()) { - // we do not delete the directory if it already exists, because it might contain custom shaders - if (shaderDir.exists()) { - Log.v(LOG_OSMO_TAG, "Shader directory already exists at: " + shaderDir); - }else if (!shaderDir.mkdir()){ - Log.e(LOG_OSMO_TAG, "Failed to create directory " + shaderDir); - } - } - copyAssets(gpacConfig, SHADER_ROOT_ASSET_DIR); - - //if there is not a GPAC.cfg in external storage (i.e using config in app directory) - //copy GPAC.cfg from gpacAppDirectoryto gpacLogDirectory - File osmo = new File(Environment.getExternalStorageDirectory(), "osmo"); - File gpac_external_cfg = new File(osmo.getAbsolutePath(), "GPAC.cfg"); - if (!gpac_external_cfg.exists()) { - try { - InputStream in = new FileInputStream(gpacConfig.getGpacAppDirectory() + "GPAC.cfg"); - OutputStream out = new FileOutputStream(gpacConfig.getGpacLogDirectory() + "GPAC.cfg"); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - in.close(); - out.close(); - } catch (IOException e) { - Log.d(LOG_OSMO_TAG, "Error in copying config file: " + e.toString()); - } - } - - } - - /* - * Copy GUI elements - * - * @param config - * - * Reference: http://stackoverflow.com/questions/4447477/android-how-to-copy-files-from-assets-folder-to-sdcard - */ - private final static String GUI_ROOT_ASSET_DIR = "gui"; - private final static String SHADER_ROOT_ASSET_DIR = "shaders"; - - private void copyAssets(GpacConfig config, String asset_dir) { - StringBuilder sb = new StringBuilder(); - HashMap exceptions = new HashMap(); - AssetManager assetManager = getAssets(); - String[] list = null; - Log.d(LOG_OSMO_TAG, "Copy assets of " + asset_dir); - try { - list = assetManager.list(asset_dir); - } catch (IOException e) { - Log.e(LOG_OSMO_TAG, "Failed to get asset file list.", e); - exceptions.put("Failed to get asset file list", e); - } - for(String path : list) { - try { - copyFileOrDir(config, asset_dir, path); - } catch(IOException e) { - Log.e(LOG_OSMO_TAG, "Failed to copy: " + path, e); - exceptions.put("Failed to copy " + path, e); - } - } - - if (!exceptions.isEmpty()) { - try { - PrintStream out = new PrintStream(config.getGpacLogDirectory() + "debug_assets.txt", "UTF-8"); //$NON-NLS-1$//$NON-NLS-2$ - sb.append("*** Exceptions:\n"); //$NON-NLS-1$ - for (Map.Entry ex : exceptions.entrySet()) { - sb.append(ex.getKey()).append(": ") //$NON-NLS-1$ - .append(ex.getValue().getLocalizedMessage()) - .append('(') - .append(ex.getValue().getClass()) - .append(")\n"); //$NON-NLS-1$ - } - out.println(sb.toString()); - out.flush(); - out.close(); - } catch (Exception e) { - Log.e(LOG_OSMO_TAG, "Failed to output debug info to debug file", e); //$NON-NLS-1$ - } - } - } - - private void copyFileOrDir(GpacConfig config, String root, String path) throws IOException { - AssetManager assetManager = getAssets(); - String assets[] = null; - assets = assetManager.list(root + "/" + path); - if (assets.length == 0) { - copyFile(config, root, path); - } else { - String fullPath = null; - if(root == GUI_ROOT_ASSET_DIR){ - fullPath = config.getGpacGuiDirectory() + path; - }else if(root == SHADER_ROOT_ASSET_DIR){ - fullPath = config.getGpacShaderDirectory() + path; - }else{ //Fallback (useless for now) - fullPath = path; - } - File dir = new File(fullPath); - if (!dir.exists()) - dir.mkdir(); - for (int i = 0; i < assets.length; ++i) { - copyFileOrDir(config, root, path + "/" + assets[i]); - } - } - } - - private void copyFile(GpacConfig config, String root, String filename) throws IOException { - // if this file exists, do nothing - - if(root.equals(GUI_ROOT_ASSET_DIR)){ - if ((new File(config.getGpacGuiDirectory() + filename).exists())) - return; - } - - AssetManager assetManager = getAssets(); - InputStream in = null; - OutputStream out = null; - in = assetManager.open(root + "/" + filename); - - String newFileName = null; - if(root.equals(GUI_ROOT_ASSET_DIR)){ - newFileName = config.getGpacGuiDirectory() + filename; - }else if(root.equals(SHADER_ROOT_ASSET_DIR)){ - newFileName = config.getGpacShaderDirectory() + filename; - }else{ //Fallback - newFileName = filename; - } - out = new FileOutputStream(newFileName); - - byte[] buffer = new byte[1024]; - int read; - while ((read = in.read(buffer)) != -1) { - out.write(buffer, 0, read); - } - in.close(); - in = null; - out.flush(); - out.close(); - out = null; - } - - // --------------------------------------- - - public static boolean isUIvisible(){ - return uivisible; - } - - public static boolean IskeyboardVisible(){ - return keyboardIsVisible; - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.main_menu, menu); - return true; - } - - private String getRecentURLsFile() { - return gpacConfig.getGpacAppDirectory() + "recentURLs.txt"; //$NON-NLS-1$ - } - - private boolean openURL() { - Future res = service.submit(new Callable() { - - @Override - public String[] call() throws Exception { - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(new FileInputStream(getRecentURLsFile()), - DEFAULT_ENCODING), DEFAULT_BUFFER_SIZE); - - String s = null; - Set results = new HashSet(); - while (null != (s = reader.readLine())) { - results.add(s); - } - addAllRecentURLs(results); - return results.toArray(new String[0]); - } finally { - if (reader != null) - reader.close(); - } - } - }); - AlertDialog.Builder builder = new AlertDialog.Builder(this); - final AutoCompleteTextView textView = new AutoCompleteTextView(this); - textView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); - builder.setMessage(R.string.pleaseEnterAnURLtoConnectTo) - .setCancelable(true) - .setPositiveButton(R.string.open_url, new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int id) { - dialog.cancel(); - final String newURL = textView.getText().toString(); - openURLasync(newURL); - service.execute(new Runnable() { - - @Override - public void run() { - addAllRecentURLs(Collections.singleton(newURL)); - File tmp = new File(getRecentURLsFile() + ".tmp"); //$NON-NLS-1$ - BufferedWriter w = null; - try { - w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tmp), - DEFAULT_ENCODING), DEFAULT_BUFFER_SIZE); - Collection toWrite = getAllRecentURLs(); - for (String s : toWrite) { - w.write(s); - w.write("\n"); //$NON-NLS-1$ - } - w.close(); - w = null; - if (tmp.renameTo(new File(getRecentURLsFile()))) - Log.e(LOG_OSMO_TAG, "Failed to rename " + tmp + " to " + getRecentURLsFile()); //$NON-NLS-1$//$NON-NLS-2$ - - } catch (IOException e) { - Log.e(LOG_OSMO_TAG, "Failed to write recent URLs to " + tmp, e); //$NON-NLS-1$ - try { - if (w != null) - w.close(); - } catch (IOException ex) { - Log.e(LOG_OSMO_TAG, "Failed to close stream " + tmp, ex); //$NON-NLS-1$ - } - } - - } - }); - } - }) - .setNegativeButton(R.string.cancel_button, null); - - textView.setText("http://"); //$NON-NLS-1$ - builder.setView(textView); - - builder.show(); - ArrayAdapter adapter; - try { - adapter = new ArrayAdapter(this, - android.R.layout.simple_dropdown_item_1line, - res.get(1, TimeUnit.SECONDS)); - textView.setAdapter(adapter); - } catch (ExecutionException e) { - // Ignored - Log.e(LOG_OSMO_TAG, "Error while parsing recent URLs", e); //$NON-NLS-1$ - } catch (TimeoutException e) { - Log.e(LOG_OSMO_TAG, "It took too long to parse recent URLs", e); //$NON-NLS-1$ - } catch (InterruptedException e) { - Log.e(LOG_OSMO_TAG, "Interrupted while parsing recent URLs", e); //$NON-NLS-1$ - } - - return true; - } - - private final ExecutorService service = Executors.newSingleThreadExecutor(); - - private final Set allRecentURLs = new HashSet(); - - private synchronized void addAllRecentURLs(Collection urlsToAdd) { - allRecentURLs.addAll(urlsToAdd); - } - - private synchronized Collection getAllRecentURLs() { - return new ArrayList(allRecentURLs); - } - - private final static Charset DEFAULT_ENCODING = Charset.forName("UTF-8"); //$NON-NLS-1$ - - /** - * Opens a new activity to select a file - * - * @return true if activity has been selected - */ - private boolean openFileDialog() { - String title = getResources().getString(R.string.pleaseSelectAFile); - Uri uriDefaultDir = Uri.fromFile(new File(gpacConfig.getGpacAppDirectory())); - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_PICK); - // Files and directories - intent.setDataAndType(uriDefaultDir, "vnd.android.cursor.dir/lysesoft.andexplorer.file"); //$NON-NLS-1$ - // Optional filtering on file extension. - intent.putExtra("browser_filter_extension_whitelist", OSMO_REGISTERED_FILE_EXTENSIONS); //$NON-NLS-1$ - // Title - intent.putExtra("explorer_title", title); //$NON-NLS-1$ - - try { - startActivityForResult(intent, PICK_FILE_REQUEST); - return true; - } catch (ActivityNotFoundException e) { - // OK, lets try with another one... (it includes out bundled one) - intent = new Intent("org.openintents.action.PICK_FILE"); //$NON-NLS-1$ - intent.setData(uriDefaultDir); - intent.putExtra(FileChooserActivity.TITLE_PARAMETER, title); - intent.putExtra("browser_filter_extension_whitelist", OSMO_REGISTERED_FILE_EXTENSIONS); //$NON-NLS-1$ - try { - startActivityForResult(intent, PICK_FILE_REQUEST); - return true; - } catch (ActivityNotFoundException ex) { - // Not found neither... We build our own dialog to display error - // Note that this should happen only if we did not embed out own intent - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage("Impossible to find an Intent to choose a file... Cannot open file !") //$NON-NLS-1$ - .setCancelable(true) - .setPositiveButton(R.string.cancel_button, null); - AlertDialog alert = builder.create(); - alert.show(); - return false; - } - } - } - - // --------------------------------------- - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent intent) { - if (requestCode == PICK_FILE_REQUEST) { - if (resultCode == RESULT_OK) { - Uri uri = intent.getData(); - if (uri != null) { - String url = uri.toString(); - String file = "file://"; //$NON-NLS-1$ - if (url.startsWith(file)) { - url = uri.getPath(); - } - Log.i(LOG_OSMO_TAG, "Requesting opening local file " + url); //$NON-NLS-1$ - openURLasync(url); - } - } - } - } - - private String currentURL; - - private void openURLasync(final String url) { - service.execute(new Runnable() { - - @Override - public void run() { - mGLView.connect(url); - currentURL = url; - runOnUiThread(new Runnable() { - - @Override - public void run() { - setTitle(getResources().getString(R.string.titleWithURL, url)); - } - }); - } - }); - } - - // --------------------------------------- - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - } - - // --------------------------------------- - - private int last_orientation = 0; - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle item selection - switch (item.getItemId()) { - case R.id.open_url: - return openURL(); - case R.id.open_file: - // newGame(); - return openFileDialog(); - case R.id.cleanCache: - return cleanCache(); - case R.id.showVirtualKeyboard: - showKeyboard(!keyboardIsVisible); - return true; - case R.id.reloadFile: - openURLasync(currentURL); - return true; - case R.id.autoRotate: - if (item.isChecked()) { - item.setChecked(false); - last_orientation = this.getRequestedOrientation(); - int ornt = getResources().getConfiguration().orientation; - if (ornt == Configuration.ORIENTATION_PORTRAIT) - this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - else - this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - } else { - item.setChecked(true); - this.setRequestedOrientation(last_orientation); - } - return true; - case R.id.enableDebug: - if (item.isChecked()) { - item.setChecked(false); - mGLView.setGpacLogs("all@error"); //$NON-NLS-1$ - } else { - item.setChecked(true); - mGLView.setGpacLogs("sync:codec:dash:media@debug:container@warning"); //$NON-NLS-1$ - } - return true; - case R.id.setAsStartupFile: { - AlertDialog.Builder b = new AlertDialog.Builder(this); - b.setTitle(R.string.setAsStartupFileTitle); - if (currentURL != null) { - b.setMessage(getResources().getString(R.string.setAsStartupFileMessage, currentURL)); - b.setPositiveButton(R.string.setAsStartupFileYes, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - mGLView.setGpacPreference(CFG_STARTUP_CATEGORY, CFG_STARTUP_NAME, currentURL); - } - }); - } else { - b.setMessage(getResources().getString(R.string.setAsStartupFileMessageNoURL)); - } - b.setNegativeButton(R.string.setAsStartupFileNo, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - } - }); - b.setNeutralButton(R.string.setAsStartupFileNull, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - mGLView.setGpacPreference(CFG_STARTUP_CATEGORY, CFG_STARTUP_NAME, null); - } - }); - b.show(); - return true; - } - case R.id.resetGpacConfig: { - AlertDialog.Builder b = new AlertDialog.Builder(this); - b.setCancelable(true) - .setTitle(R.string.resetGpacConfig) - .setMessage(R.string.resetGpacConfigMessage) - .setNegativeButton(R.string.cancel_button, null) - .setPositiveButton(R.string.ok_button, new OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - setShouldDeleteGpacConfig(true); - deleteConfigIfNeeded(); - } - }) - .show(); - return true; - } - - case R.id.configFileEditor: { - Intent i = new Intent(Osmo4.this, ConfigFileEditorActivity.class); - startActivity(i); - return true; - } - - case R.id.about: { - Dialog d = new Dialog(this); - d.setTitle(R.string.aboutTitle); - d.setCancelable(true); - d.setContentView(R.layout.about_dialog); - d.show(); - } - return true; - - case R.id.preferences:{ - Intent i = new Intent(Osmo4.this, PrefsActivity.class); - startActivity(i); - return true; - } - - case R.id.quit: - if ( mGLView != null ) - mGLView.disconnect(); - this.finish(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - /** - * Cleans GPAC cache - * - * @return true if successful - */ - protected boolean cleanCache() { - final CharSequence oldTitle = getTitle(); - runOnUiThread(new Runnable() { - - @Override - public void run() { - startupProgress.setTitle(R.string.cleaningCache); - startupProgress.setMessage(getResources().getString(R.string.cleaningCache, - gpacConfig.getGpacCacheDirectory())); - startupProgress.setProgress(0); - startupProgress.setIndeterminate(false); - startupProgress.show(); - } - }); - service.submit(new Runnable() { - - @Override - public void run() { - File dir = new File(gpacConfig.getGpacCacheDirectory()); - if (!dir.exists() || !dir.canRead() || !dir.canWrite() || !dir.isDirectory()) { - return; - } - File files[] = dir.listFiles(); - int i = 0; - for (File f : files) { - if (f.isFile()) - if (!f.delete()) { - Log.w(LOG_OSMO_TAG, "Failed to delete file " + f); //$NON-NLS-1$ - } else { - Log.v(LOG_OSMO_TAG, f + " has been deleted"); //$NON-NLS-1$ - } - final int percent = (++i) * 100 / files.length; - runOnUiThread(new Runnable() { - - @Override - public void run() { - startupProgress.setProgress(percent); - } - }); - } - runOnUiThread(new Runnable() { - - @Override - public void run() { - startupProgress.setProgress(100); - startupProgress.setTitle(oldTitle); - startupProgress.dismiss(); - } - }); - } - }); - return true; - } - - private void deleteConfigIfNeeded() { - if (isShouldDeleteGpacConfig()) { - Log.i(LOG_OSMO_TAG, "Deleting GPAC config file..."); //$NON-NLS-1$ - File f = gpacConfig.getGpacConfigFile(); - if (f.exists() && !f.delete()) { - Log.e(LOG_OSMO_TAG, "Failed to delete " + f.getAbsolutePath()); //$NON-NLS-1$ - } - f = gpacConfig.getGpacLastRevFile(); - if (f.exists() && !f.delete()) { - Log.e(LOG_OSMO_TAG, "Failed to delete " + f.getAbsolutePath()); //$NON-NLS-1$ - } - } - } - - // --------------------------------------- - @Override - protected void onDestroy() { - deleteConfigIfNeeded(); - service.shutdown(); - logger.onDestroy(); - synchronized (this) { - if (wl != null) - wl.release(); - } - Log.d(LOG_OSMO_TAG, "Disconnecting instance..."); //$NON-NLS-1$ - mGLView.disconnect(); - Log.d(LOG_OSMO_TAG, "Destroying GPAC instance..."); //$NON-NLS-1$ - mGLView.destroy(); - // Deleteing is done two times if GPAC fails to shutdown by crashing... - deleteConfigIfNeeded(); - super.onDestroy(); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - // Handle the back button - if (keyCode == KeyEvent.KEYCODE_BACK) { - // Ask the user if they want to quit - new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert) - .setTitle(R.string.quit) - .setMessage(R.string.really_quit) - .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - - // Stop the activity - if ( mGLView != null ) - mGLView.disconnect(); - Osmo4.this.finish(); - } - - }) - .setNegativeButton(R.string.no, null) - .show(); - - return true; - } else { - return super.onKeyDown(keyCode, event); - } - - } - - // --------------------------------------- - // private void loadAllModules() { - // Log.i(LOG_OSMO_TAG, "Start loading all modules..."); //$NON-NLS-1$ - // long start = System.currentTimeMillis(); - // byte buffer[] = new byte[1024]; - // int[] ids = getAllRawResources(); - // String currentRevision = "$Revision$"; //$NON-NLS-1$ - // File revisionFile = gpacConfig.getGpacLastRevFile(); - // boolean fastStartup = false; - // // We check if we already copied all the modules once without error... - // if (revisionFile.exists() && revisionFile.canRead()) { - // BufferedReader r = null; - // try { - // r = new BufferedReader(new InputStreamReader(new FileInputStream(revisionFile), DEFAULT_ENCODING), - // DEFAULT_BUFFER_SIZE); - // String rev = r.readLine(); - // if (currentRevision.equals(rev)) { - // fastStartup = true; - // } - // } catch (IOException ignored) { - // } finally { - // // Exception or not, always close the stream... - // if (r != null) - // try { - // r.close(); - // } catch (IOException ignored) { - // } - // } - // } - // boolean noErrors = true; - // final StringBuilder errorsMsg = new StringBuilder(); - // for (int i = 0; i < ids.length; i++) { - // OutputStream fos = null; - // InputStream ins = null; - // String fn = gpacConfig.getGpacModulesDirectory() + m_modules_list[i] + ".so"; //$NON-NLS-1$ - // File finalFile = new File(fn); - // // If file has already been copied, not need to do it again - // if (fastStartup && finalFile.exists() && finalFile.canRead()) { - // Log.i(LOG_OSMO_TAG, "Skipping " + finalFile); //$NON-NLS-1$ - // continue; - // } - // try { - // final String msg = getResources().getString(R.string.copying_native_libs, - // finalFile.getName(), - // finalFile.getParent()); - // runOnUiThread(new Runnable() { - // - // @Override - // public void run() { - // startupProgress.setIndeterminate(false); - // startupProgress.setMessage(msg); - // } - // }); - // Log.i(LOG_OSMO_TAG, "Copying resource " + ids[i] + " to " //$NON-NLS-1$//$NON-NLS-2$ - // + finalFile.getAbsolutePath()); - // File tmpFile = new File(fn + ".tmp"); //$NON-NLS-1$ - // int read; - // ins = new BufferedInputStream(getResources().openRawResource(ids[i]), DEFAULT_BUFFER_SIZE); - // fos = new BufferedOutputStream(new FileOutputStream(tmpFile), DEFAULT_BUFFER_SIZE); - // while (0 < (read = ins.read(buffer))) { - // fos.write(buffer, 0, read); - // } - // ins.close(); - // ins = null; - // fos.close(); - // fos = null; - // if (!tmpFile.renameTo(finalFile)) { - // if (finalFile.exists() && finalFile.delete() && !tmpFile.renameTo(finalFile)) - // Log.e(LOG_OSMO_TAG, "Failed to rename " + tmpFile.getAbsolutePath() + " to " //$NON-NLS-1$//$NON-NLS-2$ - // + finalFile.getAbsolutePath()); - // } - // final int percent = i * 10000 / ids.length; - // runOnUiThread(new Runnable() { - // - // @Override - // public void run() { - // startupProgress.setProgress(percent); - // } - // }); - // } catch (IOException e) { - // noErrors = false; - // String msg = "IOException for resource : " + ids[i]; //$NON-NLS-1$ - // errorsMsg.append(msg).append('\n').append(finalFile.getAbsolutePath()).append('\n'); - // errorsMsg.append(e.getLocalizedMessage()); - // Log.e(LOG_OSMO_TAG, msg, e); - // } finally { - // if (ins != null) { - // try { - // ins.close(); - // } catch (IOException e) { - // Log.e(LOG_OSMO_TAG, "Error while closing read stream", e); //$NON-NLS-1$ - // } - // } - // if (fos != null) { - // try { - // fos.close(); - // } catch (IOException e) { - // Log.e(LOG_OSMO_TAG, "Error while closing write stream", e); //$NON-NLS-1$ - // } - // } - // } - // } - // // If no error during copy, fast startup will be enabled for next time - // if (noErrors && !fastStartup) { - // BufferedWriter w = null; - // try { - // w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(revisionFile), DEFAULT_ENCODING), - // DEFAULT_BUFFER_SIZE); - // w.write(currentRevision); - // w.write('\n'); - // // We add the date as second line to ease debug in case of problem - // w.write(String.valueOf(new Date())); - // } catch (IOException ignored) { - // } finally { - // if (w != null) - // try { - // w.close(); - // } catch (IOException ignored) { - // } - // } - // } else { - // if (!noErrors) { - // setShouldDeleteGpacConfig(true); - // displayMessage(errorsMsg.toString(), "Errors while copying modules !", GF_Err.GF_IO_ERR.value); //$NON-NLS-1$ - // } - // } - // Log.i(LOG_OSMO_TAG, "Done loading all modules, took " + (System.currentTimeMillis() - start) + "ms."); //$NON-NLS-1$ //$NON-NLS-2$ - // startupProgress.setProgress(100); - // startupProgress.setIndeterminate(true); - // runOnUiThread(new Runnable() { - // - // @Override - // public void run() { - // setTitle(LOG_OSMO_TAG); - // } - // }); - // } - - // private int[] getAllRawResources() throws RuntimeException { - // R.raw r = new R.raw(); - // - // java.lang.reflect.Field fields[] = R.raw.class.getDeclaredFields(); - // final int ids[] = new int[fields.length]; - // m_modules_list = new String[fields.length]; - // - // try { - // for (int i = 0; i < fields.length; i++) { - // java.lang.reflect.Field f = fields[i]; - // ids[i] = f.getInt(r); - // m_modules_list[i] = f.getName(); - // Log.i(LOG_OSMO_TAG, "R.raw." + f.getName() + " = 0x" + Integer.toHexString(ids[i])); //$NON-NLS-1$ //$NON-NLS-2$ - // } - // } catch (IllegalArgumentException e) { - // throw new RuntimeException(e); - // } catch (IllegalAccessException e) { - // throw new RuntimeException(e); - // } - // - // return ids; - // } - - // --------------------------------------- - - private String lastDisplayedMessage; - - private void displayPopup(final CharSequence message, final CharSequence title) { - final String fullMsg = getResources().getString(R.string.displayPopupFormat, title, message); - synchronized (this) { - // In case of an error message, always popup it - if (fullMsg.equals(lastDisplayedMessage) && !title.equals("Error")) - return; - lastDisplayedMessage = fullMsg; - } - runOnUiThread(new Runnable() { - - @Override - public void run() { - Toast toast = Toast.makeText(Osmo4.this, fullMsg, Toast.LENGTH_SHORT); - toast.show(); - } - }); - - } - - /** - * @see com.gpac.Osmo4.GpacCallback#displayMessage(String, String, int) - */ - @Override - public void displayMessage(final String message, final String title, final int status) { - if (status == GF_Err.GF_OK.value) { - // displayPopup(message, title); - Log.d(LOG_OSMO_TAG, message); - } else { - runOnUiThread(new Runnable() { - - @Override - public void run() { - StringBuilder sb = new StringBuilder(); - sb.append(GF_Err.getError(status)); - sb.append(' '); - sb.append(title); - AlertDialog.Builder builder = new AlertDialog.Builder(Osmo4.this); - builder.setTitle(sb.toString()); - sb.append('\n'); - sb.append(message); - builder.setMessage(sb.toString()); - builder.setCancelable(true); - builder.setPositiveButton(R.string.ok_button, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - } - }); - try { - builder.create().show(); - } catch (WindowManager.BadTokenException e) { - // May happen when we close the window and there are still somes messages - Log.e(LOG_OSMO_TAG, "Failed to display Message " + sb.toString(), e); //$NON-NLS-1$ - } - } - }); - } - } - - /** - * @see com.gpac.Osmo4.GpacCallback#onLog(int, int, String) - */ - @Override - public void onLog(int level, int module, String message) { - logger.onLog(level, module, message); - if (level == Log.ERROR) - displayPopup(message, "Error"); - } - - /** - * @see com.gpac.Osmo4.GpacCallback#onProgress(java.lang.String, int, int) - */ - @Override - public void onProgress(final String msg, final int done, final int total) { - if (Log.isLoggable(LOG_OSMO_TAG, Log.DEBUG)) - Log.d(LOG_OSMO_TAG, "Setting progress to " + done + "/" + total + ", message=" + msg); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - runOnUiThread(new Runnable() { - - @Override - public void run() { - // GPAC sometimes return total = 0 - if (total < 1) { - setProgressBarIndeterminate(true); - } else { - int progress = done * 10000 / (total < 1 ? 1 : total); - if (progress > 9900) - progress = 10000; - setProgressBarIndeterminate(false); - setProgress(progress); - } - } - }); - } - - /** - * @see com.gpac.Osmo4.GpacCallback#onGPACReady() - */ - @Override - public void onGPACReady() { - startupProgress.dismiss(); - Log.i(LOG_OSMO_TAG, "GPAC is ready"); //$NON-NLS-1$ - } - - /** - * @see com.gpac.Osmo4.GpacCallback#onGPACError(java.lang.Throwable) - */ - @Override - public void onGPACError(final Throwable e) { - startupProgress.dismiss(); - Log.e(LOG_OSMO_TAG, "GPAC Error", e); //$NON-NLS-1$ - runOnUiThread(new Runnable() { - - @Override - public void run() { - // In such case, we force GPAC Configuration file deletion - setShouldDeleteGpacConfig(true); - StringBuilder sb = new StringBuilder(); - sb.append("Failed to init GPAC due to "); //$NON-NLS-1$ - sb.append(e.getClass().getSimpleName()); - AlertDialog.Builder builder = new AlertDialog.Builder(Osmo4.this); - builder.setTitle(sb.toString()); - sb.append('\n'); - sb.append("Description: "); //$NON-NLS-1$ - sb.append(e.getLocalizedMessage()); - sb.append('\n'); - sb.append("Revision: $Revision$"); //$NON-NLS-1$ - sb.append("\nConfiguration information :\n") //$NON-NLS-1$ - .append(gpacConfig.getConfigAsText()); - builder.setMessage(sb.toString()); - builder.setCancelable(true); - builder.setPositiveButton(R.string.ok_button, new OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.cancel(); - } - }); - builder.create().show(); - } - }); - } - - @Override - protected void onPause() { - super.onPause(); - if (mGLView != null) - mGLView.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - if (mGLView != null) - mGLView.onResume(); - } - - /** - * @see com.gpac.Osmo4.GpacCallback#setCaption(java.lang.String) - */ - @Override - public void setCaption(final String newCaption) { - runOnUiThread(new Runnable() { - - @Override - public void run() { - setTitle(newCaption); - } - }); - } - - /** - * @see android.app.Activity#onStop() - */ - @Override - protected void onStop() { - Log.i(LOG_OSMO_TAG, "onStop called on activity"); //$NON-NLS-1$ - super.onStop(); - } - - /** - * @see com.gpac.Osmo4.GpacCallback#showKeyboard(boolean) - */ - @Override - public void showKeyboard(boolean showKeyboard) { - this.keyboardIsVisible = showKeyboard; - - runOnUiThread(new Runnable() { - - @Override - public void run() { - InputMethodManager mgr = ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE)); - if ( Osmo4.this.keyboardIsVisible ){ - mgr.showSoftInput(mGLView, 0); - getActionBar().hide(); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); - } - else{ - mgr.hideSoftInputFromWindow(mGLView.getWindowToken(), 0); - getActionBar().show(); - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); - } - //mgr.toggleSoftInputFromWindow(mGLView.getWindowToken(), 0, 0); - mGLView.requestFocus(); - } - }); - } - @Override - public void onWindowFocusChanged(boolean hasFocus) { - super.onWindowFocusChanged(hasFocus); - - // When the window loses focus (e.g. the action overflow is shown), - // cancel any pending hide action. When the window gains focus, - // hide the system UI. - if (hasFocus) { - delayedHide(INITIAL_HIDE_DELAY); - } else { - mHideHandler.removeMessages(0); - } - } - - public void setLogFile(String logfile) { - logger.setEnableLogOnDisk(true); - logger.setLogFile(logfile); - logger.onCreate(); - } - - private void hideSystemUI() { - mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_LOW_PROFILE - | View.SYSTEM_UI_FLAG_IMMERSIVE); - } - - private void showSystemUI() { - mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } - - private final Handler mHideHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - hideSystemUI(); - } - }; - - private void delayedHide(int delayMillis) { - mHideHandler.removeMessages(0); - mHideHandler.sendEmptyMessageDelayed(0, delayMillis); - } - /** - * @see com.gpac.Osmo4.GpacCallback#sensorSwitch(boolean) - */ - @Override - public void sensorSwitch(final boolean active) { - if(active){ - //this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); - sensors.registerSensors(); - Log.i(LOG_OSMO_TAG, "Received Register Sensors call"); - }else{ - sensors.unregisterSensors(); - Log.i(LOG_OSMO_TAG, "Received Un-Register Sensors call"); - } - } - -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4GLSurfaceView.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4GLSurfaceView.java deleted file mode 100644 index f45aa9e..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4GLSurfaceView.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.gpac.Osmo4; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.widget.Toast; - -/** - * The view represented the blitted contents by libgpac - * - * @version $Revision$ - * - */ -public class Osmo4GLSurfaceView extends GLSurfaceView implements GPACInstanceInterface { - - private final static String LOG_GL_SURFACE = Osmo4GLSurfaceView.class.getSimpleName(); - - /** - * Constructor - * - * @param context - */ - public Osmo4GLSurfaceView(Context context) { - super(context); - setEGLContextClientVersion(2); - setPreserveEGLContextOnPause(true); - setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS); - setFocusable(true); - setFocusableInTouchMode(true); - } - - private Osmo4Renderer gpacRenderer; - - /** - * Set the renderer - * - * @param renderer - */ - public void setRenderer(Osmo4Renderer renderer) { - synchronized (this) { - this.gpacRenderer = renderer; - } - super.setRenderer(renderer); - setRenderMode(RENDERMODE_CONTINUOUSLY); - } - - private synchronized Osmo4Renderer getGpacRenderer() { - return gpacRenderer; - } - - private GPACInstance getInstance() { - Osmo4Renderer r = getGpacRenderer(); - if (r == null) - return null; - return r.getInstance(); - } - - // ------------------------------------ - @Override - public boolean onTouchEvent(final MotionEvent event) { - if(!Osmo4.isUIvisible() | Osmo4.IskeyboardVisible()){ - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.motionEvent(event); - } - }); - return true; - } - return false; - } - - /** - * Should we handle this key in GPAC ? - * - * @param keyCode - * @param event - * @return - */ - private static final long TIME_INTERVAL = 500; - private static long mBackPressed; - private static boolean handleInGPAC(int keyCode, KeyEvent event) { - if (event.isSystem() && keyCode!=KeyEvent.KEYCODE_BACK) - return false; - switch (keyCode) { - case KeyEvent.KEYCODE_MEDIA_STOP: - case KeyEvent.KEYCODE_MENU: - return false; - case KeyEvent.KEYCODE_BACK: - if (mBackPressed + TIME_INTERVAL > System.currentTimeMillis()){ - return false; - } - return true; - default: - return true; - } - } - - @Override - public boolean onKeyDown(final int keyCode, final KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) Toast.makeText(Osmo4.context, "Press back button twice to exit", Toast.LENGTH_SHORT).show(); - if (handleInGPAC(keyCode, event)) { - Log.d(LOG_GL_SURFACE, "onKeyDown = " + keyCode); //$NON-NLS-1$ - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.eventKey(keyCode, event, true, event.getUnicodeChar()); - } - }); - return true; - } - return false; - } - - // ------------------------------------ - @Override - public boolean onKeyUp(final int keyCode, final KeyEvent event) { - if (handleInGPAC(keyCode, event)) { - Log.d(LOG_GL_SURFACE, "onKeyUp =" + keyCode); //$NON-NLS-1$ - if (keyCode == KeyEvent.KEYCODE_BACK) mBackPressed = System.currentTimeMillis(); - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.eventKey(keyCode, event, false, event.getUnicodeChar()); - } - }); - return true; - } - return false; - } - - @Override - public void onResume() { - if (getInstance() != null) - super.onResume(); - } - - @Override - public void onPause() { - if (getInstance() != null) - super.onPause(); - } - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#connect(java.lang.String) - */ - @Override - public void connect(final String url) { - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.connect(url); - } - }); - } - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#disconnect() - */ - @Override - public void disconnect() { - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.disconnect(); - } - }); - } - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#destroy() - */ - @Override - public void destroy() { - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.destroy(); - } - }); - } - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#setGpacPreference(String, String, String) - */ - @Override - public void setGpacPreference(final String category, final String name, final String value) { - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.setGpacPreference(category, name, value); - } - }); - } - - /** - * @see com.gpac.Osmo4.GPACInstanceInterface#setGpacLogs(String tools_at_levels) - */ - @Override - public void setGpacLogs(final String tools_at_levels) { - queueEvent(new Runnable() { - - @Override - public void run() { - GPACInstance instance = getInstance(); - if (instance != null) - instance.setGpacLogs(tools_at_levels); - } - }); - } -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4Renderer.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4Renderer.java deleted file mode 100644 index a5065b9..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Osmo4Renderer.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.gpac.Osmo4; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; -import android.opengl.GLES20; -import android.opengl.GLSurfaceView; -import android.util.Log; - -/** - * The renderer - * - * @version $Revision$ - * - */ -public class Osmo4Renderer implements GLSurfaceView.Renderer { - - private final GpacConfig gpacConfig; - - private final static String LOG_RENDERER = Osmo4Renderer.class.getSimpleName(); - - @Override - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - if (instance == null) { - try { - Log.i(LOG_RENDERER, "Creating instance from thread " + Thread.currentThread()); //$NON-NLS-1$ - instance = new GPACInstance(callback, 320, 430, gpacConfig, urlToLoad); - } catch (com.gpac.Osmo4.GPACInstanceInterface.GpacInstanceException e) { - Log.e(LOG_RENDERER, "Failed to create new GPAC instance !"); //$NON-NLS-1$ - instance = null; - callback.onGPACError(e); - return; - } - if (callback != null) - callback.onGPACReady(); - } - } - - private GPACInstance instance = null; - - private final String urlToLoad; - - /** - * @return the urlToLoad - */ - public synchronized String getUrlToLoad() { - return urlToLoad; - } - - /** - * Constructor - * - * @param callback - * @param gpacConfig - * @param urlToLoad The URL to load at startup, can be null - */ - public Osmo4Renderer(GpacCallback callback, GpacConfig gpacConfig, String urlToLoad) { - this.callback = callback; - this.urlToLoad = urlToLoad; - this.gpacConfig = gpacConfig; - } - - private final GpacCallback callback; - - @Override - public void onSurfaceChanged(GL10 gl, int w, int h) { - // gl.glViewport(0, 0, w, h); - if (instance != null) { - Log.i(LOG_RENDERER, "Surface changed from thread " + Thread.currentThread()); //$NON-NLS-1$ - instance.resize(w, h); - } - } - - private int frames; - - private long startFrame = System.currentTimeMillis(); - - @Override - public void onDrawFrame(GL10 gl) { - if (instance != null) { - frames++; - if (frames % 1000 == 0) { - long now = System.currentTimeMillis(); - Log.i(LOG_RENDERER, "Frames Per Second = " + ((now - startFrame) / 1000) + " fps"); //$NON-NLS-1$//$NON-NLS-2$ - this.startFrame = now; - } - instance.render(); - } - } - - /** - * Get the current GPAC Instance - * - * @return the instance - */ - synchronized GPACInstance getInstance() { - return instance; - } -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Preview.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Preview.java deleted file mode 100644 index 2724ab6..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/Preview.java +++ /dev/null @@ -1,694 +0,0 @@ -package com.gpac.Osmo4; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.lang.reflect.Method; -import java.util.List; -import android.app.Activity; -import android.app.ProgressDialog; -import android.graphics.Bitmap; -import android.graphics.PixelFormat; -import android.hardware.Camera; -import android.hardware.Camera.Parameters; -import android.hardware.Camera.Size; -import android.os.Environment; -import android.os.Handler; -import android.os.HandlerThread; -import android.util.Log; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.View; -import android.widget.LinearLayout; - -/** - * Manage camera preview and frame grabbing. - * - * Mostly copied from - * - * {@link "http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html"} - */ -public class Preview { - - private static final String TAG = "Preview"; //$NON-NLS-1$ - - private Camera mCamera = null; - - private Size mPreviewSize = null; - - private int nBuffers = 0; - - private int mBufferSize = 0; - - private int mPreviewFormat = 0; - - private PreviewHandler mPreviewHandler = null; - - private boolean takePicture = false; - - private boolean mPreviewing = false; - - private boolean isPortrait = false; - - private int width = 0; - - private int height = 0; - - private int bitsPerPixel = 0; - - public static Activity context = null; - - private boolean previewRequested = false; - private boolean previewStarted = false; - - private CameraPreview camPreview = null; - - // Native functions - private native void processFrameBuf(byte[] data); - - Preview() { - mCamera = Camera.open(); - if (mCamera == null) { - Log.e(TAG, "Camera failed to open"); //$NON-NLS-1$ - return; - } - setParameters(mCamera.getParameters()); - mCamera.release(); - mCamera = null; - } - - private class CameraPreview implements SurfaceHolder.Callback { - - private SurfaceHolder holder = null; - private SurfaceView mCamSV; - private boolean hasCallback = false; - //private LinearLayout cam_view; - - private ProgressDialog cameraOpening; - - - public CameraPreview(final Activity context) { - Log.v(TAG, "CameraPreview: Constructor..."); - - cameraOpening = new ProgressDialog(context); - cameraOpening.setCancelable(false); - cameraOpening.setIndeterminate(true); - cameraOpening.setMessage("Opening camera"); - cameraOpening.setTitle("Osmo4 camera"); - - //cam_view = (LinearLayout)context.findViewById(R.id.surface_camera); - - //cam_view.addView(mCamSV); - - context.runOnUiThread(new Runnable() { - - @Override - public void run() { - cameraOpening.show(); - } - }); - - mCamSV = (SurfaceView)context.findViewById(R.id.surface_camera); - - holder = mCamSV.getHolder(); - holder.addCallback(CameraPreview.this); - holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); - - hasCallback = true; - - context.runOnUiThread(new Runnable() { - - @Override - public void run() { - Log.i(TAG, "CameraPreview: Set visible..."); - mCamSV.setVisibility(View.VISIBLE); - Log.i(TAG, "CameraPreview: Set visible done"); - } - }); - Log.v(TAG, "CameraPreview: Constructor done"); - } - - public void startPreview() - { - Log.v(TAG, "CameraPreview: Start preview..."); - mCamera.startPreview(); - context.runOnUiThread(new Runnable() { - @Override - public void run() { - //Log.i(TAG, "CameraPreview: Set gone..."); - Log.i(TAG, "CameraPreview: Dismiss"); - //mCamSV.setVisibility(View.GONE); - cameraOpening.dismiss(); - //Log.i(TAG, "CameraPreview: Set gone done"); - } - }); - mPreviewHandler = new PreviewHandler("CameraPreviewHandler"); - mPreviewing = true; - Log.v(TAG, "CameraPreview: Start preview done"); - } - - public void stopPreview() - { - if ( hasCallback ) - { - Log.v(TAG, "CameraPreview: Remove callback"); - holder.removeCallback(CameraPreview.this); - //cam_view.removeView(mCamSV); - //mCamSV = null; - context.runOnUiThread(new Runnable() { - @Override - public void run() { - Log.i(TAG, "CameraPreview: Set gone..."); - mCamSV.setVisibility(View.GONE); - Log.i(TAG, "CameraPreview: Set gone done"); - } - }); - hasCallback = false; - } - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - Log.v(TAG, "CameraPreview: Surface changed "+width+"x"+height+" ..."); - } - - @Override - public void surfaceCreated(SurfaceHolder holder) { - try { - Log.v(TAG, "CameraPreview: Surface created..."); - mCamera.setPreviewDisplay(holder); - if ( previewRequested ) { - startPreview(); - previewRequested = false; - } - else - previewStarted = true; - Log.v(TAG, "CameraPreview: Surface created done"); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - // TODO Auto-generated method stub - - } - - @Override - public void finalize() - { - stopPreview(); - camPreview = null; - } - } - - @Override - protected void finalize() { - stopCamera(); - } - - /** - * Set up the camera parameters and begin the preview. - * - * @param isPortrait True if camera orientation is portrait. False if it is landscape. - * @return True if successful. - */ - public boolean initializeCamera(boolean isPortrait) { - - this.isPortrait = isPortrait; - - // Open camera - if (mCamera == null) { - Log.i(TAG, "Open camera..."); //$NON-NLS-1$ - mCamera = Camera.open(); - if (mCamera == null) { - Log.w(TAG, "Camera failed to open"); //$NON-NLS-1$ - return false; - } - } - - pausePreview(); - - // Get parameters - mCamera.setParameters(setParameters(mCamera.getParameters())); - width = mPreviewSize.width; - height = mPreviewSize.height; - if (mPreviewSize == null || mPreviewFormat == 0) { - Log.e(TAG, "Preview size or format error"); //$NON-NLS-1$ - return false; - } - - // Define buffer size - PixelFormat pixelinfo = new PixelFormat(); - PixelFormat.getPixelFormatInfo(mPreviewFormat, pixelinfo); - bitsPerPixel = pixelinfo.bitsPerPixel; - mBufferSize = mPreviewSize.width * mPreviewSize.height * pixelinfo.bitsPerPixel / 8; - Log.d(TAG, "Pixelsize = " + pixelinfo.bitsPerPixel + " Buffersize = " + mBufferSize); //$NON-NLS-1$//$NON-NLS-2$ - nBuffers = 1; - - // Initialize frame grabbing - // mPreviewHandler = new PreviewHandler("CameraPreviewHandler"); - - context.runOnUiThread(new Runnable() { - - @Override - public void run() { - camPreview = new CameraPreview(context); - //camPreview.setVisibility(View.INVISIBLE); - } - }); - - Log.d(TAG, "Camera preview started"); //$NON-NLS-1$ - return true; - } - - /** - * Get the size of Preview - * - * @return null if camera not setup - */ - public Size getPreviewSize() { - return mPreviewSize; - } - - /** - * Get the preview format - * - * @return 0 if not initialized - */ - public int getPreviewFormat() { - return mPreviewFormat; - } - - /** - * Get the Image height - * - * @return -1 if not initialized, the height otherwise - */ - public int getImageHeight() { - Size sz = getPreviewSize(); - if (sz == null) - return -1; - return sz.height; - } - - /** - * Get the image Width if set - * - * @return -1 if not initialized, the width otherwise - */ - public int getImageWidth() { - Size sz = getPreviewSize(); - if (sz == null) - return -1; - return sz.width; - } - - /** - * Get the bits per pixel - * - * @return 0 if not initialized - */ - public int getBitsPerPixel() { - return bitsPerPixel; - } - - /** - * Stop preview and release the camera. Because the CameraDevice object is not a shared resource, it is very - * important to release it when the activity is paused. - */ - public void stopCamera() { - Log.v(TAG, "stopCamera()"); //$NON-NLS-1$ - - if ( mPreviewing ) - pausePreview(); - if (mCamera != null) { - camPreview.stopPreview(); - camPreview = null; - mCamera.release(); - mCamera = null; - previewRequested = false; - previewStarted = false; - Log.v(TAG, "Camera released"); //$NON-NLS-1$ - } - } - - /** - * Stop the processing thread - */ - public void pausePreview() { - Log.v(TAG, "pausePreview()"); - if ( mPreviewing ) { - if ( mPreviewHandler != null ) - mPreviewHandler.stopPreview(); - mPreviewHandler = null; - mCamera.stopPreview(); - mPreviewing = false; - Log.v(TAG, "Camera preview stopped"); //$NON-NLS-1$ - } - } - - /** - * Restart the processing thread - */ - public void resumePreview() { - Log.v(TAG, "resumePreview()"); - if ( previewStarted ) { - camPreview.startPreview(); - previewStarted = false; - } - else - previewRequested = true; - } - - /** - * Set preferred mPreviewSize and mPrevieformat and return adapted camera parameters. If mPreviewSize == null or - * mPreviewFormat == 0 then some error has occurred. - * - * @param parameters the parameters to set - * - * @return the parameters set as argument - * @throws IllegalArgumentException if argument is null - */ - protected Camera.Parameters setParameters(Camera.Parameters parameters) throws IllegalArgumentException { - if (parameters == null) - throw new IllegalArgumentException("parameters must not be null"); //$NON-NLS-1$ - // Get preview size - mPreviewSize = parameters.getPreviewSize(); - parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height); - Log.d(TAG, "PreviewSize: " + mPreviewSize.width + 'x' + mPreviewSize.height); //$NON-NLS-1$ - - // Get preview format - mPreviewFormat = PixelFormat.YCbCr_420_SP; - // getOptimalPreviewFormat(parameters - // .getSupportedPreviewFormats()); - if (mPreviewFormat == 0) { - Log.e(TAG, "Cannot set mPreviewFormat"); //$NON-NLS-1$ - } else { - Log.d(TAG, "Previewformat: " + mPreviewFormat); //$NON-NLS-1$ - parameters.setPreviewFormat(mPreviewFormat); - } - - Log.d(TAG, "PreviewFrameRate: " + parameters.getPreviewFrameRate()); //$NON-NLS-1$ - parameters.setPreviewFrameRate(parameters.getPreviewFrameRate()); - parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO ); - - return parameters; - } - - - private Size getOptimalPreviewSize(List sizes, int w, int h) { - final double ASPECT_TOLERANCE = 0.1; - double targetRatio = (double) w / h; - if (sizes == null) return null; - - Size optimalSize = null; - double minDiff = Double.MAX_VALUE; - - int targetHeight = h; - - // Try to find an size match aspect ratio and size - for (Size size : sizes) { - double ratio = (double) size.width / size.height; - if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; - if (Math.abs(size.height - targetHeight) < minDiff) { - optimalSize = size; - minDiff = Math.abs(size.height - targetHeight); - } - } - - // Cannot find the one match the aspect ratio, ignore the requirement - if (optimalSize == null) { - minDiff = Double.MAX_VALUE; - for (Size size : sizes) { - if (Math.abs(size.height - targetHeight) < minDiff) { - optimalSize = size; - minDiff = Math.abs(size.height - targetHeight); - } - } - } - return optimalSize; - } - - /** - * Return preferred camera preview format. At the moment, PixelFormat.YCbCr_420_SP is required. - * - * @param formats Supported formats: Camera.Parameters.getSupportedPreviewFormats() - * @return Image format 17 (YUV420SP) if supported, 0 if not. - */ - protected int getOptimalPreviewFormat(List formats) { - int optFormat = 0; - for (Integer format : formats) { - int intFormat = format.intValue(); - Log.d(TAG, "supported image format: " + intFormat); //$NON-NLS-1$ - if (intFormat == PixelFormat.YCbCr_420_SP) { - optFormat = intFormat; - } - } - return optFormat; - } - - /** - * Process a frame grabbed from the camera. - * - * @param data Image from camera in YUV420SP format. - */ - protected void processFrame(byte[] data) { - if (takePicture) { - // Test: decode and save image - int[] rgbBuf = decodeYUV420SP(data, width, height); - saveImageToFile(rgbBuf, width, height); - takePicture = false; - } - // End of test - - // Send data to C library - processFrameBuf(data); - } - - /** - * Save an RGB image to the file /sdcard/image.jpg - * - * @param rgbBuffer RGB image buffer to save - * @param width Width of the image - * @param height Height of the image - */ - public void saveImageToFile(int[] rgbBuffer, int width, int height) { - Bitmap bm = Bitmap.createBitmap(rgbBuffer, width, height, Bitmap.Config.RGB_565); - - // Save image - String path = Environment.getExternalStorageDirectory().toString(); - OutputStream fOut = null; - File file = new File(path, "image.jpg"); //$NON-NLS-1$ - try { - try { - fOut = new FileOutputStream(file); - bm.compress(Bitmap.CompressFormat.JPEG, 100, fOut); - fOut.flush(); - } catch (IOException e1) { - Log.e(TAG, "io error file output stream while writing", e1); //$NON-NLS-1$ - e1.printStackTrace(); - } finally { - if (fOut != null) - fOut.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Convert an image from YUV to RGB format. - * - * @param yuv420sp YUV format image, as a byte array - * @param width Width of the image - * @param height Height of the image - * @return RGB image as an int array - */ - public int[] decodeYUV420SP(byte[] yuv420sp, int width, int height) { - final int frameSize = width * height; - - int rgb[] = new int[width * height]; - for (int j = 0, yp = 0; j < height; j++) { - int uvp = frameSize + (j >> 1) * width, u = 0, v = 0; - for (int i = 0; i < width; i++, yp++) { - int y = (0xff & (yuv420sp[yp])) - 16; - if (y < 0) - y = 0; - if ((i & 1) == 0) { - v = (0xff & yuv420sp[uvp++]) - 128; - u = (0xff & yuv420sp[uvp++]) - 128; - } - - int y1192 = 1192 * y; - int r = (y1192 + 1634 * v); - int g = (y1192 - 833 * v - 400 * u); - int b = (y1192 + 2066 * u); - - if (r < 0) - r = 0; - else if (r > 262143) - r = 262143; - if (g < 0) - g = 0; - else if (g > 262143) - g = 262143; - if (b < 0) - b = 0; - else if (b > 262143) - b = 262143; - rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff); - } - } - return rgb; - } - - /** - * Interface between PreviewHandler and mCamera - * - * @param cb - */ - private void setPreviewCallbackWithBuffer(Camera.PreviewCallback cb) { - // call mCamera.setPreviewCallbackWithBuffer(cb) - // if cb != null then also add a callback buffers - try { - if (bufferWorks) { - if (cb != null) { - for (int i = 0; i < nBuffers; i++) { - // TODO level 8: mCamera.addCallbackBuffer(new - // byte[mBufferSize]); - camAddCbBuffer.invoke(mCamera, new byte[mBufferSize]); - } - } - // TODO level 8: mCamera.setPreviewCallbackWithBuffer(cb); - camSetPreview.invoke(mCamera, cb); - } else if (cb != null) { - mCamera.setOneShotPreviewCallback(cb); - } - } catch (Exception e) { - Log.e(TAG, "setPreviewCallbackWithBuffer failed:" + e, e); //$NON-NLS-1$ - } - } - - private int fps_max_count = 100; - - private int fps_count = 1; - - private long fps_last = -42; - - private void addCallbackBuffer(byte[] buffer) { - if (--fps_count == 0) { - long now = System.currentTimeMillis(); - if (fps_last != -42) { - float fps = fps_max_count * 1000.f / (now - fps_last); - Log.i(TAG, "fps: " + fps); //$NON-NLS-1$ - fps_max_count = (int) (5.f * fps); - } - fps_count = fps_max_count; - fps_last = now; - } - try { - if (bufferWorks) { - camAddCbBuffer.invoke(mCamera, buffer); - } else { - mCamera.setOneShotPreviewCallback(mPreviewHandler); - } - } catch (Exception e) { - Log.e(TAG, "addCallbackBuffer failed: " + e); //$NON-NLS-1$ - } - } - - /* - * TODO: for level 8 all the stuff below becomes obsolete Use reflection for accessing hidden methods - */ - private static final Method getCamAddCallbackBuffer() { - try { - return Class.forName("android.hardware.Camera").getMethod("addCallbackBuffer", byte[].class); //$NON-NLS-1$//$NON-NLS-2$ - } catch (Exception e) { - Log.e(TAG, "No addCallbackBuffer: " + e); //$NON-NLS-1$ - } - return null; - } - - private static final Method getCamSetPreviewCallbackWithBuffer() { - try { - return Class.forName("android.hardware.Camera").getMethod("setPreviewCallbackWithBuffer", //$NON-NLS-1$ //$NON-NLS-2$ - Camera.PreviewCallback.class); - } catch (Exception e) { - Log.e(TAG, "No setPreviewCallbackWithBuffer: " + e); //$NON-NLS-1$ - } - return null; - } - - /** - * Handles camera frame buffer callbacks in a new thread. - */ - protected class PreviewHandler extends HandlerThread implements Camera.PreviewCallback { - - private Handler mHandler; - - private boolean stopped = false; - - PreviewHandler(String name) { - super(name); - mHandler = null; - start(); - } - - @Override - public void onPreviewFrame(final byte[] data, final Camera camera) { - synchronized (this) { - if (mHandler != null && camera == mCamera) { - mHandler.post(new Runnable() { - - @Override - public void run() { - if (!stopped) { - processFrame(data); - if (mHandler != null) { - addCallbackBuffer(data); - } - } - } - }); - } - } - - } - - @Override - synchronized protected void onLooperPrepared() { - synchronized (this) { - Log.v(TAG, "onLooperPrepared()"); //$NON-NLS-1$ - if (stopped == false) { - mHandler = new Handler(); - Log.d(TAG, "frame processing start"); //$NON-NLS-1$ - setPreviewCallbackWithBuffer(this); - // mCamera.setPreviewCallback(this); - } - } - } - - synchronized private void stopPreview() { - synchronized (this) { - stopped = true; - if (mHandler != null) { - Log.d(TAG, "frame processing stop"); //$NON-NLS-1$ - setPreviewCallbackWithBuffer(null); - // mCamera.setPreviewCallback(null); - mHandler = null; - } - } - } - } - - private static final Method camAddCbBuffer = getCamAddCallbackBuffer(); - - private static final Method camSetPreview = getCamSetPreviewCallbackWithBuffer(); - - private static final boolean bufferWorks = camAddCbBuffer != null && camSetPreview != null; -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/SensorServices.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/SensorServices.java deleted file mode 100644 index a3f41b5..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/SensorServices.java +++ /dev/null @@ -1,385 +0,0 @@ -package com.gpac.Osmo4; - -import android.content.Context; -import android.util.Log; -import android.view.Display; -import android.view.WindowManager; - - -import java.util.TimerTask; -import java.util.Timer; - -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; - -/** - * Class for 360video sensors management - * - * @author Emmanouil Potetsianakis - * @version $Revision$ - */ -public class SensorServices implements SensorEventListener, GPACInstanceInterface { - - //automatically set to true, if TYPE_ROTATION_VECTOR sensor is detected - //NOTE: this is a composite sensor; does not work with fusion - private boolean useRotationVector; - -//Startof Options - private static final int SENSOR_DELAY = SensorManager.SENSOR_DELAY_FASTEST; // 0: SENSOR_DELAY_FASTEST, 1: SENSOR_DELAY_GAME, 2: SENSOR_DELAY_UI, 3: SENSOR_DELAY_NORMAL - - private static final boolean USE_ORIENTATION_FILTER = true; //if true smoothSensorMeasurement is applied to getOrientation result - private static final boolean USE_ORIENTATION_THRESHOLD = true; //if true keepOrientation() discards results within the error margin - - //the lower the value, the more smoothing is applied (lower response) - set to 1.0 for no filter - private static final float ORIENTATION_FILTER_LVL = 0.04f; - //threshold to discard orientation x, y, z - private static final float[] ORIENTATION_THRESHOLD = {0.2f, 0.02f, 0.02f}; -//Endof Options - - - private static SensorManager sensorManager; - - private static Sensor accelerometer; //base sensor - private static Sensor magnetometer; //base sensor - private static Sensor rotationSensor; //composite sensor - - protected Osmo4Renderer rend; - private Display displayDev; - - private boolean newOrientation = false; //auto-set to true when new Rotation arrives (from acc), auto-set to false when rotation is sent to player - - private Timer fuseTimer = new Timer(); - - private float[] acceleration = {0.0f, 0.0f, 0.0f}; //holds acceleration values (g) - private float[] magnetic = {0.0f, 0.0f, 0.0f}; //holds magnetic field values (μT) - private float[] rotationValues = {0.0f, 0.0f, 0.0f};//holds rotation vector - private float[] orientation = {0.0f, 0.0f, 0.0f}; //from acc+magn - private float[] lastOrient = {0.0f, 0.0f, 0.0f}, prevOrient; - - private float rotationMx[] = new float[9]; - private float rotationMxRaw[] = new float[9]; - - private static final String LOG_TAG = "GPAC SensorServices"; - private static final float _PI_ = (float) Math.PI; - - - /** - * Constructor (initialize sensors) - * - * @param context The parent Context - * @return SensorServices object - */ - public SensorServices(Context context) { - //init sensors - sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); - magnetometer = sensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); - accelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - rotationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); - - //init the rest - WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); - displayDev = wm.getDefaultDisplay(); - - //check sensor availability and select - if(rotationSensor!=null){ - useRotationVector = true; - return; - }else{ - Log.w(LOG_TAG, "No Rotation Vector composit sensor found - Switching to Acc+Magn sensors"); - } - - if (magnetometer == null || accelerometer == null){ - Log.e(LOG_TAG, "No Accelerometer and/or Magnetic Field sensors found"); //TODOk handle this - rollback to manual navigation - } - - } - - public void setRenderer(Osmo4Renderer renderer) { - rend = renderer; - } - - /** - * Register sensors to start receiving data - */ - public void registerSensors() { - - if(rotationSensor!=null){ - sensorManager.registerListener(this, rotationSensor, SENSOR_DELAY); - Log.i(LOG_TAG, "Using Rotation Vector sensor for 360navigation"); - return; - } - - if(magnetometer != null && accelerometer != null){ - sensorManager.registerListener(this, magnetometer, SENSOR_DELAY); - sensorManager.registerListener(this, accelerometer, SENSOR_DELAY); - Log.i(LOG_TAG, "Using Acceleration & Magnetic Field sensors for 360navigation"); - } - } - - //TODOk we do not handle this yet - there is an issue with onResume (not working) and onPause (working) - public void unregisterSensors() { - sensorManager.unregisterListener(this); - } - - /** - * We calculate rotation/orientation on new acc measurements - **/ - @Override - public void onSensorChanged(SensorEvent event) { - - boolean newevent = false; - - switch (event.sensor.getType()) { - case Sensor.TYPE_ROTATION_VECTOR: - rotationValues = event.values.clone(); - newOrientation = calculateRotationMx(); - if (newOrientation){ - float[] tmpOrient = new float[3]; - SensorManager.getOrientation(rotationMx, tmpOrient); - rend.getInstance().onOrientationChange(-tmpOrient[0], tmpOrient[1], -tmpOrient[2]); - } - return; - case Sensor.TYPE_ACCELEROMETER: - newevent=true; - acceleration = event.values.clone(); - break; - case Sensor.TYPE_MAGNETIC_FIELD: - newevent=true; - magnetic = event.values.clone(); - break; - default: - return; - } - if(newevent){ - newOrientation = calculateRotationMx(); - if (!newOrientation) return; - calculateOrientation(); - updateOrientation(); - } - } - - /** - * Calculate orientation X,Y,Z from Acc and Magn - * Orientation is stored in prevOrient - * Rotation matrix is stored in rotationMx - * - * @return true if rotationMatrix was updated - */ - private boolean calculateRotationMx() { - boolean gotRotation = false; - - - if(useRotationVector){ - try { - SensorManager.getRotationMatrixFromVector(rotationMxRaw, rotationValues); - gotRotation = true; - } catch (Exception e) { - gotRotation = false; - Log.e(LOG_TAG, "Error getting rotation matrix" + e.getMessage()); - } - }else{ - try { - gotRotation = SensorManager.getRotationMatrix(rotationMxRaw, null, acceleration, magnetic); - } catch (Exception e) { - gotRotation = false; - Log.e(LOG_TAG, "Error getting rotation matrix" + e.getMessage()); - } - } - - if (gotRotation) { - //NOTE: the rotation considered is according to device natural orientation - //and it might NOT be the same as the screen orientation - switch (displayDev.getRotation()) { - case 1: //Surface.ROTATION_90 - rotationMx = rotationMxRaw.clone(); - break; - case 2: //Surface.ROTATION_180 - SensorManager.remapCoordinateSystem(rotationMxRaw, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, rotationMx); - break; - case 3: //Surface.ROTATION_270 - SensorManager.remapCoordinateSystem(rotationMxRaw, SensorManager.AXIS_MINUS_X, SensorManager.AXIS_MINUS_Y, rotationMx); - break; - case 0: //no rotation (= Surface.ROTATION_0) - SensorManager.remapCoordinateSystem(rotationMxRaw, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, rotationMx); - break; - } - } - - return gotRotation; - } - - private void calculateOrientation() { - float[] tmpOrient = new float[3]; - SensorManager.getOrientation(rotationMx, tmpOrient); - orientation = tmpOrient.clone(); - } - - private void updateOrientation() { - lastOrient = orientation.clone(); - boolean refreshOrientation = true; - if (USE_ORIENTATION_THRESHOLD) { - refreshOrientation = keepOrientation(lastOrient, prevOrient); - } - - if (refreshOrientation) { - if (USE_ORIENTATION_FILTER) { - prevOrient = smoothSensorMeasurement(lastOrient, prevOrient); - } else { - prevOrient = lastOrient; - } - } - - //NOTE: we invert yaw and roll (for 360 navigation) - rend.getInstance().onOrientationChange(-prevOrient[0], prevOrient[1], -prevOrient[2]); - newOrientation = false; - } - - private float[] getRotationMxFromOrientation(float[] o) { - float[] xM = new float[9]; - float[] yM = new float[9]; - float[] zM = new float[9]; - - float sinX = (float) Math.sin(o[1]); - float cosX = (float) Math.cos(o[1]); - float sinY = (float) Math.sin(o[2]); - float cosY = (float) Math.cos(o[2]); - float sinZ = (float) Math.sin(o[0]); - float cosZ = (float) Math.cos(o[0]); - - // rotation about x-axis (pitch) - xM[0] = 1.0f; - xM[1] = 0.0f; - xM[2] = 0.0f; - xM[3] = 0.0f; - xM[4] = cosX; - xM[5] = sinX; - xM[6] = 0.0f; - xM[7] = -sinX; - xM[8] = cosX; - - // rotation about y-axis (roll) - yM[0] = cosY; - yM[1] = 0.0f; - yM[2] = sinY; - yM[3] = 0.0f; - yM[4] = 1.0f; - yM[5] = 0.0f; - yM[6] = -sinY; - yM[7] = 0.0f; - yM[8] = cosY; - - // rotation about z-axis (azimuth) - zM[0] = cosZ; - zM[1] = sinZ; - zM[2] = 0.0f; - zM[3] = -sinZ; - zM[4] = cosZ; - zM[5] = 0.0f; - zM[6] = 0.0f; - zM[7] = 0.0f; - zM[8] = 1.0f; - - // rotation order is y, x, z (roll, pitch, azimuth) - float[] resultMatrix = multiplyMx(xM, yM); - resultMatrix = multiplyMx(zM, resultMatrix); - return resultMatrix; - } - - private float[] multiplyMx(float[] A, float[] B) { - float[] result = new float[9]; - - result[0] = A[0] * B[0] + A[1] * B[3] + A[2] * B[6]; - result[1] = A[0] * B[1] + A[1] * B[4] + A[2] * B[7]; - result[2] = A[0] * B[2] + A[1] * B[5] + A[2] * B[8]; - - result[3] = A[3] * B[0] + A[4] * B[3] + A[5] * B[6]; - result[4] = A[3] * B[1] + A[4] * B[4] + A[5] * B[7]; - result[5] = A[3] * B[2] + A[4] * B[5] + A[5] * B[8]; - - result[6] = A[6] * B[0] + A[7] * B[3] + A[8] * B[6]; - result[7] = A[6] * B[1] + A[7] * B[4] + A[8] * B[7]; - result[8] = A[6] * B[2] + A[7] * B[5] + A[8] * B[8]; - - return result; - } - - private static boolean keepOrientation(float[] in, float[] out) { - - if (out == null) return true; - - for (int i = 0; i < in.length; i++) { - if (Math.abs(in[i] - out[i]) > ORIENTATION_THRESHOLD[i]) return true; - } - - return false; - } - - - private static float[] smoothSensorMeasurement(float[] in, float[] out) { - - if (out == null) return in; - - float[] output = {0.0f, 0.0f, 0.0f}; - float diff = 0.0f; - - - for (int i = 0; i < in.length; i++) { - - diff = (in[i] - out[i]); - - if (Math.abs(diff) > Math.PI) { - float diff_f = 0.0f; - if (diff > Math.PI) { - diff = 2 * _PI_ - diff; - diff_f = out[i] - ORIENTATION_FILTER_LVL * diff; - if (diff_f < -Math.PI) { - output[i] = (2 * _PI_ + diff_f); - } else { - output[i] = diff_f; - } - } else if (diff < -Math.PI) { - diff = 2 * _PI_ + diff; - diff_f = out[i] + ORIENTATION_FILTER_LVL * diff; - if (diff_f > Math.PI) { - output[i] = -2 * _PI_ + diff_f; - } else { - output[i] = diff_f; - } - - } - - } else { - output[i] = out[i] + ORIENTATION_FILTER_LVL * diff; - } - } - - return output; - } - - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - //required - but not used - } - - @Override - public native void setGpacLogs(String tools_at_levels); - - @Override - public native void setGpacPreference(String category, String name, String value); - - @Override - public void destroy() { - } - - @Override - public void connect(String pop) { - } - - @Override - public void disconnect() { - } - -} \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/ConfigFileEditor.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/ConfigFileEditor.java deleted file mode 100644 index 6fbb33d..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/ConfigFileEditor.java +++ /dev/null @@ -1,326 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.content.Context; -import android.util.Log; - -import com.gpac.Osmo4.GpacConfig; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - - -public class ConfigFileEditor { - - private String TAG = "ConfigFileEditor"; - - private String ATTRIBUTE_NAME = "name"; - private String ATTRIBUTE_TYPE = "type"; - private String ATTRIBUTE_DEFAULT = "default"; - private String ATTRIBUTE_USAGE = "usage"; - - private final String TYPE_PATH = "path"; - private final String TYPE_FILENAME = "filename"; - private final String TYPE_STRING = "string"; - private final String TYPE_BOOLEAN = "boolean"; - private final String TYPE_UINT = "uint"; - - private File configFile; - - private XmlPullParserFactory xmlFactoryObject; - private XmlPullParser parser; - private GpacConfig config; - private Context context; - - public ConfigFileEditor(Context context) { - this.context = context; - config = new GpacConfig(context); - configFile = new File(config.getGpacConfigDirectory(), "GPAC.cfg"); - - try { - xmlFactoryObject = XmlPullParserFactory.newInstance(); - } catch (XmlPullParserException e) { - Log.v(TAG, "Cannot create xml parser new instance"); - e.printStackTrace(); - } - } - - private void start() { - InputStream inputStream = null; - try { - inputStream = context.getAssets().open("configuration.xml"); - parser = xmlFactoryObject.newPullParser(); - parser.setInput(inputStream, null); - } catch (XmlPullParserException | IOException e) { - e.printStackTrace(); - } - } - - /** - * get all the keys from the xml file - * - * @return array of all keys - */ - public String[] getAllKeys() { - ArrayList list = new ArrayList<>(); - int event = 0; - try { - start(); - event = parser.getEventType(); - - while (event != XmlPullParser.END_DOCUMENT) { - String name = parser.getName(); - switch (event) { - case XmlPullParser.START_TAG: - if (name.equals("key")) { - String attrName = parser.getAttributeValue(null, ATTRIBUTE_NAME).trim(); - list.add(attrName); - } - break; - - case XmlPullParser.END_TAG: - break; - } - event = parser.next(); - } - } catch (XmlPullParserException e) { - Log.e(TAG, "XML Exception"); - e.printStackTrace(); - } catch (IOException e) { - Log.e(TAG, "IOException"); - e.printStackTrace(); - } - return list.toArray(new String[0]); - } - - /** - * get all the attributes for a single key - * - * @param key key to find attributes for - * @return Attribute object with all attributes set. If key not found, returns null - */ - public Attribute getAllAttributesForKey(String key) { - Attribute attribute = null; - String section = null; - String attrName = null; - String attrType = null; - String attrDfault = null; - String attrUsage = null; - StringBuilder attrDescription = new StringBuilder(); - - boolean keyFound = false; - boolean exit = false; - int depth = 0; - int event; - try { - start(); //start from beginning - event = parser.getEventType(); - while (event != XmlPullParser.END_DOCUMENT && !exit) { - String name = parser.getName(); - switch (event) { - case XmlPullParser.START_TAG: - - if(name.equals("section")){ - section = parser.getAttributeValue(null, ATTRIBUTE_NAME); - } - if (name.equals("key") && parser.getAttributeValue(null, ATTRIBUTE_NAME).equals(key)) { - attrName = parser.getAttributeValue(null, ATTRIBUTE_NAME); - attrType = parser.getAttributeValue(null, ATTRIBUTE_TYPE); - attrDfault = parser.getAttributeValue(null, ATTRIBUTE_DEFAULT); - attrUsage = parser.getAttributeValue(null, ATTRIBUTE_USAGE); - keyFound = true; - } - if(keyFound) - ++depth; - if (keyFound && depth > 1){ - attrDescription.append("<").append(parser.getName()).append(">"); - } - break; - - case XmlPullParser.TEXT: - if(keyFound) { - attrDescription.append(parser.getText().trim()); - } - break; - - case XmlPullParser.END_TAG: - if(keyFound) - --depth; - - if (keyFound && depth > 0){ - attrDescription.append(""); - } - - if(name.equals("key") && keyFound){ - attribute = new Attribute(section, attrName, attrType, attrDfault, attrUsage, attrDescription.toString()); - keyFound = false; - exit = true; - } - break; - } - event = parser.next(); - } - } catch (XmlPullParserException e) { - Log.e(TAG, "XML Exception"); - e.printStackTrace(); - } catch (IOException e) { - Log.e(TAG, "IOException"); - e.printStackTrace(); - } - return attribute; - } - - - /** - * get value for key from the config file - * - * @param key key to find - * @return the value from the config file, if key not found, returns null. - */ - public String getValue(String key) { - String line; - try { - BufferedReader br = new BufferedReader(new FileReader(configFile)); - - while ((line = br.readLine()) != null) { - String[] parts = line.split("="); - if(parts[0].trim().equals(key)){ - return parts[1]; - } - } - br.close(); - } catch (FileNotFoundException e) { - Log.e(TAG, "GPAC.cfg not found"); - e.printStackTrace(); - } catch (IOException e) { - Log.e(TAG, "IO Exception while parsing GPAC.cfg"); - e.printStackTrace(); - } - return null; - } - - /** - * checks if the new value is valid or not. - * @param type type of newValue - * @param newValue value to check - * @return true if valid, otherwise false - */ - public boolean isValueValid(String type, String newValue) { - - switch (type) { - /* case TYPE_PATH: - case TYPE_FILENAME: - File file = new File(newValue); - if(!file.exists()){ - Log.e(TAG, "The path does not exist : " + newValue); - return false; - } - break; - */ - - case TYPE_BOOLEAN: - return newValue.equals("yes") || newValue.equals("no"); - - case TYPE_UINT: - try { - int num = Integer.parseInt(newValue); - return num >= 0; - } catch(Exception e) { - Log.e(TAG, "The type is uint but value provided: "+ newValue); - return false; - } - - case TYPE_STRING: - default: - return true; - - } - } - - /** - * set the value in the config file - * @param key key for newValue - * @param newValue - */ - public void setValue(String key, String newValue) { - - String line = null; - try { - File tempFile = new File(config.getGpacConfigDirectory(), "temp.cfg"); - BufferedReader br = new BufferedReader(new FileReader(configFile)); - BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile)); - - while ((line = br.readLine()) != null) { - String parts[] = line.split("="); - if(parts[0].equals(key)){ - line = key + "=" + newValue; - } - bw.write(line); - bw.newLine(); - } - br.close(); - bw.close(); - - if(!configFile.delete()) { - Log.e(TAG, "Cannot delete config file"); - } - - if(!tempFile.renameTo(configFile)) { - Log.e(TAG, "Cannot rename temp file to GPAC.cfg"); - } - - } catch (IOException e) { - Log.e(TAG, "IOException "); - e.printStackTrace(); - } - } - - class Attribute { - private String section; - private String name; - private String type; - private String dfault; - private String usage; - private String desciption; - - public Attribute(String section, String name, String type, String dfault, String usage, String desciption) { - this.section = section; - this.name = name; - this.type = type; - this.dfault = dfault; - this.usage = usage; - this.desciption = desciption; - } - - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getDefault() { - return dfault; - } - - public String getUsage() { - return usage; - } - - public String getDesciption() { - return desciption; - } - } - -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/ConfigFileEditorActivity.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/ConfigFileEditorActivity.java deleted file mode 100644 index 49c6f86..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/ConfigFileEditorActivity.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.app.Activity; -import android.os.Bundle; -import android.text.Html; -import android.text.method.ScrollingMovementMethod; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.AutoCompleteTextView; -import android.widget.Button; -import android.widget.EditText; -import android.widget.TextView; -import android.widget.Toast; - -import com.gpac.Osmo4.R; - - -public class ConfigFileEditorActivity extends Activity { - - private String TAG = "ConfigFileEditorActivity"; - - private AutoCompleteTextView optionsTextView; - private TextView typeTextView; - private TextView dfaultTextView; - private TextView usageTextView; - private TextView descriptionTextView; - private TextView currentValueTextView; - private EditText newValueEditText; - private Button saveButton; - private String currentValue; - - private ConfigFileEditor editor; - private ConfigFileEditor.Attribute attribute; - private String currentName; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_config_file_editor); - - optionsTextView = (AutoCompleteTextView) findViewById(R.id.optionsTextView); - typeTextView = (TextView) findViewById(R.id.typeTextView); - dfaultTextView = (TextView) findViewById(R.id.dfaultTextView); - usageTextView = (TextView) findViewById(R.id.usageTextView); - descriptionTextView = (TextView) findViewById(R.id.descriptionTextView); - currentValueTextView = (TextView) findViewById(R.id.currentValueEditText); - newValueEditText = (EditText) findViewById(R.id.newValueEditText); - saveButton = (Button) findViewById(R.id.saveButton); - - descriptionTextView.setMovementMethod(new ScrollingMovementMethod()); - editor = new ConfigFileEditor(this); - final String[]keys = editor.getAllKeys(); - final ArrayAdapter adapter = new ArrayAdapter<>(this, - android.R.layout.simple_dropdown_item_1line, keys); - optionsTextView.setAdapter(adapter); - - optionsTextView.setOnClickListener(onOptionTextViewClick); - optionsTextView.setOnItemClickListener(onItemClick); - optionsTextView.setOnKeyListener(keyListener); - saveButton.setOnClickListener(onSaveButtonClick); - } - - private View.OnClickListener onOptionTextViewClick = new View.OnClickListener() { - @Override - public void onClick(View v) { - optionsTextView.showDropDown(); - } - }; - - private AdapterView.OnItemClickListener onItemClick = new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - setAllFields((String) parent.getItemAtPosition(position)); - } - }; - - private View.OnKeyListener keyListener = new View.OnKeyListener() { - @Override - public boolean onKey(View v, int keyCode, KeyEvent event) { - if(event.getAction() == KeyEvent.ACTION_DOWN && - keyCode == KeyEvent.KEYCODE_ENTER) { - currentName = optionsTextView.getText().toString().trim(); - if (currentName == null || currentName.equals("")) { - return false; - } else { - optionsTextView.dismissDropDown(); - setAllFields(currentName); - return true; - } - } - return false; - } - }; - - private View.OnClickListener onSaveButtonClick = new View.OnClickListener() { - @Override - public void onClick(View v) { - String newValue = newValueEditText.getText().toString().trim(); - if(newValue == null || newValue.equals("")) { - Toast.makeText(ConfigFileEditorActivity.this, "New value is empty", Toast.LENGTH_LONG).show(); - return; - } - - if(currentValue == null){ - Log.e(TAG, getString(R.string.noKey)); - return; - } - - if (newValue.equals(currentValue)){ - Toast.makeText(ConfigFileEditorActivity.this, getString(R.string.noChange), Toast.LENGTH_LONG).show(); - return; - } - - if(editor.isValueValid(currentName, newValue)){ - editor.setValue(currentName, newValue); - setAllFields(currentName); - Toast.makeText(ConfigFileEditorActivity.this, getString(R.string.valueUpdated), Toast.LENGTH_LONG).show(); - newValueEditText.setText(""); - } else { - Toast.makeText(ConfigFileEditorActivity.this, getString(R.string.valueNotValid), Toast.LENGTH_LONG).show(); - Log.e(TAG, getString(R.string.valueNotValid)); - } - - } - }; - - private void setAllFields(String key) { - currentName = key; - attribute = editor.getAllAttributesForKey(key); - if(attribute == null) { - Log.v(TAG, "no attribute found for the given key in the option file : " + key); - typeTextView.setText(getString(R.string.noAttribute)); - dfaultTextView.setText(getString(R.string.noAttribute)); - usageTextView.setText(getString(R.string.noAttribute)); - descriptionTextView.setText(getString(R.string.noAttribute)); - } - else { - typeTextView.setText(attribute.getType()); - dfaultTextView.setText(attribute.getDefault()); - usageTextView.setText(attribute.getUsage()); - descriptionTextView.setText(Html.fromHtml(attribute.getDesciption(), null, new XMLTagHandler())); - Log.v(TAG, "description " + attribute.getDesciption()); - } - currentValue = editor.getValue(key); - if (currentValue == null) currentValueTextView.setText(getString(R.string.noKey)); else currentValueTextView.setText(currentValue); - } -} \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileArrayAdapter.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileArrayAdapter.java deleted file mode 100644 index 33330db..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileArrayAdapter.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.content.Context; -import android.graphics.drawable.Drawable; -import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.drawable.DrawableCompat; -import android.support.v7.widget.CardView; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.gpac.Osmo4.R; - -import java.io.File; -import java.util.ArrayList; -import java.util.Date; - - -public class FileArrayAdapter extends RecyclerView.Adapter { - - public interface OnItemClickListener { - void onItemClick(View view, int position); - } - - private ArrayList files; - private OnItemClickListener onItemClickListener; - private Context context; - - public FileArrayAdapter(ArrayList files, OnItemClickListener onItemClickListener, Context context) { - this.files = files; - this.onItemClickListener = onItemClickListener; - this.context = context; - } - - @Override - public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - return new ListItemViewHolder( - LayoutInflater - .from(parent.getContext()) - .inflate(R.layout.list_item_file_chooser, parent, false)); - } - - @Override - public void onBindViewHolder(final RecyclerView.ViewHolder viewHolder, final int position) { - - ListItemViewHolder holder = (ListItemViewHolder) viewHolder; - File file = getItem(position); - holder.title.setText(file.getName()); - holder.lastModified.setText(new Date(file.lastModified()).toString()); - setIcon(file, holder); - holder.cardView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - onItemClickListener.onItemClick(v, position); - } - }); - } - - public void setIcon(File file, ListItemViewHolder holder) { - - String extension; - Drawable drawable = null; - - try { - extension = FileManager.getExtension(file.getAbsolutePath()); - - if (file.isFile()) { - switch (extension) { - - case ".c": case ".cpp": case ".doc": case ".docx": case ".exe": - case ".h": case ".html": case ".java": case ".log": case ".txt": - case ".pdf": case ".ppt": case ".xls": - drawable = ContextCompat.getDrawable(context, R.drawable.ic_file); - break; - - case ".3ga": case ".aac": case ".mp3": case ".m4a": case ".ogg": - case ".wav": case ".wma": - drawable = ContextCompat.getDrawable(context, R.drawable.ic_audio); - break; - - case ".3gp": case ".avi": case ".mpg": case ".mpeg": case ".mp4": - case ".mkv": case ".webm": case ".wmv": case ".vob": - drawable = ContextCompat.getDrawable(context, R.drawable.ic_video); - break; - - case ".ai": case ".bmp": case ".exif": case ".gif": case ".jpg": - case ".jpeg": case ".png": case ".svg": - drawable = ContextCompat.getDrawable(context, R.drawable.ic_image); - break; - - case ".rar": case ".zip": case ".ZIP": - drawable = ContextCompat.getDrawable(context, R.drawable.ic_compressed); - break; - - default: - drawable = ContextCompat.getDrawable(context, R.drawable.ic_error); - break; - } - } else if (file.isDirectory()) { - drawable = ContextCompat.getDrawable(context, R.drawable.ic_folder); - } else drawable = ContextCompat.getDrawable(context, R.drawable.ic_error); - - } catch (Exception e) { - drawable = ContextCompat.getDrawable(context, R.drawable.ic_error); - } - drawable = DrawableCompat.wrap(drawable); - holder.icon.setImageDrawable(drawable); - } - - @Override - public int getItemCount() { - return files.size(); - } - - public File getItem(int position) { - return files.get(position); - } - - static class ListItemViewHolder extends RecyclerView.ViewHolder { - - CardView cardView; - TextView title; - TextView lastModified; - ImageView icon; - LinearLayout linearLayout; - - public ListItemViewHolder(View itemView) { - super(itemView); - cardView = (CardView) itemView.findViewById(R.id.cardView); - title = (TextView) itemView.findViewById(R.id.title); - icon = (ImageView) itemView.findViewById(R.id.icon); - linearLayout = (LinearLayout) itemView.findViewById(R.id.linearLayout); - lastModified = (TextView) itemView.findViewById(R.id.lastModified); - } - } - - public ArrayList getFiles() { - return files; - } -} \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileChooserActivity.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileChooserActivity.java deleted file mode 100644 index c2bd94f..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileChooserActivity.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * $URL$ - *

- * $LastChangedBy$ - $LastChangedDate$ - */ -package com.gpac.Osmo4.extra; - -import android.Manifest; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.FragmentManager; -import android.content.DialogInterface; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; -import android.view.Menu; -import android.view.MenuItem; - -import com.gpac.Osmo4.R; - - -public class FileChooserActivity extends Activity { - - final String FILE_CHOOSER_FRAGMENT = "fileChooserFragment"; - public final static String TITLE_PARAMETER = "org.openintents.extra.TITLE"; - - private FragmentManager fm; - private FileChooserFragment fileChooserFragment; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_file_chooser); - - requestForPermission(); - fm = getFragmentManager(); - - if (fm.findFragmentById(R.id.fileChooserLayout) == null) { - fileChooserFragment = new FileChooserFragment(); - fm.beginTransaction() - .add(R.id.fileChooserLayout, fileChooserFragment, FILE_CHOOSER_FRAGMENT) - .addToBackStack(FILE_CHOOSER_FRAGMENT) - .commit(); - } - } - - private void requestForPermission() { - - if (ContextCompat.checkSelfPermission(FileChooserActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - - if (ActivityCompat.shouldShowRequestPermissionRationale(FileChooserActivity.this, - Manifest.permission.WRITE_EXTERNAL_STORAGE)) { - - promptForPermissionsDialog(getString(R.string.requestPermissionStorage), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - ActivityCompat.requestPermissions(FileChooserActivity.this, - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, - 100); - } - }); - } else { - ActivityCompat.requestPermissions(FileChooserActivity.this, - new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, - 100); - } - } - } - - private void promptForPermissionsDialog(String message, DialogInterface.OnClickListener onClickListener) { - new AlertDialog.Builder(FileChooserActivity.this) - .setMessage(message) - .setPositiveButton(getString(R.string.yes), onClickListener) - .setNegativeButton(getString(R.string.no), null) - .create() - .show(); - } - - @Override - public void onBackPressed() { - fileChooserFragment.backPressed(); - } - - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - return super.onOptionsItemSelected(item); - } - -} \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileChooserFragment.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileChooserFragment.java deleted file mode 100644 index c197830..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileChooserFragment.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.Manifest; -import android.app.ActionBar; -import android.app.Activity; -import android.app.Fragment; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.os.Environment; -import android.preference.PreferenceManager; -import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.Toast; - -import com.gpac.Osmo4.R; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; - -public class FileChooserFragment extends Fragment { - - private final String PREF_SHOW_HIDDEN_FILES = "SHOW_HIDDEN_FILES"; - private final String PREF_SORT_ORDER = "SORT_ORDER"; - private final String PREF_SORT_BY = "SORT_BY"; - private final String PREF_FOLDERS_FIRST = "FOLDERS_FIRST"; - - private File currDir; - private ArrayList files; - private FileArrayAdapter adapter; - private SharedPreferences prefs; - private ActionBar actionBar; - - private boolean showHiddenFiles; - private String sortOrder; - private String sortBy; - private boolean foldersFirst; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) - currDir = new File("/"); - - else currDir = Environment.getExternalStorageDirectory(); - } - - @Nullable - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_file_chooser, container, false); - setRetainInstance(true); - - RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); - GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 2); - gridLayoutManager.setOrientation(GridLayoutManager.VERTICAL); - files = new ArrayList<>(); - actionBar = getActivity().getActionBar(); - adapter = new FileArrayAdapter(files, onItemClickListenerCallback, getActivity()); - prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - setPreferences(); - recyclerView.setLayoutManager(gridLayoutManager); - populateList(currDir); - recyclerView.setAdapter(adapter); - return view; - } - - @Override - public void onResume() { - super.onResume(); - setPreferences(); - } - - private void setPreferences() { - showHiddenFiles = prefs.getBoolean(PREF_SHOW_HIDDEN_FILES, true); - sortOrder = prefs.getString(PREF_SORT_ORDER, FileManager.SORT_ORDER_ASC); - sortBy = prefs.getString(PREF_SORT_BY, FileManager.SORT_BY_NAME); - foldersFirst = prefs.getBoolean(PREF_FOLDERS_FIRST, true); - } - - public void backPressed() { - if (currDir.getAbsolutePath().equals("/") || !currDir.getParentFile().canRead()) - getActivity().finish(); - else populateList(currDir.getParentFile()); - } - - private FileArrayAdapter.OnItemClickListener onItemClickListenerCallback = new FileArrayAdapter.OnItemClickListener() { - @Override - public void onItemClick(View view, int position) { - File f = adapter.getItem(position); - if (f.isDirectory()) - onDirectoryClick(f); - else if (f.isFile()) - onFileClick(f); - } - }; - - private void onFileClick(File f) { - Intent data = new Intent(); - data.setData(Uri.fromFile(f)); - getActivity().setResult(Activity.RESULT_OK, data); - getActivity().finish(); - } - - private void onDirectoryClick(File f) { - if (f.canRead()) - populateList(f); - else Toast.makeText(getActivity(), "Cannot read " + f, Toast.LENGTH_LONG).show(); - } - - public void populateList(File file) { - new BackgroundWork(file).execute(); - } - - class BackgroundWork extends AsyncTask { - - private File file; - public BackgroundWork(File file) { - this.file = file; - } - - @Override - protected Boolean doInBackground(File... params) { - - if (!file.canRead()) { - Toast.makeText(getActivity(), "Directory cannot be read", Toast.LENGTH_LONG).show(); - return false; - } - files.clear(); - ArrayList list = new ArrayList<>(Arrays.asList(file.listFiles())); - - files.addAll( - FileManager.sort( - showHiddenFiles? list : FileManager.removeHiddenFiles(list), - sortOrder, - sortBy, - foldersFirst - )); - currDir = file; - return true; - } - - @Override - protected void onPostExecute(Boolean aVoid) { - actionBar.setTitle(file.getAbsolutePath()); - adapter.notifyDataSetChanged(); - } - } -} \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileManager.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileManager.java deleted file mode 100644 index 32ef8ec..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/FileManager.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.os.Build; -import android.support.annotation.Nullable; -import android.util.Log; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - - -public class FileManager { - - public static final String SORT_ORDER_ASC = "ASC"; - public static final String SORT_ORDER_DESC = "DESC"; - - public static final String SORT_BY_NAME = "NAME"; - public static final String SORT_BY_SIZE = "SIZE"; - public static final String SORT_BY_LAST_MODIFIED = "LAST_MODIFIED"; - - public static String getExtension(String url) { - - if (url.contains("?")) { - url = url.substring(0, url.indexOf("?")); - } - if (url.lastIndexOf(".") == -1) { - return null; - } else { - String ext = url.substring(url.lastIndexOf(".")); - if (ext.contains("%")) { - ext = ext.substring(0, ext.indexOf("%")); - } - if (ext.contains("/")) { - ext = ext.substring(0, ext.indexOf("/")); - } - return ext.toLowerCase(); - } - } - - public static ArrayList sort(ArrayList files, String sortOrder, String sortBy, boolean folderFirst) { - - switch (sortOrder) { - - case SORT_ORDER_ASC: - switch (sortBy) { - case SORT_BY_SIZE: - return sortBySize(files, SORT_ORDER_ASC, folderFirst); - - case SORT_BY_LAST_MODIFIED: - return sortByLastModified(files, SORT_ORDER_ASC, folderFirst); - - case SORT_BY_NAME: - default: - return sortByName(files, SORT_ORDER_ASC, folderFirst); - } - - case SORT_ORDER_DESC: - switch (sortBy) { - case SORT_BY_NAME: - return sortByName(files, SORT_ORDER_DESC, folderFirst); - - case SORT_BY_LAST_MODIFIED: - return sortByLastModified(files, SORT_ORDER_DESC, folderFirst); - - case SORT_BY_SIZE: - default: - return sortBySize(files, SORT_ORDER_DESC, folderFirst); - } - - default: - return sortByName(files, SORT_ORDER_ASC, folderFirst); - } - - } - - private static ArrayList sortByName(final ArrayList files, final String sortOrder, final boolean folderFirst) { - - Collections.sort(files, new Comparator() { - @Override - public int compare(File lhs, File rhs) { - if(folderFirst) { - if (lhs.isDirectory() && !rhs.isDirectory()) return -1; - if (!lhs.isDirectory() && rhs.isDirectory()) return 1; - } - switch (sortOrder) { - case SORT_ORDER_DESC: - return rhs.getName().compareToIgnoreCase(lhs.getName()); - - case SORT_ORDER_ASC: - default: - return lhs.getName().compareToIgnoreCase(rhs.getName()); - } - } - }); - return files; - } - - private static ArrayList sortBySize(ArrayList files, final String sortOrder, final boolean folderFirst) { - - Collections.sort(files, new Comparator() { - @Override - public int compare(File lhs, File rhs) { - - if(folderFirst) { - if (lhs.isDirectory() && !rhs.isDirectory()) return -1; - if (!lhs.isDirectory() && rhs.isDirectory()) return 1; - } - - long lhsLength = 0, rhsLength = 0, diff; - - if(lhs.isDirectory()) lhsLength = getFolderSize(lhs); - if(lhs.isFile()) lhsLength = lhs.length(); - if(rhs.isDirectory()) rhsLength = getFolderSize(rhs); - if(rhs.isFile()) rhsLength = rhs.length(); - - switch (sortOrder) { - case SORT_ORDER_DESC: - diff = rhsLength - lhsLength; - break; - case SORT_ORDER_ASC: - default: - diff = lhsLength - rhsLength; - break; - } - - if (diff < 0) return -1; - else if (diff > 0) return 1; - else return 0; - } - }); - return files; - } - - private static ArrayList sortByLastModified(ArrayList files, final String sortOrder, final boolean foldersFirst) { - - Collections.sort(files, new Comparator() { - @Override - public int compare(File lhs, File rhs) { - - if (foldersFirst){ - if(lhs.isDirectory() && !rhs.isDirectory()) return -1; - if(!lhs.isDirectory() && rhs.isDirectory()) return 1; - } - - long diff; - switch (sortOrder) { - case SORT_ORDER_DESC: - diff = rhs.lastModified() - lhs.lastModified(); - break; - - case SORT_ORDER_ASC: - default: - diff = lhs.lastModified() - rhs.lastModified(); - break; - } - - if (diff < 0) return -1; - else if (diff > 0) return 1; - else return 0; - } - }); - return files; - } - - public static long getFolderSize(File file) { - - long size = 0; - for (File f : file.listFiles()) { - if (f.isFile()) size += f.length(); - else size += getFolderSize(f); - } - return size; - } - - public static boolean isHiddenFile(File file) { - return file.getName().startsWith("."); - } - - public static ArrayList removeHiddenFiles(ArrayList files) { - ArrayList list = new ArrayList<>(); - - for (File file : files) { - if (!isHiddenFile(file)) - list.add(file); - } - return list; - } -} \ No newline at end of file diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/PrefsActivity.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/PrefsActivity.java deleted file mode 100644 index f4d01a8..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/PrefsActivity.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.app.Activity; -import android.os.Bundle; -import android.preference.PreferenceFragment; - - -import com.gpac.Osmo4.R; - - -public class PrefsActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - getFragmentManager().beginTransaction().replace(android.R.id.content, - new PrefsFragment()).commit(); - } - - - public static class PrefsFragment extends PreferenceFragment { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - addPreferencesFromResource(R.xml.preference); - } - } - -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/XMLTagHandler.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/XMLTagHandler.java deleted file mode 100644 index ed97ec4..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/extra/XMLTagHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.gpac.Osmo4.extra; - -import android.text.Editable; -import android.text.Html.TagHandler; - -import org.xml.sax.XMLReader; - -public class XMLTagHandler implements TagHandler{ - boolean first= true; - String parent=null; - int index=1; - @Override - public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) { - - if(tag.equals("ul")) { - parent = "ul"; - output.append("\n"); - } - else if(tag.equals("ol")) parent="ol"; - if(tag.equals("li")){ - if(parent.equals("ul")){ - if(first){ - output.append("\n\t•"); - first= false; - }else{ - first = true; - } - } - else{ - if(first){ - output.append("\n\t"+index+". "); - first= false; - index++; - }else{ - first = true; - } - } - } - } -} diff --git a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/logs/GpacLogger.java b/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/logs/GpacLogger.java deleted file mode 100644 index ce60a55..0000000 --- a/applications/osmo4_android_studio/app/src/main/java/com/gpac/Osmo4/logs/GpacLogger.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * $URL$ - * - * $LastChangedBy$ - $LastChangedDate$ - */ -package com.gpac.Osmo4.logs; - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.PrintStream; -import java.util.Date; -import java.util.SortedSet; -import java.util.TreeSet; -import android.util.Log; -import com.gpac.Osmo4.GpacCallback.GF_Log_Module; -import com.gpac.Osmo4.GpacConfig; - -/** - * This class handles logging. - * - * It will be extended soon to be configurable and enable saving files on disk - * - * @version $Revision$ - * - */ -public class GpacLogger { - - /** - * Default Constructor - * - * @param gpacConfig - */ - public GpacLogger(GpacConfig gpacConfig) { - loggedModules.add(GF_Log_Module.GF_LOG_AUDIO); - loggedModules.add(GF_Log_Module.GF_LOG_MEDIA); - loggedModules.add(GF_Log_Module.GF_LOG_MODULE); - loggedModules.add(GF_Log_Module.GF_LOG_CORE); - logDir = gpacConfig.getGpacLogDirectory(); //$NON-NLS-1$ - } - - private boolean enableLogOnDisk = false; - - /** - * @return the enableLogOnDisk - */ - public synchronized boolean isEnableLogOnDisk() { - return enableLogOnDisk; - } - - /** - * @param enableLogOnDisk the enableLogOnDisk to set - */ - public synchronized void setEnableLogOnDisk(boolean enableLogOnDisk) { - this.enableLogOnDisk = enableLogOnDisk; - } - - private String logDir; - private String logFile; - - public synchronized void setLogFile(String logFile) { - //reset writer - writer = null; - this.logFile = logDir + logFile; - } - - /** - * Called when creating logger - */ - public void onCreate() { - if (!enableLogOnDisk) - return; - if (writer == null) { - try { - writer = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(logFile)), 128), true, "UTF-8"); //$NON-NLS-1$ - } catch (Exception e) { - Log.e(GpacLogger.class.getSimpleName(), "Failed to create writer", e); //$NON-NLS-1$ - } - } - if (writer != null) - writer.println("New log $Revision$ at " + new Date()); //$NON-NLS-1$ - } - - /** - * Called when stopping logger - */ - public void onDestroy() { - if (!enableLogOnDisk) - return; - PrintStream w = this.writer; - writer = null; - if (w != null) { - w.println("Closing log file at " + new Date()); //$NON-NLS-1$ - w.close(); - } - } - - /** - * Logs from C-code - * - * @param level - * @param module - * @param message - */ - public void onLog(int level, int module, String message) { - GF_Log_Module gModule = GF_Log_Module.getModule(module); - doLog(gModule, level, message); - } - - private void doLog(GF_Log_Module module, int level, String message) { - Log.println(4, module.name(), message); - if (enableLogOnDisk) { - PrintStream s = writer; - if (s != null) { - s.println(module.name() + "\t" + message); //$NON-NLS-1$ - s.flush(); - } - } - } - - private final SortedSet loggedModules = new TreeSet(); - - // The log level used by GPAC modules that are part of loggedModules collection - private int loggedLevel = Log.DEBUG; - - // The log level used by GPAC modules not part of loggedModules collection - private int defaultLoggedLevel = Log.INFO; - - /** - * @return the loggedLevel - */ - public synchronized int getLoggedLevel() { - return loggedLevel; - } - - /** - * @param loggedLevel the loggedLevel to set - */ - public synchronized void setLoggedLevel(int loggedLevel) { - this.loggedLevel = loggedLevel; - } - - /** - * @return the defaultLoggedLevel - */ - public synchronized int getDefaultLoggedLevel() { - return defaultLoggedLevel; - } - - /** - * @param defaultLoggedLevel the defaultLoggedLevel to set - */ - public synchronized void setDefaultLoggedLevel(int defaultLoggedLevel) { - this.defaultLoggedLevel = defaultLoggedLevel; - } - - private volatile PrintStream writer; - -} diff --git a/applications/osmo4_android_studio/app/src/main/jni/README.txt b/applications/osmo4_android_studio/app/src/main/jni/README.txt deleted file mode 100644 index 05c508f..0000000 --- a/applications/osmo4_android_studio/app/src/main/jni/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -To build Android version, Please execute the script : -../../../build/android/jni/gpac_build_android diff --git a/applications/osmo4_android_studio/app/src/main/jni/wrapper.cpp b/applications/osmo4_android_studio/app/src/main/jni/wrapper.cpp deleted file mode 100644 index 73aa32a..0000000 --- a/applications/osmo4_android_studio/app/src/main/jni/wrapper.cpp +++ /dev/null @@ -1,1098 +0,0 @@ -/* - * GPAC - Multimedia Framework C SDK - * - * Authors: Jean Le Feuvre - * Copyright (c) Telecom ParisTech 2009- - * All rights reserved - * - * Created by NGO Van Luyen, Ivica ARSOV / ARTEMIS / Telecom SudParis /Institut TELECOM on Oct, 2010 - * - * This file is part of GPAC / Wrapper - * - * GPAC is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * GPAC is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include "wrapper.h" -#include "wrapper_jni.hpp" - -#include -#include - -#define TAG "GPAC_WRAPPER" - -#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) -#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) -#define LOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) -#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) -#include - -static JavaVM* javaVM = NULL; - -static pthread_key_t jni_thread_env_key = 0; - -//these two are used by modumles - define them when using static module build -#ifdef GPAC_STATIC_MODULES - -#ifdef __cplusplus -extern "C" { -#endif - -JavaVM* GetJavaVM() -{ - return javaVM; -} - -JNIEnv* GetEnv() -{ - JNIEnv* env = 0; - if (javaVM) javaVM->GetEnv((void**)(&env), JNI_VERSION_1_2); - return env; -} - -#ifdef __cplusplus -} -#endif - -#endif - - -/** - * This method is called when a pthread is destroyed, so we can delete the JNI env - */ -static void jni_destroy_env_func(void * env) { - LOGI("Destroying a thread with attached data, env=%p.\n", env); - JavaEnvTh * jniEnv = (JavaEnvTh *) env; - if (jniEnv) { - /*jniEnv->env->DeleteLocalRef(&jniEnv->cbk_displayMessage); - jniEnv->env->DeleteLocalRef(&jniEnv->cbk_onProgress); - jniEnv->env->DeleteLocalRef(&jniEnv->cbk_showKeyboard); - jniEnv->env->DeleteLocalRef(&jniEnv->cbk_setCaption); - jniEnv->env->DeleteLocalRef(&jniEnv->cbk_onLog);*/ - memset(jniEnv, 0, sizeof(JavaEnvTh)); - gf_free(jniEnv); - } - pthread_setspecific(jni_thread_env_key, NULL); - if (javaVM) - javaVM->DetachCurrentThread(); -} - -static int jniRegisterNativeMethods(JNIEnv* env, const char* className, - const JNINativeMethod* gMethods, int numMethods) -{ - int res; - jclass clazz; - clazz = env->FindClass(className); - if (clazz == NULL) { - LOGE("Native registration unable to find class '%s'\n", className); - return -1; - } - LOGI("Registering %d methods...\n", numMethods ); - res = env->RegisterNatives(clazz, gMethods, numMethods); - if (res < 0) { - LOGE("RegisterNatives failed for '%s'\n", className); - return res; - } - return 0; -} - -static JNINativeMethod sMethods[] = { - /* name, signature, funcPtr */ - - { "createInstance", - "(Lcom/gpac/Osmo4/GpacCallback;IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J", - (void*)&Java_com_gpac_Osmo4_GPACInstance_createInstance - }, - { "gpacdisconnect", - "()V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpacdisconnect - }, - { "gpacrender", - "()V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpacrender - }, - { "gpacresize", - "(II)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpacresize - }, - { "gpacfree", - "()V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpacfree - }, - { "gpaceventkeypress", - "(IIIII)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpaceventkeypress - }, - { "gpaceventmousedown", - "(FF)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpaceventmousedown - }, - { "gpaceventmouseup", - "(FF)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpaceventmouseup - }, - { "gpaceventmousemove", - "(FF)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpaceventmousemove - }, - { "gpaceventorientationchange", - "(FFF)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_gpaceventorientationchange - }, - { "setGpacPreference", - "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_setGpacPreference - }, - { "setGpacLogs", - "(Ljava/lang/String;)V", - (void*)Java_com_gpac_Osmo4_GPACInstance_setGpacLogs - }, - NULL -}; - - -jint JNI_OnUnLoad(JavaVM* vm, void* reserved) { - LOGI("Deleting library, vm=%p...\n", vm); - if (pthread_key_delete(jni_thread_env_key)) { - LOGW("Failed to delete key jni_thread_env_key jni_thread_env_key=%d\n", jni_thread_env_key); - } - javaVM = NULL; - jni_thread_env_key = (int) NULL; -} - -#define NUM_JNI_VERSIONS 4 -//--------------------------------------------------------------------------------------------------- -jint JNI_OnLoad(JavaVM* vm, void* reserved) { - int res; - int jniV; - int allowedVersions[NUM_JNI_VERSIONS]; - const char * className = "com/gpac/Osmo4/GPACInstance"; - allowedVersions[0] = JNI_VERSION_1_6; - allowedVersions[1] = JNI_VERSION_1_4; - allowedVersions[2] = JNI_VERSION_1_2; - allowedVersions[3] = JNI_VERSION_1_1; - JNIEnv * env; - if (!vm) - return -1; - for (int i = 0 ; i < NUM_JNI_VERSIONS; i++) { - jniV = allowedVersions[i]; - if (vm->GetEnv((void**)(&env), jniV) == JNI_OK) { - LOGI("Selected JNI VERSION[%d]\n", i); - break; - } else { - if (i == NUM_JNI_VERSIONS - 1) { - LOGW("Failed to find any supported JNI VERSION of the %d proposed.", NUM_JNI_VERSIONS); - return -1; - } - } - - } - javaVM = vm; - LOGI("Registering %s natives\n", className); - res = jniRegisterNativeMethods(env, className, sMethods, (sizeof(sMethods) - 1)/sizeof(JNINativeMethod)); - if (res < 0) { - LOGE("Failed to register native methods, result was = %d, try to continue anyway...\n", res); - /*return -1;*/ - } - LOGI("Registering natives DONE, now registering pthread_keys with destructor=%p\n", &jni_destroy_env_func); - int ret = pthread_key_create(&jni_thread_env_key, &jni_destroy_env_func); - if (ret) { - LOGE("Failed to register jni_thread_env_key jni_thread_env_key=%d\n", jni_thread_env_key); - } - return jniV; -} - -//--------------------------------------------------------------------------------------------------- -//CNativeWrapper -//------------------------------- - -CNativeWrapper::CNativeWrapper() { - do_log = 1; - m_term = NULL; - m_mx = NULL; - mainJavaEnv = NULL; -#ifndef GPAC_GUI_ONLY - memset(&m_user, 0, sizeof(GF_User)); - memset(&m_rti, 0, sizeof(GF_SystemRTInfo)); -#endif -} -//------------------------------- -CNativeWrapper::~CNativeWrapper() { - debug_log("~CNativeWrapper()"); - JavaEnvTh * env = getEnv(); - if (env && env->cbk_obj) - env->env->DeleteGlobalRef(env->cbk_obj); - Shutdown(); - debug_log("~CNativeWrapper() : DONE\n"); -} -//------------------------------- -void CNativeWrapper::debug_log(const char* msg) { - LOGV("%s", msg); -} -//------------------------------- -void CNativeWrapper::Shutdown() -{ - debug_log("shutdown"); - if (m_term) - gf_term_disconnect(m_term); - if (m_mx) - gf_mx_del(m_mx); - m_mx = NULL; -#ifndef GPAC_GUI_ONLY - if (m_term) { - GF_Terminal *t = m_term; - m_term = NULL; - gf_term_del(t); - } - if (m_user.config) { - gf_cfg_del(m_user.config); - m_user.config = NULL; - } - if (m_user.modules) { - gf_modules_del(m_user.modules); - m_user.modules = NULL; - } -#endif - m_term = NULL; - gf_sys_close(); - debug_log("shutdown end"); -} - -void CNativeWrapper::setJavaEnv(JavaEnvTh * envToSet, JNIEnv *env, jobject callback) { - assert( envToSet ); - jclass localRef = env->GetObjectClass(callback); - envToSet->env = env; - envToSet->javaThreadId = gf_th_id(); - envToSet->cbk_obj = callback; - envToSet->cbk_displayMessage = - env->GetMethodID(localRef, "displayMessage", "(Ljava/lang/String;Ljava/lang/String;I)V"); - envToSet->cbk_onProgress = - env->GetMethodID(localRef, "onProgress", "(Ljava/lang/String;II)V"); - envToSet->cbk_onLog = - env->GetMethodID(localRef, "onLog", "(IILjava/lang/String;)V"); - envToSet->cbk_setCaption = - env->GetMethodID(localRef, "setCaption", "(Ljava/lang/String;)V"); - envToSet->cbk_showKeyboard = - env->GetMethodID(localRef, "showKeyboard", "(Z)V"); - envToSet->cbk_setLogFile = - env->GetMethodID(localRef, "setLogFile", "(Ljava/lang/String;)V"); - envToSet->cbk_sensorSwitch = - env->GetMethodID(localRef, "sensorSwitch", "(Z)V"); - env->DeleteLocalRef(localRef); -} - -static u32 beforeThreadExits(void * param) { - /* Ivica - I think there is no need for this because the detach is done in jni_destroy_env_func() - /*LOGI("Before Thread exist, detach the JavaVM from Thread for thread %p...\n", gf_th_current()); - if (javaVM) - javaVM->DetachCurrentThread(); - */ -} - -JavaEnvTh * CNativeWrapper::getEnv() { - JNIEnv *env; - JavaEnvTh * javaEnv; - if (!javaVM) { - debug_log("************* No JVM Found ************"); - return NULL; - } - javaEnv = (JavaEnvTh*) pthread_getspecific( jni_thread_env_key ); - if (javaEnv) - return javaEnv; - javaEnv = (JavaEnvTh *) gf_malloc(sizeof(JavaEnvTh)); - if (!javaEnv) - return NULL; - memset(javaEnv, 0, sizeof(JavaEnvTh)); - javaVM->AttachCurrentThread(&env, NULL); - if (!env) { - LOGE("Attaching to thread did failed for thread id=%d", gf_th_id()); - gf_free(javaEnv); - return NULL; - } - LOGI("Rebuilding methods for thread %d", gf_th_id()); - setJavaEnv(javaEnv, env, mainJavaEnv->cbk_obj); - if (pthread_setspecific(jni_thread_env_key, javaEnv)) { - LOGE("Failed to set specific thread data to jni_thread_env_key for thread=%d. No ENV available !", gf_th_id()); - gf_free(javaEnv); - return NULL; - } - GF_Thread * t; - LOGI("Getting current Thread %d...", gf_th_id()); - t = gf_th_current(); - LOGI("Getting current Thread DONE = %p, now registering before exit...", t); - - if (GF_OK != gf_register_before_exit_function(gf_th_current(), &beforeThreadExits)) { - LOGE("Failed to register exit function for thread %p, no javaEnv for current thread.", gf_th_current()); - //javaVM->DetachCurrentThread(); - gf_free(javaEnv); - javaEnv = NULL; - } - LOGI("Registering DONE for %d", gf_th_id()); - return javaEnv; -} - - -//------------------------------- -int CNativeWrapper::MessageBox(const char* msg, const char* title, GF_Err status) { - LOGV("MessageBox start %s", msg); - JavaEnvTh * env = getEnv(); - if (!env || !env->cbk_displayMessage) - return 0; - env->env->PushLocalFrame(2); - jstring tit = env->env->NewStringUTF(title?title:"null"); - jstring mes = env->env->NewStringUTF(msg?msg:"null"); - env->env->CallVoidMethod(env->cbk_obj, env->cbk_displayMessage, mes, tit, status); - env->env->PopLocalFrame(NULL); - LOGV("MessageBox done %s", msg); - return 1; -} -//------------------------------- -void CNativeWrapper::DisplayRTI() { -#ifndef GPAC_GUI_ONLY - // display some system informations ? -#endif -} -//------------------------------- -int CNativeWrapper::Quit(int code) { - - Shutdown(); - // send shutdown request to java - return code; -} - -#include - -void CNativeWrapper::on_fm_request(void *cbk, u32 type, u32 param, int *value) { - CNativeWrapper * self = (CNativeWrapper *) cbk; - JavaEnvTh *envth = self->getEnv(); - - envth->env->PushLocalFrame(1); - switch(type) { - case 0: // Get PI - case 1: // Get RT - case 2: // Get PS - jint jvalue; - jvalue = envth->env->CallIntMethod(envth->cbk_obj, envth->cbk_onFmRequest, type, param); - *value = (int)jvalue; - break; - case 3: // Set Freq - case 4: // Set Volume - envth->env->CallVoidMethod(envth->cbk_obj, envth->cbk_onFmRequest, type, param); - break; - } - envth->env->PopLocalFrame(NULL); -} - - -//------------------------------- -void CNativeWrapper::on_gpac_log(void *cbk, GF_LOG_Level ll, GF_LOG_Tool lm, const char *fmt, va_list list) { - char szMsg[4096]; - const char * tag; - char unknTag[32]; - int level = (ll == GF_LOG_ERROR) ? ANDROID_LOG_ERROR : ANDROID_LOG_DEBUG; - vsnprintf(szMsg, 4096, fmt, list); - CNativeWrapper * self = (CNativeWrapper *) cbk; - if (!self) - goto displayInAndroidlogs; - - { - JavaEnvTh *env = self->getEnv(); - jstring msg; - - if (!env || !env->cbk_onLog) - goto displayInAndroidlogs; - - env->env->PushLocalFrame(1); - msg = env->env->NewStringUTF(szMsg); - env->env->CallVoidMethod(env->cbk_obj, env->cbk_onLog, level, lm, msg); - env->env->PopLocalFrame(NULL); - return; - } -displayInAndroidlogs: - { - /* When no callback is properly set, we use direct logging */ - switch( lm) { - case GF_LOG_CORE: - tag="GF_LOG_CORE"; - break; - case GF_LOG_CODING: - tag="GF_LOG_CODING"; - break; - case GF_LOG_CONTAINER: - tag="GF_LOG_CONTAINER"; - break; - case GF_LOG_NETWORK: - tag="GF_LOG_NETWORK"; - break; - case GF_LOG_RTP: - tag="GF_LOG_RTP"; - break; - case GF_LOG_AUTHOR: - tag="GF_LOG_AUTHOR"; - break; - case GF_LOG_SYNC: - tag="GF_LOG_SYNC"; - break; - case GF_LOG_CODEC: - tag="GF_LOG_CODEC"; - break; - case GF_LOG_PARSER: - tag="GF_LOG_PARSER"; - break; - case GF_LOG_MEDIA: - tag="GF_LOG_MEDIA"; - break; - case GF_LOG_SCENE: - tag="GF_LOG_SCENE"; - break; - case GF_LOG_SCRIPT: - tag="GF_LOG_SCRIPT"; - break; - case GF_LOG_INTERACT: - tag="GF_LOG_INTERACT"; - break; - case GF_LOG_COMPOSE: - tag="GF_LOG_COMPOSE"; - break; - case GF_LOG_CACHE: - tag="GF_LOG_CACHE"; - break; - case GF_LOG_MMIO: - tag="GF_LOG_MMIO"; - break; - case GF_LOG_RTI: - tag="GF_LOG_RTI"; - break; - case GF_LOG_SMIL: - tag="GF_LOG_SMIL"; - break; - case GF_LOG_MEMORY: - tag="GF_LOG_MEMORY"; - break; - case GF_LOG_AUDIO: - tag="GF_LOG_AUDIO"; - break; - case GF_LOG_MODULE: - tag="GF_LOG_MODULE"; - break; - case GF_LOG_MUTEX: - tag="GF_LOG_MUTEX"; - break; - case GF_LOG_CONDITION: - tag="GF_LOG_CONDITION"; - break; - case GF_LOG_DASH: - tag="GF_LOG_DASH"; - break; - case GF_LOG_CONSOLE: - tag="GF_LOG_CONSOLE"; - break; - case GF_LOG_APP: - tag="GF_LOG_APP"; - break; - case GF_LOG_SCHEDULER: - tag="GF_LOG_SCHEDULER"; - break; - default: - snprintf(unknTag, 32, "GPAC_UNKNOWN[%d]", lm); - tag = unknTag; - } - __android_log_print(level, tag, "%s\n", szMsg); - } -} -//------------------------------- -Bool CNativeWrapper::GPAC_EventProc(void *cbk, GF_Event *evt) { - if (cbk) - { - CNativeWrapper* ptr = (CNativeWrapper*)cbk; - char msg[4096]; - msg[0] = 0; - LOGD("GPAC_EventProc() Message=%d", evt->type); - switch (evt->type) { - case GF_EVENT_CLICK: - case GF_EVENT_MOUSEUP: - case GF_EVENT_MOUSEDOWN: - case GF_EVENT_MOUSEOVER: - case GF_EVENT_MOUSEOUT: - case GF_EVENT_MOUSEMOVE: - case GF_EVENT_MOUSEWHEEL: - case GF_EVENT_KEYUP: - case GF_EVENT_KEYDOWN: - case GF_EVENT_LONGKEYPRESS: - case GF_EVENT_TEXTINPUT: - /* We ignore all these events */ - break; - case GF_EVENT_MEDIA_SETUP_BEGIN: - case GF_EVENT_MEDIA_SETUP_DONE: - case GF_EVENT_MEDIA_LOAD_START: - case GF_EVENT_MEDIA_PLAYING: - case GF_EVENT_MEDIA_WAITING: - case GF_EVENT_MEDIA_PROGRESS: - case GF_EVENT_MEDIA_LOAD_DONE: - case GF_EVENT_ABORT: - case GF_EVENT_ERROR: - LOGD("GPAC_EventProc() Media Event detected = [index=%d]", evt->type - GF_EVENT_MEDIA_SETUP_BEGIN); - break; - case GF_EVENT_MESSAGE: - { - ptr->debug_log("GPAC_EventProc start"); - if ( evt->message.message ) - { - strcat(msg, evt->message.message); - strcat(msg, ": "); - } - strcat(msg, gf_error_to_string(evt->message.error)); - - ptr->debug_log(msg); - //ptr->MessageBox(msg, evt->message.service ? evt->message.service : "GF_EVENT_MESSAGE", evt->message.error); - ptr->debug_log("GPAC_EventProc end"); - }; - break; - case GF_EVENT_CONNECT: - if (evt->connect.is_connected) - ptr->MessageBox("Connected", "Connected to scene", GF_OK); - else - ptr->MessageBox("Disconnected", "Disconnected from scene.", GF_OK); - break; - case GF_EVENT_PROGRESS: - { - const char * szTitle;; - if (evt->progress.progress_type==0) - szTitle = "Buffering"; - else if (evt->progress.progress_type==1) - szTitle = "Downloading..."; - else if (evt->progress.progress_type==2) - szTitle = "Import "; - else - szTitle = "Unknown Progress Event"; - ptr->Osmo4_progress_cbk(ptr, szTitle, evt->progress.done, evt->progress.total); - gf_set_progress(szTitle, evt->progress.done, evt->progress.total); - } - break; - case GF_EVENT_TEXT_EDITING_START: - case GF_EVENT_TEXT_EDITING_END: - { - JavaEnvTh * env = ptr->getEnv(); - if (!env || !env->cbk_showKeyboard) - return GF_FALSE; - LOGI("Needs to display/hide the Virtual Keyboard (%d)", evt->type); - env->env->CallVoidMethod(env->cbk_obj, env->cbk_showKeyboard, GF_EVENT_TEXT_EDITING_START == evt->type); - LOGV("Done showing virtual keyboard (%d)", evt->type); - } - break; - case GF_EVENT_EOS: - LOGI("EOS Reached (%d)", evt->type); - break; - case GF_EVENT_DISCONNECT: - /* FIXME : not sure about this behaviour */ - if (ptr) - ptr->disconnect(); - break; - case GF_EVENT_NAVIGATE: - ptr->navigate( evt); - break; - case GF_EVENT_SENSOR_REQUEST: - if(evt->activate_sensor.sensor_type == GF_EVENT_SENSOR_ORIENTATION){ - if(evt->activate_sensor.activate){ - LOGV("We received Sensor Request for turning ON location sensors"); - JavaEnvTh * env = ptr->getEnv(); - if (!env || !env->cbk_sensorSwitch) - return GF_FALSE; - env->env->CallVoidMethod(env->cbk_obj, env->cbk_sensorSwitch, evt->activate_sensor.activate); - }else{ - LOGV("We received Sensor Request for turning OFF location sensors"); - JavaEnvTh * env = ptr->getEnv(); - if (!env || !env->cbk_sensorSwitch) - return GF_FALSE; - env->env->CallVoidMethod(env->cbk_obj, env->cbk_sensorSwitch, evt->activate_sensor.activate); - } - return GF_TRUE; - } - break; - case GF_EVENT_SENSOR_ORIENTATION: - /* Ignore this event */ - /* - LOGV("We received Sensor Orientation event (x: %f, y: %f, z: %f)",evt->sensor.x, evt->sensor.y, evt->sensor.z); - */ - break; - default: - LOGI("Unknown Message %d", evt->type); - } - } - return GF_FALSE; -} - -void CNativeWrapper::navigate( GF_Event* evt) -{ - if (gf_term_is_supported_url(m_term, evt->navigate.to_url, GF_TRUE, GF_TRUE)) - { - gf_term_navigate_to(m_term, evt->navigate.to_url); - } -} - -void CNativeWrapper::progress_cbk(const char *title, u64 done, u64 total) { - JavaEnvTh *env = getEnv(); - if (!env || !env->cbk_onProgress) - return; - //debug_log("Osmo4_progress_cbk start"); - env->env->PushLocalFrame(1); - jstring js = env->env->NewStringUTF(title); - env->env->CallVoidMethod(env->cbk_obj, env->cbk_onProgress, js, done, total); - env->env->PopLocalFrame(NULL); - //debug_log("Osmo4_progress_cbk end"); -} - - -//------------------------------- -void CNativeWrapper::Osmo4_progress_cbk(const void *usr, const char *title, u64 done, u64 total) { - if (!usr) - return; - CNativeWrapper * self = (CNativeWrapper *) usr; - self->progress_cbk(title, done, total); -} -//------------------------------- -void CNativeWrapper::SetupLogs() { - const char *opt; - debug_log("SetupLogs()"); - - gf_mx_p(m_mx); - gf_log_set_tools_levels( gf_cfg_get_key(m_user.config, "General", "Logs") ); - gf_log_set_callback(this, on_gpac_log); - opt = gf_cfg_get_key(m_user.config, "General", "LogFile"); - if (opt) { - JavaEnvTh *env = getEnv(); - if (env && env->cbk_setLogFile) { - env->env->PushLocalFrame(1); - jstring js = env->env->NewStringUTF(opt); - env->env->CallVoidMethod(env->cbk_obj, env->cbk_setLogFile, js); - env->env->PopLocalFrame(NULL); - } - } - gf_mx_v(m_mx); - - GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Osmo4 logs initialized\n")); - /* Test for JNI invocations, should work properly - int k; - for (k = 0 ; k < 512; k++){ - GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Message %d\n", k)); - }*/ -} -//------------------------------- -// dir should end with / -int CNativeWrapper::init(JNIEnv * env, void * bitmap, jobject * callback, int width, int height, const char * cfg_dir, const char * modules_dir, const char * cache_dir, const char * font_dir, const char * gui_dir, const char * urlToLoad) { - LOGI("Initializing GPAC with URL=%s...", urlToLoad); - strcpy(m_modules_dir, modules_dir); - strcpy(m_cache_dir, cache_dir); - strcpy(m_font_dir, font_dir); - if (cfg_dir) - strcpy(m_cfg_dir, cfg_dir); - - char m_cfg_filename[GF_MAX_PATH]; - if (m_cfg_dir) { - LOGI("GPAC.cfg found in %s, force using it.\n", m_cfg_dir); - strcpy(m_cfg_filename, m_cfg_dir); - strcat(m_cfg_filename, "GPAC.cfg"); - } - - int m_Width = width; - int m_Height = height; - - int first_launch = 0; - const char *opt; - - m_window = env; - m_session = bitmap; - if (!mainJavaEnv) - mainJavaEnv = (JavaEnvTh *) gf_malloc(sizeof(JavaEnvTh)); - memset(mainJavaEnv, 0, sizeof(JavaEnvTh)); - setJavaEnv(mainJavaEnv, env, env->NewGlobalRef(*callback)); - if (pthread_setspecific( jni_thread_env_key, mainJavaEnv)) { - LOGE("Failed to set specific thread data to jni_thread_env_key=%d for main thread !", jni_thread_env_key); - } - - m_mx = gf_mx_new("Osmo4"); - - //load config file - LOGI("Loading User Config %s...", "GPAC.cfg"); - m_user.config = gf_cfg_init(m_cfg_dir ? m_cfg_filename : NULL, NULL); - gf_set_progress_callback(this, Osmo4_progress_cbk); - - - char path[512]; - strcpy(path, gui_dir); - char vertex_path[512], fragment_path[512]; - strcpy(vertex_path, path); - strcpy(fragment_path, path); - strcat(vertex_path, "/../shaders/vertex.glsl"); - strcat(fragment_path, "/../shaders/fragment.glsl"); - - gf_cfg_set_key(m_user.config, "Compositor", "VertexShader", vertex_path); - gf_cfg_set_key(m_user.config, "Compositor", "FragmentShader", fragment_path); - gf_cfg_set_key(m_user.config, "Compositor", "OpenGLMode", "hybrid"); - opt = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); - LOGI("loading modules in directory %s...", opt); - m_user.modules = gf_modules_new(opt, m_user.config); - if (!m_user.modules || !gf_modules_get_count(m_user.modules)) { - LOGE("No modules found in directory %s !", opt); - if (m_user.modules) - gf_modules_del(m_user.modules); - gf_cfg_del(m_user.config); - m_user.config = NULL; - return Quit(KErrGeneral); - } - - /*we don't thread the visual compositor to be able to minimize the app and still have audio running*/ - m_user.init_flags = GF_TERM_NO_COMPOSITOR_THREAD; - m_user.opaque = this; - - m_user.os_window_handler = m_window; - m_user.os_display = m_session; - m_user.EventProc = GPAC_EventProc; - if (!javaVM) { - LOGE("NO JAVA VM FOUND, m_user=%p !!!!\n", &m_user); - return Quit(KErrGeneral); - } - - LOGD("Loading GPAC terminal, m_user=%p...", &m_user); - gf_sys_init(GF_MemTrackerNone); - gf_fm_request_set_callback(this, on_fm_request); - SetupLogs(); - m_term = gf_term_new(&m_user); - if (!m_term) { - LOGE("Cannot load GPAC Terminal with m_user=%p", &m_user); - MessageBox("Cannot load GPAC terminal", "Fatal Error", GF_SERVICE_ERROR); - gf_modules_del(m_user.modules); - m_user.modules = NULL; - gf_cfg_del(m_user.config); - m_user.config = NULL; - return Quit(KErrGeneral); - } - - /*force fullscreen*/ - gf_term_set_option(m_term, GF_OPT_FULLSCREEN, 1); - - //setAudioEnvironment(javaVM); - - LOGD("Setting term size m_user=%p...", &m_user); - gf_term_set_size(m_term, m_Width, m_Height); - - opt = gf_cfg_get_key(m_user.config, "General", "StartupFile"); - LOGD("File loaded at startup=%s.", opt); - - if (!urlToLoad) - urlToLoad = opt; - if (urlToLoad) { - LOGI("Connecting to %s...", urlToLoad); - gf_term_connect(m_term, urlToLoad); - } - debug_log("init end"); - LOGD("Saving config file...\n"); - gf_cfg_save(m_user.config); - LOGI("Initialization complete, config file saved.\n"); - - return 0; -} -//------------------------------- -int CNativeWrapper::connect(const char *url) -{ - const char *str; - char the_url[256]; - - if (m_term) - { - debug_log("Starting to connect ..."); - str = gf_cfg_get_key(m_user.config, "General", "StartupFile"); - if (str) - { - gf_cfg_set_key(m_user.config, "Temp", "GUIStartupFile", url); - gf_term_connect(m_term, str); - } - if( url ) - { - gf_term_connect_from_time(m_term, url, 0, GF_FALSE); - } - } - debug_log("connected ..."); -} - -void CNativeWrapper::setGpacPreference( const char * category, const char * name, const char * value) -{ - if (m_user.config) { - gf_cfg_set_key(m_user.config, category, name, value); - gf_cfg_save(m_user.config); - } -} - -//----------------------------------------------------- -void CNativeWrapper::disconnect() { - if (m_term) { - debug_log("disconnecting"); - gf_term_disconnect(m_term); - debug_log("disconnected ..."); - } -} -//----------------------------------------------------- -void CNativeWrapper::step(void * env, void * bitmap) { - m_window = env; - m_session = bitmap; - //debug_log("Step ..."); - if (!m_term) { - debug_log("step(): No m_term found."); - return; - } else if (!m_term->compositor) - debug_log("step(): No compositor found."); - else if (!m_term->compositor->video_out) - debug_log("step(): No video_out found"); - else if (!m_term->compositor->video_out->Setup) - debug_log("step(): No video_out->Setup found"); - else { - m_term->compositor->frame_draw_type = GF_SC_DRAW_FRAME; - gf_term_process_step(m_term); - } -} - -//----------------------------------------------------- -void CNativeWrapper::setAudioEnvironment(JavaVM* javaVM) { - if (!m_term) { - debug_log("setAudioEnvironment(): no m_term found."); - return; - } - debug_log("setAudioEnvironment start"); - m_term->compositor->audio_renderer->audio_out->Setup(m_term->compositor->audio_renderer->audio_out, javaVM, 0, 0); - debug_log("setAudioEnvironment end"); -} -//----------------------------------------------------- -void CNativeWrapper::resize(int w, int h) { - if (!m_term) - return; - debug_log("resize start"); - gf_term_set_size(m_term, w, h); - debug_log("resize end"); -} - -//----------------------------------------------------- -void CNativeWrapper::onMouseDown(float x, float y) { - if (!m_term) - return; - debug_log("onMouseDown start"); - //char msg[100]; - //sprintf(msg, "onMousedown x=%f, y=%f", x, y ); - //debug_log(msg); - - GF_Event evt; - evt.type = GF_EVENT_MOUSEDOWN; - evt.mouse.button = GF_MOUSE_LEFT; - evt.mouse.x = x; - evt.mouse.y = y; - - int ret = gf_term_user_event(m_term, &evt); - debug_log("onMouseDown end"); -} -//----------------------------------------------------- -void CNativeWrapper::onMouseUp(float x, float y) { - if (!m_term) - return; - debug_log("onMouseUp start"); - //char msg[100]; - //sprintf(msg, "onMouseUp x=%f, y=%f", x, y ); - //debug_log(msg); - - GF_Event evt; - evt.type = GF_EVENT_MOUSEUP; - evt.mouse.button = GF_MOUSE_LEFT; - evt.mouse.x = x; - evt.mouse.y = y; - - int ret = gf_term_user_event(m_term, &evt); - debug_log("onMouseUp end"); -} -//----------------------------------------------------- -void CNativeWrapper::onMouseMove(float x, float y) { - if (!m_term) - return; - GF_Event evt; - evt.type = GF_EVENT_MOUSEMOVE; - evt.mouse.button = GF_MOUSE_LEFT; - evt.mouse.x = x; - evt.mouse.y = y; - - int ret = gf_term_user_event(m_term, &evt); -} -//----------------------------------------------------- -void CNativeWrapper::onKeyPress(int keycode, int rawkeycode, int up, int flag, int unicode) { - if (!m_term) - return; - debug_log("onKeyPress start"); - GF_Event evt; - memset(&evt, 0, sizeof(GF_Event)); - if (up == 0) evt.type = GF_EVENT_KEYUP; - else evt.type = GF_EVENT_KEYDOWN; - - evt.key.flags = 0; - evt.key.hw_code = rawkeycode; - - translate_key(keycode, &evt.key); - //evt.key.key_code = GF_KEY_A; - int ret = gf_term_user_event(m_term, &evt); - - if (evt.type == GF_EVENT_KEYUP && unicode) { - memset(&evt, 0, sizeof(GF_Event)); - evt.type = GF_EVENT_TEXTINPUT; - evt.character.unicode_char = unicode; - ret = gf_term_user_event(m_term, &evt); - } -} -//----------------------------------------------------- -void CNativeWrapper::translate_key(ANDROID_KEYCODE keycode, GF_EventKey *evt) { - evt->flags = 0; - switch (keycode) { - case ANDROID_KEYCODE_BACK: - evt->key_code = GF_KEY_BACKSPACE; - evt->hw_code = 8; - break; - case ANDROID_KEYCODE_TAB: - evt->key_code = GF_KEY_TAB; - evt->hw_code = 9; - break; - case ANDROID_KEYCODE_CLEAR: - evt->key_code = GF_KEY_CLEAR; - break; - case ANDROID_KEYCODE_DPAD_CENTER: - case ANDROID_KEYCODE_ENTER: - evt->key_code = GF_KEY_ENTER; - evt->hw_code = 13; - break; - case ANDROID_KEYCODE_SHIFT_LEFT: - evt->key_code = GF_KEY_SHIFT; - break; - case ANDROID_KEYCODE_SHIFT_RIGHT: - evt->key_code = GF_KEY_SHIFT; - break; - case ANDROID_KEYCODE_ALT_LEFT: - evt->key_code = GF_KEY_ALT; - break; - case ANDROID_KEYCODE_ALT_RIGHT: - evt->key_code = GF_KEY_ALT; - break; - case ANDROID_KEYCODE_SPACE: - evt->key_code = GF_KEY_SPACE; - evt->hw_code = 32; - break; - case ANDROID_KEYCODE_HOME: - evt->key_code = GF_KEY_HOME; - break; - case ANDROID_KEYCODE_DPAD_LEFT: - evt->key_code = GF_KEY_LEFT; - break; - case ANDROID_KEYCODE_DPAD_UP: - evt->key_code = GF_KEY_UP; - break; - case ANDROID_KEYCODE_DPAD_RIGHT: - evt->key_code = GF_KEY_RIGHT; - break; - case ANDROID_KEYCODE_DPAD_DOWN: - evt->key_code = GF_KEY_DOWN; - break; - case ANDROID_KEYCODE_DEL: - evt->key_code = GF_KEY_BACKSPACE; - evt->hw_code = 8; - break; - case ANDROID_KEYCODE_0: - evt->key_code = GF_KEY_0; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_1: - evt->key_code = GF_KEY_1; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_2: - evt->key_code = GF_KEY_2; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_3: - evt->key_code = GF_KEY_3; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_4: - evt->key_code = GF_KEY_4; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_5: - evt->key_code = GF_KEY_5; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_6: - evt->key_code = GF_KEY_6; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_7: - evt->key_code = GF_KEY_7; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_8: - evt->key_code = GF_KEY_8; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - case ANDROID_KEYCODE_9: - evt->key_code = GF_KEY_9; - evt->flags = GF_KEY_EXT_NUMPAD; - break; - /*thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ - /* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ - default: - if ((keycode>=ANDROID_KEYCODE_A) && (keycode<=ANDROID_KEYCODE_Z)) { - evt->key_code = GF_KEY_A + keycode - ANDROID_KEYCODE_A; - } else { - evt->key_code = GF_KEY_UNIDENTIFIED; - } - break; - } -} -//----------------------------------------------------- - /** - * x: yaw (azimuth - rotation around the -Z axis) range: [-PI, PI] - * y: pitch (rotation around the -X axis) range: [-PI/2, PI/2] - * z: roll (rotation around the Y axis) range: [-PI, PI] - */ -void CNativeWrapper::onOrientationChange(float x, float y, float z) { - if (!m_term) - return; - GF_Event evt; - evt.type = GF_EVENT_SENSOR_ORIENTATION; - evt.sensor.x = x; - evt.sensor.y = y; - evt.sensor.z = z; - evt.sensor.w = 0; - - int ret = gf_term_user_event(m_term, &evt); -} -//----------------------------------------------------- -void CNativeWrapper::setGpacLogs(const char *tools_at_level) -{ - gf_log_set_tools_levels(tools_at_level); -} - -//--------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------- diff --git a/applications/osmo4_android_studio/app/src/main/jni/wrapper.h b/applications/osmo4_android_studio/app/src/main/jni/wrapper.h deleted file mode 100644 index fabed20..0000000 --- a/applications/osmo4_android_studio/app/src/main/jni/wrapper.h +++ /dev/null @@ -1,239 +0,0 @@ -/* - * GPAC - Multimedia Framework C SDK - * - * Authors: Jean Le Feuvre - * Copyright (c) Telecom ParisTech 2009- - * All rights reserved - * - * Created by NGO Van Luyen, Ivica ARSOV / ARTEMIS / Telecom SudParis /Institut TELECOM on Oct, 2010 - * - * This file is part of GPAC / Wrapper - * - * GPAC is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * GPAC is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef WRAPPER -#define WRAPPER - -#include - -#include -#include -#include -#include - -//#define MAX_PATH 255 - -#define KErrGeneral 1 -//#define GPAC_CFG_DIR "/data/osmo/" -#define GPAC_CFG_DIR m_cfg_dir -//#define GPAC_MODULES_DIR "/data/osmo/modules/" -#define GPAC_MODULES_DIR m_modules_dir -//#define GPAC_MODULES_PATH "/data/osmo/modules/" -#define GPAC_MODULES_PATH m_modules_dir -//#define GPAC_CACHE_DIR "/data/osmo/cache/" -#define GPAC_CACHE_DIR m_cache_dir -//#define GPAC_LOG_FILE "/data/osmo/gpac_logs.txt" -#define GPAC_LOG_FILE m_log_filename -//#define GPAC_FONT_DIR "/system/fonts/" -#define GPAC_FONT_DIR m_font_dir - -#define DEBUG_MODE 1 -//#define DEBUG_FILE "/data/osmo/osmo_debug.txt" -#define DEBUG_FILE m_debug_filename - -// keyboard code -#define ANDROID_KEYCODE int -#define ANDROID_KEYCODE_0 7 -#define ANDROID_KEYCODE_1 8 -#define ANDROID_KEYCODE_2 9 -#define ANDROID_KEYCODE_3 10 -#define ANDROID_KEYCODE_4 11 -#define ANDROID_KEYCODE_5 12 -#define ANDROID_KEYCODE_6 13 -#define ANDROID_KEYCODE_7 14 -#define ANDROID_KEYCODE_8 15 -#define ANDROID_KEYCODE_9 16 -#define ANDROID_KEYCODE_A 29 -#define ANDROID_KEYCODE_B 30 -#define ANDROID_KEYCODE_C 31 -#define ANDROID_KEYCODE_D 32 -#define ANDROID_KEYCODE_E 33 -#define ANDROID_KEYCODE_F 34 -#define ANDROID_KEYCODE_G 35 -#define ANDROID_KEYCODE_H 36 -#define ANDROID_KEYCODE_I 37 -#define ANDROID_KEYCODE_J 38 -#define ANDROID_KEYCODE_K 39 -#define ANDROID_KEYCODE_L 40 -#define ANDROID_KEYCODE_M 41 -#define ANDROID_KEYCODE_N 42 -#define ANDROID_KEYCODE_O 43 -#define ANDROID_KEYCODE_P 44 -#define ANDROID_KEYCODE_Q 45 -#define ANDROID_KEYCODE_R 46 -#define ANDROID_KEYCODE_S 47 -#define ANDROID_KEYCODE_T 48 -#define ANDROID_KEYCODE_U 49 -#define ANDROID_KEYCODE_V 50 -#define ANDROID_KEYCODE_W 51 -#define ANDROID_KEYCODE_X 52 -#define ANDROID_KEYCODE_Y 53 -#define ANDROID_KEYCODE_Z 54 -#define ANDROID_KEYCODE_ALT_LEFT 57 -#define ANDROID_KEYCODE_ALT_RIGHT 58 -#define ANDROID_KEYCODE_AT 77 -#define ANDROID_KEYCODE_BACK 4 -#define ANDROID_KEYCODE_BACKSLASH 73 -#define ANDROID_KEYCODE_CALL 5 -#define ANDROID_KEYCODE_CAMERA 27 -#define ANDROID_KEYCODE_CLEAR 28 -#define ANDROID_KEYCODE_COMMA 55 -#define ANDROID_KEYCODE_DEL 67 -#define ANDROID_KEYCODE_DPAD_CENTER 23 -#define ANDROID_KEYCODE_DPAD_DOWN 20 -#define ANDROID_KEYCODE_DPAD_LEFT 21 -#define ANDROID_KEYCODE_DPAD_RIGHT 22 -#define ANDROID_KEYCODE_DPAD_UP 19 -#define ANDROID_KEYCODE_ENDCALL 6 -#define ANDROID_KEYCODE_ENTER 66 -#define ANDROID_KEYCODE_ENVELOPE 65 -#define ANDROID_KEYCODE_EQUALS 70 -#define ANDROID_KEYCODE_EXPLORER 64 -#define ANDROID_KEYCODE_FOCUS 80 -#define ANDROID_KEYCODE_GRAVE 68 -#define ANDROID_KEYCODE_HEADSETHOOK 79 -#define ANDROID_KEYCODE_HOME 3 -#define ANDROID_KEYCODE_LEFT_BRACKET 71 -#define ANDROID_KEYCODE_MEDIA_FAST_FORWARD 90 -#define ANDROID_KEYCODE_MEDIA_NEXT 87 -#define ANDROID_KEYCODE_MEDIA_PLAY_PAUSE 85 -#define ANDROID_KEYCODE_MEDIA_PREVIOUS 88 -#define ANDROID_KEYCODE_MEDIA_REWIND 89 -#define ANDROID_KEYCODE_MEDIA_STOP 86 -#define ANDROID_KEYCODE_MENU 82 -#define ANDROID_KEYCODE_MINUS 69 -#define ANDROID_KEYCODE_MUTE 91 -#define ANDROID_KEYCODE_NUM 78 -#define ANDROID_KEYCODE_PLUS 81 -#define ANDROID_KEYCODE_POWER 26 -#define ANDROID_KEYCODE_RIGHT_BRACKET 72 -#define ANDROID_KEYCODE_SEARCH 84 -#define ANDROID_KEYCODE_SEMICOLON 74 -#define ANDROID_KEYCODE_SHIFT_LEFT 59 -#define ANDROID_KEYCODE_SHIFT_RIGHT 60 -#define ANDROID_KEYCODE_SLASH 76 -#define ANDROID_KEYCODE_SOFT_LEFT 1 -#define ANDROID_KEYCODE_SOFT_RIGHT 2 -#define ANDROID_KEYCODE_SPACE 62 -#define ANDROID_KEYCODE_STAR 17 -#define ANDROID_KEYCODE_SYM 63 -#define ANDROID_KEYCODE_TAB 61 - -#define ANDROID_KEYCODE_UNKWON -1 - -#include - -typedef struct _JavaEnvTh { - JNIEnv * env; - u32 javaThreadId; - jobject cbk_obj; - jmethodID cbk_displayMessage; - jmethodID cbk_onProgress; - jmethodID cbk_showKeyboard; - jmethodID cbk_setCaption; - jmethodID cbk_onLog; - jmethodID cbk_onFmRequest; - jmethodID cbk_setLogFile; - jmethodID cbk_sensorSwitch; -} JavaEnvTh; - - -//--------------------------------------------------------------------------------------------------- -//--------------------------------------------------------------------------------------------------- -class CNativeWrapper { - -private: - void* m_window; - void* m_session; - - GF_User *GetUser() { - return &m_user; - } - GF_Terminal *m_term; - - /* - * Callback management - */ - JavaEnvTh *mainJavaEnv; - - GF_Mutex *m_mx; - GF_User m_user; - GF_SystemRTInfo m_rti; - - int do_log; -private: - char m_cfg_dir[GF_MAX_PATH]; - char m_modules_dir[GF_MAX_PATH]; - char m_cache_dir[GF_MAX_PATH]; - char m_font_dir[GF_MAX_PATH]; - void setJavaEnv(JavaEnvTh * envToSet, JNIEnv *env, jobject callback); -private: - void SetupLogs(); - void Shutdown(); - void DisplayRTI(); -protected: - JavaEnvTh * getEnv(); - -public: - CNativeWrapper(); - ~CNativeWrapper(); - int init(JNIEnv * env, void * bitmap, jobject * callback, int width, int height, const char * cfg_dir, const char * modules_dir, const char * cache_dir, const char * font_dir, const char * gui_dir, const char * urlToLoad); - - int connect(const char *url); - void disconnect(); - void step(void * env, void * bitmap); - void resize(int w, int h); - void setAudioEnvironment(JavaVM* javaVM); - - void onMouseDown(float x, float y); - void onMouseUp(float x, float y); - void onMouseMove(float x, float y); - void onKeyPress(int keycode, int rawkeycode, int up, int flag, int unicode); - void onOrientationChange(float x, float y, float z); - void translate_key(ANDROID_KEYCODE keycode, GF_EventKey *evt); - void navigate( GF_Event* evt); - void setGpacPreference( const char * category, const char * name, const char * value); - void setGpacLogs(const char *tools_at_level); - -public: - int MessageBox(const char* msg, const char* title, GF_Err status); - int Quit(int code);WRAPPER - static void on_gpac_log(void *cbk, GF_LOG_Level ll, GF_LOG_Tool lm, const char *fmt, va_list list); - static void on_fm_request(void *cbk, u32 type, u32 param, int *value); - static Bool GPAC_EventProc(void *cbk, GF_Event *evt); - void progress_cbk(const char *title, u64 done, u64 total); - static void Osmo4_progress_cbk(const void *usr, const char *title, u64 done, u64 total); - -private: -#ifdef DEBUG_MODE - FILE *debug_f; -#endif - void debug_log(const char* msg); - -}; - -#endif diff --git a/applications/osmo4_android_studio/app/src/main/jni/wrapper_jni.cpp b/applications/osmo4_android_studio/app/src/main/jni/wrapper_jni.cpp deleted file mode 100644 index a0cdfb3..0000000 --- a/applications/osmo4_android_studio/app/src/main/jni/wrapper_jni.cpp +++ /dev/null @@ -1,200 +0,0 @@ -//#include "wrapper_jni.h" -#ifdef __cplusplus -extern "C" { -#endif - -#include "wrapper_jni.hpp" - -/* - * Class: com_gpac_Osmo4_GPACInstance - * Method: createInstance - * Signature: (Lcom/gpac/Osmo4/GpacCallback;IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jlong JNICALL Java_com_gpac_Osmo4_GPACInstance_createInstance(JNIEnv * env, jclass obj, jobject callback, jint width, jint height, jstring cfg_dir, jstring modules_dir, jstring cache_dir, jstring font_dir, jstring gui_dir, jstring url_to_open) -{ - jboolean isCopy; - const char * s1 = NULL; - if (cfg_dir) - s1 = env->GetStringUTFChars(cfg_dir, &isCopy); - const char * s2 = env->GetStringUTFChars(modules_dir, &isCopy); - const char * s3 = env->GetStringUTFChars(cache_dir, &isCopy); - const char * s4 = env->GetStringUTFChars(font_dir, &isCopy); - const char * s5 = env->GetStringUTFChars(gui_dir, &isCopy); - const char * s6 = NULL; - if (url_to_open) - s6 = env->GetStringUTFChars(url_to_open, &isCopy); - else - s6 = NULL; - CNativeWrapper * gpac_obj = new CNativeWrapper(); - if (gpac_obj) { - int w = width; - int h = height; - jniLOGI("Calling gpac_obj->init()..."); - if (gpac_obj->init(env, NULL, &callback, - w, h, - s1, s2, s3, s4, s5, s6)) { - jniLOGE("FAILED to init(), return code not 0"); - delete gpac_obj; - gpac_obj = NULL; - } - } else { - jniLOGE("FAILED to create new CNativeWrapper() : not enough memory ?"); - } - - if (s1) - env->ReleaseStringUTFChars(cfg_dir, s1); - env->ReleaseStringUTFChars(modules_dir, s2); - env->ReleaseStringUTFChars(cache_dir, s3); - env->ReleaseStringUTFChars(font_dir, s4); - env->ReleaseStringUTFChars(gui_dir, s5); - if (s6) - env->ReleaseStringUTFChars(url_to_open, s6); - __android_log_print(ANDROID_LOG_VERBOSE, jniTAG, "Returned Handle = %p", gpac_obj); - return (jlong) gpac_obj; -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacconnect(JNIEnv * env, jobject obj, jstring fileName) -{ - CAST_HANDLE(wr); - jniLOGV("connect::start"); - if (!wr) { - jniLOGV("connect::end : aborted"); - return; - } - jboolean isCopy; - const char * cFileName = env->GetStringUTFChars(fileName, &isCopy); - - wr->connect(cFileName); - - env->ReleaseStringUTFChars(fileName, cFileName); - jniLOGV("connect::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacdisconnect(JNIEnv * env, jobject obj) { - CAST_HANDLE(wr); - jniLOGV("disconnect::start"); - if (wr) - wr->disconnect(); - jniLOGV("disconnect::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacfree(JNIEnv * env, jobject obj) -{ - CAST_HANDLE(wr); - jniLOGV("free::start"); - if (wr) - delete wr; - jniLOGV("free::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacrender (JNIEnv * env, jobject obj) -{ - CAST_HANDLE(wr); - //jniLOGV("render::start"); - if (wr) - wr->step(env, NULL); - //jniLOGV("render::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacresize (JNIEnv * env, jobject obj, jint width, jint height) -{ - CAST_HANDLE(wr); - jniLOGV("resize::start"); - if (wr) - wr->resize(width, height); - jniLOGV("resize::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventmousedown(JNIEnv * env, jobject obj, jfloat x, jfloat y) { - CAST_HANDLE(wr); - //jniLOGV("mouseDown::start"); - if (wr) - wr->onMouseDown(x, y); - //jniLOGV("mouseDown::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventmouseup(JNIEnv * env, jobject obj, jfloat x, jfloat y) { - CAST_HANDLE(wr); - //jniLOGV("mouseUp::start"); - if (wr) - wr->onMouseUp(x, y); - //jniLOGV("mouseUp::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventmousemove(JNIEnv * env, jobject obj, jfloat x, jfloat y) { - CAST_HANDLE(wr); - //jniLOGV("mouseMouv::start"); - if (wr) - wr->onMouseMove(x, y); - //jniLOGV("mouseMouv::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventkeypress(JNIEnv * env, jobject obj, jint keycode, jint rawkeycode, jint up, jint flag, jint unicode) { - CAST_HANDLE(wr); - //jniLOGV("keypress::start"); - if (wr) - wr->onKeyPress(keycode, rawkeycode, up, flag, unicode); - //jniLOGV("keypress::end"); -} -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventorientationchange(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z) { - CAST_HANDLE(wr); - if (wr) - wr->onOrientationChange(x, y, z); -} - -/* -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_getdpi(JNIEnv * env, jobject obj, jint keycode,jfloat x, jfloat y){ - CAST_HANDLE(wr); - jniLOGV("get DPI::start"); - jclass cls = (*env)->GetObjectClass(env, obj); - jmethodID mid = (*env)->GetStaticMethodID(env, cls, "getdpi", "(FF)V"); - if (mid == 0) - return; - (*env)->CallStaticIntMethod(env, cls, mid, x,y); - jniLOGV("get DPI::end"); -} -*/ - -/* - * Class: com_gpac_Osmo4_GPACInstance - * Method: setGpacPreference - * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_setGpacPreference -(JNIEnv * env, jobject obj, jstring category, jstring name, jstring value) { - CAST_HANDLE(wr); - jboolean isCopy; - const char * scat = env->GetStringUTFChars(category, &isCopy); - const char * sname = env->GetStringUTFChars(name, &isCopy); - const char * svalue; - if (value) - svalue = env->GetStringUTFChars(value, &isCopy); - else - svalue = NULL; - if (wr) - wr->setGpacPreference(scat, sname, svalue); - env->ReleaseStringUTFChars(category, scat); - env->ReleaseStringUTFChars(name, sname); - if (value) - env->ReleaseStringUTFChars(value, svalue); -} -//----------------------------------- - - - -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_setGpacLogs(JNIEnv * env, jobject obj, jstring tools_at_levels) { - CAST_HANDLE(wr); - jniLOGV("setDebug::start"); - if (wr) { - jboolean isCopy; - const char * string_tools_at_levels = env->GetStringUTFChars(tools_at_levels, &isCopy); - wr->setGpacLogs(string_tools_at_levels); - env->ReleaseStringUTFChars(tools_at_levels, string_tools_at_levels); - } - jniLOGV("setDebug::end"); -} - -#ifdef __cplusplus -} -#endif diff --git a/applications/osmo4_android_studio/app/src/main/jni/wrapper_jni.hpp b/applications/osmo4_android_studio/app/src/main/jni/wrapper_jni.hpp deleted file mode 100644 index 62f827f..0000000 --- a/applications/osmo4_android_studio/app/src/main/jni/wrapper_jni.hpp +++ /dev/null @@ -1,83 +0,0 @@ -//#include "wrapper_jni.h" -#ifndef WRAPPER_JNI -#define WRAPPER_JNI - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include "wrapper.h" - -#define jniTAG "WRAPPER_JNI" - -#define jniLOGV(X) __android_log_print(ANDROID_LOG_VERBOSE, jniTAG, X) -#define jniLOGI(X) __android_log_print(ANDROID_LOG_INFO, jniTAG, X) -#define jniLOGE(X) __android_log_print(ANDROID_LOG_ERROR, jniTAG, X) - -#define CAST_HANDLE(wr) jclass c = env->GetObjectClass(obj);\ - if (!c) return;\ - jfieldID fid = env->GetFieldID(c, "handle", "J");\ - if (!fid){\ - __android_log_print(ANDROID_LOG_ERROR, jniTAG, "No Field ID, ERROR");\ - return;\ - }\ - jlong h = env->GetLongField(obj, fid);\ - CNativeWrapper* wr = (CNativeWrapper*) h; -// __android_log_print(ANDROID_LOG_VERBOSE, jniTAG, "Handle = %p", wr); - -/* - * Class: com_gpac_Osmo4_GPACInstance - * Method: createInstance - * Signature: (Lcom/gpac/Osmo4/GpacCallback;IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I - */ -JNIEXPORT jlong JNICALL Java_com_gpac_Osmo4_GPACInstance_createInstance(JNIEnv * env, jclass obj, jobject callback, jint width, jint height, jstring cfg_dir, jstring modules_dir, jstring cache_dir, jstring font_dir, jstring gui_dir, jstring url_to_open); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacconnect(JNIEnv * env, jobject obj, jstring fileName); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacdisconnect(JNIEnv * env, jobject obj); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacfree(JNIEnv * env, jobject obj); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacrender (JNIEnv * env, jobject obj); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpacresize (JNIEnv * env, jobject obj, jint width, jint height); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventmousedown(JNIEnv * env, jobject obj, jfloat x, jfloat y); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventmouseup(JNIEnv * env, jobject obj, jfloat x, jfloat y); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventmousemove(JNIEnv * env, jobject obj, jfloat x, jfloat y); -//----------------------------------- -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventkeypress(JNIEnv * env, jobject obj, jint keycode, jint rawkeycode, jint up, jint flag, jint unicode); -/* -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_getdpi(JNIEnv * env, jobject obj, jint keycode,jfloat x, jfloat y){ - CAST_HANDLE(wr); - jniLOGV("get DPI::start"); - jclass cls = (*env)->GetObjectClass(env, obj); - jmethodID mid = (*env)->GetStaticMethodID(env, cls, "getdpi", "(FF)V"); - if (mid == 0) - return; - (*env)->CallStaticIntMethod(env, cls, mid, x,y); - jniLOGV("get DPI::end"); -} -*/ - -/* - * Class: com_gpac_Osmo4_GPACInstance - * Method: setGpacPreference - * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V - */ -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_setGpacPreference -(JNIEnv * env, jobject obj, jstring category, jstring name, jstring value); - - - -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_setGpacLogs(JNIEnv * env, jobject obj, jstring tools_at_levels); -JNIEXPORT void JNICALL Java_com_gpac_Osmo4_GPACInstance_gpaceventorientationchange(JNIEnv * env, jobject obj, jfloat x, jfloat y, jfloat z); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-hdpi/icon.png b/applications/osmo4_android_studio/app/src/main/res/drawable-hdpi/icon.png deleted file mode 100644 index 3f988c1..0000000 Binary files a/applications/osmo4_android_studio/app/src/main/res/drawable-hdpi/icon.png and /dev/null differ diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-ldpi/icon.png b/applications/osmo4_android_studio/app/src/main/res/drawable-ldpi/icon.png deleted file mode 100644 index a7bbccd..0000000 Binary files a/applications/osmo4_android_studio/app/src/main/res/drawable-ldpi/icon.png and /dev/null differ diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_audio.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_audio.xml deleted file mode 100644 index a197158..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_audio.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_compressed.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_compressed.xml deleted file mode 100644 index 3284644..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_compressed.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_error.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_error.xml deleted file mode 100644 index 928cd19..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_error.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_file.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_file.xml deleted file mode 100644 index f91cde0..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_file.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_folder.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_folder.xml deleted file mode 100644 index 4e5bb1f..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_folder.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_image.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_image.xml deleted file mode 100644 index 1d26130..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_image.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_video.xml b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_video.xml deleted file mode 100644 index b9a56e3..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/ic_video.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/icon.png b/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/icon.png deleted file mode 100644 index 883b9dc..0000000 Binary files a/applications/osmo4_android_studio/app/src/main/res/drawable-mdpi/icon.png and /dev/null differ diff --git a/applications/osmo4_android_studio/app/src/main/res/drawable/ic_back.xml b/applications/osmo4_android_studio/app/src/main/res/drawable/ic_back.xml deleted file mode 100644 index beafea3..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/drawable/ic_back.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/layout/about_dialog.xml b/applications/osmo4_android_studio/app/src/main/res/layout/about_dialog.xml deleted file mode 100644 index 2518a7b..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/layout/about_dialog.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/osmo4_android_studio/app/src/main/res/layout/activity_config_file_editor.xml b/applications/osmo4_android_studio/app/src/main/res/layout/activity_config_file_editor.xml deleted file mode 100644 index 986ddad..0000000 --- a/applications/osmo4_android_studio/app/src/main/res/layout/activity_config_file_editor.xml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -