Custom Module is not installed on the kurento media server but appears on the kurento-media-server --list - webrtc

I am trying to develop a custom module for the Kurento-media-server but i have find two roadblocks,following the instructions on the documentation i have been able to:
create the custom module folder with the command:
kurento-module-scaffold.sh <module_name> <output_directory>
and them generate the files with:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr && make && sudo make install
i have added two lines to the bgRemoverFilterOpenCVImpl on the /src/server/objects/bgRemoverFilterOpenCVImpl.cpp file so the filter adds a hello world text to the image.
void bgRemoverFilterOpenCVImpl::process (cv::Mat &mat)
{
cv::Point textOrg(50, 50);
putText( mat, "Hello World", textOrg, 1, 2, cv::Scalar(0, 0, 0) );
}
i them build the .deb file with debuild -us -uc and install it successfully so that when i run the kurento-media-server --list command i see my new custom module on the list:
....
bgRemoverFilter
bgremoverfilter.bgRemoverFilter
....
i them generated the js client code with the command cmake .. -DGENERATE_JS_CLIENT_PROJECT=TRUE and added the js generated folder to my node.js project using npm link for test purposes i am using the Kurento-Chroma project from the Kurento-node-repository so i have modified it to register my module and to create my custom filter instead of the chroma one. for this made changes to the server.js file on lines 28 and 249:
...
//kurento.register('kurento-module-chroma');
kurento.register('kurento-module-bgremoverfilter');
...
pipeline.create('bgremoverfilter.bgRemoverFilter', options, function(error, filter) {
if (error) {
return callback(error);
}
return callback(null, webRtcEndpoint, filter);
});
the node application runs correctly but when i start the loopback to get my videofeed with the filter applied it sends this error message:
Error message from server: Exiting with error SyntaxError: Module 'bgRemoverFilter' is not installed in the Kurento Media Server
despite the module being loaded on kurento-media-server --list the app cant create the filter object, i thought this was a naming issue so when i create a one word name custom module like "harel" to avoid camel case naming problems and install it i get on the list:
...
harel
harel.harel
...
and when trying to create and use this filter on the same kurento-chroma example i get a different error:
SyntaxError: sink param should be a MediaElement, not harel
at ChecktypeError (/home/ubuntu/www/kurento-chroma/node_modules/kurento-client/lib/checkType.js:32:10)
at checkMediaElement (/home/ubuntu/www/kurento-chroma/node_modules/kurento-client-core/lib/abstracts/MediaElement.js:1082:11)
at checkType (/home/ubuntu/www/kurento-chroma/node_modules/kurento-client/lib/checkType.js:84:25)
at WebRtcEndpoint.MediaElement.connect (/home/ubuntu/www/kurento-chroma/node_modules/kurento-client-core/lib/abstracts/MediaElement.js:489:3)
at connectMediaElements (/home/ubuntu/www/kurento-chroma/server.js:260:20)
at /home/ubuntu/www/kurento-chroma/server.js:197:17
at /home/ubuntu/www/kurento-chroma/server.js:254:20
at callback2 (/home/ubuntu/www/kurento-chroma/node_modules/kurento-client/lib/KurentoClient.js:527:7)
at /home/ubuntu/www/kurento-chroma/node_modules/kurento-client/lib/KurentoClient.js:385:7
at Object.dispatchCallback [as callback] (/home/ubuntu/www/kurento-chroma/node_modules/kurento-jsonrpc/lib/index.js:613:9)
so, am i missing something on the installation process? i suspect there is something wrong with the JS generated code in the first case.
on the second case when using a single word name, why does this work? the app is able to create the filter but then fails when trying to connect it to the webrtcEndPoint
i have look at all the questions and threads i could find but did'nt get any answers. here is a repository with my custom filter code including the generated js library
please help, if more clarifications or details are needed request them.
UPDATE
i wrote to one of the kurento developers that recommended i use kurento-media-server --version to get the actual list of loaded modules, this is a followup to that:
kurento-media-server --version returns:
Version: 6.7.0~1.g6ebaa27
Found modules:
Module: 'backgroundremoval' version '0.0.1~3.g045ef96'
Module: 'bgremoverfilter' version '0.0.1~0.g3a1e793'
Module: 'chroma' version '6.6.1~3.g6df8f1d'
Module: 'core' version '6.6.3'
Module: 'elements' version '6.6.3'
Module: 'filters' version '6.7.0~1.g0314843'
Module: 'harel' version '0.0.1~0.gaec7e6d'
so yes backgroundremoval, bgremoverfilter and harel are the custom modules i have created and they are on the list.
i still dont know why when i use a camelcase name as bacgroundRemoverFilter i cant get the module to load in javascript althoug the generated code is loaded on my node.js project when it tries to create the filter the app sends the "module not installed error"
so i started using all minus names, for my module "harel" this gets loaded with no problems and when i try to create the media element with
pipeline.create('harel.harel')...
the filter gets created but them fails when a try to connect it to a webrtcEnpoint with
filter.connect(webRtcEndpoint, function(error) {
if (error) {
return callback(error);
}
return callback(null);
});
it returns the error: SyntaxError: sink param should be a MediaElement, not harel
turns out that error is send by /node_modules/kurento-client-core/lib/abstracts/MediaElement.js:489:3 when calling a function Checktype
checkType('MediaElement', 'sink', sink, {required: true});
so i added a console.log() after the filter its created to see what was different between the chroma filter and my custom filter, this is the result:
harel {
domain: null,
_events:
{ removeListener: [Function],
newListener: [Function],
_describe: [Function: bound emit],
_rpc: [Function: encodeRpc],
release: { [Function: bound onceWrapper] listener: [Function] } },
_eventsCount: 5,
_maxListeners: undefined,
id: 'ad5e2447-3801-4d96-81b4-c40390b16248_kurento.MediaPipeline/18e8c6b9-df88-4d52-851c- 8c664a26ee3d_harel.harel' }
ChromaFilter {
domain: null,
_events:
{ removeListener: [Function],
newListener: [Function],
_describe: [Function: bound emit],
_rpc: [Function: encodeRpc],
release: { [Function: bound onceWrapper] listener: [Function] } },
_eventsCount: 5,
_maxListeners: undefined,
id: '97f370b5-81ae-45e1-a979- dab6c1c4cd28_kurento.MediaPipeline/06658282-67bf-47bc- b006-9f0dbae01767_chroma.ChromaFilter' }
both objects have the same properties excetp for the id. so how come the same function works with ChromaFilter bu not with harel if the object passed is almost the same. This is were i am now. will keep digging.

The problem with my process was that i used npm link to add the generated client-js code to my node.js app. For that to work i had to install the kurento-client package on the client-js folder and when my app ran it will generate the custom plugin with a different kurento-client than the one it was using.
so even thought the Chroma-filter and my harel module looked the same they were from two different kurento-client classes.
instead of using npm-link i just copied the generated js-client code inside my node-modules folder and that did the trick.
hope this is usefull to people that find this error.

Related

How to add a loader in a Vue/Webpack app to support non JS files used in a dependency of a node module

I have a Vue 2 app that uses Webpack, and I am trying to use in it the node module PSD.js, which in itself utilizes CoffeeScript as part of it's dependencies. When I try to compile i get the error:
Module parse failed: Unexpected character '#' (1:0) You may need an appropriate loader to handle this file type,
referring to the the file ./node_modules/coffee-script/lib/coffee-script/register.js that PSD.js installed as part of it's dependencies when I did npm install psd.
Any ideas on how to make this work?
I understand I need to tell the Vue app how to handle .coffee files with a loader, but I have tried installing coffee-loader, coffee, set the vue.config.js to:
module.exports = {
publicPath: "./",
configureWebpack: {
target: "node-webkit",
node: false,
module: {
rules: [
// ...
{
test: /\.coffee$/,
use: [
{
loader: 'coffee-loader'
}
]
}
]
}
},
lintOnSave: false
};
yet still nothing works, I get the same error. I feel it is because I am not using CoffeeScript directly but rather a node module that I AM using, psd.js, is the one using it. That is why I cannot set lang="coffee" in the script tag attribute of my Vue module (I am using vanilla JS to run everything).
thnx in advance
ADDING MORE INFO:
I use a boilerplate framework to setup my app, and it initialises the vue/webpack app for me indirectly.
To reproduce, and even though this system is for Adobe plugins, you do not need the Adobe host app to see the issue, do:
npm install -g bombino
Then in a folder of your choosing run:
bombino
and fill in these params when asked:
? Name of panel? Hello World
? Use your custom templates or bombino defaults? Bombino
What tooling preset should be used? Vue-CLI
? Which Vue-CLI template should be used? bombino-vue-bare (Absolute minimum)
? Host apps to include: After Effects
? Base CEF Port (between 1024 and 65534) 8666
? Run npm install for you? Yes
then cd into Hello-World and run npm run serve. You should see the app is compiled correctly and is running on some port (8080 or higher if taken).
Now go back to the root folder and install psd.js: npm install psd
then go back into Hello-World and run npm run serve again. This time it will fail to compile with the error I started this question with. Even if you go and install coffee-loader by doing npm install --save coffeescript coffee-loader and change the vue.config.js to be like so:
publicPath: "./",
// Thanks Eric Robinson
configureWebpack: {
target: "node-webkit", // Set the target to node-webkit (https://webpack.js.org/configuration/target/)
node: false, // Don't set certain Node globals/modules to empty objects (https://webpack.js.org/configuration/node/),
module: {
rules: [
// ...
{
test: /\.coffee$/,
use: [
{
loader: 'coffee-loader'
}
]
}
]
}
},
lintOnSave: false
};
or if you do vue use coffee - all of these result in the same error: the compiler/packager doesn't know how to handle the .coffee file (used as a dependency by psd.js).
Thnx again to anyone who has info

Unable to run relay-compiler

I installed the relay for my react-native project following the steps on relay.dev. Running the compiler works fine when I have an empty schema file. Putting schema to the file starts throwing me this error:
thread 'main' panicked at 'Expect GraphQLAsts to exist.', /home/runner/work/relay/relay/compiler/crates/relay-compiler/src/compiler.rs:335:14
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
My schema file is
// relay_schema.graphql
type Query {
tasks: [TaskNode]
}
type TaskNode {
id: ID!
}
and my relay config is:
module.exports = {
// ...
// Configuration options accepted by the `relay-compiler` command-line tool and `babel-plugin-relay`.
src: './src/',
language: 'flow',
schema: './relay_schema.graphql',
exclude: ['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'],
};
I'm completely lost on what to do here
Started working after updating src to src: './'. It's better to verify the paths such as src and schema. Error messages shown by the compiler are not much help when stuck here.

Running Aurelia new project failed

I've just created Aurelia new project and when I run au run --watch (I am following this instructions: http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial/1), I got this message from console. I'm quite new in JS and don't know anything about error code so can anybody tell me what's wrong?
{ uid: 11,
name: 'writeBundles',
branch: false,
error: [SyntaxError: Block-scoped declarations (let, const,function,class) not yet supported outside strict mode],
duration: [ 1, 536524679 ],
time: 1493576142781 }
You'll need node.js version 6 and above for es2015 features like let, const and class

Running a durandal app with the main-built file results does not work

I am having some problems with the optimized code that weyland generates. Here is what I did so far:
This is my project structure:
This is my weyland-config file:
exports.config = function(weyland) {
weyland.build('main')
.task.uglifyjs({
include:['www/**/*.js', 'www/js/durandal/**/*.js']
})
.task.rjs({
include:['www/**/*.{js,html}', 'www/js/durandal/**/*.js'],
loaderPluginExtensionMaps:{
'.html':'text'
},
rjs:{
name:'libs/require/require', //to deploy with require.js, use the build's name here instead
baseUrl : '../www/js',
paths : {
'text': 'libs/require/text',
'durandal': 'durandal',
'plugins': 'durandal/plugins',
'transitions': 'durandal/transitions',
'knockout': 'empty:',
'bootstrap': 'empty:',
'jquery': 'empty:'
},
inlineText: true,
optimize : 'none',
pragmas: {
build: true
},
stubModules : ['text'],
keepBuildDir: true,
out:'../www/js/main-built.js'
}
});
}
This is what I added in my index.html file to run the generated file instead of the one created by me:
<script src="js/main-built.js"></script>
I have also tryed using:
<script data-main="js/main-built" src="js/libs/require/require.js"></script>
This is what I had before:
<script data-main="js/main" src="js/libs/require/require.js"></script>
After I run weyland build on the command line the main-built file get's generated without any errors.
If I try to run the app the applycation freezez at the start screen as if the the app.start() method never get's called and no errors are being displayed.
I have checked chrome debugging tools the main-built file is recieved by the client it just seems it does nothing.
What am I doing wrong?
EDIT
I have also tryed building using almond-custom and ading this aditional configuration:
insertRequire:['main']
wrap:true
When I try to run the app I get this error:
Uncaught Error: main missing durandal/app
In my main fail I am loading the 'durandal/app' threw require js and for some reason it can not find it anymore

jQuery as AMD module and optimizing with r.js

Allright, he is the thing. I am using curl.js for my AMD loader, but i don't like much of "cram" because it needs to be run on unix and i am developing on Windows. So the r.js adapter for nodeJS from RequireJS library comes in mind, because node has already binary for Windows.
Now jQuery in current version (1.6.4) is not valid AMD module (coming in version 1.7) and there is dependencies in jQueryUI components, so i had to fake like this:
curl( [js!Core/jquery.js] )
.then( function() {
define('jquery', function() { return jQuery; });
})
My application is happy with this. However using r.js (version 0.26.0) fails on this part with following error:
Tracing dependencies for: boot
function (){return jQuery}
node.js:207
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: jQuery is not defined
at eval at <anonymous> (r.js:7468:30)
at main (r.js:770:33)
at callDefMain (r.js:840:18)
This is my app.build.js
({
appDir: '../',
baseUrl: 'Scripts/',
paths: {
'link': '../../../Lib/#Javascript Libs/curl.js/src/curl/plugin/link.js'
},
dir: 'built',
optimize: 'none',
modules: [
{ name: 'boot' }
]
})
And here is complete boot.js for reference (coffeescript):
require([
'link!styles/main.css'
'js!Core/jquery.js!order'
'js!Core/underscore.js!order'
'js!Core/backbone.js!order'
]).then ->
define 'jquery', -> jQuery
.next(['Router/MainRouter'])
.then (MainRouter) ->
new MainRouter()
Backbone.history.navigate('home') unless Backbone.history.start(
pushState: false
)
Thank you in advance for any hint where the catch can be...
Correct. RequireJS uses a different syntax on its global requirejs() (aka require()) function. RequireJs also doesn't have the "js!" plugin built-in. You may have to include a path to it in your config. You could also use RequireJS's syntax for non-module javascript files.
Also: cram 0.2 will support Windows environments using Rhino. We're writing tests for cram 0.2 and will be releasing it shortly.
RequireJS syntax (remove js! prefix and include .js extension):
require([
'link!styles/main.css'
'order!Core/jquery.js'
'order!Core/underscore.js'
'order!Core/backbone.js'
], function (maincss, jQuery, underscore, backbone) {
// do something here
});