[vlc-commits] qt: medialib: convert description into Q_GADGET
Romain Vimont
git at videolan.org
Mon Jan 4 10:51:27 UTC 2021
vlc | branch: master | Romain Vimont <rom1v at videolabs.io> | Fri Dec 18 14:53:35 2020 +0100| [ea17ed0b84e2d457aec9de81668a0c4e3b55ec86] | committer: Pierre Lamot
qt: medialib: convert description into Q_GADGET
VideoDescription and AudioDescription were QObject.
To pave the way to remove the QObject inheritance from MLVideo, convert
them to Q_GADGET and return them by value.
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ea17ed0b84e2d457aec9de81668a0c4e3b55ec86
---
modules/gui/qt/medialibrary/mlvideo.cpp | 34 +++++++++++++++------------------
modules/gui/qt/medialibrary/mlvideo.hpp | 26 +++++++++++++++----------
2 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp b/modules/gui/qt/medialibrary/mlvideo.cpp
index cd87a96c11..acedfd8f9b 100644
--- a/modules/gui/qt/medialibrary/mlvideo.cpp
+++ b/modules/gui/qt/medialibrary/mlvideo.cpp
@@ -22,9 +22,8 @@
#include <vlc_thumbnailer.h>
-VideoDescription::VideoDescription(const QString &codec, const QString &language, const unsigned int fps, QObject *parent)
- : QObject(parent)
- , m_codec(codec)
+VideoDescription::VideoDescription(const QString &codec, const QString &language, const unsigned int fps)
+ : m_codec(codec)
, m_language(language)
, m_fps(fps)
{
@@ -45,9 +44,8 @@ unsigned int VideoDescription::getFps() const
return m_fps;
}
-AudioDescription::AudioDescription(const QString &codec, const QString &language, const unsigned int nbChannels, const unsigned int sampleRate, QObject *parent)
- : QObject(parent)
- , m_codec(codec)
+AudioDescription::AudioDescription(const QString &codec, const QString &language, const unsigned int nbChannels, const unsigned int sampleRate)
+ : m_codec(codec)
, m_language(language)
, m_nbchannels(nbChannels)
, m_sampleRate(sampleRate)
@@ -105,22 +103,20 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data, QObject* pa
if ( track.i_type == VLC_ML_TRACK_TYPE_AUDIO ) {
numChannel = std::max( numChannel , track.a.i_nbChannels );
- m_audioDesc.push_back( new AudioDescription ( QString::fromUtf8( track.psz_codec ) ,
- QString::fromUtf8( track.psz_language ) ,
- track.a.i_nbChannels ,
- track.a.i_sampleRate ,
- this )
- );
+ m_audioDesc.push_back( { QString::fromUtf8( track.psz_codec ) ,
+ QString::fromUtf8( track.psz_language ) ,
+ track.a.i_nbChannels ,
+ track.a.i_sampleRate }
+ );
}
else if ( track.i_type == VLC_ML_TRACK_TYPE_VIDEO ){
maxWidth = std::max( maxWidth, track.v.i_width );
maxHeight = std::max( maxHeight, track.v.i_height );
- m_videoDesc.push_back( new VideoDescription( QString::fromUtf8( track.psz_codec ) ,
- QString::fromUtf8( track.psz_language ) ,
- track.v.i_fpsNum,
- this )
- );
+ m_videoDesc.push_back( { QString::fromUtf8( track.psz_codec ) ,
+ QString::fromUtf8( track.psz_language ) ,
+ track.v.i_fpsNum }
+ );
}
}
@@ -228,12 +224,12 @@ QString MLVideo::getProgressTime() const
return MsToString(m_duration * m_progress);
}
-QObjectList MLVideo::getVideoDesc() const
+QList<VideoDescription> MLVideo::getVideoDesc() const
{
return m_videoDesc;
}
-QObjectList MLVideo::getAudioDesc() const
+QList<AudioDescription> MLVideo::getAudioDesc() const
{
return m_audioDesc;
}
diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp b/modules/gui/qt/medialibrary/mlvideo.hpp
index 50c0712d74..58d105c3d3 100644
--- a/modules/gui/qt/medialibrary/mlvideo.hpp
+++ b/modules/gui/qt/medialibrary/mlvideo.hpp
@@ -32,16 +32,17 @@
#include <functional>
-class VideoDescription : public QObject
+class VideoDescription
{
- Q_OBJECT
+ Q_GADGET
Q_PROPERTY(QString codec READ getCodec CONSTANT)
Q_PROPERTY(QString language READ getLanguage CONSTANT)
Q_PROPERTY(unsigned int fps READ getFps CONSTANT)
public:
- VideoDescription(const QString& codec, const QString& language, unsigned int fps, QObject *parent = nullptr);
+ VideoDescription() = default;
+ VideoDescription(const QString& codec, const QString& language, unsigned int fps);
QString getCodec() const;
QString getLanguage() const;
@@ -54,9 +55,11 @@ private:
unsigned int m_fps;
};
-class AudioDescription : public QObject
+Q_DECLARE_METATYPE(VideoDescription)
+
+class AudioDescription
{
- Q_OBJECT
+ Q_GADGET
Q_PROPERTY(QString codec READ getCodec CONSTANT)
Q_PROPERTY(QString language READ getLanguage CONSTANT)
@@ -64,7 +67,8 @@ class AudioDescription : public QObject
Q_PROPERTY(unsigned int sampleRate READ getSampleRate CONSTANT)
public:
- AudioDescription(const QString& codec, const QString& language, unsigned int nbChannels, unsigned int sampleRate, QObject *parent = nullptr);
+ AudioDescription() = default;
+ AudioDescription(const QString& codec, const QString& language, unsigned int nbChannels, unsigned int sampleRate);
QString getCodec() const;
QString getLanguage() const;
@@ -79,6 +83,8 @@ private:
unsigned int m_sampleRate;
};
+Q_DECLARE_METATYPE(AudioDescription)
+
class MLVideo : public QObject, public MLItem
{
Q_OBJECT
@@ -97,8 +103,8 @@ public:
float getProgress() const;
unsigned int getPlayCount() const;
QString getProgressTime() const;
- QObjectList getAudioDesc() const;
- QObjectList getVideoDesc() const;
+ QList<AudioDescription> getAudioDesc() const;
+ QList<VideoDescription> getVideoDesc() const;
private:
static void onMlEvent( void* data, const vlc_ml_event_t* event );
@@ -115,8 +121,8 @@ private:
QString m_progressTime;
unsigned int m_playCount;
vlc_ml_thumbnail_status_t m_thumbnailStatus;
- QObjectList m_audioDesc;
- QObjectList m_videoDesc;
+ QList<AudioDescription> m_audioDesc;
+ QList<VideoDescription> m_videoDesc;
std::unique_ptr<vlc_ml_event_callback_t,
std::function<void(vlc_ml_event_callback_t*)>> m_ml_event_handle;
More information about the vlc-commits
mailing list