mirror of https://bitbucket.org/ausocean/av.git
container/mts: using MPEG-TS in comments rather than MPEGTS or mpegts
This commit is contained in:
parent
5e705f793e
commit
51f4d123bf
|
@ -4,7 +4,7 @@ NAME
|
|||
|
||||
DESCRIPTION
|
||||
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.
|
||||
|
||||
AUTHOR
|
||||
|
@ -33,7 +33,7 @@ import (
|
|||
"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.
|
||||
type DiscontinuityRepairer struct {
|
||||
expCC map[int]int
|
||||
|
@ -56,7 +56,7 @@ func (dr *DiscontinuityRepairer) Failed() {
|
|||
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
|
||||
// is set to true.
|
||||
func (dr *DiscontinuityRepairer) Repair(d []byte) error {
|
||||
|
|
|
@ -124,7 +124,7 @@ const (
|
|||
pcrFreq = 90000 // Hz
|
||||
)
|
||||
|
||||
// Encoder encapsulates properties of an mpegts generator.
|
||||
// Encoder encapsulates properties of an MPEG-TS generator.
|
||||
type Encoder struct {
|
||||
dst io.WriteCloser
|
||||
|
||||
|
@ -201,7 +201,7 @@ func (e *Encoder) TimeBasedPsi(b bool, sendCount int) {
|
|||
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.
|
||||
func (e *Encoder) Write(data []byte) (int, error) {
|
||||
now := time.Now()
|
||||
|
@ -256,7 +256,7 @@ func (e *Encoder) Write(data []byte) (int, error) {
|
|||
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.
|
||||
func (e *Encoder) writePSI() error {
|
||||
// Write PAT.
|
||||
|
|
|
@ -53,7 +53,7 @@ func (d *destination) Write(p []byte) (int, error) {
|
|||
}
|
||||
|
||||
// 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.
|
||||
func TestEncodeVideo(t *testing.T) {
|
||||
Meta = meta.New()
|
||||
|
@ -148,8 +148,8 @@ func TestEncodeVideo(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// TestEncodePcm tests the mpegts 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.
|
||||
// TestEncodePcm tests the MPEG-TS encoder's ability to encode pcm audio data.
|
||||
// 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) {
|
||||
Meta = meta.New()
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
NAME
|
||||
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
|
||||
See Readme.md
|
||||
|
@ -48,7 +48,7 @@ const (
|
|||
// StreamID is the id of the first stream.
|
||||
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
|
||||
|
||||
// Consts relating to adaptation field.
|
||||
|
@ -159,23 +159,23 @@ type Packet struct {
|
|||
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.
|
||||
func FindPmt(d []byte) ([]byte, int, error) {
|
||||
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.
|
||||
func FindPat(d []byte) ([]byte, int, error) {
|
||||
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.
|
||||
func FindPid(d []byte, pid uint16) (pkt []byte, i int, err error) {
|
||||
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 {
|
||||
p := (uint16(d[i+1]&0x1f) << 8) | uint16(d[i+2])
|
||||
|
|
|
@ -97,7 +97,7 @@ func TestBytes(t *testing.T) {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
const targetPacketNum, numOfPackets, targetPid, stdPid = 6, 15, 1, 0
|
||||
|
||||
|
|
|
@ -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
|
||||
// addition to an mpegts packet
|
||||
// addition to an MPEG-TS packet
|
||||
func AddPadding(d []byte) []byte {
|
||||
t := make([]byte, PacketSize)
|
||||
copy(t, d)
|
||||
|
|
|
@ -32,7 +32,7 @@ import (
|
|||
"github.com/Comcast/gots/psi"
|
||||
)
|
||||
|
||||
// PacketSize of psi (without mpegts header)
|
||||
// PacketSize of psi (without MPEG-TS header)
|
||||
const PacketSize = 184
|
||||
|
||||
// Lengths of section definitions.
|
||||
|
|
Loading…
Reference in New Issue