Skip to content

Commit

Permalink
Add EBML elements (#103)
Browse files Browse the repository at this point in the history
- SegmentUID
- SegmentFilename
- Position
- Tags
- Tag
- SimpleTag
- TagName
- TagString
- TagBinary
  • Loading branch information
at-wat authored Dec 19, 2019
1 parent f7c1492 commit 8676cf5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions elementtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ 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},
ElementEBML: elementDef{[]byte{0x1A, 0x45, 0xDF, 0xA3}, TypeMaster, false},
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},
Expand All @@ -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},
Expand All @@ -54,14 +59,20 @@ 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},
ElementSimpleBlock: elementDef{[]byte{0xA3}, TypeBlock, false},
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},
Expand Down
47 changes: 47 additions & 0 deletions elementtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const (
ElementSeekPosition

ElementInfo
ElementSegmentUID
ElementSegmentFilename
ElementTimestampScale
ElementDuration
ElementDateUTC
Expand All @@ -55,6 +57,7 @@ const (

ElementCluster
ElementTimestamp
ElementPosition
ElementPrevSize
ElementSimpleBlock
ElementBlockGroup
Expand Down Expand Up @@ -121,6 +124,13 @@ const (
ElementCueClusterPosition
ElementCueBlockNumber

ElementTags
ElementTag
ElementSimpleTag
ElementTagName
ElementTagString
ElementTagBinary

elementMax
)

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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":
Expand All @@ -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":
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8676cf5

Please sign in to comment.