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 FMedia_AudioFrameImpl.cpp
20 * @brief This file contains the implementation of the _AudioFrameImpl class.
24 #include <unique_ptr.h>
25 #include <FBaseSysLog.h>
26 #include <FMediaAudioFrame.h>
27 #include <FMediaAudioTypes.h>
28 #include "FMedia_AudioFrameImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
33 namespace Tizen { namespace Media
35 static const int _AUDIO_PLANE_COUNT = 1;
37 _AudioFrameImpl::_AudioFrameImpl(void)
39 , __channel(AUDIO_CHANNEL_TYPE_NONE)
40 , __sampleType(AUDIO_TYPE_NONE)
41 , __planeCount(_AUDIO_PLANE_COUNT)
42 , __pAudioStreamBuffer(null)
47 _AudioFrameImpl::~_AudioFrameImpl(void)
52 _AudioFrameImpl::Initialize(byte* pStream, int size, int samplingRate, AudioChannelType channel, AudioSampleType sampleType)
56 __pAudioStreamBuffer.reset(new (std::nothrow) Tizen::Base::ByteBuffer());
57 SysTryReturn(NID_MEDIA, __pAudioStreamBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed. The object is not created.");
59 r = __pAudioStreamBuffer->Construct(pStream, 0, size, size);
60 SysTryReturn(NID_MEDIA, r== E_SUCCESS, r, r, "[%s] Propogating", GetErrorMessage(r));
62 __samplingRate = samplingRate;
64 __sampleType = sampleType;
70 _AudioFrameImpl:: GetPlaneCount(void) const
75 Tizen::Base::ByteBuffer*
76 _AudioFrameImpl::GetPlaneData(int index) const
78 SysTryReturn(NID_MEDIA, index < __planeCount, null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The index %d is out of range, plane count %d.",index, __planeCount);
80 return __pAudioStreamBuffer.get();
84 _AudioFrameImpl::GetSamplingRate(void) const
86 return __samplingRate;
90 _AudioFrameImpl::GetChannelType(void) const
96 _AudioFrameImpl::GetSampleType(void) const
102 _AudioFrameImpl::GetInstance(AudioFrame *pAudioFrame)
104 if ( pAudioFrame != null )
106 return pAudioFrame->__pImpl;
111 const _AudioFrameImpl*
112 _AudioFrameImpl::GetInstance(const AudioFrame *pAudioFrame)
114 if ( pAudioFrame != null)
116 return pAudioFrame->__pImpl;