Added QMediaRecorder::actualLocation property
To report the actual location file was written. Change-Id: Ibb56a720a258a1e5cedceaf0f9bcea73fb93bc96 Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
a26bf6c8b6
commit
ba37f73d44
@@ -111,7 +111,9 @@ QMediaRecorderControl::~QMediaRecorderControl()
|
||||
|
||||
The \a location can be relative or empty;
|
||||
in this case the service should use the system specific place and file naming scheme.
|
||||
After recording has stated, QMediaRecorderControl::outputLocation() should return the actual output location.
|
||||
|
||||
After recording has started, the backend should report the actual file location
|
||||
with actualLocationChanged() signal.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -184,6 +186,13 @@ QMediaRecorderControl::~QMediaRecorderControl()
|
||||
Signals that the \a muted state of a media recorder has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaRecorderControl::actualLocationChanged(const QUrl &location)
|
||||
|
||||
Signals that the actual media \a location has changed.
|
||||
This signal should be emitted at start of recording.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QMediaRecorderControl::error(int error, const QString &errorString)
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ Q_SIGNALS:
|
||||
void stateChanged(QMediaRecorder::State state);
|
||||
void durationChanged(qint64 position);
|
||||
void mutedChanged(bool muted);
|
||||
void actualLocationChanged(const QUrl &location);
|
||||
void error(int error, const QString &errorString);
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
@@ -145,6 +145,14 @@ void QMediaRecorderPrivate::_q_serviceDestroyed()
|
||||
metaDataControl = 0;
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_updateActualLocation(const QUrl &location)
|
||||
{
|
||||
if (actualLocation != location) {
|
||||
actualLocation = location;
|
||||
emit q_func()->actualLocationChanged(actualLocation);
|
||||
}
|
||||
}
|
||||
|
||||
void QMediaRecorderPrivate::_q_notify()
|
||||
{
|
||||
emit q_func()->durationChanged(q_func()->duration());
|
||||
@@ -257,6 +265,9 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
disconnect(d->control, SIGNAL(durationChanged(qint64)),
|
||||
this, SIGNAL(durationChanged(qint64)));
|
||||
|
||||
disconnect(d->control, SIGNAL(actualLocationChanged(QUrl)),
|
||||
this, SLOT(_q_updateActualLocation(QUrl)));
|
||||
|
||||
disconnect(d->control, SIGNAL(error(int,QString)),
|
||||
this, SLOT(_q_error(int,QString)));
|
||||
}
|
||||
@@ -338,6 +349,9 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
connect(d->control, SIGNAL(durationChanged(qint64)),
|
||||
this, SIGNAL(durationChanged(qint64)));
|
||||
|
||||
connect(d->control, SIGNAL(actualLocationChanged(QUrl)),
|
||||
this, SLOT(_q_updateActualLocation(QUrl)));
|
||||
|
||||
connect(d->control, SIGNAL(error(int,QString)),
|
||||
this, SLOT(_q_error(int,QString)));
|
||||
|
||||
@@ -371,6 +385,14 @@ bool QMediaRecorder::setMediaObject(QMediaObject *object)
|
||||
After recording has stated, QMediaRecorder::outputLocation() returns the actual output location.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\property QMediaRecorder::actualLocation
|
||||
\brief the actual location of the last media content.
|
||||
|
||||
The actual location is usually available after recording starts,
|
||||
and reset when new location is set or new recording starts.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns true if media recorder service ready to use.
|
||||
*/
|
||||
@@ -401,9 +423,15 @@ QUrl QMediaRecorder::outputLocation() const
|
||||
bool QMediaRecorder::setOutputLocation(const QUrl &location)
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
d->actualLocation.clear();
|
||||
return d->control ? d->control->setOutputLocation(location) : false;
|
||||
}
|
||||
|
||||
QUrl QMediaRecorder::actualLocation() const
|
||||
{
|
||||
return d_func()->actualLocation;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current media recorder state.
|
||||
|
||||
@@ -743,6 +771,8 @@ void QMediaRecorder::record()
|
||||
{
|
||||
Q_D(QMediaRecorder);
|
||||
|
||||
d->actualLocation.clear();
|
||||
|
||||
if (d->settingsChanged)
|
||||
d->_q_applySettings();
|
||||
|
||||
@@ -804,6 +834,13 @@ void QMediaRecorder::stop()
|
||||
Signals that the \a duration of the recorded media has changed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::actualLocationChanged(const QUrl &location)
|
||||
|
||||
Signals that the actual \a location of the recorded media has changed.
|
||||
This signal is usually emitted when recording starts.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMediaRecorder::error(QMediaRecorder::Error error)
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ class Q_MULTIMEDIA_EXPORT QMediaRecorder : public QObject, public QMediaBindable
|
||||
Q_ENUMS(Error)
|
||||
Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged)
|
||||
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(bool metaDataAvailable READ isMetaDataAvailable NOTIFY metaDataAvailableChanged)
|
||||
Q_PROPERTY(bool metaDataWritable READ isMetaDataWritable NOTIFY metaDataWritableChanged)
|
||||
@@ -105,6 +106,8 @@ public:
|
||||
QUrl outputLocation() const;
|
||||
bool setOutputLocation(const QUrl &location);
|
||||
|
||||
QUrl actualLocation() const;
|
||||
|
||||
State state() const;
|
||||
|
||||
Error error() const;
|
||||
@@ -161,6 +164,7 @@ Q_SIGNALS:
|
||||
void stateChanged(QMediaRecorder::State state);
|
||||
void durationChanged(qint64 duration);
|
||||
void mutedChanged(bool muted);
|
||||
void actualLocationChanged(const QUrl &location);
|
||||
|
||||
void error(QMediaRecorder::Error error);
|
||||
|
||||
@@ -180,6 +184,7 @@ private:
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_error(int, const QString &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_serviceDestroyed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_notify())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateActualLocation(const QUrl &))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_updateNotifyInterval(int))
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_applySettings())
|
||||
};
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
#include "qmediarecorder.h"
|
||||
#include "qmediaobject_p.h"
|
||||
#include <QtCore/qurl.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@@ -80,10 +81,12 @@ public:
|
||||
QMediaRecorder::State state;
|
||||
QMediaRecorder::Error error;
|
||||
QString errorString;
|
||||
QUrl actualLocation;
|
||||
|
||||
void _q_stateChanged(QMediaRecorder::State state);
|
||||
void _q_error(int error, const QString &errorString);
|
||||
void _q_serviceDestroyed();
|
||||
void _q_updateActualLocation(const QUrl &);
|
||||
void _q_notify();
|
||||
void _q_updateNotifyInterval(int ms);
|
||||
void _q_applySettings();
|
||||
|
||||
@@ -210,6 +210,7 @@ void tst_QMediaRecorder::testNullControls()
|
||||
|
||||
recorder.setOutputLocation(QUrl("file://test/save/file.mp4"));
|
||||
QCOMPARE(recorder.outputLocation(), QUrl());
|
||||
QCOMPARE(recorder.actualLocation(), QUrl());
|
||||
|
||||
QAudioEncoderSettings audio;
|
||||
audio.setCodec(id);
|
||||
@@ -285,6 +286,22 @@ void tst_QMediaRecorder::testSink()
|
||||
capture->setOutputLocation(QUrl("test.tmp"));
|
||||
QUrl s = capture->outputLocation();
|
||||
QCOMPARE(s.toString(), QString("test.tmp"));
|
||||
QCOMPARE(capture->actualLocation(), QUrl());
|
||||
|
||||
//the actual location is available after record
|
||||
capture->record();
|
||||
QCOMPARE(capture->actualLocation().toString(), QString("test.tmp"));
|
||||
capture->stop();
|
||||
QCOMPARE(capture->actualLocation().toString(), QString("test.tmp"));
|
||||
|
||||
//setOutputLocation resets the actual location
|
||||
capture->setOutputLocation(QUrl());
|
||||
QCOMPARE(capture->actualLocation(), QUrl());
|
||||
|
||||
capture->record();
|
||||
QCOMPARE(capture->actualLocation(), QUrl::fromLocalFile("default_name.mp4"));
|
||||
capture->stop();
|
||||
QCOMPARE(capture->actualLocation(), QUrl::fromLocalFile("default_name.mp4"));
|
||||
}
|
||||
|
||||
void tst_QMediaRecorder::testRecord()
|
||||
|
||||
@@ -100,6 +100,9 @@ public slots:
|
||||
m_position=1;
|
||||
emit stateChanged(m_state);
|
||||
emit durationChanged(m_position);
|
||||
|
||||
QUrl actualLocation = m_sink.isEmpty() ? QUrl::fromLocalFile("default_name.mp4") : m_sink;
|
||||
emit actualLocationChanged(actualLocation);
|
||||
}
|
||||
|
||||
void pause()
|
||||
|
||||
Reference in New Issue
Block a user