User:TheDJ/mediahandler

MediaHandler and associated classes are mixing lots of responsibilities and we should untangle them. They are:


 * Parse metadata from specific file formats
 * Represent interpreted metadata of files
 * Inform what thumbnails should be generated
 * Render the HTML for the thumbnail and its wrapper.

One of the biggest problems this creates is that we currently have the following relations:


 * file extension *-1 mime type
 * mime type *-1 mediahandler
 * mediahandler 1-* metadataparser
 * mediahandler 1-1 thumbnail engine
 * mediahandler 1-1 thumbnail HTML renderer

You can override a media handler for jpg completely, if you want, but you cannot easily modify the html it generates depending on a specific piece of metadata. This is especially a problem for formats that require some level of interaction or extra modifiers like:
 * PDF/Djvu browsing
 * Audio/video players
 * Animated formats for png, gif, webp (which you might want to transcode to video)
 * Alternate viewers for panorama or 360 projections
 * And in general, overriding a partial case of a built in mediahandler

Therefor, media handlers are currently choke points. A similar problem extends towards MultiMediaViewer, which is file-extension based.

Current classes

 * MediaHandlerFactory : Selects and returns a MediaHandler based on the provided mime type of a file. The mime type is either detected by mime info, or retrieved (cached) from the database row of the File object.
 * MediaHandler
 * TransformationalImageHandler : handlers which require transforming images. Provides the interface for gd, imagemagick etc transforms. Provides hooks for extensions to intercept the transform and checkimagearea.
 * BitmapHandler : like TransformationalImageHandler but with specifics for the built in handler formats and implementation of imagemagick and gd transforms.
 * MediaHandlerState : Interface to couple mediahandler state information to a file.
 * MediaTransformOutput : Interface. Consumed by the Linker. Generated by transform of mediahandlers.
 * ThumbnailImage : Generate the html (frame, link etc) for a thumbnail (but not the thumbnail contents themselves). Provides onThumbnailBeforeProduceHTML hook for others to override.
 * MediaTransformError
 * TransformParameterError
 * TransformTooBigImageAreaError


 * PNGMetadataExtracter
 * JpegMetadataExtractor
 * GIFMetadataExtractor