/* * PS3 Media Server, for streaming any medias to your PS3. * Copyright (C) 2008 A.Brochard * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; version 2 * of the License only. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package net.pms.formats; import java.util.ArrayList; import java.util.StringTokenizer; import net.pms.PMS; import net.pms.configuration.RendererConfiguration; import net.pms.dlna.DLNAMediaInfo; import net.pms.dlna.InputFile; import net.pms.encoders.Player; import net.pms.network.HTTPResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Abstract class to store known information about a given format. */ public abstract class Format implements Cloneable { private static final Logger logger = LoggerFactory.getLogger(Format.class); public int getType() { return type; } public static final int ISO = 32; public static final int PLAYLIST = 16; public static final int UNKNOWN = 8; public static final int VIDEO = 4; public static final int AUDIO = 1; public static final int IMAGE = 2; /** * The identifier (filename extension or protocol) that was matched for a * particular filename or URL. Requires {@link #match(String)} to be called * first. */ protected String matchedId; /** * Returns the identifier (filename extension or protocol) that was matched * for a particular filename or URL. Requires {@link #match(String)} to be * called first. * * @return The matched identifier. */ public String getMatchedId() { return matchedId; } protected int type = UNKNOWN; protected Format secondaryFormat; public Format getSecondaryFormat() { return secondaryFormat; } public void setSecondaryFormat(Format secondaryFormat) { this.secondaryFormat = secondaryFormat; } public void setType(int type) { if (isUnknown()) { this.type = type; } } /** * Returns the identifiers that can be used to identify a particular * format. Valid identifiers are filename extensions or URL protocols, * e.g. "mp3" or "http". Identifiers are expected to be in lower case. * * @return An array of identifiers. */ public abstract String[] getId(); /** * @deprecated Use {@link #isCompatible(DLNAMediaInfo, RendererConfiguration)} instead. *
* Returns whether or not a format can be handled by the PS3 natively.
* This means the format can be streamed to PS3 instead of having to be
* transcoded.
*
* @return True if the format can be handled by PS3, false otherwise.
*/
@Deprecated
public abstract boolean ps3compatible();
/**
* Returns whether or not a format can be handled by the renderer natively.
* This means the format can be streamed instead of having to be transcoded.
*
* @return True if the format can be handled by the renderer, false otherwise.
*
* @since 1.50.1
*/
public boolean isCompatible(DLNAMediaInfo media, RendererConfiguration renderer) {
if (renderer != null) {
// Let the renderer configuration decide on native compatibility
return renderer.isCompatible(media, this);
} else {
// Is this format among the ones configured in PMS to be streamed?
return skip(PMS.getConfiguration().getNoTranscode(), null);
}
}
public abstract boolean transcodable();
public abstract ArrayList