diff --git a/dispatch/queue.go b/dispatch/queue.go index 46586e68..84b296a4 100644 --- a/dispatch/queue.go +++ b/dispatch/queue.go @@ -9,6 +9,8 @@ package dispatch // void Dispatch_Release(void* queue); // void Dispatch_Async(void* queue, uintptr_t task); // void Dispatch_Sync(void* queue, uintptr_t task); +// void* Dispatch_Create_Queue(const char* label, int type); +// void Dispatch_Main(); import "C" import ( "math" @@ -30,6 +32,13 @@ const ( QueuePriorityBackground QueuePriority = math.MinInt16 ) +type QueueType int + +const ( + QueueTypeSerial QueueType = 0 + QueueTypeConcurrent QueueType = 1 +) + // Returns the serial dispatch queue associated with the application’s main thread. [Full Topic] // // [Full Topic]: https://developer.apple.com/documentation/dispatch/1452921-dispatch_get_main_queue?language=objc @@ -73,3 +82,17 @@ func runQueueTask(p C.uintptr_t) { task() h.Delete() } + +// Main executes blocks submitted to the main queue. +func Main() { + C.Dispatch_Main() +} + +// Creates a new dispatch queue to which blocks can be submitted. +// +// [Full Topic]: https://developer.apple.com/documentation/dispatch/1453030-dispatch_queue_create?language=objc +func CreateQueue(label string, queueType QueueType) Queue { + cLabel := C.CString(label) + p := C.Dispatch_Create_Queue(cLabel, C.int(queueType)) + return Queue{p} +} diff --git a/dispatch/queue.m b/dispatch/queue.m index 68530495..be6eae81 100644 --- a/dispatch/queue.m +++ b/dispatch/queue.m @@ -31,4 +31,15 @@ void Dispatch_Sync(void* queue, uintptr_t task) { dispatch_sync((dispatch_queue_t)queue, ^{ runQueueTask(task); }); -} \ No newline at end of file +} + +void Dispatch_Main() { + dispatch_main(); +} + +void* Dispatch_Create_Queue(const char* label, int type) { + if (type == 0) { + return dispatch_queue_create(label, DISPATCH_QUEUE_SERIAL); + } + return dispatch_queue_create(label, DISPATCH_QUEUE_CONCURRENT); +} diff --git a/generate/modules/enums/macos/screencapturekit b/generate/modules/enums/macos/screencapturekit new file mode 100644 index 00000000..6a5fb8fb --- /dev/null +++ b/generate/modules/enums/macos/screencapturekit @@ -0,0 +1,30 @@ +SCFrameStatusBlank 2 +SCFrameStatusComplete 0 +SCFrameStatusIdle 1 +SCFrameStatusStarted 4 +SCFrameStatusStopped 5 +SCFrameStatusSuspended 3 +SCStreamErrorAttemptToConfigState -3810 +SCStreamErrorAttemptToStartStreamState -3807 +SCStreamErrorAttemptToStopStreamState -3808 +SCStreamErrorAttemptToUpdateFilterState -3809 +SCStreamErrorFailedApplicationConnectionInterrupted -3805 +SCStreamErrorFailedApplicationConnectionInvalid -3804 +SCStreamErrorFailedNoMatchingApplicationContext -3806 +SCStreamErrorFailedToStart -3802 +SCStreamErrorInternalError -3811 +SCStreamErrorInvalidParameter -3812 +SCStreamErrorMissingEntitlements -3803 +SCStreamErrorNoCaptureSource -3815 +SCStreamErrorNoDisplayList -3814 +SCStreamErrorNoWindowList -3813 +SCStreamErrorRemovingStream -3816 +SCStreamErrorUserDeclined -3801 +SCStreamOutputTypeScreen 0 +SCStreamErrorDomain com.apple.ScreenCaptureKit.SCStreamErrorDomain +SCStreamFrameInfoContentRect SCStreamUpdateFrameContentRect +SCStreamFrameInfoContentScale SCStreamUpdateFrameContentScale +SCStreamFrameInfoDirtyRects SCStreamUpdateFrameDirtyRect +SCStreamFrameInfoDisplayTime SCStreamUpdateFrameDisplayTime +SCStreamFrameInfoScaleFactor SCStreamUpdateFrameDisplayResolution +SCStreamFrameInfoStatus SCStreamUpdateFrameStatus diff --git a/generate/tools/enumexport.go b/generate/tools/enumexport.go index 93bb6e8f..2505bbc3 100644 --- a/generate/tools/enumexport.go +++ b/generate/tools/enumexport.go @@ -155,7 +155,7 @@ func exportConstants(db *generate.SymbolCache, framework *modules.Module, platfo continue } if s.Kind == "Constant" && s.Type == "Global Variable" { - stmt, err := s.Parse() + stmt, err := s.Parse(TargetPlatform) if err != nil { log.Fatalf("%s: %s in '%s'", s.Name, err, s.Declaration) } @@ -177,7 +177,7 @@ func exportConstants(db *generate.SymbolCache, framework *modules.Module, platfo if typ.Declaration == "" { return nil, false } - typdef, err := typ.Parse() + typdef, err := typ.Parse(TargetPlatform) if err != nil { log.Fatalf("%s: %s in '%s'", typ.Name, err, typ.Declaration) } diff --git a/macos/_examples/screencap/main.go b/macos/_examples/screencap/main.go new file mode 100644 index 00000000..b95b965c --- /dev/null +++ b/macos/_examples/screencap/main.go @@ -0,0 +1,118 @@ +package main + +import ( + "errors" + "fmt" + + "github.com/progrium/macdriver/dispatch" + "github.com/progrium/macdriver/macos/coremedia" + "github.com/progrium/macdriver/macos/foundation" + "github.com/progrium/macdriver/macos/screencapturekit" +) + +func main() { + captureHandler := &screenCaptureHandler{} + captureHandler.refreshCapturableWindows() + + sc := screencapturekit.NewStreamConfiguration() + //cf := screencapturekit.NewContentFilter() + + dispatch.MainQueue().DispatchAsync(func() { + cf := captureHandler.GetContentFilter() + s := screencapturekit.NewStreamWithFilterConfigurationDelegate(cf, sc, captureHandler) + + var dispatchQueue dispatch.Queue + //dispatchQueue = dispatch.CreateQueue("com.example.queue", dispatch.QueueTypeSerial) + dispatchQueue = dispatch.MainQueue() + err := foundation.Error{} + ok := s.AddStreamOutputTypeSampleHandlerQueueError(captureHandler, screencapturekit.StreamOutputTypeScreen, dispatchQueue, err) + if !ok { + fmt.Println("s.AddStreamOutputTypeSampleHandlerQueueError", err) + } + + fmt.Println("s.StartCaptureWithCompletionHandler") + s.StartCaptureWithCompletionHandler(func(err foundation.Error) { + fmt.Println("s.StartCaptureWithCompletionHandler", err) + }) + + dispatch.Main() +} + +type CaptureType int + +const ( + CaptureTypeDisplay CaptureType = iota + CaptureTypeWindow CaptureType = iota +) + +func (h *screenCaptureHandler) refreshCapturableWindows() { + fmt.Println("listing sharable content") + ch := make(chan struct{}) + screencapturekit.ShareableContentClass.GetShareableContentWithCompletionHandler(func(sc screencapturekit.ShareableContent, err foundation.Error) { + defer close(ch) + h.availabileDisplays = sc.Displays() + if h.selectedDisplay == nil && len(h.availabileDisplays) > 0 { + h.selectedDisplay = &h.availabileDisplays[0] + } + h.availbleWindows = sc.Windows() + if h.selectedWindow == nil && len(h.availbleWindows) > 0 { + h.selectedWindow = &h.availbleWindows[0] + } + for _, app := range sc.Applications() { + fmt.Println("app", app.ApplicationName()) + } + fmt.Println("done listing sharable content") + }) + <-ch +} + +type screenCaptureHandler struct { + availabileDisplays []screencapturekit.Display + availbleWindows []screencapturekit.Window + + selectedDisplay *screencapturekit.Display + selectedWindow *screencapturekit.Window + + captureType CaptureType +} + +func (sh *screenCaptureHandler) GetContentFilter() screencapturekit.ContentFilter { + filter := screencapturekit.NewContentFilter() + + switch sh.captureType { + case CaptureTypeDisplay: + display := sh.selectedDisplay + windows := []screencapturekit.IWindow{} + for _, w := range sh.availbleWindows { + windows = append(windows, w) + } + fmt.Println("display:", display) + fmt.Println("windows:", windows) + filter = screencapturekit.NewContentFilterWithDisplayIncludingWindows(display, windows) + case CaptureTypeWindow: + } + return filter +} + +var _ screencapturekit.PStreamOutput = (*screenCaptureHandler)(nil) +var _ screencapturekit.PStreamDelegate = (*screenCaptureHandler)(nil) + +// StreamOutput methods + +func (sh *screenCaptureHandler) HasStreamDidOutputSampleBufferOfType() bool { + panic(errors.New("*streamHandler.HasStreamDidOutputSampleBufferOfType not implemented")) +} + +func (sh *screenCaptureHandler) StreamDidOutputSampleBufferOfType(s screencapturekit.Stream, buf coremedia.SampleBufferRef, out screencapturekit.StreamOutputType) { + panic(errors.New("*streamHandler.StreamDidOutputSampleBufferOfType not implemented")) +} + +// StreamDelegate methods + +func (sh *screenCaptureHandler) StreamDidStopWithError(s screencapturekit.Stream, err foundation.Error) { + fmt.Println("StreamDidStopWithError", err) +} +func (sh *screenCaptureHandler) HasStreamDidStopWithError() bool { + fmt.Println("HasStreamDidStopWithError") + return true +} diff --git a/macos/screencapturekit/content_filter.gen.go b/macos/screencapturekit/content_filter.gen.go new file mode 100644 index 00000000..0ed6b786 --- /dev/null +++ b/macos/screencapturekit/content_filter.gen.go @@ -0,0 +1,82 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [ContentFilter] class. +var ContentFilterClass = _ContentFilterClass{objc.GetClass("SCContentFilter")} + +type _ContentFilterClass struct { + objc.Class +} + +// An interface definition for the [ContentFilter] class. +type IContentFilter interface { + objc.IObject +} + +// An object that filters the content a stream captures. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/sccontentfilter?language=objc +type ContentFilter struct { + objc.Object +} + +func ContentFilterFrom(ptr unsafe.Pointer) ContentFilter { + return ContentFilter{ + Object: objc.ObjectFrom(ptr), + } +} + +func (c_ ContentFilter) InitWithDisplayIncludingWindows(display IDisplay, includedWindows []IWindow) ContentFilter { + rv := objc.Call[ContentFilter](c_, objc.Sel("initWithDisplay:includingWindows:"), objc.Ptr(display), includedWindows) + return rv +} + +// Creates a filter that captures only specific windows from a display. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/sccontentfilter/3919808-initwithdisplay?language=objc +func NewContentFilterWithDisplayIncludingWindows(display IDisplay, includedWindows []IWindow) ContentFilter { + instance := ContentFilterClass.Alloc().InitWithDisplayIncludingWindows(display, includedWindows) + instance.Autorelease() + return instance +} + +func (c_ ContentFilter) InitWithDesktopIndependentWindow(window IWindow) ContentFilter { + rv := objc.Call[ContentFilter](c_, objc.Sel("initWithDesktopIndependentWindow:"), objc.Ptr(window)) + return rv +} + +// Creates a filter that captures only the specified window. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/sccontentfilter/3919804-initwithdesktopindependentwindow?language=objc +func NewContentFilterWithDesktopIndependentWindow(window IWindow) ContentFilter { + instance := ContentFilterClass.Alloc().InitWithDesktopIndependentWindow(window) + instance.Autorelease() + return instance +} + +func (cc _ContentFilterClass) Alloc() ContentFilter { + rv := objc.Call[ContentFilter](cc, objc.Sel("alloc")) + return rv +} + +func (cc _ContentFilterClass) New() ContentFilter { + rv := objc.Call[ContentFilter](cc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewContentFilter() ContentFilter { + return ContentFilterClass.New() +} + +func (c_ ContentFilter) Init() ContentFilter { + rv := objc.Call[ContentFilter](c_, objc.Sel("init")) + return rv +} diff --git a/macos/screencapturekit/display.gen.go b/macos/screencapturekit/display.gen.go new file mode 100644 index 00000000..7df4aed8 --- /dev/null +++ b/macos/screencapturekit/display.gen.go @@ -0,0 +1,91 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/macos/coregraphics" + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [Display] class. +var DisplayClass = _DisplayClass{objc.GetClass("SCDisplay")} + +type _DisplayClass struct { + objc.Class +} + +// An interface definition for the [Display] class. +type IDisplay interface { + objc.IObject + Width() int + Height() int + DisplayID() coregraphics.DirectDisplayID + Frame() coregraphics.Rect +} + +// An object that represents a display device. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scdisplay?language=objc +type Display struct { + objc.Object +} + +func DisplayFrom(ptr unsafe.Pointer) Display { + return Display{ + Object: objc.ObjectFrom(ptr), + } +} + +func (dc _DisplayClass) Alloc() Display { + rv := objc.Call[Display](dc, objc.Sel("alloc")) + return rv +} + +func (dc _DisplayClass) New() Display { + rv := objc.Call[Display](dc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewDisplay() Display { + return DisplayClass.New() +} + +func (d_ Display) Init() Display { + rv := objc.Call[Display](d_, objc.Sel("init")) + return rv +} + +// The width of the display in points. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scdisplay/3916722-width?language=objc +func (d_ Display) Width() int { + rv := objc.Call[int](d_, objc.Sel("width")) + return rv +} + +// The height of the display in points. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scdisplay/3916721-height?language=objc +func (d_ Display) Height() int { + rv := objc.Call[int](d_, objc.Sel("height")) + return rv +} + +// The Core Graphics display identifier. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scdisplay/3916720-displayid?language=objc +func (d_ Display) DisplayID() coregraphics.DirectDisplayID { + rv := objc.Call[coregraphics.DirectDisplayID](d_, objc.Sel("displayID")) + return rv +} + +// The frame of the display. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scdisplay/3919798-frame?language=objc +func (d_ Display) Frame() coregraphics.Rect { + rv := objc.Call[coregraphics.Rect](d_, objc.Sel("frame")) + return rv +} diff --git a/macos/screencapturekit/doc.gen.go b/macos/screencapturekit/doc.gen.go new file mode 100644 index 00000000..75f2d762 --- /dev/null +++ b/macos/screencapturekit/doc.gen.go @@ -0,0 +1,8 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +// Filter and select screen content and stream it to your app. +// +// [Apple Documentation] +// +// [Apple Documentation]: https://developer.apple.com/documentation/screencapturekit?language=objc +package screencapturekit diff --git a/macos/screencapturekit/enumtypes.gen.go b/macos/screencapturekit/enumtypes.gen.go new file mode 100644 index 00000000..d1060383 --- /dev/null +++ b/macos/screencapturekit/enumtypes.gen.go @@ -0,0 +1,64 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +// Status values for a frame from a stream. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scframestatus?language=objc +type FrameStatus int + +const ( + FrameStatusBlank FrameStatus = 2 + FrameStatusComplete FrameStatus = 0 + FrameStatusIdle FrameStatus = 1 + FrameStatusStarted FrameStatus = 4 + FrameStatusStopped FrameStatus = 5 + FrameStatusSuspended FrameStatus = 3 +) + +// Error conditions that occur in framework operations. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamerrorcode?language=objc +type StreamErrorCode int + +const ( + StreamErrorAttemptToConfigState StreamErrorCode = -3810 + StreamErrorAttemptToStartStreamState StreamErrorCode = -3807 + StreamErrorAttemptToStopStreamState StreamErrorCode = -3808 + StreamErrorAttemptToUpdateFilterState StreamErrorCode = -3809 + StreamErrorFailedApplicationConnectionInterrupted StreamErrorCode = -3805 + StreamErrorFailedApplicationConnectionInvalid StreamErrorCode = -3804 + StreamErrorFailedNoMatchingApplicationContext StreamErrorCode = -3806 + StreamErrorFailedToStart StreamErrorCode = -3802 + StreamErrorInternalError StreamErrorCode = -3811 + StreamErrorInvalidParameter StreamErrorCode = -3812 + StreamErrorMissingEntitlements StreamErrorCode = -3803 + StreamErrorNoCaptureSource StreamErrorCode = -3815 + StreamErrorNoDisplayList StreamErrorCode = -3814 + StreamErrorNoWindowList StreamErrorCode = -3813 + StreamErrorRemovingStream StreamErrorCode = -3816 + StreamErrorUserDeclined StreamErrorCode = -3801 +) + +// A structure that defines keys you use to retrieve metadata from a frame the system captures. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamframeinfo?language=objc +type StreamFrameInfo string + +const ( + StreamFrameInfoContentRect StreamFrameInfo = "SCStreamUpdateFrameContentRect" + StreamFrameInfoContentScale StreamFrameInfo = "SCStreamUpdateFrameContentScale" + StreamFrameInfoDirtyRects StreamFrameInfo = "SCStreamUpdateFrameDirtyRect" + StreamFrameInfoDisplayTime StreamFrameInfo = "SCStreamUpdateFrameDisplayTime" + StreamFrameInfoScaleFactor StreamFrameInfo = "SCStreamUpdateFrameDisplayResolution" + StreamFrameInfoStatus StreamFrameInfo = "SCStreamUpdateFrameStatus" +) + +// Constants that represent output types for a stream. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamoutputtype?language=objc +type StreamOutputType int + +const ( + StreamOutputTypeScreen StreamOutputType = 0 +) diff --git a/macos/screencapturekit/protocols.gen.m b/macos/screencapturekit/protocols.gen.m new file mode 100644 index 00000000..1148d1f6 --- /dev/null +++ b/macos/screencapturekit/protocols.gen.m @@ -0,0 +1,9 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +#import "ScreenCaptureKit/ScreenCaptureKit.h" + +void importScreenCaptureKitProtocols() { + id o; + o = @protocol(SCStreamDelegate); + o = @protocol(SCStreamOutput); +} diff --git a/macos/screencapturekit/running_application.gen.go b/macos/screencapturekit/running_application.gen.go new file mode 100644 index 00000000..83b6c970 --- /dev/null +++ b/macos/screencapturekit/running_application.gen.go @@ -0,0 +1,72 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [RunningApplication] class. +var RunningApplicationClass = _RunningApplicationClass{objc.GetClass("SCRunningApplication")} + +type _RunningApplicationClass struct { + objc.Class +} + +// An interface definition for the [RunningApplication] class. +type IRunningApplication interface { + objc.IObject + BundleIdentifier() string + ApplicationName() string +} + +// An object that represents an app running on a device. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scrunningapplication?language=objc +type RunningApplication struct { + objc.Object +} + +func RunningApplicationFrom(ptr unsafe.Pointer) RunningApplication { + return RunningApplication{ + Object: objc.ObjectFrom(ptr), + } +} + +func (rc _RunningApplicationClass) Alloc() RunningApplication { + rv := objc.Call[RunningApplication](rc, objc.Sel("alloc")) + return rv +} + +func (rc _RunningApplicationClass) New() RunningApplication { + rv := objc.Call[RunningApplication](rc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewRunningApplication() RunningApplication { + return RunningApplicationClass.New() +} + +func (r_ RunningApplication) Init() RunningApplication { + rv := objc.Call[RunningApplication](r_, objc.Sel("init")) + return rv +} + +// The unique bundle identifier of the app. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scrunningapplication/3919799-bundleidentifier?language=objc +func (r_ RunningApplication) BundleIdentifier() string { + rv := objc.Call[string](r_, objc.Sel("bundleIdentifier")) + return rv +} + +// The display name of the app. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scrunningapplication/3916724-applicationname?language=objc +func (r_ RunningApplication) ApplicationName() string { + rv := objc.Call[string](r_, objc.Sel("applicationName")) + return rv +} diff --git a/macos/screencapturekit/screencapturekit.go b/macos/screencapturekit/screencapturekit.go new file mode 100644 index 00000000..8c91ba47 --- /dev/null +++ b/macos/screencapturekit/screencapturekit.go @@ -0,0 +1,6 @@ +//go:generate go run ../../generate/tools/genmod.go +package screencapturekit + +// #cgo CFLAGS: -x objective-c +// #cgo LDFLAGS: -framework ScreenCaptureKit +import "C" diff --git a/macos/screencapturekit/screencapturekit_custom.go b/macos/screencapturekit/screencapturekit_custom.go new file mode 100644 index 00000000..040ff5c6 --- /dev/null +++ b/macos/screencapturekit/screencapturekit_custom.go @@ -0,0 +1 @@ +package screencapturekit diff --git a/macos/screencapturekit/screencapturekit_test.go b/macos/screencapturekit/screencapturekit_test.go new file mode 100644 index 00000000..f832119e --- /dev/null +++ b/macos/screencapturekit/screencapturekit_test.go @@ -0,0 +1,5 @@ +package screencapturekit + +import "testing" + +func TestScreenCaptureKitValid(t *testing.T) {} diff --git a/macos/screencapturekit/shareable_content.gen.go b/macos/screencapturekit/shareable_content.gen.go new file mode 100644 index 00000000..dac8dde6 --- /dev/null +++ b/macos/screencapturekit/shareable_content.gen.go @@ -0,0 +1,110 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/macos/foundation" + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [ShareableContent] class. +var ShareableContentClass = _ShareableContentClass{objc.GetClass("SCShareableContent")} + +type _ShareableContentClass struct { + objc.Class +} + +// An interface definition for the [ShareableContent] class. +type IShareableContent interface { + objc.IObject + Windows() []Window + Displays() []Display + Applications() []RunningApplication +} + +// An object that represents a set of displays, apps, and windows that your app can capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent?language=objc +type ShareableContent struct { + objc.Object +} + +func ShareableContentFrom(ptr unsafe.Pointer) ShareableContent { + return ShareableContent{ + Object: objc.ObjectFrom(ptr), + } +} + +func (sc _ShareableContentClass) Alloc() ShareableContent { + rv := objc.Call[ShareableContent](sc, objc.Sel("alloc")) + return rv +} + +func (sc _ShareableContentClass) New() ShareableContent { + rv := objc.Call[ShareableContent](sc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewShareableContent() ShareableContent { + return ShareableContentClass.New() +} + +func (s_ ShareableContent) Init() ShareableContent { + rv := objc.Call[ShareableContent](s_, objc.Sel("init")) + return rv +} + +// Retrieves the displays, apps, and windows that your app can capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916733-getshareablecontentwithcompletio?language=objc +func (sc _ShareableContentClass) GetShareableContentWithCompletionHandler(completionHandler func(shareableContent ShareableContent, error foundation.Error)) { + objc.Call[objc.Void](sc, objc.Sel("getShareableContentWithCompletionHandler:"), completionHandler) +} + +// Retrieves the displays, apps, and windows that your app can capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916733-getshareablecontentwithcompletio?language=objc +func ShareableContent_GetShareableContentWithCompletionHandler(completionHandler func(shareableContent ShareableContent, error foundation.Error)) { + ShareableContentClass.GetShareableContentWithCompletionHandler(completionHandler) +} + +// Retrieves the displays, apps, and windows that are behind the specified window. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916732-getshareablecontentexcludingdesk?language=objc +func (sc _ShareableContentClass) GetShareableContentExcludingDesktopWindowsOnScreenWindowsOnlyBelowWindowCompletionHandler(excludeDesktopWindows bool, window IWindow, completionHandler func(shareableContent ShareableContent, error foundation.Error)) { + objc.Call[objc.Void](sc, objc.Sel("getShareableContentExcludingDesktopWindows:onScreenWindowsOnlyBelowWindow:completionHandler:"), excludeDesktopWindows, objc.Ptr(window), completionHandler) +} + +// Retrieves the displays, apps, and windows that are behind the specified window. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916732-getshareablecontentexcludingdesk?language=objc +func ShareableContent_GetShareableContentExcludingDesktopWindowsOnScreenWindowsOnlyBelowWindowCompletionHandler(excludeDesktopWindows bool, window IWindow, completionHandler func(shareableContent ShareableContent, error foundation.Error)) { + ShareableContentClass.GetShareableContentExcludingDesktopWindowsOnScreenWindowsOnlyBelowWindowCompletionHandler(excludeDesktopWindows, window, completionHandler) +} + +// The windows that are available to capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916734-windows?language=objc +func (s_ ShareableContent) Windows() []Window { + rv := objc.Call[[]Window](s_, objc.Sel("windows")) + return rv +} + +// The displays that are available to capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916729-displays?language=objc +func (s_ ShareableContent) Displays() []Display { + rv := objc.Call[[]Display](s_, objc.Sel("displays")) + return rv +} + +// The apps that are available to capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scshareablecontent/3916728-applications?language=objc +func (s_ ShareableContent) Applications() []RunningApplication { + rv := objc.Call[[]RunningApplication](s_, objc.Sel("applications")) + return rv +} diff --git a/macos/screencapturekit/stream.gen.go b/macos/screencapturekit/stream.gen.go new file mode 100644 index 00000000..25aa9ff8 --- /dev/null +++ b/macos/screencapturekit/stream.gen.go @@ -0,0 +1,141 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/dispatch" + "github.com/progrium/macdriver/macos/foundation" + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [Stream] class. +var StreamClass = _StreamClass{objc.GetClass("SCStream")} + +type _StreamClass struct { + objc.Class +} + +// An interface definition for the [Stream] class. +type IStream interface { + objc.IObject + RemoveStreamOutputTypeError(output PStreamOutput, type_ StreamOutputType, error foundation.IError) bool + RemoveStreamOutputObjectTypeError(outputObject objc.IObject, type_ StreamOutputType, error foundation.IError) bool + StopCaptureWithCompletionHandler(completionHandler func(error foundation.Error)) + AddStreamOutputTypeSampleHandlerQueueError(output PStreamOutput, type_ StreamOutputType, sampleHandlerQueue dispatch.Queue, error foundation.IError) bool + AddStreamOutputObjectTypeSampleHandlerQueueError(outputObject objc.IObject, type_ StreamOutputType, sampleHandlerQueue dispatch.Queue, error foundation.IError) bool + UpdateConfigurationCompletionHandler(streamConfig IStreamConfiguration, completionHandler func(error foundation.Error)) + StartCaptureWithCompletionHandler(completionHandler func(error foundation.Error)) + UpdateContentFilterCompletionHandler(contentFilter IContentFilter, completionHandler func(error foundation.Error)) +} + +// An object that represents a stream of shareable content. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream?language=objc +type Stream struct { + objc.Object +} + +func StreamFrom(ptr unsafe.Pointer) Stream { + return Stream{ + Object: objc.ObjectFrom(ptr), + } +} + +func (s_ Stream) InitWithFilterConfigurationDelegate(contentFilter IContentFilter, streamConfig IStreamConfiguration, delegate PStreamDelegate) Stream { + po2 := objc.WrapAsProtocol("SCStreamDelegate", delegate) + rv := objc.Call[Stream](s_, objc.Sel("initWithFilter:configuration:delegate:"), objc.Ptr(contentFilter), objc.Ptr(streamConfig), po2) + return rv +} + +// Creates a stream with a content filter and configuration. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928169-initwithfilter?language=objc +func NewStreamWithFilterConfigurationDelegate(contentFilter IContentFilter, streamConfig IStreamConfiguration, delegate PStreamDelegate) Stream { + instance := StreamClass.Alloc().InitWithFilterConfigurationDelegate(contentFilter, streamConfig, delegate) + instance.Autorelease() + return instance +} + +func (sc _StreamClass) Alloc() Stream { + rv := objc.Call[Stream](sc, objc.Sel("alloc")) + return rv +} + +func (sc _StreamClass) New() Stream { + rv := objc.Call[Stream](sc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewStream() Stream { + return StreamClass.New() +} + +func (s_ Stream) Init() Stream { + rv := objc.Call[Stream](s_, objc.Sel("init")) + return rv +} + +// Removes a destination from receiving stream output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928170-removestreamoutput?language=objc +func (s_ Stream) RemoveStreamOutputTypeError(output PStreamOutput, type_ StreamOutputType, error foundation.IError) bool { + po0 := objc.WrapAsProtocol("SCStreamOutput", output) + rv := objc.Call[bool](s_, objc.Sel("removeStreamOutput:type:error:"), po0, type_, objc.Ptr(error)) + return rv +} + +// Removes a destination from receiving stream output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928170-removestreamoutput?language=objc +func (s_ Stream) RemoveStreamOutputObjectTypeError(outputObject objc.IObject, type_ StreamOutputType, error foundation.IError) bool { + rv := objc.Call[bool](s_, objc.Sel("removeStreamOutput:type:error:"), objc.Ptr(outputObject), type_, objc.Ptr(error)) + return rv +} + +// Stops the stream. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928172-stopcapturewithcompletionhandler?language=objc +func (s_ Stream) StopCaptureWithCompletionHandler(completionHandler func(error foundation.Error)) { + objc.Call[objc.Void](s_, objc.Sel("stopCaptureWithCompletionHandler:"), completionHandler) +} + +// Adds a destination that receives the stream output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928168-addstreamoutput?language=objc +func (s_ Stream) AddStreamOutputTypeSampleHandlerQueueError(output PStreamOutput, type_ StreamOutputType, sampleHandlerQueue dispatch.Queue, error foundation.IError) bool { + po0 := objc.WrapAsProtocol("SCStreamOutput", output) + rv := objc.Call[bool](s_, objc.Sel("addStreamOutput:type:sampleHandlerQueue:error:"), po0, type_, sampleHandlerQueue, objc.Ptr(error)) + return rv +} + +// Adds a destination that receives the stream output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928168-addstreamoutput?language=objc +func (s_ Stream) AddStreamOutputObjectTypeSampleHandlerQueueError(outputObject objc.IObject, type_ StreamOutputType, sampleHandlerQueue dispatch.Queue, error foundation.IError) bool { + rv := objc.Call[bool](s_, objc.Sel("addStreamOutput:type:sampleHandlerQueue:error:"), objc.Ptr(outputObject), type_, sampleHandlerQueue, objc.Ptr(error)) + return rv +} + +// Updates the stream with a new configuration. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928173-updateconfiguration?language=objc +func (s_ Stream) UpdateConfigurationCompletionHandler(streamConfig IStreamConfiguration, completionHandler func(error foundation.Error)) { + objc.Call[objc.Void](s_, objc.Sel("updateConfiguration:completionHandler:"), objc.Ptr(streamConfig), completionHandler) +} + +// Starts the stream with a callback to indicate whether it successfully starts. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3928171-startcapturewithcompletionhandle?language=objc +func (s_ Stream) StartCaptureWithCompletionHandler(completionHandler func(error foundation.Error)) { + objc.Call[objc.Void](s_, objc.Sel("startCaptureWithCompletionHandler:"), completionHandler) +} + +// Updates the stream by applying a new content filter. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstream/3916740-updatecontentfilter?language=objc +func (s_ Stream) UpdateContentFilterCompletionHandler(contentFilter IContentFilter, completionHandler func(error foundation.Error)) { + objc.Call[objc.Void](s_, objc.Sel("updateContentFilter:completionHandler:"), objc.Ptr(contentFilter), completionHandler) +} diff --git a/macos/screencapturekit/stream_configuration.gen.go b/macos/screencapturekit/stream_configuration.gen.go new file mode 100644 index 00000000..aeaa2c6f --- /dev/null +++ b/macos/screencapturekit/stream_configuration.gen.go @@ -0,0 +1,261 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/macos/corefoundation" + "github.com/progrium/macdriver/macos/coregraphics" + "github.com/progrium/macdriver/macos/coremedia" + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [StreamConfiguration] class. +var StreamConfigurationClass = _StreamConfigurationClass{objc.GetClass("SCStreamConfiguration")} + +type _StreamConfigurationClass struct { + objc.Class +} + +// An interface definition for the [StreamConfiguration] class. +type IStreamConfiguration interface { + objc.IObject + Width() uint + SetWidth(value uint) + QueueDepth() int + SetQueueDepth(value int) + ShowsCursor() bool + SetShowsCursor(value bool) + Height() uint + SetHeight(value uint) + ColorSpaceName() corefoundation.StringRef + SetColorSpaceName(value corefoundation.StringRef) + BackgroundColor() coregraphics.ColorRef + SetBackgroundColor(value coregraphics.ColorRef) + SourceRect() coregraphics.Rect + SetSourceRect(value coregraphics.Rect) + MinimumFrameInterval() coremedia.Time + SetMinimumFrameInterval(value coremedia.Time) + PixelFormat() uint + SetPixelFormat(value uint) + DestinationRect() coregraphics.Rect + SetDestinationRect(value coregraphics.Rect) + ColorMatrix() corefoundation.StringRef + SetColorMatrix(value corefoundation.StringRef) + ScalesToFit() bool + SetScalesToFit(value bool) +} + +// An object that provides the output configuration for a stream. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration?language=objc +type StreamConfiguration struct { + objc.Object +} + +func StreamConfigurationFrom(ptr unsafe.Pointer) StreamConfiguration { + return StreamConfiguration{ + Object: objc.ObjectFrom(ptr), + } +} + +func (sc _StreamConfigurationClass) Alloc() StreamConfiguration { + rv := objc.Call[StreamConfiguration](sc, objc.Sel("alloc")) + return rv +} + +func (sc _StreamConfigurationClass) New() StreamConfiguration { + rv := objc.Call[StreamConfiguration](sc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewStreamConfiguration() StreamConfiguration { + return StreamConfigurationClass.New() +} + +func (s_ StreamConfiguration) Init() StreamConfiguration { + rv := objc.Call[StreamConfiguration](s_, objc.Sel("init")) + return rv +} + +// The width of the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919830-width?language=objc +func (s_ StreamConfiguration) Width() uint { + rv := objc.Call[uint](s_, objc.Sel("width")) + return rv +} + +// The width of the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919830-width?language=objc +func (s_ StreamConfiguration) SetWidth(value uint) { + objc.Call[objc.Void](s_, objc.Sel("setWidth:"), value) +} + +// The maximum number of frames for the queue to store. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919826-queuedepth?language=objc +func (s_ StreamConfiguration) QueueDepth() int { + rv := objc.Call[int](s_, objc.Sel("queueDepth")) + return rv +} + +// The maximum number of frames for the queue to store. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919826-queuedepth?language=objc +func (s_ StreamConfiguration) SetQueueDepth(value int) { + objc.Call[objc.Void](s_, objc.Sel("setQueueDepth:"), value) +} + +// A Boolean value that determines whether the cursor is visible in the stream. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919828-showscursor?language=objc +func (s_ StreamConfiguration) ShowsCursor() bool { + rv := objc.Call[bool](s_, objc.Sel("showsCursor")) + return rv +} + +// A Boolean value that determines whether the cursor is visible in the stream. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919828-showscursor?language=objc +func (s_ StreamConfiguration) SetShowsCursor(value bool) { + objc.Call[objc.Void](s_, objc.Sel("setShowsCursor:"), value) +} + +// The height of the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919823-height?language=objc +func (s_ StreamConfiguration) Height() uint { + rv := objc.Call[uint](s_, objc.Sel("height")) + return rv +} + +// The height of the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919823-height?language=objc +func (s_ StreamConfiguration) SetHeight(value uint) { + objc.Call[objc.Void](s_, objc.Sel("setHeight:"), value) +} + +// A color space to use for the output buffer. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919821-colorspacename?language=objc +func (s_ StreamConfiguration) ColorSpaceName() corefoundation.StringRef { + rv := objc.Call[corefoundation.StringRef](s_, objc.Sel("colorSpaceName")) + return rv +} + +// A color space to use for the output buffer. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919821-colorspacename?language=objc +func (s_ StreamConfiguration) SetColorSpaceName(value corefoundation.StringRef) { + objc.Call[objc.Void](s_, objc.Sel("setColorSpaceName:"), value) +} + +// A background color for the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919819-backgroundcolor?language=objc +func (s_ StreamConfiguration) BackgroundColor() coregraphics.ColorRef { + rv := objc.Call[coregraphics.ColorRef](s_, objc.Sel("backgroundColor")) + return rv +} + +// A background color for the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919819-backgroundcolor?language=objc +func (s_ StreamConfiguration) SetBackgroundColor(value coregraphics.ColorRef) { + objc.Call[objc.Void](s_, objc.Sel("setBackgroundColor:"), value) +} + +// A rectangle that specifies the source area to capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919829-sourcerect?language=objc +func (s_ StreamConfiguration) SourceRect() coregraphics.Rect { + rv := objc.Call[coregraphics.Rect](s_, objc.Sel("sourceRect")) + return rv +} + +// A rectangle that specifies the source area to capture. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919829-sourcerect?language=objc +func (s_ StreamConfiguration) SetSourceRect(value coregraphics.Rect) { + objc.Call[objc.Void](s_, objc.Sel("setSourceRect:"), value) +} + +// The desired minimum time between frame updates, in seconds. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3928174-minimumframeinterval?language=objc +func (s_ StreamConfiguration) MinimumFrameInterval() coremedia.Time { + rv := objc.Call[coremedia.Time](s_, objc.Sel("minimumFrameInterval")) + return rv +} + +// The desired minimum time between frame updates, in seconds. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3928174-minimumframeinterval?language=objc +func (s_ StreamConfiguration) SetMinimumFrameInterval(value coremedia.Time) { + objc.Call[objc.Void](s_, objc.Sel("setMinimumFrameInterval:"), value) +} + +// A pixel format for sample buffers that a stream outputs. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919825-pixelformat?language=objc +func (s_ StreamConfiguration) PixelFormat() uint { + rv := objc.Call[uint](s_, objc.Sel("pixelFormat")) + return rv +} + +// A pixel format for sample buffers that a stream outputs. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919825-pixelformat?language=objc +func (s_ StreamConfiguration) SetPixelFormat(value uint) { + objc.Call[objc.Void](s_, objc.Sel("setPixelFormat:"), value) +} + +// A rectangle that specifies a destination into which to write the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919822-destinationrect?language=objc +func (s_ StreamConfiguration) DestinationRect() coregraphics.Rect { + rv := objc.Call[coregraphics.Rect](s_, objc.Sel("destinationRect")) + return rv +} + +// A rectangle that specifies a destination into which to write the output. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919822-destinationrect?language=objc +func (s_ StreamConfiguration) SetDestinationRect(value coregraphics.Rect) { + objc.Call[objc.Void](s_, objc.Sel("setDestinationRect:"), value) +} + +// A color matrix to apply to the output surface. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919820-colormatrix?language=objc +func (s_ StreamConfiguration) ColorMatrix() corefoundation.StringRef { + rv := objc.Call[corefoundation.StringRef](s_, objc.Sel("colorMatrix")) + return rv +} + +// A color matrix to apply to the output surface. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919820-colormatrix?language=objc +func (s_ StreamConfiguration) SetColorMatrix(value corefoundation.StringRef) { + objc.Call[objc.Void](s_, objc.Sel("setColorMatrix:"), value) +} + +// A Boolean value that indicates whether to scale the output to fit the configured width and height. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919827-scalestofit?language=objc +func (s_ StreamConfiguration) ScalesToFit() bool { + rv := objc.Call[bool](s_, objc.Sel("scalesToFit")) + return rv +} + +// A Boolean value that indicates whether to scale the output to fit the configured width and height. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamconfiguration/3919827-scalestofit?language=objc +func (s_ StreamConfiguration) SetScalesToFit(value bool) { + objc.Call[objc.Void](s_, objc.Sel("setScalesToFit:"), value) +} diff --git a/macos/screencapturekit/stream_delegate.gen.go b/macos/screencapturekit/stream_delegate.gen.go new file mode 100644 index 00000000..589b4f8c --- /dev/null +++ b/macos/screencapturekit/stream_delegate.gen.go @@ -0,0 +1,59 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "github.com/progrium/macdriver/macos/foundation" + "github.com/progrium/macdriver/objc" +) + +// A delegate protocol to adopt to respond to stream events. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamdelegate?language=objc +type PStreamDelegate interface { + // optional + StreamDidStopWithError(stream Stream, error foundation.Error) + HasStreamDidStopWithError() bool +} + +// A delegate implementation builder for the [PStreamDelegate] protocol. +type StreamDelegate struct { + _StreamDidStopWithError func(stream Stream, error foundation.Error) +} + +func (di *StreamDelegate) HasStreamDidStopWithError() bool { + return di._StreamDidStopWithError != nil +} + +// Tells the delegate that the stream stopped with an error. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamdelegate/3916743-stream?language=objc +func (di *StreamDelegate) SetStreamDidStopWithError(f func(stream Stream, error foundation.Error)) { + di._StreamDidStopWithError = f +} + +// Tells the delegate that the stream stopped with an error. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamdelegate/3916743-stream?language=objc +func (di *StreamDelegate) StreamDidStopWithError(stream Stream, error foundation.Error) { + di._StreamDidStopWithError(stream, error) +} + +// ensure impl type implements protocol interface +var _ PStreamDelegate = (*StreamDelegateObject)(nil) + +// A concrete type for the [PStreamDelegate] protocol. +type StreamDelegateObject struct { + objc.Object +} + +func (s_ StreamDelegateObject) HasStreamDidStopWithError() bool { + return s_.RespondsToSelector(objc.Sel("stream:didStopWithError:")) +} + +// Tells the delegate that the stream stopped with an error. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamdelegate/3916743-stream?language=objc +func (s_ StreamDelegateObject) StreamDidStopWithError(stream Stream, error foundation.Error) { + objc.Call[objc.Void](s_, objc.Sel("stream:didStopWithError:"), objc.Ptr(stream), objc.Ptr(error)) +} diff --git a/macos/screencapturekit/stream_output_protocol.gen.go b/macos/screencapturekit/stream_output_protocol.gen.go new file mode 100644 index 00000000..9f469dfe --- /dev/null +++ b/macos/screencapturekit/stream_output_protocol.gen.go @@ -0,0 +1,36 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "github.com/progrium/macdriver/macos/coremedia" + "github.com/progrium/macdriver/objc" +) + +// A protocol you adopt to receive stream output events. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamoutput?language=objc +type PStreamOutput interface { + // optional + StreamDidOutputSampleBufferOfType(stream Stream, sampleBuffer coremedia.SampleBufferRef, type_ StreamOutputType) + HasStreamDidOutputSampleBufferOfType() bool +} + +// ensure impl type implements protocol interface +var _ PStreamOutput = (*StreamOutputObject)(nil) + +// A concrete type for the [PStreamOutput] protocol. +type StreamOutputObject struct { + objc.Object +} + +func (s_ StreamOutputObject) HasStreamDidOutputSampleBufferOfType() bool { + return s_.RespondsToSelector(objc.Sel("stream:didOutputSampleBuffer:ofType:")) +} + +// Tells the delegate that the stream produced a video frame. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scstreamoutput/3928182-stream?language=objc +func (s_ StreamOutputObject) StreamDidOutputSampleBufferOfType(stream Stream, sampleBuffer coremedia.SampleBufferRef, type_ StreamOutputType) { + objc.Call[objc.Void](s_, objc.Sel("stream:didOutputSampleBuffer:ofType:"), objc.Ptr(stream), sampleBuffer, type_) +} diff --git a/macos/screencapturekit/window.gen.go b/macos/screencapturekit/window.gen.go new file mode 100644 index 00000000..8add0f21 --- /dev/null +++ b/macos/screencapturekit/window.gen.go @@ -0,0 +1,109 @@ +// Code generated by DarwinKit. DO NOT EDIT. + +package screencapturekit + +import ( + "unsafe" + + "github.com/progrium/macdriver/macos/coregraphics" + "github.com/progrium/macdriver/objc" +) + +// The class instance for the [Window] class. +var WindowClass = _WindowClass{objc.GetClass("SCWindow")} + +type _WindowClass struct { + objc.Class +} + +// An interface definition for the [Window] class. +type IWindow interface { + objc.IObject + OwningApplication() RunningApplication + WindowID() coregraphics.WindowID + WindowLayer() int + IsOnScreen() bool + Frame() coregraphics.Rect + Title() string +} + +// An object that represents an onscreen window. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow?language=objc +type Window struct { + objc.Object +} + +func WindowFrom(ptr unsafe.Pointer) Window { + return Window{ + Object: objc.ObjectFrom(ptr), + } +} + +func (wc _WindowClass) Alloc() Window { + rv := objc.Call[Window](wc, objc.Sel("alloc")) + return rv +} + +func (wc _WindowClass) New() Window { + rv := objc.Call[Window](wc, objc.Sel("new")) + rv.Autorelease() + return rv +} + +func NewWindow() Window { + return WindowClass.New() +} + +func (w_ Window) Init() Window { + rv := objc.Call[Window](w_, objc.Sel("init")) + return rv +} + +// The app that owns the window. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow/3916792-owningapplication?language=objc +func (w_ Window) OwningApplication() RunningApplication { + rv := objc.Call[RunningApplication](w_, objc.Sel("owningApplication")) + return rv +} + +// The Core Graphics window identifier. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow/3916793-windowid?language=objc +func (w_ Window) WindowID() coregraphics.WindowID { + rv := objc.Call[coregraphics.WindowID](w_, objc.Sel("windowID")) + return rv +} + +// The layer of the window relative to other windows. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow/3919802-windowlayer?language=objc +func (w_ Window) WindowLayer() int { + rv := objc.Call[int](w_, objc.Sel("windowLayer")) + return rv +} + +// A Boolean value that indicates whether the window is on screen. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow/3916790-onscreen?language=objc +func (w_ Window) IsOnScreen() bool { + rv := objc.Call[bool](w_, objc.Sel("isOnScreen")) + return rv +} + +// A rectangle the represents the frame of the window within a display. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow/3919800-frame?language=objc +func (w_ Window) Frame() coregraphics.Rect { + rv := objc.Call[coregraphics.Rect](w_, objc.Sel("frame")) + return rv +} + +// The string that displays in a window’s title bar. [Full Topic] +// +// [Full Topic]: https://developer.apple.com/documentation/screencapturekit/scwindow/3919801-title?language=objc +func (w_ Window) Title() string { + rv := objc.Call[string](w_, objc.Sel("title")) + return rv +}