scte35

package module
v0.0.0-...-1f1d5be Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: Unlicense Imports: 4 Imported by: 0

README

scte35 Go Report Card

The SCTE 35 Parser in Go.

Heads up, work in progress.
What is working:

✓ Parsing MPEG-TS files

✓ Parsing Base64 strings

✓ Splice Info Section

✓ Splice Null

✓ Time Signal

✓ Splice Insert

✓ Bandwidth Reservation

✓ Private Command

Installation
go get -u github.com/futzu/scte35
Parsing local MPEG-TS files
/** call this file test.go
	
    go build test.go
	
  ./test video1 video2 video3
**/ 	
package main

import (
	"os"
	"fmt"
	"github.com/futzu/scte35"
)

func main(){

	args := os.Args[1:]
	for i := range args{
		fmt.Printf( "\nNext File: %s\n\n",args[i] )
		scte35.FileParser(args[i])
	}
}     
Parsing a base64 string
/** call this file test1.go

    go build test1.go 
    
   ./test1 "/DAvAAAAAAAA///wFAVIAACPf+/+c2nALv4AUsz1AAAAAAAKAAhDVUVJAAABNWLbowo="
**/

package main

import (
	"os"
	"fmt"
	"github.com/futzu/scte35"
)

func main() {


	args := os.Args[1:]
	for i := range args{
		bites := scte35.DeB64(args[i])
		fmt.Println(args[i])
		scte35.SCTE35Parser(bites)
	}
}

Output
{Name:Splice Info Section TableId:0xfc SectionSyntaxIndicator:false
Private:false Reserved:0x3 SectionLength:47 ProtocolVersion:0
EncryptedPacket:false EncryptionAlgorithm:0 PtsAdjustment:0 CwIndex:0xff 
Tier:0xfff SpliceCommandLength:20 SpliceCommandType:5}
{Name:Splice Insert SpliceEventId:0x4800008f SpliceEventCancelIndicator:false 
OutOfNetworkIndicator:true ProgramSpliceFlag:true DurationFlag:true BreakAutoReturn:true 
BreakDuration:60.293566 SpliceImmediateFlag:false TimeSpecifiedFlag:true PTS:21514.559088 
ComponentCount:0 Components:[] UniqueProgramId:0 AvailNum:0 AvailExpected:0 Identifier:0}

Documentation

Index

Constants

View Source
const BufferSize = 384 * PktSz

BufferSize is the size of a read when parsing files.

View Source
const PktSz = 188

PktSz is the size of an MPEG-TS packet in bytes.

Variables

This section is empty.

Functions

func Chk

func Chk(e error)

Chk is generic catchall error checking.

func DeB64

func DeB64(b64 string) []byte

DeB64 decodes base64 strings.

func FileParser

func FileParser(fname string)

FileParser is a parser for an MPEG-TS file.

func IsIn

func IsIn(slice []uint8, val uint8) bool

IsIn is a test for slice membership

func PktParser

func PktParser(pkt []byte)

PktParser is a parser for an MPEG-TS SCTE 35 packet

func SCTE35Parser

func SCTE35Parser(bites []byte)

SCTE35Parser parses a slice of bytes for SCTE 35 data.

Types

type SpCmd

type SpCmd struct {
	Name                       string
	SpliceEventId              string
	SpliceEventCancelIndicator bool
	OutOfNetworkIndicator      bool
	ProgramSpliceFlag          bool
	DurationFlag               bool
	BreakAutoReturn            bool
	BreakDuration              float64
	SpliceImmediateFlag        bool
	TimeSpecifiedFlag          bool
	PTS                        float64
	ComponentCount             uint64
	Components                 []uint64
	UniqueProgramId            uint64
	AvailNum                   uint64
	AvailExpected              uint64
	Identifier                 uint64
}

SpCmd is the splice command for the SCTE35 cue.

func (*SpCmd) BandwidthReservation

func (cmd *SpCmd) BandwidthReservation(bitn *bitter.Bitn)

BandwidthReservation splice command.

func (*SpCmd) Decode

func (cmd *SpCmd) Decode(bitn *bitter.Bitn, cmdtype uint64)

Decode the splice command values.

func (*SpCmd) ParseBreak

func (cmd *SpCmd) ParseBreak(bitn *bitter.Bitn)

ParseBreak parses out the ad break duration values.

func (*SpCmd) PrivateCommand

func (cmd *SpCmd) PrivateCommand(bitn *bitter.Bitn)

PrivateCommand splice command.

func (*SpCmd) SpliceInsert

func (cmd *SpCmd) SpliceInsert(bitn *bitter.Bitn)

SpliceInsert handles SCTE 35 splice insert commands.

func (*SpCmd) SpliceNull

func (cmd *SpCmd) SpliceNull()

SpliceNull is a No-Op command.

func (*SpCmd) SpliceTime

func (cmd *SpCmd) SpliceTime(bitn *bitter.Bitn)

SpliceTime parses out the PTS value as needed.

func (*SpCmd) TimeSignal

func (cmd *SpCmd) TimeSignal(bitn *bitter.Bitn)

TimeSignal splice command is a wrapper for SpliceTime.

type SpInfo

type SpInfo struct {
	Name                   string
	TableId                string
	SectionSyntaxIndicator bool
	Private                bool
	Reserved               string
	SectionLength          uint64
	ProtocolVersion        uint64
	EncryptedPacket        bool
	EncryptionAlgorithm    uint64
	PtsAdjustment          float64
	CwIndex                string
	Tier                   string
	SpliceCommandLength    uint64
	SpliceCommandType      uint64
	DescriptorLoopLength   uint64
}

SpInfo is the splice info section of the SCTE 35 cue.

func (*SpInfo) Decode

func (spi *SpInfo) Decode(bitn *bitter.Bitn)

Decode extracts bits for the splice info section values.

Jump to

Keyboard shortcuts

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