-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust twitch ingest urls #726
Conversation
"github.com/livekit/protocol/utils" | ||
) | ||
|
||
var twitchEndpoint = regexp.MustCompile("^rtmps?://.*\\.contribute\\.live-video\\.net/app/(.*)( live=1)?$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit, but if you use backquote you won't need to escape the slash.
switch outputType { | ||
case types.OutputTypeRTMP: | ||
if parsed.Scheme == "mux" { | ||
rawUrl = fmt.Sprintf("rtmps://global-live.mux.com:443/app/%s", parsed.Host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fmt.Sprintf
could be swapped to +
. Up to you, though.
} | ||
|
||
func updateTwitchURL(key string) (string, error) { | ||
resp, err := http.Get("https://ingest.twitch.tv/ingests") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could pass context here from the UpdateStream
? I see that it's passed to other methods of ipcServiceClient
, so it will get cancelled there eventually. We'll just wait a bit longer here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it only gets passed around for projectID in cloud
@@ -264,7 +264,7 @@ func (c *Controller) UpdateStream(ctx context.Context, req *livekit.UpdateStream | |||
// add stream outputs first | |||
for _, rawUrl := range req.AddOutputUrls { | |||
// validate and redact url | |||
url, redacted, err := c.ValidateUrl(rawUrl, types.OutputTypeRTMP) | |||
url, redacted, err := config.ValidateUrl(rawUrl, types.OutputTypeRTMP) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question about this one. It's called for each output URL and it may eventually call updateTwitchURL
. How likely is that its called twice? I guess it's not typical to output to multiple Twitch streams, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never seen anyone do it. I considered caching the results but it's a pretty cheap call and didn't seem worth the added complexity
Uses the ingest endpoint api to choose the best url for twitch streams