2021-06-06 01:26:18 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2022-01-05 08:42:46 +00:00
|
|
|
* Copyright © 2017-2022 The Looking Glass Authors
|
2021-06-06 01:26:18 +00:00
|
|
|
* https://looking-glass.io
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2019-02-28 05:35:30 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2019-10-01 13:17:20 +00:00
|
|
|
#include "common/framebuffer.h"
|
2021-07-10 22:39:40 +00:00
|
|
|
#include "common/KVMFR.h"
|
2019-02-28 05:35:30 +00:00
|
|
|
|
|
|
|
typedef enum CaptureResult
|
|
|
|
{
|
2019-03-04 06:55:45 +00:00
|
|
|
CAPTURE_RESULT_OK ,
|
|
|
|
CAPTURE_RESULT_REINIT ,
|
2019-02-28 05:35:30 +00:00
|
|
|
CAPTURE_RESULT_TIMEOUT,
|
|
|
|
CAPTURE_RESULT_ERROR
|
|
|
|
}
|
|
|
|
CaptureResult;
|
|
|
|
|
2019-03-02 09:33:21 +00:00
|
|
|
typedef enum CaptureFormat
|
|
|
|
{
|
2019-03-04 06:45:19 +00:00
|
|
|
// frame formats
|
2020-10-11 08:22:31 +00:00
|
|
|
CAPTURE_FMT_BGRA ,
|
|
|
|
CAPTURE_FMT_RGBA ,
|
|
|
|
CAPTURE_FMT_RGBA10 ,
|
|
|
|
CAPTURE_FMT_RGBA16F,
|
2019-03-04 06:45:19 +00:00
|
|
|
|
|
|
|
// pointer formats
|
|
|
|
CAPTURE_FMT_COLOR ,
|
|
|
|
CAPTURE_FMT_MONO ,
|
|
|
|
CAPTURE_FMT_MASKED,
|
|
|
|
|
2019-03-02 09:33:21 +00:00
|
|
|
CAPTURE_FMT_MAX
|
|
|
|
}
|
|
|
|
CaptureFormat;
|
|
|
|
|
2021-01-18 02:53:29 +00:00
|
|
|
typedef enum CaptureRotation
|
|
|
|
{
|
|
|
|
CAPTURE_ROT_0,
|
|
|
|
CAPTURE_ROT_90,
|
|
|
|
CAPTURE_ROT_180,
|
|
|
|
CAPTURE_ROT_270
|
|
|
|
}
|
|
|
|
CaptureRotation;
|
|
|
|
|
2019-03-02 09:33:21 +00:00
|
|
|
typedef struct CaptureFrame
|
|
|
|
{
|
2021-01-18 02:53:29 +00:00
|
|
|
unsigned int formatVer;
|
2022-05-01 09:45:44 +00:00
|
|
|
unsigned int screenWidth;
|
|
|
|
unsigned int screenHeight;
|
|
|
|
unsigned int frameWidth;
|
|
|
|
unsigned int frameHeight;
|
|
|
|
bool truncated;
|
2021-01-18 02:53:29 +00:00
|
|
|
unsigned int pitch;
|
|
|
|
unsigned int stride;
|
|
|
|
CaptureFormat format;
|
|
|
|
CaptureRotation rotation;
|
2021-07-10 22:39:40 +00:00
|
|
|
uint32_t damageRectsCount;
|
|
|
|
FrameDamageRect damageRects[KVMFR_MAX_DAMAGE_RECTS];
|
2019-03-02 09:33:21 +00:00
|
|
|
}
|
|
|
|
CaptureFrame;
|
|
|
|
|
2019-03-04 06:45:19 +00:00
|
|
|
typedef struct CapturePointer
|
|
|
|
{
|
2020-01-26 06:25:14 +00:00
|
|
|
bool positionUpdate;
|
2019-03-04 06:45:19 +00:00
|
|
|
int x, y;
|
2019-03-04 08:26:02 +00:00
|
|
|
bool visible;
|
|
|
|
|
|
|
|
bool shapeUpdate;
|
2019-03-04 06:45:19 +00:00
|
|
|
CaptureFormat format;
|
2020-08-20 03:46:18 +00:00
|
|
|
unsigned int hx, hy;
|
2019-03-04 06:45:19 +00:00
|
|
|
unsigned int width, height;
|
|
|
|
unsigned int pitch;
|
|
|
|
}
|
|
|
|
CapturePointer;
|
|
|
|
|
2020-01-09 04:42:32 +00:00
|
|
|
typedef bool (*CaptureGetPointerBuffer )(void ** data, uint32_t * size);
|
|
|
|
typedef void (*CapturePostPointerBuffer)(CapturePointer pointer);
|
|
|
|
|
2019-03-02 09:33:21 +00:00
|
|
|
typedef struct CaptureInterface
|
2019-02-28 05:35:30 +00:00
|
|
|
{
|
2021-07-12 06:53:46 +00:00
|
|
|
const char * shortName;
|
|
|
|
const bool asyncCapture;
|
2022-02-20 16:43:36 +00:00
|
|
|
const char * (*getName )(void);
|
|
|
|
void (*initOptions )(void);
|
2019-05-09 12:06:58 +00:00
|
|
|
|
2020-01-09 04:42:32 +00:00
|
|
|
bool(*create)(
|
|
|
|
CaptureGetPointerBuffer getPointerBufferFn,
|
|
|
|
CapturePostPointerBuffer postPointerBufferFn
|
|
|
|
);
|
|
|
|
|
2022-02-20 16:43:36 +00:00
|
|
|
bool (*init )(void);
|
|
|
|
bool (*start )(void);
|
|
|
|
void (*stop )(void);
|
|
|
|
bool (*deinit )(void);
|
|
|
|
void (*free )(void);
|
2019-03-01 04:45:46 +00:00
|
|
|
|
2022-02-20 16:43:36 +00:00
|
|
|
CaptureResult (*capture )(void);
|
2021-06-12 08:44:28 +00:00
|
|
|
CaptureResult (*waitFrame )(CaptureFrame * frame, const size_t maxFrameSize);
|
2021-07-11 23:18:59 +00:00
|
|
|
CaptureResult (*getFrame )(FrameBuffer * frame, const unsigned int height, int frameIndex);
|
2019-03-02 09:33:21 +00:00
|
|
|
}
|
2020-01-26 06:25:14 +00:00
|
|
|
CaptureInterface;
|