⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registrydefaults.java

📁 FMJ(freedom media for java)是java视频开发的新选择
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package net.sf.fmj.media;import java.util.ArrayList;import java.util.List;import java.util.Vector;import javax.media.Format;import javax.media.PackageManager;import javax.media.format.AudioFormat;import javax.media.format.RGBFormat;import javax.media.format.VideoFormat;import javax.media.format.YUVFormat;import javax.media.pim.PlugInManager;import javax.media.protocol.ContentDescriptor;import javax.media.protocol.FileTypeDescriptor;import net.sf.fmj.utility.OSUtils;import net.sf.fmj.utility.PlugInUtility;/** * Defaults for the FMJ registry.  Broken out into fmj, jmf, and third-party. * fmj ones are fmj-specific. * jmf ones are to duplicate what is in jmf (useful if jmf is in the classpath). * third-party ones are those that are not included with fmj but might be in the classpath * (like fobs4jmf). * The flags give us the flexibility to make the registry the same as JMF's or JMF's + FMJ's, or just FMJ's. * Making it the same as JMF's is useful for unit testing. * @author Ken Larson * */public class RegistryDefaults{	public static final int JMF 			= 0x0001;	public static final int FMJ 			= 0x0002;	public static final int THIRD_PARTY 	= 0x0004;	public static final int ALL = JMF | FMJ | THIRD_PARTY;		public static void registerAll(int flags)	{			registerProtocolPrefixList(flags);		registerContentPrefixList(flags);		registerPlugins(flags);	}		public static void unRegisterAll(int flags)	{			unRegisterProtocolPrefixList(flags);		unRegisterContentPrefixList(flags);		unRegisterPlugins(flags);	}		public static void registerProtocolPrefixList(int flags)	{		final Vector v = PackageManager.getProtocolPrefixList();		final List<String> add = protocolPrefixList(flags);		for (String s : add)		{			if (!v.contains(s))				v.add(s);		}		PackageManager.setProtocolPrefixList(v);			}		public static void registerContentPrefixList(int flags)	{		final Vector v = PackageManager.getContentPrefixList();		final List<String> add = contentPrefixList(flags);		for (String s : add)		{			if (!v.contains(s))				v.add(s);		}				PackageManager.setContentPrefixList(v);	}		public static void unRegisterProtocolPrefixList(int flags)	{		final Vector v = PackageManager.getProtocolPrefixList();		final List<String> add = protocolPrefixList(flags);		for (String s : add)		{			if (v.contains(s))				v.remove(s);		}		PackageManager.setProtocolPrefixList(v);			}		public static void unRegisterContentPrefixList(int flags)	{		final Vector v = PackageManager.getContentPrefixList();		final List<String> add = contentPrefixList(flags);		for (String s : add)		{			if (v.contains(s))				v.remove(s);		}				PackageManager.setContentPrefixList(v);	}			public static List<String> protocolPrefixList(int flags)	{		final List<String> protocolPrefixList = new ArrayList<String>();			if ((flags & JMF) != 0)		{			protocolPrefixList.add("javax");			protocolPrefixList.add("com.sun");			protocolPrefixList.add("com.ibm");		}		if ((flags & FMJ) != 0)		{			if (OSUtils.isMacOSX())			{				// Quicktime:				protocolPrefixList.add("net.sf.fmj.qt");			}			if (OSUtils.isWindows())			{				// DirectShow:				protocolPrefixList.add("net.sf.fmj.ds");			}			if (OSUtils.isLinux())	// TODO: we could add these for other OS's, as gstreamer is cross-platform.			{				// GStreamer:				protocolPrefixList.add("net.sf.fmj.gst");			}				protocolPrefixList.add("net.sf.fmj");		}		if ((flags & THIRD_PARTY) != 0)		{			protocolPrefixList.add("com.omnividea");	// FOBS4JMF: may not be in classpath		}				return protocolPrefixList;	}		public static List<String> contentPrefixList(int flags)	{		final List<String> contentPrefixList = new ArrayList<String>();				if ((flags & JMF) != 0)		{			contentPrefixList.add("javax");			contentPrefixList.add("com.sun");			contentPrefixList.add("com.ibm");		}		if ((flags & FMJ) != 0)		{			if (OSUtils.isMacOSX())			{				// Quicktime:				contentPrefixList.add("net.sf.fmj.qt");			}			if (OSUtils.isWindows())			{				// DirectShow:				contentPrefixList.add("net.sf.fmj.ds");			}			if (OSUtils.isLinux())	// TODO: we could add these for other OS's, as gstreamer is cross-platform.			{				// DirectShow:				contentPrefixList.add("net.sf.fmj.gst");			}				contentPrefixList.add("net.sf.fmj");				}		if ((flags & THIRD_PARTY) != 0)		{			// none to add		}		return contentPrefixList;	}					public static void registerPlugins(int flags)	{		// TODO: if JMF is in the classpath ahead of FMJ, we get://		Problem adding net.sf.fmj.media.codec.video.jpeg.Packetizer to plugin table.//		 Already hash value of 8706141154469562557 in plugin table for class name of com.sun.media.codec.video.jpeg.Packetizer//		Problem adding net.sf.fmj.media.codec.video.jpeg.DePacketizer to plugin table.//		 Already hash value of 3049617401990556986 in plugin table for class name of com.sun.media.codec.video.jpeg.DePacketizer//		Problem adding net.sf.fmj.media.renderer.audio.JavaSoundRenderer to plugin table.//		 Already hash value of 1262232571547748861 in plugin table for class name of com.sun.media.renderer.audio.JavaSoundRenderer//		Problem adding net.sf.fmj.media.multiplexer.RTPSyncBufferMux to plugin table.//		 Already hash value of -2095741743343195187 in plugin table for class name of com.sun.media.multiplexer.RTPSyncBufferMux				//		 PlugInManager.DEMULTIPLEXER:		if ((flags & JMF) != 0)		{			PlugInManager.addPlugIn("com.ibm.media.parser.video.MpegParser", 				new Format[] {					new ContentDescriptor("audio.mpeg"),					new ContentDescriptor("video.mpeg"),					new ContentDescriptor("audio.mpeg"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.audio.WavParser", 				new Format[] {					new ContentDescriptor("audio.x_wav"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.audio.AuParser", 				new Format[] {					new ContentDescriptor("audio.basic"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.audio.AiffParser", 				new Format[] {					new ContentDescriptor("audio.x_aiff"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.audio.GsmParser", 				new Format[] {					new ContentDescriptor("audio.x_gsm"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);		}//		 FMJ overrides to come before SUN ones:// 		 this one needs to be after the audio parsers, otherwise it will be used instead of them in some cases.//		 TODO: why does the sun one get an NPE?//		 TODO: this causes audio not to play properly:		if ((flags & FMJ) != 0)		{			PlugInManager.addPlugIn("net.sf.fmj.media.parser.RawPushBufferParser", 						new Format[] {							new ContentDescriptor("raw"),						}, 						new Format[] {}, 						PlugInManager.DEMULTIPLEXER);		// end FMJ override.		}		if ((flags & JMF) != 0)		{			PlugInManager.addPlugIn("com.sun.media.parser.RawStreamParser", 				new Format[] {					new ContentDescriptor("raw"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.RawBufferParser", 				new Format[] {					new ContentDescriptor("raw"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.RawPullStreamParser", 				new Format[] {					new ContentDescriptor("raw"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.RawPullBufferParser", 				new Format[] {					new ContentDescriptor("raw"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.video.QuicktimeParser", 				new Format[] {					new ContentDescriptor("video.quicktime"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);			PlugInManager.addPlugIn("com.sun.media.parser.video.AviParser", 				new Format[] {					new ContentDescriptor("video.x_msvideo"),				}, 				new Format[] {}, 				PlugInManager.DEMULTIPLEXER);		//		 PlugInManager.CODEC:			PlugInManager.addPlugIn("com.sun.media.codec.audio.mpa.JavaDecoder", 				new Format[] {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -