[vlc-devel] [PATCH 10/15] qml: expose video and audio description as separate properties in mlvideo
Pierre Lamot
pierre at videolabs.io
Tue Jul 21 15:03:09 CEST 2020
On 2020-07-21 14:18, Prince Gupta wrote:
> ---
> modules/gui/qt/medialibrary/mlvideo.cpp | 81 +++++++++++++++++++++----
> modules/gui/qt/medialibrary/mlvideo.hpp | 58 ++++++++++++++++--
> 2 files changed, 121 insertions(+), 18 deletions(-)
>
> diff --git a/modules/gui/qt/medialibrary/mlvideo.cpp
> b/modules/gui/qt/medialibrary/mlvideo.cpp
> index 075bc2adc0..8d0536cdde 100644
> --- a/modules/gui/qt/medialibrary/mlvideo.cpp
> +++ b/modules/gui/qt/medialibrary/mlvideo.cpp
> @@ -22,6 +22,58 @@
>
> #include <vlc_thumbnailer.h>
>
> +VideoDescription::VideoDescription(const QString &codec, const
> QString &language, const QString &fps, QObject *parent)
> + : QObject(parent)
> + , m_codec(codec)
> + , m_language(language)
> + , m_fps(fps)
> +{
> +}
> +
> +QString VideoDescription::getCodec() const
> +{
> + return m_codec;
> +}
> +
> +QString VideoDescription::getLanguage() const
> +{
> + return m_language;
> +}
> +
> +QString VideoDescription::getFps() const
> +{
> + return m_fps;
> +}
> +
> +AudioDescription::AudioDescription(const QString &codec, const
> QString &language, const QString &nbChannels, const QString
> &sampleRate, QObject *parent)
> + : QObject(parent)
> + , m_codec(codec)
> + , m_language(language)
> + , m_nbchannels(nbChannels)
> + , m_sampleRate(sampleRate)
> +{
> +}
> +
> +QString AudioDescription::getCodec() const
> +{
> + return m_codec;
> +}
> +
> +QString AudioDescription::getLanguage() const
> +{
> + return m_language;
> +}
> +
> +QString AudioDescription::getNbChannels() const
> +{
> + return m_nbchannels;
> +}
> +
> +QString AudioDescription::getSampleRate() const
> +{
> + return m_sampleRate;
> +}
> +
> MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data,
> QObject* parent)
> : QObject( parent )
> , m_ml( ml )
> @@ -60,20 +112,22 @@ 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
> );
>
> - audioDesc += qtr( "\n\tCodec: %1\n\tLanguage:
> %2\n\tChannels: %3\n\tSample Rate: %4" )
> - .arg( QString::fromUtf8( track.psz_codec ))
> - .arg( QString::fromUtf8( track.psz_language ) )
> - .arg( QString::number( track.a.i_nbChannels) )
> - .arg( QString::number( track.a.i_sampleRate ) );
> + m_audioDesc.push_back( new AudioDescription (
> QString::fromUtf8( track.psz_codec ) ,
> +
> QString::fromUtf8( track.psz_language ) ,
> +
> QString::number( track.a.i_nbChannels ) ,
> +
> QString::number( track.a.i_sampleRate ) ,
> + this )
> + );
> }
> 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 );
>
> - videoDesc += qtr( "\n\tCodec: %1\n\tLanguage: %2\n\tFPS:
> %3" )
> - .arg( QString::fromUtf8( track.psz_codec ) )
> - .arg( QString::fromUtf8( track.psz_language ) )
> - .arg( QString::number( track.v.i_fpsNum ) );
> + m_videoDesc.push_back( new VideoDescription(
> QString::fromUtf8( track.psz_codec ) ,
> +
> QString::fromUtf8( track.psz_language ) ,
> +
> QString::number( track.v.i_fpsNum ) ,
> + this )
> + );
> }
> }
>
> @@ -190,19 +244,20 @@ unsigned int MLVideo::getPlayCount() const
> {
> return m_playCount;
> }
> +
> QString MLVideo::getProgressTime() const
> {
> return MsToString(m_duration * m_progress);
> }
>
> -QString MLVideo::getVideoDesc() const
> +QObjectList MLVideo::getVideoDesc() const
> {
> - return videoDesc;
> + return m_videoDesc;
> }
>
> -QString MLVideo::getAudioDesc() const
> +QObjectList MLVideo::getAudioDesc() const
> {
> - return audioDesc;
> + return m_audioDesc;
> }
>
> MLVideo*MLVideo::clone(QObject* parent) const
> diff --git a/modules/gui/qt/medialibrary/mlvideo.hpp
> b/modules/gui/qt/medialibrary/mlvideo.hpp
> index c5f6bbb23b..e8780b17a3 100644
> --- a/modules/gui/qt/medialibrary/mlvideo.hpp
> +++ b/modules/gui/qt/medialibrary/mlvideo.hpp
> @@ -32,6 +32,53 @@
>
> #include <functional>
>
> +class VideoDescription : public QObject
> +{
> + Q_OBJECT
> +
> + Q_PROPERTY(QString codec READ getCodec CONSTANT)
> + Q_PROPERTY(QString language READ getLanguage CONSTANT)
> + Q_PROPERTY(QString fps READ getFps CONSTANT)
> +
> +public:
> + VideoDescription(const QString& codec, const QString& language,
> const QString& fps, QObject *parent = nullptr);
> +
> + QString getCodec() const;
> + QString getLanguage() const;
> + QString getFps() const;
> +
> +private:
> +
> + QString m_codec;
> + QString m_language;
> + QString m_fps;
> +};
> +
> +class AudioDescription : public QObject
> +{
> + Q_OBJECT
> +
> + Q_PROPERTY(QString codec READ getCodec CONSTANT)
> + Q_PROPERTY(QString language READ getLanguage CONSTANT)
> + Q_PROPERTY(QString nbchannels READ getNbChannels CONSTANT)
> + Q_PROPERTY(QString sampleRate READ getSampleRate CONSTANT)
> +
> +public:
> + AudioDescription(const QString& codec, const QString& language,
> const QString& nbChannels, const QString &sampleRate, QObject *parent
> = nullptr);
> +
> + QString getCodec() const;
> + QString getLanguage() const;
> + QString getNbChannels() const;
> + QString getSampleRate() const;
> +
> +private:
> +
> + QString m_codec;
> + QString m_language;
> + QString m_nbchannels;
> + QString m_sampleRate;
Maybe you should store numeral values as numbers
> +};
> +
> class MLVideo : public QObject
> {
> Q_OBJECT
> @@ -48,8 +95,8 @@ class MLVideo : public QObject
> Q_PROPERTY(QString resolution_name READ getResolutionName
> CONSTANT);
> Q_PROPERTY(QString channel READ getChannel CONSTANT);
> Q_PROPERTY(QString progressTime READ getProgressTime CONSTANT);
> - Q_PROPERTY(QString audioDesc READ getAudioDesc CONSTANT);
> - Q_PROPERTY(QString videoDesc READ getVideoDesc CONSTANT);
> + Q_PROPERTY(QObjectList audioDesc READ getAudioDesc CONSTANT);
> + Q_PROPERTY(QObjectList videoDesc READ getVideoDesc CONSTANT);
>
> public:
> MLVideo(vlc_medialibrary_t *ml, const vlc_ml_media_t *data,
> QObject *parent = nullptr);
> @@ -66,8 +113,8 @@ public:
> float getProgress() const;
> unsigned int getPlayCount() const;
> QString getProgressTime() const;
> - QString getAudioDesc() const;
> - QString getVideoDesc() const;
> + QObjectList getAudioDesc() const;
> + QObjectList getVideoDesc() const;
>
> MLVideo* clone(QObject* parent = nullptr) const;
>
> @@ -93,7 +140,8 @@ private:
> QString m_progressTime;
> unsigned int m_playCount;
> bool m_thumbnailGenerated;
> - QString audioDesc,videoDesc;
> + QObjectList m_audioDesc;
> + QObjectList 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-devel
mailing list