FLAC-in-Ogg recognition against a real stream
Browse files at this commit573addd8e3989939ef933cb45d827d8bcfc92038Parent: 339321d- test
- FLAC-in-Ogg recognition against a real stream
1 changed file +42 -0
- crates/ec-ogg/tests/ogg.rs +42 -0
crates/ec-ogg/tests/ogg.rsmodified+42 -0
| @@ -451,6 +451,48 @@ fn seeks_land_at_or_before_the_target() { | |||
| 451 | } | 451 | } |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | +/// FLAC-in-Ogg: recognised, described and read to the end. No fixture ships in | ||
| 455 | +/// this mapping, so ffmpeg makes one from a fixture that does. | ||
| 456 | +#[test] | ||
| 457 | +fn reads_flac_in_ogg() { | ||
| 458 | + let files = ogg_fixtures(); | ||
| 459 | + let Some(source) = files | ||
| 460 | + .iter() | ||
| 461 | + .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-44100")) | ||
| 462 | + else { | ||
| 463 | + eprintln!("fixtures absent — skipping"); | ||
| 464 | + return; | ||
| 465 | + }; | ||
| 466 | + let path = workdir("flac").join("flac-in.ogg"); | ||
| 467 | + let made = Command::new("ffmpeg") | ||
| 468 | + .args(["-v", "error", "-y", "-i"]) | ||
| 469 | + .arg(source) | ||
| 470 | + .args(["-c:a", "flac", "-f", "ogg"]) | ||
| 471 | + .arg(&path) | ||
| 472 | + .status() | ||
| 473 | + .expect("ffmpeg"); | ||
| 474 | + assert!(made.success(), "ffmpeg could not write FLAC-in-Ogg"); | ||
| 475 | + | ||
| 476 | + let (streams, packets, damaged) = demux_all(&path); | ||
| 477 | + assert_eq!(damaged, 0); | ||
| 478 | + assert_eq!(streams[0].params.codec, CodecId::Flac); | ||
| 479 | + assert_eq!( | ||
| 480 | + demuxer_mapping_rate(&streams[0]), | ||
| 481 | + 44_100, | ||
| 482 | + "the rate comes out of STREAMINFO, not the file name" | ||
| 483 | + ); | ||
| 484 | + assert_eq!(packets.len() as u64, ffprobe_packets(&path)); | ||
| 485 | + println!("flac-in-ogg: {} packets", packets.len()); | ||
| 486 | +} | ||
| 487 | + | ||
| 488 | +/// The sample rate a stream description states. | ||
| 489 | +fn demuxer_mapping_rate(info: &StreamInfo) -> u32 { | ||
| 490 | + match &info.params.media { | ||
| 491 | + MediaParameters::Audio(audio) => audio.sample_rate, | ||
| 492 | + _ => 0, | ||
| 493 | + } | ||
| 494 | +} | ||
| 495 | + | ||
| 454 | /// Payload sizes Ogg's own lacing has to work for, none of which the fixtures | 496 | /// Payload sizes Ogg's own lacing has to work for, none of which the fixtures |
| 455 | /// contain: a packet that is exactly a multiple of 255, one that fills more | 497 | /// contain: a packet that is exactly a multiple of 255, one that fills more |
| 456 | /// than one page's segment table, and an empty one. | 498 | /// than one page's segment table, and an empty one. |