From 5ddfcd433a000be3c32e7fc6ade4de9e0673de9e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 18 Oct 2015 14:13:48 +0300 Subject: [PATCH] Display stream size and codecs on the playback page --- remote/qml/components/StreamInfo.qml | 16 ++++++++++++ remote/qml/pages/PlaybackPage.qml | 21 +++++++++++++++ remote/source/streamcontrolitem.cpp | 38 ++++++++++++++++++++++++++++ remote/source/streamcontrolitem.h | 11 ++++++++ remote/source/xinemacontrol.cpp | 22 ++++++++++++++++ remote/source/xinemacontrol.h | 12 +++++++++ 6 files changed, 120 insertions(+) create mode 100644 remote/qml/components/StreamInfo.qml diff --git a/remote/qml/components/StreamInfo.qml b/remote/qml/components/StreamInfo.qml new file mode 100644 index 0000000..6ad4457 --- /dev/null +++ b/remote/qml/components/StreamInfo.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Label +{ + anchors + { + left: parent.left + right: parent.right + margins: Theme.horizontalPageMargin + } + + horizontalAlignment: Text.AlignHCenter + color: Theme.secondaryColor + font.pixelSize: Theme.fontSizeSmall +} diff --git a/remote/qml/pages/PlaybackPage.qml b/remote/qml/pages/PlaybackPage.qml index bf1d976..abbd0d8 100644 --- a/remote/qml/pages/PlaybackPage.qml +++ b/remote/qml/pages/PlaybackPage.qml @@ -30,6 +30,27 @@ Page wrapMode: Text.WordWrap } + Column + { + width: parent.width + spacing: Theme.paddingSmall + + StreamInfo + { + text: streamControl.videoSize.width+"×"+streamControl.videoSize.height+" @ "+streamControl.framerate.toFixed(2)+"fps" + } + + StreamInfo + { + text: streamControl.videoCodec + } + + StreamInfo + { + text: streamControl.audioCodec + } + } + Slider { id: slider diff --git a/remote/source/streamcontrolitem.cpp b/remote/source/streamcontrolitem.cpp index fb518bf..3bd94b8 100644 --- a/remote/source/streamcontrolitem.cpp +++ b/remote/source/streamcontrolitem.cpp @@ -19,6 +19,9 @@ void StreamControlItem::set_control(XinemaControlItem *c) connect(&xc, &XinemaControl::title_changed, this, &StreamControlItem::title_changed); connect(&xc, &XinemaControl::duration_changed, this, &StreamControlItem::duration_changed); connect(&xc, &XinemaControl::position_changed, this, &StreamControlItem::position_changed); + connect(&xc, &XinemaControl::size_changed, this, &StreamControlItem::size_changed); + connect(&xc, &XinemaControl::framerate_changed, this, &StreamControlItem::framerate_changed); + connect(&xc, &XinemaControl::codecs_changed, this, &StreamControlItem::codecs_changed); connect(&xc, &XinemaControl::channels_changed, this, &StreamControlItem::control_channels_changed); connect(&xc, &XinemaControl::current_audio_channel_changed, this, &StreamControlItem::current_audio_channel_changed); connect(&xc, &XinemaControl::current_spu_channel_changed, this, &StreamControlItem::current_spu_channel_changed); @@ -32,6 +35,9 @@ void StreamControlItem::set_control(XinemaControlItem *c) emit title_changed(); emit duration_changed(); emit position_changed(); + emit size_changed(); + emit framerate_changed(); + emit codecs_changed(); emit channels_changed(); emit current_audio_channel_changed(); emit current_spu_channel_changed(); @@ -90,6 +96,38 @@ float StreamControlItem::get_position() const return control->get_control().get_position(); } +QSize StreamControlItem::get_video_size() const +{ + if(!control) + return QSize(); + + return control->get_control().get_video_size(); +} + +float StreamControlItem::get_framerate() const +{ + if(!control) + return 0.0f; + + return control->get_control().get_framerate(); +} + +QString StreamControlItem::get_video_codec() const +{ + if(!control) + return QString(); + + return control->get_control().get_video_codec(); +} + +QString StreamControlItem::get_audio_codec() const +{ + if(!control) + return QString(); + + return control->get_control().get_audio_codec(); +} + QStringList StreamControlItem::get_audio_channels() const { if(!control) diff --git a/remote/source/streamcontrolitem.h b/remote/source/streamcontrolitem.h index 8bb2cce..be7bcc8 100644 --- a/remote/source/streamcontrolitem.h +++ b/remote/source/streamcontrolitem.h @@ -15,6 +15,10 @@ class StreamControlItem: public QQuickItem Q_PROPERTY(QString title READ get_title NOTIFY title_changed) Q_PROPERTY(float duration READ get_duration NOTIFY duration_changed) Q_PROPERTY(float position READ get_position WRITE set_position NOTIFY position_changed) + Q_PROPERTY(QSize videoSize READ get_video_size NOTIFY size_changed) + Q_PROPERTY(float framerate READ get_framerate NOTIFY framerate_changed) + Q_PROPERTY(QString videoCodec READ get_video_codec NOTIFY codecs_changed) + Q_PROPERTY(QString audioCodec READ get_audio_codec NOTIFY codecs_changed) Q_PROPERTY(QStringList audioChannels READ get_audio_channels NOTIFY channels_changed) Q_PROPERTY(QStringList spuChannels READ get_spu_channels NOTIFY channels_changed) Q_PROPERTY(int currentAudioChannel READ get_current_audio_channel WRITE select_audio_channel NOTIFY current_audio_channel_changed) @@ -45,6 +49,10 @@ public: float get_duration() const; void set_position(float); float get_position() const; + QSize get_video_size() const; + float get_framerate() const; + QString get_video_codec() const; + QString get_audio_codec() const; QStringList get_audio_channels() const; QStringList get_spu_channels() const; void select_audio_channel(int); @@ -58,6 +66,9 @@ signals: void title_changed(); void duration_changed(); void position_changed(); + void size_changed(); + void framerate_changed(); + void codecs_changed(); void channels_changed(); void current_audio_channel_changed(); void current_spu_channel_changed(); diff --git a/remote/source/xinemacontrol.cpp b/remote/source/xinemacontrol.cpp index eb2ec47..7a013df 100644 --- a/remote/source/xinemacontrol.cpp +++ b/remote/source/xinemacontrol.cpp @@ -4,6 +4,7 @@ XinemaControl::XinemaControl(): playback_state(STOPPED), duration(0.0f), position(0.0f), + framerate(0.0f), current_audio_channel(-1), current_spu_channel(-1) { @@ -147,6 +148,27 @@ void XinemaControl::process_reply(const QString &reply) position = args.toFloat(); emit position_changed(position); } + else if(keyword=="video_size") + { + space = args.indexOf(' '); + video_size = QSize(args.mid(0, space).toInt(), args.mid(space+1).toInt()); + emit size_changed(video_size); + } + else if(keyword=="framerate") + { + framerate = args.toFloat(); + emit framerate_changed(framerate); + } + else if(keyword=="video_codec") + { + video_codec = args; + emit codecs_changed(video_codec, audio_codec); + } + else if(keyword=="audio_codec") + { + audio_codec = args; + emit codecs_changed(video_codec, audio_codec); + } else if(keyword=="audio_count") resize_list(audio_channels, args.toInt()); else if(keyword=="audio") diff --git a/remote/source/xinemacontrol.h b/remote/source/xinemacontrol.h index 5732073..fb62bab 100644 --- a/remote/source/xinemacontrol.h +++ b/remote/source/xinemacontrol.h @@ -2,6 +2,7 @@ #define XINEMACONTROL_H_ #include +#include #include class XinemaControl: public QObject @@ -28,6 +29,10 @@ private: QString title; float duration; float position; + QSize video_size; + float framerate; + QString video_codec; + QString audio_codec; QStringList audio_channels; QStringList spu_channels; int current_audio_channel; @@ -46,6 +51,10 @@ public: const QString &get_title() const { return title; } float get_duration() const { return duration; } float get_position() const { return position; } + const QSize &get_video_size() const { return video_size; } + float get_framerate() const { return framerate; } + const QString &get_video_codec() const { return video_codec; } + const QString &get_audio_codec() const { return audio_codec; } void play(); void seek(float); @@ -69,6 +78,9 @@ signals: void title_changed(const QString &); void duration_changed(float); void position_changed(float); + void size_changed(const QSize &); + void framerate_changed(float); + void codecs_changed(const QString &, const QString &); void channels_changed(); void current_audio_channel_changed(int); void current_spu_channel_changed(int); -- 2.43.0