| 241 | // WAV |
| 242 | if bytes.len() >= 12 && bytes.starts_with(b"RIFF") && &bytes[8..12] == b"WAVE" { |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | // OGG container (often Vorbis/Opus audio) |
| 247 | if bytes.starts_with(b"OggS") { |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | // FLAC |
| 252 | if bytes.starts_with(b"fLaC") { |
| 253 | return true; |
| 254 | } |
| 255 | |
| 256 | // MP4/M4A family |
| 257 | if bytes.len() >= 12 && &bytes[4..8] == b"ftyp" { |
| 258 | let brand = &bytes[8..12]; |
| 259 | if brand == b"M4A " || brand == b"M4B " || brand == b"isom" || brand == b"mp42" { |
| 260 | return true; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | false |
| 265 | } |
| 266 | |
| 267 | fn looks_like_image(bytes: &[u8]) -> bool { |
| 268 | bytes.starts_with(b"\x89PNG\r\n\x1A\n") |
| 269 | || bytes.starts_with(b"\xFF\xD8\xFF") |
| 270 | || bytes.starts_with(b"GIF87a") |
| 271 | || bytes.starts_with(b"GIF89a") |
| 272 | || bytes.starts_with(b"RIFF") && bytes.len() >= 12 && &bytes[8..12] == b"WEBP" |
| 273 | || bytes.starts_with(b"BM") |
| 274 | } |
| 275 | |
| 276 | fn looks_like_text(bytes: &[u8]) -> bool { |
| 277 | if bytes.is_empty() { |
| 278 | return true; |
| 279 | } |