mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
Merge branch 'v1'
This commit is contained in:
@@ -94,6 +94,28 @@ func TestNewFromMediaDescription(t *testing.T) {
|
|||||||
ChannelCount: 2,
|
ChannelCount: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"audio lpcm 16 with no explicit channel",
|
||||||
|
&psdp.MediaDescription{
|
||||||
|
MediaName: psdp.MediaName{
|
||||||
|
Media: "audio",
|
||||||
|
Protos: []string{"RTP", "AVP"},
|
||||||
|
Formats: []string{"97"},
|
||||||
|
},
|
||||||
|
Attributes: []psdp.Attribute{
|
||||||
|
{
|
||||||
|
Key: "rtpmap",
|
||||||
|
Value: "97 L16/16000",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
&LPCM{
|
||||||
|
PayloadTyp: 97,
|
||||||
|
BitDepth: 16,
|
||||||
|
SampleRate: 16000,
|
||||||
|
ChannelCount: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"audio lpcm 24",
|
"audio lpcm 24",
|
||||||
&psdp.MediaDescription{
|
&psdp.MediaDescription{
|
||||||
|
@@ -47,22 +47,26 @@ func (t *LPCM) unmarshal(payloadType uint8, clock string, codec string, rtpmap s
|
|||||||
t.BitDepth = 24
|
t.BitDepth = 24
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp := strings.SplitN(clock, "/", 32)
|
tmp := strings.SplitN(clock, "/", 2)
|
||||||
if len(tmp) != 2 {
|
if len(tmp) < 1 {
|
||||||
return fmt.Errorf("invalid clock (%v)", clock)
|
return fmt.Errorf("invalid clock (%v)", clock)
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleRate, err := strconv.ParseInt(tmp[0], 10, 64)
|
tmp1, err := strconv.ParseInt(tmp[0], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
t.SampleRate = int(sampleRate)
|
t.SampleRate = int(tmp1)
|
||||||
|
|
||||||
channelCount, err := strconv.ParseInt(tmp[1], 10, 64)
|
if len(tmp) >= 2 {
|
||||||
if err != nil {
|
tmp1, err := strconv.ParseInt(tmp[1], 10, 64)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
t.ChannelCount = int(tmp1)
|
||||||
|
} else {
|
||||||
|
t.ChannelCount = 1
|
||||||
}
|
}
|
||||||
t.ChannelCount = int(channelCount)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user