2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file CmCameraStarterThread.cpp
19 * @brief This is the implementation file for CameraStarterThread class.
25 #include "CmCameraPresentationModel.h"
26 #include "CmCameraStarterThread.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
33 CameraStarterThread* CameraStarterThread::__pCameraStarterThread = null;
35 CameraStarterThread::CameraStarterThread(void)
42 CameraStarterThread::~CameraStarterThread(void)
45 if (__pBufferInfo != null)
53 CameraStarterThread::GetInstance(void)
56 if (__pCameraStarterThread == null)
61 return __pCameraStarterThread;
65 CameraStarterThread::CreateInstance(void)
68 __pCameraStarterThread = new (std::nothrow) CameraStarterThread();
70 result r = __pCameraStarterThread->Construct();
73 AppLogDebug("IsFailed");
74 __pCameraStarterThread->Stop();
75 __pCameraStarterThread->Join();
76 delete __pCameraStarterThread;
77 __pCameraStarterThread = null;
81 //std::atexit(DestroyInstance);
87 CameraStarterThread::DestroyInstance(void)
91 __pCameraStarterThread->Stop();
92 __pCameraStarterThread->Join();
93 delete __pCameraStarterThread;
94 __pCameraStarterThread = null;
99 CameraStarterThread::DestroyCameraStarterThreadInstance(void)
101 AppLogDebug("ENTER");
102 CameraStarterThread* pCameraStarterThread = CameraStarterThread::GetInstance();
104 if (pCameraStarterThread)
106 delete pCameraStarterThread;
112 CameraStarterThread::Construct(void)
114 AppLogDebug("ENTER");
116 return Thread::Construct();
120 CameraStarterThread::SetBufferinfo(Tizen::Graphics::BufferInfo* bufferinfo)
122 AppLogDebug("ENTER");
123 __pBufferInfo = bufferinfo;
125 if (__pBufferInfo == null)
127 AppLogDebug("SetBufferinfo is __pBufferInfo is null");
135 CameraStarterThread::OnStart(void)
141 CameraStarterThread::OnStop(void)
143 //empty implementation
147 CameraStarterThread::Run(void)
149 AppLogDebug("ENTER");
152 AppLogDebug("Run::StartPreview");
153 CameraPresentationModel* pCameraPresentationModel = CameraPresentationModel::GetInstance();
155 if (pCameraPresentationModel->IsCameraInstance())
157 pCameraPresentationModel->StartPreview(__pBufferInfo);
161 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));