2022-02-16 21:31:02 +05:30
|
|
|
/*
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {Track, TrackType} from "./MediaDevices";
|
2022-02-25 21:24:00 +05:30
|
|
|
import {SDPStreamMetadataPurpose} from "../../matrix/calls/callEventTypes";
|
2022-02-16 21:31:02 +05:30
|
|
|
|
|
|
|
export interface WebRTC {
|
2022-04-12 17:32:38 +05:30
|
|
|
createPeerConnection(handler: PeerConnectionHandler, forceTURN: boolean, turnServers: RTCIceServer[], iceCandidatePoolSize): PeerConnection;
|
2022-02-16 21:31:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export interface PeerConnectionHandler {
|
|
|
|
onIceConnectionStateChange(state: RTCIceConnectionState);
|
|
|
|
onLocalIceCandidate(candidate: RTCIceCandidate);
|
|
|
|
onIceGatheringStateChange(state: RTCIceGatheringState);
|
|
|
|
onRemoteTracksChanged(tracks: Track[]);
|
2022-04-11 19:23:34 +05:30
|
|
|
onRemoteDataChannel(dataChannel: any | undefined);
|
2022-02-16 21:31:02 +05:30
|
|
|
onNegotiationNeeded();
|
|
|
|
// request the type of incoming stream
|
2022-02-25 21:24:00 +05:30
|
|
|
getPurposeForStreamId(streamId: string): SDPStreamMetadataPurpose;
|
2022-02-16 21:31:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export interface PeerConnection {
|
2022-02-25 21:24:00 +05:30
|
|
|
notifyStreamPurposeChanged(): void;
|
|
|
|
get remoteTracks(): Track[];
|
|
|
|
get iceGatheringState(): RTCIceGatheringState;
|
2022-03-02 18:23:22 +05:30
|
|
|
get signalingState(): RTCSignalingState;
|
2022-02-25 21:24:00 +05:30
|
|
|
get localDescription(): RTCSessionDescription | undefined;
|
2022-02-16 21:31:02 +05:30
|
|
|
createOffer(): Promise<RTCSessionDescriptionInit>;
|
|
|
|
createAnswer(): Promise<RTCSessionDescriptionInit>;
|
2022-02-18 21:08:10 +05:30
|
|
|
setLocalDescription(description?: RTCSessionDescriptionInit): Promise<void>;
|
2022-02-17 21:28:44 +05:30
|
|
|
setRemoteDescription(description: RTCSessionDescriptionInit): Promise<void>;
|
|
|
|
addIceCandidate(candidate: RTCIceCandidate): Promise<void>;
|
2022-02-16 21:31:02 +05:30
|
|
|
addTrack(track: Track): void;
|
|
|
|
removeTrack(track: Track): boolean;
|
|
|
|
replaceTrack(oldTrack: Track, newTrack: Track): Promise<boolean>;
|
2022-04-11 19:23:34 +05:30
|
|
|
createDataChannel(options: RTCDataChannelInit): any;
|
2022-02-18 21:08:10 +05:30
|
|
|
dispose(): void;
|
2022-03-02 18:23:22 +05:30
|
|
|
close(): void;
|
2022-02-16 21:31:02 +05:30
|
|
|
}
|