From b3f1f78636aca6035847e8540f3e213f602fd827 Mon Sep 17 00:00:00 2001 From: Eric Zuck Date: Wed, 5 Dec 2018 13:15:05 -0500 Subject: [PATCH] T773:orkaudio: compile under Ubuntu 18.04 & OpenSuse Leap -- add conditional support for xerces 3 if we are on an ubuntu or opensuse system. xerces2.8 will continue to be used under Centos 6/7 and windows. -- in silk codec,cast timestamps to long before computing interval With GCC 7.3, compiler complains about computing abs(t2-t1) if t2 and t1 are unsigned ints. In this case we are invoking abs() on an unsigned int, which is seen to be ambiguous. Casting "unsigned int" to "long" range extends the unsigned int, so that a difference can be computed correctly without overflow. --- orkaudio/configure.in | 5 ++++ orkaudio/filters/silkcodec/SilkCodec.cpp | 4 +++- orkbasecxx/ConfigManager.cpp | 1 - orkbasecxx/MultiThreadedServer.cpp | 1 - orkbasecxx/configure.in | 6 ++++- orkbasecxx/serializers/DomSerializer.cpp | 30 ++++++++++++++++++++++++ 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/orkaudio/configure.in b/orkaudio/configure.in index cc62f50..5d8f059 100644 --- a/orkaudio/configure.in +++ b/orkaudio/configure.in @@ -10,6 +10,11 @@ if [cat /etc/issue | grep Ubuntu]; then CXXFLAGS+="-std=c++11" fi +if [ grep -i opensuse /etc/os-release ]; then + speex_lib=speex + CXXFLAGS+="-std=c++11" +fi + if [grep "release 5" /etc/redhat-release]; then CXXFLAGS+="-DCENTOS_5" fi diff --git a/orkaudio/filters/silkcodec/SilkCodec.cpp b/orkaudio/filters/silkcodec/SilkCodec.cpp index af84303..2f320fb 100644 --- a/orkaudio/filters/silkcodec/SilkCodec.cpp +++ b/orkaudio/filters/silkcodec/SilkCodec.cpp @@ -124,7 +124,9 @@ void SilkCodecDecoder::AudioChunkIn(AudioChunkRef& inputAudioChunk) } } - else if(abs(outputDetails.m_timestamp - m_lastRtpTs) != (abs(outputDetails.m_sequenceNumber - m_lastRtpSeq) *m_sampleRate8KhzMultiplier*160)) + // cast timestamps to long so that we can take difference of unsigned ints + else if(abs((long)outputDetails.m_timestamp - (long)m_lastRtpTs) != + (abs((long)outputDetails.m_sequenceNumber - (long)m_lastRtpSeq) *m_sampleRate8KhzMultiplier*160)) { // sequence number delta is not coherent with timestamp delta, recalculating m_sampleRate8KhzMultiplier. //Using abs() in the condition to make sure that out of order packets will not trigger this and cause one additional unecessary lost packet diff --git a/orkbasecxx/ConfigManager.cpp b/orkbasecxx/ConfigManager.cpp index 41c3369..ccaceec 100644 --- a/orkbasecxx/ConfigManager.cpp +++ b/orkbasecxx/ConfigManager.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include "serializers/DomSerializer.h" diff --git a/orkbasecxx/MultiThreadedServer.cpp b/orkbasecxx/MultiThreadedServer.cpp index 32561e0..c3cde26 100644 --- a/orkbasecxx/MultiThreadedServer.cpp +++ b/orkbasecxx/MultiThreadedServer.cpp @@ -17,7 +17,6 @@ //#include "winsock2.h" #endif #include -#include #include #include diff --git a/orkbasecxx/configure.in b/orkbasecxx/configure.in index 2143f14..cc7c7d8 100644 --- a/orkbasecxx/configure.in +++ b/orkbasecxx/configure.in @@ -9,8 +9,12 @@ if [cat /etc/redhat-release | grep "release 6"]; then CXXFLAGS+="-DCENTOS_6 -D__STDC_CONSTANT_MACROS" fi +if [grep -i "opensuse" /etc/os-release]; then + CXXFLAGS+="-std=c++11 -DXERCES_3" +fi + if [cat /etc/issue | grep "Ubuntu"]; then - CXXFLAGS+="-std=c++11" + CXXFLAGS+="-std=c++11 -DXERCES_3" fi # Check if gcc supports cpp11 diff --git a/orkbasecxx/serializers/DomSerializer.cpp b/orkbasecxx/serializers/DomSerializer.cpp index a91d11d..def2f9d 100644 --- a/orkbasecxx/serializers/DomSerializer.cpp +++ b/orkbasecxx/serializers/DomSerializer.cpp @@ -17,7 +17,11 @@ #include #include #include +#ifdef XERCES_3 +#include +#else #include +#endif #include #include "DomSerializer.h" @@ -187,6 +191,31 @@ DOMNode* DomSerializer::FindElementByName(DOMNode *node, CStdString name) return NULL; } +#ifdef XERCES_3 +CStdString DomSerializer::DomNodeToString(DOMNode* node) +{ + CStdString output; + DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(XStr("LS").unicodeForm()); + DOMLSSerializer* theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer(); + + XMLFormatTarget *myFormTarget; + myFormTarget = new MemBufFormatTarget (); + DOMLSOutput* theOutput = ((DOMImplementationLS*)impl)->createLSOutput(); + theOutput->setByteStream(myFormTarget); + + // do the serialization through DOMLSSerializer::write(); + theSerializer->write(node, theOutput); + + output = (char *)((MemBufFormatTarget*)myFormTarget)->getRawBuffer(); + + // clean up + theOutput->release(); + theSerializer->release(); + delete myFormTarget; + + return output; +} +#else CStdString DomSerializer::DomNodeToString(DOMNode* node) { CStdString output; @@ -212,3 +241,4 @@ CStdString DomSerializer::DomNodeToString(DOMNode* node) return output; } +#endif