Skip to content

Commit

Permalink
Expose withAudio and withVideo from the BaseConnection (#1149)
Browse files Browse the repository at this point in the history
* Expose  and  from the BaseConnection

* include changeset:
  • Loading branch information
iAmmar7 authored Dec 10, 2024
1 parent 5545910 commit 5e45391
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/early-pots-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@signalwire/webrtc': minor
'@signalwire/core': minor
---

Browser SDKs: Expose the `withAudio` and `withVideo` flags to indicate the receiving media.
8 changes: 6 additions & 2 deletions packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ export interface BaseConnectionContract<
readonly cameraId: string | null
/** The label of the video device, or null if not available */
readonly cameraLabel: string | null
/** Provides access to the local [MediaStream](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream) */
readonly localStream: MediaStream | undefined
/** Indicates if there is any receiving audio */
readonly withAudio: boolean
/** Indicates if there is any receiving video */
readonly withVideo: boolean
/**
* Provides access to the local audio
* [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack).
*/
readonly localAudioTrack: MediaStreamTrack | null
/** Provides access to the local [MediaStream](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream) */
readonly localStream: MediaStream | undefined
/**
* Provides access to the local video
* [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack).
Expand Down
12 changes: 5 additions & 7 deletions packages/webrtc/src/BaseConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class BaseConnection<EventTypes extends EventEmitter.ValidEventTypes>
dialogParams(rtcPeerId: string) {
const {
destinationNumber,
attach,
attach,
callerName,
callerNumber,
remoteCallerName,
Expand Down Expand Up @@ -249,24 +249,22 @@ export class BaseConnection<EventTypes extends EventEmitter.ValidEventTypes>
return this.peer ? this.peer.getDeviceLabel('audio') : null
}

/** @internal */
get withAudio() {
return Boolean(this.peer?.hasAudioReceiver)
}

/** @internal */
get withVideo() {
return Boolean(this.peer?.hasVideoReceiver)
}

get localVideoTrack() {
return this.peer ? this.peer.localVideoTrack : null
}

get localAudioTrack() {
return this.peer ? this.peer.localAudioTrack : null
}

get localVideoTrack() {
return this.peer ? this.peer.localVideoTrack : null
}

get peer() {
return this.getRTCPeerById(this.activeRTCPeerId)
}
Expand Down

0 comments on commit 5e45391

Please sign in to comment.