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 FMediaGifDecoder.cpp
20 * @brief This file contains the implementation of GifDecoder.
23 #include <FMediaTypes.h>
24 #include <FBaseSysLog.h>
25 #include "FMediaGifDecoder.h"
26 #include "FMedia_GifDecoderImpl.h"
28 namespace Tizen { namespace Media
31 GifDecoder::GifDecoder(void)
36 GifDecoder::~GifDecoder(void)
45 GifDecoder::Construct(const Tizen::Base::String& filePath, MediaPixelFormat pixelFormat)
49 // Check pre-construct
50 SysAssertf(__pDecImpl == null,
51 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
52 // Create _GifDecoderImpl_ instance
53 _GifDecoderImpl* pGifDecoderImpl = new (std::nothrow) _GifDecoderImpl();
54 SysTryCatch(NID_MEDIA, pGifDecoderImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed Propagated.");
55 r = pGifDecoderImpl->Construct(filePath,pixelFormat);
56 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagated", GetErrorMessage(r));
57 __pDecImpl = pGifDecoderImpl;
62 delete pGifDecoderImpl;
63 pGifDecoderImpl = null;
69 GifDecoder::Construct(const Tizen::Base::ByteBuffer& srcBuf, MediaPixelFormat pixelFormat)
73 // Check pre-construct
74 SysAssertf(__pDecImpl == null,
75 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
76 // Create _GifDecoderImpl_ instance
77 _GifDecoderImpl* pGifDecoderImpl = new (std::nothrow) _GifDecoderImpl();
78 SysTryCatch(NID_MEDIA, pGifDecoderImpl, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed Propagated.");
79 r = pGifDecoderImpl->Construct(srcBuf,pixelFormat);
80 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagated", GetErrorMessage(r));
81 __pDecImpl = pGifDecoderImpl;
86 delete pGifDecoderImpl;
87 pGifDecoderImpl = null;
94 GifDecoder::GetWidth(void) const
97 SysAssertf(__pDecImpl != null, "Not yet constructed. Construct() should be called before use.");
98 return __pDecImpl->GetWidth();
103 GifDecoder::GetHeight(void) const
106 SysAssertf(__pDecImpl != null, "Not yet constructed. Construct() should be called before use.");
107 return __pDecImpl->GetHeight();
110 Tizen::Base::ByteBuffer*
111 GifDecoder::GetNextFrameN(long& duration)
114 SysAssertf(__pDecImpl != null, "Not yet constructed. Construct() should be called before use.");
116 return __pDecImpl->GetNextFrameN(duration);
119 Tizen::Graphics::Bitmap*
120 GifDecoder::GetNextBitmapN(long& duration, Tizen::Graphics::BufferScaling bufferScaling)
123 SysAssertf(__pDecImpl != null, "Not yet constructed. Construct() should be called before use.");
125 return __pDecImpl->GetNextBitmapN(duration, bufferScaling);