GUAC-236: Add display, buffer, image, and stream abstractions.
This commit is contained in:
parent
23af2d3041
commit
f286bd92c7
@ -25,11 +25,16 @@ AUTOMAKE_OPTIONS = foreign
|
||||
bin_PROGRAMS = guacenc
|
||||
|
||||
noinst_HEADERS = \
|
||||
buffer.h \
|
||||
display.h \
|
||||
encode.h \
|
||||
image-stream.h \
|
||||
instructions.h \
|
||||
layer.h \
|
||||
log.h
|
||||
|
||||
guacenc_SOURCES = \
|
||||
display.c \
|
||||
encode.c \
|
||||
guacenc.c \
|
||||
instructions.c \
|
||||
|
47
src/guacenc/buffer.h
Normal file
47
src/guacenc/buffer.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Glyptodon, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GUACENC_BUFFER_H
|
||||
#define GUACENC_BUFFER_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* The image and size storage for either a buffer (a Guacamole layer with a
|
||||
* negative index) or a layer (a Guacamole layer with a non-negative index).
|
||||
*/
|
||||
typedef struct guacenc_buffer {
|
||||
|
||||
/**
|
||||
* The width of this buffer or layer, in pixels.
|
||||
*/
|
||||
int width;
|
||||
|
||||
/**
|
||||
* The height of this buffer or layer, in pixels.
|
||||
*/
|
||||
int height;
|
||||
|
||||
} guacenc_buffer;
|
||||
|
||||
#endif
|
||||
|
32
src/guacenc/display.c
Normal file
32
src/guacenc/display.c
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Glyptodon, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "display.h"
|
||||
|
||||
#include <guacamole/timestamp.h>
|
||||
|
||||
int guacenc_display_sync(guacenc_display* display, guac_timestamp timestamp) {
|
||||
/* STUB */
|
||||
return 0;
|
||||
}
|
||||
|
105
src/guacenc/display.h
Normal file
105
src/guacenc/display.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Glyptodon, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GUACENC_DISPLAY_H
|
||||
#define GUACENC_DISPLAY_H
|
||||
|
||||
#include "config.h"
|
||||
#include "buffer.h"
|
||||
#include "image-stream.h"
|
||||
#include "layer.h"
|
||||
|
||||
#include <guacamole/timestamp.h>
|
||||
|
||||
/**
|
||||
* The maximum number of buffers that the Guacamole video encoder will handle
|
||||
* within a single Guacamole protocol dump.
|
||||
*/
|
||||
#define GUACENC_DISPLAY_MAX_BUFFERS 4096
|
||||
|
||||
/**
|
||||
* The maximum number of layers that the Guacamole video encoder will handle
|
||||
* within a single Guacamole protocol dump.
|
||||
*/
|
||||
#define GUACENC_DISPLAY_MAX_LAYERS 64
|
||||
|
||||
/**
|
||||
* The maximum number of streams that the Guacamole video encoder will handle
|
||||
* within a single Guacamole protocol dump.
|
||||
*/
|
||||
#define GUACENC_DISPLAY_MAX_STREAMS 64
|
||||
|
||||
/**
|
||||
* The current state of the Guacamole video encoder's internal display.
|
||||
*/
|
||||
typedef struct guacenc_display {
|
||||
|
||||
/**
|
||||
* All currently-allocated buffers. The index of the buffer corresponds to
|
||||
* its position within this array, where -1 is the 0th entry. If a buffer
|
||||
* has not yet been allocated, or a buffer has been freed (due to a
|
||||
* "dispose" instruction), its entry here will be NULL.
|
||||
*/
|
||||
guacenc_buffer* buffers[GUACENC_DISPLAY_MAX_BUFFERS];
|
||||
|
||||
/**
|
||||
* All currently-allocated layers. The index of the layer corresponds to
|
||||
* its position within this array. If a layer has not yet been allocated,
|
||||
* or a layer has been freed (due to a "dispose" instruction), its entry
|
||||
* here will be NULL.
|
||||
*/
|
||||
guacenc_layer* layers[GUACENC_DISPLAY_MAX_LAYERS];
|
||||
|
||||
/**
|
||||
* All currently-allocated image streams. The index of the stream
|
||||
* corresponds to its position within this array. If a stream has not yet
|
||||
* been allocated, or a stream has been freed (due to an "end"
|
||||
* instruction), its entry here will be NULL.
|
||||
*/
|
||||
guacenc_image_stream* image_streams[GUACENC_DISPLAY_MAX_STREAMS];
|
||||
|
||||
/**
|
||||
* The timestamp of the last sync instruction handled, or 0 if no sync has
|
||||
* yet been read.
|
||||
*/
|
||||
guac_timestamp last_sync;
|
||||
|
||||
} guacenc_display;
|
||||
|
||||
/**
|
||||
* Handles a received "sync" instruction having the given timestamp, flushing
|
||||
* the current display to the in-progress video encoding.
|
||||
*
|
||||
* @param display
|
||||
* The display to flush to the video encoding as a new frame.
|
||||
*
|
||||
* @param timestamp
|
||||
* The timestamp of the new frame, as dictated by the "sync" instruction
|
||||
* sent at the end of the frame.
|
||||
*
|
||||
* @return
|
||||
* Zero if the frame was successfully written, non-zero if an error occurs.
|
||||
*/
|
||||
int guacenc_display_sync(guacenc_display* display, guac_timestamp timestamp);
|
||||
|
||||
#endif
|
||||
|
42
src/guacenc/image-stream.h
Normal file
42
src/guacenc/image-stream.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Glyptodon, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GUACENC_IMAGE_STREAM_H
|
||||
#define GUACENC_IMAGE_STREAM_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* The current state of an allocated Guacamole image stream.
|
||||
*/
|
||||
typedef struct guacenc_image_stream {
|
||||
|
||||
/**
|
||||
* STUB: Placeholder property. This property exists only so that the
|
||||
* guacenc_image_stream struct can be defined prior to implementation.
|
||||
*/
|
||||
int __PLACEHOLDER;
|
||||
|
||||
} guacenc_image_stream;
|
||||
|
||||
#endif
|
||||
|
80
src/guacenc/layer.h
Normal file
80
src/guacenc/layer.h
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Glyptodon, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GUACENC_LAYER_H
|
||||
#define GUACENC_LAYER_H
|
||||
|
||||
#include "config.h"
|
||||
#include "buffer.h"
|
||||
|
||||
/**
|
||||
* The value assigned to the parent_index property of a guacenc_layer if it has
|
||||
* no parent.
|
||||
*/
|
||||
#define GUACENC_LAYER_NO_PARENT -1
|
||||
|
||||
/**
|
||||
* A visible Guacamole layer.
|
||||
*/
|
||||
typedef struct guacenc_layer {
|
||||
|
||||
/**
|
||||
* The actual image contents of this layer, as well as this layer's size
|
||||
* (width and height).
|
||||
*/
|
||||
guacenc_buffer buffer;
|
||||
|
||||
/**
|
||||
* The index of the layer that contains this layer. If this layer is the
|
||||
* default layer (and thus has no parent), this will be
|
||||
* GUACENC_LAYER_NO_PARENT.
|
||||
*/
|
||||
int parent_index;
|
||||
|
||||
/**
|
||||
* The X coordinate of the upper-left corner of this layer within the
|
||||
* Guacamole display.
|
||||
*/
|
||||
int x;
|
||||
|
||||
/**
|
||||
* The Y coordinate of the upper-left corner of this layer within the
|
||||
* Guacamole display.
|
||||
*/
|
||||
int y;
|
||||
|
||||
/**
|
||||
* The relative stacking order of this layer with respect to other sibling
|
||||
* layers.
|
||||
*/
|
||||
int z;
|
||||
|
||||
/**
|
||||
* The opacity of this layer, where 0 is completely transparent and 255 is
|
||||
* completely opaque.
|
||||
*/
|
||||
int opacity;
|
||||
|
||||
} guacenc_layer;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user