Skip to content

Commit

Permalink
feat: add id and readyState to stream classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce Tham committed Sep 29, 2023
1 parent 787e429 commit c7859ed
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@types/mocha": "^9.0.0",
"@types/node": "^16.0.1",
"@types/sdp-transform": "^2.4.5",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"chai": "^4.3.4",
Expand Down Expand Up @@ -111,6 +112,7 @@
"events": "^3.3.0",
"js-logger": "^1.6.1",
"typed-emitter": "^2.1.0",
"uuid": "^8.3.2",
"webrtc-adapter": "^8.1.2"
},
"lint-staged": {
Expand Down
9 changes: 9 additions & 0 deletions src/media/local-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ abstract class _LocalStream extends Stream {
return this.inputTrack.label;
}

/**
* Get the readyState of the input track on this stream.
*
* @returns The readyState of the track.
*/
get readyState(): string {
return this.inputTrack.readyState;
}

/**
* Change the track of the output stream to a different track.
*
Expand Down
3 changes: 3 additions & 0 deletions src/media/stream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AddEvents, TypedEvent, WithEventsDummyType } from '@webex/ts-events';
import { v4 as uuid } from 'uuid';

export enum StreamEventNames {
MuteStateChange = 'mute-state-change',
Expand All @@ -14,6 +15,8 @@ interface StreamEvents {
* Base stream class.
*/
abstract class _Stream {
readonly id = uuid();

// The output stream should never be reassigned, since it is the stream that is being given out.
readonly outputStream: MediaStream;

Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2533,6 +2533,11 @@
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
integrity sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==

"@types/uuid@^8.3.4":
version "8.3.4"
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.4.tgz#bd86a43617df0594787d38b735f55c805becf1bc"
integrity sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==

"@types/which@^1.3.2":
version "1.3.2"
resolved "https://registry.yarnpkg.com/@types/which/-/which-1.3.2.tgz#9c246fc0c93ded311c8512df2891fb41f6227fdf"
Expand Down Expand Up @@ -11233,7 +11238,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==

uuid@^8.0.0:
uuid@^8.0.0, uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
Expand Down

0 comments on commit c7859ed

Please sign in to comment.