mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-22 18:16:28 +00:00
hlssink3: Fix racy test by separating events (signals) from bus messages
Was regularly failing on the CI. Bus messages are handled async here, so they need to be tracked separately. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1737>
This commit is contained in:
parent
170e769812
commit
b6406013c5
1 changed files with 32 additions and 8 deletions
|
@ -130,6 +130,7 @@ fn test_hlssink3_element_with_video_content() -> Result<(), ()> {
|
|||
hlssink3.set_property_from_str("playlist-type", "unspecified");
|
||||
|
||||
let (hls_events_sender, hls_events_receiver) = mpsc::sync_channel(20);
|
||||
let (hls_messages_sender, hls_messages_receiver) = mpsc::sync_channel(10);
|
||||
let playlist_content = Arc::new(Mutex::new(String::from("")));
|
||||
|
||||
hlssink3.connect("get-playlist-stream", false, {
|
||||
|
@ -204,7 +205,7 @@ fn test_hlssink3_element_with_video_content() -> Result<(), ()> {
|
|||
if let Some(structure) = msg.structure() {
|
||||
if structure.has_name("hls-segment-added") {
|
||||
let location = structure.get::<String>("location").unwrap();
|
||||
hls_events_sender
|
||||
hls_messages_sender
|
||||
.try_send(HlsSinkEvent::SegmentAddedMessage(location))
|
||||
.expect("Send segment added event");
|
||||
}
|
||||
|
@ -228,27 +229,38 @@ fn test_hlssink3_element_with_video_content() -> Result<(), ()> {
|
|||
vec![
|
||||
GetFragmentStream("segment00000.ts".to_string()),
|
||||
GetPlaylistStream("playlist.m3u8".to_string()),
|
||||
SegmentAddedMessage("segment00000.ts".to_string()),
|
||||
GetFragmentStream("segment00001.ts".to_string()),
|
||||
GetPlaylistStream("playlist.m3u8".to_string()),
|
||||
SegmentAddedMessage("segment00001.ts".to_string()),
|
||||
GetFragmentStream("segment00002.ts".to_string()),
|
||||
GetPlaylistStream("playlist.m3u8".to_string()),
|
||||
DeleteFragment("segment00000.ts".to_string()),
|
||||
SegmentAddedMessage("segment00002.ts".to_string()),
|
||||
GetFragmentStream("segment00003.ts".to_string()),
|
||||
GetPlaylistStream("playlist.m3u8".to_string()),
|
||||
DeleteFragment("segment00001.ts".into()),
|
||||
SegmentAddedMessage("segment00003.ts".to_string()),
|
||||
GetFragmentStream("segment00004.ts".to_string()),
|
||||
GetPlaylistStream("playlist.m3u8".to_string()),
|
||||
DeleteFragment("segment00002.ts".to_string()),
|
||||
SegmentAddedMessage("segment00004.ts".to_string()),
|
||||
GetPlaylistStream("playlist.m3u8".to_string()),
|
||||
]
|
||||
};
|
||||
assert_eq!(expected_ordering_of_events, actual_events);
|
||||
|
||||
let mut actual_messages = Vec::new();
|
||||
while let Ok(event) = hls_messages_receiver.recv_timeout(Duration::from_millis(1)) {
|
||||
actual_messages.push(event);
|
||||
}
|
||||
let expected_messages = {
|
||||
use self::HlsSinkEvent::*;
|
||||
vec![
|
||||
SegmentAddedMessage("segment00000.ts".to_string()),
|
||||
SegmentAddedMessage("segment00001.ts".to_string()),
|
||||
SegmentAddedMessage("segment00002.ts".to_string()),
|
||||
SegmentAddedMessage("segment00003.ts".to_string()),
|
||||
SegmentAddedMessage("segment00004.ts".to_string()),
|
||||
]
|
||||
};
|
||||
assert_eq!(expected_messages, actual_messages);
|
||||
|
||||
let contents = playlist_content.lock().unwrap();
|
||||
assert_eq!(
|
||||
r###"#EXTM3U
|
||||
|
@ -354,6 +366,7 @@ fn test_hlssink3_write_correct_playlist_content() -> Result<(), ()> {
|
|||
.expect("Must be able to instantiate hlssink3");
|
||||
|
||||
let (hls_events_sender, hls_events_receiver) = mpsc::sync_channel(20);
|
||||
let (hls_messages_sender, hls_messages_receiver) = mpsc::sync_channel(10);
|
||||
let playlist_content = Arc::new(Mutex::new(String::from("")));
|
||||
|
||||
hlssink3.connect("get-playlist-stream", false, {
|
||||
|
@ -428,7 +441,7 @@ fn test_hlssink3_write_correct_playlist_content() -> Result<(), ()> {
|
|||
if let Some(structure) = msg.structure() {
|
||||
if structure.has_name("hls-segment-added") {
|
||||
let location = structure.get::<String>("location").unwrap();
|
||||
hls_events_sender
|
||||
hls_messages_sender
|
||||
.try_send(HlsSinkEvent::SegmentAddedMessage(location))
|
||||
.expect("Send segment added event");
|
||||
}
|
||||
|
@ -452,12 +465,23 @@ fn test_hlssink3_write_correct_playlist_content() -> Result<(), ()> {
|
|||
vec![
|
||||
GetFragmentStream("/www/media/segments/my-own-filename-000.ts".to_string()),
|
||||
GetPlaylistStream("/www/media/main.m3u8".to_string()),
|
||||
SegmentAddedMessage("/www/media/segments/my-own-filename-000.ts".to_string()),
|
||||
GetPlaylistStream("/www/media/main.m3u8".to_string()),
|
||||
]
|
||||
};
|
||||
assert_eq!(expected_ordering_of_events, actual_events);
|
||||
|
||||
let mut actual_messages = Vec::new();
|
||||
while let Ok(event) = hls_messages_receiver.recv_timeout(Duration::from_millis(1)) {
|
||||
actual_messages.push(event);
|
||||
}
|
||||
let expected_messages = {
|
||||
use self::HlsSinkEvent::*;
|
||||
vec![SegmentAddedMessage(
|
||||
"/www/media/segments/my-own-filename-000.ts".to_string(),
|
||||
)]
|
||||
};
|
||||
assert_eq!(expected_messages, actual_messages);
|
||||
|
||||
let contents = playlist_content.lock().unwrap();
|
||||
assert_eq!(
|
||||
r###"#EXTM3U
|
||||
|
|
Loading…
Reference in a new issue