mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Toggle wide mode only when videos with frames.
This commit is contained in:
parent
aaad250a77
commit
e50a7a2e42
4 changed files with 37 additions and 14 deletions
|
@ -496,6 +496,14 @@ void GroupCall::toggleScreenSharing(std::optional<QString> uniqueId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GroupCall::hasVideoWithFrames() const {
|
||||||
|
return _hasVideoWithFrames.current();
|
||||||
|
}
|
||||||
|
|
||||||
|
rpl::producer<bool> GroupCall::hasVideoWithFramesValue() const {
|
||||||
|
return _hasVideoWithFrames.value();
|
||||||
|
}
|
||||||
|
|
||||||
void GroupCall::setScheduledDate(TimeId date) {
|
void GroupCall::setScheduledDate(TimeId date) {
|
||||||
const auto was = _scheduleDate;
|
const auto was = _scheduleDate;
|
||||||
_scheduleDate = date;
|
_scheduleDate = date;
|
||||||
|
@ -801,6 +809,7 @@ void GroupCall::markEndpointActive(VideoEndpoint endpoint, bool active) {
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto hasVideoWithFrames = _hasVideoWithFrames.current();
|
||||||
if (active) {
|
if (active) {
|
||||||
const auto i = _activeVideoTracks.emplace(
|
const auto i = _activeVideoTracks.emplace(
|
||||||
endpoint,
|
endpoint,
|
||||||
|
@ -810,15 +819,33 @@ void GroupCall::markEndpointActive(VideoEndpoint endpoint, bool active) {
|
||||||
_requireARGB32),
|
_requireARGB32),
|
||||||
.peer = endpoint.peer,
|
.peer = endpoint.peer,
|
||||||
}).first;
|
}).first;
|
||||||
addVideoOutput(i->first.id, { i->second.track->sink() });
|
const auto track = i->second.track.get();
|
||||||
|
track->renderNextFrame(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
if (!track->frameSize().isEmpty()) {
|
||||||
|
_hasVideoWithFrames = true;
|
||||||
|
}
|
||||||
|
}, i->second.lifetime);
|
||||||
|
if (!track->frameSize().isEmpty()) {
|
||||||
|
hasVideoWithFrames = true;
|
||||||
|
}
|
||||||
|
addVideoOutput(i->first.id, { track->sink() });
|
||||||
} else {
|
} else {
|
||||||
if (_videoEndpointPinned.current() == endpoint) {
|
if (_videoEndpointPinned.current() == endpoint) {
|
||||||
_videoEndpointPinned = VideoEndpoint();
|
_videoEndpointPinned = VideoEndpoint();
|
||||||
}
|
}
|
||||||
_activeVideoTracks.erase(i);
|
_activeVideoTracks.erase(i);
|
||||||
|
hasVideoWithFrames = false;
|
||||||
|
for (const auto &[endpoint, track] : _activeVideoTracks) {
|
||||||
|
if (!track.track->frameSize().isEmpty()) {
|
||||||
|
hasVideoWithFrames = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateRequestedVideoChannelsDelayed();
|
updateRequestedVideoChannelsDelayed();
|
||||||
_videoStreamActiveUpdates.fire(std::move(endpoint));
|
_videoStreamActiveUpdates.fire(std::move(endpoint));
|
||||||
|
_hasVideoWithFrames = hasVideoWithFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::rejoin() {
|
void GroupCall::rejoin() {
|
||||||
|
@ -1515,11 +1542,9 @@ void GroupCall::setupMediaDevices() {
|
||||||
void GroupCall::ensureOutgoingVideo() {
|
void GroupCall::ensureOutgoingVideo() {
|
||||||
Expects(_id != 0);
|
Expects(_id != 0);
|
||||||
|
|
||||||
if (_videoInited) {
|
if (_cameraOutgoing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_videoInited = true;
|
|
||||||
|
|
||||||
_cameraOutgoing = std::make_unique<Webrtc::VideoTrack>(
|
_cameraOutgoing = std::make_unique<Webrtc::VideoTrack>(
|
||||||
Webrtc::VideoState::Inactive,
|
Webrtc::VideoState::Inactive,
|
||||||
_requireARGB32);
|
_requireARGB32);
|
||||||
|
|
|
@ -297,13 +297,9 @@ public:
|
||||||
return _videoEndpointPinned.value();
|
return _videoEndpointPinned.value();
|
||||||
}
|
}
|
||||||
struct VideoTrack {
|
struct VideoTrack {
|
||||||
//VideoTrack();
|
|
||||||
//VideoTrack(VideoTrack &&other);
|
|
||||||
//VideoTrack &operator=(VideoTrack &&other);
|
|
||||||
//~VideoTrack();
|
|
||||||
|
|
||||||
std::unique_ptr<Webrtc::VideoTrack> track;
|
std::unique_ptr<Webrtc::VideoTrack> track;
|
||||||
PeerData *peer = nullptr;
|
PeerData *peer = nullptr;
|
||||||
|
rpl::lifetime lifetime;
|
||||||
Group::VideoQuality quality = Group::VideoQuality();
|
Group::VideoQuality quality = Group::VideoQuality();
|
||||||
|
|
||||||
[[nodiscard]] explicit operator bool() const {
|
[[nodiscard]] explicit operator bool() const {
|
||||||
|
@ -342,6 +338,8 @@ public:
|
||||||
[[nodiscard]] QString screenSharingDeviceId() const;
|
[[nodiscard]] QString screenSharingDeviceId() const;
|
||||||
void toggleVideo(bool active);
|
void toggleVideo(bool active);
|
||||||
void toggleScreenSharing(std::optional<QString> uniqueId);
|
void toggleScreenSharing(std::optional<QString> uniqueId);
|
||||||
|
[[nodiscard]] bool hasVideoWithFrames() const;
|
||||||
|
[[nodiscard]] rpl::producer<bool> hasVideoWithFramesValue() const;
|
||||||
|
|
||||||
void toggleMute(const Group::MuteRequest &data);
|
void toggleMute(const Group::MuteRequest &data);
|
||||||
void changeVolume(const Group::VolumeRequest &data);
|
void changeVolume(const Group::VolumeRequest &data);
|
||||||
|
@ -531,13 +529,13 @@ private:
|
||||||
rpl::variable<bool> _isSharingScreen = false;
|
rpl::variable<bool> _isSharingScreen = false;
|
||||||
QString _screenDeviceId;
|
QString _screenDeviceId;
|
||||||
|
|
||||||
bool _videoInited = false;
|
|
||||||
bool _requireARGB32 = true;
|
bool _requireARGB32 = true;
|
||||||
|
|
||||||
rpl::event_stream<LevelUpdate> _levelUpdates;
|
rpl::event_stream<LevelUpdate> _levelUpdates;
|
||||||
rpl::event_stream<VideoEndpoint> _videoStreamActiveUpdates;
|
rpl::event_stream<VideoEndpoint> _videoStreamActiveUpdates;
|
||||||
base::flat_map<VideoEndpoint, VideoTrack> _activeVideoTracks;
|
base::flat_map<VideoEndpoint, VideoTrack> _activeVideoTracks;
|
||||||
rpl::variable<VideoEndpoint> _videoEndpointPinned;
|
rpl::variable<VideoEndpoint> _videoEndpointPinned;
|
||||||
|
rpl::variable<bool> _hasVideoWithFrames = false;
|
||||||
base::flat_map<uint32, Data::LastSpokeTimes> _lastSpoke;
|
base::flat_map<uint32, Data::LastSpokeTimes> _lastSpoke;
|
||||||
rpl::event_stream<Group::RejoinEvent> _rejoinEvents;
|
rpl::event_stream<Group::RejoinEvent> _rejoinEvents;
|
||||||
rpl::event_stream<> _allowedToSpeakNotifications;
|
rpl::event_stream<> _allowedToSpeakNotifications;
|
||||||
|
|
|
@ -400,7 +400,6 @@ Panel::Panel(not_null<GroupCall*> call)
|
||||||
st::groupCallTitle))
|
st::groupCallTitle))
|
||||||
#endif // !Q_OS_MAC
|
#endif // !Q_OS_MAC
|
||||||
, _viewport(std::make_unique<Viewport>(widget(), _mode.current()))
|
, _viewport(std::make_unique<Viewport>(widget(), _mode.current()))
|
||||||
, _videoMode(true) // #TODO calls
|
|
||||||
, _mute(std::make_unique<Ui::CallMuteButton>(
|
, _mute(std::make_unique<Ui::CallMuteButton>(
|
||||||
widget(),
|
widget(),
|
||||||
st::callMuteButton,
|
st::callMuteButton,
|
||||||
|
@ -556,7 +555,9 @@ void Panel::initWindow() {
|
||||||
: Flag::None;
|
: Flag::None;
|
||||||
});
|
});
|
||||||
|
|
||||||
_call->videoCallValue(
|
rpl::combine(
|
||||||
|
_call->hasVideoWithFramesValue(),
|
||||||
|
_call->videoCallValue()
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
updateMode();
|
updateMode();
|
||||||
}, _window->lifetime());
|
}, _window->lifetime());
|
||||||
|
@ -1656,7 +1657,7 @@ bool Panel::updateMode() {
|
||||||
if (!_viewport) {
|
if (!_viewport) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto wide = _call->videoCall()
|
const auto wide = _call->hasVideoWithFrames()
|
||||||
&& (widget()->width() >= st::groupCallWideModeWidthMin);
|
&& (widget()->width() >= st::groupCallWideModeWidthMin);
|
||||||
const auto mode = wide ? PanelMode::Wide : PanelMode::Default;
|
const auto mode = wide ? PanelMode::Wide : PanelMode::Default;
|
||||||
if (_mode.current() == mode) {
|
if (_mode.current() == mode) {
|
||||||
|
|
|
@ -162,7 +162,6 @@ private:
|
||||||
std::shared_ptr<Ui::GroupCallScheduledLeft> _countdownData;
|
std::shared_ptr<Ui::GroupCallScheduledLeft> _countdownData;
|
||||||
object_ptr<Ui::FlatLabel> _startsWhen = { nullptr };
|
object_ptr<Ui::FlatLabel> _startsWhen = { nullptr };
|
||||||
ChooseJoinAsProcess _joinAsProcess;
|
ChooseJoinAsProcess _joinAsProcess;
|
||||||
rpl::variable<bool> _videoMode;
|
|
||||||
std::optional<QRect> _lastSmallGeometry;
|
std::optional<QRect> _lastSmallGeometry;
|
||||||
std::optional<QRect> _lastLargeGeometry;
|
std::optional<QRect> _lastLargeGeometry;
|
||||||
bool _lastLargeMaximized = false;
|
bool _lastLargeMaximized = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue