Browse Source

RTMP client: avoid errors when there are no NALUs in the queue

pull/372/head
aler9 4 years ago
parent
commit
e513f0b028
  1. 9
      internal/clientrtmp/client.go

9
internal/clientrtmp/client.go

@ -295,7 +295,7 @@ func (c *Client) runRead() {
} }
for _, nalu := range nalus { for _, nalu := range nalus {
// remove SPS, PPS and AUD, not needed by RTMP // remove SPS, PPS and AUD, not needed by RTSP
typ := h264.NALUType(nalu[0] & 0x1F) typ := h264.NALUType(nalu[0] & 0x1F)
switch typ { switch typ {
case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter: case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter:
@ -521,8 +521,9 @@ func (c *Client) runPublish() {
} }
var outNALUs [][]byte var outNALUs [][]byte
for _, nalu := range nalus { for _, nalu := range nalus {
// remove SPS, PPS and AUD, not needed by RTSP / RTMP // remove SPS, PPS and AUD, not needed by RTSP
typ := h264.NALUType(nalu[0] & 0x1F) typ := h264.NALUType(nalu[0] & 0x1F)
switch typ { switch typ {
case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter: case h264.NALUTypeSPS, h264.NALUTypePPS, h264.NALUTypeAccessUnitDelimiter:
@ -532,6 +533,10 @@ func (c *Client) runPublish() {
outNALUs = append(outNALUs, nalu) outNALUs = append(outNALUs, nalu)
} }
if len(outNALUs) == 0 {
continue
}
frames, err := h264Encoder.Encode(outNALUs, pkt.Time+pkt.CTime) frames, err := h264Encoder.Encode(outNALUs, pkt.Time+pkt.CTime)
if err != nil { if err != nil {
return fmt.Errorf("ERR while encoding H264: %v", err) return fmt.Errorf("ERR while encoding H264: %v", err)

Loading…
Cancel
Save