Skip to content
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

m3u8: higher-level validation of Variant before returning #12

Open
ollytom opened this issue May 31, 2024 · 0 comments
Open

m3u8: higher-level validation of Variant before returning #12

ollytom opened this issue May 31, 2024 · 0 comments

Comments

@ollytom
Copy link
Member

ollytom commented May 31, 2024

In parseVariant(), we don't do much validation beyond type checking and parsing tokens before returning a Variant.
For example, Apple HLS authoring spec mentions that the CODECS attribute must be set for all variants.

There's some easy validation. After we've broken out of the loop reading items from the lexer, have a bunch of basic if statements checking stuff:

func parseVariant() {
	var v Variant
	for it := range items {
		switch ... {
		}
	}
	if v.Codecs == "" {
		return nil, fmt.Errorf("codecs not set")
	}
	return v, nil
}

Not sure how to test this exactly. Two ways off the top of my head:

  1. make a chan item and send items through it. Pass the chan to parseVariant().
  2. decode simple playlists which have different "bad" variants in them.

However we do it, as long as it's easy to add new, readable test cases.
My first instinct is to go for option 2 as it feels clearer to have bad playlist specified as text as opposed to code with structs sent through channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant