diff --git a/format/rtspv2/client.go b/format/rtspv2/client.go index d32e207..5cfcb1d 100644 --- a/format/rtspv2/client.go +++ b/format/rtspv2/client.go @@ -585,7 +585,6 @@ func (client *RTSPClient) RTPDemuxer(payloadRAW *[]byte) ([]*av.Packet, bool) { client.PreVideoTS = timestamp } if timestamp-client.PreVideoTS < 0 { - //var ui32 uint64 = math.MaxUint32 if math.MaxUint32-client.PreVideoTS < 90*100 { //100 ms client.PreVideoTS = 0 client.PreVideoTS -= (math.MaxUint32 - client.PreVideoTS) @@ -715,7 +714,7 @@ func (client *RTSPClient) RTPDemuxer(payloadRAW *[]byte) ([]*av.Packet, bool) { } } default: - //client.Println("Unsupported NAL Type", naluType) + client.Println("Unsupported NAL Type", naluType) } } } diff --git a/format/webrtcv3/adapter.go b/format/webrtcv3/adapter.go index c93cbf1..13bf90a 100644 --- a/format/webrtcv3/adapter.go +++ b/format/webrtcv3/adapter.go @@ -7,11 +7,11 @@ import ( "log" "time" - "github.com/pion/interceptor" - "github.com/pion/webrtc/v3" + "github.com/deepch/vdk/codec/h264parser" "github.com/deepch/vdk/av" - "github.com/deepch/vdk/codec/h264parser" + "github.com/pion/interceptor" + "github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3/pkg/media" ) @@ -219,12 +219,29 @@ func (element *Muxer) WritePacket(pkt av.Packet) (err error) { } switch tmp.codec.Type() { case av.H264: - codec := tmp.codec.(h264parser.CodecData) - if pkt.IsKeyFrame { - pkt.Data = append([]byte{0, 0, 0, 1}, bytes.Join([][]byte{codec.SPS(), codec.PPS(), pkt.Data[4:]}, []byte{0, 0, 0, 1})...) - } else { - pkt.Data = pkt.Data[4:] + nalus, _ := h264parser.SplitNALUs(pkt.Data) + for _, nalu := range nalus { + naltype := nalu[0] & 0x1f + if naltype == 5 { + codec := tmp.codec.(h264parser.CodecData) + err = tmp.track.WriteSample(media.Sample{Data: append([]byte{0, 0, 0, 1}, bytes.Join([][]byte{codec.SPS(), codec.PPS(), nalu}, []byte{0, 0, 0, 1})...), Duration: pkt.Duration}) + } else { + err = tmp.track.WriteSample(media.Sample{Data: append([]byte{0, 0, 0, 1}, nalu...), Duration: pkt.Duration}) + } + if err != nil { + return err + } } + WritePacketSuccess = true + return + /* + codec := tmp.codec.(h264parser.CodecData) + if pkt.IsKeyFrame { + pkt.Data = append([]byte{0, 0, 0, 1}, bytes.Join([][]byte{codec.SPS(), codec.PPS(), pkt.Data[4:]}, []byte{0, 0, 0, 1})...) + } else { + pkt.Data = pkt.Data[4:] + } + */ case av.PCM_ALAW: case av.OPUS: case av.PCM_MULAW: