Sets the \a muted state of a media recorder.
*/
+/*!
+ \fn qreal QMediaRecorderControl::volume() const
+
+ Returns the linear audio gain of media recorder.
+*/
+
+/*!
+ \fn void QMediaRecorderControl::setVolume(qreal gain)
+
+ Sets the linear audio \a gain of a media recorder.
+*/
/*!
\fn void QMediaRecorderControl::stateChanged(QMediaRecorder::State state)
*/
/*!
+ \fn void QMediaRecorderControl::volume(qreal gain)
+
+ Signals that the audio \a gain value has changed.
+*/
+
+/*!
\fn void QMediaRecorderControl::actualLocationChanged(const QUrl &location)
Signals that the actual media \a location has changed.
virtual qint64 duration() const = 0;
virtual bool isMuted() const = 0;
+ virtual qreal volume() const = 0;
virtual void applySettings() = 0;
void statusChanged(QMediaRecorder::Status status);
void durationChanged(qint64 position);
void mutedChanged(bool muted);
+ void volumeChanged(qreal volume);
void actualLocationChanged(const QUrl &location);
void error(int error, const QString &errorString);
public Q_SLOTS:
virtual void setState(QMediaRecorder::State state) = 0;
virtual void setMuted(bool muted) = 0;
+ virtual void setVolume(qreal volume) = 0;
protected:
QMediaRecorderControl(QObject* parent = 0);
disconnect(d->control, SIGNAL(mutedChanged(bool)),
this, SIGNAL(mutedChanged(bool)));
+ disconnect(d->control, SIGNAL(volumeChanged(qreal)),
+ this, SIGNAL(volumeChanged(qreal)));
+
disconnect(d->control, SIGNAL(durationChanged(qint64)),
this, SIGNAL(durationChanged(qint64)));
connect(d->control, SIGNAL(mutedChanged(bool)),
this, SIGNAL(mutedChanged(bool)));
+ connect(d->control, SIGNAL(volumeChanged(qreal)),
+ this, SIGNAL(volumeChanged(qreal)));
+
connect(d->control, SIGNAL(durationChanged(qint64)),
this, SIGNAL(durationChanged(qint64)));
}
/*!
+ \property QMediaRecorder::volume
+
+ \brief the linear audio gain of media recorder.
+*/
+
+qreal QMediaRecorder::volume() const
+{
+ return d_func()->control ? d_func()->control->volume() : 1.0;
+}
+
+
+void QMediaRecorder::setVolume(qreal volume)
+{
+ Q_D(QMediaRecorder);
+
+ if (d->control)
+ d->control->setVolume(volume);
+}
+
+/*!
Returns a list of supported container formats.
*/
QStringList QMediaRecorder::supportedContainers() const
Q_PROPERTY(QUrl outputLocation READ outputLocation WRITE setOutputLocation)
Q_PROPERTY(QUrl actualLocation READ actualLocation NOTIFY actualLocationChanged)
Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
+ Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged)
Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged)
public:
qint64 duration() const;
bool isMuted() const;
+ qreal volume() const;
QStringList supportedContainers() const;
QString containerDescription(const QString &format) const;
void pause();
void stop();
void setMuted(bool muted);
+ void setVolume(qreal volume);
Q_SIGNALS:
void stateChanged(QMediaRecorder::State state);
void statusChanged(QMediaRecorder::Status status);
void durationChanged(qint64 duration);
void mutedChanged(bool muted);
+ void volumeChanged(qreal volume);
void actualLocationChanged(const QUrl &location);
void error(QMediaRecorder::Error error);
return false;
}
+qreal AudioMediaRecorderControl::volume() const
+{
+ //TODO: implement muting and audio gain
+ return 1.0;
+}
+
void AudioMediaRecorderControl::setState(QMediaRecorder::State state)
{
if (m_state == state)
{
}
+void AudioMediaRecorderControl::setVolume(qreal volume)
+{
+ if (!qFuzzyCompare(volume, qreal(1.0)))
+ qWarning() << "Media service doesn't support recorder audio gain.";
+}
+
void AudioMediaRecorderControl::updateStatus()
{
QMediaRecorder::Status newStatus = status();
qint64 duration() const;
bool isMuted() const;
+ qreal volume() const;
void applySettings() {}
public slots:
void setState(QMediaRecorder::State state);
void setMuted(bool);
+ void setVolume(qreal volume);
private slots:
void updateStatus();
return m_session->isMuted();
}
+qreal CameraBinRecorder::volume() const
+{
+ return 1.0;
+}
+
void CameraBinRecorder::setMuted(bool muted)
{
m_session->setMuted(muted);
}
+void CameraBinRecorder::setVolume(qreal volume)
+{
+ if (!qFuzzyCompare(volume, qreal(1.0)))
+ qWarning() << "Media service doesn't support recorder audio gain.";
+}
+
QT_END_NAMESPACE
+
qint64 duration() const;
bool isMuted() const;
+ qreal volume() const;
void applySettings();
GstEncodingContainerProfile *videoProfile();
public slots:
void setState(QMediaRecorder::State state);
void setMuted(bool);
+ void setVolume(qreal volume);
private slots:
void updateStatus();
m_audioPreview(0),
m_audioVolume(0),
m_muted(false),
+ m_volume(1.0),
m_videoSrc(0),
m_videoTee(0),
m_videoPreviewQueue(0),
return 0;
}
- g_object_set(G_OBJECT(m_audioVolume), "volume", (m_muted ? 0.0 : 1.0), NULL);
+ g_object_set(G_OBJECT(m_audioVolume), "mute", m_muted, NULL);
+ g_object_set(G_OBJECT(m_audioVolume), "volume", m_volume, NULL);
// add ghostpads
GstPad *pad = gst_element_get_static_pad(audioConvert, "sink");
void QGstreamerCaptureSession::setMuted(bool muted)
{
- if (m_muted != muted) {
+ if (bool(m_muted) != muted) {
m_muted = muted;
if (m_audioVolume)
- g_object_set(G_OBJECT(m_audioVolume), "volume", (m_muted ? 0.0 : 1.0), NULL);
+ g_object_set(G_OBJECT(m_audioVolume), "mute", m_muted, NULL);
+
emit mutedChanged(muted);
}
}
+void QGstreamerCaptureSession::setVolume(qreal volume)
+{
+ if (!qFuzzyCompare(volume, m_volume)) {
+ m_volume = volume;
+ if (m_audioVolume)
+ g_object_set(G_OBJECT(m_audioVolume), "volume", m_volume, NULL);
+
+ emit volumeChanged(volume);
+ }
+}
+
void QGstreamerCaptureSession::addProbe(QGstreamerAudioProbeControl* probe)
{
QMutexLocker locker(&m_audioProbeMutex);
qint64 duration() const;
bool isMuted() const { return m_muted; }
+ qreal volume() const { return m_volume; }
bool isReady() const;
void imageCaptured(int requestId, const QImage &img);
void imageSaved(int requestId, const QString &path);
void mutedChanged(bool);
+ void volumeChanged(qreal);
void readyChanged(bool);
void viewfinderChanged();
void setMetaData(const QMap<QByteArray, QVariant>&);
void setMuted(bool);
+ void setVolume(qreal volume);
private:
enum PipelineMode { EmptyPipeline, PreviewPipeline, RecordingPipeline, PreviewAndRecordingPipeline };
GstElement *m_audioPreviewQueue;
GstElement *m_audioPreview;
GstElement *m_audioVolume;
- bool m_muted;
+ gboolean m_muted;
+ double m_volume;
GstElement *m_videoSrc;
GstElement *m_videoTee;
connect(m_session, SIGNAL(error(int,QString)), SLOT(handleSessionError(int,QString)));
connect(m_session, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64)));
connect(m_session, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool)));
+ connect(m_session, SIGNAL(volumeChanged(qreal)), SIGNAL(volumeChanged(qreal)));
m_hasPreviewState = m_session->captureMode() != QGstreamerCaptureSession::Audio;
}
return m_session->isMuted();
}
+qreal QGstreamerRecorderControl::volume() const
+{
+ return m_session->volume();
+}
+
void QGstreamerRecorderControl::setMuted(bool muted)
{
m_session->setMuted(muted);
}
+void QGstreamerRecorderControl::setVolume(qreal volume)
+{
+ m_session->setVolume(volume);
+}
+
QDir QGstreamerRecorderControl::defaultDir() const
{
QStringList dirCandidates;
qint64 duration() const;
bool isMuted() const;
+ qreal volume() const;
void applySettings();
void pause();
void stop();
void setMuted(bool);
+ void setVolume(qreal volume);
private slots:
void updateStatus();
void testSink();
void testRecord();
void testMute();
+ void testVolume();
void testAudioDeviceControl();
void testAudioEncodeControl();
void testMediaFormatsControl();
QCOMPARE(mutedChanged.size(), 2);
}
+void tst_QMediaRecorder::testVolume()
+{
+ QSignalSpy volumeChanged(capture, SIGNAL(volumeChanged(qreal)));
+ QCOMPARE(capture->volume(), 1.0);
+ capture->setVolume(2.0);
+
+ QCOMPARE(volumeChanged.size(), 1);
+ QCOMPARE(volumeChanged[0][0].toReal(), 2.0);
+ QCOMPARE(capture->volume(), 2.0);
+
+ capture->setVolume(1.0);
+
+ QCOMPARE(volumeChanged.size(), 2);
+ QCOMPARE(volumeChanged[1][0].toReal(), 1.0);
+ QCOMPARE(capture->volume(), 1.0);
+
+ capture->setVolume(1.0);
+ QCOMPARE(volumeChanged.size(), 2);
+}
+
void tst_QMediaRecorder::testAudioDeviceControl()
{
QSignalSpy readSignal(audio,SIGNAL(activeEndpointChanged(QString)));
m_status(QMediaRecorder::LoadedStatus),
m_position(0),
m_muted(false),
+ m_volume(1.0),
m_settingAppliedCount(0)
{
}
return m_muted;
}
+ qreal volume() const
+ {
+ return m_volume;
+ }
+
void applySettings()
{
m_settingAppliedCount++;
emit mutedChanged(m_muted = muted);
}
+ void setVolume(qreal volume)
+ {
+ if (!qFuzzyCompare(m_volume, volume))
+ emit volumeChanged(m_volume = volume);
+ }
+
public:
QUrl m_sink;
QMediaRecorder::State m_state;
QMediaRecorder::Status m_status;
qint64 m_position;
bool m_muted;
+ qreal m_volume;
int m_settingAppliedCount;
};