Skip to content

Commit

Permalink
feat(screenshare): add optional contentType param to akka-apps signal…
Browse files Browse the repository at this point in the history
…ing RPCs

This is an initial step at making content sharing via RTC generic

The RPCs may have a contentType field which defines whether the content being shared is a screen or camera - that way a camera can be shared as content and properly identified as so

The next steps would be to refactor screen sharing state and RPC/event nomenclatures to reflect this approach
  • Loading branch information
prlanzarin committed Apr 3, 2023
1 parent f74deeb commit 9846926
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/bbb/messages/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
VIDEO_WIDTH: "vidWidth",
VIDEO_HEIGHT: "vidHeight",
HAS_AUDIO: "hasAudio",
CONTENT_TYPE: "contentType",
RTC_CONTENT_TYPE_CAMERA: "camera",
RTC_CONTENT_TYPE_SCREENSHARING: "screensharing",

// Audio
NAME: "name",
Expand Down
4 changes: 2 additions & 2 deletions lib/bbb/messages/Messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const GetMicrophonePermissionReqMsg =

module.exports = {
generateScreenshareRTMPBroadcastStartedEvent2x: (
conferenceName, screenshareConf, streamUrl, vw, vh, timestamp, hasAudio
conferenceName, screenshareConf, streamUrl, vw, vh, timestamp, options = {},
) => {
return (new ScreenshareRTMPBroadcastStartedEventMessage2x(
conferenceName, screenshareConf, streamUrl, vw, vh, timestamp, hasAudio
conferenceName, screenshareConf, streamUrl, vw, vh, timestamp, options,
)).toJson();
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const C = require('../Constants.js');

module.exports = class ScreenshareRTMPBroadcastStartedEventMessage2x extends OutMessage2x {
constructor (
conferenceName, screenshareConf, streamUrl, vw, vh, timestamp, hasAudio
conferenceName, screenshareConf, streamUrl, vw, vh, timestamp, options = {},
) {
super(
C.SCREENSHARE_RTMP_BROADCAST_STARTED_2x,
Expand All @@ -20,8 +20,11 @@ module.exports = class ScreenshareRTMPBroadcastStartedEventMessage2x extends Out
this.core.body[C.VIDEO_HEIGHT] = vh;
this.core.body[C.TIMESTAMP] = timestamp;
// Ensure backwards compatibility
if (typeof hasAudio !== 'undefined') {
this.core.body[C.HAS_AUDIO] = hasAudio;
if (typeof options?.hasAudio !== 'undefined') {
this.core.body[C.HAS_AUDIO] = options?.hasAudio;
}
if (typeof options?.contentType !== 'undefined') {
this.core.body[C.CONTENT_TYPE] = options?.contentType;
}
}
}
6 changes: 5 additions & 1 deletion lib/screenshare/ScreenshareManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ module.exports = class ScreenshareManager extends BaseManager {
sdpOffer,
callerName: userId,
bitrate,
vh = 0, vw = 0, hasAudio, mediaServer = SCREENSHARE_MEDIA_SERVER,
vh = 0, vw = 0,
hasAudio,
mediaServer = SCREENSHARE_MEDIA_SERVER,
contentType,
} = request;

// Throws SFU_UNAUTHORIZED on failure
Expand All @@ -213,6 +216,7 @@ module.exports = class ScreenshareManager extends BaseManager {
internalMeetingId,
this.mcs,
hasAudio,
contentType,
);

this.storeSession(voiceBridge, session);
Expand Down
27 changes: 24 additions & 3 deletions lib/screenshare/screenshare.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ module.exports = class Screenshare extends BaseProvider {
}
}

constructor(id, bbbGW, voiceBridge, userId, vh, vw, meetingId, mcs, hasAudio) {
constructor(
id,
bbbGW,
voiceBridge,
userId,
vh,
vw,
meetingId,
mcs,
hasAudio,
contentType,
) {
super(bbbGW);
this.sfuApp = C.SCREENSHARE_APP;
this.mcs = mcs;
Expand All @@ -105,6 +116,7 @@ module.exports = class Screenshare extends BaseProvider {
this._startRecordingEventFired = false;
this._stopRecordingEventFired = false;
this.hasAudio = hasAudio;
this.contentType = contentType;
this._mediaFlowingTimeouts = {};
this.handleMCSCoreDisconnection = this.handleMCSCoreDisconnection.bind(this);
this.hgaRecordingSet = {
Expand Down Expand Up @@ -897,8 +909,17 @@ module.exports = class Screenshare extends BaseProvider {
);
this._streamUrl = this._presenterEndpoint;
const timestamp = Math.floor(new Date());
const dsrbstam = Messaging.generateScreenshareRTMPBroadcastStartedEvent2x(this._voiceBridge,
this._voiceBridge, this._streamUrl, this._vw, this._vh, timestamp, this.hasAudio);
const dsrbstam = Messaging.generateScreenshareRTMPBroadcastStartedEvent2x(
this._voiceBridge,
this._voiceBridge,
this._streamUrl,
this._vw,
this._vh,
timestamp, {
hasAudio: this.hasAudio,
contentType: this.contentType,
}
);
this.bbbGW.publish(dsrbstam, C.TO_AKKA_APPS);
this._rtmpBroadcastStarted = true;
Logger.debug("Sent startRtmpBroadcast", this._getPartialLogMetadata());
Expand Down

0 comments on commit 9846926

Please sign in to comment.