Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
VLMC
Commits
edad8fd2
Commit
edad8fd2
authored
Nov 24, 2009
by
Hugo Beauzee-Luyssen
Browse files
Clip splitting is now fully synchrone, thus avoiding the workflow to think it reached its end.
parent
60077905
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/GUI/TracksView.cpp
View file @
edad8fd2
...
...
@@ -688,14 +688,20 @@ GraphicsTrack* TracksView::getTrack( unsigned int number )
void
TracksView
::
split
(
GraphicsMovieItem
*
item
,
qint64
frame
)
{
Q_ASSERT
(
item
);
Clip
*
newclip
=
item
->
clip
()
->
split
(
frame
);
Q_ASSERT
(
newclip
);
addMediaItem
(
newclip
,
item
->
trackNumber
(),
item
->
pos
().
x
()
+
frame
);
Commands
::
trigger
(
new
Commands
::
MainWorkflow
::
AddClip
(
m_renderer
,
newclip
,
item
->
trackNumber
(),
item
->
pos
().
x
()
+
frame
,
MainWorkflow
::
VideoTrack
)
);
// Q_ASSERT( item );
// Clip* newclip = item->clip()->split( frame );
// Q_ASSERT( newclip );
//
// addMediaItem( newclip, item->trackNumber(), item->pos().x() + frame );
// Commands::trigger( new Commands::MainWorkflow::AddClip( m_renderer,
// newclip,
// item->trackNumber(),
// item->pos().x() + frame,
// MainWorkflow::VideoTrack ) );
//frame is the number of frame from the beginning of the clip
//item->pos().x() is the position of the splitted clip (in frame)
//therefore, the position of the newly created clip is
//the splitted clip pos + the splitting point (ie pos().x() + frame)
m_renderer
->
split
(
item
->
clip
(),
item
->
trackNumber
(),
item
->
pos
().
x
()
+
frame
,
frame
,
MainWorkflow
::
VideoTrack
);
}
src/Media/Clip.cpp
View file @
edad8fd2
...
...
@@ -177,12 +177,11 @@ void Clip::setEnd( qint64 end )
emit
lengthUpdated
();
}
Clip
*
Clip
::
s
plit
(
qint64
endFrame
)
void
Clip
::
s
etBoundaries
(
qint64
newBegin
,
qint64
newEnd
)
{
Q_ASSERT
(
endFrame
!=
m_end
);
endFrame
+=
m_begin
;
Clip
*
newClip
=
new
Clip
(
this
,
endFrame
,
m_end
);
m_end
=
endFrame
;
Q_ASSERT
(
newBegin
<
newEnd
);
m_begin
=
newBegin
;
m_end
=
newEnd
;
computeLength
();
return
newClip
;
emit
lengthUpdated
()
;
}
src/Media/Clip.h
View file @
edad8fd2
...
...
@@ -57,6 +57,7 @@ class Clip : public QObject
void
setBegin
(
qint64
begin
);
void
setEnd
(
qint64
end
);
void
setBoundaries
(
qint64
newBegin
,
qint64
newEnd
);
/**
\return Returns the clip length in frame.
...
...
@@ -89,14 +90,6 @@ class Clip : public QObject
const
QString
&
getNotes
()
const
;
void
setNotes
(
const
QString
&
notes
);
/**
* \brief Split this clip in two parts.
* \param newEnd The new end for this Clip. This will be the beginning of the
* newly created Clip.
* \returns A new Clip starting at newEnd.
*/
Clip
*
split
(
qint64
newEndFrame
);
private:
void
computeLength
();
...
...
src/Renderer/WorkflowRenderer.cpp
View file @
edad8fd2
...
...
@@ -137,6 +137,9 @@ void WorkflowRenderer::checkActions()
case
RemoveClip
:
m_mainWorkflow
->
removeClip
(
act
->
uuid
,
act
->
trackId
,
act
->
trackType
);
break
;
case
ResizeClip
:
resizeClip
(
act
->
clip
,
act
->
newBegin
,
act
->
newEnd
);
break
;
default:
qDebug
()
<<
"Unhandled action:"
<<
act
->
action
;
break
;
...
...
@@ -316,6 +319,45 @@ void WorkflowRenderer::rulerCursorChanged( qint64 newFrame )
m_mainWorkflow
->
setCurrentFrame
(
newFrame
,
MainWorkflow
::
RulerCursor
);
}
Clip
*
WorkflowRenderer
::
split
(
Clip
*
toSplit
,
uint32_t
trackId
,
qint64
newClipPos
,
qint64
newClipBegin
,
MainWorkflow
::
TrackType
trackType
)
{
Clip
*
newClip
=
new
Clip
(
toSplit
,
newClipBegin
,
toSplit
->
getEnd
()
);
if
(
m_isRendering
==
true
)
{
//adding clip
//We can NOT call addClip, as it would lock the action lock and then release it,
//thus potentially breaking the synchrone way of doing this
StackedAction
*
act
=
new
StackedAction
(
AddClip
);
act
->
clip
=
newClip
;
act
->
trackId
=
trackId
;
act
->
startingPos
=
newClipPos
;
act
->
trackType
=
trackType
;
//resizing it
StackedAction
*
act2
=
new
StackedAction
(
ResizeClip
);
act2
->
clip
=
toSplit
;
act2
->
newBegin
=
toSplit
->
getBegin
();
act2
->
newEnd
=
newClipBegin
;
//Push the actions onto the action stack
QMutexLocker
lock
(
m_actionsMutex
);
m_actions
.
push
(
act
);
m_actions
.
push
(
act2
);
}
else
{
toSplit
->
setEnd
(
newClipBegin
);
m_mainWorkflow
->
addClip
(
newClip
,
trackId
,
newClipPos
,
trackType
);
}
return
newClip
;
}
void
WorkflowRenderer
::
resizeClip
(
Clip
*
clip
,
qint64
newBegin
,
qint64
newEnd
)
{
clip
->
setBoundaries
(
newBegin
,
newEnd
);
}
/////////////////////////////////////////////////////////////////////
/////SLOTS :
/////////////////////////////////////////////////////////////////////
...
...
@@ -352,4 +394,3 @@ void WorkflowRenderer::__videoStopped()
{
emit
endReached
();
}
src/Renderer/WorkflowRenderer.h
View file @
edad8fd2
...
...
@@ -42,6 +42,7 @@ class WorkflowRenderer : public GenericRenderer
Pause
,
AddClip
,
RemoveClip
,
ResizeClip
,
//Unpause,
};
struct
StackedAction
...
...
@@ -53,6 +54,8 @@ class WorkflowRenderer : public GenericRenderer
MainWorkflow
::
TrackType
trackType
;
Clip
*
clip
;
qint64
startingPos
;
qint64
newBegin
;
qint64
newEnd
;
};
WorkflowRenderer
();
~
WorkflowRenderer
();
...
...
@@ -64,8 +67,10 @@ class WorkflowRenderer : public GenericRenderer
virtual
qint64
getLengthMs
()
const
;
virtual
qint64
getCurrentFrame
()
const
;
virtual
float
getFps
()
const
;
void
addClip
(
Clip
*
clip
,
uint32_t
track
Number
,
qint64
startingPos
,
MainWorkflow
::
TrackType
trackType
);
void
addClip
(
Clip
*
clip
,
uint32_t
track
Id
,
qint64
startingPos
,
MainWorkflow
::
TrackType
trackType
);
void
removeClip
(
const
QUuid
&
uuid
,
uint32_t
trackId
,
MainWorkflow
::
TrackType
trackType
);
Clip
*
split
(
Clip
*
toSplit
,
uint32_t
trackId
,
qint64
newClipPos
,
qint64
newClipBegin
,
MainWorkflow
::
TrackType
trackType
);
void
resizeClip
(
Clip
*
clip
,
qint64
newBegin
,
qint64
newEnd
);
static
void
*
lock
(
void
*
datas
);
static
void
*
lockAudio
(
void
*
datas
);
...
...
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