, __orientationFlag(0)
, __cameraOrientation(CAMERA_EXIF_ORIENTATION_TOP_LEFT)
, __recordingRotation(RECORDING_ROTATION_NONE)
+ , __reloadCameraPreviewFormat(::CAMERA_PIXEL_FORMAT_I420)
{
}
}
result
+_CameraCoordinator::CreateVideoRecorder(void)
+{
+ result r = E_SUCCESS;
+ _RecorderDeviceType recorderDevice = _RECORDER_DEVICE_NONE;
+ SysLog(NID_MEDIA, "enter.");
+
+ // Start recorder
+ if ( __recorderHandle == MM_INVALID_HANDLE )
+ {
+ recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+ _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+ r = AddRecorder(recorderDevice); // recorder_create() will be called.
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ __mode = _CAMERA_MODE_VIDEO;
+ }
+ return r;
+CATCH:
+ return r;
+}
+
+result
+_CameraCoordinator::DestroyVideoRecorder(void)
+{
+ result r = E_SUCCESS;
+ int err = MM_SUCCESS;
+ recorder_state_e recorderState = ::RECORDER_STATE_NONE;
+ _RecorderDeviceType recorderDevice = _RECORDER_DEVICE_NONE;
+ SysLog(NID_MEDIA, "enter.");
+
+ if ( __recorderHandle != MM_INVALID_HANDLE )
+ {
+ recorderState = GetRecorderState();
+ // Stop the recorder
+ switch (recorderState)
+ {
+ case ::RECORDER_STATE_NONE:
+ break;
+
+ case ::RECORDER_STATE_CREATED:
+ //fall through
+ case ::RECORDER_STATE_READY:
+ recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+ _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+ RemoveRecorder(recorderDevice);
+ __mode = _CAMERA_MODE_IMAGE;
+ break;
+
+ case ::RECORDER_STATE_RECORDING:
+ //fall through
+ case ::RECORDER_STATE_PAUSED:
+ err = recorder_cancel(__recorderHandle);
+ r = ConvertResult(err);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+ _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+ RemoveRecorder(recorderDevice);
+ __mode = _CAMERA_MODE_IMAGE;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return r;
+CATCH:
+ return r;
+}
+
+
+result
+_CameraCoordinator::ChangeFormat(_CameraMode mode, bool callback, camera_pixel_format_e reloadCameraPreviewFormat)
+{
+ result r = E_SUCCESS;
+ int err = MM_SUCCESS;
+ _RecorderDeviceType recorderDevice = _RECORDER_DEVICE_NONE;
+ camera_state_e cameraState = ::CAMERA_STATE_NONE;
+ recorder_state_e recorderState = ::RECORDER_STATE_NONE;
+ SysLog(NID_MEDIA, "enter. mode:%d, callback:%d, reloadCameraPreviewFormat:%d", mode, callback, reloadCameraPreviewFormat);
+
+ if (mode == _CAMERA_MODE_VIDEO)
+ {
+ cameraState = GetCameraState();
+
+ switch (cameraState)
+ {
+ case ::CAMERA_STATE_CREATED:
+ //fall through
+ case ::CAMERA_STATE_NONE:
+ break;
+
+ case ::CAMERA_STATE_PREVIEW:
+ //fall through
+ case ::CAMERA_STATE_CAPTURED:
+ r = ChangeCameraStateTo(::CAMERA_STATE_CREATED);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ break;
+
+ case ::CAMERA_STATE_CAPTURING:
+ r = E_INVALID_STATE;
+ SysLogException(NID_MEDIA, r, "[E_INVALID_STATE] cameraState(%d) is in an invalid state. While the camera is capturing, the mode cannot be changed.", cameraState);
+ goto CATCH;
+ break;
+
+ default:
+ break;
+ }
+
+ __mode = _CAMERA_MODE_VIDEO;
+ __reloadCameraPreviewFormat = reloadCameraPreviewFormat;
+ if (callback)
+ {
+ r = NotifyModeChangePrepared(mode);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ switch (cameraState)
+ {
+ case ::CAMERA_STATE_NONE:
+ //fall through
+ case ::CAMERA_STATE_CREATED:
+ break;
+
+ case ::CAMERA_STATE_PREVIEW:
+ r = ChangeRecorderStateTo(::RECORDER_STATE_READY);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ break;
+
+ case ::CAMERA_STATE_CAPTURED:
+ default:
+ break;
+ }
+ }
+ else if ( mode == _CAMERA_MODE_IMAGE )
+ {
+ recorderState = GetRecorderState();
+
+ switch (recorderState)
+ {
+ case ::RECORDER_STATE_NONE:
+ break;
+ case ::RECORDER_STATE_CREATED:
+ __mode = _CAMERA_MODE_IMAGE;
+ __reloadCameraPreviewFormat = reloadCameraPreviewFormat;
+ if (callback)
+ {
+ r = NotifyModeChangePrepared(mode);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ break;
+
+ case ::RECORDER_STATE_READY:
+ r = ChangeRecorderStateTo(::RECORDER_STATE_CREATED);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __mode = _CAMERA_MODE_IMAGE;
+ __reloadCameraPreviewFormat = reloadCameraPreviewFormat;
+ if (callback)
+ {
+ r = NotifyModeChangePrepared(mode);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ r = ChangeCameraStateTo(::CAMERA_STATE_PREVIEW);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ break;
+
+ case ::RECORDER_STATE_RECORDING:
+ //fall through
+ case ::RECORDER_STATE_PAUSED:
+ err = recorder_cancel(__recorderHandle); // TODO
+ r = ConvertResult(err);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = ChangeRecorderStateTo(::RECORDER_STATE_CREATED);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ recorderDevice = __cameraDevice == _CAMERA_DEVICE_PRIMARY ?
+ _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA;
+
+ __mode = _CAMERA_MODE_IMAGE;
+ __reloadCameraPreviewFormat = reloadCameraPreviewFormat;
+ if (callback)
+ {
+ r = NotifyModeChangePrepared(mode);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ r = ChangeCameraStateTo(::CAMERA_STATE_PREVIEW);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (callback)
+ {
+ // Notify that the mode is changed to callback camera and video recorder's configurations.
+ r = NotifyModeChanged(mode);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+ return r;
+CATCH:
+ return r;
+}
+
+result
_CameraCoordinator::ChangeMode(_CameraMode mode, bool callback)
{
result r = E_SUCCESS;
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
}
+ __mode = _CAMERA_MODE_IMAGE;
err = camera_start_capture(__cameraHandle, capturingCb, completedCb, pUserData);
r = ConvertResult(err);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Camera capture failed.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
}
+ __mode = _CAMERA_MODE_VIDEO;
err = recorder_start(__recorderHandle);
r = ConvertResult(err);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Recorder record failed.", GetErrorMessage(r));
return r;
}
+camera_pixel_format_e
+_CameraCoordinator::GetReloadPreviewFormat(void) const
+{
+ SysLog(NID_MEDIA, "reloadCameraPreviewFormat is :%d", __reloadCameraPreviewFormat);
+ return __reloadCameraPreviewFormat;
+}
}}
result StopMmPreview(void);
/**
+ * Create videorecorder handle.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result CreateVideoRecorder(void);
+
+ /**
+ * Destory videorecorder handle.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result DestroyVideoRecorder(void);
+
+ /**
+ * Change camera source prview format.
+ *
+ * @return An error code
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
+ result ChangeFormat(_CameraMode mode, bool callback, camera_pixel_format_e reloadCameraPreviewFormat);
+
+
+ /**
* Changes the camcorder mode.
*
* @return An error code
*/
void SetCameraOrientation(CameraExifOrientation orientation);
+ /**
+ * Gets the reloaded preview format of the camera.
+ *
+ * @return An error code
+ */
+ camera_pixel_format_e GetReloadPreviewFormat(void) const;
+
private:
friend class _CameraCoordinatorSafeHashMapT;
/**
int __orientationFlag;
CameraExifOrientation __cameraOrientation;
RecordingRotation __recordingRotation;
+ camera_pixel_format_e __reloadCameraPreviewFormat;
static _CameraCoordinatorSafeHashMapT* __pMap;
};
{
result r = E_SUCCESS;
CameraState state = CAMERA_STATE_ERROR;
+ camera_pixel_format_e previewFormat = ::CAMERA_PIXEL_FORMAT_INVALID;
SysLog(NID_MEDIA, "Camera Capture");
SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on.");
if ( __pCoordinator->GetMode() != _CAMERA_MODE_IMAGE )
{
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, true);
- SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = _CameraUtil::GetMmPixelFormat(__previewFormat, previewFormat);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. __previewFormat:%d", GetErrorMessage(r), __previewFormat);
+ if (previewFormat != __pCoordinator->GetCameraSourceFormat())
+ {
+ r = __pCoordinator->ChangeFormat(_CAMERA_MODE_IMAGE, true, previewFormat);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
}
r = __pCoordinator->StartCapture(CaptureCb, CaptureCompletedCb, this);
return __zeroShutterLag;
}
+Tizen::Graphics::PixelFormat
+_CameraImpl::GetDeviceRecommendPreviewFormat(void) const
+{
+ return __deviceDefaultPreviewFormat;
+}
+
result
_CameraImpl::SetProperty(_CameraOperationType operation, int min, int max, int value)
{
}
if (reload & _RELOAD_INTERNAL_PREVIEW_FORMAT)
{
- err = camera_set_preview_format(__handle, __pCoordinator->GetCameraSourceFormat());
+ err = camera_set_preview_format(__handle, __pCoordinator->GetReloadPreviewFormat());
r = ConvertResult(err);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
}
*/
bool IsZeroShutterLag(void) const;
+
+ /**
+ * Gets the camera's recommened preview format
+ *
+ * @return recommened preview format
+ */
+ Tizen::Graphics::PixelFormat GetDeviceRecommendPreviewFormat(void) const;
+
/**
* Called when the event is received from the %_ICameraCoordinatorListener object.
*
{
if (__previousCameraMode == _CAMERA_MODE_IMAGE)
{
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, false);
+ r = __pCoordinator->DestroyVideoRecorder();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
}
SysLog(NID_MEDIA, "Release the recorder device:%d", __recorderDevice);
if (__pCoordinator->GetMode() == _CAMERA_MODE_IMAGE)
{
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+ r = __pCoordinator->CreateVideoRecorder();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
__previousCameraMode = _CAMERA_MODE_IMAGE;
}
if (cameraCount < 2)
{
targetRecorder = (runningCamera == _CAMERA_DEVICE_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+ r = __pCoordinator->CreateVideoRecorder();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
__previousCameraMode = _CAMERA_MODE_IMAGE;
}
if(__pCoordinator->IsCalmChangeMode(_CAMERA_MODE_VIDEO))
{
targetRecorder = (runningCamera == _CAMERA_DEVICE_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+ r = __pCoordinator->CreateVideoRecorder();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
__previousCameraMode = _CAMERA_MODE_IMAGE;
}
if(__pCoordinator->IsCalmChangeMode(_CAMERA_MODE_VIDEO))
{
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false);
+ r = __pCoordinator->CreateVideoRecorder();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
__previousCameraMode = _CAMERA_MODE_IMAGE;
}
}
if (__pCoordinator != null)
{
- __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, false);
+ if (__pVideoSourceAdapter != null)
+ {
+ if (__pVideoSourceAdapter->GetUserPreviewFormat() != __pCoordinator->GetCameraSourceFormat())
+ {
+ __pCoordinator->ChangeFormat(_CAMERA_MODE_IMAGE, true, __pVideoSourceAdapter->GetUserPreviewFormat());
+ }
+ }
+ __pCoordinator->DestroyVideoRecorder();
__pCoordinator->RemoveCameraCoordinatorListener(*this);
_CameraCoordinator::Release(__deviceType);
result r = E_SUCCESS;
Tizen::Media::Camera* pCamera = null;
Tizen::Media::_CameraImpl* pCamImpl = null;
- _CameraHandle cameraHandle = MM_INVALID_HANDLE;
int err = MM_SUCCESS;
int streamFps = 0;
_CapabilityImpl* pCapabilityImpl = null;
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
//If the reload flag is true, the __handle will be updated in the OnCameraCoordinatorModeChangePrepared(), otherwise the __handle should be updated manually.
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, false); // Do not reload. The __mmSourceFormat is not set yet.
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder Mode change failed.", GetErrorMessage(r));
+ r = __pCoordinator->CreateVideoRecorder(); // Do not reload. The __mmSourceFormat is not set yet.
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] CreateVideoRecorder failed.", GetErrorMessage(r));
__handle = __pCoordinator->GetRecorderHandle();
- cameraHandle = __pCoordinator->GetCameraHandle();
- r = __pVideoSourceAdapter->SetRecommendPreviewFormat(cameraHandle);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video adapter SetRecommendPreviewFormat failed.", GetErrorMessage(r));
err = recorder_set_state_changed_cb(__handle, StateChangedCb, this);
r = ConvertResult(err);
state = GetState();
SysTryReturn(NID_MEDIA, state == RECORDER_STATE_INITIALIZED || state == RECORDER_STATE_CLOSED,
- E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state.");
+ E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state(%d).", state);
std::unique_ptr<char[]> pFileName (_StringConverter::CopyToCharArrayN(mediaLocalPath));
SysTryCatch(NID_MEDIA, pFileName.get() != null, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(mediaLocalPath) is used. File name is null.");
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder prepare file failed. mediaLocalPath:%s, overwirte:%d",
GetErrorMessage(r), pFileName.get(), overwrite);
- if (__handle != MM_INVALID_HANDLE)
- {
- err = recorder_set_filename(__handle, pFileName.get());
- r = ConvertResult(err);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
- }
+ err = recorder_set_filename(__handle, pFileName.get());
+ r = ConvertResult(err);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SetState(RECORDER_STATE_OPENED);
- if (__handle != MM_INVALID_HANDLE)
- {
- // re-configuration for new recorder handle
- r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY | _RELOAD_MAX_TIME | _RELOAD_INIT | _RELOAD_ROTATION);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration failed", GetErrorMessage(r));
- }
+ // re-configuration for new recorder handle
+ r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY | _RELOAD_MAX_TIME | _RELOAD_INIT | _RELOAD_ROTATION);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration failed", GetErrorMessage(r));
__filePath = mediaLocalPath;
return r;
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Camera mode change failed.", GetErrorMessage(r));
// If the preview data format is changed, the properties should be set again.
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, true);
+ r = __pCoordinator->ChangeFormat(_CAMERA_MODE_VIDEO, true, __mmSourceFormat);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder Mode change failed.", GetErrorMessage(r));
}
else if ( __pCoordinator->GetMode() != _CAMERA_MODE_VIDEO )
{
- SysLog(NID_MEDIA, "Current mode is IMAGE. It should be moved to VIDEO mode.");
+ SysLog(NID_MEDIA, "Current Preview mm format format is default mm format format (%d). ", __pCoordinator->GetCameraSourceFormat());
__mmSourceFormat = __pCoordinator->GetCameraSourceFormat();
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_VIDEO, true);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder Mode change failed.", GetErrorMessage(r));
+
+ r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY | _RELOAD_MAX_TIME | _RELOAD_FILE_PATH | _RELOAD_CALLBACK | _RELOAD_MUTE | _RELOAD_ROTATION);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
}
mmState = GetMmState();
SysTryReturn(NID_MEDIA, msTime > 0, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] msTime is out of range. msTime:%d must be greater than 0.",
msTime);
- if (__handle != MM_INVALID_HANDLE)
- {
- r = SetMaxRecordingTimeAttr(msTime);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder set max recording time failed. msTime:%ls", GetErrorMessage(r), msTime);
- }
+ r = SetMaxRecordingTimeAttr(msTime);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder set max recording time failed. msTime:%ls", GetErrorMessage(r), msTime);
// For reload and Get the exact value
__maxTime = msTime;
SysTryCatch(NID_MEDIA, audioCodec != CODEC_NONE && videoCodec != CODEC_NONE, r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC
, "[E_UNSUPPORTED_CODEC]. This codec(%ls) is not supported in the device.\n", codec.GetPointer());
- if (__handle != MM_INVALID_HANDLE)
- {
- r = SetFormatAttr(audioCodec, videoCodec, container);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set failed. audioCodec:0x%x videoCodec:0x%x container:0x%x",
+ r = SetFormatAttr(audioCodec, videoCodec, container);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set failed. audioCodec:0x%x videoCodec:0x%x container:0x%x",
GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
- }
__audioCodec = audioCodec;
__videoCodec = videoCodec;
__container = container;
- if (__handle != MM_INVALID_HANDLE)
- {
- // Call the dependency function.
- r = ReloadConfiguration(_RELOAD_QUALITY);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
- }
+ // Call the dependency function.
+ r = ReloadConfiguration(_RELOAD_QUALITY);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
CATCH:
return r;
SysTryCatch(NID_MEDIA, audioCodec != CODEC_NONE && videoCodec != CODEC_NONE, r = E_UNSUPPORTED_CODEC, E_UNSUPPORTED_CODEC
, "[E_UNSUPPORTED_CODEC]. This format(%d) is not supported in the device.\n", format);
- if (__handle != MM_INVALID_HANDLE)
- {
- r = SetFormatAttr(audioCodec, videoCodec, container);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set failed. audioCodec:0x%x videoCodec:0x%x container:0x%x",
- GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
- }
+ r = SetFormatAttr(audioCodec, videoCodec, container);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set failed. audioCodec:0x%x videoCodec:0x%x container:0x%x",
+ GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
+
__format = format;
__audioCodec = audioCodec;
__videoCodec = videoCodec;
__container = container;
- if (__handle != MM_INVALID_HANDLE)
- {
- // Call the dependency function.
- r = ReloadConfiguration(_RELOAD_QUALITY);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
- }
+ // Call the dependency function.
+ r = ReloadConfiguration(_RELOAD_QUALITY);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
+
return r;
CATCH:
audioCodec, videoCodec,
container);
- if (__handle != MM_INVALID_HANDLE)
- {
- r = SetFormatAttr(audioCodec, videoCodec, container);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set failed. audioCodec:0x%x videoCodec:0x%x container:0x%x",
+ r = SetFormatAttr(audioCodec, videoCodec, container);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] File format set failed. audioCodec:0x%x videoCodec:0x%x container:0x%x",
GetErrorMessage(r), audioCodec, videoCodec, videoCodec);
- }
+
__audioCodec = audioCodec;
__videoCodec = videoCodec;
__container = container;
- if (__handle != MM_INVALID_HANDLE)
- {
- // Call the dependency function.
- r = ReloadConfiguration(_RELOAD_QUALITY);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
- }
+ // Call the dependency function.
+ r = ReloadConfiguration(_RELOAD_QUALITY);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder reload configuration.", GetErrorMessage(r));
CATCH:
return r;
GetFormat(audioCodec, videoCodec, container);
- if (__handle != MM_INVALID_HANDLE)
- {
- r = SetQualityAttr(quality, audioCodec, videoCodec);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] set quality failed. quality:%d", GetErrorMessage(r), quality);
- }
+ r = SetQualityAttr(quality, audioCodec, videoCodec);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] set quality failed. quality:%d", GetErrorMessage(r), quality);
__quality = quality;
return r;
|| state == RECORDER_STATE_STOPPED || state == RECORDER_STATE_PAUSED || state == RECORDER_STATE_RECORDING
, E_INVALID_STATE, r, "[E_INVALID_STATE] VideoRecorder is in an invalid state:%d.", state);
- if (__handle != MM_INVALID_HANDLE)
- {
- r = SetMuteAttr(mute);
- SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. mute:%d", GetErrorMessage(r), mute);
- }
+
+ r = SetMuteAttr(mute);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. mute:%d", GetErrorMessage(r), mute);
__mute = mute;
return r;
}
SysTryReturn(NID_MEDIA, (rotation >= RECORDING_ROTATION_NONE&& rotation <= RECORDING_ROTATION_270)
, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(rotation) is used. The rotation=%d.", rotation);
- if (__handle != MM_INVALID_HANDLE)
- {
- __pCoordinator->SetRecordingOrientation(rotation);
- }
+ __pCoordinator->SetRecordingOrientation(rotation);
__rotation = rotation;
return r;
if ( mode == _CAMERA_MODE_VIDEO )
{
- r = __pCoordinator->SetCameraSourceFormat(__mmSourceFormat);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
r = ReloadConfiguration(_RELOAD_FORMAT | _RELOAD_QUALITY);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
}
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
- _CameraCoordinator* __pCoordinator = null;
- __pCoordinator = _CameraCoordinator::AddInstance(pImpl->GetDeviceType());
- SysTryCatch(NID_MEDIA, __pCoordinator != null, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraCoordinator instance is not available. Coordinator is not found");
-
- r = __pCoordinator->ChangeMode(_CAMERA_MODE_IMAGE, true);
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- _CameraCoordinator::Release(pImpl->GetDeviceType());
-
r = pImpl->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- return;
CATCH:
return;
}
#include "FMedia_CameraCapability.h"
#include "FMedia_CameraImpl.h"
#include "FMedia_CamPtrUtil.h"
-
-//#define _SAFE_VIDEO_FORMAT_
+#include "FMedia_CameraUtil.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
{
__pSource = const_cast<_CameraImpl*>(&cameraImpl);
__sourceType = _VIDEO_SOURCE_CAMERA;
- __recommendPreviewFormat = CAMERA_PIXEL_FORMAT_NV12;
}
_VideoSourceAdapter::~_VideoSourceAdapter()
{
result r = E_SUCCESS;
std::unique_ptr <ArrayListT<camera_pixel_format_e>, _ListPtrUtil::Remover> pListT (null, _ListPtrUtil::remover);
- camera_pixel_format_e recommendPreviewFormat = CAMERA_PIXEL_FORMAT_NV12;
+ camera_pixel_format_e recommendPreviewFormat = ::CAMERA_PIXEL_FORMAT_INVALID;
if (__sourceType == _VIDEO_SOURCE_CAMERA)
{
+ Tizen::Graphics::PixelFormat recommendPreviewPixelFormat;
+ _CameraImpl* pCameraImpl = null;
+ pCameraImpl = dynamic_cast<_CameraImpl*>(__pSource);
+ SysTryReturn(NID_MEDIA, pCameraImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. This is not the camera object.");
+
pListT.reset(new (std::nothrow) ArrayListT<camera_pixel_format_e>());
SysTryReturn(NID_MEDIA, pListT.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. out of memory");
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating", GetErrorMessage(r));
// This means that the device supports recommeded format for the recording.
- recommendPreviewFormat = __recommendPreviewFormat;
+ recommendPreviewPixelFormat = pCameraImpl->GetDeviceRecommendPreviewFormat();
+ SysLog(NID_MEDIA, "Enter. recommendPreview Osp PixelFormat:%d", recommendPreviewPixelFormat);
+
+ r = _CameraUtil::GetMmPixelFormat(recommendPreviewPixelFormat, recommendPreviewFormat);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating. previewPixelFormat:%d", GetErrorMessage(r), recommendPreviewFormat);
+
r = pListT->Add(recommendPreviewFormat);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating", GetErrorMessage(r));
+
+ SysLog(NID_MEDIA, "recommendPreview MM Format:%d", recommendPreviewFormat);
}
return pListT.release();
return Dimension(0, 0);
}
+camera_pixel_format_e
+_VideoSourceAdapter::GetUserPreviewFormat(void) const
+{
+ result r = E_SUCCESS;
+ Tizen::Graphics::PixelFormat previewPixelFormat;
+ camera_pixel_format_e previewFormat = ::CAMERA_PIXEL_FORMAT_INVALID;
+
+ if (__sourceType == _VIDEO_SOURCE_CAMERA)
+ {
+ _CameraImpl* pCameraImpl = null;
+ pCameraImpl = dynamic_cast<_CameraImpl*>(__pSource);
+ SysTryCatch(NID_MEDIA, pCameraImpl != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. This is not the camera object.");
+
+ previewPixelFormat = pCameraImpl->GetPreviewFormat();
+ SysLog(NID_MEDIA, "Enter. previewPixelFormat:%d", previewPixelFormat);
+
+ r = _CameraUtil::GetMmPixelFormat(previewPixelFormat, previewFormat);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. previewPixelFormat:%d", GetErrorMessage(r), previewPixelFormat);
+ }
+
+ return previewFormat;
+
+CATCH:
+ return previewFormat;
+}
+
bool
_VideoSourceAdapter::HasRecordingResolutionRestriction(void) const
{
return restriction;
}
-
-result
-_VideoSourceAdapter::SetRecommendPreviewFormat(_CameraHandle cameraHandle)
-{
- int err = MM_SUCCESS;
- result r = E_SUCCESS;
-#if defined _SAFE_VIDEO_FORMAT_
- camera_pixel_format_e recommendPreviewFormat = CAMERA_PIXEL_FORMAT_I420;
-#else
- camera_pixel_format_e recommendPreviewFormat = CAMERA_PIXEL_FORMAT_NV12;
-
- err = camera_get_preview_format(cameraHandle, &recommendPreviewFormat);
- SysTryCatch(NID_MEDIA, err == MM_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Getting the Recommend Preview Format error.");
-#endif
- __recommendPreviewFormat = recommendPreviewFormat;
- err = camera_set_preview_format(cameraHandle, __recommendPreviewFormat);
-
- SysLog(NID_MEDIA, "the Recommend Preview Format:%d", __recommendPreviewFormat);
- return r;
-CATCH:
- return r;
-}
}}
*/
Tizen::Graphics::Dimension GetSourceResolution(void) const;
+ camera_pixel_format_e GetUserPreviewFormat(void) const;
+
/**
* Check if the source has the restriction of recording resolution.
*
* else @c false
*/
bool HasRecordingResolutionRestriction(void) const;
- /**
- * Set the recommended preview format for videorecord.
- *
- * @return An error code
- * @param[in] mode _CameraHandle
- * @exception E_SUCCESS The method is successful.
- * @exception E_SYSTEM A system error has occurred.
- * @remarks The specific error code can be accessed using the GetLastResult() method.
- */
- result SetRecommendPreviewFormat(_CameraHandle cameraHandle);
-
private:
Tizen::Base::Object* __pSource;
_VideoSourceType __sourceType;
- camera_pixel_format_e __recommendPreviewFormat;
};
}}// Tizen::Media