- 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)
#include "HL_CrashRpt.h"
#include "HL_String.h"
@ -171,4 +172,22 @@ CrashReporterGuard::~CrashReporterGuard()
CrashReporter::free();
}
#else
CrashReporterThreadPoint::CrashReporterThreadPoint()
{
}
CrashReporterThreadPoint::~CrashReporterThreadPoint()
{
}
CrashReporterGuard::CrashReporterGuard()
{
}
CrashReporterGuard::~CrashReporterGuard()
{
}
#endif

View File

@ -20,6 +20,9 @@ bool CsvReader::readLine(std::vector<std::string>& cells)
std::string line;
if (!std::getline(mInputStream, line))
return false;
StringHelper::trim(line);
if (line.empty())
return false;
StringHelper::split(line, cells, ",;");
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 cp = cmd;
std::shared_ptr<FILE> pipe(popen(cp.c_str(), "r"), pclose);
if (!pipe)
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)
{
auto wsfront = std::find_if_not(s.begin(), s.end(), [](int c) { return std::isspace(c); });
auto wsback = std::find_if_not(s.rbegin(), s.rend(), [](int c) { return std::isspace(c); }).base();
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) || c == '\r' || c == '\n'; }).base();
return (wsback <= wsfront ? std::string() : std::string(wsfront,wsback));
}

View File

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

View File

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

View File

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