Skip to content

Commit

Permalink
Merge pull request #189 from livepeer/eli/mapic-dont-overwrite
Browse files Browse the repository at this point in the history
mapic: don't overwrite existing stream definitions
  • Loading branch information
iameli authored Aug 30, 2022
2 parents cd8f077 + f32b870 commit 06a1452
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
13 changes: 12 additions & 1 deletion apis/mist/mist.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,18 @@ func (mapi *API) caclChallengeResponse(password, challenge string) string {

// CreateStream creates new stream in Mist server
// func (mapi *API) CreateStream(name string, presets []string, profiles []Profile, segmentSize, customURL, source string) error
func (mapi *API) CreateStream(name string, presets []string, profiles []Profile, segmentSize, customURL, source, hardcodedBroadcasters string, skipTranscoding, sendAudio bool) error {
func (mapi *API) CreateStream(name string, presets []string, profiles []Profile, segmentSize, customURL, source, hardcodedBroadcasters string, skipTranscoding, sendAudio, overwrite bool) error {
if !overwrite {
streams, _, err := mapi.Streams()
if err != nil {
return err
}
_, exists := streams[name]
if exists {
glog.Infof("Mist stream '%s' already exists, skipping creation", name)
return nil
}
}
glog.Infof("Creating Mist stream '%s' with presets '%+v' profiles %+v", name, presets, profiles)
reqs := &addStreamReq{
Minimal: 1,
Expand Down
2 changes: 1 addition & 1 deletion cmd/mapi/mapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func createStream(host, creds, token, name string) error {

mapi := mist.NewMist(host, credsp[0], credsp[1], token, mistPort)
mapi.Login()
mapi.CreateStream(name, []string{"P240p30fps16x9"}, nil, "", "", "", "", false, false)
mapi.CreateStream(name, []string{"P240p30fps16x9"}, nil, "", "", "", "", false, false, true)

return nil
}
Expand Down
6 changes: 3 additions & 3 deletions internal/app/mistapiconnector/mistapiconnector_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ func (mc *mac) createMistStream(streamName string, stream *livepeer.CreateStream
}
audio := mc.shouldEnableAudio(stream)
err := mc.mapi.CreateStream(streamName, stream.Presets,
LivepeerProfiles2MistProfiles(stream.Profiles), "1", mc.lapi.GetServer()+"/api/stream/"+stream.ID, source, mc.mistHardcodedBroadcasters, skipTranscoding, audio)
LivepeerProfiles2MistProfiles(stream.Profiles), "1", mc.lapi.GetServer()+"/api/stream/"+stream.ID, source, mc.mistHardcodedBroadcasters, skipTranscoding, audio, true)
// err = mc.mapi.CreateStream(streamKey, stream.Presets, LivepeerProfiles2MistProfiles(stream.Profiles), "1", "http://host.docker.internal:3004/api/stream/"+stream.ID)
return err
}
Expand Down Expand Up @@ -1126,13 +1126,13 @@ func (mc *mac) SetupTriggers(ownURI string) error {
apiURL := mc.lapi.GetServer() + "/api/stream/" + mc.baseStreamName
presets := []string{"P144p30fps16x9"}
// base stream created with audio disabled
err = mc.mapi.CreateStream(mc.baseStreamName, presets, nil, "1", apiURL, mc.mistStreamSource, mc.mistHardcodedBroadcasters, false, false)
err = mc.mapi.CreateStream(mc.baseStreamName, presets, nil, "1", apiURL, mc.mistStreamSource, mc.mistHardcodedBroadcasters, false, false, false)
if err != nil {
glog.Error(err)
return err
}
// create second stream with audio enabled - used for stream with recording enabled
err = mc.mapi.CreateStream(mc.baseStreamName+audioEnabledStreamSuffix, presets, nil, "1", apiURL, mc.mistStreamSource, mc.mistHardcodedBroadcasters, false, true)
err = mc.mapi.CreateStream(mc.baseStreamName+audioEnabledStreamSuffix, presets, nil, "1", apiURL, mc.mistStreamSource, mc.mistHardcodedBroadcasters, false, true, false)
}
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/testers/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (sr *streamer) startStreams(baseManfistID, sourceFileName string, repeatNum
}
manifestID := fmt.Sprintf("%s_%d_%d", baseManfistID, repeatNum, i)
if sr.mapi != nil {
err := sr.mapi.CreateStream(manifestID, []string{"P720p30fps16x9"}, nil, "1", "", "", "", false, false)
err := sr.mapi.CreateStream(manifestID, []string{"P720p30fps16x9"}, nil, "1", "", "", "", false, false, true)
if err != nil {
messenger.SendFatalMessage(fmt.Sprintf("Error creating stream %s on Mist", manifestID))
}
Expand Down

0 comments on commit 06a1452

Please sign in to comment.