Question

So, there is a WebRTC inside Firefox and there is a convenient class for making RTC communication possible called RTCPeerConnection which can be instantiated and used from the JavaScript app. You can find some decent example of it on [1]. And here am I with my custom transport (if you're interested - [2]) would like to use it for RTC communication. Briefly, I need to "substitute" the transport layer of WebRTC engine by my custom transport while providing the same RTCPeerConnection-like JavaScript interface for the user. And preferably, it should not look like custom build of Firefox (no patches). So I've come up with the idea of extension, which will be written in C++ (since it need to be linked with WebRTC library and my custom transport library) and somehow will expose its interface to Javascript. And I've found XPCOM which, as I thought, can provide me this. So I've started to fight with out-dated and sparsed info on this topic and after 3 days of struggling finally ended up with builded add-on. Unfortunately, I can't access it from Javascript, because of Javascript's "Components.classes is undefined" error. And it seems that there is no way to access it at all. Or I'm wrong on that?

Here is Javascript:

function check()
{
console.debug("checking...");   

const {Cc,Ci,Cu} = require("chrome");
var rtc = Components.classes["@named-data.net/ndnrtc;1"].createInstance();
rtc = rtc.QueryInterface(Ci.ndINrtc);   

console.debug("rtc: "+rtc);
}

My component is visible with XPCOM Viewer addon and the code above I can execute in the console while empty page is open in Firefox.

Given all that, I would like to ask Firefox experts regarding possible approaches which I can take in order to implement my idea. Thank you in advance

1 https://apprtc.appspot.com/

2 http://named-data.net

Was it helpful?

Solution

Finally, I've figured out one possible solution for that and describe it in my post

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top