-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A pure EBML parser
--
-- Pure decoder for the Extensible Binary Meta Language (EBML) format.
--
-- Use this library to parse mkv/webm file or split a webm stream
-- segments.
--
-- Checkout a motivating use-case presented in this blog post:
-- Broadcasting a WebM stream using MSE.
--
-- Read the haskell-ebml demo app for simple usage: Main.hs.
@package ebml
@version 0.1.1.0
-- | This module is intended to be imported qualified:
--
--
-- import qualified Codec.EBML as EBML
--
--
-- Decode a webm file with:
--
--
-- EBML.decodeWebMFile "path/file.webm"
--
--
-- Split a webm stream segments with:
--
--
-- let streamReader = EBML.newStreamReader
-- buf <- acquire data
-- EBML.feedReader buf streamReader
--
--
-- References:
--
--
module Codec.EBML
-- | Lazy decode a WebMDocument.
decodeWebM :: ByteString -> Either Text WebMDocument
-- | A WebM document.
data WebMDocument
WebMDocument :: Word64 -> [WebMCluster] -> WebMDocument
-- | Base unit for Segment Ticks and Track Ticks, in nanoseconds. A
-- TimestampScale of 1_000_000 means segments' timestamps are expressed
-- in milliseconds;
[$sel:timestampScale:WebMDocument] :: WebMDocument -> Word64
-- | The list of clusters.
[$sel:clusters:WebMDocument] :: WebMDocument -> [WebMCluster]
-- | A WebM cluster, e.g. a media segment.
data WebMCluster
WebMCluster :: Word64 -> [EBMLElement] -> WebMCluster
-- | Absolute timestamp of the cluster.
[$sel:timestamp:WebMCluster] :: WebMCluster -> Word64
-- | The cluster elements.
[$sel:content:WebMCluster] :: WebMCluster -> [EBMLElement]
-- | Lazy decode a EBMLDocument.
decodeEBMLDocument :: [EBMLSchema] -> ByteString -> Either Text EBMLDocument
-- | The webm document schemas.
webmSchemas :: [EBMLSchema]
-- | Create a stream reader with newStreamReader, and decode media
-- segments with feedReader.
data StreamReader
-- | Initialize a stream reader.
newStreamReader :: StreamReader
-- | A valid frame that can be served.
data StreamFrame
StreamFrame :: ByteString -> ByteString -> StreamFrame
-- | The initialization segments, to be provided before the first media
-- segment.
[$sel:initialization:StreamFrame] :: StreamFrame -> ByteString
-- | The begining of the last media segment found in the input buffer.
[$sel:media:StreamFrame] :: StreamFrame -> ByteString
-- | Feed data into a stream reader. Returns either an error, or maybe a
-- new StreamFrame and an updated StreamReader.
feedReader :: ByteString -> StreamReader -> Either Text (Maybe StreamFrame, StreamReader)
-- | EBML document structure, including the Header and Body Root.
newtype EBMLDocument
EBMLDocument :: [EBMLElement] -> EBMLDocument
-- | EBML element.
data EBMLElement
EBMLElement :: EBMLElementHeader -> EBMLValue -> EBMLElement
[$sel:header:EBMLElement] :: EBMLElement -> EBMLElementHeader
[$sel:value:EBMLElement] :: EBMLElement -> EBMLValue
-- | EBML element value.
data EBMLValue
EBMLRoot :: [EBMLElement] -> EBMLValue
EBMLSignedInteger :: Int64 -> EBMLValue
EBMLUnsignedInteger :: Word64 -> EBMLValue
EBMLFloat :: Double -> EBMLValue
EBMLText :: Text -> EBMLValue
EBMLDate :: Text -> EBMLValue
EBMLBinary :: ByteString -> EBMLValue
-- | EBML element header.
data EBMLElementHeader
EBMLElementHeader :: EBMLID -> Maybe Word64 -> EBMLElementHeader
[$sel:eid:EBMLElementHeader] :: EBMLElementHeader -> EBMLID
-- | size is Nothing for unknown-sized element.
[$sel:size:EBMLElementHeader] :: EBMLElementHeader -> Maybe Word64
-- | EBML element id.
newtype EBMLID
EBMLID :: Word32 -> EBMLID
-- | EBML schema definition.
--
-- Note that this is missing:
--
--
-- - min/max occurrence constraint.
-- - default value.
-- - element path.
--
data EBMLSchema
EBMLSchema :: Text -> EBMLID -> (EBMLSchemas -> EBMLElementHeader -> Get EBMLValue) -> EBMLSchema
-- | The element name.
[$sel:name:EBMLSchema] :: EBMLSchema -> Text
-- | The element id.
[$sel:eid:EBMLSchema] :: EBMLSchema -> EBMLID
-- | How to decode the element value.
[$sel:decode:EBMLSchema] :: EBMLSchema -> EBMLSchemas -> EBMLElementHeader -> Get EBMLValue
-- | Decode a raw EBML file.
decodeEBMLFile :: [EBMLSchema] -> FilePath -> IO (Either Text EBMLDocument)
-- | Decode a webm file.
decodeWebMFile :: FilePath -> IO (Either Text WebMDocument)
-- | Pretty-print a EBMLDocument.
prettyEBMLDocument :: [EBMLSchema] -> EBMLDocument -> Text
data EBMLSchemas
-- | Combine a list of schema for decoder.
compileSchemas :: [EBMLSchema] -> EBMLSchemas
getDocument :: EBMLSchemas -> Get EBMLDocument
getElementHeader :: Get EBMLElementHeader
getElementID :: Get EBMLID
getDataSize :: Get Word64
getElement :: EBMLSchemas -> Get EBMLElement