- forgotten fixes from March

This commit is contained in:
Dmytro Bogovych 2020-05-05 12:34:52 +03:00
parent 762eb9ca33
commit 0d69c26a13
7 changed files with 233 additions and 212 deletions

View File

@ -1,6 +1,7 @@
#include "HL_CrashRpt.h"
#if defined(USE_CRASHRPT) #if defined(USE_CRASHRPT)
#include "HL_CrashRpt.h"
#include "HL_String.h" #include "HL_String.h"
@ -171,4 +172,22 @@ CrashReporterGuard::~CrashReporterGuard()
CrashReporter::free(); CrashReporter::free();
} }
#else
CrashReporterThreadPoint::CrashReporterThreadPoint()
{
}
CrashReporterThreadPoint::~CrashReporterThreadPoint()
{
}
CrashReporterGuard::CrashReporterGuard()
{
}
CrashReporterGuard::~CrashReporterGuard()
{
}
#endif #endif

View File

@ -20,6 +20,9 @@ bool CsvReader::readLine(std::vector<std::string>& cells)
std::string line; std::string line;
if (!std::getline(mInputStream, line)) if (!std::getline(mInputStream, line))
return false; return false;
StringHelper::trim(line);
if (line.empty())
return false;
StringHelper::split(line, cells, ",;"); StringHelper::split(line, cells, ",;");
return true; return true;

View File

@ -202,7 +202,6 @@ std::shared_ptr<std::thread> OsProcess::asyncExecCommand(const std::string& cmdl
std::string OsProcess::execCommand(const std::string& cmd) std::string OsProcess::execCommand(const std::string& cmd)
{ {
std::string cp = cmd; std::string cp = cmd;
std::shared_ptr<FILE> pipe(popen(cp.c_str(), "r"), pclose); std::shared_ptr<FILE> pipe(popen(cp.c_str(), "r"), pclose);
if (!pipe) if (!pipe)
throw std::runtime_error("Failed to run."); throw std::runtime_error("Failed to run.");

View File

@ -276,8 +276,8 @@ float StringHelper::toFloat(const std::string &s, float v, bool* isOk)
std::string StringHelper::trim(const std::string &s) std::string StringHelper::trim(const std::string &s)
{ {
auto wsfront = std::find_if_not(s.begin(), s.end(), [](int c) { return std::isspace(c); }); auto wsfront = std::find_if_not(s.begin(), s.end(), [](int c) { return std::isspace(c) || c == '\r' || c == '\n'; });
auto wsback = std::find_if_not(s.rbegin(), s.rend(), [](int c) { return std::isspace(c); }).base(); auto wsback = std::find_if_not(s.rbegin(), s.rend(), [](int c) { return std::isspace(c) || c == '\r' || c == '\n'; }).base();
return (wsback <= wsfront ? std::string() : std::string(wsfront,wsback)); return (wsback <= wsfront ? std::string() : std::string(wsfront,wsback));
} }

View File

@ -17,8 +17,8 @@
extern "C" extern "C"
{ {
#include "libgsm/gsm.h" #include "libgsm/gsm.h"
#include "g722/g722.h" #include "g722/g722.h"
} }
#include "libg729/g729_typedef.h" #include "libg729/g729_typedef.h"
@ -28,14 +28,14 @@ extern "C"
namespace MT namespace MT
{ {
class G729Codec: public Codec class G729Codec: public Codec
{ {
protected: protected:
CodState* mEncoder = nullptr; CodState* mEncoder = nullptr;
DecState* mDecoder = nullptr; DecState* mDecoder = nullptr;
void decodeFrame(const uint8_t* rtp, int16_t* pcm); void decodeFrame(const uint8_t* rtp, int16_t* pcm);
public: public:
class G729Factory: public Factory class G729Factory: public Factory
{ {
public: public:
@ -62,16 +62,16 @@ namespace MT
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override; int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override; int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
int plc(int lostFrames, void* output, int outputCapacity) override; int plc(int lostFrames, void* output, int outputCapacity) override;
}; };
class OpusCodec: public Codec class OpusCodec: public Codec
{ {
protected: protected:
OpusEncoder *mEncoderCtx; OpusEncoder *mEncoderCtx;
OpusDecoder *mDecoderCtx; OpusDecoder *mDecoderCtx;
int mPTime, mSamplerate, mChannels; int mPTime, mSamplerate, mChannels;
Audio::SpeexResampler mDecodeResampler; Audio::SpeexResampler mDecodeResampler;
public: public:
struct Params struct Params
{ {
bool mUseDtx, mUseInbandFec, mStereo; bool mUseDtx, mUseInbandFec, mStereo;
@ -119,16 +119,16 @@ namespace MT
int encode(const void* input, int inputBytes, void* output, int outputCapacity); int encode(const void* input, int inputBytes, void* output, int outputCapacity);
int decode(const void* input, int inputBytes, void* output, int outputCapacity); int decode(const void* input, int inputBytes, void* output, int outputCapacity);
int plc(int lostFrames, void* output, int outputCapacity); int plc(int lostFrames, void* output, int outputCapacity);
}; };
class IlbcCodec: public Codec class IlbcCodec: public Codec
{ {
protected: protected:
int mPacketTime; /// Single frame time (20 or 30 ms) int mPacketTime; /// Single frame time (20 or 30 ms)
iLBC_encinst_t* mEncoderCtx; iLBC_encinst_t* mEncoderCtx;
iLBC_decinst_t* mDecoderCtx; iLBC_decinst_t* mDecoderCtx;
public: public:
class IlbcFactory: public Factory class IlbcFactory: public Factory
{ {
protected: protected:
@ -159,11 +159,11 @@ namespace MT
int encode(const void* input, int inputBytes, void* output, int outputCapacity); int encode(const void* input, int inputBytes, void* output, int outputCapacity);
int decode(const void* input, int inputBytes, void* output, int outputCapacity); int decode(const void* input, int inputBytes, void* output, int outputCapacity);
int plc(int lostFrames, void* output, int outputCapacity); int plc(int lostFrames, void* output, int outputCapacity);
}; };
class G711Codec: public Codec class G711Codec: public Codec
{ {
public: public:
class AlawFactory: public Factory class AlawFactory: public Factory
{ {
public: public:
@ -201,17 +201,17 @@ namespace MT
int decode(const void* input, int inputBytes, void* output, int outputCapacity); int decode(const void* input, int inputBytes, void* output, int outputCapacity);
int plc(int lostSamples, void* output, int outputCapacity); int plc(int lostSamples, void* output, int outputCapacity);
protected: protected:
int mType; /// Determines if it is u-law or a-law codec. Its value is ALaw or ULaw. int mType; /// Determines if it is u-law or a-law codec. Its value is ALaw or ULaw.
}; };
class IsacCodec: public Codec class IsacCodec: public Codec
{ {
protected: protected:
int mSamplerate; int mSamplerate;
ISACFIX_MainStruct* mEncoderCtx; ISACFIX_MainStruct* mEncoderCtx;
ISACFIX_MainStruct* mDecoderCtx; ISACFIX_MainStruct* mDecoderCtx;
public: public:
class IsacFactory16K: public Factory class IsacFactory16K: public Factory
{ {
public: public:
@ -251,38 +251,38 @@ namespace MT
int encode(const void* input, int inputBytes, void* output, int outputCapacity); int encode(const void* input, int inputBytes, void* output, int outputCapacity);
int decode(const void* input, int inputBytes, void* output, int outputCapacity); int decode(const void* input, int inputBytes, void* output, int outputCapacity);
int plc(int lostFrames, void* output, int outputCapacity); int plc(int lostFrames, void* output, int outputCapacity);
}; };
/// GSM MIME name /// GSM MIME name
#define GSM_MIME_NAME "gsm" #define GSM_MIME_NAME "gsm"
/// Optional GSM SIP attributes /// Optional GSM SIP attributes
#define GSM_SIP_ATTR "" #define GSM_SIP_ATTR ""
/// GSM codec single frame time in milliseconds /// GSM codec single frame time in milliseconds
#define GSM_AUDIOFRAME_TIME 20 #define GSM_AUDIOFRAME_TIME 20
/// GSM codec single RTP frame size in bytes /// GSM codec single RTP frame size in bytes
#define GSM_RTPFRAME_SIZE_33 33 #define GSM_RTPFRAME_SIZE_33 33
#define GSM_RTPFRAME_SIZE_32 32 #define GSM_RTPFRAME_SIZE_32 32
#define GSM_RTPFRAME_SIZE_31 31 #define GSM_RTPFRAME_SIZE_31 31
/// GSM payload type /// GSM payload type
#define GSM_PAYLOAD_TYPE 3 #define GSM_PAYLOAD_TYPE 3
/// GSM bitrate (bits/sec) /// GSM bitrate (bits/sec)
#define GSM_BITRATE 13000 #define GSM_BITRATE 13000
/*! /*!
* GSM codec wrapper. Based on implementation located in libgsm directory. * GSM codec wrapper. Based on implementation located in libgsm directory.
* @see IMediaCodec * @see IMediaCodec
*/ */
class GsmCodec: public Codec class GsmCodec: public Codec
{ {
public: public:
enum class Type enum class Type
{ {
Bytes_33, Bytes_33,
@ -290,11 +290,11 @@ namespace MT
Bytes_31, Bytes_31,
Bytes_65 Bytes_65
}; };
protected: protected:
struct gsm_state * mGSM; /// Pointer to codec context struct gsm_state * mGSM; /// Pointer to codec context
Type mCodecType; Type mCodecType;
public: public:
class GsmFactory: public Factory class GsmFactory: public Factory
{ {
protected: protected:
@ -325,33 +325,33 @@ namespace MT
int encode(const void* input, int inputBytes, void* output, int outputCapacity); int encode(const void* input, int inputBytes, void* output, int outputCapacity);
int decode(const void* input, int inputBytes, void* output, int outputCapacity); int decode(const void* input, int inputBytes, void* output, int outputCapacity);
int plc(int lostFrames, void* output, int outputCapacity); int plc(int lostFrames, void* output, int outputCapacity);
}; };
/// GSM MIME name /// GSM MIME name
#define G722_MIME_NAME "g722" #define G722_MIME_NAME "g722"
/// Optional GSM SIP attributes /// Optional GSM SIP attributes
#define G722_SIP_ATTR "" #define G722_SIP_ATTR ""
/// GSM codec single frame time in milliseconds /// GSM codec single frame time in milliseconds
#define G722_AUDIOFRAME_TIME 20 #define G722_AUDIOFRAME_TIME 20
/// GSM codec single RTP frame size in bytes /// GSM codec single RTP frame size in bytes
#define G722_RTPFRAME_SIZE 80 #define G722_RTPFRAME_SIZE 80
/// GSM payload type /// GSM payload type
#define G722_PAYLOAD_TYPE 9 #define G722_PAYLOAD_TYPE 9
/// GSM bitrate (bits/sec) /// GSM bitrate (bits/sec)
#define G722_BITRATE 64000 #define G722_BITRATE 64000
class G722Codec: public Codec class G722Codec: public Codec
{ {
protected: protected:
void* mEncoder; void* mEncoder;
void* mDecoder; void* mDecoder;
public: public:
class G722Factory: public Factory class G722Factory: public Factory
{ {
public: public:
@ -376,14 +376,14 @@ namespace MT
int plc(int lostFrames, void* output, int outputCapacity); int plc(int lostFrames, void* output, int outputCapacity);
//unsigned GetSamplerate() { return 16000; } //unsigned GetSamplerate() { return 16000; }
}; };
class GsmHrCodec: public Codec class GsmHrCodec: public Codec
{ {
protected: protected:
void* mDecoder; void* mDecoder;
public: public:
class GsmHrFactory: public Factory class GsmHrFactory: public Factory
{ {
protected: protected:
@ -410,7 +410,7 @@ namespace MT
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override; int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override; int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
int plc(int lostFrames, void* output, int outputCapacity) override; int plc(int lostFrames, void* output, int outputCapacity) override;
}; };
} }
#endif #endif

View File

@ -16,16 +16,16 @@
namespace MT namespace MT
{ {
class Codec; class Codec;
typedef std::shared_ptr<Codec> PCodec; typedef std::shared_ptr<Codec> PCodec;
class CodecMap: public std::map<int, PCodec> class CodecMap: public std::map<int, PCodec>
{ {
}; };
class Codec class Codec
{ {
public: public:
class Factory class Factory
{ {
public: public:
@ -59,6 +59,6 @@ namespace MT
// Returns size of codec in memory // Returns size of codec in memory
virtual int getSize() const { return 0; }; virtual int getSize() const { return 0; };
}; };
} }
#endif #endif

View File

@ -19,9 +19,9 @@
namespace MT namespace MT
{ {
class CodecList class CodecList
{ {
public: public:
struct Settings struct Settings
{ {
bool mWrapIuUP = false; bool mWrapIuUP = false;
@ -64,15 +64,15 @@ namespace MT
int findCodec(const std::string& name) const; int findCodec(const std::string& name) const;
void fillCodecMap(CodecMap& cm); void fillCodecMap(CodecMap& cm);
protected: protected:
typedef std::vector<Codec::Factory*> FactoryList; typedef std::vector<Codec::Factory*> FactoryList;
FactoryList mFactoryList; FactoryList mFactoryList;
Settings mSettings; Settings mSettings;
}; };
class CodecListPriority class CodecListPriority
{ {
public: public:
CodecListPriority(); CodecListPriority();
~CodecListPriority(); ~CodecListPriority();
@ -80,7 +80,7 @@ namespace MT
int count(const CodecList& cl) const; int count(const CodecList& cl) const;
Codec::Factory& codecAt(const CodecList& cl, int index) const; Codec::Factory& codecAt(const CodecList& cl, int index) const;
protected: protected:
struct Item struct Item
{ {
int mCodecIndex; int mCodecIndex;
@ -90,6 +90,6 @@ namespace MT
static bool isNegativePriority(const CodecListPriority::Item& item); static bool isNegativePriority(const CodecListPriority::Item& item);
static bool compare(const Item& item1, const Item& item2); static bool compare(const Item& item1, const Item& item2);
}; };
} }
#endif #endif