@@ -1181,7 +1181,9 @@ QSize OverlayWidget::videoSize() const {
11811181 Expects (videoShown ());
11821182
11831183 const auto use = (_document && _chosenQuality != _document)
1184- ? _document->dimensions
1184+ // get dimentions using the selected quality
1185+ // not the original
1186+ ? _chosenQuality->dimensions
11851187 : _streamed->instance .info ().video .size ;
11861188 return flipSizeByRotation (use);
11871189}
@@ -4265,8 +4267,22 @@ void OverlayWidget::initStreamingThumbnail() {
42654267void OverlayWidget::streamingReady (Streaming::Information &&info) {
42664268 markStreamedReady ();
42674269 if (videoShown ()) {
4270+ if (_document && _streamed && _streamed->ready ) {
4271+ const auto targetDocument = _chosenQuality ? _chosenQuality : _document;
4272+ if (const auto video = targetDocument->video ()) {
4273+ video->realVideoSize = info.video .realSize ;
4274+ }
4275+ }
42684276 applyVideoSize ();
42694277 _streamedQualityChangeFrame = QImage ();
4278+ if (_streamed && _streamed->controls ) {
4279+ const auto weak = base::make_weak (_widget);
4280+ crl::on_main (weak, [=] {
4281+ if (_streamed && _streamed->controls ) {
4282+ _streamed->controls ->updateSpeedToggleQuality ();
4283+ }
4284+ });
4285+ }
42704286 } else {
42714287 updateContentRect ();
42724288 }
@@ -4659,12 +4675,16 @@ void OverlayWidget::restartAtSeekPosition(crl::time position) {
46594675 }
46604676 const auto overrideDuration = _stories
46614677 || (_chosenQuality && _chosenQuality != _document);
4678+ const auto durationDocument = (_chosenQuality && _chosenQuality != _document)
4679+ ? _chosenQuality
4680+ : _document;
4681+
46624682 auto options = Streaming::PlaybackOptions{
46634683 .position = position,
46644684 .durationOverride = ((overrideDuration
4665- && _document
4666- && _document ->hasDuration ())
4667- ? _document ->duration ()
4685+ && durationDocument
4686+ && durationDocument ->hasDuration ())
4687+ ? durationDocument ->duration ()
46684688 : crl::time (0 )),
46694689 .hwAllowed = Core::App ().settings ().hardwareAcceleratedVideo (),
46704690 .seekable = !_stories,
@@ -4769,21 +4789,30 @@ std::vector<int> OverlayWidget::playbackControlsQualities() {
47694789 }
47704790 auto result = std::vector<int >();
47714791 result.reserve (list.size ());
4792+ auto seen = std::vector<int >();
47724793 for (const auto &quality : list) {
4773- result.push_back (quality->resolveVideoQuality ());
4794+ const auto res = quality->resolveVideoQuality ();
4795+ const auto value = (quality == _document)
4796+ ? (res + Media::kVideoQualityOriginalOffset )
4797+ : res;
4798+ if (std::find (seen.begin (), seen.end (), value) == seen.end ()) {
4799+ result.push_back (value);
4800+ seen.push_back (value);
4801+ }
47744802 }
47754803 return result;
47764804}
47774805
47784806VideoQuality OverlayWidget::playbackControlsCurrentQuality () {
4779- return _chosenQuality
4780- ? VideoQuality{
4781- .manual = _quality.manual ,
4782- .height = uint32 (_chosenQuality->resolveVideoQuality ()),
4783- }
4784- : _quality;
4807+ if (!_chosenQuality) {
4808+ return _quality;
4809+ }
4810+ auto height = uint32 (_chosenQuality->resolveVideoQuality ());
4811+ if (_chosenQuality == _document) {
4812+ height += Media::kVideoQualityOriginalOffset ;
4813+ }
4814+ return { .manual = _quality.manual , .height = height };
47854815}
4786-
47874816void OverlayWidget::playbackControlsQualityChanged (int quality) {
47884817 applyVideoQuality ({
47894818 .manual = (quality > 0 ),
@@ -5085,6 +5114,7 @@ void OverlayWidget::updatePlaybackState() {
50855114 _streamedPosition = state.position ;
50865115 if (_streamed->controls ) {
50875116 _streamed->controls ->updatePlayback (state);
5117+ _streamed->controls ->updateSpeedToggleQuality ();
50885118 _touchbarTrackState.fire_copy (state);
50895119 updatePowerSaveBlocker (state);
50905120 }
0 commit comments