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.
17 #include <FMediaVideoFrameExtractor.h>
18 #include <FMedia_VideoFrameExtractorImpl.h>
19 #include <FBaseSysLog.h>
21 using namespace Tizen::Base;
22 using namespace Tizen::Graphics;
24 namespace Tizen { namespace Media {
26 VideoFrameExtractor::VideoFrameExtractor(void)
31 VideoFrameExtractor::~VideoFrameExtractor(void)
42 VideoFrameExtractor::Construct(const Tizen::Base::String &filePath, MediaPixelFormat pixelFormat)
45 _VideoFrameExtractorImpl* pVideoFrameExtractorImpl = null;
47 SysAssertf(__pImpl == null,
48 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50 SysTryReturn(NID_MEDIA, !filePath.IsEmpty(), E_FILE_NOT_FOUND, E_FILE_NOT_FOUND,
51 "[%s] Propagating.", GetErrorMessage(E_FILE_NOT_FOUND));
53 pVideoFrameExtractorImpl = new (std::nothrow) _VideoFrameExtractorImpl();
54 SysTryReturnResult(NID_MEDIA, pVideoFrameExtractorImpl != null, E_OUT_OF_MEMORY, "Create instance failed.");
56 r = pVideoFrameExtractorImpl->Construct(filePath, pixelFormat);
57 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , GetLastResult(),
58 "[%s] Failed to Construct pVideoFrameExtractorImpl.", GetErrorMessage(GetLastResult()));
60 __pImpl = pVideoFrameExtractorImpl;
65 delete pVideoFrameExtractorImpl;
66 pVideoFrameExtractorImpl = null;
73 VideoFrameExtractor::GetWidth(void) const
75 SysAssertf(__pImpl != null,
76 "Not yet constructed. Construct() should be called before use.");
78 return __pImpl->GetWidth();
82 VideoFrameExtractor::GetHeight(void) const
84 SysAssertf(__pImpl != null,
85 "Not yet constructed. Construct() should be called before use.");
87 return __pImpl->GetHeight();
92 VideoFrameExtractor::GetDuration(void) const
94 SysAssertf(__pImpl != null,
95 "Not yet constructed. Construct() should be called before use.");
97 return __pImpl->GetDuration();
101 VideoFrameExtractor::GetFrameN(long timestamp)
103 SysAssertf(__pImpl != null,
104 "Not yet constructed. Construct() should be called before use.");
106 return __pImpl->GetFrameN(timestamp);
111 VideoFrameExtractor::GetFrameN(const Tizen::Base::String& path, MediaPixelFormat pixelFormat, long timestamp )
113 return _VideoFrameExtractorImpl::GetFrameN(path, pixelFormat, timestamp);