# HG changeset patch # User ddehaven # Date 1406676660 25200 # Tue Jul 29 16:31:00 2014 -0700 # Node ID 4c583334e5d910f25e7c3e2d5f9ce062e8886882 # Parent df28c1bdf2e1157a45dcd414767050f144b159c8 RT-38074: [macosx] Separate QTKit platform code from core media code so it can be removed for MAS Reviewed-by: diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -2887,10 +2887,14 @@ if (IS_COMPILE_MEDIA) { [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name -> from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library(name)}") } - - if (t.name == "linux") { + + if (t.name == "mac") { + // OSX media natives + [ "jfxmedia_qtkit", "glib-lite" ].each { name -> + from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library(name)}") } + } else if (t.name == "linux") { from("modules/media/build/native/${t.name}/${mediaBuildType}") { include "libavplugin*.so" } - } else from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library("glib-lite")}") + } else from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library("glib-lite")}") } else { [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name -> from ("$LIBRARY_STUB/${library(name)}") } diff --git a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaManager.java b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaManager.java --- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaManager.java +++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaManager.java @@ -33,6 +33,7 @@ import com.sun.media.jfxmediaimpl.platform.PlatformManager; import java.lang.ref.WeakReference; import java.security.AccessController; +import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.List; @@ -45,11 +46,6 @@ */ public class NativeMediaManager { /** - * The NativeMediaManager singleton. - */ - // If we create NativeMediaManager here we will not be able to catch exception from constructor. - private static NativeMediaManager theInstance = null; - /** * Whether the native layer has been initialized. */ private static boolean isNativeLayerInitialized = false; @@ -57,19 +53,28 @@ * The {@link MediaErrorListener}s. */ // FIXME: Change to WeakHashMap as it's more efficient - private List> errorListeners = - new ArrayList>(); - private static NativeMediaPlayerDisposer playerDisposer = new NativeMediaPlayerDisposer(); + private final List> errorListeners = + new ArrayList(); + private final static NativeMediaPlayerDisposer playerDisposer = + new NativeMediaPlayerDisposer(); /** * List of all un-disposed players. */ - private static Map allMediaPlayers = - new WeakHashMap(); + private final static Map allMediaPlayers = + new WeakHashMap(); // cached content types, so we don't have to poll and sort each time, this list // should never change once we're initialized private final List supportedContentTypes = - new ArrayList(); + new ArrayList(); + + /** + * The NativeMediaManager singleton. + */ + private static class NativeMediaManagerInitializer { + private static final NativeMediaManager globalInstance + = new NativeMediaManager(); + } /** * Get the default @@ -78,11 +83,8 @@ * @return the singleton * NativeMediaManager instance. */ - public static synchronized NativeMediaManager getDefaultInstance() { - if (theInstance == null) { - theInstance = new NativeMediaManager(); - } - return theInstance; + public static NativeMediaManager getDefaultInstance() { + return NativeMediaManagerInitializer.globalInstance; } //************************************************************************** @@ -91,43 +93,43 @@ /** * Create a NativeMediaManager. */ - protected NativeMediaManager() {} + protected NativeMediaManager() { + /* + * Load native libraries. This must be done early as platforms may need + * to attempt loading their own native libs that are dependent on these + * This is a slight performance hit, but necessary otherwise we could + * erroneously report content types for platforms that cannot be loaded + */ + try { + AccessController.doPrivileged((PrivilegedExceptionAction) () -> { + if (HostUtils.isWindows() || HostUtils.isMacOSX()) { + NativeLibLoader.loadLibrary("glib-lite"); + } + + if (!HostUtils.isLinux() && !HostUtils.isIOS()) { + NativeLibLoader.loadLibrary("gstreamer-lite"); + } + + NativeLibLoader.loadLibrary("jfxmedia"); + return null; + }); + } catch (PrivilegedActionException pae) { + MediaUtils.error(null, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL.code(), + "Unable to load one or more dependent libraries.", pae); + } + + // Get the Logger native side rolling before we load platforms + if (!Logger.initNative()) { + MediaUtils.error(null, MediaError.ERROR_MANAGER_LOGGER_INIT.code(), + "Unable to init logger", null); + } + } /** * Initialize the native layer if it has not been so already. */ synchronized static void initNativeLayer() { if (!isNativeLayerInitialized) { - // preload platforms - PlatformManager.getManager().preloadPlatforms(); - - // Load native libraries. - try { - AccessController.doPrivileged((PrivilegedExceptionAction) () -> { - if (HostUtils.isWindows() || HostUtils.isMacOSX()) { - NativeLibLoader.loadLibrary("glib-lite"); - } - - if (!HostUtils.isLinux() && !HostUtils.isIOS()) { - NativeLibLoader.loadLibrary("gstreamer-lite"); - } - - NativeLibLoader.loadLibrary("jfxmedia"); - return null; - }); - } catch (Exception e) { - MediaUtils.error(null, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL.code(), - "Unable to load one or more dependent libraries.", e); - return; // abort - } - - // Get the Logger native side rolling before we load platforms - if (!Logger.initNative()) { - MediaUtils.error(null, MediaError.ERROR_MANAGER_LOGGER_INIT.code(), - "Unable to init logger", null); - return; // abort - } - // load platforms PlatformManager.getManager().loadPlatforms(); diff --git a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java --- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java +++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,15 +41,6 @@ throw new UnsupportedOperationException("Invalid platform class."); } - /* - * Loading stages - * preloadPlatform gives the platform a chance to load or check dependencies - * before the main jfxmedia library is loaded. Then loadPlatform is called - * after jfxmedia library is loaded in case the platform has further - * dependencies. - */ - public void preloadPlatform() {} - /** * @return false if the platform cannot be loaded */ diff --git a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java --- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java +++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java @@ -81,6 +81,14 @@ Platform platty; + /* + * We don't want to fully initialize the platforms here for performance + * reasons but some platforms may be dependent on native resources that + * need to be loaded, those platforms need to be given a chance to load + * those resources (without initializing) and determine if the natives + * are available. + */ + // Now "universal" platform(s) if (isPlatformEnabled("JavaPlatform")) { platty = JavaPlatform.getPlatformInstance(); @@ -121,12 +129,6 @@ } } - public synchronized void preloadPlatforms() { - for (Platform platty : platforms) { - platty.preloadPlatform(); - } - } - public synchronized void loadPlatforms() { // Use an iterator so we can remove on failure Iterator iter = platforms.iterator(); @@ -147,6 +149,9 @@ if (!platforms.isEmpty()) { for (Platform platty : platforms) { + if (Logger.canLog(Logger.DEBUG)) { + Logger.logMsg(Logger.DEBUG, "Getting content types from platform: "+platty); + } String[] npt = platty.getSupportedContentTypes(); if (npt != null) { for (String type : npt) { diff --git a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java --- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java +++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java @@ -65,9 +65,6 @@ private IOSPlatform() { } - @Override - public void preloadPlatform() {} - /** * @return false if the platform cannot be loaded */ diff --git a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java --- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java +++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,12 +25,15 @@ package com.sun.media.jfxmediaimpl.platform.osx; +import com.sun.glass.utils.NativeLibLoader; import com.sun.media.jfxmedia.Media; import com.sun.media.jfxmedia.MediaPlayer; import com.sun.media.jfxmedia.locator.Locator; import com.sun.media.jfxmedia.logging.Logger; import com.sun.media.jfxmediaimpl.HostUtils; import com.sun.media.jfxmediaimpl.platform.Platform; +import java.security.AccessController; +import java.security.PrivilegedAction; /** * Mac OS X Platform implementation. @@ -48,7 +51,30 @@ }; private static final class OSXPlatformInitializer { - private static final OSXPlatform globalInstance = new OSXPlatform(); + private static final OSXPlatform globalInstance; + static { + // Platform is only available if we can load it's native lib + // Do this early so we can report the correct content types + boolean isLoaded = false; + try { + isLoaded = AccessController.doPrivileged((PrivilegedAction) () -> { + try { + NativeLibLoader.loadLibrary("jfxmedia_qtkit"); + } catch (UnsatisfiedLinkError ule) { + // non-fatal condition, keep quiet about it + return Boolean.FALSE; + } + return Boolean.TRUE; + }); + } catch (Exception e) { + // Ignore + } + if (isLoaded) { + globalInstance = new OSXPlatform(); + } else { + globalInstance = null; + } + } } public static Platform getPlatformInstance() { @@ -58,9 +84,6 @@ private OSXPlatform() { } - @Override - public void preloadPlatform() {} - /** * @return false if the platform cannot be loaded */ @@ -70,13 +93,14 @@ return false; } + // ULE should not happen here, but just in case try { osxPlatformInit(); } catch (UnsatisfiedLinkError ule) { if (Logger.canLog(Logger.DEBUG)) { Logger.logMsg(Logger.DEBUG, "Unable to load OSX platform."); } -// MediaUtils.nativeError(OSXPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL); +// MediaUtils.nativeError(OSXPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL); return false; } return true; diff --git a/modules/media/src/main/native/jfxmedia/Utils/JObjectPeers.h b/modules/media/src/main/native/jfxmedia/Utils/JObjectPeers.h --- a/modules/media/src/main/native/jfxmedia/Utils/JObjectPeers.h +++ b/modules/media/src/main/native/jfxmedia/Utils/JObjectPeers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ */ #import -#import +#import // A place to store native peers to Java objects @interface JObjectPeers : NSObject diff --git a/modules/media/src/main/native/jfxmedia/Utils/JavaUtils.h b/modules/media/src/main/native/jfxmedia/Utils/JavaUtils.h --- a/modules/media/src/main/native/jfxmedia/Utils/JavaUtils.h +++ b/modules/media/src/main/native/jfxmedia/Utils/JavaUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ */ #import -#import +#import #ifdef __cplusplus extern "C" { diff --git a/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.h b/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.h --- a/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.h +++ b/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,9 @@ */ #import -#import #import #import "OSXPlayerProtocol.h" -#import +#import #import "JavaPlayerEventDispatcher.h" @@ -42,6 +41,9 @@ id player; // actual player implementation } +// Called from OSXPlatform.osxPlatformInit() (java) ++ (void) initPlayerPlatform; + @property (readonly) id player; @end diff --git a/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.mm b/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.mm --- a/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.mm +++ b/modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,20 +24,20 @@ */ #import "OSXMediaPlayer.h" +#import "OSXPlayerProtocol.h" #import "com_sun_media_jfxmediaimpl_platform_osx_OSXMediaPlayer.h" #import #import #import #import -#import "QTKMediaPlayer.h" - #import #define USE_WEAK_REFS 0 // Don't access directly, use the OSXMediaPlayer static methods to ensure thread safe access static JObjectPeers *gMediaPlayerPeers = nil; +static Class gMediaPlayerClass = nil; @implementation OSXMediaPlayer @@ -61,6 +61,19 @@ [gMediaPlayerPeers removePeer:player]; } ++ (void) initPlayerPlatform +{ + // Determine if we can use QTKMediaPlayer or not, without directly linking and pulling + // in unwanted dependencies + Class klass = objc_getClass("QTKMediaPlayer"); + if (klass) { + // And make sure it conforms to the OSXPlayerProtocol + if ([klass conformsToProtocol:@protocol(OSXPlayerProtocol)]) { + gMediaPlayerClass = klass; + } + } // else we can't log yet, so fail silently +} + - (id) init { if ((self = [super init]) != nil) { @@ -70,6 +83,11 @@ - (id) initWithURL:(NSURL *)source javaPlayer:(jobject)jp andEnv:(JNIEnv*)env eventHandler:(CJavaPlayerEventDispatcher*)hdlr { + if (!gMediaPlayerClass) { + // No player class available, abort + return nil; + } + if ((self = [super init]) != nil) { movieURL = [source retain]; @@ -84,12 +102,19 @@ eventHandler = hdlr; - // create the movie object - player = [[QTKMediaPlayer alloc] initWithURL:movieURL eventHandler:eventHandler]; + // create the player object + player = [[gMediaPlayerClass alloc] initWithURL:movieURL eventHandler:eventHandler]; } return self; } +- (id) initWithURL:(NSURL *)source eventHandler:(CJavaPlayerEventDispatcher*)hdlr +{ + // stub initWithURL message to satisfy the protocol requirements, this should + // never be called + return nil; +} + - (void) dealloc { [self dispose]; // just in case diff --git a/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlatform.mm b/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlatform.mm --- a/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlatform.mm +++ b/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlatform.mm @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ */ #import "com_sun_media_jfxmediaimpl_platform_osx_OSXPlatform.h" +#import "OSXMediaPlayer.h" /* * Class: com_sun_media_jfxmediaimpl_platform_osx_OSXPlatform @@ -33,6 +34,6 @@ JNIEXPORT void JNICALL Java_com_sun_media_jfxmediaimpl_platform_osx_OSXPlatform_osxPlatformInit (JNIEnv *env, jclass klass) { - // http://javafx-jira.kenai.com/browse/RT-27041 - // TODO: choose between QTKit and AVFoundation (if 10.8+) + // Tell OSXMediaPlayer to initialize itself + [OSXMediaPlayer initPlayerPlatform]; } diff --git a/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlayerProtocol.h b/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlayerProtocol.h --- a/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlayerProtocol.h +++ b/modules/media/src/main/native/jfxmedia/platform/osx/OSXPlayerProtocol.h @@ -50,6 +50,8 @@ @property (nonatomic,assign) float volume; @property (nonatomic,assign) float balance; +- (id) initWithURL:(NSURL *)source eventHandler:(CJavaPlayerEventDispatcher*)hdlr; + - (void) play; - (void) pause; - (void) stop; diff --git a/modules/media/src/main/native/jfxmedia/projects/mac/Makefile b/modules/media/src/main/native/jfxmedia/projects/mac/Makefile --- a/modules/media/src/main/native/jfxmedia/projects/mac/Makefile +++ b/modules/media/src/main/native/jfxmedia/projects/mac/Makefile @@ -1,10 +1,10 @@ # -# MacOs jfxmedia makefile +# Mac OS X jfxmedia makefile # +# OUTPUT_DIR, BUILD_TYPE and BASE_NAME are passed on the command line or from the +# parent make process BUILD_DIR = $(OUTPUT_DIR)/$(BUILD_TYPE) -TARGET_DIRS = $(BUILD_DIR) - SRCBASE_DIR = ../.. OBJBASE_DIR = $(BUILD_DIR)/obj/jfxmedia @@ -12,31 +12,25 @@ GSTREAMER_LITE_DIR = $(BASE_DIR)/gstreamer/gstreamer-lite GLIB_LITE_DIR = $(BASE_DIR)/gstreamer/3rd_party/glib/glib-2.28.8 -DIRLIST = MediaManagement \ - Locator \ - PipelineManagement \ - jni \ - Utils \ - Utils/posix \ - platform/gstreamer \ - platform/osx \ - Projects/utils - TARGET_NAME = lib$(BASE_NAME).dylib TARGET = $(BUILD_DIR)/$(TARGET_NAME) +# separate library for QTKit based platform +QTK_NAME = lib$(BASE_NAME)_qtkit.dylib +QTK_LIB = $(BUILD_DIR)/$(QTK_NAME) + +# Set up base search path for source and headers +VPATH = $(SRCBASE_DIR):$(GENERATED_HEADERS_DIR):$(JAVA_HOME)/include:$(JAVA_HOME)/include/darwin + +# ------------------------------------------------------------------ +# Base compile/link flags + CFLAGS = -arch x86_64 \ - -fPIC \ - -Werror=implicit-function-declaration \ + -pipe \ + -fPIC \ + -Werror=implicit-function-declaration \ -DTARGET_OS_MAC=1 \ -D_GNU_SOURCE \ - -DGST_REMOVE_DEPRECATED \ - -DGST_DISABLE_GST_DEBUG \ - -DGST_DISABLE_LOADSAVE \ - -DGST_DISABLE_XML \ - -DHAVE_CONFIG_H \ - -DJFXMEDIA_JNI_EXPORTS \ - -DGSTREAMER_LITE \ -msse2 \ -mmacosx-version-min=10.7 @@ -46,28 +40,51 @@ CFLAGS += -O0 -g -Wall endif -BASE_INCLUDES = -I$(JAVA_HOME)/include \ - -I$(JAVA_HOME)/include/darwin \ - -I$(SRCBASE_DIR) \ - -I$(SRCBASE_DIR)/jni \ - -I$(GENERATED_HEADERS_DIR) -INCLUDES = $(BASE_INCLUDES) \ +INCLUDES = -I$(JAVA_HOME)/include \ + -I$(JAVA_HOME)/include/darwin \ + -I$(SRCBASE_DIR) \ + -I$(SRCBASE_DIR)/jni \ + -I$(GENERATED_HEADERS_DIR) + + +LDFLAGS = -mmacosx-version-min=10.7 \ + -arch x86_64 \ + -L$(BUILD_DIR) \ + -lobjc \ + -framework Cocoa \ + -framework CoreVideo + +# ------------------------------------------------------------------ +# jfxmedia compile/link flags + +JFXMEDIA_CFLAGS = $(CFLAGS) \ + -DGST_REMOVE_DEPRECATED \ + -DGST_DISABLE_GST_DEBUG \ + -DGST_DISABLE_LOADSAVE \ + -DGST_DISABLE_XML \ + -DGSTREAMER_LITE \ + -DJFXMEDIA_JNI_EXPORTS \ + -DHAVE_CONFIG_H \ + +JFXMEDIA_INCLUDES = $(INCLUDES) \ -I$(GLIB_LITE_DIR)/ \ -I$(GLIB_LITE_DIR)/glib \ -I$(GLIB_LITE_DIR)/gmodule \ -I$(GLIB_LITE_DIR)/build/osx \ - -I$(GSTREAMER_LITE_DIR)/gstreamer \ + -I$(GSTREAMER_LITE_DIR)/gstreamer \ -I$(GSTREAMER_LITE_DIR)/gst-plugins-base/gst-libs \ - -I$(GSTREAMER_LITE_DIR)/gstreamer/libs + -I$(GSTREAMER_LITE_DIR)/gstreamer/libs -LDFLAGS = -mmacosx-version-min=10.7 -arch x86_64 \ - -L$(BUILD_DIR) -Wl,-install_name,@rpath/$(TARGET_NAME) \ - -lgstreamer-lite -lglib-lite -lobjc \ - -framework CoreVideo -framework CoreAudio -framework QTKit \ - -framework Cocoa -framework Carbon -framework CoreServices -framework JavaVM +JFXMEDIA_LDFLAGS = $(LDFLAGS) \ + -Wl,-install_name,@rpath/$(TARGET_NAME) \ + -lgstreamer-lite \ + -lglib-lite -CPP_SOURCES = \ +# ------------------------------------------------------------------ +# jfxmedia sources/objects + +JFXMEDIA_SOURCES = \ MediaManagement/Media.cpp \ MediaManagement/MediaManager.cpp \ Locator/Locator.cpp \ @@ -103,50 +120,71 @@ platform/gstreamer/GstEqualizerBand.cpp \ platform/gstreamer/GstMedia.cpp \ platform/gstreamer/GstMediaPlayer.cpp \ - -C_SOURCES = Utils/ColorConverter.c - -OBJCMM_SOURCES = \ + Utils/ColorConverter.c \ + Utils/JObjectPeers.m \ + Utils/JavaUtils.m \ + Utils/MTObjectProxy.m \ platform/osx/OSXPlatform.mm \ platform/osx/OSXMediaPlayer.mm \ - platform/osx/QTKMediaPlayer.mm \ platform/osx/CVVideoFrame.mm -OBJCM_SOURCES = \ - Utils/JObjectPeers.m \ - Utils/JavaUtils.m \ - Utils/MTObjectProxy.m +JFXMEDIA_OBJECTS = \ + $(patsubst %.c, $(OBJBASE_DIR)/%.o, $(filter %.c, $(JFXMEDIA_SOURCES))) \ + $(patsubst %.m, $(OBJBASE_DIR)/%.o, $(filter %.m, $(JFXMEDIA_SOURCES))) \ + $(patsubst %.cpp, $(OBJBASE_DIR)/%.o, $(filter %.cpp, $(JFXMEDIA_SOURCES))) \ + $(patsubst %.mm, $(OBJBASE_DIR)/%.o, $(filter %.mm, $(JFXMEDIA_SOURCES))) -OBJ_DIRS = $(addprefix $(OBJBASE_DIR)/,$(DIRLIST)) -OBJECTS = $(patsubst %.cpp,$(OBJBASE_DIR)/%.o,$(CPP_SOURCES)) \ - $(patsubst %.c,$(OBJBASE_DIR)/%.o,$(C_SOURCES)) \ - $(patsubst %.mm,$(OBJBASE_DIR)/%.o,$(OBJCMM_SOURCES)) \ - $(patsubst %.m,$(OBJBASE_DIR)/%.o,$(OBJCM_SOURCES)) +# ------------------------------------------------------------------ +# Rules .PHONY: default +default: $(TARGET) $(QTK_LIB) -default: $(TARGET) -$(OBJBASE_DIR)/%.o: $(SRCBASE_DIR)/%.cpp - $(CC) $(CFLAGS) $(INCLUDES) -x c++ -c $< -o $@ +# ------------------------------------------------------------------ +# jfxmedia rules -$(OBJBASE_DIR)/%.o: $(SRCBASE_DIR)/%.c - $(CC) $(CFLAGS) $(INCLUDES) -x c -c $< -o $@ +# auto-dependencies +-include $(JFXMEDIA_OBJECTS:.o=.d) -$(OBJBASE_DIR)/%.o: $(SRCBASE_DIR)/%.mm - $(CC) $(CFLAGS) $(INCLUDES) -x objective-c++ -c $< -o $@ +$(OBJBASE_DIR)/%.o: %.cpp + @mkdir -p $(dir $@) + $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x c++ -c $< -o $@ -$(OBJBASE_DIR)/%.o: $(SRCBASE_DIR)/%.m - $(CC) $(CFLAGS) $(INCLUDES) -x objective-c -c $< -o $@ +$(OBJBASE_DIR)/%.o: %.c + @mkdir -p $(dir $@) + $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x c -c $< -o $@ -$(OBJECTS): | $(OBJ_DIRS) $(TARGET_DIRS) +$(OBJBASE_DIR)/%.o: %.mm + @mkdir -p $(dir $@) + $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x objective-c++ -c $< -o $@ -$(OBJ_DIRS): - mkdir -p $(OBJ_DIRS) +$(OBJBASE_DIR)/%.o: %.m + @mkdir -p $(dir $@) + $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x objective-c -c $< -o $@ -$(TARGET_DIRS): - mkdir -p $(TARGET_DIRS) +$(TARGET): $(JFXMEDIA_OBJECTS) + @mkdir -p $(dir $@) + $(LINK) -dynamiclib $(JFXMEDIA_LDFLAGS) $(JFXMEDIA_OBJECTS) -o $@ -$(TARGET): $(OBJECTS) - $(LINK) -dynamiclib $(OBJECTS) $(LDFLAGS) -o $@ +# ------------------------------------------------------------------ +# QTKit platform lib rules + +QTK_OBJBASE = $(OBJBASE_DIR)/qtk +QTK_LDFLAGS = $(LDFLAGS) \ + -Wl,-install_name,@rpath/$(QTK_NAME) \ + -framework QTKit + +QTK_SOURCES = platform/osx/QTKMediaPlayer.mm +QTK_OBJECTS = $(patsubst %.mm,$(QTK_OBJBASE)/%.o,$(QTK_SOURCES)) + +-include $(QTK_OBJECTS:.o=.d) + +$(QTK_OBJBASE)/%.o: %.mm + @mkdir -p $(dir $@) + $(CC) $(CFLAGS) $(INCLUDES) -MD -MF $(QTK_OBJBASE)/$*.d -x objective-c++ -c $< -o $@ + +$(QTK_LIB): $(TARGET) $(QTK_OBJECTS) + @mkdir -p $(dir $@) + $(LINK) $(QTK_LDFLAGS) -dynamiclib $(QTK_OBJECTS) -l$(BASE_NAME) -o $@