diff --git a/package.json b/package.json index 8e7c8fd..1a74f24 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,7 @@ "license": "MIT", "licenseFilename": "LICENSE", "readmeFilename": "README.md", - "peerDependencies": { - "react-native-webrtc": "^1.75.1" - }, "devDependencies": { - "react-native-webrtc": "^1.75.1", "react-native-background-timer": "^2.1.1" } } diff --git a/src/verto/Call.js b/src/verto/Call.js index b748b83..9570141 100644 --- a/src/verto/Call.js +++ b/src/verto/Call.js @@ -75,6 +75,9 @@ export default class Call { this.ring(); } } + + this.causeCode = null; + this.cause = null; } bootstrapRealtimeConnection() { @@ -264,7 +267,13 @@ export default class Call { case ENUM.state.hangup: if (isAfterRequesting && isBeforeHangup) { - this.broadcastMethod('verto.bye', {}); + var params = {}; + if (this.cause != null && this.causeCode != null) + params = { causeCode:this.causeCode, cause: this.cause }; + + this.broadcastMethod('verto.bye', params); + this.causeCode = null; + this.cause = null; } this.setState(ENUM.state.destroy); @@ -333,7 +342,7 @@ export default class Call { this.cause = params.cause; } - if (!this.cause && !this.causeCode) { + if (this.cause === null && this.causeCode === null) { this.cause = 'NORMAL_CLEARING'; } diff --git a/src/verto/VertoClient.js b/src/verto/VertoClient.js index b07e540..79545f4 100644 --- a/src/verto/VertoClient.js +++ b/src/verto/VertoClient.js @@ -78,7 +78,7 @@ export default class VertinhoClient { onWebSocketLoginSuccess: () => {}, onWebSocketLoginError: error => printError('Error reported by WebSocket login', error), - onPeerStreaming: () => {}, + onPeerStreaming: (stream) => this.callbacks.onStreamReady(stream), onPeerStreamingError: () => {}, ...this.params, ...this.callbacks, diff --git a/src/webrtc/FSRTCPeerConnection.js b/src/webrtc/FSRTCPeerConnection.js index 2e94dde..993de57 100644 --- a/src/webrtc/FSRTCPeerConnection.js +++ b/src/webrtc/FSRTCPeerConnection.js @@ -79,14 +79,25 @@ export default class FSRTCPeerConnection { } }; - peer.onaddstream = event => { + /* peer.onaddstream = event => { const remoteMediaStream = event.stream; + if (onRemoteStream) { + onRemoteStream(remoteMediaStream); + } + }; + peer.addStream(attachStream);*/ + peer.ontrack = event => { + const remoteMediaStream = event.stream; if (onRemoteStream) { onRemoteStream(remoteMediaStream); } }; - peer.addStream(attachStream); + + attachStream.getTracks().forEach(track => { + console.log('Peer add track ',track); + peer.addTrack(track, attachStream); + }); if (onOfferSDP) { peer