Skip to content

Commit

Permalink
[GStreamer] Video element keeps changing the aspect ratio randomly (w…
Browse files Browse the repository at this point in the history
…hen 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
  • Loading branch information
philn committed Dec 15, 2022
1 parent c3591d2 commit 07f6e1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Expand Up @@ -3391,18 +3391,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 @@ -3711,15 +3714,16 @@ RefPtr<VideoFrame> MediaPlayerPrivateGStreamer::videoFrameForCurrentTime()
return VideoFrameGStreamer::create(WTFMove(sample), size);
}

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 @@ -436,7 +436,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 07f6e1d

Please sign in to comment.