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: listen to track events and additional updates to stream classes #57

Merged
merged 4 commits into from
Jul 14, 2023

Conversation

brycetham
Copy link
Contributor

This PR makes several additional changes to the stream classes, including listening to media stream track events in Stream, adding more abstract methods, and updating how inputTrack and outputTrack are used in LocalStream.

@brycetham brycetham requested a review from bbaldino July 13, 2023 13:01
if (this.inputTrack.id === newTrack.id) {
this._outputStream = this.inputStream;
} else if (this.inputTrack.id === this.outputTrack.id) {
this._outputStream = new MediaStream([newTrack]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to preserve the output stream, since that's what callers will have a handle to. So we actually need to create a new stream that'll be used as the input stream, and move the current input/output track to that, and then add the new track to the existing outputstream. (Tweak the comment as well)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd think enabling background blur or something should show that this doesn't work: the local rendering of the video wouldn't show the blur since the outputstream changes?

Comment on lines 102 to 115
// input track is same as old output track, so separate the input stream into a new stream
if (this.inputTrack.id === this.outputTrack.id) {
this.inputStream = new MediaStream(this.inputStream);
}

this.outputStream.removeTrack(this.outputTrack);
this.outputStream.addTrack(newTrack);

// input track is same as new output track, so set the streams to be the same
if (this.inputTrack.id === this.outputTrack.id) {
this.inputStream = this.outputStream;
}

this[LocalStreamEventNames.OutputTrackChange].emit(newTrack);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think be really verbose/descriptive with the comments here, the logic is pretty dense.

@brycetham brycetham merged commit 7d0fcef into stream_classes Jul 14, 2023
@brycetham brycetham deleted the btham/stream_class_events branch July 14, 2023 16:07
brycetham added a commit that referenced this pull request Jul 19, 2023
* feat: new stream classes initial commit (#49)

* feat: new stream classes initial commit

* refactor: originStream -> inputStream

* feat: integrate new stream types (#50)

* feat: replace LocalMicrophoneTrack with LocalMicrophoneStream

* refactor: replace LocalDisplayTrack with LocalDisplayStream

* refactor: replace LocalCameraTrack with LocalCameraStream

* refactor: remove LocalTrack

* refactor: rename originTrack -> inputTrack

* feat: effects api (#52)

* feat: add effects api

* fix: add loadingeffects protection

* test: localstream unit tests

* chore: upgrade effects version

* refactor: add methods and update events for stream classes (#55)

* refactor: add support for wcme refactor

* chore: minor updates to LocalStream and unit tests

---------

Co-authored-by: Bryce Tham <[email protected]>

* feat: limit appliable constraints (#56)

* feat: limit appliable constraints

* refactor: pick VideoDeviceConstraints from MediaTrackConstraints

---------

Co-authored-by: Bryce Tham <[email protected]>

* feat: listen to track events and additional updates to stream classes (#57)

* feat: listen to track events and additional updates to stream classes

* fix: preserve outputStream in changeOutputTrack

* chore: change outputStream to readonly

* chore: update unit tests and comments

---------

Co-authored-by: Bryce Tham <[email protected]>

* chore: update docs and errors in device management API

* fix: stop outputTrack on LocalStream stop

---------

Co-authored-by: bbaldino <[email protected]>
Co-authored-by: Tyler McCarthy <[email protected]>
Co-authored-by: Bryce Tham <[email protected]>
brycetham added a commit that referenced this pull request Jul 19, 2023
* feat: new stream classes initial commit (#49)

* feat: new stream classes initial commit

* refactor: originStream -> inputStream

* feat: integrate new stream types (#50)

* feat: replace LocalMicrophoneTrack with LocalMicrophoneStream

* refactor: replace LocalDisplayTrack with LocalDisplayStream

* refactor: replace LocalCameraTrack with LocalCameraStream

* refactor: remove LocalTrack

* refactor: rename originTrack -> inputTrack

* feat: effects api (#52)

* feat: add effects api

* fix: add loadingeffects protection

* test: localstream unit tests

* chore: upgrade effects version

* refactor: add methods and update events for stream classes (#55)

* refactor: add support for wcme refactor

* chore: minor updates to LocalStream and unit tests

---------

Co-authored-by: Bryce Tham <[email protected]>

* feat: limit appliable constraints (#56)

* feat: limit appliable constraints

* refactor: pick VideoDeviceConstraints from MediaTrackConstraints

---------

Co-authored-by: Bryce Tham <[email protected]>

* feat: listen to track events and additional updates to stream classes (#57)

* feat: listen to track events and additional updates to stream classes

* fix: preserve outputStream in changeOutputTrack

* chore: change outputStream to readonly

* chore: update unit tests and comments

---------

Co-authored-by: Bryce Tham <[email protected]>

* chore: update docs and errors in device management API

* fix: stop outputTrack on LocalStream stop

---------

Co-authored-by: bbaldino <[email protected]>
Co-authored-by: Tyler McCarthy <[email protected]>
Co-authored-by: Bryce Tham <[email protected]>

BREAKING CHANGE: convert track-based classes into stream-based classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants