merge checked header file
[platform/framework/native/media.git] / inc / FMediaICameraEventListener.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                        FMediaICameraEventListener.h
20  * @brief                       This is the header file for the %ICameraEventListener interface.
21  *
22  * This header file contains the declarations of the %ICameraEventListener interface.
23  */
24
25 #ifndef _FMEDIA_ICAMERA_EVENT_LISTENER_H_
26 #define _FMEDIA_ICAMERA_EVENT_LISTENER_H_
27
28 #include <FBase.h>
29 #include <FMediaCameraTypes.h>
30
31 namespace Tizen { namespace Media
32 {
33
34 /**
35  * @interface   ICameraEventListener
36  * @brief               This interface provides a listener that receives events associated with the Camera class.
37  *
38  * @since               2.0
39  *
40  * The %ICameraEventListener interface specifies the methods used to notify the status of the camera and camera events.
41  * The camera engine works asynchronously. Therefore, it is important to implement this listener
42  * to ensure smooth performance of the camera.
43  *
44  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/media/capturing_still_images.htm">Capturing Still Images</a>.
45  */
46 class _OSP_EXPORT_ ICameraEventListener
47         : virtual public Tizen::Base::Runtime::IEventListener
48 {
49
50 public:
51         /**
52         * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
53         *
54         * @since                2.0
55         */
56         virtual ~ICameraEventListener(void) {}
57
58         /**
59         * Called when the Camera::SetAutoFocus() method is completed.
60         *
61         * @since                2.0
62         *
63         * @param[in]     completeCondition   The condition of auto focus completion @n
64         *                                                                                 Set to @c true if it succeeds, @n
65         *                                                                                 else @c false.
66         */
67         virtual void OnCameraAutoFocused(bool completeCondition) = 0;
68
69         /**
70         * Called when the Camera::StartPreview() method is completed. @n
71         * Notifies to the application periodically, at the speed of the camera's frame rate,
72         * once the %Camera::StartPreview() method is called, so as to receive the preview data.
73         *
74         * @since                2.0
75         *
76         *       @param[in]      previewedData                   The displayed image data in the viewfinder @n
77         *                                                                               The previewed data format is same as the format
78         *                                                                          set by Camera::SetPreviewFormat().
79         * @param[in]    r       The cause of the error
80         *       @exception       E_SUCCESS      The method is successful.
81         *       @exception       E_INVALID_DATA  The ByteBuffer contains invalid data.
82         *       @remarks        This method is called only if the @c previewedData flag of
83         *                               Camera::StartPreview() is @c true.
84         *       @remarks        This method can be delayed or dropped depending on system performance.
85         *   @see            Camera::GetPreviewFormat()
86         *
87         * The camera rotation can be different according to the physical design.
88         * For keeping the compatibility between targets, the application must check the H/W camera rotation.
89         * Based on this information, the application can rotate the preview data.
90         *
91         * The following example demonstrates how to use the %OnCameraPreviewed() method to rotate the preview data in the portrait mode.
92         *
93         * @code
94         // Rotates the preview data to use it
95         int rotation = (int)CAMERA_ROTATION_NONE;
96         MediaCapability::GetValue(CAMERA_SECONDARY_ROTATION, rotation);
97
98         ByteBuffer rotatedData;
99         rotatedData.Construct(previewedData.GetLimit());
100
101         switch ((CameraRotation) rotation)
102         {
103                         case CAMERA_ROTATION_90:
104                                         ImageUtil::Rotate(previewedData, rotatedData,
105                                                                 Dimension(__previewWidth, __previewHeight), IMAGE_ROTATION_90, MEDIA_PIXEL_FORMAT_YUV420P);
106                                         break;
107
108                         case CAMERA_ROTATION_180:
109                                         ImageUtil::Rotate(previewedData, rotatedData,
110                                                                 Dimension(__previewWidth, __previewHeight), IMAGE_ROTATION_180, MEDIA_PIXEL_FORMAT_YUV420P);
111                                         break;
112
113                         case CAMERA_ROTATION_270:
114                                         ImageUtil::Rotate(previewedData, rotatedData,
115                                                                 Dimension(__previewWidth, __previewHeight), IMAGE_ROTATION_270, MEDIA_PIXEL_FORMAT_YUV420P);
116                                         break;
117
118                         default:
119                                         break;
120         }
121         // Normally Camera::SetFlip(CAMERA_FLIP_VERTICAL) is used when using the front camera.
122         // Remember that the OverlayRegion method rotates the visible region internally corresponding to the form's orientation.
123         // An application does not need to rotate the visible region explicitly.
124         // However, the preview data itself is not rotated. If an application wants to rotate the preview data, the data must be rotated like above.
125         // The width and height changes according to the degree of rotation.
126         * @endcode
127         */
128         virtual void OnCameraPreviewed(Tizen::Base::ByteBuffer& previewedData, result r) = 0;
129
130         /**
131         *       Called when the Camera::Capture() method is completed.
132         *
133         * @since                2.0
134         *
135         *       @param[in]       capturedData                   The image data captured by the camera @n
136         *                                                                               The captured data format is the same as the format
137         *                                                                          set by Camera::SetCaptureFormat().
138         * @param[in]     r      The cause of the error
139         *       @exception       E_SUCCESS      The method is successful.
140         *       @exception       E_INVALID_DATA  The ByteBuffer contains invalid data.
141         *       @see            Camera::Capture()
142         *   @see            Camera::GetCaptureFormat()
143         */
144         virtual void OnCameraCaptured(Tizen::Base::ByteBuffer& capturedData, result r) = 0;
145
146         /**
147         *       Called when an error occurs in Camera.
148         *
149         * @since                2.0
150         *
151         *       @param[in]      r               A camera error @n
152         *                                               This is one of the ::CameraErrorReason values.
153         *       @remarks                        The ::CAMERA_ERROR_DEVICE_FAILED error occurs when the camera device
154         *                                          has a problem, such as damaged shape or hardware malfunction.
155         *                                               The ::CAMERA_ERROR_DEVICE_INTERRUPTED error occurs when the camera
156         *                                          device has been interrupted by other request, such as an incoming
157         *                                          video telephony call.
158         *                                               In this method, the application calls the Camera::PowerOff()
159         *                                        method to reset the camera device.
160         */
161         virtual void OnCameraErrorOccurred(CameraErrorReason r) = 0;
162
163 protected:
164         //
165         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
166         //
167         // This method is reserved and may change its name at any time without prior notice.
168         //
169         // @since               2.0
170         //
171         virtual void ICameraEventListener_Reserved1(void) {}
172
173         //
174         // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
175         //
176         // This method is reserved and may change its name at any time without prior notice.
177         //
178         // @since               2.0
179         //
180         virtual void ICameraEventListener_Reserved2(void) {}
181
182 };
183
184 }}// Tizen::Media
185
186 #endif