javax.emb
Interface MediaConverter


public interface MediaConverter

A media converter performs actual conversions of media content. Implementations of this interface can work in one of two ways: Synchronous converters perform conversions completely before returning the input stream on the converted content. Asynchronous converters return a piped input stream immediately after checking the input and spawning a new thread to perform the conversion. The latter has the advantage of being very memory efficient in case the result is consumed immediately, while the first tends to be more robust because it doesn't require the maintenance of additional threads of execution.

The design assumes a converter is instantiated for a specific kind of conversion. Therefore, classes implementing this interface should take a media converter spec as a constructor argument. Said media converter spec should contain the necessary conversion parameters, for example the desired bandwidth for a WAV to MP3 converter.


Method Summary
 java.io.InputStream process(java.io.InputStream inputStream)
          Converts the media content offered on the given input stream and returns the converted media content as an input stream.
 void process(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Converts the media content offered on the given input stream and writes the converted media content on the given output stream.
 

Method Detail

process

public java.io.InputStream process(java.io.InputStream inputStream)
                            throws MediaException (src) 
Converts the media content offered on the given input stream and returns the converted media content as an input stream. Implementations of this method may, but are not required to, spawn a new thread to perform the actual conversion, and return a PipedInputStream immediately.

Parameters:
inputStream - the input stream to process.
Returns:
the processed input stream.
Throws:
java.lang.NullPointerException - if the value passed is null.
FormatSyntaxException (src) - if the content provided with the input stream does not meet the expected format syntax.
FormatFeatureException (src) - if the content provided in the input stream utilizes a format feature not supported by the receiver.
LinkTranslationException (src) - if the content provided contains relative links to child media objects.
ContentAccessException (src) - if an I/O problem occurs or if said child links cannot be resolved to child media content.
ConversionException (src) - if the conversion fails because a conversion specific problem occurred.
MediaException (src)

process

public void process(java.io.InputStream inputStream,
                    java.io.OutputStream outputStream)
             throws MediaException (src) 
Converts the media content offered on the given input stream and writes the converted media content on the given output stream. In any case, this method will block until the conversion is completed.

Parameters:
inputStream - the stream to process.
outputStream - the processed stream.
Throws:
java.lang.NullPointerException - if one the values passed is null.
FormatSyntaxException (src) - if the content provided with the input stream does not meet the expected format syntax.
FormatFeatureException (src) - if the content provided in the input stream utilizes a format feature not supported by the receiver.
LinkTranslationException (src) - if the content provided contains relative links to child media objects.
ContentAccessException (src) - if an I/O problem occurs or if said child links cannot be resolved to child media content.
ConversionException (src) - is thrown if the conversion fails because a conversion specific problem occurred.
MediaException (src)