Skip to content

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

@ollytom

Description

@ollytom

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions