#include "qtcamviewfinderrenderer.h"
#include <QPainter>
#include <QMatrix4x4>
+#include <cmath>
#if defined(QT4)
VideoPlayer::VideoPlayer(QDeclarativeItem *parent) :
return;
}
+ g_signal_connect (G_OBJECT (m_bin), "notify::volume", G_CALLBACK (on_volume_changed), this);
g_object_set (m_bin, "flags", 99, NULL);
GstElement *elem = gst_element_factory_make("pulsesink", "VideoPlayerPulseSink");
void VideoPlayer::updateRequested() {
update();
}
+
+quint32 VideoPlayer::volume() {
+ double vol = 1.0;
+ g_object_get (m_bin, "volume", &vol, NULL);
+
+ qint32 res = (int)round(vol * 100.0);
+
+ return res;
+}
+
+void VideoPlayer::setVolume(quint32 volume) {
+ if (VideoPlayer::volume() != volume) {
+ double vol = volume / 100.0;
+ g_object_set (m_bin, "volume", vol, NULL);
+ emit volumeChanged();
+ }
+}
+
+void VideoPlayer::on_volume_changed(GObject *object, GParamSpec *pspec, gpointer user_data) {
+ Q_UNUSED(object);
+ Q_UNUSED(pspec);
+
+ VideoPlayer *player = (VideoPlayer *) user_data;
+
+ QMetaObject::invokeMethod(player, "volumeChanged", Qt::QueuedConnection);
+}
Q_PROPERTY(qint64 position READ position WRITE setPosition NOTIFY positionChanged);
Q_PROPERTY(State state READ state NOTIFY stateChanged);
Q_ENUMS(State);
+ Q_PROPERTY(quint32 volume READ volume WRITE setVolume NOTIFY volumeChanged);
public:
State state() const;
+ quint32 volume();
+ void setVolume(quint32 volume);
+
signals:
void sourceChanged();
void cameraConfigChanged();
void positionChanged();
void error(const QString& message, int code, const QString& debug);
void stateChanged();
+ void volumeChanged();
protected:
void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
private:
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data);
+ static void on_volume_changed(GObject *object, GParamSpec *pspec, gpointer user_data);
bool setState(const State& state);
onTriggered: toolBar.show = false
}
+ DeviceKeys {
+ id: zoomKeys
+ active: Qt.application.active && pipelineManager.scaleAcquired
+ repeat: true
+
+ onVolumeUpPressed: {
+ timer.restart()
+ video.volume = Math.min(video.volume + 2, 100)
+ }
+
+ onVolumeDownPressed: {
+ timer.restart()
+ video.volume = Math.max(video.volume - 2, 0)
+ }
+ }
+
VideoPlayer {
+ Rectangle {
+ id: volumeControl
+ anchors.top: parent.top
+ anchors.left: parent.left
+ width: (parent.width * video.volume) / 100
+ color: "blue"
+ border.color: "black"
+ height: 25
+ opacity: timer.running ? 1.0 : 0.0
+
+ Behavior on opacity {
+ NumberAnimation { duration: 250 }
+ }
+
+ Timer {
+ id: timer
+ interval: 500
+ repeat: false
+ }
+ }
+
id: video
anchors.fill: parent
cameraConfig: camera.cameraConfig
*ok = updateSet(QList<ResourcePolicy::ResourceType>()
<< ResourcePolicy::VideoPlaybackType
<< ResourcePolicy::AudioPlaybackType,
- QList<ResourcePolicy::ResourceType>());
+ QList<ResourcePolicy::ResourceType>()
+ << ResourcePolicy::ScaleButtonType);
break;
default: