-
-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
screencapturekit: Add bindings for screencapturekit
- Loading branch information
Showing
15 changed files
with
1,109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.