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
luyikei
VLMC
Commits
ce964a45
Commit
ce964a45
authored
Jun 02, 2009
by
Hugo Beauzee-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Multitracks timeline o//
parent
921cbf72
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
159 additions
and
39 deletions
+159
-39
src/Workflow/MainWorkflow.cpp
src/Workflow/MainWorkflow.cpp
+53
-9
src/Workflow/MainWorkflow.h
src/Workflow/MainWorkflow.h
+17
-11
src/Workflow/TrackWorkflow.cpp
src/Workflow/TrackWorkflow.cpp
+4
-12
src/Workflow/TrackWorkflow.h
src/Workflow/TrackWorkflow.h
+4
-3
src/gui/Timeline.cpp
src/gui/Timeline.cpp
+1
-1
src/gui/TracksView.cpp
src/gui/TracksView.cpp
+1
-1
src/gui/TracksView.h
src/gui/TracksView.h
+1
-1
src/tools/Singleton.hpp
src/tools/Singleton.hpp
+0
-0
src/tools/Toggleable.hpp
src/tools/Toggleable.hpp
+76
-0
vlmc.pro
vlmc.pro
+2
-1
No files found.
src/Workflow/MainWorkflow.cpp
View file @
ce964a45
...
...
@@ -25,19 +25,30 @@
#include "MainWorkflow.h"
MainWorkflow
::
MainWorkflow
()
:
m_renderStarted
(
false
)
unsigned
char
*
MainWorkflow
::
blackOutput
=
NULL
;
MainWorkflow
::
MainWorkflow
(
int
trackCount
)
:
m_trackCount
(
trackCount
),
m_renderStarted
(
false
)
{
m_tracks
=
new
TrackWorkflow
*
[
NB_TRACKS
];
for
(
unsigned
int
i
=
0
;
i
<
NB_TRACKS
;
++
i
)
if
(
MainWorkflow
::
blackOutput
==
NULL
)
{
m_tracks
[
i
]
=
new
TrackWorkflow
;
connect
(
m_tracks
[
i
],
SIGNAL
(
trackEndReached
()
),
this
,
SLOT
(
__endReached
()
)
);
//TODO: this ain't free !
MainWorkflow
::
blackOutput
=
new
unsigned
char
[
VIDEOHEIGHT
*
VIDEOWIDTH
*
3
];
memset
(
MainWorkflow
::
blackOutput
,
0
,
VIDEOHEIGHT
*
VIDEOWIDTH
*
3
);
}
m_tracks
=
new
Toggleable
<
TrackWorkflow
*>
[
trackCount
];
for
(
int
i
=
0
;
i
<
trackCount
;
++
i
)
{
m_tracks
[
i
].
setPtr
(
new
TrackWorkflow
(
i
)
);
connect
(
m_tracks
[
i
],
SIGNAL
(
trackEndReached
(
unsigned
int
)
),
this
,
SLOT
(
trackEndReached
(
unsigned
int
)
)
);
}
}
void
MainWorkflow
::
addClip
(
Clip
*
clip
,
unsigned
int
trackId
,
qint64
start
)
{
Q_ASSERT_X
(
trackId
<
NB_TRACKS
,
"MainWorkflow::addClip"
,
Q_ASSERT_X
(
trackId
<
m_trackCount
,
"MainWorkflow::addClip"
,
"The specified trackId isn't valid, for it's higher than the number of tracks"
);
qDebug
()
<<
"MainWorkflow: Adding clip"
<<
clip
->
getUuid
()
<<
"to track"
<<
trackId
;
...
...
@@ -46,15 +57,36 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
void
MainWorkflow
::
startRender
()
{
qint64
maxLength
=
0
;
m_renderStarted
=
true
;
m_currentFrame
=
0
;
emit
frameChanged
(
0
);
m_length
=
m_tracks
[
0
]
->
getLength
();
for
(
unsigned
int
i
=
0
;
i
<
m_trackCount
;
++
i
)
{
if
(
m_tracks
[
i
]
->
getLength
()
>
maxLength
)
maxLength
=
m_tracks
[
i
]
->
getLength
();
}
m_length
=
maxLength
;
}
unsigned
char
*
MainWorkflow
::
getOutput
()
{
unsigned
char
*
ret
=
m_tracks
[
0
]
->
getOutput
(
m_currentFrame
);
unsigned
char
*
ret
;
for
(
unsigned
int
i
=
0
;
i
<
m_trackCount
;
++
i
)
{
if
(
m_tracks
[
i
].
activated
()
==
false
)
continue
;
if
(
(
ret
=
m_tracks
[
i
]
->
getOutput
(
m_currentFrame
)
)
!=
NULL
)
{
qDebug
()
<<
"Getting a frame"
;
break
;
}
}
if
(
ret
==
NULL
)
ret
=
MainWorkflow
::
blackOutput
;
++
m_currentFrame
;
emit
frameChanged
(
m_currentFrame
);
emit
positionChanged
(
(
float
)
m_currentFrame
/
(
float
)
m_length
);
...
...
@@ -76,10 +108,22 @@ qint64 MainWorkflow::getLength() const
return
m_length
;
}
void
MainWorkflow
::
__e
ndReached
()
void
MainWorkflow
::
trackE
ndReached
(
unsigned
int
trackId
)
{
m_tracks
[
trackId
].
deactivate
();
for
(
unsigned
int
i
=
0
;
i
<
m_trackCount
;
++
i
)
{
if
(
m_tracks
[
i
].
activated
()
==
true
)
return
;
}
emit
mainWorkflowEndReached
();
m_renderStarted
=
false
;
m_currentFrame
=
0
;
emit
frameChanged
(
0
);
}
unsigned
int
MainWorkflow
::
getTrackCount
()
const
{
return
m_trackCount
;
}
src/Workflow/MainWorkflow.h
View file @
ce964a45
...
...
@@ -26,17 +26,15 @@
#include <QObject>
#include "tools/Toggleable.hpp"
#include "TrackWorkflow.h"
//TODO: THIS HAS TO GO ASAP !!!!!
#define NB_TRACKS 1
class
MainWorkflow
:
public
QObject
{
Q_OBJECT
public:
MainWorkflow
();
MainWorkflow
(
int
trackCount
);
void
addClip
(
Clip
*
clip
,
unsigned
int
trackId
,
qint64
start
);
void
startRender
();
...
...
@@ -53,18 +51,26 @@ class MainWorkflow : public QObject
* in frames.
*/
qint64
getLength
()
const
;
/**
*
This boolean describe is a render has been started
*/
bool
m_renderStarted
;
*
Returns the number of tracks in this workflow
*/
unsigned
int
getTrackCount
()
const
;
static
unsigned
char
*
blackOutput
;
private:
TrackWorkflow
**
m_tracks
;
qint64
m_currentFrame
;
qint64
m_length
;
Toggleable
<
TrackWorkflow
*>*
m_tracks
;
qint64
m_currentFrame
;
qint64
m_length
;
unsigned
int
m_trackCount
;
/**
* This boolean describe is a render has been started
*/
bool
m_renderStarted
;
private
slots
:
void
__endReached
(
);
void
trackEndReached
(
unsigned
int
trackId
);
signals:
/**
...
...
src/Workflow/TrackWorkflow.cpp
View file @
ce964a45
...
...
@@ -24,17 +24,9 @@
#include "TrackWorkflow.h"
unsigned
char
*
TrackWorkflow
::
blackOutput
=
NULL
;
TrackWorkflow
::
TrackWorkflow
()
TrackWorkflow
::
TrackWorkflow
(
unsigned
int
trackId
)
:
m_trackId
(
trackId
)
{
m_mediaPlayer
=
new
LibVLCpp
::
MediaPlayer
();
if
(
TrackWorkflow
::
blackOutput
==
NULL
)
{
//TODO: this ain't free !
TrackWorkflow
::
blackOutput
=
new
unsigned
char
[
VIDEOHEIGHT
*
VIDEOWIDTH
*
3
];
memset
(
TrackWorkflow
::
blackOutput
,
0
,
VIDEOHEIGHT
*
VIDEOWIDTH
*
3
);
}
}
TrackWorkflow
::~
TrackWorkflow
()
...
...
@@ -65,7 +57,7 @@ qint64 TrackWorkflow::getLength() const
unsigned
char
*
TrackWorkflow
::
renderClip
(
ClipWorkflow
*
cw
,
qint64
currentFrame
,
qint64
start
,
bool
needRepositioning
)
{
unsigned
char
*
ret
=
TrackWorkflow
::
blackOutput
;
unsigned
char
*
ret
=
NULL
;
cw
->
getStateLock
()
->
lockForRead
();
...
...
@@ -198,7 +190,7 @@ bool TrackWorkflow::checkEnd( qint64 currentFrame ) const
unsigned
char
*
TrackWorkflow
::
getOutput
(
qint64
currentFrame
)
{
unsigned
char
*
ret
=
TrackWorkflow
::
blackOutput
;
unsigned
char
*
ret
=
NULL
;
QMap
<
qint64
,
ClipWorkflow
*>::
iterator
it
=
m_clips
.
begin
();
QMap
<
qint64
,
ClipWorkflow
*>::
iterator
end
=
m_clips
.
end
();
static
qint64
lastFrame
=
0
;
...
...
@@ -206,7 +198,7 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
if
(
checkEnd
(
currentFrame
)
==
true
)
{
emit
trackEndReached
();
emit
trackEndReached
(
m_trackId
);
//We continue, as there can be ClipWorkflow that required to be stopped.
}
needRepositioning
=
(
abs
(
currentFrame
-
lastFrame
)
>
1
)
?
true
:
false
;
...
...
src/Workflow/TrackWorkflow.h
View file @
ce964a45
...
...
@@ -43,7 +43,7 @@ class TrackWorkflow : public QObject
Q_OBJECT
public:
TrackWorkflow
();
TrackWorkflow
(
unsigned
int
trackId
);
~
TrackWorkflow
();
unsigned
char
*
getOutput
(
qint64
currentFrame
);
...
...
@@ -51,7 +51,6 @@ class TrackWorkflow : public QObject
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static
const
unsigned
int
nbFrameBeforePreload
=
60
;
static
unsigned
char
*
blackOutput
;
private:
void
computeLength
();
...
...
@@ -62,6 +61,8 @@ class TrackWorkflow : public QObject
bool
checkEnd
(
qint64
currentFrame
)
const
;
private:
unsigned
int
m_trackId
;
QMap
<
qint64
,
ClipWorkflow
*>
m_clips
;
/**
...
...
@@ -79,7 +80,7 @@ class TrackWorkflow : public QObject
void
addClip
(
Clip
*
,
qint64
start
);
signals:
void
trackEndReached
();
void
trackEndReached
(
unsigned
int
);
};
#endif // TRACKWORKFLOW_H
src/gui/Timeline.cpp
View file @
ce964a45
...
...
@@ -32,7 +32,7 @@ Timeline::Timeline( QWidget *parent ) :
{
m_ui
.
setupUi
(
this
);
m_mainWorkflow
=
new
MainWorkflow
();
m_mainWorkflow
=
new
MainWorkflow
(
5
);
m_tracksScene
=
new
TracksScene
(
this
);
m_tracksView
=
new
TracksView
(
m_tracksScene
,
m_mainWorkflow
,
m_ui
.
tracksFrame
);
...
...
src/gui/TracksView.cpp
View file @
ce964a45
...
...
@@ -38,7 +38,7 @@ TracksView::TracksView( QGraphicsScene* scene, MainWorkflow* mainWorkflow, QWidg
m_tracksHeight
=
50
;
//TODO should be dynamic
m_tracksCount
=
5
;
m_tracksCount
=
mainWorkflow
->
getTrackCount
()
;
m_fps
=
30
;
setMouseTracking
(
true
);
...
...
src/gui/TracksView.h
View file @
ce964a45
...
...
@@ -43,7 +43,7 @@ public:
void
setDuration
(
int
duration
);
int
duration
()
const
{
return
m_projectDuration
;
}
int
tracksHeight
()
const
{
return
m_tracksHeight
;
}
int
tracksCount
()
const
{
return
m_tracksCount
;
}
unsigned
int
tracksCount
()
const
{
return
m_tracksCount
;
}
void
setCursorPos
(
int
pos
);
int
cursorPos
();
GraphicsCursorItem
*
tracksCursor
()
const
{
return
m_cursorLine
;
}
...
...
src/Singleton.hpp
→
src/
tools/
Singleton.hpp
View file @
ce964a45
File moved
src/tools/Toggleable.hpp
0 → 100644
View file @
ce964a45
/*****************************************************************************
* Toggleable.hpp : Represents a generic container for toglleable values
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef TOGGLEABLE_HPP
#define TOGGLEABLE_HPP
#include <QtDebug>
/**
* This class represents a generic toggleable value container.
*/
template
<
typename
T
>
class
Toggleable
{
public:
Toggleable
()
:
m_ptr
(
NULL
),
m_activated
(
true
)
{
}
void
setPtr
(
T
ptr
)
{
Q_ASSERT
(
m_ptr
==
NULL
);
m_ptr
=
ptr
;
}
operator
T
()
{
return
m_ptr
;
}
T
operator
->
()
{
if
(
m_activated
==
true
)
return
m_ptr
;
qDebug
()
<<
"using operator -> on a disabled value !"
;
return
NULL
;
}
bool
activated
()
const
{
return
m_activated
;
}
bool
deactivated
()
const
{
return
!
m_activated
;
}
void
activate
()
{
m_activated
=
true
;
}
void
deactivate
()
{
m_activated
=
false
;
}
private:
T
m_ptr
;
bool
m_activated
;
};
#endif // TOGGLEABLE_HPP
vlmc.pro
View file @
ce964a45
...
...
@@ -76,7 +76,8 @@ HEADERS += src/gui/MainWindow.h \
src
/
Workflow
/
MainWorkflow
.
h
\
src
/
gui
/
PreviewWidget
.
h
\
src
/
gui
/
RenderPreviewWidget
.
h
\
src
/
gui
/
GenericPreviewWidget
.
h
src
/
gui
/
GenericPreviewWidget
.
h
\
src
/
tools
/
Toggleable
.
hpp
FORMS
+=
src
/
gui
/
ui
/
MainWindow
.
ui
\
src
/
gui
/
ui
/
PreviewWidget
.
ui
\
src
/
gui
/
ui
/
Preferences
.
ui
\
...
...
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