[Spice-devel] [PATCH spice 12/12] server: Add h264 support to the GStreamer video encoder. (take 3b)

Francois Gouget fgouget at codeweavers.com
Thu Jun 11 15:28:14 PDT 2015


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

Updated so it applies after the VP8 'take 3b' patch.


diff --git a/server/gstreamer_encoder.c b/server/gstreamer_encoder.c
index c638c3e..58c4c7e 100644
--- a/server/gstreamer_encoder.c
+++ b/server/gstreamer_encoder.c
@@ -206,6 +206,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;
@@ -262,6 +265,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 latency */
+                     "intra-refresh", TRUE,
+                     "sliced-threads", TRUE,
+                     "speed-preset", 1, /* ultrafast */
+                     NULL);
+        break;
     default:
         spice_warning("unknown encoder type %d", encoder->base.codec_type);
         reset_pipeline(encoder);
@@ -601,7 +615,8 @@ GstEncoder *create_gstreamer_encoder(SpiceVideoCodecType codec_type, uint64_t st
 
     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 08623e2..a034949 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -267,12 +267,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.1.4


More information about the Spice-devel mailing list