mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
add MP4A-LATM decoder and encoder (#299)
This commit is contained in:
@@ -6,10 +6,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
|
||||
"github.com/pion/rtp"
|
||||
|
||||
"github.com/bluenviron/gortsplib/v3/pkg/formats/rtpmpeg4audio"
|
||||
"github.com/bluenviron/mediacommon/pkg/codecs/mpeg4audio"
|
||||
)
|
||||
|
||||
// MPEG4Audio is an alias for MPEG4AudioGeneric.
|
||||
@@ -170,19 +170,40 @@ func (f *MPEG4AudioGeneric) PTSEqualsDTS(*rtp.Packet) bool {
|
||||
}
|
||||
|
||||
// CreateDecoder creates a decoder able to decode the content of the format.
|
||||
//
|
||||
// Deprecated: this has been replaced by CreateDecoder2() that can also return an error.
|
||||
func (f *MPEG4AudioGeneric) CreateDecoder() *rtpmpeg4audio.Decoder {
|
||||
d, _ := f.CreateDecoder2()
|
||||
return d
|
||||
}
|
||||
|
||||
// CreateDecoder2 creates a decoder able to decode the content of the format.
|
||||
func (f *MPEG4AudioGeneric) CreateDecoder2() (*rtpmpeg4audio.Decoder, error) {
|
||||
d := &rtpmpeg4audio.Decoder{
|
||||
SampleRate: f.Config.SampleRate,
|
||||
SizeLength: f.SizeLength,
|
||||
IndexLength: f.IndexLength,
|
||||
IndexDeltaLength: f.IndexDeltaLength,
|
||||
}
|
||||
d.Init()
|
||||
return d
|
||||
|
||||
err := d.Init()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return d, nil
|
||||
}
|
||||
|
||||
// CreateEncoder creates an encoder able to encode the content of the format.
|
||||
//
|
||||
// Deprecated: this has been replaced by CreateEncoder2() that can also return an error.
|
||||
func (f *MPEG4AudioGeneric) CreateEncoder() *rtpmpeg4audio.Encoder {
|
||||
e, _ := f.CreateEncoder2()
|
||||
return e
|
||||
}
|
||||
|
||||
// CreateEncoder2 creates an encoder able to encode the content of the format.
|
||||
func (f *MPEG4AudioGeneric) CreateEncoder2() (*rtpmpeg4audio.Encoder, error) {
|
||||
e := &rtpmpeg4audio.Encoder{
|
||||
PayloadType: f.PayloadTyp,
|
||||
SampleRate: f.Config.SampleRate,
|
||||
@@ -190,6 +211,11 @@ func (f *MPEG4AudioGeneric) CreateEncoder() *rtpmpeg4audio.Encoder {
|
||||
IndexLength: f.IndexLength,
|
||||
IndexDeltaLength: f.IndexDeltaLength,
|
||||
}
|
||||
e.Init()
|
||||
return e
|
||||
|
||||
err := e.Init()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user