From 96aa2e9af703d50f9f1ef8b3139aa2c1cde233cc Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Tue, 7 Feb 2012 14:34:50 +1000 Subject: [PATCH] Updated declarative camera recorder with C++ API changes. Added key,value parameters to metadataChanged() signal; Added a separate actualLocation property to desribe the path of recorded file. It may be different from outputLocation when default location is used. Change-Id: I5a4b77833b6458a19ed7e1dcf7e53fc7400cdf21 Reviewed-by: Jonas Rabbe Reviewed-by: Michael Goddard --- .../multimedia/qdeclarativecamerarecorder.cpp | 47 ++++++++++++++++++---- .../multimedia/qdeclarativecamerarecorder_p.h | 11 +++-- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/imports/multimedia/qdeclarativecamerarecorder.cpp b/src/imports/multimedia/qdeclarativecamerarecorder.cpp index dc49ba2..f2bb8fb 100644 --- a/src/imports/multimedia/qdeclarativecamerarecorder.cpp +++ b/src/imports/multimedia/qdeclarativecamerarecorder.cpp @@ -64,6 +64,10 @@ QDeclarativeCameraRecorder::QDeclarativeCameraRecorder(QCamera *camera, QObject SLOT(updateRecorderError(QMediaRecorder::Error))); connect(m_recorder, SIGNAL(mutedChanged(bool)), SIGNAL(mutedChanged(bool))); connect(m_recorder, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); + connect(m_recorder, SIGNAL(actualLocationChanged(QUrl)), + SLOT(updateActualLocation(QUrl))); + connect(m_recorder, SIGNAL(metaDataChanged(QString,QVariant)), + SIGNAL(metaDataChanged(QString,QVariant))); } QDeclarativeCameraRecorder::~QDeclarativeCameraRecorder() @@ -242,14 +246,42 @@ void QDeclarativeCameraRecorder::setRecorderState(QDeclarativeCameraRecorder::Re } } +/*! + \qmlproperty string CameraRecorder::outputLocation + \property QDeclarativeCameraRecorder::outputLocation + + \brief the destination location of media content. + + The location can be relative or empty; + in this case the recorder uses the system specific place and file naming scheme. +*/ + QString QDeclarativeCameraRecorder::outputLocation() const { return m_recorder->outputLocation().toString(); } -void QDeclarativeCameraRecorder::setOutputLocation(const QUrl &location) +/*! + \qmlproperty string CameraRecorder::actualLocation + \property QDeclarativeCameraRecorder::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. +*/ + +QString QDeclarativeCameraRecorder::actualLocation() const { - m_recorder->setOutputLocation(location); + return m_recorder->actualLocation().toString(); +} + +void QDeclarativeCameraRecorder::setOutputLocation(const QString &location) +{ + if (outputLocation() != location) { + m_recorder->setOutputLocation(location); + emit outputLocationChanged(outputLocation()); + } } qint64 QDeclarativeCameraRecorder::duration() const @@ -277,12 +309,6 @@ void QDeclarativeCameraRecorder::updateRecorderState(QMediaRecorder::State state if (state == QMediaRecorder::PausedState) state = QMediaRecorder::StoppedState; - if (state == QMediaRecorder::StoppedState) { - QString location = outputLocation(); - if (!location.isEmpty()) - emit outputLocationChanged(location); - } - emit recorderStateChanged(RecorderState(state)); } @@ -292,6 +318,11 @@ void QDeclarativeCameraRecorder::updateRecorderError(QMediaRecorder::Error error emit error(errorCode); } +void QDeclarativeCameraRecorder::updateActualLocation(const QUrl &url) +{ + emit actualLocationChanged(url.toString()); +} + QT_END_NAMESPACE #include "moc_qdeclarativecamerarecorder_p.cpp" diff --git a/src/imports/multimedia/qdeclarativecamerarecorder_p.h b/src/imports/multimedia/qdeclarativecamerarecorder_p.h index c6315c2..c0599b0 100644 --- a/src/imports/multimedia/qdeclarativecamerarecorder_p.h +++ b/src/imports/multimedia/qdeclarativecamerarecorder_p.h @@ -84,6 +84,7 @@ class QDeclarativeCameraRecorder : public QObject Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) Q_PROPERTY(QString outputLocation READ outputLocation WRITE setOutputLocation NOTIFY outputLocationChanged) + Q_PROPERTY(QString actualLocation READ actualLocation NOTIFY actualLocationChanged) Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY error) @@ -101,6 +102,8 @@ public: QSize captureResolution(); QString outputLocation() const; + QString actualLocation() const; + qint64 duration() const; bool isMuted() const; @@ -118,7 +121,7 @@ public: int audioSampleRate() const; public Q_SLOTS: - void setOutputLocation(const QUrl &location); + void setOutputLocation(const QString &location); void record(); void stop(); @@ -143,12 +146,11 @@ Q_SIGNALS: void durationChanged(qint64 duration); void mutedChanged(bool muted); void outputLocationChanged(const QString &location); + void actualLocationChanged(const QString &location); void error(QMediaRecorder::Error errorCode); - void metaDataAvailableChanged(bool available); - void metaDataWritableChanged(bool writable); - void metaDataChanged(); + void metaDataChanged(const QString &key, const QVariant &value); void captureResolutionChanged(const QSize &); void audioCodecChanged(const QString &codec); @@ -164,6 +166,7 @@ Q_SIGNALS: private slots: void updateRecorderState(QMediaRecorder::State); void updateRecorderError(QMediaRecorder::Error); + void updateActualLocation(const QUrl&); private: friend class QDeclarativeCamera; -- 2.7.4