ts

package
v0.0.0-...-5a4bddd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2025 License: MIT Imports: 8 Imported by: 0

README

Go Transport Stream parsing

TODO

  • Removing use of TeeReader should give better performance

SCTE-35 JSON subset used:

{
   "pts": 8554888184,
   "protocol_version": 0,
   "tier": 4095,
   "encryption_algorithm": 0,
   "cw_index": 0,
   "splice_command_type": 6,
   "splice_null": {},
   "time_signal": {},
   "splice_descriptors": [
      {
         "splice_descriptor_tag": 2,
         "splice_descriptor_name": "segmentation_descriptor",
         "segmentation_event_id": 158662685,
         "segmentation_event_cancel_indicator": false,
         "segmentation_duration": 0,
         "segmentation_type_id": 33,
         "segment_num": 5,
         "segments_expected": 1,
         "sub_segment_num": 0,
         "sub_segments_expected": 0,
         "delivery_restrictions": {
            "web_delivery_allowed_flag": true,
            "no_regional_blackout_flag": true,
            "archive_allowed_flag": true,
            "device_restrictions": 3
         },
         "segmentation_upids": [
            {
               "segmentation_upid_type": 1,
               "format_identifier": 123,
               "upid": "EP034115060099 RVAwMzQxMTUwNjAwOTk="
            }
         ],
         "components": [
            {
               "component_tag": 8,
               "pts_offset": 33
            }
         ]
      },
      {
         "splice_descriptor_tag": 2,
         "...": "multiple descriptors allowed"
      }
   ]
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	ComponentTag uint8  `json:"component_tag"`
	PTSOffset    uint64 `json:"pts_offset"`
}

type DeliveryRestrictions

type DeliveryRestrictions struct {
	WebDeliveryAllowed bool                      `json:"web_delivery_allowed_flag"`
	NoRegionalBlackout bool                      `json:"no_regional_blackout_flag"`
	ArchiveAllowed     bool                      `json:"archive_allowed_flag"`
	DeviceRestrictions scte35.DeviceRestrictions `json:"device_restrictions"`
}

type Pipe

type Pipe struct {
	// contains filtered or unexported fields
}

TODO The Tee is unnecessary once we have code to parse TS packets directly Implements io.ReadCloser

func NewPipe

func NewPipe(source io.Reader, sourceCloser io.Closer, sctePID int,
	tsInfo chan<- ScteSignal) *Pipe

func (*Pipe) Close

func (t *Pipe) Close() (err error)

func (*Pipe) Read

func (t *Pipe) Read(p []byte) (n int, err error)

type ScteSignal

type ScteSignal struct {
	SpliceInfo SpliceInfo
	Err        error
}

type SegmentationUpid

type SegmentationUpid struct {
	SegmentationUpidType scte35.SegUPIDType `json:"segmentation_upid_type"`
	FormatIdentifier     uint32             `json:"format_identifier,omitempty"` // not handled
	Upid                 []byte             `json:"upid,omitempty"`
}

type SpliceDescriptor

type SpliceDescriptor struct {
	SpliceDescriptorTag uint8 `json:"splice_descriptor_tag"`

	// SegmentationDescriptor fields
	//
	// scte35.SegDescType seems to be missing:
	//   OpeningCreditStart                                   = 36
	//   OpeningCreditEnd                                     = 37
	//   ClosingCreditStart                                   = 38
	//   ClosingCreditEnd                                     = 39
	//   ProviderOverlayPlacementOpportunityStart             = 56
	//   ProviderOverlayPlacementOpportunityEnd               = 57
	//   DistributorOverlayPlacementOpportunityStart          = 58
	//   DistributorOverlayPlacementOpportunityEnd            = 59
	SegmentationEventId              uint32                `json:"segmentation_event_id"`
	SegmentationEventCancelIndicator bool                  `json:"segmentation_event_cancel_indicator"`
	SegmentationDuration             uint64                `json:"segmentation_duration,omitempty"`
	SegmentationTypeId               scte35.SegDescType    `json:"segmentation_type_id"`
	SegmentNum                       uint8                 `json:"segment_num"`
	SegmentsExpected                 uint8                 `json:"segments_expected"`
	SubSegmentNum                    uint8                 `json:"sub_segment_num"`
	SubSegmentsExpected              uint8                 `json:"sub_segments_expected"`
	DeliveryRestrictions             *DeliveryRestrictions `json:"delivery_restrictions,omitempty"`
	SegmentationUpids                []SegmentationUpid    `json:"segmentation_upids,omitempty"`
	Components                       []Component           `json:"components,omitempty"`
}

type SpliceInfo

type SpliceInfo struct {
	PID                 uint16                   `json:"pid"`
	PTS                 uint64                   `json:"pts"`
	ProtocolVersion     uint8                    `json:"protocol_version,omitempty"` // always 0
	Tier                uint16                   `json:"tier"`
	EncryptionAlgorithm uint8                    `json:"encryption_algorithm,omitempty"` // not handled
	CWIndex             uint8                    `json:"cw_index,omitempty"`             // not handled
	SpliceCommandType   scte35.SpliceCommandType `json:"splice_command_type"`
	SpliceDescriptors   []SpliceDescriptor       `json:"splice_descriptors,omitempty"`
}

The purpose of this struct is for JSON marshaling with minimal complexity

func ConvertGots

func ConvertGots(pid uint16, gsi scte35.SCTE35) (si SpliceInfo, err error)

TODO We should parse the SCTE data directly instead of going through layers of gots, which doesn't support JSON marshaling

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL