Documentation
ΒΆ
Index ΒΆ
- func Hexed(somebites []byte) string
- func IsIn[T comparable](slice []T, val T) bool
- func MkCrc32(data []byte) string
- type AvailDescriptor
- type BandwidthReservation
- type Command
- type Cue
- type DTMFDescriptor
- type Descriptor
- type InfoSection
- type NameAndType
- type Pids
- type PrivateCommand
- type SegmentationDescriptor
- type SpliceInsert
- type SpliceNull
- type SpliceTime
- type Stream
- type TagLenNameId
- type TimeDescriptor
- type TimeSignal
- type Upid
Examples ΒΆ
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
Types ΒΆ
type AvailDescriptor ΒΆ
type AvailDescriptor struct { TagLenNameId ProviderAvailID uint32 }
Avail Descriptor
type Command ΒΆ
type Command struct { NameAndType SpliceTime BandwidthReservation SpliceInsert SpliceNull PrivateCommand TimeSignal }
Command
These Splice Command types are consolidated into Command, this is done to enable dot notation in a SCTE-35 Cue. 0x0: Splice Null, 0x5: Splice Insert, 0x6: Time Signal, 0x7: Bandwidth Reservation, 0xff: Private Command,
func (*Command) MarshalJSON ΒΆ
MarshalJSON trims down a Command instance to a specific type and then turns it into JSON.
type Cue ΒΆ
type Cue struct { InfoSection *InfoSection Command *Command Dll uint16 `json:"DescriptorLoopLength"` Descriptors []Descriptor `json:",omitempty"` Crc32 string PacketData *packetData `json:",omitempty"` }
* Cue is a SCTE35 cue.
A Cue contains:
1 InfoSection 1 Crc32 1 Command 1 Dll Descriptor loop length 0 or more Splice Descriptors 1 packetData (if parsed from MPEGTS)
*
func Json2Cue ΒΆ
Take a JSON string and return a *Cue
Example ΒΆ
package main import ( "github.com/superkabuki/skdc" ) func main() { js := `{ "InfoSection": { "Name": "Splice Info Section", "TableID": "0xfc", "SectionSyntaxIndicator": false, "Private": false, "Reserved": "0x3", "SectionLength": 42, "ProtocolVersion": 0, "EncryptedPacket": false, "EncryptionAlgorithm": 0, "PtsAdjustment": 0, "CwIndex": "0xff", "Tier": "0xfff", "CommandLength": 15, "CommandType": 5 }, "Command": { "Name": "Splice Insert", "CommandType": 5, "SpliceEventID": 5690, "OutOfNetworkIndicator": true, "ProgramSpliceFlag": true, "TimeSpecifiedFlag": true, "PTS": 23683.480033 }, "DescriptorLoopLength": 10, "Descriptors": [ { "Length": 8, "Identifier": "CUEI", "Name": "Avail Descriptor" } ] } ` cue := skdc.Json2Cue(js) cue.Show() }
Output:
func NewCue ΒΆ
func NewCue() *Cue
initialize and return a *Cue
Example ΒΆ
package main import ( "github.com/superkabuki/skdc" ) func main() { data := "/DCtAAAAAAAAAP/wBQb+Tq9DwQCXAixDVUVJCUvhcH+fAR1QQ1IxXzEyMTYyMTE0MDBXQUJDUkFDSEFFTFJBWSEBAQIsQ1VFSQlL4W9/nwEdUENSMV8xMjE2MjExNDAwV0FCQ1JBQ0hBRUxSQVkRAQECGUNVRUkJTBwVf58BClRLUlIxNjA4NEEQAQECHkNVRUkJTBwWf98AA3clYAEKVEtSUjE2MDg0QSABAdHBXYA=" cue := skdc.NewCue() // cue.Command = &skdc.Command{} cue.Decode(data) cue.Show() }
Output:
func (*Cue) AdjustPts ΒΆ
AdjustPts adds seconds to cue.InfoSection.PtsAdjustment
Example ΒΆ
package main import ( "fmt" "github.com/superkabuki/skdc" ) func main() { data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q==" cue := skdc.NewCue() cue.Decode(data) fmt.Println("Before calling Cue.AdjustPts") fmt.Println(data) cue.InfoSection.Show() fmt.Println() // Change cue.InfoSection.PtsAdjustment and re-encode cue to bytes cue.AdjustPts(33.333) fmt.Println("After calling Cue.AdjustPts") fmt.Println(cue.Encode2B64()) cue.InfoSection.Show() }
Output:
func (*Cue) Decode ΒΆ
Decode takes Cue data as []byte, base64 or hex string.
Example ΒΆ
package main import ( "fmt" "github.com/superkabuki/skdc" ) func main() { data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q==" cue := skdc.NewCue() cue.Decode(data) fmt.Println("Cue.Decode() parses data and populate the fields in the Cue.") cue.Show() fmt.Println("\n\nCue values can be accessed via dot notiation,") cue.Command.PTS = 987.654321 fmt.Printf("cue.Command.PTS = %v\n", cue.Command.PTS) cue.Show() }
Output:
func (*Cue) Encode ΒΆ
Encode Cue currently works for Splice Inserts and Time Signals
Example ΒΆ
package main import ( "fmt" "github.com/superkabuki/skdc" ) func main() { data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q==" cue := skdc.NewCue() cue.Decode(data) // encode to bytes fmt.Println(cue.Encode()) }
Output:
func (*Cue) Encode2B64 ΒΆ
Encode2B64 Encodes cue and returns Base64 string
Example ΒΆ
package main import ( "fmt" "github.com/superkabuki/skdc" ) func main() { data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q==" cue := skdc.NewCue() cue.Decode(data) // encode to base64 fmt.Println(cue.Encode2B64()) }
Output:
func (*Cue) Encode2Hex ΒΆ
Encode2Hex encodes cue and returns as a hex string
Example ΒΆ
package main import ( "fmt" "github.com/superkabuki/skdc" ) func main() { data := "/DAWAAAAAAAAAP/wBQb+AKmKxwAACzuu2Q==" cue := skdc.NewCue() // decode base64 data into cue cue.Decode(data) // Encode the cue as hex hexed := cue.Encode2Hex() fmt.Println(hexed) // decode the hex back into a Cue cue.Decode(hexed) cue.Show() }
Output:
func (*Cue) Show ΒΆ
func (cue *Cue) Show()
Show display SCTE-35 data as JSON.
Example ΒΆ
package main import ( "github.com/superkabuki/skdc" ) func main() { dee := "/DA0AAAAAAAAAAAABQb/4zZ7tQAeAhxDVUVJAA6Gjz/TAAESy7EICAAAAAAA0/cuIgAAjFLk9Q==" cue := skdc.NewCue() cue.Decode(dee) cue.Show() cue.Showthreefive() }
Output:
type DTMFDescriptor ΒΆ
type DTMFDescriptor struct { TagLenNameId PreRoll uint8 DTMFCount uint8 DTMFChars uint64 }
DTMF Descriptor
type Descriptor ΒΆ
type Descriptor struct { TagLenNameId AvailDescriptor DTMFDescriptor SegmentationDescriptor TimeDescriptor }
*
Descriptor is the combination of all the descriptors this is to maintain dot notation in the Cue struct.
*
func (*Descriptor) MarshalJSON ΒΆ
func (dscptr *Descriptor) MarshalJSON() ([]byte, error)
* Custom MarshalJSON Marshal a Descriptor into 0x0: AvailDescriptor, 0x1: DTMFDescriptor, 0x2: SegmentationDescriptor, 0x3: TimeDescriptor, or just return the Descriptor
*
type InfoSection ΒΆ
type InfoSection struct { Name string TableID string SectionSyntaxIndicator bool Private bool SapType uint8 SapDetails string SectionLength uint16 ProtocolVersion uint8 EncryptedPacket bool EncryptionAlgorithm uint8 PtsAdjustment float64 CwIndex string Tier string CommandLength uint16 CommandType uint8 }
InfoSection is the splice info section of the SCTE 35 cue.
type PrivateCommand ΒΆ
type PrivateCommand struct { NameAndType PrivateBytes []byte Identifier uint32 }
Private Command
type SegmentationDescriptor ΒΆ
type SegmentationDescriptor struct { TagLenNameId SegmentationEventID string SegmentationEventCancelIndicator bool SegmentationEventIDComplianceIndicator bool ProgramSegmentationFlag bool SegmentationDurationFlag bool DeliveryNotRestrictedFlag bool WebDeliveryAllowedFlag bool NoRegionalBlackoutFlag bool ArchiveAllowedFlag bool DeviceRestrictions string SegmentationDuration float64 SegmentationMessage string SegmentationUpidType uint8 SegmentationUpidLength uint8 SegmentationUpid *Upid SegmentationTypeID uint8 SegmentNum uint8 SegmentsExpected uint8 SubSegmentNum uint8 SubSegmentsExpected uint8 }
Segmentation Descriptor
type SpliceInsert ΒΆ
type SpliceInsert struct { NameAndType SpliceTime SpliceEventID uint32 `xml:"spliceEventId,attr"` SpliceEventCancelIndicator bool `xml:"spliceEventCancelIndicator,attr"` OutOfNetworkIndicator bool `xml: "outOfNetworkIndicator,attr"` ProgramSpliceFlag bool DurationFlag bool BreakDuration float64 BreakAutoReturn bool SpliceImmediateFlag bool `xml:"spliceImmediateFlag,attr"` EventIDComplianceFlag bool `xml:"eventIdComplianceFlag,attr"` UniqueProgramID uint16 `xml:"uniqueProgramId,attr"` AvailNum uint8 `xml:"availNum,attr"` AvailExpected uint8 `xml: "availsExpected,attr"` }
Splice Insert
type SpliceTime ΒΆ
type SpliceTime struct { TimeSpecifiedFlag bool `json:",omitempty"` PTS float64 `json:",omitempty"` //`xml:"pts_time"` }
SpliceTime is Used by Time Signal and Splice Insert
type Stream ΒΆ
type Stream struct { Cues []*Cue Pids *Pids Pid2Prgm map[uint16]uint16 // pid to program map Pid2Type map[uint16]uint8 // pid to stream type map Programs []uint16 Prgm2Pcr map[uint16]uint64 // program to pcr map Prgm2Pts map[uint16]uint64 // program to pts map Quiet bool // Don't call Cue.Show() when a Cue is found. // contains filtered or unexported fields }
Stream for parsing MPEGTS for SCTE-35
func (*Stream) DecodeBytes ΒΆ
DecodeBytes Parses a chunk of mpegts bytes for SCTE-35
func (*Stream) DecodeMulticast ΒΆ
Decode Multicast Notes:
- multicast urls start with udp://@
- datagram size should be 1316
type TagLenNameId ΒΆ
Tag, Length , Name and Identifier for Descriptors
type TimeDescriptor ΒΆ
type TimeDescriptor struct { TagLenNameId TAISeconds uint64 TAINano uint32 UTCOffset uint16 }
Time Descriptor
type Upid ΒΆ
type Upid struct { Name string `json:",omitempty"` UpidType uint8 `json:",omitempty"` Value string `json:",omitempty"` TSID uint16 `json:",omitempty"` Reserved uint8 `json:",omitempty"` EndOfDay uint8 `json:",omitempty"` UniqueFor uint16 `json:",omitempty"` ContentID []byte `json:",omitempty"` Upids []Upid `json:",omitempty"` FormatIdentifier string `json:",omitempty"` PrivateData []byte `json:",omitempty"` }
Upid is the Struct for Segmentation Upids
Non-standard UPID types are returned as bytes.