Documentation ¶
Index ¶
- Constants
- Variables
- func PrintGSI(gsi *GSIBlock)
- func PrintTTI(tti *TTIBlock, cct CharacterCodeTable)
- type CharacterCodeTable
- type Charmap
- type CodePageNumber
- type CommentFlag
- type ControlCode
- type CumulativeStatus
- type DecodeError
- type DiskFormatCode
- type DisplayStandardCode
- type EncodeError
- type EncodingError
- type Field
- type FieldError
- type File
- type GSIBlock
- type GSIError
- type GSIField
- type JustificationCode
- type LanguageCode
- type TTIBlock
- func (tti *TTIBlock) Decode(r io.Reader) error
- func (tti *TTIBlock) Encode(w io.Writer) error
- func (tti *TTIBlock) Reset()
- func (tti *TTIBlock) SetText(text string, cct CharacterCodeTable) error
- func (tti *TTIBlock) Text(cct CharacterCodeTable) (string, error)
- func (tti *TTIBlock) Validate(framerate uint, dsc DisplayStandardCode, mnr int) ([]error, error)
- type TTIError
- type TTIField
- type TeletextColor
- type TeletextControlCode
- type TextDecoder
- type TextEncoder
- type TimeCodeStatus
- type Timecode
- type ValidateError
Constants ¶
const GSIBlockSize = 1024
GSIBlockSize is the size in bytes of the GSI block in a STL file.
const TTIBlockSize = 128
TTIBlockSize is the size in bytes of a TTI block in a STL file.
Variables ¶
var ( ErrInvalidGSIIntValue = errors.New("invalid GSI int value") ErrEmptyGSIIntValue = errors.New("empty GSI int value") ErrInvalidGSIByteValue = errors.New("invalid GSI byte value") ErrEmptyGSIByteValue = errors.New("empty GSI byte value") ErrInvalidGSIHexValue = errors.New("invalid GSI hex value") ErrEmptyGSIHexValue = errors.New("empty GSI hex value") ErrInvalidGSIStringValue = errors.New("invalid GSI string value") ErrEmptyGSIStringValue = errors.New("empty GSI string value") ErrUnsupportedGSICodePage = errors.New("unsupported code page") ErrInvalidGSIDateValue = errors.New("invalid GSI date value") ErrEmptyGSIDateValue = errors.New("empty GSI date value") ErrInvalidGSITimecodeValue = errors.New("invalid GSI timecode value") ErrEmptyGSITimecodeValue = errors.New("empty GSI timecode value") )
var ( ErrUnknown = errors.New("unknown error") ErrNoTTIBlocks = errors.New("no TTI blocks") ErrTTIBlocksCountMismatch = errors.New("TTI blocks count mismatch") ErrTCFFirstTCIMismatch = errors.New("first TTI timecode mismatch") ErrEBNNotConsecutive = errors.New("EBN not consecutive") ErrSNNotConsecutive = errors.New("SN not consecutive") ErrSGNNotConsecutive = errors.New("SGN not consecutive") ErrNoFirstSubtitleInNewGroup = errors.New("no first subtitle in new group") ErrNonClosingEBNForLastSubtitle = errors.New("non closing EBN for last subtitle") ErrCSNotNoneOrFirst = errors.New("CS not none or first") ErrCSNotIntermediateOrLast = errors.New("CS not intermediate or last") ErrCSNotNoneOrLast = errors.New("CS not none or last") ErrSubtitleCountMismatch = errors.New("subtitle count mismatch") ErrGroupCountMismatch = errors.New("group count mismatch") )
var ( ErrUnsupportedCPN = errors.New("unsupported CPN") ErrUnsupportedDFC = errors.New("unsupported DFC") ErrUnsupportedFramerate = errors.New("unsupported framerate") ErrUnsupportedDSC = errors.New("unsupported DSC") ErrUnsupportedCCT = errors.New("unsupported CCT") ErrUnsupportedLC = errors.New("unsupported LC") ErrEmptyOPT = errors.New("empty OPT") ErrEmptyOET = errors.New("empty OET") ErrEmptyTPT = errors.New("empty TPT") ErrEmptyTET = errors.New("empty TET") ErrEmptyTN = errors.New("empty TN") ErrEmptyTCD = errors.New("empty TCD") ErrEmptySLR = errors.New("empty SLR") ErrEmptyCD = errors.New("empty CD") ErrEmptyCR = errors.New("empty CR") ErrEmptyRD = errors.New("empty RD") ErrCDGreaterThanRD = errors.New("CD greater than RD") ErrUnsupportedRN = errors.New("unsupported RN") ErrUnsupportedTNB = errors.New("unsupported TNB") ErrUnsupportedTNS = errors.New("unsupported TNS") ErrUnsupportedTNG = errors.New("unsupported TNG") ErrUnsupportedMNC = errors.New("unsupported MNC") ErrUnsupportedMNRTeletext = errors.New("unsupported MNR (teletext)") ErrUnsupportedMNROpenSubtitling = errors.New("unsupported MNR (open subtitling)") ErrUnsupportedTCS = errors.New("unsupported TCS") ErrEmptyTCP = errors.New("empty TCP") ErrEmptyTCF = errors.New("empty TCF") ErrTCPTCFOrder = errors.New("TCP greater than TCF") ErrInvalidTimecodes = errors.New("invalid timecodes") ErrUnsupportedTND = errors.New("unsupported TND") ErrUnsupportedDSN = errors.New("unsupported DSN") ErrEmptyCO = errors.New("empty CO") ErrEmptyPUB = errors.New("empty PUB") ErrEmptyEN = errors.New("empty EN") ErrEmptyECD = errors.New("empty ECD") )
var ( ErrInvalidFramerate = errors.New("invalid framerate") ErrUnsupportedSGN = errors.New("unsupported SGN") ErrUnsupportedSN = errors.New("unsupported SN") ErrLastEBNNotTerminatedBySpace = errors.New("last EBN not terminated by space") ErrReservedEBNRange = errors.New("reserved EBN range") ErrUnsupportedCS = errors.New("unsupported CS") ErrInvalidTCI = errors.New("invalid TCI") ErrInvalidTCO = errors.New("invalid TCO") ErrInvalidTCITCOOrder = errors.New("invalid TCI/TCO order") ErrUnsupportedVPTeletext = errors.New("unsupported VP (teletext)") ErrUnsupportedVPOpenSubtitling = errors.New("unsupported VP (for open subtitling)") ErrUnsupportedVPDSC = errors.New("unsupported DSC, cannot use VP") ErrUnsupportedJC = errors.New("unsupported JC") ErrUnsupportedCF = errors.New("unsupported CF") )
var CharacterCodeTableDecoders = map[CharacterCodeTable]TextDecoder{ CharacterCodeTableLatin: &ISO6937, CharacterCodeTableLatinCyrillic: &Charmap{charmap.ISO8859_5}, CharacterCodeTableLatinArabic: &Charmap{charmap.ISO8859_6}, CharacterCodeTableLatinGreek: &Charmap{charmap.ISO8859_7}, CharacterCodeTableLatinHebrew: &Charmap{charmap.ISO8859_8}, }
var CharacterCodeTableEncoders = map[CharacterCodeTable]TextEncoder{ CharacterCodeTableLatin: &ISO6937, CharacterCodeTableLatinCyrillic: &Charmap{charmap.ISO8859_5}, CharacterCodeTableLatinArabic: &Charmap{charmap.ISO8859_6}, CharacterCodeTableLatinGreek: &Charmap{charmap.ISO8859_7}, CharacterCodeTableLatinHebrew: &Charmap{charmap.ISO8859_8}, }
var CodePageNumberDecoders = map[CodePageNumber]TextDecoder{ CodePageNumberUnitedStates: &Charmap{charmap.CodePage437}, CodePageNumberMultiLingual: &Charmap{charmap.CodePage850}, CodePageNumberPortugal: &Charmap{charmap.CodePage860}, CodePageNumberCanadianFrench: &Charmap{charmap.CodePage863}, CodePageNumberNordic: &Charmap{charmap.CodePage865}, }
var CodePageNumberEncoders = map[CodePageNumber]TextEncoder{ CodePageNumberUnitedStates: &Charmap{charmap.CodePage437}, CodePageNumberMultiLingual: &Charmap{charmap.CodePage850}, CodePageNumberPortugal: &Charmap{charmap.CodePage860}, CodePageNumberCanadianFrench: &Charmap{charmap.CodePage863}, CodePageNumberNordic: &Charmap{charmap.CodePage865}, }
var ISO6937 = iso6937{}
ISO6937 implements the ISO 6937 encoding. It implements the TextDecoder and TextEncoder interfaces.
Functions ¶
func PrintTTI ¶
func PrintTTI(tti *TTIBlock, cct CharacterCodeTable)
Types ¶
type CharacterCodeTable ¶
type CharacterCodeTable byte
CharacterCodeTable is the code used to represent the character code table used to define the text in the Text Field (TF) of the TTI blocks. Only "Latin" (0), "Latin/Cyrillic" (1), "Latin/Arabic" (2), "Latin/Greek" (3) and "Latin/Hebrew" (4) are supported values.
const ( CharacterCodeTableInvalid CharacterCodeTable = 0xFF CharacterCodeTableLatin CharacterCodeTable = 0x00 CharacterCodeTableLatinCyrillic CharacterCodeTable = 0x01 CharacterCodeTableLatinArabic CharacterCodeTable = 0x02 CharacterCodeTableLatinGreek CharacterCodeTable = 0x03 CharacterCodeTableLatinHebrew CharacterCodeTable = 0x04 )
func (CharacterCodeTable) String ¶
func (cct CharacterCodeTable) String() string
String returns the string representation of CharacterCodeTable.
type Charmap ¶
type Charmap struct {
// contains filtered or unexported fields
}
Charmap is a wrapper around golang.org/x/text/encoding/charmap.Charmap It implements the TextDecoder and TextEncoder interfaces.
type CodePageNumber ¶
type CodePageNumber int
CodePageNumber is the number of the code page used in the GSI block. Note: Other code pages may be used within a given national environment.
const ( CodePageNumberInvalid CodePageNumber = -1 CodePageNumberUnitedStates CodePageNumber = 437 CodePageNumberMultiLingual CodePageNumber = 850 CodePageNumberPortugal CodePageNumber = 860 CodePageNumberCanadianFrench CodePageNumber = 863 CodePageNumberNordic CodePageNumber = 865 )
func (CodePageNumber) String ¶
func (cpn CodePageNumber) String() string
String returns the string representation of CodePageNumber.
type CommentFlag ¶
type CommentFlag byte
CommentFlag is used to indicate TTI blocks which contains text as translator's comments instead of subtitle data. Only "subtitle data" (0) and "translator's comments" (1) are supported.
const ( CommentFlagInvalid CommentFlag = 0xFF CommentFlagSubtitleData CommentFlag = 0x00 CommentFlagTranslatorComments CommentFlag = 0x01 )
func (CommentFlag) String ¶
func (cf CommentFlag) String() string
String returns the string representation of CommentFlag.
type ControlCode ¶
type ControlCode byte
ControlCode
const ( ControlCodeItalicOn ControlCode = 0x80 ControlCodeItalicOff ControlCode = 0x81 ControlCodeUnderlineOn ControlCode = 0x82 ControlCodeUnderlineOff ControlCode = 0x83 ControlCodeBoxingOn ControlCode = 0x84 ControlCodeBoxingOff ControlCode = 0x85 ControlCodeLineBreak ControlCode = 0x8A ControlCodeUnusedSpace ControlCode = 0x8F )
func (ControlCode) String ¶
func (cc ControlCode) String() string
String returns the string representation of ControlCode.
type CumulativeStatus ¶
type CumulativeStatus byte
CumulativeStatus is indicating that a subtitle is part of a cumulative set of subtitles.
const ( CumulativeStatusInvalid CumulativeStatus = 0xFF CumulativeStatusNone CumulativeStatus = 0x00 CumulativeStatusFirst CumulativeStatus = 0x01 CumulativeStatusIntermediate CumulativeStatus = 0x02 CumulativeStatusLast CumulativeStatus = 0x03 )
func (CumulativeStatus) String ¶
func (cs CumulativeStatus) String() string
String returns the string representation of CumulativeStatus.
type DecodeError ¶
type DecodeError struct {
EncodingError
}
DecodeError is an error that occurred during decoding. It extends EncodingError that carries the value that caused the error.
func (*DecodeError) Unwrap ¶
func (e *DecodeError) Unwrap() error
Unwrap returns the underlying error.
type DiskFormatCode ¶
type DiskFormatCode string
DiskFormatCode is the code used to represent the frame-rate of the data. Only "STL25.01" (25 fps) and "STL30.01" (30 fps) are supported values.
const ( DiskFormatCodeInvalid DiskFormatCode = " " DiskFormatCode25_01 DiskFormatCode = "STL25.01" DiskFormatCode30_01 DiskFormatCode = "STL30.01" )
func (DiskFormatCode) String ¶
func (dfc DiskFormatCode) String() string
String returns the string representation of DiskFormatCode.
type DisplayStandardCode ¶
type DisplayStandardCode byte
DisplayStandardCode is the code used to represent the display mode. Only "Undefined" (blank), "Open Subtitling" (0), "Level-1 Teletext" (1) and "Level-2 Teletext" (2) are supported values.
const ( DisplayStandardCodeBlank DisplayStandardCode = 0xFF DisplayStandardCodeOpenSubtitling DisplayStandardCode = 0x00 DisplayStandardCodeLevel1Teletext DisplayStandardCode = 0x01 DisplayStandardCodeLevel2Teletext DisplayStandardCode = 0x02 )
func (DisplayStandardCode) String ¶
func (dsc DisplayStandardCode) String() string
String returns the string representation of DisplayStandardCode.
type EncodeError ¶
type EncodeError struct {
EncodingError
}
EncodeError is an error that occurred during encoding. It extends EncodingError that carries the input buffer that caused the error.
func (*EncodeError) Unwrap ¶
func (e *EncodeError) Unwrap() error
Unwrap returns the underlying error.
type EncodingError ¶
type EncodingError struct {
// contains filtered or unexported fields
}
EncodingError is an error that occurred during encoding or decoding. It carries the input buffer that caused the error. EncodingError implements the error and Unwrap interfaces.
func (*EncodingError) Error ¶
func (e *EncodingError) Error() string
Error returns the error message.
func (*EncodingError) Input ¶
func (e *EncodingError) Input() interface{}
Input returns the input buffer.
func (*EncodingError) Unwrap ¶
func (e *EncodingError) Unwrap() error
Unwrap returns the underlying error.
type Field ¶
type Field string
Filed represents a block field.
const FieldUnknown Field = "<unknown>" // Unknown field
type FieldError ¶
type FieldError struct {
// contains filtered or unexported fields
}
FieldError is an error that occurred on a field.
func (*FieldError) Unwrap ¶
func (e *FieldError) Unwrap() error
Unwrap returns the underlying error.
type File ¶
File is the representation of a STL file. The file comprises one General Subtitle Information (GSI) block and a number of Text and Timing Information (TTI) blocks.
func (*File) Validate ¶
Validate validates STL file. It returns a slice of warnings and an error if any. Warnings are returned for each field that is invalid, warnings can flagged as fatal if they are considered to be fatal to further file processing. An error is returned if a field is invalid and prevents validation of further fields.
type GSIBlock ¶
type GSIBlock struct { CPN CodePageNumber // Code Page Number DFC DiskFormatCode // Disk Format Code DSC DisplayStandardCode // Display Standard Code CCT CharacterCodeTable // Character Code Table number LC LanguageCode // Language Code OPT string // Original Program Title OET string // Original Episode Title TPT string // Translated Program Title TET string // Translated Episode Title TN string // Translator's Name TCD string // Translator's Contact Details SLR string // Subtitle List Reference Code CD time.Time // Creation Date RD time.Time // Revision Date RN int // Revision Number TNB int // Total Number of Text and Timing Information (TTI) blocks TNS int // Total Number of Subtitles TNG int // Total Number of Subtitle Groups MNC int // Maximum Number of Displayable Characters in any text row MNR int // Maximum Number of Displayable Rows TCS TimeCodeStatus // Time Code: Status TCP Timecode // Time Code: Start-of-Program TCF Timecode // Time Code: First In-Cue TND int // Total Number of Disks DSN int // Disk Sequence Number CO string // Country of Origin PUB string // Publisher EN string // Editor's Name ECD string // Editor's Contact UDA []byte // User-Defined Area }
GSIBlock is the General Subtitle Information (GSI) block representation.
func (*GSIBlock) Decode ¶
Decode reads and decodes GSI block from reader. It returns a slice of warnings and an error if any. Warnings are returned for each field that is invalid and are not fatal. An error is returned if a fatal error occurs that prevents further decoding.
func (*GSIBlock) Encode ¶
Encode encodes and writes GSI block to writer. An error is returned if a fatal error occurs that prevents further encoding.
func (*GSIBlock) Framerate ¶
Framerate returns the framerate of the GSI block (extracted from the Disk Format Code). The supported values are 25 and 30 fps. Returns -1 if Disk Format Code is unsupported.
func (*GSIBlock) Reset ¶
func (gsi *GSIBlock) Reset()
Reset resets the GSI block to its default values.
func (*GSIBlock) Validate ¶
Validate validates GSI block. It returns a slice of warnings and an error if any. Warnings are returned for each field that is invalid, warnings can flagged as fatal if they are considered to be fatal to further file processing. An error is returned if a field is invalid and prevents validation of further fields.
type GSIError ¶
type GSIError struct { FieldError // contains filtered or unexported fields }
GSIError is an error that occurred on a GSI field. It extends FieldError that carries the concerned GSI field.
type GSIField ¶
type GSIField Field
GSIField represents a GSI block field. It extends Field.
const ( GSIFieldCPN GSIField = "CPN" // Code Page Number GSIFieldDFC GSIField = "DSC" // Disk Format Code GSIFieldDSC GSIField = "DSC" // Display Standard Code GSIFieldCCT GSIField = "CCT" // Character Code Table number GSIFieldLC GSIField = "LC" // Language Code GSIFieldOPT GSIField = "OPT" // Original Program Title GSIFieldOET GSIField = "OET" // Original Episode Title GSIFieldTPT GSIField = "TPT" // Translated Program Title GSIFieldTET GSIField = "TET" // Translated Episode Title GSIFieldTN GSIField = "TN" // Translator's Name GSIFieldTCD GSIField = "TCD" // Translator's Contact Details GSIFieldSLR GSIField = "SLR" // Subtitle List Reference Code GSIFieldCD GSIField = "CD" // Creation Date GSIFieldRD GSIField = "RD" // Revision Date GSIFieldRN GSIField = "RN" // Revision Number GSIFieldTNB GSIField = "TNB" // Total Number of Text and Timing Information (TTI) blocks GSIFieldTNS GSIField = "TNS" // Total Number of Subtitles GSIFieldTNG GSIField = "TNG" // Total Number of Subtitle Groups GSIFieldMNC GSIField = "MNC" // Maximum Number of Displayable Characters in any text row GSIFieldMNR GSIField = "MNR" // Maximum Number of Displayable Rows GSIFieldTCS GSIField = "TCS" // Time Code: Status GSIFieldTCP GSIField = "TCP" // Time Code: Start-of-Program GSIFieldTCF GSIField = "TCF" // Time Code: First In-Cue GSIFieldTND GSIField = "TND" // Total Number of Disks GSIFieldDSN GSIField = "DSN" // Disk Sequence Number GSIFieldCO GSIField = "CO" // Country of Origin GSIFieldPUB GSIField = "PUB" // Publisher GSIFieldEN GSIField = "EN" // Editor's Name GSIFieldECD GSIField = "ECD" // Editor's Contact GSIFieldUDA GSIField = "UDA" // User-Defined Area )
type JustificationCode ¶
type JustificationCode byte
JustificationCode is indicating the horizontal alignment of the displayed subtitle. Only "unchanged presentation" (0), "left-justified text" (1), "centered text" (2) and "right-justified text" (3) are supported.
const ( JustificationCodeInvalid JustificationCode = 0xFF JustificationCodeUnchangedPresentation JustificationCode = 0x00 JustificationCodeLeftJustifiedText JustificationCode = 0x01 JustificationCodeCenteredText JustificationCode = 0x02 JustificationCodeRightJustifiedText JustificationCode = 0x03 )
func (JustificationCode) String ¶
func (jc JustificationCode) String() string
String returns the string representation of JustificationCode.
type LanguageCode ¶
type LanguageCode byte
Language Code is the code of the language for wih the subtitle list is prepared.
const ( LanguageCodeInvalid LanguageCode = 0xFF LanguageCodeUnknown LanguageCode = 0x00 LanguageCodeAlbanian LanguageCode = 0x01 LanguageCodeBreton LanguageCode = 0x02 LanguageCodeCatalan LanguageCode = 0x03 LanguageCodeCroatian LanguageCode = 0x04 LanguageCodeWelsh LanguageCode = 0x05 LanguageCodeCzech LanguageCode = 0x06 LanguageCodeDanish LanguageCode = 0x07 LanguageCodeGerman LanguageCode = 0x08 LanguageCodeEnglish LanguageCode = 0x09 LanguageCodeSpanish LanguageCode = 0x0A LanguageCodeEsperanto LanguageCode = 0x0B LanguageCodeEstonian LanguageCode = 0x0C LanguageCodeBasque LanguageCode = 0x0D LanguageCodeFaroese LanguageCode = 0x0E LanguageCodeFrench LanguageCode = 0x0F LanguageCodeFrisian LanguageCode = 0x10 LanguageCodeIrish LanguageCode = 0x11 LanguageCodeGaelic LanguageCode = 0x12 LanguageCodeGalician LanguageCode = 0x13 LanguageCodeIcelandic LanguageCode = 0x14 LanguageCodeItalian LanguageCode = 0x15 LanguageCodeLappish LanguageCode = 0x16 LanguageCodeLatin LanguageCode = 0x17 LanguageCodeLatvian LanguageCode = 0x18 LanguageCodeLuxembourgian LanguageCode = 0x19 LanguageCodeLithuanian LanguageCode = 0x1A LanguageCodeHungarian LanguageCode = 0x1B LanguageCodeMaltese LanguageCode = 0x1C LanguageCodeDutch LanguageCode = 0x1D LanguageCodeNorwegian LanguageCode = 0x1E LanguageCodeOccitan LanguageCode = 0x1F LanguageCodePolish LanguageCode = 0x20 LanguageCodePortugese LanguageCode = 0x21 LanguageCodeRomanian LanguageCode = 0x22 LanguageCodeRomansh LanguageCode = 0x23 LanguageCodeSerbian LanguageCode = 0x24 LanguageCodeSlovak LanguageCode = 0x25 LanguageCodeSlovenian LanguageCode = 0x26 LanguageCodeFinnish LanguageCode = 0x27 LanguageCodeSwedish LanguageCode = 0x28 LanguageCodeTurkish LanguageCode = 0x29 LanguageCodeFlemish LanguageCode = 0x2A LanguageCodeWallon LanguageCode = 0x2B LanguageCodeAmharic LanguageCode = 0x7F LanguageCodeArabic LanguageCode = 0x7E LanguageCodeArmenian LanguageCode = 0x7D LanguageCodeAssamese LanguageCode = 0x7C LanguageCodeAzerbaijani LanguageCode = 0x7B LanguageCodeBambora LanguageCode = 0x7A LanguageCodeBielorussian LanguageCode = 0x79 LanguageCodeBengali LanguageCode = 0x78 LanguageCodeBulgarian LanguageCode = 0x77 LanguageCodeBurmese LanguageCode = 0x76 LanguageCodeChinese LanguageCode = 0x75 LanguageCodeChurash LanguageCode = 0x74 LanguageCodeDari LanguageCode = 0x73 LanguageCodeFulani LanguageCode = 0x72 LanguageCodeGeorgian LanguageCode = 0x71 LanguageCodeGreek LanguageCode = 0x70 LanguageCodeGujurati LanguageCode = 0x6F LanguageCodeGurani LanguageCode = 0x6E LanguageCodeHausa LanguageCode = 0x6D LanguageCodeHebrew LanguageCode = 0x6C LanguageCodeHindi LanguageCode = 0x6B LanguageCodeIndonesian LanguageCode = 0x6A LanguageCodeJapanese LanguageCode = 0x69 LanguageCodeKannada LanguageCode = 0x68 LanguageCodeKazakh LanguageCode = 0x67 LanguageCodeKhmer LanguageCode = 0x66 LanguageCodeKorean LanguageCode = 0x65 LanguageCodeLaotian LanguageCode = 0x64 LanguageCodeMacedonian LanguageCode = 0x63 LanguageCodeMalagasay LanguageCode = 0x62 LanguageCodeMalaysian LanguageCode = 0x61 LanguageCodeMoldavian LanguageCode = 0x60 LanguageCodeMarathi LanguageCode = 0x5F LanguageCodeNdebele LanguageCode = 0x5E LanguageCodeNepali LanguageCode = 0x5D LanguageCodeOriya LanguageCode = 0x5C LanguageCodePapamiento LanguageCode = 0x5B LanguageCodePersian LanguageCode = 0x5A LanguageCodePunjabi LanguageCode = 0x59 LanguageCodePushtu LanguageCode = 0x58 LanguageCodeQuechua LanguageCode = 0x57 LanguageCodeRussian LanguageCode = 0x56 LanguageCodeRuthenian LanguageCode = 0x55 LanguageCodeSerboCroat LanguageCode = 0x54 LanguageCodeShona LanguageCode = 0x53 LanguageCodeSinhalese LanguageCode = 0x52 LanguageCodeSomali LanguageCode = 0x51 LanguageCodeSrananTongo LanguageCode = 0x50 LanguageCodeSwahili LanguageCode = 0x4F LanguageCodeTadzhik LanguageCode = 0x4E LanguageCodeTamil LanguageCode = 0x4D LanguageCodeTatar LanguageCode = 0x4C LanguageCodeTelugu LanguageCode = 0x4B LanguageCodeThai LanguageCode = 0x4A LanguageCodeUkrainian LanguageCode = 0x49 LanguageCodeUrdu LanguageCode = 0x48 LanguageCodeUzbek LanguageCode = 0x47 LanguageCodeVietnamese LanguageCode = 0x46 LanguageCodeZulu LanguageCode = 0x45 )
func (LanguageCode) String ¶
func (lc LanguageCode) String() string
String returns the string representation of LanguageCode.
type TTIBlock ¶
type TTIBlock struct { SGN int // Subtitle Group Number SN int // Subtitle Number EBN int // Extension Block Number CS CumulativeStatus // Cumulative Status TCI Timecode // Time Code In TCO Timecode // Time Code Out VP int // Vertical Position JC JustificationCode // Justification Code CF CommentFlag // Comment Flag TF string // Text Field // contains filtered or unexported fields }
TTIBlock is the Text and Timing Information (TTI) block representation.
func (*TTIBlock) Decode ¶
Decode reads and decodes TTI block from reader. An error is returned if a fatal error occurs that prevents further decoding.
func (*TTIBlock) Encode ¶
Encode encodes and writes TTI block to writer. An error is returned if a fatal error occurs that prevents further encoding.
func (*TTIBlock) Reset ¶
func (tti *TTIBlock) Reset()
Reset resets the TTI block to its default values.
func (*TTIBlock) SetText ¶
func (tti *TTIBlock) SetText(text string, cct CharacterCodeTable) error
SetText sets the Text Field (TF) from the UTF-8 encoded text.
func (*TTIBlock) Text ¶
func (tti *TTIBlock) Text(cct CharacterCodeTable) (string, error)
Text returns the UTF-8 decoded Text Field (TF).
func (*TTIBlock) Validate ¶
Validate validates TTI block. It returns a slice of warnings and an error if any. Warnings are returned for each field that is invalid, warnings can flagged as fatal if they are considered to be fatal to further file processing. An error is returned if a field is invalid and prevents validation of further fields.
type TTIError ¶
type TTIError struct { FieldError // contains filtered or unexported fields }
TTIError is an error that occurred on a TTI field. It extends FieldError that carries the concerned TTI field. It carries the concerned TTI block number. If TTI block number is -1, it means that the TTI block number is unknown.
func (*TTIError) BlockNumber ¶
BlockNumber returns the concerned TTI block number. If TTI block number is -1, it means that the TTI block number is unknown.
type TTIField ¶
type TTIField Field
TTIField represents a TTI block field. It extends Field.
const ( TTIFieldSGN TTIField = "SGN" // Subtitle Group Number TTIFieldSN TTIField = "SN" // Subtitle Number TTIFieldEBN TTIField = "EBN" // Extension Block Number TTIFieldCS TTIField = "CS" // Cumulative Status TTIFieldTCI TTIField = "TCI" // Time Code In TTIFieldTCO TTIField = "TCO" // Time Code Out TTIFieldVP TTIField = "VP" // Vertical Position TTIFieldJC TTIField = "JC" // Justification Code TTIFieldCF TTIField = "CF" // Comment Flag TTIFieldTF TTIField = "TF" // Text Field )
type TeletextColor ¶
type TeletextColor TeletextControlCode
TeletextColor is the code used to represent a Teletext color (from EBU document Tech. 3240)
const ( TeletextColorBlack TeletextColor = 0x0 TeletextColorRed TeletextColor = 0x1 TeletextColorGreen TeletextColor = 0x2 TeletextColorYellow TeletextColor = 0x3 TeletextColorBlue TeletextColor = 0x4 TeletextColorMagenta TeletextColor = 0x5 TeletextColorCyan TeletextColor = 0x6 TeletextColorWhite TeletextColor = 0x7 )
func (TeletextColor) String ¶
func (c TeletextColor) String() string
String returns the string representation of TeletextColor.
type TeletextControlCode ¶
type TeletextControlCode ControlCode
TeletextControlCode (from EBU document Tech. 3240)
const ( TeletextControlCodeAlphaBlack TeletextControlCode = 0x00 TeletextControlCodeAlphaRed TeletextControlCode = 0x01 TeletextControlCodeAlphaGreen TeletextControlCode = 0x02 TeletextControlCodeAlphaYellow TeletextControlCode = 0x03 TeletextControlCodeAlphaBlue TeletextControlCode = 0x04 TeletextControlCodeAlphaMagenta TeletextControlCode = 0x05 TeletextControlCodeAlphaCyan TeletextControlCode = 0x06 TeletextControlCodeAlphaWhite TeletextControlCode = 0x07 TeletextControlCodeFlash TeletextControlCode = 0x08 TeletextControlCodeSteady TeletextControlCode = 0x09 TeletextControlCodeEndBox TeletextControlCode = 0x0A TeletextControlCodeStartBox TeletextControlCode = 0x0B TeletextControlCodeNormalHeight TeletextControlCode = 0x0C TeletextControlCodeDoubleHeight TeletextControlCode = 0x0D TeletextControlCodeDoubleWidth TeletextControlCode = 0x0E TeletextControlCodeDoubleSize TeletextControlCode = 0x0F TeletextControlCodeMosaicBlack TeletextControlCode = 0x10 TeletextControlCodeMosaicRed TeletextControlCode = 0x11 TeletextControlCodeMosaicGreen TeletextControlCode = 0x12 TeletextControlCodeMosaicYellow TeletextControlCode = 0x13 TeletextControlCodeMosaicBlue TeletextControlCode = 0x14 TeletextControlCodeMosaicMagenta TeletextControlCode = 0x15 TeletextControlCodeMosaicCyan TeletextControlCode = 0x16 TeletextControlCodeMosaicWhite TeletextControlCode = 0x17 TeletextControlCodeConceal TeletextControlCode = 0x18 TeletextControlCodeContiguousMosaic TeletextControlCode = 0x19 TeletextControlCodeSeparatedMosaic TeletextControlCode = 0x1A TeletextControlCodeReserved TeletextControlCode = 0x1B TeletextControlCodeBlackBackground TeletextControlCode = 0x1C TeletextControlCodeNewBackground TeletextControlCode = 0x1D TeletextControlCodeHoldMosaic TeletextControlCode = 0x1E TeletextControlCodeReleaseMosaic TeletextControlCode = 0x1F )
func (TeletextControlCode) String ¶
func (c TeletextControlCode) String() string
String returns the string representation of TeletextControlCode.
type TextDecoder ¶
type TextDecoder interface { // Decode decodes a X-encoded byte slice to a UTF-8 byte slice. Decode(b []byte) ([]byte, error) }
TextDecoder is a decoder for text.
type TextEncoder ¶
type TextEncoder interface { // Encode decodes a UTF-8 byte slice to a X-encoded byte slice. Encode(b []byte) ([]byte, error) }
TextEncoder is an encoder for text.
type TimeCodeStatus ¶
type TimeCodeStatus byte
TimeCodeStatus is indicating the validity of the information given in the GSI and TTI blocks containing time-code data. Only "Not intended for use" (0) and "Intended for use" (1) are supported values.
const ( TimeCodeStatusInvalid TimeCodeStatus = 0xFF TimeCodeStatusNotIntendedForUse TimeCodeStatus = 0x00 TimeCodeStatusIntendedForUse TimeCodeStatus = 0x01 )
func (TimeCodeStatus) String ¶
func (tcs TimeCodeStatus) String() string
String returns the string representation of TimeCodeStatus.
type Timecode ¶
Timecode represents a temporal position.
func TimecodeFromDuration ¶
TimecodeFromDuration returns a timecode from the given time.Duration.
func TimecodeFromFrames ¶
TimecodeFromFrames returns a timecode from the given number of frames.
func (*Timecode) Correct ¶
Correct corrects the timecode to make sure that the values are within the valid ranges. For example, if the timecode is 00:00:00:30 with a framerate of 25, the timecode will be corrected to 00:00:01:05.
func (Timecode) ToDuration ¶
ToDuration returns timecode time.Duration representation.
type ValidateError ¶
type ValidateError struct {
// contains filtered or unexported fields
}
ValidateError is an error that occurred during validation. It carries the value that caused the error. ValidateError implements the error and Unwrap interfaces.
func (*ValidateError) Error ¶
func (e *ValidateError) Error() string
Error returns the error message.
func (*ValidateError) IsFatal ¶
func (e *ValidateError) IsFatal() bool
IsFatal returns true if the error is fatal.
func (*ValidateError) Unwrap ¶
func (e *ValidateError) Unwrap() error
Unwrap returns the underlying error.
func (*ValidateError) Value ¶
func (e *ValidateError) Value() any
Value returns the value that caused the error.
Source Files ¶
- control.go
- debug.go
- encoding_error.go
- field.go
- file.go
- file_validation.go
- gsi.go
- gsi_encoding.go
- gsi_error.go
- gsi_field.go
- gsi_types.go
- gsi_validation.go
- iso6937_2.go
- text_encoding.go
- timecode.go
- tti.go
- tti_encoding.go
- tti_error.go
- tti_field.go
- tti_types.go
- tti_validation.go
- utils.go
- validation.go
- validation_error.go