mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
Merge branch 'master' into multichannel
Resolved Conflicts: daemon/src/sfl_types.h
This commit is contained in:
@ -420,7 +420,7 @@ void AudioRecord::closeWavFile()
|
||||
WARN("Can't close file");
|
||||
}
|
||||
|
||||
//void AudioRecord::recData(SFLDataFormat* buffer, size_t nSamples)
|
||||
//void AudioRecord::recData(SFLAudioSample* buffer, size_t nSamples)
|
||||
void AudioRecord::recData(AudioBuffer& buffer)
|
||||
{
|
||||
if (recordingEnabled_) {
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "cc_config.h"
|
||||
#include "sfl_types.h"
|
||||
#include <ccrtp/formats.h> // for ost::DynamicPayloadFormat
|
||||
|
||||
#define XSTR(s) STR(s)
|
||||
@ -70,14 +71,14 @@ class AudioCodec {
|
||||
* @param buffer_size : the size of the input buffer
|
||||
* @return the number of samples decoded
|
||||
*/
|
||||
virtual int decode(short *dst, unsigned char *buf, size_t buffer_size) = 0;
|
||||
virtual int decode(SFLAudioSample *dst, unsigned char *buf, size_t buffer_size) = 0;
|
||||
|
||||
/**
|
||||
* Encode an input buffer and fill the output buffer with the encoded data
|
||||
* @param buffer_size : the maximum size of encoded data buffer (dst)
|
||||
* @return the number of bytes encoded
|
||||
*/
|
||||
virtual int encode(unsigned char *dst, short *src, size_t buffer_size) = 0;
|
||||
virtual int encode(unsigned char *dst, SFLAudioSample *src, size_t buffer_size) = 0;
|
||||
|
||||
/**
|
||||
* Multichannel version of decode().
|
||||
|
@ -28,12 +28,13 @@
|
||||
* as that of the covered work.
|
||||
*/
|
||||
#include "g729.h"
|
||||
#include "sfl_types.h"
|
||||
#include <iostream>
|
||||
#include <dlfcn.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#define G729_TYPE_ENCODER (void (*)(bcg729EncoderChannelContextStruct*, int16_t[], uint8_t[]))
|
||||
#define G729_TYPE_DECODER (void (*)(bcg729DecoderChannelContextStruct*, uint8_t[], uint8_t, int16_t[]))
|
||||
#define G729_TYPE_ENCODER (void (*)(bcg729EncoderChannelContextStruct*, SFLAudioSample[], uint8_t[]))
|
||||
#define G729_TYPE_DECODER (void (*)(bcg729DecoderChannelContextStruct*, uint8_t[], uint8_t, SFLAudioSample[]))
|
||||
|
||||
#define G729_TYPE_DECODER_INIT (bcg729DecoderChannelContextStruct*(*)())
|
||||
#define G729_TYPE_ENCODER_INIT (bcg729EncoderChannelContextStruct*(*)())
|
||||
@ -72,14 +73,14 @@ G729::~G729()
|
||||
dlclose(handler_);
|
||||
}
|
||||
|
||||
int G729::decode(short *dst, unsigned char *buf, size_t buffer_size)
|
||||
int G729::decode(SFLAudioSample *dst, unsigned char *buf, size_t buffer_size)
|
||||
{
|
||||
decoder_(decoderContext_, buf, false, dst);
|
||||
decoder_(decoderContext_, buf + (buffer_size / 2), false, dst + 80);
|
||||
return 160;
|
||||
}
|
||||
|
||||
int G729::encode(unsigned char *dst, short *src, size_t buffer_size)
|
||||
int G729::encode(unsigned char *dst, SFLAudioSample *src, size_t buffer_size)
|
||||
{
|
||||
encoder_(encoderContext_, src, dst);
|
||||
encoder_(encoderContext_, src + (buffer_size / 2), dst + 10);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define G729_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include "sfl_types.h"
|
||||
#include "noncopyable.h"
|
||||
|
||||
#include "audiocodec.h"
|
||||
@ -43,8 +44,8 @@ public:
|
||||
G729();
|
||||
~G729();
|
||||
private:
|
||||
virtual int decode(short *dst, unsigned char *buf, size_t buffer_size);
|
||||
virtual int encode(unsigned char *dst, short *src, size_t buffer_size);
|
||||
virtual int decode(SFLAudioSample *dst, unsigned char *buf, size_t buffer_size);
|
||||
virtual int encode(unsigned char *dst, SFLAudioSample *src, size_t buffer_size);
|
||||
|
||||
NON_COPYABLE(G729);
|
||||
//Attributes
|
||||
@ -53,8 +54,8 @@ private:
|
||||
void* handler_;
|
||||
|
||||
//Extern functions
|
||||
void (*encoder_) (bcg729EncoderChannelContextStruct *encoderChannelContext, int16_t inputFrame[], uint8_t bitStream[]);
|
||||
void (*decoder_) (bcg729DecoderChannelContextStruct *decoderChannelContext, uint8_t bitStream[], uint8_t frameErasureFlag, int16_t signal[]);
|
||||
void (*encoder_) (bcg729EncoderChannelContextStruct *encoderChannelContext, SFLAudioSample inputFrame[], uint8_t bitStream[]);
|
||||
void (*decoder_) (bcg729DecoderChannelContextStruct *decoderChannelContext, uint8_t bitStream[], uint8_t frameErasureFlag, SFLAudioSample signal[]);
|
||||
|
||||
static void loadError(const char *error);
|
||||
};
|
||||
|
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "audiocodec.h"
|
||||
#include "sfl_types.h"
|
||||
#include <tr1/array>
|
||||
#include <algorithm>
|
||||
|
||||
@ -50,13 +51,13 @@ class Ilbc: public sfl::AudioCodec {
|
||||
|
||||
private:
|
||||
// iLBC expects floating point data, so we have to convert
|
||||
int decode(short *dst, unsigned char *src, size_t /*buf_size*/) {
|
||||
int decode(SFLAudioSample *dst, unsigned char *src, size_t /*buf_size*/) {
|
||||
const int NORMAL_MODE = 1;
|
||||
iLBC_decode(dst, reinterpret_cast<WebRtc_UWord16*>(src), &ilbc_dec_, NORMAL_MODE);
|
||||
return frameSize_;
|
||||
}
|
||||
|
||||
int encode(unsigned char *dst, short* src, size_t /*buf_size*/) {
|
||||
int encode(unsigned char *dst, SFLAudioSample * src, size_t /*buf_size*/) {
|
||||
iLBC_encode(reinterpret_cast<WebRtc_UWord16*>(dst), src, &ilbc_enc_);
|
||||
return frameSize_;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
* as that of the covered work.
|
||||
*/
|
||||
#include "opus.h"
|
||||
#include "sfl_types.h"
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
@ -60,12 +61,12 @@ Opus::~Opus()
|
||||
opus_decoder_destroy(decoder_);
|
||||
}
|
||||
|
||||
int Opus::decode(short *dst, unsigned char *buf, size_t buffer_size)
|
||||
int Opus::decode(SFLAudioSample *dst, unsigned char *buf, size_t buffer_size)
|
||||
{
|
||||
return opus_decode(decoder_, buf, buffer_size, dst, FRAME_SIZE, 0);
|
||||
}
|
||||
|
||||
int Opus::encode(unsigned char *dst, short *src, size_t buffer_size)
|
||||
int Opus::encode(unsigned char *dst, SFLAudioSample *src, size_t buffer_size)
|
||||
{
|
||||
return opus_encode(encoder_, src, FRAME_SIZE, dst, buffer_size * 2);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define OPUS_H_
|
||||
|
||||
#include "noncopyable.h"
|
||||
#include "sfl_types.h"
|
||||
|
||||
#include "audiocodec.h"
|
||||
|
||||
@ -45,8 +46,8 @@ public:
|
||||
static const uint8 PAYLOAD_TYPE = 104; // dynamic payload type, out of range of video (96-99)
|
||||
|
||||
private:
|
||||
virtual int decode(short *dst, unsigned char *buf, size_t buffer_size);
|
||||
virtual int encode(unsigned char *dst, short *src, size_t buffer_size);
|
||||
virtual int decode(SFLAudioSample *dst, unsigned char *buf, size_t buffer_size);
|
||||
virtual int encode(unsigned char *dst, SFLAudioSample *src, size_t buffer_size);
|
||||
|
||||
//multichannel version
|
||||
virtual int decode(std::vector<std::vector<short> > *dst, unsigned char *buf, size_t buffer_size, size_t dst_offset=0);
|
||||
|
@ -29,7 +29,7 @@
|
||||
* as that of the covered work.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "sfl_types.h"
|
||||
#include "audiocodec.h"
|
||||
#include "noncopyable.h"
|
||||
#include "array_size.h"
|
||||
@ -83,13 +83,13 @@ private:
|
||||
|
||||
NON_COPYABLE(Speex);
|
||||
|
||||
virtual int decode(short *dst, unsigned char *src, size_t buf_size) {
|
||||
virtual int decode(SFLAudioSample *dst, unsigned char *src, size_t buf_size) {
|
||||
speex_bits_read_from(&speex_dec_bits_, (char*) src, buf_size);
|
||||
speex_decode_int(speex_dec_state_, &speex_dec_bits_, dst);
|
||||
return frameSize_;
|
||||
}
|
||||
|
||||
virtual int encode(unsigned char *dst, short *src, size_t buf_size) {
|
||||
virtual int encode(unsigned char *dst, SFLAudioSample *src, size_t buf_size) {
|
||||
speex_bits_reset(&speex_enc_bits_);
|
||||
speex_encode_int(speex_enc_state_, src, &speex_enc_bits_);
|
||||
return speex_bits_write(&speex_enc_bits_, (char*) dst, buf_size);
|
||||
|
@ -39,7 +39,7 @@ void DcBlocker::reset()
|
||||
states.assign(states.size(), (struct StreamState){0, 0, 0, 0});
|
||||
}
|
||||
|
||||
void DcBlocker::doProcess(SFLAudioSample *out, SFLAudioSample *in, int samples, struct StreamState * state)
|
||||
void DcBlocker::doProcess(SFLAudioSample *out, SFLAudioSample *in, unsigned samples, struct StreamState * state)
|
||||
{
|
||||
for (unsigned i = 0; i < samples; ++i) {
|
||||
state->x_ = in[i];
|
||||
|
@ -52,7 +52,7 @@ class DcBlocker {
|
||||
SFLAudioSample y_, x_, xm1_, ym1_;
|
||||
};
|
||||
|
||||
void doProcess(SFLAudioSample *out, SFLAudioSample *in, int samples, struct StreamState * state);
|
||||
void doProcess(SFLAudioSample *out, SFLAudioSample *in, unsigned samples, struct StreamState * state);
|
||||
|
||||
std::vector<StreamState> states;
|
||||
};
|
||||
|
@ -69,7 +69,7 @@ void GainControl::process(SFLAudioSample *buf, int samples)
|
||||
|
||||
for (int i = 0; i < samples; i++) {
|
||||
// linear conversion
|
||||
in = (double)buf[i] / (double)SHRT_MAX;
|
||||
in = (double) buf[i] / (double) SFL_DATA_FORMAT_MAX;
|
||||
|
||||
out = currentGain_ * in;
|
||||
|
||||
@ -81,7 +81,7 @@ void GainControl::process(SFLAudioSample *buf, int samples)
|
||||
|
||||
out = limiter_.limit(out);
|
||||
|
||||
buf[i] = (short)(out * (double)SHRT_MAX);
|
||||
buf[i] = (SFLAudioSample) (out * (double) SFL_DATA_FORMAT_MAX);
|
||||
}
|
||||
|
||||
diffRms = maxRms - targetLevelLinear_;
|
||||
|
@ -275,14 +275,14 @@ size_t MainBuffer::getData(AudioBuffer& buffer, const std::string &call_id)
|
||||
|
||||
for (CallIDSet::iterator iter_id = callid_set->begin();
|
||||
iter_id != callid_set->end(); ++iter_id) {
|
||||
/*size_t nbSmplToCopy = toCopy / sizeof(SFLDataFormat);
|
||||
SFLDataFormat mixBuffer[nbSmplToCopy];
|
||||
/*size_t nbSmplToCopy = toCopy / sizeof(SFLAudioSample);
|
||||
SFLAudioSample mixBuffer[nbSmplToCopy];
|
||||
memset(mixBuffer, 0, toCopy);
|
||||
size = getDataByID(mixBuffer, toCopy, *iter_id, call_id);*/
|
||||
size = getDataByID(mixBuffer, *iter_id, call_id);
|
||||
|
||||
if (size > 0) {
|
||||
/*SFLDataFormat *dest = static_cast<SFLDataFormat*>(buffer);
|
||||
/*SFLAudioSample *dest = static_cast<SFLAudioSample*>(buffer);
|
||||
for (size_t k = 0; k < nbSmplToCopy; ++k)
|
||||
dest[k] += mixBuffer[k];*/
|
||||
buffer.mix(mixBuffer);
|
||||
|
@ -29,6 +29,7 @@
|
||||
*/
|
||||
|
||||
#include "samplerateconverter.h"
|
||||
#include "sfl_types.h"
|
||||
#include "manager.h"
|
||||
#include <cassert>
|
||||
#include "logger.h"
|
||||
@ -54,7 +55,7 @@ SamplerateConverter::~SamplerateConverter()
|
||||
}
|
||||
|
||||
void
|
||||
SamplerateConverter::Short2FloatArray(const short *in, float *out, int len)
|
||||
SamplerateConverter::Short2FloatArray(const SFLAudioSample *in, float *out, int len)
|
||||
{
|
||||
// factor is 1/(2^15), used to rescale the short int range to the
|
||||
// [-1.0 - 1.0] float range.
|
||||
@ -64,8 +65,8 @@ SamplerateConverter::Short2FloatArray(const short *in, float *out, int len)
|
||||
}
|
||||
|
||||
void SamplerateConverter::resample(const AudioBuffer &dataIn, AudioBuffer &dataOut)
|
||||
/*void SamplerateConverter::resample(SFLDataFormat *dataIn,
|
||||
SFLDataFormat *dataOut,
|
||||
/*void SamplerateConverter::resample(SFLAudioSample *dataIn,
|
||||
SFLAudioSample *dataOut,
|
||||
size_t dataOutSize,
|
||||
int inputFreq,
|
||||
int outputFreq,
|
||||
|
@ -60,7 +60,7 @@ class SamplerateConverter {
|
||||
* @param SamplerateConverter2 The desired sample rate
|
||||
* @param nbSamples The number of samples to process
|
||||
*/
|
||||
//void resample(SFLDataFormat* dataIn, SFLDataFormat* dataOut, size_t dataOutSize, int oldrate, int newrate, size_t nbSamples);
|
||||
//void resample(SFLAudioSample* dataIn, SFLAudioSample* dataOut, size_t dataOutSize, int oldrate, int newrate, size_t nbSamples);
|
||||
void resample(const AudioBuffer& dataIn, AudioBuffer& dataOut);
|
||||
|
||||
/**
|
||||
@ -69,7 +69,7 @@ class SamplerateConverter {
|
||||
* @param out The resulting (float) array
|
||||
* @param len The number of elements in both tables
|
||||
*/
|
||||
void Short2FloatArray(const short *in, float *out, int len);
|
||||
void Short2FloatArray(const SFLAudioSample *in, float *out, int len);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -101,7 +101,7 @@ class DTMFGenerator {
|
||||
|
||||
/*
|
||||
* Get n samples of the signal of code code
|
||||
* @param buffer a SFLDataFormat vector
|
||||
* @param buffer a SFLAudioSample vector
|
||||
* @param code dtmf code to get sound
|
||||
*/
|
||||
void getSamples(std::vector<SFLAudioSample> &buffer, unsigned char code);
|
||||
@ -109,7 +109,7 @@ class DTMFGenerator {
|
||||
/*
|
||||
* Get next n samples (continues where previous call to
|
||||
* genSample or genNextSamples stopped
|
||||
* @param buffer a SFLDataFormat vector
|
||||
* @param buffer a SFLAudioSample vector
|
||||
*/
|
||||
void getNextSamples(std::vector<SFLAudioSample> &buffer);
|
||||
|
||||
@ -118,7 +118,7 @@ class DTMFGenerator {
|
||||
/**
|
||||
* Fill tone buffer for a given index of the array of tones.
|
||||
* @param index of the tone in the array tones_
|
||||
* @return SFLDataFormat* The generated data
|
||||
* @return SFLAudioSample* The generated data
|
||||
*/
|
||||
SFLAudioSample* fillToneBuffer(int index);
|
||||
};
|
||||
|
@ -32,12 +32,13 @@
|
||||
#define SFL_TYPES_H_
|
||||
|
||||
#include <cstddef> // for size_t
|
||||
#include <stdint.h>
|
||||
|
||||
typedef short SFLAudioSample;
|
||||
//typedef size_t AudioChannel;
|
||||
typedef int16_t SFLAudioSample;
|
||||
|
||||
typedef signed short SINT16;
|
||||
typedef signed int SINT32;
|
||||
typedef int16_t SINT16;
|
||||
typedef int32_t SINT32;
|
||||
#define SFL_DATA_FORMAT_MAX SHRT_MAX
|
||||
|
||||
/*
|
||||
typedef struct {
|
||||
|
Reference in New Issue
Block a user