Added support for configurable keyframe interval

This commit is contained in:
prlanzarin 2018-05-10 14:30:15 +00:00
parent d1477943bd
commit 21e3dbab30
8 changed files with 20 additions and 13 deletions

View File

@ -17,6 +17,7 @@ to-audio: "to-audio-sfu"
to-akka: "to-akka-apps-redis-channel"
webcam-force-h264: true
screenshare-force-h264: true
screenshareKeyframeInterval: 2
recordScreenSharing: true
recordWebcams: false

View File

@ -142,11 +142,11 @@ module.exports = class MediaController {
switch (type) {
case "RtpEndpoint":
case "WebRtcEndpoint":
session = user.addSdp(params.descriptor, type);
session = user.addSdp(params.descriptor, type, params);
answer = await user.startSession(session.id);
break;
case "URI":
session = user.addUri(params.descriptor, type);
session = user.addUri(params.descriptor, type, params);
answer = await user.startSession(session.id);
break;
@ -197,7 +197,7 @@ module.exports = class MediaController {
switch (type) {
case "RtpEndpoint":
case "WebRtcEndpoint":
session = user.addSdp(params.descriptor, type);
session = user.addSdp(params.descriptor, type, params);
answer = await user.startSession(session.id);
await sourceSession.connect(session._mediaElement);

View File

@ -135,11 +135,15 @@ module.exports = class MediaServer extends EventEmitter {
}
async createMediaElement (roomId, type, options) {
async createMediaElement (roomId, type, options = {}) {
options = options || {};
try {
const pipeline = await this._getMediaPipeline(roomId);
const mediaElement = await this._createElement(pipeline, type, options);
if (typeof mediaElement.setKeyframeInterval === 'function' && options.keyframeInterval) {
Logger.debug("[mcs-media] Creating element with keyframe interval set to", options.keyframeInterval);
mediaElement.setKeyframeInterval(options.keyframeInterval);
}
this._mediaPipelines[roomId].activeElements++;
return Promise.resolve(mediaElement.id);
}

View File

@ -15,8 +15,9 @@ const kurentoUrl = config.get('kurentoUrl');
const Logger = require('../../../utils/Logger');
module.exports = class SdpSession extends MediaSession {
constructor(emitter, sdp = null, room, type = 'WebRtcEndpoint') {
super(emitter, room, type);
constructor(emitter, sdp = null, room, type = 'WebRtcEndpoint', options) {
super(emitter, room, type, options);
Logger.info("[mcs-sdp-session] New session with options", options);
// {SdpWrapper} SdpWrapper
this._sdp;
if (sdp && type) {

View File

@ -49,9 +49,9 @@ module.exports = class SfuUser extends User {
}
}
addSdp (sdp, type) {
addSdp (sdp, type, options) {
// TODO switch from type to children SdpSessions (WebRTC|SDP)
let session = new SdpSession(this.emitter, sdp, this.roomId, type);
let session = new SdpSession(this.emitter, sdp, this.roomId, type, options);
session.emitter.on(C.EVENT.MEDIA_SESSION_STOPPED, (sessId) => {
if (sessId === session.id) {
Logger.info("[mcs-sfu-user] Session ", sessId, "stopped, cleaning it...");

View File

@ -21,6 +21,7 @@ const FORCE_H264 = config.get('screenshare-force-h264');
const EventEmitter = require('events').EventEmitter;
const Logger = require('../utils/Logger');
const SHOULD_RECORD = config.get('recordScreenSharing');
const KEYFRAME_INTERVAL = config.get('screenshareKeyframeInterval');
// Global MCS endpoints mapping. These hashes maps IDs generated by the mcs-core
// lib to the ones generate in the ScreenshareManager
@ -227,7 +228,7 @@ module.exports = class Screenshare extends EventEmitter {
let sendVideoPort = MediaHandler.getVideoPort();
let rtpSdpOffer = MediaHandler.generateVideoSdp(localIpAddress, sendVideoPort);
const retRtp = await this.mcs.subscribe(this.userId, sharedScreens[this._voiceBridge], 'RtpEndpoint', {descriptor: rtpSdpOffer});
const retRtp = await this.mcs.subscribe(this.userId, sharedScreens[this._voiceBridge], 'RtpEndpoint', { descriptor: rtpSdpOffer, keyframeInterval: KEYFRAME_INTERVAL});
this._ffmpegEndpoint = retRtp.sessionId;
rtpEndpoints[this._voiceBridge] = this._ffmpegEndpoint;

View File

@ -133,14 +133,14 @@
"integrity": "sha1-BUNS5MTIDIbAkjh31EneF2pzLI0="
},
"kurento-client": {
"version": "git+https://github.com/Kurento/kurento-client-js.git#efb160e85a4b1f376307fe1979c9fbcb5f978393",
"version": "git+https://github.com/mconf/kurento-client-js.git#fb7015b8de91bdc2c83aae1553081406188ea20c",
"requires": {
"async": "2.0.1",
"error-tojson": "0.0.1",
"es6-promise": "4.2.4",
"extend": "3.0.1",
"inherits": "2.0.3",
"kurento-client-core": "github:Kurento/kurento-client-core-js#2160f8e6938f138b52b72a5c5c354d1e5fce1ca0",
"kurento-client-core": "git+https://github.com/mconf/kurento-client-core-js.git#3bfcff9cb21430a4f451239100b4c306b9705757",
"kurento-client-elements": "github:Kurento/kurento-client-elements-js#cbd1ff67fbf0faddc9f6f266bb33e449bc9e1f81",
"kurento-client-filters": "github:Kurento/kurento-client-filters-js#51308da53e432a2db9559dcdb308d87951417bf0",
"kurento-jsonrpc": "github:Kurento/kurento-jsonrpc-js#827827bbeb557e1c1901f5a562c4c700b9a51401",
@ -151,7 +151,7 @@
},
"dependencies": {
"kurento-client-core": {
"version": "github:Kurento/kurento-client-core-js#2160f8e6938f138b52b72a5c5c354d1e5fce1ca0"
"version": "git+https://github.com/mconf/kurento-client-core-js.git#3bfcff9cb21430a4f451239100b4c306b9705757"
},
"kurento-client-elements": {
"version": "github:Kurento/kurento-client-elements-js#cbd1ff67fbf0faddc9f6f266bb33e449bc9e1f81"

View File

@ -8,7 +8,7 @@
"dependencies": {
"config": "^1.30.0",
"js-yaml": "^3.11.0",
"kurento-client": "git+https://github.com/Kurento/kurento-client-js.git#master",
"kurento-client": "git+https://github.com/mconf/kurento-client-js.git#mconf",
"moment": "^2.22.1",
"readable-id": "^1.0.0",
"redis": "^2.8.0",