Skip to content
Snippets Groups Projects
Commit 967c11a0 authored by Pierre Lespagnol's avatar Pierre Lespagnol Committed by Adrien Béraud
Browse files

conference: add final frame size to confInfo

Gitlab: #467
Change-Id: I541ea21fabf7e4ee957174676579c5850115f9fb
parent 26b75a62
Branches
Tags
No related merge requests found
...@@ -109,6 +109,10 @@ Conference::Conference() ...@@ -109,6 +109,10 @@ Conference::Conference()
isModeratorMuted, isModeratorMuted,
isModerator}); isModerator});
} }
if (auto videoMixer = shared->getVideoMixer()) {
newInfo.h = videoMixer->getHeight();
newInfo.w = videoMixer->getWidth();
}
lk.unlock(); lk.unlock();
// Handle participants not present in the video mixer // Handle participants not present in the video mixer
for (const auto& subCall : subCalls) { for (const auto& subCall : subCalls) {
...@@ -369,11 +373,13 @@ ConfInfo::toVectorMapStringString() const ...@@ -369,11 +373,13 @@ ConfInfo::toVectorMapStringString() const
std::string std::string
ConfInfo::toString() const ConfInfo::toString() const
{ {
Json::Value jsonArray = {}; Json::Value val = {};
for (const auto& info : *this) { for (const auto& info : *this) {
jsonArray.append(info.toJson()); val["p"].append(info.toJson());
} }
return Json::writeString(Json::StreamWriterBuilder {}, jsonArray); val["w"] = w;
val["h"] = h;
return Json::writeString(Json::StreamWriterBuilder {}, val);
} }
void void
...@@ -977,18 +983,20 @@ Conference::muteLocalHost(bool is_muted, const std::string& mediaType) ...@@ -977,18 +983,20 @@ Conference::muteLocalHost(bool is_muted, const std::string& mediaType)
} }
void void
Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo& remoteCell) Conference::resizeRemoteParticipants(ConfInfo& confInfo, std::string_view peerURI)
{ {
int remoteFrameHeight {0}; int remoteFrameHeight = confInfo.h;
int remoteFrameWidth {0}; int remoteFrameWidth = confInfo.w;
ParticipantInfo localCell;
// get the size of the remote frame if (remoteFrameHeight == 0 or remoteFrameWidth == 0) {
// get the size of the remote frame from receiveThread
// if the one from confInfo is empty
if (auto call = std::dynamic_pointer_cast<SIPCall>( if (auto call = std::dynamic_pointer_cast<SIPCall>(
getCallFromPeerID(string_remove_suffix(peerURI, '@')))) { getCallFromPeerID(string_remove_suffix(peerURI, '@')))) {
remoteFrameHeight = call->getVideoRtp().getVideoReceive()->getHeight(); remoteFrameHeight = call->getVideoRtp().getVideoReceive()->getHeight();
remoteFrameWidth = call->getVideoRtp().getVideoReceive()->getWidth(); remoteFrameWidth = call->getVideoRtp().getVideoReceive()->getWidth();
} }
}
if (remoteFrameHeight == 0 or remoteFrameWidth == 0) { if (remoteFrameHeight == 0 or remoteFrameWidth == 0) {
JAMI_WARN("Remote frame size not found."); JAMI_WARN("Remote frame size not found.");
...@@ -996,6 +1004,7 @@ Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo& ...@@ -996,6 +1004,7 @@ Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo&
} }
// get the size of the local frame // get the size of the local frame
ParticipantInfo localCell;
for (const auto& p : confInfo_) { for (const auto& p : confInfo_) {
if (p.uri == peerURI) { if (p.uri == peerURI) {
localCell = p; localCell = p;
...@@ -1003,6 +1012,8 @@ Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo& ...@@ -1003,6 +1012,8 @@ Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo&
} }
} }
// Do the resize for each remote participant
for (auto& remoteCell : confInfo) {
const float zoomX = (float) remoteFrameWidth / localCell.w; const float zoomX = (float) remoteFrameWidth / localCell.w;
const float zoomY = (float) remoteFrameHeight / localCell.h; const float zoomY = (float) remoteFrameHeight / localCell.h;
...@@ -1011,15 +1022,6 @@ Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo& ...@@ -1011,15 +1022,6 @@ Conference::resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo&
remoteCell.w = remoteCell.w / zoomX; remoteCell.w = remoteCell.w / zoomX;
remoteCell.h = remoteCell.h / zoomY; remoteCell.h = remoteCell.h / zoomY;
} }
std::string
Conference::confInfo2str(const ConfInfo& confInfo)
{
Json::Value jsonArray = {};
for (const auto& info : confInfo) {
jsonArray.append(info.toJson());
}
return Json::writeString(Json::StreamWriterBuilder {}, jsonArray);
} }
void void
...@@ -1031,9 +1033,7 @@ Conference::mergeConfInfo(ConfInfo& newInfo, const std::string& peerURI) ...@@ -1031,9 +1033,7 @@ Conference::mergeConfInfo(ConfInfo& newInfo, const std::string& peerURI)
return; return;
} }
for (auto& partInfo : newInfo) { resizeRemoteParticipants(newInfo, peerURI);
resizeRemoteParticipant(peerURI, partInfo);
}
bool updateNeeded = false; bool updateNeeded = false;
auto it = remoteHosts_.find(peerURI); auto it = remoteHosts_.find(peerURI);
......
...@@ -135,6 +135,9 @@ struct ConfInfo : public std::vector<ParticipantInfo> ...@@ -135,6 +135,9 @@ struct ConfInfo : public std::vector<ParticipantInfo>
friend bool operator==(const ConfInfo& c1, const ConfInfo& c2) friend bool operator==(const ConfInfo& c1, const ConfInfo& c2)
{ {
if (c1.h != c2.h or c1.w != c2.w)
return false;
for (auto& p1 : c1) { for (auto& p1 : c1) {
auto it = std::find_if(c2.begin(), c2.end(), [p1](const ParticipantInfo& p2) { auto it = std::find_if(c2.begin(), c2.end(), [p1](const ParticipantInfo& p2) {
return p1 == p2; return p1 == p2;
...@@ -289,7 +292,6 @@ public: ...@@ -289,7 +292,6 @@ public:
void updateMuted(); void updateMuted();
void muteLocalHost(bool is_muted, const std::string& mediaType); void muteLocalHost(bool is_muted, const std::string& mediaType);
bool isRemoteParticipant(const std::string& uri); bool isRemoteParticipant(const std::string& uri);
void resizeRemoteParticipant(const std::string& peerURI, ParticipantInfo& remoteCell);
void mergeConfInfo(ConfInfo& newInfo, const std::string& peerURI); void mergeConfInfo(ConfInfo& newInfo, const std::string& peerURI);
private: private:
...@@ -338,7 +340,7 @@ private: ...@@ -338,7 +340,7 @@ private:
bool localModAdded_ {false}; bool localModAdded_ {false};
std::map<std::string, ConfInfo> remoteHosts_; std::map<std::string, ConfInfo> remoteHosts_;
std::string confInfo2str(const ConfInfo& confInfo); void resizeRemoteParticipants(ConfInfo& confInfo, std::string_view peerURI);
std::string_view findHostforRemoteParticipant(std::string_view uri); std::string_view findHostforRemoteParticipant(std::string_view uri);
std::shared_ptr<Call> getCallFromPeerID(std::string_view peerID); std::shared_ptr<Call> getCallFromPeerID(std::string_view peerID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment