-
Notifications
You must be signed in to change notification settings - Fork 0
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
Multi channel #6
base: main
Are you sure you want to change the base?
Conversation
megaadam
commented
May 20, 2022
- support multi-channels
- support arbitrary live-window-size
return 0, err | ||
} | ||
|
||
ci, err := esf.ParseContentInfo(bytes) |
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.
TODO: get duration from a dat file instead,
only the "demo-contentinfo" files contain a duration
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 number of minor remarks, but in general it looks fine.
However, we should be careful with growing this code too much, since it is intended as a an open-source "simple" example that one can learn from. If we want to have a tool for testing performance, it should probably be another piece of software.
v2l/channel.go
Outdated
nowMS := time.Now().UnixNano() / 1_000_000 | ||
return nowMS/(gopDurMS*nrGopsPerSegment) - 1 | ||
// CreateChannels - create a slice filled with channels | ||
func CreateChannels(nofChannels int, |
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.
Use "nrOfChannels" instead of "nofChannels" to be consistent with the rest of the names.
main.go
Outdated
) | ||
|
||
func main() { | ||
err := v2l.DeleteChannel(server, channelName) // Delete any old channel and schedule | ||
nofChannels := 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.
change variable name to nrOfChannels to align with reset of code
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
chIndex++ |
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'd suggest that you do the modulo operation right away, so that one does not suspect an error. index should be less than nrOfChannels. From a performance point of view, it is also better to write it as
chIndex++
if chIndex == nrOfChannels {
chIndex -= nrOfChannels
}
since divisions and mod are very expensive operations.
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.
or rather this
if ... {
chIndex = 0
}
v2l/assetpaths.go
Outdated
|
||
cd := ci.ContentDurationMS | ||
if cd == 0 { | ||
return 0, fmt.Errorf("ContentDurationMS not found") |
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.
Use the proper JSON name here instead of the internal Go name.
} | ||
|
||
// CreateSchedule -- create a complete schedule to fill the entire live window | ||
func (channel *Channel) CreateSchedule(slidingWindowNrGops, futureScheduleNrGops, gopDurMS int64, assetPaths []AssetPath) { |
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 extend here is that the schedule is built by pairs of a "program" and an "ad"
v2l/channel.go
Outdated
} | ||
} | ||
|
||
// CreateChannel - create a channel with two assets and an ad in between |
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.
This comment no longer describes what the function does so it should be updated
v2l/channel.go
Outdated
assetPaths []AssetPath) (*Channel, error) { | ||
startGopNr := nowToGopNr(gopDurMS, time.Now()) | ||
|
||
log.Printf("Start time for channels set to %s\n", time.Duration(startGopNr*gopDurMS)*(time.Millisecond)) |
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.
Would be better to get a UTC time here or at least also.
gd := ci.GOPDurationMS | ||
if gd == 0 { | ||
return 0, fmt.Errorf("GOPDurationMS not found") | ||
} |
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.
And JSON here too