|
@@ -341,7 +341,7 @@ int rtcSetLocalDescriptionCallback(int pc, rtcDescriptionCallbackFunc cb) {
|
|
return WRAP({
|
|
return WRAP({
|
|
auto peerConnection = getPeerConnection(pc);
|
|
auto peerConnection = getPeerConnection(pc);
|
|
if (cb)
|
|
if (cb)
|
|
- peerConnection->onLocalDescription([pc, cb](const Description &desc) {
|
|
|
|
|
|
+ peerConnection->onLocalDescription([pc, cb](Description desc) {
|
|
if (auto ptr = getUserPointer(pc))
|
|
if (auto ptr = getUserPointer(pc))
|
|
cb(string(desc).c_str(), desc.typeString().c_str(), *ptr);
|
|
cb(string(desc).c_str(), desc.typeString().c_str(), *ptr);
|
|
});
|
|
});
|
|
@@ -354,7 +354,7 @@ int rtcSetLocalCandidateCallback(int pc, rtcCandidateCallbackFunc cb) {
|
|
return WRAP({
|
|
return WRAP({
|
|
auto peerConnection = getPeerConnection(pc);
|
|
auto peerConnection = getPeerConnection(pc);
|
|
if (cb)
|
|
if (cb)
|
|
- peerConnection->onLocalCandidate([pc, cb](const Candidate &cand) {
|
|
|
|
|
|
+ peerConnection->onLocalCandidate([pc, cb](Candidate cand) {
|
|
if (auto ptr = getUserPointer(pc))
|
|
if (auto ptr = getUserPointer(pc))
|
|
cb(cand.candidate().c_str(), cand.mid().c_str(), *ptr);
|
|
cb(cand.candidate().c_str(), cand.mid().c_str(), *ptr);
|
|
});
|
|
});
|
|
@@ -542,7 +542,7 @@ int rtcSetErrorCallback(int id, rtcErrorCallbackFunc cb) {
|
|
return WRAP({
|
|
return WRAP({
|
|
auto channel = getChannel(id);
|
|
auto channel = getChannel(id);
|
|
if (cb)
|
|
if (cb)
|
|
- channel->onError([id, cb](const string &error) {
|
|
|
|
|
|
+ channel->onError([id, cb](string error) {
|
|
if (auto ptr = getUserPointer(id))
|
|
if (auto ptr = getUserPointer(id))
|
|
cb(error.c_str(), *ptr);
|
|
cb(error.c_str(), *ptr);
|
|
});
|
|
});
|
|
@@ -556,11 +556,11 @@ int rtcSetMessageCallback(int id, rtcMessageCallbackFunc cb) {
|
|
auto channel = getChannel(id);
|
|
auto channel = getChannel(id);
|
|
if (cb)
|
|
if (cb)
|
|
channel->onMessage(
|
|
channel->onMessage(
|
|
- [id, cb](const binary &b) {
|
|
|
|
|
|
+ [id, cb](binary b) {
|
|
if (auto ptr = getUserPointer(id))
|
|
if (auto ptr = getUserPointer(id))
|
|
cb(reinterpret_cast<const char *>(b.data()), int(b.size()), *ptr);
|
|
cb(reinterpret_cast<const char *>(b.data()), int(b.size()), *ptr);
|
|
},
|
|
},
|
|
- [id, cb](const string &s) {
|
|
|
|
|
|
+ [id, cb](string s) {
|
|
if (auto ptr = getUserPointer(id))
|
|
if (auto ptr = getUserPointer(id))
|
|
cb(s.c_str(), -int(s.size() + 1), *ptr);
|
|
cb(s.c_str(), -int(s.size() + 1), *ptr);
|
|
});
|
|
});
|
|
@@ -643,13 +643,13 @@ int rtcReceiveMessage(int id, char *buffer, int *size) {
|
|
if (auto message = channel->receive())
|
|
if (auto message = channel->receive())
|
|
return std::visit( //
|
|
return std::visit( //
|
|
overloaded{ //
|
|
overloaded{ //
|
|
- [&](const binary &b) {
|
|
|
|
|
|
+ [&](binary b) {
|
|
*size = std::min(*size, int(b.size()));
|
|
*size = std::min(*size, int(b.size()));
|
|
auto data = reinterpret_cast<const char *>(b.data());
|
|
auto data = reinterpret_cast<const char *>(b.data());
|
|
std::copy(data, data + *size, buffer);
|
|
std::copy(data, data + *size, buffer);
|
|
return 1;
|
|
return 1;
|
|
},
|
|
},
|
|
- [&](const string &s) {
|
|
|
|
|
|
+ [&](string s) {
|
|
int len = std::min(*size - 1, int(s.size()));
|
|
int len = std::min(*size - 1, int(s.size()));
|
|
if (len >= 0) {
|
|
if (len >= 0) {
|
|
std::copy(s.data(), s.data() + len, buffer);
|
|
std::copy(s.data(), s.data() + len, buffer);
|