mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 07:06:58 +08:00
server: use absolute RTSP URL as control attribute (#210)
this is necessary in order to make GStreamer's rtspsrc to send query parameters correctly in SETUP requests.
This commit is contained in:
@@ -25,15 +25,27 @@ func getSessionID(header base.Header) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func filterMedias(medias media.Medias, streamMedias map[*media.Media]*serverStreamMedia) media.Medias {
|
||||
func mediasForSDP(
|
||||
medias media.Medias,
|
||||
streamMedias map[*media.Media]*serverStreamMedia,
|
||||
contentBase *url.URL,
|
||||
) media.Medias {
|
||||
copy := make(media.Medias, len(medias))
|
||||
for i, medi := range medias {
|
||||
copy[i] = &media.Media{
|
||||
mc := &media.Media{
|
||||
Type: medi.Type,
|
||||
// Direction: skipped for the moment
|
||||
Formats: medi.Formats,
|
||||
Control: "mediaUUID=" + streamMedias[medi].uuid.String(),
|
||||
}
|
||||
|
||||
// always use the absolute URL of the track as control attribute, in order
|
||||
// to support GStreamer's rtspsrc. When a relative control is used, GStreamer
|
||||
// puts it between path and query, instead of appending it to the URL.
|
||||
u, _ := mc.URL(contentBase)
|
||||
mc.Control = u.String()
|
||||
|
||||
copy[i] = mc
|
||||
}
|
||||
return copy
|
||||
}
|
||||
@@ -392,7 +404,7 @@ func (sc *ServerConn) handleRequest(req *base.Request) (*base.Response, error) {
|
||||
}
|
||||
|
||||
if stream != nil {
|
||||
byts, _ := filterMedias(stream.medias, stream.streamMedias).Marshal(multicast).Marshal()
|
||||
byts, _ := mediasForSDP(stream.medias, stream.streamMedias, req.URL).Marshal(multicast).Marshal()
|
||||
res.Body = byts
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user