Skip to content

Commit

Permalink
streaming: enhance simulcast support
Browse files Browse the repository at this point in the history
  • Loading branch information
atoppi committed Jan 31, 2024
1 parent c8247f7 commit d4f1196
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 25 deletions.
40 changes: 26 additions & 14 deletions examples/streaming/html/streaming-client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable multiline-comment-style */
/* global io */

'use strict';
Expand Down Expand Up @@ -86,12 +87,15 @@ function _stop() {
});
}

function _configure({ audio, video, data }) {
function _configure({ audio, video, data, substream, temporal, fallback }) {
socket.emit('configure', {
data: {
audio,
video,
data,
substream,
temporal,
fallback,
},
_id: getId(),
});
Expand Down Expand Up @@ -164,26 +168,34 @@ function _stopRec({ id = myStream, secret = 'adminpwd' } = {}) {
});
}

function _createMp({ aport, vport, secret = null, pin = null }) {
function _createMp({ audio, video, data, secret = null, pin = null } = {}) {
const settings = {};
settings.name = 'test_opus_vp8_' + Date.now();
settings.description = 'this is ' + settings.name;
settings.secret = secret || null;
settings.pin = pin || null;
settings.permanent = false;
settings.is_private = false;
settings.audio = {
port: aport,
pt: 111,
rtpmap: 'opus/48000/2',
};
settings.video = {
port: vport,
pt: 100,
rtpmap: 'VP8/90000',
buffer: true,
};
settings.data = {};
if (audio) {
settings.audio = typeof audio === 'object' ? audio : {};
settings.audio.port = settings.audio.port || 0;
settings.audio.pt = settings.audio.pt || 111;
settings.audio.rtpmap = settings.audio.rtpmap || 'opus/48000/2';
}
if (video) {
settings.video = typeof video === 'object' ? video : {};
settings.video.port = settings.video.port || 0;
//settings.video.port2 = settings.video.port2 || 0;
//settings.video.port3 = settings.video.port3 || 0;
//setting.video.rtcpport = setting.video.rtcpport || 0;
settings.video.pt = settings.video.pt || 100;
settings.video.rtpmap = settings.video.rtpmap || 'VP8/90000';
//settings.video.buffer = settings.video.buffer || false;
}
if (data) {
settings.data = typeof data === 'object' ? data : {};
//settings.data.buffer = settings.data.buffer || false;
}
socket.emit('create', {
data: settings,
_id: getId(),
Expand Down
4 changes: 0 additions & 4 deletions examples/streaming/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,6 @@ function initFrontEnd() {

if (!checkSessions(janodeSession, janodeManagerHandle, socket, evtdata)) return;

mpdata.audio = (typeof mpdata.audio === 'object' && mpdata.audio) ? mpdata.audio : null;
mpdata.video = (typeof mpdata.video === 'object' && mpdata.video) ? mpdata.video : null;
mpdata.data = (typeof mpdata.data === 'object' && mpdata.data) ? mpdata.data : null;

try {
const created = await janodeManagerHandle.createRtpMountpoint(mpdata);
replyEvent(socket, 'created', created, _id);
Expand Down
25 changes: 18 additions & 7 deletions src/plugins/streaming-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ class StreamingHandle extends Handle {
janode_event.data.audio_port = (message_data.stream) ? message_data.stream.audio_port : null;
janode_event.data.audio_rtcp_port = (message_data.stream) ? message_data.stream.audio_rtcp_port : null;
janode_event.data.video_port = (message_data.stream) ? message_data.stream.video_port : null;
janode_event.data.video_port_2 = (message_data.stream) ? message_data.stream.video_port_2 : null;
janode_event.data.video_port_3 = (message_data.stream) ? message_data.stream.video_port_3 : null;
janode_event.data.video_rtcp_port = (message_data.stream) ? message_data.stream.video_rtcp_port : null;
janode_event.data.data_port = (message_data.stream) ? message_data.stream.data_port : null;
break;
Expand Down Expand Up @@ -540,6 +542,8 @@ class StreamingHandle extends Handle {
* @param {boolean} [params.audio.skew] - Set skew compensation
* @param {object} [params.video] - The video descriptor for the mp
* @param {number} [params.video.port] - Port used for video RTP
* @param {number} [params.video.port2] - Port used for video RTP (simulcast layer)
* @param {number} [params.video.port3] - Port used for video RTP (simulcast layer)
* @param {number} [params.video.rtcpport] - Port used for video RTCP
* @param {string} [params.video.mcast] - Multicast address to listen to
* @param {number} [params.video.pt] - Payload type that will be used
Expand Down Expand Up @@ -573,28 +577,33 @@ class StreamingHandle extends Handle {
if (typeof pin === 'string') body.pin = pin;
if (typeof audio === 'object' && audio) {
body.audio = true;
if (typeof audio.port === 'number') body.audioport = audio.port;
body.audioport = (typeof audio.port === 'number') ? audio.port : 0;
if (typeof audio.rtcpport === 'number') body.audiortcpport = audio.rtcppport;
if (typeof audio.mcast === 'string') body.audiomcast = audio.mcast;
if (audio.pt) body.audiopt = audio.pt;
if (audio.rtpmap) body.audiortpmap = audio.rtpmap;
if (audio.skew) body.audioskew = audio.skew || false;
if (typeof audio.skew === 'boolean') body.audioskew = audio.skew;
}
if (typeof video === 'object' && video) {
body.video = true;
if (typeof video.port === 'number') body.videoport = video.port;
body.videoport = (typeof video.port === 'number') ? video.port : 0;
if (typeof video.rtcpport === 'number') body.videortcpport = video.rtcpport;
if (typeof video.mcast === 'string') body.videomcast = video.mcast;
if (video.pt) body.videopt = video.pt;
if (video.rtpmap) body.videortpmap = video.rtpmap;
if (video.fmtp) body.videofmtp = video.fmtp;
if (video.buffer) body.videobufferkf = video.buffer || false;
if (video.skew) body.videoskew = video.skew || false;
if (typeof video.buffer === 'boolean') body.videobufferkf = video.buffer;
if (typeof video.skew === 'boolean') body.videoskew = video.skew;
if (typeof video.port2 === 'number' && typeof video.port3 === 'number') {
body.videosimulcast = true;
body.videoport2 = video.port2;
body.videoport3 = video.port3;
}
}
if (typeof data === 'object' && data) {
body.data = true;
body.dataport = data.port || 0;
if (data.buffer) body.databuffermsg = data.buffer || false;
body.dataport = (typeof data.port === 'number') ? data.port : 0;
if (typeof data.buffer === 'boolean') body.databuffermsg = data.buffer;
}
if (typeof threads === 'number' && threads > 0) body.threads = threads;
if (metadata) body.metadata = metadata;
Expand Down Expand Up @@ -669,6 +678,8 @@ class StreamingHandle extends Handle {
* @property {number} [audio_port] - The port for RTP audio
* @property {number} [audio_rtcp_port] - The port RTCP audio
* @property {number} [video_port] - The port for RTP video
* @property {number} [video_port_2] - The port for RTP video (simulcast)
* @property {number} [video_port_3] - The port for RTP video (simulcast)
* @property {number} [video_rtcp_port] - The port for RTCP video
* @property {number} [data_port] - The port for datachannels
*/
Expand Down

0 comments on commit d4f1196

Please sign in to comment.