mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 03:21:00 +00:00
uriplaylistbin: Properly check for stream-collection/streams-selected events
There is only a new stream-collection event if the media has actually changed, and that's also the only time in these tests when a streams-selected event is sent as the default stream selection is always used and never changed. Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/597 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1769>
This commit is contained in:
parent
2e0f52de2c
commit
8fd2b7daa4
1 changed files with 26 additions and 6 deletions
|
@ -17,6 +17,12 @@ struct TestMedia {
|
|||
len: gst::ClockTime,
|
||||
}
|
||||
|
||||
impl PartialEq for TestMedia {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.uri == other.uri
|
||||
}
|
||||
}
|
||||
|
||||
fn file_name_to_uri(name: &str) -> String {
|
||||
let input_path = {
|
||||
let mut r = PathBuf::new();
|
||||
|
@ -103,8 +109,6 @@ fn test(
|
|||
) -> (Vec<gst::Message>, u32, u64) {
|
||||
init();
|
||||
|
||||
let playlist_len = medias.len() * (iterations as usize);
|
||||
|
||||
let total_len: gst::ClockTime = medias.iter().map(|t| t.len * (iterations as u64)).sum();
|
||||
|
||||
let uris: Vec<String> = medias.iter().map(|t| t.uri.clone()).collect();
|
||||
|
@ -221,11 +225,27 @@ fn test(
|
|||
|
||||
// check stream-collection and streams-selected message ordering
|
||||
let mut events = events.clone().into_iter();
|
||||
let playlist = std::iter::repeat(medias.iter())
|
||||
.take(iterations as usize)
|
||||
.flatten();
|
||||
let mut last_media = None;
|
||||
|
||||
for i in 0..playlist_len {
|
||||
let decodebin = assert_stream_collection(events.next().unwrap(), n_streams as usize);
|
||||
if i == 0 {
|
||||
// decodebin3 sends StreamSelected only once, which is ok as the selected stream stays the same
|
||||
for media in playlist {
|
||||
let mut media_changed = false;
|
||||
|
||||
if last_media
|
||||
.as_ref()
|
||||
.map_or(true, |last_media| *last_media != media)
|
||||
{
|
||||
last_media = Some(media);
|
||||
media_changed = true;
|
||||
}
|
||||
|
||||
// decodebin3 only sends a new stream-collection and streams-selected if it actually
|
||||
// changes, which only happens here if the actual underlying media is changing.
|
||||
if media_changed {
|
||||
let decodebin =
|
||||
assert_stream_collection(events.next().unwrap(), n_streams as usize);
|
||||
assert_eq!(
|
||||
assert_stream_selected(events.next().unwrap(), n_streams as usize),
|
||||
decodebin
|
||||
|
|
Loading…
Reference in a new issue