2021-06-06 01:26:18 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2024-02-01 06:16:31 +00:00
|
|
|
* Copyright © 2017-2024 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>
|
2021-07-10 22:39:40 +00:00
|
|
|
#include "common/KVMFR.h"
|
2019-02-28 05:35:30 +00:00
|
|
|
|
2022-05-16 12:09:11 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
/* using common/framebuffer.h breaks compatibillity with C++ due to it's usage
|
|
|
|
* of stdatomic.h, so we need to forward declare the structure here */
|
|
|
|
typedef struct stFrameBuffer FrameBuffer;
|
|
|
|
#else
|
|
|
|
#include "common/framebuffer.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
2023-10-26 14:11:57 +00:00
|
|
|
CAPTURE_FMT_BGRA ,
|
|
|
|
CAPTURE_FMT_RGBA ,
|
|
|
|
CAPTURE_FMT_RGBA10 ,
|
|
|
|
CAPTURE_FMT_RGBA16F,
|
2023-11-08 05:04:58 +00:00
|
|
|
CAPTURE_FMT_BGR_32 ,
|
|
|
|
CAPTURE_FMT_RGB_24 ,
|
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
|
|
|
|
{
|
2023-10-29 21:42:08 +00:00
|
|
|
unsigned formatVer;
|
|
|
|
unsigned screenWidth; // actual screen width
|
|
|
|
unsigned screenHeight; // actual screen height
|
|
|
|
unsigned dataWidth; // the width of the packed frame data
|
|
|
|
unsigned dataHeight; // the height of the packed frame data
|
|
|
|
unsigned frameWidth; // width of the frame image
|
|
|
|
unsigned frameHeight; // height of the frame image
|
|
|
|
unsigned pitch; // total width of one row of data in bytes
|
|
|
|
unsigned stride; // total width of one row of data in pixels
|
|
|
|
CaptureFormat format; // the data format of the frame
|
|
|
|
bool truncated; // true if the frame data is truncated
|
|
|
|
bool hdr; // true if the frame format is HDR
|
|
|
|
bool hdrPQ; // true if the frame format is PQ transformed
|
|
|
|
CaptureRotation rotation; // output rotation of the frame
|
|
|
|
|
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;
|
2023-10-29 21:42:08 +00:00
|
|
|
unsigned hx, hy;
|
|
|
|
unsigned width, height;
|
|
|
|
unsigned pitch;
|
2019-03-04 06:45:19 +00:00
|
|
|
}
|
|
|
|
CapturePointer;
|
|
|
|
|
2020-01-09 04:42:32 +00:00
|
|
|
typedef bool (*CaptureGetPointerBuffer )(void ** data, uint32_t * size);
|
2024-01-29 10:47:02 +00:00
|
|
|
typedef void (*CapturePostPointerBuffer)(const CapturePointer * pointer);
|
2020-01-09 04:42:32 +00:00
|
|
|
|
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;
|
2024-03-11 01:46:02 +00:00
|
|
|
const bool deprecated;
|
|
|
|
|
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,
|
2024-01-29 10:47:02 +00:00
|
|
|
CapturePostPointerBuffer postPointerBufferFn,
|
|
|
|
unsigned frameBuffers
|
2020-01-09 04:42:32 +00:00
|
|
|
);
|
|
|
|
|
2024-01-29 10:47:02 +00:00
|
|
|
bool (*init )(void * ivshmemBase, unsigned * alignSize);
|
2022-02-20 16:43:36 +00:00
|
|
|
bool (*start )(void);
|
|
|
|
void (*stop )(void);
|
|
|
|
bool (*deinit )(void);
|
|
|
|
void (*free )(void);
|
2019-03-01 04:45:46 +00:00
|
|
|
|
2024-01-29 10:47:02 +00:00
|
|
|
CaptureResult (*capture )(
|
|
|
|
unsigned frameBufferIndex,
|
|
|
|
FrameBuffer * frame);
|
|
|
|
CaptureResult (*waitFrame )(
|
|
|
|
unsigned frameBufferIndex,
|
|
|
|
CaptureFrame * frame,
|
|
|
|
const size_t maxFrameSize);
|
|
|
|
CaptureResult (*getFrame )(
|
|
|
|
unsigned frameBufferIndex,
|
|
|
|
FrameBuffer * frame,
|
|
|
|
const size_t maxFrameSize);
|
2019-03-02 09:33:21 +00:00
|
|
|
}
|
2020-01-26 06:25:14 +00:00
|
|
|
CaptureInterface;
|