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>
31 namespace Tizen { namespace Media {
34 * @class VideoFrameExtractor
35 * @brief This class is used to extract video frame from video file.
39 * The %VideoFrameExtractor class is used to extract video frame from video file.
41 * The following example demonstrates how to use the %VideoFrameExtractor class to extract video frame from video file.
46 * #include <FGraphics.h>
48 * using namespace Tizen::Base;
49 * using namespace Tizen::Media;
50 * using namespace Tizen::Graphics;
54 * TestVideoFrameExtractor(void)
56 * VideoFrameExtractor extractor;
57 * String path = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/test.mp4";
58 * result r = extractor.Construct(path, MEDIA_PIXEL_FORMAT_BGRA8888);
59 * long duration = extractor.GetDuration();
61 * // Extracts video frames from the video file
63 * for (int i = 0; i < 10; i++)
65 * ImageBuffer* pImage = extractor.GetFrameN(duration*i/10);
67 * // Adds some codes that handles extracted video frame
75 class _OSP_EXPORT_ VideoFrameExtractor
76 : public Tizen::Base::Object
80 * This is the default constructor for this class.
86 VideoFrameExtractor(void);
89 * This destructor overrides Tizen::Base::Object::~Object().
95 virtual ~VideoFrameExtractor(void);
98 * Initializes this instance of %VideoFrameExtractor with the specified parameters.
102 * @return An error code
103 * @param[in] filePath The video file path
104 * @param[in] pixelFormat The pixel format of output image data.
105 * @exception E_SUCCESS The method is successful.
106 * @exception E_INVALID_ARG A specified input parameter is invalid.
107 * @exception E_UNSUPPORTED_FORMAT The specified format is not supported.
108 * @exception E_OUT_OF_MEMORY The memory is insufficient.
109 * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
111 result Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat);
114 * Gets the width of the video frame.
118 * @return The width of video frame
120 int GetWidth(void) const;
123 * Gets the height of the video frame.
127 * @return The height of the video frame
129 int GetHeight(void) const;
132 * Gets the duration of the video in millisecond.
136 * @return The duration of the video in millisecond
138 long GetDuration(void) const;
141 * Extract video frame at the specified position.
145 * @return A pointer to the ImageBuffer containing extracted video frame.
146 * @param[in] timestamp The timestamp of video frame to extract
147 * @exception E_SUCCESS The method is successful.
148 * @exception E_OUT_OF_RANGE The specified @c timestamp is out of range.
149 * @exception E_OUT_OF_MEMORY The memory is insufficient.
150 * @exception E_OPERATION_FAILED Video frame at given position is not found or extraction is failed.
151 * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported.
152 * @remarks The specific error code can be accessed using the GetLastResult() method.
153 * @remarks The extracted frame may not be exact frame of given timestamp,
154 * so that the same frame can be returned even if the timestamp is different.
155 * @remarks Frames near the end of contents may not be extracted if no key-frame is found after timestamp.
157 ImageBuffer* GetFrameN(long timestamp);
160 * Extract video thumbnail from the specified position.
164 * @return A pointer to the ImageBuffer containing the extracted video frame.
165 * @param[in] path The video file path
166 * @param[in] timestamp The timestamp of video frame that want to extract
167 * @param[in] pixelFormat The pixel format of output image data.
168 * @exception E_SUCCESS The method is successful.
169 * @exception E_INVALID_ARG A specified input parameter is invalid.
170 * @exception E_OUT_OF_RANGE The specified @c timestamp is out of range.
171 * @exception E_OUT_OF_MEMORY The memory is insufficient.
172 * @exception E_OPERATION_FAILED Video frame at given position is not found or extraction is failed.
173 * @exception E_UNSUPPORTED_FORMAT The specified pixel format is not supported.
174 * @remarks The specific error code can be accessed using the GetLastResult() method.
175 * @remarks The extracted frame may not be exact frame of given timestamp,
176 * so that the same frame can be returned even if the timestamp is different.
177 * @remarks Frames near the end of contents may not be extracted if no key-frame is found after timestamp.
179 static ImageBuffer* GetFrameN(const Tizen::Base::String& path, MediaPixelFormat pixelFormat, long timestamp);
183 * This is the copy constructor for this class.
185 VideoFrameExtractor(const VideoFrameExtractor& rhs);
188 * This is the assignment operator.
190 VideoFrameExtractor& operator =(const VideoFrameExtractor& rhs);
193 friend class _VideoFrameExtractorImpl;
194 class _VideoFrameExtractorImpl* __pImpl;
199 #endif // _FMEDIA_VIDEO_FRAME_EXTRACTOR_H_