Skip to content

Commit

Permalink
set 1 as default num of channels (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Vorontsov <n.vorontsov@webinar.ru>
  • Loading branch information
NoobsEnslaver and Nikita Vorontsov authored Oct 9, 2024
1 parent 9683c2a commit 1b7a6af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions sdp/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (d *Decoder) format(m *Media, a *Attr) error {
Payload: uint8(pt),
ClockRate: wellKnownClockRate(pt),
Name: wellKnownName(pt),
Channels: 1,
}
m.Format = append(m.Format, f)
}
Expand Down Expand Up @@ -263,6 +264,7 @@ func (d *Decoder) proto(m *Media, v string) error {
Payload: uint8(pt),
ClockRate: wellKnownClockRate(pt),
Name: wellKnownName(pt),
Channels: 1,
})
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion sdp/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (w writer) format(f *Format) writer {
p := int64(f.Payload)
if f.Name != "" && int(f.Payload) > len(wellKnownNames) {
w = w.add('a').str("rtpmap:").int(p).sp().str(f.Name).char('/').int(int64(f.ClockRate))
if f.Channels > 0 {
if f.Channels > 1 {
w = w.char('/').int(int64(f.Channels))
}
}
Expand Down
16 changes: 10 additions & 6 deletions sdp/sdp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ a=fmtp:100 profile-level-id=42c01f;level-asymmetry-allowed=1
Port: 49170,
Proto: "RTP/AVP",
Format: []*Format{
{Payload: 0, Name: "PCMU", ClockRate: 8000},
{Payload: 0, Name: "PCMU", ClockRate: 8000, Channels: 1},
},
},
{
Type: "video",
Port: 51372,
Proto: "RTP/AVP",
Format: []*Format{
{Payload: 99, Name: "h263-1998", ClockRate: 90000},
{Payload: 100, Name: "H264", ClockRate: 90000, Params: []string{
{Payload: 99, Name: "h263-1998", ClockRate: 90000, Channels: 1},
{Payload: 100, Name: "H264", ClockRate: 90000, Channels: 1, Params: []string{
"profile-level-id=42c01f;level-asymmetry-allowed=1",
}, Feedback: []string{
"ccm fir", "nack", "nack pli",
Expand All @@ -109,7 +109,9 @@ s=Example
c=IN IP4 127.0.0.1
t=0 0
a=sendrecv
m=audio 10000 RTP/AVP 0 8
m=audio 10000 RTP/AVP 0 8 97 98
a=rtpmap:97 telephone-event/8000
a=rtpmap:98 telephone-event/16000
`,
Session: &Session{
Origin: &Origin{
Expand All @@ -132,8 +134,10 @@ m=audio 10000 RTP/AVP 0 8
Port: 10000,
Proto: "RTP/AVP",
Format: []*Format{
{Payload: 0, Name: "PCMU", ClockRate: 8000},
{Payload: 8, Name: "PCMA", ClockRate: 8000},
{Payload: 0, Name: "PCMU", ClockRate: 8000, Channels: 1},
{Payload: 8, Name: "PCMA", ClockRate: 8000, Channels: 1},
{Payload: 97, Name: "telephone-event", ClockRate: 8000, Channels: 1},
{Payload: 98, Name: "telephone-event", ClockRate: 16000, Channels: 1},
},
},
},
Expand Down

0 comments on commit 1b7a6af

Please sign in to comment.