mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 23:52:46 +08:00
fix support for LPCM tracks with no explicit channel count
(https://github.com/aler9/rtsp-simple-server/issues/1292)
This commit is contained in:
@@ -39,8 +39,8 @@ func newTrackLPCMFromMediaDescription(
|
|||||||
bitDepth = 24
|
bitDepth = 24
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp := strings.SplitN(clock, "/", 32)
|
tmp := strings.SplitN(clock, "/", 2)
|
||||||
if len(tmp) != 2 {
|
if len(tmp) < 1 {
|
||||||
return nil, fmt.Errorf("invalid clock (%v)", clock)
|
return nil, fmt.Errorf("invalid clock (%v)", clock)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,16 +49,22 @@ func newTrackLPCMFromMediaDescription(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
channelCount, err := strconv.ParseInt(tmp[1], 10, 64)
|
var channelCount int
|
||||||
if err != nil {
|
if len(tmp) >= 2 {
|
||||||
return nil, err
|
tmp, err := strconv.ParseInt(tmp[1], 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
channelCount = int(tmp)
|
||||||
|
} else {
|
||||||
|
channelCount = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return &TrackLPCM{
|
return &TrackLPCM{
|
||||||
PayloadType: payloadType,
|
PayloadType: payloadType,
|
||||||
BitDepth: bitDepth,
|
BitDepth: bitDepth,
|
||||||
SampleRate: int(sampleRate),
|
SampleRate: int(sampleRate),
|
||||||
ChannelCount: int(channelCount),
|
ChannelCount: channelCount,
|
||||||
trackBase: trackBase{
|
trackBase: trackBase{
|
||||||
control: control,
|
control: control,
|
||||||
},
|
},
|
||||||
|
@@ -95,6 +95,28 @@ func TestTrackNewFromMediaDescription(t *testing.T) {
|
|||||||
ChannelCount: 2,
|
ChannelCount: 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
&TrackLPCM{
|
||||||
|
PayloadType: 97,
|
||||||
|
BitDepth: 16,
|
||||||
|
SampleRate: 16000,
|
||||||
|
ChannelCount: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"lpcm 24",
|
"lpcm 24",
|
||||||
&psdp.MediaDescription{
|
&psdp.MediaDescription{
|
||||||
|
Reference in New Issue
Block a user