This commit is contained in:
deepch 2022-06-14 15:32:10 +03:00
parent b2320900f5
commit 417f833371
4 changed files with 29 additions and 5 deletions

View File

@ -121,6 +121,7 @@ var (
VP8 = MakeVideoCodecType(avCodecTypeMagic + 4)
VP9 = MakeVideoCodecType(avCodecTypeMagic + 5)
AV1 = MakeVideoCodecType(avCodecTypeMagic + 6)
MJPEG = MakeVideoCodecType(avCodecTypeMagic + 7)
AAC = MakeAudioCodecType(avCodecTypeMagic + 1)
PCM_MULAW = MakeAudioCodecType(avCodecTypeMagic + 2)
PCM_ALAW = MakeAudioCodecType(avCodecTypeMagic + 3)

10
codec/mjpeg/parser.go Normal file
View File

@ -0,0 +1,10 @@
package mjpeg
import "github.com/deepch/vdk/av"
type CodecData struct {
}
func (d CodecData) Type() av.CodecType {
return av.MJPEG
}

View File

@ -3,13 +3,15 @@ package ts
import (
"bufio"
"fmt"
"io"
"time"
"github.com/deepch/vdk/av"
"github.com/deepch/vdk/codec/aacparser"
"github.com/deepch/vdk/codec/h264parser"
"github.com/deepch/vdk/codec/mjpeg"
"github.com/deepch/vdk/format/ts/tsio"
"github.com/deepch/vdk/utils/bits/pio"
"io"
"time"
)
type Demuxer struct {
@ -117,6 +119,8 @@ func (self *Demuxer) initPMT(payload []byte) (err error) {
self.streams = append(self.streams, stream)
case tsio.ElementaryStreamTypeAdtsAAC:
self.streams = append(self.streams, stream)
case tsio.ElementaryStreamTypeAlignmentDescriptor:
self.streams = append(self.streams, stream)
}
}
return
@ -228,8 +232,16 @@ func (self *Stream) payloadEnd() (n int, err error) {
return
}
self.data = nil
switch self.streamType {
case tsio.ElementaryStreamTypeAlignmentDescriptor:
if self.CodecData == nil {
self.CodecData = mjpeg.CodecData{}
}
b := make([]byte, 4+len(payload))
pio.PutU32BE(b[0:4], uint32(len(payload)))
copy(b[4:], payload)
self.addPacket(b, time.Duration(0), 0)
n++
case tsio.ElementaryStreamTypeAdtsAAC:
var config aacparser.MPEG4AudioConfig

View File

@ -33,8 +33,9 @@ var ErrParsePMT = fmt.Errorf("invalid PMT")
var ErrParsePAT = fmt.Errorf("invalid PAT")
const (
ElementaryStreamTypeH264 = 0x1B
ElementaryStreamTypeAdtsAAC = 0x0F
ElementaryStreamTypeH264 = 0x1B
ElementaryStreamTypeAdtsAAC = 0x0F
ElementaryStreamTypeAlignmentDescriptor = 0x06
)
type PATEntry struct {