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
VLMC
Commits
b8dbba21
Commit
b8dbba21
authored
Aug 19, 2016
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Media: Store Clip as QSharedPointer
parent
069ba8c8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
39 deletions
+37
-39
src/Commands/Commands.cpp
src/Commands/Commands.cpp
+3
-3
src/Commands/Commands.h
src/Commands/Commands.h
+9
-7
src/Library/Library.cpp
src/Library/Library.cpp
+2
-3
src/Library/Library.h
src/Library/Library.h
+2
-2
src/Media/Media.cpp
src/Media/Media.cpp
+6
-6
src/Media/Media.h
src/Media/Media.h
+4
-4
src/Workflow/SequenceWorkflow.cpp
src/Workflow/SequenceWorkflow.cpp
+7
-10
src/Workflow/SequenceWorkflow.h
src/Workflow/SequenceWorkflow.h
+4
-4
No files found.
src/Commands/Commands.cpp
View file @
b8dbba21
...
...
@@ -141,7 +141,7 @@ Commands::Clip::Add::retranslate()
setText
(
tr
(
"Adding clip to track %1"
).
arg
(
m_trackId
)
);
}
std
::
shared_ptr
<
Clip
>
QSharedPointer
<::
Clip
>
Commands
::
Clip
::
Add
::
newClip
()
{
return
m_clip
;
...
...
@@ -307,8 +307,8 @@ Commands::Clip::Split::Split( std::shared_ptr<SequenceWorkflow> const& workflow,
retranslate
();
return
;
}
m_newClip
=
std
::
shared_ptr
<::
Clip
>
(
m_toSplit
->
media
()
->
cut
(
newClipBegin
-
m_toSplit
->
begin
(),
m_toSplit
->
end
()
-
m_toSplit
->
begin
()
)
);
m_newClip
=
m_toSplit
->
media
()
->
cut
(
newClipBegin
-
m_toSplit
->
begin
(),
m_toSplit
->
end
()
-
m_toSplit
->
begin
()
);
m_oldEnd
=
m_toSplit
->
end
();
retranslate
();
}
...
...
src/Commands/Commands.h
View file @
b8dbba21
...
...
@@ -31,6 +31,8 @@
#endif
#include <QObject>
#include <QUuid>
#include <QSharedPointer>
#include <memory>
class
Clip
;
...
...
@@ -83,12 +85,12 @@ namespace Commands
virtual
void
internalUndo
();
virtual
void
retranslate
();
std
::
shared_pt
r
<::
Clip
>
newClip
();
QSharedPointe
r
<::
Clip
>
newClip
();
private:
std
::
shared_ptr
<
SequenceWorkflow
>
m_workflow
;
QUuid
m_uuid
;
std
::
shared_pt
r
<::
Clip
>
m_clip
;
QSharedPointe
r
<::
Clip
>
m_clip
;
quint32
m_trackId
;
qint64
m_pos
;
bool
m_isAudioClip
;
...
...
@@ -104,7 +106,7 @@ namespace Commands
private:
std
::
shared_ptr
<
SequenceWorkflow
>
m_workflow
;
std
::
shared_pt
r
<::
Clip
>
m_clip
;
QSharedPointe
r
<::
Clip
>
m_clip
;
quint32
m_newTrackId
;
quint32
m_oldTrackId
;
qint64
m_newPos
;
...
...
@@ -121,7 +123,7 @@ namespace Commands
private:
std
::
shared_ptr
<
SequenceWorkflow
>
m_workflow
;
std
::
shared_pt
r
<::
Clip
>
m_clip
;
QSharedPointe
r
<::
Clip
>
m_clip
;
quint32
m_trackId
;
qint64
m_pos
;
};
...
...
@@ -144,7 +146,7 @@ namespace Commands
private:
std
::
shared_ptr
<
SequenceWorkflow
>
m_workflow
;
std
::
shared_pt
r
<::
Clip
>
m_clip
;
QSharedPointe
r
<::
Clip
>
m_clip
;
qint64
m_newBegin
;
qint64
m_oldBegin
;
qint64
m_newEnd
;
...
...
@@ -163,9 +165,9 @@ namespace Commands
virtual
void
retranslate
();
private:
std
::
shared_ptr
<
SequenceWorkflow
>
m_workflow
;
std
::
shared_pt
r
<::
Clip
>
m_toSplit
;
QSharedPointe
r
<::
Clip
>
m_toSplit
;
quint32
m_trackId
;
std
::
shared_pt
r
<::
Clip
>
m_newClip
;
QSharedPointe
r
<::
Clip
>
m_newClip
;
qint64
m_newClipPos
;
qint64
m_newClipBegin
;
qint64
m_oldEnd
;
...
...
src/Library/Library.cpp
View file @
b8dbba21
...
...
@@ -85,7 +85,7 @@ Library::addMedia( QSharedPointer<Media> media )
if
(
m_media
.
contains
(
media
->
id
()
)
)
return
;
m_media
[
media
->
id
()]
=
media
;
connect
(
media
.
data
(),
&
Media
::
subclipAdded
,
[
this
](
Clip
*
c
)
{
connect
(
media
.
data
(),
&
Media
::
subclipAdded
,
[
this
](
QSharedPointer
<
Clip
>
c
)
{
m_clips
[
c
->
uuid
()]
=
c
;
setCleanState
(
false
);
});
...
...
@@ -108,8 +108,7 @@ Library::media( qint64 mediaId )
return
m_media
.
value
(
mediaId
);
}
Clip
*
Library
::
clip
(
const
QUuid
&
uuid
)
QSharedPointer
<
Clip
>
Library
::
clip
(
const
QUuid
&
uuid
)
{
return
m_clips
.
value
(
uuid
);
...
...
src/Library/Library.h
View file @
b8dbba21
...
...
@@ -60,7 +60,7 @@ public:
* @return The clip if it exists, or nullptr
* This can be any clip, the given UUID doesn't have to refer to a root clip
*/
Clip
*
clip
(
const
QUuid
&
uuid
);
QSharedPointer
<
Clip
>
clip
(
const
QUuid
&
uuid
);
void
clear
();
private:
...
...
@@ -75,7 +75,7 @@ private:
* @brief m_clips contains all the clips loaded in the library, without any
* subclip hierarchy
*/
QHash
<
QUuid
,
Clip
*
>
m_clips
;
QHash
<
QUuid
,
QSharedPointer
<
Clip
>
>
m_clips
;
void
preSave
();
void
postLoad
();
...
...
src/Media/Media.cpp
View file @
b8dbba21
...
...
@@ -116,10 +116,10 @@ Media::id() const
return
m_mlMedia
->
id
();
}
Clip
*
Media
::
cut
(
qint64
begin
,
qint64
end
)
QSharedPointer
<
Clip
>
Media
::
cut
(
qint64
begin
,
qint64
end
)
{
auto
clip
=
new
Clip
(
sharedFromThis
(),
begin
,
end
);
auto
clip
=
QSharedPointer
<
Clip
>
(
new
Clip
(
sharedFromThis
(),
begin
,
end
)
);
m_clips
[
clip
->
uuid
()]
=
clip
;
emit
subclipAdded
(
clip
);
return
clip
;
...
...
@@ -221,18 +221,18 @@ Media::snapshot()
return
m_snapshot
.
isNull
()
?
*
Media
::
defaultSnapshot
:
m_snapshot
;
}
Clip
*
QSharedPointer
<
Clip
>
Media
::
loadSubclip
(
const
QVariantMap
&
m
)
{
if
(
m
.
contains
(
"uuid"
)
==
false
||
m
.
contains
(
"begin"
)
==
false
||
m
.
contains
(
"end"
)
==
false
)
{
vlmcWarning
()
<<
"Invalid clip provided:"
<<
m
;
return
nullptr
;
return
{}
;
}
const
auto
&
uuid
=
m
[
"uuid"
].
toUuid
();
const
auto
begin
=
m
[
"begin"
].
toLongLong
();
const
auto
end
=
m
[
"end"
].
toLongLong
();
auto
clip
=
new
Clip
(
sharedFromThis
(),
begin
,
end
,
uuid
);
auto
clip
=
QSharedPointer
<
Clip
>
(
new
Clip
(
sharedFromThis
(),
begin
,
end
,
uuid
)
);
//FIXME: This shouldn't be loaded from the library
clip
->
loadFilters
(
m
);
...
...
src/Media/Media.h
View file @
b8dbba21
...
...
@@ -99,7 +99,7 @@ public:
* @param end The last frame of the cut
* @return A new Clip, representing the media from [begin] to [end]
*/
Clip
*
cut
(
qint64
begin
,
qint64
end
);
QSharedPointer
<
Clip
>
cut
(
qint64
begin
,
qint64
end
);
void
removeSubclip
(
const
QUuid
&
uuid
);
QVariant
toVariant
()
const
;
...
...
@@ -115,14 +115,14 @@ public:
#endif
private:
Clip
*
loadSubclip
(
const
QVariantMap
&
m
);
QSharedPointer
<
Clip
>
loadSubclip
(
const
QVariantMap
&
m
);
protected:
std
::
unique_ptr
<
Backend
::
IInput
>
m_input
;
medialibrary
::
MediaPtr
m_mlMedia
;
medialibrary
::
FilePtr
m_mlFile
;
Clip
*
m_baseClip
;
QHash
<
QUuid
,
Clip
*>
m_clips
;
QHash
<
QUuid
,
QSharedPointer
<
Clip
>>
m_clips
;
#ifdef HAVE_GUI
static
QPixmap
*
defaultSnapshot
;
...
...
@@ -134,7 +134,7 @@ signals:
* \brief This signal should be emitted to tell a new sublip have been added
* \param Clip The newly added subclip
*/
void
subclipAdded
(
Clip
*
);
void
subclipAdded
(
QSharedPointer
<
Clip
>
);
/**
* \brief This signal should be emiteted when a subclip has been removed
* This signal pass a QUuid as the clip may be deleted when the signal reaches its
...
...
src/Workflow/SequenceWorkflow.cpp
View file @
b8dbba21
...
...
@@ -64,7 +64,7 @@ SequenceWorkflow::~SequenceWorkflow()
}
bool
SequenceWorkflow
::
addClip
(
std
::
shared_pt
r
<
Clip
>
const
&
clip
,
quint32
trackId
,
qint32
pos
)
SequenceWorkflow
::
addClip
(
QSharedPointe
r
<
Clip
>
const
&
clip
,
quint32
trackId
,
qint32
pos
)
{
auto
ret
=
trackFromFormats
(
trackId
,
clip
->
formats
()
)
->
insertAt
(
*
clip
->
input
(),
pos
);
if
(
ret
==
false
)
...
...
@@ -76,16 +76,13 @@ SequenceWorkflow::addClip( std::shared_ptr<Clip> const& clip, quint32 trackId, q
QString
SequenceWorkflow
::
addClip
(
const
QUuid
&
uuid
,
quint32
trackId
,
qint32
pos
,
bool
isAudioClip
)
{
Clip
*
c
lip
=
Core
::
instance
()
->
library
()
->
clip
(
uuid
);
if
(
c
lip
==
nullptr
)
auto
newC
lip
=
Core
::
instance
()
->
library
()
->
clip
(
uuid
);
if
(
newC
lip
==
nullptr
)
{
vlmcCritical
()
<<
"Couldn't find an acceptable parent to be added."
;
return
QUuid
().
toString
();
}
//FIXME: This will blow up:
auto
newClip
=
std
::
shared_ptr
<
Clip
>
(
clip
);
if
(
isAudioClip
==
true
)
newClip
->
setFormats
(
Clip
::
Audio
);
else
...
...
@@ -150,14 +147,14 @@ SequenceWorkflow::resizeClip( const QUuid& uuid, qint64 newBegin, qint64 newEnd,
return
ret
;
}
std
::
shared_pt
r
<
Clip
>
QSharedPointe
r
<
Clip
>
SequenceWorkflow
::
removeClip
(
const
QUuid
&
uuid
)
{
auto
it
=
m_clips
.
find
(
uuid
);
if
(
it
==
m_clips
.
end
()
)
{
vlmcCritical
()
<<
"Couldn't find a clip "
<<
uuid
;
return
std
::
shared_ptr
<
Clip
>
(
nullptr
)
;
return
{}
;
}
auto
clip
=
std
::
get
<
ClipTupleIndex
::
Clip
>
(
it
.
value
()
);
auto
trackId
=
std
::
get
<
ClipTupleIndex
::
TrackId
>
(
it
.
value
()
);
...
...
@@ -266,12 +263,12 @@ SequenceWorkflow::clear()
}
}
std
::
shared_pt
r
<
Clip
>
QSharedPointe
r
<
Clip
>
SequenceWorkflow
::
clip
(
const
QUuid
&
uuid
)
{
auto
it
=
m_clips
.
find
(
uuid
);
if
(
it
==
m_clips
.
end
()
)
return
std
::
shared_ptr
<
Clip
>
(
nullptr
)
;
return
{}
;
return
std
::
get
<
ClipTupleIndex
::
Clip
>
(
it
.
value
()
);
}
...
...
src/Workflow/SequenceWorkflow.h
View file @
b8dbba21
...
...
@@ -57,14 +57,14 @@ class SequenceWorkflow : public QObject
~
SequenceWorkflow
();
// Clip, Track Id, and Position
using
ClipTuple
=
std
::
tuple
<
std
::
shared_pt
r
<
Clip
>
,
quint32
,
qint64
>
;
using
ClipTuple
=
std
::
tuple
<
QSharedPointe
r
<
Clip
>
,
quint32
,
qint64
>
;
bool
addClip
(
std
::
shared_pt
r
<
Clip
>
const
&
clip
,
quint32
trackId
,
qint32
pos
);
bool
addClip
(
QSharedPointe
r
<
Clip
>
const
&
clip
,
quint32
trackId
,
qint32
pos
);
QString
addClip
(
const
QUuid
&
uuid
,
quint32
trackId
,
qint32
pos
,
bool
isAudioClip
);
bool
moveClip
(
const
QUuid
&
uuid
,
quint32
trackId
,
qint64
pos
);
bool
resizeClip
(
const
QUuid
&
uuid
,
qint64
newBegin
,
qint64
newEnd
,
qint64
newPos
);
std
::
shared_pt
r
<
Clip
>
removeClip
(
const
QUuid
&
uuid
);
QSharedPointe
r
<
Clip
>
removeClip
(
const
QUuid
&
uuid
);
bool
linkClips
(
const
QUuid
&
uuidA
,
const
QUuid
&
uuidB
);
bool
unlinkClips
(
const
QUuid
&
uuidA
,
const
QUuid
&
uuidB
);
...
...
@@ -72,7 +72,7 @@ class SequenceWorkflow : public QObject
void
loadFromVariant
(
const
QVariant
&
variant
);
void
clear
();
std
::
shared_pt
r
<
Clip
>
clip
(
const
QUuid
&
uuid
);
QSharedPointe
r
<
Clip
>
clip
(
const
QUuid
&
uuid
);
quint32
trackId
(
const
QUuid
&
uuid
);
qint32
position
(
const
QUuid
&
uuid
);
...
...
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