mirror of https://bitbucket.org/ausocean/av.git
Merged in feature/103 (pull request #209)
Export StandardPAT, StandardPMT and MaxPTS. Approved-by: Saxon Milton <saxon.milton@gmail.com> Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
commit
44089d9c35
|
@ -34,10 +34,10 @@ import (
|
||||||
"bitbucket.org/ausocean/av/container/mts/psi"
|
"bitbucket.org/ausocean/av/container/mts/psi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Some common manifestations of PSI
|
// Some common manifestations of PSI.
|
||||||
var (
|
var (
|
||||||
// standardPat is a minimal PAT.
|
// StandardPAT is a minimal PAT.
|
||||||
standardPat = psi.PSI{
|
StandardPAT = psi.PSI{
|
||||||
Pf: 0x00,
|
Pf: 0x00,
|
||||||
Tid: 0x00,
|
Tid: 0x00,
|
||||||
Ssi: true,
|
Ssi: true,
|
||||||
|
@ -55,6 +55,21 @@ var (
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Base PMT is a minimal PMT without specific data.
|
||||||
|
BasePMT = psi.PSI{
|
||||||
|
Pf: 0x00,
|
||||||
|
Tid: 0x02,
|
||||||
|
Ssi: true,
|
||||||
|
Sl: 0x12,
|
||||||
|
Tss: &psi.TSS{
|
||||||
|
Tide: 0x01,
|
||||||
|
V: 0,
|
||||||
|
Cni: true,
|
||||||
|
Sn: 0,
|
||||||
|
Lsn: 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -69,7 +84,7 @@ const (
|
||||||
var Meta *meta.Data
|
var Meta *meta.Data
|
||||||
|
|
||||||
var (
|
var (
|
||||||
patTable = standardPat.Bytes()
|
patTable = StandardPAT.Bytes()
|
||||||
pmtTable []byte
|
pmtTable []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,6 +117,9 @@ const (
|
||||||
|
|
||||||
// PTSFrequency is the presentation timestamp frequency in Hz.
|
// PTSFrequency is the presentation timestamp frequency in Hz.
|
||||||
PTSFrequency = 90000
|
PTSFrequency = 90000
|
||||||
|
|
||||||
|
// MaxPTS is the largest PTS value (i.e., for a 33-bit unsigned integer).
|
||||||
|
MaxPTS = (1 << 33) - 1
|
||||||
)
|
)
|
||||||
|
|
||||||
// Encoder encapsulates properties of an MPEG-TS generator.
|
// Encoder encapsulates properties of an MPEG-TS generator.
|
||||||
|
@ -143,29 +161,17 @@ func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
sid = H264ID
|
sid = H264ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// standardPmt is a minimal PMT, without descriptors for metadata.
|
pmt := BasePMT
|
||||||
pmtTable = (&psi.PSI{
|
pmt.Tss.Sd = &psi.PMT{
|
||||||
Pf: 0x00,
|
Pcrpid: 0x0100,
|
||||||
Tid: 0x02,
|
Pil: 0,
|
||||||
Ssi: true,
|
Essd: &psi.ESSD{
|
||||||
Sl: 0x12,
|
St: byte(sid),
|
||||||
Tss: &psi.TSS{
|
Epid: 0x0100,
|
||||||
Tide: 0x01,
|
Esil: 0x00,
|
||||||
V: 0,
|
|
||||||
Cni: true,
|
|
||||||
Sn: 0,
|
|
||||||
Lsn: 0,
|
|
||||||
Sd: &psi.PMT{
|
|
||||||
Pcrpid: 0x0100,
|
|
||||||
Pil: 0,
|
|
||||||
Essd: &psi.ESSD{
|
|
||||||
St: byte(sid),
|
|
||||||
Epid: 0x0100,
|
|
||||||
Esil: 0x00,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}).Bytes()
|
}
|
||||||
|
pmtTable = pmt.Bytes()
|
||||||
|
|
||||||
return &Encoder{
|
return &Encoder{
|
||||||
dst: dst,
|
dst: dst,
|
||||||
|
|
|
@ -173,6 +173,10 @@ func TestErorHandling(t *testing.T) {
|
||||||
// TestFromFrame tests streaming from a single H.264 frame which is repeated.
|
// TestFromFrame tests streaming from a single H.264 frame which is repeated.
|
||||||
func TestFromFrame(t *testing.T) {
|
func TestFromFrame(t *testing.T) {
|
||||||
testLog(0, "TestFromFrame")
|
testLog(0, "TestFromFrame")
|
||||||
|
testFrame := os.Getenv("RTMP_TEST_FRAME")
|
||||||
|
if testFrame == "" {
|
||||||
|
t.Skip("Skipping TestFromFrame since no RTMP_TEST_FRAME")
|
||||||
|
}
|
||||||
if testKey == "" {
|
if testKey == "" {
|
||||||
t.Skip("Skipping TestFromFrame since no RTMP_TEST_KEY")
|
t.Skip("Skipping TestFromFrame since no RTMP_TEST_KEY")
|
||||||
}
|
}
|
||||||
|
@ -181,7 +185,6 @@ func TestFromFrame(t *testing.T) {
|
||||||
t.Errorf("Dial failed with error: %v", err)
|
t.Errorf("Dial failed with error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
testFrame := os.Getenv("RTMP_TEST_FRAME")
|
|
||||||
b, err := ioutil.ReadFile(testFrame)
|
b, err := ioutil.ReadFile(testFrame)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("ReadFile failed with error: %v", err)
|
t.Errorf("ReadFile failed with error: %v", err)
|
||||||
|
|
Loading…
Reference in New Issue