Skip to content

Commit

Permalink
move AUD logic into mediacommon (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 25, 2024
1 parent a9149e0 commit b3204e7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 18 deletions.
7 changes: 2 additions & 5 deletions examples/client-play-format-h264-save-to-disk/mpegts_muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func (e *mpegtsMuxer) close() {

// writeH264 writes a H264 access unit into MPEG-TS.
func (e *mpegtsMuxer) writeH264(au [][]byte, pts time.Duration) error {
// prepend an AUD. This is required by some players
filteredAU := [][]byte{
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
}
var filteredAU [][]byte

nonIDRPresent := false
idrPresent := false
Expand Down Expand Up @@ -86,7 +83,7 @@ func (e *mpegtsMuxer) writeH264(au [][]byte, pts time.Duration) error {

au = filteredAU

if len(au) <= 1 || (!nonIDRPresent && !idrPresent) {
if au == nil || (!nonIDRPresent && !idrPresent) {
return nil
}

Expand Down
7 changes: 2 additions & 5 deletions examples/client-play-format-h265-save-to-disk/mpegts_muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ func (e *mpegtsMuxer) close() {

// writeH265 writes a H265 access unit into MPEG-TS.
func (e *mpegtsMuxer) writeH265(au [][]byte, pts time.Duration) error {
// prepend an AUD. This is required by some players
filteredAU := [][]byte{
{byte(h265.NALUType_AUD_NUT) << 1, 1, 0x50},
}
var filteredAU [][]byte

isRandomAccess := false

Expand Down Expand Up @@ -87,7 +84,7 @@ func (e *mpegtsMuxer) writeH265(au [][]byte, pts time.Duration) error {

au = filteredAU

if len(au) <= 1 {
if au == nil {
return nil
}

Expand Down
7 changes: 2 additions & 5 deletions examples/server-h264-save-to-disk/mpegts_muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func (e *mpegtsMuxer) close() {

// writeH264 writes a H264 access unit into MPEG-TS.
func (e *mpegtsMuxer) writeH264(au [][]byte, pts time.Duration) error {
// prepend an AUD. This is required by some players
filteredAU := [][]byte{
{byte(h264.NALUTypeAccessUnitDelimiter), 240},
}
var filteredAU [][]byte

nonIDRPresent := false
idrPresent := false
Expand Down Expand Up @@ -86,7 +83,7 @@ func (e *mpegtsMuxer) writeH264(au [][]byte, pts time.Duration) error {

au = filteredAU

if len(au) <= 1 || (!nonIDRPresent && !idrPresent) {
if au == nil || (!nonIDRPresent && !idrPresent) {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bluenviron/gortsplib/v4
go 1.20

require (
github.com/bluenviron/mediacommon v1.11.0
github.com/bluenviron/mediacommon v1.11.1-0.20240525122142-20163863aa75
github.com/google/uuid v1.6.0
github.com/pion/rtcp v1.2.14
github.com/pion/rtp v1.8.7-0.20240429002300-bc5124c9d0d0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/asticode/go-astikit v0.30.0 h1:DkBkRQRIxYcknlaU7W7ksNfn4gMFsB0tqMJflx
github.com/asticode/go-astikit v0.30.0/go.mod h1:h4ly7idim1tNhaVkdVBeXQZEE3L0xblP7fCWbgwipF0=
github.com/asticode/go-astits v1.13.0 h1:XOgkaadfZODnyZRR5Y0/DWkA9vrkLLPLeeOvDwfKZ1c=
github.com/asticode/go-astits v1.13.0/go.mod h1:QSHmknZ51pf6KJdHKZHJTLlMegIrhega3LPWz3ND/iI=
github.com/bluenviron/mediacommon v1.11.0 h1:1xY4QGYz7da9tsV2Xvd+ol+Ul5qq2g7ADJtIlVkQSRI=
github.com/bluenviron/mediacommon v1.11.0/go.mod h1:HDyW2CzjvhYJXtdxstdFPio3G0qSocPhqkhUt/qffec=
github.com/bluenviron/mediacommon v1.11.1-0.20240525122142-20163863aa75 h1:5P8Um+ySuwZApuVS9gI6U0MnrIFybTfLrZSqV2ie5lA=
github.com/bluenviron/mediacommon v1.11.1-0.20240525122142-20163863aa75/go.mod h1:HDyW2CzjvhYJXtdxstdFPio3G0qSocPhqkhUt/qffec=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit b3204e7

Please sign in to comment.