Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/sip/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package sip

type SDPError struct {
Err error
}

func (e SDPError) Error() string {
return e.Err.Error()
}

func (e SDPError) Unwrap() error {
return e.Err
}
27 changes: 23 additions & 4 deletions pkg/sip/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,24 @@ func (c *inboundCall) handleInvite(ctx context.Context, tid traceid.ID, req *sip
}

runMedia := func(enc livekit.SIPMediaEncryption) ([]byte, error) {
answerData, err := c.runMediaConn(tid, req.Body(), enc, conf, disp.EnabledFeatures)
log := c.log()
if h := req.ContentLength(); h != nil {
log = log.WithValues("contentLength", int(*h))
}
if h := req.ContentType(); h != nil {
log = log.WithValues("contentType", h.Value())
switch h.Value() {
default:
log.Infow("unsupported offer type")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any point continuing if it's not "application/sdp" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. But I want to see first that this doesn't happen in the wild first.

case "application/sdp":
}
} else {
log.Infow("no offer type specified")
}
rawSDP := req.Body()
answerData, err := c.runMediaConn(tid, rawSDP, enc, conf, disp.EnabledFeatures)
if err != nil {
log = log.WithValues("sdp", string(rawSDP))
isError := true
status, reason := callDropped, "media-failed"
if errors.Is(err, sdp.ErrNoCommonMedia) {
Expand All @@ -730,11 +746,14 @@ func (c *inboundCall) handleInvite(ctx context.Context, tid traceid.ID, req *sip
} else if errors.Is(err, sdp.ErrNoCommonCrypto) {
status, reason = callMediaFailed, "no-common-crypto"
isError = false
} else if e := (SDPError{}); errors.As(err, &e) {
status, reason = callMediaFailed, "sdp-error"
isError = false
}
if isError {
c.log().Errorw("Cannot start media", err)
log.Errorw("Cannot start media", err)
} else {
c.log().Warnw("Cannot start media", err)
log.Warnw("Cannot start media", err)
}
c.cc.RespondAndDrop(sip.StatusInternalServerError, "")
c.close(true, status, reason)
Expand Down Expand Up @@ -924,7 +943,7 @@ func (c *inboundCall) runMediaConn(tid traceid.ID, offerData []byte, enc livekit

answer, mconf, err := mp.SetOffer(offerData, e)
if err != nil {
return nil, err
return nil, SDPError{Err: err}
}
answerData, err = answer.SDP.Marshal()
if err != nil {
Expand Down