From e29a8a559bac9fab04f78c2a81a278cee8023dc3 Mon Sep 17 00:00:00 2001 From: hdz-666 <93115614+hdz-666@users.noreply.github.com> Date: Wed, 11 Dec 2024 11:59:38 +0530 Subject: [PATCH 1/3] fix: add new changes for sending rtc peer connection --- packages/hms-video-store/src/connection/HMSConnection.ts | 2 +- .../hms-video-store/src/connection/publish/publishConnection.ts | 2 +- .../src/connection/subscribe/subscribeConnection.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hms-video-store/src/connection/HMSConnection.ts b/packages/hms-video-store/src/connection/HMSConnection.ts index 198b02eb36..08dea1aa9a 100644 --- a/packages/hms-video-store/src/connection/HMSConnection.ts +++ b/packages/hms-video-store/src/connection/HMSConnection.ts @@ -16,7 +16,7 @@ export default abstract class HMSConnection { protected readonly signal: JsonRpcSignal; protected abstract readonly observer: IConnectionObserver; - abstract readonly nativeConnection: RTCPeerConnection; + abstract nativeConnection: RTCPeerConnection; /** * We keep a list of pending IceCandidates received * from the signalling server. When the peer-connection diff --git a/packages/hms-video-store/src/connection/publish/publishConnection.ts b/packages/hms-video-store/src/connection/publish/publishConnection.ts index 422c7eb8c8..2e2fe5f26e 100644 --- a/packages/hms-video-store/src/connection/publish/publishConnection.ts +++ b/packages/hms-video-store/src/connection/publish/publishConnection.ts @@ -8,7 +8,7 @@ import { HMSConnectionRole } from '../model'; export default class HMSPublishConnection extends HMSConnection { private readonly TAG = '[HMSPublishConnection]'; protected readonly observer: IPublishConnectionObserver; - readonly nativeConnection: RTCPeerConnection; + nativeConnection: RTCPeerConnection; readonly channel: RTCDataChannel; constructor(signal: JsonRpcSignal, config: RTCConfiguration, observer: IPublishConnectionObserver) { diff --git a/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts b/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts index 9120824a24..316df672aa 100644 --- a/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts +++ b/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts @@ -21,7 +21,7 @@ export default class HMSSubscribeConnection extends HMSConnection { protected readonly observer: ISubscribeConnectionObserver; private readonly MAX_RETRIES = 3; - readonly nativeConnection: RTCPeerConnection; + nativeConnection: RTCPeerConnection; private pendingMessageQueue: string[] = []; From 98fce62a0048bf707dd8c5a3b2341b4d75df544d Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Mon, 16 Dec 2024 11:51:29 +0530 Subject: [PATCH 2/3] docs: added inline code comments --- .../src/connection/HMSConnection.ts | 18 +++++++++++++++--- .../connection/publish/publishConnection.ts | 13 +++++++++++++ .../subscribe/subscribeConnection.ts | 9 +++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/packages/hms-video-store/src/connection/HMSConnection.ts b/packages/hms-video-store/src/connection/HMSConnection.ts index 08dea1aa9a..bf548bce26 100644 --- a/packages/hms-video-store/src/connection/HMSConnection.ts +++ b/packages/hms-video-store/src/connection/HMSConnection.ts @@ -11,12 +11,27 @@ import { enableOpusDtx, fixMsid } from '../utils/session-description'; const TAG = '[HMSConnection]'; +/** + * Abstract base class that handles WebRTC peer connections for 100ms SDK + * Provides common functionality for both publishing (sending) and subscribing (receiving) connections + */ export default abstract class HMSConnection { + /** + * Indicates whether this connection is for publishing or subscribing media + */ readonly role: HMSConnectionRole; + protected readonly signal: JsonRpcSignal; protected abstract readonly observer: IConnectionObserver; + + /** + * The native WebRTC peer connection object + * @abstract + * @type {RTCPeerConnection} + */ abstract nativeConnection: RTCPeerConnection; + /** * We keep a list of pending IceCandidates received * from the signalling server. When the peer-connection @@ -131,7 +146,6 @@ export default abstract class HMSConnection { const iceTransport = transmitter.transport.iceTransport; const handleSelectedCandidate = () => { - // @ts-expect-error if (typeof iceTransport.getSelectedCandidatePair === 'function') { // @ts-expect-error this.selectedCandidatePair = iceTransport.getSelectedCandidatePair(); @@ -147,9 +161,7 @@ export default abstract class HMSConnection { } }; - // @ts-expect-error if (typeof iceTransport.onselectedcandidatepairchange === 'function') { - // @ts-expect-error iceTransport.onselectedcandidatepairchange = handleSelectedCandidate; } handleSelectedCandidate(); diff --git a/packages/hms-video-store/src/connection/publish/publishConnection.ts b/packages/hms-video-store/src/connection/publish/publishConnection.ts index 2e2fe5f26e..719623e3e8 100644 --- a/packages/hms-video-store/src/connection/publish/publishConnection.ts +++ b/packages/hms-video-store/src/connection/publish/publishConnection.ts @@ -5,10 +5,23 @@ import HMSLogger from '../../utils/logger'; import HMSConnection from '../HMSConnection'; import { HMSConnectionRole } from '../model'; +/** + * Represents a connection for publishing media to the signalling server. + * Extends the HMSConnection class to provide additional functionality for publishing media + * @extends {HMSConnection} + */ export default class HMSPublishConnection extends HMSConnection { private readonly TAG = '[HMSPublishConnection]'; protected readonly observer: IPublishConnectionObserver; + /** + * The native WebRTC peer connection object + * @type {RTCPeerConnection} + */ nativeConnection: RTCPeerConnection; + /** + * The data channel used for communication with the signalling server + * @type {RTCDataChannel} + */ readonly channel: RTCDataChannel; constructor(signal: JsonRpcSignal, config: RTCConfiguration, observer: IPublishConnectionObserver) { diff --git a/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts b/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts index 316df672aa..ee18130670 100644 --- a/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts +++ b/packages/hms-video-store/src/connection/subscribe/subscribeConnection.ts @@ -15,12 +15,21 @@ import HMSConnection from '../HMSConnection'; import HMSDataChannel from '../HMSDataChannel'; import { HMSConnectionRole } from '../model'; +/** + * Represents a connection for subscribing to media from the signalling server. + * Extends the HMSConnection class to provide additional functionality for subscribing to media + * @extends {HMSConnection} + */ export default class HMSSubscribeConnection extends HMSConnection { private readonly TAG = '[HMSSubscribeConnection]'; private readonly remoteStreams = new Map(); protected readonly observer: ISubscribeConnectionObserver; private readonly MAX_RETRIES = 3; + /** + * The native WebRTC peer connection object + * @type {RTCPeerConnection} + */ nativeConnection: RTCPeerConnection; private pendingMessageQueue: string[] = []; From 50cf4042d6e9c10ee4748768bece94817bca865e Mon Sep 17 00:00:00 2001 From: Yogesh Singh Date: Mon, 16 Dec 2024 12:00:11 +0530 Subject: [PATCH 3/3] docs: reverted removal of ts expect error directive --- packages/hms-video-store/src/connection/HMSConnection.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/hms-video-store/src/connection/HMSConnection.ts b/packages/hms-video-store/src/connection/HMSConnection.ts index bf548bce26..eb584c1f03 100644 --- a/packages/hms-video-store/src/connection/HMSConnection.ts +++ b/packages/hms-video-store/src/connection/HMSConnection.ts @@ -146,6 +146,7 @@ export default abstract class HMSConnection { const iceTransport = transmitter.transport.iceTransport; const handleSelectedCandidate = () => { + // @ts-expect-error if (typeof iceTransport.getSelectedCandidatePair === 'function') { // @ts-expect-error this.selectedCandidatePair = iceTransport.getSelectedCandidatePair(); @@ -161,7 +162,9 @@ export default abstract class HMSConnection { } }; + // @ts-expect-error if (typeof iceTransport.onselectedcandidatepairchange === 'function') { + // @ts-expect-error iceTransport.onselectedcandidatepairchange = handleSelectedCandidate; } handleSelectedCandidate();