[GStreamer][WebRTC]: Use codec setting video height/width as fallback
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 15:28:08 +0000 (15:28 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 15:28:08 +0000 (15:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195675

Patch by Thibault Saunier <tsaunier@igalia.com> on 2019-03-13
Reviewed by Philippe Normand.

In some cases the frame height and width is not set (not sure why/ in
what conditions but it happens) so make sure to get the information from
the VideoCodec when configuring the encoder.

* platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp:
(WebCore::GStreamerVideoDecoder::GStreamerVideoDecoder):
(WebCore::GStreamerVideoDecoder::GetCapsForFrame):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242881 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp

index 3d45c3a..79372c4 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-13  Thibault Saunier  <tsaunier@igalia.com>
+
+        [GStreamer][WebRTC]: Use codec setting video height/width as fallback
+        https://bugs.webkit.org/show_bug.cgi?id=195675
+
+        Reviewed by Philippe Normand.
+
+        In some cases the frame height and width is not set (not sure why/ in
+        what conditions but it happens) so make sure to get the information from
+        the VideoCodec when configuring the encoder.
+
+        * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp:
+        (WebCore::GStreamerVideoDecoder::GStreamerVideoDecoder):
+        (WebCore::GStreamerVideoDecoder::GetCapsForFrame):
+
 2019-03-13  Miguel Gomez  <magomez@igalia.com>
 
         [CoordinatedGraphics] Null dereference in CoordinatedGraphicsLayer::setCoordinatorIncludingSubLayersIfNeeded
index 98d0502..9d17a11 100644 (file)
@@ -54,6 +54,8 @@ class GStreamerVideoDecoder : public webrtc::VideoDecoder {
 public:
     GStreamerVideoDecoder()
         : m_pictureId(0)
+        , m_width(0)
+        , m_height(0)
         , m_firstBufferPts(GST_CLOCK_TIME_NONE)
         , m_firstBufferDts(GST_CLOCK_TIME_NONE)
     {
@@ -80,13 +82,18 @@ public:
         return gst_element_factory_make(factoryName, name.get());
     }
 
-    int32_t InitDecode(const webrtc::VideoCodec*, int32_t) override
+    int32_t InitDecode(const webrtc::VideoCodec* codecSettings, int32_t) override
     {
         m_src = makeElement("appsrc");
 
         auto capsfilter = CreateFilter();
         auto decoder = makeElement("decodebin");
 
+        if (codecSettings) {
+            m_width = codecSettings->width;
+            m_height = codecSettings->height;
+        }
+
         // Make the decoder output "parsed" frames only and let the main decodebin
         // do the real decoding. This allows us to have optimized decoding/rendering
         // happening in the main pipeline.
@@ -193,8 +200,8 @@ public:
     {
         if (!m_caps) {
             m_caps = adoptGRef(gst_caps_new_simple(Caps(),
-                "width", G_TYPE_INT, image._encodedWidth,
-                "height", G_TYPE_INT, image._encodedHeight,
+                "width", G_TYPE_INT, image._encodedWidth ? image._encodedWidth : m_width,
+                "height", G_TYPE_INT, image._encodedHeight ? image._encodedHeight : m_height,
                 nullptr));
         }
 
@@ -269,6 +276,8 @@ public:
 protected:
     GRefPtr<GstCaps> m_caps;
     gint m_pictureId;
+    gint m_width;
+    gint m_height;
 
 private:
     static GstFlowReturn newSampleCallbackTramp(GstElement* sink, GStreamerVideoDecoder* enc)
@@ -327,10 +336,8 @@ public:
     {
         if (!m_caps) {
             m_caps = adoptGRef(gst_caps_new_simple(Caps(),
-                "width", G_TYPE_INT, image._encodedWidth,
-                "height", G_TYPE_INT, image._encodedHeight,
-                "profile", G_TYPE_STRING, m_profile ? m_profile : "baseline",
-                "stream-format", G_TYPE_STRING, "byte-stream",
+                "width", G_TYPE_INT, image._encodedWidth ? image._encodedWidth : m_width,
+                "height", G_TYPE_INT, image._encodedHeight ? image._encodedHeight : m_height,
                 "alignment", G_TYPE_STRING, "au",
                 nullptr));
         }