Support multiple ice connections

This commit is contained in:
dijunkun
2023-08-17 17:31:08 +08:00
parent a9db3d290b
commit 3a55dd0938
16 changed files with 335 additions and 232 deletions

33
src/common/common.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef _COMMON_H_
#define _COMMON_H_
#include <iostream>
constexpr size_t HASH_STRING_PIECE(const char *string_piece) {
std::size_t result = 0;
while (*string_piece) {
result = (result * 131) + *string_piece++;
}
return result;
}
constexpr size_t operator"" _H(const char *string_piece, size_t) {
return HASH_STRING_PIECE(string_piece);
}
inline const std::string GetIceUsername(const std::string &sdp) {
std::string result = "";
std::string start = "ice-ufrag:";
std::string end = "\r\n";
size_t startPos = sdp.find(start);
size_t endPos = sdp.find(end);
if (startPos != std::string::npos && endPos != std::string::npos) {
result = sdp.substr(startPos + start.length(),
endPos - startPos - start.length());
}
return result;
}
#endif