From f0d46f4fc058292d03a4003304378eb47262465e Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 16 Feb 2013 10:54:40 +0000 Subject: [PATCH] started OPUS integration by just creating the OPUS objects and do nothing with them right now --- src/client.cpp | 32 ++++++++++++++++++++++++++++++++ src/client.h | 5 +++++ src/server.cpp | 31 +++++++++++++++++++++++++++++++ src/server.h | 5 +++++ 4 files changed, 73 insertions(+) diff --git a/src/client.cpp b/src/client.cpp index 26053de3..0ac74f69 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -51,6 +51,8 @@ CClient::CClient ( const quint16 iPortNumber ) : bUseDefaultCentralServerAddress ( true ), iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ) { + int iOpusError; + // init audio encoder/decoder (mono) CeltModeMono = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 1, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); @@ -64,6 +66,21 @@ CClient::CClient ( const quint16 iPortNumber ) : cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif + OpusEncoderMono = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 1, + OPUS_APPLICATION_RESTRICTED_LOWDELAY, + &iOpusError ); + + OpusDecoderMono = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 1, + &iOpusError ); + +#ifdef USE_LOW_COMPLEXITY_CELT_ENC + // set encoder low complexity + opus_encoder_ctl ( OpusEncoderMono, + OPUS_SET_COMPLEXITY ( 1 ) ); +#endif + // init audio encoder/decoder (stereo) CeltModeStereo = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); @@ -77,6 +94,21 @@ CClient::CClient ( const quint16 iPortNumber ) : cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif + OpusEncoderStereo = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 2, + OPUS_APPLICATION_RESTRICTED_LOWDELAY, + &iOpusError ); + + OpusDecoderStereo = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 2, + &iOpusError ); + +#ifdef USE_LOW_COMPLEXITY_CELT_ENC + // set encoder low complexity + opus_encoder_ctl ( OpusEncoderStereo, + OPUS_SET_COMPLEXITY ( 1 ) ); +#endif + // Connections ------------------------------------------------------------- // connection for protocol diff --git a/src/client.h b/src/client.h index ca7d0754..18c4ed08 100755 --- a/src/client.h +++ b/src/client.h @@ -31,6 +31,7 @@ #include #include #include "cc6_celt.h" +#include "opus.h" #include "global.h" #include "socket.h" #include "channel.h" @@ -271,6 +272,10 @@ protected: cc6_CELTMode* CeltModeStereo; cc6_CELTEncoder* CeltEncoderStereo; cc6_CELTDecoder* CeltDecoderStereo; + OpusEncoder* OpusEncoderMono; + OpusDecoder* OpusDecoderMono; + OpusEncoder* OpusEncoderStereo; + OpusDecoder* OpusDecoderStereo; int iCeltNumCodedBytes; bool bCeltDoHighQuality; bool bUseStereo; diff --git a/src/server.cpp b/src/server.cpp index 44979a31..96101b2e 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -186,6 +186,7 @@ CServer::CServer ( const int iNewNumChan, bAutoRunMinimized ( false ), strWelcomeMessage ( strNewWelcomeMessage ) { + int iOpusError; int i; // create CELT encoder/decoder for each channel (must be done before @@ -206,6 +207,21 @@ CServer::CServer ( const int iNewNumChan, cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif + OpusEncoderMono[i] = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 1, + OPUS_APPLICATION_RESTRICTED_LOWDELAY, + &iOpusError ); + + OpusDecoderMono[i] = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 1, + &iOpusError ); + +#ifdef USE_LOW_COMPLEXITY_CELT_ENC + // set encoder low complexity + opus_encoder_ctl ( OpusEncoderMono[i], + OPUS_SET_COMPLEXITY ( 1 ) ); +#endif + // init audio endocder/decoder (stereo) CeltModeStereo[i] = cc6_celt_mode_create ( SYSTEM_SAMPLE_RATE_HZ, 2, SYSTEM_FRAME_SIZE_SAMPLES, NULL ); @@ -218,6 +234,21 @@ CServer::CServer ( const int iNewNumChan, cc6_celt_encoder_ctl ( CeltEncoderStereo[i], cc6_CELT_SET_COMPLEXITY_REQUEST, cc6_celt_int32_t ( 1 ) ); #endif + + OpusEncoderStereo[i] = opus_encoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 2, + OPUS_APPLICATION_RESTRICTED_LOWDELAY, + &iOpusError ); + + OpusDecoderStereo[i] = opus_decoder_create ( SYSTEM_SAMPLE_RATE_HZ, + 2, + &iOpusError ); + +#ifdef USE_LOW_COMPLEXITY_CELT_ENC + // set encoder low complexity + opus_encoder_ctl ( OpusEncoderStereo[i], + OPUS_SET_COMPLEXITY ( 1 ) ); +#endif } // define colors for chat window identifiers diff --git a/src/server.h b/src/server.h index b4e313ac..52cd8453 100755 --- a/src/server.h +++ b/src/server.h @@ -30,6 +30,7 @@ #include #include #include "cc6_celt.h" +#include "opus.h" #include "global.h" #include "socket.h" #include "channel.h" @@ -213,6 +214,10 @@ protected: cc6_CELTMode* CeltModeStereo[MAX_NUM_CHANNELS]; cc6_CELTEncoder* CeltEncoderStereo[MAX_NUM_CHANNELS]; cc6_CELTDecoder* CeltDecoderStereo[MAX_NUM_CHANNELS]; + OpusEncoder* OpusEncoderMono[MAX_NUM_CHANNELS]; + OpusDecoder* OpusDecoderMono[MAX_NUM_CHANNELS]; + OpusEncoder* OpusEncoderStereo[MAX_NUM_CHANNELS]; + OpusDecoder* OpusDecoderStereo[MAX_NUM_CHANNELS]; CVector vstrChatColors;