mirror of https://github.com/OpenVidu/openvidu.git
Added madia flow out chnage event distribution in openvidu-browser
parent
511ffb0786
commit
4086744e15
|
@ -20,6 +20,8 @@ export class Publisher {
|
||||||
stream: Stream;
|
stream: Stream;
|
||||||
session: Session; //Initialized by Session.publish(Publisher)
|
session: Session; //Initialized by Session.publish(Publisher)
|
||||||
isScreenRequested: boolean = false;
|
isScreenRequested: boolean = false;
|
||||||
|
flowOutAudio: boolean = false;
|
||||||
|
flowOutVideo: boolean = false;
|
||||||
|
|
||||||
constructor(stream: Stream, parentId: string, isScreenRequested: boolean) {
|
constructor(stream: Stream, parentId: string, isScreenRequested: boolean) {
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
|
@ -34,6 +36,22 @@ export class Publisher {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.stream.addEventListener('media-flow-out-changed', (event) => {
|
||||||
|
let wasFlowing = this.flowOutAudio || this.flowOutVideo;
|
||||||
|
if(event.mediaType == "AUDIO"){
|
||||||
|
this.flowOutAudio = event.newState == "FLOWING"
|
||||||
|
}
|
||||||
|
if(event.mediaType == "VIDEO"){
|
||||||
|
this.flowOutVideo = event.newState == "FLOWING"
|
||||||
|
}
|
||||||
|
if(wasFlowing && !this.flowOutAudio && !this.flowOutVideo){
|
||||||
|
this.ee.emitEvent('flowStopped');
|
||||||
|
}
|
||||||
|
if (!wasFlowing && (this.flowOutAudio || this.flowOutVideo)) {
|
||||||
|
this.ee.emitEvent('flowStarted');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (document.getElementById(parentId) != null) {
|
if (document.getElementById(parentId) != null) {
|
||||||
this.element = document.getElementById(parentId)!!;
|
this.element = document.getElementById(parentId)!!;
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,9 @@ export class OpenViduInternal {
|
||||||
sendMessage: this.onNewMessage.bind(this),
|
sendMessage: this.onNewMessage.bind(this),
|
||||||
iceCandidate: this.iceCandidateEvent.bind(this),
|
iceCandidate: this.iceCandidateEvent.bind(this),
|
||||||
mediaError: this.onMediaError.bind(this),
|
mediaError: this.onMediaError.bind(this),
|
||||||
custonNotification: this.customNotification.bind(this)
|
custonNotification: this.customNotification.bind(this),
|
||||||
|
mediaFlowInChange: this.onMediaFlowInChange.bind(this),
|
||||||
|
mediaFlowOutChange: this.onMediaFlowOutChange.bind(this),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -294,6 +296,17 @@ export class OpenViduInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onMediaFlowOutChange(params) {
|
||||||
|
if (this.isRoomAvailable()) {
|
||||||
|
this.session.onMediaFlowOutChange(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onMediaFlowInChange(params) {
|
||||||
|
if (this.isRoomAvailable()) {
|
||||||
|
this.session.onMediaFlowInChange(params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setRpcParams(params: any) {
|
setRpcParams(params: any) {
|
||||||
this.rpcParams = params;
|
this.rpcParams = params;
|
||||||
|
|
|
@ -460,6 +460,21 @@ export class SessionInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMediaFlowInChange(params) {
|
||||||
|
console.info("Media flow in change: " + JSON.stringify(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
onMediaFlowOutChange(params) {
|
||||||
|
console.info("Media flow out change: " + JSON.stringify(params));
|
||||||
|
for(let streamId in this.streams){
|
||||||
|
this.streams[streamId].onMediaFlowOutChange({
|
||||||
|
id: params.id,
|
||||||
|
mediaType: params.mediaType,
|
||||||
|
newState: params.newState
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* forced means the user was evicted, no need to send the 'leaveRoom' request
|
* forced means the user was evicted, no need to send the 'leaveRoom' request
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,14 +5,15 @@
|
||||||
*
|
*
|
||||||
* stream.hasAudio(); stream.hasVideo(); stream.hasData();
|
* stream.hasAudio(); stream.hasVideo(); stream.hasData();
|
||||||
*/
|
*/
|
||||||
import { Connection } from './Connection';
|
import {Connection} from './Connection';
|
||||||
import { SessionInternal } from './SessionInternal';
|
import {SessionInternal} from './SessionInternal';
|
||||||
import { OpenViduInternal, Callback } from './OpenViduInternal';
|
import {OpenViduInternal, Callback} from './OpenViduInternal';
|
||||||
import { OpenViduError, OpenViduErrorName } from './OpenViduError';
|
import {OpenViduError, OpenViduErrorName} from './OpenViduError';
|
||||||
import EventEmitter = require('wolfy87-eventemitter');
|
import EventEmitter = require('wolfy87-eventemitter');
|
||||||
import * as kurentoUtils from '../KurentoUtils/kurento-utils-js';
|
import * as kurentoUtils from '../KurentoUtils/kurento-utils-js';
|
||||||
|
|
||||||
import * as adapter from 'webrtc-adapter';
|
import * as adapter from 'webrtc-adapter';
|
||||||
|
|
||||||
declare var navigator: any;
|
declare var navigator: any;
|
||||||
declare var RTCSessionDescription: any;
|
declare var RTCSessionDescription: any;
|
||||||
|
|
||||||
|
@ -235,6 +236,13 @@ export class Stream {
|
||||||
this.ee.removeAllListeners(eventName);
|
this.ee.removeAllListeners(eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMediaFlowOutChange(event) {
|
||||||
|
if (event.id !== this.connection.connectionId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.ee.emit('media-flow-out-changed',event);
|
||||||
|
}
|
||||||
|
|
||||||
showSpinner(spinnerParentId: string) {
|
showSpinner(spinnerParentId: string) {
|
||||||
let progress = document.createElement('div');
|
let progress = document.createElement('div');
|
||||||
progress.id = 'progress-' + this.streamId;
|
progress.id = 'progress-' + this.streamId;
|
||||||
|
@ -378,7 +386,8 @@ export class Stream {
|
||||||
this.accessIsDenied = true;
|
this.accessIsDenied = true;
|
||||||
this.accessIsAllowed = false;
|
this.accessIsAllowed = false;
|
||||||
let errorName: OpenViduErrorName;
|
let errorName: OpenViduErrorName;
|
||||||
let errorMessage = error.toString();;
|
let errorMessage = error.toString();
|
||||||
|
;
|
||||||
if (!this.isScreenRequested) {
|
if (!this.isScreenRequested) {
|
||||||
errorName = this.sendVideo ? OpenViduErrorName.CAMERA_ACCESS_DENIED : OpenViduErrorName.MICROPHONE_ACCESS_DENIED;
|
errorName = this.sendVideo ? OpenViduErrorName.CAMERA_ACCESS_DENIED : OpenViduErrorName.MICROPHONE_ACCESS_DENIED;
|
||||||
} else {
|
} else {
|
||||||
|
@ -437,7 +446,7 @@ export class Stream {
|
||||||
doLoopback: this.displayMyRemote() || false,
|
doLoopback: this.displayMyRemote() || false,
|
||||||
audioActive: this.sendAudio,
|
audioActive: this.sendAudio,
|
||||||
videoActive: this.sendVideo,
|
videoActive: this.sendVideo,
|
||||||
typeOfVideo: ((this.sendVideo) ? ((this.isScreenRequested) ? 'SCREEN' :'CAMERA') : '')
|
typeOfVideo: ((this.sendVideo) ? ((this.isScreenRequested) ? 'SCREEN' : 'CAMERA') : '')
|
||||||
}, (error, response) => {
|
}, (error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error("Error on publishVideo: " + JSON.stringify(error));
|
console.error("Error on publishVideo: " + JSON.stringify(error));
|
||||||
|
@ -578,7 +587,7 @@ export class Stream {
|
||||||
|
|
||||||
if (this.wrStream.getAudioTracks()[0] != null) {
|
if (this.wrStream.getAudioTracks()[0] != null) {
|
||||||
|
|
||||||
this.speechEvent = kurentoUtils.WebRtcPeer.hark(this.wrStream, { threshold: this.room.thresholdSpeaker });
|
this.speechEvent = kurentoUtils.WebRtcPeer.hark(this.wrStream, {threshold: this.room.thresholdSpeaker});
|
||||||
|
|
||||||
this.speechEvent.on('speaking', () => {
|
this.speechEvent.on('speaking', () => {
|
||||||
//this.room.addParticipantSpeaking(participantId);
|
//this.room.addParticipantSpeaking(participantId);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var Session_1 = require("./Session");
|
var Session_1 = require("./Session");
|
||||||
var OpenVidu = (function () {
|
var OpenVidu = /** @class */ (function () {
|
||||||
function OpenVidu(urlOpenViduServer, secret) {
|
function OpenVidu(urlOpenViduServer, secret) {
|
||||||
this.urlOpenViduServer = urlOpenViduServer;
|
this.urlOpenViduServer = urlOpenViduServer;
|
||||||
this.secret = secret;
|
this.secret = secret;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var OpenViduRole_1 = require("./OpenViduRole");
|
var OpenViduRole_1 = require("./OpenViduRole");
|
||||||
var https = require('https');
|
var https = require('https');
|
||||||
var Session = (function () {
|
var Session = /** @class */ (function () {
|
||||||
function Session(urlOpenViduServer, secret) {
|
function Session(urlOpenViduServer, secret) {
|
||||||
this.urlOpenViduServer = urlOpenViduServer;
|
this.urlOpenViduServer = urlOpenViduServer;
|
||||||
this.secret = secret;
|
this.secret = secret;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
var TokenOptions = (function () {
|
var TokenOptions = /** @class */ (function () {
|
||||||
function TokenOptions(data, role) {
|
function TokenOptions(data, role) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.role = role;
|
this.role = role;
|
||||||
|
@ -17,7 +17,7 @@ var TokenOptions = (function () {
|
||||||
}());
|
}());
|
||||||
exports.TokenOptions = TokenOptions;
|
exports.TokenOptions = TokenOptions;
|
||||||
(function (TokenOptions) {
|
(function (TokenOptions) {
|
||||||
var Builder = (function () {
|
var Builder = /** @class */ (function () {
|
||||||
function Builder() {
|
function Builder() {
|
||||||
}
|
}
|
||||||
Builder.prototype.build = function () {
|
Builder.prototype.build = function () {
|
||||||
|
|
Loading…
Reference in New Issue