org.jboss.media.format
Class EmbeddedMediaFormat

java.lang.Object
  extended byorg.jboss.media.format.EmbeddedMediaFormat
All Implemented Interfaces:
MediaFormat (src) , java.io.Serializable
Direct Known Subclasses:
IIOMediaFormat (src)

public abstract class EmbeddedMediaFormat
extends java.lang.Object
implements MediaFormat (src)

Facade around GenericMediaFormat to represent embedded media formats.

See Also:
Serialized Form

Constructor Summary
EmbeddedMediaFormat()
           
 
Method Summary
 byte[] assembleContent(java.net.URL mediaLocation, MediaSegment (src) [] mediaSegments)
          Assembles the given media segments and returns the resulting media content as a byte array.
 MediaSegment (src) [] disassembleContent(java.net.URL mediaLocation, byte[] mediaContent)
          Disassembles the given media content into an array of media segments preserving the order of the original content, and returns said array of media segments.
abstract  MediaHeader (src) extractHeader(java.io.InputStream content)
          Extracts a media header instance from the given media content and returns it.
 Media (src) extractProxy(java.io.InputStream content)
          Extracts a proxy from the given media content and returns it.
abstract  java.lang.String getDefaultMimeType()
          Returns the default MIME type for the given media format as a String.
 boolean isEmbedded()
          Returns false if the media format allows links to external media, or true otherwise.
abstract  boolean isStreamingDesirable()
          Returns true if it is always desirable to stream media of this format, or false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmbeddedMediaFormat

public EmbeddedMediaFormat()
Method Detail

assembleContent

public final byte[] assembleContent(java.net.URL mediaLocation,
                                    MediaSegment (src) [] mediaSegments)
                             throws MediaException (src) 
Description copied from interface: MediaFormat (src)
Assembles the given media segments and returns the resulting media content as a byte array. The optional media location describes where the content itself is stored, and passing it allows links to child media to be written as relative file paths. In case the given media location is null, all links in the resulting media content will be URLs. In case it is not null, those links that can be expressed relative to the given URL will be relative file paths, and all others will be URLs.

This means a media object that has been disassembled into media segments beforehand can be reassembled using this operation. The given media location is used to handle relative links to external media correctly. Media Entity Beans use this operation when maintaining referential integrity between complex graphs of persistent, non-embedded, media objects. The implicit limitation of media size to a theoretical limit of 2GB should not impose a restriction in practice as this operation is only of value for non-embedded media, which tends to be relatively small in size.

Specified by:
assembleContent in interface MediaFormat (src)
Parameters:
mediaLocation - the intended location of the media to be assembled.
mediaSegments - the segments that are to be assembled.
Returns:
the assembled content.
Throws:
MediaException (src)

disassembleContent

public final MediaSegment (src) [] disassembleContent(java.net.URL mediaLocation,
                                               byte[] mediaContent)
                                        throws MediaException (src) 
Description copied from interface: MediaFormat (src)
Disassembles the given media content into an array of media segments preserving the order of the original content, and returns said array of media segments. The optional media location describes where the content itself is stored, and passing it allows relative links to child media to be interpreted.

In case of simple media formats, the resulting media segment array contains exactly one element, which consists of null as child location and the complete media content as content. Media Entity Beans use this operation when maintaining referential integrity between complex graphs of persistent, non embedded, media objects. Note that this operation is only of value for non-embedded media formats. As the reassembly is limited to media up to 2GB in size, the MediaFormat.isEmbedded()operation should be used to determine if disassembling a given media content is of value beforehand.

Specified by:
disassembleContent in interface MediaFormat (src)
Parameters:
mediaLocation - the location of the media to be disassembled.
mediaContent - the content to be disassembled.
Returns:
the segments.
Throws:
MediaException (src)

extractHeader

public abstract MediaHeader (src)  extractHeader(java.io.InputStream content)
                                   throws MediaException (src) 
Description copied from interface: MediaFormat (src)
Extracts a media header instance from the given media content and returns it. The information presented by the header is up to the implementation of the media format bean, and the information returned can therefore be the complete header information as defined in the relevant media format standard, no information at all, or something in between. However, implementers are encouraged to return header information as complete as possible, as such information can be highly useful for format specific algorithms and optimizations.

Please note that the given input stream is not closed once the operation is successfully completed.

Specified by:
extractHeader in interface MediaFormat (src)
Parameters:
content - the media content to extract the header from.
Returns:
the header.
Throws:
MediaException (src)

extractProxy

public Media (src)  extractProxy(java.io.InputStream content)
                   throws MediaException (src) 
Description copied from interface: MediaFormat (src)
Extracts a proxy from the given media content and returns it. The proxy may be of any media format. For example, a key frame image may be returned in case of video content, a waveform image in case of audio content, or a thumbnail in case of image content. In case there's a problem creating the surrogate, a default format specific proxy must be returned - for example GenericMediaFormat.GENERIC_PROXY. Please note that the given input stream is closed once the operation is completed.

Specified by:
extractProxy in interface MediaFormat (src)
Parameters:
content - the content to extract the proxy from.
Returns:
the proxy.
Throws:
MediaException (src) - if the given media is not compatible with the receiver

getDefaultMimeType

public abstract java.lang.String getDefaultMimeType()
Description copied from interface: MediaFormat (src)
Returns the default MIME type for the given media format as a String. If there is no suitable MIME type, Media.MIME_TYPE_UNKNOWN should be returned.

Specified by:
getDefaultMimeType in interface MediaFormat (src)
Returns:
the default MIME type.

isEmbedded

public final boolean isEmbedded()
Description copied from interface: MediaFormat (src)
Returns false if the media format allows links to external media, or true otherwise. It can be used to determine if the media content has to be examined and possibly altered when a persistent media object is moved from one location to another while having child and/or parent dependencies to other media objects.

Specified by:
isEmbedded in interface MediaFormat (src)
Returns:
true if the format is embedded, false if it is non-embedded.

isStreamingDesirable

public abstract boolean isStreamingDesirable()
Description copied from interface: MediaFormat (src)
Returns true if it is always desirable to stream media of this format, or false otherwise. For example, it is not always desirable to stream JPEG or GIF images, even given the possibility to stream them with a Real player. Servlets can use this information to decide whether they should try to stream content or transfer it using burst transfer instead.

Specified by:
isStreamingDesirable in interface MediaFormat (src)
Returns:
true if it desirable to stream the format, false otherwise.