diff --git a/codec/mpegts/mpegts_pes.go b/codec/mpegts/mpegts_pes.go index cc223f8..84ba074 100644 --- a/codec/mpegts/mpegts_pes.go +++ b/codec/mpegts/mpegts_pes.go @@ -646,7 +646,7 @@ func PESToTs(frame *MpegtsPESFrame, packet MpegTsPESPacket) (tsPkts []byte, err err = errors.New("packetStartCodePrefix != 0x000001") return } - + bwTsHeader := &bytes.Buffer{} bwPESPkt := &bytes.Buffer{} _, err = WritePESHeader(bwPESPkt, packet.Header) if err != nil { @@ -659,8 +659,7 @@ func PESToTs(frame *MpegtsPESFrame, packet MpegTsPESPacket) (tsPkts []byte, err var tsHeaderLength int for i := 0; bwPESPkt.Len() > 0; i++ { - bwTsHeader := &bytes.Buffer{} - + bwTsHeader.Reset() tsHeader := MpegTsHeader{ SyncByte: 0x47, TransportErrorIndicator: 0, @@ -739,15 +738,14 @@ func PESToTs(frame *MpegtsPESFrame, packet MpegTsPESPacket) (tsPkts []byte, err // if tmp == 2 { // fmt.Println("fuck you mother.") // } + tsPktByteLen := len(tsHeaderByte) + len(tsPayloadByte) - tsPktByte := append(tsHeaderByte, tsPayloadByte...) - - if len(tsPktByte) != TS_PACKET_SIZE { - err = errors.New(fmt.Sprintf("%s, packet size=%d", "TS_PACKET_SIZE != 188,", len(tsPktByte))) + if tsPktByteLen != TS_PACKET_SIZE { + err = errors.New(fmt.Sprintf("%s, packet size=%d", "TS_PACKET_SIZE != 188,", tsPktByteLen)) return } - - tsPkts = append(tsPkts, tsPktByte...) + tsPkts = append(tsPkts, tsHeaderByte...) + tsPkts = append(tsPkts, tsPayloadByte...) } return diff --git a/config/types.go b/config/types.go index f02e05f..f7b80bb 100755 --- a/config/types.go +++ b/config/types.go @@ -90,7 +90,6 @@ type Engine struct { RTPReorder bool EnableAVCC bool //启用AVCC格式,rtmp协议使用 EnableRTP bool //启用RTP格式,rtsp、gb18181等协议使用 - EnableFLV bool //开启FLV格式,hdl协议使用 ConsoleURL string //远程控制台地址 Secret string //远程控制台密钥 } @@ -172,5 +171,5 @@ var Global = &Engine{ Publish{true, true, false, 10, 0}, Subscribe{true, true, true, false, 10}, HTTP{ListenAddr: ":8080", CORS: true, mux: http.DefaultServeMux}, - false, true, true, true, "wss://console.monibuca.com/ws/v1", "", + false, true, true, "wss://console.monibuca.com/ws/v1", "", } diff --git a/subscriber.go b/subscriber.go index 4e60e3a..9f7afe7 100644 --- a/subscriber.go +++ b/subscriber.go @@ -285,7 +285,6 @@ func (s *Subscriber) PlayBlock(subType byte) { break } } - continue } // 正常模式下或者纯音频模式下,音频开始播放 if s.Audio.ring != nil && s.Config.SubAudio { @@ -311,9 +310,7 @@ func (s *Subscriber) PlayBlock(subType byte) { break } } - continue } - time.Sleep(time.Second) } } diff --git a/track/audio.go b/track/audio.go index a4ab6f3..ad692c7 100644 --- a/track/audio.go +++ b/track/audio.go @@ -68,8 +68,8 @@ func (a *Audio) WriteADTS(adts []byte) { func (a *Audio) Flush() { // AVCC 格式补完 - value := a.Media.RingBuffer.Value - if len(value.AVCC) == 0 && (config.Global.EnableAVCC || config.Global.EnableFLV) { + value := &a.Media.RingBuffer.Value + if len(value.AVCC) == 0 && (config.Global.EnableAVCC) { value.AppendAVCC(a.AVCCHead) for _, raw := range value.Raw { value.AppendAVCC(raw) diff --git a/track/video.go b/track/video.go index 14b5763..d096025 100644 --- a/track/video.go +++ b/track/video.go @@ -115,7 +115,7 @@ func (vt *Video) Flush() { return } // AVCC格式补完 - if len(rv.AVCC) == 0 && (config.Global.EnableAVCC || config.Global.EnableFLV) { + if len(rv.AVCC) == 0 && (config.Global.EnableAVCC) { var b util.Buffer if cap(rv.AVCC) > 0 { if avcc := rv.AVCC[:1]; len(avcc[0]) == 5 {