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 video frame data.
38 * @final This class is not intended for extension.
42 * The %VideoFrame class has video frame data.
43 * The frame has several plane components which represent each color of YUV. @n
44 * This object is delivered to the application by IVideoStreamFilter::ProcessVideoStream() when the video is being streamed.
46 * The following example demonstrates how to use the %VideoFrame class.
53 * using namespace Tizen::Graphics;
54 * using namespace Tizen::Ui;
55 * using namespace Tizen::Ui::Controls;
56 * using namespace Tizen::Media;
58 * class VideoFrameSample
59 * : public Tizen::Ui::Controls::Form
60 * , public Tizen::Media::ICameraEventListener
61 * , public Tizen::Media::IVideoStreamFilter
64 * VideoFrameSample(void);
69 * virtual void OnCameraAutoFocused(bool completeCondition) {}
70 * virtual void OnCameraPreviewed( Tizen::Base::ByteBuffer& previewedData, result r) {}
71 * virtual void OnCameraCaptured( Tizen::Base::ByteBuffer& capturedData, result r) {}
72 * virtual void OnCameraErrorOccurred(CameraErrorReason r ) {}
73 * virtual void ProcessVideoStream(VideoFrame &frame);
77 * OverlayRegion * __pOverlay;
80 * VideoFrameSample::VideoFrameSample(void)
86 * VideoFrameSample::Start(void)
88 * result r = E_SUCCESS;
89 * Rectangle rect(0, 0, 320, 240);
90 * bool modified = false;
91 * bool isValid = false;
92 * BufferInfo bufferInfo;
94 * r = __camera.Construct(*this, CAMERA_PRIMARY);
100 * r = __camera.PowerOn();
106 * r = __camera.AddVideoStreamFilter(*this);
112 * isValid = OverlayRegion::EvaluateBounds(OVERLAY_REGION_EVALUATION_OPTION_LESS_THAN, rect, modified);
113 * if (isValid != true)
115 * return GetLastResult();
118 * // Gets OverlayRegion from this Form
119 * __pOverlay = GetOverlayRegionN(rect, OVERLAY_REGION_TYPE_PRIMARY_CAMERA);
120 * if (__pOverlay == null)
122 * return GetLastResult();
125 * __pOverlay->GetBackgroundBufferInfo(bufferInfo);
127 * r = __camera.StartPreview(&bufferInfo, true);
144 * VideoFrameSample::Stop(void)
146 * __camera.StopPreview();
147 * __camera.PowerOff();
156 * VideoFrameSample::ProcessVideoStream(VideoFrame &frame)
158 * MediaPixelFormat format = frame.GetPixelFormat();
159 * int count = frame.GetPlaneCount();
160 * int width = frame.GetWidth();
161 * int height = frame.GetHeight();
163 * AppLog("frame plane count is %d", count);
164 * AppLog("frame plane width is %d and height is %d", width, height);
165 * AppLog("frame Pixel Format is %d", format);
167 * for (int i=0; i<count; i++)
169 * switch(frame.GetPlaneType(i))
171 * case VIDEO_PLANE_TYPE_Y:
172 * // Manipulates Y plane.
174 * case VIDEO_PLANE_TYPE_U:
175 * // Manipulates U plane.
177 * case VIDEO_PLANE_TYPE_V:
178 * // Manipulates V plane.
180 * case VIDEO_PLANE_TYPE_YUV:
181 * // Manipulates YUV plane, which YUV data exists in linear memory space. Check pixel format to detect the order of YUV data.
183 * case VIDEO_PLANE_TYPE_UV:
184 * // Manipulates UV plane, which UV data exists in linear memory space. Check pixel format to detect the order or UV data.
196 class _OSP_EXPORT_ VideoFrame
197 : public Tizen::Base::Object
201 * Gets the plane count of the frame data.
205 * @return The plane count
208 int GetPlaneCount(void) const;
211 * Gets the video plane type at the specified index from the frame.
215 * @return The video plane type, @n
216 * else ::VIDEO_PLANE_TYPE_NONE if an error occurs
217 * @param[in] index The index at which the value is read
218 * @exception E_SUCCESS The method is successful.
219 * @exception E_OUT_OF_RANGE The specified @c index is out of the valid range.
221 * - The index should be less than the plane count.
222 * - The specific error code can be accessed using the GetLastResult() method.
225 VideoPlaneType GetPlaneType(int index) const;
229 * Gets the plane data at the specified index from the frame.
233 * @return The plane data, @n
234 * else @c null if an error occurs
235 * @param[in] index The index at which the value is read
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_OUT_OF_RANGE The specified @c index is out of the valid range.
239 * - The index should be less than the plane count.
240 * - The buffer in Tizen::Base::ByteBuffer is shared with the %VideoFrame instance.
241 * - The specific error code can be accessed using the GetLastResult() method.
244 Tizen::Base::ByteBuffer* GetPlaneData(int index) const;
247 * Gets the byte count per line of the specified index plane.
251 * @return The number of bytes per line of the plane, @n
252 * else @c 0 if an error occurs
253 * @param[in] index The index at which the value is read
254 * @exception E_SUCCESS The method is successful.
255 * @exception E_OUT_OF_RANGE The specified @c index is out of the valid range.
257 * - The index should be less than the plane count.
258 * - The specific error code can be accessed using the GetLastResult() method.
261 int GetBytesCountPerLine(int index) const;
264 * Gets the width of the frame.
268 * @return The width of the frame
271 int GetWidth(void) const;
274 * Gets the height of the frame.
278 * @return The height of the frame
281 int GetHeight(void) const;
284 * Gets the pixel format of the frame.
288 * @return The pixel format of the frame
291 MediaPixelFormat GetPixelFormat(void) const;
295 * This is the default constructor for this class. @n
296 * The object is not fully constructed after this constructor is called. @n For full construction,
297 * the Construct() method must be called right after calling this constructor.
304 * This is the destructor for this class. @n
305 * All allocated resources are deallocated by this method. This polymorphic destructor should be overridden if required.
306 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
310 virtual ~VideoFrame(void);
313 * Constructs the instance of this class. @n
317 * @return An error code
318 * @exception E_SUCCESS The method is successful.
321 result Construct(void);
324 * This is the copy constructor for this class.
328 * @remarks The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
330 VideoFrame(const VideoFrame& rhs);
333 * This is the copy assignment operator for this class.
337 * @remarks The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
340 VideoFrame& operator =(const VideoFrame& rhs);
342 friend class _VideoStreamCoordinator;
343 friend class _VideoFrameImpl;
344 class _VideoFrameImpl* __pImpl;