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 FMediaVideoFrame.h
20 * @brief This is the header file for the %VideoFrame class.
22 * This header file contains the declarations of the %VideoFrame class.
25 #ifndef _FMEDIA_VIDEO_FRAME_H_
26 #define _FMEDIA_VIDEO_FRAME_H_
29 #include <FMediaTypes.h>
31 namespace Tizen { namespace Media
36 * @brief This class has the video frame data.
38 * @final This class is not intended for extension.
42 * The %VideoFrame class has the video frame data.
43 * The frame has several plane components which represents each color of YUV. @n
44 * This object is delivered to the application by IVideoStreamFilter::ProcessVideoStream() when the video stream is coming.
46 * The following example demonstrates how to use the %VideoFrame class.
52 * using namespace Tizen::Graphics;
53 * using namespace Tizen::Ui;
54 * using namespace Tizen::Ui::Controls;
55 * using namespace Tizen::Media;
57 * class VideoFrameSample
58 * : public Tizen::Ui::Controls::Form
59 * , public Tizen::Media::ICameraEventListener
60 * , public Tizen::Media::IVideoStreamFilter
63 * VideoFrameSample(void);
68 * virtual void OnCameraAutoFocused(bool completeCondition) {}
69 * virtual void OnCameraPreviewed( Tizen::Base::ByteBuffer& previewedData, result r) {}
70 * virtual void OnCameraCaptured( Tizen::Base::ByteBuffer& capturedData, result r) {}
71 * virtual void OnCameraErrorOccurred(CameraErrorReason r ) {}
72 * virtual void ProcessVideoStream(VideoFrame &frame);
76 * OverlayRegion * __pOverlay;
79 * VideoFrameSample::VideoFrameSample(void)
85 * VideoFrameSample::Start(void)
87 * result r = E_SUCCESS;
88 * Rectangle rect(0, 0, 320, 240);
89 * bool modified = false;
90 * bool isValid = false;
91 * BufferInfo bufferInfo;
93 * r = __camera.Construct(*this, CAMERA_PRIMARY);
99 * r = __camera.PowerOn();
105 * r = __camera.AddVideoStreamFilter(*this);
111 * isValid = OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN, rect, modified);
112 * if (isValid != true)
114 * return GetLastResult();
117 * // Gets OverlayRegion from this Form
118 * __pOverlay = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_PRIMARY_CAMERA);
119 * if (__pOverlay == null)
121 * return GetLastResult();
124 * __pOverlay->GetBackgroundBufferInfo(bufferInfo);
126 * r = __camera.StartPreview(&bufferInfo, true);
143 * VideoFrameSample::Stop(void)
145 * __camera.StopPreview();
146 * __camera.PowerOff();
155 * VideoFrameSample::ProcessVideoStream(VideoFrame &frame)
157 * MediaPixelFormat format = frame.GetPixelFormat();
158 * int count = frame.GetPlaneCount();
159 * int width = frame.GetWidth();
160 * int height = frame.GetHeight();
162 * for (int i=0; i<count; i++)
164 * switch(frame.GetPlaneType(i))
166 * case VIDEO_PLANE_TYPE_Y:
167 * // manipulate Y plane.
169 * case VIDEO_PLANE_TYPE_U:
170 * // manipulate U plane.
172 * case VIDEO_PLANE_TYPE_V:
173 * // manipulate V plane.
175 * case VIDEO_PLANE_TYPE_YUV:
176 * // manipulate YUV plane, which YUV data exists in linear memory space. Check pixel format to detect the order of YUV data.
178 * case VIDEO_PLANE_TYPE_UV:
179 * // manipulate UV plane, which UV data exists in linear memory space. Check pixel format to detect the order or UV data.
190 class _OSP_EXPORT_ VideoFrame
191 : public Tizen::Base::Object
196 * Gets the plane count which the frame data has.
200 * @return The plane count
203 int GetPlaneCount(void) const;
207 * Gets the video plane type at the specified index from the frame.
211 * @return The video plane type, @n
212 * else ::VIDEO_PLANE_TYPE_NONE if an error occurred
213 * @param[in] index The index at which the value is read
214 * @exception E_SUCCESS The method is successful.
215 * @exception E_OUT_OF_RANGE The specified index is out of range.
216 * @remarks The index should be less than the plane count. @n
217 * The specific error code can be accessed using the GetLastResult() method.
220 VideoPlaneType GetPlaneType(int index) const;
224 * Gets the plane data at the specified index from the frame.
228 * @return The plane data, @n
229 * else @null if an error occurred
230 * @param[in] index The index at which the value is read
231 * @exception E_SUCCESS The method is successful.
232 * @exception E_OUT_OF_RANGE The specified index is out of range.
233 * @remarks The index should be less than the plane count. @n
234 * The buffer in ByteBuffer is shared with @c VideoFrame instance. @n
235 * The specific error code can be accessed using the GetLastResult() method.
238 Tizen::Base::ByteBuffer* GetPlaneData(int index) const;
242 * Gets the bytes count per a line of the specified index plane.
246 * @return The number of bytes per a line of the plane, @n
247 * else @c 0 if an error occurred
248 * @param[in] index The index at which the value is read
249 * @exception E_SUCCESS The method is successful.
250 * @exception E_OUT_OF_RANGE The specified index is out of range.
251 * @remarks The index should be less than the plane count. @n
252 * The specific error code can be accessed using the GetLastResult() method.
255 int GetBytesCountPerLine(int index) const;
259 * Gets the width of the frame.
263 * @return The width of the frame
266 int GetWidth(void) const;
270 * Gets the height of the frame.
274 * @return The height of the frame
277 int GetHeight(void) const;
281 * Gets the pixel format of the frame.
285 * @return The pixel format of the frame
288 MediaPixelFormat GetPixelFormat(void) const;
292 * This is the default constructor for this class.
295 * @remarks The object is not fully constructed after this constructor is called. For full construction,
296 * the Construct() method must be called right after calling this constructor.
301 * This is the destructor for this class. @n
302 * All allocated resources are deallocated by this method. This polymorphic destructor should be overridden if required.
303 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
307 virtual ~VideoFrame(void);
310 * Constructs the instance of this class. @n
314 * @return An error code
315 * @exception E_SUCCESS The method is successful.
318 result Construct(void);
321 * This is the copy constructor for this class.
325 * @remarks The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
327 VideoFrame(const VideoFrame& rhs);
330 * This is the copy assignment operator for this class.
334 * @remarks The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
337 VideoFrame& operator =(const VideoFrame& rhs);
339 friend class _VideoStreamCoordinator;
340 friend class _VideoFrameImpl;
341 class _VideoFrameImpl* __pImpl;