Skip to content

Commit

Permalink
PSSH generation: only set protobuf fields if they are not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
emarsden committed Feb 21, 2024
1 parent 6a679c7 commit d727178
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ pub fn generate_widevine_pssh_b64(
pssh.add_key_id(kid);
}
if let PsshData::Widevine(ref mut pd) = pssh.pssh_data {
pd.provider = Some(String::from(provider));
pd.policy = Some(String::from(policy));
pd.content_id = Some(content_id.into());
if !provider.is_empty() {
pd.provider = Some(String::from(provider));
}
if !policy.is_empty() {
pd.policy = Some(String::from(policy));
}
if !content_id.is_empty() {
pd.content_id = Some(content_id.into());
}
}
Ok(pssh.to_base64())
}
Expand All @@ -133,7 +139,7 @@ pub async fn fetch_pssh_data(url: &str) -> Result<String, JsError> {
}
let mut opts = RequestInit::new();
opts.method("GET");
let request = Request::new_with_str_and_init(&url, &opts)
let request = Request::new_with_str_and_init(url, &opts)
.or(Err(PsshBoxWasmError::WebSys(String::from("creating Request"))))?;
request
.headers()
Expand Down

0 comments on commit d727178

Please sign in to comment.