org.mmbase.applications.media.builders
Class MediaSources

java.lang.Object
  extended by org.mmbase.util.functions.FunctionProvider
      extended by org.mmbase.module.core.MMTable
          extended by org.mmbase.module.core.MMObjectBuilder
              extended by org.mmbase.applications.media.builders.MediaSources
All Implemented Interfaces:
EventListener, NodeEventListener, RelationEventListener
Direct Known Subclasses:
AudioSources, ImageSources

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 42444 2010-06-08 09:31:03Z andre $
Author:
Rob Vermeulen, Michiel Meeuwissen

Field Summary
static Parameter[] AVAILABLE_PARAMETERS
           
static Parameter[] CODEC_PARAMETERS
           
static Parameter[] FILTEREDURLS_PARAMETERS
           
static Parameter[] FORMAT_PARAMETERS
           
static String FUNCTION_AVAILABLE
           
static String FUNCTION_CODEC
           
static String FUNCTION_FILTEREDURLS
           
static String FUNCTION_FORMAT
           
static String FUNCTION_MIMETYPE
           
static String FUNCTION_URL
           
static String FUNCTION_URLS
           
static Parameter[] MIMETYPE_PARAMETERS
           
static int MONO
           
static int STATE_DONE
          Deprecated.  
static int STATE_REMOVED
          Deprecated.  
static int STATE_SOURCE
          Deprecated.  
static String STATES_RESOURCE
           
static int STEREO
           
static Parameter[] URL_PARAMETERS
           
static Parameter[] URLS_PARAMETERS
           
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadCastChanges, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, EVENT_TYPE_LOCAL, EVENT_TYPE_REMOTE, FIELD_NUMBER, FIELD_OBJECT_TYPE, FIELD_OWNER, fields, genericBlobCache, getFunctions, GUI_INDICATOR, GUI_PARAMETERS, guiFunction, infoFunction, internalVersion, nodeCache, oType, pluralNames, searchAge, singularNames, SYSTEM_OWNER, TEMPNODE_DEFAULT_SIZE, TMP_FIELD_EXISTS, TMP_FIELD_NUMBER, virtual, WRAP_PARAMETERS, wrapFunction
 
Fields inherited from class org.mmbase.module.core.MMTable
maxNodesFromQuery, mmb, storageConnector, tableName
 
Fields inherited from class org.mmbase.util.functions.FunctionProvider
functions
 
Constructor Summary
MediaSources()
           
 
Method Summary
 void addProvider(MMObjectNode source, String providername, String owner)
          Relates a source with given provider.
 boolean commit(MMObjectNode node)
          The commit can be used to automatically fill unfilled fields.
 MMObjectNode createSource(MMObjectNode mediafragment, int status, int format, int speed, int channels, String url, String owner)
          create a new mediasource, and relate it with specified mediafragment.
protected  Object executeFunction(MMObjectNode node, String function, List<?> args)
          Executes a function on the field of a node, and returns the result.
 int getChannels(MMObjectNode node)
           
protected  Codec getCodec(MMObjectNode source)
          The codec field is an integer, this function returns a string-presentation
protected  List<URLComposer> getFilteredURLs(MMObjectNode source, MMObjectNode fragment, Map<String,Object> 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  String getFormat(MMObjectNode source, Map<String,Object> info)
           
 String getGUIIndicator(MMObjectNode source)
          Used in the editors
(package private)  MimeType getMimeType(MMObjectNode source)
          Resolve the mimetype for a certain media source
protected  List<MMObjectNode> getProviders(MMObjectNode source)
          Get all mediaproviders belonging to this mediasource
 int getSpeed(MMObjectNode node)
           
protected  String getURL(MMObjectNode source, Map<String,Object> info)
          Resolve the url of the mediasource.
protected  List<URLComposer> getURLs(MMObjectNode source, MMObjectNode fragment, Map<String,Object> info, List<URLComposer> urls, Set<MMObjectNode> 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(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, String fieldName, Object value)
          Sets a key/value pair in the main values of this node.
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addEventListener, addField, addLocalObserver, addRemoteObserver, broadcastChanges, checkAddTmpField, clearBlobCache, create, createAlias, createAlias, delete, equals, equals, executeFunction, fieldLocalChanged, getAncestors, getBlobCache, getClassName, getConfigFile, getConfigResource, getDataTypeCollector, getDBState, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEmptyNode, getField, getFieldNames, getFields, getFields, getFunction, getFunctionParameters, getFunctions, getGUIIndicator, getGUIIndicator, getHTML, getInitParameter, getInitParameters, getInitParameters, getInternalVersion, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNodeFromCache, getNodeGUIIndicator, getNumber, getObjectType, getObjectValue, getParentBuilder, getPluralName, getPluralName, getPluralNames, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedInputStream, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hasField, hashCode, hashCode, hostname_function, insert, isExtensionOf, isNodeCached, isNull, isVirtual, loadInitParameters, newFunctionInstance, nodeLocalChanged, nodeRemoteChanged, notify, notify, preCommit, process, removeEventListener, removeField, removeLocalObserver, removeNode, removeRelations, removeRemoteObserver, removeSyncNodes, replace, safeCache, sendFieldChangeSignal, setDefaults, setDescription, setDescriptions, setFields, setInitParameter, setMaintainer, setPluralNames, setSearchAge, setSingularNames, setUniqueValue, setUniqueValue, setValue, setVersion, setXMLPath, shutdown, testValidData, toString, toString, update, updateFields, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
count, count, created, getFullTableName, getMMBase, getNode, getNodes, getNodes, getNodes, getNodeType, getStorageConnector, getTableName, search, searchVector, setMMBase, setTableName, size
 
Methods inherited from class org.mmbase.util.functions.FunctionProvider
addFunction, createParameters, getFunction, getFunctions, getFunctionValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FUNCTION_URLS

public static final String FUNCTION_URLS
See Also:
Constant Field Values

FUNCTION_FILTEREDURLS

public static final String FUNCTION_FILTEREDURLS
See Also:
Constant Field Values

FUNCTION_URL

public static final String FUNCTION_URL
See Also:
Constant Field Values

FUNCTION_AVAILABLE

public static final String FUNCTION_AVAILABLE
See Also:
Constant Field Values

FUNCTION_FORMAT

public static final String FUNCTION_FORMAT
See Also:
Constant Field Values

FUNCTION_CODEC

public static final String FUNCTION_CODEC
See Also:
Constant Field Values

FUNCTION_MIMETYPE

public static final String FUNCTION_MIMETYPE
See Also:
Constant Field Values

URLS_PARAMETERS

public static final Parameter[] URLS_PARAMETERS

FILTEREDURLS_PARAMETERS

public static final Parameter[] FILTEREDURLS_PARAMETERS

URL_PARAMETERS

public static final Parameter[] URL_PARAMETERS

AVAILABLE_PARAMETERS

public static final Parameter[] AVAILABLE_PARAMETERS

FORMAT_PARAMETERS

public static final Parameter[] FORMAT_PARAMETERS

CODEC_PARAMETERS

public static final Parameter[] CODEC_PARAMETERS

MIMETYPE_PARAMETERS

public static final Parameter[] MIMETYPE_PARAMETERS

STATE_DONE

public static final int STATE_DONE
Deprecated. 

STATE_SOURCE

public static final int STATE_SOURCE
Deprecated. 

STATE_REMOVED

public static final int STATE_REMOVED
Deprecated. 

STATES_RESOURCE

public static final 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()
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,
                                 String url,
                                 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 String getURL(MMObjectNode source,
                        Map<String,Object> 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

getMimeType

MimeType getMimeType(MMObjectNode source)
Resolve the mimetype for a certain media source

Parameters:
source - the media source
Returns:
the content type

getGUIIndicator

public 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 String getFormat(MMObjectNode source,
                           Map<String,Object> info)

getCodec

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


executeFunction

protected Object executeFunction(MMObjectNode node,
                                 String function,
                                 List<?> args)
Executes a function on the field of a node, and returns the result. This method is called by the builder's MMObjectBuilder.getValue(org.mmbase.module.core.MMObjectNode, java.lang.String) method. Derived builders should override this method to provide additional functions.

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

getURLs

protected List<URLComposer> getURLs(MMObjectNode source,
                                    MMObjectNode fragment,
                                    Map<String,Object> info,
                                    List<URLComposer> urls,
                                    Set<MMObjectNode> cacheExpireObjects)
Returns all possible URLs for this source. (A source can be on different providers)


getFilteredURLs

protected List<URLComposer> getFilteredURLs(MMObjectNode source,
                                            MMObjectNode fragment,
                                            Map<String,Object> info)
Returns all URLs for this source, but filtered, with the best ones on top.


addProvider

public void addProvider(MMObjectNode source,
                        String providername,
                        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 List<MMObjectNode> 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,
                        String fieldName,
                        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:
node - The node on which to change the field (the new value is in this node)
fieldName - the name of the field to change
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 automatically 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(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 2.0-SNAPSHOT - null