knightbenax / Cobalt

OSX Virtual Camera Plugin based on CoreMediaIO
9 stars 3 forks source link

How to send frames from a C++ application #1

Open Raj123456788 opened 3 years ago

Raj123456788 commented 3 years ago

I have asked this questions to every repository. I am pretty new to swift itself. I am looking for steps where I can send a buffer(dataptr*) to a plugin. Imagine you let user decide which image to be shown through a picker and send it to a plugin. Not sure why anyone has not done that yet. Thanks for the demo!

Raj123456788 commented 3 years ago

@knightbenax : can you please reply? if there is an sample application it would be great.

knightbenax commented 3 years ago

@Raj123456788 Hi, I haven't implemented that yet. But I did hope to do so soon. So hopefully before the week runs out, I would have something for you

Raj123456788 commented 3 years ago

@knightbenax :Thanks from C# person. I would appreciate if you can share some light/examples or repository on how you are planning to do it. So even I can try. I have been struggling with this since last week also have a deadline :) so far I have received response from https://github.com/zakk4223/CSVirtualCamera/issues/3

knightbenax commented 3 years ago

@Raj123456788 I think this repo can be a good place to start. All thought it's in Swift

https://github.com/kishikawakatsumi/VirtualCameraComposer-Example

Raj123456788 commented 3 years ago

@knightbenax I have already reported an issue: https://github.com/kishikawakatsumi/VirtualCameraComposer-Example/issues/1 Do you know what am I missing?It builds but nothing happens... can you please try to run it and let me know? Thanks!

Raj123456788 commented 3 years ago

Can I create lib.a from the plugin code instead of plugin and use it in C++?. Call the stream object? Just need a working sample :)

Raj123456788 commented 3 years ago

I am trying to take the swift files(PluginInterface,Stream, Device) and create a .app. You think that should work?

Raj123456788 commented 3 years ago

@knightbenax: Hey Buddy, will wait for you to post the application. Thanks!

knightbenax commented 3 years ago

@Raj123456788 so I have been able to solve it. It's pretty simple. You create a separate Window for Rendering to the plugin, if the app that controls the rendering. And get the windowID

Then in the CoreMediaIO Plugin you pass the windowID(through any means, notably through a local server you set running) to CGWindowListCreateImage. Which returns a CGImage that you can render in the pixelbuffer.

Raj123456788 commented 3 years ago

@knightbenax : I am not rendering the data to a window. Instead I am sending directly to the Plugin to render the data. Using Different plugin: I am able to send the data to a plugin running a server and change the background image but it is not 30 FPS. Working on it. Can you explain the set up? let request = URLRequest(url: URL(string: "http://127.0.0.1:34000/settings")!) self.session.dataTask(with: request) { (data, res, _) in if let data = data, let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] { self.settings = jsonObject } }.resume()

My data is coming from a terminal application. I replaced the url with my server still it cannot find the window ID

alokmahor commented 2 years ago

Can you help in How to send window id from another application to this plugin?