mirror of
https://github.com/sile/hls_m3u8.git
synced 2025-01-08 19:25:24 +00:00
fix EXT-X-MEDIA DEFAULT=yes wrt AUTOSELECT (#1)
* fix EXT-X-MEDIA DEFAULT=yes wrt AUTOSELECT In 4.3.4.1. EXT-X-MEDIA section about AUTOSELECT is written If the AUTOSELECT attribute is present, its value MUST be YES if the value of the DEFAULT attribute is YES. That means, that if DEFAULT is YES and AUTOSELECT is *not present*, it ok. Before the patch, incorrect error is emitted If `DEFAULT` is true, `AUTOSELECT` has to be true too, Default: Some(true), Autoselect: None! Signed-off-by: Nikola Pajkovsky <nikola.pajkovsky@livesporttv.cz> * update src/tags/master_playlist/media.rs Co-authored-by: Nikola Pajkovsky <nikola.pajkovsky@livesporttv.cz> Co-authored-by: Lucas <24826124+Luro02@users.noreply.github.com>
This commit is contained in:
parent
fdc3442bb6
commit
34df16f7d6
1 changed files with 22 additions and 2 deletions
|
@ -238,9 +238,9 @@ impl ExtXMediaBuilder {
|
|||
).to_string());
|
||||
}
|
||||
|
||||
if self.is_default.unwrap_or(false) && !self.is_autoselect.unwrap_or(false) {
|
||||
if self.is_default.unwrap_or(false) && self.is_autoselect.map_or(false, |b| !b) {
|
||||
return Err(Error::custom(format!(
|
||||
"If `DEFAULT` is true, `AUTOSELECT` has to be true too, Default: {:?}, Autoselect: {:?}!",
|
||||
"If `DEFAULT` is true, `AUTOSELECT` has to be true too, if present. Default: {:?}, Autoselect: {:?}!",
|
||||
self.is_default, self.is_autoselect
|
||||
))
|
||||
.to_string());
|
||||
|
@ -462,6 +462,26 @@ mod test {
|
|||
}
|
||||
|
||||
generate_tests! {
|
||||
{
|
||||
ExtXMedia::builder()
|
||||
.media_type(MediaType::Audio)
|
||||
.group_id("audio")
|
||||
.language("eng")
|
||||
.name("English")
|
||||
.is_default(true)
|
||||
.uri("eng/prog_index.m3u8")
|
||||
.build()
|
||||
.unwrap(),
|
||||
concat!(
|
||||
"#EXT-X-MEDIA:",
|
||||
"TYPE=AUDIO,",
|
||||
"URI=\"eng/prog_index.m3u8\",",
|
||||
"GROUP-ID=\"audio\",",
|
||||
"LANGUAGE=\"eng\",",
|
||||
"NAME=\"English\",",
|
||||
"DEFAULT=YES",
|
||||
)
|
||||
},
|
||||
{
|
||||
ExtXMedia::builder()
|
||||
.media_type(MediaType::Audio)
|
||||
|
|
Loading…
Reference in a new issue