Copyright © 2014 Kurento. Licensed under LGPL License.
The project contains the implementation of the JavaScript Kurento Client for web applications and Node.js.
The source code of this project can be cloned from the GitHub repository.
These instructions are intended for code contributors or people willing to compile the browser version themselves. If you are a browser-only developer, it's better that you have a look at the JavaScript Kurento Client for Bower instructions.
Be sure to have installed Node.js in your system:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
To install the library, it's recommended to do that from the NPM repository :
npm install kurento-client
Alternatively, or if you want to modify the JavaScript Kurento Client code or generate yourself the browser version of the library, you can download the development code files using git and install manually its dependencies:
git clone https://github.com/Kurento/kurento-client-js
cd kurento-client-js
npm install
In this last case, you will also need to have installed Kurento Module Creator so you can be able to generate the client libraries code.
To build the browser version of the library, after downloading the development
code files, you'll only need to exec the grunt task runner from the root of
the project and they will be generated on the dist
folder. Alternatively,
if you don't have it globally installed, you can run a local copy by executing
node_modules/.bin/grunt
Tests are autonomous and based on QUnit testing framework. Their only
requirement is to exec previously npm install
to have installed all the
dev dependencies.
After building the web browser version of the library, just open the file
test/index.html
with any browser, and the tests will launch automatically.
In case of the browser raise some security policy errors, you can host the tests
code by running any static web server at the source code root folder, for
example by launching the command
python -m SimpleHTTPServer 8000
You can be able to configure to what WebSocket endpoint you want to connect on the dropdown list at the top of the tests page.
To exec test in Node.js, you only need to exec npm test
, that will launch
all the tests automatically using QUnit-cli.
At this moment, the default WebSocket endpoint can not be changed due to limits of the current implementation of NPM. If you need to use a different WebSocket endpoint from the default one, you can exec the underlying test command and append a ws_uri parameter pointing to the alternative WebSocket endpoint:
node_modules/.bin/qunit-cli -c kurentoClient:. -c wock:node_modules/wock -c test/_common.js -c test/_proxy.js test/*.js --ws_uri=ws://localhost:8080
For tutorial purposes, we are going to create a basic pipeline that play a video file from its URL and stream it over HTTP :
-
Create an instance of the KurentoClient class that will manage the connection with the Kurento Media Server, so you'll need to provide the URI of its WebSocket endpoint. Alternatively, instead of using a constructor, you can also provide success and error callbacks:
var kurento = kurentoClient.KurentoClient(ws_uri); kurento.then(function(kurento) { // Connection success … }, function(error) { // Connection error … });
kurentoClient.KurentoClient(ws_uri, function(kurento) { // Connection success … }, function(error) { // Connection error … });
-
Create a pipeline. This will host and connect the diferent elements. In case of error, it will be notified on the
error
parameter of the callback, otherwise this will be null as it's common on Node.js style APIs:kurento.create('MediaPipeline', function(error, pipeline) { … });
-
Create the elements. The player need an object with the URL of the video, and we'll also subscribe to the 'EndOfStream' event of the HTTP stream:
pipeline.create('PlayerEndpoint', {uri: "https://ci.kurento.com/video/small.webm"}, function(error, player) { … }); pipeline.create('HttpGetEndpoint', function(error, httpGet) { httpGet.on('EndOfStream', function(event) { … }); … });
-
Connect the elements, so the media stream can flow between them:
player.connect(httpGet, function(error, pipeline) { … });
-
Get the URL where the media stream will be available:
httpGet.getUrl(function(error, url) { … });
-
Start the reproduction of the media:
player.play(function(error) { … });
Kurento provides an open platform for video processing and streaming based on standards.
This platform has several APIs and components which provide solutions to the requirements of multimedia content application developers. These include:
- Kurento Media Server (KMS). A full featured media server providing the capability to create and manage dynamic multimedia pipelines.
- Kurento Clients. Libraries to create applications with media capabilities. Kurento provides libraries for Java, browser JavaScript, and Node.js.
To download binary releases of Kurento components visit http://kurento.org
Code for other Kurento projects can be found in the GitHub Kurento group.
Information about Kurento can be found on our website. Follow us on Twitter @kurentoms.