From: Joseph Spiros Date: Sat, 9 Apr 2011 13:18:00 +0000 (-0400) Subject: Added the ability to parse specdata XML files to create Schemas. X-Git-Url: http://git.ithinksw.org/~jspiros/python-ebml.git/commitdiff_plain/3e0006c63000d5c09a9a09657806a6046cf6009d?ds=inline;pf=~jspiros Added the ability to parse specdata XML files to create Schemas. Switched the Matroska schema definition to read from bundled matroska.xml file (renamed specdata.xml from Matroska foundation_src/spectool). --- diff --git a/ebml/schema/matroska.py b/ebml/schema/matroska.py index 9e3b690..c0fcd64 100644 --- a/ebml/schema/matroska.py +++ b/ebml/schema/matroska.py @@ -1,1590 +1,9 @@ -from .base import * +import os.path +from .specs import parse_specdata -class SegmentElement(Element): - class_id = 0x18538067 - class_name = 'Segment' - class_root = True - data_type = CONTAINER +_Elements, Matroska = parse_specdata(os.path.join(os.path.dirname(__file__), 'matroska.xml'), 'Matroska') -class SeekHeadElement(Element): - class_id = 0x114d9b74 - class_name = 'SeekHead' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class SeekElement(Element): - class_id = 0x4dbb - class_name = 'Seek' - class_parents = (SeekHeadElement,) - data_type = CONTAINER - - -class SeekIDElement(Element): - class_id = 0x53ab - class_name = 'SeekID' - class_parents = (SeekElement,) - data_type = BINARY - - -class SeekPositionElement(Element): - class_id = 0x53ac - class_name = 'SeekPosition' - class_parents = (SeekElement,) - data_type = UINT - - -class InfoElement(Element): - class_id = 0x1549a966 - class_name = 'Info' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class SegmentUIDElement(Element): - class_id = 0x73a4 - class_name = 'SegmentUID' - class_parents = (InfoElement,) - data_type = BINARY - - -class SegmentFilenameElement(Element): - class_id = 0x7384 - class_name = 'SegmentFilename' - class_parents = (InfoElement,) - data_type = UNICODE - - -class PrevUIDElement(Element): - class_id = 0x3cb923 - class_name = 'PrevUID' - class_parents = (InfoElement,) - data_type = BINARY - - -class PrevFilenameElement(Element): - class_id = 0x3c83ab - class_name = 'PrevFilename' - class_parents = (InfoElement,) - data_type = UNICODE - - -class NextUIDElement(Element): - class_id = 0x3eb923 - class_name = 'NextUID' - class_parents = (InfoElement,) - data_type = BINARY - - -class NextFilenameElement(Element): - class_id = 0x3e83bb - class_name = 'NextFilename' - class_parents = (InfoElement,) - data_type = UNICODE - - -class SegmentFamilyElement(Element): - class_id = 0x4444 - class_name = 'SegmentFamily' - class_parents = (InfoElement,) - data_type = BINARY - - -class ChapterTranslateElement(Element): - class_id = 0x6924 - class_name = 'ChapterTranslate' - class_parents = (InfoElement,) - data_type = CONTAINER - - -class ChapterTranslateEditionUIDElement(Element): - class_id = 0x69FC - class_name = 'ChapterTranslateEditionUID' - class_parents = (ChapterTranslateElement,) - data_type = UINT - - -class ChapterTranslateCodecElement(Element): - class_id = 0x69bf - class_name = 'ChapterTranslateCodec' - class_parents = (ChapterTranslateElement,) - data_type = UINT - - -class ChapterTranslateIDElement(Element): - class_id = 0x69a5 - class_name = 'ChapterTranslateID' - class_parents = (ChapterTranslateElement,) - data_type = BINARY - - -class TimecodeScaleElement(Element): - class_id = 0x2ad7b1 - class_name = 'TimecodeScale' - class_parents = (InfoElement,) - data_type = UINT - - -class DurationElement(Element): - class_id = 0x4489 - class_name = 'Duration' - class_parents = (InfoElement,) - data_type = FLOAT - - -class DateUTCElement(Element): - class_id = 0x4461 - class_name = 'DateUTC' - class_parents = (InfoElement,) - data_type = DATE - - -class TitleElement(Element): - class_id = 0x7ba9 - class_name = 'Title' - class_parents = (InfoElement,) - data_type = UNICODE - - -class MuxingAppElement(Element): - class_id = 0x4d80 - class_name = 'MuxingApp' - class_parents = (InfoElement,) - data_type = UNICODE - - -class WritingAppElement(Element): - class_id = 0x5741 - class_name = 'WritingApp' - class_parents = (InfoElement,) - data_type = UNICODE - - -class ClusterElement(Element): - class_id = 0x1f43b675 - class_name = 'Cluster' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class TimecodeElement(Element): - class_id = 0xe7 - class_name = 'Timecode' - class_parents = (ClusterElement,) - data_type = UINT - - -class SilentTracksElement(Element): - class_id = 0x5854 - class_name = 'SilentTracks' - class_parents = (ClusterElement,) - data_type = CONTAINER - - -class SilentTrackNumberElement(Element): - class_id = 0x58d7 - class_name = 'SilentTrackNumber' - class_parents = (SilentTracksElement,) - data_type = UINT - - -class PositionElement(Element): - class_id = 0xa7 - class_name = 'Position' - class_parents = (ClusterElement,) - data_type = UINT - - -class PrevSizeElement(Element): - class_id = 0xab - class_name = 'PrevSize' - class_parents = (ClusterElement,) - data_type = UINT - - -class SimpleBlockElement(Element): - class_id = 0xa3 - class_name = 'SimpleBlock' - class_parents = (ClusterElement,) - data_type = BINARY - - -class BlockGroupElement(Element): - class_id = 0xa0 - class_name = 'BlockGroup' - class_parents = (ClusterElement,) - data_type = CONTAINER - - -class BlockElement(Element): - class_id = 0xa1 - class_name = 'Block' - class_parents = (BlockGroupElement,) - data_type = BINARY - - -class BlockVirtualElement(Element): - class_id = 0xa2 - class_name = 'BlockVirtual' - class_parents = (BlockGroupElement,) - data_type = BINARY - - -class BlockAdditionsElement(Element): - class_id = 0x75a1 - class_name = 'BlockAdditions' - class_parents = (BlockGroupElement,) - data_type = CONTAINER - - -class BlockMoreElement(Element): - class_id = 0xa6 - class_name = 'BlockMore' - class_parents = (BlockAdditionsElement,) - data_type = CONTAINER - - -class BlockAddIDElement(Element): - class_id = 0xee - class_name = 'BlockAddID' - class_parents = (BlockMoreElement,) - data_type = UINT - - -class BlockAdditionalElement(Element): - class_id = 0xa5 - class_name = 'BlockAdditional' - class_parents = (BlockMoreElement,) - data_type = BINARY - - -class BlockDurationElement(Element): - class_id = 0x9b - class_name = 'BlockDuration' - class_parents = (BlockGroupElement,) - data_type = UINT - - -class ReferencePriorityElement(Element): - class_id = 0xfa - class_name = 'ReferencePriority' - class_parents = (BlockGroupElement,) - data_type = UINT - - -class ReferenceBlockElement(Element): - class_id = 0xfb - class_name = 'ReferenceBlock' - class_parents = (BlockGroupElement,) - data_type = INT - - -class ReferenceVirtualElement(Element): - class_id = 0xfd - class_name = 'ReferenceVirtual' - class_parents = (BlockGroupElement,) - data_type = INT - - -class CodecStateElement(Element): - class_id = 0xa4 - class_name = 'CodecState' - class_parents = (BlockGroupElement,) - data_type = BINARY - - -class SlicesElement(Element): - class_id = 0x8e - class_name = 'Slices' - class_parents = (BlockGroupElement,) - data_type = CONTAINER - - -class TimeSliceElement(Element): - class_id = 0xe8 - class_name = 'TimeSlice' - class_parents = (SlicesElement,) - data_type = CONTAINER - - -class LaceNumberElement(Element): - class_id = 0xcc - class_name = 'LaceNumber' - class_parents = (TimeSliceElement,) - data_type = UINT - - -class FrameNumberElement(Element): - class_id = 0xcd - class_name = 'FrameNumber' - class_parents = (TimeSliceElement,) - data_type = UINT - - -class BlockAdditionIDElement(Element): - class_id = 0xcb - class_name = 'BlockAdditionID' - class_parents = (TimeSliceElement,) - data_type = UINT - - -class DelayElement(Element): - class_id = 0xce - class_name = 'Delay' - class_parents = (TimeSliceElement,) - data_type = UINT - - -class SliceDurationElement(Element): - class_id = 0xcf - class_name = 'SliceDuration' - class_parents = (TimeSliceElement,) - data_type = UINT - - -class ReferenceFrameElement(Element): - class_id = 0xc8 - class_name = 'ReferenceFrame' - class_parents = (BlockGroupElement,) - data_type = CONTAINER - - -class ReferenceOffsetElement(Element): - class_id = 0xc9 - class_name = 'ReferenceOffset' - class_parents = (ReferenceFrameElement,) - data_type = UINT - - -class ReferenceTimeCodeElement(Element): - class_id = 0xca - class_name = 'ReferenceTimeCode' - class_parents = (ReferenceFrameElement,) - data_type = UINT - - -class EncryptedBlockElement(Element): - class_id = 0xaf - class_name = 'EncryptedBlock' - class_parents = (ClusterElement,) - data_type = BINARY - - -class TracksElement(Element): - class_id = 0x1654ae6b - class_name = 'Tracks' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class TrackEntryElement(Element): - class_id = 0xae - class_name = 'TrackEntry' - class_parents = (TracksElement,) - data_type = CONTAINER - - -class TrackNumberElement(Element): - class_id = 0xd7 - class_name = 'TrackNumber' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrackUIDElement(Element): - class_id = 0x73c5 - class_name = 'TrackUID' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrackTypeElement(Element): - class_id = 0x83 - class_name = 'TrackType' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class FlagEnabledElement(Element): - class_id = 0xb9 - class_name = 'FlagEnabled' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class FlagDefaultElement(Element): - class_id = 0x88 - class_name = 'FlagDefault' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class FlagForcedElement(Element): - class_id = 0x55aa - class_name = 'FlagForced' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class FlagLacingElement(Element): - class_id = 0x9c - class_name = 'FlagLacing' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class MinCacheElement(Element): - class_id = 0x6de7 - class_name = 'MinCache' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class MaxCacheElement(Element): - class_id = 0x6df8 - class_name = 'MaxCache' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class DefaultDurationElement(Element): - class_id = 0x23e383 - class_name = 'DefaultDuration' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrackTimecodeScaleElement(Element): - class_id = 0x23314f - class_name = 'TrackTimecodeScale' - class_parents = (TrackEntryElement,) - data_type = FLOAT - - -class TrackOffsetElement(Element): - class_id = 0x537F - class_name = 'TrackOffset' - class_parents = (TrackEntryElement,) - data_type = INT - - -class MaxBlockAdditionIDElement(Element): - class_id = 0x55EE - class_name = 'MaxBlockAdditionID' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class NameElement(Element): - class_id = 0x536E - class_name = 'Name' - class_parents = (TrackEntryElement,) - data_type = UNICODE - - -class LanguageElement(Element): - class_id = 0x22B59C - class_name = 'Language' - class_parents = (TrackEntryElement,) - data_type = STRING - - -class CodecIDElement(Element): - class_id = 0x86 - class_name = 'CodecID' - class_parents = (TrackEntryElement,) - data_type = STRING - - -class CodecPrivateElement(Element): - class_id = 0x63A2 - class_name = 'CodecPrivate' - class_parents = (TrackEntryElement,) - data_type = BINARY - - -class CodecNameElement(Element): - class_id = 0x258688 - class_name = 'CodecName' - class_parents = (TrackEntryElement,) - data_type = UNICODE - - -class AttachmentLinkElement(Element): - class_id = 0x7446 - class_name = 'AttachmentLink' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class CodecSettingsElement(Element): - class_id = 0x3A9697 - class_name = 'CodecSettings' - class_parents = (TrackEntryElement,) - data_type = UNICODE - - -class CodecInfoURLElement(Element): - class_id = 0x3B4040 - class_name = 'CodecInfoURL' - class_parents = (TrackEntryElement,) - data_type = STRING - - -class CodecDownloadURLElement(Element): - class_id = 0x26B240 - class_name = 'CodecDownloadURL' - class_parents = (TrackEntryElement,) - data_type = STRING - - -class CodecDecodeAllElement(Element): - class_id = 0xAA - class_name = 'CodecDecodeAll' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrackOverlayElement(Element): - class_id = 0x6FAB - class_name = 'TrackOverlay' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrackTranslateElement(Element): - class_id = 0x6624 - class_name = 'TrackTranslate' - class_parents = (TrackEntryElement,) - data_type = CONTAINER - - -class TrackTranslateEditionUIDElement(Element): - class_id = 0x66FC - class_name = 'TrackTranslateEditionUID' - class_parents = (TrackTranslateElement,) - data_type = UINT - - -class TrackTranslateCodecElement(Element): - class_id = 0x66BF - class_name = 'TrackTranslateCodec' - class_parents = (TrackTranslateElement,) - data_type = UINT - - -class TrackTranslateTrackIDElement(Element): - class_id = 0x66A5 - class_name = 'TrackTranslateTrackID' - class_parents = (TrackTranslateElement,) - data_type = BINARY - - -class VideoElement(Element): - class_id = 0xE0 - class_name = 'Video' - class_parents = (TrackEntryElement,) - data_type = CONTAINER - - -class FlagInterlacedElement(Element): - class_id = 0x9A - class_name = 'FlagInterlaced' - class_parents = (VideoElement,) - data_type = UINT - - -class StereoModeElement(Element): - class_id = 0x53B8 - class_name = 'StereoMode' - class_parents = (VideoElement,) - data_type = UINT - - -class OldStereoModeElement(Element): - class_id = 0x53B9 - class_name = 'OldStereoMode' - class_parents = (VideoElement,) - data_type = UINT - - -class PixelWidthElement(Element): - class_id = 0xB0 - class_name = 'PixelWidth' - class_parents = (VideoElement,) - data_type = UINT - - -class PixelHeightElement(Element): - class_id = 0xBA - class_name = 'PixelHeight' - class_parents = (VideoElement,) - data_type = UINT - - -class PixelCropBottomElement(Element): - class_id = 0x54AA - class_name = 'PixelCropBottom' - class_parents = (VideoElement,) - data_type = UINT - - -class PixelCropTopElement(Element): - class_id = 0x54BB - class_name = 'PixelCropTop' - class_parents = (VideoElement,) - data_type = UINT - - -class PixelCropLeftElement(Element): - class_id = 0x54CC - class_name = 'PixelCropLeft' - class_parents = (VideoElement,) - data_type = UINT - - -class PixelCropRightElement(Element): - class_id = 0x54DD - class_name = 'PixelCropRight' - class_parents = (VideoElement,) - data_type = UINT - - -class DisplayWidthElement(Element): - class_id = 0x54B0 - class_name = 'DisplayWidth' - class_parents = (VideoElement,) - data_type = UINT - - -class DisplayHeightElement(Element): - class_id = 0x54BA - class_name = 'DisplayHeight' - class_parents = (VideoElement,) - data_type = UINT - - -class DisplayUnitElement(Element): - class_id = 0x54B2 - class_name = 'DisplayUnit' - class_parents = (VideoElement,) - data_type = UINT - - -class AspectRatioTypeElement(Element): - class_id = 0x54B3 - class_name = 'AspectRatioType' - class_parents = (VideoElement,) - data_type = UINT - - -class ColourSpaceElement(Element): - class_id = 0x2EB524 - class_name = 'ColourSpace' - class_parents = (VideoElement,) - data_type = BINARY - - -class GammaValueElement(Element): - class_id = 0x2FB523 - class_name = 'GammaValue' - class_parents = (VideoElement,) - data_type = FLOAT - - -class FrameRateElement(Element): - class_id = 0x2383E3 - class_name = 'FrameRate' - class_parents = (VideoElement,) - data_type = FLOAT - - -class AudioElement(Element): - class_id = 0xE1 - class_name = 'Audio' - class_parents = (TrackEntryElement,) - data_type = CONTAINER - - -class SamplingFrequencyElement(Element): - class_id = 0xB5 - class_name = 'SamplingFrequency' - class_parents = (AudioElement,) - data_type = FLOAT - - -class OutputSamplingFrequencyElement(Element): - class_id = 0x78B5 - class_name = 'OutputSamplingFrequency' - class_parents = (AudioElement,) - data_type = FLOAT - - -class ChannelsElement(Element): - class_id = 0x9F - class_name = 'Channels' - class_parents = (AudioElement,) - data_type = UINT - - -class ChannelPositionsElement(Element): - class_id = 0x7D7B - class_name = 'ChannelPositions' - class_parents = (AudioElement,) - data_type = BINARY - - -class BitDepthElement(Element): - class_id = 0x6264 - class_name = 'BitDepth' - class_parents = (AudioElement,) - data_type = UINT - - -class TrackOperationElement(Element): - class_id = 0xE2 - class_name = 'TrackOperation' - class_parents = (TrackEntryElement,) - data_type = CONTAINER - - -class TrackCombinePlanesElement(Element): - class_id = 0xE3 - class_name = 'TrackCombinePlanes' - class_parents = (TrackOperationElement,) - data_type = CONTAINER - - -class TrackPlaneElement(Element): - class_id = 0xE4 - class_name = 'TrackPlane' - class_parents = (TrackCombinePlanesElement,) - data_type = CONTAINER - - -class TrackPlaneUIDElement(Element): - class_id = 0xE5 - class_name = 'TrackPlaneUID' - class_parents = (TrackPlaneElement,) - data_type = UINT - - -class TrackPlaneTypeElement(Element): - class_id = 0xE6 - class_name = 'TrackPlaneType' - class_parents = (TrackPlaneElement,) - data_type = UINT - - -class TrackJoinBlocksElement(Element): - class_id = 0xE9 - class_name = 'TrackJoinBlocks' - class_parents = (TrackOperationElement,) - data_type = CONTAINER - - -class TrackJoinUIDElement(Element): - class_id = 0xED - class_name = 'TrackJoinUID' - class_parents = (TrackJoinBlocksElement,) - data_type = UINT - - -class TrickTrackUIDElement(Element): - class_id = 0xC0 - class_name = 'TrickTrackUID' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrickTrackSegmentUIDElement(Element): - class_id = 0xC1 - class_name = 'TrickTrackSegmentUID' - class_parents = (TrackEntryElement,) - data_type = BINARY - - -class TrickTrackFlagElement(Element): - class_id = 0xC6 - class_name = 'TrickTrackFlag' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrickMasterTrackUIDElement(Element): - class_id = 0xC7 - class_name = 'TrickMasterTrackUID' - class_parents = (TrackEntryElement,) - data_type = UINT - - -class TrickMasterTrackSegmentUIDElement(Element): - class_id = 0xC4 - class_name = 'TrickMasterTrackSegmentUID' - class_parents = (TrackEntryElement,) - data_type = BINARY - - -class ContentEncodingsElement(Element): - class_id = 0x6D80 - class_name = 'ContentEncodings' - class_parents = (TrackEntryElement,) - data_type = CONTAINER - - -class ContentEncodingElement(Element): - class_id = 0x6240 - class_name = 'ContentEncoding' - class_parents = (ContentEncodingsElement,) - data_type = CONTAINER - - -class ContentEncodingOrderElement(Element): - class_id = 0x5031 - class_name = 'ContentEncodingOrder' - class_parents = (ContentEncodingElement,) - data_type = UINT - - -class ContentEncodingScopeElement(Element): - class_id = 0x5032 - class_name = 'ContentEncodingScope' - class_parents = (ContentEncodingElement,) - data_type = UINT - - -class ContentEncodingTypeElement(Element): - class_id = 0x5033 - class_name = 'ContentEncodingType' - class_parents = (ContentEncodingElement,) - data_type = UINT - - -class ContentCompressionElement(Element): - class_id = 0x5034 - class_name = 'ContentCompression' - class_parents = (ContentEncodingElement,) - data_type = CONTAINER - - -class ContentCompAlgoElement(Element): - class_id = 0x4254 - class_name = 'ContentCompAlgo' - class_parents = (ContentCompressionElement,) - data_type = UINT - - -class ContentCompSettingsElement(Element): - class_id = 0x4255 - class_name = 'ContentCompSettings' - class_parents = (ContentCompressionElement,) - data_type = BINARY - - -class ContentEncryptionElement(Element): - class_id = 0x5035 - class_name = 'ContentEncryption' - class_parents = (ContentEncodingElement,) - data_type = CONTAINER - - -class ContentEncAlgoElement(Element): - class_id = 0x47E1 - class_name = 'ContentEncAlgo' - class_parents = (ContentEncryptionElement,) - data_type = UINT - - -class ContentEncKeyIDElement(Element): - class_id = 0x47E2 - class_name = 'ContentEncKeyID' - class_parents = (ContentEncryptionElement,) - data_type = BINARY - - -class ContentSignatureElement(Element): - class_id = 0x47E3 - class_name = 'ContentSignature' - class_parents = (ContentEncryptionElement,) - data_type = BINARY - - -class ContentSigKeyIDElement(Element): - class_id = 0x47E4 - class_name = 'ContentSigKeyID' - class_parents = (ContentEncryptionElement,) - data_type = BINARY - - -class ContentSigAlgoElement(Element): - class_id = 0x47E5 - class_name = 'ContentSigAlgo' - class_parents = (ContentEncryptionElement,) - data_type = UINT - - -class ContentSigHashAlgoElement(Element): - class_id = 0x47E6 - class_name = 'ContentSigHashAlgo' - class_parents = (ContentEncryptionElement,) - data_type = UINT - - -class CuesElement(Element): - class_id = 0x1c53bb6b - class_name = 'Cues' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class CuePointElement(Element): - class_id = 0xbb - class_name = 'CuePoint' - class_parents = (CuesElement,) - data_type = CONTAINER - - -class CueTimeElement(Element): - class_id = 0xb3 - class_name = 'CueTime' - class_parents = (CuePointElement,) - data_type = UINT - - -class CueTrackPositionsElement(Element): - class_id = 0xb7 - class_name = 'CueTrackPositions' - class_parents = (CuePointElement,) - data_type = CONTAINER - - -class CueTrackElement(Element): - class_id = 0xf7 - class_name = 'CueTrack' - class_parents = (CueTrackPositionsElement,) - data_type = UINT - - -class CueClusterPositionElement(Element): - class_id = 0xf1 - class_name = 'CueClusterPosition' - class_parents = (CueTrackPositionsElement,) - data_type = UINT - - -class CueBlockNumberElement(Element): - class_id = 0x5378 - class_name = 'CueBlockNumber' - class_parents = (CueTrackPositionsElement,) - data_type = UINT - - -class CueCodecStateElement(Element): - class_id = 0xea - class_name = 'CueCodecState' - class_parents = (CueTrackPositionsElement,) - data_type = UINT - - -class CueReferenceElement(Element): - class_id = 0xdb - class_name = 'CueReference' - class_parents = (CueTrackPositionsElement,) - data_type = CONTAINER - - -class CueRefTimeElement(Element): - class_id = 0x96 - class_name = 'CueRefTime' - class_parents = (CueReferenceElement,) - data_type = UINT - - -class CueRefClusterElement(Element): - class_id = 0x97 - class_name = 'CueRefCluster' - class_parents = (CueReferenceElement,) - data_type = UINT - - -class CueRefNumberElement(Element): - class_id = 0x535f - class_name = 'CueRefNumber' - class_parents = (CueReferenceElement,) - data_type = UINT - - -class CueRefCodecStateElement(Element): - class_id = 0xeb - class_name = 'CueRefCodecState' - class_parents = (CueReferenceElement,) - data_type = UINT - - -class AttachmentsElement(Element): - class_id = 0x1941a469 - class_name = 'Attachments' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class AttachedFileElement(Element): - class_id = 0x61a7 - class_name = 'AttachedFile' - class_parents = (AttachmentsElement,) - data_type = CONTAINER - - -class FileDescriptionElement(Element): - class_id = 0x467e - class_name = 'FileDescription' - class_parents = (AttachedFileElement,) - data_type = UNICODE - - -class FileNameElement(Element): - class_id = 0x466e - class_name = 'FileName' - class_parents = (AttachedFileElement,) - data_type = UNICODE - - -class FileMimeTypeElement(Element): - class_id = 0x4660 - class_name = 'FileMimeType' - class_parents = (AttachedFileElement,) - data_type = STRING - - -class FileDataElement(Element): - class_id = 0x465c - class_name = 'FileData' - class_parents = (AttachedFileElement,) - data_type = BINARY - - -class FileUIDElement(Element): - class_id = 0x46ae - class_name = 'FileUID' - class_parents = (AttachedFileElement,) - data_type = UINT - - -class FileReferralElement(Element): - class_id = 0x4675 - class_name = 'FileReferral' - class_parents = (AttachedFileElement,) - data_type = BINARY - - -class FileUsedStartTimeElement(Element): - class_id = 0x4661 - class_name = 'FileUsedStartTime' - class_parents = (AttachedFileElement,) - data_type = UINT - - -class FileUsedEndTimeElement(Element): - class_id = 0x4662 - class_name = 'FileUsedEndTime' - class_parents = (AttachedFileElement,) - data_type = UINT - - -class ChaptersElement(Element): - class_id = 0x1043a770 - class_name = 'Chapters' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class EditionEntryElement(Element): - class_id = 0x45b9 - class_name = 'EditionEntry' - class_parents = (ChaptersElement,) - data_type = CONTAINER - - -class EditionUIDElement(Element): - class_id = 0x45bc - class_name = 'EditionUID' - class_parents = (EditionEntryElement,) - data_type = UINT - - -class EditionFlagHiddenElement(Element): - class_id = 0x45bd - class_name = 'EditionFlagHidden' - class_parents = (EditionEntryElement,) - data_type = UINT - - -class EditionFlagDefaultElement(Element): - class_id = 0x45db - class_name = 'EditionFlagDefault' - class_parents = (EditionEntryElement,) - data_type = UINT - - -class EditionFlagOrderedElement(Element): - class_id = 0x45dd - class_name = 'EditionFlagOrdered' - class_parents = (EditionEntryElement,) - data_type = UINT - - -class ChapterAtomElement(Element): - class_id = 0xb6 - class_name = 'ChapterAtom' - class_parents = (EditionEntryElement, 'self') - data_type = CONTAINER - - -class ChapterUIDElement(Element): - class_id = 0x73c4 - class_name = 'ChapterUID' - class_parents = (ChapterAtomElement,) - data_type = UINT - - -class ChapterTimeStartElement(Element): - class_id = 0x91 - class_name = 'ChapterTimeStart' - class_parents = (ChapterAtomElement,) - data_type = UINT - - -class ChapterTimeEndElement(Element): - class_id = 0x92 - class_name = 'ChapterTimeEnd' - class_parents = (ChapterAtomElement,) - data_type = UINT - - -class ChapterFlagHiddenElement(Element): - class_id = 0x98 - class_name = 'ChapterFlagHidden' - class_parents = (ChapterAtomElement,) - data_type = UINT - - -class ChapterFlagEnabledElement(Element): - class_id = 0x4598 - class_name = 'ChapterFlagEnabled' - class_parents = (ChapterAtomElement,) - data_type = UINT - - -class ChapterSegmentUIDElement(Element): - class_id = 0x6e67 - class_name = 'ChapterSegmentUID' - class_parents = (ChapterAtomElement,) - data_type = BINARY - - -class ChapterSegmentEditionUIDElement(Element): - class_id = 0x6ebc - class_name = 'ChapterSegmentEditionUID' - class_parents = (ChapterAtomElement,) - data_type = BINARY - - -class ChapterPhysicalEquivElement(Element): - class_id = 0x63c3 - class_name = 'ChapterPhysicalEquiv' - class_parents = (ChapterAtomElement,) - data_type = UINT - - -class ChapterTrackElement(Element): - class_id = 0x8f - class_name = 'ChapterTrack' - class_parents = (ChapterAtomElement,) - data_type = CONTAINER - - -class ChapterTrackNumberElement(Element): - class_id = 0x89 - class_name = 'ChapterTrackNumber' - class_parents = (ChapterTrackElement,) - data_type = UINT - - -class ChapterDisplayElement(Element): - class_id = 0x80 - class_name = 'ChapterDisplay' - class_parents = (ChapterAtomElement,) - data_type = CONTAINER - - -class ChapStringElement(Element): - class_id = 0x85 - class_name = 'ChapString' - class_parents = (ChapterDisplayElement,) - data_type = UNICODE - - -class ChapLanguageElement(Element): - class_id = 0x437c - class_name = 'ChapLanguage' - class_parents = (ChapterDisplayElement,) - data_type = STRING - - -class ChapCountryElement(Element): - class_id = 0x437e - class_name = 'ChapCountry' - class_parents = (ChapterDisplayElement,) - data_type = STRING - - -class ChapProcessElement(Element): - class_id = 0x6944 - class_name = 'ChapProcess' - class_parents = (ChapterAtomElement,) - data_type = CONTAINER - - -class ChapProcessCodecIDElement(Element): - class_id = 0x6955 - class_name = 'ChapProcessCodecID' - class_parents = (ChapProcessElement,) - data_type = UINT - - -class ChapProcessPrivateElement(Element): - class_id = 0x450d - class_name = 'ChapProcessPrivate' - class_parents = (ChapProcessElement,) - data_type = BINARY - - -class ChapProcessCommandElement(Element): - class_id = 0x6911 - class_name = 'ChapProcessCommand' - class_parents = (ChapProcessElement,) - data_type = CONTAINER - - -class ChapProcessTimeElement(Element): - class_id = 0x6922 - class_name = 'ChapProcessTime' - class_parents = (ChapProcessCommandElement,) - data_type = UINT - - -class ChapProcessDataElement(Element): - class_id = 0x6933 - class_name = 'ChapProcessData' - class_parents = (ChapProcessCommandElement,) - data_type = BINARY - - -class TagsElement(Element): - class_id = 0x1254c367 - class_name = 'Tags' - class_parents = (SegmentElement,) - data_type = CONTAINER - - -class TagElement(Element): - class_id = 0x7373 - class_name = 'Tag' - class_parents = (TagsElement,) - data_type = CONTAINER - - -class TargetsElement(Element): - class_id = 0x63c0 - class_name = 'Targets' - class_parents = (TagElement,) - data_type = CONTAINER - - -class TargetTypeValueElement(Element): - class_id = 0x68ca - class_name = 'TargetTypeValue' - class_parents = (TargetsElement,) - data_type = UINT - - -class TargetTypeElement(Element): - class_id = 0x63ca - class_name = 'TargetType' - class_parents = (TargetsElement,) - data_type = STRING - - -class TagTrackUIDElement(Element): - class_id = 0x63c5 - class_name = 'TagTrackUID' - class_parents = (TargetsElement,) - data_type = UINT - - -class TagEditionUIDElement(Element): - class_id = 0x63c9 - class_name = 'TagEditionUID' - class_parents = (TargetsElement,) - data_type = UINT - - -class TagChapterUIDElement(Element): - class_id = 0x63c4 - class_name = 'TagChapterUID' - class_parents = (TargetsElement,) - data_type = UINT - - -class TagAttachmentUIDElement(Element): - class_id = 0x63c6 - class_name = 'TagAttachmentUID' - class_parents = (TargetsElement,) - data_type = UINT - - -class SimpleTagElement(Element): - class_id = 0x67c8 - class_name = 'SimpleTag' - class_parents = (TagElement, 'self') - data_type = CONTAINER - - -class TagNameElement(Element): - class_id = 0x45a3 - class_name = 'TagName' - class_parents = (SimpleTagElement,) - data_type = UNICODE - - -class TagLanguageElement(Element): - class_id = 0x447a - class_name = 'TagLanguage' - class_parents = (SimpleTagElement,) - data_type = STRING - - -class TagDefaultElement(Element): - class_id = 0x4484 - class_name = 'TagDefault' - class_parents = (SimpleTagElement,) - data_type = UINT - - -class TagStringElement(Element): - class_id = 0x4487 - class_name = 'TagString' - class_parents = (SimpleTagElement,) - data_type = UNICODE - - -class TagBinaryElement(Element): - class_id = 0x4485 - class_name = 'TagBinary' - class_parents = (SimpleTagElement,) - data_type = BINARY - - -class Matroska(EBML): - elements = EBML.elements + ( - SegmentElement, - SeekHeadElement, - SeekElement, - SeekIDElement, - SeekPositionElement, - InfoElement, - SegmentUIDElement, - SegmentFilenameElement, - PrevUIDElement, - PrevFilenameElement, - NextUIDElement, - NextFilenameElement, - SegmentFamilyElement, - ChapterTranslateElement, - ChapterTranslateEditionUIDElement, - ChapterTranslateCodecElement, - ChapterTranslateIDElement, - TimecodeScaleElement, - DurationElement, - DateUTCElement, - TitleElement, - MuxingAppElement, - WritingAppElement, - ClusterElement, - TimecodeElement, - SilentTracksElement, - SilentTrackNumberElement, - PositionElement, - PrevSizeElement, - SimpleBlockElement, - BlockGroupElement, - BlockElement, - BlockVirtualElement, - BlockAdditionsElement, - BlockMoreElement, - BlockAddIDElement, - BlockAdditionalElement, - BlockDurationElement, - ReferencePriorityElement, - ReferenceBlockElement, - ReferenceVirtualElement, - CodecStateElement, - SlicesElement, - TimeSliceElement, - LaceNumberElement, - FrameNumberElement, - BlockAdditionIDElement, - DelayElement, - SliceDurationElement, - ReferenceFrameElement, - ReferenceOffsetElement, - ReferenceTimeCodeElement, - EncryptedBlockElement, - TracksElement, - TrackEntryElement, - TrackNumberElement, - TrackUIDElement, - TrackTypeElement, - FlagEnabledElement, - FlagDefaultElement, - FlagForcedElement, - FlagLacingElement, - MinCacheElement, - MaxCacheElement, - DefaultDurationElement, - TrackTimecodeScaleElement, - TrackOffsetElement, - MaxBlockAdditionIDElement, - NameElement, - LanguageElement, - CodecIDElement, - CodecPrivateElement, - CodecNameElement, - AttachmentLinkElement, - CodecSettingsElement, - CodecInfoURLElement, - CodecDownloadURLElement, - CodecDecodeAllElement, - TrackOverlayElement, - TrackTranslateElement, - TrackTranslateEditionUIDElement, - TrackTranslateCodecElement, - TrackTranslateTrackIDElement, - VideoElement, - FlagInterlacedElement, - StereoModeElement, - OldStereoModeElement, - PixelWidthElement, - PixelHeightElement, - PixelCropBottomElement, - PixelCropTopElement, - PixelCropLeftElement, - PixelCropRightElement, - DisplayWidthElement, - DisplayHeightElement, - DisplayUnitElement, - AspectRatioTypeElement, - ColourSpaceElement, - GammaValueElement, - FrameRateElement, - AudioElement, - SamplingFrequencyElement, - OutputSamplingFrequencyElement, - ChannelsElement, - ChannelPositionsElement, - BitDepthElement, - TrackOperationElement, - TrackCombinePlanesElement, - TrackPlaneElement, - TrackPlaneUIDElement, - TrackPlaneTypeElement, - TrackJoinBlocksElement, - TrackJoinUIDElement, - TrickTrackUIDElement, - TrickTrackSegmentUIDElement, - TrickTrackFlagElement, - TrickMasterTrackUIDElement, - TrickMasterTrackSegmentUIDElement, - ContentEncodingsElement, - ContentEncodingElement, - ContentEncodingOrderElement, - ContentEncodingScopeElement, - ContentEncodingTypeElement, - ContentCompressionElement, - ContentCompAlgoElement, - ContentCompSettingsElement, - ContentEncryptionElement, - ContentEncAlgoElement, - ContentEncKeyIDElement, - ContentSignatureElement, - ContentSigKeyIDElement, - ContentSigAlgoElement, - ContentSigHashAlgoElement, - CuesElement, - CuePointElement, - CueTimeElement, - CueTrackPositionsElement, - CueTrackElement, - CueClusterPositionElement, - CueBlockNumberElement, - CueCodecStateElement, - CueReferenceElement, - CueRefTimeElement, - CueRefClusterElement, - CueRefNumberElement, - CueRefCodecStateElement, - AttachmentsElement, - AttachedFileElement, - FileDescriptionElement, - FileNameElement, - FileMimeTypeElement, - FileDataElement, - FileUIDElement, - FileReferralElement, - FileUsedStartTimeElement, - FileUsedEndTimeElement, - ChaptersElement, - EditionEntryElement, - EditionUIDElement, - EditionFlagHiddenElement, - EditionFlagDefaultElement, - EditionFlagOrderedElement, - ChapterAtomElement, - ChapterUIDElement, - ChapterTimeStartElement, - ChapterTimeEndElement, - ChapterFlagHiddenElement, - ChapterFlagEnabledElement, - ChapterSegmentUIDElement, - ChapterSegmentEditionUIDElement, - ChapterPhysicalEquivElement, - ChapterTrackElement, - ChapterTrackNumberElement, - ChapterDisplayElement, - ChapStringElement, - ChapLanguageElement, - ChapCountryElement, - ChapProcessElement, - ChapProcessCodecIDElement, - ChapProcessPrivateElement, - ChapProcessCommandElement, - ChapProcessTimeElement, - ChapProcessDataElement, - TagsElement, - TagElement, - TargetsElement, - TargetTypeValueElement, - TargetTypeElement, - TagTrackUIDElement, - TagEditionUIDElement, - TagChapterUIDElement, - TagAttachmentUIDElement, - SimpleTagElement, - TagNameElement, - TagLanguageElement, - TagDefaultElement, - TagStringElement, - TagBinaryElement - ) \ No newline at end of file +for name, element in _Elements.iteritems(): + globals()[name] = element \ No newline at end of file diff --git a/ebml/schema/matroska.xml b/ebml/schema/matroska.xml new file mode 100644 index 0000000..3243769 --- /dev/null +++ b/ebml/schema/matroska.xml @@ -0,0 +1,219 @@ + + + Set the EBML characteristics of the data to follow. Each EBML document has to start with this. + The version of EBML parser used to create the file. + The minimum EBML version a parser has to support to read this file. + The maximum length of the IDs you'll find in this file (4 or less in Matroska). + The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid. + A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files. + The version of DocType interpreter used to create the file. + The minimum DocType version an interpreter has to support to read this file. + Used to void damaged data, to avoid unexpected behaviors when using damaged data. The content is discarded. Also used to reserve space in a sub-element for later use. + The CRC is computed on all the data of the Master element it's in. The CRC element should be the first in it's parent master for easier reading. All level 1 elements should include a CRC-32. The CRC in use is the IEEE CRC32 Little Endian + Contain signature of some (coming) elements in the stream. + Signature algorithm used (1=RSA, 2=elliptic). + Hash algorithm used (1=SHA1-160, 2=MD5). + The public key to use with the algorithm (in the case of a PKI-based signature). + The signature of the data (until a new. + Contains elements that will be used to compute the signature. + A list consists of a number of consecutive elements that represent one case where data is used in signature. Ex: Cluster|Block|BlockAdditional means that the BlockAdditional of all Blocks in all Clusters is used for encryption. + An element ID whose data will be used to compute the signature. + This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment. + Contains the position of other level 1 elements. + Contains a single seek entry to an EBML element. + The binary ID corresponding to the element name. + The position of the element in the segment in octets (0 = first level 1 element). + Contains miscellaneous general information and statistics on the file. + A randomly generated unique ID to identify the current segment between many others (128 bits). + A filename corresponding to this segment. + A unique ID to identify the previous chained segment (128 bits). + An escaped filename corresponding to the previous segment. + A unique ID to identify the next chained segment (128 bits). + An escaped filename corresponding to the next segment. + A randomly generated unique ID that all segments related to each other must use (128 bits). + A tuple of corresponding ID used by chapter codecs to represent this segment. + Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment. + The chapter codec using this ID (0: Matroska Script, 1: DVD-menu). + The binary value used to represent this segment in the chapter codec data. The format depends on the ChapProcessCodecID used. + Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds). + Duration of the segment (based on TimecodeScale). + Date of the origin of timecode (value 0), i.e. production date. + General name of the segment. + Muxing application or library ("libmatroska-0.4.3"). + Writing application ("mkvmerge-0.3.3"). + The lower level element containing the (monolithic) Block structure. + Absolute timecode of the cluster (based on TimecodeScale). + The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use. + One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster. + The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams. + Size of the previous Cluster, in octets. Can be useful for backward playing. + Similar to Block but without all the extra information, mostly used to reduced overhead when no extra feature is needed. (see SimpleBlock Structure) + Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock. + Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode. (see Block Structure) + A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual) + Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data. + Contain the BlockAdditional and some parameters. + An ID to identify the BlockAdditional level. + Interpreted by the codec as it wishes (using the BlockAddID). + The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track. When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. + This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced. + Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to. + Relative position of the data that should be in position of the virtual block. + The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry. + Contains slices description. + Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback. + The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback. + The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame). + The ID of the BlockAdditional element (0 is the main Block). + The (scaled) delay to apply to the element. + The (scaled) duration to apply to the element. + DivX trick track extenstions + DivX trick track extenstions + DivX trick track extenstions + Similar to SimpleBlock but the data inside the Block are Transformed (encrypt and/or signed). (see EncryptedBlock Structure) + A top-level block of information with many tracks described. + Describes a track with all elements. + The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number). + A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file. + A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control). + Set if the track is used. (1 bit) + Set if that track (audio, video or subs) SHOULD be used if no language found matches the user preference. (1 bit) + Set if that track MUST be used during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced and non-forced track of the same kind. (1 bit) + Set if the track may contain blocks using lacing. (1 bit) + The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used. + The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed. + Number of nanoseconds (i.e. not scaled) per frame. + The scale to apply on this track to work at normal speed in relation with other tracks (mostly used to adjust video speed when the audio length differs). + A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track. + The maximum value of BlockAddID. A value 0 means there is no BlockAdditions for this track. + A human-readable track name. + Specifies the language of the track in the Matroska languages form. + An ID corresponding to the codec, see the codec page for more info. + Private data only known to the codec. + A human-readable string specifying the codec. + The UID of an attachment that is used by this codec. + A string describing the encoding setting used. + A URL to find information about the codec used. + A URL to download about the codec used. + The codec can decode potentially damaged data (1 bit). + Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see SilentTracks) the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc. + The track identification for the given Chapter Codec. + Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment. + The chapter codec using this ID (0: Matroska Script, 1: DVD-menu). + The binary value used to represent this track in the chapter codec data. The format depends on the ChapProcessCodecID used. + Video settings. + Set if the video is interlaced. (1 bit) + Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved (left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta)) . There are some more details on 3D support in the Specification Notes. + Bogus StereoMode value used in old versions of libmatroska. DO NOT USE. (0: mono, 1: right eye, 2: left eye, 3: both eyes). + Width of the encoded video frames in pixels. + Height of the encoded video frames in pixels. + The number of video pixels to remove at the bottom of the image (for HDTV content). + The number of video pixels to remove at the top of the image. + The number of video pixels to remove on the left of the image. + The number of video pixels to remove on the right of the image. + Width of the video frames to display. The default value is only valid when DisplayUnit is 0. + Height of the video frames to display. The default value is only valid when DisplayUnit is 0. + How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio). + Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed). + Same value as in AVI (32 bits). + Gamma Value. + Number of frames per second. Informational only. + Audio settings. + Sampling frequency in Hz. + Real output sampling frequency in Hz (used for SBR techniques). + Numbers of channels in the track. + Table of horizontal angles for each successive channel, see appendix. + Bits per sample, mostly used for PCM. + Operation that needs to be applied on tracks to create this virtual track. For more details look at the Specification Notes on the subject. + Contains the list of all video plane tracks that need to be combined to create this 3D track + Contains a video plane track that need to be combined to create this 3D track + The trackUID number of the track representing the plane. + The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background). + Contains the list of all tracks whose Blocks need to be combined to create this virtual track + The trackUID number of a track whose blocks are used to create this virtual track. + DivX trick track extenstions + DivX trick track extenstions + DivX trick track extenstions + DivX trick track extenstions + DivX trick track extenstions + Settings for several content encoding mechanisms like compression or encryption. + Settings for one content encoding like compression or encryption. + Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements in the segment. + A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values:
1 - all frame contents,
2 - the track's private data,
4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)
+ A value describing what kind of transformation has been done. Possible values:
0 - compression,
1 - encryption
+ Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking. + The compression algorithm used. Algorithms that have been specified so far are:
0 - zlib,
1 - bzlib,
2 - lzo1x
3 - Header Stripping
+ Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track. + Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise. + The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values:
1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES
+ For public key algorithms this is the ID of the public key the the data was encrypted with. + A cryptographic signature of the contents. + This is the ID of the private key the data was signed with. + The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
1 - RSA
+ The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
1 - SHA1-160
2 - MD5
+ A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non "live" streams. + Contains all information relative to a seek point in the segment. + Absolute timecode according to the segment time base. + Contain positions for different tracks corresponding to the timecode. + The track for which a position is given. + The position of the Cluster containing the required Block. + Number of the Block in the specified Cluster. + The position of the Codec State corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry. + The Clusters containing the required referenced Blocks. + Timecode of the referenced Block. + The Position of the Cluster containing the referenced Block. + Number of the referenced Block of Track X in the specified Cluster. + The position of the Codec State corresponding to this referenced element. 0 means that the data is taken from the initial Track Entry. + Contain attached files. + An attached file. + A human-friendly name for the attached file. + Filename of the attached file. + MIME type of the file. + The data of the file. + Unique ID representing the file, as random as possible. + A binary value that a track/codec can refer to when the attachment is needed. + DivX font extension + DivX font extension + A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation. + Contains all information about a segment edition. + A unique ID to identify the edition. It's useful for tagging an edition. + If an edition is hidden (1), it should not be available to the user interface (but still to Control Tracks). (1 bit) + If a flag is set (1) the edition should be used as the default one. (1 bit) + Specify if the chapters can be defined multiple times and the order to play them is enforced. (1 bit) + Contains the atom information to use as the chapter atom (apply to all tracks). + A unique ID to identify the Chapter. + Timecode of the start of Chapter (not scaled). + Timecode of the end of Chapter (timecode excluded, not scaled). + If a chapter is hidden (1), it should not be available to the user interface (but still to Control Tracks). (1 bit) + Specify wether the chapter is enabled. It can be enabled/disabled by a Control Track. When disabled, the movie should skip all the content between the TimeStart and TimeEnd of this chapter. (1 bit) + A segment to play in place of this chapter. Edition ChapterSegmentEditionUID should be used for this segment, otherwise no edition is used. + The edition to play from the segment linked in ChapterSegmentUID. + Specify the physical equivalent of this ChapterAtom like "DVD" (60) or "SIDE" (50), see complete list of values. + List of tracks on which the chapter applies. If this element is not present, all tracks apply + UID of the Track to apply this chapter too. In the absense of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks. Absense of this element indicates that the Chapter should be applied to any currently used Tracks. + Contains all possible strings to use for the chapter display. + Contains the string to use as the chapter atom. + The languages corresponding to the string, in the bibliographic ISO-639-2 form. + The countries corresponding to the string, same 2 octets as in Internet domains. + Contains all the commands associated to the Atom. + Contains the type of the codec used for the processing. A value of 0 means native Matroska processing (to be defined), a value of 1 means the DVD command set is used. More codec IDs can be added later. + Some optional data attached to the ChapProcessCodecID information. For ChapProcessCodecID = 1, it is the "DVD level" equivalent. + Contains all the commands associated to the Atom. + Defines when the process command should be handled (0: during the whole chapter, 1: before starting playback, 2: after playback of the chapter). + Contains the command information. The data should be interpreted depending on the ChapProcessCodecID value. For ChapProcessCodecID = 1, the data correspond to the binary DVD cell pre/post commands. + Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here. + Element containing elements specific to Tracks/Chapters. + Contain all UIDs where the specified meta data apply. It is empty to describe everything in the segment. + A number to indicate the logical level of the target (see TargetType). + An informational string that can be used to display the logical level of the target like "ALBUM", "TRACK", "MOVIE", "CHAPTER", etc (see TargetType). + A unique ID to identify the Track(s) the tags belong to. If the value is 0 at this level, the tags apply to all tracks in the Segment. + A unique ID to identify the EditionEntry(s) the tags belong to. If the value is 0 at this level, the tags apply to all editions in the Segment. + A unique ID to identify the Chapter(s) the tags belong to. If the value is 0 at this level, the tags apply to all chapters in the Segment. + A unique ID to identify the Attachment(s) the tags belong to. If the value is 0 at this level, the tags apply to all the attachments in the Segment. + Contains general information about the target. + The name of the Tag that is going to be stored. + Specifies the language of the tag specified, in the Matroska languages form. + Indication to know if this is the default/original language to use for the given tag. (1 bit) + The value of the Tag. + The values of the Tag if it is binary. Note that this cannot be used in the same SimpleTag as TagString. +
diff --git a/ebml/schema/specs.py b/ebml/schema/specs.py new file mode 100644 index 0000000..7320b6b --- /dev/null +++ b/ebml/schema/specs.py @@ -0,0 +1,74 @@ +from xml.etree.ElementTree import parse as parse_xml +from .base import INT, UINT, FLOAT, STRING, UNICODE, DATE, BINARY, CONTAINER, Element, Schema + + +SPECDATA_TYPES = { + 'integer': INT, + 'uinteger': UINT, + 'float': FLOAT, + 'string': STRING, + 'utf-8': UNICODE, + 'date': DATE, + 'binary': BINARY, + 'master': CONTAINER +} + + +def parse_specdata(source, schema_name): + """ + + Reads a schema specification from a file (e.g., specdata.xml) or file-like object, and returns a tuple containing: + + * a mapping of class names to Element subclasses + * a Schema subclass + + :arg source: the file or file-like object + :type source: str or file-like object + :arg schema_name: the name of the schema + :type schema_name: str + :returns: tuple + + """ + + tree = parse_xml(source) + elements = {} + parent_elements = [] + + for element_element in tree.getiterator('element'): + raw_attrs = element_element.attrib + + element_name = '%sElement' % raw_attrs.get('cppname', raw_attrs.get('name')) + element_level = int(raw_attrs['level']) + element_attrs = { + '__module__': None, + 'class_id': int(raw_attrs['id'], 0), + 'class_name': raw_attrs['name'], + 'data_type': SPECDATA_TYPES[raw_attrs['type']] + } + + while parent_elements and element_level <= parent_elements[-1][0]: + parent_elements.pop() + + if element_level == -1: + element_attrs['class_global'] = True + parent_elements = [] + elif element_level == 0: + element_attrs['class_root'] = True + parent_elements = [] + else: + if raw_attrs.get('recursive', '0') == '1': + element_attrs['class_parents'] = (parent_elements[-1][1], 'self') + else: + element_attrs['class_parents'] = (parent_elements[-1][1],) + + element = type(element_name, (Element,), element_attrs) + elements[element_name] = element + parent_elements.append((element_level, element)) + + schema_attrs = { + '__module__': None, + 'elements': tuple(elements.values()) + } + schema = type(schema_name, (Schema,), schema_attrs) + + return elements, schema \ No newline at end of file