Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion src/plugins/videoroom-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
const REQUEST_LIST_PARTICIPANTS = 'listparticipants';
const REQUEST_ENABLE_RECORDING = 'enable_recording';
const REQUEST_KICK = 'kick';
const REQUEST_MODERATE = 'moderate';
const REQUEST_START = 'start';
const REQUEST_PAUSE = 'pause';
const REQUEST_SWITCH = 'switch';
Expand Down Expand Up @@ -56,6 +57,7 @@
LEAVING: 'videoroom_leaving',
UPDATED: 'videoroom_updated',
KICKED: 'videoroom_kicked',
MODERATED: 'videoroom_moderated',
RECORDING_ENABLED_STATE: 'videoroom_recording_enabled_state',
TALKING: 'videoroom_talking',
SC_SUBSTREAM_LAYER: 'videoroom_sc_substream_layer',
Expand Down Expand Up @@ -590,6 +592,15 @@
janode_event.data.sc_temporal_layers = message_data.temporal;
break;
}
/* Publisher moderated, i.e. a track has been muted or unmuted */
if (typeof message_data.moderation !== 'undefined') {
janode_event.event = PLUGIN_EVENT.MODERATED;
janode_event.data.feed = message_data.id;
janode_event.data.mid = message_data.mid;
janode_event.data.moderation = message_data.moderation;
break;
}

}

/* The event has been handled */
Expand Down Expand Up @@ -1187,6 +1198,29 @@
throw (error);
}

async moderate({ room, feed, mID, mute, secret }) {
const body = {
request: REQUEST_MODERATE,
room,
id: feed,
mid: mID,
mute
};
if (typeof secret === 'string') body.secret = secret;

const response = await this.message(body);
const { event, data: evtdata } = this._getPluginEvent(response);
if (event === PLUGIN_EVENT.SUCCESS) {
evtdata.room = body.room;
evtdata.feed = body.id;
evtdata.mid = body.mid;
evtdata.mute = body.mute

Check warning on line 1217 in src/plugins/videoroom-plugin.js

View workflow job for this annotation

GitHub Actions / build-and-lint

Missing semicolon
return evtdata;
}
const error = new Error(`unexpected response to ${body.request} request`);
throw (error);
}

/**
* Check if a room exists.
*
Expand Down Expand Up @@ -1479,7 +1513,7 @@
* @typedef {Object} VIDEOROOM_EVENT_PUB_JOINED
* @property {number|string} room - The involved room
* @property {number|string} feed - The feed identifier
* @property {string} [display] - The dsplay name, if available
* @property {string} [display] - The display name, if available
* @property {string} description - A description of the room, if available
* @property {number} private_id - The private id that can be used when subscribing
* @property {object[]} publishers - The list of active publishers
Expand Down Expand Up @@ -1676,6 +1710,16 @@
* @property {number|string} feed - The feed that has been kicked
*/

/**
* A publisher has been moderated (muted or unmuted)
*
* @typedef {Object} VIDEOROOM_EVENT_MODERATED
* @property {number|string} room - The involved room
* @property {number|string} feed - The feed that has been moderated
* @property {string} mid - The mid of the moderated track
* @property {'muted'|'unmuted' } moderation - The moderation action taken
*/

Check warning on line 1721 in src/plugins/videoroom-plugin.js

View workflow job for this annotation

GitHub Actions / build-and-lint

Expected this line to be aligned with the start of the comment

/**
* The response event for the recording enabled request.
*
Expand Down Expand Up @@ -1710,6 +1754,7 @@
* @property {string} EVENT.VIDEOROOM_SLOWLINK {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_SLOWLINK VIDEOROOM_SLOWLINK}
* @property {string} EVENT.VIDEOROOM_TALKING {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_TALKING VIDEOROOM_TALKING}
* @property {string} EVENT.VIDEOROOM_KICKED {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_KICKED VIDEOROOM_KICKED}
* @property {string} EVENT.VIDEOROOM_MODERATED {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_MODERATED VIDEOROOM_MODERATED}
* @property {string} EVENT.VIDEOROOM_RECORDING_ENABLED_STATE {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_RECORDING_ENABLED_STATE VIDEOROOM_RECORDING_ENABLED_STATE}
* @property {string} EVENT.VIDEOROOM_SC_SUBSTREAM_LAYER {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_SC_SUBSTREAM_LAYER VIDEOROOM_SC_SUBSTREAM_LAYER}
* @property {string} EVENT.VIDEOROOM_SC_TEMPORAL_LAYERS {@link module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_SC_TEMPORAL_LAYERS VIDEOROOM_SC_TEMPORAL_LAYERS}
Expand Down Expand Up @@ -1841,6 +1886,18 @@
*/
VIDEOROOM_KICKED: PLUGIN_EVENT.KICKED,

/**
* A publisher has been moderated (muted or unmuted)
*

Check warning on line 1891 in src/plugins/videoroom-plugin.js

View workflow job for this annotation

GitHub Actions / build-and-lint

Trailing spaces not allowed
* @event module:videoroom-plugin~VideoRoomHandle#event:VIDEOROOM_MODERATED
* @type {Object}
* @property {number|string} room - The involved room
* @property {number|string} feed - The feed that has been moderated
* @property {string} mid - The mid of the moderated track
* @property {'muted'|'unmuted' } moderation - The moderation action taken
*/
VIDEOROOM_MODERATED: PLUGIN_EVENT.MODERATED,

/**
* Conference recording has been enabled or disabled.
*
Expand Down
Loading