mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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);
|
}, _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() {
|
bool GroupCall::emitShareCameraError() {
|
||||||
const auto emitError = [=](Error error) {
|
const auto emitError = [=](Error error) {
|
||||||
emitShareCameraError(error);
|
emitShareCameraError(error);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if (const auto real = lookupReal()
|
if (const auto real = lookupReal()
|
||||||
; real && _activeVideoTracks.size() >= real->unmutedVideoLimit()) {
|
; real && activeVideoSendersCount() >= real->unmutedVideoLimit()) {
|
||||||
return emitError(Error::DisabledNoCamera);
|
return emitError(Error::DisabledNoCamera);
|
||||||
} else if (!videoIsWorking()) {
|
} else if (!videoIsWorking()) {
|
||||||
return emitError(Error::DisabledNoCamera);
|
return emitError(Error::DisabledNoCamera);
|
||||||
|
@ -1989,7 +2011,7 @@ bool GroupCall::emitShareScreenError() {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
if (const auto real = lookupReal()
|
if (const auto real = lookupReal()
|
||||||
; real && _activeVideoTracks.size() >= real->unmutedVideoLimit()) {
|
; real && activeVideoSendersCount() >= real->unmutedVideoLimit()) {
|
||||||
return emitError(Error::DisabledNoScreen);
|
return emitError(Error::DisabledNoScreen);
|
||||||
} else if (!videoIsWorking()) {
|
} else if (!videoIsWorking()) {
|
||||||
return emitError(Error::DisabledNoScreen);
|
return emitError(Error::DisabledNoScreen);
|
||||||
|
|
|
@ -551,6 +551,8 @@ private:
|
||||||
void markTrackPaused(const VideoEndpoint &endpoint, bool paused);
|
void markTrackPaused(const VideoEndpoint &endpoint, bool paused);
|
||||||
void markTrackShown(const VideoEndpoint &endpoint, bool shown);
|
void markTrackShown(const VideoEndpoint &endpoint, bool shown);
|
||||||
|
|
||||||
|
[[nodiscard]] int activeVideoSendersCount() const;
|
||||||
|
|
||||||
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
||||||
|
|
||||||
const not_null<Delegate*> _delegate;
|
const not_null<Delegate*> _delegate;
|
||||||
|
|
Loading…
Add table
Reference in a new issue