diff --git a/internal/protocols/webrtc/peer_connection.go b/internal/protocols/webrtc/peer_connection.go index 850ca345..30ea0688 100644 --- a/internal/protocols/webrtc/peer_connection.go +++ b/internal/protocols/webrtc/peer_connection.go @@ -311,7 +311,7 @@ func (co *PeerConnection) CreateFullAnswer( answer, err := co.wr.CreateAnswer(nil) if err != nil { if errors.Is(err, webrtc.ErrSenderWithNoCodecs) { - return nil, fmt.Errorf("track codecs are not supported by remote") + return nil, fmt.Errorf("codecs not supported by client") } return nil, err } diff --git a/internal/servers/webrtc/publish_index.html b/internal/servers/webrtc/publish_index.html index 122bba6a..832006f1 100644 --- a/internal/servers/webrtc/publish_index.html +++ b/internal/servers/webrtc/publish_index.html @@ -409,7 +409,7 @@ const sendLocalCandidates = (candidates) => { }) .then((res) => { if (res.status !== 204) { - throw new Error('bad status code'); + throw new Error(`bad status code ${res.status}`); } }) .catch((err) => { @@ -464,13 +464,20 @@ const sendOffer = (offer) => { body: offer, }) .then((res) => { - if (res.status !== 201) { - throw new Error('bad status code'); + switch (res.status) { + case 201: + break; + case 400: + return res.json().then((e) => { throw new Error(e.error); }); + default: + throw new Error(`bad status code ${res.status}`); } + sessionUrl = new URL(res.headers.get('location'), window.location.href).toString(); - return res.text(); + + return res.text() + .then((answer) => onRemoteAnswer(answer)); }) - .then((answer) => onRemoteAnswer(answer)) .catch((err) => { onError(err.toString(), true); }); diff --git a/internal/servers/webrtc/read_index.html b/internal/servers/webrtc/read_index.html index f3052d59..427073f9 100644 --- a/internal/servers/webrtc/read_index.html +++ b/internal/servers/webrtc/read_index.html @@ -426,13 +426,17 @@ const sendOffer = (offer) => { break; case 404: throw new Error('stream not found'); + case 400: + return res.json().then((e) => { throw new Error(e.error); }); default: throw new Error(`bad status code ${res.status}`); } + sessionUrl = new URL(res.headers.get('location'), window.location.href).toString(); - return res.text(); + + return res.text() + .then((sdp) => onRemoteAnswer(sdp)); }) - .then((sdp) => onRemoteAnswer(sdp)) .catch((err) => { onError(err.toString()); });