[vlc-commits] qt: add channel, position, audioDesc, videoDesc and resolution roles & properties
Abel Tesfaye
git at videolan.org
Tue Jul 30 17:56:59 CEST 2019
vlc | branch: master | Abel Tesfaye <Abeltesfaye45 at gmail.com> | Thu Jul 25 13:40:47 2019 +0300| [c5264d1aa92530dc28bd60f6a9340fb69de56506] | committer: Jean-Baptiste Kempf
qt: add channel, position, audioDesc, videoDesc and resolution roles & properties
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c5264d1aa92530dc28bd60f6a9340fb69de56506
---
modules/gui/qt/components/mediacenter/mlvideo.cpp | 66 +++++++++++++++++++++-
modules/gui/qt/components/mediacenter/mlvideo.hpp | 16 ++++++
.../gui/qt/components/mediacenter/mlvideomodel.cpp | 24 ++++++++
3 files changed, 105 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt/components/mediacenter/mlvideo.cpp b/modules/gui/qt/components/mediacenter/mlvideo.cpp
index 4305327be0..1d86ee5fab 100644
--- a/modules/gui/qt/components/mediacenter/mlvideo.cpp
+++ b/modules/gui/qt/components/mediacenter/mlvideo.cpp
@@ -30,6 +30,7 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data, QObject* pa
, m_thumbnail( QString::fromUtf8( data->thumbnails[VLC_ML_THUMBNAIL_SMALL].psz_mrl ) )
, m_playCount( data->i_playcount )
, m_thumbnailGenerated( data->thumbnails[VLC_ML_THUMBNAIL_SMALL].b_generated )
+ , m_position( 0.f )
, m_ml_event_handle( nullptr, [this](vlc_ml_event_callback_t* cb ) {
assert( m_ml != nullptr );
vlc_ml_event_unregister_callback( m_ml, cb );
@@ -64,8 +65,49 @@ MLVideo::MLVideo(vlc_medialibrary_t* ml, const vlc_ml_media_t* data, QObject* pa
{
m_progress = atoi( psz_progress );
free( psz_progress );
+
+ if( data->i_duration )
+ m_position = m_progress / (float)data->i_duration;
+ }
+
+ unsigned int numChannel = 0 , maxWidth = 0 , maxHeight = 0;
+ for( const vlc_ml_media_track_t& track: ml_range_iterate<vlc_ml_media_track_t>( data->p_tracks ) ) {
+ 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 ) );
+ }
+ 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_channel = "";
+ if ( numChannel >= 8 )
+ m_channel = "7.1";
+ else if ( numChannel >= 6 )
+ m_channel = "5.1";
+
+ m_resolution = "SD";
+ if ( maxWidth >= 7680 && maxHeight >= 4320 )
+ m_resolution = "8K";
+ else if ( maxWidth >= 3840 && maxHeight >= 2160 )
+ m_resolution = "4K";
+ else if ( maxWidth >= 1440 && maxHeight >= 1080 )
+ m_resolution = "HD";
+ else if ( maxWidth >= 720 && maxHeight >= 1280 )
+ m_resolution = "720p";
}
-}
MLVideo::MLVideo(const MLVideo& video, QObject* parent)
: QObject( parent )
@@ -134,6 +176,14 @@ QString MLVideo::getMRL() const
{
return m_mrl;
}
+QString MLVideo::getResolutionName() const
+{
+ return m_resolution;
+}
+QString MLVideo::getChannel() const
+{
+ return m_channel;
+}
unsigned int MLVideo::getProgress() const
{
@@ -144,6 +194,20 @@ unsigned int MLVideo::getPlayCount() const
{
return m_playCount;
}
+float MLVideo::getSavedPosition() const
+{
+ return m_position;
+}
+
+QString MLVideo::getVideoDesc() const
+{
+ return videoDesc;
+}
+
+QString MLVideo::getAudioDesc() const
+{
+ return audioDesc;
+}
MLVideo*MLVideo::clone(QObject* parent) const
{
diff --git a/modules/gui/qt/components/mediacenter/mlvideo.hpp b/modules/gui/qt/components/mediacenter/mlvideo.hpp
index f8f204878a..de4a94dc44 100644
--- a/modules/gui/qt/components/mediacenter/mlvideo.hpp
+++ b/modules/gui/qt/components/mediacenter/mlvideo.hpp
@@ -23,6 +23,8 @@
#include "config.h"
#endif
+#include "qt.hpp"
+
#include <QObject>
#include <vlc_media_library.h>
#include "mlhelper.hpp"
@@ -41,6 +43,11 @@ class MLVideo : public QObject
Q_PROPERTY(QString mrl READ getMRL CONSTANT);
Q_PROPERTY(unsigned int progress READ getProgress CONSTANT);
Q_PROPERTY(unsigned int playCount READ getPlayCount CONSTANT);
+ Q_PROPERTY(QString resolution_name READ getResolutionName CONSTANT);
+ Q_PROPERTY(QString channel READ getChannel CONSTANT);
+ Q_PROPERTY(float saved_position READ getSavedPosition CONSTANT);
+ Q_PROPERTY(QString audioDesc READ getAudioDesc CONSTANT);
+ Q_PROPERTY(QString videoDesc READ getVideoDesc CONSTANT);
public:
MLVideo(vlc_medialibrary_t *ml, const vlc_ml_media_t *data, QObject *parent = nullptr);
@@ -49,9 +56,14 @@ public:
QString getTitle() const;
QString getThumbnail();
QString getDuration() const;
+ QString getResolutionName() const;
+ QString getChannel() const;
QString getMRL() const;
unsigned int getProgress() const;
unsigned int getPlayCount() const;
+ float getSavedPosition() const;
+ QString getAudioDesc() const;
+ QString getVideoDesc() const;
MLVideo* clone(QObject* parent = nullptr) const;
@@ -71,9 +83,13 @@ private:
QString m_thumbnail;
QString m_duration;
QString m_mrl;
+ QString m_resolution;
+ QString m_channel;
unsigned int m_progress;
unsigned int m_playCount;
bool m_thumbnailGenerated;
+ float m_position;
+ QString audioDesc,videoDesc;
std::unique_ptr<vlc_ml_event_callback_t,
std::function<void(vlc_ml_event_callback_t*)>> m_ml_event_handle;
diff --git a/modules/gui/qt/components/mediacenter/mlvideomodel.cpp b/modules/gui/qt/components/mediacenter/mlvideomodel.cpp
index 021531bc58..01fe549d0f 100644
--- a/modules/gui/qt/components/mediacenter/mlvideomodel.cpp
+++ b/modules/gui/qt/components/mediacenter/mlvideomodel.cpp
@@ -27,6 +27,12 @@ enum Role {
VIDEO_DURATION,
VIDEO_PROGRESS,
VIDEO_PLAYCOUNT,
+ VIDEO_RESOLUTION,
+ VIDEO_CHANNEL,
+ VIDEO_POSITION,
+ VIDEO_MRL,
+ VIDEO_VIDEO_TRACK,
+ VIDEO_AUDIO_TRACK,
};
}
@@ -62,6 +68,18 @@ QVariant MLVideoModel::data(const QModelIndex& index, int role) const
return QVariant::fromValue( video->getProgress() );
case VIDEO_PLAYCOUNT:
return QVariant::fromValue( video->getPlayCount() );
+ case VIDEO_RESOLUTION:
+ return QVariant::fromValue( video->getResolutionName() );
+ case VIDEO_CHANNEL:
+ return QVariant::fromValue( video->getChannel() );
+ case VIDEO_POSITION:
+ return QVariant::fromValue( video->getSavedPosition() );
+ case VIDEO_MRL:
+ return QVariant::fromValue( video->getMRL() );
+ case VIDEO_VIDEO_TRACK:
+ return QVariant::fromValue( video->getVideoDesc() );
+ case VIDEO_AUDIO_TRACK:
+ return QVariant::fromValue( video->getAudioDesc() );
default:
return {};
}
@@ -76,6 +94,12 @@ QHash<int, QByteArray> MLVideoModel::roleNames() const
{ VIDEO_DURATION, "duration" },
{ VIDEO_PROGRESS, "progress" },
{ VIDEO_PLAYCOUNT, "playcount" },
+ { VIDEO_RESOLUTION, "resolution_name" },
+ { VIDEO_CHANNEL, "channel" },
+ { VIDEO_POSITION, "saved_position" },
+ { VIDEO_MRL, "mrl" },
+ { VIDEO_AUDIO_TRACK, "audioDesc" },
+ { VIDEO_VIDEO_TRACK, "videoDesc" },
};
}
More information about the vlc-commits
mailing list