0

In my app, I am implementing video chat and for that I am using sinch client and I am reffering below link provided by official documentation.

https://www.sinch.com/docs/video/android/#videocalling

and using below code i am adding remote view to the layout

 @Override
    public void onVideoTrackAdded(Call call) {
        Log.e("test","video track added is called now");
        SinchClient sinchClient = getSinchServiceInterface().getSinchClient();
        if (sinchClient != null) {
            VideoController videoController =  sinchClient.getVideoController();

            View myPreview = videoController.getLocalView();
            View remoteView = videoController.getRemoteView();
            mUpperLinearLayout.addView(myPreview);
            mLowerLinearLayout.addView(remoteView);
        }
    }

I have splitted out my UI into two linear layouts name upper layout and lower layout and I am adding remote view to the linear layout as mentioned in the documents. But I am getting black or blank view on connecting video call successfully.Why is that so am I missing anything?one more thing I have observed in log cat there is an error as mentioned below

 CameraEnumerator: java.lang.RuntimeException: Fail to connect to camera service

I have googled a lot and tried different links as mentioned below

Sinch Video Chat - Remote Video Issue

but no luck . Any help?

I am using below code for permission.

 private void callVideo() {
    try {
        Call call = getSinchServiceInterface().callVideoUser(mVoipContact.getUserName());
        if (call == null) {
            // Service failed for some reason, show a Toast and abort
            Toast.makeText(getApplicationContext(), getString(R.string.txt_service_not_started) + getString(R.string.txt_placing_call), Toast.LENGTH_LONG).show();
            return;
        }
        String callId = call.getCallId();
        Intent callScreen = new Intent(getApplicationContext(), VideoCallScreenActivity.class);
        callScreen.putExtra(VoipConstants.CALL_ID, callId);
        startActivity(callScreen);
    } catch (MissingPermissionException e) {
        ActivityCompat.requestPermissions(MessagingActivity.this, new String[]{e.getRequiredPermission()}, REQUEST_CODE_PERMISSION_CALL);
    }
}

Now i can see below log cat error

VideoCapturerAndroid: Camera freezed: Camera failure.

2 Answers2

0

Like this

if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 50);
}    else {       


   callVideo(); 
}

For other error try adding this setPreviewTexture() in Try Catch OR just remove this line

Abdul Kawee
  • 2,687
  • 1
  • 14
  • 26
0

You are adding localView when remote view will be active. Try to add localView when sinch client is ready. In sinch if localView will not be clear then remote view will not show.

I don't know your code flow so I can't say where you have to add localView.

I hope, It will help you.

Sumit Kumar
  • 564
  • 6
  • 14