magoffin.matt.ma2
Interface MediaHandler

All Known Implementing Classes:
AbstractMediaHandler, BaseAwtImageMediaHandler, BaseImageIOMediaHandler, BaseImageMediaHandler, BaseJMagickMediaHandler, BasicAudioMediaHandler, BasicIconBasedMediaHandler, JpegMediaHandler, JpegMediaHandler, PngMediaHandler, PngMediaHandler, SvgMediaHandler

public interface MediaHandler

API for performing operations on media items.

This is the main API Matte uses for processing media items. It serves primarily to allow Matte to:

  1. Add new media items into the application, via the createNewMediaItem(File) method.
  2. Respond to requests for media items, along with request processing instructions such as the desired size, quality, etc, via the handleMediaRequest(MediaItem, MediaRequest, MediaResponse) method.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
matt.magoffin

Method Summary
 MediaItem createNewMediaItem(java.io.File inputFile)
          Create a new instance of MediaItem from a File.
 MediaEffect getEffect(java.lang.String key, java.util.Map<java.lang.String,?> effectParameters)
          Get a MediaEffect instance for a specific key.
 java.lang.String getFileExtension(MediaItem item, MediaRequest request)
          Get the preferred file extension for this handler.
 void handleMediaRequest(MediaItem item, MediaRequest request, MediaResponse response)
          Handle a media request by processing the specified media item and writing the result to MediaResponse.getOutputStream().
 

Method Detail

createNewMediaItem

MediaItem createNewMediaItem(java.io.File inputFile)
Create a new instance of MediaItem from a File.

This method will be called when a new media item is to be added into Matte. This method should populate as much information as it can extract from the file into a MediaItem instance, including populating any Metadata it can extract from the file.

This method does not need to persist the MediaItem instance, just populate it and return it.

Parameters:
inputFile - the file to create the media item from
Returns:
an instance of MediaItem

getFileExtension

java.lang.String getFileExtension(MediaItem item,
                                  MediaRequest request)
Get the preferred file extension for this handler.

Some handlers might return a different file extension for a given request then the default file extension for their type (for example a PNG image handler that returns JPEG images when resizing the images.

Parameters:
item - the media item to process
request - the request
Returns:
a file extension, without the period

getEffect

MediaEffect getEffect(java.lang.String key,
                      java.util.Map<java.lang.String,?> effectParameters)
Get a MediaEffect instance for a specific key.

Implementaions must define the keys they support, and define the parameters that go with it.

Parameters:
key - the key of the desired effect
effectParameters - a Map of parameters (optional)
Returns:
a MediaEffect instance

handleMediaRequest

void handleMediaRequest(MediaItem item,
                        MediaRequest request,
                        MediaResponse response)
Handle a media request by processing the specified media item and writing the result to MediaResponse.getOutputStream().

Parameters:
item - the media item to process
request - the request
response - the response