Skip to content

Commit fe83369

Browse files
committed
[GStreamer] Avoid crash for unexisting pad in webkitGstTraceProcessingTimeForElement
https://bugs.webkit.org/show_bug.cgi?id=258986 Reviewed by Philippe Normand. In some platforms srcPad can become null, hence crashing. Now it's protected. We also avoid the cause of the crash in the first place. * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::configureElement): * Source/WebCore/platform/graphics/gstreamer/VideoFrameMetadataGStreamer.cpp: (webkitGstTraceProcessingTimeForElement): Canonical link: https://commits.webkit.org/265902@main
1 parent 19e0c1e commit fe83369

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ void MediaPlayerPrivateGStreamer::configureElement(GstElement* element)
22462246
g_object_set(element, "use-buffering", FALSE, nullptr);
22472247

22482248
// Collect processing time metrics for video decoders and converters.
2249-
if ((classifiers.contains("Converter"_s) || classifiers.contains("Decoder"_s)) && classifiers.contains("Video"_s) && !classifiers.contains("Parser"_s))
2249+
if ((classifiers.contains("Converter"_s) || classifiers.contains("Decoder"_s)) && classifiers.contains("Video"_s) && !classifiers.contains("Parser"_s) && !classifiers.contains("Sink"_s))
22502250
webkitGstTraceProcessingTimeForElement(element);
22512251

22522252
if (classifiers.contains("Decoder"_s) && classifiers.contains("Video"_s)) {

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,25 @@ void webkitGstTraceProcessingTimeForElement(GstElement* element)
116116
GST_DEBUG_CATEGORY_INIT(webkit_video_frame_meta_debug, "webkitvideoframemeta", 0, "Video frame processing metrics");
117117
});
118118

119+
auto sinkPad = adoptGRef(gst_element_get_static_pad(element, "sink"));
120+
auto srcPad = adoptGRef(gst_element_get_static_pad(element, "src"));
121+
if (!sinkPad || !srcPad) {
122+
GST_WARNING("Can't add the processing time probes for %s", GST_OBJECT_NAME(element));
123+
ASSERT_NOT_REACHED();
124+
return;
125+
}
126+
119127
GST_DEBUG("Tracing processing time for %" GST_PTR_FORMAT, element);
120-
auto probeType = static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_BUFFER);
121128

122-
auto sinkPad = adoptGRef(gst_element_get_static_pad(element, "sink"));
129+
static auto probeType = static_cast<GstPadProbeType>(GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_BUFFER);
130+
123131
gst_pad_add_probe(sinkPad.get(), probeType, [](GstPad*, GstPadProbeInfo* info, gpointer userData) -> GstPadProbeReturn {
124132
auto [modifiedBuffer, meta] = ensureVideoFrameMetadata(GST_PAD_PROBE_INFO_BUFFER(info));
125133
GST_PAD_PROBE_INFO_DATA(info) = modifiedBuffer;
126134
meta->priv->processingTimes.set(String::fromLatin1(reinterpret_cast<char*>(userData)), std::make_pair(gst_util_get_timestamp(), GST_CLOCK_TIME_NONE));
127135
return GST_PAD_PROBE_OK;
128136
}, gst_element_get_name(element), g_free);
129137

130-
auto srcPad = adoptGRef(gst_element_get_static_pad(element, "src"));
131138
gst_pad_add_probe(srcPad.get(), probeType, [](GstPad*, GstPadProbeInfo* info, gpointer userData) -> GstPadProbeReturn {
132139
auto* meta = getInternalVideoFrameMetadata(GST_PAD_PROBE_INFO_BUFFER(info));
133140
// Some decoders (such as theoradec) do not always copy the input meta to the output frame,

0 commit comments

Comments
 (0)