Skip to content
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: specify when publish fails due to media access denied #202

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/NetworkTest/errors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum ErrorNames {
NO_VIDEO_CAPTURE_DEVICES = 'NoVideoCaptureDevicesError',
NO_AUDIO_CAPTURE_DEVICES = 'NoAudioCaptureDevicesError',
PUBLISH_TO_SESSION_ERROR = 'PublishToSessionError',
MEDIA_PERMISSIONS_ERROR = 'MediaAccessDeniedError',
INIT_PUBLISHER_ERROR = 'InitPublisherError',
FAILED_MESSAGING_SERVER_TEST = 'FailedMessagingServerTestError',
FAILED_TO_CREATE_LOCAL_PUBLISHER = 'FailedToCreateLocalPublisher',
Expand All @@ -46,6 +47,7 @@ export enum OTErrorType {
OT_INVALID_HTTP_STATUS = 'OT_INVALID_HTTP_STATUS',
OT_CONNECT_FAILED = 'OT_CONNECT_FAILED',
OT_INVALID_SESSION_ID = 'OT_INVALID_SESSION_ID',
OT_USER_MEDIA_ACCESS_DENIED = 'OT_USER_MEDIA_ACCESS_DENIED',
CONNECT_FAILED = 'CONNECT_FAILED',
CONNECT_REJECTED = 'CONNECT_REJECTED',
CONNECTION_TIMEOUT = 'CONNECTION_TIMEOUT',
Expand Down
6 changes: 6 additions & 0 deletions src/NetworkTest/testConnectivity/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ export class FailedToCreateLocalPublisher extends PublishToSessionError {
}
}

export class MediaPermissionsDeniedError extends PublishToSessionError {
constructor() {
super('Precall failed to publish because media permissions have been denied.', ErrorNames.MEDIA_PERMISSIONS_ERROR);
}
}

export class PublishToSessionNotConnectedError extends PublishToSessionError {
constructor() {
super('Precall failed to publish to the session because it was not connected.',
Expand Down
2 changes: 2 additions & 0 deletions src/NetworkTest/testConnectivity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ function checkCreateLocalPublisher(
const publisher = OT.initPublisher(publisherDiv, publisherOptions, (error?: OT.OTError) => {
if (!error) {
resolve({ publisher });
} else if (errorHasName(error, OTErrorType.OT_USER_MEDIA_ACCESS_DENIED)) {
reject(new e.MediaPermissionsDeniedError())
} else {
reject(new e.FailedToCreateLocalPublisher());
}
Expand Down