Open tmc opened 10 months ago
whats wrong with the example?
whats wrong with the example?
it doesn't actually work -- I think we need to allocate a new DispatchQueue for this and need to be able to call c fns to do that.
@tmc maybe You just forgot to configure stream?
I used your code but added parameters for the SCStreamConfiguration
object and it looks like the StreamDidOutputSampleBufferOfType
method is called correctly and at the correct frequency. Additionally, I used a global queue, not an application. I still need to check if the buffer has the correct data, but it looks promising. If I find a moment, I can improve the example from your PR.
I remember reading somewhere on the internet that it is crucial to set minimumFrameInterval
in order to receive notifications about new frames at all.
The example below is from my application, but the methods are the same.
streamConfiguration := api.NewSCStreamConfiguration()
streamConfiguration.SetWidth(displayWidth)
streamConfiguration.SetHeight(displayHeight)
streamConfiguration.SetMinimumFrameInterval(api.CMTime{Value: 1, Timescale: int32(framerate)})
streamConfiguration.SetQueueDepth(3)
@tmc maybe You just forgot to configure stream?
I used your code but added parameters for the
SCStreamConfiguration
object and it looks like theStreamDidOutputSampleBufferOfType
method is called correctly and at the correct frequency. Additionally, I used a global queue, not an application. I still need to check if the buffer has the correct data, but it looks promising. If I find a moment, I can improve the example from your PR.I remember reading somewhere on the internet that it is crucial to set
minimumFrameInterval
in order to receive notifications about new frames at all.The example below is from my application, but the methods are the same.
streamConfiguration := api.NewSCStreamConfiguration() streamConfiguration.SetWidth(displayWidth) streamConfiguration.SetHeight(displayHeight) streamConfiguration.SetMinimumFrameInterval(api.CMTime{Value: 1, Timescale: int32(framerate)}) streamConfiguration.SetQueueDepth(3)
I have some further work on this branch: https://github.com/tmc/macdriver/tree/add-screencapturekit-debugging -- can you try to get it working? I think a very light wrapper might be needed for https://developer.apple.com/documentation/coremedia/1489563-cmsamplebuffercallforeachsample?language=objc to get at the sample data.
Sure, but I'm receiving errors about duplicated symbols from C code during compilation, even though there is no duplication at all. I've never encountered this problem before. Do you know what could be causing it?
$ /usr/local/opt/go/libexec/bin/go build -o /Users/sz-po/Library/Caches/JetBrains/GoLand2023.2/tmp/GoLand/___build_screencap . #gosetup
# github.com/progrium/macdriver/macos/_examples/screencap
/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running cc failed: exit status 1
ld: warning: -no_pie is deprecated when targeting new OS versions
duplicate symbol '_callGoFunction' in:
/var/folders/kx/mthnzv495450pln165x7hn1h0000gn/T/go-link-3764031552/000000.o
/var/folders/kx/mthnzv495450pln165x7hn1h0000gn/T/go-link-3764031552/000001.o
duplicate symbol '_setGoCallback' in:
/var/folders/kx/mthnzv495450pln165x7hn1h0000gn/T/go-link-3764031552/000000.o
/var/folders/kx/mthnzv495450pln165x7hn1h0000gn/T/go-link-3764031552/000001.o
duplicate symbol '_Go_CMSampleBufferCallForEachSample' in:
/var/folders/kx/mthnzv495450pln165x7hn1h0000gn/T/go-link-3764031552/000000.o
/var/folders/kx/mthnzv495450pln165x7hn1h0000gn/T/go-link-3764031552/000001.o
ld: 3 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've never seen it either and @tmc was able to reproduce without using macdriver at all, so I guess it's a weird cgo bug?
This adds screencapturekit bindings.
The example isn't fully functional.
Refs #227