sipxmedialib  Version 3.3
MpResamplerSpeex.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2008-2018 SIPez LLC. All rights reserved.
3 //
4 // $$
6 
7 // Author: Keith Kyzivat <kkyzivat AT SIPez DOT com>
8 
9 #ifndef _MpResamplerSpeex_h_
10 #define _MpResamplerSpeex_h_
11 
12 #if defined(HAVE_SPEEX) || defined(HAVE_SPEEX_RESAMPLER)
13 
14 // SYSTEM INCLUDES
15 // APPLICATION INCLUDES
16 #include "mp/MpResampler.h"
17 #include <mp/MpTypes.h>
18 #include <os/OsStatus.h>
19 
20 // DEFINES
21 // MACROS
22 // EXTERNAL FUNCTIONS
23 // EXTERNAL VARIABLES
24 // CONSTANTS
25 // STRUCTS
26 // TYPEDEFS
27 // FORWARD DECLARATIONS
28 // NOTE: If the below forward declaration causes problems for some compilers
29 // due to double-typedef, then it can be corrected by including
30 // speex_resampler.h instead.
31 typedef struct SpeexResamplerState_ SpeexResamplerState;
32 
36 class MpResamplerSpeex : public MpResamplerBase
37 {
38 /* //////////////////////////////// PUBLIC //////////////////////////////// */
39 public:
40 
41 /* =============================== CREATORS =============================== */
43 
44 
45  MpResamplerSpeex(uint32_t numChannels,
46  uint32_t inputRate,
47  uint32_t outputRate,
48  int32_t quality = -1);
61  ~MpResamplerSpeex();
67 
68 /* ============================= MANIPULATORS ============================= */
70 
71 
72  OsStatus resetStream();
77  OsStatus resample(uint32_t channelIndex,
78  const MpAudioSample* pInBuf,
79  uint32_t inBufLength,
80  uint32_t& inSamplesProcessed,
81  MpAudioSample* pOutBuf,
82  uint32_t outBufLength,
83  uint32_t& outSamplesWritten);
89  OsStatus resampleInterleavedStereo(const MpAudioSample* pInBuf,
90  uint32_t inBufLength,
91  uint32_t& inSamplesProcessed,
92  MpAudioSample* pOutBuf,
93  uint32_t outBufLength,
94  uint32_t& outSamplesWritten);
100  OsStatus setInputRate(const uint32_t inputRate);
106  // Set the output sample rate, in Hz
107  OsStatus setOutputRate(const uint32_t outputRate);
112  // Set the quality of resampling conversion
113  OsStatus setQuality(const int32_t quality);
119 
120 /* ============================== ACCESSORS =============================== */
122 
123 
125 
126 /* =============================== INQUIRY ================================ */
128 
129 
130 
132 
133 /* ////////////////////////////// PROTECTED /////////////////////////////// */
134 protected:
135 
136 /* /////////////////////////////// PRIVATE //////////////////////////////// */
137 private:
138  OsStatus speexErrToOsStatus(int speexErr);
139 
140 private:
141  SpeexResamplerState* mpState;
142 
143 };
144 
145 /* ============================ INLINE METHODS ============================ */
146 
147 #endif // HAVE_SPEEX
148 #endif // _MpResamplerSpeex_h_
Generic audio resampler.
Definition: MpResampler.h:34
virtual OsStatus resampleInterleavedStereo(const MpAudioSample *pInBuf, uint32_t inBufLength, uint32_t &inSamplesProcessed, MpAudioSample *pOutBuf, uint32_t outBufLength, uint32_t &outSamplesWritten)
Resample interleaved stereo audio data.
Definition: MpResampler.cpp:129
virtual OsStatus resample(uint32_t channelIndex, const MpAudioSample *pInBuf, uint32_t inBufLength, uint32_t &inSamplesProcessed, MpAudioSample *pOutBuf, uint32_t outBufLength, uint32_t &outSamplesWritten)
Resample audio data coming from the specified channel.
Definition: MpResampler.cpp:72
virtual OsStatus setOutputRate(const uint32_t outputRate)
Set the output sample rate, in Hz.
Definition: MpResampler.cpp:228
virtual OsStatus resetStream()
Reset resampler state to prepare for processing new (unrelated) stream.
Definition: MpResampler.cpp:65
int16_t MpAudioSample
Definition: MpTypes.h:44
virtual OsStatus setInputRate(const uint32_t inputRate)
Set the input sample rate, in Hz.
Definition: MpResampler.cpp:222
virtual OsStatus setQuality(const int32_t quality)
Set the quality of resampling conversion.
Definition: MpResampler.cpp:234