28 #include "cxeerrormappingsymbian.h" |
28 #include "cxeerrormappingsymbian.h" |
29 #include "cxeviewfindercontrol.h" |
29 #include "cxeviewfindercontrol.h" |
30 #include "cxestillimagesymbian.h" |
30 #include "cxestillimagesymbian.h" |
31 #include "cxecameradevice.h" |
31 #include "cxecameradevice.h" |
32 #include "cxutils.h" |
32 #include "cxutils.h" |
33 #include "cxesysutil.h" |
|
34 #include "cxestate.h" |
33 #include "cxestate.h" |
35 #include "cxesettings.h" |
34 #include "cxesettings.h" |
36 #include "cxenamespace.h" |
35 #include "cxenamespace.h" |
37 #include "OstTraceDefinitions.h" |
|
38 #include "cxesoundplayersymbian.h" |
36 #include "cxesoundplayersymbian.h" |
39 #include "cxequalitypresetssymbian.h" |
37 #include "cxequalitypresetssymbian.h" |
40 #include "cxeviewfindercontrolsymbian.h" |
38 #include "cxeviewfindercontrolsymbian.h" |
|
39 #include "cxediskmonitor.h" |
|
40 |
|
41 #include "OstTraceDefinitions.h" |
41 #ifdef OST_TRACE_COMPILER_IN_USE |
42 #ifdef OST_TRACE_COMPILER_IN_USE |
42 #include "cxevideocapturecontrolsymbianTraces.h" |
43 #include "cxevideocapturecontrolsymbianTraces.h" |
43 #endif |
44 #endif |
44 |
45 |
45 |
46 |
46 // constants |
47 // constants |
47 const TInt64 KMinRequiredSpaceVideo = 4000000; |
48 namespace |
48 const uint KOneMillion = 1000000; |
49 { |
49 const qreal KMetaDataCoeff = 1.03; // Coefficient to estimate metadata amount |
50 // Controller UId, can be used by the client to identify the controller, e.g. if the custom command can be used |
50 const uint KCamCMaxClipDurationInSecs = 5400; // Maximun video clip duration in seconds |
51 const TUid KCamCControllerImplementationUid = {0x101F8503}; |
51 const qreal KCMRAvgVideoBitRateScaler = 0.9; // avg video bit rate scaler |
52 // TMMFEvent UIDs for Async stop |
|
53 const TUid KCamCControllerCCVideoRecordStopped = {0x2000E546}; |
|
54 const TUid KCamCControllerCCVideoFileComposed = {0x2000E547}; |
|
55 |
|
56 // Custom command for setting a new filename without closing & reopening the controller |
|
57 enum TCamCControllerCustomCommands |
|
58 { |
|
59 ECamCControllerCCNewFilename = 0, |
|
60 ECamCControllerCCVideoStopAsync |
|
61 }; |
|
62 |
|
63 const TInt KOneSecond = 1000000; |
|
64 const int KMaintainAspectRatio = false; |
|
65 const TInt64 KMinRequiredSpaceVideo = 4000000; |
|
66 const uint KOneMillion = 1000000; |
|
67 const qreal KMetaDataCoeff = 1.03; // Coefficient to estimate metadata amount |
|
68 const uint KCamCMaxClipDurationInSecs = 5400; // Maximun video clip duration in seconds |
|
69 const qreal KCMRAvgVideoBitRateScaler = 0.9; // avg video bit rate scaler |
|
70 } |
52 |
71 |
53 |
72 |
54 /*! |
73 /*! |
55 * CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian |
74 * CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian |
56 */ |
75 */ |
57 CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian(CxeCameraDevice &cameraDevice, |
76 CxeVideoCaptureControlSymbian::CxeVideoCaptureControlSymbian( |
58 CxeViewfinderControl &viewfinderControl, |
77 CxeCameraDevice &cameraDevice, |
59 CxeCameraDeviceControl &cameraDeviceControl, |
78 CxeViewfinderControl &viewfinderControl, |
60 CxeFilenameGenerator &nameGenerator, |
79 CxeCameraDeviceControl &cameraDeviceControl, |
61 CxeSettings &settings, |
80 CxeFilenameGenerator &nameGenerator, |
62 CxeQualityPresets &qualityPresets) : |
81 CxeSettings &settings, |
63 CxeStateMachine("CxeVideoCaptureControlSymbian"), |
82 CxeQualityPresets &qualityPresets, |
64 mVideoRecorder(NULL), |
83 CxeDiskMonitor &diskMonitor) |
65 mCameraDevice(cameraDevice), |
84 : CxeStateMachine("CxeVideoCaptureControlSymbian"), |
66 mCameraDeviceControl(cameraDeviceControl), |
85 mVideoRecorder(NULL), |
67 mViewfinderControl(viewfinderControl), |
86 mCameraDevice(cameraDevice), |
68 mFilenameGenerator(nameGenerator), |
87 mCameraDeviceControl(cameraDeviceControl), |
69 mSettings(settings), |
88 mViewfinderControl(viewfinderControl), |
70 mQualityPresets(qualityPresets), |
89 mFilenameGenerator(nameGenerator), |
71 mSnapshot(), |
90 mSettings(settings), |
72 mNewFileName(""), |
91 mQualityPresets(qualityPresets), |
73 mCurrentFilename("") |
92 mDiskMonitor(diskMonitor), |
74 { |
93 mSnapshot(), |
75 CX_DEBUG_ENTER_FUNCTION(); |
94 mNewFileName(""), |
|
95 mCurrentFilename("") |
|
96 { |
|
97 CX_DEBUG_ENTER_FUNCTION(); |
|
98 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_IN, "msg: e_CX_VIDEOCAPTURECONTROL_NEW 1"); |
76 |
99 |
77 qRegisterMetaType<CxeVideoCaptureControl::State> (); |
100 qRegisterMetaType<CxeVideoCaptureControl::State> (); |
78 initializeStates(); |
101 initializeStates(); |
|
102 |
79 mVideoStopSoundPlayer = new |
103 mVideoStopSoundPlayer = new |
80 CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStop); |
104 CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStop); |
81 mVideoStartSoundPlayer = new |
105 mVideoStartSoundPlayer = new |
82 CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStart); |
106 CxeSoundPlayerSymbian(CxeSoundPlayerSymbian::VideoCaptureStart); |
83 |
107 |
|
108 // If camera is already allocated, call the slot ourselves. |
|
109 if (mCameraDevice.camera()) { |
|
110 handleCameraAllocated(CxeError::None); |
|
111 } |
|
112 |
|
113 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M1, "msg: e_CX_ENGINE_CONNECT_SIGNALS 1"); |
84 // connect signals from cameraDevice, so we recieve events when camera reference changes |
114 // connect signals from cameraDevice, so we recieve events when camera reference changes |
85 connect(&cameraDevice, SIGNAL(prepareForCameraDelete()), |
115 connect(&cameraDevice, SIGNAL(prepareForCameraDelete()), |
86 this, SLOT(prepareForCameraDelete())); |
116 this, SLOT(prepareForCameraDelete())); |
87 connect(&cameraDevice, SIGNAL(prepareForRelease()), |
117 connect(&cameraDevice, SIGNAL(prepareForRelease()), |
88 this, SLOT(prepareForRelease()) ); |
118 this, SLOT(prepareForRelease()) ); |
336 } |
372 } |
337 |
373 |
338 CX_DEBUG(("Video resoulution (%d,%d)", mCurrentVideoDetails.mWidth, |
374 CX_DEBUG(("Video resoulution (%d,%d)", mCurrentVideoDetails.mWidth, |
339 mCurrentVideoDetails.mHeight)); |
375 mCurrentVideoDetails.mHeight)); |
340 CX_DEBUG(("Video bitrate = %d)", mCurrentVideoDetails.mVideoBitRate)); |
376 CX_DEBUG(("Video bitrate = %d)", mCurrentVideoDetails.mVideoBitRate)); |
341 CX_DEBUG(("Video frame rate = %f)", mCurrentVideoDetails.mVideoFrameRate)); |
|
342 |
377 |
343 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_VIDCAPCONT_PREPARE 1"); |
378 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_PREPARE, "msg: e_CX_VIDCAPCONT_PREPARE 1"); |
344 TSize frameSize; |
379 TSize frameSize; |
345 frameSize.SetSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); |
380 frameSize.SetSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); |
346 |
381 |
347 int muteSetting = 0; // audio enabled |
382 int muteSetting = 0; // audio enabled |
348 mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); |
383 mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); |
349 |
384 |
|
385 // Check if scene defines frame rate. |
|
386 // Use generic frame rate defined in video details, if no value is set in scene. |
|
387 int frameRate = 0; |
|
388 mSettings.get(CxeSettingIds::FRAME_RATE, frameRate); |
|
389 if (frameRate <= 0) { |
|
390 frameRate = mCurrentVideoDetails.mVideoFrameRate; |
|
391 } |
|
392 |
|
393 CX_DEBUG(("Video frame rate = %d)", frameRate)); |
|
394 |
350 TRAPD(err, |
395 TRAPD(err, |
351 { |
396 { |
352 mVideoRecorder->SetVideoFrameSizeL(frameSize); |
397 mVideoRecorder->SetVideoFrameSizeL(frameSize); |
353 mVideoRecorder->SetVideoFrameRateL(mCurrentVideoDetails.mVideoFrameRate); |
398 mVideoRecorder->SetVideoFrameRateL(frameRate); |
354 mVideoRecorder->SetVideoBitRateL(mCurrentVideoDetails.mVideoBitRate); |
399 mVideoRecorder->SetVideoBitRateL(mCurrentVideoDetails.mVideoBitRate); |
355 mVideoRecorder->SetAudioEnabledL(muteSetting == 0); |
400 mVideoRecorder->SetAudioEnabledL(muteSetting == 0); |
356 // "No limit" value is handled in video recorder wrapper. |
401 // "No limit" value is handled in video recorder wrapper. |
357 mVideoRecorder->SetMaxClipSizeL(mCurrentVideoDetails.mMaximumSizeInBytes); |
402 mVideoRecorder->SetMaxClipSizeL(mCurrentVideoDetails.mMaximumSizeInBytes); |
358 } |
403 } |
1166 if (mCameraDeviceControl.mode() == Cxe::VideoMode) { |
1237 if (mCameraDeviceControl.mode() == Cxe::VideoMode) { |
1167 if (settingId == CxeSettingIds::VIDEO_QUALITY) { |
1238 if (settingId == CxeSettingIds::VIDEO_QUALITY) { |
1168 // re-prepare for video |
1239 // re-prepare for video |
1169 if (state() == Ready) { |
1240 if (state() == Ready) { |
1170 // release resources |
1241 // release resources |
1171 deinit(); |
1242 deinit(); |
1172 // initialize video recording again |
1243 // initialize video recording again |
1173 init(); |
1244 init(); |
1174 } |
1245 } |
1175 } else if (settingId == CxeSettingIds::VIDEO_MUTE_SETTING) { |
1246 } else if (settingId == CxeSettingIds::VIDEO_MUTE_SETTING) { |
1176 // mute setting changed, apply the new setting and re-prepare. |
1247 // mute setting changed, apply the new setting and re-prepare. |
1177 setState(Preparing); |
1248 setState(Preparing); |
1178 prepare(); |
1249 prepare(); |
|
1250 } else if (settingId == CxeSettingIds::FRAME_RATE){ |
|
1251 // Frame rate setting changed. Need to re-prepare if we are prepared already. |
|
1252 // Otherwise can wait for next init call. |
|
1253 if (state() == Ready) { |
|
1254 setState(Preparing); |
|
1255 prepare(); |
|
1256 } |
1179 } else { |
1257 } else { |
1180 // Setting not relevant to video mode |
1258 // Setting not relevant to video mode |
1181 } |
1259 } |
1182 } |
1260 } |
1183 |
1261 |
1184 CX_DEBUG_EXIT_FUNCTION(); |
1262 CX_DEBUG_EXIT_FUNCTION(); |
1185 } |
1263 } |
1186 |
1264 |
|
1265 /*! |
|
1266 * Scene mode changed. We need to know about it because frame rate |
|
1267 * might have changed. |
|
1268 */ |
|
1269 void CxeVideoCaptureControlSymbian::handleSceneChanged(CxeScene& scene) |
|
1270 { |
|
1271 CX_DEBUG_ENTER_FUNCTION(); |
|
1272 |
|
1273 // make sure we are in video mode |
|
1274 if (mCameraDeviceControl.mode() == Cxe::VideoMode) { |
|
1275 // Frame rate setting might have changed so re-prepare. |
|
1276 if (state() == Ready) { |
|
1277 setState(Preparing); |
|
1278 prepare(); |
|
1279 } |
|
1280 |
|
1281 } |
|
1282 CX_DEBUG_EXIT_FUNCTION(); |
|
1283 } |
|
1284 |
|
1285 /*! |
|
1286 * Disk space changed. |
|
1287 * Emit remaining time changed signal, if space change affects it. |
|
1288 */ |
|
1289 void CxeVideoCaptureControlSymbian::handleDiskSpaceChanged() |
|
1290 { |
|
1291 CX_DEBUG_ENTER_FUNCTION(); |
|
1292 |
|
1293 // Ignore updates on preparing phase. |
|
1294 if (state() == CxeVideoCaptureControl::Ready) { |
|
1295 |
|
1296 int time(0); |
|
1297 calculateRemainingTime(mCurrentVideoDetails, time); |
|
1298 |
|
1299 if (time != mCurrentVideoDetails.mRemainingTime) { |
|
1300 mCurrentVideoDetails.mRemainingTime = time; |
|
1301 emit remainingTimeChanged(); |
|
1302 } |
|
1303 } |
|
1304 |
|
1305 CX_DEBUG_EXIT_FUNCTION(); |
|
1306 } |
1187 |
1307 |
1188 /*! |
1308 /*! |
1189 * Returns QList of all supported video quality details based on the camera index |
1309 * Returns QList of all supported video quality details based on the camera index |
1190 * (primary/secondary). |
1310 * (primary/secondary). |
1191 */ |
1311 */ |