forked from react-native-webrtc/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 2
Add VoIP calling capabilties to fishjam #78
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
afabf24
[FCE-3434] Android telecom integration (#63)
Magmusacy a206f36
[FCE-3435] Handle common VoIP patterns (#67)
Magmusacy e912024
[FCE-3599] Allow for FCM services coexistance (#70)
Magmusacy 14488e6
Use only transactional-valid DisconnectCause codes (#75)
Magmusacy 9ec1a35
Merge branch 'master' into feature/voip-calls
Magmusacy 4a2de23
Tear down the JS call on iOS answer-fulfill timeout and restore hones…
Magmusacy e73fa3a
Avoid NPE
Magmusacy 03d498b
Do not re-emit native events when mounted (they are already read on m…
Magmusacy cf00ec2
Fix cross-thread races in CallKitManager (iOS) and CallManager (Andro…
Magmusacy 19f70a8
Make VoIP naming consistent
Magmusacy 8c27c98
Fix
Magmusacy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
android/src/main/java/com/oney/WebRTCModule/TelecomController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| package com.oney.WebRTCModule; | ||
|
|
||
| import android.app.Activity; | ||
| import android.os.Build; | ||
|
|
||
| import com.facebook.react.bridge.Arguments; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.bridge.WritableMap; | ||
| import com.oney.WebRTCModule.voip.CallEventsListener; | ||
| import com.oney.WebRTCModule.voip.CallManager; | ||
| import com.oney.WebRTCModule.voip.LockScreenController; | ||
|
|
||
| final class TelecomController implements CallEventsListener { | ||
| private final WebRTCModule webRTCModule; | ||
| private final ReactApplicationContext reactContext; | ||
| private final AudioOutputManager audioOutputManager; | ||
|
|
||
| TelecomController( | ||
| WebRTCModule webRTCModule, ReactApplicationContext reactContext, AudioOutputManager audioOutputManager) { | ||
| this.webRTCModule = webRTCModule; | ||
| this.reactContext = reactContext; | ||
| this.audioOutputManager = audioOutputManager; | ||
| } | ||
|
|
||
| // Core-Telecom (CallManager) requires API 26+; below that, Telecom methods are no-ops. | ||
| void attach() { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| CallManager.INSTANCE.setListener(this); | ||
| CallManager.INSTANCE.setAudioOutputManager(audioOutputManager); | ||
| } | ||
| } | ||
|
|
||
| void detach() { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| // CallManager is a process-wide singleton; detach so it doesn't hold a | ||
| // reference to this (possibly destroyed) controller after a reload. | ||
| CallManager.INSTANCE.setListener(null); | ||
| CallManager.INSTANCE.setAudioOutputManager(null); | ||
| } | ||
| } | ||
|
|
||
| void startCall(String displayName, String handle, boolean isVideo) { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| CallManager.INSTANCE.startOutgoingCall(reactContext, displayName, handle, isVideo); | ||
| } | ||
| } | ||
|
|
||
| void reportOutgoingCallConnected() { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| CallManager.INSTANCE.reportOutgoingCallConnected(); | ||
| } | ||
| } | ||
|
|
||
| boolean fulfillAnswered(String requestId) { | ||
| return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && CallManager.INSTANCE.fulfillAnswered(requestId); | ||
| } | ||
|
|
||
| void failAnswered(String requestId) { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| CallManager.INSTANCE.failAnswered(requestId); | ||
| } | ||
| } | ||
|
|
||
| void endCall(String reason) { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| CallManager.INSTANCE.endCall(CallManager.INSTANCE.reasonToCause(reason)); | ||
| } | ||
| } | ||
|
|
||
| void setCallHeld(boolean onHold) { | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| CallManager.INSTANCE.setCallHeld(onHold); | ||
| } | ||
| } | ||
|
|
||
| boolean hasActiveCall() { | ||
| return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && CallManager.INSTANCE.hasActiveCall(); | ||
| } | ||
|
|
||
| boolean isAnswered() { | ||
| return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && CallManager.INSTANCE.isAnswered(); | ||
| } | ||
|
|
||
| boolean isOnHold() { | ||
| return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && CallManager.INSTANCE.isOnHold(); | ||
| } | ||
|
|
||
| String pendingAnswerRequestId() { | ||
| return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ? CallManager.INSTANCE.pendingAnswerRequestId() : null; | ||
| } | ||
|
|
||
| @Override | ||
| public void onStarted() { | ||
| WritableMap body = Arguments.createMap(); | ||
| body.putString("event", "started"); | ||
| webRTCModule.sendEvent("telecomActionPerformed", body); | ||
| } | ||
|
|
||
| @Override | ||
| public void onAnswered(String requestId) { | ||
| // Warm start: the host activity already exists, so the lifecycle hook | ||
| // in LockScreenController never fires — flag it directly. | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| Activity activity = reactContext.getCurrentActivity(); | ||
| if (activity != null) { | ||
| LockScreenController.INSTANCE.showOverLockScreen(activity); | ||
| } | ||
| } | ||
| WritableMap body = Arguments.createMap(); | ||
| body.putString("event", "answer"); | ||
| body.putString("requestId", requestId); | ||
| webRTCModule.sendEvent("telecomActionPerformed", body); | ||
| } | ||
|
|
||
| @Override | ||
| public void onEnded(String reason) { | ||
| WritableMap body = Arguments.createMap(); | ||
| body.putString("event", "ended"); | ||
| body.putString("reason", reason); | ||
| webRTCModule.sendEvent("telecomActionPerformed", body); | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailed(String reason) { | ||
| WritableMap body = Arguments.createMap(); | ||
| body.putString("event", "failed"); | ||
| body.putString("reason", reason); | ||
| webRTCModule.sendEvent("telecomActionPerformed", body); | ||
| } | ||
|
|
||
| @Override | ||
| public void onMuteChanged(boolean muted) { | ||
| WritableMap body = Arguments.createMap(); | ||
| body.putString("event", "muteChanged"); | ||
| body.putBoolean("muted", muted); | ||
| webRTCModule.sendEvent("telecomActionPerformed", body); | ||
| } | ||
|
|
||
| @Override | ||
| public void onHoldChanged(boolean onHold) { | ||
| WritableMap body = Arguments.createMap(); | ||
| body.putString("event", "holdChanged"); | ||
| body.putBoolean("held", onHold); | ||
| webRTCModule.sendEvent("telecomActionPerformed", body); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.