(payload: &[u8])
| 37 | } |
| 38 | |
| 39 | pub(crate) fn payload_encoding(payload: &[u8]) -> FormatResult<SemanticEncoding> { |
| 40 | if payload.starts_with(b"ATSC\x02") { |
| 41 | if payload.get(5) != Some(&1) { |
| 42 | return Err(wire::invalid("unknown predictive semantic algorithm")); |
| 43 | } |
| 44 | return Ok(SemanticEncoding::PredictiveV2); |
| 45 | } |
| 46 | let bytes = payload |
| 47 | .strip_prefix(wire::MAGIC) |
| 48 | .ok_or_else(|| wire::invalid("unknown magic/version"))?; |
| 49 | match bytes.first() { |
| 50 | Some(1) => Ok(SemanticEncoding::Compact), |
| 51 | Some(0) => Ok(SemanticEncoding::CompactMixed), |
| 52 | _ => Err(wire::invalid("invalid layout discriminator")), |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | pub(crate) struct SelectedSemantic { |
| 57 | pub compact: bool, |
no test coverage detected