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
0ce15dbd
Commit
0ce15dbd
authored
Feb 24, 2014
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework snapshot & metadata updates.
Do not emit the signal from outside of the class Remove GUIMedia class
parent
b6eb37cc
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
70 additions
and
156 deletions
+70
-156
src/Backend/ISource.h
src/Backend/ISource.h
+1
-0
src/Backend/VLC/VLCSource.cpp
src/Backend/VLC/VLCSource.cpp
+9
-0
src/Backend/VLC/VLCSource.h
src/Backend/VLC/VLCSource.h
+1
-0
src/CMakeLists.txt
src/CMakeLists.txt
+0
-1
src/Gui/import/ImportController.cpp
src/Gui/import/ImportController.cpp
+0
-1
src/Gui/library/MediaCellView.cpp
src/Gui/library/MediaCellView.cpp
+6
-5
src/Gui/library/MediaCellView.h
src/Gui/library/MediaCellView.h
+1
-1
src/Gui/media/GuiMedia.cpp
src/Gui/media/GuiMedia.cpp
+0
-58
src/Gui/media/GuiMedia.h
src/Gui/media/GuiMedia.h
+0
-57
src/Library/Library.cpp
src/Library/Library.cpp
+0
-1
src/Media/Media.cpp
src/Media/Media.cpp
+39
-16
src/Media/Media.h
src/Media/Media.h
+12
-14
src/Metadata/MetaDataManager.cpp
src/Metadata/MetaDataManager.cpp
+1
-2
No files found.
src/Backend/ISource.h
View file @
0ce15dbd
...
...
@@ -50,6 +50,7 @@ namespace Backend
virtual
unsigned
int
nbVideoTracks
()
const
=
0
;
virtual
bool
hasAudio
()
const
=
0
;
virtual
unsigned
int
nbAudioTracks
()
const
=
0
;
virtual
const
uint8_t
*
snapshot
()
const
=
0
;
};
class
IMemorySource
...
...
src/Backend/VLC/VLCSource.cpp
View file @
0ce15dbd
...
...
@@ -168,3 +168,12 @@ VLCSource::nbAudioTracks() const
{
return
m_nbAudioTracks
;
}
const
uint8_t
*
VLCSource
::
snapshot
()
const
{
if
(
hasVideo
()
==
false
||
m_snapshot
==
NULL
)
return
NULL
;
return
m_snapshot
->
bits
();
}
src/Backend/VLC/VLCSource.h
View file @
0ce15dbd
...
...
@@ -52,6 +52,7 @@ public:
virtual
unsigned
int
nbVideoTracks
()
const
;
virtual
bool
hasAudio
()
const
;
virtual
unsigned
int
nbAudioTracks
()
const
;
const
uint8_t
*
snapshot
()
const
;
// Below this point are backend internal methods:
LibVLCpp
::
Media
*
media
();
...
...
src/CMakeLists.txt
View file @
0ce15dbd
...
...
@@ -151,7 +151,6 @@ ELSE(NOT WITH_GUI)
Gui/library/StackViewNavController.cpp
Gui/library/ViewController.h
Gui/media/ClipMetadataDisplayer.cpp
Gui/media/GuiMedia.cpp
Gui/preview/LCDTimecode.cpp
Gui/preview/PreviewRuler.cpp
Gui/preview/PreviewWidget.cpp
...
...
src/Gui/import/ImportController.cpp
View file @
0ce15dbd
...
...
@@ -159,7 +159,6 @@ ImportController::importMedia( const QString &filePath )
Media
*
media
=
m_temporaryMedias
->
addMedia
(
filePath
);
connect
(
media
,
SIGNAL
(
metaDataComputed
(
const
Media
*
)
),
this
,
SLOT
(
mediaLoaded
()
)
);
media
->
computeMetadata
();
if
(
media
==
NULL
)
{
vlmcCritical
()
<<
"An error occurred while loading media:"
<<
filePath
;
...
...
src/Gui/library/MediaCellView.cpp
View file @
0ce15dbd
...
...
@@ -71,8 +71,9 @@ MediaCellView::MediaCellView( Clip* clip, QWidget *parent ) :
}
connect
(
clip
->
getMedia
(),
SIGNAL
(
metaDataComputed
(
const
Media
*
)
),
this
,
SLOT
(
metadataUpdated
(
const
Media
*
)
)
);
connect
(
clip
->
getMedia
(),
SIGNAL
(
snapshotComputed
(
const
Media
*
)
),
this
,
SLOT
(
snapshotUpdated
(
const
Media
*
)
)
);
// Snapshot generation will generate a QPixmap, which has to be done on GUI thread
connect
(
clip
->
getMedia
(),
SIGNAL
(
snapshotComputed
()
),
this
,
SLOT
(
snapshotUpdated
()
),
Qt
::
QueuedConnection
);
setThumbnail
(
clip
->
getMedia
()
->
snapshot
()
);
setTitle
(
clip
->
getMedia
()
->
fileName
()
);
...
...
@@ -108,9 +109,9 @@ MediaCellView::metadataUpdated( const Media *media )
}
void
MediaCellView
::
snapshotUpdated
(
const
Media
*
media
)
MediaCellView
::
snapshotUpdated
()
{
setThumbnail
(
media
->
snapshot
()
);
setThumbnail
(
m
_clip
->
getM
edia
()
->
snapshot
()
);
m_ui
->
delLabel
->
setEnabled
(
true
);
}
...
...
@@ -219,7 +220,7 @@ MediaCellView::mouseMoveEvent( QMouseEvent* event )
mimeData
->
setData
(
"vlmc/uuid"
,
m_clip
->
fullId
().
toLatin1
()
);
QDrag
*
drag
=
new
QDrag
(
this
);
drag
->
setMimeData
(
mimeData
);
const
Media
*
parent
=
m_clip
->
getMedia
();
Media
*
parent
=
m_clip
->
getMedia
();
drag
->
setPixmap
(
parent
->
snapshot
().
scaled
(
100
,
100
,
Qt
::
KeepAspectRatio
)
);
drag
->
exec
(
Qt
::
CopyAction
|
Qt
::
MoveAction
,
Qt
::
CopyAction
);
}
...
...
src/Gui/library/MediaCellView.h
View file @
0ce15dbd
...
...
@@ -73,7 +73,7 @@ public slots:
void
arrowButtonClicked
(
QWidget
*
sender
,
QMouseEvent
*
event
);
private
slots
:
void
snapshotUpdated
(
const
Media
*
media
);
void
snapshotUpdated
();
void
metadataComputingStarted
(
const
Media
*
media
);
void
metadataUpdated
(
const
Media
*
media
);
void
nbClipUpdated
();
...
...
src/Gui/media/GuiMedia.cpp
deleted
100644 → 0
View file @
b6eb37cc
/*****************************************************************************
* GUIMedia.cpp: Represents the GUI part of a Media
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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.
*****************************************************************************/
#include "GuiMedia.h"
#include "Media.h"
QPixmap
*
GUIMedia
::
defaultSnapshot
=
NULL
;
GUIMedia
::
GUIMedia
()
{
}
void
GUIMedia
::
snapshotReady
(
const
QImage
*
snapshot
)
{
m_snapshot
=
QPixmap
::
fromImage
(
*
snapshot
);
if
(
m_snapshot
.
isNull
()
==
false
)
emit
snapshotComputed
(
qobject_cast
<
const
Media
*>
(
this
)
);
delete
snapshot
;
}
GUIMedia
::~
GUIMedia
()
{
}
const
QPixmap
&
GUIMedia
::
snapshot
()
const
{
if
(
hasSnapshot
()
)
return
m_snapshot
;
if
(
GUIMedia
::
defaultSnapshot
==
NULL
)
GUIMedia
::
defaultSnapshot
=
new
QPixmap
(
":/images/vlmc"
);
return
*
GUIMedia
::
defaultSnapshot
;
}
bool
GUIMedia
::
hasSnapshot
()
const
{
return
!
m_snapshot
.
isNull
();
}
src/Gui/media/GuiMedia.h
deleted
100644 → 0
View file @
b6eb37cc
/*****************************************************************************
* GUIMedia.h: Represents the GUI part of a Media
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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 GUIMEDIA_H
#define GUIMEDIA_H
#include <QObject>
#include <QPixmap>
class
QImage
;
class
QPixmap
;
class
Media
;
class
GUIMedia
:
public
QObject
{
Q_OBJECT
public:
~
GUIMedia
();
const
QPixmap
&
snapshot
()
const
;
bool
hasSnapshot
()
const
;
protected:
//A GUIMedia shouldn't be constructed by something else than a media
GUIMedia
();
static
QPixmap
*
defaultSnapshot
;
QPixmap
m_snapshot
;
public
slots
:
void
snapshotReady
(
const
QImage
*
snapshot
);
signals:
void
snapshotComputed
(
const
Media
*
);
};
#endif // GUIMEDIA_H
src/Library/Library.cpp
View file @
0ce15dbd
...
...
@@ -135,7 +135,6 @@ Library::addMedia( const QFileInfo &fileInfo )
connect
(
media
,
SIGNAL
(
metaDataComputed
(
const
Media
*
)
),
this
,
SLOT
(
mediaLoaded
(
const
Media
*
)
),
Qt
::
QueuedConnection
);
m_medias
[
fileInfo
.
absoluteFilePath
()]
=
media
;
media
->
computeMetadata
();
}
return
media
;
}
...
...
src/Media/Media.cpp
View file @
0ce15dbd
...
...
@@ -52,16 +52,20 @@ const QString Media::AudioExtensions = "*.a52 *.aac *.ac3 *.aiff *.amr *.aob *
"*.wma *.wv *.xa *.xm"
;
const
QString
Media
::
streamPrefix
=
"stream://"
;
Media
::
Media
(
const
QString
&
path
)
:
m_fileInfo
(
NULL
),
m_nbFrames
(
0
),
m_baseClip
(
NULL
),
m_metadataComputed
(
false
),
m_inWorkspace
(
false
)
QPixmap
*
Media
::
defaultSnapshot
=
NULL
;
Media
::
Media
(
const
QString
&
path
)
:
m_fileInfo
(
NULL
)
,
m_nbFrames
(
0
)
,
m_baseClip
(
NULL
)
,
m_metadataComputed
(
false
)
,
m_inWorkspace
(
false
)
,
m_snapshotImage
(
NULL
)
{
setFilePath
(
path
);
Backend
::
IBackend
*
backend
=
Backend
::
getBackend
();
m_source
=
backend
->
createSource
(
qPrintable
(
path
)
);
MetaDataManager
::
getInstance
()
->
computeMediaMetadata
(
this
);
}
Media
::~
Media
()
...
...
@@ -103,13 +107,6 @@ void Media::setFileType(Media::FileType type)
m_fileType
=
type
;
}
void
Media
::
emitMetaDataComputed
()
{
m_metadataComputed
=
true
;
emit
metaDataComputed
(
this
);
}
Media
::
InputType
Media
::
inputType
()
const
{
...
...
@@ -182,6 +179,19 @@ Media::isInWorkspace() const
return
m_inWorkspace
;
}
void
Media
::
onMetaDataComputed
()
{
emit
metaDataComputed
();
if
(
m_source
->
hasVideo
()
&&
m_source
->
snapshot
()
!=
NULL
)
{
Q_ASSERT
(
m_snapshotImage
==
NULL
);
m_snapshotImage
=
new
QImage
(
m_source
->
snapshot
(),
m_source
->
width
(),
m_source
->
height
(),
QImage
::
Format_RGB32
);
emit
snapshotAvailable
();
}
}
void
Media
::
setFilePath
(
const
QString
&
filePath
)
{
...
...
@@ -209,8 +219,21 @@ Media::setFilePath( const QString &filePath )
emit
workspaceStateChanged
(
m_inWorkspace
);
}
void
Media
::
computeMetadata
()
QPixmap
&
Media
::
snapshot
()
{
MetaDataManager
::
getInstance
()
->
computeMediaMetadata
(
this
);
if
(
m_snapshot
.
isNull
()
==
false
)
return
m_snapshot
;
if
(
m_snapshotImage
!=
NULL
)
{
m_snapshot
=
QPixmap
::
fromImage
(
*
m_snapshotImage
);
delete
m_snapshotImage
;
if
(
m_snapshot
.
isNull
()
==
false
)
return
m_snapshot
;
}
if
(
Media
::
defaultSnapshot
==
NULL
)
Media
::
defaultSnapshot
=
new
QPixmap
(
":/images/vlmc"
);
return
*
Media
::
defaultSnapshot
;
}
src/Media/Media.h
View file @
0ce15dbd
...
...
@@ -38,7 +38,8 @@
#include <QXmlStreamWriter>
#ifdef WITH_GUI
#include "media/GuiMedia.h"
#include <QPixmap>
#include <QImage>
#endif
namespace
Backend
...
...
@@ -50,11 +51,7 @@ class Clip;
/**
* Represents a basic container for media informations.
*/
#ifdef WITH_GUI
class
Media
:
public
GUIMedia
#else
class
Media
:
public
QObject
#endif
{
Q_OBJECT
...
...
@@ -103,8 +100,6 @@ public:
InputType
inputType
()
const
;
void
emitMetaDataComputed
();
Clip
*
baseClip
()
{
return
m_baseClip
;
}
const
Clip
*
baseClip
()
const
{
return
m_baseClip
;
}
void
setBaseClip
(
Clip
*
clip
);
...
...
@@ -115,12 +110,10 @@ public:
bool
isInWorkspace
()
const
;
/**
* \brief Just an helper to compute metadata.
*
* Actual computing is performed by MetadataManager
*/
void
computeMetadata
();
void
onMetaDataComputed
();
// This has to be called from the GUI thread.
QPixmap
&
snapshot
();
private:
void
computeFileType
();
...
...
@@ -138,9 +131,14 @@ protected:
bool
m_inWorkspace
;
QString
m_workspacePath
;
static
QPixmap
*
defaultSnapshot
;
QPixmap
m_snapshot
;
QImage
*
m_snapshotImage
;
signals:
void
metaDataComputed
(
const
Media
*
);
void
metaDataComputed
();
void
workspaceStateChanged
(
bool
);
void
snapshotAvailable
();
};
#endif // MEDIA_H__
src/Metadata/MetaDataManager.cpp
View file @
0ce15dbd
...
...
@@ -63,8 +63,7 @@ MetaDataManager::run()
Backend
::
ISource
*
targetSource
=
target
->
source
();
if
(
targetSource
->
preparse
()
==
false
)
emit
failedToCompute
(
target
);
//FIXME: this looks really ugly. And doesn't handle snapshot for now
else
target
->
emit
MetaDataComputed
();
target
->
on
MetaDataComputed
();
}
}
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