neatvnc/include/encoder.h

101 lines
2.8 KiB
C
Raw Normal View History

2021-12-09 22:48:31 +00:00
/*
2022-04-14 16:56:41 +00:00
* Copyright (c) 2021 - 2022 Andri Yngvason
2021-12-09 22:48:31 +00:00
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#pragma once
#include "rfb-proto.h"
#include <stdint.h>
#include <unistd.h>
struct encoder;
struct nvnc_fb;
struct pixman_region16;
struct rcbuf;
2021-12-25 15:45:28 +00:00
enum encoder_impl_flags {
ENCODER_IMPL_FLAG_NONE = 0,
ENCODER_IMPL_FLAG_IGNORES_DAMAGE = 1 << 0,
};
enum encoder_kind {
ENCODER_KIND_INVALID = 0,
ENCODER_KIND_REGULAR,
ENCODER_KIND_PUSH_PULL,
};
2021-12-09 22:48:31 +00:00
struct encoder_impl {
2021-12-25 15:45:28 +00:00
enum encoder_impl_flags flags;
2021-12-09 22:48:31 +00:00
void (*destroy)(struct encoder*);
void (*set_output_format)(struct encoder*,
const struct rfb_pixel_format*);
void (*set_quality)(struct encoder*, int quality);
2021-12-09 22:48:31 +00:00
int (*resize)(struct encoder*, uint16_t width, uint16_t height);
int (*encode)(struct encoder*, struct nvnc_fb* fb,
struct pixman_region16* damage);
int (*push)(struct encoder*, struct nvnc_fb* fb,
struct pixman_region16* damage);
2022-04-14 16:56:41 +00:00
struct rcbuf* (*pull)(struct encoder*, uint64_t* pts);
void (*request_key_frame)(struct encoder*);
2021-12-09 22:48:31 +00:00
};
struct encoder {
struct encoder_impl* impl;
2022-10-30 10:41:20 +00:00
int ref;
2021-12-11 21:55:56 +00:00
uint16_t x_pos;
uint16_t y_pos;
2021-12-12 16:05:29 +00:00
int n_rects;
2022-04-14 16:56:41 +00:00
void (*on_done)(struct encoder*, struct rcbuf* result, uint64_t pts);
2021-12-09 22:48:31 +00:00
void* userdata;
};
struct encoder* encoder_new(enum rfb_encodings type, uint16_t width,
uint16_t height);
2022-10-30 10:41:20 +00:00
void encoder_ref(struct encoder* self);
void encoder_unref(struct encoder* self);
void encoder_init(struct encoder* self, struct encoder_impl*);
2021-12-09 22:48:31 +00:00
enum rfb_encodings encoder_get_type(const struct encoder* self);
enum encoder_kind encoder_get_kind(const struct encoder* self);
2021-12-09 22:48:31 +00:00
void encoder_set_output_format(struct encoder* self,
const struct rfb_pixel_format*);
void encoder_set_quality(struct encoder* self, int value);
2021-12-09 22:48:31 +00:00
int encoder_resize(struct encoder* self, uint16_t width, uint16_t height);
int encoder_encode(struct encoder* self, struct nvnc_fb* fb,
struct pixman_region16* damage);
int encoder_push(struct encoder* self, struct nvnc_fb* fb,
struct pixman_region16* damage);
2022-04-14 16:56:41 +00:00
struct rcbuf* encoder_pull(struct encoder* self, uint64_t* pts);
void encoder_request_key_frame(struct encoder* self);
2022-06-05 15:50:43 +00:00
void encoder_finish_frame(struct encoder* self, struct rcbuf* result,
uint64_t pts);