Skip to content

Commit fd293f7

Browse files
philncadubentzen
authored andcommitted
Incoming video track renderer should rely on the track intrinsic size https://bugs.webkit.org/show_bug.cgi?id=274093
Reviewed by Xabier Rodriguez-Calvar. Pixel and display aspect ratios shouldn't be applied for WebRTC video tracks. The intrinsic size is re-used as it is. The avf MediaStream player behaves similarly. * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::updateVideoSizeAndOrientationFromCaps): * Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp: (WebCore::RealtimeIncomingVideoSourceGStreamer::ensureSizeAndFramerate): (WebCore::RealtimeIncomingVideoSourceGStreamer::dispatchSample): Canonical link: https://commits.webkit.org/278745@main
1 parent 2584afa commit fd293f7

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,8 +3595,21 @@ void MediaPlayerPrivateGStreamer::updateVideoSizeAndOrientationFromCaps(const Gs
35953595
if (m_videoSourceOrientation.usesWidthAsHeight())
35963596
originalSize = originalSize.transposedSize();
35973597

3598+
auto scopeExit = makeScopeExit([&] {
3599+
if (auto* player = m_player) {
3600+
GST_DEBUG_OBJECT(pipeline(), "Notifying sizeChanged event to upper layer");
3601+
player->sizeChanged();
3602+
}
3603+
});
3604+
35983605
GST_DEBUG_OBJECT(pipeline(), "Original video size: %dx%d", originalSize.width(), originalSize.height());
3599-
GST_DEBUG_OBJECT(pipeline(), "Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
3606+
if (isMediaStreamPlayer()) {
3607+
GST_DEBUG_OBJECT(pipeline(), "Using original MediaStream track video intrinsic size");
3608+
m_videoSize = originalSize;
3609+
return;
3610+
}
3611+
3612+
GST_DEBUG_OBJECT(pipeline(), "Applying pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
36003613

36013614
// Calculate DAR based on PAR and video size.
36023615
int displayWidth = originalSize.width() * pixelAspectRatioNumerator;
@@ -3625,7 +3638,6 @@ void MediaPlayerPrivateGStreamer::updateVideoSizeAndOrientationFromCaps(const Gs
36253638

36263639
GST_DEBUG_OBJECT(pipeline(), "Saving natural size: %" G_GUINT64_FORMAT "x%" G_GUINT64_FORMAT, width, height);
36273640
m_videoSize = FloatSize(static_cast<int>(width), static_cast<int>(height));
3628-
m_player->sizeChanged();
36293641
}
36303642

36313643
void MediaPlayerPrivateGStreamer::setCachedPosition(const MediaTime& cachedPosition) const

Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingVideoSourceGStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void RealtimeIncomingVideoSourceGStreamer::settingsDidChange(OptionSet<RealtimeM
103103
void RealtimeIncomingVideoSourceGStreamer::ensureSizeAndFramerate(const GRefPtr<GstCaps>& caps)
104104
{
105105
if (auto size = getVideoResolutionFromCaps(caps.get()))
106-
setSize({ static_cast<int>(size->width()), static_cast<int>(size->height()) });
106+
setIntrinsicSize({ static_cast<int>(size->width()), static_cast<int>(size->height()) });
107107

108108
int frameRateNumerator, frameRateDenominator;
109109
auto* structure = gst_caps_get_structure(caps.get(), 0);
@@ -122,7 +122,7 @@ void RealtimeIncomingVideoSourceGStreamer::dispatchSample(GRefPtr<GstSample>&& s
122122
auto* caps = gst_sample_get_caps(sample.get());
123123
ensureSizeAndFramerate(GRefPtr<GstCaps>(caps));
124124

125-
videoFrameAvailable(VideoFrameGStreamer::create(WTFMove(sample), size(), fromGstClockTime(GST_BUFFER_PTS(buffer))), { });
125+
videoFrameAvailable(VideoFrameGStreamer::create(WTFMove(sample), intrinsicSize(), fromGstClockTime(GST_BUFFER_PTS(buffer))), { });
126126
}
127127

128128
const GstStructure* RealtimeIncomingVideoSourceGStreamer::stats()

0 commit comments

Comments
 (0)