From 1e16a4cd123aafe41d51f01b41fad5a77c4ffbe3 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Mon, 16 Apr 2012 21:30:52 +0200
Subject: Adding initial Libav/FFMpeg GLMediaPlayer implementation

The Java classes already slipped through in
commit 10935e1ec0d8ed677bc3fddfaa8cd73898a3bcbf - oops.

Since we cannot provide a Libav binary (even though Google does in Android and Chrome)
due to legal uncertainities .. we dynamically link to an existing Libav / FFmpeg library
in a 'relaxed' manner. Ie. we allow certain recent functions to be absent to be able
to run on a wider range of Libav versions.

Currently tested on Debian Linux and Windows7 64bit/32bit
Binaries for Win/OSX:
  - Windows http://ffmpeg.zeranoe.com/builds/
  - OSX http://www.ffmpegx.com/

Features:
  - Dynamic relaxed linking to Libav (see above)
  - YUV420P texture lookup function shader stub (conversion to RGB)
  - 1-copy only (decoder buffer to texture)
  - simple
  - uses libavformat's network streaming
  - fixes some odd PTS values

TODO:
  - Audio output (Should use OpenAL, duh)
  - Seek works poorly
  - Offthread multi-texture fetching for smoother animation
  - Maybe more pixelformat conversions
---
 .../com/jogamp/opengl/util/av/GLMediaPlayerFactory.java        | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'src/jogl/classes/com/jogamp/opengl/util/av')

diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java
index df12fd12c..6fcf20ed2 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java
@@ -35,13 +35,21 @@ import com.jogamp.common.util.ReflectionUtil;
 
 public class GLMediaPlayerFactory {
     private static final String AndroidGLMediaPlayerAPI14ClazzName = "jogamp.opengl.android.av.AndroidGLMediaPlayerAPI14";
+    private static final String FFMPEGMediaPlayerClazzName = "jogamp.opengl.util.av.impl.FFMPEGMediaPlayer";
+    private static final String isAvailableMethodName = "isAvailable";
     
     public static GLMediaPlayer create() {
+        final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader();
         if(Platform.OS_TYPE.equals(Platform.OSType.ANDROID)) {
             if(AndroidVersion.SDK_INT >= 14) {
-                return (GLMediaPlayer) ReflectionUtil.createInstance(AndroidGLMediaPlayerAPI14ClazzName, GLMediaPlayerFactory.class.getClassLoader());
+                if(((Boolean)ReflectionUtil.callStaticMethod(AndroidGLMediaPlayerAPI14ClazzName, isAvailableMethodName, null, null, cl)).booleanValue()) {
+                    return (GLMediaPlayer) ReflectionUtil.createInstance(AndroidGLMediaPlayerAPI14ClazzName, cl);
+                }
             }
         }
+        if(((Boolean)ReflectionUtil.callStaticMethod(FFMPEGMediaPlayerClazzName, isAvailableMethodName, null, null, cl)).booleanValue()) {
+            return (GLMediaPlayer) ReflectionUtil.createInstance(FFMPEGMediaPlayerClazzName, cl);
+        }
         return new NullGLMediaPlayer();
     }
 }
-- 
cgit v1.2.3