Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions amrwb/amrwb.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import (
)

const (
SDPName = "AMR-WB/16000"
SampleRate = 16000
SDPNameOnly = "AMR-WB"
SDPNameAndRate = SDPNameOnly + "/16000"
SDPName = SDPNameAndRate // Deprecated: use SDPNameOnly or SDPNameAndRate
SampleRate = 16000
)

func init() {
media.RegisterCodec(media.NewAudioCodec(media.CodecInfo{
SDPName: SDPName,
SDPName: SDPNameAndRate,
SampleRate: SampleRate,
RTPIsStatic: false,
Priority: -4,
Expand Down
8 changes: 6 additions & 2 deletions dtmf/dtmf.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ import (
"github.com/livekit/media-sdk/tones"
)

const SDPName = "telephone-event/8000"
const (
SDPNameOnly = "telephone-event"
SDPNameAndRate = SDPNameOnly + "/8000"
SDPName = SDPNameAndRate // Deprecated: use SDPNameOnly or SDPNameAndRate
)
const SampleRate = 8000

func init() {
media.RegisterCodec(media.NewCodec(media.CodecInfo{
SDPName: SDPName,
SDPName: SDPNameAndRate,
SampleRate: SampleRate,
RTPIsStatic: false,
Priority: -100, // let it be last in SDP
Expand Down
8 changes: 6 additions & 2 deletions g711/alaw.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ import (
"github.com/livekit/media-sdk"
)

const ALawSDPName = "PCMA/8000"
const (
ALawSDPNameOnly = "PCMA"
ALawSDPNameAndRate = ALawSDPNameOnly + "/8000"
ALawSDPName = ALawSDPNameAndRate // Deprecated: use ALawSDPNameOnly or ALawSDPNameAndRate
)

func init() {
media.RegisterCodec(media.NewAudioCodec(media.CodecInfo{
SDPName: ALawSDPName,
SDPName: ALawSDPNameAndRate,
SampleRate: 8000,
RTPDefType: prtp.PayloadTypePCMA,
RTPIsStatic: true,
Expand Down
8 changes: 6 additions & 2 deletions g711/ulaw.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ import (
"github.com/livekit/media-sdk"
)

const ULawSDPName = "PCMU/8000"
const (
ULawSDPNameOnly = "PCMU"
ULawSDPNameAndRate = ULawSDPNameOnly + "/8000"
ULawSDPName = ULawSDPNameAndRate // Deprecated: use ULawSDPNameOnly or ULawSDPNameAndRate
)

func init() {
media.RegisterCodec(media.NewAudioCodec(media.CodecInfo{
SDPName: ULawSDPName,
SDPName: ULawSDPNameAndRate,
SampleRate: 8000,
RTPDefType: prtp.PayloadTypePCMU,
RTPIsStatic: true,
Expand Down
8 changes: 6 additions & 2 deletions g722/g722.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import (
"github.com/livekit/media-sdk"
)

const SDPName = "G722/8000"
const (
SDPNameOnly = "G722"
SDPNameAndRate = SDPNameOnly + "/8000"
SDPName = SDPNameAndRate // Deprecated: use SDPNameOnly or SDPNameAndRate
)

var (
g722ID atomic.Uint32
Expand All @@ -35,7 +39,7 @@ var (

func init() {
media.RegisterCodec(media.NewAudioCodec(media.CodecInfo{
SDPName: SDPName,
SDPName: SDPNameAndRate,
SampleRate: 16000,
RTPClockRate: 8000,
RTPDefType: prtp.PayloadTypeG722,
Expand Down
6 changes: 3 additions & 3 deletions sdp/offer.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func OfferMediaWith(s *media.CodecSet, rtpListenerPort int, encrypted Encryption
formats := make([]string, 0, len(codecs))
dtmfType := byte(0)
for _, codec := range codecs {
if codec.Codec.Info().SDPName == dtmf.SDPName {
if codec.Codec.Info().SDPName == dtmf.SDPNameAndRate {
dtmfType = codec.Type
}
styp := strconv.Itoa(int(codec.Type))
Expand Down Expand Up @@ -198,7 +198,7 @@ func AnswerMedia(rtpListenerPort int, audio *AudioConfig, crypt *srtp.Profile) *
if audio.DTMFType != 0 {
formats = append(formats, strconv.Itoa(int(audio.DTMFType)))
attrs = append(attrs, []sdp.Attribute{
{Key: "rtpmap", Value: fmt.Sprintf("%d %s", audio.DTMFType, dtmf.SDPName)},
{Key: "rtpmap", Value: fmt.Sprintf("%d %s", audio.DTMFType, dtmf.SDPNameAndRate)},
{Key: "fmtp", Value: fmt.Sprintf("%d 0-16", audio.DTMFType)},
}...)
}
Expand Down Expand Up @@ -634,7 +634,7 @@ func ParseMediaWith(s *media.CodecSet, d *sdp.MediaDescription) (*MediaDesc, err
continue
}
name := sub[1]
if name == dtmf.SDPName || name == dtmf.SDPName+"/1" {
if name == dtmf.SDPNameAndRate || name == dtmf.SDPNameAndRate+"/1" {
out.DTMFType = byte(typ)
continue
}
Expand Down
30 changes: 15 additions & 15 deletions sdp/offer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestSDPMediaOffer(t *testing.T) {
}, offer)

noG722 := g.NewSet()
noG722.SetEnabled(g722.SDPName, false)
noG722.SetEnabled(g722.SDPNameAndRate, false)

_, offer, err = OfferMediaWith(noG722, port, EncryptionNone)
require.NoError(t, err)
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g722.SDPName),
Codec: getCodec(g, g722.SDPNameAndRate),
Type: 9,
DTMFType: 101,
},
Expand All @@ -162,7 +162,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g722.SDPName),
Codec: getCodec(g, g722.SDPNameAndRate),
Type: 9,
DTMFType: 101,
},
Expand All @@ -179,7 +179,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g722.SDPName),
Codec: getCodec(g, g722.SDPNameAndRate),
Type: 9,
},
},
Expand All @@ -196,7 +196,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g722.SDPName),
Codec: getCodec(g, g722.SDPNameAndRate),
Type: 9,
DTMFType: 103,
},
Expand All @@ -213,7 +213,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g711.ULawSDPName),
Codec: getCodec(g, g711.ULawSDPNameAndRate),
Type: 0,
DTMFType: 101,
},
Expand All @@ -230,7 +230,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g722.SDPName),
Codec: getCodec(g, g722.SDPNameAndRate),
Type: 9,
DTMFType: 101,
},
Expand Down Expand Up @@ -259,7 +259,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g711.ULawSDPName),
Codec: getCodec(g, g711.ULawSDPNameAndRate),
Type: 0,
DTMFType: 101,
},
Expand All @@ -273,7 +273,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g711.ULawSDPName),
Codec: getCodec(g, g711.ULawSDPNameAndRate),
Type: 0,
DTMFType: 101,
},
Expand All @@ -290,7 +290,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g711.ULawSDPName),
Codec: getCodec(g, g711.ULawSDPNameAndRate),
Type: 0,
},
},
Expand All @@ -306,7 +306,7 @@ func TestSDPMediaAnswer(t *testing.T) {
},
},
exp: &AudioConfig{
Codec: getCodec(g, g711.ALawSDPName),
Codec: getCodec(g, g711.ALawSDPNameAndRate),
Type: 8,
},
},
Expand Down Expand Up @@ -361,13 +361,13 @@ func TestSDPMediaAnswerOneDisabled(t *testing.T) {
},
}
exp := &AudioConfig{
Codec: getCodec(g, g711.ULawSDPName),
Codec: getCodec(g, g711.ULawSDPNameAndRate),
Type: 0,
DTMFType: 101,
}

noG722 := g.NewSet()
noG722.SetEnabled(g722.SDPName, false)
noG722.SetEnabled(g722.SDPNameAndRate, false)

m, err := ParseMediaWith(noG722, &offer)
require.NoError(t, err)
Expand All @@ -392,8 +392,8 @@ func TestSDPMediaAnswerAllDisabled(t *testing.T) {
}

allOff := g.NewSet()
allOff.SetEnabled(g722.SDPName, false)
allOff.SetEnabled(g711.ULawSDPName, false)
allOff.SetEnabled(g722.SDPNameAndRate, false)
allOff.SetEnabled(g711.ULawSDPNameAndRate, false)

m, err := ParseMediaWith(allOff, &offer)
require.NoError(t, err)
Expand Down
Loading