Skip to content

Commit

Permalink
mapic: Fix multistream target URL ? handling (#1300)
Browse files Browse the repository at this point in the history
It turns out that Mist has a special parsing of these push URLs which
is not a regular URL parsing. It removes anything after the last `?`
in the URL and uses that as its config. If there are multiple `?` in
the URL (e.g. query-string already existed in target URL), it will
strip only (from) the last one and keep the previous.

So instead of merging Mist's qs with the existing ones, we actually
need to create a separate `?` section for Mist. This guarantees both
that Mist gets its config properly, as well as that it preserves the
URL to call the target service.
  • Loading branch information
victorges authored Sep 5, 2024
1 parent 0b50934 commit b4097be
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mapic/mistapiconnector_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,16 +748,13 @@ func (mc *mac) getPushUrl(stream *api.Stream, targetRef *api.MultistreamTargetRe
}
videoSelector = fmt.Sprintf("~%dx%d", prof.Width, prof.Height)
}
join := "?"
if strings.Contains(target.URL, "?") {
join = "&"
}
audioSelector := "maxbps"
if targetRef.VideoOnly {
audioSelector = "silent"
}
// Inject ?video=~widthxheight to send the correct rendition
return target, fmt.Sprintf("%s%svideo=%s&audio=%s", target.URL, join, videoSelector, audioSelector), nil
// Inject ?video=~widthxheight to send the correct rendition. Notice that we don't care if there is already a
// query-string in the URL since Mist will always strip from the last `?` in the push URL for its configs.
return target, fmt.Sprintf("%s?video=%s&audio=%s", target.URL, videoSelector, audioSelector), nil
}

func (mc *mac) getStreamInfoLogged(playbackID string) (*streamInfo, bool) {
Expand Down

0 comments on commit b4097be

Please sign in to comment.