javax.media.Manager Maven / Gradle / Ivy
/**
. *This is not an official specification document, and usage is restricted.
NOTICE
(c) 2005-2008 Sun Microsystems, Inc. All Rights Reserved.Neither this file nor any files generated from it describe a complete specification, and they may only be used as described below.
Sun Microsystems Inc. owns the copyright in this file and it is provided to you for informative use only. For example, this file and any files generated from it may be used to generate other documentation, such as a unified set of documents of API signatures for a platform that includes technologies expressed as Java APIs. This file may also be used to produce "compilation stubs," which allow applications to be compiled and validated for such platforms. By contrast, no permission is given for you to incorporate this file, in whole or in part, in an implementation of a Java specification.
Any work generated from this file, such as unified javadocs or compiled stub files, must be accompanied by this notice in its entirety.
This work corresponds to the API signatures of JSR 927: Java TV API 1.1.1. In the event of a discrepency between this work and the JSR 927 specification, which is available at http://www.jcp.org/en/jsr/detail?id=927, the latter takes precedence. */ package javax.media; import java.io.IOException; import java.net.URL; import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Vector; import javax.media.protocol.DataSource; import javax.media.protocol.URLDataSource; /** *
Manager
is the access point for obtaining * system dependent resources such asPlayers
, *DataSources
, and the systemTimeBase
. ** * A
Player
is an object used to * control and render multimedia data that * is specific to the content type of the data. * ADataSource
is an object used to * deliver time-based multimedia data that is specific * to a delivery protocol. * ADataSource
provides * aPlayer
with media data; * aPlayer
must have aDataSource
. *Manager
provides access to a protocol and media independent * mechanism for constructingPlayers
and *DataSources
. * *Creating Players and DataSources
* *Manager
will createPlayers
from a *URL
, aMediaLocator
or aDataSource
. * Creating aPlayer
requires the following: **
* * It is possible to create multiple Players for the same scarce resource * (such as a hardware video decoder). * However, doing so may affect the state of other Players which depend on * that resource. * *- Obtain the connected
DataSource
for the specified * protocol *- Obtain the
Player
for the content-type * specified by theDataSource
*- Attach the
DataSource
to thePlayer
* using thesetSource
method. *Finding DataSources by Protocol
* * AMediaLocator
defines a protocol for obtaining * content. *DataSources
are identified by the protocol * that they support.Manager
uses the protocol * name to findDataSource
classes. ** * To find a
DataSource
using aMediaLocator
, *Manager
constructs a list of class names from the protocol * package-prefix list and the protocol name obtained * from theMediaLocator
. * For each class name in the constructed list a newDataSource
* is instanced, theMediaLocator
is attached, * and theDataSource
is connected. * If no errors have occurred, the procces is considered finished and the * connectedDataSource
is used by *Manager
in any following operations. * If there was an error then the next class name in the list * is tried. * The exact details of the search algorithm is described in * the method documentation below. * *Finding Players by Content Type
* * APlayer
is aMediaHandler
. * AMediaHandler
is a an object that reads * data from aDataSource
. There are two types * of supportedMediaHandler
:MediaProxy
, * andPlayer
. ** *
MediaHandlers
are identified by the content type that they * support. ADataSource
identifies the content type * of the data it produces with thegetContentType
method. *Manager
uses the content type name to * find instances ofMediaHandler
. ** * To find a
MediaHandler
using a content type name, *Manager
constructs a list of class names from * the content package-prefix list and the content type name. * For each class name in the constructed list a newMediaHandler
* is instanced, and theDataSource
is attached to * theMediaHandler
usingMediaHandler.setSource * * If the
MediaHandler
is aPlayer
and the *setSource
was successful the process is finished * and thePlayer
is returned. * If thesetSource
failed, another name in the * list is tried. ** * If the
MediaHandler
is aMediaProxy
* then a newDataSource
is obtained from the *MediaProxy
, a new list is created for the * content type theDataSource
supports and the * whole thing is tried again. ** * If a valid
Player
, is not found then the whole * procedure is repeated is repeated with "unknown" substituted * for the content-type name. The "unknown" content type is supported * by genericPlayers
that are capable of handling * a large variety of media types, often in a platform dependent * way. ** * The detailed creation algorithm is specified in the methods below. *
* *
Player Threads
* *Players
render media data asynchronously from * the main program flow. * This implies that aPlayer
must often manage one * or more threads. * The threads managed by thePlayer
are not * in the thread group of the application that calls *createPlayer
. * *System Time Base
* * AllPlayers
need aTimeBase
. Many * use a system-wideTimeBase
, often based on * a time-of-day clock. *Manager
provides access to the systemTimeBase
* throughgetSystemTimeBase
. * * * @see java.net.URL * @see MediaLocator * @see PackageManager * @see javax.media.protocol.DataSource * @see javax.media.protocol.URLDataSource * @see MediaHandler * @see Player * @see MediaProxy * @see TimeBase * * @version 1.58, 07/09/19. */ public final class Manager { public static final String UNKNOWN_CONTENT_NAME = "unknown"; /* * This hidden constructor does not necessarily correspond to * a constructor in the original source file -- it keeps javadoc * from generating an inappropriate default constructor. */ private Manager() { } /** * Create aPlayer
for the specified media. * This creates a MediaLocator from the URL and then * callscreatePlayer
. * * @param sourceURL TheURL
that describes the media data. * @return A newPlayer
. * @exception NoPlayerException Thrown if noPlayer
* can be found. * @exception IOException Thrown if there was a problem connecting * with the source. */ public static Player createPlayer(URL sourceURL) throws IOException, NoPlayerException { return null; } /** * Create aPlayer
for the specified media. ** The algorithm for creating a
Player
from * aMediaLocator
is: **
- Get the protocol from the
MediaLocator
. *- Get a list of
DataSource
classes that * support the protocol, using the protocol package-prefix-list. *- For each source class in the list: *
*
*- Instantiate a new
DataSource
, *- Call the
connect
method to connect the source. *- Get the media content-type-name (using
getContentType
) * from the source. *- Get a list of
MediaHandler
classes that support the * media-content-type-name, using the content package-prefix-list. *- For each
MediaHandler
class in the list: **
*- Instantiate a new
MediaHandler
. *- Attach the source to the
MediaHandler
by calling *MediaHandler.setSource
. *- If there are no failures, determine the type of * the
MediaHandler
; otherwise try the next *MediaHandler in the list. * - If the
MediaHandler
is aPlayer
, * return the newPlayer
. *- If the
MediaHandler
is aMediaProxy
, * obtain a newDataSource
from theMediaProxy
, * obtain the list ofMediaHandlers
that support the new *DataSource
, and continue searching the new list. *- If no
MediaHandler
is found for this source, * try the next source in the list. *- If no
Player
is found after trying all of the sources, * reuse the source list.
* This time, for each source class in the list: **
* @param sourceLocator A- Instantiate the source. *
- Call the
connect
method to connect to the source. *- Use the content package-prefix-list to create a list of *
MediaHandler
classes that support the * "unknown" content-type-name. *- For each
MediaHandler
class in the list, * search for aPlayer
as in the previous search. **
*- If no
Player
is found after trying all of the sources, * aNoPlayerException
is thrown. *MediaLocator
that describes * the media content. * @return APlayer
for the media described by the source. * @exception NoPlayerException Thrown if noPlayer
can * be found. * @exception IOException Thrown if there was a problem connecting * with the source. */ public static Player createPlayer(MediaLocator sourceLocator) throws IOException, NoPlayerException { return null; } /** * Create aPlayer
for theDataSource
. ** The algorithm for creating a
Player
from * aDataSource
is: **
* @param DataSource The- Get the media content-type-name from the source by * calling
getContentType
. *- Use the content package-prefix-list to get a list of *
Player
classes that support the media content-type name. *- For each
Player
class in the list: **
*- Instantiate a new
Player
. *- Attach the source to the
Player
by calling *setSource
on thePlayer
. *- If there are no failures, return the new
Player
; * otherwise, * try the nextPlayer
in the list. *- If no
Player
is found for this source: **
*- Use the content package-prefix-list to create a list * of
Player
classes that support the * "unknown" content-type-name. *- For each
Player
class in the list: **
*- Instantiate a new
Player
. *- Attach the source to the
Player
by * callingsetSource
* on thePlayer
. *- If there are no failures, return the new
Player
; * otherwise, try the nextPlayer
in the list. *- If no
Player
can be created, * aNoPlayerException
is thrown. *DataSource
that describes * the media content. * @return A newPlayer
. * @exception NoPlayerException Thrown if aPlayer
can't * be created. * @exception IOException Thrown if there was a problem connecting * with the source. */ public static Player createPlayer(DataSource source) throws IOException, NoPlayerException { return null; } /** * Create aDataSource
for the specified media. * * @param sourceURL TheURL
that describes the media data. * @return A newDataSource
for the media. * @exception NoDataSourceException Thrown if noDataSource
* can be found. * @exception IOException Thrown if there was a problem connecting * with the source. */ public static DataSource createDataSource(URL sourceURL) throws IOException, NoDataSourceException { return null; } /** * Create aDataSource
for the specified media. ** * Returns a data source for the protocol specified by * the
MediaLocator
. The returned data source * is connected;DataSource.connect
has been * invoked. ** * The algorithm for creating a
DataSource
from * aMediaLocator
is: **
* * * @param sourceLocator The source protocol for the media data. * @return A connected- Get the protocol from the
MediaLocator
. *- Use the protocol package-prefix list to get a list of *
DataSource
classes that * support the protocol. *- For each source class in the list: *
*
*- Instantiate a new
DataSource
. *- Call
connect
to connect the source. *- If there are no errors, return the connected * source; otherwise, try the next source in the list. *
- If no source has been found, obtain a
URL
from the *MediaLocator
and use it to create * aURLDataSource
*- If no source can be found, a
NoDataSourceException
* is thrown. *DataSource
. * @exception NoDataSourceException Thrown if noDataSource
* can be found. * @exception IOException Thrown if there was a problem connecting * with the source. */ public static DataSource createDataSource(MediaLocator sourceLocator) throws IOException, NoDataSourceException { return null; } /** * Get the time-base object for the system. * @return The system time base. */ public static TimeBase getSystemTimeBase() { return null; } /** * Build a list ofDataSource
class names from the * protocol prefix-list and a protocol name. ** The first name in the list will always be: *
** media.protocol.<protocol>DataSource ** * Each additional name looks like: *
* for every* <protocol-prefix>.media.protocol.<protocol>.DataSource *<protocol-prefix>
in the * protocol-prefix-list. * * @param protocol The name of the protocol the source must * support. * @return A vector of strings, where each string is * aPlayer
class-name. */ public static Vector getDataSourceList(String protocolName) { return null; } /** * Build a list ofHandler/CODE> classes from the * content-prefix-list and a content name. *
* The first name in the list will always be: *
** media.content.<contentType>.Handler ** * Each additional name looks like: *
* for every* <content-prefix>.media.content.<contentName>.Player *<content-prefix>
in the * content-prefix-list. * * @param contentName The content type to use in the class name. * @return A vector of strings where each one is aPlayer
* class-name. */ public static Vector getHandlerClassList(String contentName) { return null; } }