Comcast / gots

MPEG Transport Stream handling in Go
Other
308 stars 88 forks source link

Scte35 creation #94

Closed alextarasov1 closed 6 years ago

alextarasov1 commented 6 years ago

Added functionality that allows for the creation and modification of SCTE35. Exposed some private fields from SCTE35 related interfaces, such as mid. Segmentation Descriptors, Splice Commands, and SCTE35 are able to decode all of the fields instead of just skipping over them. Added Interfaces and structures that were necessary to achieve this. Every field that can be decoded into a struct can now also be encoded back into bytes.

PSI interface was removed because nothing implemented it. It was replaced by a TableHeader struct.

Tests were added for both the new SCTE35 functions and the TableHeader functions.

Example of how to use the new SCTE35 functions:

scte := scte35.CreateSCTE35()
scte.SetTier(0xFFF)
cmd := scte35.CreateTimeSignalCommand()
scte.SetCommandInfo(cmd)
cmd.SetHasPTS(true)
scte.SetPTS(0x86DF7550)

descriptor := scte35.CreateSegmentationDescriptor()
descriptor.SetEventID(0x41424344)
descriptor.SetIsEventCanceled(false)
descriptor.SetHasProgramSegmentation(true)
descriptor.SetHasDuration(false)
descriptor.SetIsDeliveryNotRestricted(false)
descriptor.SetIsWebDeliveryAllowed(false)
descriptor.SetHasNoRegionalBlackout(true)
descriptor.SetIsArchiveAllowed(true)
descriptor.SetDeviceRestrictions(scte35.RestrictNone)
descriptor.SetUPIDType(scte35.SegUPIDNotUsed)

descriptor.SetTypeID(0x10)
descriptor.SetSegmentNumber(1)
descriptor.SetSegmentsExpected(1)

scte.SetDescriptors([]scte35.SegmentationDescriptor{descriptor})

fmt.Printf("%X\n", scte.UpdateData())