Fix RTSP server SDP for some clients
This commit is contained in:
@@ -162,6 +162,8 @@ func tcpHandler(conn *rtsp.Conn) {
|
|||||||
|
|
||||||
log.Debug().Str("stream", name).Msg("[rtsp] new consumer")
|
log.Debug().Str("stream", name).Msg("[rtsp] new consumer")
|
||||||
|
|
||||||
|
conn.SessionName = app.UserAgent
|
||||||
|
|
||||||
initMedias(conn)
|
initMedias(conn)
|
||||||
|
|
||||||
if err := stream.AddConsumer(conn); err != nil {
|
if err := stream.AddConsumer(conn); err != nil {
|
||||||
|
|||||||
+2
-1
@@ -78,6 +78,7 @@ type Conn struct {
|
|||||||
// public
|
// public
|
||||||
|
|
||||||
Backchannel bool
|
Backchannel bool
|
||||||
|
SessionName string
|
||||||
|
|
||||||
Medias []*streamer.Media
|
Medias []*streamer.Media
|
||||||
Session string
|
Session string
|
||||||
@@ -618,7 +619,7 @@ func (c *Conn) Accept() error {
|
|||||||
medias = append(medias, media)
|
medias = append(medias, media)
|
||||||
}
|
}
|
||||||
|
|
||||||
res.Body, err = streamer.MarshalSDP(medias)
|
res.Body, err = streamer.MarshalSDP(c.SessionName, medias)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -183,8 +183,22 @@ func UnmarshalSDP(rawSDP []byte) ([]*Media, error) {
|
|||||||
return medias, nil
|
return medias, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MarshalSDP(medias []*Media) ([]byte, error) {
|
func MarshalSDP(name string, medias []*Media) ([]byte, error) {
|
||||||
sd := &sdp.SessionDescription{}
|
sd := &sdp.SessionDescription{
|
||||||
|
Origin: sdp.Origin{
|
||||||
|
Username: "-", SessionID: 1, SessionVersion: 1,
|
||||||
|
NetworkType: "IN", AddressType: "IP4", UnicastAddress: "0.0.0.0",
|
||||||
|
},
|
||||||
|
SessionName: sdp.SessionName(name),
|
||||||
|
ConnectionInformation: &sdp.ConnectionInformation{
|
||||||
|
NetworkType: "IN", AddressType: "IP4", Address: &sdp.Address{
|
||||||
|
Address: "0.0.0.0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
TimeDescriptions: []sdp.TimeDescription{
|
||||||
|
{Timing: sdp.Timing{}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
payloadType := uint8(96)
|
payloadType := uint8(96)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package streamer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pion/sdp/v3"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSDP(t *testing.T) {
|
||||||
|
medias := []*Media{{
|
||||||
|
Kind: KindAudio, Direction: DirectionSendonly,
|
||||||
|
Codecs: []*Codec{
|
||||||
|
{Name: CodecPCMU, ClockRate: 8000},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
|
||||||
|
data, err := MarshalSDP("go2rtc/1.0.0", medias)
|
||||||
|
assert.Empty(t, err)
|
||||||
|
|
||||||
|
sd := &sdp.SessionDescription{}
|
||||||
|
err = sd.Unmarshal(data)
|
||||||
|
assert.Empty(t, err)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user