mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
81 lines
1.6 KiB
Go
81 lines
1.6 KiB
Go
package gortsplib
|
|
|
|
import (
|
|
"testing"
|
|
|
|
psdp "github.com/pion/sdp/v3"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/aler9/gortsplib/pkg/mpeg4audio"
|
|
)
|
|
|
|
func TestTrackMPEG4AudioAttributes(t *testing.T) {
|
|
track := &TrackMPEG4Audio{
|
|
PayloadType: 96,
|
|
Config: &mpeg4audio.Config{
|
|
Type: 2,
|
|
SampleRate: 48000,
|
|
ChannelCount: 2,
|
|
},
|
|
SizeLength: 13,
|
|
IndexLength: 3,
|
|
IndexDeltaLength: 3,
|
|
}
|
|
require.Equal(t, 48000, track.ClockRate())
|
|
require.Equal(t, "", track.GetControl())
|
|
}
|
|
|
|
func TestTrackMPEG4AudioClone(t *testing.T) {
|
|
track := &TrackMPEG4Audio{
|
|
PayloadType: 96,
|
|
Config: &mpeg4audio.Config{
|
|
Type: 2,
|
|
SampleRate: 48000,
|
|
ChannelCount: 2,
|
|
},
|
|
SizeLength: 13,
|
|
IndexLength: 3,
|
|
IndexDeltaLength: 3,
|
|
}
|
|
|
|
clone := track.clone()
|
|
require.NotSame(t, track, clone)
|
|
require.Equal(t, track, clone)
|
|
}
|
|
|
|
func TestTrackMPEG4AudioMediaDescription(t *testing.T) {
|
|
track := &TrackMPEG4Audio{
|
|
PayloadType: 96,
|
|
Config: &mpeg4audio.Config{
|
|
Type: 2,
|
|
SampleRate: 48000,
|
|
ChannelCount: 2,
|
|
},
|
|
SizeLength: 13,
|
|
IndexLength: 3,
|
|
IndexDeltaLength: 3,
|
|
}
|
|
|
|
require.Equal(t, &psdp.MediaDescription{
|
|
MediaName: psdp.MediaName{
|
|
Media: "audio",
|
|
Protos: []string{"RTP", "AVP"},
|
|
Formats: []string{"96"},
|
|
},
|
|
Attributes: []psdp.Attribute{
|
|
{
|
|
Key: "rtpmap",
|
|
Value: "96 mpeg4-generic/48000/2",
|
|
},
|
|
{
|
|
Key: "fmtp",
|
|
Value: "96 profile-level-id=1; mode=AAC-hbr; sizelength=13; indexlength=3; indexdeltalength=3; config=1190",
|
|
},
|
|
{
|
|
Key: "control",
|
|
Value: "",
|
|
},
|
|
},
|
|
}, track.MediaDescription())
|
|
}
|