-
Notifications
You must be signed in to change notification settings - Fork 13.6k
chore: Implement base signaling system for media calls #36452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
9a74aba
Partial implementation; media signaling and media calls collection
pierre-lehnen-rc f1436bf
started work on media-signaling-server
pierre-lehnen-rc 8b44642
split channels into a new model, send offer request to caller
pierre-lehnen-rc 5c911f3
call acceptance
pierre-lehnen-rc c062c57
split files
pierre-lehnen-rc 8ed0635
service, endpoints and streams
pierre-lehnen-rc 866d7d2
dependencies
pierre-lehnen-rc e6fb9d9
client call state
pierre-lehnen-rc abfbd3f
integrating
pierre-lehnen-rc e9938bd
integrating
pierre-lehnen-rc 9271940
webrtc processor, some fixes and reorganization
pierre-lehnen-rc 0374b5a
accept calls, exchange offers and answers
pierre-lehnen-rc 9046b76
first working state
pierre-lehnen-rc 1f2642c
call by extension
pierre-lehnen-rc b5f5cba
missed a file
pierre-lehnen-rc abc9062
simplifying everything
pierre-lehnen-rc 4d4b53c
moving test code to a separate branch
pierre-lehnen-rc fc8fd1a
rebase conflict oopsie
pierre-lehnen-rc df797ec
rejection and handling of temporary data
pierre-lehnen-rc 8339874
client side timeouts
pierre-lehnen-rc eb4a7b7
handle actor signals through agents and contracts
pierre-lehnen-rc 566f9a7
use a signal to request calls too
pierre-lehnen-rc 378abb9
report webrtc states
pierre-lehnen-rc 7553d66
house cleaning
pierre-lehnen-rc 8ed2343
serialization and type validation
pierre-lehnen-rc a1c6907
Multi session
pierre-lehnen-rc 834fd5a
active state
pierre-lehnen-rc 4afb2af
organized global media signaling server functions
pierre-lehnen-rc ebf940e
renamed package
pierre-lehnen-rc 2c3f20e
expire old calls
pierre-lehnen-rc 739304a
update comment
pierre-lehnen-rc eab5358
unneeded dependency
pierre-lehnen-rc f0731b6
dev dependencies
pierre-lehnen-rc d5d3673
removing comments
pierre-lehnen-rc b3bb38a
missed a couple
pierre-lehnen-rc 2f606ec
rename and move token function
pierre-lehnen-rc 79b882b
clarify cronjob interval with a comment
pierre-lehnen-rc 5ea0a46
remove token function
pierre-lehnen-rc 2a1e9dd
remove unnecessary warn
pierre-lehnen-rc fb08a4d
use setTimeout instead of cronjob
pierre-lehnen-rc af06988
Merge branch 'develop' into feat/media-calls
pierre-lehnen-rc 65f6f50
reorganization to better accomodate sip integration
pierre-lehnen-rc c71572d
ice configuration
pierre-lehnen-rc d0e2279
ice gathering timeout on session
pierre-lehnen-rc 98c11e6
Merge branch 'develop' into feat/media-calls
pierre-lehnen-rc e42bca5
support accepting a call after the webrtc negotiation is complete
pierre-lehnen-rc 79025c8
removing some dead code
pierre-lehnen-rc 808db2f
importing fixes from sip branch
pierre-lehnen-rc 08e298f
better error handling
pierre-lehnen-rc d370c03
webrtc improvements
pierre-lehnen-rc 9ed9ca5
renamed `onHold` to `held` and improved some comments
pierre-lehnen-rc 1cf44bb
allow passing the inputTrack as param when creating a new call;
pierre-lehnen-rc 246f70d
feat: webrtc renegotiation (#36874)
pierre-lehnen-rc 0cfb569
Merge branch 'develop' into feat/media-calls
pierre-lehnen-rc 0274eb6
feat: media call transfer (#36898)
pierre-lehnen-rc 4c8c523
Merge branch 'feat/media-calls-backend' into feat/media-calls
pierre-lehnen-rc 4a85e27
Merge branch 'develop' into feat/media-calls
pierre-lehnen-rc fb3abc3
improving code quality + applying some suggestions from code review
pierre-lehnen-rc 69e4896
better state and presence management
pierre-lehnen-rc e5b269d
changes from code review
pierre-lehnen-rc 05c4be8
strip sensitive data from logs
pierre-lehnen-rc 6a3831e
code review
pierre-lehnen-rc d41cca7
dockerfiles
pierre-lehnen-rc 21a1a28
unregisterPeerEvents
pierre-lehnen-rc 1f3e97b
hangup call on unavailable response from a signed client
pierre-lehnen-rc 6fed7a8
code review
pierre-lehnen-rc acf08fa
better handling of call expiration
pierre-lehnen-rc fabc48b
improved client side state handling
pierre-lehnen-rc b5a91fe
logs
pierre-lehnen-rc 3c5258c
Merge branch 'develop' into feat/media-calls
pierre-lehnen-rc dcfd74e
handle situation where ICE Gathering time outs with no candidates
pierre-lehnen-rc 3e0a01d
ice candidate count
pierre-lehnen-rc 433d3ce
endSession
pierre-lehnen-rc 0eeb087
code review
pierre-lehnen-rc e29335b
fix: getUserMedia being called too early
pierre-lehnen-rc e95286b
improve handling of input tracks
pierre-lehnen-rc f9abc9f
bug fixes
pierre-lehnen-rc 1973027
fix presence check on transfered calls
pierre-lehnen-rc 5f9f7e3
Merge branch 'develop' into feat/media-calls
pierre-lehnen-rc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| import { MediaCall } from '@rocket.chat/core-services'; | ||
| import { License } from '@rocket.chat/license'; | ||
| import { Meteor } from 'meteor/meteor'; | ||
|
|
||
| import { addSettings } from '../settings/voip'; | ||
|
|
||
| Meteor.startup(async () => { | ||
| License.onValidateLicense(async () => { | ||
| await addSettings(); | ||
| }); | ||
| License.onValidateLicense(async () => { | ||
| await addSettings(); | ||
|
|
||
| await MediaCall.hangupExpiredCalls(); | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,100 @@ | ||
| import { api, ServiceClassInternal, type IMediaCallService } from '@rocket.chat/core-services'; | ||
| import type { IUser } from '@rocket.chat/core-typings'; | ||
| import { Logger } from '@rocket.chat/logger'; | ||
| import { callServer, type IMediaCallServerSettings } from '@rocket.chat/media-calls'; | ||
| import { isClientMediaSignal, type ClientMediaSignal, type ServerMediaSignal } from '@rocket.chat/media-signaling'; | ||
| import { MediaCalls } from '@rocket.chat/models'; | ||
|
|
||
| import { settings } from '../../../app/settings/server'; | ||
|
|
||
| const logger = new Logger('media-call service'); | ||
|
|
||
| export class MediaCallService extends ServiceClassInternal implements IMediaCallService { | ||
| protected name = 'media-call'; | ||
|
|
||
| constructor() { | ||
| super(); | ||
| callServer.emitter.on('signalRequest', ({ toUid, signal }) => this.sendSignal(toUid, signal)); | ||
|
|
||
| this.onEvent('watch.settings', async ({ setting }): Promise<void> => { | ||
| if (setting._id.startsWith('VoIP_TeamCollab_')) { | ||
| setImmediate(() => this.configureMediaCallServer()); | ||
| } | ||
| }); | ||
|
|
||
| this.configureMediaCallServer(); | ||
| } | ||
|
|
||
| public async processSignal(uid: IUser['_id'], signal: ClientMediaSignal): Promise<void> { | ||
| try { | ||
| logger.debug({ msg: 'new client signal', type: signal.type, uid }); | ||
| callServer.receiveSignal(uid, signal); | ||
| } catch (error) { | ||
| logger.error({ msg: 'failed to process client signal', error, signal, uid }); | ||
| } | ||
| } | ||
|
|
||
| public async processSerializedSignal(uid: IUser['_id'], signal: string): Promise<void> { | ||
| try { | ||
| logger.debug({ msg: 'new client signal', uid }); | ||
|
|
||
| const deserialized = await this.deserializeClientSignal(signal); | ||
|
|
||
| callServer.receiveSignal(uid, deserialized); | ||
| } catch (error) { | ||
| logger.error({ msg: 'failed to process client signal', error, uid }); | ||
| } | ||
| } | ||
|
|
||
| public async hangupExpiredCalls(): Promise<void> { | ||
| await callServer.hangupExpiredCalls().catch((error) => { | ||
| logger.error({ msg: 'Media Call Server failed to hangup expired calls', error }); | ||
| }); | ||
|
|
||
| try { | ||
| if (await MediaCalls.hasUnfinishedCalls()) { | ||
| callServer.scheduleExpirationCheck(); | ||
| } | ||
| } catch (error) { | ||
| logger.error({ msg: 'Media Call Server failed to check if there are expired calls', error }); | ||
| } | ||
| } | ||
|
|
||
| private async sendSignal(toUid: IUser['_id'], signal: ServerMediaSignal): Promise<void> { | ||
| void api.broadcast('user.media-signal', { userId: toUid, signal }); | ||
| } | ||
|
|
||
| private configureMediaCallServer(): void { | ||
| callServer.configure(this.getMediaServerSettings()); | ||
| } | ||
|
|
||
| private getMediaServerSettings(): IMediaCallServerSettings { | ||
| const enabled = settings.get<boolean>('VoIP_TeamCollab_Enabled') ?? false; | ||
|
KevLehman marked this conversation as resolved.
|
||
| const sipEnabled = false; | ||
| const forceSip = false; | ||
|
|
||
| return { | ||
| enabled, | ||
| internalCalls: { | ||
| requireExtensions: forceSip, | ||
| routeExternally: forceSip ? 'always' : 'never', | ||
| }, | ||
| sip: { | ||
| enabled: sipEnabled, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| private async deserializeClientSignal(serialized: string): Promise<ClientMediaSignal> { | ||
| try { | ||
| const signal = JSON.parse(serialized); | ||
| if (!isClientMediaSignal(signal)) { | ||
| throw new Error('signal-format-invalid'); | ||
| } | ||
| return signal; | ||
| } catch (error) { | ||
| logger.error({ msg: 'Failed to parse client signal' }, error); | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
| { | ||
| "extends": ["@rocket.chat/eslint-config"], | ||
| "ignorePatterns": ["**/dist"] | ||
| } |
This file contains hidden or 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,33 @@ | ||
| { | ||
| "name": "@rocket.chat/media-calls", | ||
| "version": "0.0.1", | ||
| "private": true, | ||
| "devDependencies": { | ||
| "@rocket.chat/jest-presets": "workspace:~", | ||
| "@rocket.chat/tsconfig": "workspace:*", | ||
| "@types/jest": "~30.0.0", | ||
| "eslint": "~8.45.0", | ||
| "jest": "~30.0.5", | ||
| "typescript": "~5.9.2" | ||
| }, | ||
| "scripts": { | ||
| "lint": "eslint --ext .js,.jsx,.ts,.tsx .", | ||
| "lint:fix": "eslint --ext .js,.jsx,.ts,.tsx . --fix", | ||
| "test": "jest", | ||
| "build": "rm -rf dist && tsc -p tsconfig.json", | ||
| "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", | ||
| "build-preview": "mkdir -p ../../.preview && cp -r ./dist ../../.preview/media-calls" | ||
| }, | ||
| "main": "./dist/index.js", | ||
| "typings": "./dist/index.d.ts", | ||
| "files": [ | ||
| "/dist" | ||
| ], | ||
| "dependencies": { | ||
| "@rocket.chat/core-typings": "workspace:^", | ||
| "@rocket.chat/emitter": "~0.31.25", | ||
| "@rocket.chat/logger": "workspace:^", | ||
| "@rocket.chat/media-signaling": "workspace:^", | ||
| "@rocket.chat/models": "workspace:^" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.