Overview

Here follows a list of often used classes and descriptions for implementing plug-ins

IMediaConverter

To perform conversion from a media file to a target format you need to implement an interface named IMediaConverter. You can inherit the MediaConverterBase class to get a base implementation of many methods. Only override the necessary methods.

The IMediaConverter defines the following methods:

CanConvert

This method questions the converter if the specified conversion can be made. It is called with the source media and target format as parameters. The converter needs to inspect the source media and target format (including effects) and then return true if the converter can perform the conversion.

Convert

This method is called if the converter has returned true on the CanConvert call for the specific conversion. This method should implement the conversion and return a MediaContent instance.

CalculateMediaName

Is used to calculate the name for the specific conversion

Ex. if I convert the file "file.pdf" to a jpeg image, this could return "file.jpg" There is a base implementation that handles image conversions in MediaConverterBase

CalculateContentType

Is used to calculate the content type for the specific conversion. The utility class ContentTypeUtil can be helpful when implementing this method.

Ex. if I convert the file "file.pdf" to a jpeg image, this could return "image/jpeg" There is a base implementation that handles image conversions in MediaConverterBase

ApplyFormatOnMedia

This method is used to calculate the effects a specific format has on a media. It will only calculate the result of the effect (like output width/height) to be able to deliver pre conversion information to the client.

IMediaInformationGenerator2

The IMediaInformationGenerator2 is an interface that creates the information details about an original or converted media. This information is created and cached in the database using the methods included in this interface. The interface contains two methods that creates/updates the Media instance of the DbMediaContentReference instance for the item.

IMediaStorage

The [IMediaStorage][] interface can be implemented to store/read data from custom sources.

TODO

IMediaAnalyser

This can be registered on your [IMediaStorage][] implementation to provide a set of meta data when the media is stored.

You can also implement a separate class and register it as a MediaAnalyser to provide meta data analysis before the media item is uploaded to a storage.

Media

The media class contains information about a media conversion. It contains the URL to the content, content type, Id of the MediaItem, id of the format and specific properties depending on the type of media it is. For images and video we get width and height for example. There exists a few subclasses, mainly Image, Video and Thumbnail. It also contains the html needed for displaying the media on a web page.

MediaConverterBase

The MediaConverterBase is a base class for implementing a IMediaConverter. It has a IServiceFactory property for easy access for the core services and provides a base implementation for the CalculateMediaName method.

MediaContent

The MediaContent class defines the content that can be delivered to the client. It inherits the MediaContentBase class and provides all information needed to be able to deliver a response containing the media. It contains the MediaItemId (id of the media), MediaContentReferenceId (unique id for the MediaItem,MediaFormat combination), name of the content and content type.

The concrete implementations of the MediaContent class are StreamedBinaryMediaContent which supplies a binary stream to the content, BufferedBinaryMediaContent which supplies a byte array for the content and ExternalMediaContent which redirects the client to another URL.

DbMediaContentReference

The DbMediaContentReference represents a row in the MediaContentReference table in the database.

MediaFormatBase

The MediaFormatBase is the base implementation of an IMediaFormat. A media format represents the way a media should be converted/displayed. Often used subclasses are OriginalFormat that represents the original, unchanged format of the media, ImageFormat used to convert the source to an image, VideoFormat used to convert the source to a video, WebMediaFormat keeps the original format (image, video) but allows specifying resize operations on it.

Each format can have a list of effects that should be applied to it, like ResizeEffect and CropEffect.

IServiceFactory

The IServiceFactory is an interface that allows us to get in contact with the different services that ImageVault core provides.

comments powered by Disqus