camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp
changeset 24 2094593137f5
parent 21 fa6d9f75d6a6
child 29 699651f2666f
--- a/camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp	Mon May 03 12:22:55 2010 +0300
+++ b/camerauis/cameraxui/cxengine/src/cxevideocapturecontrolsymbian.cpp	Fri May 14 15:40:46 2010 +0300
@@ -126,6 +126,8 @@
     connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)),
             this, SLOT(handleSettingValueChanged(const QString&,QVariant)));
 
+    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");
@@ -372,7 +374,6 @@
     CX_DEBUG(("Video resoulution (%d,%d)", mCurrentVideoDetails.mWidth,
                                            mCurrentVideoDetails.mHeight));
     CX_DEBUG(("Video bitrate = %d)", mCurrentVideoDetails.mVideoBitRate));
-    CX_DEBUG(("Video frame rate = %f)", mCurrentVideoDetails.mVideoFrameRate));
 
     OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_VIDCAPCONT_PREPARE 1");
     TSize frameSize;
@@ -381,10 +382,20 @@
     int muteSetting = 0; // audio enabled
     mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting);
 
+    // Check if scene defines frame rate.
+    // Use generic frame rate defined in video details, if no value is set in scene.
+    int frameRate = 0;
+    mSettings.get(CxeSettingIds::FRAME_RATE, frameRate);
+    if (frameRate <= 0) {
+        frameRate = mCurrentVideoDetails.mVideoFrameRate;
+    }
+
+    CX_DEBUG(("Video frame rate = %d)", frameRate));
+
     TRAPD(err,
               {
               mVideoRecorder->SetVideoFrameSizeL(frameSize);
-              mVideoRecorder->SetVideoFrameRateL(mCurrentVideoDetails.mVideoFrameRate);
+              mVideoRecorder->SetVideoFrameRateL(frameRate);
               mVideoRecorder->SetVideoBitRateL(mCurrentVideoDetails.mVideoBitRate);
               mVideoRecorder->SetAudioEnabledL(muteSetting == 0);
               // "No limit" value is handled in video recorder wrapper.
@@ -665,6 +676,8 @@
 
     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
@@ -1078,7 +1091,8 @@
 {
     CX_DEBUG_ENTER_FUNCTION();
 
-    if (state() == CxeVideoCaptureControl::Recording) {
+    if (state() == CxeVideoCaptureControl::Recording ||
+        state() == CxeVideoCaptureControl::Paused) {
         TTimeIntervalMicroSeconds remaining = 0;
         remaining = mVideoRecorder->RecordTimeAvailable();
         time = remaining.Int64() * 1.0 / KOneSecond;
@@ -1175,7 +1189,8 @@
 
     TTimeIntervalMicroSeconds timeElapsed = 0;
     bool ok = false;
-    if (state() == CxeVideoCaptureControl::Recording) {
+    if (state() == CxeVideoCaptureControl::Recording ||
+        state() == CxeVideoCaptureControl::Paused) {
         TRAPD( err, timeElapsed = mVideoRecorder->DurationL() );
         if (!err) {
             time = timeElapsed.Int64() * 1.0 / KOneSecond;
@@ -1232,6 +1247,13 @@
             // mute setting changed, apply the new setting and re-prepare.
             setState(Preparing);
             prepare();
+        } 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) {
+                setState(Preparing);
+                prepare();
+            }
         } else {
             // Setting not relevant to video mode
         }
@@ -1241,6 +1263,26 @@
 }
 
 /*!
+ * Scene mode changed. We need to know about it because frame rate
+ * might have changed.
+ */
+void CxeVideoCaptureControlSymbian::handleSceneChanged(CxeScene& scene)
+{
+    CX_DEBUG_ENTER_FUNCTION();
+
+    // make sure we are in video mode
+    if (mCameraDeviceControl.mode() == Cxe::VideoMode) {
+        // Frame rate setting might have changed so re-prepare.
+        if (state() == Ready) {
+            setState(Preparing);
+            prepare();
+        }
+
+    }
+    CX_DEBUG_EXIT_FUNCTION();
+}
+
+/*!
 * Disk space changed.
 * Emit remaining time changed signal, if space change affects it.
 */