From 8676cf590bc24f9332cb1cbe7882e3e429aa63b1 Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Thu, 19 Dec 2019 21:24:01 +0900 Subject: [PATCH] Add EBML elements (#103) - SegmentUID - SegmentFilename - Position - Tags - Tag - SimpleTag - TagName - TagString - TagBinary --- elementtable.go | 11 +++++++++++ elementtype.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/elementtable.go b/elementtable.go index ab8aa64..82cd893 100644 --- a/elementtable.go +++ b/elementtable.go @@ -27,6 +27,7 @@ type elementTable map[ElementType]elementDef var table = elementTable{ ElementSeekHead: elementDef{[]byte{0x11, 0x4D, 0x9B, 0x74}, TypeMaster, true}, + ElementTags: elementDef{[]byte{0x12, 0x54, 0xC3, 0x67}, TypeMaster, true}, ElementInfo: elementDef{[]byte{0x15, 0x49, 0xA9, 0x66}, TypeMaster, true}, ElementSegment: elementDef{[]byte{0x18, 0x53, 0x80, 0x67}, TypeMaster, false}, ElementTracks: elementDef{[]byte{0x16, 0x54, 0xAE, 0x6B}, TypeMaster, true}, @@ -34,6 +35,7 @@ var table = elementTable{ ElementCues: elementDef{[]byte{0x1C, 0x53, 0xBB, 0x6B}, TypeMaster, true}, ElementCluster: elementDef{[]byte{0x1F, 0x43, 0xB6, 0x75}, TypeMaster, true}, ElementDefaultDuration: elementDef{[]byte{0x23, 0xE3, 0x83}, TypeUInt, false}, + ElementCodecName: elementDef{[]byte{0x25, 0x86, 0x88}, TypeString, false}, ElementTimecodeScale: elementDef{[]byte{0x2A, 0xD7, 0xB1}, TypeUInt, false}, ElementEBMLVersion: elementDef{[]byte{0x42, 0x86}, TypeUInt, false}, ElementEBMLReadVersion: elementDef{[]byte{0x42, 0xF7}, TypeUInt, false}, @@ -42,8 +44,11 @@ var table = elementTable{ ElementEBMLDocType: elementDef{[]byte{0x42, 0x82}, TypeString, false}, ElementEBMLDocTypeVersion: elementDef{[]byte{0x42, 0x87}, TypeUInt, false}, ElementEBMLDocTypeReadVersion: elementDef{[]byte{0x42, 0x85}, TypeUInt, false}, + ElementTagBinary: elementDef{[]byte{0x44, 0x85}, TypeBinary, false}, + ElementTagString: elementDef{[]byte{0x44, 0x87}, TypeString, false}, ElementDateUTC: elementDef{[]byte{0x44, 0x61}, TypeDate, false}, ElementDuration: elementDef{[]byte{0x44, 0x89}, TypeFloat, false}, + ElementTagName: elementDef{[]byte{0x45, 0xA3}, TypeString, false}, ElementSeek: elementDef{[]byte{0x4D, 0xBB}, TypeMaster, false}, ElementSeekID: elementDef{[]byte{0x53, 0xAB}, TypeBinary, false}, ElementSeekPosition: elementDef{[]byte{0x53, 0xAC}, TypeUInt, false}, @@ -54,7 +59,12 @@ var table = elementTable{ ElementSeekPreRoll: elementDef{[]byte{0x56, 0xBB}, TypeUInt, false}, ElementWritingApp: elementDef{[]byte{0x57, 0x41}, TypeString, false}, ElementCodecPrivate: elementDef{[]byte{0x63, 0xA2}, TypeBinary, false}, + ElementSimpleTag: elementDef{[]byte{0x67, 0xC8}, TypeMaster, false}, + ElementTag: elementDef{[]byte{0x73, 0x73}, TypeMaster, false}, + ElementSegmentFilename: elementDef{[]byte{0x73, 0x84}, TypeString, false}, + ElementSegmentUID: elementDef{[]byte{0x73, 0xA4}, TypeBinary, false}, ElementTrackUID: elementDef{[]byte{0x73, 0xC5}, TypeUInt, false}, + ElementTitle: elementDef{[]byte{0x7B, 0xA9}, TypeString, false}, ElementTrackType: elementDef{[]byte{0x83}, TypeUInt, false}, ElementCodecID: elementDef{[]byte{0x86}, TypeString, false}, ElementChannels: elementDef{[]byte{0x9F}, TypeUInt, false}, @@ -62,6 +72,7 @@ var table = elementTable{ ElementBlockGroup: elementDef{[]byte{0xA0}, TypeMaster, false}, ElementBlockDuration: elementDef{[]byte{0x9B}, TypeUInt, false}, ElementBlock: elementDef{[]byte{0xA1}, TypeBlock, false}, + ElementPosition: elementDef{[]byte{0xA7}, TypeUInt, false}, ElementPrevSize: elementDef{[]byte{0xAB}, TypeUInt, false}, ElementTrackEntry: elementDef{[]byte{0xAE}, TypeMaster, false}, ElementPixelWidth: elementDef{[]byte{0xB0}, TypeUInt, false}, diff --git a/elementtype.go b/elementtype.go index 9d47d6d..1f012c3 100644 --- a/elementtype.go +++ b/elementtype.go @@ -46,6 +46,8 @@ const ( ElementSeekPosition ElementInfo + ElementSegmentUID + ElementSegmentFilename ElementTimestampScale ElementDuration ElementDateUTC @@ -55,6 +57,7 @@ const ( ElementCluster ElementTimestamp + ElementPosition ElementPrevSize ElementSimpleBlock ElementBlockGroup @@ -121,6 +124,13 @@ const ( ElementCueClusterPosition ElementCueBlockNumber + ElementTags + ElementTag + ElementSimpleTag + ElementTagName + ElementTagString + ElementTagBinary + elementMax ) @@ -162,6 +172,10 @@ func (i ElementType) String() string { return "SeekPosition" case ElementInfo: return "Info" + case ElementSegmentUID: + return "SegmentUID" + case ElementSegmentFilename: + return "SegmentFilename" case ElementTimestampScale: return "TimestampScale" case ElementDuration: @@ -178,6 +192,8 @@ func (i ElementType) String() string { return "Cluster" case ElementTimestamp: return "Timestamp" + case ElementPosition: + return "Position" case ElementPrevSize: return "PrevSize" case ElementSimpleBlock: @@ -304,6 +320,18 @@ func (i ElementType) String() string { return "CueClusterPosition" case ElementCueBlockNumber: return "CueBlockNumber" + case ElementTags: + return "Tags" + case ElementTag: + return "Tag" + case ElementSimpleTag: + return "SimpleTag" + case ElementTagName: + return "TagName" + case ElementTagString: + return "TagString" + case ElementTagBinary: + return "TagBinary" default: return "unknown" } @@ -347,6 +375,10 @@ func ElementTypeFromString(s string) (ElementType, error) { return ElementSeekPosition, nil case "Info": return ElementInfo, nil + case "SegmentUID": + return ElementSegmentUID, nil + case "SegmentFilename": + return ElementSegmentFilename, nil case "TimestampScale": return ElementTimestampScale, nil case "Duration": @@ -363,6 +395,8 @@ func ElementTypeFromString(s string) (ElementType, error) { return ElementCluster, nil case "Timestamp": return ElementTimestamp, nil + case "Position": + return ElementPosition, nil case "PrevSize": return ElementPrevSize, nil case "SimpleBlock": @@ -490,6 +524,19 @@ func ElementTypeFromString(s string) (ElementType, error) { case "CueBlockNumber": return ElementCueBlockNumber, nil + case "Tags": + return ElementTags, nil + case "Tag": + return ElementTag, nil + case "SimpleTag": + return ElementSimpleTag, nil + case "TagName": + return ElementTagName, nil + case "TagString": + return ElementTagString, nil + case "TagBinary": + return ElementTagBinary, nil + // WebM aliases case "TimecodeScale": return ElementTimecodeScale, nil