Skip to content
Snippets Groups Projects
Unverified Commit 53f8883a authored by Nicolas Werner's avatar Nicolas Werner Committed by GitHub
Browse files

Merge pull request #50 from trilene/master

Fix calls with voip v1 clients
parents 004d4203 a37827de
No related branches found
No related tags found
No related merge requests found
Pipeline #791 passed
......@@ -22,7 +22,7 @@ struct CallInvite
//! The SDP text of the session description.
std::string sdp;
//! The version of the VoIP specification this message adheres to.
uint16_t version;
std::string version;
//! The time in milliseconds that the invite is valid for.
uint32_t lifetime;
};
......@@ -51,7 +51,7 @@ struct CallCandidates
//! Array of objects describing the candidates.
std::vector<Candidate> candidates;
//! The version of the VoIP specification this message adheres to.
uint16_t version;
std::string version;
};
void
......@@ -68,7 +68,7 @@ struct CallAnswer
//! The SDP text of the session description.
std::string sdp;
//! The version of the VoIP specification this message adheres to.
uint16_t version;
std::string version;
};
void
......@@ -90,7 +90,7 @@ struct CallHangUp
//! The ID of the call this event relates to.
std::string call_id;
//! The version of the VoIP specification this message adheres to.
uint16_t version;
std::string version;
//! The reason for the call hang up.
Reason reason = Reason::User;
};
......
#include <string>
#include "mtx/events/voip.hpp"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
namespace {
std::string
version(const json &obj)
{
auto v = obj.at("version");
return v.is_number() ? "0" : v.get<std::string>();
}
}
namespace mtx::events::msg {
// m.call.invite
......@@ -12,7 +23,7 @@ from_json(const json &obj, CallInvite &content)
{
content.call_id = obj.at("call_id").get<std::string>();
content.sdp = obj.at("offer").at("sdp").get<std::string>();
content.version = obj.at("version").get<uint16_t>();
content.version = version(obj);
content.lifetime = obj.at("lifetime").get<uint32_t>();
}
......@@ -47,7 +58,7 @@ from_json(const json &obj, CallCandidates &content)
{
content.call_id = obj.at("call_id").get<std::string>();
content.candidates = obj.at("candidates").get<std::vector<CallCandidates::Candidate>>();
content.version = obj.at("version").get<uint16_t>();
content.version = version(obj);
}
void
......@@ -64,7 +75,7 @@ from_json(const json &obj, CallAnswer &content)
{
content.call_id = obj.at("call_id").get<std::string>();
content.sdp = obj.at("answer").at("sdp").get<std::string>();
content.version = obj.at("version").get<uint16_t>();
content.version = version(obj);
}
void
......@@ -80,7 +91,7 @@ void
from_json(const json &obj, CallHangUp &content)
{
content.call_id = obj.at("call_id").get<std::string>();
content.version = obj.at("version").get<uint16_t>();
content.version = version(obj);
if (obj.count("reason") == 0) {
content.reason = CallHangUp::Reason::User;
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment