mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-25 13:01:07 +00:00
uriplaylistbin: factor out create_items()
This commit is contained in:
parent
7c909e59a9
commit
4a5815cc97
1 changed files with 11 additions and 4 deletions
|
@ -617,6 +617,15 @@ struct Playlist {
|
||||||
|
|
||||||
impl Playlist {
|
impl Playlist {
|
||||||
fn new(uris: Vec<String>, iterations: u32) -> Self {
|
fn new(uris: Vec<String>, iterations: u32) -> Self {
|
||||||
|
Self {
|
||||||
|
items: Self::create_items(uris, iterations),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_items(
|
||||||
|
uris: Vec<String>,
|
||||||
|
iterations: u32,
|
||||||
|
) -> Box<dyn Iterator<Item = Item> + Send + Sync> {
|
||||||
fn infinite_iter(uris: Vec<String>) -> Box<dyn Iterator<Item = Item> + Send + Sync> {
|
fn infinite_iter(uris: Vec<String>) -> Box<dyn Iterator<Item = Item> + Send + Sync> {
|
||||||
Box::new(
|
Box::new(
|
||||||
uris.into_iter()
|
uris.into_iter()
|
||||||
|
@ -642,13 +651,11 @@ impl Playlist {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = if iterations == 0 {
|
if iterations == 0 {
|
||||||
infinite_iter(uris)
|
infinite_iter(uris)
|
||||||
} else {
|
} else {
|
||||||
finite_iter(uris, iterations)
|
finite_iter(uris, iterations)
|
||||||
};
|
}
|
||||||
|
|
||||||
Self { items }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next(&mut self) -> Result<Option<Item>, PlaylistError> {
|
fn next(&mut self) -> Result<Option<Item>, PlaylistError> {
|
||||||
|
|
Loading…
Reference in a new issue