add getFrequencyIndex and use it to correctly set the frequency index

This commit is contained in:
Isaac Connor 2021-03-04 13:24:26 -05:00
parent 1adeda6241
commit eb36c9e919
2 changed files with 11 additions and 5 deletions

View File

@ -6,11 +6,8 @@
**
** -------------------------------------------------------------------------*/
#include "zm_logger.h"
#include "zm_rtsp_server_fifo_audio_source.h"
#include <sstream>
#if HAVE_RTSP_SERVER
static unsigned const samplingFrequencyTable[16] = {
@ -35,4 +32,9 @@ ZoneMinderFifoAudioSource::ZoneMinderFifoAudioSource(
channels(1)
{
}
int ZoneMinderFifoAudioSource::getFrequencyIndex() {
for (int i=0; i<16; i++)
if (samplingFrequencyTable[i] == frequency) return i;
return -1;
}
#endif // HAVE_RTSP_SERVER

View File

@ -39,8 +39,12 @@ class ZoneMinderFifoAudioSource : public ZoneMinderFifoSource {
virtual ~ZoneMinderFifoAudioSource() {}
public:
void setFrequency(int p_frequency) { frequency = p_frequency; };
void setFrequency(int p_frequency) {
frequency = p_frequency;
samplingFrequencyIndex = getFrequencyIndex();
};
int getFrequency() { return frequency; };
int getFrequencyIndex();
const char *configStr() const { return config.c_str(); };
void setChannels(int p_channels) { channels = p_channels; };
int getChannels() const { return channels; };
@ -48,7 +52,7 @@ class ZoneMinderFifoAudioSource : public ZoneMinderFifoSource {
protected:
std::string config;
int samplingFrequencyIndex;
int frequency;
unsigned int frequency;
int channels;
};
#endif // HAVE_RTSP_SERVER