-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
RoomSession.joinAudience()
method (#557)
* add option to keep track of the session auth key * update types * add skeleton for joinAudience * fix tests * add initial implementation for the joinAudience * update demo to use joinAudience * fix test * rename utils and interfaces, move to external file, pr feedback * move values to util and always default to true * update name * add changesets * mark joinAudience as internal, remove mocked flags * restore to join
- Loading branch information
Showing
18 changed files
with
194 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@signalwire/core': patch | ||
--- | ||
|
||
[internal] Add ability to track the Authorization state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@signalwire/js': minor | ||
--- | ||
|
||
[internal] Add RoomSession.joinAudience method |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@signalwire/webrtc': patch | ||
--- | ||
|
||
[internal] Add ability to update the media options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { getLogger } from '@signalwire/core' | ||
import type { Authorization } from '@signalwire/core' | ||
import type { RoomSessionJoinAudienceParams } from './interfaces' | ||
|
||
// `joinAudience` utils | ||
const getJoinAudienceMediaParams = ({ | ||
authState, | ||
audio = true, | ||
video = true, | ||
}: RoomSessionJoinAudienceParams & { | ||
authState: Authorization | ||
}) => { | ||
const getMediaValue = ({ | ||
remote, | ||
local, | ||
kind, | ||
}: { | ||
remote?: boolean | ||
local?: boolean | ||
kind: 'audio' | 'video' | ||
}) => { | ||
if (!remote && local) { | ||
getLogger().warn( | ||
`[joinAudience] ${kind} is currently not allowed on this room.` | ||
) | ||
} | ||
|
||
return !!(remote && local) | ||
} | ||
|
||
return { | ||
audio: false, | ||
video: false, | ||
negotiateAudio: getMediaValue({ | ||
remote: authState.audio_allowed, | ||
local: audio, | ||
kind: 'audio', | ||
}), | ||
negotiateVideo: getMediaValue({ | ||
remote: authState.video_allowed, | ||
local: video, | ||
kind: 'video', | ||
}), | ||
} | ||
} | ||
|
||
const isValidJoinAudienceMediaParams = ( | ||
options: Record<string, boolean | undefined> | ||
) => { | ||
// At least one value must be true | ||
return Object.values(options).some(Boolean) | ||
} | ||
|
||
export { getJoinAudienceMediaParams, isValidJoinAudienceMediaParams } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters