diff --git a/doc/client_api.md b/doc/client_api.md index 5ed7aac37b..b5dba51709 100644 --- a/doc/client_api.md +++ b/doc/client_api.md @@ -219,7 +219,7 @@ The attributes variable is usually a JSON object. ``` var stream = Erizo.Stream({audio:true, video:false, data: true, attributes: {name:'myStream', type:'public'}}); - + var attributes = stream.getAttributes(); if(attributes.type === 'public') { console.log(attributes.name); @@ -256,19 +256,19 @@ The client can get the bitmap raw data from the video streams. The Stream return var bitmap; var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); - + canvas.id = "testCanvas"; document.body.appendChild(canvas); - + setInterval(function() { - + bitmap = stream.getVideoFrame(); - + canvas.width = bitmap.width; canvas.height = bitmap.height; - + context.putImageData(bitmap, 0, 0); - + }, 100); ``` @@ -288,13 +288,13 @@ You can update the maximun bandwidth of video and audio. These values are define ``` var config = {maxVideoBW: 300, maxAudioBW: 300}; - + localstream.updateConfiguration(config, function(result) { console.log(result); }); - + // We can update options also on a remote stream - + remoteStream.updateConfiguration({slideShowMode:true}, function (result){ console.log(result); }); @@ -750,6 +750,7 @@ There are the different types of Stream events: - `streamEvent.bandwidth` is the available bandwidth reported by that stream. - `streamEvent.msg` the status of that stream, depends on the adaptation [scheme](#schemes). - *stream-failed*: A stream has failed, either in the connection establishment or during the communication. +- *stream-ended*: A track of the stream (specified in the msg. es.audio/video) is ended, probably caused by an hardware disconnection. Emitted only once They all are dispatched by Room objects. @@ -775,11 +776,11 @@ room.addEventListener("stream-removed", function(evt){...}); ``` stream.addEventListener("access-accepted", function(evt){...}); - + stream.addEventListener("stream-data", function(evt){ console.log('Received data ', evt.msg, 'from stream ', evt.stream.getAttributes().name); }); - + room.addEventListener("stream-attributes-update", function(evt){...}); ``` @@ -799,14 +800,14 @@ In this example we will make a basic videoconference application. Every client t Licode Basic Example - +
@@ -879,4 +880,4 @@ You can also use Erizo Client Logger for managing log levels, etc. ``` var L = require('.erizofc').L; L.Logger.setLogLevel(2); -``` \ No newline at end of file +``` diff --git a/erizo_controller/erizoClient/src/Stream.js b/erizo_controller/erizoClient/src/Stream.js index cb1d062dd4..fe5e32c31e 100644 --- a/erizo_controller/erizoClient/src/Stream.js +++ b/erizo_controller/erizoClient/src/Stream.js @@ -126,6 +126,17 @@ Erizo.Stream = function (spec) { streamEvent = Erizo.StreamEvent({type: 'access-accepted'}); that.dispatchEvent(streamEvent); + that.stream.getTracks().forEach(function(track) { + track.onended = function() { + that.stream.getTracks().forEach(function(track) { + track.onended = null; + }); + streamEvent = Erizo.StreamEvent({type: 'stream-ended', stream: that, + msg: track.kind}); + that.dispatchEvent(streamEvent); + }; + }); + }, function (error) { L.Logger.error('Failed to get access to local media. Error code was ' + error.code + '.'); @@ -153,6 +164,7 @@ Erizo.Stream = function (spec) { that.hide(); if (that.stream !== undefined) { that.stream.getTracks().forEach(function (track) { + track.onended = null; track.stop(); }); }