MCPcopy Create free account
hub / github.com/Monibuca/engine / ReadPMT

Function ReadPMT

codec/mpegts/mpegts_pmt.go:97–177  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

95}
96
97func ReadPMT(r io.Reader) (pmt MpegTsPMT, err error) {
98 lr, psi, err := ReadPSI(r, PSI_TYPE_PMT)
99 if err != nil {
100 return
101 }
102
103 pmt = psi.Pmt
104
105 // reserved3(3) + pcrPID(13)
106 pcrPID, err := util.ReadByteToUint16(lr, true)
107 if err != nil {
108 return
109 }
110
111 pmt.PcrPID = pcrPID & 0x1fff
112
113 // reserved4(4) + programInfoLength(12)
114 // programInfoLength(12) == 0x00(固定为0) + programInfoLength(10)
115 programInfoLength, err := util.ReadByteToUint16(lr, true)
116 if err != nil {
117 return
118 }
119
120 pmt.ProgramInfoLength = programInfoLength & 0x3ff
121
122 // 如果length>0那么,紧跟programInfoLength后面就有length个字节
123 if pmt.ProgramInfoLength > 0 {
124 lr := &io.LimitedReader{R: lr, N: int64(pmt.ProgramInfoLength)}
125 pmt.ProgramInfoDescriptor, err = ReadPMTDescriptor(lr)
126 if err != nil {
127 return
128 }
129 }
130
131 // N Loop
132 // 开始N循环,读取所有的流的信息
133 for lr.N > 0 {
134 var streams MpegTsPmtStream
135 // streamType(8)
136 streams.StreamType, err = util.ReadByteToUint8(lr)
137 if err != nil {
138 return
139 }
140
141 // reserved5(3) + elementaryPID(13)
142 streams.ElementaryPID, err = util.ReadByteToUint16(lr, true)
143 if err != nil {
144 return
145 }
146
147 streams.ElementaryPID = streams.ElementaryPID & 0x1fff
148
149 // reserved6(4) + esInfoLength(12)
150 // esInfoLength(12) == 0x00(固定为0) + esInfoLength(10)
151 streams.EsInfoLength, err = util.ReadByteToUint16(lr, true)
152 if err != nil {
153 return
154 }

Callers 2

ReadPMTMethod · 0.85
FeedMethod · 0.85

Calls 5

ReadByteToUint16Function · 0.92
ReadByteToUint8Function · 0.92
ReadPSIFunction · 0.85
ReadPMTDescriptorFunction · 0.85
ReadCrc32UIntAndCheckMethod · 0.80

Tested by

no test coverage detected