From 8cb96bb66d3de04a3dae3e2c886c4a49736f1b65 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 21 Sep 2014 20:41:25 +0200 Subject: Centralise all media configuration values in mediaconfig.h --- src/opusencoder.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/opusencoder.cc') diff --git a/src/opusencoder.cc b/src/opusencoder.cc index 27bdb90..a3fee36 100644 --- a/src/opusencoder.cc +++ b/src/opusencoder.cc @@ -29,17 +29,13 @@ #include #include -// 500 to 512000 -#define OPUS_BITRATE 64000 - -// Frame size 10ms -#define OPUS_FRAME_SIZE 10 +#include "mediaconfig.h" OpusEncoder::OpusEncoder() : cache(5760 * 10) { int err = 0; - encoder = opus_encoder_create(16000, 1, OPUS_APPLICATION_AUDIO, &err); + encoder = opus_encoder_create(SAMPLERATE, 1, OPUS_APPLICATION_AUDIO, &err); if(!encoder || err != OPUS_OK) { printf("opus_encoder_create: %d\n", err); } @@ -57,7 +53,7 @@ OpusEncoder::~OpusEncoder() unsigned int OpusEncoder::framesize() { - return 16000 / 1000 * OPUS_FRAME_SIZE; // 10ms audio data + return SAMPLERATE / 1000 * OPUS_FRAME_SIZE; // 10ms audio data } framelist_t OpusEncoder::encode(const char *pcm, size_t size) @@ -69,7 +65,7 @@ framelist_t OpusEncoder::encode(const char *pcm, size_t size) printf("encoder == NULL\n"); } - size_t bytes_per_packet = ((OPUS_BITRATE *framesize())/16000+4)/8; + size_t bytes_per_packet = ((OPUS_BITRATE *framesize())/SAMPLERATE+4)/8; cache.addSamples((short*)pcm, size / sizeof(short)); -- cgit v1.2.3