Allow setting response body in OnDescribe (#758)

* Allow setting response body in OnDescribe

Since commit 8c6495c33b, the server can no
longer directly specify the response body to DESCRIBE requests. This is
a breaking change and is a limitation for users who manually handle their
SDPs. This commit allows setting the body explicitly and takes it into
account if the `ServerStream` part of the `OnDecsribe` return value is
nil. If neither the stream, nor the body are set, the application panics.

* Add test for non-nil body for Describe
This commit is contained in:
Yuriy Gabuev
2025-04-17 12:43:01 +02:00
committed by GitHub
parent c3b5e0b76a
commit d162df21ec
2 changed files with 41 additions and 2 deletions

View File

@@ -328,8 +328,8 @@ func (sc *ServerConn) handleRequestInner(req *base.Request) (*base.Response, err
})
if res.StatusCode == base.StatusOK {
if stream == nil {
panic("stream cannot be nil when StatusCode is StatusOK")
if stream == nil && len(res.Body) == 0 {
panic("stream should be not nil or response body should be nonempty when StatusCode is StatusOK")
}
if res.Header == nil {
@@ -339,6 +339,10 @@ func (sc *ServerConn) handleRequestInner(req *base.Request) (*base.Response, err
res.Header["Content-Base"] = base.HeaderValue{req.URL.String() + "/"}
res.Header["Content-Type"] = base.HeaderValue{"application/sdp"}
if stream == nil {
return res, err
}
// VLC uses multicast if the SDP contains a multicast address.
// therefore, we introduce a special query (vlcmulticast) that allows
// to return a SDP that contains a multicast address.