mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 12:45:35 +08:00
Support multiple ice connections
This commit is contained in:
33
src/common/common.h
Normal file
33
src/common/common.h
Normal 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
|
||||
Reference in New Issue
Block a user