diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-09-17 01:15:38 +0200 |
---|---|---|
committer | Pavel Grunt <pgrunt@redhat.com> | 2015-11-13 17:21:35 +0100 |
commit | 8cd91cf921b6f75aae9fb8985f28e2facf9abb18 (patch) | |
tree | 15ffc1f9bd2aabf61f2a22e447b031ef2d9512e4 /server/dcc-encoders.h | |
parent | 276b299e17e0dd0985113926e8a48155a6c783ae (diff) |
worker: move encoders to dcc-encoders
Diffstat (limited to 'server/dcc-encoders.h')
-rw-r--r-- | server/dcc-encoders.h | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/server/dcc-encoders.h b/server/dcc-encoders.h new file mode 100644 index 00000000..dfdda2e3 --- /dev/null +++ b/server/dcc-encoders.h @@ -0,0 +1,145 @@ +/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/* + Copyright (C) 2009-2015 Red Hat, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef DCC_ENCODERS_H_ +#define DCC_ENCODERS_H_ + +#include "common/marshaller.h" +#include "common/quic.h" +#include "red_channel.h" +#include "red_parse_qxl.h" +#include "spice_image_cache.h" +#include "glz_encoder_dictionary.h" +#include "glz_encoder.h" +#include "jpeg_encoder.h" +#ifdef USE_LZ4 +#include "lz4_encoder.h" +#endif +#include "zlib_encoder.h" + +typedef struct RedCompressBuf RedCompressBuf; +typedef struct GlzDrawableInstanceItem GlzDrawableInstanceItem; + +void dcc_encoders_init (DisplayChannelClient *dcc); +void dcc_free_glz_drawable_instance (DisplayChannelClient *dcc, + GlzDrawableInstanceItem *item); +void marshaller_add_compressed (SpiceMarshaller *m, + RedCompressBuf *comp_buf, + size_t size); + +RedCompressBuf* compress_buf_new (void); +void compress_buf_free (RedCompressBuf *buf); + +struct RedCompressBuf { + uint8_t buf[64 * 1024]; + RedCompressBuf *send_next; +}; + +typedef struct GlzSharedDictionary { + RingItem base; + GlzEncDictContext *dict; + uint32_t refs; + uint8_t id; + pthread_rwlock_t encode_lock; + int migrate_freeze; + RedClient *client; // channel clients of the same client share the dict +} GlzSharedDictionary; + +typedef struct { + DisplayChannelClient *dcc; + RedCompressBuf *bufs_head; + RedCompressBuf *bufs_tail; + jmp_buf jmp_env; + union { + struct { + SpiceChunks *chunks; + int next; + int stride; + int reverse; + } lines_data; + struct { + RedCompressBuf* next; + int size_left; + } compressed_data; // for encoding data that was already compressed by another method + } u; + char message_buf[512]; +} EncoderData; + +typedef struct { + QuicUsrContext usr; + EncoderData data; +} QuicData; + +typedef struct { + LzUsrContext usr; + EncoderData data; +} LzData; + +typedef struct { + JpegEncoderUsrContext usr; + EncoderData data; +} JpegData; + +#ifdef USE_LZ4 +typedef struct { + Lz4EncoderUsrContext usr; + EncoderData data; +} Lz4Data; +#endif + +typedef struct { + ZlibEncoderUsrContext usr; + EncoderData data; +} ZlibData; + +typedef struct { + GlzEncoderUsrContext usr; + EncoderData data; +} GlzData; + +#define MAX_GLZ_DRAWABLE_INSTANCES 2 + +typedef struct RedGlzDrawable RedGlzDrawable; + +/* for each qxl drawable, there may be several instances of lz drawables */ +/* TODO - reuse this stuff for the top level. I just added a second level of multiplicity + * at the Drawable by keeping a ring, so: + * Drawable -> (ring of) RedGlzDrawable -> (up to 2) GlzDrawableInstanceItem + * and it should probably (but need to be sure...) be + * Drawable -> ring of GlzDrawableInstanceItem. + */ +struct GlzDrawableInstanceItem { + RingItem glz_link; + RingItem free_link; + GlzEncDictImageContext *glz_instance; + RedGlzDrawable *red_glz_drawable; +}; + +struct RedGlzDrawable { + RingItem link; // ordered by the time it was encoded + RingItem drawable_link; + RedDrawable *red_drawable; + Drawable *drawable; + uint32_t group_id; + GlzDrawableInstanceItem instances_pool[MAX_GLZ_DRAWABLE_INSTANCES]; + Ring instances; + uint8_t instances_count; + DisplayChannelClient *dcc; +}; + + +#endif /* DCC_ENCODERS_H_ */ |