container/mts: using MPEG-TS in comments rather than MPEGTS or mpegts

This commit is contained in:
Saxon 2019-05-11 21:14:28 +09:30
parent 5e705f793e
commit 51f4d123bf
7 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,7 @@ NAME
DESCRIPTION DESCRIPTION
discontinuity.go provides functionality for detecting discontinuities in discontinuity.go provides functionality for detecting discontinuities in
mpegts and accounting for using the discontinuity indicator in the adaptation MPEG-TS and accounting for using the discontinuity indicator in the adaptation
field. field.
AUTHOR AUTHOR
@ -33,7 +33,7 @@ import (
"github.com/Comcast/gots/packet" "github.com/Comcast/gots/packet"
) )
// discontinuityRepairer provides function to detect discontinuities in mpegts // discontinuityRepairer provides function to detect discontinuities in MPEG-TS
// and set the discontinuity indicator as appropriate. // and set the discontinuity indicator as appropriate.
type DiscontinuityRepairer struct { type DiscontinuityRepairer struct {
expCC map[int]int expCC map[int]int
@ -56,7 +56,7 @@ func (dr *DiscontinuityRepairer) Failed() {
dr.decExpectedCC(PatPid) dr.decExpectedCC(PatPid)
} }
// Repair takes a clip of mpegts and checks that the first packet, which should // Repair takes a clip of MPEG-TS and checks that the first packet, which should
// be a PAT, contains a cc that is expected, otherwise the discontinuity indicator // be a PAT, contains a cc that is expected, otherwise the discontinuity indicator
// is set to true. // is set to true.
func (dr *DiscontinuityRepairer) Repair(d []byte) error { func (dr *DiscontinuityRepairer) Repair(d []byte) error {

View File

@ -124,7 +124,7 @@ const (
pcrFreq = 90000 // Hz pcrFreq = 90000 // Hz
) )
// Encoder encapsulates properties of an mpegts generator. // Encoder encapsulates properties of an MPEG-TS generator.
type Encoder struct { type Encoder struct {
dst io.WriteCloser dst io.WriteCloser
@ -201,7 +201,7 @@ func (e *Encoder) TimeBasedPsi(b bool, sendCount int) {
e.pktCount = e.psiSendCount e.pktCount = e.psiSendCount
} }
// Write implements io.Writer. Write takes raw h264 and encodes into mpegts, // Write implements io.Writer. Write takes raw h264 and encodes into MPEG-TS,
// then sending it to the encoder's io.Writer destination. // then sending it to the encoder's io.Writer destination.
func (e *Encoder) Write(data []byte) (int, error) { func (e *Encoder) Write(data []byte) (int, error) {
now := time.Now() now := time.Now()
@ -256,7 +256,7 @@ func (e *Encoder) Write(data []byte) (int, error) {
return len(data), nil return len(data), nil
} }
// writePSI creates mpegts with pat and pmt tables - with pmt table having updated // writePSI creates MPEG-TS with pat and pmt tables - with pmt table having updated
// location and time data. // location and time data.
func (e *Encoder) writePSI() error { func (e *Encoder) writePSI() error {
// Write PAT. // Write PAT.

View File

@ -53,7 +53,7 @@ func (d *destination) Write(p []byte) (int, error) {
} }
// TestEncodeVideo checks that we can correctly encode some dummy data into a // TestEncodeVideo checks that we can correctly encode some dummy data into a
// valid MPEGTS stream. This checks for correct MPEGTS headers and also that the // valid MPEG-TS stream. This checks for correct MPEG-TS headers and also that the
// original data is stored correctly and is retreivable. // original data is stored correctly and is retreivable.
func TestEncodeVideo(t *testing.T) { func TestEncodeVideo(t *testing.T) {
Meta = meta.New() Meta = meta.New()
@ -148,8 +148,8 @@ func TestEncodeVideo(t *testing.T) {
} }
} }
// TestEncodePcm tests the mpegts encoder's ability to encode pcm audio data. // TestEncodePcm tests the MPEG-TS encoder's ability to encode pcm audio data.
// It reads and encodes input pcm data into mpegts, then decodes the mpegts and compares the result to the input pcm. // It reads and encodes input pcm data into MPEG-TS, then decodes the MPEG-TS and compares the result to the input pcm.
func TestEncodePcm(t *testing.T) { func TestEncodePcm(t *testing.T) {
Meta = meta.New() Meta = meta.New()

View File

@ -1,7 +1,7 @@
/* /*
NAME NAME
mpegts.go - provides a data structure intended to encapsulate the properties mpegts.go - provides a data structure intended to encapsulate the properties
of an MpegTs packet and also functions to allow manipulation of these packets. of an MPEG-TS packet and also functions to allow manipulation of these packets.
DESCRIPTION DESCRIPTION
See Readme.md See Readme.md
@ -48,7 +48,7 @@ const (
// StreamID is the id of the first stream. // StreamID is the id of the first stream.
const StreamID = 0xe0 const StreamID = 0xe0
// HeadSize is the size of an mpegts packet header. // HeadSize is the size of an MPEG-TS packet header.
const HeadSize = 4 const HeadSize = 4
// Consts relating to adaptation field. // Consts relating to adaptation field.
@ -159,23 +159,23 @@ type Packet struct {
Payload []byte // Mpeg ts Payload Payload []byte // Mpeg ts Payload
} }
// FindPmt will take a clip of mpegts and try to find a PMT table - if one // FindPmt will take a clip of MPEG-TS and try to find a PMT table - if one
// is found, then it is returned along with its index, otherwise nil, -1 and an error is returned. // is found, then it is returned along with its index, otherwise nil, -1 and an error is returned.
func FindPmt(d []byte) ([]byte, int, error) { func FindPmt(d []byte) ([]byte, int, error) {
return FindPid(d, PmtPid) return FindPid(d, PmtPid)
} }
// FindPat will take a clip of mpegts and try to find a PAT table - if one // FindPat will take a clip of MPEG-TS and try to find a PAT table - if one
// is found, then it is returned along with its index, otherwise nil, -1 and an error is returned. // is found, then it is returned along with its index, otherwise nil, -1 and an error is returned.
func FindPat(d []byte) ([]byte, int, error) { func FindPat(d []byte) ([]byte, int, error) {
return FindPid(d, PatPid) return FindPid(d, PatPid)
} }
// FindPid will take a clip of mpegts and try to find a packet with given PID - if one // FindPid will take a clip of MPEG-TS and try to find a packet with given PID - if one
// is found, then it is returned along with its index, otherwise nil, -1 and an error is returned. // is found, then it is returned along with its index, otherwise nil, -1 and an error is returned.
func FindPid(d []byte, pid uint16) (pkt []byte, i int, err error) { func FindPid(d []byte, pid uint16) (pkt []byte, i int, err error) {
if len(d) < PacketSize { if len(d) < PacketSize {
return nil, -1, errors.New("MPEGTS data not of valid length") return nil, -1, errors.New("MPEG-TS data not of valid length")
} }
for i = 0; i < len(d); i += PacketSize { for i = 0; i < len(d); i += PacketSize {
p := (uint16(d[i+1]&0x1f) << 8) | uint16(d[i+2]) p := (uint16(d[i+1]&0x1f) << 8) | uint16(d[i+2])

View File

@ -97,7 +97,7 @@ func TestBytes(t *testing.T) {
} }
// TestFindPid checks that FindPid can correctly extract the first instance // TestFindPid checks that FindPid can correctly extract the first instance
// of a PID from an MPEGTS stream. // of a PID from an MPEG-TS stream.
func TestFindPid(t *testing.T) { func TestFindPid(t *testing.T) {
const targetPacketNum, numOfPackets, targetPid, stdPid = 6, 15, 1, 0 const targetPacketNum, numOfPackets, targetPid, stdPid = 6, 15, 1, 0

View File

@ -125,7 +125,7 @@ func trimTo(d []byte, t byte) []byte {
} }
// addPadding adds an appropriate amount of padding to a pat or pmt table for // addPadding adds an appropriate amount of padding to a pat or pmt table for
// addition to an mpegts packet // addition to an MPEG-TS packet
func AddPadding(d []byte) []byte { func AddPadding(d []byte) []byte {
t := make([]byte, PacketSize) t := make([]byte, PacketSize)
copy(t, d) copy(t, d)

View File

@ -32,7 +32,7 @@ import (
"github.com/Comcast/gots/psi" "github.com/Comcast/gots/psi"
) )
// PacketSize of psi (without mpegts header) // PacketSize of psi (without MPEG-TS header)
const PacketSize = 184 const PacketSize = 184
// Lengths of section definitions. // Lengths of section definitions.