1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Make MatrixCall use CallFeed

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner
2021-03-07 14:17:21 +01:00
parent ba8577f268
commit 530b60cbc2
2 changed files with 70 additions and 152 deletions

View File

@@ -14,15 +14,40 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import EventEmitter from "events";
export enum CallFeedType {
Webcam = "webcam",
Screenshare = "screenshare",
}
export class CallFeed {
export enum CallFeedEvent {
NewStream = "new_stream",
}
export class CallFeed extends EventEmitter {
constructor(
public stream: MediaStream,
public userId: string,
public type: CallFeedType,
) {}
private client: any, // Fix when client is TSified
) {
super()
}
public isLocal() {
return this.userId === this.client.getUserId();
}
// TODO: This should be later replaced by a method
// that will also check if the remote is muted.
public isAudioOnly(): boolean {
// We assume only one video track
return !this.stream.getTracks().some((track) => track.kind === "video");
}
public setNewStream(newStream: MediaStream) {
this.stream = newStream;
this.emit(CallFeedEvent.NewStream, this.stream);
}
}