2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FMedia_CameraCoordinator.h
20 * @brief This header file contains the declarations of the %_CameraCoordinator class.
24 #ifndef _FMEDIA_INTERNAL_CAMERA_COORDINATOR_H_
25 #define _FMEDIA_INTERNAL_CAMERA_COORDINATOR_H_
29 #include <FBaseColLinkedListT.h>
30 #include <FBaseColHashMapT.h>
31 #include <FMediaCameraTypes.h>
32 #include <FMediaRecorderTypes.h>
33 #include "FMedia_CameraTypes.h"
34 #include "FMedia_RecorderTypes.h"
35 #include "FMedia_CameraRefHelper.h"
37 namespace Tizen { namespace Media
39 class _ICameraCoordinatorListener;
40 class _CameraCoordinatorSafeHashMapT;
43 * @class _CameraCoordinator
44 * @brief This class implements the _CameraCoordinator class.
47 class _CameraCoordinator
48 : public _CameraRefHelper
52 * Get the instance of _CameraCoordinator.
54 * @return The _CameraCoordinator instance
55 * @param[in] cameraDevice The camera device id.
56 * @exception E_SUCCESS The method is successful.
57 * @exception E_SYSTEM A system error has occurred.
58 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
59 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
61 static _CameraCoordinator* AddInstance(_CameraDeviceType cameraDevice);
64 * Get the instance of _CameraCoordinator.
66 * @return The _CameraCoordinator instance
67 * @param[in] recorderDevice The recorder device id.
68 * @exception E_SUCCESS The method is successful.
69 * @exception E_SYSTEM A system error has occurred.
70 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
71 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
73 static _CameraCoordinator* AddInstance(_RecorderDeviceType recorderDevice);
76 * Release the specific _CameraCoordinator.
78 * @param[in] cameraDevice The camera device type
80 static void Release(_CameraDeviceType cameraDevice);
83 * Release the specific _CameraCoordinator.
85 * @param[in] recorderDevice The recorder device type
87 static void Release(_RecorderDeviceType recorderDevice);
90 * Check whether it has the instance.
92 * @return The _CameraCoordinator instance
93 * @param[in] cameraDevice The camera device id.
94 * @exception E_SUCCESS The method is successful.
95 * @exception E_SYSTEM A system error has occurred.
96 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
97 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
99 static _CameraCoordinator* HasInstance(_CameraDeviceType cameraDevice);
102 * Check whether it has the instance.
104 * @return The _CameraCoordinator instance
105 * @param[in] recorderDevice The recorder device id.
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_SYSTEM A system error has occurred.
108 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
109 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
111 static _CameraCoordinator* HasInstance(_RecorderDeviceType recorderDevice);
114 * Adds the listener to this object. @n
115 * Added listeners are called after this object's callbacks are called from the camera.
117 * @return An error code
118 * @param[in] listener A listener instance
119 * @exception E_SUCCESS The method is successful.
120 * @exception E_SYSTEM A system error has occurred.
122 result AddCameraCoordinatorListener(_ICameraCoordinatorListener& listener);
125 * Removes the listener from this object. @n
127 * @return An error code
128 * @param[in] listener A listener instance
129 * @exception E_SUCCESS The method is successful.
130 * @exception E_SYSTEM A system error has occurred.
132 result RemoveCameraCoordinatorListener(_ICameraCoordinatorListener& listener);
137 * @return The camera mode
139 _CameraMode GetMode(void) const;
142 * Gets the camera device selection.
144 * @return The camera device selection
146 _CameraDeviceType GetCameraDevice(void) const;
149 * Gets the camera handle
151 * @return The camera handle
153 _CameraHandle GetCameraHandle(void) const;
156 * Gets the recorder handle
158 * @return The recorder handle
160 _RecorderHandle GetRecorderHandle(void) const;
163 * Notifies the mode changing status to _ICameraCoordinatorListener
165 * @return An error code
166 * @param[in] mode camera mode
167 * @remarks This mtehod calls _ICameraCoordinatorListener::::OnCameraCoordinatorModeChangePrepared().
168 * This method will call every _ICameraCoordinatorListener which are registered to _CameraCoordinator.
170 result NotifyModeChangePrepared(_CameraMode mode);
173 * Notifies the mode changed status to _ICameraCoordinatorListener
175 * @return An error code
176 * @param[in] mode camera mode
177 * @remarks This mtehod calls _ICameraCoordinatorListener::::OnCameraCoordinatorModeChanged().
178 * This method will call every _ICameraCoordinatorListener which are registered to _CameraCoordinator.
180 result NotifyModeChanged(_CameraMode mode);
185 * @return An error code
186 * @param[in] mode The mode to set
187 * @exception E_SUCCESS The method is successful.
188 * @exception E_INVALID_STATE This instance is in an invalid state for this method.
190 result StartMmPreview(void);
195 * @return An error code
196 * @param[in] mode The mode to set
197 * @exception E_SUCCESS The method is successful.
198 * @exception E_INVALID_STATE This instance is in an invalid state for this method.
200 result StopMmPreview(void);
203 * Changes the camcorder mode.
205 * @return An error code
206 * @param[in] mode The mode to set
207 * @param[in] callback The flag to call the callback
208 * @exception E_SUCCESS The method is successful.
209 * @exception E_INVALID_STATE This instance is in an invalid state for this method.
210 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
211 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
212 * @exception E_DEVICE_FAILED The device operation has failed.
213 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
215 result ChangeMode(_CameraMode mode, bool callback);
218 * Check if the change mode can be calmly.
220 * @return The flag of calm change mode
221 * @param[in] mode The mode to set
223 bool IsCalmChangeMode(_CameraMode mode);
228 * @return An error code
229 * @param[in] pixelFormat camera's preview format
231 result SetCameraSourceFormat(camera_pixel_format_e pixelFormat);
236 * @return camera's preview format
238 camera_pixel_format_e GetCameraSourceFormat(void) const;
241 * Captures the current image data from the camera sensor.
243 * @return An error code
244 * @param[in] capturingCb The capture callback
245 * @param[in] completedCb The capture completed callback
246 * @param[in] pUserData The user data
247 * @exception E_SUCCESS The method is successful.
248 * @exception E_INVALID_STATE This instance is in an invalid state for this method.
249 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
250 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
251 * @exception E_DEVICE_FAILED The device operation has failed.
252 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
253 * @exception E_OUT_OF_MEMORY The memory is insufficient.
255 result StartCapture(camera_capturing_cb capturingCb , camera_capture_completed_cb completedCb , void *pUserData);
260 * @return An error code
262 result StartRecord(void);
265 * Sets the orientation of the recorder.
267 * @return An error code
269 void SetRecordingOrientation(RecordingRotation rotation);
272 * Sets the orientation of the camera.
274 * @return An error code
276 void SetCameraOrientation(CameraExifOrientation orientation);
279 friend class _CameraCoordinatorSafeHashMapT;
281 * This is the default constructor for this class.
283 * @remarks After creating an instance of this class, the Construct() method must be called explicitly to
284 * initialize this instance.
287 _CameraCoordinator(void);
290 * This is the destructor for this class. @n
291 * All allocated resources are deallocated by this method. This method should be called in the same thread
292 * where the Construct() method is called.
296 virtual ~_CameraCoordinator(void);
299 * Initializes this instance of _CameraCoordinator.
301 * @return An error code
302 * @param[in] cameraDevice The camera device id.
303 * @exception E_SUCCESS The method is successful.
304 * @exception E_SYSTEM A system error has occurred.
305 * @exception E_DEVICE_BUSY The device cannot be approached because of other operations.
306 * @exception E_DEVICE_UNAVAILABLE The device is unavailable.
308 result Construct(_CameraDeviceType cameraDevice);
313 * @return An error code
314 * @param[in] recorderDevice The recorder device id.
315 * @exception E_SUCCESS The method is successful.
316 * @exception E_SYSTEM A system error has occurred.
318 result AddRecorder(_RecorderDeviceType recorderDevice);
321 * Remove the recorder
323 * @param[in] recorderDevice The recorder device id.
324 * @exception E_SUCCESS The method is successful.
325 * @exception E_SYSTEM A system error has occurred.
327 void RemoveRecorder(_RecorderDeviceType recorderDevice);
330 * Converts the error from camera to Result.
332 * @return An error code
333 * @param[in] err camera error
335 result ConvertResult(int err) const;
340 * @return An error code
341 * @param[in] destState camera's destinationed state
342 * @remarks This method makes the camera's state change. @n
343 * Acccording to this, Camera's state is changed.
345 result ChangeCameraStateTo(camera_state_e destState);
348 * Gets the camera's state.
352 camera_state_e GetCameraState(void) const;
355 * Gets the recorder's state.
359 recorder_state_e GetRecorderState(void) const;
364 * @return An error code
365 * @param[in] destState recorder's destinationed state
366 * @remarks This method makes the camera's state change. @n
367 * acccording to this, VideoRecorder and AudioRecorder's state is changed.
369 result ChangeRecorderStateTo(recorder_state_e destState);
372 * Sets the orientation of the recorder.
374 * @return An error code
375 * @param[in] rotation The rotation of the recorder
376 * @exception E_SUCCESS The method is successful.
377 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
378 * @exception E_INVALID_ARG The specified @c rotation is not supported.
380 result SetRecordingOrientationAttr(RecordingRotation rotation);
383 * Sets the orientation of the camera.
385 * @return An error code
386 * @param[in] orientation The orientation of the camera
387 * @exception E_SUCCESS The method is successful.
388 * @exception E_INVALID_STATE This method is invalid for the current state of this instance.
389 * @exception E_INVALID_ARG The specified @c rotation is not supported.
391 result SetCameraOrientationAttr(CameraExifOrientation orientation);
393 _CameraCoordinator(const _CameraCoordinator& rhs);
394 _CameraCoordinator& operator =(const _CameraCoordinator& rhs);
396 _CameraDeviceType __cameraDevice;
397 _CameraHandle __cameraHandle;
398 _RecorderHandle __recorderHandle;
400 Tizen::Base::Collection::LinkedListT <_ICameraCoordinatorListener*>* __pListenerList;
401 int __orientationFlag;
402 CameraExifOrientation __cameraOrientation;
403 RecordingRotation __recordingRotation;
405 static _CameraCoordinatorSafeHashMapT* __pMap;
409 * @class _CameraCoordinatorSafeHashMapT
410 * @brief This class is for handling safe HashMap.
413 class _CameraCoordinatorSafeHashMapT
414 : public Tizen::Base::Collection::HashMapT<_CameraDeviceType, _CameraCoordinator*>
415 , public virtual Tizen::Base::Collection::ICollectionT <Tizen::Base::Collection::MapEntryT <_CameraDeviceType, _CameraCoordinator*> >
418 _CameraCoordinatorSafeHashMapT(void);
419 virtual ~_CameraCoordinatorSafeHashMapT(void);
420 void RemoveItems(void);
423 _CameraCoordinatorSafeHashMapT(const _CameraCoordinatorSafeHashMapT& rhs);
424 _CameraCoordinatorSafeHashMapT& operator =(const _CameraCoordinatorSafeHashMapT& rhs);