Skip to content

Commit

Permalink
Cherry-pick 257912@main (07f6e1d). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=246824

    [GStreamer] Video element keeps changing the aspect ratio randomly (when the orientation information is in video's metadata)
    https://bugs.webkit.org/show_bug.cgi?id=246824
    <rdar://problem/101646324>

    Reviewed by Xabier Rodriguez-Calvar.

    Emit sizeChanged notifications towards the parent player only if the video orientation actually
    changed, otherwise the continuous size re-transposition affects the visual rendering of the video
    element.

    * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
    (WebCore::MediaPlayerPrivateGStreamer::updateVideoOrientation):
    (WebCore::MediaPlayerPrivateGStreamer::setVideoSourceOrientation):

    Canonical link: https://commits.webkit.org/257912@main

Canonical link: https://commits.webkit.org/253173.313@webkitglib/2.38
  • Loading branch information
philn authored and mcatanzaro committed Dec 20, 2022
1 parent 9faa180 commit 3e9403c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -3388,18 +3388,21 @@ static ImageOrientation getVideoOrientation(const GstTagList* tagList)
void MediaPlayerPrivateGStreamer::updateVideoOrientation(const GstTagList* tagList)
{
GST_DEBUG_OBJECT(pipeline(), "Updating orientation from %" GST_PTR_FORMAT, tagList);
setVideoSourceOrientation(getVideoOrientation(tagList));
auto sizeActuallyChanged = setVideoSourceOrientation(getVideoOrientation(tagList));

if (!sizeActuallyChanged)
return;

// If the video is tagged as rotated 90 or 270 degrees, swap width and height.
if (m_videoSourceOrientation.usesWidthAsHeight())
m_videoSize = m_videoSize.transposedSize();

GST_DEBUG("Enqueuing and waiting for main-thread task to call sizeChanged()...");
GST_DEBUG_OBJECT(pipeline(), "Enqueuing and waiting for main-thread task to call sizeChanged()...");
bool sizeChangedProcessed = m_sinkTaskQueue.enqueueTaskAndWait<AbortableTaskQueue::Void>([this] {
m_player->sizeChanged();
return AbortableTaskQueue::Void();
}).has_value();
GST_DEBUG("Finished waiting for main-thread task to call sizeChanged()... %s", sizeChangedProcessed ? "sizeChanged() was called." : "task queue aborted by flush");
GST_DEBUG_OBJECT(pipeline(), "Finished waiting for main-thread task to call sizeChanged()... %s", sizeChangedProcessed ? "sizeChanged() was called." : "task queue aborted by flush");
}

void MediaPlayerPrivateGStreamer::updateVideoSizeAndOrientationFromCaps(const GstCaps* caps)
Expand Down Expand Up @@ -3750,15 +3753,16 @@ RefPtr<NativeImage> MediaPlayerPrivateGStreamer::nativeImageForCurrentTime()
}
#endif // USE(GSTREAMER_GL)

void MediaPlayerPrivateGStreamer::setVideoSourceOrientation(ImageOrientation orientation)
bool MediaPlayerPrivateGStreamer::setVideoSourceOrientation(ImageOrientation orientation)
{
if (m_videoSourceOrientation == orientation)
return;
return false;

m_videoSourceOrientation = orientation;
#if USE(TEXTURE_MAPPER_GL)
updateTextureMapperFlags();
#endif
return true;
}

#if USE(TEXTURE_MAPPER_GL)
Expand Down
Expand Up @@ -439,7 +439,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface

bool isPlayerShuttingDown() const { return m_isPlayerShuttingDown.load(); }
MediaTime maxTimeLoaded() const;
void setVideoSourceOrientation(ImageOrientation);
bool setVideoSourceOrientation(ImageOrientation);
MediaTime platformDuration() const;
bool isMuted() const;
void commitLoad();
Expand Down

0 comments on commit 3e9403c

Please sign in to comment.