Porting c++ code (native client) to browser (Web app) - c++

I have a c++ module written using Qt-creator SDK. I want to port this code to run on any webpage without compromising the source-code to end user. User should be able to see the output of this module on any browser(Chrome, Firefox, Safari, Explorer) without having to install any additional browser plugin. What are the better options available to achieve this. I have googled and found few such options:
Google Native client (NaCl) - But it runs only on Chrome. Is this the future of web applications??
PPAPI - Not sure if it is same as NaCl
NPAPI - almost depricated
Emscripten - It converts c++ to js. So source-code is visible to user.
WebAssembly
Are there any other options to achievce waht I am looking for? If not which one I should pick from the above options!? Many thanks in advance. a

Some clarification:
NaCl will not be supported by browsers other than Chrome. We (Google's NaCl/WebAssembly team) are more focused on WebAssembly for the future.
PPAPI is the set of APIs used by NaCl.
NPAPI: on the way out, and needs a plugin installation anyway.
Emscripten. It does compile C++ to JS, but I would not say that it reveals your source code to the user. It has been significantly transformed through the usual compilation and optimization process, and I would say it's closer to machine code than source code. In addition we are adding WebAssembly support to emscripten, so that with the same source you can produce WebAssembly for those browsers that support it, and asm.js for those that don't yet.
WebAssembly is the future, and will meet all of your criteria, with the caveat that the browser APIs and capabilities available to wasm are the same as those available to JavaScript. So you won't be able to get unlimited access to the user's filesystem, for example. All 4 major browser vendors are implementing webassembly, but it should appear in Chrome and Firefox first, because the release schedules of those browsers are uncoupled from their respective operating systems.
My suggestion would be to try porting your code with emscripten. You can start that today and use asm.js, and when WebAssembly launches, you can target that with minimal extra effort. In the future there will be other toolchains and languages that support wasm, but today emscripten is really the only ready-to-go option.

Related

How can I use WebRTC in a desktop application for voice chat?

I am trying to add voice chat between peers using my software - desktop application to desktop application over a network. My software is compatible with Windows and OSX. The difficulty is that there seems to be very little documentation on using the native API, and all the tutorials I've come across are out of date.
I started off by building the libraries and linking them in a new project, but as I mentioned, the tutorials I have found on the Internet are several years out of date, so I didn't get far with that.
So instead I built the native code, following these instructions https://webrtc.org/native-code/development/, and have successfully used peerconnection_client and -_server, which work great.
My problem now is that the peerconnection_client is more complicated than what I need, and I'm finding it difficult extracting the relevant parts (I want to remove the GUI, connect to a peer programmatically, and only transmit audio). And even if I do manage to strip down the peerconnection_client code, to just make voice calls through a terminal, it would still be lot of code to then embed into my program because it isn't linked to libraries, but raw code.
Has anyone else tried using WebRTC for native desktop applications in this way before? Is there any up to date documentation for this I can use? Any help would be greatly appreciated.
Best solution is to use this project :
CEF project
You will get mac os, windows and linux implementation from one project.
You can always update your cef library's to stay on road.
You can also use Firefox variant :
Firefox implementation
There is a lot of other ways like :
QT framework.
https://www.qt.io/
I've worked on a couple Voice/Video/Screen over IP projects using native C++ API, and my advice is: don't do it unless you have tons of time on your hands. Native API/samples is very much abandonware - Google devs keep it in sync with Chrome, but you're on your own, you'll have to dig through WebRTC & Chrome issues and PRs when your code stops working after updating to a newer release branch.
The only documentation is the source code itself, there's plenty of comments, but it's still very hard to figure things out. And those things tend to change from one release to another

Native code plugin for the most popular browsers

I need to write plugins for the most popular browsers such as:
Google Chrome
Opera
Mozilla Firefox
Safari
Edge
Yandex Browser
The problem is:
I have to use C++, cause I'm not enough skilled in web languages. Also I'm using extra lib for C++: OpenCV. Is there any ways of creating multiplatform cross-browser plugin? I have to add, that this plugin is only for PC version of browser.
If there is no such way, please tell me, how to make plugin for each browser using C++.
Maybe you can have a look at emscripten, it translates c++ code to javascript using llvm.

Is it possible to use Native C++ code in ARC?

We want to try to launch our software on Chrome OS using ARC. Many parts of our software application are written in C++ and compiled using the Android NDK.
Is it possible to launch this kind of application under ARC?
Is it possible to launch Native applications(or Java + JNI) under ARC?
Yes, ARM compiled NDK libraries will run on all Chromebooks currently. For ARM machines they run more or less natively.
For non-ARM machines there is a binary translation layer that dynamically converts the code to run on the target machine. This layer may not be 100% machine compatible and if you see errors or crashes indicating instructions cannot be translated, or fundamental differences between your app on ARM and x86, you should file a bug: http://goo.gl/megdlG
I am currently using a library in my project called PDFtron. It contains ".so" files that I have to assume are either c or c++, and they work fine with Java + JNI. There doesn't seems to be a lot of information out there about how this all works(and what works or doesn't), so please post your findings.
From google spokesperson(taken from arstechnica):
"""The app code is all running on top of the Chrome platform, specifically inside of Native Client. In this way the ARC (App Runtime for Chrome) apps run in the same environment as other apps you can download from the Chrome Web Store, even though they are written on top of standard Android APIs. The developers do not need to port or modify their code, though they often choose to improve it to work well with the Chromebook form factor (keyboard, touchpad, optional touchscreen, etc)."""
In this quote I think the important part is the integration with native client, which is a technology for executing Native code like C and C++ in the browser.

From C++ to Actionscript via FLASCC

I'm hoping to get some feedback from anyone who is familiar with BOTH C++ AND Actionscript. I am not a C++ coder unfortunately.
I am developing Kinect applications using the AIRKinect framework. Unfortunately a limitation of this framework is the lack of any useful gesture dection algorithms.
I came across this gesture recognition library built in C++.
http://www.nickgillian.com/wiki/pmwiki.php?n=GRT.FAQ
There is also the Flash C+++ cross compiler(formerly known as Alchemy)
http://gaming.adobe.com/technologies/flascc/
I was wondering if it might be possible to convert this gesture recognition library into a swc(Flash format) so I can use it with AIRKinect?
It's Possible.
FlasCC uses a version of LLVM-GCC 4.2 with a custom LLVM backend that
generates ActionScript bytecode capable of running within the Flash
Runtime. More specifically, the bytecode runs in the ActionScript
virtual machine (AVM). This lets you compile arbitrary C/C++ code into
a managed bytecode format capable of high performance execution within
the Flash Runtime on Mac, Windows, or Linux
more information read a FlasCC doucmentation: FlasCC
If you want download FlasCC. rejoin this site(Adobe rebrand): https://creative.adobe.com/apps?trial=GAME&promoid=KBYQD
and click Download.
redirect to this site. download Flascc tools.

How to write a browser plugin?

I'm curious as to the procedure for writing browser plugins for browsers like Chrome, Safari, and Opera. I'm thinking specifically of Windows here and would prefer working with C++.
Are there any tools or tutorials that detail the process?
Note: I am not referring to extensions or 'addons'. I'm referring to a plugin similar to how Flash and Adobe Reader have plugins to handle specific content-types.
As others point out, plugins for those browser are written using the NPAPI.
Note: Both Firefox and Chrome will default most plugins to click-to-play soon, with Chrome planning to phase out NPAPI entirely. NPAPI for new projects is discouraged at this point.
Resources for getting started with NPAPI:
MDC plugin section
three part NPAPI tutorial
memory management in NPAPI
npsimple - the "Hello World" of NPAPI plugins
npapi-sdk - the source for the canonical NPAPI headers
Mozillas test plugin - good for looking up specific NPAPI use cases
The NPAPI itself is however relatively low-level, but there are tools and frameworks that can help you with it:
FireBreath - cross-browser, cross-platform frame-work for plugins
Nixysa - generate glue-code for NPAPI plugins
JUCE - application framework also providing support for plugins
QtBrowserPlugin - Qt based browser plugin framework
I investigated some frameworks listed by Georg, here is what I get:
FireBreath. I think it is almost the best one available. You can create a cross platform browser plugin with FireBreath in a few days. I did find some cons: It does not support utf-8 characters on Windows. For example: if there are Chinese characters in a file name, you cannot read the content of that file. I believe that boost/locale can resolve this issue. But FireBreath does not contain boost/locale. Yes you can use external boost, but I spent several days configuring and tweaking and still cannot get it compiling on Windows. The author uses cmake to orgnize code and sub-projects. And he created a lot of bat or shell scripts and cmake macros, it is very hard to understand and configure. In short, if you want something that FireBreath currently does not provide, you will have a bad luck, it is very hard to add new features.
Nixysa. I don't think that it is being actively developed. Documentation is poor. And from the comments of the wiki page: https://code.google.com/p/nixysa/wiki/HelloWorldWalkThru We can know that users could not get help at all and were having trouble get it running on Windows
JUCE. It is not specially for creating browser plugins. It does NOT support Linux. The author thinks that NPAPI is going to die so he has no plan to support Linux or add new features.
QtBrowserPlugin. You can not find it in documentation later than QT 4.5. In another word, it is not maintained(and removed from Qt 5.0)
I will update this answer once I find more.
Update: Chrome dropped NPAPI support. I think in the future it becomes harder and harder to write plugins in C++ because lacks of support from browsers.
Browsers like Netscape-based browsers, Chrome, Safari and Opera uses NPAPI plugin system, you can learn how to write NPAPI plugins in https://developer.mozilla.org/en/Plugins and http://code.google.com/chrome/extensions/npapi.html
If you know Qt then they have got some classes that makes it easier to implement browser plug-ins