2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Play video userpics in photo change messages.

This commit is contained in:
John Preston
2020-07-03 21:44:21 +04:00
parent e363b254f6
commit f99960e1f6
7 changed files with 212 additions and 46 deletions

View File

@@ -102,6 +102,30 @@ template <typename Data>
return result;
}
template <typename Data>
void Streaming::keepAlive(
base::flat_map<not_null<Data*>, std::weak_ptr<Document>> &documents,
not_null<Data*> data) {
const auto i = documents.find(data);
if (i == end(documents)) {
return;
}
auto shared = i->second.lock();
if (!shared) {
return;
}
const auto till = crl::now() + kKeepAliveTimeout;
const auto j = _keptAlive.find(shared);
if (j != end(_keptAlive)) {
j->second = till;
} else {
_keptAlive.emplace(std::move(shared), till);
}
if (!_keptAliveTimer.isActive()) {
_keptAliveTimer.callOnce(kKeepAliveTimeout);
}
}
std::shared_ptr<Streaming::Reader> Streaming::sharedReader(
not_null<DocumentData*> document,
FileOrigin origin,
@@ -129,24 +153,11 @@ std::shared_ptr<Streaming::Document> Streaming::sharedDocument(
}
void Streaming::keepAlive(not_null<DocumentData*> document) {
const auto i = _fileDocuments.find(document);
if (i == end(_fileDocuments)) {
return;
}
auto shared = i->second.lock();
if (!shared) {
return;
}
const auto till = crl::now() + kKeepAliveTimeout;
const auto j = _keptAlive.find(shared);
if (j != end(_keptAlive)) {
j->second = till;
} else {
_keptAlive.emplace(std::move(shared), till);
}
if (!_keptAliveTimer.isActive()) {
_keptAliveTimer.callOnce(kKeepAliveTimeout);
}
keepAlive(_fileDocuments, document);
}
void Streaming::keepAlive(not_null<PhotoData*> photo) {
keepAlive(_photoDocuments, photo);
}
void Streaming::clearKeptAlive() {

View File

@@ -51,6 +51,7 @@ public:
FileOrigin origin);
void keepAlive(not_null<DocumentData*> document);
void keepAlive(not_null<PhotoData*> photo);
private:
void clearKeptAlive();
@@ -69,6 +70,11 @@ private:
not_null<Data*> data,
FileOrigin origin);
template <typename Data>
void keepAlive(
base::flat_map<not_null<Data*>, std::weak_ptr<Document>> &documents,
not_null<Data*> data);
const not_null<Session*> _owner;
base::flat_map<