adding opus chanel in mumblib configuration
This commit is contained in:
parent
7d64b05e3c
commit
429e1a54f7
@ -12,6 +12,7 @@ namespace mumlib {
|
||||
|
||||
constexpr int DEFAULT_OPUS_ENCODER_BITRATE = 16000;
|
||||
constexpr int DEFAULT_OPUS_SAMPLE_RATE = 48000;
|
||||
constexpr int DEFAULT_OPUS_NUM_CHANNELS = 1;
|
||||
|
||||
using namespace std;
|
||||
using namespace boost::asio;
|
||||
@ -24,6 +25,7 @@ namespace mumlib {
|
||||
struct MumlibConfiguration {
|
||||
int opusEncoderBitrate = DEFAULT_OPUS_ENCODER_BITRATE;
|
||||
int opusSampleRate = DEFAULT_OPUS_SAMPLE_RATE;
|
||||
int opusChannels = DEFAULT_OPUS_NUM_CHANNELS;
|
||||
// additional fields will be added in the future
|
||||
};
|
||||
|
||||
|
@ -25,8 +25,10 @@ namespace mumlib {
|
||||
};
|
||||
|
||||
class Audio : boost::noncopyable {
|
||||
public:
|
||||
Audio(int opusSampleRate, int opusEncoderBitrate);
|
||||
public:
|
||||
explicit Audio(int opusSampleRate=DEFAULT_OPUS_SAMPLE_RATE,
|
||||
int opusEncoderBitrate=DEFAULT_OPUS_ENCODER_BITRATE,
|
||||
int channels=DEFAULT_OPUS_NUM_CHANNELS);
|
||||
|
||||
virtual ~Audio();
|
||||
|
||||
|
@ -29,6 +29,6 @@ namespace mumlib {
|
||||
private:
|
||||
const int64_t value;
|
||||
|
||||
long parseVariant(const uint8_t *buffer);
|
||||
int64_t parseVariant(const uint8_t *buffer);
|
||||
};
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
|
||||
static boost::posix_time::seconds RESET_SEQUENCE_NUMBER_INTERVAL(5);
|
||||
|
||||
mumlib::Audio::Audio(int opusSampleRate, int opusEncoderBitrate)
|
||||
mumlib::Audio::Audio(int opusSampleRate, int opusEncoderBitrate, int channels)
|
||||
: logger(log4cpp::Category::getInstance("mumlib.Audio")),
|
||||
opusDecoder(nullptr),
|
||||
opusEncoder(nullptr),
|
||||
@ -13,12 +13,12 @@ mumlib::Audio::Audio(int opusSampleRate, int opusEncoderBitrate)
|
||||
int error;
|
||||
this->sampleRate = opusSampleRate;
|
||||
|
||||
opusDecoder = opus_decoder_create(opusSampleRate, 1, &error);
|
||||
opusDecoder = opus_decoder_create(opusSampleRate, channels, &error);
|
||||
if (error != OPUS_OK) {
|
||||
throw AudioException((boost::format("failed to initialize OPUS decoder: %s") % opus_strerror(error)).str());
|
||||
}
|
||||
|
||||
opusEncoder = opus_encoder_create(opusSampleRate, 1, OPUS_APPLICATION_VOIP, &error);
|
||||
opusEncoder = opus_encoder_create(opusSampleRate, channels, OPUS_APPLICATION_VOIP, &error);
|
||||
if (error != OPUS_OK) {
|
||||
throw AudioException((boost::format("failed to initialize OPUS encoder: %s") % opus_strerror(error)).str());
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ void mumlib::Transport::connect(
|
||||
|
||||
void mumlib::Transport::disconnect() {
|
||||
|
||||
pingTimer.cancel();
|
||||
if (state != ConnectionState::NOT_CONNECTED) {
|
||||
boost::system::error_code errorCode;
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace mumlib {
|
||||
externalIoService(true),
|
||||
transport(ioService, boost::bind(&_Mumlib_Private::processIncomingTcpMessage, this, _1, _2, _3),
|
||||
boost::bind(&_Mumlib_Private::processAudioPacket, this, _1, _2, _3)),
|
||||
audio(configuration.opusSampleRate, configuration.opusEncoderBitrate) {
|
||||
audio(configuration.opusSampleRate, configuration.opusEncoderBitrate, configuration.opusChannels) {
|
||||
|
||||
audio.setOpusEncoderBitrate(configuration.opusEncoderBitrate);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user