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 FMediaVideoFrameExtractor.h
20 * @brief This is the header file for the %VideoFrameExtractor class.
22 * This header file contains the declarations of the %VideoFrameExtractor class.
25 #ifndef _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_
26 #define _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_
28 #include <FBaseObject.h>
29 #include <FMediaImageBuffer.h>
30 #include <FMediaRecorderTypes.h>
32 namespace Tizen { namespace Media {
35 * @class VideoFrameExtractor
36 * @brief This class is used to extract video frame from video file.
40 * The %VideoFrameExtractor class is used to extract video frame from video file.
42 * The following example demonstrates how to use the %VideoFrameExtractor class to extract video frame from video file.
47 * #include <FGraphics.h>
49 * using namespace Tizen::Base;
50 * using namespace Tizen::Media;
51 * using namespace Tizen::Graphics;
55 * TestVideoFrameExtractor(void)
57 * VideoFrameExtractor extractor;
58 * String path = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp4";
59 * result r = extractor.Construct(path, MEDIA_PIXEL_FORMAT_BGRA8888);
60 * long duration = extractor.GetDuration();
62 * // Extracts video frames from the video file
64 * for (int i = 0; i < 10; i++)
66 * ImageBuffer* pImage = extractor.GetFrameN(duration*i/10);
68 * // Adds some codes that handles extracted video frame
76 class _OSP_EXPORT_ VideoFrameExtractor
77 : public Tizen::Base::Object
81 * This is the default constructor for this class.
87 VideoFrameExtractor(void);
90 * This destructor overrides Tizen::Base::Object::~Object().
96 virtual ~VideoFrameExtractor(void);
99 * Initializes this instance of %VideoFrameExtractor with the specified parameters.
103 * @return An error code
104 * @param[in] filePath The video file path
105 * @param[in] pixelFormat The pixel format of output image data.
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_INVALID_ARG A specified input parameter is invalid.
108 * @exception E_UNSUPPORTED_FORMAT The specified format is not supported.
109 * @exception E_OUT_OF_MEMORY The memory is insufficient.
110 * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
112 result Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat);
115 * Gets the width of the video frame.
119 * @return The width of video frame
121 int GetWidth(void) const;
124 * Gets the height of the video frame.
128 * @return The height of the video frame
130 int GetHeight(void) const;
133 * Gets the duration of the video in millisecond.
137 * @return The duration of the video in millisecond
139 long GetDuration(void) const;
142 * Extract video frame at the specified position.
146 * @return A pointer to the ImageBuffer containing extracted video frame.
147 * @param[in] timestamp The timestamp of video frame to extract
148 * @exception E_SUCCESS The method is successful.
149 * @exception E_OUT_OF_RANGE The specified @c timestamp is out of range.
150 * @exception E_OUT_OF_MEMORY The memory is insufficient.
151 * @exception E_OPERATION_FAILED Video frame at given position is not found or extraction is failed.
152 * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported.
153 * @remarks The specific error code can be accessed using the GetLastResult() method.
154 * @remarks The extracted frame may not be exact frame of given timestamp,
155 * so that the same frame can be returned even if the timestamp is different.
156 * @remarks Frames near the end of contents may not be extracted if no key-frame is found after timestamp.
158 ImageBuffer* GetFrameN(long timestamp);
161 * Extract video thumbnail from the specified position.
165 * @return A pointer to the ImageBuffer containing the extracted video frame.
166 * @param[in] path The video file path
167 * @param[in] timestamp The timestamp of video frame that want to extract
168 * @param[in] pixelFormat The pixel format of output image data.
169 * @exception E_SUCCESS The method is successful.
170 * @exception E_INVALID_ARG A specified input parameter is invalid.
171 * @exception E_OUT_OF_RANGE The specified @c timestamp is out of range.
172 * @exception E_OUT_OF_MEMORY The memory is insufficient.
173 * @exception E_OPERATION_FAILED Video frame at given position is not found or extraction is failed.
174 * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported.
175 * @remarks The specific error code can be accessed using the GetLastResult() method.
176 * @remarks The extracted frame may not be exact frame of given timestamp,
177 * so that the same frame can be returned even if the timestamp is different.
178 * @remarks Frames near the end of contents may not be extracted if no key-frame is found after timestamp.
180 static ImageBuffer* GetFrameN(const Tizen::Base::String& path, MediaPixelFormat pixelFormat, long timestamp);
183 * Gets the current recording rotation of video data. @n
187 * @return Recording rotation information of the current video data.
189 RecordingRotation GetRecordingRotation(void) const;
194 * This is the copy constructor for this class.
196 VideoFrameExtractor(const VideoFrameExtractor& rhs);
199 * This is the assignment operator.
201 VideoFrameExtractor& operator =(const VideoFrameExtractor& rhs);
204 friend class _VideoFrameExtractorImpl;
205 class _VideoFrameExtractorImpl* __pImpl;
210 #endif // _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_