use h264parser.CheckNALUsType for muxer and demuxer
This commit is contained in:
parent
f8b8ea404c
commit
ebdf95b174
15
rtmp.go
15
rtmp.go
@ -708,7 +708,11 @@ func (self *Conn) ReadPacket() (pkt av.Packet, err error) {
|
||||
switch tag := _tag.(type) {
|
||||
case *flvio.Videodata:
|
||||
pkt.CompositionTime = tsToTime(uint32(tag.CompositionTime))
|
||||
pkt.Data = tag.Data
|
||||
if typ := h264parser.CheckNALUsType(tag.Data); typ != h264parser.NALU_AVCC {
|
||||
err = fmt.Errorf("rtmp: input h264 nalu format=%d invalid", typ)
|
||||
return
|
||||
}
|
||||
pkt.Data = tag.Data[4:]
|
||||
pkt.IsKeyFrame = tag.FrameType == flvio.FRAME_KEY
|
||||
pkt.Idx = int8(self.videostreamidx)
|
||||
break poll
|
||||
@ -809,7 +813,14 @@ func (self *Conn) WritePacket(pkt av.Packet) (err error) {
|
||||
}
|
||||
|
||||
case av.H264:
|
||||
videodata := self.makeH264Videodata(flvio.AVC_NALU, pkt.IsKeyFrame, pkt.Data)
|
||||
if typ := h264parser.CheckNALUsType(pkt.Data); typ != h264parser.NALU_RAW {
|
||||
err = fmt.Errorf("rtmp: h264 nalu format=%d invalid", typ)
|
||||
return
|
||||
}
|
||||
var b [4]byte
|
||||
pio.PutU32BE(b[:], uint32(len(pkt.Data)))
|
||||
videodata := self.makeH264Videodata(flvio.AVC_NALU, pkt.IsKeyFrame, []byte{})
|
||||
videodata.Datav = [][]byte{b[:], pkt.Data}
|
||||
videodata.CompositionTime = int32(timeToTs(pkt.CompositionTime))
|
||||
w := self.writeVideoDataStart()
|
||||
videodata.Marshal(w)
|
||||
|
Loading…
x
Reference in New Issue
Block a user