Skip to content

[Android] Video support on incomingCall#251

Draft
sboily wants to merge 10 commits into
masterfrom
video_support
Draft

[Android] Video support on incomingCall#251
sboily wants to merge 10 commits into
masterfrom
video_support

Conversation

@sboily

@sboily sboily commented Jul 29, 2020

Copy link
Copy Markdown
Member

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
Copy Markdown

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

sboily commented Nov 12, 2020

Copy link
Copy Markdown
Member Author

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
Copy Markdown

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
Copy Markdown

any progress on this feature?

@danjenkins

danjenkins commented Dec 6, 2020 via email

Copy link
Copy Markdown
Collaborator


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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

hussainsherwani commented May 24, 2021

Copy link
Copy Markdown

@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