38 #include "cxenamespace.h" |
38 #include "cxenamespace.h" |
39 #include "cxesoundplayersymbian.h" |
39 #include "cxesoundplayersymbian.h" |
40 #include "cxequalitypresetssymbian.h" |
40 #include "cxequalitypresetssymbian.h" |
41 #include "cxeviewfindercontrolsymbian.h" |
41 #include "cxeviewfindercontrolsymbian.h" |
42 #include "cxediskmonitor.h" |
42 #include "cxediskmonitor.h" |
|
43 #include "cxesettingsmappersymbian.h" |
43 |
44 |
44 #include "OstTraceDefinitions.h" |
45 #include "OstTraceDefinitions.h" |
45 #ifdef OST_TRACE_COMPILER_IN_USE |
46 #ifdef OST_TRACE_COMPILER_IN_USE |
46 #include "cxevideocapturecontrolsymbianTraces.h" |
47 #include "cxevideocapturecontrolsymbianTraces.h" |
47 #endif |
48 #endif |
121 this, SLOT(handleSnapshotReady(CxeError::Id, const QImage&))); |
122 this, SLOT(handleSnapshotReady(CxeError::Id, const QImage&))); |
122 |
123 |
123 // enabling setting change callbacks to videocapturecontrol |
124 // enabling setting change callbacks to videocapturecontrol |
124 connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)), |
125 connect(&mSettings, SIGNAL(settingValueChanged(const QString&,QVariant)), |
125 this, SLOT(handleSettingValueChanged(const QString&,QVariant))); |
126 this, SLOT(handleSettingValueChanged(const QString&,QVariant))); |
126 connect(&mSettings, SIGNAL(sceneChanged(CxeScene&)), |
127 |
127 this, SLOT(handleSceneChanged(CxeScene&))); |
128 mSettings.listenForSetting(CxeSettingIds::VIDEO_SCENE, this, SLOT(handleSceneChanged(const QVariant&))); |
|
129 |
128 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0"); |
130 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_M2, "msg: e_CX_ENGINE_CONNECT_SIGNALS 0"); |
129 |
131 |
130 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_OUT, "msg: e_CX_VIDEOCAPTURECONTROL_NEW 0"); |
132 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_CREATE_OUT, "msg: e_CX_VIDEOCAPTURECONTROL_NEW 0"); |
131 CX_DEBUG_EXIT_FUNCTION(); |
133 CX_DEBUG_EXIT_FUNCTION(); |
132 } |
134 } |
212 CX_DEBUG_ENTER_FUNCTION(); |
214 CX_DEBUG_ENTER_FUNCTION(); |
213 |
215 |
214 // Init needed only in Idle state |
216 // Init needed only in Idle state |
215 if (state() == Idle) { |
217 if (state() == Idle) { |
216 try { |
218 try { |
217 // if video recorder is not created, do it now. |
219 // If video recorder is not yet created, do it now. |
218 createVideoRecorder(); |
220 createVideoRecorder(); |
219 |
221 |
220 // update current video quality details from icm. |
222 // Update current video quality details from ICM. |
221 // Throws an error if unable to get the quality. |
223 // Throws an error if unable to get the quality. |
222 getVideoQualityDetails(mCurrentVideoDetails); |
224 updateVideoCaptureParameters(); |
223 |
225 |
224 // Video recorder is ready to open video file for recording. |
226 // Video recorder is ready to open video file for recording. |
225 setState(Initialized); |
227 setState(Initialized); |
226 open(); |
228 open(); |
227 } catch (const std::exception &e) { |
229 } catch (const std::exception &e) { |
300 } |
302 } |
301 |
303 |
302 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_1, "msg: e_CX_VIDCAPCONT_PREPARE 1"); |
304 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_1, "msg: e_CX_VIDCAPCONT_PREPARE 1"); |
303 QSize frameSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); |
305 QSize frameSize(mCurrentVideoDetails.mWidth, mCurrentVideoDetails.mHeight); |
304 |
306 |
305 int muteSetting = 0; // audio enabled |
307 bool muteSetting = mSettings.get<bool>(CxeSettingIds::VIDEO_MUTE_SETTING, false); |
306 mSettings.get(CxeSettingIds::VIDEO_MUTE_SETTING, muteSetting); |
|
307 |
308 |
308 // Check if scene defines frame rate. |
309 // Check if scene defines frame rate. |
309 // Use generic frame rate defined in video details, if no value is set in scene. |
310 // Use generic frame rate defined in video details, if no value is set in scene. |
310 int frameRate = 0; |
311 int frameRate = mSettings.get<int>(CxeSettingIds::FRAME_RATE, 0); |
311 mSettings.get(CxeSettingIds::FRAME_RATE, frameRate); |
|
312 if (frameRate <= 0) { |
312 if (frameRate <= 0) { |
313 frameRate = mCurrentVideoDetails.mVideoFrameRate; |
313 frameRate = mCurrentVideoDetails.mVideoFrameRate; |
314 } |
314 } |
315 |
315 |
316 CX_DEBUG(("Video resolution (%d,%d)", mCurrentVideoDetails.mWidth, |
316 CX_DEBUG(("Video resolution (%d,%d)", mCurrentVideoDetails.mWidth, |
320 |
320 |
321 try { |
321 try { |
322 mVideoRecorder->setVideoFrameSize(frameSize); |
322 mVideoRecorder->setVideoFrameSize(frameSize); |
323 mVideoRecorder->setVideoFrameRate(frameRate); |
323 mVideoRecorder->setVideoFrameRate(frameRate); |
324 mVideoRecorder->setVideoBitRate(mCurrentVideoDetails.mVideoBitRate); |
324 mVideoRecorder->setVideoBitRate(mCurrentVideoDetails.mVideoBitRate); |
325 mVideoRecorder->setAudioEnabled(muteSetting == 0); |
325 mVideoRecorder->setAudioEnabled(!muteSetting); |
326 // "No limit" value is handled in video recorder wrapper. |
326 // "No limit" value is handled in video recorder wrapper. |
327 mVideoRecorder->setVideoMaxSize(mCurrentVideoDetails.mMaximumSizeInBytes); |
327 mVideoRecorder->setVideoMaxSize(mCurrentVideoDetails.mMaximumSizeInBytes); |
328 |
328 |
329 // Settings have been applied successfully, start to prepare. |
329 // Settings have been applied successfully, start to prepare. |
330 mVideoRecorder->prepare(); |
330 mVideoRecorder->prepare(); |
331 |
|
332 // Prepare snapshot. Snapshot control throws error if problems. |
|
333 QSize snapshotSize = mSnapshotControl.calculateSnapshotSize( |
|
334 mViewfinderControl.deviceDisplayResolution(), |
|
335 mCurrentVideoDetails.mAspectRatio); |
|
336 mSnapshotControl.start(snapshotSize); |
|
337 |
331 |
338 // Prepare zoom only when there are no errors during prepare. |
332 // Prepare zoom only when there are no errors during prepare. |
339 emit prepareZoomForVideo(); |
333 emit prepareZoomForVideo(); |
340 emit videoPrepareComplete(CxeError::None); |
334 emit videoPrepareComplete(CxeError::None); |
341 } catch (const std::exception &e) { |
335 } catch (const std::exception &e) { |
346 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_2, "msg: e_CX_VIDCAPCONT_PREPARE 0"); |
340 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARE_2, "msg: e_CX_VIDCAPCONT_PREPARE 0"); |
347 CX_DEBUG_EXIT_FUNCTION(); |
341 CX_DEBUG_EXIT_FUNCTION(); |
348 } |
342 } |
349 |
343 |
350 /*! |
344 /*! |
351 * Fetches video qualites details based on video quality setting. |
345 * Prepare video snapshot. |
352 */ |
346 * Throws exception on error. |
353 void |
347 */ |
354 CxeVideoCaptureControlSymbian::getVideoQualityDetails(CxeVideoDetails &videoInfo) |
348 void CxeVideoCaptureControlSymbian::prepareSnapshot() |
355 { |
349 { |
356 CX_DEBUG_ENTER_FUNCTION(); |
350 CX_DEBUG_ENTER_FUNCTION(); |
357 OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_GETQUALITYDETAILS_1, "msg: e_CX_GET_QUALITY_DETAILS 1" ); |
351 OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARESNAP_1, "msg: e_CX_PREPARE_SNAPSHOT 1" ); |
358 |
352 |
359 int quality(0); |
353 // Prepare snapshot. Snapshot control throws error if problems. |
|
354 QSize snapshotSize = mSnapshotControl.calculateSnapshotSize( |
|
355 mViewfinderControl.deviceDisplayResolution(), |
|
356 mCurrentVideoDetails.mAspectRatio); |
|
357 mSnapshotControl.start(snapshotSize); |
|
358 |
|
359 OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_PREPARESNAP_2, "msg: e_CX_PREPARE_SNAPSHOT 0" ); |
|
360 CX_DEBUG_EXIT_FUNCTION(); |
|
361 } |
|
362 |
|
363 /*! |
|
364 Fetch video quality details based on current video quality setting. |
|
365 */ |
|
366 void CxeVideoCaptureControlSymbian::updateVideoCaptureParameters() |
|
367 { |
|
368 CX_DEBUG_ENTER_FUNCTION(); |
|
369 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_UPDATEVIDEOCAPTUREPARAMETERS_1, "msg: e_CX_UPDATE_VIDEO_CAPTURE_PARAMETERS 1"); |
|
370 |
|
371 int quality = 0; |
360 |
372 |
361 // Get quality index for primary camera. Only one quality for secondary camera. |
373 // Get quality index for primary camera. Only one quality for secondary camera. |
362 if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) { |
374 if (mCameraDeviceControl.cameraIndex() == Cxe::PrimaryCameraIndex) { |
363 CxeException::throwIfError(mSettings.get(CxeSettingIds::VIDEO_QUALITY, quality)); |
375 quality = mSettings.get<int>(CxeSettingIds::VIDEO_QUALITY); |
364 } |
376 } |
365 |
377 |
366 if (quality < 0 || quality >= mIcmSupportedVideoResolutions.count()) { |
378 if (quality < 0 || quality >= mIcmSupportedVideoResolutions.count()) { |
367 throw new CxeException(CxeError::NotFound); |
379 throw new CxeException(CxeError::NotFound); |
368 } |
380 } |
369 |
381 |
370 // get video quality details |
382 // Get video quality details |
371 videoInfo = mIcmSupportedVideoResolutions.at(quality); |
383 mCurrentVideoDetails = mIcmSupportedVideoResolutions.at(quality); |
372 |
384 |
373 OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROL_GETQUALITYDETAILS_2, "msg: e_CX_GET_QUALITY_DETAILS 0" ); |
385 OstTrace0(camerax_performance, CXEVIDEOCAPTURECONTROL_UPDATEVIDEOCAPTUREPARAMETERS_2, "msg: e_CX_UPDATE_VIDEO_CAPTURE_PARAMETERS 0"); |
374 CX_DEBUG_EXIT_FUNCTION(); |
386 CX_DEBUG_EXIT_FUNCTION(); |
375 } |
387 } |
376 |
388 |
377 /*! |
389 /*! |
378 * Resets the video snapshot and current video filename |
390 * Resets the video snapshot and current video filename |
502 { |
514 { |
503 CX_DEBUG_ENTER_FUNCTION(); |
515 CX_DEBUG_ENTER_FUNCTION(); |
504 CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoPrepareComplete, err=%d", aError)); |
516 CX_DEBUG(("CxeVideoCaptureControlSymbian::MvruoPrepareComplete, err=%d", aError)); |
505 |
517 |
506 if (state() == Preparing) { |
518 if (state() == Preparing) { |
507 if (!aError) { |
519 try { |
|
520 // Check that no error coming in. |
|
521 CxeException::throwIfError(aError); |
|
522 // Start viewfinder |
|
523 mViewfinderControl.start(); |
|
524 // Prepare snapshot (throws exception if fails). |
|
525 prepareSnapshot(); |
|
526 // Ready for recording now. |
508 setState(CxeVideoCaptureControl::Ready); |
527 setState(CxeVideoCaptureControl::Ready); |
509 mViewfinderControl.start(); |
|
510 OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_GOTOVIDEO, "msg: e_CX_GO_TO_VIDEO_MODE 0" ); |
528 OstTrace0( camerax_performance, CXEVIDEOCAPTURECONTROLSYMBIAN_GOTOVIDEO, "msg: e_CX_GO_TO_VIDEO_MODE 0" ); |
511 } else { |
529 } catch (const std::exception &e) { |
512 handlePrepareFailed(); |
530 handlePrepareFailed(); |
513 } |
531 } |
514 } |
532 } |
515 |
533 |
516 CX_DEBUG_EXIT_FUNCTION(); |
534 CX_DEBUG_EXIT_FUNCTION(); |
893 |
911 |
894 CX_DEBUG_EXIT_FUNCTION(); |
912 CX_DEBUG_EXIT_FUNCTION(); |
895 } |
913 } |
896 |
914 |
897 /*! |
915 /*! |
|
916 Use ECam Use Case Hint Custom API to inform ECam of our intended use case |
|
917 before calling Reserve(). |
|
918 */ |
|
919 void CxeVideoCaptureControlSymbian::hintUseCase() |
|
920 { |
|
921 CX_DEBUG_ENTER_FUNCTION(); |
|
922 |
|
923 // Make sure ECam knows we're doing video recording so it can prepare |
|
924 // for the correct use case. |
|
925 if (mCameraDeviceControl.mode() == Cxe::VideoMode) { |
|
926 MCameraUseCaseHint *useCaseHintApi = mCameraDevice.useCaseHintApi(); |
|
927 if (useCaseHintApi) { |
|
928 MCameraUseCaseHint::TVideoCodec codec = |
|
929 MCameraUseCaseHint::ECodecUnknown; |
|
930 MCameraUseCaseHint::TVideoProfile profile = |
|
931 MCameraUseCaseHint::EProfileUnknown; |
|
932 |
|
933 updateVideoCaptureParameters(); |
|
934 CxeSettingsMapperSymbian::Map2UseCaseHintVideoParameters( |
|
935 mCurrentVideoDetails, codec, profile); |
|
936 |
|
937 TSize resolution(mCurrentVideoDetails.mWidth, |
|
938 mCurrentVideoDetails.mHeight); |
|
939 TRAP_IGNORE(useCaseHintApi->HintDirectVideoCaptureL(codec, profile, |
|
940 resolution)); |
|
941 } |
|
942 } |
|
943 |
|
944 CX_DEBUG_EXIT_FUNCTION(); |
|
945 } |
|
946 |
|
947 /*! |
898 * Returns QList of all supported video quality details based on the camera index |
948 * Returns QList of all supported video quality details based on the camera index |
899 * (primary/secondary). |
949 * (primary/secondary). |
900 */ |
950 */ |
901 QList<CxeVideoDetails> CxeVideoCaptureControlSymbian::supportedVideoQualities() |
951 QList<CxeVideoDetails> CxeVideoCaptureControlSymbian::supportedVideoQualities() |
902 { |
952 { |