Skip to content

Commit

Permalink
T773:orkaudio: compile under Ubuntu 18.04 & OpenSuse Leap
Browse files Browse the repository at this point in the history
  -- 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.
  • Loading branch information
ericzuck committed Dec 5, 2018
1 parent 061f703 commit b3f1f78
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 4 deletions.
5 changes: 5 additions & 0 deletions orkaudio/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion orkaudio/filters/silkcodec/SilkCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion orkbasecxx/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#include <xercesc/sax/SAXParseException.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationRegistry.hpp>
#include "serializers/DomSerializer.h"
Expand Down
1 change: 0 additions & 1 deletion orkbasecxx/MultiThreadedServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//#include "winsock2.h"
#endif
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOMWriter.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationRegistry.hpp>

Expand Down
6 changes: 5 additions & 1 deletion orkbasecxx/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions orkbasecxx/serializers/DomSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#include <xercesc/dom/DOMElement.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#ifdef XERCES_3
#include <xercesc/dom/DOMLSSerializer.hpp>
#else
#include <xercesc/dom/DOMWriter.hpp>
#endif
#include <xercesc/framework/MemBufFormatTarget.hpp>

#include "DomSerializer.h"
Expand Down Expand Up @@ -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;
Expand All @@ -212,3 +241,4 @@ CStdString DomSerializer::DomNodeToString(DOMNode* node)

return output;
}
#endif

0 comments on commit b3f1f78

Please sign in to comment.