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