cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
10196
Views
1
Helpful
37
Replies

video and preview views rendering green

Murat Demirel
Cisco Employee
Cisco Employee

Hi team,

Below is the sentence from the Advanced CSDK Developer's Guide:

"When there is no video stream being sent or received, the video view and preview view renders a full frame of green. Only when streaming does video appear."


It seems this green screen is by design. However, I wanted to ask whether there is a way to change this?


Thanks and regards,

Murat



37 Replies 37

rdavies1
Level 1
Level 1

Hi Murat.

Thank you for your question.

I don't believe it is possible to change the colour of this but let me find out more information for you.

Can I just confirm If you are interested in any platform in particular?

Cheers,

Rach D

Hi Rach,

Thanks for the reply. Sorry, I forgot to mention in my first message. This is only for Android platform.

iOS is working fine but in Android we see the green screen.

Thanks and regards,

Murat

Hi Murat.

Thank you for the update, I've just had a quick discussion with the team here and they asked me to check if you have tried this:

"Register as a VideoSurfaceListener, and implement the onSurfaceRenderingStarted() method, and only display the VideoSurface in the app once rendering has started."

Our Sample application uses this approach and doesn't display the green frames.

If this doesn't work for you please do let us know and we can investigate into this further. We will in that case however need to know more information on what you are trying to achieve and where the issue is occurring.

Cheers,

Rach

Hi Rach,

I will try this and let you know about the results.

Thanks and regards,

Murat

Hi Rach,

We tried but it did not work. Do you have a sample code snippet for this?

Thanks and regards,

Murat

rdavies1
Level 1
Level 1

Hi Murat.

That's no problem, do you have access to our sample application? You can use the code from there if so, it may even be worth checking that is what you are looking for by previewing the sample.

Cheers,

Rach D

Murat Demirel
Cisco Employee
Cisco Employee

Hi Rach,

Do you mean the sample application coming with the SDK?

Thanks and regards,

Murat

Hi Rach,

The related code in the SDK is as follows:

----------------------------------------------------------------------------------------------------------------------------

        @Override

        public void onSurfaceRenderingStarted(VideoSurface videoSurface)

        {

            if (videoViews.contains(videoSurface))

            {

                assignVideoSurfaceToCall(videoSurface);

            }

            if (listener != null)

            {

                listener.onSurfaceRenderingStarted(videoSurface);

            }

        }

----------------------------------------------------------------------------------------------------------------------------      

  

My customer's code is as follows:

----------------------------------------------------------------------------------------------------------------------------    

        public void onSurfaceRenderingStarted(VideoSurface videoSurface) {

        new Handler(Looper.getMainLooper()).post(new Runnable() {

            @Override

            public void run() {

                remotePreviewContainer.setVisibility(View.VISIBLE);

            }

        });

----------------------------------------------------------------------------------------------------------------------------

Do you see a problem with this code?

Thanks and regards,

Murat

Hi Murat.

Would you be able to give a little more information on the customers code? a larger snippet would be good but we are looking to find out of the video view was visible before the renderingStarted event?

Cheers,

Rach

Hi Rach,

I could not attach the file itself. It is little bit long but I am pasting the code of the class here. Thank you very much for your support.

Regards,

Murat

------------------------------------------------------------------------------------------------------------------------------------------------------------

public class MainActivity extends AppCompatActivity implements UCListener, VideoSurfaceListener {

    private UC uc;

    private Phone phone;

    private RelativeLayout container;

    private RelativeLayout remotePreviewContainer;

    private VideoSurface remotePreview;

    private RelativeLayout selfPreviewContainer;

    private VideoSurface selfPreview;

    private Button startStopButton;

    private com.alicecallsbob.fcsdk.android.phone.Call activeCall;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        container = new RelativeLayout(this);

        setContentView(container);

        encryptionTest();

        remotePreviewContainer = new RelativeLayout(this);

        remotePreviewContainer.setBackgroundColor(Color.BLACK);

        remotePreviewContainer.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        container.addView(remotePreviewContainer);

        selfPreviewContainer = new RelativeLayout(this);

        selfPreviewContainer.setBackgroundColor(Color.BLACK);

        RelativeLayout.LayoutParams selfPreviewContainerParams = new RelativeLayout.LayoutParams(Utils.convertPx(80), Utils.convertPx(100));

        selfPreviewContainerParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

        selfPreviewContainerParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

        selfPreviewContainerParams.setMargins(0, 0, Utils.convertPx(10), Utils.convertPx(10));

        selfPreviewContainer.setLayoutParams(selfPreviewContainerParams);

        container.addView(selfPreviewContainer);

        RelativeLayout.LayoutParams startStopLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

        startStopLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

        startStopLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

        startStopLayoutParams.setMargins(0, 0, 0, Utils.convertPx(10));

        startStopButton = new Button(this);

        startStopButton.setText("Start");

        container.addView(startStopButton, startStopLayoutParams);

        startStopButton.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                postToGetSessionId();

            }

        });

        PermissionManager pm = PermissionManager.create(this);

        pm.with(android.Manifest.permission.CAMERA, android.Manifest.permission.RECORD_AUDIO).request();

        AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

        audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);

        audioManager.setSpeakerphoneOn(true);

    }

    private void postToGetSessionId(){

        String postDataJSON =

        "{\n" +

        "  \"webAppId\": \"OdeaRemoteExpertProject\",\n" +

        "  \"allowedOrigins\": [\"*\"],\n" +

        "  \"urlSchemeDetails\": {\n" +

        "      \"host\": \"remoteexpert.odeabank.com.tr\",\n" +

        "      \"port\": \"443\",\n" +

        "      \"secure\": true\n" +

        "  },\n" +

        "  \"voice\": {\n" +

        "      \"username\": \"assist-m2v7r3jpb0jsk5j28ok4b5o4s\",\n" +

        "      \"displayName\": \"An Anonymous User\",\n" +

        "      \"domain\": \"10.224.60.211\"\n" +

        "  },\n" +

        "  \"uuiData\": \"deneme1\"\n" +

        "};";

        OkHttpClient httpClient = new OkHttpClient();

        Request request = new Request.Builder()

                .url("https://remoteexpert.odeabank.com.tr/gateway/sessions/session")

                .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), postDataJSON))

                .build();

        httpClient.newCall(request).enqueue(new Callback() {

            @Override

            public void onFailure(Call call, IOException e) {

                Log.v("Error", "Error");

            }

            @Override

            public void onResponse(Call call, Response response) throws IOException {

                Log.v("Response", response.toString());

                JSONObject responseData = null;

                try {

                    responseData = new JSONObject(response.body().string());

                    if (responseData != null) {

                        final String sessionId = responseData.getString("sessionid");

                        new Handler(Looper.getMainLooper()).post(new Runnable() {

                            @Override

                            public void run() {

                                startSession(sessionId);

                            }

                        });

                    }

                } catch (JSONException e) {

                    e.printStackTrace();

                }

            }

        });

    }

    private void startSession(String sessionId) {

        uc = UCFactory.createUc(this, sessionId, this);

        uc.setNetworkReachable(true);

        uc.setTrustManager(new TrustAllCerts());

        uc.setHostnameVerifier(new NullHostNameVerifier());

        uc.startSession();

        phone = uc.getPhone();

        phone.addListener(new PhoneListener() {

            @Override

            public void onIncomingCall(com.alicecallsbob.fcsdk.android.phone.Call call) {

            }

            @Override

            public void onCaptureSettingChange(PhoneVideoCaptureSetting phoneVideoCaptureSetting, int i) {

            }

            @Override

            public void onLocalMediaStream() {

            }

        });

        phone.setCamera(CAMERA_FACING_FRONT);

        //phone.setVideoOrientation(Surface.ROTATION_0);

        phone.setVideoOrientation(270);

        phone.setPreferredCaptureResolution(PhoneVideoCaptureResolution.RESOLUTION_960x720);

        remotePreview = phone.createVideoSurface(MainActivity.this, new Point(remotePreviewContainer.getWidth(), remotePreviewContainer.getHeight()), MainActivity.this);

        remotePreviewContainer.addView(remotePreview);

        remotePreviewContainer.setVisibility(View.GONE);

        selfPreview = phone.createVideoSurface(MainActivity.this, new Point(selfPreviewContainer.getWidth(), selfPreviewContainer.getHeight()), MainActivity.this);

        selfPreview.setZOrderOnTop(true);

        selfPreviewContainer.addView(selfPreview);

        phone.setPreviewView(selfPreview);

    }

    @Override

    public void onSessionStarted() {

        new Handler(Looper.getMainLooper()).post(new Runnable() {

            @Override

            public void run() {

                try {

                    activeCall = phone.createCall("sip:80003@10.224.60.211", true, true, new CallListener() {

                        @Override

                        public void onDialFailed(com.alicecallsbob.fcsdk.android.phone.Call call, String s, CallStatus callStatus) {

                        }

                        @Override

                        public void onCallFailed(com.alicecallsbob.fcsdk.android.phone.Call call, String s, CallStatus callStatus) {

                        }

                        @Override

                        public void onMediaChangeRequested(com.alicecallsbob.fcsdk.android.phone.Call call, boolean b, boolean b1) {

                        }

                        @Override

                        public void onStatusChanged(com.alicecallsbob.fcsdk.android.phone.Call call, CallStatus callStatus) {

                        }

                        @Override

                        public void onStatusChanged(com.alicecallsbob.fcsdk.android.phone.Call call, CallStatusInfo callStatusInfo) {

                        }

                        @Override

                        public void onRemoteDisplayNameChanged(com.alicecallsbob.fcsdk.android.phone.Call call, String s) {

                        }

                        @Override

                        public void onRemoteMediaStream(com.alicecallsbob.fcsdk.android.phone.Call call) {

                        }

                        @Override

                        public void onInboundQualityChanged(com.alicecallsbob.fcsdk.android.phone.Call call, int i) {

                        }

                        @Override

                        public void onRemoteHeld(com.alicecallsbob.fcsdk.android.phone.Call call) {

                        }

                        @Override

                        public void onRemoteUnheld(com.alicecallsbob.fcsdk.android.phone.Call call) {

                        }

                    });

                    activeCall.setVideoView(remotePreview);

                } catch (CallCreationWithErrorException e) {

                    e.printStackTrace();

                }

            }

        });

    }

    @Override

    public void onSessionNotStarted() {

    }

    @Override

    public void onSystemFailure() {

    }

    @Override

    public void onConnectionLost() {

    }

    @Override

    public void onConnectionRetry(int i, long l) {

    }

    @Override

    public void onConnectionReestablished() {

    }

    @Override

    public void onGenericError(String s, String s1) {

    }

    @Override

    public void onFrameSizeChanged(int i, int i1, VideoSurface.Endpoint endpoint, VideoSurface videoSurface) {

    }

    @Override

    public void onSurfaceRenderingStarted(VideoSurface videoSurface) {

        new Handler(Looper.getMainLooper()).post(new Runnable() {

            @Override

            public void run() {

                remotePreviewContainer.setVisibility(View.VISIBLE);

            }

        });

    }

    private void encryptionTest() {

        String userID = "************";

        String password = "***************";

        String encryptred = null;

        try {

            encryptred = EncryptionManager.encrypt(userID, password);

            Log.v("EncryptionManager::encryptData", encryptred);

        }

        catch (Exception e) {

            e.printStackTrace();

        }

        try {

            String decrypted = EncryptionManager.decrypt(encryptred, password);

            Log.v("EncryptionManager::decryptData", decrypted);

        }

        catch (Exception e) {

            e.printStackTrace();

        }

    }

}

------------------------------------------------------------------------------------------------------------------------------------------------------------

Thanks Murat.

Will get back to you as soon as we can.

Cheers,

Rach

A potential issue we see is with the 'onSurfaceRenderingStarted' callback. It seems to be being called for both local preview and the remote preview. There doesn't seem to be a distinction between the two and it's possible that the remote view is being made visible when the local preview has started rendering.

Could you try

if (videoSurface == myRemoteSurface) {//make remote visible}

and see if that helps? 

We're hoping by making a clear definitive between the two you may not see the green screen issue any longer.

Cheers,

Rach D

Hi Rach,

We tried this but unfortunately still the same. We are receiving the onSurfaceRenderingStarted event and we are checking if videoSurface == myRemoteSurface. However, again we are seeing the green background for a few seconds.


When is the onSurfaceRenderingStarted event coming? Is it triggered by the SIP OK message or by the RTP packets coming?

Thanks and regards,

Murat

Hi Murat.

Thank you for your reply. Can I just confirm if the green background has improved to only a few seconds or a few seconds was always the case?
Was there any change saw after you added the above suggestion?

For the SurfaceRenderingStarted I believe it's the incoming RTP packets but let me clarify that with the team to be 100% sure.

Cheers,

Rach

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: