Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
gstreamer-rs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zeeshan Ali
gstreamer-rs
Commits
54d8065d
Commit
54d8065d
authored
Oct 28, 2018
by
Sebastian Dröge
🍵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add TagList::iter_tag_list_simple() for getting a single value per tag
parent
7207bbed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
gstreamer/src/tags.rs
gstreamer/src/tags.rs
+78
-0
No files found.
gstreamer/src/tags.rs
View file @
54d8065d
...
...
@@ -476,6 +476,10 @@ impl TagListRef {
TagListIterator
::
new
(
self
)
}
pub
fn
iter_tag_list_simple
(
&
self
)
->
TagListSimpleIterator
{
TagListSimpleIterator
::
new
(
self
)
}
pub
fn
to_string
(
&
self
)
->
String
{
unsafe
{
from_glib_full
(
ffi
::
gst_tag_list_to_string
(
self
.as_ptr
()))
}
}
...
...
@@ -699,6 +703,64 @@ impl<'a> DoubleEndedIterator for TagListIterator<'a> {
impl
<
'a
>
ExactSizeIterator
for
TagListIterator
<
'a
>
{}
pub
struct
TagListSimpleIterator
<
'a
>
{
taglist
:
&
'a
TagListRef
,
idx
:
u32
,
size
:
u32
,
}
impl
<
'a
>
TagListSimpleIterator
<
'a
>
{
fn
new
(
taglist
:
&
'a
TagListRef
)
->
TagListSimpleIterator
<
'a
>
{
skip_assert_initialized!
();
let
size
=
taglist
.n_tags
();
TagListSimpleIterator
{
taglist
,
idx
:
0
,
size
:
if
size
>
0
{
size
as
u32
}
else
{
0
},
}
}
}
impl
<
'a
>
Iterator
for
TagListSimpleIterator
<
'a
>
{
type
Item
=
(
&
'a
str
,
glib
::
SendValue
);
fn
next
(
&
mut
self
)
->
Option
<
Self
::
Item
>
{
if
self
.idx
>=
self
.size
{
return
None
;
}
let
name
=
self
.taglist
.nth_tag_name
(
self
.idx
);
let
item
=
(
name
,
self
.taglist
.get_generic
(
name
)
.unwrap
());
self
.idx
+=
1
;
Some
(
item
)
}
fn
size_hint
(
&
self
)
->
(
usize
,
Option
<
usize
>
)
{
if
self
.idx
==
self
.size
{
return
(
0
,
Some
(
0
));
}
let
remaining
=
(
self
.size
-
self
.idx
)
as
usize
;
(
remaining
,
Some
(
remaining
))
}
}
impl
<
'a
>
DoubleEndedIterator
for
TagListSimpleIterator
<
'a
>
{
fn
next_back
(
&
mut
self
)
->
Option
<
Self
::
Item
>
{
if
self
.idx
==
self
.size
{
return
None
;
}
self
.size
-=
1
;
let
name
=
self
.taglist
.nth_tag_name
(
self
.idx
);
Some
((
name
,
self
.taglist
.get_generic
(
name
)
.unwrap
()))
}
}
impl
<
'a
>
ExactSizeIterator
for
TagListSimpleIterator
<
'a
>
{}
#[cfg(test)]
mod
tests
{
use
super
::
*
;
...
...
@@ -836,5 +898,21 @@ mod tests {
let
first_duration
=
tag_iter
.next
()
.unwrap
();
assert_eq!
(
first_duration
.get
(),
Some
(::
SECOND
*
120
));
assert
!
(
tag_iter
.next
()
.is_none
());
// TagListSimpleIterator
let
mut
tag_list_iter
=
tags
.iter_tag_list_simple
();
assert_eq!
(
tag_list_iter
.size_hint
(),
(
2
,
Some
(
2
)));
let
(
tag_name
,
tag_value
)
=
tag_list_iter
.next
()
.unwrap
();
assert_eq!
(
tag_name
,
*
TAG_TITLE
);
assert_eq!
(
tag_value
.get
(),
Some
(
"some title, second title, third title"
)
);
let
(
tag_name
,
tag_value
)
=
tag_list_iter
.next
()
.unwrap
();
assert_eq!
(
tag_name
,
*
TAG_DURATION
);
assert_eq!
(
tag_value
.get
(),
Some
(::
SECOND
*
120
));
assert
!
(
tag_iter
.next
()
.is_none
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment