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

📄 generalinputstream.java

📁 项目描述: Fluid is a server daemon for streaming media. The latest release is built as an API for buil
💻 JAVA
字号:
package streams.general;import streams.MediaInputStream;import common.Configuration;import common.Delay;import java.io.*;/** * A general media input stream with fixed delay and  * packet size. * <P> * This class can be used to handle possibly most medias * that have a fixed frame size and bitrate. It can also * be used in conjunction with other media input streams. * * @author Lars Samuelsson */public class GeneralInputStream extends MediaInputStream {    private byte[] packet;    private Delay delay;    private int packetSize;    /**     * Creates a general input stream.     */    public GeneralInputStream() {	super();    }    /**     * Configures the general input stream.     * <P>     * The properties that are read from the configuration     * are:      * <P>     * <UL>     * <LI> <B> generalinputstream.packetsize </B><BR>     *      The size of packets to be read     * <LI> <B> generalinputstream.delay </B><BR>     *      The delay before next packet should     *      be fetched     * </UL>     *      * @param conf A configuration from which      *             parameters can be read     */    public void configure(Configuration conf) {	try {	    packetSize = Integer.parseInt(conf.getProperty("generalinputstream.packetsize"));	    long millis = Long.parseLong(conf.getProperty("generalinputstream.delay"));	    delay = new Delay(millis);	}	catch(Exception e) {	    System.err.println("The MP3InputStream could not be configured");	    e.printStackTrace();	    System.exit(1);	}    }    /**     * Returns the fixed delay for this kind of media input.     *     * @return the delay as specified in the configuration     */    public Delay getDelay() {	return delay;    }    /**     * Reads a packet from the underlying input stream and      * returns it.     *      * Uses a fixed size packet for reading and will block     * until that packet is filled with data.      *      * @return A packet read from the underlying input stream     */    public byte[] read() throws IOException {	packet = new byte[packetSize];	if(getInputStream().read(packet) == -1) 	    return null;	return packet;    }    /**     * The general input stream can handle any type of      * media.     *      * @param type A media type     * @return     true if this type is "*"     */    public boolean handlesMedia(String type) {	return type.equals("*");    }}

⌨️ 快捷键说明

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