|
| 1 | +// AUTO-GENERATED. DO NOT EDIT. |
| 2 | +// Any manual changes WILL BE LOST when this file is regenerated. |
| 3 | + |
| 4 | +#pragma once |
| 5 | + |
| 6 | +#include <stdbool.h> |
| 7 | +#include <stdint.h> |
| 8 | + |
| 9 | +#include "common_c.h" |
| 10 | +typedef uint64_t native_display_t; |
| 11 | +typedef uint64_t native_window_t; |
| 12 | + |
| 13 | +#include "display_c.h" |
| 14 | +#include "window_c.h" |
| 15 | + |
| 16 | +#if _WIN32 |
| 17 | +#define FFI_PLUGIN_EXPORT __declspec(dllexport) |
| 18 | +#else |
| 19 | +#define FFI_PLUGIN_EXPORT |
| 20 | +#endif |
| 21 | + |
| 22 | +#ifdef __cplusplus |
| 23 | +extern "C" { |
| 24 | +#endif |
| 25 | + |
| 26 | +typedef enum { |
| 27 | + NATIVE_CAPTURE_SOURCE_TYPE_NONE = 0, |
| 28 | + NATIVE_CAPTURE_SOURCE_TYPE_DISPLAY = 1, |
| 29 | + NATIVE_CAPTURE_SOURCE_TYPE_WINDOW = 2, |
| 30 | + NATIVE_CAPTURE_SOURCE_TYPE_UNKNOWN = 3, |
| 31 | +} native_capture_source_type_t; |
| 32 | + |
| 33 | +/// Opaque CaptureSource handle. |
| 34 | +/// |
| 35 | +/// A generational index into the library's handle table, NOT a pointer: |
| 36 | +/// never dereference it, and compare it against NATIVE_INVALID_CAPTURE_SOURCE rather than NULL. |
| 37 | +/// Releasing a handle invalidates it; later calls fail safely instead of |
| 38 | +/// touching freed memory. |
| 39 | +typedef uint64_t native_capture_source_t; |
| 40 | + |
| 41 | +/// Never refers to a live CaptureSource. |
| 42 | +#define NATIVE_INVALID_CAPTURE_SOURCE ((native_capture_source_t)0) |
| 43 | + |
| 44 | +/// Caller owns the returned handle; release it with native_capture_source_free(). |
| 45 | +FFI_PLUGIN_EXPORT |
| 46 | +native_capture_source_t native_capture_source_from_display(native_display_t display); |
| 47 | + |
| 48 | +/// Caller owns the returned handle; release it with native_capture_source_free(). |
| 49 | +FFI_PLUGIN_EXPORT |
| 50 | +native_capture_source_t native_capture_source_from_window(native_window_t window); |
| 51 | + |
| 52 | +FFI_PLUGIN_EXPORT |
| 53 | +native_capture_source_type_t native_capture_source_get_type(native_capture_source_t capture_source); |
| 54 | + |
| 55 | +/// Caller owns the returned string; free it with free_c_str(). |
| 56 | +FFI_PLUGIN_EXPORT |
| 57 | +char* native_capture_source_get_name(native_capture_source_t capture_source); |
| 58 | + |
| 59 | +/// Releases the caller's reference. Safe to call with an invalid or |
| 60 | +/// already-released handle. |
| 61 | +FFI_PLUGIN_EXPORT |
| 62 | +void native_capture_source_free(native_capture_source_t capture_source); |
| 63 | + |
| 64 | +#ifdef __cplusplus |
| 65 | +} |
| 66 | +#endif |
| 67 | + |
| 68 | +#ifdef __cplusplus |
| 69 | +#include "../capture_source.h" |
| 70 | +#include "string_utils_c.h" |
| 71 | +#include "user_data.h" |
| 72 | + |
| 73 | +// Conversion helpers between these C types and their C++ originals. |
| 74 | + |
| 75 | +inline native_capture_source_type_t to_c_capture_source_type(nativeapi::CaptureSourceType value); |
| 76 | +inline nativeapi::CaptureSourceType to_cpp_capture_source_type(native_capture_source_type_t value); |
| 77 | + |
| 78 | +inline native_capture_source_type_t to_c_capture_source_type(nativeapi::CaptureSourceType value) { |
| 79 | + switch (value) { |
| 80 | + case nativeapi::CaptureSourceType::None: |
| 81 | + return NATIVE_CAPTURE_SOURCE_TYPE_NONE; |
| 82 | + case nativeapi::CaptureSourceType::Display: |
| 83 | + return NATIVE_CAPTURE_SOURCE_TYPE_DISPLAY; |
| 84 | + case nativeapi::CaptureSourceType::Window: |
| 85 | + return NATIVE_CAPTURE_SOURCE_TYPE_WINDOW; |
| 86 | + case nativeapi::CaptureSourceType::Unknown: |
| 87 | + return NATIVE_CAPTURE_SOURCE_TYPE_UNKNOWN; |
| 88 | + default: |
| 89 | + return NATIVE_CAPTURE_SOURCE_TYPE_NONE; |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +inline nativeapi::CaptureSourceType to_cpp_capture_source_type(native_capture_source_type_t value) { |
| 94 | + switch (value) { |
| 95 | + case NATIVE_CAPTURE_SOURCE_TYPE_NONE: |
| 96 | + return nativeapi::CaptureSourceType::None; |
| 97 | + case NATIVE_CAPTURE_SOURCE_TYPE_DISPLAY: |
| 98 | + return nativeapi::CaptureSourceType::Display; |
| 99 | + case NATIVE_CAPTURE_SOURCE_TYPE_WINDOW: |
| 100 | + return nativeapi::CaptureSourceType::Window; |
| 101 | + case NATIVE_CAPTURE_SOURCE_TYPE_UNKNOWN: |
| 102 | + return nativeapi::CaptureSourceType::Unknown; |
| 103 | + default: |
| 104 | + return static_cast<nativeapi::CaptureSourceType>(value); |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +#endif // __cplusplus |
0 commit comments