Fix video quality when opening from chat.

This commit is contained in:
John Preston 2019-12-23 11:10:11 +03:00
parent 621a5cc4ab
commit 8ae6156477
2 changed files with 7 additions and 10 deletions

View File

@ -339,6 +339,9 @@ void VideoTrackObject::fillRequests(not_null<Frame*> frame) const {
QSize VideoTrackObject::chooseOriginalResize() const { QSize VideoTrackObject::chooseOriginalResize() const {
auto chosen = QSize(); auto chosen = QSize();
for (const auto &[_, request] : _requests) { for (const auto &[_, request] : _requests) {
if (request.resize.isEmpty()) {
return QSize();
}
const auto byWidth = (request.resize.width() >= chosen.width()); const auto byWidth = (request.resize.width() >= chosen.width());
const auto byHeight = (request.resize.height() >= chosen.height()); const auto byHeight = (request.resize.height() >= chosen.height());
if (byWidth && byHeight) { if (byWidth && byHeight) {
@ -459,9 +462,6 @@ void VideoTrackObject::addTimelineDelay(crl::time delayed) {
if (!delayed) { if (!delayed) {
return; return;
} }
if (delayed > 1000) {
int a = 0;
}
_syncTimePoint.worldTime += delayed; _syncTimePoint.worldTime += delayed;
} }
@ -806,10 +806,6 @@ void VideoTrack::Shared::addTimelineDelay(crl::time delayed) {
} }
const auto recountCurrentFrame = [&](int counter) { const auto recountCurrentFrame = [&](int counter) {
_delay += delayed; _delay += delayed;
if (delayed > 1000) {
int a = 0;
}
//const auto next = (counter + 1) % (2 * kFramesCount); //const auto next = (counter + 1) % (2 * kFramesCount);
//const auto index = next / 2; //const auto index = next / 2;
//const auto frame = getFrame(index); //const auto frame = getFrame(index);
@ -976,14 +972,14 @@ QImage VideoTrack::frame(
const auto frame = _shared->frameForPaint(); const auto frame = _shared->frameForPaint();
const auto i = frame->prepared.find(instance); const auto i = frame->prepared.find(instance);
const auto none = (i == frame->prepared.end()); const auto none = (i == frame->prepared.end());
const auto preparedFor = none const auto preparedFor = frame->prepared.empty()
? FrameRequest::NonStrict() ? FrameRequest::NonStrict()
: i->second.request; : (none ? frame->prepared.begin() : i)->second.request;
const auto changed = !preparedFor.goodFor(request); const auto changed = !preparedFor.goodFor(request);
const auto useRequest = changed ? request : preparedFor; const auto useRequest = changed ? request : preparedFor;
if (changed) { if (changed) {
_wrapped.with([=](Implementation &unwrapped) { _wrapped.with([=](Implementation &unwrapped) {
unwrapped.updateFrameRequest(instance, request); unwrapped.updateFrameRequest(instance, useRequest);
}); });
} }
if (GoodForRequest(frame->original, _streamRotation, useRequest)) { if (GoodForRequest(frame->original, _streamRotation, useRequest)) {

View File

@ -125,6 +125,7 @@ void DownloadManagerMtproto::remove(not_null<Task*> task) {
const auto dcId = task->dcId(); const auto dcId = task->dcId();
auto &queue = _queues[dcId]; auto &queue = _queues[dcId];
queue.remove(task); queue.remove(task);
checkSendNext(dcId, queue);
} }
void DownloadManagerMtproto::resetGeneration() { void DownloadManagerMtproto::resetGeneration() {