Title: [237865] trunk/Source/WebCore
Revision
237865
Author
commit-qu...@webkit.org
Date
2018-11-06 07:54:34 -0800 (Tue, 06 Nov 2018)

Log Message

[GStreamer][WebRTC] Handle setting max number of frame between keyframes
https://bugs.webkit.org/show_bug.cgi?id=190682

Patch by Thibault Saunier <tsaun...@igalia.com> on 2018-11-06
Reviewed by Philippe Normand.

That has been manually checked.

* platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:
(gst_webrtc_video_encoder_get_property):
(gst_webrtc_video_encoder_set_property):
(register_known_encoder):
(gst_webrtc_video_encoder_class_init):
* platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
(WebCore::GStreamerVideoEncoder::InitEncode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (237864 => 237865)


--- trunk/Source/WebCore/ChangeLog	2018-11-06 15:46:13 UTC (rev 237864)
+++ trunk/Source/WebCore/ChangeLog	2018-11-06 15:54:34 UTC (rev 237865)
@@ -1,3 +1,20 @@
+2018-11-06  Thibault Saunier  <tsaun...@igalia.com>
+
+        [GStreamer][WebRTC] Handle setting max number of frame between keyframes
+        https://bugs.webkit.org/show_bug.cgi?id=190682
+
+        Reviewed by Philippe Normand.
+
+        That has been manually checked.
+
+        * platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp:
+        (gst_webrtc_video_encoder_get_property):
+        (gst_webrtc_video_encoder_set_property):
+        (register_known_encoder):
+        (gst_webrtc_video_encoder_class_init):
+        * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
+        (WebCore::GStreamerVideoEncoder::InitEncode):
+
 2018-11-03  Alex Christensen  <achristen...@webkit.org>
 
         [Mac] Implement safe browsing in WebKit

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp (237864 => 237865)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp	2018-11-06 15:46:13 UTC (rev 237864)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoder.cpp	2018-11-06 15:54:34 UTC (rev 237865)
@@ -54,6 +54,7 @@
   SetBitrateFunc setBitrate;
   SetupEncoder setupEncoder;
   const gchar *bitrate_propname;
+  const gchar *keyframe_interval_propname;
 } EncoderDefinition;
 
 typedef enum
@@ -74,6 +75,7 @@
   NULL,
   NULL,
   NULL,
+  NULL,
 };
 
 typedef struct
@@ -97,6 +99,7 @@
   PROP_FORMAT,
   PROP_ENCODER,
   PROP_BITRATE,
+  PROP_KEYFRAME_INTERVAL,
   N_PROPS
 };
 
@@ -126,6 +129,11 @@
     case PROP_BITRATE:
       g_value_set_uint (value, priv->bitrate);
       break;
+    case PROP_KEYFRAME_INTERVAL:
+      if (priv->encoder)
+        g_object_get_property (G_OBJECT (priv->encoder),
+            encoders[priv->encoderId].keyframe_interval_propname, value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   }
@@ -212,6 +220,7 @@
     guint prop_id, const GValue * value, GParamSpec * pspec)
 {
   GstWebrtcVideoEncoder *self = GST_WEBRTC_VIDEO_ENCODER (object);
+  GstWebrtcVideoEncoderPrivate *priv = PRIV (self);
 
   switch (prop_id) {
     case PROP_FORMAT:
@@ -220,6 +229,13 @@
     case PROP_BITRATE:
       gst_webrtc_video_encoder_set_bitrate (self, g_value_get_uint (value));
       break;
+    case PROP_KEYFRAME_INTERVAL:
+      if (priv->encoder)
+        g_object_set (priv->encoder,
+            encoders[priv->encoderId].keyframe_interval_propname,
+            g_value_get_uint (value), NULL);
+
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
   }
@@ -229,7 +245,7 @@
 register_known_encoder (EncoderId encId, const gchar * name,
     const gchar * parser_name, const gchar * caps, const gchar * encoded_format,
     SetupEncoder setupEncoder, const gchar * bitrate_propname,
-    SetBitrateFunc setBitrate)
+    SetBitrateFunc setBitrate, const gchar * keyframe_interval_propname)
 {
   GstPluginFeature *feature =
       gst_registry_lookup_feature (gst_registry_get (), name);
@@ -252,6 +268,7 @@
   encoders[encId].setupEncoder = setupEncoder;
   encoders[encId].bitrate_propname = bitrate_propname;
   encoders[encId].setBitrate = setBitrate;
+  encoders[encId].keyframe_interval_propname = keyframe_interval_propname;
 }
 
 static void
@@ -314,15 +331,22 @@
           (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
               G_PARAM_CONSTRUCT)));
 
+  g_object_class_install_property (object_class, PROP_KEYFRAME_INTERVAL,
+      g_param_spec_uint ("keyframe-interval", "Keyframe interval",
+          "The interval between keyframes", 0, G_MAXINT, 0,
+          (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+              G_PARAM_CONSTRUCT)));
+
   register_known_encoder (ENCODER_X264, "x264enc", "h264parse", "video/x-h264",
       "video/x-h264,alignment=au,stream-format=byte-stream,profile=""
-      setup_x264enc, "bitrate", set_bitrate_kbit_per_sec);
+      setup_x264enc, "bitrate", set_bitrate_kbit_per_sec, "key-int-max");
   register_known_encoder (ENCODER_OPENH264, "openh264enc", "h264parse",
       "video/x-h264",
       "video/x-h264,alignment=au,stream-format=byte-stream,profile=""
-      setup_openh264enc, "bitrate", set_bitrate_kbit_per_sec);
+      setup_openh264enc, "bitrate", set_bitrate_kbit_per_sec, "gop-size");
   register_known_encoder (ENCODER_VP8, "vp8enc", NULL, "video/x-vp8", NULL,
-      setup_vp8enc, "target-bitrate", set_bitrate_bit_per_sec);
+      setup_vp8enc, "target-bitrate", set_bitrate_bit_per_sec,
+      "keyframe-max-dist");
 }
 
 static void

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp (237864 => 237865)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp	2018-11-06 15:46:13 UTC (rev 237864)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp	2018-11-06 15:54:34 UTC (rev 237865)
@@ -131,6 +131,8 @@
         ASSERT(encoder);
         m_encoder = encoder.get();
 
+        g_object_set(m_encoder, "keyframe-interval", KeyframeInterval(codecSettings), nullptr);
+
         m_src = makeElement("appsrc");
         g_object_set(m_src, "is-live", true, "format", GST_FORMAT_TIME, nullptr);
 
@@ -375,6 +377,7 @@
     }
 
     virtual const gchar* Name() = 0;
+    virtual int KeyframeInterval(const webrtc::VideoCodec* codecSettings) = 0;
 
     void SetRestrictionCaps(GRefPtr<GstCaps> caps)
     {
@@ -421,6 +424,11 @@
             packetizationMode = webrtc::H264PacketizationMode::NonInterleaved;
     }
 
+    int KeyframeInterval(const webrtc::VideoCodec* codecSettings) final
+    {
+        return codecSettings->H264().keyFrameInterval;
+    }
+
     // FIXME - MT. safety!
     void Fragmentize(webrtc::EncodedImage* encodedImage, std::unique_ptr<uint8_t[]>* encodedImageBuffer, size_t *bufferSize,
         GstBuffer* gstbuffer, webrtc::RTPFragmentationHeader* fragmentationHeader) final
@@ -508,6 +516,11 @@
     const gchar* Name() final { return cricket::kVp8CodecName; }
     webrtc::VideoCodecType CodecType() final { return webrtc::kVideoCodecVP8; }
 
+    int KeyframeInterval(const webrtc::VideoCodec* codecSettings) final
+    {
+        return codecSettings->VP8().keyFrameInterval;
+    }
+
     void PopulateCodecSpecific(webrtc::CodecSpecificInfo* codecSpecifiInfos, GstBuffer* buffer) final
     {
         codecSpecifiInfos->codecType = webrtc::kVideoCodecVP8;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to