mac-sck-common.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include <AvailabilityMacros.h>
  2. #include <Cocoa/Cocoa.h>
  3. #include <stdlib.h>
  4. #include <obs-module.h>
  5. #include <util/threading.h>
  6. #include <pthread.h>
  7. #include <IOSurface/IOSurface.h>
  8. #include <ScreenCaptureKit/ScreenCaptureKit.h>
  9. #include <CoreMedia/CMSampleBuffer.h>
  10. #include <CoreVideo/CVPixelBuffer.h>
  11. #define MACCAP_LOG(level, msg, ...) blog(level, "[ mac-screencapture ]: " msg, ##__VA_ARGS__)
  12. #define MACCAP_ERR(msg, ...) MACCAP_LOG(LOG_ERROR, msg, ##__VA_ARGS__)
  13. typedef enum {
  14. ScreenCaptureDisplayStream = 0,
  15. ScreenCaptureWindowStream = 1,
  16. ScreenCaptureApplicationStream = 2,
  17. } ScreenCaptureStreamType;
  18. typedef enum {
  19. ScreenCaptureAudioDesktopStream = 0,
  20. ScreenCaptureAudioApplicationStream = 1,
  21. } ScreenCaptureAudioStreamType;
  22. API_AVAILABLE(macos(12.5)) typedef SCDisplay *SCDisplayRef;
  23. API_AVAILABLE(macos(12.5))
  24. @interface ScreenCaptureDelegate : NSObject <SCStreamOutput, SCStreamDelegate>
  25. @property struct screen_capture *sc;
  26. @end
  27. struct API_AVAILABLE(macos(12.5)) screen_capture {
  28. obs_source_t *source;
  29. gs_effect_t *effect;
  30. gs_texture_t *tex;
  31. NSRect frame;
  32. bool hide_cursor;
  33. bool hide_obs;
  34. bool show_hidden_windows;
  35. bool show_empty_names;
  36. bool audio_only;
  37. SCStream *disp;
  38. SCStreamConfiguration *stream_properties;
  39. SCShareableContent *shareable_content;
  40. ScreenCaptureDelegate *capture_delegate;
  41. os_event_t *stream_start_completed;
  42. os_sem_t *shareable_content_available;
  43. IOSurfaceRef current, prev;
  44. bool capture_failed;
  45. pthread_mutex_t mutex;
  46. ScreenCaptureStreamType capture_type;
  47. ScreenCaptureAudioStreamType audio_capture_type;
  48. CGDirectDisplayID display;
  49. CGWindowID window;
  50. NSString *application_id;
  51. };
  52. bool is_screen_capture_available(void);
  53. API_AVAILABLE(macos(12.5)) void screen_capture_build_content_list(struct screen_capture *sc, bool display_capture);
  54. API_AVAILABLE(macos(12.5)) bool build_display_list(struct screen_capture *sc, obs_properties_t *props);
  55. API_AVAILABLE(macos(12.5)) bool build_window_list(struct screen_capture *sc, obs_properties_t *props);
  56. API_AVAILABLE(macos(12.5)) bool build_application_list(struct screen_capture *sc, obs_properties_t *props);
  57. static const char *screen_capture_getname(void *unused __unused);
  58. API_AVAILABLE(macos(12.5)) void screen_stream_video_update(struct screen_capture *sc, CMSampleBufferRef sample_buffer);
  59. API_AVAILABLE(macos(12.5)) void screen_stream_audio_update(struct screen_capture *sc, CMSampleBufferRef sample_buffer);