()
| 75 | } |
| 76 | |
| 77 | func (t *TSReader) ReadPES() { |
| 78 | for pes := range t.PESChan { |
| 79 | if t.Err() != nil { |
| 80 | continue |
| 81 | } |
| 82 | if pes.Header.Dts == 0 { |
| 83 | pes.Header.Dts = pes.Header.Pts |
| 84 | } |
| 85 | switch pes.Header.StreamID & 0xF0 { |
| 86 | case mpegts.STREAM_ID_VIDEO: |
| 87 | if t.VideoTrack == nil { |
| 88 | for _, s := range t.PMT.Stream { |
| 89 | t.OnPmtStream(s) |
| 90 | } |
| 91 | } |
| 92 | if t.VideoTrack != nil { |
| 93 | t.WriteAnnexB(uint32(pes.Header.Pts), uint32(pes.Header.Dts), pes.Payload) |
| 94 | } |
| 95 | default: |
| 96 | if t.AudioTrack == nil { |
| 97 | for _, s := range t.PMT.Stream { |
| 98 | t.OnPmtStream(s) |
| 99 | } |
| 100 | } |
| 101 | if t.AudioTrack != nil { |
| 102 | switch t.AudioTrack.(type) { |
| 103 | case *track.AAC: |
| 104 | t.AudioTrack.WriteADTS(uint32(pes.Header.Pts), pes.Payload) |
| 105 | case *track.G711: |
| 106 | t.AudioTrack.WriteRawBytes(uint32(pes.Header.Pts), pes.Payload) |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | } |
no test coverage detected