- fix various build problems

This commit is contained in:
Dmytro Bogovych 2025-11-20 08:51:58 +03:00
parent 3f9dbda40a
commit 3e87b9e7ec
5 changed files with 37 additions and 32 deletions

View File

@ -26,6 +26,8 @@ set (OPENSSL_INCLUDE ${LIB_PLATFORM}/openssl/1.1/include)
message ("Using OpenSSL include files from ${OPENSSL_INCLUDE}") message ("Using OpenSSL include files from ${OPENSSL_INCLUDE}")
message ("Using OpenSSL libs: ${OPENSSL_SSL} and ${OPENSSL_CRYPTO}") message ("Using OpenSSL libs: ${OPENSSL_SSL} and ${OPENSSL_CRYPTO}")
include_directories(${OPENSSL_INCLUDE}) include_directories(${OPENSSL_INCLUDE})
message ("Using Opus include files: ${OPUS_INCLUDE}")
message ("Using Opus lib: ${OPUS_LIB}")
# Used defines for our project # Used defines for our project
set (DEFINES -DUSE_OPENSSL) set (DEFINES -DUSE_OPENSSL)
@ -309,7 +311,7 @@ set (RTPHONE_SOURCES
) )
if (USE_OPUS_CODEC) if (USE_OPUS_CODEC)
set (DEFINES ${DEFINES} -DUSE_OPUS_CODEC) set (DEFINES ${DEFINES} -DUSE_OPUS_CODEC)
endif() endif()
add_library (rtphone STATIC ${RTPHONE_SOURCES}) add_library (rtphone STATIC ${RTPHONE_SOURCES})
@ -363,6 +365,7 @@ target_include_directories(rtphone
${CMAKE_CURRENT_SOURCE_DIR}/libs ${CMAKE_CURRENT_SOURCE_DIR}/libs
${LIB_PLATFORM}/opus/include ${LIB_PLATFORM}/opus/include
${E}/helper ${E}/helper
${E}/audio
${E}/media ${E}/media
${L} ${L}
${L}/ice ${L}/ice

View File

@ -8,7 +8,7 @@
# include <Windows.h> # include <Windows.h>
#endif #endif
#if defined(TARGET_LINUX) #if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
# include <arpa/inet.h> # include <arpa/inet.h>
#endif #endif

View File

@ -309,14 +309,14 @@ void OpusCodec::Params::parse(const resip::Data &params)
if (paramIter->mName == "usedtx") if (paramIter->mName == "usedtx")
mUseDtx = paramIter->mValue == "1"; mUseDtx = paramIter->mValue == "1";
else else
if (paramIter->mName == "useinbandfec") if (paramIter->mName == "useinbandfec")
mUseInbandFec = paramIter->mValue == "1"; mUseInbandFec = paramIter->mValue == "1";
else else
if (paramIter->mName == "stereo") if (paramIter->mName == "stereo")
mStereo = paramIter->mValue == "1"; mStereo = paramIter->mValue == "1";
else else
if (paramIter->mName == "ptime") if (paramIter->mName == "ptime")
mPtime = strx::toInt(paramIter->mValue.c_str(), 20); mPtime = strx::toInt(paramIter->mValue.c_str(), 20);
} }
} }
@ -406,8 +406,6 @@ OpusCodec::OpusCodec(int samplerate, int channels, int ptime)
mEncoderCtx = opus_encoder_create(mSamplerate, mChannels, OPUS_APPLICATION_VOIP, &status); mEncoderCtx = opus_encoder_create(mSamplerate, mChannels, OPUS_APPLICATION_VOIP, &status);
if (OPUS_OK != opus_encoder_ctl(mEncoderCtx, OPUS_SET_COMPLEXITY(OPUS_CODEC_COMPLEXITY))) if (OPUS_OK != opus_encoder_ctl(mEncoderCtx, OPUS_SET_COMPLEXITY(OPUS_CODEC_COMPLEXITY)))
ICELogError(<< "Failed to set Opus encoder complexity"); ICELogError(<< "Failed to set Opus encoder complexity");
//if (OPUS_OK != opus_encoder_ctl(mEncoderCtx, OPUS_SET_FORCE_CHANNELS(AUDIO_CHANNELS)))
// ICELogCritical(<<"Failed to set channel number in Opus encoder");
// Decoder creation is postponed until first packet arriving (because it may use different channel number // Decoder creation is postponed until first packet arriving (because it may use different channel number
} }
@ -521,8 +519,12 @@ int OpusCodec::decode(const void* input, int inputBytes, void* output, int outpu
int decoded = opus_decode(mDecoderCtx, int decoded = opus_decode(mDecoderCtx,
reinterpret_cast<const unsigned char *>(input), inputBytes, reinterpret_cast<const unsigned char *>(input), inputBytes,
buffer_decode, nr_of_frames, 0); buffer_decode, nr_of_frames, 0);
if (decoded < 0)
{
ICELogCritical(<< "opus_decode() returned " << decoded);
return 0;
}
size_t resampler_processed = 0;
opus_int16 *buffer_stereo = nullptr; opus_int16 *buffer_stereo = nullptr;
int buffer_stereo_capacity = buffer_capacity * 2; int buffer_stereo_capacity = buffer_capacity * 2;
@ -1150,8 +1152,8 @@ int GsmCodec::plc(int lostFrames, void* output, int outputCapacity)
G722Codec::G722Codec() G722Codec::G722Codec()
{ {
mEncoder = g722_encode_init(NULL, 64000, 0); mEncoder = g722_encode_init(nullptr, 64000, 0);
mDecoder = g722_decode_init(NULL, 64000, 0); mDecoder = g722_decode_init(nullptr, 64000, 0);
} }

View File

@ -151,7 +151,7 @@ CodecList::Settings::EvsSpec CodecList::Settings::EvsSpec::parse(const std::stri
{ {
EvsSpec result; EvsSpec result;
auto parts = strx::split(spec, "-/"); auto parts = strx::split(spec, "-/ ,:");
if (parts.size() == 3) if (parts.size() == 3)
{ {
// Payload type number // Payload type number
@ -162,10 +162,10 @@ CodecList::Settings::EvsSpec CodecList::Settings::EvsSpec::parse(const std::stri
if (encoding_type == "mime") if (encoding_type == "mime")
result.mEncodingType = Encoding_MIME; result.mEncodingType = Encoding_MIME;
else else
if (encoding_type == "g192") if (encoding_type == "g192")
result.mEncodingType = Encoding_G192; result.mEncodingType = Encoding_G192;
else else
throw std::logic_error("Bad EVS codec encoding type"); throw std::logic_error("Bad EVS codec encoding type");
// Bandwidth // Bandwidth
std::string& bandwidth = parts.back(); std::string& bandwidth = parts.back();
@ -196,7 +196,7 @@ CodecList::Settings::OpusSpec CodecList::Settings::OpusSpec::parse(const std::st
{ {
OpusSpec result; OpusSpec result;
auto parts = strx::split(spec, "-/"); auto parts = strx::split(spec, "-/ ,:");
if (parts.size() == 3) if (parts.size() == 3)
{ {
result.mPayloadType = strx::toInt(strx::trim(parts.front()).c_str(), -1); result.mPayloadType = strx::toInt(strx::trim(parts.front()).c_str(), -1);
@ -215,7 +215,7 @@ static int findOctetMode(const char* line)
p += strlen(param_name); p += strlen(param_name);
char int_buf[8] = {0}; char int_buf[8] = {0};
int int_buf_offset = 0; size_t int_buf_offset = 0;
while (*p && isdigit(*p) && int_buf_offset < sizeof(int_buf)) while (*p && isdigit(*p) && int_buf_offset < sizeof(int_buf))
int_buf[int_buf_offset++] = *p++; int_buf[int_buf_offset++] = *p++;
return atoi(int_buf); return atoi(int_buf);
@ -337,8 +337,7 @@ void CodecList::init(const Settings& settings)
#if !defined(TARGET_ANDROID) && !defined(TARGET_OPENWRT) && !defined(TARGET_RPI) #if !defined(TARGET_ANDROID) && !defined(TARGET_OPENWRT) && !defined(TARGET_RPI)
#if defined(USE_AMR_CODEC) #if defined(USE_AMR_CODEC)
for (int pt: mSettings.mAmrWbPayloadType) for (int pt: mSettings.mAmrWbPayloadType)
mFactoryList.push_back(std::make_shared<AmrWbCodec::CodecFactory>( mFactoryList.push_back(std::make_shared<AmrWbCodec::CodecFactory>(AmrCodecConfig{mSettings.mWrapIuUP, false, pt}));
AmrCodecConfig{mSettings.mWrapIuUP, false, pt}));
for (int pt: mSettings.mAmrWbOctetPayloadType) for (int pt: mSettings.mAmrWbOctetPayloadType)
mFactoryList.push_back(std::make_shared<AmrWbCodec::CodecFactory>(AmrCodecConfig{mSettings.mWrapIuUP, true, pt})); mFactoryList.push_back(std::make_shared<AmrWbCodec::CodecFactory>(AmrCodecConfig{mSettings.mWrapIuUP, true, pt}));

View File

@ -95,11 +95,11 @@ public:
std::vector<OpusSpec> mOpusSpec; std::vector<OpusSpec> mOpusSpec;
// Payload type // Payload type
bool contains(int ptype) const; bool contains(int ptype) const;
// Textual representation - used in logging // Textual representation - used in logging
std::string toString() const; std::string toString() const;
void clear(); void clear();
static Settings DefaultSettings; static Settings DefaultSettings;
@ -110,16 +110,17 @@ public:
CodecList(const Settings& settings); CodecList(const Settings& settings);
~CodecList(); ~CodecList();
void setSettings(const Settings& settings) { void setSettings(const Settings& settings)
{
init(settings); init(settings);
} }
int count() const; int count() const;
Codec::Factory& codecAt(int index) const; Codec::Factory& codecAt(int index) const;
int findCodec(const std::string& name) const; int findCodec(const std::string& name) const;
void fillCodecMap(CodecMap& cm); void fillCodecMap(CodecMap& cm);
PCodec createCodecByPayloadType(int payloadType); PCodec createCodecByPayloadType(int payloadType);
void clear(); void clear();
protected: protected:
typedef std::vector<std::shared_ptr<Codec::Factory>> FactoryList; typedef std::vector<std::shared_ptr<Codec::Factory>> FactoryList;