Merge remote-tracking branch 'origin/stable'
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
1
src/engine/helper/HL_Statistics.cpp
Normal file
1
src/engine/helper/HL_Statistics.cpp
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
82
src/engine/helper/HL_Statistics.h
Normal file
82
src/engine/helper/HL_Statistics.h
Normal 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
|
||||
10
src/engine/helper/HL_Time.cpp
Normal file
10
src/engine/helper/HL_Time.cpp
Normal 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;
|
||||
}
|
||||
6
src/engine/helper/HL_Time.h
Normal file
6
src/engine/helper/HL_Time.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __HELPER_TIME_H
|
||||
#define __HELPER_TIME_H
|
||||
|
||||
extern double now_ms();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user