1 /* 2 * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.media.jfxmediaimpl.platform.ios; 27 28 import com.sun.media.jfxmedia.Media; 29 import com.sun.media.jfxmedia.MediaPlayer; 30 import com.sun.media.jfxmedia.locator.Locator; 31 import com.sun.media.jfxmedia.logging.Logger; 32 import com.sun.media.jfxmediaimpl.HostUtils; 33 import com.sun.media.jfxmediaimpl.platform.Platform; 34 import java.util.Arrays; 35 36 /** 37 * iOS Platform implementation. 38 */ 39 public final class IOSPlatform extends Platform { 40 41 /** 42 * The MIME types of all supported media. 43 */ 44 private static final String[] CONTENT_TYPES = { 45 "video/mp4", 46 "audio/x-m4a", 47 "video/x-m4v", 48 "application/vnd.apple.mpegurl", 49 "audio/mpegurl", 50 "audio/mpeg", 51 "audio/mp3", 52 "audio/x-wav", 53 "video/quicktime", 54 "video/x-quicktime", 55 "audio/x-aiff" 56 }; 57 58 /** 59 * All supported protocols. 60 */ 61 private static final String[] PROTOCOLS = { 62 "http", 63 "https", 64 "ipod-library" 65 }; 66 67 private static final class IOSPlatformInitializer { 68 private static final IOSPlatform globalInstance = new IOSPlatform(); 69 } 70 71 public static Platform getPlatformInstance() { 72 return IOSPlatformInitializer.globalInstance; 73 } 74 75 private IOSPlatform() { 76 } 77 78 /** 79 * @return false if the platform cannot be loaded 80 */ 81 @Override 82 public boolean loadPlatform() { 83 if (!HostUtils.isIOS()) { 84 return false; 85 } 86 87 try { 88 iosPlatformInit(); 89 } catch (UnsatisfiedLinkError ule) { 90 if (Logger.canLog(Logger.DEBUG)) { 91 Logger.logMsg(Logger.DEBUG, "Unable to load iOS platform."); 92 } 93 //MediaUtils.nativeError(IOSPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL); 94 return false; 95 } 96 return true; 97 } 98 99 @Override 100 public String[] getSupportedContentTypes() { 101 return Arrays.copyOf(CONTENT_TYPES, CONTENT_TYPES.length); 102 } 103 104 @Override 105 public String[] getSupportedProtocols() { 106 return Arrays.copyOf(PROTOCOLS, PROTOCOLS.length); 107 } 108 109 @Override 110 public Media createMedia(Locator source) { 111 return new IOSMedia(source); 112 } 113 114 @Override 115 public MediaPlayer createMediaPlayer(Locator source) { 116 try { 117 return new IOSMediaPlayer(source); 118 } catch (Exception e) { 119 if (Logger.canLog(Logger.DEBUG)) { 120 Logger.logMsg(Logger.DEBUG, "IOSPlatform caught exception while creating media player: "+e); 121 } 122 } 123 return null; 124 } 125 126 private static native void iosPlatformInit(); 127 }