-
Notifications
You must be signed in to change notification settings - Fork 17
WIP: Unify device updates #1207
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import { | |
| } from '@signalwire/core' | ||
|
|
||
| import { BaseConnection } from '../BaseConnection' | ||
| import { emitDeviceUpdatedEventHelper } from '../utils/helpers' | ||
|
|
||
| type VertoEventWorkerOnDone = (args: BaseConnection<any>) => void | ||
| type VertoEventWorkerOnFail = (args: { error: Error }) => void | ||
|
|
@@ -129,11 +130,28 @@ export const vertoEventWorker: SDKWorker< | |
| break | ||
| } | ||
| const { audio, video } = params.mediaParams | ||
|
|
||
| const prevAudioTrack = peer?.localAudioTrack?.clone() | ||
| const prevVideoTrack = peer?.localVideoTrack?.clone() | ||
| if (peer && video) { | ||
| peer.applyMediaConstraints('video', video) | ||
| peer.applyMediaConstraints('video', video).then(() => { | ||
| emitDeviceUpdatedEventHelper({ | ||
| prevAudioTrack, | ||
| prevVideoTrack, | ||
| newTrack: peer?.localVideoTrack!, | ||
| emitFn: instance.emit, | ||
| }) | ||
| }) | ||
| } | ||
| if (peer && audio) { | ||
| peer.applyMediaConstraints('audio', audio) | ||
| peer.applyMediaConstraints('audio', audio).then(() => { | ||
|
||
| emitDeviceUpdatedEventHelper({ | ||
| prevAudioTrack, | ||
| prevVideoTrack, | ||
| newTrack: peer?.localAudioTrack!, | ||
| emitFn: instance.emit, | ||
| }) | ||
| }) | ||
| } | ||
| break | ||
| } | ||
|
|
@@ -164,6 +182,4 @@ export const vertoEventWorker: SDKWorker< | |
| }) | ||
| yield sagaEffects.fork(catchableWorker, action) | ||
| } | ||
|
|
||
| getLogger().trace('vertoEventWorker ended') | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have this helper function now, do you need the
emitDeviceUpdatedEventsmethod? It seems to be just calling the helper function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more approach we can take is to declare this class method as a public method but mark it as internal (SDK follows this pattern and mark variable as
/** @internal */), and then simply call the class method since you have access to the class instance.This way, you can also avoid passing the
emitFnsince you will call the class method.Up to you. Whatever approach you like to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the
/** @internal */approach sounds good to me.