org.mmbase.applications.media.builders
Class MediaSources

java.lang.Object
  extended byorg.mmbase.module.core.MMTable
      extended byorg.mmbase.module.core.MMObjectBuilder
          extended byorg.mmbase.applications.media.builders.MediaSources
Direct Known Subclasses:
AudioSources

public class MediaSources
extends MMObjectBuilder

The MediaSource builder describes a specific type of media that can be retrieved (real/mp3/etc). Information about format, quality, and status will be maintained in this object. A MediaSource belongs to a MediaFragement that describes the piece of media, the MediaSource is the real audio/video itself. A MediaSource is connected to provider objects that indicate where the real audio/video files can be found.

Since:
MMBase-1.7
Version:
$Id: MediaSources.java,v 1.26.2.1 2004/05/12 14:41:46 rob Exp $
Author:
Rob Vermeulen, Michiel Meeuwissen

Field Summary
static java.lang.String FUNCTION_AVAILABLE
           
static java.lang.String FUNCTION_CODEC
           
static java.lang.String FUNCTION_FILTEREDURLS
           
static java.lang.String FUNCTION_FORMAT
           
static java.lang.String FUNCTION_MIMETYPE
           
static java.lang.String FUNCTION_URL
           
static java.lang.String FUNCTION_URLS
           
static int MONO
           
static int STATE_DONE
           
static java.lang.String STATES_RESOURCE
           
static int STEREO
           
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadcastChanges, database, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, fields, GUI_PARAMETERS, listCache, nodeCache, OBJ2TYPE_MAX_SIZE, oType, REPLACE_CACHE, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
MediaSources()
           
 
Method Summary
 void addProvider(MMObjectNode source, java.lang.String providername, java.lang.String owner)
          relates a source with given provider.
 boolean commit(MMObjectNode node)
          The commit can be used to automaticly fill unfilled fields.
 MMObjectNode createSource(MMObjectNode mediafragment, int status, int format, int speed, int channels, java.lang.String url, java.lang.String owner)
          create a new mediasource, and relate it with specified mediafragment.
protected  java.lang.Object executeFunction(MMObjectNode node, java.lang.String function, java.util.List args)
          Functions.
 int getChannels(MMObjectNode node)
           
protected  Codec getCodec(MMObjectNode source)
          The codec field is an integer, this function returns a string-presentation
protected  java.util.List getFilteredURLs(MMObjectNode source, MMObjectNode fragment, java.util.Map info)
          Returns all URLs for this source, but filtered, with the best ones on top.
protected  Format getFormat(MMObjectNode source)
          The format field is an integer, this function returns a string-presentation
protected  java.lang.String getFormat(MMObjectNode source, java.util.Map info)
           
 java.lang.String getGUIIndicator(MMObjectNode source)
          used in the editors
protected  java.util.List getProviders(MMObjectNode source)
          get all mediaproviders belonging to this mediasource
 int getSpeed(MMObjectNode node)
           
protected  java.lang.String getURL(MMObjectNode source, java.util.Map info)
          resolve the url of the mediasource.
protected  java.util.List getURLs(MMObjectNode source, MMObjectNode fragment, java.util.Map info, java.util.List urls, java.util.Set cacheExpireObjects)
          Returns all possible URLs for this source.
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 int insert(java.lang.String owner, MMObjectNode node)
          Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided).
 boolean setValue(MMObjectNode node, java.lang.String fieldName, java.lang.Object value)
          Sets a key/value pair in the main values of this node.
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, convertMMNode2SQL, count, count, create, createAlias, delete, deleteNodeCache, drop, equals, equals, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getAncestors, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getConfigFile, getDBByte, getDBKey, getDBState, getDBText, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEditFields, getField, getFieldNames, getFields, getFields, getFunctionParameters, getGUIIndicator, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getMMBase, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNode, getNodes, getNodes, getNodeType, getNumberFromName, getObjectType, getObjectValue, getParameterDefinition, getParentBuilder, getPluralName, getPluralName, getPluralNames, getQuery, getQuery, getQuery, getRawNodes, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hashCode, hostname_function, insert, insertDone, isExtensionOf, isNodeCached, isVirtual, nodeLocalChanged, nodeRemoteChanged, preCommit, preEdit, process, processSearchResults, putTmpNode, readSearchResults, removeField, removeNode, removeRelations, removeSyncNodes, removeTmpNode, replace, safeCache, safeCommit, safeInsert, search, search, search, searchIn, searchIn, searchIn, searchList, searchList, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setDBLayout_xml, setDefaults, setDescription, setDescriptions, setInitParameter, setMaintainer, setMMBase, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setTableName, setUniqueValue, setUniqueValue, setValue, setVersion, setXMLPath, setXMLValues, signalNewObject, testValidData, toString, toString, toXML, updateFields, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
created, getFullTableName, getTableName, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FUNCTION_URLS

public static final java.lang.String FUNCTION_URLS
See Also:
Constant Field Values

FUNCTION_FILTEREDURLS

public static final java.lang.String FUNCTION_FILTEREDURLS
See Also:
Constant Field Values

FUNCTION_URL

public static final java.lang.String FUNCTION_URL
See Also:
Constant Field Values

FUNCTION_AVAILABLE

public static final java.lang.String FUNCTION_AVAILABLE
See Also:
Constant Field Values

FUNCTION_FORMAT

public static final java.lang.String FUNCTION_FORMAT
See Also:
Constant Field Values

FUNCTION_CODEC

public static final java.lang.String FUNCTION_CODEC
See Also:
Constant Field Values

FUNCTION_MIMETYPE

public static final java.lang.String FUNCTION_MIMETYPE
See Also:
Constant Field Values

STATE_DONE

public static final int STATE_DONE
See Also:
Constant Field Values

STATES_RESOURCE

public static final java.lang.String STATES_RESOURCE
See Also:
Constant Field Values

MONO

public static final int MONO
See Also:
Constant Field Values

STEREO

public static final int STEREO
See Also:
Constant Field Values
Constructor Detail

MediaSources

public MediaSources()
Method Detail

init

public boolean init()
Description copied from class: MMObjectBuilder
Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called. The method retrieves data from the TypeDef builder, or adds data to that builder if the current builder is not yet registered.

Overrides:
init in class MMObjectBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

createSource

public MMObjectNode createSource(MMObjectNode mediafragment,
                                 int status,
                                 int format,
                                 int speed,
                                 int channels,
                                 java.lang.String url,
                                 java.lang.String owner)
create a new mediasource, and relate it with specified mediafragment.

Parameters:
mediafragment - the media fragment to which this source belongs
status - of the media source
format - the format of the source (Real, Mp3)
channels - stereo/mono
url - the file name of the media source
owner - creator of the new object
Returns:
the new MediaSource

getURL

protected java.lang.String getURL(MMObjectNode source,
                                  java.util.Map info)
resolve the url of the mediasource. (e.g. pnm://www.mmbase.org/test/test.ra)

Parameters:
source - the media source
info - extra info (i.e. HttpRequestIno, bitrate, etc.)
Returns:
the url of the media source

getGUIIndicator

public java.lang.String getGUIIndicator(MMObjectNode source)
used in the editors

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
source - The node to display
Returns:
the display of the node as a String

getSpeed

public int getSpeed(MMObjectNode node)

getChannels

public int getChannels(MMObjectNode node)

getFormat

protected Format getFormat(MMObjectNode source)
The format field is an integer, this function returns a string-presentation


getFormat

protected java.lang.String getFormat(MMObjectNode source,
                                     java.util.Map info)

getCodec

protected Codec getCodec(MMObjectNode source)
The codec field is an integer, this function returns a string-presentation


executeFunction

protected java.lang.Object executeFunction(MMObjectNode node,
                                           java.lang.String function,
                                           java.util.List args)
Functions.

Overrides:
executeFunction in class MMObjectBuilder
See Also:
MMObjectBuilder.executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List)

getURLs

protected java.util.List getURLs(MMObjectNode source,
                                 MMObjectNode fragment,
                                 java.util.Map info,
                                 java.util.List urls,
                                 java.util.Set cacheExpireObjects)
Returns all possible URLs for this source. (A source can be on different providers)


getFilteredURLs

protected java.util.List getFilteredURLs(MMObjectNode source,
                                         MMObjectNode fragment,
                                         java.util.Map info)
Returns all URLs for this source, but filtered, with the best ones on top.


addProvider

public void addProvider(MMObjectNode source,
                        java.lang.String providername,
                        java.lang.String owner)
relates a source with given provider. Only if there is one provider matching.

Parameters:
source - the media source.
providername - the name of the provider that is going to be related.
owner - the owner name that is creating the relation.

getProviders

protected java.util.List getProviders(MMObjectNode source)
get all mediaproviders belonging to this mediasource

Parameters:
source - the mediasource
Returns:
All mediaproviders related to the given mediasource

setValue

public boolean setValue(MMObjectNode node,
                        java.lang.String fieldName,
                        java.lang.Object value)
Description copied from class: MMObjectBuilder
Sets a key/value pair in the main values of this node. Note that if this node is a node in cache, the changes are immediately visible to everyone, even if the changes are not committed. The fieldname is added to the (public) 'changed' vector to track changes.

Overrides:
setValue in class MMObjectBuilder
Parameters:
value - the value which was original in the field
Returns:
true When an update is required(when changed), false if original value was set back into the field.

commit

public boolean commit(MMObjectNode node)
The commit can be used to automaticly fill unfilled fields. For example the format can well be guessed by the URL. (todo: which of commit,insert must be overriden?)

Overrides:
commit in class MMObjectBuilder
Parameters:
node - The node to be committed
Returns:
true if commit successful

insert

public int insert(java.lang.String owner,
                  MMObjectNode node)
Description copied from class: MMObjectBuilder
Insert a new object (content provided) in the cloud, including an entry for the object alias (if provided). This method indirectly calls MMObjectBuilder.preCommit(org.mmbase.module.core.MMObjectNode).

Overrides:
insert in class MMObjectBuilder
Parameters:
owner - The administrator creating the node
node - The object to insert. The object need be of the same type as the current builder.
Returns:
An int value which is the new object's unique number, -1 if the insert failed.


MMBase build 1.7.1.20041002