Compare commits

..

4 Commits

12 changed files with 322 additions and 403 deletions

View File

@ -184,80 +184,3 @@ void RtpDump::flush()
} }
#endif #endif
// -------------- MediaStreamId --------------------
bool MediaStreamId::operator < (const MediaStreamId& right) const
{
if (mSsrcIsId)
return std::tie(mSSRC, mSource, mDestination) < std::tie(right.mSSRC, right.mSource, right.mDestination);
else
return std::tie(mSource, mDestination) < std::tie(right.mSource, right.mDestination);
}
bool MediaStreamId::operator == (const MediaStreamId& right) const
{
if (mSsrcIsId)
return std::tie(mSSRC, mSource, mDestination) == std::tie(right.mSSRC, right.mSource, right.mDestination);
else
return std::tie(mSource, mDestination) == std::tie(right.mSource, right.mDestination);
}
std::string MediaStreamId::toString() const
{
std::ostringstream oss;
oss << "src: " << mSource.toStdString() <<
" dst: " << mDestination.toStdString() <<
" ssrc: " << StringHelper::toHex(mSSRC);
return oss.str();
}
void writeToJson(const MediaStreamId& id, std::ostringstream& oss)
{
oss << " \"src\": \"" << id.mSource.toStdString() << "\"," << std::endl
<< " \"dst\": \"" << id.mDestination.toStdString() << "\"," << std::endl
<< " \"ssrc\": \"" << StringHelper::toHex(id.mSSRC) << "\"," << std::endl
#if !defined(USE_NULL_UUID)
<< " \"link_id\": \"" << id.mLinkId.toString() << "\"" << std::endl
#endif
;
}
std::string MediaStreamId::getDetectDescription() const
{
std::ostringstream oss;
oss << "{\"event\": \"stream_detected\"," << std::endl;
writeToJson(*this, oss);
oss << "}";
return oss.str();
}
std::string MediaStreamId::getFinishDescription() const
{
std::ostringstream oss;
oss << "{" << std::endl
<< " \"event\": \"stream_finished\", " << std::endl;
writeToJson(*this, oss);
oss << "}";
return oss.str();
}
MediaStreamId& MediaStreamId::operator = (const MediaStreamId& src)
{
this->mDestination = src.mDestination;
this->mSource = src.mSource;
this->mLinkId = src.mLinkId;
this->mSSRC = src.mSSRC;
this->mSsrcIsId = src.mSsrcIsId;
return *this;
}
std::ostream& operator << (std::ostream& output, const MediaStreamId& id)
{
return (output << id.toString());
}

View File

@ -72,22 +72,4 @@ public:
}; };
#endif #endif
struct MediaStreamId
{
InternetAddress mSource;
InternetAddress mDestination;
uint32_t mSSRC = 0;
bool mSsrcIsId = true;
Uuid mLinkId;
bool operator < (const MediaStreamId& s2) const;
bool operator == (const MediaStreamId& right) const;
std::string toString() const;
std::string getDetectDescription() const;
std::string getFinishDescription() const;
MediaStreamId& operator = (const MediaStreamId& src);
};
std::ostream& operator << (std::ostream& output, const MediaStreamId& id);
#endif #endif

View File

@ -80,6 +80,8 @@ if (CMAKE_SYSTEM MATCHES "Windows*")
endif() endif()
add_library(media_lib ${SOURCES}) add_library(media_lib ${SOURCES})
# Depending on ice stack library to provide bit level operations
target_link_libraries(media_lib PUBLIC ice_stack)
target_include_directories(media_lib target_include_directories(media_lib
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/

View File

@ -67,7 +67,7 @@ void JitterStatistics::process(jrtplib::RTPPacket* packet, int rate)
Statistics::Statistics() Statistics::Statistics()
:mReceived(0), mSent(0), mReceivedRtp(0), mSentRtp(0), :mReceived(0), mSent(0), mReceivedRtp(0), mSentRtp(0),
mReceivedRtcp(0), mSentRtcp(0), mDuplicatedRtp(0), mOldRtp(0), mIllegalRtp(0), mReceivedRtcp(0), mSentRtcp(0), mDuplicatedRtp(0), mOldRtp(0), mIllegalRtp(0),
mPacketLoss(0), mJitter(0.0), mAudioTime(0), mSsrc(0), mPacketDropped(0) mPacketLoss(0), mJitter(0.0), mAudioTime(0), mSsrc(0), mPacketDropped(0), mDecodedAudio(0)
{ {
mBitrateSwitchCounter = 0; mBitrateSwitchCounter = 0;
memset(mLoss, 0, sizeof mLoss); memset(mLoss, 0, sizeof mLoss);
@ -95,7 +95,7 @@ void Statistics::reset()
mJitter = 0.0; mJitter = 0.0;
mAudioTime = 0; mAudioTime = 0;
mPacketDropped = 0; mPacketDropped = 0;
mDecodedAudio = 0;
memset(mLoss, 0, sizeof mLoss); memset(mLoss, 0, sizeof mLoss);
} }
@ -179,7 +179,7 @@ Statistics& Statistics::operator += (const Statistics& src)
mPacketLoss += src.mPacketLoss; mPacketLoss += src.mPacketLoss;
mPacketDropped += src.mPacketDropped; mPacketDropped += src.mPacketDropped;
mAudioTime += src.mAudioTime; mAudioTime += src.mAudioTime;
mDecodedAudio += src.mDecodedAudio;
for (auto codecStat: src.mCodecCount) for (auto codecStat: src.mCodecCount)
{ {
@ -230,6 +230,7 @@ Statistics& Statistics::operator -= (const Statistics& src)
mOldRtp -= src.mOldRtp; mOldRtp -= src.mOldRtp;
mPacketLoss -= src.mPacketLoss; mPacketLoss -= src.mPacketLoss;
mPacketDropped -= src.mPacketDropped; mPacketDropped -= src.mPacketDropped;
mDecodedAudio -= src.mDecodedAudio;
mAudioTime -= src.mAudioTime; mAudioTime -= src.mAudioTime;
for (auto codecStat: src.mCodecCount) for (auto codecStat: src.mCodecCount)

View File

@ -63,6 +63,8 @@ public:
mPacketDropped, // Number of dropped packets (due to time unsync when playing)б mPacketDropped, // Number of dropped packets (due to time unsync when playing)б
mIllegalRtp; // Number of rtp packets with bad payload type mIllegalRtp; // Number of rtp packets with bad payload type
size_t mDecodedAudio; // Size of decoded audio bytes
TestResult<float> mDecodingInterval, // Average interval on call to packet decode TestResult<float> mDecodingInterval, // Average interval on call to packet decode
mDecodeRequested, // Average amount of requested audio frames to play mDecodeRequested, // Average amount of requested audio frames to play
mPacketInterval; // Average interval between packet adding to jitter buffer mPacketInterval; // Average interval between packet adding to jitter buffer
@ -98,10 +100,10 @@ public:
Statistics& operator -= (const Statistics& src); Statistics& operator -= (const Statistics& src);
float mNetworkMos = 0.0; float mNetworkMos = 0.0;
#if defined(USE_PVQA_LIBRARY) && !defined(PVQA_SERVER) // #if defined(USE_PVQA_LIBRARY) && !defined(PVQA_SERVER)
float mPvqaMos = 0.0; // float mPvqaMos = 0.0;
std::string mPvqaReport; //std::string mPvqaReport;
#endif // #endif
std::string toString() const; std::string toString() const;
}; };

View File

@ -201,7 +201,6 @@ void Logger::beginLine(LogLevel level, const char* filename, int linenumber, con
void void
Logger::endLine() Logger::endLine()
{ {
*mStream << std::endl;
*mStream << std::flush; *mStream << std::flush;
mStream->flush(); mStream->flush();
@ -213,7 +212,7 @@ Logger::endLine()
result << time_buffer << ":" << (unix_timestamp_ms.count() % 1000 ) << "\t" << " | " << std::setw(8) << ThreadInfo::currentThread() << " | " << std::setw(30) result << time_buffer << ":" << (unix_timestamp_ms.count() % 1000 ) << "\t" << " | " << std::setw(8) << ThreadInfo::currentThread() << " | " << std::setw(30)
<< mFilename.c_str() << " | " << std::setw(4) << mLine << " | " << std::setw(12) << mSubsystem.c_str() << " | " << mFilename.c_str() << " | " << std::setw(4) << mLine << " | " << std::setw(12) << mSubsystem.c_str() << " | "
<< mStream->str().c_str(); << mStream->str().c_str() << std::endl;
std::string t = result.str(); std::string t = result.str();
if (mUseDebugWindow) { if (mUseDebugWindow) {

View File

@ -86,8 +86,14 @@ protected:
class LogLock class LogLock
{ {
public: public:
LogLock(LogGuard& g) :mGuard(g) { mGuard.Lock(); } LogLock(LogGuard& g) :mGuard(g)
~LogLock() { mGuard.Unlock(); } {
mGuard.Lock();
}
~LogLock()
{
mGuard.Unlock();
}
protected: protected:
LogGuard& mGuard; LogGuard& mGuard;

View File

@ -91,4 +91,4 @@ set(JRTPLIB_SOURCES
rtpexternaltransmitter.cpp) rtpexternaltransmitter.cpp)
add_library(jrtplib STATIC ${JRTPLIB_SOURCES}) add_library(jrtplib STATIC ${JRTPLIB_SOURCES})
target_include_directories(jrtplib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -152,6 +152,8 @@ int RTPPacket::ParseRawPacket(RTPRawPacket &rawpack)
csrccount = rtpheader->csrccount; csrccount = rtpheader->csrccount;
payloadoffset = sizeof(RTPHeader)+(int)(csrccount*sizeof(uint32_t)); payloadoffset = sizeof(RTPHeader)+(int)(csrccount*sizeof(uint32_t));
if ((size_t)payloadoffset > packetlen)
return ERR_RTP_PACKET_INVALIDPACKET;
if (rtpheader->padding) // adjust payload length to take padding into account if (rtpheader->padding) // adjust payload length to take padding into account
{ {
@ -167,6 +169,8 @@ int RTPPacket::ParseRawPacket(RTPRawPacket &rawpack)
{ {
rtpextheader = (RTPExtensionHeader *)(packetbytes+payloadoffset); rtpextheader = (RTPExtensionHeader *)(packetbytes+payloadoffset);
payloadoffset += sizeof(RTPExtensionHeader); payloadoffset += sizeof(RTPExtensionHeader);
if ((size_t)payloadoffset > packetlen)
return ERR_RTP_PACKET_INVALIDPACKET;
exthdrlen = ntohs(rtpextheader->length); exthdrlen = ntohs(rtpextheader->length);
payloadoffset += ((int)exthdrlen)*sizeof(uint32_t); payloadoffset += ((int)exthdrlen)*sizeof(uint32_t);
} }

View File

@ -20,7 +20,7 @@ set (SPEEXDSP_SOURCES
) )
add_library(speexdsp ${SPEEXDSP_SOURCES}) add_library(speexdsp ${SPEEXDSP_SOURCES})
target_compile_definitions(speexdsp PUBLIC -DUSE_KISS_FFT -DFIXED_POINT -DHAVE_STDINT_H) target_compile_definitions(speexdsp PUBLIC -DUSE_KISS_FFT -DFLOATING_POINT -DHAVE_STDINT_H)
target_include_directories(speexdsp PUBLIC target_include_directories(speexdsp PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/libspeexdsp ${CMAKE_CURRENT_SOURCE_DIR}/libspeexdsp