Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
VLMC
Commits
34508ae4
Commit
34508ae4
authored
Aug 17, 2016
by
Hugo Beauzée-Luyssen
Browse files
MediaContainer: Move createClipFromVariant to Clip class
parent
076e08d8
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/Library/Library.cpp
View file @
34508ae4
...
...
@@ -78,7 +78,11 @@ Library::postLoad()
}
for
(
const
auto
&
var
:
m_settings
->
value
(
"clips"
)
->
get
().
toList
()
)
createClipFromVariant
(
var
,
nullptr
);
{
auto
c
=
Clip
::
fromVariant
(
var
);
if
(
c
!=
nullptr
)
addClip
(
c
);
}
}
Library
::~
Library
()
...
...
@@ -123,6 +127,12 @@ Library::isInCleanState() const
return
m_cleanState
;
}
Media
*
Library
::
media
(
const
QString
&
mrl
)
{
return
m_medias
.
value
(
mrl
);
}
void
Library
::
setCleanState
(
bool
newState
)
{
...
...
src/Library/Library.h
View file @
34508ae4
...
...
@@ -54,6 +54,7 @@ public:
virtual
Media
*
addMedia
(
const
QFileInfo
&
fileInfo
);
virtual
bool
addClip
(
Clip
*
clip
);
bool
isInCleanState
()
const
;
Media
*
media
(
const
QString
&
mrl
);
private:
void
setCleanState
(
bool
newState
);
...
...
src/Library/MediaContainer.cpp
View file @
34508ae4
...
...
@@ -192,27 +192,3 @@ MediaContainer::count() const
{
return
m_clips
.
size
();
}
Clip
*
MediaContainer
::
createClipFromVariant
(
const
QVariant
&
var
,
Clip
*
parent
)
{
QVariantMap
h
=
var
.
toMap
();
Clip
*
c
=
nullptr
;
if
(
h
.
contains
(
"parent"
)
)
c
=
new
Clip
(
parent
,
h
[
"begin"
].
toULongLong
(),
h
[
"end"
].
toULongLong
(),
h
[
"uuid"
].
toString
()
);
else
{
c
=
new
Clip
(
m_medias
[
h
[
"media"
].
toString
()
],
0
,
-
1
,
h
[
"uuid"
].
toString
()
);
addClip
(
c
);
}
if
(
h
.
contains
(
"subClips"
)
)
for
(
auto
&
var
:
h
[
"subClips"
].
toList
()
)
c
->
addSubclip
(
createClipFromVariant
(
var
,
c
)
);
if
(
h
.
contains
(
"filters"
)
)
for
(
auto
&
var
:
h
[
"filters"
].
toList
()
)
EffectHelper
::
loadFromVariant
(
var
,
c
->
input
()
);
return
c
;
}
src/Library/MediaContainer.h
View file @
34508ae4
...
...
@@ -121,8 +121,6 @@ protected:
Clip
*
m_parent
;
Clip
*
createClipFromVariant
(
const
QVariant
&
var
,
Clip
*
parent
);
public
slots
:
/**
* \brief Removes a Clip from the container and delete it
...
...
src/Media/Clip.cpp
View file @
34508ae4
...
...
@@ -36,6 +36,7 @@
#include
"Media/Media.h"
#include
"Project/Workspace.h"
#include
"EffectsEngine/EffectHelper.h"
#include
"Tools/VlmcDebug.h"
#include
<QVariant>
Clip
::
Clip
(
Media
*
media
,
qint64
begin
/*= 0*/
,
qint64
end
/*= Backend::IInput::EndOfMedia */
,
const
QString
&
uuid
/*= QString()*/
)
:
...
...
@@ -342,6 +343,89 @@ Clip::input()
return
m_input
.
get
();
}
Clip
*
Clip
::
fromVariant
(
const
QVariant
&
v
)
{
auto
m
=
v
.
toMap
();
if
(
m
.
contains
(
"parent"
)
)
{
vlmcWarning
()
<<
"Refusing to load a root clip with a parent field"
;
return
nullptr
;
}
auto
mediaMrl
=
m
[
"media"
].
toString
();
if
(
mediaMrl
.
isEmpty
()
==
true
)
{
vlmcWarning
()
<<
"Refusing to load an invalid root clip with no base media"
;
return
nullptr
;
}
auto
uuid
=
m
[
"uuid"
].
toString
();
if
(
uuid
.
isEmpty
()
==
true
)
{
vlmcWarning
()
<<
"Refusing to load an invalid root clip with no UUID"
;
return
nullptr
;
}
auto
media
=
Core
::
instance
()
->
library
()
->
media
(
mediaMrl
);
auto
clip
=
new
Clip
(
media
,
0
,
-
1
,
uuid
);
clip
->
loadVariant
(
m
);
return
clip
;
}
Clip
*
Clip
::
fromVariant
(
const
QVariant
&
v
,
Clip
*
parent
)
{
auto
m
=
v
.
toMap
();
if
(
m
.
contains
(
"parent"
)
==
false
)
{
vlmcWarning
()
<<
"Refusing to load a subclip with no parent field"
;
return
nullptr
;
}
auto
mediaMrl
=
m
[
"media"
].
toString
();
if
(
mediaMrl
.
isEmpty
()
==
true
)
{
vlmcWarning
()
<<
"Refusing to load an invalid root clip with no base media"
;
return
nullptr
;
}
auto
uuid
=
m
[
"uuid"
].
toString
();
if
(
uuid
.
isEmpty
()
==
true
)
{
vlmcWarning
()
<<
"Refusing to load an invalid root clip with no UUID"
;
return
nullptr
;
}
auto
begin
=
m
[
"begin"
].
toLongLong
();
auto
end
=
m
[
"end"
].
toLongLong
();
auto
media
=
Core
::
instance
()
->
library
()
->
media
(
mediaMrl
);
auto
clip
=
new
Clip
(
parent
,
begin
,
end
,
uuid
);
clip
->
loadVariant
(
m
);
return
clip
;
}
void
Clip
::
loadVariant
(
const
QVariantMap
&
m
)
{
if
(
m
.
contains
(
"subClips"
)
)
{
auto
children
=
m
[
"subClips"
].
toList
();
for
(
const
auto
&
clipMap
:
children
)
m_childs
->
addClip
(
fromVariant
(
clipMap
,
this
)
);
}
if
(
m
.
contains
(
"filters"
)
)
{
const
auto
&
filters
=
m
[
"filters"
].
toList
();
for
(
const
auto
&
f
:
filters
)
EffectHelper
::
loadFromVariant
(
f
,
input
()
);
}
}
void
Clip
::
mediaMetadataUpdated
()
{
...
...
src/Media/Clip.h
View file @
34508ae4
...
...
@@ -144,6 +144,12 @@ class Clip : public Workflow::Helper
Backend
::
IInput
*
input
();
static
Clip
*
fromVariant
(
const
QVariant
&
v
);
private:
static
Clip
*
fromVariant
(
const
QVariant
&
v
,
Clip
*
parent
);
void
loadVariant
(
const
QVariantMap
&
v
);
private:
Media
*
m_media
;
std
::
unique_ptr
<
Backend
::
IInput
>
m_input
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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