开发者

Calling Native(C++) Code in GWT

开发者 https://www.devze.com 2023-01-04 19:49 出处:网络
I am developing an application in GWT which needs to call a native C++ code in Directshow to do some multimedia processing.I am gue开发者_StackOverflowssing that I cant use JNI because GWT convertscod

I am developing an application in GWT which needs to call a native C++ code in Directshow to do some multimedia processing.I am gue开发者_StackOverflowssing that I cant use JNI because GWT converts code to javascript.I did have a look at similar posts on the forum(and on GWT site about JSNI) but cant find a example that specifically talks about calling C++ code from GWT(its mostly about calling Java code from Javascript).Can anyone throw some light on this or direct me to a tutorial?


Where exactly is this code supposed run? Surely not on the client-side. Client-side native code is nowhere near mass adoption.

GWT can either interface with JSNI in order to write native JS code inside your GWT Java code, or to interface with Java back-ends, whilst the framework handles the RPC. Even without GWT you have no way to run native code from within the browser (at least in the near future).

Bottom line - if you can't do it in plain vanilla Javascript on the client side, you can't do it in GWT.

What you can do is use this native code in the back-end, and call it via classic JNI from your Java back-end classes (and then what difference does it make if it's part of a GWT project or not?), but it sounds like this is not the case.


First of all, have a clear separation of Client (HTML / Javascript running in the browser) and server components (java service servlets).

If I understood your problem statement right, You need the UI to collect parameters for your transcoders and your transcoders need to run on a Windows box.

You can look up any simple GWT application to figure out how to serve a GWT application in any container (perhaps jetty for the time being) and process basic HTML form inputs. Once you have all the parameters on the server, you need to figure out how to delegate these parameters posted from the browser (your GWT application) from the service servlet (running within a web server) to your DirectShow application. This point onwards its a java application talking to a native process problem.

You can use various ways to communicate parameters to your native directshow application. Simplest solution is to initiate the application with the exec method passing command parameters inline. Otherwise you can communicate to a running native application via TCP sockets or integrate the native app using JNI. It all depends on your architectural design, which approach you wish to take.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号