Title: [258832] trunk/Source/WebCore
Revision
258832
Author
[email protected]
Date
2020-03-23 04:03:58 -0700 (Mon, 23 Mar 2020)

Log Message

[GStreamer] Fail gracefully in the absence of a WebVTT encoder.
https://bugs.webkit.org/show_bug.cgi?id=209290

Reviewed by Philippe Normand.

Covered by existing tests.

* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::initializeGStreamer): Gets rid of "plugin not found"
errors. It's not an error to have potentially broken AAC decoders,
but it's nice to give a clear warning.
* platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
(webkit_text_combiner_class_init):
(webkitTextCombinerNew): Check for the "subenc" *plugin*. This
check indirectly tells us the "webvttenc" *element* will exist.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258831 => 258832)


--- trunk/Source/WebCore/ChangeLog	2020-03-23 10:57:14 UTC (rev 258831)
+++ trunk/Source/WebCore/ChangeLog	2020-03-23 11:03:58 UTC (rev 258832)
@@ -1,3 +1,21 @@
+2020-03-23  Charlie Turner  <[email protected]>
+
+        [GStreamer] Fail gracefully in the absence of a WebVTT encoder.
+        https://bugs.webkit.org/show_bug.cgi?id=209290
+
+        Reviewed by Philippe Normand.
+
+        Covered by existing tests.
+
+        * platform/graphics/gstreamer/GStreamerCommon.cpp:
+        (WebCore::initializeGStreamer): Gets rid of "plugin not found"
+        errors. It's not an error to have potentially broken AAC decoders,
+        but it's nice to give a clear warning.
+        * platform/graphics/gstreamer/TextCombinerGStreamer.cpp:
+        (webkit_text_combiner_class_init):
+        (webkitTextCombinerNew): Check for the "subenc" *plugin*. This
+        check indirectly tells us the "webvttenc" *element* will exist.
+
 2020-03-23  Carlos Garcia Campos  <[email protected]>
 
         [WPE] AsyncScrolling: horizontal scrolling is inverted

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (258831 => 258832)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2020-03-23 10:57:14 UTC (rev 258831)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2020-03-23 11:03:58 UTC (rev 258832)
@@ -258,18 +258,18 @@
         // If the FDK-AAC decoder is available, promote it and downrank the
         // libav AAC decoders, due to their broken LC support, as reported in:
         // https://ffmpeg.org/pipermail/ffmpeg-devel/2019-July/247063.html
-        GRefPtr<GstElement> aacDecoder = gst_element_factory_make("fdkaacdec", nullptr);
-        if (aacDecoder) {
-            GstElementFactory* factory = gst_element_get_factory(aacDecoder.get());
-            gst_plugin_feature_set_rank(GST_PLUGIN_FEATURE_CAST(factory), GST_RANK_PRIMARY);
+        GRefPtr<GstElementFactory> elementFactory = adoptGRef(gst_element_factory_find("fdkaacdec"));
+        if (elementFactory) {
+            gst_plugin_feature_set_rank(GST_PLUGIN_FEATURE_CAST(elementFactory.get()), GST_RANK_PRIMARY);
 
             const char* const elementNames[] = {"avdec_aac", "avdec_aac_fixed", "avdec_aac_latm"};
             for (unsigned i = 0; i < G_N_ELEMENTS(elementNames); i++) {
-                GRefPtr<GstElement> avAACDecoder = gst_element_factory_make(elementNames[i], nullptr);
-                if (avAACDecoder)
-                    gst_plugin_feature_set_rank(GST_PLUGIN_FEATURE_CAST(gst_element_get_factory(avAACDecoder.get())), GST_RANK_MARGINAL);
+                GRefPtr<GstElementFactory> avAACDecoderFactory = adoptGRef(gst_element_factory_find(elementNames[i]));
+                if (avAACDecoderFactory)
+                    gst_plugin_feature_set_rank(GST_PLUGIN_FEATURE_CAST(avAACDecoderFactory.get()), GST_RANK_MARGINAL);
             }
-        }
+        } else
+            WTFLogAlways("WARNING: You might have broken LC support in your AAC decoders, consider installing fdkaacdec");
 
 #endif
     });

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp (258831 => 258832)


--- trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp	2020-03-23 10:57:14 UTC (rev 258831)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/TextCombinerGStreamer.cpp	2020-03-23 11:03:58 UTC (rev 258832)
@@ -273,6 +273,7 @@
         GST_DEBUG_FUNCPTR(webkitTextCombinerReleasePad);
 
     GRefPtr<GstElementFactory> webVTTEncFactory = adoptGRef(gst_element_factory_find("webvttenc"));
+    ASSERT(webVTTEncFactory);
     gst_object_unref(gst_plugin_feature_load(GST_PLUGIN_FEATURE(webVTTEncFactory.get())));
     webVTTEncType = gst_element_factory_get_element_type(webVTTEncFactory.get());
     ASSERT(webVTTEncType);
@@ -292,6 +293,12 @@
 
 GstElement* webkitTextCombinerNew()
 {
+    // The combiner relies on webvttenc, fail early if it's not there.
+    if (!WebCore::isGStreamerPluginAvailable("subenc")) {
+        WTFLogAlways("WebKit wasn't able to find a WebVTT encoder. Not continuing without platform support for subtitles.");
+        return nullptr;
+    }
+
     return GST_ELEMENT(g_object_new(WEBKIT_TYPE_TEXT_COMBINER, nullptr));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to