Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
20b12b14
Commit
20b12b14
authored
Jun 22, 2018
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Media: Provide an unsetMetadata method
parent
82c8fb24
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
0 deletions
+35
-0
include/medialibrary/IMedia.h
include/medialibrary/IMedia.h
+1
-0
src/Media.cpp
src/Media.cpp
+8
-0
src/Media.h
src/Media.h
+1
-0
test/unittest/MediaTests.cpp
test/unittest/MediaTests.cpp
+25
-0
No files found.
include/medialibrary/IMedia.h
View file @
20b12b14
...
...
@@ -156,6 +156,7 @@ class IMedia
///
virtual
bool
setMetadata
(
MetadataType
type
,
const
std
::
string
&
value
)
=
0
;
virtual
bool
setMetadata
(
MetadataType
type
,
int64_t
value
)
=
0
;
virtual
bool
unsetMetadata
(
MetadataType
type
)
=
0
;
};
}
src/Media.cpp
View file @
20b12b14
...
...
@@ -322,6 +322,14 @@ bool Media::setMetadata( IMedia::MetadataType type, int64_t value )
return
m_metadata
.
set
(
static_cast
<
MDType
>
(
type
),
value
);
}
bool
Media
::
unsetMetadata
(
IMedia
::
MetadataType
type
)
{
using
MDType
=
typename
std
::
underlying_type
<
IMedia
::
MetadataType
>::
type
;
if
(
m_metadata
.
isReady
()
==
false
)
m_metadata
.
init
(
m_id
,
IMedia
::
NbMeta
);
return
m_metadata
.
unset
(
static_cast
<
MDType
>
(
type
)
);
}
void
Media
::
setReleaseDate
(
unsigned
int
date
)
{
if
(
m_releaseDate
==
date
)
...
...
src/Media.h
View file @
20b12b14
...
...
@@ -113,6 +113,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
virtual
const
IMetadata
&
metadata
(
MetadataType
type
)
const
override
;
virtual
bool
setMetadata
(
MetadataType
type
,
const
std
::
string
&
value
)
override
;
virtual
bool
setMetadata
(
MetadataType
type
,
int64_t
value
)
override
;
virtual
bool
unsetMetadata
(
MetadataType
type
)
override
;
void
setReleaseDate
(
unsigned
int
date
);
bool
save
();
...
...
test/unittest/MediaTests.cpp
View file @
20b12b14
...
...
@@ -542,6 +542,31 @@ TEST_F( Medias, MetadataOverride )
ASSERT_EQ
(
"otter"
,
md
.
str
()
);
}
TEST_F
(
Medias
,
MetadataUnset
)
{
auto
m
=
ml
->
addMedia
(
"media.mp3"
);
auto
res
=
m
->
unsetMetadata
(
Media
::
MetadataType
::
ApplicationSpecific
);
ASSERT_TRUE
(
res
);
res
=
m
->
setMetadata
(
Media
::
MetadataType
::
ApplicationSpecific
,
"otters"
);
ASSERT_TRUE
(
res
);
auto
&
md
=
m
->
metadata
(
Media
::
MetadataType
::
ApplicationSpecific
);
ASSERT_TRUE
(
md
.
isSet
()
);
ASSERT_EQ
(
"otters"
,
md
.
str
()
);
res
=
m
->
unsetMetadata
(
Media
::
MetadataType
::
ApplicationSpecific
);
ASSERT_TRUE
(
res
);
ASSERT_FALSE
(
md
.
isSet
()
);
Reload
();
m
=
ml
->
media
(
m
->
id
()
);
auto
&
md2
=
m
->
metadata
(
Media
::
MetadataType
::
ApplicationSpecific
);
ASSERT_FALSE
(
md2
.
isSet
()
);
}
TEST_F
(
Medias
,
ExternalMrl
)
{
auto
m
=
ml
->
addMedia
(
"https://foo.bar/sea-otters.mkv"
);
...
...
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