Skip to content

[Android] Video support on incomingCall #251

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

[Android] Video support on incomingCall #251

wants to merge 10 commits into from

Conversation

sboily
Copy link
Member

@sboily sboily commented Jul 29, 2020

This PR add video support on incomingCall. Video support means when you received a video call, your phone replace the answer button by a video button, add an icon to explain you you are receiving a video call from the caller. This PR add a new arg to displayIncomingCall hasVideo (boolean). I only tested on my pixel phone for the moment and it missed some stuff to work correctly when screen is locked but it works.

@sboily sboily changed the title Video support on incomingCall [Android] Video support on incomingCall Aug 3, 2020
@nerdymind-dev
Copy link

I was just curious what stage this is at? I would love to test on an upcoming app as we need the features implemented here, but wasn't sure the stability of the current progress.

@sboily
Copy link
Member Author

sboily commented Nov 12, 2020

Hello, i have some issue with android 11 and i have no time to continue for the moment ... Help and feedback are welcome ;)

@nerdymind-dev
Copy link

Hello, i have some issue with android 11 and i have no time to continue for the moment ... Help and feedback are welcome ;)

Sure! I'd be happy too. I have a Pixel phone w/ Android 11 ready to go actually ;)

When I have time I'll switch to this branch and see if I can help contribute.

In the meantime, thanks for the quick reply!

@podvipodvert
Copy link

any progress on this feature?

@danjenkins
Copy link
Collaborator

danjenkins commented Dec 6, 2020 via email

@@ -479,7 +481,7 @@ private void registerPhoneAccount(Context appContext) {
String appName = this.getApplicationName(this.getAppContext());

PhoneAccount.Builder builder = new PhoneAccount.Builder(handle, appName)
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER);
.setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER | PhoneAccount.CAPABILITY_VIDEO_CALLING);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the phone account disappear on restart. Just investigating this myself and have tracked it down to this line - even changing it to PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING breaks it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But based on https://android.googlesource.com/platform/cts/+/cc920ce%5E%21/ this should be allowed.

If you enable this, enable the calling account etc, and then restart the phone your calling account won't be there until you launch the app.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh... it appears on first look of the settings and then disappears! So maybe the above is wrong...

@sboily sboily added help wanted Extra attention is needed WIP Work in progress labels Feb 19, 2021
@manuquentin
Copy link
Contributor

@jonastelzio @danjenkins we're kind of stuck with this feature 😕

When display the native video incoming call scene, Android provides a surface where to display the remote video.

I've this piece of code (waiting for react-native-webrtc/react-native-webrtc#987 to be merged):

@ReactMethod
    public void setRemoteVideo(String streamURL, String uuid) {
        Log.d("RNCK", "setRemoteVideo: " + streamURL);
        Context context = reactContext.getApplicationContext();
        Handler mainHandler = new Handler(context.getMainLooper());

        Runnable myRunnable = new Runnable() {
            @Override
            public void run() {
                Connection connection = VoiceConnectionService.getConnection(uuid);
                if (connection == null) {
                    Log.w("RNCK", "No connection found for call uuid: " + uuid);
                    return;
                }
                VideoConnectionProvider videoProvider = (VideoConnectionProvider) connection.getVideoProvider();
                Surface remoteSurface = videoProvider.getRemoteSurface();

                // Get video track
                VideoTrack videoTrack = null;
                WebRTCModule module = reactContext.getNativeModule(WebRTCModule.class);
                MediaStream stream = module.getStreamForReactTag(streamURL);
                if (stream != null) {
                    List<VideoTrack> videoTracks = stream.videoTracks;

                    if (!videoTracks.isEmpty()) {
                        videoTrack = videoTracks.get(0);
                    }
                }

                if (videoTrack == null) {
                    Log.w("RNCK", "No WebRTC video track found for call uuid: " + uuid);
                    return;
                }

                SurfaceViewRenderer surfaceViewRenderer = new SurfaceViewRenderer(context);
                EglBase.Context sharedContext = EglUtils.getRootEglBaseContext();
                surfaceViewRenderer.init(sharedContext, null);

                videoTrack.addSink(surfaceViewRenderer);

                EglBase eglBase = EglUtils.getRootEglBase();
                Log.w("RNCK", "remoteSurface: " + remoteSurface);
                eglBase.createSurface(remoteSurface);
                eglBase.makeCurrent();
            }
        };

        mainHandler.post(myRunnable);
    }

This method should be called when the video stream and the remote Surface is available.
The streamURL is the URL returned by toURL() method of react-native-webrtc and the uuid is the callkeep uuid call.

The issue is that I can't find a way to render the videoTrack in the Surface remoteSurface. Have you any clue of how to do it ?

Thanks !

@hussainsherwani
Copy link

hussainsherwani commented May 24, 2021

@manuquentin any update in this regards ? Found react-native-webrtc/react-native-webrtc#987 is merged and released in latest version. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants