src/FMedia_CameraManager.cpp
src/FMedia_CameraCapabilitySession.cpp
src/FMedia_CameraBuffer.cpp
+ src/FMedia_CamRef.cpp
+ src/FMedia_CameraRef.cpp
+ src/FMedia_RecorderRef.cpp
src/FMediaAudioRecorder.cpp
src/FMedia_AudioRecorderImpl.cpp
src/FMedia_AudioRecorderEvent.cpp
#include "FMedia_RecorderManager.h"
#include "FMedia_CamPtrUtil.h"
#include "FMedia_AudioStreamCoordinator.h"
+#include "FMedia_RecorderRef.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
{::RECORDER_STATE_READY, ::RECORDER_STATE_CREATED, _RECORDER_STATE_REASON_NORMAL, _RECORDER_EVENT_CLOSED, RECORDER_ERROR_NONE },
};
-bool _AudioRecorderImpl::__isUsed = false;
-
_AudioRecorderImpl::_AudioRecorderImpl(void)
- : __pAudioRecorderEvent(null)
+ : __pRecorderRef(null)
+ , __pAudioRecorderEvent(null)
, __pAudioRecorderEventListener(null)
, __pRecorderManager(null)
, __isConstructed(false)
_RecorderManager::Release(_RECORDER_DEVICE_AUDIO);
}
- if (__isConstructed)
- {
- __isUsed = false;
- }
-
SysLog(NID_MEDIA, "Destroyed");
}
SysLog(NID_MEDIA, "Starting Audio Recorder construct.");
- SysTryReturn(NID_MEDIA, !__isUsed, E_DEVICE_BUSY, E_DEVICE_BUSY,
- "[E_DEVICE_BUSY] _AudioRecorderImpl is now being used.");
SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] AudioRecorder is in an invalid state. A device is already constructed.");
+ // Register this object to _RecorderRef
+ __pRecorderRef.reset(new (std::nothrow) _RecorderRef());
+ SysTryCatch(NID_MEDIA, __pRecorderRef.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = __pRecorderRef->Construct(*this, _RECORDER_DEVICE_AUDIO);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
//Create Event
__pAudioRecorderEvent.reset(new (std::nothrow) _AudioRecorderEvent());
- SysTryReturn(NID_MEDIA, __pAudioRecorderEvent.get() !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, __pAudioRecorderEvent.get() !=null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pAudioRecorderEvent->Construct(*this);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
// Create audio stream coordinator
__pAudioStreamCoordinator.reset(new (std::nothrow) _AudioStreamCoordinator());
- SysTryCatch(NID_MEDIA, __pAudioStreamCoordinator.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, __pAudioStreamCoordinator.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pAudioStreamCoordinator->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
pCapabilityImpl = _CapabilityImpl::GetInstance();
SysTryCatch(NID_MEDIA, pCapabilityImpl != null, r= E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Capability is not obtained.");
- // Get the capability
- r = pCapabilityImpl->GetValue(String(L"AudioRecorder.Device.fps"), streamFps);
- //SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- streamFps = 50;
-
- if (streamFps != 0)
- {
- __audioStreamTimeDuration = (1000/streamFps); //Time duration in milisec
- }
-
__pRecorderManager = _RecorderManager::AddInstance(_RECORDER_DEVICE_AUDIO);
r = GetLastResult();
SysTryCatch(NID_MEDIA, __pRecorderManager != null, , r, "[%s] audio recorder creation failed");
-
__handle = __pRecorderManager->GetHandle();
+ // Get the audio stream fps
+ r = pCapabilityImpl->GetValue(AUDIORECORDER_DEVICE_FPS, streamFps);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS && streamFps > 0, , r, "[%s] Propagating. fps:%d", GetErrorMessage(r), streamFps);
+ __audioStreamTimeDuration = (1000/streamFps); //Time duration in milisec
+
err = recorder_set_state_changed_cb(__handle, StateChangedCb, this);
r = ConvertResult(err);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] audio recorder set message callback failed.", GetErrorMessage(r));
SetState(RECORDER_STATE_INITIALIZED);
__isConstructed = true;
- __isUsed = true;
return r;
CATCH:
__pAudioRecorderEventListener = null;
}
+ __pRecorderRef.reset(null);
__pAudioRecorderEvent.reset(null);
+ __pAudioStreamCoordinator.reset(null);
return r;
}
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list is empty.");
std::unique_ptr <ArrayListT<CodecType>, _ListPtrUtil::Remover> pAudioCodecList (new (std::nothrow) ArrayListT<CodecType>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pAudioCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pAudioCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pAudioCodecList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list is empty.");
std::unique_ptr <ArrayListT<MediaContainerType>, _ListPtrUtil::Remover> pContainerList (new (std::nothrow) ArrayListT<MediaContainerType>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pContainerList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pContainerList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pContainerList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
_AudioRecorderImpl::StateChangedCb(recorder_state_e previous, recorder_state_e current, bool byPolicy, void* pUserData)
{
result r = E_SUCCESS;
- _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>( pUserData);
+ _AudioRecorderImpl* pImpl = static_cast<_AudioRecorderImpl*>( pUserData);
int tableTotalCount = 0;
int i = 0;
- SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
- SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+ SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
tableTotalCount = sizeof(_AUDIO_CALLBACK_EVENT) / sizeof(_AUDIO_CALLBACK_EVENT[0]);
for (i = 0; i < tableTotalCount; i++)
{
- if (previous == _AUDIO_CALLBACK_EVENT[i].prevState && current == _AUDIO_CALLBACK_EVENT[i].postState && pObj->GetStateChangeReason() == _AUDIO_CALLBACK_EVENT[i].reason)
+ if (previous == _AUDIO_CALLBACK_EVENT[i].prevState && current == _AUDIO_CALLBACK_EVENT[i].postState && pImpl->GetStateChangeReason() == _AUDIO_CALLBACK_EVENT[i].reason)
{
- r = pObj->GetEvent()->SendEvent(_AUDIO_CALLBACK_EVENT[i].event, _AUDIO_CALLBACK_EVENT[i].error, E_SUCCESS);
+ r = pImpl->GetEvent()->SendEvent(_AUDIO_CALLBACK_EVENT[i].event, _AUDIO_CALLBACK_EVENT[i].error, E_SUCCESS);
SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating. i:%d", GetErrorMessage(r), i);
break;
}
void
_AudioRecorderImpl::RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData)
{
- _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
- SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+ _AudioRecorderImpl* pImpl = static_cast<_AudioRecorderImpl*>(pUserData);
+ SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, " FileSize:%llu,elapsedTime:%llu",fileSize,elapsedTime);
- pObj->SetRecordingTime((long)elapsedTime);
- pObj->SetRecordingSize((long)fileSize);
+ pImpl->SetRecordingTime((long)elapsedTime);
+ pImpl->SetRecordingSize((long)fileSize);
}
void
_AudioRecorderImpl::AudioStreamCb(void* pStream, int size, audio_sample_type_e format, int channel, unsigned int timeStamp, void *pUserData)
{
- _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
+ _AudioRecorderImpl* pImpl = static_cast<_AudioRecorderImpl*>(pUserData);
int samplingRate =0;
- SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
- SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+ SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pStream != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. Stream data is null.");
- if (pObj->__audioStreamCallback == true)
+ if (pImpl->__audioStreamCallback == true)
{
- samplingRate = _RecorderUtil::CalculateSampleRate(size, channel, pObj->__audioStreamTimeDuration, _RecorderUtil::GetOspSampleType(format));
- (pObj->__pAudioStreamCoordinator)->ProcessAudioStreamData((byte*)pStream, size, samplingRate, _RecorderUtil::GetOspChannelType(channel), _RecorderUtil::GetOspSampleType(format));
+ samplingRate = _RecorderUtil::CalculateSampleRate(size, channel, pImpl->__audioStreamTimeDuration, _RecorderUtil::GetOspSampleType(format));
+ (pImpl->__pAudioStreamCoordinator)->ProcessAudioStreamData((byte*)pStream, size, samplingRate, _RecorderUtil::GetOspChannelType(channel), _RecorderUtil::GetOspSampleType(format));
}
}
_AudioRecorderImpl::LimitReachedCb(recorder_recording_limit_type_e type, void *pUserData)
{
result r = E_SUCCESS;
- _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
- SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
+ _AudioRecorderImpl* pImpl = static_cast<_AudioRecorderImpl*>(pUserData);
+ SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "Type:%d", type);
{
case ::RECORDER_RECORDING_LIMIT_TIME:
{
- r = pObj->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED);
+ r = pImpl->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_TIME_REACHED);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
}
break;
case ::RECORDER_RECORDING_LIMIT_SIZE:
{
- r = pObj->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED);
+ r = pImpl->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_END_SIZE_REACHED);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
}
break;
case ::RECORDER_RECORDING_LIMIT_FREE_SPACE:
{
- r = pObj->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_OUT_OF_STORAGE);
+ r = pImpl->ChangeStateTo(::RECORDER_STATE_READY, _RECORDER_STATE_REASON_OUT_OF_STORAGE);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
- r = pObj->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_OUT_OF_STORAGE, E_STORAGE_FULL);
+ r = pImpl->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_OUT_OF_STORAGE, E_STORAGE_FULL);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
}
break;
_AudioRecorderImpl::ErrorCb(recorder_error_e error, recorder_state_e state, void *pUserData)
{
result r = E_SUCCESS;
- _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
- SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pObj is null.");
+ _AudioRecorderImpl* pImpl = static_cast<_AudioRecorderImpl*>(pUserData);
+ SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _AudioRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
- r = pObj->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
+ r = pImpl->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
return;
void
_AudioRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData)
{
- _AudioRecorderImpl* pObj = static_cast<_AudioRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _AudioRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
- SysTryReturnVoidResult(NID_MEDIA, pObj != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pObj _AudioRecorderImpl is not available. pObj is null.");
+ _AudioRecorderImpl* pImpl = static_cast<_AudioRecorderImpl*>(pUserData);
+ SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] pImpl _AudioRecorderImpl is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "Policy:%d, previous:%d, current:%d", policy, previous, current);
}
-bool
-_AudioRecorderImpl::IsAlive(void)
-{
- return __isUsed;
-}
-
_AudioRecorderImpl*
_AudioRecorderImpl::GetInstance(AudioRecorder *pAudioRecorder)
{
{
class AudioRecorder;
class IAudioRecorderEventListener;
+class _RecorderRef;
class _AudioRecorderEvent;
class _RecorderManager;
class _AudioStreamCoordinator;
static void InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData);
/**
- * Function check fo this object is alive.
- *
- * @return true if the object is alive, otherwise false.
- */
- static bool IsAlive(void);
-
- /**
* Gets the Impl instance.
*
* @return The pointer to %_AudioRecorderImpl
_AudioRecorderImpl(const _AudioRecorderImpl&);
_AudioRecorderImpl& operator =(const _AudioRecorderImpl& _AudioRecorderImpl);
+ std::unique_ptr <_RecorderRef> __pRecorderRef;
std::unique_ptr <_AudioRecorderEvent> __pAudioRecorderEvent;
IAudioRecorderEventListener* __pAudioRecorderEventListener;
_RecorderManager* __pRecorderManager;
bool __mute;
_RecorderHandle __handle;
_RecorderStateChangeReason __stateChangeReason;
- static bool __isUsed;
std::unique_ptr <_AudioStreamCoordinator> __pAudioStreamCoordinator;
int __audioStreamTimeDuration;
bool __audioStreamCallback;
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FMedia_CamRef.cpp
+ * @brief This file contains the implementation of the %_CamRef class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include "FMedia_CamRef.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+IList* _CamRef::__pList = null;
+
+_CamRef::_CamRef(void)
+:__pObj(null)
+{
+}
+
+_CamRef::~_CamRef(void)
+{
+ if (__pObj != null)
+ {
+ UnRegisterObject(*__pObj);
+ }
+}
+
+result
+_CamRef::Construct(const Tizen::Base::Object& obj)
+{
+ result r = E_SUCCESS;
+ r = RegisterObject(obj);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ __pObj = const_cast<Tizen::Base::Object*>(&obj);
+ return r;
+}
+
+void
+_CamRef::InitSingleton()
+{
+ result r = E_SUCCESS;
+ std::unique_ptr <ArrayList> pList (new (std::nothrow) ArrayList());
+ SysTryReturnVoidResult(NID_MEDIA, pList.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = pList->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pList = pList.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_CamRef::DestroySingleton(void)
+{
+ delete __pList;
+}
+
+bool
+_CamRef::IsAlive(const Tizen::Base::Object& obj)
+{
+ SysTryReturn(NID_MEDIA, __pList != null, false, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Any object was not found.");
+ return __pList->Contains(obj);
+}
+
+result
+_CamRef::RegisterObject(const Tizen::Base::Object& obj)
+{
+ result r = E_SUCCESS;
+
+ static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+ if (!__pList)
+ {
+ pthread_once(&once_block, InitSingleton);
+ r = GetLastResult();
+ SysTryReturn(NID_MEDIA, __pList != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ r = __pList->Add(const_cast<Tizen::Base::Object*>(&obj));
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
+}
+
+void
+_CamRef::UnRegisterObject(const Tizen::Base::Object& obj)
+{
+ result r = E_SUCCESS;
+ SysTryReturnVoidResult(NID_MEDIA, __pList != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] No object has been registered.");
+
+ r = __pList->Remove(obj);
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+}
+
+}}// Tizen::Media
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FMedia_CamRef.h
+ * @brief This header file contains the declarations of the %_CamRef class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAM_REF_H_
+#define _FMEDIA_INTERNAL_CAM_REF_H_
+
+#include <FBaseColIList.h>
+#include <FBaseObject.h>
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class _CamRef
+ * @brief This class implements the _CamRef class.
+ */
+class _CamRef
+ : public Tizen::Base::Object
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to
+ * initialize this instance.
+ * @see Construct()
+ */
+ _CamRef(void);
+
+ /**
+ * This is the destructor for this class.
+ */
+ virtual ~_CamRef(void);
+
+ /**
+ * Initializes this instance of _CamRef.
+ *
+ * @return An error code
+ * @param[in] obj The object
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ */
+ result Construct(const Tizen::Base::Object& obj);
+
+ /**
+ * Check the object is alive
+ *
+ * @return The pointer of Object instance
+ * @param[in] obj The object
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified obj is not found.
+ */
+ static bool IsAlive(const Tizen::Base::Object& obj);
+private:
+ /**
+ * Register an instance of Object to the list.
+ *
+ * @return An error code
+ * @param[in] obj The object pointer
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ */
+ result RegisterObject(const Tizen::Base::Object& obj);
+
+ /**
+ * Unregister the specific instance of Object from the list.
+ *
+ * @param[in] obj The object pointer
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified obj is not found.
+ */
+ void UnRegisterObject(const Tizen::Base::Object& obj);
+
+ _CamRef(const _CamRef& rhs);
+ _CamRef& operator =(const _CamRef& rhs);
+
+ Tizen::Base::Object* __pObj;
+
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+ static Tizen::Base::Collection::IList* __pList;
+};
+
+}}// Tizen::Media
+
+#endif
}
void
-_CameraCapability::InitSafeHashMapInst()
+_CameraCapability::InitSingleton()
{
- static _CameraCapabilitySafeHashMapT map;
result r = E_SUCCESS;
+ std::unique_ptr <_CameraCapabilitySafeHashMapT> pMap (new (std::nothrow) _CameraCapabilitySafeHashMapT());
+ SysTryReturnVoidResult(NID_MEDIA, pMap.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
- r = map.Construct();
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pMap->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- __pMap = ↦
- return;
-CATCH:
- __pMap = null;
+ __pMap = pMap.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_CameraCapability::DestroySingleton(void)
+{
+ delete __pMap;
}
_CameraCapability*
if (!__pMap)
{
- pthread_once(&once_block, InitSafeHashMapInst);
+ pthread_once(&once_block, InitSingleton);
r = GetLastResult();
SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
}
static bool SupportedCameraAttrMeteringModeCb(camera_attr_exposure_mode_e mode, void *pUserData);
static bool SupportedCameraAttrAfModeCb(camera_attr_af_mode_e mode, void *pUserData);
- static void InitSafeHashMapInst(void);
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
static _CameraCapabilitySafeHashMapT* __pMap;
static const keyServiceMap __SERVICE_MAP[];
_CameraCapabilitySession::~_CameraCapabilitySession(void)
{
_CameraCapability::Release(__cameraDevice);
- SysLog(NID_MEDIA, "Capability handle released");
+// SysLog(NID_MEDIA, "Capability handle released");
}
result
_CameraCapabilitySession::Construct(_CameraDeviceType cameraDevice)
{
result r = E_SUCCESS;
- SysLog(NID_MEDIA, "Enter. camera device:%d", cameraDevice);
+// SysLog(NID_MEDIA, "Enter. camera device:%d", cameraDevice);
__pCameraCapability = _CameraCapability::AddInstance(cameraDevice);
SysTryCatch(NID_MEDIA, __pCameraCapability != null, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. __pCameraCapability instance must not be null.");
}
}
+void
+_CameraCoordinator::InitSingleton()
+{
+ result r = E_SUCCESS;
+ std::unique_ptr <_CameraCoordinatorSafeHashMapT> pMap (new (std::nothrow) _CameraCoordinatorSafeHashMapT());
+ SysTryReturnVoidResult(NID_MEDIA, pMap.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = pMap->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pMap = pMap.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_CameraCoordinator::DestroySingleton(void)
+{
+ delete __pMap;
+}
+
_CameraCoordinator*
_CameraCoordinator::AddInstance(_CameraDeviceType cameraDevice)
{
bool out = false;
ClearLastResult();
- static bool isMapConstructed = false;
- static _CameraCoordinatorSafeHashMapT map;
_CameraCoordinator* pCoordinator = null;
SysTryReturn(NID_MEDIA, cameraDevice > _CAMERA_DEVICE_NONE && cameraDevice < _CAMERA_DEVICE_MAX,
null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(camderDevice) is used. camderDevice:%d is wrong.", cameraDevice);
- if (!isMapConstructed)
+ static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+ if (!__pMap)
{
- r = map.Construct();
- SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
- isMapConstructed = true;
- __pMap = ↦
+ pthread_once(&once_block, InitSingleton);
+ r = GetLastResult();
+ SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
}
- r = map.ContainsKey(cameraDevice, out);
+ r = __pMap->ContainsKey(cameraDevice, out);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
if (out)
{
- r = map.GetValue(cameraDevice, pCoordinator);
+ r = __pMap->GetValue(cameraDevice, pCoordinator);
SysTryReturn(NID_MEDIA, r == E_SUCCESS && pCoordinator != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
}
else
r = pCoord->Construct(cameraDevice);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
- r = map.Add(cameraDevice, pCoord.get());
+ r = __pMap->Add(cameraDevice, pCoord.get());
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
pCoordinator = pCoord.release();
std::unique_ptr<Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>, _ListPtrUtil::Remover> __pListenerList;
camera_pixel_format_e __reloadCameraPreviewFormat;
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
static _CameraCoordinatorSafeHashMapT* __pMap;
};
#include "FMedia_CameraCoordinator.h"
#include "FMedia_CapabilityImpl.h"
#include "FMedia_VideoStreamCoordinator.h"
+#include "FMedia_CameraRef.h"
#define _CAMERA_EVAS_PIXMAP_ 1
static const int _MAX_PROPERTY = 9;
static const int _INVALID_FOCUS_COORDINATE = -1;
-bool _CameraImpl::__isUsed = false;
-
enum _FocusModeOperation
{
_FOCUS_MODE_OP_NONE,
, __pCameraCapability(null)
, __state(CAMERA_STATE_INITIALIZED)
, __handle(MM_INVALID_HANDLE)
+ , __pCameraRef(null)
, __pCameraEvent(null)
, __pVideoStreamCoordinator(null)
, __pCameraEventListener(null)
_CameraCapability::Release(__deviceType);
}
- if ( __isConstructed )
- {
- __isUsed = false;
- }
-
SysLog(NID_MEDIA, "Destroyed");
}
{
result r = E_SUCCESS;
int err = MM_SUCCESS;
+ int direction = 0;
+ int rotation = 0;
+ int focusPoint = 0;
SysLog(NID_MEDIA, "Enter. camSel:%d", camSel);
- SysTryReturn(NID_MEDIA, !__isUsed, E_DEVICE_BUSY, E_DEVICE_BUSY, "[E_DEVICE_BUSY] A camera device is already used.");
SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] _CameraImpl is in an invalid state. A camera device is already constructed.");
SysTryReturn(NID_MEDIA, camSel >= CAMERA_PRIMARY && camSel <= CAMERA_SECONDARY, E_DEVICE_UNAVAILABLE, E_DEVICE_UNAVAILABLE, "[E_DEVICE_UNAVAILABLE] The camsel(%d) is invalid.", camSel);
SysTryReturn(NID_MEDIA, camSel < cameraCount, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The camSel(%d) is not available.", camSel);
__selection = camSel;
+ __deviceType = (camSel == CAMERA_PRIMARY ? _CAMERA_DEVICE_PRIMARY : _CAMERA_DEVICE_SECONDARY);
+
+ // Register this object to _CameraRef
+ __pCameraRef.reset(new (std::nothrow) _CameraRef());
+ SysTryCatch(NID_MEDIA, __pCameraRef.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = __pCameraRef->Construct(*this, __deviceType);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
// Get the _CameraCapability.
// This is just for the performance enhancement by incrementing ref counts of _CameraCapability.
// It forbiddens creating and deleting the _CameraCapability object repeatedly.
- __deviceType = (camSel == CAMERA_PRIMARY ? _CAMERA_DEVICE_PRIMARY : _CAMERA_DEVICE_SECONDARY);
__pCameraCapability = _CameraCapability::AddInstance(__deviceType);
SysTryReturn(NID_MEDIA, __pCameraCapability != null, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Capability instance is not available.");
- int direction = 0;
- int rotation = 0;
- int focusPoint = 0;
r = pCapabilityImpl->GetValue(camSel == CAMERA_PRIMARY ? String(L"Camera.Primary.Direction") : String(L"Camera.Secondary.Direction"), direction);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
__supportedFocusPointCount = focusPoint;
-// Create Event
+ // Create Event
__pCameraEvent.reset(new (std::nothrow) _CameraEvent());
- SysTryReturn(NID_MEDIA, __pCameraEvent.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, __pCameraEvent.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pCameraEvent->Construct(*this);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
__pCameraEventListener = &listener;
-// Video stream coordinator
+ // Video stream coordinator
__pVideoStreamCoordinator.reset(new (std::nothrow) _VideoStreamCoordinator());
- SysTryReturn(NID_MEDIA, __pVideoStreamCoordinator.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, __pVideoStreamCoordinator.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pVideoStreamCoordinator->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-// Prepare captured buffer list
+ // Prepare captured buffer list
__pCaptureBufferQueue.reset(new (std::nothrow) Tizen::Base::Collection::Queue());
- SysTryCatch(NID_MEDIA, __pCaptureBufferQueue.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, __pCaptureBufferQueue.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pCaptureBufferQueue->Construct(_MAX_CAPTURE_BUFFER_COUNT); // For async panorama shot.
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-// Prepare preview buffer list
+ // Prepare preview buffer list
__pPreviewBufferQueue.reset(new (std::nothrow) Tizen::Base::Collection::Queue());
- SysTryCatch(NID_MEDIA, __pPreviewBufferQueue.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, __pPreviewBufferQueue.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pPreviewBufferQueue->Construct(_MAX_PREVIEW_BUFFER_COUNT); // For async preview data.
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SetState(CAMERA_STATE_INITIALIZED);
__isConstructed = true;
- __isUsed = true;
return r;
CATCH:
if (__pCoordinator != null)
{
__pCoordinator->RemoveCameraCoordinatorListener(*this);
+ _CameraCoordinator::Release(__deviceType);
+ __pCoordinator = null;
+ }
+
+ if (__pCameraCapability != null)
+ {
+ _CameraCapability::Release(__deviceType);
+ __pCameraCapability = null;
}
if (__pCameraEventListener != null)
__pCameraEventListener = null;
}
+ __pCameraRef.reset(null);
__pCameraEvent.reset(null);
__pVideoStreamCoordinator.reset(null);
__pCaptureBufferQueue.reset(null);
+ __pPreviewBufferQueue.reset(null);
return r;
}
//Create new list
std::unique_ptr <_MediaSafeArrayList, _ListPtrUtil::Remover> pFocusPointList (new (std::nothrow) _MediaSafeArrayList(), _ListPtrUtil::remover);
- SysTryCatch(NID_MEDIA, pFocusPointList.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, pFocusPointList.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pFocusPointList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr <Tizen::Base::Collection::ArrayListT<Tizen::Graphics::PixelFormat>, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) ArrayListT<Tizen::Graphics::PixelFormat>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pFormatList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr <Tizen::Base::Collection::ArrayListT<Tizen::Graphics::PixelFormat>, _ListPtrUtil::Remover> pFormatList (new (std::nothrow) ArrayListT<Tizen::Graphics::PixelFormat>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pFormatList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pFormatList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr <Tizen::Base::Collection::ArrayListT<int>, _ListPtrUtil::Remover> pListT (new (std::nothrow) ArrayListT<int>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pListT.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pListT.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pListT->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr <Tizen::Base::Collection::ArrayListT<int>, _ListPtrUtil::Remover> pListT (new (std::nothrow) ArrayListT<int>(), _ListPtrUtil::remover);
- SysTryCatch(NID_MEDIA, pListT.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, pListT.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pListT->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, cameraBuffer.GetLimit() > 0, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
std::unique_ptr <_CameraBuffer> pCameraBuffer (new (std::nothrow) _CameraBuffer());
- SysTryReturn(NID_MEDIA, pCameraBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pCameraBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pCameraBuffer->Construct(cameraBuffer);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating. bufferType:%d", GetErrorMessage(r), bufferType);
_CapabilityImpl* pCapability = null;
std::unique_ptr <ArrayList, _ListPtrUtil::Remover> pList (new (std::nothrow) ArrayList(), _ListPtrUtil::remover);
- SysTryCatch(NID_MEDIA, pList.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, pList.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
_CameraImpl::StateChangedCb(camera_state_e previous, camera_state_e current, bool byPolicy, void *pUserData)
{
_CameraImpl* pImpl = static_cast<_CameraImpl*>( pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[%s] _CameraImpl instance is not available.", GetErrorMessage(E_OBJ_NOT_FOUND));
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
}
_CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
MediaPixelFormat format = MEDIA_PIXEL_FORMAT_NONE;
double ratio = 0.0;
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
//******************
//SysTryReturnVoidResult(NID_MEDIA, pImpl->GetState() == CAMERA_STATE_CAPTURING, E_INVALID_STATE, "[E_INVALID_STATE] The camera is already capturing");
//Commentout : Because it is not guaranteed that CaptureCb API is called after Capture API is completed.
_CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
SysLog(NID_MEDIA, "CaptureCompletedCb");
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
std::unique_ptr <ByteBuffer> pBuffer (pImpl->DequeueDataN(_CAMERA_BUFFER_CAPTURE));
if (pBuffer.get() != null)
int queueCount = 0;
_CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pFrame != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] camera_preview_data_s instance is not available.");
SysLog(NID_MEDIA, "Enter. preview format:%d, width:%d, height:%d, num_of_planes:%d", pFrame->format, pFrame->width, pFrame->height, pFrame->num_of_planes);
result r = E_SUCCESS;
_CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
SysLog(NID_MEDIA, "InterruptedCb called, policy is %d, previous state is %d, current state is %d, pUserData address is %x ", policy, previous, current, pUserData );
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl->IsPoweredOn() == true, E_INVALID_OPERATION ,"The camera is already power-offed");
r = pImpl->__pCameraEvent->SendEvent(_CAMERA_EVENT_ERROR, CAMERA_ERROR_DEVICE_INTERRUPTED, E_DEVICE_FAILED, null);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "Sending camera interrupted failed [%s] .", GetErrorMessage(r));
result r = E_SUCCESS;
_CameraImpl* pImpl = static_cast<_CameraImpl*>(pUserData);
SysLog(NID_MEDIA, "ErrorCb called, error is 0x%x, current state is %d, pUserData address is %x ", error, current, pUserData );
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
switch (error)
{
case ::CAMERA_ERROR_OUT_OF_MEMORY:
CameraErrorReason cameraErrorReason = CAMERA_ERROR_NONE;
result cameraResult = E_SUCCESS;
SysLog(NID_MEDIA, "Enter. state is %d.", state);
- SysTryReturnVoidResult(NID_MEDIA, _CameraImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _CameraImpl instance is not available.");
+ SysTryReturnVoidResult(NID_MEDIA, _CameraRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
CameraFocusMode focusMode = pImpl->GetFocusMode();
return;
}
-bool
-_CameraImpl::IsAlive(void)
-{
- return __isUsed;
-}
-
_CameraImpl*
_CameraImpl::GetInstance(Camera *pCamera)
{
{
class Camera;
class ICameraEventListener;
+class _CameraRef;
class _CameraEvent;
class _CameraCoordinator;
class _CameraCapability;
static void FocusStateChangedCb(camera_focus_state_e state, void *pUserData);
/**
- * Function check fo this object is alive.
- *
- * @return true if the object is alive, otherwise false.
- */
- static bool IsAlive(void);
-
- /**
* Gets the Impl instance.
*
* @return The pointer to %_CameraImpl
CameraState __state;
_CameraHandle __handle;
+ std::unique_ptr <_CameraRef> __pCameraRef;
std::unique_ptr <_CameraEvent> __pCameraEvent;
std::unique_ptr <_VideoStreamCoordinator> __pVideoStreamCoordinator;
ICameraEventListener* __pCameraEventListener;
int __focusPoints[2][MAX_FOCUS_POINT];
int __supportedFocusPointCount;
- static bool __isUsed;
static const int MAX_CAMERA_PLANE_COUNT = 4;
};
}
void
-_CameraManager::InitSafeHashMapInst()
+_CameraManager::InitSingleton()
{
- static _CameraManagerSafeHashMapT map;
result r = E_SUCCESS;
+ std::unique_ptr <_CameraManagerSafeHashMapT> pMap (new (std::nothrow) _CameraManagerSafeHashMapT());
+ SysTryReturnVoidResult(NID_MEDIA, pMap.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
- r = map.Construct();
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pMap->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- __pMap = ↦
- return;
-CATCH:
- __pMap = null;
+ __pMap = pMap.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_CameraManager::DestroySingleton(void)
+{
+ delete __pMap;
}
_CameraManager*
static pthread_once_t once_block = PTHREAD_ONCE_INIT;
if (!__pMap)
{
- pthread_once(&once_block, InitSafeHashMapInst);
+ pthread_once(&once_block, InitSingleton);
r = GetLastResult();
SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
}
*/
result ConvertResult(int err) const;
- _CameraManager(const _CameraManager& camera);
- _CameraManager& operator =(const _CameraManager& camera);
+ _CameraManager(const _CameraManager& rhs);
+ _CameraManager& operator =(const _CameraManager& rhs);
- static void InitSafeHashMapInst(void);
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
_CameraHandle __handle;
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FMedia_CameraRef.cpp
+ * @brief This file contains the implementation of the %_CameraRef class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include <FBaseColArrayListT.h>
+#include "FMedia_CameraRef.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+IListT<_CameraDeviceType>* _CameraRef::__pList = null;
+
+_CameraRef::_CameraRef(void)
+:__deviceType(_CAMERA_DEVICE_NONE)
+{
+}
+
+_CameraRef::~_CameraRef(void)
+{
+ UnRegisterCamera(__deviceType);
+}
+
+result
+_CameraRef::Construct(const Tizen::Base::Object& obj, _CameraDeviceType deviceType)
+{
+ result r = E_SUCCESS;
+
+ r = _CamRef::Construct(obj);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = RegisterCamera(deviceType);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __deviceType = deviceType;
+ return r;
+}
+
+void
+_CameraRef::InitSingleton(void)
+{
+ result r = E_SUCCESS;
+ std::unique_ptr <ArrayListT<_CameraDeviceType> > pList (new (std::nothrow) ArrayListT<_CameraDeviceType>());
+ SysTryReturnVoidResult(NID_MEDIA, pList.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = pList->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pList = pList.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_CameraRef::DestroySingleton(void)
+{
+ delete __pList;
+}
+
+result
+_CameraRef::RegisterCamera(_CameraDeviceType deviceType)
+{
+ result r = E_SUCCESS;
+
+ static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+ if (!__pList)
+ {
+ pthread_once(&once_block, InitSingleton);
+ r = GetLastResult();
+ SysTryReturn(NID_MEDIA, __pList != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+ // Duplicate camera devices cannot be created.
+ // Separate camera devices can be created.
+ SysTryReturn(NID_MEDIA, __pList->Contains(deviceType) != true, E_DEVICE_BUSY, E_DEVICE_BUSY
+ , "[E_DEVICE_BUSY] The camera%d is under use by other application or already used in this application.", deviceType);
+
+ r = __pList->Add(deviceType);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
+}
+
+void
+_CameraRef::UnRegisterCamera(_CameraDeviceType deviceType)
+{
+ result r = E_SUCCESS;
+ SysTryReturnVoidResult(NID_MEDIA, __pList != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] No object has been registered.");
+
+ r = __pList->Remove(deviceType);
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+}
+
+}}// Tizen::Media
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FMedia_CameraRef.h
+ * @brief This header file contains the declarations of the %_CameraRef class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_CAMERA_REF_H_
+#define _FMEDIA_INTERNAL_CAMERA_REF_H_
+
+#include <FBaseColIListT.h>
+#include "FMedia_CameraTypes.h"
+#include "FMedia_CamRef.h"
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class _CameraRef
+ * @brief This class implements the _CameraRef class.
+ */
+class _CameraRef
+ : public _CamRef
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to
+ * initialize this instance.
+ * @see Construct()
+ */
+ _CameraRef(void);
+
+ /**
+ * This is the destructor for this class.
+ */
+ virtual ~_CameraRef(void);
+
+ /**
+ * Initializes this instance of _CameraRef.
+ *
+ * @return An error code
+ * @param[in] obj The object
+ * @param[in] deviceType The camera device type
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ */
+ result Construct(const Tizen::Base::Object& obj, _CameraDeviceType deviceType);
+
+private:
+ /**
+ * Register a camera device to the list.
+ *
+ * @return An error code
+ * @param[in] deviceType The camera device type
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_DEVICE_BUSY The camera is under use by other application or already used in this application.
+ */
+ result RegisterCamera(_CameraDeviceType deviceType);
+
+ /**
+ * Unregister the specific camera device from the list.
+ *
+ * @param[in] deviceType The camera device type
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified device type is not found.
+ */
+ void UnRegisterCamera(_CameraDeviceType deviceType);
+
+ _CameraRef(const _CameraRef& rhs);
+ _CameraRef& operator =(const _CameraRef& rhs);
+
+ _CameraDeviceType __deviceType;
+
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+ static Tizen::Base::Collection::IListT<_CameraDeviceType>* __pList;
+};
+
+}}// Tizen::Media
+
+#endif
const wchar_t* const CAMERA_PRIMARY_ZOOM_LEVEL = L"Camera.Primary.ZoomLevel";
const wchar_t* const CAMERA_SECONDARY_ZOOM_LEVEL = L"Camera.Secondary.ZoomLevel";
+const wchar_t* const AUDIORECORDER_DEVICE_FPS = L"AudioRecorder.AudioFps";
+const wchar_t* const VIDEORECORDER_DEVICE_FPS = L"VideoRecorder.AudioFps";
+
_CapabilityImpl* _CapabilityImpl::__pCapabilityImplInst = null;
void
-_CapabilityImpl::InitCapabilityImpl()
+_CapabilityImpl::InitSingleton(void)
{
- static _CapabilityImpl capabilityImpl;
result r = E_SUCCESS;
+ std::unique_ptr <_CapabilityImpl> pCapabilityImpl (new (std::nothrow) _CapabilityImpl());
+ SysTryReturnVoidResult(NID_MEDIA, pCapabilityImpl.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
- r = capabilityImpl.Construct();
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Propagating.");
+ r = pCapabilityImpl->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Capability resource creation failed.");
- __pCapabilityImplInst = &capabilityImpl;
- return;
-CATCH:
- __pCapabilityImplInst = null;
+ __pCapabilityImplInst = pCapabilityImpl.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_CapabilityImpl::DestroySingleton(void)
+{
+ delete __pCapabilityImplInst;
}
_CapabilityImpl*
if (!__pCapabilityImplInst)
{
- pthread_once(&once_block, InitCapabilityImpl);
+ pthread_once(&once_block, InitSingleton);
+ SysTryReturn(NID_MEDIA, __pCapabilityImplInst != null, null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The instance is not found.");
}
return __pCapabilityImplInst;
{ AUDIOOUT_SAMPLE_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO },
{ AUDIORECORDER_FORMAT, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
-
{ AUDIORECORDER_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
{ AUDIORECORDER_MEDIA_CONTAINER_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
+ { AUDIORECORDER_DEVICE_FPS, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_AUDIO_RECORDER },
{ CAMERA_COUNT, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_PRIMARY_CAMERA },
{ VIDEORECORDER_AUDIO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
{ VIDEORECORDER_FORMAT, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
{ VIDEORECORDER_VIDEO_CODEC, _CapabilityImpl::CopyListString, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
-
{ VIDEORECORDER_AUDIO_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
{ VIDEORECORDER_VIDEO_CODEC_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
{ VIDEORECORDER_MEDIA_CONTAINER_TYPE, _CapabilityImpl::CopyListInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
+ { VIDEORECORDER_DEVICE_FPS, _CapabilityImpl::CopyInteger, _MEDIA_CAP_CATEGORY_VIDEO_RECORDER },
};
result
{ AUDIOOUT_SAMPLE_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _AUDIO_SAMPLE_TYPE_MAP },
{ AUDIORECORDER_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+ { AUDIORECORDER_DEVICE_FPS, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
// { AUDIORECORDER_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
// { AUDIORECORDER_MEDIA_CONTAINER_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _MEDIA_CONTAINER_TYPE_MAP},
{ VIDEORECORDER_AUDIO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
{ VIDEORECORDER_FORMAT, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
{ VIDEORECORDER_VIDEO_CODEC, ParseValueList, _CapabilityImpl::ConvertCharToString, 0 },
+ { VIDEORECORDER_DEVICE_FPS, ParseContent, _CapabilityImpl::ConvertCharToInteger, 0 },
// { VIDEORECORDER_AUDIO_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
// { VIDEORECORDER_VIDEO_CODEC_TYPE, ParseValueList, _CapabilityImpl::ConvertCharToEnum, _CODEC_TYPE_MAP},
String* pKey = null;
pKey = new (std::nothrow) Tizen::Base::String(key);
SysTryReturnVoidResult(NID_MEDIA, pKey !=null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The key is not created.");
-
r = __pMap->Add(*pKey, *pRet);
SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
}
}
void
-_RecorderManager::InitSafeHashMapInst()
+_RecorderManager::InitSingleton()
{
- static _RecorderManagerSafeHashMapT map;
result r = E_SUCCESS;
+ std::unique_ptr <_RecorderManagerSafeHashMapT> pMap (new (std::nothrow) _RecorderManagerSafeHashMapT());
+ SysTryReturnVoidResult(NID_MEDIA, pMap.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
- r = map.Construct();
- SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pMap->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- __pMap = ↦
- return;
-CATCH:
- __pMap = null;
+ __pMap = pMap.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_RecorderManager::DestroySingleton(void)
+{
+ delete __pMap;
}
_RecorderManager*
if (!__pMap)
{
- pthread_once(&once_block, InitSafeHashMapInst);
+ pthread_once(&once_block, InitSingleton);
r = GetLastResult();
SysTryReturn(NID_MEDIA, __pMap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
}
*/
result ConvertResult(int err) const;
- _RecorderManager(const _RecorderManager& camera);
- _RecorderManager& operator =(const _RecorderManager& camera);
+ _RecorderManager(const _RecorderManager& rhs);
+ _RecorderManager& operator =(const _RecorderManager& rhs);
- static void InitSafeHashMapInst(void);
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
_RecorderHandle __handle;
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FMedia_RecorderRef.cpp
+ * @brief This file contains the implementation of the %_RecorderRef class.
+ *
+ */
+
+#include <unique_ptr.h>
+#include <pthread.h>
+#include <FBaseSysLog.h>
+#include <FBaseColArrayListT.h>
+#include "FMedia_RecorderRef.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+
+namespace Tizen { namespace Media
+{
+
+IListT<_RecorderDeviceType>* _RecorderRef::__pList = null;
+
+_RecorderRef::_RecorderRef(void)
+:__deviceType(_RECORDER_DEVICE_NONE)
+{
+}
+
+_RecorderRef::~_RecorderRef(void)
+{
+ UnRegisterRecorder(__deviceType);
+}
+
+result
+_RecorderRef::Construct(const Tizen::Base::Object& obj, _RecorderDeviceType deviceType)
+{
+ result r = E_SUCCESS;
+
+ r = _CamRef::Construct(obj);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = RegisterRecorder(deviceType);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __deviceType = deviceType;
+ return r;
+}
+
+void
+_RecorderRef::InitSingleton(void)
+{
+ result r = E_SUCCESS;
+ std::unique_ptr <ArrayListT<_RecorderDeviceType> > pList (new (std::nothrow) ArrayListT<_RecorderDeviceType>());
+ SysTryReturnVoidResult(NID_MEDIA, pList.get() != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = pList->Construct();
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ __pList = pList.release();
+ std::atexit(DestroySingleton);
+}
+
+void
+_RecorderRef::DestroySingleton(void)
+{
+ delete __pList;
+}
+
+result
+_RecorderRef::RegisterRecorder(_RecorderDeviceType deviceType)
+{
+ result r = E_SUCCESS;
+
+ static pthread_once_t once_block = PTHREAD_ONCE_INIT;
+ if (!__pList)
+ {
+ pthread_once(&once_block, InitSingleton);
+ r = GetLastResult();
+ SysTryReturn(NID_MEDIA, __pList != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ }
+
+/*
+ // Multiple recorder devices cannot be created.
+ if (__pList->GetCount() > 0)
+ {
+ _RecorderDeviceType usedDeviceType = _RECORDER_DEVICE_NONE;
+ r = __pList->GetAt(0, usedDeviceType);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ SysLogException(NID_MEDIA, E_DEVICE_BUSY, "[E_DEVICE_BUSY] The recorder%d is under use %d by other application or already used in this application.", deviceType, usedDeviceType);
+ return E_DEVICE_BUSY;
+ }
+*/
+ r = __pList->Add(deviceType);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
+}
+
+void
+_RecorderRef::UnRegisterRecorder(_RecorderDeviceType deviceType)
+{
+ result r = E_SUCCESS;
+ SysTryReturnVoidResult(NID_MEDIA, __pList != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] No object has been registered.");
+
+ r = __pList->Remove(deviceType);
+ SysTryReturnVoidResult(NID_MEDIA, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
+}
+
+}}// Tizen::Media
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file FMedia_RecorderRef.h
+ * @brief This header file contains the declarations of the %_RecorderRef class.
+ *
+ */
+
+#ifndef _FMEDIA_INTERNAL_RECORDER_REF_H_
+#define _FMEDIA_INTERNAL_RECORDER_REF_H_
+
+#include <FBaseColIListT.h>
+#include "FMedia_RecorderTypes.h"
+#include "FMedia_CamRef.h"
+
+namespace Tizen { namespace Media
+{
+
+/**
+ * @class _RecorderRef
+ * @brief This class implements the _RecorderRef class.
+ */
+class _RecorderRef
+ : public _CamRef
+{
+public:
+ /**
+ * This is the default constructor for this class.
+ *
+ * @remarks After creating an instance of this class, the Construct() method must be called explicitly to
+ * initialize this instance.
+ * @see Construct()
+ */
+ _RecorderRef(void);
+
+ /**
+ * This is the destructor for this class.
+ */
+ virtual ~_RecorderRef(void);
+
+ /**
+ * Initializes this instance of _RecorderRef.
+ *
+ * @return An error code
+ * @param[in] obj The object
+ * @param[in] deviceType The camera device type
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ */
+ result Construct(const Tizen::Base::Object& obj, _RecorderDeviceType deviceType);
+
+private:
+ /**
+ * Register a camera device to the list.
+ *
+ * @return An error code
+ * @param[in] deviceType The camera device type
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM Internal error.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @exception E_DEVICE_BUSY The recorder is under use by other application or already used in this application.
+ */
+ result RegisterRecorder(_RecorderDeviceType deviceType);
+
+ /**
+ * Unregister the specific camera device from the list.
+ *
+ * @param[in] deviceType The camera device type
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OBJ_NOT_FOUND The specified device type is not found.
+ */
+ void UnRegisterRecorder(_RecorderDeviceType deviceType);
+
+ _RecorderRef(const _RecorderRef& rhs);
+ _RecorderRef& operator =(const _RecorderRef& rhs);
+
+ _RecorderDeviceType __deviceType;
+
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
+
+ static Tizen::Base::Collection::IListT<_RecorderDeviceType>* __pList;
+};
+
+}}// Tizen::Media
+
+#endif
#include "FMedia_RecorderCapability.h"
#include "FMedia_CamPtrUtil.h"
#include "FMedia_AudioStreamCoordinator.h"
+#include "FMedia_RecorderRef.h"
//#define _VIDEO_RECORDER_ROTATION_
{null, CODEC_NONE, CODEC_NONE, MEDIA_CONTAINER_NONE}
};
-bool _VideoRecorderImpl::__isUsed = false;
-
_VideoRecorderImpl::_VideoRecorderImpl(void)
: __pCoordinator(null)
+ , __pRecorderRef(null)
, __pVideoRecorderEvent(null)
, __pVideoRecorderEventListener(null)
, __pVideoSourceAdapter(null)
_CameraCoordinator::Release(__deviceType);
}
- if ( __isConstructed )
- {
- __isUsed = false;
- }
-
SysLog(NID_MEDIA, "video recorder Destroyed");
}
int streamFps = 0;
_CapabilityImpl* pCapabilityImpl = null;
- SysTryReturn(NID_MEDIA, !__isUsed, E_DEVICE_BUSY, E_DEVICE_BUSY, "[E_DEVICE_BUSY] _VideoRecorderImpl is now being used.");
SysTryReturn(NID_MEDIA, !__isConstructed, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] VideoRecorder is in an invalid state. A device is already constructed.");
SysLog(NID_MEDIA, "video recorder construct");
pCamera = const_cast<Tizen::Media::Camera*>(&camera);
pCamImpl = _CameraImpl::GetInstance(pCamera);
+ __deviceType = (pCamImpl->GetSelection() == CAMERA_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA
+ : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
+
+ // Register this object to _RecorderRef
+ __pRecorderRef.reset(new (std::nothrow) _RecorderRef());
+ SysTryCatch(NID_MEDIA, __pRecorderRef.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+
+ r = __pRecorderRef->Construct(*this, __deviceType);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
// Source Adapter
__pVideoSourceAdapter.reset(new (std::nothrow) _VideoSourceAdapter(*pCamImpl));
- SysTryCatch(NID_MEDIA, __pVideoSourceAdapter.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, __pVideoSourceAdapter.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
// Create Event
__pVideoRecorderEvent.reset(new (std::nothrow) _VideoRecorderEvent());
- SysTryCatch(NID_MEDIA, __pVideoRecorderEvent.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, __pVideoRecorderEvent.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pVideoRecorderEvent->Construct(*this);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
// Create audio stream coordinator
__pAudioStreamCoordinator.reset(new (std::nothrow) _AudioStreamCoordinator());
- SysTryCatch(NID_MEDIA, __pAudioStreamCoordinator.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, __pAudioStreamCoordinator.get() != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = __pAudioStreamCoordinator->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
- // Get the capability
- pCapabilityImpl = _CapabilityImpl::GetInstance();
- SysTryCatch(NID_MEDIA, pCapabilityImpl != null, r= E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Capability is not obtained.");
-
- r = pCapabilityImpl->GetValue(String(L"VideoRecorder.Device.fps"), streamFps);
- //SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- streamFps = 50;
-
- if (streamFps != 0)
- {
- __audioStreamTimeDuration = (1000/streamFps); //Time duration in milisec
- }
-
- __deviceType = (pCamImpl->GetSelection() == CAMERA_PRIMARY ? _RECORDER_DEVICE_VIDEO_PRIMARY_CAMERA
- : _RECORDER_DEVICE_VIDEO_SECONDARY_CAMERA);
-
__pCoordinator = _CameraCoordinator::AddInstance(__deviceType);
r = GetLastResult();
SysTryCatch(NID_MEDIA, __pCoordinator != null, , r, "[E_OBJ_NOT_FOUND] _CameraCoordinator instance is not available.");
__handle = __pCoordinator->GetRecorderHandle();
+ // Get the capability
+ pCapabilityImpl = _CapabilityImpl::GetInstance();
+ SysTryCatch(NID_MEDIA, pCapabilityImpl != null, r= E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Capability is not obtained.");
+
+ // Get the audio stream fps
+ r = pCapabilityImpl->GetValue(VIDEORECORDER_DEVICE_FPS, streamFps);
+ SysTryCatch(NID_MEDIA, r == E_SUCCESS && streamFps > 0, , r, "[%s] Propagating. fps:%d", GetErrorMessage(r), streamFps);
+ __audioStreamTimeDuration = (1000/streamFps); //Time duration in milisec
+
err = recorder_set_state_changed_cb(__handle, StateChangedCb, this);
r = ConvertResult(err);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] video recorder set message callback failed.", GetErrorMessage(r));
SetState(RECORDER_STATE_INITIALIZED);
__isConstructed = true;
- __isUsed = true;
return r;
if (__pCoordinator != null)
{
__pCoordinator->RemoveCameraCoordinatorListener(*this);
+ _CameraCoordinator::Release(__deviceType);
+ __pCoordinator = null;
}
+ __pRecorderRef.reset(null);
+ __pVideoSourceAdapter.reset(null);
+ __pVideoRecorderEvent.reset(null);
+ __pAudioStreamCoordinator.reset(null);
+
return r;
}
SysTryReturn(NID_MEDIA, pCapImpl != null, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Get capability information failed.");
std::unique_ptr<ArrayList, _ListPtrUtil::Remover> pCodecList (new (std::nothrow) Tizen::Base::Collection::ArrayList(), _ListPtrUtil::remover);
- SysTryCatch(NID_MEDIA, pCodecList.get() !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryCatch(NID_MEDIA, pCodecList.get() !=null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pCodecList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camcorder get attribute failed.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr<ArrayListT<CodecType>, _ListPtrUtil::Remover> pAudioCodecList (new (std::nothrow) ArrayListT<CodecType>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pAudioCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pAudioCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pAudioCodecList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr<ArrayListT<CodecType>, _ListPtrUtil::Remover> pVideoCodecList (new (std::nothrow) ArrayListT<CodecType>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pVideoCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pVideoCodecList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pVideoCodecList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, pIntegerList->GetCount() > 0, null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. The list was empty.");
std::unique_ptr<ArrayListT<MediaContainerType>, _ListPtrUtil::Remover> pContainerList (new (std::nothrow) ArrayListT<MediaContainerType>(), _ListPtrUtil::remover);
- SysTryReturn(NID_MEDIA, pContainerList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
+ SysTryReturn(NID_MEDIA, pContainerList.get() != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
r = pContainerList->Construct();
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
_VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>( pUserData);
int tableTotalCount = 0;
int i = 0;
- SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "State previous:%d, current:%d, byPolicy:%d", previous, current, byPolicy);
tableTotalCount = sizeof(_VIDEO_CALLBACK_EVENT) / sizeof(_VIDEO_CALLBACK_EVENT[0]);
_VideoRecorderImpl::RecordingStatusCb(unsigned long long elapsedTime, unsigned long long fileSize, void *pUserData)
{
_VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "FileSize:%llu,elapsedTime:%llu",fileSize,elapsedTime);
{
_VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
int samplingRate =0;
- SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. Impl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pStream != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] void instance is not available. pStream is null.");
if (pImpl->__audioStreamCallback == true)
{
result r = E_SUCCESS;
_VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "Type:%d", type);
{
result r = E_SUCCESS;
_VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "Error:%d, state:%d", error, state);
r = pImpl->GetEvent()->SendEvent(_RECORDER_EVENT_ERROR, RECORDER_ERROR_DEVICE_FAILED, E_SUCCESS);
_VideoRecorderImpl::InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData)
{
_VideoRecorderImpl* pImpl = static_cast<_VideoRecorderImpl*>(pUserData);
- SysTryReturnVoidResult(NID_MEDIA, _VideoRecorderImpl::IsAlive(), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysTryReturnVoidResult(NID_MEDIA, pImpl != null, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] _VideoRecorderImpl instance is not available. pImpl is null.");
+ SysTryReturnVoidResult(NID_MEDIA, _CamRef::IsAlive(*pImpl), E_INVALID_OPERATION, "[E_INVALID_OPERATION] The object was already destroyed.");
SysLog(NID_MEDIA, "Policy:%d, previous:%d, current:%d", policy, previous, current);
}
return r;
}
-bool
-_VideoRecorderImpl::IsAlive(void)
-{
- return __isUsed;
-}
-
_VideoRecorderImpl*
_VideoRecorderImpl::GetInstance(VideoRecorder *pVideoRecorder)
{
class IAudioStreamFilter;
class _CameraCoordinator;
+class _RecorderRef;
class _VideoRecorderEvent;
class _VideoSourceAdapter;
static void InterruptedCb(recorder_policy_e policy, recorder_state_e previous, recorder_state_e current, void *pUserData);
/**
- * Function check fo this object is alive.
- *
- * @return true if the object is alive, otherwise false.
- */
- static bool IsAlive(void);
-
- /**
* Gets the Impl instance.
*
* @return The pointer to %_VideoRecorderImpl
_VideoRecorderImpl& operator =(const _VideoRecorderImpl& _VideoRecorderImpl);
_CameraCoordinator* __pCoordinator;
+ std::unique_ptr <_RecorderRef> __pRecorderRef;
std::unique_ptr <_VideoRecorderEvent> __pVideoRecorderEvent;
IVideoRecorderEventListener* __pVideoRecorderEventListener;
std::unique_ptr <_VideoSourceAdapter> __pVideoSourceAdapter;
camera_pixel_format_e __mmSourceFormat;
Tizen::Base::String __filePath;
_RecorderStateChangeReason __stateChangeReason;
- static bool __isUsed;
std::unique_ptr <_AudioStreamCoordinator> __pAudioStreamCoordinator;
int __audioStreamTimeDuration;
bool __audioStreamCallback;
{
_OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_CODEC_TYPE;
_OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_MEDIA_CONTAINER_TYPE;
+_OSP_EXPORT_ extern const wchar_t* const AUDIORECORDER_DEVICE_FPS;
+
_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_AUDIO_CODEC_TYPE;
_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_VIDEO_CODEC_TYPE;
_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_MEDIA_CONTAINER_TYPE;
_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_CODEC;
+_OSP_EXPORT_ extern const wchar_t* const VIDEORECORDER_DEVICE_FPS;
_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_ZOOM_LEVEL;
_OSP_EXPORT_ extern const wchar_t* const CAMERA_PRIMARY_FOCUS_POINT;
: public Tizen::Base::Object
{
public:
+ /**
+ * This is the destructor for this class.
+ *
+ * @see Construct()
+ */
+ virtual ~_CapabilityImpl(void);
+
+ /**
+ * Get the instance of _CapabilityImpl.
+ *
+ * @return The _CapabilityImpl instance
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_SYSTEM A system error has occurred.
+ */
static _CapabilityImpl* GetInstance(void);
/**
_CapabilityImpl(void);
/**
- * This is the destructor for this class. @n
- * Resources are deallocated by this method.
- * This method should be called in the same thread as Construct() method
- *
- * @see Construct()
- */
- virtual ~_CapabilityImpl(void);
-
- /**
* copy constructor
* @param[in] src _CapabilityImpl type object
*/
*/
result ParseCapability(_MediaCapCategoryType category);
- static void InitCapabilityImpl(void);
+ static void InitSingleton(void);
+ static void DestroySingleton(void);
std::unique_ptr <Tizen::Base::Collection::HashMap> __pMap;
int __cameraCount;