[Spice-devel] [PATCH v5 10/20] server: Add h264 support to the GStreamer video encoder.

Francois Gouget fgouget at codeweavers.com
Thu Aug 27 12:01:15 PDT 2015


Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

Changes since take 4:
 - Tweaked the h264 options comments.

 server/gstreamer_encoder.c | 17 ++++++++++++++++-
 server/red_dispatcher.c    |  2 ++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/server/gstreamer_encoder.c b/server/gstreamer_encoder.c
index be18101..e42641b 100644
--- a/server/gstreamer_encoder.c
+++ b/server/gstreamer_encoder.c
@@ -269,6 +269,9 @@ static gboolean construct_pipeline(GstEncoder *encoder, const SpiceBitmap *bitma
     case SPICE_VIDEO_CODEC_TYPE_VP8:
         gstenc_name = "vp8enc";
         break;
+    case SPICE_VIDEO_CODEC_TYPE_H264:
+        gstenc_name = "x264enc";
+        break;
     default:
         spice_warning("unsupported codec type %d", encoder->base.codec_type);
         return FALSE;
@@ -331,6 +334,17 @@ static gboolean construct_pipeline(GstEncoder *encoder, const SpiceBitmap *bitma
                      NULL);
         break;
         }
+    case SPICE_VIDEO_CODEC_TYPE_H264:
+        g_object_set(G_OBJECT(encoder->gstenc),
+                     "bitrate", encoder->bit_rate / 1024,
+                     "byte-stream", TRUE,
+                     "aud", FALSE,
+                     "tune", 4, /* zero-frame latency */
+                     "sliced-threads", TRUE, /* zero-frame latency */
+                     "speed-preset", 1, /* ultrafast */
+                     "intra-refresh", TRUE, /* uniform compressed frame sizes */
+                     NULL);
+        break;
     default:
         spice_warning("unknown encoder type %d", encoder->base.codec_type);
         reset_pipeline(encoder);
@@ -729,7 +743,8 @@ GstEncoder *create_gstreamer_encoder(SpiceVideoCodecType codec_type,
 
     spice_assert(!cbs || (cbs && cbs->get_roundtrip_ms && cbs->get_source_fps));
     if (codec_type != SPICE_VIDEO_CODEC_TYPE_MJPEG &&
-        codec_type != SPICE_VIDEO_CODEC_TYPE_VP8) {
+        codec_type != SPICE_VIDEO_CODEC_TYPE_VP8 &&
+        codec_type != SPICE_VIDEO_CODEC_TYPE_H264) {
         spice_warning("unsupported codec type %d", codec_type);
         return NULL;
     }
diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index 105bdd3..0427725 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -268,12 +268,14 @@ static create_video_encoder_proc video_encoder_procs[] = {
 static const EnumNames video_codec_names[] = {
     {SPICE_VIDEO_CODEC_TYPE_MJPEG, "mjpeg"},
     {SPICE_VIDEO_CODEC_TYPE_VP8, "vp8"},
+    {SPICE_VIDEO_CODEC_TYPE_H264, "h264"},
     {0, NULL},
 };
 
 static const EnumNames video_cap_names[] = {
     {SPICE_DISPLAY_CAP_CODEC_MJPEG, "mjpeg"},
     {SPICE_DISPLAY_CAP_CODEC_VP8, "vp8"},
+    {SPICE_DISPLAY_CAP_CODEC_H264, "h264"},
     {0, NULL},
 };
 
-- 
2.5.0



More information about the Spice-devel mailing list