Changeset 270404 in webkit


Ignore:
Timestamp:
Dec 3, 2020 1:12:34 PM (3 years ago)
Author:
aboya@igalia.com
Message:

[GStreamer] Fix video losing size at the end of the stream
https://bugs.webkit.org/show_bug.cgi?id=219493

Reviewed by Xabier Rodriguez-Calvar.

LayoutTests/imported/w3c:

Added a test reproducing the bug that gets fixed with the patch.

  • web-platform-tests/html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended-expected.txt: Added.
  • web-platform-tests/html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html: Added.
  • web-platform-tests/media/test-1s.mp4: Added.
  • web-platform-tests/media/test-1s.webm: Added.

Source/WebCore:

Our port for long had an issue where at the end of the video the
tracks would be erased, causing the video to lose its size and by
extension its aspect ratio.

In absence of a size, WebKit uses the default video size defined by
the spec of 300x150 (2:1 aspect ratio). This causes a video element
that doesn't have a size set through CSS to shrink to that size at the
end of playback, and also for black bars to appear on wider content
(e.g. 16:9 video) when watched in full screen mode.

This patch fixes the problem by not removing the tracks after an end
of stream, and instead reusing them with different pads the next time
the video is played.

Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo):
(WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio):

  • platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:

(WebCore::TrackPrivateBaseGStreamer::setPad):

  • platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r270324 r270404  
     12020-12-03  Alicia Boya García  <aboya@igalia.com>
     2
     3        [GStreamer] Fix video losing size at the end of the stream
     4        https://bugs.webkit.org/show_bug.cgi?id=219493
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Added a test reproducing the bug that gets fixed with the patch.
     9
     10        * web-platform-tests/html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended-expected.txt: Added.
     11        * web-platform-tests/html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html: Added.
     12        * web-platform-tests/media/test-1s.mp4: Added.
     13        * web-platform-tests/media/test-1s.webm: Added.
     14
    1152020-12-01  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r270403 r270404  
     12020-12-03  Alicia Boya García  <aboya@igalia.com>
     2
     3        [GStreamer] Fix video losing size at the end of the stream
     4        https://bugs.webkit.org/show_bug.cgi?id=219493
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        Our port for long had an issue where at the end of the video the
     9        tracks would be erased, causing the video to lose its size and by
     10        extension its aspect ratio.
     11
     12        In absence of a size, WebKit uses the default video size defined by
     13        the spec of 300x150 (2:1 aspect ratio). This causes a video element
     14        that doesn't have a size set through CSS to shrink to that size at the
     15        end of playback, and also for black bars to appear on wider content
     16        (e.g. 16:9 video) when watched in full screen mode.
     17
     18        This patch fixes the problem by not removing the tracks after an end
     19        of stream, and instead reusing them with different pads the next time
     20        the video is played.
     21
     22        Test: imported/w3c/web-platform-tests/html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html
     23
     24        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     25        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfVideo):
     26        (WebCore::MediaPlayerPrivateGStreamer::notifyPlayerOfAudio):
     27        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
     28        (WebCore::TrackPrivateBaseGStreamer::setPad):
     29        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
     30
    1312020-12-03  Aditya Keerthi  <akeerthi@apple.com>
    232
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r269951 r270404  
    10241024    ASSERT(m_isLegacyPlaybin || isMediaSource());
    10251025
     1026    // Ignore notifications after a EOS. We don't want the tracks to disappear when the video is finished.
     1027    if (m_isEndReached)
     1028        return;
     1029
    10261030    unsigned numTracks = 0;
    10271031    bool useMediaSource = isMediaSource();
     
    10571061            if (existingTrack) {
    10581062                existingTrack->setIndex(i);
    1059                 if (existingTrack->pad() == pad)
    1060                     continue;
     1063                // If the video has been played twice, the track is still there, but we need
     1064                // to update the pad pointer.
     1065                if (existingTrack->pad() != pad)
     1066                    existingTrack->setPad(GRefPtr(pad));
     1067                continue;
    10611068            }
    10621069        }
     
    11021109    ASSERT(m_isLegacyPlaybin || isMediaSource());
    11031110
     1111    // Ignore notifications after a EOS. We don't want the tracks to disappear when the video is finished.
     1112    if (m_isEndReached)
     1113        return;
     1114
    11041115    unsigned numTracks = 0;
    11051116    bool useMediaSource = isMediaSource();
     
    11311142            if (existingTrack) {
    11321143                existingTrack->setIndex(i);
    1133                 if (existingTrack->pad() == pad)
    1134                     continue;
     1144                // If the video has been played twice, the track is still there, but we need
     1145                // to update the pad pointer.
     1146                if (existingTrack->pad() != pad)
     1147                    existingTrack->setPad(GRefPtr(pad));
     1148                continue;
    11351149            }
    11361150        }
  • trunk/Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h

    r262695 r270404  
    5050
    5151    GstPad* pad() const { return m_pad.get(); }
     52    void setPad(GRefPtr<GstPad>&& pad) { m_pad = WTFMove(pad); }
    5253
    5354    virtual void disconnect();
Note: See TracChangeset for help on using the changeset viewer.