mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Count unique video senders in limit.
This commit is contained in:
parent
ab67aa28b5
commit
86a2a4d63a
2 changed files with 26 additions and 2 deletions
|
@ -1956,13 +1956,35 @@ void GroupCall::setupMediaDevices() {
|
|||
}, _lifetime);
|
||||
}
|
||||
|
||||
int GroupCall::activeVideoSendersCount() const {
|
||||
auto result = 0;
|
||||
for (const auto &[endpoint, track] : _activeVideoTracks) {
|
||||
if (endpoint.type == VideoEndpointType::Camera) {
|
||||
++result;
|
||||
} else {
|
||||
auto sharesCameraToo = false;
|
||||
for (const auto &[other, _] : _activeVideoTracks) {
|
||||
if (other.type == VideoEndpointType::Camera
|
||||
&& other.peer == endpoint.peer) {
|
||||
sharesCameraToo = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!sharesCameraToo) {
|
||||
++result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GroupCall::emitShareCameraError() {
|
||||
const auto emitError = [=](Error error) {
|
||||
emitShareCameraError(error);
|
||||
return true;
|
||||
};
|
||||
if (const auto real = lookupReal()
|
||||
; real && _activeVideoTracks.size() >= real->unmutedVideoLimit()) {
|
||||
; real && activeVideoSendersCount() >= real->unmutedVideoLimit()) {
|
||||
return emitError(Error::DisabledNoCamera);
|
||||
} else if (!videoIsWorking()) {
|
||||
return emitError(Error::DisabledNoCamera);
|
||||
|
@ -1989,7 +2011,7 @@ bool GroupCall::emitShareScreenError() {
|
|||
return true;
|
||||
};
|
||||
if (const auto real = lookupReal()
|
||||
; real && _activeVideoTracks.size() >= real->unmutedVideoLimit()) {
|
||||
; real && activeVideoSendersCount() >= real->unmutedVideoLimit()) {
|
||||
return emitError(Error::DisabledNoScreen);
|
||||
} else if (!videoIsWorking()) {
|
||||
return emitError(Error::DisabledNoScreen);
|
||||
|
|
|
@ -551,6 +551,8 @@ private:
|
|||
void markTrackPaused(const VideoEndpoint &endpoint, bool paused);
|
||||
void markTrackShown(const VideoEndpoint &endpoint, bool shown);
|
||||
|
||||
[[nodiscard]] int activeVideoSendersCount() const;
|
||||
|
||||
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
||||
|
||||
const not_null<Delegate*> _delegate;
|
||||
|
|
Loading…
Add table
Reference in a new issue