# HG changeset patch # User hgs # Date 1279147470 -10800 # Node ID 0f0b4c1d77445f6bcc2af234dffe0085099cb5b3 # Parent 3075d9b614e65448b968195bd587dde41944b86f 201019 diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/cxengine.pro --- a/camerauis/cameraxui/cxengine/cxengine.pro Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/cxengine.pro Thu Jul 15 01:44:30 2010 +0300 @@ -156,6 +156,8 @@ cxememorymonitorprivate.h \ cxediskmonitor.h \ cxediskmonitorprivate.h \ + cxesnapshotcontrol.h \ + cxesnapshotcontrolprivate.h \ sensor/xqsensor.h \ sensor/xqaccsensor.h \ sensor/xqdeviceorientation.h \ @@ -202,6 +204,8 @@ cxememorymonitorprivate.cpp \ cxediskmonitor.cpp \ cxediskmonitorprivate.cpp \ + cxesnapshotcontrol.cpp \ + cxesnapshotcontrolprivate.cpp \ sensor/xqsensor.cpp \ sensor/xqaccsensor.cpp \ sensor/xqdeviceorientation.cpp \ diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/data/autoFocus.wav Binary file camerauis/cameraxui/cxengine/data/autoFocus.wav has changed diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/data/capture.wav Binary file camerauis/cameraxui/cxengine/data/capture.wav has changed diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/data/videoStart.wav Binary file camerauis/cameraxui/cxengine/data/videoStart.wav has changed diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/data/videoStop.wav Binary file camerauis/cameraxui/cxengine/data/videoStop.wav has changed diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/api/cxeengine.h --- a/camerauis/cameraxui/cxengine/inc/api/cxeengine.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/api/cxeengine.h Thu Jul 15 01:44:30 2010 +0300 @@ -22,6 +22,7 @@ class CxeCameraDeviceControl; class CxeViewfinderControl; +class CxeSnapshotControl; class CxeStillCaptureControl; class CxeVideoCaptureControl; class CxeAutoFocusControl; @@ -59,6 +60,11 @@ virtual CxeViewfinderControl &viewfinderControl() = 0; /** + * Access the snapshot control. + */ + virtual CxeSnapshotControl &snapshotControl() = 0; + + /** * Access the still capture control. */ virtual CxeStillCaptureControl &stillCaptureControl() = 0; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/api/cxeerror.h --- a/camerauis/cameraxui/cxengine/inc/api/cxeerror.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/api/cxeerror.h Thu Jul 15 01:44:30 2010 +0300 @@ -64,7 +64,6 @@ //! any other general errors General = 11 }; - } Q_DECLARE_METATYPE(CxeError::Id) diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxediskmonitorprivate.h --- a/camerauis/cameraxui/cxengine/inc/cxediskmonitorprivate.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxediskmonitorprivate.h Thu Jul 15 01:44:30 2010 +0300 @@ -30,9 +30,6 @@ { Q_OBJECT - // Owner of this private implementation. - friend class CxeDiskMonitor; - private: explicit CxeDiskMonitorPrivate(CxeSettings &settings); ~CxeDiskMonitorPrivate(); @@ -60,6 +57,8 @@ #endif // Q_OS_SYMBIAN qint64 mTriggerLevelBytes; qint64 mLatestFreeBytes; + + friend class CxeDiskMonitor; }; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxeenginesymbian.h --- a/camerauis/cameraxui/cxengine/inc/cxeenginesymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxeenginesymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -24,6 +24,7 @@ class CxeCameraDevice; class CxeCameraDeviceControl; class CxeViewfinderControl; +class CxeSnapshotControl; class CxeStillCaptureControl; class CxeVideoCaptureControl; class CxeSettingsControlSymbian; @@ -50,6 +51,7 @@ CxeCameraDeviceControl &cameraDeviceControl(); CxeViewfinderControl &viewfinderControl(); + CxeSnapshotControl &snapshotControl(); CxeStillCaptureControl &stillCaptureControl(); CxeVideoCaptureControl &videoCaptureControl(); CxeAutoFocusControl &autoFocusControl(); @@ -62,6 +64,8 @@ void initMode(Cxe::CameraMode cameraMode); bool isEngineReady(); + void construct(); + signals: void reserveStarted(); @@ -69,7 +73,6 @@ virtual void createControls(); private slots: - void construct(); void doInit(); private: @@ -83,6 +86,7 @@ CxeCameraDeviceControl *mCameraDeviceControl; CxeCameraDevice *mCameraDevice; // not own CxeViewfinderControl *mViewfinderControl; + CxeSnapshotControl *mSnapshotControl; CxeStillCaptureControl *mStillCaptureControl; CxeVideoCaptureControl *mVideoCaptureControl; CxeSettingsControlSymbian *mSettingsControl; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxeexception.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/inc/cxeexception.h Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef CXEEXCEPTION_H +#define CXEEXCEPTION_H + +#include + +/*! +* Exception class for engine internal errors. +* Contains one integer which can be used to carry error code, +* in normal cases which is of type CxeError::Id. +*/ +class CxeException : public std::exception +{ +public: + /*! + * Constructor. + */ + explicit CxeException(int error) : mError(error) {}; + + /*! + * Destructor. + */ + virtual ~CxeException() throw() {}; + + /*! + * Get the error code causing this exception. + * @return The error code. + */ + int error() const { return mError; }; + + /*! + * Helper method to throw exception if given status code is an error. + * Everything but zero is considered error. + * @param status The status code to check. + */ + static void throwIfError(int status) { if (status) { throw new CxeException(status); } } + +private: + //! Error code for this exception. + int mError; +}; + +#endif // CXEEXCEPTION_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxememorymonitorprivate.h --- a/camerauis/cameraxui/cxengine/inc/cxememorymonitorprivate.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxememorymonitorprivate.h Thu Jul 15 01:44:30 2010 +0300 @@ -31,9 +31,6 @@ { Q_OBJECT - // Owner of this private implementation. - friend class CxeMemoryMonitor; - private: explicit CxeMemoryMonitorPrivate(CxeFeatureManager &features); ~CxeMemoryMonitorPrivate(); @@ -55,6 +52,8 @@ #ifdef Q_OS_SYMBIAN ROomMonitorSession mOomMonitor; #endif // Q_OS_SYMBIAN + + friend class CxeMemoryMonitor; }; #endif // CXEMEMORYMONITORPRIVATE_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxequalitypresets.h --- a/camerauis/cameraxui/cxengine/inc/cxequalitypresets.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxequalitypresets.h Thu Jul 15 01:44:30 2010 +0300 @@ -23,8 +23,8 @@ /**! * Interface Class for CxeQualityPresetsSymbian -* Queries supported image and video qualities from ICM and creates the related -* data and wraps up the quality settings for the client. +* Queries supported image and video qualities from ICM and creates the related +* data and wraps up the quality settings for the client. */ class CxeQualityPresets { @@ -32,7 +32,7 @@ virtual ~CxeQualityPresets() {}; virtual QList imageQualityPresets(Cxe::CameraIndex cameraId) = 0; virtual QList videoQualityPresets(Cxe::CameraIndex cameraId) = 0; - virtual qreal avgVideoBitRateScaler() = 0; + virtual int recordingTimeAvailable(const CxeVideoDetails& details, qint64 space) = 0; }; #endif // CXEQUALITYPRESETS_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxequalitypresetssymbian.h --- a/camerauis/cameraxui/cxengine/inc/cxequalitypresetssymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxequalitypresetssymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -37,9 +37,10 @@ ~CxeQualityPresetsSymbian(); QList imageQualityPresets(Cxe::CameraIndex cameraId); QList videoQualityPresets(Cxe::CameraIndex cameraId); - qreal avgVideoBitRateScaler(); + int recordingTimeAvailable(const CxeVideoDetails& details, qint64 space); private: + qreal avgVideoBitRateScaler(); Cxe::AspectRatio calculateAspectRatio(int width, int height) const; QString toString(const TUint8* aData); CxeVideoDetails createVideoPreset(TVideoQualitySet set); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxesnapshotcontrol.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/inc/cxesnapshotcontrol.h Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef CXESNAPSHOTCONTROL_H +#define CXESNAPSHOTCONTROL_H + +#include +#include "cxeerror.h" + +class CxeCameraDevice; +class CxeSnapshotControlPrivate; + +/*! +* Snapshot control class. +*/ +class CxeSnapshotControl : public QObject +{ + Q_OBJECT + +public: + + // State Machine + enum State { + //! Idle, snapshot not active. + Idle = 0x01, + //! Active, snapshot events provided after successful capture. + Active = 0x02 + }; + + + explicit CxeSnapshotControl(CxeCameraDevice &device); + virtual ~CxeSnapshotControl(); + +public: + State state() const; + QSize calculateSnapshotSize(const QSize& displaySize, const QSize& outputResolution) const; + void start(const QSize& size); + void stop(); + +signals: + void stateChanged(CxeSnapshotControl::State newState, CxeError::Id status); + void snapshotReady(CxeError::Id status, const QPixmap& snapshot); + +public slots: + void handleCameraEvent(int id, int error); + +private: + CxeSnapshotControlPrivate *d; + + Q_DISABLE_COPY(CxeSnapshotControl) + friend class CxeSnapshotControlPrivate; +}; + +Q_DECLARE_METATYPE(CxeSnapshotControl::State) + +#endif // CXESNAPSHOTCONTROL_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxesnapshotcontrolprivate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/inc/cxesnapshotcontrolprivate.h Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef CXESNAPSHOTCONTROLPRIVATE_H +#define CXESNAPSHOTCONTROLPRIVATE_H + + +#include +#include "cxeerror.h" +#include "cxestatemachine.h" + +class QPixmap; +class CxeSnapshotControl; +class CxeCameraDevice; + + +/*! +* Snapshot control private implementation. +*/ +class CxeSnapshotControlPrivate : public CxeStateMachine +{ +private: + CxeSnapshotControlPrivate(CxeSnapshotControl *parent, CxeCameraDevice &device); + virtual ~CxeSnapshotControlPrivate(); + +protected: // from CxeStateMachine + void handleStateChanged(int newStateId, CxeError::Id error); + +private: + CxeSnapshotControl::State state() const; + void initializeStates(); + QSize calculateSnapshotSize(const QSize &displaySize, const QSize &outputResolution) const; + void start(const QSize &size); + void stop(); + void handleCameraEvent(int id, int error); + QPixmap snapshot(); + +private: + CxeSnapshotControl *q; + CxeCameraDevice &mDevice; + + friend class CxeSnapshotControl; +}; + +#endif // CXESNAPSHOTCONTROLPRIVATE_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxestillcapturecontrolsymbian.h --- a/camerauis/cameraxui/cxengine/inc/cxestillcapturecontrolsymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxestillcapturecontrolsymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -38,6 +38,7 @@ class CxeImageDataQueue; class CxeImageDataQueueSymbian; class CxeViewfinderControl; +class CxeSnapshotControl; class CxeSensorEventHandler; class CxeCameraDeviceControl; class CxeAutoFocusControl; @@ -59,6 +60,7 @@ CxeStillCaptureControlSymbian(CxeCameraDevice &cameraDevice, CxeViewfinderControl &viewfinderControl, + CxeSnapshotControl &snapshotControl, CxeCameraDeviceControl &cameraDeviceControl, CxeFilenameGenerator &nameGenerator, CxeSensorEventHandler &sensorEventHandler, @@ -105,9 +107,11 @@ void prepareForRelease(); // ECam events - void handleCameraEvent( int eventUid, int error ); void handleImageData( MCameraBuffer *buffer, int error ); + // Snapshot event + void handleSnapshotReady(CxeError::Id status, const QPixmap& snapshot); + // settings call back void handleSettingValueChanged(const QString& settingId,QVariant newValue); @@ -128,9 +132,7 @@ CCamera::TFormat supportedStillFormat(Cxe::CameraIndex cameraIndex); int prepareStillSnapshot(); CxeError::Id getImageQualityDetails(CxeImageDetails &imageInfo); - TSize getSnapshotSize() const; void handleSnapshotEvent(CxeError::Id error); - QPixmap extractSnapshot(); void initializeStates(); void prepare(); void updateRemainingImagesCounter(); @@ -141,6 +143,7 @@ CxeImageDataQueueSymbian *mImageDataQueue; // own CxeCameraDevice &mCameraDevice; CxeViewfinderControl &mViewfinderControl; + CxeSnapshotControl &mSnapshotControl; CxeCameraDeviceControl &mCameraDeviceControl; CxeFilenameGenerator &mFilenameGenerator; //! @todo could be shared with video capture control? CxeSensorEventHandler &mSensorEventHandler; @@ -162,20 +165,6 @@ QList mECamSupportedImageResolutions; //current image quality details in use CxeImageDetails mCurrentImageDetails; - -private: // Helper class - - class CxeCameraBufferCleanup - { - public: - CxeCameraBufferCleanup(MCameraBuffer* buffer) : mBuffer(buffer) {} - ~CxeCameraBufferCleanup() { if (mBuffer) { mBuffer->Release(); } } - - private: - Q_DISABLE_COPY(CxeCameraBufferCleanup) - - MCameraBuffer* mBuffer; - }; }; #endif // CXESTILLCAPTURECONTROLSYMBIAN_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxevideocapturecontrolsymbian.h --- a/camerauis/cameraxui/cxengine/inc/cxevideocapturecontrolsymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxevideocapturecontrolsymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -38,6 +38,7 @@ class CxeQualityPresets; class CxeFilenameGenerator; class CxeViewfinderControl; +class CxeSnapshotControl; class CxeStillImageSymbian; class CxeSoundPlayerSymbian; class CxeCameraDeviceControl; @@ -55,6 +56,7 @@ CxeVideoCaptureControlSymbian(CxeCameraDevice &cameraDevice, CxeViewfinderControl &viewfinderControl, + CxeSnapshotControl &snapshotControl, CxeCameraDeviceControl &cameraDeviceControl, CxeFilenameGenerator &nameGenerator, CxeSettings &settings, @@ -75,9 +77,6 @@ QPixmap snapshot() const; QList supportedVideoQualities(); -public: // public member functions, not in client API - void handleSnapshotEvent(CxeError::Id error); - public: // functions from MVideoRecorderUtilityObserver void MvruoOpenComplete(TInt aError); void MvruoPrepareComplete(TInt aError); @@ -98,14 +97,14 @@ void deinit(); //! Notification that videocapture sound has been played void handleSoundPlayed(); + //! Snapshot has been received from adaptiation. + void handleSnapshotReady(CxeError::Id status, const QPixmap& snapshot); protected slots: // notifications when ECam reference is changed void prepareForCameraDelete(); void handleCameraAllocated(CxeError::Id error); void prepareForRelease(); - // ECam events - void handleCameraEvent(int eventUid, int error); // settings call back void handleSettingValueChanged(const QString& settingId,QVariant newValue); // scene mode change @@ -114,19 +113,18 @@ void handleDiskSpaceChanged(); private: // helper methods - CxeError::Id findVideoController(const TDesC8& aMimeType, const TDesC& aPreferredSupplier); void releaseResources(); void initializeStates(); - CxeError::Id getVideoQualityDetails(CxeVideoDetails &videoInfo); - int prepareVideoSnapshot(); + void getVideoQualityDetails(CxeVideoDetails &videoInfo); void initVideoRecorder(); void open(); void prepare(); - TSize getSnapshotSize() const; virtual void createVideoRecorder(); - void calculateRemainingTime(CxeVideoDetails videoDetails, int &time); - TFourCC audioType(const QString& str); + int calculateRemainingTime(const CxeVideoDetails& videoDetails); void updateRemainingRecordingTimeCounter(); + void generateFilename(); + void handlePrepareFailed(); + void handleComposeFailed(int error); protected: // protected data //! Video Recorder @@ -141,6 +139,7 @@ CxeCameraDevice &mCameraDevice; CxeCameraDeviceControl &mCameraDeviceControl; CxeViewfinderControl &mViewfinderControl; + CxeSnapshotControl &mSnapshotControl; CxeFilenameGenerator &mFilenameGenerator; CxeSettings &mSettings; CxeQualityPresets &mQualityPresets; @@ -150,8 +149,6 @@ //! Soundplayers, own CxeSoundPlayerSymbian *mVideoStartSoundPlayer; CxeSoundPlayerSymbian *mVideoStopSoundPlayer; - //! New file name generated for the video prepare. - QString mNewFileName; //! Current video file name QString mCurrentFilename; //video resolutions supported by ICM diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxevideorecorderutility.h --- a/camerauis/cameraxui/cxengine/inc/cxevideorecorderutility.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxevideorecorderutility.h Thu Jul 15 01:44:30 2010 +0300 @@ -18,36 +18,36 @@ #define CXEVIDEORECORDERUTILITY_H_ #include +#include +#include -// interface class for usage of CVideoRecorderUtility +/*! +* Video Recorder Utility interface. +*/ class CxeVideoRecorderUtility { public: virtual ~CxeVideoRecorderUtility() {} - virtual TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, - TInt aFunction, - const TDesC8& aDataTo1, - const TDesC8& aDataTo2) = 0; - virtual void OpenFileL(const TDesC& aFileName, - TInt aCameraHandle, - TUid aControllerUid, - TUid aVideoFormat, - const TDesC8& aVideoType = KNullDesC8, - TFourCC aAudioType = KMMFFourCCCodeNULL) = 0; - virtual void SetVideoFrameSizeL(TSize aSize) = 0; - virtual void SetVideoFrameRateL(TInt aRate) = 0; - virtual void SetVideoBitRateL(TInt aRate) = 0; - virtual void SetAudioEnabledL(TBool aEnable) = 0; - virtual void SetMaxClipSizeL(TInt aClipSizeInBytes) = 0; - virtual void Close() = 0; - virtual void Prepare() = 0; - virtual void Record() = 0; - virtual int Stop() = 0; - virtual void PauseL() = 0; - virtual TTimeIntervalMicroSeconds RecordTimeAvailable() = 0; - virtual TTimeIntervalMicroSeconds DurationL() = 0; + virtual void open(int cameraHandle, + const QString &filename, + const QString &fileMimeType, + const QString &supplier, + const QString &videoType, + const QString &aAudioType) = 0; + virtual void setVideoFrameSize(const QSize& size) = 0; + virtual void setVideoFrameRate(int rate) = 0; + virtual void setVideoBitRate(int rate) = 0; + virtual void setAudioEnabled(bool enable) = 0; + virtual void setVideoMaxSize(int sizeInBytes) = 0; + virtual void close() = 0; + virtual void prepare() = 0; + virtual void record() = 0; + virtual void stop(bool asynchronous = false) = 0; + virtual void pause() = 0; + virtual int availableRecordingTime() = 0; + virtual int duration() = 0; protected: CxeVideoRecorderUtility() {} diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/inc/cxevideorecorderutilitysymbian.h --- a/camerauis/cameraxui/cxengine/inc/cxevideorecorderutilitysymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/inc/cxevideorecorderutilitysymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -24,37 +24,38 @@ { public: - CxeVideoRecorderUtilitySymbian(MVideoRecorderUtilityObserver& aObserver, - TInt aPriority=EMdaPriorityNormal, - TMdaPriorityPreference aPref=EMdaPriorityPreferenceTimeAndQuality); - + CxeVideoRecorderUtilitySymbian(MVideoRecorderUtilityObserver& aObserver); ~CxeVideoRecorderUtilitySymbian(); - TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, - TInt aFunction, - const TDesC8& aDataTo1, - const TDesC8& aDataTo2); - void OpenFileL(const TDesC& aFileName, - TInt aCameraHandle, - TUid aControllerUid, - TUid aVideoFormat, - const TDesC8& aVideoType = KNullDesC8, - TFourCC aAudioType = KMMFFourCCCodeNULL); - void SetVideoFrameSizeL(TSize aSize); - void SetVideoFrameRateL(TInt aRate); - void SetVideoBitRateL(TInt aRate); - void SetAudioEnabledL(TBool aEnable); - void SetMaxClipSizeL(TInt aClipSizeInBytes); - void Close(); - void Prepare(); - void Record(); - int Stop(); - void PauseL(); - TTimeIntervalMicroSeconds RecordTimeAvailable(); - TTimeIntervalMicroSeconds DurationL(); + virtual void open(int cameraHandle, + const QString &filename, + const QString &fileMimeType, + const QString &supplier, + const QString &videoType, + const QString &audioType); + virtual void setVideoFrameSize(const QSize& size); + virtual void setVideoFrameRate(int rate); + virtual void setVideoBitRate(int rate); + virtual void setAudioEnabled(bool enabled); + virtual void setVideoMaxSize(int sizeInBytes); + virtual void close(); + virtual void prepare(); + virtual void record(); + virtual void stop(bool asynchronous = false); + virtual void pause(); + virtual int availableRecordingTime(); + virtual int duration(); + +private: + void findControllerL(const QString& fileMimeType, + const QString& supplier, + TUid& controllerId, + TUid& formatId); + + TFourCC audioFourCC(const QString& str); + private: CVideoRecorderUtility *mVideoRecorder; - int mStartuperror; }; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxediskmonitorprivate.cpp --- a/camerauis/cameraxui/cxengine/src/cxediskmonitorprivate.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxediskmonitorprivate.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -72,14 +72,6 @@ // Get the current free space. mLatestFreeBytes = free(false); - // TESTING >>> - /* - static qint64 TEST = 20*1000*1000; - TEST /= 2; - mLatestFreeBytes = TEST; - */ - // <<< TESTING - // If space has changed during monitoring, signal it now. if (previousFree != mLatestFreeBytes && isMonitoring()) { CX_DEBUG(("CxeDiskMonitorPrivate - Disk space changed %d -> %d bytes", previousFree, mLatestFreeBytes)); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxeengine.cpp --- a/camerauis/cameraxui/cxengine/src/cxeengine.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxeengine.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -26,7 +26,7 @@ CX_DEBUG_ENTER_FUNCTION(); CxeEngineSymbian *res = new CxeEngineSymbian(); - + res->construct(); CX_DEBUG_EXIT_FUNCTION(); return res; } diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp --- a/camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxeenginesymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -23,6 +23,7 @@ #include "cxevideocapturecontrolsymbian.h" #include "cxesettingscontrolsymbian.h" #include "cxeviewfindercontrolsymbian.h" +#include "cxesnapshotcontrol.h" #include "cxefilenamegeneratorsymbian.h" #include "cxeautofocuscontrolsymbian.h" #include "cxezoomcontrolsymbian.h" @@ -51,6 +52,7 @@ : mCameraDeviceControl(NULL), mCameraDevice(NULL), mViewfinderControl(NULL), + mSnapshotControl(NULL), mStillCaptureControl(NULL), mVideoCaptureControl(NULL), mSettingsControl(NULL), @@ -62,27 +64,11 @@ mFilenameGenerator(NULL), mSensorEventHandler(NULL), mQualityPresets(NULL), - mFileSaveThread(NULL) + mFileSaveThread(NULL), + mDiskMonitor(NULL), + mMemoryMonitor(NULL) { - CX_DEBUG_ENTER_FUNCTION(); - - // Do secondary construction during reserve call. - //! @todo temporarily commented as part of a hack to change the startup sequence - // to avoid GOOM issues - // connect(this, SIGNAL(reserveStarted()), this, SLOT(construct())); - - CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian(); - mCameraDeviceControl = deviceControl; - mCameraDevice = deviceControl->cameraDevice(); - CX_ASSERT_ALWAYS(mCameraDeviceControl); - CX_ASSERT_ALWAYS(mCameraDevice); - - mCameraDeviceControl->init(); - //! @todo calling construct here is a hack to change the startup sequence - // to avoid GOOM issues - construct(); - - CX_DEBUG_EXIT_FUNCTION(); + CX_DEBUG_IN_FUNCTION(); } @@ -112,6 +98,15 @@ if (!mSettingsModel) { OstTrace0(camerax_performance, CXEENGINESYMBIAN_CREATECONTROLS_IN, "e_CX_ENGINE_CREATE_CONTROLS 1"); + CxeCameraDeviceControlSymbian *deviceControl = new CxeCameraDeviceControlSymbian(); + mCameraDeviceControl = deviceControl; + mCameraDevice = deviceControl->cameraDevice(); + + CX_ASSERT_ALWAYS(mCameraDeviceControl); + CX_ASSERT_ALWAYS(mCameraDevice); + + mCameraDeviceControl->init(); + CxeSettingsCenRepStore *settingsStore(NULL); if (XQServiceUtil::isService()) { settingsStore = new CxeSettingsLocalStore(); @@ -153,20 +148,22 @@ mViewfinderControl = new CxeViewfinderControlSymbian(*mCameraDevice, *mCameraDeviceControl); + mSnapshotControl = new CxeSnapshotControl(*mCameraDevice); + mAutoFocusControl = new CxeAutoFocusControlSymbian(*mCameraDevice); mFileSaveThread = CxeFileSaveThreadFactory::createFileSaveThread(); mStillCaptureControl = new CxeStillCaptureControlSymbian( - *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl, + *mCameraDevice, *mViewfinderControl, *mSnapshotControl, *mCameraDeviceControl, *mFilenameGenerator, *mSensorEventHandler, *mAutoFocusControl, *mSettings, *mQualityPresets, *mFileSaveThread, *mDiskMonitor); - mZoomControl = new CxeZoomControlSymbian( *mCameraDevice, - *mCameraDeviceControl, *mSettings, *mFeatureManager); + mZoomControl = new CxeZoomControlSymbian( + *mCameraDevice, *mCameraDeviceControl, *mSettings, *mFeatureManager); mVideoCaptureControl = new CxeVideoCaptureControlSymbian( - *mCameraDevice, *mViewfinderControl, *mCameraDeviceControl, + *mCameraDevice, *mViewfinderControl, *mSnapshotControl, *mCameraDeviceControl, *mFilenameGenerator, *mSettings, *mQualityPresets, *mDiskMonitor); mSettingsControl = new CxeSettingsControlSymbian(*mCameraDevice, *mSettings); @@ -200,7 +197,7 @@ // Connect signals for ECam events connect(mCameraDeviceControl, SIGNAL(cameraEvent(int,int)), - mVideoCaptureControl, + mSnapshotControl, SLOT(handleCameraEvent(int,int))); connect(mCameraDeviceControl, @@ -266,6 +263,7 @@ delete mSettingsControl; delete mStillCaptureControl; delete mVideoCaptureControl; + delete mSnapshotControl; delete mViewfinderControl; delete mFilenameGenerator; delete mDiskMonitor; @@ -290,6 +288,11 @@ return *mViewfinderControl; } +CxeSnapshotControl &CxeEngineSymbian::snapshotControl() +{ + return *mSnapshotControl; +} + CxeStillCaptureControl &CxeEngineSymbian::stillCaptureControl() { return *mStillCaptureControl; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxequalitypresetssymbian.cpp --- a/camerauis/cameraxui/cxengine/src/cxequalitypresetssymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxequalitypresetssymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -17,6 +17,7 @@ * */ +#include #include // For Symbian types used in mmsenginedomaincrkeys.h #include @@ -35,15 +36,22 @@ namespace { // Display IDs for cameras, used when requesting data from ICM - const int PRIMARY_CAMERA_DISPLAY_ID = 2; - const int SECONDARY_CAMERA_DISPLAY_ID = 3; + const int PRIMARY_CAMERA_DISPLAY_ID = 2; + const int SECONDARY_CAMERA_DISPLAY_ID = 3; - const int ONE_MILLION = 1000000; - const qreal ASPECT_16_BY_9 = (16/9.0); - const qreal DELTA_ERROR = 0.20; + const int ONE_MILLION = 1000000; + const qreal ASPECT_16_BY_9 = (16/9.0); + const qreal DELTA_ERROR = 0.20; // ICM "camcorderVisible" parameter value below this means sharing aka mms quality. - const int MMS_QUALITY_CAMCORDERVISIBLE_LIMIT = 200; + const int MMS_QUALITY_CAMCORDERVISIBLE_LIMIT = 200; + + // Average video bit rate scaler + const qreal VIDEO_AVG_BITRATE_SCALER = 0.9; + // Coefficient to estimate video metadata amount + const qreal VIDEO_METADATA_COEFF = 1.03; + // Maximum video clip duration in seconds for all qualities + const qint64 VIDEO_MAX_DURATION = 5400; } @@ -98,7 +106,7 @@ int totalLevels = mIcm->NumberOfImageQualityLevels(); CX_DEBUG(("Total image quality levels = %d", totalLevels)); - CArrayFixFlat* levels= new CArrayFixFlat(totalLevels); + CArrayFixFlat* levels = new CArrayFixFlat(totalLevels); // Get camera display id based on camera index int displayId = cameraId == Cxe::SecondaryCameraIndex @@ -235,6 +243,7 @@ */ CxeVideoDetails CxeQualityPresetsSymbian::createVideoPreset(TVideoQualitySet set) { + CX_DEBUG_ENTER_FUNCTION(); CxeVideoDetails newPreset; // set setting values from quality set newPreset.mWidth = set.iVideoWidth; @@ -272,6 +281,7 @@ // set audiotype newPreset.mAudioType = toString(fourCCBuf); + CX_DEBUG_EXIT_FUNCTION(); return newPreset; } @@ -341,6 +351,48 @@ } +/*! +* Get the available recording time with given video quality details and disk space. +* @param details Video quality details to use in calculation. +* @param space Available disk space to use in calculation. +* @return Available recording time estimate in seconds. +*/ +int CxeQualityPresetsSymbian::recordingTimeAvailable(const CxeVideoDetails& details, qint64 space) +{ + CX_DEBUG_ENTER_FUNCTION(); + int time(0); + + // Maximum clip size may be limited for mms quality. + // If mMaximumSizeInBytes == 0, no limit is specified. + if (details.mMaximumSizeInBytes > 0 && details.mMaximumSizeInBytes < space) { + space = details.mMaximumSizeInBytes; + } + + // Use average audio/video bitrates to estimate remaining time + qreal scaler(avgVideoBitRateScaler()); + if (scaler == 0) { + // video bit rate scaler is 0, use the constant value + scaler = VIDEO_AVG_BITRATE_SCALER; + } + + int muteSetting = 0; // audio enabled + mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); + + int avgVideoBitRate = (details.mVideoBitRate * scaler); + int avgAudioBitRate = (muteSetting == 1) ? 0 : details.mAudioBitRate; + + quint32 averageBitRate = (quint32)((avgVideoBitRate + avgAudioBitRate) * VIDEO_METADATA_COEFF); + quint32 averageByteRate = averageBitRate / 8; + + // 0 <= Remaining time <= KCamCMaxClipDurationInSecs + qint64 remaining = std::max(qint64(0), space/averageByteRate); + time = std::min(remaining, VIDEO_MAX_DURATION); + + CX_DEBUG(( "remaining time from algorithm: %d", time )); + CX_DEBUG_EXIT_FUNCTION(); + return time; +} + /*! Operator to sort values in ascending order. diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxesnapshotcontrol.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/src/cxesnapshotcontrol.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include "cxutils.h" +#include "cxesnapshotcontrol.h" +#include "cxesnapshotcontrolprivate.h" + +/*! +* Constructor. +* @param device Camera device interface, used for getting hold of adaptation snapshot API. +*/ +CxeSnapshotControl::CxeSnapshotControl(CxeCameraDevice& device) +{ + d = new CxeSnapshotControlPrivate(this, device); + CX_ASSERT_ALWAYS(d); +} + +/*! +* Destructor. +*/ +CxeSnapshotControl::~CxeSnapshotControl() +{ + delete d; +} + +/*! +* Get the state of Snapshot Control. +* @return The current state. +*/ +CxeSnapshotControl::State CxeSnapshotControl::state() const +{ + return d->state(); +} + +/*! +* Calculate snapshot size based on diplay size and image / video output resolution. +* @param displaySize Display size in pixels. +* @param outputResolution Resolution of the output image / video in pixels. +* @return Proposed best snapshot size. +*/ +QSize CxeSnapshotControl::calculateSnapshotSize(const QSize& displaySize, const QSize& outputResolution) const +{ + return d->calculateSnapshotSize(displaySize, outputResolution); +} + +/*! +* Start snapshot events. Snapshots will be signalled +* through snapshotReady() signal. +* @param size Size of the snapshot image. +*/ +void CxeSnapshotControl::start(const QSize& size) +{ + d->start(size); +} + +/*! +* Stop snapshot events. +*/ +void CxeSnapshotControl::stop() +{ + d->stop(); +} + +/*! +* Handle camera events. +* @param id Event uid. +* @param error Status code of the event. +*/ +void CxeSnapshotControl::handleCameraEvent(int eventUid, int error) +{ + d->handleCameraEvent(eventUid, error); +} + +// end of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxesnapshotcontrolprivate.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/src/cxesnapshotcontrolprivate.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,297 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +// Note: Keep atleast one Qt include before preprocessor flags +#ifdef Q_OS_SYMBIAN +#include +#include +#include +#include +#endif // Q_OS_SYMBIAN + +#include "cxutils.h" +#include "cxeerror.h" +#include "cxeexception.h" +#include "cxeerrormappingsymbian.h" +#include "cxecameradevice.h" +#include "cxestate.h" +#include "cxesnapshotcontrol.h" +#include "cxesnapshotcontrolprivate.h" + + +namespace +{ + const int MAINTAIN_ASPECT = false; + +#ifdef Q_OS_SYMBIAN + /*! + * Helper class for cleaning up MCameraBuffer instances. + */ + class CxeCameraBufferCleanup + { + public: + explicit CxeCameraBufferCleanup(MCameraBuffer *buffer) + : mBuffer(buffer) + { + } + + ~CxeCameraBufferCleanup() + { + if (mBuffer) { + CX_DEBUG(("CxeCameraBufferCleanup - releasing MCameraBuffer..")); + mBuffer->Release(); + mBuffer = NULL; + } + } + private: + Q_DISABLE_COPY(CxeCameraBufferCleanup) + MCameraBuffer *mBuffer; + }; +#endif // Q_OS_SYMBIAN +} + + +/*! +* Constructor. +* @param parent Public interface of Snapshot control. +* @param device Camera device interface, used for getting hold of adaptation snapshot API. +*/ +CxeSnapshotControlPrivate::CxeSnapshotControlPrivate(CxeSnapshotControl *parent, + CxeCameraDevice& device) + : CxeStateMachine("CxeSnapshotControlPrivate"), + q(parent), + mDevice(device) +{ + CX_DEBUG_ENTER_FUNCTION(); + CX_ASSERT_ALWAYS(q); + initializeStates(); + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Destructor. +*/ +CxeSnapshotControlPrivate::~CxeSnapshotControlPrivate() +{ + CX_DEBUG_ENTER_FUNCTION(); + stop(); + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Called when state changes. +* @param newStateId Id of the new state. +* @param error Error code or CxeError::None in successful case. +*/ +void CxeSnapshotControlPrivate::handleStateChanged(int newStateId, CxeError::Id error) +{ + emit q->stateChanged(static_cast(newStateId), error); +} + + +/*! +* Get the state of Snapshot Control. +* @return The current state. +*/ +CxeSnapshotControl::State CxeSnapshotControlPrivate::state() const +{ + return static_cast (stateId()); +} + +/*! +* Initialize Snapshot Control states +*/ +void CxeSnapshotControlPrivate::initializeStates() +{ + CX_DEBUG_ENTER_FUNCTION(); + // addState( id, name, allowed next states ) + addState(new CxeState(CxeSnapshotControl::Idle, "Idle", CxeSnapshotControl::Active)); + addState(new CxeState(CxeSnapshotControl::Active, "Active", CxeSnapshotControl::Idle)); + + setInitialState(CxeSnapshotControl::Idle); + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Calculate snapshot size based on diplay size and image / video output resolution. +* @param displaySize Display size in pixels. +* @param outputResolution Resolution of the output image / video in pixels. +* @return Proposed best snapshot size. +*/ +QSize CxeSnapshotControlPrivate::calculateSnapshotSize(const QSize &displaySize, const QSize &outputResolution) const +{ + CX_DEBUG_ENTER_FUNCTION(); + CX_DEBUG(("CxeSnapshotControlPrivate - output resolution (%d,%d)", outputResolution.width(), outputResolution.height())); + CX_DEBUG(("CxeSnapshotControlPrivate - display size (%d,%d)", displaySize.width(), displaySize.height())); + + // Take resolution as reference for aspect ratio. + // Scale keeping aspect ratio to just fit display. + QSize size(outputResolution); + size.scale(displaySize, Qt::KeepAspectRatio); + CX_DEBUG(("CxeSnapshotControlPrivate - calculated size, (%d,%d)", size.width(), size.height())); + size.setHeight(displaySize.height()); + CX_DEBUG(("CxeSnapshotControlPrivate - adjusted final size, (%d,%d)", size.width(), size.height())); + CX_DEBUG_EXIT_FUNCTION(); + return size; +} + +/*! +* Start getting snapshots from camera. +* Throws CxeException with CxeError::Id if error encountered. +* @param size Size of the snapshot in pixels. +*/ +void CxeSnapshotControlPrivate::start(const QSize &size) +{ + CX_DEBUG_ENTER_FUNCTION(); +#ifdef Q_OS_SYMBIAN + CCamera::CCameraSnapshot *ss = mDevice.cameraSnapshot(); + CX_ASSERT_ALWAYS(ss); + + if (ss->IsSnapshotActive()) { + CX_DEBUG(("Stop currently active snapshot..")); + ss->StopSnapshot(); + } + + // Prepare snapshot + CCamera::TFormat snapFormat = CCamera::EFormatFbsBitmapColor16MU; + TSize snapSize = TSize(size.width(), size.height()); + + CX_DEBUG(("Prepare snapshot, size (%d x %d)..", size.width(), size.height())); + TRAPD(status, ss->PrepareSnapshotL(snapFormat, snapSize, MAINTAIN_ASPECT)); + CxeException::throwIfError(CxeErrorHandlingSymbian::map(status)); + CX_DEBUG(("After prepare ECAM modified size to (%d x %d)..", size.width(), size.height())); + + CX_DEBUG(("Start snapshot..")); + ss->StartSnapshot(); +#else + Q_UNUSED(size); +#endif // Q_OS_SYMBIAN + setState(CxeSnapshotControl::Active); + + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Stop getting snapshots from camera. +*/ +void CxeSnapshotControlPrivate::stop() +{ + CX_DEBUG_ENTER_FUNCTION(); +#ifdef Q_OS_SYMBIAN + if (mDevice.cameraSnapshot()) { + mDevice.cameraSnapshot()->StopSnapshot(); + } +#endif // Q_OS_SYMBIAN + setState(CxeSnapshotControl::Idle); + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Helper method for getting the snapshot. +* Throws exception if fetching the snapshot fails. +* @return QPixmap containing the snapshot. +*/ +QPixmap CxeSnapshotControlPrivate::snapshot() +{ + CX_DEBUG_ENTER_FUNCTION(); + QPixmap pixmap; + +#ifdef Q_OS_SYMBIAN + TRAPD(status, { + RArray frameIndex; + CleanupClosePushL(frameIndex); + + MCameraBuffer &buffer(mDevice.cameraSnapshot()->SnapshotDataL(frameIndex)); + // Make sure buffer is released on leave / exception. + // Buffer is released once the cleanup item goes out of scope. + CxeCameraBufferCleanup cleaner(&buffer); + + TInt firstImageIndex(frameIndex.Find(0)); + CFbsBitmap &snapshot(buffer.BitmapL(firstImageIndex)); + + CleanupStack::PopAndDestroy(); // frameIndex + + TSize size = snapshot.SizeInPixels(); + TInt sizeInWords = size.iHeight * CFbsBitmap::ScanLineLength(size.iWidth, EColor16MU) / sizeof(TUint32); + CX_DEBUG(("size %d x %d, sizeInWords = %d", size.iWidth, size.iHeight, sizeInWords )); + + TUint32 *pixelData = new (ELeave) TUint32[ sizeInWords ]; + // Convert to QImage + snapshot.LockHeap(); + TUint32 *dataPtr = snapshot.DataAddress(); + memcpy(pixelData, dataPtr, sizeof(TUint32)*sizeInWords); + snapshot.UnlockHeap(); + + CX_DEBUG(("Creating QImage")); + QImage *snapImage = new QImage((uchar*)pixelData, size.iWidth, size.iHeight, + CFbsBitmap::ScanLineLength(size.iWidth, EColor16MU), + QImage::Format_RGB32); + + pixmap = QPixmap::fromImage(*snapImage); + delete [] pixelData; + delete snapImage; + }); + // We throw error with the Symbian error code if there was problems. + CxeException::throwIfError(status); +#endif // Q_OS_SYMBIAN + + CX_DEBUG_EXIT_FUNCTION(); + return pixmap; +} + +/*! +* Handle camera snapshot events. +* @param id Event uid. +* @param error Status code of the event. +*/ +void CxeSnapshotControlPrivate::handleCameraEvent(int id, int error) +{ + CX_DEBUG_ENTER_FUNCTION(); + + // Ignoring all events if not active. + if (state() == CxeSnapshotControl::Active) { +#ifdef Q_OS_SYMBIAN + if (id == KUidECamEventSnapshotUidValue) { + QPixmap ss; + + if (!error) { + try { + ss = snapshot(); + } catch (const CxeException& e) { + // Note: Normally CxeException carries CxeError::Id, + // but we intentionally use Symbian code in getSnapshot + // as it's easier to handle here. + error = e.error(); + } catch (...) { + error = KErrGeneral; + } + } + + // Emit snapshot ready signal through the public interface. + emit q->snapshotReady(CxeErrorHandlingSymbian::map(error), ss); + } +#else + Q_UNUSED(id) + Q_UNUSED(error) +#endif // Q_OS_SYMBIAN + } + CX_DEBUG_EXIT_FUNCTION(); +} + +// end of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxestillcapturecontrolsymbian.cpp --- a/camerauis/cameraxui/cxengine/src/cxestillcapturecontrolsymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxestillcapturecontrolsymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -18,11 +18,9 @@ #include #include -#include #include #include #include -#include #include #include "cxestillcapturecontrolsymbian.h" @@ -34,8 +32,8 @@ #include "cxecameradevice.h" #include "cxesoundplayersymbian.h" #include "cxestillimagesymbian.h" -#include "cxeviewfindercontrol.h" #include "cxeviewfindercontrolsymbian.h" +#include "cxesnapshotcontrol.h" #include "cxesettingsmappersymbian.h" #include "cxestate.h" #include "cxesettings.h" @@ -53,9 +51,10 @@ // constants -const int KMaintainAspectRatio = false; -const TInt64 KMinRequiredSpaceImage = 2000000; - +namespace +{ + const TInt64 KMinRequiredSpaceImage = 2000000; +} /** * Constructor. @@ -63,6 +62,7 @@ CxeStillCaptureControlSymbian::CxeStillCaptureControlSymbian( CxeCameraDevice &cameraDevice, CxeViewfinderControl &viewfinderControl, + CxeSnapshotControl &snapshotControl, CxeCameraDeviceControl &cameraDeviceControl, CxeFilenameGenerator &nameGenerator, CxeSensorEventHandler &sensorEventHandler, @@ -74,6 +74,7 @@ : CxeStateMachine("CxeStillCaptureControlSymbian"), mCameraDevice(cameraDevice), mViewfinderControl(viewfinderControl), + mSnapshotControl(snapshotControl), mCameraDeviceControl(cameraDeviceControl), mFilenameGenerator(nameGenerator), mSensorEventHandler(sensorEventHandler), @@ -116,9 +117,9 @@ // Connect ECam image buffer ready event connect(&mCameraDeviceControl, SIGNAL(imageBufferReady(MCameraBuffer*,int)), this, SLOT(handleImageData(MCameraBuffer*,int))); - // Connect signals for ECam events - connect(&mCameraDeviceControl, SIGNAL(cameraEvent(int,int)), - this, SLOT(handleCameraEvent(int,int))); + // connect snapshot ready signal + connect(&mSnapshotControl, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&)), + this, SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&))); OstTrace0(camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_CREATE_MID2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0"); @@ -217,16 +218,15 @@ //stop viewfinder mViewfinderControl.stop(); + if (state() == Capturing) { + mCameraDevice.camera()->CancelCaptureImage(); + } + // disable sensor event handler. mSensorEventHandler.deinit(); - if (mCameraDevice.cameraSnapshot()) { - mCameraDevice.cameraSnapshot()->StopSnapshot(); - } + mSnapshotControl.stop(); - if (state() == Capturing) { - mCameraDevice.camera()->CancelCaptureImage(); - } setState(Uninitialized); OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_DEINIT_OUT, "msg: e_CX_STILL_CAPCONT_DEINIT 0" ); @@ -332,39 +332,21 @@ int CxeStillCaptureControlSymbian::prepareStillSnapshot() { CX_DEBUG_ENTER_FUNCTION(); - - CCamera::CCameraSnapshot *cameraSnapshot = mCameraDevice.cameraSnapshot(); - CX_ASSERT_ALWAYS(cameraSnapshot); - - int err = KErrNone; - // Whether or not we have postcapture on, we need the snapshot for Thumbnail Manager. - if (cameraSnapshot) { - // Cancel active snapshot - cameraSnapshot->StopSnapshot(); + OstTrace0( camerax_performance, DUP4_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_PREPARE_SNAPSHOT 1" ); - // Prepare snapshot - CCamera::TFormat snapFormat = CCamera::EFormatFbsBitmapColor16MU; - OstTrace0( camerax_performance, DUP4_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_PREPARE_SNAPSHOT 1" ); - TRAP(err, cameraSnapshot->PrepareSnapshotL(snapFormat, - getSnapshotSize(), - KMaintainAspectRatio)); - OstTrace0( camerax_performance, DUP5_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_PREPARE_SNAPSHOT 0" ); - CX_DEBUG(("PrepareSnapshotL done, err=%d", err)); - - // Start snapshot if no errors encountered. - if (err == KErrNone) { - CX_DEBUG(("Start still snapshot")); - cameraSnapshot->StartSnapshot(); - } - } else { - // No snapshot interface available. Report error. - // Assert above takes care of this, but keeping this as an option. - err = KErrNotReady; + int status(KErrNone); + try { + QSize snapshotSize = mSnapshotControl.calculateSnapshotSize( + mViewfinderControl.deviceDisplayResolution(), + QSize(mCurrentImageDetails.mWidth, mCurrentImageDetails.mHeight)); + mSnapshotControl.start(snapshotSize); + } catch (...) { + status = KErrGeneral; } + OstTrace0( camerax_performance, DUP5_CXESTILLCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_PREPARE_SNAPSHOT 0" ); CX_DEBUG_EXIT_FUNCTION(); - - return err; + return status; } @@ -400,31 +382,6 @@ return err; } - -/*! -* Returns snapshot size. Snapshot size is calculated based on the -* display resolution and current image aspect ratio. -*/ -TSize CxeStillCaptureControlSymbian::getSnapshotSize() const -{ - CX_DEBUG_ENTER_FUNCTION(); - - TSize snapshotSize; - - QSize deviceResolution = mViewfinderControl.deviceDisplayResolution(); - QSize size = QSize(mCurrentImageDetails.mWidth, mCurrentImageDetails.mHeight); - - // scale according to aspect ratio. - size.scale(deviceResolution.width(), deviceResolution.height(), Qt::KeepAspectRatio); - CX_DEBUG(("Still Snapshot size, (%d,%d)", size.width(), size.height())); - snapshotSize.SetSize(size.width(), deviceResolution.height()); - - CX_DEBUG_EXIT_FUNCTION(); - - return snapshotSize; -} - - /** * Command to start image capture now. */ @@ -481,112 +438,38 @@ return imgFormat; } - -/** - * Camera events. Only relevant one(s) are handled. - */ -void CxeStillCaptureControlSymbian::handleCameraEvent(int eventUid, int error) -{ - CX_DEBUG_ENTER_FUNCTION(); - - if (eventUid == KUidECamEventSnapshotUidValue && - mCameraDeviceControl.mode() == Cxe::ImageMode) { - handleSnapshotEvent(CxeErrorHandlingSymbian::map(error)); - } - - CX_DEBUG_EXIT_FUNCTION(); -} - /** * Snapshot ready notification. Ask the snapshot from snapshot interface. * NB: Typically snapshot arrives before image data but can be in reverse * order as well. */ -void CxeStillCaptureControlSymbian::handleSnapshotEvent(CxeError::Id error) +void CxeStillCaptureControlSymbian::handleSnapshotReady(CxeError::Id status, const QPixmap& snapshot) { CX_DEBUG_ENTER_FUNCTION(); - - if (state() == CxeStillCaptureControl::Uninitialized) { - // we ignore this event, when we are not active - return; - } + if (mCameraDeviceControl.mode() == Cxe::ImageMode) { - OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_HANDLESNAPSHOTEVENT, "msg: e_CX_HANDLE_SNAPSHOT 1" ); - - // Get image container for current snapshot index. - // Remember to increment counter. - CxeStillImageSymbian* stillImage = getImageForIndex(mNextSnapshotIndex++); + OstTrace0( camerax_performance, CXESTILLCAPTURECONTROLSYMBIAN_HANDLESNAPSHOTEVENT, "msg: e_CX_HANDLE_SNAPSHOT 1" ); - if (error == CxeError::None) { - try { - stillImage->setSnapshot(extractSnapshot()); - } catch (const std::exception& ex) { - error = CxeError::General; + // Get image container for current snapshot index. + // Remember to increment counter. + CxeStillImageSymbian* stillImage = getImageForIndex(mNextSnapshotIndex++); + if (status == CxeError::None) { + stillImage->setSnapshot(snapshot); } - } - - // Emit snapshotReady signal in all cases (error or not) - emit snapshotReady(error, stillImage->snapshot(), stillImage->id()); - - // When the snapshot ready event is handled, prepare new filename. - if (stillImage->filename().isEmpty()) { - // Error ignored at this point, try again when image data arrives. - prepareFilename(stillImage); - } - - OstTrace0( camerax_performance, DUP1_CXESTILLCAPTURECONTROLSYMBIAN_HANDLESNAPSHOTEVENT, "msg: e_CX_HANDLE_SNAPSHOT 0" ); - CX_DEBUG_EXIT_FUNCTION(); -} -/** -* Gets QPixmap snapshot from ECAM buffer, if available. -* @param buffer ECAM buffer containing the snapshot data. Will be released when this -* method returns, even on exception. -*/ -QPixmap CxeStillCaptureControlSymbian::extractSnapshot() -{ - CX_DEBUG_ENTER_FUNCTION(); - QPixmap pixmap; - - if (mCameraDevice.cameraSnapshot()) { - - QT_TRAP_THROWING({ - RArray frameIndex; - CleanupClosePushL(frameIndex); - - MCameraBuffer &buffer(mCameraDevice.cameraSnapshot()->SnapshotDataL(frameIndex)); - - // Make sure buffer is released on leave / exception - CxeCameraBufferCleanup cleaner(&buffer); - TInt firstImageIndex(frameIndex.Find(0)); - CFbsBitmap &snapshot(buffer.BitmapL(firstImageIndex)); + // Emit snapshotReady signal in all cases (error or not) + emit snapshotReady(status, snapshot, stillImage->id()); - CleanupStack::PopAndDestroy(); // frameIndex - - TSize size = snapshot.SizeInPixels(); - TInt sizeInWords = size.iHeight * CFbsBitmap::ScanLineLength(size.iWidth, EColor16MU) / sizeof(TUint32); - CX_DEBUG(("size %d x %d, sizeInWords = %d", size.iWidth, size.iHeight, sizeInWords )); + // When the snapshot ready event is handled, prepare new filename. + if (stillImage->filename().isEmpty()) { + // Error ignored at this point, try again when image data arrives. + prepareFilename(stillImage); + } - TUint32* pixelData = new (ELeave) TUint32[ sizeInWords ]; - // Convert to QImage - snapshot.LockHeap(); - TUint32* dataPtr = snapshot.DataAddress(); - memcpy(pixelData, dataPtr, sizeof(TUint32)*sizeInWords); - snapshot.UnlockHeap(); - - CX_DEBUG(("Creating QImage")); - QImage *snapImage = new QImage((uchar*)pixelData, size.iWidth, size.iHeight, - CFbsBitmap::ScanLineLength(size.iWidth, EColor16MU), - QImage::Format_RGB32); - - pixmap = QPixmap::fromImage(*snapImage); - delete [] pixelData; - delete snapImage; - }); + OstTrace0( camerax_performance, DUP1_CXESTILLCAPTURECONTROLSYMBIAN_HANDLESNAPSHOTEVENT, "msg: e_CX_HANDLE_SNAPSHOT 0" ); } CX_DEBUG_EXIT_FUNCTION(); - return pixmap; } /** diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxesysutil.cpp --- a/camerauis/cameraxui/cxengine/src/cxesysutil.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxesysutil.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -154,12 +154,6 @@ CX_DEBUG(("status getting volume info: %d", status)); qt_symbian_throwIfError(status); - CX_DEBUG(("TVolumeInfo.iDrive.iType: %d", volumeInfo.iDrive.iType)); - CX_DEBUG((" EMediaNotPresent: %d", EMediaNotPresent)); - CX_DEBUG((" EMediaUnknown: %d", EMediaUnknown)); - CX_DEBUG(("TVolumeInfo.iDrive.iMediaAtt: %d", volumeInfo.iDrive.iMediaAtt)); - CX_DEBUG((" KMediaAttLocked: %d", KMediaAttLocked)); - // Get critical treshold for free space on the drive. // We must leave the free space above this. QVariant criticalThreshold; @@ -174,6 +168,7 @@ freeSpace = 0; } + CX_DEBUG(("CxeSysUtil - free space: %d", freeSpace)); CX_DEBUG_EXIT_FUNCTION(); return freeSpace; } diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxethumbnailmanagersymbian.cpp --- a/camerauis/cameraxui/cxengine/src/cxethumbnailmanagersymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxethumbnailmanagersymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -21,7 +21,7 @@ #include "cxutils.h" #include "cxethumbnailmanagersymbian.h" -//#define CXE_USE_THUMBNAIL_MANAGER + /*! @@ -31,14 +31,11 @@ { CX_DEBUG_ENTER_FUNCTION(); -#ifdef CXE_USE_THUMBNAIL_MANAGER - mThumbnailManager = new ThumbnailManager(); // connect thumbnail ready signal from thumbnailmanager connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void *, int, int)), this, SLOT(thumbnailReady(QPixmap, void *, int, int))); -#endif CX_DEBUG_EXIT_FUNCTION(); } @@ -51,10 +48,8 @@ { CX_DEBUG_ENTER_FUNCTION(); -#ifdef CXE_USE_THUMBNAIL_MANAGER mThumbnailRequests.clear(); delete mThumbnailManager; -#endif CX_DEBUG_EXIT_FUNCTION(); } @@ -71,7 +66,6 @@ { CX_DEBUG_ENTER_FUNCTION(); -#ifdef CXE_USE_THUMBNAIL_MANAGER TPtrC16 fName(reinterpret_cast(filename.utf16())); CX_DEBUG(("Create thumbnail! filename = %s", filename.toAscii().constData())); @@ -87,9 +81,6 @@ CX_DEBUG(("error initializing data to thumbnail manager")); } } -#else - Q_UNUSED(filename); -#endif CX_DEBUG_EXIT_FUNCTION(); } @@ -103,7 +94,6 @@ { CX_DEBUG_ENTER_FUNCTION(); -#ifdef CXE_USE_THUMBNAIL_MANAGER if (mThumbnailRequests.contains(filename)) { int thumbnailId = mThumbnailRequests.value(filename); if (mThumbnailManager && @@ -112,9 +102,7 @@ mThumbnailRequests.remove(filename); } } -#else - Q_UNUSED(filename); -#endif + CX_DEBUG_EXIT_FUNCTION(); } @@ -132,7 +120,7 @@ CX_DEBUG_ENTER_FUNCTION(); Q_UNUSED(data); -#ifdef CXE_USE_THUMBNAIL_MANAGER + CX_DEBUG(("CxeThumbnailManagerSymbian::thumbnailReady error = %d", error)); QString key; @@ -151,11 +139,6 @@ mThumbnailRequests.remove(key); emit thumbnailReady(thumbnail, error); } -#else - Q_UNUSED(thumbnail); - Q_UNUSED(id); - Q_UNUSED(error); -#endif CX_DEBUG_EXIT_FUNCTION(); } diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp --- a/camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -14,19 +14,22 @@ * Description: * */ + +#include +#include #include -#include #include #include #include -#include +#include "cxeexception.h" #include "cxevideocapturecontrolsymbian.h" #include "cxevideorecorderutilitysymbian.h" #include "cxecameradevicecontrolsymbian.h" #include "cxefilenamegeneratorsymbian.h" #include "cxeerrormappingsymbian.h" #include "cxeviewfindercontrol.h" +#include "cxesnapshotcontrol.h" #include "cxestillimagesymbian.h" #include "cxecameradevice.h" #include "cxutils.h" @@ -47,26 +50,11 @@ // constants namespace { - // Controller UId, can be used by the client to identify the controller, e.g. if the custom command can be used - const TUid KCamCControllerImplementationUid = {0x101F8503}; // TMMFEvent UIDs for Async stop const TUid KCamCControllerCCVideoRecordStopped = {0x2000E546}; const TUid KCamCControllerCCVideoFileComposed = {0x2000E547}; - // Custom command for setting a new filename without closing & reopening the controller - enum TCamCControllerCustomCommands - { - ECamCControllerCCNewFilename = 0, - ECamCControllerCCVideoStopAsync - }; - - const TInt KOneSecond = 1000000; - const int KMaintainAspectRatio = false; const TInt64 KMinRequiredSpaceVideo = 4000000; - const uint KOneMillion = 1000000; - const qreal KMetaDataCoeff = 1.03; // Coefficient to estimate metadata amount - const uint KCamCMaxClipDurationInSecs = 5400; // Maximun video clip duration in seconds - const qreal KCMRAvgVideoBitRateScaler = 0.9; // avg video bit rate scaler } @@ -76,6 +64,7 @@ CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian( CxeCameraDevice &cameraDevice, CxeViewfinderControl &viewfinderControl, + CxeSnapshotControl &snapshotControl, CxeCameraDeviceControl &cameraDeviceControl, CxeFilenameGenerator &nameGenerator, CxeSettings &settings, @@ -86,12 +75,14 @@ mCameraDevice(cameraDevice), mCameraDeviceControl(cameraDeviceControl), mViewfinderControl(viewfinderControl), + mSnapshotControl(snapshotControl), mFilenameGenerator(nameGenerator), mSettings(settings), mQualityPresets(qualityPresets), mDiskMonitor(diskMonitor), mSnapshot(), - mNewFileName(""), + mVideoStartSoundPlayer(NULL), + mVideoStopSoundPlayer(NULL), mCurrentFilename("") { CX_DEBUG_ENTER_FUNCTION(); @@ -118,23 +109,26 @@ this, SLOT(prepareForRelease()) ); connect(&cameraDevice, SIGNAL(cameraAllocated(CxeError::Id)), this, SLOT(handleCameraAllocated(CxeError::Id))); + // connect playing sound signals connect(mVideoStartSoundPlayer, SIGNAL(playComplete(int)), this, SLOT(handleSoundPlayed())); + // connect snapshot ready signal + connect(&mSnapshotControl, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&)), + this, SLOT(handleSnapshotReady(CxeError::Id, const QPixmap&))); + // enabling setting change callbacks to videocapturecontrol connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)), this, SLOT(handleSettingValueChanged(const QString&,QVariant))); - - connect(&mSettings, SIGNAL(sceneChanged(CxeScene&)), this, SLOT(handleSceneChanged(CxeScene&))); - + connect(&mSettings, SIGNAL(sceneChanged(CxeScene&)), + this, SLOT(handleSceneChanged(CxeScene&))); OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0"); OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_OUT, "msg: e_CX_VIDEOCAPTURECONTROL_NEW 0"); CX_DEBUG_EXIT_FUNCTION(); } - /*! * CxeVideoCaptureControlSymbian::~CxeVideoCaptureControlSymbian() */ @@ -150,7 +144,6 @@ CX_DEBUG_EXIT_FUNCTION(); } - /*! * Initializes resources for video recording. */ @@ -168,11 +161,9 @@ } OstTrace0( camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_INIT, "msg: e_CX_VIDEO_CAPCONT_INIT 0" ); - CX_DEBUG_EXIT_FUNCTION(); } - /* * Releases all resources */ @@ -180,39 +171,31 @@ { CX_DEBUG_ENTER_FUNCTION(); - if(state() == Idle) { - // nothing to do - return; - } + // Nothing to do if already idle. + if(state() != Idle) { + OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 1" ); - OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 1" ); + // first stop viewfinder + mViewfinderControl.stop(); - // first stop viewfinder - mViewfinderControl.stop(); - - // stop video-recording in-case if its ongoing. - stop(); + // stop video-recording in-case if its ongoing. + stop(); - if (mCameraDevice.cameraSnapshot()) { - mCameraDevice.cameraSnapshot()->StopSnapshot(); - } + mSnapshotControl.stop(); - if (mVideoRecorder) { - mVideoRecorder->Close(); - } + if (mVideoRecorder) { + mVideoRecorder->close(); + } - // revert back the new filename to empty string so that we generate a new file name - // when we init again - mNewFileName = QString(""); + mCurrentFilename = QString(""); - setState(Idle); + setState(Idle); - OstTrace0( camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 0" ); - + OstTrace0( camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_DEINIT, "msg: e_CX_VIDEO_CAPCONT_DEINIT 0" ); + } CX_DEBUG_EXIT_FUNCTION(); } - /*! * Intializes VideoRecorder for recording. */ @@ -220,52 +203,28 @@ { CX_DEBUG_ENTER_FUNCTION(); - if (state() != Idle) { - // not valid state to start "open" operation - return; - } - - if(!mVideoRecorder) { - // if video recorder is not created, do it now. - createVideoRecorder(); - } - - // update current video quality details from icm - CxeError::Id err = getVideoQualityDetails(mCurrentVideoDetails); + // Init needed only in Idle state + if (state() == Idle) { + try { + // if video recorder is not created, do it now. + createVideoRecorder(); - if (!err) { - // read videofile mime type - QByteArray videoFileData = - mCurrentVideoDetails.mVideoFileMimeType.toLatin1(); - TPtrC8 videoFileMimeType(reinterpret_cast - (videoFileData.constData()), videoFileData.size()); + // update current video quality details from icm. + // Throws an error if unable to get the quality. + getVideoQualityDetails(mCurrentVideoDetails); - // read preferred supplier - TPtrC16 supplier(reinterpret_cast - (mCurrentVideoDetails.mPreferredSupplier.utf16())); - - err = findVideoController(videoFileMimeType, supplier); - - if (!err) { - // video recorder is ready to open video file for recording. + // Video recorder is ready to open video file for recording. setState(Initialized); open(); + } catch (const std::exception &e) { + // Handle error + handlePrepareFailed(); } - } else { - err = CxeErrorHandlingSymbian::map(KErrNotReady); - } - - if (err) { - // In case of error - emit videoPrepareComplete(err); - deinit(); } CX_DEBUG_EXIT_FUNCTION(); } - - /*! * Opens file for video recording. */ @@ -273,92 +232,53 @@ { CX_DEBUG_ENTER_FUNCTION(); - if (state() != Initialized) { - // not valid state to start "open" operation - return; - } - - CxeError::Id err = CxeError::None; + // Check valid state to start "open" operation + if (state() == Initialized) { + try { + // generate video file name, if necessary + generateFilename(); + CX_DEBUG(( "Next video file path: %s", mCurrentFilename.toAscii().constData() )); - // generate video file name, if necessary - if (mNewFileName.isEmpty()) { - QStringList list = mCurrentVideoDetails.mVideoFileMimeType.split("/"); - QString fileExt("."); - if (list.count() == 2) { - fileExt = fileExt + list[1]; - } - // Generate new filename and open the file for writing video data - err = mFilenameGenerator.generateFilename(mNewFileName, fileExt); - if (err == CxeError::None) { - mCurrentFilename = mNewFileName; - } else { - // file name is not valid, re-initialize the value of current string - // back to empty string - mCurrentFilename = QString(""); - } - } + // Start preparing.. + setState(CxeVideoCaptureControl::Preparing); - if (!err && - mVideoRecorder && - !mCurrentFilename.isEmpty()) { - - TPtrC16 fName(reinterpret_cast(mCurrentFilename.utf16())); - CX_DEBUG(( "Next video file path: %s", mCurrentFilename.toAscii().constData() )); - - // read video codec mime type - QByteArray videoCodecData = - mCurrentVideoDetails.mVideoCodecMimeType.toLatin1(); - TPtrC8 videoCodecMimeType(reinterpret_cast - (videoCodecData.constData()), videoCodecData.size()); - - setState(CxeVideoCaptureControl::Preparing); - - TRAPD(openErr, mVideoRecorder->OpenFileL(fName, - mCameraDevice.camera()->Handle(), - mVideoControllerUid, - mVideoFormatUid, - videoCodecMimeType, - audioType(mCurrentVideoDetails.mAudioType))); - - err = CxeErrorHandlingSymbian::map(openErr); - } - if (err) { - // error occured. - deinit(); - emit videoPrepareComplete(err); + // Exception thrown if open fails. + mVideoRecorder->open(mCameraDevice.camera()->Handle(), + mCurrentFilename, + mCurrentVideoDetails.mVideoFileMimeType, + mCurrentVideoDetails.mPreferredSupplier, + mCurrentVideoDetails.mVideoCodecMimeType, + mCurrentVideoDetails.mAudioType); + } catch (const std::exception &e) { + handlePrepareFailed(); + } } CX_DEBUG_EXIT_FUNCTION(); } - /*! -* Prepare Video Recorder with necessary settings for video capture. +* Helper method for generating filename. +* Throws exception, if file type mime is formatted wrong or +* filename generation fails. */ -TFourCC CxeVideoCaptureControlSymbian::audioType(const QString& str) +void CxeVideoCaptureControlSymbian::generateFilename() { CX_DEBUG_ENTER_FUNCTION(); - - QByteArray audioType = str.toAscii(); - - quint8 char1(' '); - quint8 char2(' '); - quint8 char3(' '); - quint8 char4(' '); + mCurrentFilename = QString(""); - if (audioType.count() > 3) { - char1 = audioType[0]; - char2 = audioType[1]; - char3 = audioType[2]; + QStringList list = mCurrentVideoDetails.mVideoFileMimeType.split("/"); + // Throw exception if mime string is formatted wrong. + if (list.count() != 2) { + throw new CxeException(CxeError::General); + } + QString fileExt = "." + list[1]; - if (audioType.count() == 4) { - char4 = audioType[3]; - } - } + // Generate new filename and open the file for writing video data + CxeException::throwIfError(mFilenameGenerator.generateFilename(mCurrentFilename, fileExt)); - return TFourCC(char1, char2, char3, char4); + CX_DEBUG_EXIT_FUNCTION(); } - /*! * Prepare Video Recorder with necessary settings for video capture. */ @@ -371,13 +291,8 @@ return; } - CX_DEBUG(("Video resoulution (%d,%d)", mCurrentVideoDetails.mWidth, - mCurrentVideoDetails.mHeight)); - CX_DEBUG(("Video bitrate = %d)", mCurrentVideoDetails.mVideoBitRate)); - OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_VIDCAPCONT_PREPARE 1"); - TSize frameSize; - frameSize.SetSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); + QSize frameSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); int muteSetting = 0; // audio enabled mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); @@ -390,227 +305,65 @@ frameRate = mCurrentVideoDetails.mVideoFrameRate; } + CX_DEBUG(("Video resolution (%d,%d)", mCurrentVideoDetails.mWidth, + mCurrentVideoDetails.mHeight)); + CX_DEBUG(("Video bitrate = %d)", mCurrentVideoDetails.mVideoBitRate)); CX_DEBUG(("Video frame rate = %d)", frameRate)); - TRAPD(err, - { - mVideoRecorder->SetVideoFrameSizeL(frameSize); - mVideoRecorder->SetVideoFrameRateL(frameRate); - mVideoRecorder->SetVideoBitRateL(mCurrentVideoDetails.mVideoBitRate); - mVideoRecorder->SetAudioEnabledL(muteSetting == 0); - // "No limit" value is handled in video recorder wrapper. - mVideoRecorder->SetMaxClipSizeL(mCurrentVideoDetails.mMaximumSizeInBytes); - } - ); + try { + mVideoRecorder->setVideoFrameSize(frameSize); + mVideoRecorder->setVideoFrameRate(frameRate); + mVideoRecorder->setVideoBitRate(mCurrentVideoDetails.mVideoBitRate); + mVideoRecorder->setAudioEnabled(muteSetting == 0); + // "No limit" value is handled in video recorder wrapper. + mVideoRecorder->setVideoMaxSize(mCurrentVideoDetails.mMaximumSizeInBytes); + + // Settings have been applied successfully, start to prepare. + mVideoRecorder->prepare(); - if (!err) { - // settings have been applied successfully, start to prepare - mVideoRecorder->Prepare(); - // prepare snapshot - err = prepareVideoSnapshot(); + // Prepare snapshot. Snapshot control throws error if problems. + QSize snapshotSize = mSnapshotControl.calculateSnapshotSize( + mViewfinderControl.deviceDisplayResolution(), + QSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight)); + mSnapshotControl.start(snapshotSize); + + // Prepare zoom only when there are no errors during prepare. + emit prepareZoomForVideo(); + emit videoPrepareComplete(CxeError::None); + } catch (const std::exception &e) { + // Handle error. + handlePrepareFailed(); } - if (!err) { - // prepare zoom only when there are no errors during prepare. - emit prepareZoomForVideo(); - } - // emit video prepare status - emit videoPrepareComplete(CxeErrorHandlingSymbian::map(err)); - OstTrace0(camerax_performance, DUP1_CXEVIDEOCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_VIDCAPCONT_PREPARE 0"); - CX_DEBUG_EXIT_FUNCTION(); } - - /*! -Fetches video qualites details based on video quality setting. -Returns CxeError codes if any. +* Fetches video qualites details based on video quality setting. */ -CxeError::Id +void CxeVideoCaptureControlSymbian::getVideoQualityDetails(CxeVideoDetails &videoInfo) { CX_DEBUG_ENTER_FUNCTION(); - int videoQuality = 0; - CxeError::Id err = CxeError::None; - - if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) { - err = mSettings.get(CxeSettingIds::VIDEO_QUALITY, videoQuality); - - bool validQuality = (videoQuality >= 0 && - videoQuality < mIcmSupportedVideoResolutions.count()); - if (err == CxeError::None && validQuality) { - // get video quality details - videoInfo = mIcmSupportedVideoResolutions.at(videoQuality); - } else { - // not valid video quality - err = CxeError::NotFound; - } - } else { - // get secondary camera video quality index - if (mIcmSupportedVideoResolutions.count() > 0) { - videoInfo = mIcmSupportedVideoResolutions.at(videoQuality); - } else { - // not valid video quality - err = CxeError::NotFound; - } - } - - CX_DEBUG_EXIT_FUNCTION(); - - return err; -} - + int quality(0); -/**! - Prepare snapshot - Returns symbian error code. - */ -int CxeVideoCaptureControlSymbian::prepareVideoSnapshot() -{ - CX_DEBUG_ENTER_FUNCTION(); - - CCamera::CCameraSnapshot *cameraSnapshot = mCameraDevice.cameraSnapshot(); - CX_ASSERT_ALWAYS(cameraSnapshot); - - int err = KErrNone; - // Whether or not we have postcapture on, we need the snapshot for Thumbnail Manager. - if (cameraSnapshot) { - // Cancel active snapshot - cameraSnapshot->StopSnapshot(); - - // Prepare snapshot - CCamera::TFormat snapFormat = CCamera::EFormatFbsBitmapColor16MU; - TRAP(err, cameraSnapshot->PrepareSnapshotL(snapFormat, - getSnapshotSize(), - KMaintainAspectRatio)); - CX_DEBUG(("PrepareSnapshotL done, err=%d", err)); - // Start snapshot if no errors encountered. - if (err == KErrNone) { - CX_DEBUG(("Start video snapshot")); - cameraSnapshot->StartSnapshot(); - } - } else { - // No snapshot interface available. Report error. - // Assert above takes care of this, but keeping this as an option. - err = KErrNotReady; + // Get quality index for primary camera. Only one quality for secondary camera. + if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) { + CxeException::throwIfError(mSettings.get(CxeSettingIds::VIDEO_QUALITY, quality)); } - CX_DEBUG_EXIT_FUNCTION(); - - return err; -} - - - -/*! -* Returns snapshot size. Snapshot size is calculated based on the -* display resolution and current video aspect ratio. -*/ -TSize CxeVideoCaptureControlSymbian::getSnapshotSize() const -{ - CX_DEBUG_ENTER_FUNCTION(); - - TSize snapshotSize; - - QSize deviceResolution = mViewfinderControl.deviceDisplayResolution(); - QSize size = QSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); - - // scale according to aspect ratio. - size.scale(deviceResolution.width(), - deviceResolution.height(), - Qt::KeepAspectRatio); - CX_DEBUG(("Video Snapshot size, (%d,%d)", size.width(), size.height())); - snapshotSize.SetSize(size.width(), deviceResolution.height()); - - CX_DEBUG_EXIT_FUNCTION(); - - return snapshotSize; -} - - - -/**! -* Camera events coming from ecam. -*/ -void CxeVideoCaptureControlSymbian::handleCameraEvent(int eventUid, int error) -{ - CX_DEBUG_ENTER_FUNCTION(); - if (eventUid == KUidECamEventSnapshotUidValue) { - handleSnapshotEvent(CxeErrorHandlingSymbian::map(error)); - } - CX_DEBUG_EXIT_FUNCTION(); -} - - -/*! -* Handle Snapshot event from ecam -*/ -void CxeVideoCaptureControlSymbian::handleSnapshotEvent(CxeError::Id error) -{ - CX_DEBUG_ENTER_FUNCTION(); - - if (state() == Idle) { - // we ignore this event, when we are not in active state(s) - CX_DEBUG(( "wrong state, ignoring snapshot" )); - CX_DEBUG_EXIT_FUNCTION(); - return; + if (quality < 0 || quality >= mIcmSupportedVideoResolutions.count()) { + throw new CxeException(CxeError::NotFound); } - if (error) { - mSnapshot = QPixmap(); - emit snapshotReady(error, mSnapshot, filename()); - return; - } - - RArray snapList; - MCameraBuffer* buffer(NULL); - // Note: Cleanup not required in this function - CFbsBitmap *snapshot = NULL; - TRAPD(snapErr, - buffer = &mCameraDevice.cameraSnapshot()->SnapshotDataL(snapList)); - if (!snapErr) { - TInt firstImageIndex = snapList.Find(0); - snapList.Close(); - TRAP(snapErr, snapshot = &(buffer->BitmapL(firstImageIndex))); - } - if (!snapErr) { - TSize size = snapshot->SizeInPixels(); - TInt sizeInWords = size.iHeight * CFbsBitmap::ScanLineLength(size.iWidth, EColor16MU) - / sizeof(TUint32); - - TUint32 *snapshotData = NULL; - snapshotData = new TUint32[sizeInWords]; - - if (snapshotData) { - // Convert to QImage - snapshot->LockHeap(); - TUint32* dataPtr = snapshot->DataAddress(); - memcpy(snapshotData, dataPtr, sizeof(TUint32) * sizeInWords); - snapshot->UnlockHeap(); - - - QImage *img = new QImage((uchar*) snapshotData, size.iWidth, size.iHeight, - CFbsBitmap::ScanLineLength(size.iWidth, EColor16MU), - QImage::Format_RGB32); - - mSnapshot = QPixmap::fromImage(*img); - delete [] snapshotData; - delete img; - } - } - if (buffer) { - buffer->Release(); - } - // Snapshot ready - emit snapshotReady(CxeErrorHandlingSymbian::map(snapErr), mSnapshot, filename()); + // get video quality details + videoInfo = mIcmSupportedVideoResolutions.at(quality); CX_DEBUG_EXIT_FUNCTION(); } - /*! * Resets the video snapshot and current video filename */ @@ -627,7 +380,6 @@ CX_DEBUG_EXIT_FUNCTION(); } - /*! * Returns current video filename */ @@ -639,7 +391,6 @@ return mCurrentFilename; } - /*! * Returns current video snapshot */ @@ -648,7 +399,6 @@ return mSnapshot; } - /*! * Starts video recording if we are in appropriate state. */ @@ -666,30 +416,23 @@ CX_DEBUG_EXIT_FUNCTION(); } - /*! * Pauses video recording. */ void CxeVideoCaptureControlSymbian::pause() { CX_DEBUG_ENTER_FUNCTION(); - - setState(CxeVideoCaptureControl::Paused); - TRAPD(pauseErr, mVideoRecorder->PauseL()); - // play the sound, but not changing the state - mVideoStopSoundPlayer->play(); - if (pauseErr) { - CX_DEBUG(("[WARNING] Error %d pausing!", pauseErr)); - //pause operation failed, report it - emit videoComposed(CxeErrorHandlingSymbian::map(pauseErr), filename()); - // release resources. - deinit(); + try { + mVideoRecorder->pause(); + setState(CxeVideoCaptureControl::Paused); + // play the sound, but not changing the state + mVideoStopSoundPlayer->play(); + } catch (const std::exception &e) { + handleComposeFailed(qt_symbian_exception2Error(e)); } - CX_DEBUG_EXIT_FUNCTION(); } - /*! * Stops video recording. */ @@ -701,35 +444,30 @@ // first stop viewfinder mViewfinderControl.stop(); - TInt asyncStopErr = mVideoRecorder->CustomCommandSync( - TMMFMessageDestination(KCamCControllerImplementationUid, - KMMFObjectHandleController), - ECamCControllerCCVideoStopAsync, - KNullDesC8, - KNullDesC8 ); - CX_DEBUG(("ECamCControllerCCVideoStopAsync sent, err=%d", asyncStopErr)); - if (asyncStopErr) { // fall back to synchronous stop - TInt syncStopErr = mVideoRecorder->Stop(); - if (syncStopErr) { - // error during stop operation, release resources - emit videoComposed(CxeErrorHandlingSymbian::map(asyncStopErr), filename()); - deinit(); - } else { - // stop operation went fine, set back the state to Initialized. + try { + // Try asynchronous stopping first. + mVideoRecorder->stop(true); + // No error from asynchronous stop -> wait for stop event + setState(Stopping); + } catch (const std::exception &e) { + CX_DEBUG(("CxeVideoCaptureControlSymbian - async stop failed, try sync..")); + try { + mVideoRecorder->stop(false); + // stop operation went fine, set back the state to Initialized. setState(Initialized); + // must increment counter now since no callback is coming in sync stop mFilenameGenerator.raiseCounterValue(); + } catch (const std::exception &e) { + // Even synchronous stopping failed -> release resources. + CX_DEBUG(("CxeVideoCaptureControlSymbian - sync stop failed, too!")); + handleComposeFailed(qt_symbian_exception2Error(e)); } - } else { - // No error from asynch stop custom command... wait for stop event - setState(Stopping); - mFilenameGenerator.raiseCounterValue(); } } CX_DEBUG_EXIT_FUNCTION(); } - /*! * Callback when "Open" operation is complete. */ @@ -739,20 +477,16 @@ CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoOpenComplete, err=%d", aError)); if (state() == Preparing) { - if (aError != KErrNone) { - deinit(); - CxeError::Id err = CxeErrorHandlingSymbian::map(KErrNotReady); - // report error to interested parties - emit videoPrepareComplete(CxeErrorHandlingSymbian::map(err)); + if (!aError) { + prepare(); } else { - prepare(); + handlePrepareFailed(); } } CX_DEBUG_EXIT_FUNCTION(); } - /*! * Callback when "Prepare" request is complete. */ @@ -767,17 +501,13 @@ mViewfinderControl.start(); OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_GOTOVIDEO, "msg: e_CX_GO_TO_VIDEO_MODE 0" ); } else { - deinit(); - // report error to interested parties - CxeError::Id err = CxeErrorHandlingSymbian::map(KErrNotReady); - emit videoPrepareComplete(CxeErrorHandlingSymbian::map(err)); + handlePrepareFailed(); } } CX_DEBUG_EXIT_FUNCTION(); } - /*! * Callback when "Record" operation is complete. */ @@ -799,14 +529,12 @@ } else { // error during recording, report to client - deinit(); - emit videoComposed(CxeErrorHandlingSymbian::map(aError), filename()); + handleComposeFailed(aError); } CX_DEBUG_EXIT_FUNCTION(); } - /*! * Callback from MVideoRecorderUtilityObserver */ @@ -824,11 +552,9 @@ // stop operation went fine, set back the state to intialized. setState(Initialized); } + mFilenameGenerator.raiseCounterValue(); // video file has composed, everything went well, inform the client emit videoComposed(CxeError::None, filename()); - // revert back the new filename to empty string, since recording - // is complete and we need to generate a new file name - mNewFileName = QString(""); } else { CX_DEBUG(("ignoring unknown MvruoEvent 0x%08x", aEvent.iEventType.iUid )); } @@ -836,85 +562,6 @@ CX_DEBUG_EXIT_FUNCTION(); } - -/*! -Get corresponding controller for video capture. -@param aMimeType denotes videofile mimetype, -@param aPreferredSupplier denotes supplier. -Returns CxeError::Id if any. -*/ -CxeError::Id -CxeVideoCaptureControlSymbian::findVideoController(const TDesC8& aMimeType, - const TDesC& aSupplier) -{ - CX_DEBUG_ENTER_FUNCTION(); - - CX_DEBUG(("video file mime type : %s", &aMimeType)); - CX_DEBUG(("supplier name: %s", &aSupplier)); - - mVideoControllerUid.iUid = 0; - mVideoFormatUid.iUid = 0; - - // Retrieve a list of possible controllers from ECOM. - // Controller must support recording the requested mime type. - // Controller must be provided by preferred supplier. - - CMMFControllerPluginSelectionParameters* cSelect(NULL); - CMMFFormatSelectionParameters* fSelect(NULL); - RMMFControllerImplInfoArray controllers; - - TRAPD(err, cSelect = CMMFControllerPluginSelectionParameters::NewL()); - if (err) { - return CxeErrorHandlingSymbian::map(err); - } - - TRAP(err, fSelect = CMMFFormatSelectionParameters::NewL()); - if (err) { - if(cSelect) { - delete cSelect; - } - return CxeErrorHandlingSymbian::map(err); - } - - TRAP( err, { - fSelect->SetMatchToMimeTypeL(aMimeType); - cSelect->SetRequiredRecordFormatSupportL(*fSelect); - cSelect->SetPreferredSupplierL(aSupplier, - CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); - cSelect->ListImplementationsL(controllers); - } ); - - if (!err && controllers.Count() >= 1) { - // KErrNotFound is returned unless a controller is found - err = KErrNotFound; - // Get the controller UID. - mVideoControllerUid = controllers[0]->Uid(); - - // Inquires the controller about supported formats. - // We use the first controller found having index 0. - RMMFFormatImplInfoArray formats; - formats = controllers[0]->RecordFormats(); - - // Get the first format that supports our mime type. - int count = formats.Count(); - for (int i=0; iSupportsMimeType(aMimeType)) { - mVideoFormatUid = formats[i]->Uid(); // set the UID - err = KErrNone; - break; - } - } - } - delete cSelect; - delete fSelect; - controllers.ResetAndDestroy(); - - CX_DEBUG_EXIT_FUNCTION(); - - return CxeErrorHandlingSymbian::map(err); -} - - /*! * camera reference changing, release resources */ @@ -935,19 +582,24 @@ CX_DEBUG_EXIT_FUNCTION(); } - /*! -* new camera available, +* new camera available */ void CxeVideoCaptureControlSymbian::handleCameraAllocated(CxeError::Id error) { CX_DEBUG_ENTER_FUNCTION(); if (!error) { - // initialize the video recorder utility - createVideoRecorder(); + try { + // Create the video recorder utility + createVideoRecorder(); + } catch (...) { + // We are just trying to create the recorder early. + // Retry later when preparing, and fail then if + // error still persists. + } // new camera available, read supported video qualities from icm - // load all still qualities supported by icm + // load all video qualities supported by icm mIcmSupportedVideoResolutions.clear(); Cxe::CameraIndex cameraIndex = mCameraDeviceControl.cameraIndex(); // get list of supported image qualities based on camera index @@ -958,34 +610,21 @@ CX_DEBUG_EXIT_FUNCTION(); } - /*! * Initializes video recorder. +* May throw exception. */ void CxeVideoCaptureControlSymbian::createVideoRecorder() { CX_DEBUG_ENTER_FUNCTION(); - - // init video recoder - if (state() == CxeVideoCaptureControl::Idle) { - if (mVideoRecorder == NULL) { - TRAPD(initErr, mVideoRecorder = - new CxeVideoRecorderUtilitySymbian( *this , - KAudioPriorityVideoRecording, - TMdaPriorityPreference( KAudioPrefVideoRecording ))); - if (initErr) { - CX_DEBUG(("WARNING - VideoRecorderUtility could not be reserved. Failed with err:%d", initErr)); - mVideoRecorder = NULL; - } - } + if (mVideoRecorder == NULL) { + mVideoRecorder = new CxeVideoRecorderUtilitySymbian(*this); } - CX_DEBUG_EXIT_FUNCTION(); } - /*! -* releases resources used by videocapture +* releases resources used by video capture control */ void CxeVideoCaptureControlSymbian::releaseResources() { @@ -1013,18 +652,16 @@ CX_DEBUG_EXIT_FUNCTION(); } - /*! -Returns current state of videocapture +* Returns current state of video capture control */ CxeVideoCaptureControl::State CxeVideoCaptureControlSymbian::state() const { return static_cast (stateId()); } - /*! -* slot called when state is changed. +* Called when state is changed. */ void CxeVideoCaptureControlSymbian::handleStateChanged(int newStateId, CxeError::Id error) { @@ -1047,7 +684,6 @@ emit stateChanged(static_cast (newStateId), error); } - /*! * Initialize states for videocapturecontrol */ @@ -1066,7 +702,6 @@ setInitialState(Idle); } - /*! * Updates remaining video recordng time counter to all the video qualities supported by ICM * this should be done whenever storage location setting changes and when values are @@ -1078,7 +713,7 @@ for( int index = 0; index < mIcmSupportedVideoResolutions.count(); index++) { CxeVideoDetails &qualityDetails = mIcmSupportedVideoResolutions[index]; - calculateRemainingTime(qualityDetails, qualityDetails.mRemainingTime); + qualityDetails.mRemainingTime = calculateRemainingTime(qualityDetails); } CX_DEBUG_EXIT_FUNCTION(); @@ -1093,14 +728,12 @@ if (state() == CxeVideoCaptureControl::Recording || state() == CxeVideoCaptureControl::Paused) { - TTimeIntervalMicroSeconds remaining = 0; - remaining = mVideoRecorder->RecordTimeAvailable(); - time = remaining.Int64() * 1.0 / KOneSecond; - CX_DEBUG(( "timeRemaining2: %d", time )); + time = mVideoRecorder->availableRecordingTime(); + CX_DEBUG(("CxeVideoCaptureControlSymbian - time remaining: %d", time)); } else { // Check if we need to recalculate the remaining time. if (mCurrentVideoDetails.mRemainingTime == CxeVideoDetails::UNKNOWN) { - calculateRemainingTime(mCurrentVideoDetails, mCurrentVideoDetails.mRemainingTime); + mCurrentVideoDetails.mRemainingTime = calculateRemainingTime(mCurrentVideoDetails); } time = mCurrentVideoDetails.mRemainingTime; } @@ -1108,99 +741,41 @@ CX_DEBUG_EXIT_FUNCTION(); } - - /*! -* algorithm to calculate remaining recording time -@ param videoDetails contains the current video resolution that is in use. -@ time contains the remaining recording time +* Get the remaining recording time +* @param videoDetails Contains the current video resolution that is in use. +* @return The remaining recording time */ -void CxeVideoCaptureControlSymbian::calculateRemainingTime(CxeVideoDetails videoDetails, int &time) +int CxeVideoCaptureControlSymbian::calculateRemainingTime(const CxeVideoDetails& videoDetails) { CX_DEBUG_ENTER_FUNCTION(); - - TTimeIntervalMicroSeconds remaining = 0; - - // get available space in the drive selected in the settings - // for storing videos - qint64 availableSpace = mDiskMonitor.free(); - - availableSpace = availableSpace - KMinRequiredSpaceVideo; - - // Maximum clip size may be limited for mms quality. - // If mMaximumSizeInBytes == 0, no limit is specified. - if (videoDetails.mMaximumSizeInBytes > 0 && videoDetails.mMaximumSizeInBytes < availableSpace) { - availableSpace = videoDetails.mMaximumSizeInBytes; - } - - // Use average audio/video bitrates to estimate remaining time - quint32 averageBitRate = 0; - quint32 averageByteRate = 0; - qreal scaler = mQualityPresets.avgVideoBitRateScaler(); - - if (scaler == 0) { - // video bit rate scaler is 0, use the constant value - scaler = KCMRAvgVideoBitRateScaler; - } - - int avgVideoBitRate = (videoDetails.mVideoBitRate * scaler); - int avgAudioBitRate = videoDetails.mAudioBitRate; - - int muteSetting = 0; // audio enabled - mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); - - if (muteSetting == 1) { - // audio disabled from setting. hence no audio - avgAudioBitRate = 0; - } - - averageBitRate = (quint32)( - (avgVideoBitRate + avgAudioBitRate) * KMetaDataCoeff); - - averageByteRate = averageBitRate / 8; - - if (availableSpace <= 0) { - remaining = 0; - } else { - // converting microseconds to seconds - remaining = availableSpace * KOneMillion / averageByteRate; - if ( (remaining.Int64()) > (quint64(KCamCMaxClipDurationInSecs) * KOneMillion) ) { - remaining = (quint64(KCamCMaxClipDurationInSecs) * KOneMillion); - } - } - if ( remaining <= quint64(0) ) { - remaining = 0; - } - - time = remaining.Int64() * 1.0 / KOneSecond; - - CX_DEBUG(( "remaining time from algorithm: %d", time )); - + qint64 availableSpace = mDiskMonitor.free() - KMinRequiredSpaceVideo; + int time = mQualityPresets.recordingTimeAvailable(videoDetails, availableSpace); CX_DEBUG_EXIT_FUNCTION(); + return time; } - /*! -* Calculates remaining recording time during video recording +* Calculates elapsed recording time during video recording +* @return Did fetching elapsed time succeed. */ bool CxeVideoCaptureControlSymbian::elapsedTime(int &time) { CX_DEBUG_ENTER_FUNCTION(); - TTimeIntervalMicroSeconds timeElapsed = 0; bool ok = false; if (state() == CxeVideoCaptureControl::Recording || state() == CxeVideoCaptureControl::Paused) { - TRAPD( err, timeElapsed = mVideoRecorder->DurationL() ); - if (!err) { - time = timeElapsed.Int64() * 1.0 / KOneSecond; - CX_DEBUG(("timeElapsed2: %d", time)); + try { + time = mVideoRecorder->duration(); + CX_DEBUG(("CxeVideoCaptureControlSymbian - elapsed: %d", time)); ok = true; + } catch (const std::exception &e) { + // Returning false. } } CX_DEBUG_EXIT_FUNCTION(); - return ok; } @@ -1214,8 +789,7 @@ // start recording, if we were playing capture sound if (state() == CxeVideoCaptureControl::PlayingStartSound) { setState(CxeVideoCaptureControl::Recording); - - mVideoRecorder->Record(); + mVideoRecorder->record(); } // in case of video capture stop sound playing, nothing needs to be done @@ -1224,6 +798,23 @@ CX_DEBUG_EXIT_FUNCTION(); } +/*! +* Handle new snapshot. +* @param status Status code for getting the snapshot. +* @param snapshot Snapshot pixmap. Empty if error code reported. +*/ +void CxeVideoCaptureControlSymbian::handleSnapshotReady(CxeError::Id status, const QPixmap& snapshot) +{ + CX_DEBUG_ENTER_FUNCTION(); + + if (mCameraDeviceControl.mode() == Cxe::VideoMode) { + // Need to store snapshot for ui to be able to get it also later. + mSnapshot = snapshot; + emit snapshotReady(status, snapshot, filename()); + } + + CX_DEBUG_EXIT_FUNCTION(); +} /*! * setting has changed, check if we are interested. @@ -1247,7 +838,7 @@ // mute setting changed, apply the new setting and re-prepare. setState(Preparing); prepare(); - } else if (settingId == CxeSettingIds::FRAME_RATE){ + } else if (settingId == CxeSettingIds::FRAME_RATE) { // Frame rate setting changed. Need to re-prepare if we are prepared already. // Otherwise can wait for next init call. if (state() == Ready) { @@ -1268,6 +859,7 @@ */ void CxeVideoCaptureControlSymbian::handleSceneChanged(CxeScene& scene) { + Q_UNUSED(scene) CX_DEBUG_ENTER_FUNCTION(); // make sure we are in video mode @@ -1293,8 +885,7 @@ // Ignore updates on preparing phase. if (state() == CxeVideoCaptureControl::Ready) { - int time(0); - calculateRemainingTime(mCurrentVideoDetails, time); + int time(calculateRemainingTime(mCurrentVideoDetails)); if (time != mCurrentVideoDetails.mRemainingTime) { mCurrentVideoDetails.mRemainingTime = time; @@ -1316,4 +907,32 @@ return mIcmSupportedVideoResolutions; } +/*! +* Helper method to handle error during preparing phase. +*/ +void CxeVideoCaptureControlSymbian::handlePrepareFailed() +{ + CX_DEBUG_ENTER_FUNCTION(); + CX_DEBUG(("[ERROR] Preparing video failed!")); + // Cleanup + deinit(); + // Inform client + emit videoPrepareComplete(CxeError::InitializationFailed); + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Helper method to handle error from video composing. +* @param error Symbian error code. +*/ +void CxeVideoCaptureControlSymbian::handleComposeFailed(int error) +{ + CX_DEBUG_ENTER_FUNCTION(); + CX_DEBUG(("[ERROR] Composing video failed!")); + // Inform client + emit videoComposed(CxeErrorHandlingSymbian::map(error), filename()); + // Cleanup + deinit(); + CX_DEBUG_EXIT_FUNCTION(); +} // End of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/src/cxevideorecorderutilitysymbian.cpp --- a/camerauis/cameraxui/cxengine/src/cxevideorecorderutilitysymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/src/cxevideorecorderutilitysymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -17,6 +17,22 @@ #include "cxevideorecorderutilitysymbian.h" #include "cxenamespace.h" #include "cxutils.h" +#include + +namespace +{ + // Controller UId, can be used by the client to identify the controller, e.g. if the custom command can be used + const TUid KCamCControllerImplementationUid = {0x101F8503}; + + // Custom command for setting a new filename without closing & reopening the controller + enum TCamCControllerCustomCommands + { + ECamCControllerCCNewFilename = 0, + ECamCControllerCCVideoStopAsync + }; + + const uint KOneMillion = 1000000; +} CxeVideoRecorderUtilitySymbian::~CxeVideoRecorderUtilitySymbian() @@ -27,121 +43,296 @@ CX_DEBUG_EXIT_FUNCTION(); } -CxeVideoRecorderUtilitySymbian::CxeVideoRecorderUtilitySymbian(MVideoRecorderUtilityObserver& aObserver, - TInt aPriority, - TMdaPriorityPreference aPref) +CxeVideoRecorderUtilitySymbian::CxeVideoRecorderUtilitySymbian(MVideoRecorderUtilityObserver& aObserver) { CX_DEBUG_ENTER_FUNCTION(); - TRAPD(initErr, mVideoRecorder = CVideoRecorderUtility::NewL(aObserver, aPriority, aPref)); - mStartuperror = initErr; + QT_TRAP_THROWING(mVideoRecorder = + CVideoRecorderUtility::NewL(aObserver, + KAudioPriorityVideoRecording, + TMdaPriorityPreference(KAudioPrefVideoRecording))); CX_DEBUG_EXIT_FUNCTION(); } -TInt CxeVideoRecorderUtilitySymbian::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, - TInt aFunction, - const TDesC8& aDataTo1, - const TDesC8& aDataTo2) -{ - CX_DEBUG_IN_FUNCTION(); - return mVideoRecorder->CustomCommandSync(aDestination, aFunction, aDataTo1, aDataTo2); -} - -void CxeVideoRecorderUtilitySymbian::OpenFileL(const TDesC& aFileName, - TInt aCameraHandle, - TUid aControllerUid, - TUid aVideoFormat, - const TDesC8& aVideoType, - TFourCC aAudioType) +/*! +* Open new file for recording. +* @param cameraHandle Handle for camera. +* @param filename Full filename of the video file to open. +* @param fileMimeType MIME type for the video file. +* @param supplier Preferred supplier. +* @param videoType Video codec MIME type. +* @param audioType Audio FourCC type. +*/ +void CxeVideoRecorderUtilitySymbian::open(int cameraHandle, + const QString &filename, + const QString &fileMimeType, + const QString &supplier, + const QString &videoType, + const QString &audioType) { CX_DEBUG_ENTER_FUNCTION(); - mVideoRecorder->OpenFileL(aFileName, aCameraHandle, aControllerUid, aVideoFormat, aVideoType, aAudioType); + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - filename [%s]", filename.toAscii().constData())); + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - file mime [%s]", fileMimeType.toAscii().constData())); + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - supplier [%s]", supplier.toAscii().constData())); + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - codec mime [%s]", videoType.toAscii().constData())); + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - audio FourCC [%s]", audioType.toAscii().constData())); + + QByteArray bytes = videoType.toLatin1(); + TPtrC8 videoTypeDesC(reinterpret_cast(bytes.constData()), bytes.size()); + TPtrC16 filenameDesC(reinterpret_cast(filename.utf16())); + + TUid controllerId; + TUid formatId; + QT_TRAP_THROWING({ + // Find the video controller id and video format id. + findControllerL(fileMimeType, supplier, controllerId, formatId); + + // Try to open new video file with given parameters. + mVideoRecorder->OpenFileL(filenameDesC, cameraHandle, controllerId, + formatId, videoTypeDesC, audioFourCC(audioType)); + }); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::SetVideoFrameSizeL(TSize aSize) +/*! +* Set frame size. +* @param size The video frame size. +*/ +void CxeVideoRecorderUtilitySymbian::setVideoFrameSize(const QSize &size) { CX_DEBUG_ENTER_FUNCTION(); - mVideoRecorder->SetVideoFrameSizeL(aSize); + TSize frameSize(size.width(), size.height()); + QT_TRAP_THROWING(mVideoRecorder->SetVideoFrameSizeL(frameSize)); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::SetVideoFrameRateL(TInt aRate) +/*! +* Set video frame rate. +* @param rate The video frame rate. +*/ +void CxeVideoRecorderUtilitySymbian::setVideoFrameRate(int rate) { CX_DEBUG_ENTER_FUNCTION(); - mVideoRecorder->SetVideoFrameRateL(aRate); + QT_TRAP_THROWING(mVideoRecorder->SetVideoFrameRateL(rate)); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::SetVideoBitRateL(TInt aRate) +/*! +* Set video bit rate. +* @param The video bit rate. +*/ +void CxeVideoRecorderUtilitySymbian::setVideoBitRate(int rate) { CX_DEBUG_ENTER_FUNCTION(); - mVideoRecorder->SetVideoBitRateL(aRate); + QT_TRAP_THROWING(mVideoRecorder->SetVideoBitRateL(rate)); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::SetAudioEnabledL(TBool aEnable) +/*! +* Set if audio recording is on or not. +* @param enabled Is audio recording enabled. +*/ +void CxeVideoRecorderUtilitySymbian::setAudioEnabled(bool enabled) { CX_DEBUG_ENTER_FUNCTION(); - mVideoRecorder->SetAudioEnabledL(aEnable); + QT_TRAP_THROWING(mVideoRecorder->SetAudioEnabledL(enabled)); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::SetMaxClipSizeL(TInt aClipSizeInBytes) +/*! +* Set maximum video clip size in bytes. +* @param sizeInBytes Video clip size limit. +*/ +void CxeVideoRecorderUtilitySymbian::setVideoMaxSize(int sizeInBytes) { CX_DEBUG_ENTER_FUNCTION(); - if (aClipSizeInBytes <= 0) { - aClipSizeInBytes = KMMFNoMaxClipSize; + if (sizeInBytes <= 0) { + sizeInBytes = KMMFNoMaxClipSize; } - mVideoRecorder->SetMaxClipSizeL(aClipSizeInBytes); + QT_TRAP_THROWING(mVideoRecorder->SetMaxClipSizeL(sizeInBytes)); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::Close() +/*! +* Close video recorder, freeing its resources. +*/ +void CxeVideoRecorderUtilitySymbian::close() { CX_DEBUG_ENTER_FUNCTION(); mVideoRecorder->Close(); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::Prepare() +/*! +* Prepare for video recording. +*/ +void CxeVideoRecorderUtilitySymbian::prepare() { CX_DEBUG_ENTER_FUNCTION(); mVideoRecorder->Prepare(); CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::Record() +/*! +* Start recording. +*/ +void CxeVideoRecorderUtilitySymbian::record() { CX_DEBUG_ENTER_FUNCTION(); mVideoRecorder->Record(); CX_DEBUG_EXIT_FUNCTION(); } -int CxeVideoRecorderUtilitySymbian::Stop() +/*! +* Stop recording. +* @param asynchronous Use asynchronous (true) or synchronous (false) stopping. +*/ +void CxeVideoRecorderUtilitySymbian::stop(bool asynchronous) { - CX_DEBUG_IN_FUNCTION(); - return mVideoRecorder->Stop(); + CX_DEBUG_ENTER_FUNCTION(); + + if (asynchronous) { + TMMFMessageDestination dest(KCamCControllerImplementationUid, KMMFObjectHandleController); + qt_symbian_throwIfError(mVideoRecorder->CustomCommandSync( + dest, ECamCControllerCCVideoStopAsync, KNullDesC8, KNullDesC8)); + } else { + qt_symbian_throwIfError(mVideoRecorder->Stop()); + } + CX_DEBUG_EXIT_FUNCTION(); } -void CxeVideoRecorderUtilitySymbian::PauseL() +/*! +* Pause recording. +*/ +void CxeVideoRecorderUtilitySymbian::pause() { CX_DEBUG_ENTER_FUNCTION(); - mVideoRecorder->PauseL(); + QT_TRAP_THROWING(mVideoRecorder->PauseL()); CX_DEBUG_EXIT_FUNCTION(); } -TTimeIntervalMicroSeconds CxeVideoRecorderUtilitySymbian::RecordTimeAvailable() +/*! +* Get estimated available recording time. +* @return Available recording time estimate in seconds. +*/ +int CxeVideoRecorderUtilitySymbian::availableRecordingTime() { CX_DEBUG_IN_FUNCTION(); - return mVideoRecorder->RecordTimeAvailable(); + // Convert microseconds to seconds. + return mVideoRecorder->RecordTimeAvailable().Int64() * 1.0 / KOneMillion; +} + +/*! +* Get elapsed duration of the recorded video. +* @return Duration of the video in seconds. +*/ +int CxeVideoRecorderUtilitySymbian::duration() +{ + CX_DEBUG_ENTER_FUNCTION(); + int time(0); + // Convert microseconds to seconds. + QT_TRAP_THROWING(time = mVideoRecorder->DurationL().Int64() * 1.0 / KOneMillion); + CX_DEBUG_EXIT_FUNCTION(); + return time; } -TTimeIntervalMicroSeconds CxeVideoRecorderUtilitySymbian::DurationL() +/*! +* Find video controller and format UIDs based on file mime type and preferred supplier. +* @param fileMimeType MIME type for the video file. +* @param supplier Preferred supplier. +* @param controllerId Returns found controller UID. +* @param formatId Returns found format UID. +*/ +void CxeVideoRecorderUtilitySymbian::findControllerL(const QString& fileMimeType, + const QString& supplier, + TUid& controllerId, + TUid& formatId) { - CX_DEBUG_IN_FUNCTION(); - return mVideoRecorder->DurationL(); + CX_DEBUG_ENTER_FUNCTION(); + + // Retrieve a list of possible controllers from ECOM. + // Controller must support recording the requested mime type. + // Controller must be provided by preferred supplier. + controllerId = KNullUid; + formatId = KNullUid; + + QByteArray bytes = fileMimeType.toLatin1(); + TPtrC8 mimeTPtr(reinterpret_cast(bytes.constData()), bytes.size()); + TPtrC16 supplierTPtr(reinterpret_cast(supplier.utf16())); + + CMMFControllerPluginSelectionParameters* cSelect(NULL); + CMMFFormatSelectionParameters* fSelect(NULL); + RMMFControllerImplInfoArray controllers; + + cSelect = CMMFControllerPluginSelectionParameters::NewLC(); + fSelect = CMMFFormatSelectionParameters::NewLC(); + + fSelect->SetMatchToMimeTypeL(mimeTPtr); + cSelect->SetRequiredRecordFormatSupportL(*fSelect); + cSelect->SetPreferredSupplierL(supplierTPtr, + CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned); + cSelect->ListImplementationsL(controllers); + CleanupResetAndDestroyPushL(controllers); + + if (controllers.Count() <= 0) { + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - zero controllers found, leaving!")); + User::Leave(KErrNotFound); + } + + // Inquires the controller about supported formats. + // We use the first controller found having index 0. + const RMMFFormatImplInfoArray& formats = controllers[0]->RecordFormats(); + + // Get the first format that supports our mime type. + int count(formats.Count()); + for (int i=0; iSupportsMimeType(mimeTPtr)) { + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - found controller")); + // Store the format UID + formatId = formats[i]->Uid(); + // Store the controller UID + controllerId = controllers[0]->Uid(); + break; + } + } + + // Check that we found the uids. + if (controllerId == KNullUid) { + CX_DEBUG(("CxeVideoRecorderUtilitySymbian - no matching controller found, leaving!")); + User::Leave(KErrNotFound); + } + + CleanupStack::PopAndDestroy(3); // controllers, fSelect, cSelect + CX_DEBUG_EXIT_FUNCTION(); +} + +/*! +* Helper method to convert QString to TFourCC. +* @param str String to convert. +*/ +TFourCC CxeVideoRecorderUtilitySymbian::audioFourCC(const QString& str) +{ + CX_DEBUG_ENTER_FUNCTION(); + + QByteArray audioType = str.toAscii(); + + quint8 char1(' '); + quint8 char2(' '); + quint8 char3(' '); + quint8 char4(' '); + + if (audioType.count() > 3) { + char1 = audioType[0]; + char2 = audioType[1]; + char3 = audioType[2]; + + if (audioType.count() == 4) { + char4 = audioType[3]; + } + } + + CX_DEBUG_EXIT_FUNCTION(); + return TFourCC(char1, char2, char3, char4); } - // end of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.cpp --- a/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -35,7 +35,7 @@ CX_DEBUG_IN_FUNCTION(); } -CxeError::Id CxeFakeAutoFocusControl::start() +CxeError::Id CxeFakeAutoFocusControl::start(bool soundEnabled) { CX_DEBUG_IN_FUNCTION(); return CxeError::None; @@ -64,6 +64,11 @@ return true; } +bool CxeFakeAutoFocusControl::isSoundEnabled() const +{ + return true; +} + CxeAutoFocusControl::State CxeFakeAutoFocusControl::state() const { return static_cast(stateId()); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.h --- a/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakeautofocuscontrol.h Thu Jul 15 01:44:30 2010 +0300 @@ -32,12 +32,13 @@ CxeFakeAutoFocusControl(); virtual ~CxeFakeAutoFocusControl(); - CxeError::Id start(); + CxeError::Id start(bool soundEnabled = true); void cancel(); void setMode(CxeAutoFocusControl::Mode newMode); CxeAutoFocusControl::Mode mode() const; CxeAutoFocusControl::State state() const; bool supported() const; + bool isSoundEnabled() const; public: // methods for testing void setFakeState(CxeAutoFocusControl::State); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakequalitypresets.cpp --- a/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakequalitypresets.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakequalitypresets.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -47,9 +47,15 @@ return list; } -qreal CxeFakeQualityPresets::avgVideoBitRateScaler() +int CxeFakeQualityPresets::recordingTimeAvailable(const CxeVideoDetails& details, qint64 space) { - return 1.0; + int time(0); + if (details.mMaximumSizeInBytes > 0 && details.mMaximumSizeInBytes < space) { + time = details.mMaximumSizeInBytes / 1000; // 1 kB/s + } else { + time = space / 1000; + } + return time; } CxeImageDetails CxeFakeQualityPresets::fakeImageDetails() diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakequalitypresets.h --- a/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakequalitypresets.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakequalitypresets.h Thu Jul 15 01:44:30 2010 +0300 @@ -28,7 +28,7 @@ virtual ~CxeFakeQualityPresets(); QList imageQualityPresets(Cxe::CameraIndex cameraId); QList videoQualityPresets(Cxe::CameraIndex cameraId); - qreal avgVideoBitRateScaler(); + int recordingTimeAvailable(const CxeVideoDetails& details, qint64 space); public: static CxeImageDetails fakeImageDetails(); static CxeVideoDetails fakeVideoDetails(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideorecorderutility.cpp --- a/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideorecorderutility.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideorecorderutility.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -35,104 +35,86 @@ : mObserver( &aObserver ) { CX_DEBUG_IN_FUNCTION(); - //return new (ELeave) CxeFakeVideoRecorderUtility(aObserver); } -/*CxeVideoRecorderUtility* CxeFakeVideoRecorderUtility::NewL(MVideoRecorderUtilityObserver& aObserver, - TInt aPriority, - TMdaPriorityPreference aPref) -{ - CX_DEBUG_IN_FUNCTION(); - return new (ELeave) CxeFakeVideoRecorderUtility(aObserver); -}*/ - -TInt CxeFakeVideoRecorderUtility::CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, - TInt aFunction, - const TDesC8& aDataTo1, - const TDesC8& aDataTo2) -{ - CX_DEBUG_IN_FUNCTION(); - return KErrNone; -} - -void CxeFakeVideoRecorderUtility::OpenFileL(const TDesC& aFileName, - TInt aCameraHandle, - TUid aControllerUid, - TUid aVideoFormat, - const TDesC8& aVideoType, - TFourCC aAudioType) +void CxeFakeVideoRecorderUtility::open(int cameraHandle, + const QString &/*filename*/, + const QString &/*fileMimeType*/, + const QString &/*supplier*/, + const QString &/*videoType*/, + const QString &/*audioType*/) { CX_DEBUG_ENTER_FUNCTION(); mObserver->MvruoOpenComplete(KErrNone); CX_DEBUG_EXIT_FUNCTION(); } -void CxeFakeVideoRecorderUtility::SetVideoFrameSizeL(TSize aSize) +void CxeFakeVideoRecorderUtility::setVideoFrameSize(const QSize &/*size*/) { CX_DEBUG_IN_FUNCTION(); } -void CxeFakeVideoRecorderUtility::SetVideoFrameRateL(TInt aRate) +void CxeFakeVideoRecorderUtility::setVideoFrameRate(int rate) { CX_DEBUG_IN_FUNCTION(); } -void CxeFakeVideoRecorderUtility::SetVideoBitRateL(TInt aRate) +void CxeFakeVideoRecorderUtility::setVideoBitRate(int rate) { CX_DEBUG_IN_FUNCTION(); } -void CxeFakeVideoRecorderUtility::SetAudioEnabledL(TBool aEnable) +void CxeFakeVideoRecorderUtility::setAudioEnabled(bool enabled) { CX_DEBUG_IN_FUNCTION(); } -void CxeFakeVideoRecorderUtility::SetMaxClipSizeL(TInt aClipSizeInBytes) +void CxeFakeVideoRecorderUtility::setVideoMaxSize(int sizeInBytes) { CX_DEBUG_IN_FUNCTION(); } -void CxeFakeVideoRecorderUtility::Close() +void CxeFakeVideoRecorderUtility::close() { CX_DEBUG_IN_FUNCTION(); } -void CxeFakeVideoRecorderUtility::Prepare() +void CxeFakeVideoRecorderUtility::prepare() { CX_DEBUG_ENTER_FUNCTION(); mObserver->MvruoPrepareComplete(KErrNone); CX_DEBUG_EXIT_FUNCTION(); } -void CxeFakeVideoRecorderUtility::Record() +void CxeFakeVideoRecorderUtility::record() { CX_DEBUG_IN_FUNCTION(); } -int CxeFakeVideoRecorderUtility::Stop() +void CxeFakeVideoRecorderUtility::stop(bool asynchronous) { - CX_DEBUG_IN_FUNCTION(); + CX_DEBUG_ENTER_FUNCTION(); mObserver->MvruoRecordComplete(KErrNone); - return KErrNone; + CX_DEBUG_EXIT_FUNCTION(); } -void CxeFakeVideoRecorderUtility::PauseL() +void CxeFakeVideoRecorderUtility::pause() { CX_DEBUG_IN_FUNCTION(); } -TTimeIntervalMicroSeconds CxeFakeVideoRecorderUtility::RecordTimeAvailable() +int CxeFakeVideoRecorderUtility::availableRecordingTime() { CX_DEBUG_IN_FUNCTION(); // 100 s - return TTimeIntervalMicroSeconds(100000000); + return 100; } -TTimeIntervalMicroSeconds CxeFakeVideoRecorderUtility::DurationL() +int CxeFakeVideoRecorderUtility::duration() { CX_DEBUG_IN_FUNCTION(); // 10 s - return TTimeIntervalMicroSeconds(10000000); + return 10; } diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideorecorderutility.h --- a/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideorecorderutility.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/fakeclasses/cxefakevideorecorderutility.h Thu Jul 15 01:44:30 2010 +0300 @@ -29,32 +29,25 @@ TMdaPriorityPreference aPref=EMdaPriorityPreferenceTimeAndQuality); ~CxeFakeVideoRecorderUtility(); + virtual void open(int cameraHandle, + const QString &filename, + const QString &fileMimeType, + const QString &supplier, + const QString &videoType, + const QString &audioType); + virtual void setVideoFrameSize(const QSize& size); + virtual void setVideoFrameRate(int rate); + virtual void setVideoBitRate(int rate); + virtual void setAudioEnabled(bool enabled); + virtual void setVideoMaxSize(int sizeInBytes); + virtual void close(); + virtual void prepare(); + virtual void record(); + virtual void stop(bool asynchronous = false); + virtual void pause(); + virtual int availableRecordingTime(); + virtual int duration(); - //CxeVideoRecorderUtility* NewL(MVideoRecorderUtilityObserver& aObserver, - // TInt aPriority=EMdaPriorityNormal, - // TMdaPriorityPreference aPref=EMdaPriorityPreferenceTimeAndQuality); - TInt CustomCommandSync(const TMMFMessageDestinationPckg& aDestination, - TInt aFunction, - const TDesC8& aDataTo1, - const TDesC8& aDataTo2); - void OpenFileL(const TDesC& aFileName, - TInt aCameraHandle, - TUid aControllerUid, - TUid aVideoFormat, - const TDesC8& aVideoType = KNullDesC8, - TFourCC aAudioType = KMMFFourCCCodeNULL); - void SetVideoFrameSizeL(TSize aSize); - void SetVideoFrameRateL(TInt aRate); - void SetVideoBitRateL(TInt aRate); - void SetAudioEnabledL(TBool aEnable); - void SetMaxClipSizeL(TInt aClipSizeInBytes); - void Close(); - void Prepare(); - void Record(); - int Stop(); - void PauseL(); - TTimeIntervalMicroSeconds RecordTimeAvailable(); - TTimeIntervalMicroSeconds DurationL(); private: CxeFakeVideoRecorderUtility(MVideoRecorderUtilityObserver& aObserver); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/cxeunitrunner/cxetestrunner.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/cxeunitrunner/cxetestrunner.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/cxeunitrunner/cxetestrunner.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -66,6 +66,7 @@ << "unittest_cxethumbnailmanagersymbian" << "unittest_cxeharvestercontrolsymbian" << "unittest_cxesettingscontrolsymbian" + << "unittest_cxesnapshotcontrol" << "unittest_cxeenginesymbian"; QDir dir; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unit.pro --- a/camerauis/cameraxui/cxengine/tsrc/unit/unit.pro Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unit.pro Thu Jul 15 01:44:30 2010 +0300 @@ -42,6 +42,7 @@ unittest_cxequalitypresetssymbian \ unittest_cxethumbnailmanagersymbian \ unittest_cxeharvestercontrolsymbian \ - unittest_cxesettingscontrolsymbian + unittest_cxesettingscontrolsymbian \ + unittest_cxesnapshotcontrol CONFIG *= ordered diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/cxeenginesymbianunit.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/cxeenginesymbianunit.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/cxeenginesymbianunit.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -27,15 +27,18 @@ #include "cxefakesensoreventhandler.h" #include "cxefakefilenamegenerator.h" #include "cxutils.h" +#include "cxefakesettingsmodel.h" // Member Functions CxeEngineSymbianUnit::CxeEngineSymbianUnit() { + CX_DEBUG_IN_FUNCTION(); } CxeEngineSymbianUnit::~CxeEngineSymbianUnit() { + CX_DEBUG_IN_FUNCTION(); } @@ -67,6 +70,10 @@ mVideoCaptureControl = new CxeFakeVideoCaptureControl(); + mSettingsModel = new CxeFakeSettingsModel(); + + mFeatureManager = new CxeFakeFeatureManager(); + } CX_DEBUG_EXIT_FUNCTION(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/cxeenginesymbianunit.h --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/cxeenginesymbianunit.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/cxeenginesymbianunit.h Thu Jul 15 01:44:30 2010 +0300 @@ -27,6 +27,7 @@ CxeEngineSymbianUnit(); virtual ~CxeEngineSymbianUnit(); +protected: void createControls(); }; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/unittest_cxeenginesymbian.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/unittest_cxeenginesymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/unittest_cxeenginesymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -42,6 +42,7 @@ delete mEngine; mEngine = NULL; mEngine = new CxeEngineSymbianUnit(); + mEngine->construct(); mEngine->initMode(Cxe::ImageMode); mCameraDeviceControl = qobject_cast( diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/unittest_cxeenginesymbian.pro --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/unittest_cxeenginesymbian.pro Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxeenginesymbian/unittest_cxeenginesymbian.pro Thu Jul 15 01:44:30 2010 +0300 @@ -102,7 +102,10 @@ cxediskmonitor.cpp \ cxediskmonitorprivate.cpp \ cxememorymonitor.cpp \ - cxememorymonitorprivate.cpp + cxememorymonitorprivate.cpp \ + cxesnapshotcontrol.cpp \ + cxesnapshotcontrolprivate.cpp \ + cxefakesettingsmodel.cpp @@ -174,4 +177,7 @@ cxediskmonitor.h \ cxediskmonitorprivate.h \ cxememorymonitor.h \ - cxememorymonitorprivate.h + cxememorymonitorprivate.h \ + cxesnapshotcontrol.h \ + cxesnapshotcontrolprivate.h \ + cxefakesettingsmodel.h diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxequalitypresetssymbian/unittest_cxequalitypresetssymbian.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxequalitypresetssymbian/unittest_cxequalitypresetssymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxequalitypresetssymbian/unittest_cxequalitypresetssymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -95,6 +95,40 @@ CX_DEBUG_EXIT_FUNCTION(); } + +void UnitTestCxeQualityPresetsSymbian::testRecordingTimeAvailable() +{ + CX_DEBUG_ENTER_FUNCTION(); + + int time(0); + + CxeVideoDetails details; + details.mAudioBitRate = 100; + details.mVideoBitRate = 100; + + // Check zero time when disk full. + time = mQualityPresets->recordingTimeAvailable(details, qint64(0)); + QVERIFY(time == 0); + + // Common time limit is 90 minutes + time = mQualityPresets->recordingTimeAvailable(details, qint64(1000*1000*1000)); + QVERIFY(time == 5400); + + // Normal case, no quality specific limit + time = mQualityPresets->recordingTimeAvailable(details, qint64(1000*1000)); + QVERIFY(time > 0); + QVERIFY(time < 5400); + + // Normal case, quality specifies limit + details.mMaximumSizeInBytes = 10*1000; + time = mQualityPresets->recordingTimeAvailable(details, qint64(1000*1000)); + QVERIFY(time > 0); + QVERIFY(time < 5400); + + CX_DEBUG_EXIT_FUNCTION(); +} + + // main() function non-GUI testing QTEST_MAIN(UnitTestCxeQualityPresetsSymbian); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxequalitypresetssymbian/unittest_cxequalitypresetssymbian.h --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxequalitypresetssymbian/unittest_cxequalitypresetssymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxequalitypresetssymbian/unittest_cxequalitypresetssymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -39,6 +39,7 @@ void testImageQualityPresets(); void testVideoQualityPresets(); + void testRecordingTimeAvailable(); private: //data members diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxesnapshotcontrol/unittest_cxesnapshotcontrol.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxesnapshotcontrol/unittest_cxesnapshotcontrol.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: + * + */ +#include +#include +#include +#include + +#include "cxefakecameradevice.h" +#include "cxefakecameradevicecontrol.h" +#include "cxeerror.h" +#include "cxetestutils.h" +#include "cxesnapshotcontrol.h" +#include "cxesnapshotcontrolprivate.h" +#include "unittest_cxesnapshotcontrol.h" + + +UnitTestCxeSnapshotControl::UnitTestCxeSnapshotControl() + : mSnapshotControl(NULL), + mCameraDevice(NULL), + mCameraDeviceControl(NULL) +{ +} + +UnitTestCxeSnapshotControl::~UnitTestCxeSnapshotControl() +{ + cleanup(); +} + + +void UnitTestCxeSnapshotControl::init() +{ + CX_DEBUG_ENTER_FUNCTION(); + + mCameraDeviceControl = new CxeFakeCameraDeviceControl; + mCameraDevice = new CxeFakeCameraDevice; + mCameraDevice->newCamera(Cxe::PrimaryCameraIndex, mCameraDeviceControl); + mCameraDeviceControl->setState(CxeCameraDeviceControl::Ready); + + mSnapshotControl = new CxeSnapshotControl(*mCameraDevice); + + CX_DEBUG_EXIT_FUNCTION(); +} + +void UnitTestCxeSnapshotControl::cleanup() +{ + delete mSnapshotControl; + mSnapshotControl = NULL; + + delete mCameraDevice; + mCameraDevice = NULL; + + delete mCameraDeviceControl; + mCameraDeviceControl = NULL; +} + +void UnitTestCxeSnapshotControl::testState() +{ + CX_DEBUG_ENTER_FUNCTION(); + + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Idle); + + CX_DEBUG_EXIT_FUNCTION(); +} + +void UnitTestCxeSnapshotControl::testCalculateSnapshotSize() +{ + CX_DEBUG_ENTER_FUNCTION(); + + QSize snapshotSize; + QSize displaySize; + QSize captureResolution; + + // 16:9 display, 4:3 capture format + displaySize = QSize(1600, 900); + captureResolution = QSize(400, 300); + snapshotSize = mSnapshotControl->calculateSnapshotSize(displaySize, captureResolution); + QVERIFY(snapshotSize == QSize(1200, 900)); + + // 16:9 display, 16:9 capture format + displaySize = QSize(640, 360); + captureResolution = QSize(4000, 2248); + snapshotSize = mSnapshotControl->calculateSnapshotSize(displaySize, captureResolution); + QVERIFY(snapshotSize == QSize(640, 360)); + + + // 4:3 display, 16:9 capture format + displaySize = QSize(640, 480); + captureResolution = QSize(4000, 2248); + snapshotSize = mSnapshotControl->calculateSnapshotSize(displaySize, captureResolution); + QVERIFY(snapshotSize == QSize(640, 360)); + + // 4:3 display, 4:3 capture format + displaySize = QSize(640, 480); + captureResolution = QSize(2048, 1536); + snapshotSize = mSnapshotControl->calculateSnapshotSize(displaySize, captureResolution); + QVERIFY(snapshotSize == QSize(640, 480)); + + CX_DEBUG_EXIT_FUNCTION(); +} + +void UnitTestCxeSnapshotControl::testStart() +{ + CX_DEBUG_ENTER_FUNCTION(); + + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Idle); + mSnapshotControl->start(QSize(640,360)); + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Active); + + CX_DEBUG_EXIT_FUNCTION(); +} + +void UnitTestCxeSnapshotControl::testStop() +{ + CX_DEBUG_ENTER_FUNCTION(); + + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Idle); + mSnapshotControl->stop(); + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Idle); + mSnapshotControl->start(QSize(640,360)); + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Active); + mSnapshotControl->stop(); + QVERIFY(mSnapshotControl->state() == CxeSnapshotControl::Idle); + + CX_DEBUG_EXIT_FUNCTION(); +} + +void UnitTestCxeSnapshotControl::testHandleCameraEvent() +{ + CX_DEBUG_ENTER_FUNCTION(); + + QSignalSpy spySnapshotReady(mSnapshotControl, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&))); + + // Snapshot not started, camera events should not effect in any way. + mSnapshotControl->handleCameraEvent(KUidECamEventSnapshotUidValue, KErrNone); + QVERIFY(!CxeTestUtils::waitForSignal(spySnapshotReady, 1000)); + + // After starting we are supposed to get the snapshotReady signal. + mSnapshotControl->start(QSize(640,360)); + mSnapshotControl->handleCameraEvent(KUidECamEventSnapshotUidValue, KErrNone); + QVERIFY(CxeTestUtils::waitForSignal(spySnapshotReady, 1000)); + + CX_DEBUG_EXIT_FUNCTION(); +} + +QTEST_MAIN(UnitTestCxeSnapshotControl); + +// end of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxesnapshotcontrol/unittest_cxesnapshotcontrol.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxesnapshotcontrol/unittest_cxesnapshotcontrol.h Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#ifndef UNITTEST_CXESNAPSHOTCONTROL_H +#define UNITTEST_CXESNAPSHOTCONTROL_H + +#include + +class CxeSnapshotControl; +class CxeFakeCameraDevice; +class CxeFakeCameraDeviceControl; + +class UnitTestCxeSnapshotControl : public QObject +{ + Q_OBJECT + +public: + + UnitTestCxeSnapshotControl(); + virtual ~UnitTestCxeSnapshotControl(); + +private slots: + + void init(); + void cleanup(); + + void testState(); + void testCalculateSnapshotSize(); + void testStart(); + void testStop(); + void testHandleCameraEvent(); + +private: + + CxeSnapshotControl *mSnapshotControl; + CxeFakeCameraDevice *mCameraDevice; + CxeFakeCameraDeviceControl *mCameraDeviceControl; +}; + +#endif /* UNITTEST_CXESNAPSHOTCONTROL_H */ diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxesnapshotcontrol/unittest_cxesnapshotcontrol.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxesnapshotcontrol/unittest_cxesnapshotcontrol.pro Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,48 @@ +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# Initial Contributors: +# Nokia Corporation - initial contribution. +# Contributors: +# Description: + +DEFINES *= CXE_USE_DUMMY_CAMERA + +include(../unittest.pri) + +TARGET = unittest_cxesnapshotcontrol + +LIBS *= -lecamsnapshot +LIBS *= -lecamadvsettings +LIBS *= -lecam +LIBS *= -lecampluginsupport +LIBS *= -lfbscli +LIBS *= -lbitgdi + +SOURCES *= unittest_cxesnapshotcontrol.cpp +SOURCES *= cxesnapshotcontrol.cpp +SOURCES *= cxesnapshotcontrolprivate.cpp +SOURCES *= cxedummycamera.cpp +SOURCES *= cxecameradevice.cpp +SOURCES *= cxefakecameradevice.cpp +SOURCES *= cxefakecameradevicecontrol.cpp +SOURCES *= cxeerrormappingsymbian.cpp +SOURCES *= cxestate.cpp +SOURCES *= cxestatemachine.cpp +SOURCES *= cxestatemachinebase.cpp + +HEADERS *= unittest_cxesnapshotcontrol.h +HEADERS *= cxesnapshotcontrol.h +HEADERS *= cxesnapshotcontrolprivate.h +HEADERS *= cxedummycamera.h +HEADERS *= cxecameradevice.h +HEADERS *= cxefakecameradevice.h +HEADERS *= cxecameradevicecontrol.h +HEADERS *= cxefakecameradevicecontrol.h +HEADERS *= cxeerrormappingsymbian.h +HEADERS *= cxestate.h +HEADERS *= cxestatemachine.h +HEADERS *= cxestatemachinebase.h diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -26,6 +26,7 @@ #include "cxestillcapturecontrolsymbian.h" #include "unittest_cxestillcapturecontrolsymbian.h" #include "cxefakeviewfindercontrol.h" +#include "cxesnapshotcontrol.h" #include "cxesettingsmodel.h" #include "cxesensoreventhandlersymbian.h" #include "cxefilenamegeneratorsymbian.h" @@ -64,20 +65,21 @@ mFakeCameraDeviceControl = new CxeFakeCameraDeviceControl(); mFakeCameraDevice = new CxeFakeCameraDevice(); mFakeCameraDevice->newCamera(mFakeCameraDeviceControl->cameraIndex(), mFakeCameraDeviceControl); - mViewfinderControl = new CxeFakeViewfinderControl(); + mSnapshotControl = new CxeSnapshotControl(*mFakeCameraDevice); mFilenameGenerator = new CxeFakeFilenameGenerator(); mSensorEventHandler = new CxeFakeSensorEventHandler(); mFakeAutoFocusControl = new CxeFakeAutoFocusControl(); mFakeQualityPresets = new CxeFakeQualityPresets(); mFakeFileSaveThread = new CxeFakeFileSaveThread(); - + mDiskMonitor = new CxeDiskMonitor(*mFakeSettings); mStillCaptureControl = new CxeStillCaptureControlSymbian( *mFakeCameraDevice, *mViewfinderControl, + *mSnapshotControl, *mFakeCameraDeviceControl, *mFilenameGenerator, *mSensorEventHandler, @@ -106,6 +108,8 @@ mFilenameGenerator = 0; delete mViewfinderControl; mViewfinderControl = 0; + delete mSnapshotControl; + mSnapshotControl = 0; delete mFakeCameraDeviceControl; mFakeCameraDeviceControl = 0; delete mFakeCameraDevice; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.h --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -26,6 +26,7 @@ class CxeFakeCameraDeviceControl; class CxeStillCaptureControlSymbian; class CxeFakeViewfinderControl; +class CxeSnapshotControl; class CxeFakeFilenameGenerator; class CxeFilenameGenerator; class CxeFakeSensorEventHandler; @@ -68,6 +69,7 @@ CxeFakeCameraDeviceControl *mFakeCameraDeviceControl; CxeFakeCameraDevice *mFakeCameraDevice; CxeFakeViewfinderControl *mViewfinderControl; + CxeSnapshotControl *mSnapshotControl; CxeFakeFilenameGenerator *mFilenameGenerator; CxeFakeSensorEventHandler *mSensorEventHandler; CxeStillCaptureControlSymbian *mStillCaptureControl; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.pro --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.pro Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxestillcapturecontrolsymbian/unittest_cxestillcapturecontrolsymbian.pro Thu Jul 15 01:44:30 2010 +0300 @@ -68,6 +68,8 @@ cxefilesavethread.cpp \ cxediskmonitor.cpp \ cxediskmonitorprivate.cpp \ + cxesnapshotcontrol.cpp \ + cxesnapshotcontrolprivate.cpp \ cxefakefilesavethread.cpp HEADERS *= unittest_cxestillcapturecontrolsymbian.h \ @@ -116,4 +118,6 @@ cxefilesavethread.h \ cxediskmonitor.h \ cxediskmonitorprivate.h \ + cxesnapshotcontrol.h \ + cxesnapshotcontrolprivate.h \ cxequalitypresets.h diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/cxevideocapturecontrolsymbianunit.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/cxevideocapturecontrolsymbianunit.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/cxevideocapturecontrolsymbianunit.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -23,15 +23,16 @@ #include "cxutils.h" #include "cxediskmonitor.h" -CxeVideoCaptureControlSymbianUnit::CxeVideoCaptureControlSymbianUnit( +CxeVideoCaptureControlSymbianUnit::CxeVideoCaptureControlSymbianUnit( CxeCameraDevice &cameraDevice, CxeViewfinderControl &viewfinderControl, + CxeSnapshotControl &snapshotControl, CxeCameraDeviceControl &cameraDeviceControl, CxeFilenameGenerator &nameGenerator, CxeSettings &settings, CxeQualityPresets &qualityPresets, CxeDiskMonitor &diskMonitor) - : CxeVideoCaptureControlSymbian(cameraDevice, viewfinderControl, + : CxeVideoCaptureControlSymbian(cameraDevice, viewfinderControl, snapshotControl, cameraDeviceControl, nameGenerator, settings, qualityPresets, diskMonitor) { @@ -50,7 +51,7 @@ // init video recoder if (state() == CxeVideoCaptureControl::Idle) { if (mVideoRecorder == NULL) { - TRAPD(initErr, mVideoRecorder = + TRAPD(initErr, mVideoRecorder = new CxeFakeVideoRecorderUtility( *this , KAudioPriorityVideoRecording, TMdaPriorityPreference( KAudioPrefVideoRecording ))); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/cxevideocapturecontrolsymbianunit.h --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/cxevideocapturecontrolsymbianunit.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/cxevideocapturecontrolsymbianunit.h Thu Jul 15 01:44:30 2010 +0300 @@ -27,13 +27,14 @@ * CxeCameraDeviceControlSymbian except for that CxeFakeCameraDevice is used * instead of the real implementation. */ -class CxeVideoCaptureControlSymbianUnit : public CxeVideoCaptureControlSymbian +class CxeVideoCaptureControlSymbianUnit : public CxeVideoCaptureControlSymbian { Q_OBJECT public: CxeVideoCaptureControlSymbianUnit(CxeCameraDevice &cameraDevice, CxeViewfinderControl &viewfinderControl, + CxeSnapshotControl &snapshotControl, CxeCameraDeviceControl &cameraDeviceControl, CxeFilenameGenerator &nameGenerator, CxeSettings &settings, diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.cpp --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -21,6 +21,7 @@ #include "unittest_cxevideocapturecontrolsymbian.h" #include "cxevideocapturecontrolsymbian.h" #include "cxevideocapturecontrolsymbianunit.h" +#include "cxesnapshotcontrol.h" #include "cxefakefilenamegenerator.h" #include "cxedummycamera.h" #include "cxefakecameradevice.h" @@ -65,6 +66,7 @@ mCameraDeviceControl->setMode(Cxe::VideoMode); mCameraDevice = new CxeFakeCameraDevice(); mViewfinderControl = new CxeFakeViewfinderControl(); + mSnapshotControl = new CxeSnapshotControl(*mCameraDevice); mSettings = new CxeFakeSettings(); mSettings->set(CxeSettingIds::VIDEO_SHOWCAPTURED, -1); mFilenameGeneratorSymbian = new CxeFakeFilenameGenerator(); @@ -73,6 +75,7 @@ mDiskMonitor = new CxeDiskMonitor(*mSettings); mCxeVideoCaptureControlSymbian = new CxeVideoCaptureControlSymbianUnit(*mCameraDevice, *mViewfinderControl, + *mSnapshotControl, *mCameraDeviceControl, *mFilenameGeneratorSymbian, *mSettings, @@ -102,6 +105,8 @@ mFilenameGeneratorSymbian = 0; delete mViewfinderControl; mViewfinderControl = 0; + delete mSnapshotControl; + mSnapshotControl = 0; delete mCameraDeviceControl; mCameraDeviceControl = 0; delete mCameraDevice; @@ -230,21 +235,22 @@ CX_DEBUG_EXIT_FUNCTION(); } -void UnitTestCxeVideoCaptureControlSymbian::testHandleSnapshotEvent() +void UnitTestCxeVideoCaptureControlSymbian::testHandleSnapshotReady() { CX_DEBUG_ENTER_FUNCTION(); + QPixmap snapshot; QSignalSpy spy(mCxeVideoCaptureControlSymbian, SIGNAL(snapshotReady(CxeError::Id, const QPixmap&, const QString&))); mCxeVideoCaptureControlSymbian->deinit(); doPrepareStuff(); - mCxeVideoCaptureControlSymbian->handleSnapshotEvent(CxeError::OutOfMemory); + mCxeVideoCaptureControlSymbian->handleSnapshotReady(CxeError::OutOfMemory, snapshot); QCOMPARE(mCxeVideoCaptureControlSymbian->state(), CxeVideoCaptureControl::Ready); // check that we receive this signal once the snapshot is ready QVERIFY(CxeTestUtils::waitForSignal(spy, 1000)); doPrepareStuff(); - mCxeVideoCaptureControlSymbian->handleSnapshotEvent(CxeError::None); + mCxeVideoCaptureControlSymbian->handleSnapshotReady(CxeError::None, snapshot); QVERIFY(CxeTestUtils::waitForSignal(spy, 1000)); CX_DEBUG_EXIT_FUNCTION(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.h --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.h Thu Jul 15 01:44:30 2010 +0300 @@ -23,6 +23,7 @@ class CxeFakeCameraDevice; class CxeFakeViewfinderControl; +class CxeSnapshotControl; class CxeFakeCameraDeviceControl; class CxeFakeSettings; class CxeFakeFilenameGenerator; @@ -53,7 +54,7 @@ void testReset(); void testFilename(); void testSnapshot(); - void testHandleSnapshotEvent(); + void testHandleSnapshotReady(); void testInit(); void testDeinit(); void testHandleSoundPlayed(); @@ -70,6 +71,7 @@ CxeVideoCaptureControlSymbianUnit *mCxeVideoCaptureControlSymbian; CxeFakeCameraDevice *mCameraDevice; CxeFakeViewfinderControl *mViewfinderControl; + CxeSnapshotControl *mSnapshotControl; CxeFakeCameraDeviceControl *mCameraDeviceControl; CxeFakeSettings *mSettings; CxeFakeFilenameGenerator *mFilenameGeneratorSymbian; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.pro --- a/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.pro Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxengine/tsrc/unit/unittest_cxevideocapturecontrolsymbian/unittest_cxevideocapturecontrolsymbian.pro Thu Jul 15 01:44:30 2010 +0300 @@ -52,6 +52,8 @@ cxefakequalitypresets.cpp \ cxediskmonitor.cpp \ cxediskmonitorprivate.cpp \ + cxesnapshotcontrol.cpp \ + cxesnapshotcontrolprivate.cpp \ cxesysutil.cpp HEADERS *= unittest_cxevideocapturecontrolsymbian.h \ @@ -83,4 +85,6 @@ cxutils.h \ cxediskmonitor.h \ cxediskmonitorprivate.h \ + cxesnapshotcontrol.h \ + cxesnapshotcontrolprivate.h \ cxesysutil.h diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/cxui.pro --- a/camerauis/cameraxui/cxui/cxui.pro Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/cxui.pro Thu Jul 15 01:44:30 2010 +0300 @@ -31,6 +31,12 @@ MMP_RULES += "USERINCLUDE traces" } +# export sound file +symbian { + CXUI_DIR = $$section(PWD,":",1) + BLD_INF_RULES.prj_exports += "$$CXUI_DIR/data/selftimer.wav /epoc32/data/z/system/sounds/digital/selftimer.wav" +} + DEPENDPATH += ../cxengine/inc/api VPATH += src \ inc @@ -45,7 +51,6 @@ -lcxengine \ -lapmime \ -lcommonui \ - -lxqsettingsmanager \ -lxqutils \ -lxqservice \ -lxqserviceutil \ diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/cxui.qrc --- a/camerauis/cameraxui/cxui/cxui.qrc Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/cxui.qrc Thu Jul 15 01:44:30 2010 +0300 @@ -1,5 +1,6 @@ + layouts/cxui.css layouts/setting_scenemode.docml diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/data/selftimer.wav Binary file camerauis/cameraxui/cxui/data/selftimer.wav has changed diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/inc/cxuienums.h --- a/camerauis/cameraxui/cxui/inc/cxuienums.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/inc/cxuienums.h Thu Jul 15 01:44:30 2010 +0300 @@ -92,9 +92,9 @@ static const char *STILL_PRE_CAPTURE_SELFTIMER_CANCEL_BUTTON = "still_selftimer_cancel_button"; static const char *VIDEO_PRE_CAPTURE_VIEW = "video_capture_view"; - + static const char *SETTINGS_DIALOG_OK_ACTION = "action_ok"; - + // video // In order to be able to refer to a widget, we need to know its object name. static const char *VIDEO_PRE_CAPTURE_TOOLBAR = "video_toolbar"; @@ -112,6 +112,7 @@ static const char *VIDEO_PRE_CAPTURE_POST_CAPTURE_ACTION = "cxui_video_action_showcapturedvideo"; static const char *VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_TOP = "video_indicator_container_top"; static const char *VIDEO_PRE_CAPTURE_INDICATOR_CONTAINER_BOTTOM = "video_indicator_container_bottom"; + static const char *VIDEO_PRE_CAPTURE_SCENE_MODE_ACTION = "cxui_video_action_scene"; static const char *VIDEO_PRE_CAPTURE_QUALITY_ICON = "video_quality_indicator"; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/inc/cxuiprecaptureview.h --- a/camerauis/cameraxui/cxui/inc/cxuiprecaptureview.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/inc/cxuiprecaptureview.h Thu Jul 15 01:44:30 2010 +0300 @@ -144,6 +144,7 @@ void addIncreaseDecreaseButtons(CxuiZoomSlider *slider); QString getSettingItemIcon(const QString &key, QVariant value); void updateQualityIcon(); + void updateSceneIcon(const QString& sceneId); void createWidgetBackgroundGraphic(HbWidget *widget, const QString &graphicName, HbFrameDrawer::FrameType frameType = @@ -197,7 +198,7 @@ CxuiSettingSlider *mSettingsSlider; CxuiSettingsInfo *mSettingsInfo; - + HbAction *mSettingsDialogOkAction; HbAction *mSliderSettingsDialogOkAction; }; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/inc/cxuiselftimer.h --- a/camerauis/cameraxui/cxui/inc/cxuiselftimer.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/inc/cxuiselftimer.h Thu Jul 15 01:44:30 2010 +0300 @@ -19,6 +19,7 @@ #include #include +#include class CxeSettings; class CxuiDocumentLoader; @@ -45,17 +46,17 @@ public slots: void changeTimeOut(int seconds); void startTimer(); - void reset(); + void reset(bool update = true); void cancel(); protected slots: void timeout(); private: - void reset(bool update); void updateWidgets(); void showWidgets(); void hideWidgets(); + void playSound(); private: Q_DISABLE_COPY(CxuiSelfTimer) @@ -74,6 +75,7 @@ // settings, not own CxeSettings &mSettings; + QSound mSound; }; #endif // CXUISELFTIMER_H diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/inc/cxuisettingsinfo.h --- a/camerauis/cameraxui/cxui/inc/cxuisettingsinfo.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/inc/cxuisettingsinfo.h Thu Jul 15 01:44:30 2010 +0300 @@ -98,10 +98,11 @@ void getVideoQualitySettings(CxUiSettings::RadioButtonListParams &settings); void handleQualitySettings(const QString &key, CxUiSettings::RadioButtonListParams &settings); -private slots: - void initForCurrentMode(CxeError::Id status); +private: + void checkMode(); private: // data members + int mMode; CxeEngine *mEngine; CxuiSettingXmlReader *mXmlReader; }; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/inc/cxuivideoprecaptureview.h --- a/camerauis/cameraxui/cxui/inc/cxuivideoprecaptureview.h Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/inc/cxuivideoprecaptureview.h Thu Jul 15 01:44:30 2010 +0300 @@ -74,6 +74,7 @@ // from CxuiPrecaptureView virtual void handleSettingValueChanged(const QString& key, QVariant newValue); + void handleSceneChanged(CxeScene &scene); void handleQuitClicked(); protected slots: @@ -82,7 +83,6 @@ void record(); void pause(); void stop(); - void stopAndPrepareNewVideo(); void goToStill(); void showEvent(QShowEvent *event); void handleVideoStateChanged(CxeVideoCaptureControl::State newState, CxeError::Id error); @@ -123,6 +123,7 @@ // from QObject bool eventFilter(QObject *object, QEvent *event); + protected: QTimer mElapsedTimer; int mTimeElapsed; diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/layouts/cxui.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/camerauis/cameraxui/cxui/layouts/cxui.css Thu Jul 15 01:44:30 2010 +0300 @@ -0,0 +1,69 @@ +/* +Mode/setting indicators in still precapture +All HbLabel icons and text inside indicatorContainer +*/ +HbWidget#indicatorContainer > HbLabel::icon +{ +color: var(qtc_popup_trans_normal); +} +HbWidget#indicatorContainer > HbLabel::text +{ +color: var(qtc_popup_trans_normal); +} +/* +Selftimer +All HbLabel text and icons inside still_precapture_selftimer_container +*/ +HbWidget#still_precapture_selftimer_container > HbLabel::icon +{ +color: var(qtc_popup_trans_normal); +} +HbWidget#still_precapture_selftimer_container > HbLabel::text +{ +color: var(qtc_popup_trans_normal); +} +/* +Images left +All HbLabel text and icons inside images_left_container +*/ +HbWidget#images_left_container > HbLabel::text +{ +color: var(qtc_popup_trans_normal); +} +/* +Mode/setting indicators +All HbLabel icons and text inside video_indicator_container_top +*/ +HbWidget#video_indicator_container_top > HbLabel::icon +{ +color: var(qtc_popup_trans_normal); +} +HbWidget#video_indicator_container_top > HbLabel::text +{ +color: var(qtc_popup_trans_normal); +} +/* +Bottom indicators (recording icon, time elapsed & left) +HbLabels defined separately since they should be colored differently +*/ +/* Elapsed time is a special case, it will always be red */ +HbLabel#video_elapsed_time::text +{ +color: red; +} +HbLabel#video_remaining_time::text +{ +color: var(qtc_popup_trans_normal); +} +/* +Zoom sliders +Decrement and increase icons both +*/ +CxuiZoomSlider::decrement-icon +{ +color: var(qtc_popup_trans_normal); +} +CxuiZoomSlider::increment-icon +{ +color: var(qtc_popup_trans_normal); +} diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/layouts/setting_scenemode.docml --- a/camerauis/cameraxui/cxui/layouts/setting_scenemode.docml Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/layouts/setting_scenemode.docml Thu Jul 15 01:44:30 2010 +0300 @@ -15,20 +15,15 @@ - - - - - @@ -40,12 +35,11 @@ - - + @@ -62,6 +56,7 @@ + diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/layouts/setting_slider.docml --- a/camerauis/cameraxui/cxui/layouts/setting_slider.docml Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/layouts/setting_slider.docml Thu Jul 15 01:44:30 2010 +0300 @@ -15,8 +15,9 @@ + - + diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/layouts/view_still_precapture.docml --- a/camerauis/cameraxui/cxui/layouts/view_still_precapture.docml Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/layouts/view_still_precapture.docml Thu Jul 15 01:44:30 2010 +0300 @@ -14,18 +14,9 @@ - - - - - - - - - @@ -33,9 +24,6 @@ - - - @@ -206,12 +194,8 @@ - - - - @@ -220,11 +204,11 @@ - + - +
@@ -235,12 +219,8 @@ - - - -
@@ -250,10 +230,7 @@ - - -
diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/layouts/view_video_precapture.docml --- a/camerauis/cameraxui/cxui/layouts/view_video_precapture.docml Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/layouts/view_video_precapture.docml Thu Jul 15 01:44:30 2010 +0300 @@ -22,9 +22,6 @@ - - - @@ -41,12 +38,6 @@ - - - - - - @@ -211,10 +202,7 @@ - - - @@ -223,7 +211,7 @@ - +
@@ -234,10 +222,7 @@ - - -
@@ -246,10 +231,7 @@ - - -
diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuipostcaptureview.cpp --- a/camerauis/cameraxui/cxui/src/cxuipostcaptureview.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuipostcaptureview.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -476,8 +476,8 @@ // void CxuiPostcaptureView::mousePressEvent(QGraphicsSceneMouseEvent *event) { - //! @todo temporary workaround for title bar mouse event handling bug - if (event->type() == QEvent::GraphicsSceneMousePress && event->scenePos().y() > 70) { + + if (event->type() == QEvent::GraphicsSceneMousePress) { mPostcaptureTimer.stop(); toggleControls(); event->accept(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuiprecaptureview.cpp --- a/camerauis/cameraxui/cxui/src/cxuiprecaptureview.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuiprecaptureview.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -748,6 +748,8 @@ return; } + hideControls(); + QString key = action->property(PROPERTY_KEY_SETTING_ID).toString(); CX_DEBUG(("settingsKey=%s", key.toAscii().constData())); @@ -856,6 +858,8 @@ return; } + hideControls(); + QString key = action->property(PROPERTY_KEY_SETTING_ID).toString(); CX_DEBUG(("settingsKey=%s", key.toAscii().constData())); @@ -1138,4 +1142,41 @@ CX_DEBUG_EXIT_FUNCTION(); } +/*! +* Update the scene mode icon. +* @param sceneId The new scene id. +*/ +void CxuiPrecaptureView::updateSceneIcon(const QString& sceneId) +{ + CX_DEBUG_ENTER_FUNCTION(); + CX_DEBUG(("CxuiPrecaptureView - scene: %s", sceneId.toAscii().constData())); + + // No need to update icon, if widgets are not even loaded yet. + // We'll update the icon once the widgets are loaded. + if (mWidgetsLoaded) { + + QString key; + QString iconObjectName; + if (mEngine->mode() == Cxe::VideoMode) { + key = CxeSettingIds::VIDEO_SCENE; + iconObjectName = VIDEO_PRE_CAPTURE_SCENE_MODE_ACTION; + } else { + key = CxeSettingIds::IMAGE_SCENE; + iconObjectName = STILL_PRE_CAPTURE_SCENE_MODE_ACTION; + } + + QString icon = getSettingItemIcon(key, sceneId); + CX_DEBUG(("CxuiPrecaptureView - icon: %s", icon.toAscii().constData())); + + if (mDocumentLoader) { + QObject *obj = mDocumentLoader->findObject(iconObjectName); + CX_DEBUG_ASSERT(obj); + qobject_cast(obj)->setIcon(HbIcon(icon)); + } + } else { + CX_DEBUG(("CxuiPrecaptureView - widgets not loaded yet, ignored!")); + } + CX_DEBUG_EXIT_FUNCTION(); +} + // end of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuiselftimer.cpp --- a/camerauis/cameraxui/cxui/src/cxuiselftimer.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuiselftimer.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -37,9 +37,12 @@ */ // constants + const int CONTINUOUS_POSTCAPTURE = -1; const int UNKNOWN = -99; +const static QString SELFTIMER_SOUND = "z:\\system\\sounds\\digital\\selftimer.wav"; + CxuiSelfTimer::CxuiSelfTimer(CxeSettings &settings) : mDelay(-1), mCounter(0), @@ -49,7 +52,8 @@ mTimerLabel(NULL), mCancelButton(NULL), mStartButton(NULL), - mSettings(settings) + mSettings(settings), + mSound(SELFTIMER_SOUND) { CX_DEBUG_ENTER_FUNCTION(); @@ -173,9 +177,13 @@ // so the UI seems to update smoother. updateWidgets(); + playSound(); + // Check if timer ran out if (mCounter >= mDelay) { mTimer.stop(); + mSound.stop(); + hideWidgets(); emit timerFinished(); } @@ -183,14 +191,32 @@ } /*! - Slot for resetting the selftimer countdown. Countdown is stopped, - and set back to starting value. Start button is set enabled. - + * Play selftimer sound. */ -void CxuiSelfTimer::reset() +void CxuiSelfTimer::playSound() { CX_DEBUG_ENTER_FUNCTION(); - reset(true); + + int timeLeft = mDelay - mCounter; + + if (timeLeft <= 3) { + // play as fast as we can + if (mSound.isFinished()) { + mSound.setLoops(-1); + mSound.play(); + } + } else if (timeLeft <= 10) { + // play every second + mSound.setLoops(1); + mSound.play(); + } else { + // play once every two seconds + if (mCounter%2) { + mSound.setLoops(1); + mSound.play(); + } + } + CX_DEBUG_EXIT_FUNCTION(); } @@ -221,6 +247,7 @@ // start countdown mCounter = 0; + playSound(); mTimer.start(1000); // 1000 milliseconds == 1 second CX_DEBUG_EXIT_FUNCTION(); @@ -262,6 +289,7 @@ { // Stop timer and reset counter. mTimer.stop(); + mSound.stop(); mCounter = 0; // Set start buttonback to enabled. diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuisettingradiobuttonlist.cpp --- a/camerauis/cameraxui/cxui/src/cxuisettingradiobuttonlist.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuisettingradiobuttonlist.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -107,6 +107,8 @@ CX_DEBUG_ENTER_FUNCTION(); initOriginalSelectedItem(); + // ensure that currently selected item is visible + scrollTo(currentIndex()); QGraphicsWidget::showEvent(event); CX_DEBUG_EXIT_FUNCTION(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuisettingsinfo.cpp --- a/camerauis/cameraxui/cxui/src/cxuisettingsinfo.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuisettingsinfo.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -83,21 +83,12 @@ * CxuiSettingsInfo::CxuiSettingsInfo */ CxuiSettingsInfo::CxuiSettingsInfo(CxeEngine *engine) -: mEngine(engine) + : mMode(-1), mEngine(engine) { CX_DEBUG_ENTER_FUNCTION(); CX_ASSERT_ALWAYS(engine); mXmlReader = new CxuiSettingXmlReader(); - - // Initialize for the mode already so that the UI - // can already use the settings info even if engine isn't ready yet. - initForCurrentMode(CxeError::None); - - // Follow engine mode changes - connect(&engine->cameraDeviceControl(), SIGNAL(initModeComplete(CxeError::Id)), - this, SLOT(initForCurrentMode(CxeError::Id))); - CX_DEBUG_EXIT_FUNCTION(); } @@ -125,6 +116,9 @@ { CX_DEBUG_ENTER_FUNCTION(); + // Check that right content is loaded. Load now if not. + checkMode(); + bool found(false); if (key == CxeSettingIds::IMAGE_QUALITY || @@ -154,6 +148,9 @@ { CX_DEBUG_ENTER_FUNCTION(); + // Check that right content is loaded. Load now if not. + checkMode(); + bool found(false); if (mXmlReader) { @@ -326,23 +323,33 @@ CX_DEBUG_EXIT_FUNCTION(); } -/** -* Load new setting content based on the new mode. +/*! +* Check that the right content for current mode is loaded. +* +* UI gets "settings changed" / "scene changed" events quite +* early when switching mode (image / video). We cannot rely +* on CxeCameraDeviceControl::initModeComplete signal since +* that would be coming too late. (We would be using setting XML +* for the old mode, and setting keys/values/icons would not +* be found.) Better check this whenever UI requests for +* content for a setting, and reload the XML when needed. +* @see CxuiSettingsInfo::getSettingsContent(const QString &, RadioButtonListParams &) +* @see CxuiSettingsInfo::getSettingsContent(const QString &, SliderParams &) +* @see CxeCameraDeviceControl::initModeComplete(CxeError::Id) */ -void CxuiSettingsInfo::initForCurrentMode(CxeError::Id status) +void CxuiSettingsInfo::checkMode() { CX_DEBUG_ENTER_FUNCTION(); - if (status == CxeError::None) { + int oldMode = mMode; + mMode = mEngine->cameraDeviceControl().mode(); + if (mMode != oldMode) { // Select the setting XML file based on mode. QString sourceXml(mEngine->cameraDeviceControl().mode() == Cxe::ImageMode ? CxUiSettings::IMAGE_SETTING_MAPPING_FILE : CxUiSettings::VIDEO_SETTING_MAPPING_FILE); mXmlReader->setXmlSource(sourceXml); - } else { - // Clear XML reader content on error. - mXmlReader->setXmlSource(QString()); } CX_DEBUG_EXIT_FUNCTION(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuistillprecaptureview.cpp --- a/camerauis/cameraxui/cxui/src/cxuistillprecaptureview.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuistillprecaptureview.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -240,22 +240,23 @@ } - // update toolbar flash icon + // Setting widgets loaded here so updating icons works. + mWidgetsLoaded = true; + + // Update toolbar flash mode icon int flash; if (mEngine->settings().get(CxeSettingIds::FLASH_MODE, flash) == CxeError::None) { handleSettingValueChanged(CxeSettingIds::FLASH_MODE, flash); } - // update toolbar scene mode - QString scene; - if (mEngine->settings().get(CxeSettingIds::IMAGE_SCENE, scene) == CxeError::None) { - handleSettingValueChanged(CxeSettingIds::IMAGE_SCENE, scene); + // Update toolbar scene mode icon + QString sceneId; + if (mEngine->settings().get(CxeSettingIds::SCENE_ID, sceneId) == CxeError::None) { + updateSceneIcon(sceneId); } hideControls(); - mWidgetsLoaded = true; - OstTrace0( camerax_performance, DUP1_CXUISTILLPRECAPTUREVIEW_LOADWIDGETS, "msg: e_CX_STILLPRECAPTUREVIEW_LOADWIDGETS 0" ); CX_DEBUG_EXIT_FUNCTION(); } @@ -271,31 +272,31 @@ // Initialize settings grid mSettingsGrid = new HbToolBarExtension; - action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure.svg"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::EV_COMPENSATION_VALUE); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_mono_iso.svg"), hbTrId("txt_cam_button_iso"), this, SLOT(launchSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_iso"), hbTrId("txt_cam_button_iso"), this, SLOT(launchSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::LIGHT_SENSITIVITY); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb.svg"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::COLOR_TONE); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance.svg"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::WHITE_BALANCE); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_mono_sharpness.svg"), hbTrId("txt_cam_grid_sharpness"), this, SLOT(launchSliderSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_sharpness"), hbTrId("txt_cam_grid_sharpness"), this, SLOT(launchSliderSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::SHARPNESS); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_mono_contrast.svg"), hbTrId("txt_cam_button_contrast"), this, SLOT(launchSliderSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_contrast"), hbTrId("txt_cam_button_contrast"), this, SLOT(launchSliderSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::CONTRAST); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - mSettingsGrid->addAction(HbIcon("qtg_mono_face_tracking.svg"), hbTrId("txt_cam_button_face_tracking"), this, SLOT(launchNotSupportedNotification())); + mSettingsGrid->addAction(HbIcon("qtg_mono_face_tracking"), hbTrId("txt_cam_button_face_tracking"), this, SLOT(launchNotSupportedNotification())); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); connect(mKeyHandler, SIGNAL(autofocusKeyPressed()), mSettingsGrid, SLOT(close())); @@ -700,13 +701,7 @@ if (mEngine->mode() == Cxe::ImageMode) { // update toolbar scene mode icon - QString icon = getSettingItemIcon(CxeSettingIds::IMAGE_SCENE, scene[CxeSettingIds::SCENE_ID]); - CX_DEBUG((("New scene mode icon: %s"), icon.toAscii().constData())); - if (mDocumentLoader) { - QObject *obj = mDocumentLoader->findObject(STILL_PRE_CAPTURE_SCENE_MODE_ACTION); - CX_DEBUG_ASSERT(obj); - qobject_cast(obj)->setIcon(HbIcon(icon)); - } + updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString()); // for now, we are only interested in flashmode change if (scene.contains(CxeSettingIds::FLASH_MODE)) { diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp --- a/camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuivideoprecaptureview.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -110,6 +110,8 @@ this, SLOT(handleSnapshot(CxeError::Id))); connect(mVideoCaptureControl, SIGNAL(stateChanged(CxeVideoCaptureControl::State, CxeError::Id)), this, SLOT(handleVideoStateChanged(CxeVideoCaptureControl::State,CxeError::Id))); + connect(&(mEngine->settings()), SIGNAL(sceneChanged(CxeScene&)), + this, SLOT(handleSceneChanged(CxeScene&))); connect(mVideoCaptureControl, SIGNAL(remainingTimeChanged()), this, SLOT(updateTimeLabels())); @@ -262,9 +264,17 @@ mRecordingAnimation->setLoopCount(-1); mRecordingAnimation->setEasingCurve(QEasingCurve::OutInQuad); + + // Update toolbar scene mode icon. + QString sceneId; + if (mEngine->settings().get(CxeSettingIds::SCENE_ID, sceneId) == CxeError::None) { + updateSceneIcon(sceneId); + } + // Initialize the video time counters. updateTimeLabels(); + CX_DEBUG_EXIT_FUNCTION(); } @@ -278,15 +288,15 @@ mSettingsGrid = new HbToolBarExtension; - action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure.svg"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_exposure"), hbTrId("txt_cam_button_exposure_compensation"), this, SLOT(launchSliderSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::EV_COMPENSATION_VALUE); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb.svg"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_small_rgb"), hbTrId("txt_cam_button_color_tone"), this, SLOT(launchSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::COLOR_TONE); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); - action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance.svg"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting())); + action = mSettingsGrid->addAction(HbIcon("qtg_mono_white_balance"), hbTrId("txt_cam_button_white_balance"), this, SLOT(launchSetting())); action->setProperty(PROPERTY_KEY_SETTING_ID, CxeSettingIds::WHITE_BALANCE); action->setProperty(PROPERTY_KEY_SETTING_GRID, PROPERTY_KEY_TRUE); @@ -335,45 +345,17 @@ void CxuiVideoPrecaptureView::stop() { CX_DEBUG_ENTER_FUNCTION(); - if (isPostcaptureOn()) { - CxeVideoCaptureControl::State state = mVideoCaptureControl->state(); - if (state == CxeVideoCaptureControl::Recording || - state == CxeVideoCaptureControl::Paused) { - mVideoCaptureControl->stop(); - // Continue in handleVideoStateChanged(). - } - } else { - // no postcapture - stopAndPrepareNewVideo(); + + CxeVideoCaptureControl::State state = mVideoCaptureControl->state(); + if (state == CxeVideoCaptureControl::Recording || + state == CxeVideoCaptureControl::Paused) { + mVideoCaptureControl->stop(); + // Continue in handleVideoStateChanged(). } - CX_DEBUG_EXIT_FUNCTION(); } -// CxuiVideoPrecaptureView::stopAndPrepareNewVideo() -// A version of stop that doesn't go to post-capture. When -// not going to post-capture, we need to prepare new video -void CxuiVideoPrecaptureView::stopAndPrepareNewVideo() -{ - CX_DEBUG_ENTER_FUNCTION(); - mVideoCaptureControl->stop(); - mElapsedTimer.stop(); - hideControls(); - - if (mMenu) { - setMenu(mMenu); - mMenu = NULL; - } - - // prepare new video when old one is ready - connect(mVideoCaptureControl, SIGNAL(videoComposed(CxeError::Id, const QString&)), - this, SLOT(prepareNewVideo(CxeError::Id))); - - CX_DEBUG_EXIT_FUNCTION(); -} - - // CxuiPrecaptureView::showToolbar() // Shows toolbar. Calls the base class implementation if not recording // since toolbar is not shown during recording @@ -604,20 +586,21 @@ } enableFeedback(); - if (isPostcaptureOn()) { - mElapsedTimer.stop(); - hideControls(); + mElapsedTimer.stop(); + hideControls(); + + if (mMenu) { + setMenu(mMenu); + mMenu = NULL; + } - if (mRecordingAnimation && mRecordingIcon) { - mRecordingAnimation->stop(); - mRecordingIcon->setOpacity(0); - } - if (mMenu) { - setMenu(mMenu); - mMenu = NULL; - } - + if (isPostcaptureOn()) { emit changeToPostcaptureView(); + } else { + // post capture off, we need prepare new video + // do the prepare when the previous video is ready + connect(mVideoCaptureControl, SIGNAL(videoComposed(CxeError::Id, const QString&)), + this, SLOT(prepareNewVideo(CxeError::Id))); } break; default: @@ -778,6 +761,24 @@ } /*! +* Handle scene mode change. +* @param scene The new active scene mode. +*/ +void CxuiVideoPrecaptureView::handleSceneChanged(CxeScene &scene) +{ + CX_DEBUG_ENTER_FUNCTION(); + // Ignore if not in video mode. + if (mEngine->mode() == Cxe::VideoMode) { + // Update toolbar scene mode icon. + updateSceneIcon(scene[CxeSettingIds::SCENE_ID].toString()); + } + + CX_DEBUG_EXIT_FUNCTION(); +} + + + +/*! Sets the visibility of recording icon and elapsed time text. \param visible True if widgets are to be shown, false if not. */ @@ -816,6 +817,4 @@ return CxuiPrecaptureView::eventFilter(object, event); } - - //end of file diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/cxui/src/cxuiviewmanager.cpp --- a/camerauis/cameraxui/cxui/src/cxuiviewmanager.cpp Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/cxui/src/cxuiviewmanager.cpp Thu Jul 15 01:44:30 2010 +0300 @@ -19,7 +19,7 @@ #include #include #include - +#include #include "cxuiapplication.h" #include "cxuiapplicationframeworkmonitor.h" @@ -144,6 +144,10 @@ mStandbyHandler->startTimer(); } + // Register stylesheet. It will be automatically destroyed on application + // exit. + HbStyleLoader::registerFilePath(":/camerax/cxui.css"); + CX_DEBUG_EXIT_FUNCTION(); } @@ -227,25 +231,26 @@ bool ok = false; CX_DEBUG_ASSERT(mCameraDocumentLoader); - + CxuiDocumentLoader *documentLoader = new CxuiDocumentLoader(&mEngine); // Use document loader to create widgets and layouts // (non-sectioned parts are parsed and loaded) - mCameraDocumentLoader->load(SCENEMODE_SETTING_XML, &ok); + documentLoader->load(SCENEMODE_SETTING_XML, &ok); QGraphicsWidget *widget = NULL; // ask for the scenes mode view widget pointer - widget = mCameraDocumentLoader->findWidget(STILL_SCENES_VIEW); + widget = documentLoader->findWidget(STILL_SCENES_VIEW); Q_ASSERT_X(ok && (widget != 0), "camerax ui", "invalid xml file"); mSceneModeView = qobject_cast (widget); // call for needed construction methods - mSceneModeView->construct(&mMainWindow, &mEngine, mCameraDocumentLoader, mKeyHandler); + mSceneModeView->construct(&mMainWindow, &mEngine, documentLoader, mKeyHandler); // .. and add to main window (which also takes ownership) mMainWindow.addView(widget); mSceneModeView->loadBackgroundImages(); connect(mSceneModeView, SIGNAL(viewCloseEvent()), this, SLOT(changeToPrecaptureView())); + delete documentLoader; CX_DEBUG_EXIT_FUNCTION(); } @@ -417,6 +422,10 @@ mMainWindow.setCurrentView(view, false); mMainWindow.blockSignals(false); + if (mSceneModeView){ + delete mSceneModeView; + mSceneModeView = NULL; + } // connecting necessary pre-capture view signals connectPreCaptureSignals(); emit startStandbyTimer(); diff -r 3075d9b614e6 -r 0f0b4c1d7744 camerauis/cameraxui/rom/camerax.iby --- a/camerauis/cameraxui/rom/camerax.iby Thu May 13 21:30:19 2010 +0300 +++ b/camerauis/cameraxui/rom/camerax.iby Thu Jul 15 01:44:30 2010 +0300 @@ -30,6 +30,7 @@ data = DATAZ_\system\sounds\digital\videoStart.wav system\sounds\digital\videoStart.wav data = DATAZ_\system\sounds\digital\videoStop.wav system\sounds\digital\videoStop.wav data = DATAZ_\system\sounds\digital\autoFocus.wav system\sounds\digital\autoFocus.wav +data = DATAZ_\system\sounds\digital\selftimer.wav system\sounds\digital\selftimer.wav // CR key files data = DATAZ_\private\10202be9\20027017.txt private\10202be9\20027017.txt