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
7943189e
Commit
7943189e
authored
Jun 26, 2009
by
Hugo Beauzee-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Corrected random crash when moving a media between tracks
Added a basic media player pool
parent
bba5a790
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
103 additions
and
32 deletions
+103
-32
src/LibVLCpp/VLCInstance.cpp
src/LibVLCpp/VLCInstance.cpp
+2
-1
src/Workflow/ClipWorkflow.cpp
src/Workflow/ClipWorkflow.cpp
+15
-13
src/Workflow/ClipWorkflow.h
src/Workflow/ClipWorkflow.h
+7
-1
src/Workflow/TrackWorkflow.cpp
src/Workflow/TrackWorkflow.cpp
+12
-7
src/Workflow/TrackWorkflow.h
src/Workflow/TrackWorkflow.h
+1
-7
src/gui/AbstractGraphicsMediaItem.cpp
src/gui/AbstractGraphicsMediaItem.cpp
+1
-1
src/gui/RenderPreviewWidget.cpp
src/gui/RenderPreviewWidget.cpp
+0
-1
src/tools/Pool.hpp
src/tools/Pool.hpp
+63
-0
vlmc.pro
vlmc.pro
+2
-1
No files found.
src/LibVLCpp/VLCInstance.cpp
View file @
7943189e
...
...
@@ -32,10 +32,11 @@ Instance::Instance()
{
char
const
*
argv
[]
=
{
//
"-vvvvv",
//
"-vvvvv",
"--no-skip-frames"
,
//"--no-audio",
//"--plugin-path", VLC_TREE "/modules",
"--disable-screensaver"
,
"--ignore-config"
,
//Don't use VLC's config files
};
int
argc
=
sizeof
(
argv
)
/
sizeof
(
*
argv
);
...
...
src/Workflow/ClipWorkflow.cpp
View file @
7943189e
...
...
@@ -24,6 +24,7 @@
#include "vlmc.h"
#include "ClipWorkflow.h"
#include "Pool.hpp"
int
g_debugId
=
0
;
...
...
@@ -114,34 +115,34 @@ void ClipWorkflow::setVmem()
{
char
buffer
[
32
];
m_
clip
->
getParent
()
->
addVolatileParam
(
":no-audio"
,
":
audio"
);
m_
clip
->
getParent
()
->
addVolatileParam
(
":vout=vmem"
,
":vout=''"
);
m_
clip
->
getParent
()
->
getVLC
Media
()
->
setDataCtx
(
this
);
m_
clip
->
getParent
()
->
getVLC
Media
()
->
setLockCallback
(
reinterpret_cast
<
LibVLCpp
::
Media
::
lockCallback
>
(
&
ClipWorkflow
::
lock
)
);
m_
clip
->
getParent
()
->
getVLC
Media
()
->
setUnlockCallback
(
reinterpret_cast
<
LibVLCpp
::
Media
::
unlockCallback
>
(
&
ClipWorkflow
::
unlock
)
);
m_
clip
->
getParent
()
->
addConstantParam
(
":vmem-chroma=RV24"
);
m_
vlcMedia
->
addOption
(
":no-
audio"
);
m_
vlcMedia
->
addOption
(
":vout=vmem"
);
m_
vlc
Media
->
setDataCtx
(
this
);
m_
vlc
Media
->
setLockCallback
(
reinterpret_cast
<
LibVLCpp
::
Media
::
lockCallback
>
(
&
ClipWorkflow
::
lock
)
);
m_
vlc
Media
->
setUnlockCallback
(
reinterpret_cast
<
LibVLCpp
::
Media
::
unlockCallback
>
(
&
ClipWorkflow
::
unlock
)
);
m_
vlcMedia
->
addOption
(
":vmem-chroma=RV24"
);
sprintf
(
buffer
,
":vmem-width=%i"
,
VIDEOWIDTH
);
m_
clip
->
getParent
()
->
addConstantParam
(
buffer
);
m_
vlcMedia
->
addOption
(
buffer
);
sprintf
(
buffer
,
":vmem-height=%i"
,
VIDEOHEIGHT
);
m_
clip
->
getParent
()
->
addConstantParam
(
buffer
);
m_
vlcMedia
->
addOption
(
buffer
);
sprintf
(
buffer
,
"vmem-pitch=%i"
,
VIDEOWIDTH
*
3
);
m_
clip
->
getParent
()
->
addConstantParam
(
buffer
);
m_
vlcMedia
->
addOption
(
buffer
);
}
void
ClipWorkflow
::
initialize
(
LibVLCpp
::
MediaPlayer
*
mediaPlayer
)
void
ClipWorkflow
::
initialize
()
{
setState
(
Initializing
);
m_vlcMedia
=
new
LibVLCpp
::
Media
(
m_clip
->
getParent
()
->
getFileInfo
()
->
absoluteFilePath
()
);
setVmem
();
m_mediaPlayer
=
mediaPlayer
;
m_mediaPlayer
->
setMedia
(
m_
clip
->
getParent
()
->
getVLC
Media
()
);
m_mediaPlayer
=
Pool
<
LibVLCpp
::
MediaPlayer
>::
getInstance
()
->
get
()
;
m_mediaPlayer
->
setMedia
(
m_
vlc
Media
);
connect
(
m_mediaPlayer
,
SIGNAL
(
playing
()
),
this
,
SLOT
(
setPositionAfterPlayback
()
),
Qt
::
DirectConnection
);
connect
(
m_mediaPlayer
,
SIGNAL
(
endReached
()
),
this
,
SLOT
(
clipEndReached
()
),
Qt
::
DirectConnection
);
m_mediaPlayer
->
play
();
//m_clip->getParent()->flushVolatileParameters();
}
void
ClipWorkflow
::
setPositionAfterPlayback
()
...
...
@@ -218,6 +219,7 @@ void ClipWorkflow::stop()
setState
(
Stopped
);
QMutexLocker
lock
(
m_requiredStateLock
);
m_requiredState
=
ClipWorkflow
::
None
;
delete
m_vlcMedia
;
}
else
qDebug
()
<<
"ClipWorkflow has already been stopped"
;
...
...
src/Workflow/ClipWorkflow.h
View file @
7943189e
...
...
@@ -64,7 +64,7 @@ class ClipWorkflow : public QObject
* of the rendering process advancement.
*/
unsigned
char
*
getOutput
();
void
initialize
(
LibVLCpp
::
MediaPlayer
*
mediaPlayer
);
void
initialize
();
/**
* Return true ONLY if the state is equal to Ready.
* If the state is Rendering, EndReached or anything else, this will
...
...
@@ -154,6 +154,12 @@ class ClipWorkflow : public QObject
private:
Clip
*
m_clip
;
/**
* \brief The VLC media used to render
*/
LibVLCpp
::
Media
*
m_vlcMedia
;
unsigned
char
*
m_buffer
;
//unsigned char* m_backBuffer;
/**
...
...
src/Workflow/TrackWorkflow.cpp
View file @
7943189e
...
...
@@ -30,7 +30,6 @@ TrackWorkflow::TrackWorkflow( unsigned int trackId ) :
m_length
(
0
),
m_forceRepositionning
(
false
)
{
m_mediaPlayer
=
new
LibVLCpp
::
MediaPlayer
();
m_forceRepositionningMutex
=
new
QMutex
;
m_clipsLock
=
new
QReadWriteLock
;
}
...
...
@@ -48,7 +47,6 @@ TrackWorkflow::~TrackWorkflow()
}
delete
m_clipsLock
;
delete
m_forceRepositionningMutex
;
delete
m_mediaPlayer
;
}
void
TrackWorkflow
::
addClip
(
Clip
*
clip
,
qint64
start
)
...
...
@@ -59,6 +57,13 @@ void TrackWorkflow::addClip( Clip* clip, qint64 start )
computeLength
();
}
void
TrackWorkflow
::
addClip
(
ClipWorkflow
*
cw
,
qint64
start
)
{
QWriteLocker
lock
(
m_clipsLock
);
m_clips
.
insert
(
start
,
cw
);
computeLength
();
}
//Must be called from a thread safe method (m_clipsLock locked)
void
TrackWorkflow
::
computeLength
()
{
...
...
@@ -112,7 +117,7 @@ unsigned char* TrackWorkflow::renderClip( ClipWorkflow* cw, qint64 currentF
else
if
(
cw
->
getState
()
==
ClipWorkflow
::
Stopped
)
{
cw
->
getStateLock
()
->
unlock
();
cw
->
initialize
(
m_mediaPlayer
);
cw
->
initialize
(
);
cw
->
startRender
();
if
(
start
!=
currentFrame
)
//Clip was not started as its real begining
{
...
...
@@ -148,7 +153,7 @@ void TrackWorkflow::preloadClip( ClipWorkflow* cw )
if
(
cw
->
getState
()
==
ClipWorkflow
::
Stopped
)
{
cw
->
getStateLock
()
->
unlock
();
cw
->
initialize
(
m_mediaPlayer
);
cw
->
initialize
();
return
;
}
cw
->
getStateLock
()
->
unlock
();
...
...
@@ -190,7 +195,7 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
}
else
{
qDebug
()
<<
"Unexpected ClipWorkflow::State when stopping :"
<<
cw
->
getState
();
//
qDebug() << "Unexpected ClipWorkflow::State when stopping :" << cw->getState();
cw
->
getStateLock
()
->
unlock
();
}
}
...
...
@@ -308,8 +313,8 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
ClipWorkflow
*
cw
=
it
.
value
();
Clip
*
clip
=
cw
->
getClip
();
m_clips
.
erase
(
it
);
stopClipWorkflow
(
cw
);
delete
cw
;
//
stopClipWorkflow( cw );
//
delete cw;
return
clip
;
}
++
it
;
...
...
src/Workflow/TrackWorkflow.h
View file @
7943189e
...
...
@@ -31,7 +31,6 @@
#include <QReadWriteLock>
#include "ClipWorkflow.h"
#include "VLCMediaPlayer.h"
//TODO: REMOVE THIS
#ifndef FPS
...
...
@@ -56,6 +55,7 @@ class TrackWorkflow : public QObject
void
moveClip
(
const
QUuid
&
id
,
qint64
startingFrame
);
Clip
*
removeClip
(
const
QUuid
&
id
);
void
addClip
(
Clip
*
,
qint64
start
);
void
addClip
(
ClipWorkflow
*
,
qint64
start
);
//FIXME: this won't be reliable as soon as we change the fps from the configuration
static
const
unsigned
int
nbFrameBeforePreload
=
60
;
...
...
@@ -73,12 +73,6 @@ class TrackWorkflow : public QObject
QMap
<
qint64
,
ClipWorkflow
*>
m_clips
;
/**
* This is the MediaPlayer that the clipworkflow
* will be using to process its render.
* It is never used internally.
*/
LibVLCpp
::
MediaPlayer
*
m_mediaPlayer
;
/**
* \brief The track length in frames.
*/
...
...
src/gui/AbstractGraphicsMediaItem.cpp
View file @
7943189e
...
...
@@ -23,7 +23,7 @@
#include "AbstractGraphicsMediaItem.h"
AbstractGraphicsMediaItem
::
AbstractGraphicsMediaItem
()
:
m_tracksView
(
NULL
),
oldTrackNumber
(
-
1
)
oldTrackNumber
(
-
1
),
m_tracksView
(
NULL
)
{
setCursor
(
Qt
::
OpenHandCursor
);
}
...
...
src/gui/RenderPreviewWidget.cpp
View file @
7943189e
...
...
@@ -86,7 +86,6 @@ void RenderPreviewWidget::unlock( void* datas )
{
RenderPreviewWidget
*
self
=
reinterpret_cast
<
RenderPreviewWidget
*>
(
datas
);
// qDebug() << "RenderPreviewWidget::unlock() : Frame rendered";
QWriteLocker
lock
(
self
->
m_framePlayedLock
);
self
->
m_framePlayed
=
true
;
}
...
...
src/tools/Pool.hpp
0 → 100644
View file @
7943189e
/*****************************************************************************
* Pool.hpp: Generic object pool
*****************************************************************************
* 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 POOL_HPP
#define POOL_HPP
#include <QMutex>
#include <QQueue>
#include "Singleton.hpp"
template
<
typename
T
>
class
Pool
:
public
Singleton
<
Pool
<
T
>
>
{
public:
T
*
get
()
{
if
(
m_pool
.
size
()
==
0
)
return
new
T
;
return
m_pool
.
dequeue
();
}
void
release
(
T
*
toRelease
)
{
m_pool
.
enqueue
(
toRelease
);
}
private:
Pool
()
{
m_mutex
=
new
QMutex
;
}
~
Pool
()
{
while
(
m_pool
.
size
()
!=
0
)
{
T
*
ptr
=
m_pool
.
dequeue
();
delete
ptr
;
}
}
QQueue
<
T
*>
m_pool
;
QMutex
*
m_mutex
;
friend
class
Singleton
<
Pool
<
T
>
>
;
};
#endif // POOL_HPP
vlmc.pro
View file @
7943189e
...
...
@@ -87,7 +87,8 @@ HEADERS += src/gui/MainWindow.h \
src
/
API
/
ModuleManager
.
h
\
src
/
API
/
vlmc_module_internal
.
h
\
src
/
WorkflowFileRenderer
.
h
\
src
/
vlmc
.
h
src
/
vlmc
.
h
\
src
/
tools
/
Pool
.
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