isobmff-builder-0.9.0.0: A (bytestring-) builder for the ISO-14496-12 base media file format

Safe HaskellNone
LanguageHaskell2010

Data.ByteString.IsoBaseFileFormat.Boxes.Box

Contents

Description

Definition of the most basic element in an ISOBMFF file: a box. See Chapter 4 in the standard document. A box is a container with a type, a size, some data and some nested boxes. The standard defines - among other characteristics - available box types and their semantics, the fields they contain and how they are nested into each other. This library tries to capture some of these characteristics using modern Haskell type system features, in order to provide compile time checks for (partial) standard compliance.

Synopsis

Box Type Classes

class IsBoxContent (BoxContent t) => IsBoxType t where Source #

Base class for all (abstractphantomnormal-) types that represent boxes

Minimal complete definition

toBoxType

Associated Types

type BoxContent t Source #

Methods

toBoxType :: proxy t -> BoxContent t -> BoxType Source #

Instances

IsBoxType * FileType Source #

File Type Box

Associated Types

type BoxContent FileType (t :: FileType) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent FileType t -> BoxType Source #

IsBoxType * Handler Source # 

Associated Types

type BoxContent Handler (t :: Handler) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent Handler t -> BoxType Source #

IsBoxType * Media Source # 

Associated Types

type BoxContent Media (t :: Media) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent Media t -> BoxType Source #

IsBoxType * MediaData Source # 

Associated Types

type BoxContent MediaData (t :: MediaData) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent MediaData t -> BoxType Source #

IsBoxType * MediaInformation Source # 

Associated Types

type BoxContent MediaInformation (t :: MediaInformation) :: * Source #

IsBoxType * Movie Source # 

Associated Types

type BoxContent Movie (t :: Movie) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent Movie t -> BoxType Source #

IsBoxType * ProgressiveDownload Source # 
IsBoxType * Skip Source # 

Associated Types

type BoxContent Skip (t :: Skip) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent Skip t -> BoxType Source #

IsBoxType * SpecificMediaHeader Source # 
IsBoxType * Track Source # 

Associated Types

type BoxContent Track (t :: Track) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent Track t -> BoxType Source #

KnownNat v => IsBoxType * (MediaHeader v) Source # 

Associated Types

type BoxContent (MediaHeader v) (t :: MediaHeader v) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent (MediaHeader v) t -> BoxType Source #

KnownNat version => IsBoxType * (MovieHeader version) Source # 

Associated Types

type BoxContent (MovieHeader version) (t :: MovieHeader version) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent (MovieHeader version) t -> BoxType Source #

KnownNat version => IsBoxType * (TrackHeader version) Source # 

Associated Types

type BoxContent (TrackHeader version) (t :: TrackHeader version) :: * Source #

Methods

toBoxType :: proxy t -> BoxContent (TrackHeader version) t -> BoxType Source #

class IsBoxContent a where Source #

Types that go into a box. A box content is a piece of data that can be reused in different instances of IsBox. It has no BoxType and hence defines no box.

Minimal complete definition

boxSize, boxBuilder

Instances

IsBoxContent () Source #

An empty box content can by represented by () (i.e. unit).

Methods

boxSize :: () -> BoxSize Source #

boxBuilder :: () -> Builder Source #

IsBoxContent ByteString Source #

Trivial instance for ByteString

IsBoxContent Text Source #

This Text instance writes a null terminated UTF-8 string.

IsBoxContent BoxTypeExtension Source # 
IsBoxContent FourCc Source # 
IsBoxContent BoxType Source # 
IsBoxContent BoxSizeExtension Source # 
IsBoxContent BoxSize Source # 
IsBoxContent FileType Source # 
IsBoxContent HandlerType Source # 
IsBoxContent Handler Source # 
IsBoxContent Language Source # 
IsBoxContent Skip Source # 
IsBoxContent SpecificMediaHeader Source # 
IsBoxContent (MediaHeader v) Source # 
IsBoxContent (MovieHeader version) Source # 
IsBoxContent (TrackHeader version) Source # 
IsBoxContent (Boxes brand bs) Source # 

Methods

boxSize :: Boxes brand bs -> BoxSize Source #

boxBuilder :: Boxes brand bs -> Builder Source #

IsBoxContent (Box brand cnt) Source # 

Methods

boxSize :: Box brand cnt -> BoxSize Source #

boxBuilder :: Box brand cnt -> Builder Source #

(IsBoxContent p, IsBoxContent c) => IsBoxContent ((:+) p c) Source # 

Methods

boxSize :: (p :+ c) -> BoxSize Source #

boxBuilder :: (p :+ c) -> Builder Source #

KnownNat bits => IsBoxContent (BoxFlags Nat bits) Source #

Get the number of bytes required to store a number of bits.

(IsBoxContent o, FromTypeLit k o v) => IsBoxContent (Template k o v) Source # 
IsBoxContent (Scalar k Int64 label) Source # 

Methods

boxSize :: Scalar k Int64 label -> BoxSize Source #

boxBuilder :: Scalar k Int64 label -> Builder Source #

IsBoxContent (Scalar k Int32 label) Source # 

Methods

boxSize :: Scalar k Int32 label -> BoxSize Source #

boxBuilder :: Scalar k Int32 label -> Builder Source #

IsBoxContent (Scalar k Int16 label) Source # 

Methods

boxSize :: Scalar k Int16 label -> BoxSize Source #

boxBuilder :: Scalar k Int16 label -> Builder Source #

IsBoxContent (Scalar k Int8 label) Source # 

Methods

boxSize :: Scalar k Int8 label -> BoxSize Source #

boxBuilder :: Scalar k Int8 label -> Builder Source #

IsBoxContent (Scalar k Word64 label) Source # 
IsBoxContent (Scalar k Word32 label) Source # 
IsBoxContent (Scalar k Word16 label) Source # 
IsBoxContent (Scalar k Word8 label) Source # 

Methods

boxSize :: Scalar k Word8 label -> BoxSize Source #

boxBuilder :: Scalar k Word8 label -> Builder Source #

(KnownNat version, IsBoxContent t) => IsBoxContent (FullBox Nat version t) Source # 

Methods

boxSize :: FullBox Nat version t -> BoxSize Source #

boxBuilder :: FullBox Nat version t -> Builder Source #

IsBoxContent (Versioned v0 v1 version) Source # 

Methods

boxSize :: Versioned v0 v1 version -> BoxSize Source #

boxBuilder :: Versioned v0 v1 version -> Builder Source #

(IsBoxContent o, FromTypeLit k o v) => IsBoxContent (Constant * k o v) Source # 
(Num o, IsBoxContent (Scalar k o label), KnownNat len) => IsBoxContent (ScalarArray k label len o) Source # 

Methods

boxSize :: ScalarArray k label len o -> BoxSize Source #

boxBuilder :: ScalarArray k label len o -> Builder Source #

Data types

data Box brand b where Source #

A type that wraps the contents of a box and the box type.

Constructors

Box :: (IsBoxType b, IsBrandConform brand (Just b) ts) => BoxContent b -> Boxes brand ts -> Box brand b 

Instances

IsBoxContent (Box brand cnt) Source # 

Methods

boxSize :: Box brand cnt -> BoxSize Source #

boxBuilder :: Box brand cnt -> Builder Source #

data Boxes brand boxTypes where Source #

A heterogenous collection of boxes.

Constructors

NoBoxes :: Boxes brand '[] 
(:.) :: Box brand l -> Boxes brand r -> Boxes brand (l ': r) infixr 2 
(:|) :: Box brand l -> Box brand r -> Boxes brand '[l, r] infixr 2

Create a Boxes collection from two Boxes

(:<>) :: Boxes brand l -> Boxes brand r -> Boxes brand (l :++ r) infixr 1 

Instances

IsBoxContent (Boxes brand bs) Source # 

Methods

boxSize :: Boxes brand bs -> BoxSize Source #

boxBuilder :: Boxes brand bs -> Builder Source #

($:) :: (Boxes brand '[l] -> r) -> Box brand l -> r infixr 3 Source #

Apply a function to a Boxes collection containing only a single Box.

singletonBox :: Box brand l -> Boxes brand '[l] Source #

Create a Boxes collection with a single Box.

closedBox :: (IsBoxType t, IsBrandConform brand (Just t) '[]) => BoxContent t -> Box brand t Source #

A box that contains no nested boxes.

containerBox :: (IsBoxType t, IsBrandConform brand (Just t) ts, BoxContent t ~ ()) => Boxes brand ts -> Box brand t Source #

A box that contains no fields, but nested boxes.

Box Size and Type

data BoxSize Source #

The size of the box. If the size is limited to a (fixed) value, it can be provided as a Word64 which will be represented as either a 32bit compact size or as 64 bit largesize. If UnlimitedSize is used, the box extends to the end of the file.

data BoxSizeExtension Source #

The BoxSize can be > 2^32 in which case an BoxSizeExtension must be added after the type field.

data BoxType Source #

A box has a type, this is the value level representation for the box type.

Constructors

StdType FourCc

FourCc can be used as boxType in Box, standard four letter character code, e.g. ftyp

CustomBoxType String

CustomBoxType defines custom boxTypes in Boxes.

newtype FourCc Source #

A type containin a printable four letter character code.

Constructors

FourCc (Char, Char, Char, Char) 

data BoxTypeExtension Source #

When using custom types extra data must be written after the extra size information. Since the box type and the optional custom box type are not guaranteed to be consequtive, this type handles the second part seperately.

IsBoxContent instances