Merge remote-tracking branch 'origin/stable'

This commit is contained in:
Dmytro Bogovych
2022-06-03 08:46:24 +03:00
1332 changed files with 134626 additions and 292 deletions

View File

@@ -25,10 +25,15 @@ NetworkFrame::PacketData NetworkFrame::GetUdpPayloadForEthernet(NetworkFrame::Pa
uint16_t proto = 0;
if (ethernet->mEtherType == 129)
{
const VlanHeader* vlan = reinterpret_cast<const VlanHeader*>(packet.mData);
packet.mData += sizeof(VlanHeader);
packet.mLength -= sizeof(VlanHeader);
proto = ntohs(vlan->mData);
// Skip 1 or more VLAN headers
do
{
const VlanHeader* vlan = reinterpret_cast<const VlanHeader*>(packet.mData);
packet.mData += sizeof(VlanHeader);
packet.mLength -= sizeof(VlanHeader);
proto = ntohs(vlan->mData);
}
while (proto == 0x8100);
}
// Skip MPLS headers

View File

@@ -245,6 +245,17 @@ std::string MediaStreamId::getFinishDescription() const
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

@@ -85,6 +85,7 @@ struct MediaStreamId
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);

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,82 @@
#ifndef __HELPER_STATISTICS_H
#define __HELPER_STATISTICS_H
template<typename T>
struct Average
{
int mCount = 0;
T mSum = 0;
T average() const
{
if (!mCount)
return 0;
return mSum / mCount;
}
T value() const
{
return average();
}
void process(T value)
{
mCount++;
mSum += value;
}
};
template<typename T, int minimum = 100000, int maximum = 0, int default_value = 0>
struct TestResult
{
T mMin = minimum;
T mMax = maximum;
Average<T> mAverage;
T mCurrent = default_value;
void process(T value)
{
if (mMin > value)
mMin = value;
if (mMax < value)
mMax = value;
mCurrent = value;
mAverage.process(value);
}
bool is_initialized() const
{
return mAverage.mCount > 0;
}
T current() const
{
if (is_initialized())
return mCurrent;
else
return 0;
}
T value() const
{
return current();
}
T average() const
{
return mAverage.average();
}
TestResult<T>& operator = (T value)
{
process(value);
return *this;
}
operator T()
{
return mCurrent;
}
};
#endif

View File

@@ -0,0 +1,10 @@
#include "HL_Time.h"
#include <time.h>
/* return current time in milliseconds */
double now_ms(void) {
struct timespec res;
clock_gettime(CLOCK_MONOTONIC, &res);
return 1000.0 * res.tv_sec + (double) res.tv_nsec / 1e6;
}

View File

@@ -0,0 +1,6 @@
#ifndef __HELPER_TIME_H
#define __HELPER_TIME_H
extern double now_ms();
#endif