Skip to content

Commit

Permalink
Export field instead of creating method to better respect pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
YannSc committed Feb 13, 2025
1 parent 5a15836 commit e2c3e61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions codecs/h264_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import (
// H264Payloader payloads H264 packets.
type H264Payloader struct {
spsNalu, ppsNalu []byte
disableStapA bool
}

func (p *H264Payloader) DisableStapAPackets() {
p.disableStapA = true
DisableStapA bool
}

const (
Expand Down Expand Up @@ -89,16 +85,16 @@ func (p *H264Payloader) Payload(mtu uint16, payload []byte) [][]byte { //nolint:
case naluType == audNALUType || naluType == fillerNALUType:
return
case naluType == spsNALUType:
if !p.disableStapA {
if !p.DisableStapA {
p.spsNalu = nalu
return

Check failure on line 90 in codecs/h264_packet.go

View workflow job for this annotation

GitHub Actions / lint / Go

return with no blank line before (nlreturn)
}
case naluType == ppsNALUType:
if !p.disableStapA {
if !p.DisableStapA {
p.ppsNalu = nalu
return

Check failure on line 95 in codecs/h264_packet.go

View workflow job for this annotation

GitHub Actions / lint / Go

return with no blank line before (nlreturn)
}
case !p.disableStapA && p.spsNalu != nil && p.ppsNalu != nil:
case !p.DisableStapA && p.spsNalu != nil && p.ppsNalu != nil:
// Pack current NALU with SPS and PPS as STAP-A
spsLen := make([]byte, 2)
binary.BigEndian.PutUint16(spsLen, uint16(len(p.spsNalu))) // nolint: gosec // G115
Expand Down
2 changes: 1 addition & 1 deletion codecs/h264_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestH264Payloader_Payload_SPS_and_PPS_handling(t *testing.T) {

func TestH264Payloader_Payload_SPS_and_PPS_handling_no_stapA(t *testing.T) {
pck := H264Payloader{}
pck.DisableStapAPackets()
pck.DisableStapA = true

expectedSps := []byte{0x07, 0x00, 0x01}
// The SPS is packed as a single NALU
Expand Down

0 comments on commit e2c3e61

Please sign in to comment.