Skip to content

Commit

Permalink
screencapturekit: Add bindings for screencapturekit
Browse files Browse the repository at this point in the history
  • Loading branch information
tmc committed Nov 22, 2023
1 parent 2653e6a commit bc05a8b
Show file tree
Hide file tree
Showing 14 changed files with 1,103 additions and 1 deletion.
60 changes: 60 additions & 0 deletions macos/_examples/screencap/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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() {
streamOutputHandler := &streamHandler{}

sc := screencapturekit.NewStreamConfiguration()
cf := screencapturekit.NewContentFilter()
s := screencapturekit.NewStreamWithFilterConfigurationDelegate(cf, sc, streamOutputHandler)

var dispatchQueue dispatch.Queue
//dispatchQueue = dispatch.CreateQueue("com.example.queue", dispatch.QueueTypeSerial)
dispatchQueue = dispatch.MainQueue()
err := foundation.Error{}
ok := s.AddStreamOutputTypeSampleHandlerQueueError(streamOutputHandler, 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 streamHandler struct{}

var _ screencapturekit.PStreamOutput = (*streamHandler)(nil)
var _ screencapturekit.PStreamDelegate = (*streamHandler)(nil)

// StreamOutput methods

func (sh *streamHandler) HasStreamDidOutputSampleBufferOfType() bool {
panic(errors.New("*streamHandler.HasStreamDidOutputSampleBufferOfType not implemented"))
}

func (sh *streamHandler) StreamDidOutputSampleBufferOfType(s screencapturekit.Stream, buf coremedia.SampleBufferRef, out screencapturekit.StreamOutputType) {
panic(errors.New("*streamHandler.StreamDidOutputSampleBufferOfType not implemented"))
}

// StreamDelegate methods

func (sh *streamHandler) StreamDidStopWithError(s screencapturekit.Stream, err foundation.Error) {
fmt.Println("StreamDidStopWithError", err)
}
func (sh *streamHandler) HasStreamDidStopWithError() bool {
fmt.Println("HasStreamDidStopWithError")
return true
}
82 changes: 82 additions & 0 deletions macos/screencapturekit/content_filter.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions macos/screencapturekit/display.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions macos/screencapturekit/doc.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions macos/screencapturekit/enumtypes.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions macos/screencapturekit/protocols.gen.m
Original file line number Diff line number Diff line change
@@ -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);
}
72 changes: 72 additions & 0 deletions macos/screencapturekit/running_application.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion macos/screencapturekit/screencapturekit_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package screencapturekit

import "testing"

func TestScreenCaptureKitValid(t *testing.T) {}
Loading

0 comments on commit bc05a8b

Please sign in to comment.