| 
									
										
										
										
											2021-06-05 21:26:18 -04:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Looking Glass | 
					
						
							| 
									
										
										
										
											2023-10-20 15:36:34 +11:00
										 |  |  |  * Copyright © 2017-2023 The Looking Glass Authors | 
					
						
							| 
									
										
										
										
											2021-06-05 21:26:18 -04: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 16:35:30 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <stdbool.h>
 | 
					
						
							|  |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2021-07-10 18:39:40 -04:00
										 |  |  | #include "common/KVMFR.h"
 | 
					
						
							| 
									
										
										
										
											2019-02-28 16:35:30 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-16 22:09:11 +10: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 16:35:30 +11:00
										 |  |  | typedef enum CaptureResult | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-04 17:55:45 +11:00
										 |  |  |   CAPTURE_RESULT_OK     , | 
					
						
							|  |  |  |   CAPTURE_RESULT_REINIT , | 
					
						
							| 
									
										
										
										
											2019-02-28 16:35:30 +11:00
										 |  |  |   CAPTURE_RESULT_TIMEOUT, | 
					
						
							|  |  |  |   CAPTURE_RESULT_ERROR | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | CaptureResult; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 20:33:21 +11:00
										 |  |  | typedef enum CaptureFormat | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-04 17:45:19 +11:00
										 |  |  |   // frame formats
 | 
					
						
							| 
									
										
										
										
											2023-10-27 01:11:57 +11:00
										 |  |  |   CAPTURE_FMT_BGRA   , | 
					
						
							|  |  |  |   CAPTURE_FMT_RGBA   , | 
					
						
							|  |  |  |   CAPTURE_FMT_RGBA10 , | 
					
						
							|  |  |  |   CAPTURE_FMT_RGBA16F, | 
					
						
							| 
									
										
										
										
											2023-11-08 16:04:58 +11:00
										 |  |  |   CAPTURE_FMT_BGR_32 , | 
					
						
							|  |  |  |   CAPTURE_FMT_RGB_24 , | 
					
						
							| 
									
										
										
										
											2019-03-04 17:45:19 +11:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // pointer formats
 | 
					
						
							|  |  |  |   CAPTURE_FMT_COLOR , | 
					
						
							|  |  |  |   CAPTURE_FMT_MONO  , | 
					
						
							|  |  |  |   CAPTURE_FMT_MASKED, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 20:33:21 +11:00
										 |  |  |   CAPTURE_FMT_MAX | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | CaptureFormat; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-18 13:53:29 +11:00
										 |  |  | typedef enum CaptureRotation | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   CAPTURE_ROT_0, | 
					
						
							|  |  |  |   CAPTURE_ROT_90, | 
					
						
							|  |  |  |   CAPTURE_ROT_180, | 
					
						
							|  |  |  |   CAPTURE_ROT_270 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | CaptureRotation; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 20:33:21 +11:00
										 |  |  | typedef struct CaptureFrame | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-10-30 08:42:08 +11: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 18:39:40 -04:00
										 |  |  |   uint32_t        damageRectsCount; | 
					
						
							|  |  |  |   FrameDamageRect damageRects[KVMFR_MAX_DAMAGE_RECTS]; | 
					
						
							| 
									
										
										
										
											2019-03-02 20:33:21 +11:00
										 |  |  | } | 
					
						
							|  |  |  | CaptureFrame; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-04 17:45:19 +11:00
										 |  |  | typedef struct CapturePointer | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-01-26 17:25:14 +11:00
										 |  |  |   bool          positionUpdate; | 
					
						
							| 
									
										
										
										
											2019-03-04 17:45:19 +11:00
										 |  |  |   int           x, y; | 
					
						
							| 
									
										
										
										
											2019-03-04 19:26:02 +11:00
										 |  |  |   bool          visible; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   bool          shapeUpdate; | 
					
						
							| 
									
										
										
										
											2019-03-04 17:45:19 +11:00
										 |  |  |   CaptureFormat format; | 
					
						
							| 
									
										
										
										
											2023-10-30 08:42:08 +11:00
										 |  |  |   unsigned      hx, hy; | 
					
						
							|  |  |  |   unsigned      width, height; | 
					
						
							|  |  |  |   unsigned      pitch; | 
					
						
							| 
									
										
										
										
											2019-03-04 17:45:19 +11:00
										 |  |  | } | 
					
						
							|  |  |  | CapturePointer; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-09 15:42:32 +11:00
										 |  |  | typedef bool (*CaptureGetPointerBuffer )(void ** data, uint32_t * size); | 
					
						
							| 
									
										
										
										
											2024-01-29 21:47:02 +11:00
										 |  |  | typedef void (*CapturePostPointerBuffer)(const CapturePointer * pointer); | 
					
						
							| 
									
										
										
										
											2020-01-09 15:42:32 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-02 20:33:21 +11:00
										 |  |  | typedef struct CaptureInterface | 
					
						
							| 
									
										
										
										
											2019-02-28 16:35:30 +11:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-07-12 16:53:46 +10:00
										 |  |  |   const char * shortName; | 
					
						
							|  |  |  |   const bool   asyncCapture; | 
					
						
							| 
									
										
										
										
											2022-02-20 11:43:36 -05:00
										 |  |  |   const char * (*getName        )(void); | 
					
						
							|  |  |  |   void         (*initOptions    )(void); | 
					
						
							| 
									
										
										
										
											2019-05-09 22:06:58 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-09 15:42:32 +11:00
										 |  |  |   bool(*create)( | 
					
						
							|  |  |  |     CaptureGetPointerBuffer  getPointerBufferFn, | 
					
						
							| 
									
										
										
										
											2024-01-29 21:47:02 +11:00
										 |  |  |     CapturePostPointerBuffer postPointerBufferFn, | 
					
						
							|  |  |  |     unsigned                 frameBuffers | 
					
						
							| 
									
										
										
										
											2020-01-09 15:42:32 +11:00
										 |  |  |   ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-29 21:47:02 +11:00
										 |  |  |   bool          (*init         )(void * ivshmemBase, unsigned * alignSize); | 
					
						
							| 
									
										
										
										
											2022-02-20 11:43:36 -05:00
										 |  |  |   bool          (*start        )(void); | 
					
						
							|  |  |  |   void          (*stop         )(void); | 
					
						
							|  |  |  |   bool          (*deinit       )(void); | 
					
						
							|  |  |  |   void          (*free         )(void); | 
					
						
							| 
									
										
										
										
											2019-03-01 15:45:46 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-29 21:47:02 +11: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 20:33:21 +11:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-01-26 17:25:14 +11:00
										 |  |  | CaptureInterface; |