[Spice-commits] server/dcc-send.c server/gstreamer-encoder.c server/mjpeg-encoder.c server/tests server/video-encoder.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Mar 24 08:38:43 UTC 2020
server/dcc-send.c | 2 +-
server/gstreamer-encoder.c | 22 ++++++++++++----------
server/mjpeg-encoder.c | 28 +++++++++++++++-------------
server/tests/test-gst.c | 6 +++---
server/video-encoder.h | 12 ++++++------
5 files changed, 37 insertions(+), 33 deletions(-)
New commits:
commit 271dd5de41ce80a5f86882c317bbfc3d89e08ba2
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Tue Mar 24 02:34:45 2020 +0000
video-encoder: Use enumeration for encode_frame result type
Better clear the result type instead of a generic "int".
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Kevin Pouget <kpouget at redhat.com>
diff --git a/server/dcc-send.c b/server/dcc-send.c
index 4a92ce8c..909c237b 100644
--- a/server/dcc-send.c
+++ b/server/dcc-send.c
@@ -1687,7 +1687,7 @@ static bool red_marshall_stream_data(RedChannelClient *rcc,
SpiceCopy *copy;
uint32_t frame_mm_time;
int is_sized;
- int ret;
+ VideoEncodeResults ret;
spice_assert(drawable->red_drawable->type == QXL_DRAW_COPY);
diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
index 3ca04d7a..1bab1df1 100644
--- a/server/gstreamer-encoder.c
+++ b/server/gstreamer-encoder.c
@@ -1347,10 +1347,11 @@ static void unmap_and_release_memory(GstMapInfo *map, GstBuffer *buffer)
}
/* A helper for spice_gst_encoder_encode_frame() */
-static int push_raw_frame(SpiceGstEncoder *encoder,
- const SpiceBitmap *bitmap,
- const SpiceRect *src, int top_down,
- gpointer bitmap_opaque)
+static VideoEncodeResults
+push_raw_frame(SpiceGstEncoder *encoder,
+ const SpiceBitmap *bitmap,
+ const SpiceRect *src, int top_down,
+ gpointer bitmap_opaque)
{
uint32_t height = src->bottom - src->top;
// GStreamer require the stream to be 4 bytes aligned
@@ -1465,12 +1466,13 @@ static void spice_gst_encoder_destroy(VideoEncoder *video_encoder)
g_free(encoder);
}
-static int spice_gst_encoder_encode_frame(VideoEncoder *video_encoder,
- uint32_t frame_mm_time,
- const SpiceBitmap *bitmap,
- const SpiceRect *src, int top_down,
- gpointer bitmap_opaque,
- VideoBuffer **outbuf)
+static VideoEncodeResults
+spice_gst_encoder_encode_frame(VideoEncoder *video_encoder,
+ uint32_t frame_mm_time,
+ const SpiceBitmap *bitmap,
+ const SpiceRect *src, int top_down,
+ gpointer bitmap_opaque,
+ VideoBuffer **outbuf)
{
SpiceGstEncoder *encoder = (SpiceGstEncoder*)video_encoder;
g_return_val_if_fail(outbuf != NULL, VIDEO_ENCODER_FRAME_UNSUPPORTED);
diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c
index 6b658966..53efc9b9 100644
--- a/server/mjpeg-encoder.c
+++ b/server/mjpeg-encoder.c
@@ -717,11 +717,12 @@ static void mjpeg_encoder_adjust_fps(MJpegEncoder *encoder, uint64_t now)
* MJPEG_ENCODER_FRAME_ENCODE_DONE : frame encoding started. Continue with
* mjpeg_encoder_encode_scanline.
*/
-static int mjpeg_encoder_start_frame(MJpegEncoder *encoder,
- SpiceBitmapFmt format,
- const SpiceRect *src,
- MJpegVideoBuffer *buffer,
- uint32_t frame_mm_time)
+static VideoEncodeResults
+mjpeg_encoder_start_frame(MJpegEncoder *encoder,
+ SpiceBitmapFmt format,
+ const SpiceRect *src,
+ MJpegVideoBuffer *buffer,
+ uint32_t frame_mm_time)
{
uint32_t quality;
@@ -936,12 +937,13 @@ static bool encode_frame(MJpegEncoder *encoder, const SpiceRect *src,
return TRUE;
}
-static int mjpeg_encoder_encode_frame(VideoEncoder *video_encoder,
- uint32_t frame_mm_time,
- const SpiceBitmap *bitmap,
- const SpiceRect *src, int top_down,
- gpointer bitmap_opaque,
- VideoBuffer **outbuf)
+static VideoEncodeResults
+mjpeg_encoder_encode_frame(VideoEncoder *video_encoder,
+ uint32_t frame_mm_time,
+ const SpiceBitmap *bitmap,
+ const SpiceRect *src, int top_down,
+ gpointer bitmap_opaque,
+ VideoBuffer **outbuf)
{
MJpegEncoder *encoder = SPICE_CONTAINEROF(video_encoder, MJpegEncoder, base);
MJpegVideoBuffer *buffer = create_mjpeg_video_buffer();
@@ -949,8 +951,8 @@ static int mjpeg_encoder_encode_frame(VideoEncoder *video_encoder,
return VIDEO_ENCODER_FRAME_UNSUPPORTED;
}
- int ret = mjpeg_encoder_start_frame(encoder, bitmap->format, src,
- buffer, frame_mm_time);
+ VideoEncodeResults ret = mjpeg_encoder_start_frame(encoder, bitmap->format, src,
+ buffer, frame_mm_time);
if (ret == VIDEO_ENCODER_FRAME_ENCODE_DONE) {
if (encode_frame(encoder, src, bitmap, top_down)) {
buffer->base.size = mjpeg_encoder_end_frame(encoder);
diff --git a/server/tests/test-gst.c b/server/tests/test-gst.c
index 43ee4004..80e62a7e 100644
--- a/server/tests/test-gst.c
+++ b/server/tests/test-gst.c
@@ -206,9 +206,9 @@ input_frames(GstSample *sample, void *param)
TestFrame *frame = gst_to_spice_frame(sample);
// send frame to our video encoder (must be from a single thread)
- int res = video_encoder->encode_frame(video_encoder, frame_mm_time, frame->bitmap,
- &clipping_rect, top_down, frame,
- &p_outbuf);
+ VideoEncodeResults res =
+ video_encoder->encode_frame(video_encoder, frame_mm_time, frame->bitmap,
+ &clipping_rect, top_down, frame, &p_outbuf);
switch (res) {
case VIDEO_ENCODER_FRAME_ENCODE_DONE:
// save frame into queue for comparison later
diff --git a/server/video-encoder.h b/server/video-encoder.h
index 90d21312..f32544b5 100644
--- a/server/video-encoder.h
+++ b/server/video-encoder.h
@@ -42,11 +42,11 @@ struct VideoBuffer {
void (*free)(VideoBuffer *buffer);
};
-enum {
+typedef enum {
VIDEO_ENCODER_FRAME_UNSUPPORTED = -1,
VIDEO_ENCODER_FRAME_DROP,
VIDEO_ENCODER_FRAME_ENCODE_DONE,
-};
+} VideoEncodeResults;
typedef struct VideoEncoderStats {
uint64_t starting_bit_rate;
@@ -77,10 +77,10 @@ struct VideoEncoder {
* VIDEO_ENCODER_FRAME_DROP if the frame was dropped. This value can
* only happen if rate control is active.
*/
- int (*encode_frame)(VideoEncoder *encoder, uint32_t frame_mm_time,
- const SpiceBitmap *bitmap,
- const SpiceRect *src, int top_down,
- gpointer bitmap_opaque, VideoBuffer** outbuf);
+ VideoEncodeResults (*encode_frame)(VideoEncoder *encoder, uint32_t frame_mm_time,
+ const SpiceBitmap *bitmap,
+ const SpiceRect *src, int top_down,
+ gpointer bitmap_opaque, VideoBuffer** outbuf);
/*
* Bit rate control methods.
More information about the Spice-commits
mailing list