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.
18 #include <FMediaAudioDecoder.h>
19 #include <FBaseSysLog.h>
20 #include "FMedia_AudioDecoderImpl.h"
22 using namespace Tizen::Base;
23 using namespace Tizen::Base::Collection;
25 namespace Tizen { namespace Media
28 AudioDecoder::AudioDecoder(void)
33 AudioDecoder::~AudioDecoder(void)
42 AudioDecoder::Construct(CodecType type, const Tizen::Base::Collection::HashMap* pOption)
46 SysAssertf(__pImpl == null,
47 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
49 _AudioDecoderImpl* pAudioDecoderImpl = new (std::nothrow) _AudioDecoderImpl();
50 SysTryCatch(NID_MEDIA, pAudioDecoderImpl != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
51 "[%s] Memory Allocation Failed. Propagating. ",GetErrorMessage(E_OUT_OF_MEMORY));
\r
53 r = pAudioDecoderImpl->Construct(type, pOption);
54 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
57 __pImpl = pAudioDecoderImpl;
61 if (pAudioDecoderImpl != null)
63 delete pAudioDecoderImpl;
64 pAudioDecoderImpl = null;
70 AudioDecoder::Probe(const Tizen::Base::ByteBuffer& srcBuf, AudioSampleType& sampleType,
71 AudioChannelType& channelType, int& sampleRate)
75 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
77 r = __pImpl->Probe(srcBuf, sampleType, channelType, sampleRate);
78 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
88 AudioDecoder::Decode(Tizen::Base::ByteBuffer& srcBuf, Tizen::Base::ByteBuffer& dstBuf)
92 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
94 r = __pImpl->Decode(srcBuf, dstBuf);
95 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
105 AudioDecoder::Reset(void)
107 result r = E_SUCCESS;
109 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
111 r = __pImpl->Reset();
112 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
122 AudioDecoder::GetValue(MediaPropertyType GetValue, int& value) const
124 result r = E_SUCCESS;
126 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
128 r = __pImpl->GetValue(GetValue, value);
129 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
139 Tizen::Base::Collection::IListT<MediaPropertyType>*
140 AudioDecoder::GetSupportedPropertyListN(void) const
142 result r = E_SUCCESS;
143 Tizen::Base::Collection::IListT<MediaPropertyType> *pList = null;
145 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
147 pList = __pImpl->GetSupportedPropertyListN();
148 SysTryCatch(NID_MEDIA, pList != null, , GetLastResult(), "[%s] Propagating", GetErrorMessage(GetLastResult()));
150 SetLastResult(E_SUCCESS);
158 AudioDecoder::IsPropertySupported(MediaPropertyType key) const
160 result r = E_SUCCESS;
161 bool supported = false;
163 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
165 supported = __pImpl->IsPropertySupported(key);
167 SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating", GetErrorMessage(r));
176 Tizen::Base::Collection::IListT<CodecType>*
177 AudioDecoder::GetSupportedCodecListN(void)
179 result r = E_SUCCESS;
180 Tizen::Base::Collection::IListT<CodecType> *pList = null;
182 pList = _AudioDecoderImpl::GetSupportedCodecListN();
184 SysTryReturn(NID_MEDIA, pList != null, null, r, "[%s] Propagating", GetErrorMessage(r));
186 SetLastResult(E_SUCCESS);