Store VariantStream attributes in more specific types and validate them

This commit is contained in:
Sebastian Dröge
2022-04-17 09:20:01 +03:00
committed by Sebastian Dröge
parent 0789098d7d
commit 6559e45b49
3 changed files with 224 additions and 32 deletions

View File

@ -285,14 +285,14 @@ fn master_playlist_from_tags(mut tags: Vec<MasterPlaylistTag>) -> MasterPlaylist
}
fn variant_stream_tag(i: &[u8]) -> IResult<&[u8], VariantStream> {
map(
map_res(
pair(tag("#EXT-X-STREAM-INF:"), key_value_pairs),
|(_, attributes)| VariantStream::from_hashmap(attributes, false),
)(i)
}
fn variant_i_frame_stream_tag(i: &[u8]) -> IResult<&[u8], VariantStream> {
map(
map_res(
pair(tag("#EXT-X-I-FRAME-STREAM-INF:"), key_value_pairs),
|(_, attributes)| VariantStream::from_hashmap(attributes, true),
)(i)
@ -780,7 +780,7 @@ mod tests {
VariantStream {
is_i_frame: false,
uri: "".into(),
bandwidth: "300000".into(),
bandwidth: 300000,
average_bandwidth: None,
codecs: Some("xxx".into()),
resolution: None,