-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: add generics to device management #61
Conversation
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
type Constructor<T> = new (...args: any[]) => T; | ||
|
||
/** | ||
* Represents a WCME error, which contains error type and error message. |
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.
We can do this in a later PR, but I think it's kind of weird that we're referencing WCME here, and naming the error class WcmeError
, especially since WCME doesn't actually call any of the device management APIs.
let stream: MediaStream; | ||
try { | ||
stream = await media.getUserMedia({ audio: { ...constraints } }); | ||
} catch (error) { | ||
throw new WcmeError( | ||
ErrorTypes.CREATE_MICROPHONE_STREAM_FAILED, | ||
`Failed to create microphone stream ${error}` | ||
ErrorTypes.CREATE_STREAM_FAILED, |
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.
Not now but would be nicer to have error codes associated later , so that we know what the cause of failure else anyone using this lib need to figureout what does all getuser media error corresponds to
>( | ||
cameraStreamConstructor: Constructor<T>, | ||
microphoneStreamConstructor: Constructor<U>, | ||
constraints?: { video?: VideoDeviceConstraints; audio?: AudioDeviceConstraints } |
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.
nice
# [2.1.0](v2.0.0...v2.1.0) (2023-07-28) ### Features * add generics to device management ([#61](#61)) ([adf048e](adf048e))
This PR adds generics to device management
create*Stream
functions in order to support using custom stream classes in these methods. It also adds a new API,createCameraAndMicrophoneStreams
, to create both a camera stream and a microphone stream with a singlegetUserMedia
call.As part of this change, I've also slightly modified the
ErrorTypes
to have a genericCREATE_STREAM_FAILED
error so it can be used in all cases in whichgetUserMedia
orgetDisplayMedia
fail.This completes SPARK-448441 and SPARK-448443.