forked from openland/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRTCRtpSender.js
27 lines (23 loc) · 928 Bytes
/
RTCRtpSender.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {NativeModules} from 'react-native';
import RTCRtpTransceiver from './RTCRtpTransceiver';
const {WebRTCModule} = NativeModules;
export default class RTCRtpSender {
_transceiver: RTCRtpTransceiver;
_mergeState: Function;
constructor(_transceiver: RTCRtpTransceiver, mergeState: Function) {
this._transceiver = _transceiver;
this._mergeState = mergeState;
}
replaceTrack = (track: MediaStreamTrack | null) => {
return new Promise((resolve, reject) => {
WebRTCModule.peerConnectionTransceiverReplaceTrack(this._transceiver._peerConnectionId, this._transceiver.id, track ? track.id : null, (successful, data) => {
if (successful) {
this._transceiver._mergeState(data.state);
resolve();
} else {
reject(new Error(data));
}
});
});
}
}