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 13, 2023
1 parent 93bf217 commit 3b70a65
Show file tree
Hide file tree
Showing 15 changed files with 1,109 additions and 1 deletion.
66 changes: 66 additions & 0 deletions macos/_examples/screencap/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package main

import (
"context"
"errors"
"fmt"
"os"
"os/signal"

"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.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)
})

// wait until ctrl-c:
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
<-ctx.Done()
}

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
}
Binary file added macos/_examples/screencap/screencap
Binary file not shown.
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.

Loading

0 comments on commit 3b70a65

Please sign in to comment.