Skip to content

Commit

Permalink
VIDCS-721: Add support for audio-only sessions (aullman#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-kpheng authored May 17, 2023
1 parent 20d9856 commit 11e9e90
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ angular.module('opentok-meet').controller('RoomCtrl', ['$scope', '$http', '$wind

const encryptionSecret = url.searchParams.get('e2ee');
const isSpc = url.searchParams.get('spc');
const isAudioOnlyMode = url.searchParams.get('audioOnlyMode') === 'true';

const facePublisherPropsSD = {
name: 'face',
Expand All @@ -66,6 +67,10 @@ angular.module('opentok-meet').controller('RoomCtrl', ['$scope', '$http', '$wind
},
};

if (isAudioOnlyMode) {
facePublisherPropsSD.publishVideo = false;
}

const facePublisherProps720 = Object.assign({
frameRate: 30,
}, facePublisherPropsSD);
Expand Down
9 changes: 8 additions & 1 deletion src/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ angular.module('opentok-meet').directive('draggable', ['$document', '$window',
},
};
}])
.directive('mutePublisher', ['OTSession', function mutePublisher(OTSession) {
.directive('mutePublisher', ['$window', 'OTSession', function mutePublisher($window, OTSession) {
return {
restrict: 'A',
link(scope, element, attrs) {
const type = attrs.mutedType || 'Video';
scope[`muted${type}`] = false;

// When audio-only mode is enabled, make sure Camera button set to disabled
if (type === 'Video') {
const url = new URL($window.location.href);
const isAudioOnlyMode = url.searchParams.get('audioOnlyMode') === 'true';
scope[`muted${type}`] = isAudioOnlyMode;
}

const getPublisher = () =>
OTSession.publishers.filter(el => el.id === attrs.publisherId)[0];

Expand Down
5 changes: 5 additions & 0 deletions src/js/login/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('opentok-meet-login', [])
$scope.advanced = false;
$scope.dtx = true;
$scope.paf = true;
$scope.audioOnlyMode = false;
$scope.e2ee = false;
$scope.encryptionSecret = '';
$scope.joinRoom = () => {
Expand All @@ -37,6 +38,10 @@ angular.module('opentok-meet-login', [])
url = appendQueryParamToUrl('paf=false', url);
}

if ($scope.audioOnlyMode) {
url = appendQueryParamToUrl('audioOnlyMode=true', url);
}

if ($scope.e2ee && $scope.encryptionSecret) {
url = appendQueryParamToUrl(`e2ee=${$scope.encryptionSecret}`, url);
}
Expand Down
8 changes: 7 additions & 1 deletion views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@
</label>
<input type="checkbox" name="Publisher Audio-Fallback" id="paf" ng-model="paf">
</div>
<br>
<div>
<label for="audioOnlyMode">
Audio-Only Mode
</label>
<input type="checkbox" name="Audio-Only Mode" id="audioOnlyMode" ng-model="audioOnlyMode">
</div>
<br>
<div id="tokenRole">
<label>Moderator<input type="radio" name="tokenRole" ng-model="tokenRole" value="moderator"><br></label>
<label>Publisher<input type="radio" name="tokenRole" ng-model="tokenRole" value="publisher"><br></label>
Expand Down

0 comments on commit 11e9e90

Please sign in to comment.