- cleanup namespace usage

This commit is contained in:
Dmytro Bogovych 2019-02-04 09:15:01 +03:00
parent 5232d33f6e
commit 51780413af
1 changed files with 71 additions and 73 deletions

View File

@ -16,89 +16,87 @@
namespace Audio namespace Audio
{ {
class SpeexResampler class SpeexResampler
{ {
public: public:
SpeexResampler(); SpeexResampler();
~SpeexResampler(); ~SpeexResampler();
void start(int channels, int sourceRate, int destRate);
void stop();
size_t processBuffer(const void* source, size_t sourceLength, size_t& sourceProcessed,
void* dest, size_t destCapacity);
int sourceRate();
int destRate();
size_t getDestLength(size_t sourceLen);
size_t getSourceLength(size_t destLen);
// Returns instance + speex encoder size in bytes void start(int channels, int sourceRate, int destRate);
size_t getSize() const; void stop();
int processBuffer(const void* source, int sourceLength, int& sourceProcessed, void* dest, int destCapacity);
int sourceRate();
int destRate();
int getDestLength(int sourceLen);
int getSourceLength(int destLen);
protected: // Returns instance + speex encoder size in bytes
void* mContext; int getSize() const;
int mErrorCode;
int mSourceRate,
mDestRate,
mChannels;
short mLastSample;
};
typedef SpeexResampler Resampler; protected:
typedef std::shared_ptr<Resampler> PResampler; void* mContext;
int mErrorCode;
int mSourceRate,
mDestRate,
mChannels;
short mLastSample;
};
class ChannelConverter typedef SpeexResampler Resampler;
{ typedef std::shared_ptr<Resampler> PResampler;
public:
static int stereoToMono(const void* source, int sourceLength, void* dest, int destLength);
static int monoToStereo(const void* source, int sourceLength, void* dest, int destLength);
};
// Operates with AUDIO_CHANNELS number of channels class ChannelConverter
class UniversalResampler {
{ public:
public: static int stereoToMono(const void* source, int sourceLength, void* dest, int destLength);
UniversalResampler(); static int monoToStereo(const void* source, int sourceLength, void* dest, int destLength);
~UniversalResampler(); };
size_t resample(int sourceRate, const void* sourceBuffer, size_t sourceLength, size_t& sourceProcessed, // Operates with AUDIO_CHANNELS number of channels
int destRate, void* destBuffer, size_t destCapacity); class UniversalResampler
size_t getDestLength(int sourceRate, int destRate, size_t sourceLength); {
size_t getSourceLength(int sourceRate, int destRate, size_t destLength); public:
UniversalResampler();
~UniversalResampler();
protected: int resample(int sourceRate, const void* sourceBuffer, int sourceLength, int& sourceProcessed, int destRate, void* destBuffer, int destCapacity);
typedef std::pair<int, int> RatePair; int getDestLength(int sourceRate, int destRate, int sourceLength);
typedef std::map<RatePair, PResampler> ResamplerMap; int getSourceLength(int sourceRate, int destRate, int destLength);
ResamplerMap mResamplerMap;
PResampler findResampler(int sourceRate, int destRate);
void preload(); protected:
}; typedef std::pair<int, int> RatePair;
typedef std::map<RatePair, PResampler> ResamplerMap;
ResamplerMap mResamplerMap;
PResampler findResampler(int sourceRate, int destRate);
#ifdef USE_WEBRTC_RESAMPLER void preload();
// n*10 milliseconds buffers required! };
class Resampler48kTo16k
{
public:
Resampler48kTo16k();
~Resampler48kTo16k();
int process(const void* source, int sourceLen, void* dest, int destLen);
protected:
WebRtc_Word32 mTemp[496];
WebRtcSpl_State48khzTo16khz mContext;
};
class Resampler16kto48k #ifdef USE_WEBRTC_RESAMPLER
{ // n*10 milliseconds buffers required!
public: class Resampler48kTo16k
Resampler16kto48k(); {
~Resampler16kto48k(); public:
int process(const void* source, int sourceLen, void* dest, int destLen); Resampler48kTo16k();
~Resampler48kTo16k();
int process(const void* source, int sourceLen, void* dest, int destLen);
protected:
WebRtc_Word32 mTemp[496];
WebRtcSpl_State48khzTo16khz mContext;
};
protected: class Resampler16kto48k
WebRtc_Word32 mTemp[336]; {
WebRtcSpl_State16khzTo48khz mContext; public:
}; Resampler16kto48k();
#endif ~Resampler16kto48k();
} int process(const void* source, int sourceLen, void* dest, int destLen);
protected:
WebRtc_Word32 mTemp[336];
WebRtcSpl_State16khzTo48khz mContext;
};
#endif
} // end of namespace
#endif #endif