mirror of
https://github.com/bluenviron/mediacommon.git
synced 2025-09-26 21:01:14 +08:00
mpeg4audio: deprecate Config (#216)
This commit is contained in:
@@ -434,15 +434,15 @@ func WriteCodecBoxes(w *Writer, codec mp4.Codec, trackID int, info *CodecInfo, a
|
||||
},
|
||||
DataReferenceIndex: 1,
|
||||
},
|
||||
ChannelCount: uint16(codec.ChannelCount),
|
||||
ChannelCount: uint16(codec.Config.ChannelCount),
|
||||
SampleSize: 16,
|
||||
SampleRate: uint32(codec.SampleRate * 65536),
|
||||
SampleRate: uint32(codec.Config.SampleRate * 65536),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
enc, _ := codec.Marshal()
|
||||
enc, _ := codec.Config.Marshal()
|
||||
|
||||
_, err = w.WriteBox(&4.Esds{ // <esds/>
|
||||
Descriptors: []amp4.Descriptor{
|
||||
|
@@ -7,6 +7,8 @@ import (
|
||||
)
|
||||
|
||||
// Config is an alias for AudioSpecificConfig.
|
||||
//
|
||||
// Deprecated: replaced by AudioSpecificConfig.
|
||||
type Config = AudioSpecificConfig
|
||||
|
||||
// AudioSpecificConfig is an AudioSpecificConfig.
|
||||
@@ -25,13 +27,13 @@ type AudioSpecificConfig struct {
|
||||
CoreCoderDelay uint16
|
||||
}
|
||||
|
||||
// Unmarshal decodes a Config.
|
||||
// Unmarshal decodes a AudioSpecificConfig.
|
||||
func (c *AudioSpecificConfig) Unmarshal(buf []byte) error {
|
||||
pos := 0
|
||||
return c.UnmarshalFromPos(buf, &pos)
|
||||
}
|
||||
|
||||
// UnmarshalFromPos decodes a Config.
|
||||
// UnmarshalFromPos decodes a AudioSpecificConfig.
|
||||
func (c *AudioSpecificConfig) UnmarshalFromPos(buf []byte, pos *int) error {
|
||||
tmp, err := bits.ReadBits(buf, pos, 5)
|
||||
if err != nil {
|
||||
@@ -187,7 +189,7 @@ func (c AudioSpecificConfig) marshalSize() int {
|
||||
return ret
|
||||
}
|
||||
|
||||
// Marshal encodes a Config.
|
||||
// Marshal encodes a AudioSpecificConfig.
|
||||
func (c AudioSpecificConfig) Marshal() ([]byte, error) {
|
||||
buf := make([]byte, c.marshalSize())
|
||||
pos := 0
|
||||
|
@@ -471,7 +471,7 @@ func (i *Init) Unmarshal(r io.ReadSeeker) error {
|
||||
return nil, fmt.Errorf("unable to find decoder specific info")
|
||||
}
|
||||
|
||||
var c mpeg4audio.Config
|
||||
var c mpeg4audio.AudioSpecificConfig
|
||||
err := c.Unmarshal(spec)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid MPEG-4 Audio configuration: %w", err)
|
||||
|
@@ -24,7 +24,7 @@ var testVideoTrack = &mp4.CodecH264{
|
||||
}
|
||||
|
||||
var testAudioTrack = &mp4.CodecMPEG4Audio{
|
||||
Config: mpeg4audio.Config{
|
||||
Config: mpeg4audio.AudioSpecificConfig{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
@@ -994,7 +994,7 @@ var casesInit = []struct {
|
||||
Tracks: []*InitTrack{
|
||||
{
|
||||
ID: 1,
|
||||
TimeScale: uint32(testAudioTrack.SampleRate),
|
||||
TimeScale: uint32(testAudioTrack.Config.SampleRate),
|
||||
Codec: testAudioTrack,
|
||||
},
|
||||
},
|
||||
@@ -1461,7 +1461,7 @@ var casesInit = []struct {
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
TimeScale: uint32(testAudioTrack.SampleRate),
|
||||
TimeScale: uint32(testAudioTrack.Config.SampleRate),
|
||||
Codec: testAudioTrack,
|
||||
},
|
||||
},
|
||||
@@ -1886,7 +1886,7 @@ func TestInitUnmarshalExternal(t *testing.T) {
|
||||
ID: 257,
|
||||
TimeScale: 10000000,
|
||||
Codec: &mp4.CodecMPEG4Audio{
|
||||
Config: mpeg4audio.Config{
|
||||
Config: mpeg4audio.AudioSpecificConfig{
|
||||
Type: mpeg4audio.ObjectTypeAACLC,
|
||||
SampleRate: 48000,
|
||||
ChannelCount: 2,
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// CodecMPEG4Audio is a MPEG-4 Audio codec.
|
||||
type CodecMPEG4Audio struct {
|
||||
mpeg4audio.Config
|
||||
Config mpeg4audio.AudioSpecificConfig
|
||||
}
|
||||
|
||||
// IsVideo implements Codec.
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/bluenviron/mediacommon/v2/pkg/codecs/mpeg4audio"
|
||||
)
|
||||
|
||||
func findMPEG4AudioConfig(dem *astits.Demuxer, pid uint16) (*mpeg4audio.Config, error) {
|
||||
func findMPEG4AudioConfig(dem *astits.Demuxer, pid uint16) (*mpeg4audio.AudioSpecificConfig, error) {
|
||||
for {
|
||||
data, err := dem.NextData()
|
||||
if err != nil {
|
||||
@@ -26,7 +26,7 @@ func findMPEG4AudioConfig(dem *astits.Demuxer, pid uint16) (*mpeg4audio.Config,
|
||||
}
|
||||
|
||||
pkt := adtsPkts[0]
|
||||
return &mpeg4audio.Config{
|
||||
return &mpeg4audio.AudioSpecificConfig{
|
||||
Type: pkt.Type,
|
||||
SampleRate: pkt.SampleRate,
|
||||
ChannelCount: pkt.ChannelCount,
|
||||
|
@@ -523,7 +523,7 @@ func (p *Presentation) Unmarshal(r io.ReadSeeker) error {
|
||||
return nil, fmt.Errorf("unable to find decoder specific info")
|
||||
}
|
||||
|
||||
var c mpeg4audio.Config
|
||||
var c mpeg4audio.AudioSpecificConfig
|
||||
err := c.Unmarshal(spec)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid MPEG-4 Audio configuration: %w", err)
|
||||
|
@@ -188,7 +188,7 @@ var casesPresentation = []struct {
|
||||
ID: 8,
|
||||
TimeScale: 90000,
|
||||
Codec: &mp4.CodecMPEG4Audio{
|
||||
Config: mpeg4audio.Config{
|
||||
Config: mpeg4audio.AudioSpecificConfig{
|
||||
Type: 2,
|
||||
SampleRate: 44100,
|
||||
ChannelCount: 2,
|
||||
|
Reference in New Issue
Block a user