From cc5b704997ea55b5fafdffbf4effb71338078562 Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Fri, 30 Oct 2020 12:52:42 +0200 Subject: [PATCH] - minor improvements --- src/engine/agent/Agent_Impl.cpp | 1 - src/engine/audio/Audio_WavFile.cpp | 2 +- src/libs/ice/ICEByteBuffer.cpp | 11 ++++++++--- src/libs/ice/ICEByteBuffer.h | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/engine/agent/Agent_Impl.cpp b/src/engine/agent/Agent_Impl.cpp index 6a762ac4..40355552 100644 --- a/src/engine/agent/Agent_Impl.cpp +++ b/src/engine/agent/Agent_Impl.cpp @@ -554,7 +554,6 @@ void AgentImpl::processGetMediaStats(Json::Value& request, Json::Value& answer) #if defined(USE_AQUA_LIBRARY) if (includeAqua) { - // Send recorded audio to upper level answer["incoming_audio"] = mAquaIncoming.hexstring(); ICELogInfo(<< "Running AQuA analyzer."); diff --git a/src/engine/audio/Audio_WavFile.cpp b/src/engine/audio/Audio_WavFile.cpp index a3375e80..ec4eda0e 100644 --- a/src/engine/audio/Audio_WavFile.cpp +++ b/src/engine/audio/Audio_WavFile.cpp @@ -246,7 +246,7 @@ unsigned WavFileReader::size() const #define BITS_PER_CHANNEL 16 WavFileWriter::WavFileWriter() -:mHandle(nullptr), mLengthOffset(0), mRate(AUDIO_SAMPLERATE), mChannels(1) +:mHandle(nullptr), mLengthOffset(0), mRate(AUDIO_SAMPLERATE), mChannels(1), mWritten(0) { } diff --git a/src/libs/ice/ICEByteBuffer.cpp b/src/libs/ice/ICEByteBuffer.cpp index 0a6ff620..4f99e8c4 100644 --- a/src/libs/ice/ICEByteBuffer.cpp +++ b/src/libs/ice/ICEByteBuffer.cpp @@ -126,13 +126,18 @@ std::string ByteBuffer::comment() } std::string ByteBuffer::hexstring() +{ + return toHex(mDataPtr, mDataSize); +} + +std::string ByteBuffer::toHex(const void* bytes, size_t len) { std::string result; - result.resize(mDataSize * 2, (char)0xCC); - for (std::vector::size_type index = 0; index < mDataSize; index++) + result.resize(len * 2, (char)0xCC); + for (std::vector::size_type index = 0; index < len; index++) { char value[3]; - sprintf(value, "%02X", (unsigned char)mDataPtr[index]); + sprintf(value, "%02X", (unsigned char)((const unsigned char*)bytes)[index]); result[index*2] = value[0]; result[index*2+1] = value[1]; } diff --git a/src/libs/ice/ICEByteBuffer.h b/src/libs/ice/ICEByteBuffer.h index 33f17dd5..ac848059 100644 --- a/src/libs/ice/ICEByteBuffer.h +++ b/src/libs/ice/ICEByteBuffer.h @@ -47,7 +47,9 @@ namespace ice void setComment(std::string comment); std::string comment(); std::string hexstring(); - + + static std::string toHex(const void* bytes, size_t len); + void reserve(size_t capacity); void insertTurnPrefix(unsigned short prefix); void truncate(size_t newsize);