2023-06-25 19:47:38 +00:00
|
|
|
#include <AvailabilityMacros.h>
|
|
|
|
#include <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <obs-module.h>
|
|
|
|
#include <util/threading.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include <IOSurface/IOSurface.h>
|
|
|
|
#include <ScreenCaptureKit/ScreenCaptureKit.h>
|
|
|
|
#include <CoreMedia/CMSampleBuffer.h>
|
|
|
|
#include <CoreVideo/CVPixelBuffer.h>
|
|
|
|
|
|
|
|
#define MACCAP_LOG(level, msg, ...) blog(level, "[ mac-screencapture ]: " msg, ##__VA_ARGS__)
|
|
|
|
#define MACCAP_ERR(msg, ...) MACCAP_LOG(LOG_ERROR, msg, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ScreenCaptureDisplayStream = 0,
|
|
|
|
ScreenCaptureWindowStream = 1,
|
|
|
|
ScreenCaptureApplicationStream = 2,
|
|
|
|
} ScreenCaptureStreamType;
|
|
|
|
|
2023-06-25 21:10:10 +00:00
|
|
|
typedef enum {
|
|
|
|
ScreenCaptureAudioDesktopStream = 0,
|
|
|
|
ScreenCaptureAudioApplicationStream = 1,
|
|
|
|
} ScreenCaptureAudioStreamType;
|
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) typedef SCDisplay *SCDisplayRef;
|
2024-02-28 20:45:32 +00:00
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5))
|
2023-06-25 19:47:38 +00:00
|
|
|
@interface ScreenCaptureDelegate : NSObject <SCStreamOutput, SCStreamDelegate>
|
|
|
|
|
|
|
|
@property struct screen_capture *sc;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
struct API_AVAILABLE(macos(12.5)) screen_capture {
|
2023-06-25 19:47:38 +00:00
|
|
|
obs_source_t *source;
|
|
|
|
|
|
|
|
gs_effect_t *effect;
|
|
|
|
gs_texture_t *tex;
|
|
|
|
|
|
|
|
NSRect frame;
|
|
|
|
bool hide_cursor;
|
|
|
|
bool hide_obs;
|
|
|
|
bool show_hidden_windows;
|
|
|
|
bool show_empty_names;
|
2023-06-25 21:10:10 +00:00
|
|
|
bool audio_only;
|
2023-06-25 19:47:38 +00:00
|
|
|
|
|
|
|
SCStream *disp;
|
|
|
|
SCStreamConfiguration *stream_properties;
|
|
|
|
SCShareableContent *shareable_content;
|
|
|
|
ScreenCaptureDelegate *capture_delegate;
|
|
|
|
|
|
|
|
os_event_t *disp_finished;
|
|
|
|
os_event_t *stream_start_completed;
|
|
|
|
os_sem_t *shareable_content_available;
|
|
|
|
IOSurfaceRef current, prev;
|
2023-07-01 11:26:47 +00:00
|
|
|
bool capture_failed;
|
2023-06-25 19:47:38 +00:00
|
|
|
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
|
|
|
|
ScreenCaptureStreamType capture_type;
|
2023-06-25 21:10:10 +00:00
|
|
|
ScreenCaptureAudioStreamType audio_capture_type;
|
2023-06-25 19:47:38 +00:00
|
|
|
CGDirectDisplayID display;
|
|
|
|
CGWindowID window;
|
|
|
|
NSString *application_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool is_screen_capture_available(void);
|
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) void screen_capture_build_content_list(struct screen_capture *sc, bool display_capture);
|
2023-06-25 19:47:38 +00:00
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) bool build_display_list(struct screen_capture *sc, obs_properties_t *props);
|
2023-06-25 19:47:38 +00:00
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) bool build_window_list(struct screen_capture *sc, obs_properties_t *props);
|
2023-06-25 19:47:38 +00:00
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) bool build_application_list(struct screen_capture *sc, obs_properties_t *props);
|
2023-06-25 19:47:38 +00:00
|
|
|
|
|
|
|
static const char *screen_capture_getname(void *unused __unused);
|
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) void screen_stream_video_update(struct screen_capture *sc, CMSampleBufferRef sample_buffer);
|
2023-06-25 19:47:38 +00:00
|
|
|
|
2024-03-29 14:42:18 +00:00
|
|
|
API_AVAILABLE(macos(12.5)) void screen_stream_audio_update(struct screen_capture *sc, CMSampleBufferRef sample_buffer);
|