summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTuomas Viitanen <tuomas.viitanen@nokia.com>2011-08-31 11:04:52 +0300
committerTuomas Viitanen <tuomas.viitanen@nokia.com>2011-08-31 11:04:52 +0300
commit8f9f4e92bd98be2edb49d447a32ce17992d8bffb (patch)
tree0db65cea6e46cb42e64382741542386f721acf35
parent625cce87e28fc7b5ec8785824affb3129fd3607b (diff)
SymbianCameraBE: Support for platform specific file naming
Save the image/video files by default in a same way as the native camera application does. Prefer mass memory in case that is available. Otherwise use c:/Data/ folder. In case of relative name use following bases: * /Images/Camera/ * /Videos/Camera/ Task-number: QTMOBILITY-1720 Reviewed-by: Derick Hawcroft Change-Id: I5475650d0e914b259c2765254253765dcfed6df6
-rw-r--r--plugins/multimedia/symbian/ecam/camera_s60.pri6
-rw-r--r--plugins/multimedia/symbian/ecam/s60filenamegenerator.cpp247
-rw-r--r--plugins/multimedia/symbian/ecam/s60filenamegenerator.h87
-rw-r--r--plugins/multimedia/symbian/ecam/s60imagecapturesession.cpp78
-rw-r--r--plugins/multimedia/symbian/ecam/s60videocapturesession.cpp108
-rw-r--r--plugins/multimedia/symbian/ecam/s60videocapturesession.h2
6 files changed, 408 insertions, 120 deletions
diff --git a/plugins/multimedia/symbian/ecam/camera_s60.pri b/plugins/multimedia/symbian/ecam/camera_s60.pri
index 3d6ae4e0a6..023a2036e6 100644
--- a/plugins/multimedia/symbian/ecam/camera_s60.pri
+++ b/plugins/multimedia/symbian/ecam/camera_s60.pri
@@ -133,7 +133,8 @@ HEADERS += $$PWD/s60cameraconstants.h \
$$PWD/s60cameraengineobserver.h \
$$PWD/s60videorenderercontrol.h \
$$PWD/s60cameracapturedestinationcontrol.h \
- $$PWD/s60cameracapturebufferformatcontrol.h
+ $$PWD/s60cameracapturebufferformatcontrol.h \
+ $$PWD/s60filenamegenerator.h
SOURCES += $$PWD/s60cameralockscontrol.cpp \
$$PWD/s60camerafocuscontrol.cpp \
@@ -156,6 +157,7 @@ SOURCES += $$PWD/s60cameralockscontrol.cpp \
$$PWD/s60cameraviewfinderengine.cpp \
$$PWD/s60videorenderercontrol.cpp \
$$PWD/s60cameracapturedestinationcontrol.cpp \
- $$PWD/s60cameracapturebufferformatcontrol.cpp
+ $$PWD/s60cameracapturebufferformatcontrol.cpp \
+ $$PWD/s60filenamegenerator.cpp
# End of file
diff --git a/plugins/multimedia/symbian/ecam/s60filenamegenerator.cpp b/plugins/multimedia/symbian/ecam/s60filenamegenerator.cpp
new file mode 100644
index 0000000000..65997d4dbe
--- /dev/null
+++ b/plugins/multimedia/symbian/ecam/s60filenamegenerator.cpp
@@ -0,0 +1,247 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "s60filenamegenerator.h"
+
+/*
+ * This method generates a default image or video file name. On Symbian it may
+ * be e.g. one of the following:
+ * c:/Data/Images/Camera/201105/201105A0/16052011001.jpg
+ * e:/Images/Camera/201105/201105A0/16052011001.jpg
+ * e./Videos/Camera/201105/201105A0/16052011001.mp4
+ * The file name and path are returned in native format (i.e. using '\' separators).
+ */
+QString S60FileNameGenerator::defaultFileName(const FileNameType nameType, const QString postfix)
+{
+ QDir directory;
+ QString newFileName = detectDestinationDrive(directory);
+
+ if (nameType == ImageFileName)
+ newFileName.append(QLatin1String("Images/"));
+ else
+ newFileName.append(QLatin1String("Videos/"));
+
+ newFileName.append(QLatin1String("Camera"));
+ newFileName.append(QLatin1Char('/'));
+
+ QDate date = QDate::currentDate();
+ directory.setPath(newFileName);
+ int fileNameIndex = 0;
+ generateFolder(directory, date, fileNameIndex);
+ newFileName = directory.path();
+
+ // Detect file name
+ QString dateForFileName = date.toString(QLatin1String("ddMMyyyy"));
+
+ while (true) {
+ QString indexString = QString::number(fileNameIndex);
+ while (indexString.length() < 3)
+ indexString.prepend(QLatin1Char('0'));
+ if (directory.entryList().contains(dateForFileName + indexString + postfix)) {
+ // Check next file name
+ ++fileNameIndex;
+ continue;
+ } else {
+ // Proper name found
+ newFileName.append(QLatin1Char('/'));
+ newFileName.append(dateForFileName);
+ newFileName.append(indexString);
+ newFileName.append(postfix);
+ break;
+ }
+ }
+
+ return QDir::toNativeSeparators(newFileName);
+}
+
+/*
+ * Generates a image/video file name based on the given parameters:
+ * * Type (image or video)
+ * * Base (either absolute or relative file name of type QString)
+ * * File type
+ */
+QString S60FileNameGenerator::generateFileNameFromString(const FileNameType nameType,
+ const QString base,
+ const QString postfix)
+{
+ QString baseString(base);
+ return generateFileName(nameType, baseString, postfix);
+}
+
+/*
+ * Generates a image/video file name based on the given parameters:
+ * * Type (image or video)
+ * * Base (either absolute or relative file name of type QUrl)
+ * * File type
+ */
+QString S60FileNameGenerator::generateFileNameFromUrl(const FileNameType nameType,
+ const QUrl base,
+ const QString postfix)
+{
+
+ QString baseString(base.toLocalFile());
+ return generateFileName(nameType, baseString, postfix);
+}
+
+QString S60FileNameGenerator::generateFileName(const FileNameType nameType,
+ QString base,
+ const QString postfix)
+{
+
+ // To Qt format
+ base.replace(QLatin1Char('\\'), QLatin1Char('/'));
+
+ QString newFileName;
+ // Relative FileName
+ if (!base.contains(QLatin1Char(':'))) {
+ QDir directory;
+ newFileName = detectDestinationDrive(directory);
+
+ if (nameType == ImageFileName)
+ newFileName.append(QLatin1String("Images/"));
+ else
+ newFileName.append(QLatin1String("Videos/"));
+ newFileName.append(QLatin1String("Camera"));
+
+ if (base.at(0) != QLatin1Char('/'))
+ newFileName.append(QLatin1Char('/'));
+ newFileName.append(base);
+
+ // Make sure full path exists
+ QString path = newFileName.left(newFileName.lastIndexOf(QLatin1Char('/')));
+ directory.setPath(path);
+ if (!directory.exists())
+ directory.mkpath(path);
+ newFileName = QDir::toNativeSeparators(newFileName);
+
+ // Absolute FileName
+ } else {
+ // Make sure path exists
+ QString path = base.left(base.lastIndexOf(QLatin1Char('/')));
+ QDir directory(path);
+ if (!directory.exists())
+ directory.mkpath(path);
+ newFileName = QDir::toNativeSeparators(base);
+ }
+
+ // Confirm file name has proper postfix
+ if (!newFileName.contains(QRegExp(QLatin1String(".+\\..+$"))))
+ newFileName.append(postfix);
+
+ return newFileName;
+}
+
+/*
+ * Method to detect whether the device has mass memory available
+ * Returns the drive and base folder to be used in file name generation
+ * In practive it is either of the following:
+ * * c:\Data
+ * * e:\
+ */
+QString S60FileNameGenerator::detectDestinationDrive(const QDir currentDirectory)
+{
+ QFileInfoList driveList = currentDirectory.drives();
+ bool isMassMemoryAvailable = false;
+ foreach (QFileInfo info, driveList) {
+ if (info.path() == QLatin1String("E:/") && info.isWritable())
+ isMassMemoryAvailable = true;
+ }
+
+ if (isMassMemoryAvailable) {
+ return QLatin1String("e:/");
+ } else {
+ return QLatin1String("c:/Data/");
+ }
+}
+
+/*
+ * Method to generate Symbian specific date based folder structure where the
+ * captured image or video will be saved.
+ */
+void S60FileNameGenerator::generateFolder(QDir &currentDirectory,
+ QDate &date,
+ int &fileNameOffset)
+{
+ // Folder of format: YYYYMM
+ QString newFolder = date.toString(QLatin1String("yyyyMM"));
+ if (!currentDirectory.cd(newFolder)) {
+ if (!currentDirectory.mkpath(newFolder)) {
+ currentDirectory.mkpath(currentDirectory.path());
+ return;
+ }
+ if (!currentDirectory.cd(newFolder)) {
+ currentDirectory.mkpath(currentDirectory.path());
+ return;
+ }
+ }
+
+ // Now create subfolder of format: YYYYMM[A-Z][0-9]
+ fileNameOffset = 0;
+ char indexChar('A');
+ int indexInt = 0;
+ QString testFolder;
+ while (true) {
+ testFolder = currentDirectory.path() + QLatin1Char('/') + newFolder + indexChar + QString::number(indexInt);
+ if (currentDirectory.cd(testFolder)) {
+ // Check file count (max 100 files per folder)
+ if (currentDirectory.entryList().count() < 100) {
+ return;
+ } else {
+ // Folder full, check next
+ if (indexInt < 9) {
+ ++indexInt;
+ } else {
+ indexInt = 0;
+ indexChar += 1;
+ }
+ fileNameOffset += 100;
+ continue;
+ }
+ } else {
+ if (currentDirectory.mkpath(testFolder)) {
+ if (currentDirectory.cd(testFolder))
+ return;
+ }
+ }
+ }
+}
+
+// End of file
diff --git a/plugins/multimedia/symbian/ecam/s60filenamegenerator.h b/plugins/multimedia/symbian/ecam/s60filenamegenerator.h
new file mode 100644
index 0000000000..14d0f03e3f
--- /dev/null
+++ b/plugins/multimedia/symbian/ecam/s60filenamegenerator.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef S60FILENAMEGENERATOR_H
+#define S60FILENAMEGENERATOR_H
+
+#include <QtCore/QObject>
+#include <QtCore/QUrl>
+#include <QtCore/QDir>
+#include <QtCore/QDate>
+
+QT_USE_NAMESPACE
+
+/*
+ * Class to generate image and video file name.
+ */
+class S60FileNameGenerator : public QObject
+{
+ Q_OBJECT
+
+public: // Enums
+
+ enum FileNameType {
+ ImageFileName,
+ VideoFileName
+ };
+
+public: // API
+
+ static QString defaultFileName(const FileNameType nameType,
+ const QString postfix);
+ static QString generateFileNameFromString(const FileNameType nameType,
+ const QString base,
+ const QString postfix);
+ static QString generateFileNameFromUrl(const FileNameType nameType,
+ const QUrl base,
+ const QString postfix);
+
+private: // Internal
+
+ static QString generateFileName(const FileNameType nameType,
+ QString base,
+ QString postfix);
+ static QString detectDestinationDrive(const QDir currentDirectory);
+ static void generateFolder(QDir &currentDirectory, QDate &date, int &fileNameOffset);
+
+};
+
+#endif // S60FILENAMEGENERATOR_H
diff --git a/plugins/multimedia/symbian/ecam/s60imagecapturesession.cpp b/plugins/multimedia/symbian/ecam/s60imagecapturesession.cpp
index ea4705ca0f..f062d3a8b9 100644
--- a/plugins/multimedia/symbian/ecam/s60imagecapturesession.cpp
+++ b/plugins/multimedia/symbian/ecam/s60imagecapturesession.cpp
@@ -45,6 +45,7 @@
#include "s60imagecapturesession.h"
#include "s60videowidgetcontrol.h"
#include "s60cameraservice.h"
+#include "s60filenamegenerator.h"
#include "s60cameraconstants.h"
#include <fbs.h> // CFbsBitmap
@@ -637,7 +638,9 @@ int S60ImageCaptureSession::capture(const QString &fileName)
QImage *snapImage = new QImage(QLatin1String("C:/Data/testimage.jpg"));
emit imageExposed(m_currentImageId);
emit imageCaptured(m_currentImageId, *snapImage);
- emit imageSaved(m_currentImageId, m_stillCaptureFileName);
+ QString qtFileName(m_stillCaptureFileName);
+ qtFileName.replace(QChar('\\'), QChar('/'));
+ emit imageSaved(m_currentImageId, qtFileName);
#endif // Q_CC_NOKIAX86
return m_currentImageId;
@@ -656,59 +659,14 @@ void S60ImageCaptureSession::cancelCapture()
void S60ImageCaptureSession::processFileName(const QString &fileName)
{
- // Empty FileName - Use default file name and path (C:\Data\Images\image.jpg)
- if (fileName.isEmpty()) {
- // Make sure default directory exists
- QDir videoDir(QDir::rootPath());
- if (!videoDir.exists(KDefaultImagePath))
- videoDir.mkpath(KDefaultImagePath);
- QString defaultFile = KDefaultImagePath;
- defaultFile.append("\\");
- defaultFile.append(KDefaultImageFileName);
- m_stillCaptureFileName = defaultFile;
-
- } else { // Not empty
-
- QString fullFileName;
-
- // Relative FileName
- if (!fileName.contains(":")) {
- // Extract file name and path from the URL
- fullFileName = KDefaultImagePath;
- if (fileName.at(0) != '\\')
- fullFileName.append("\\");
- fullFileName.append(QDir::toNativeSeparators(QDir::cleanPath(fileName)));
-
- // Absolute FileName
- } else {
- // Extract file name and path from the given location
- fullFileName = QDir::toNativeSeparators(QDir::cleanPath(fileName));
- }
-
- QString fileNameOnly = fullFileName.right(fullFileName.length() - fullFileName.lastIndexOf("\\") - 1);
- QString directory = fullFileName.left(fullFileName.lastIndexOf("\\"));
- if (directory.lastIndexOf("\\") == (directory.length() - 1))
- directory = directory.left(directory.length() - 1);
-
- // URL is Absolute path, not including file name
- if (!fileNameOnly.contains(".")) {
- if (fileNameOnly != "") {
- directory.append("\\");
- directory.append(fileNameOnly);
- }
- fileNameOnly = KDefaultImageFileName;
- }
-
- // Make sure absolute directory exists
- QDir imageDir(QDir::rootPath());
- if (!imageDir.exists(directory))
- imageDir.mkpath(directory);
-
- QString resolvedFileName = directory;
- resolvedFileName.append("\\");
- resolvedFileName.append(fileNameOnly);
- m_stillCaptureFileName = resolvedFileName;
- }
+ // Empty FileName - Use default file name
+ if (fileName.isEmpty())
+ m_stillCaptureFileName = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::ImageFileName,
+ QLatin1String(".jpg"));
+ else // Not empty
+ m_stillCaptureFileName = S60FileNameGenerator::generateFileNameFromString(S60FileNameGenerator::ImageFileName,
+ fileName,
+ QLatin1String(".jpg"));
}
void S60ImageCaptureSession::MceoFocusComplete()
@@ -850,8 +808,8 @@ TFileName S60ImageCaptureSession::convertImagePath()
// Convert to Symbian path
TPtrC16 attachmentPath(KNullDesC);
- // Path is already included in filename
- attachmentPath.Set(reinterpret_cast<const TUint16*>(QDir::toNativeSeparators(m_stillCaptureFileName).utf16()));
+ // Path is already included in filename and native separators are being used
+ attachmentPath.Set(reinterpret_cast<const TUint16*>(m_stillCaptureFileName.utf16()));
path.Append(attachmentPath);
return path;
@@ -952,7 +910,9 @@ void S60ImageCaptureSession::saveImageL(TDesC8 *aData, TFileName &aPath)
m_fileSystemAccess = fileSystemAccess;
#endif // ECAM_PREVIEW_API
- emit imageSaved(m_currentImageId, m_stillCaptureFileName);
+ QString qtFileName(m_stillCaptureFileName);
+ qtFileName.replace(QChar('\\'), QChar('/'));
+ emit imageSaved(m_currentImageId, qtFileName);
// Inform that we can continue taking more pictures
emit readyForCaptureChanged(true);
@@ -1930,7 +1890,9 @@ void S60ImageCaptureSession::handleImageEncoded(int error)
setError(error, tr("Saving captured image to file failed."));
return;
} else {
- QT_TRYCATCH_LEAVING( emit imageSaved(m_currentImageId, m_stillCaptureFileName) );
+ QString qtFileName(m_stillCaptureFileName);
+ qtFileName.replace(QChar('\\'), QChar('/'));
+ QT_TRYCATCH_LEAVING( emit imageSaved(m_currentImageId, qtFileName) );
}
if (m_imageEncoder) {
diff --git a/plugins/multimedia/symbian/ecam/s60videocapturesession.cpp b/plugins/multimedia/symbian/ecam/s60videocapturesession.cpp
index 7ed0fd2542..e725ab09e5 100644
--- a/plugins/multimedia/symbian/ecam/s60videocapturesession.cpp
+++ b/plugins/multimedia/symbian/ecam/s60videocapturesession.cpp
@@ -44,6 +44,7 @@
#include <QtCore/qtimer.h>
#include "s60videocapturesession.h"
+#include "s60filenamegenerator.h"
#include "s60cameraconstants.h"
#include <utf.h>
@@ -61,7 +62,7 @@ S60VideoCaptureSession::S60VideoCaptureSession(QObject *parent) :
m_error(KErrNone),
m_cameraStarted(false),
m_captureState(ENotInitialized), // Default state
- m_sink(QUrl()),
+ m_sink(QString()),
m_requestedSink(QUrl()),
m_captureSettingsSet(false),
m_container(QString()),
@@ -264,7 +265,19 @@ void S60VideoCaptureSession::doInitializeVideoRecorderL()
m_captureState = EInitializing;
emit stateChanged(m_captureState);
- // Open Dummy file to be able to query supported settings
+ // OpenFile using generated default file name
+ if (m_requestedContainer == QLatin1String("video/mp4"))
+ m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
+ QLatin1String(".mp4"));
+ else if (m_requestedContainer == QLatin1String("video/3gp"))
+ m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
+ QLatin1String(".3gp"));
+ else
+ m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
+ QLatin1String(".3gp2"));
+ QString symbianFileName = QDir::toNativeSeparators(m_sink);
+ TPtrC16 fileSink(reinterpret_cast<const TUint16*>(symbianFileName.utf16()));
+
int cameraHandle = m_cameraEngine->Camera() ? m_cameraEngine->Camera()->Handle() : 0;
TUid controllerUid;
@@ -273,7 +286,7 @@ void S60VideoCaptureSession::doInitializeVideoRecorderL()
if (m_videoRecorder) {
// File open completes in MvruoOpenComplete
- TRAPD(err, m_videoRecorder->OpenFileL(KDummyVideoFile, cameraHandle, controllerUid, formatUid));
+ TRAPD(err, m_videoRecorder->OpenFileL(fileSink, cameraHandle, controllerUid, formatUid));
setError(err, tr("Failed to initialize video recorder."));
m_container = m_requestedContainer;
} else {
@@ -584,65 +597,40 @@ bool S60VideoCaptureSession::setOutputLocation(const QUrl &sink)
return false;
}
- // Empty URL - Use default file name and path (C:\Data\Videos\video.mp4)
+ // Empty URL - Use default file name and path
if (sink.isEmpty()) {
-
- // Make sure default directory exists
- QDir videoDir(QDir::rootPath());
- if (!videoDir.exists(KDefaultVideoPath))
- videoDir.mkpath(KDefaultVideoPath);
- QString defaultFile = KDefaultVideoPath;
- defaultFile.append("\\");
- defaultFile.append(KDefaultVideoFileName);
- m_sink.setUrl(defaultFile);
+ if (m_captureState == EInitialized) {
+ // File is already opened with generated default name
+ } else {
+ // Video not yet initialized
+ if (m_requestedContainer == QLatin1String("video/mp4"))
+ m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
+ QLatin1String(".mp4"));
+ else if (m_requestedContainer == QLatin1String("video/3gp"))
+ m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
+ QLatin1String(".3gp"));
+ else
+ m_sink = S60FileNameGenerator::defaultFileName(S60FileNameGenerator::VideoFileName,
+ QLatin1String(".3gp2"));
+ }
} else { // Non-empty URL
- QString fullUrl = sink.scheme();
-
- // Relative URL
- if (sink.isRelative()) {
-
- // Extract file name and path from the URL
- fullUrl = KDefaultVideoPath;
- fullUrl.append("\\");
- fullUrl.append(QDir::toNativeSeparators(sink.path()));
+ QString postfix;
+ if (m_requestedContainer == QLatin1String("video/mp4"))
+ postfix = QLatin1String(".mp4");
+ else if (m_requestedContainer == QLatin1String("video/3gp"))
+ postfix = QLatin1String(".3gp");
+ else
+ postfix = QLatin1String(".3gp2");
- // Absolute URL
+ if (sink.scheme().contains(QLatin1String("file"), Qt::CaseInsensitive)) {
+ m_sink = S60FileNameGenerator::generateFileNameFromUrl(S60FileNameGenerator::VideoFileName,
+ sink,
+ postfix);
} else {
-
- // Extract file name and path from the URL
- if (fullUrl == "file") {
- fullUrl = QDir::toNativeSeparators(sink.path().right(sink.path().length() - 1));
- } else {
- fullUrl.append(":");
- fullUrl.append(QDir::toNativeSeparators(sink.path()));
- }
- }
-
- QString fileName = fullUrl.right(fullUrl.length() - fullUrl.lastIndexOf("\\") - 1);
- QString directory = fullUrl.left(fullUrl.lastIndexOf("\\"));
- if (directory.lastIndexOf("\\") == (directory.length() - 1))
- directory = directory.left(directory.length() - 1);
-
- // URL is Absolute path, not including file name
- if (!fileName.contains(".")) {
- if (fileName != "") {
- directory.append("\\");
- directory.append(fileName);
- }
- fileName = KDefaultVideoFileName;
+ setError(KErrNotSupported, tr("Network URL is not supported as video sink."));
}
-
- // Make sure absolute directory exists
- QDir videoDir(QDir::rootPath());
- if (!videoDir.exists(directory))
- videoDir.mkpath(directory);
-
- QString resolvedURL = directory;
- resolvedURL.append("\\");
- resolvedURL.append(fileName);
- m_sink = QUrl(resolvedURL);
}
// State is either Initialized, OpenComplete or Prepared, Close previously opened file
@@ -653,7 +641,7 @@ bool S60VideoCaptureSession::setOutputLocation(const QUrl &sink)
// Open file
- QString fileName = QDir::toNativeSeparators(m_sink.toString());
+ QString fileName(m_sink);
TPtrC16 fileSink(reinterpret_cast<const TUint16*>(fileName.utf16()));
int cameraHandle = m_cameraEngine->Camera() ? m_cameraEngine->Camera()->Handle() : 0;
@@ -669,9 +657,9 @@ bool S60VideoCaptureSession::setOutputLocation(const QUrl &sink)
m_container = m_requestedContainer;
m_captureState = EOpening;
emit stateChanged(m_captureState);
- }
- else
+ } else {
setError(KErrNotReady, tr("Unexpected camera error."));
+ }
m_uncommittedSettings = true;
return true;
@@ -679,7 +667,9 @@ bool S60VideoCaptureSession::setOutputLocation(const QUrl &sink)
QUrl S60VideoCaptureSession::outputLocation() const
{
- return m_sink;
+ QString qtLocation(m_sink);
+ qtLocation.replace(QLatin1Char('\\'), QLatin1Char('/'));
+ return QUrl::fromLocalFile(qtLocation);
}
qint64 S60VideoCaptureSession::position()
diff --git a/plugins/multimedia/symbian/ecam/s60videocapturesession.h b/plugins/multimedia/symbian/ecam/s60videocapturesession.h
index cc2514e6c7..e9a10bfba8 100644
--- a/plugins/multimedia/symbian/ecam/s60videocapturesession.h
+++ b/plugins/multimedia/symbian/ecam/s60videocapturesession.h
@@ -342,7 +342,7 @@ private: // Data
// Internal state of the video recorder
TVideoCaptureState m_captureState;
// Actual output file name/path
- QUrl m_sink;
+ QString m_sink;
// Requested output file name/path, this may be different from m_sink if
// asynchronous operation was ongoing in the CVideoRecorderUtility when new
// outputLocation was set.