[Spice-devel] [spice v9 09/24] server: Add h264 support to the GStreamer video encoder
Francois Gouget
fgouget at codeweavers.com
Mon Jan 18 03:05:06 PST 2016
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
server/gstreamer-encoder.c | 17 ++++++++++++++++-
server/reds.c | 2 ++
server/video-encoder.h | 2 +-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
index 11be91b..fe07852 100644
--- a/server/gstreamer-encoder.c
+++ b/server/gstreamer-encoder.c
@@ -231,6 +231,9 @@ static gboolean create_pipeline(SpiceGstEncoder *encoder)
case SPICE_VIDEO_CODEC_TYPE_VP8:
gstenc_name = "vp8enc";
break;
+ case SPICE_VIDEO_CODEC_TYPE_H264:
+ gstenc_name = "x264enc";
+ break;
default:
/* gstreamer_encoder_new() should have rejected this codec type */
spice_warning("unsupported codec type %d", encoder->base.codec_type);
@@ -296,6 +299,17 @@ static gboolean configure_pipeline(SpiceGstEncoder *encoder,
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:
/* gstreamer_encoder_new() should have rejected this codec type */
spice_warning("unknown encoder type %d", encoder->base.codec_type);
@@ -700,7 +714,8 @@ VideoEncoder *gstreamer_encoder_new(SpiceVideoCodecType codec_type,
void *cbs_opaque)
{
spice_return_val_if_fail(codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG ||
- codec_type == SPICE_VIDEO_CODEC_TYPE_VP8, NULL);
+ codec_type == SPICE_VIDEO_CODEC_TYPE_VP8 ||
+ codec_type == SPICE_VIDEO_CODEC_TYPE_H264, NULL);
GError *err = NULL;
if (!gst_init_check(NULL, NULL, &err)) {
diff --git a/server/reds.c b/server/reds.c
index a5f600c..18d8bb1 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3494,12 +3494,14 @@ static new_video_encoder_t 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},
};
diff --git a/server/video-encoder.h b/server/video-encoder.h
index db520eb..edfb392 100644
--- a/server/video-encoder.h
+++ b/server/video-encoder.h
@@ -193,6 +193,6 @@ VideoEncoder* gstreamer_encoder_new(SpiceVideoCodecType codec_type,
void *cbs_opaque);
#endif
-#define VIDEO_ENCODER_DEFAULT_PREFERENCE "spice:mjpeg;gstreamer:mjpeg;gstreamer:vp8"
+#define VIDEO_ENCODER_DEFAULT_PREFERENCE "spice:mjpeg;gstreamer:mjpeg;gstreamer:h264;gstreamer:vp8"
#endif
--
2.6.4
More information about the Spice-devel
mailing list