Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Employee
42 Views

Switching between Front & Rear Cameras

Is there any way to switch from the front facing cam to the rear cam in the android client?

If not, can I set the rear camera as the default for the stream?

Tags (2)
0 Kudos
2 Replies
Highlighted
Beginner
42 Views

Hello Vinay,

yes, it's possible. I've done it with the following solution in the MainActivity:

1. Get the cameras

    private void showCameraList() {
        CameraType[] camTypes = MediaStreamParameters.getCameraList();
        if(camTypes.length == 1){
            selectedCam = 0;
            joinRoom();
        }else{
            int camNumber = camTypes.length;
            ArrayList<String> cams = new ArrayList<String>();
            for (int i = 0; i < camNumber; i++) {
                cams.add(camTypes.name());
            }
            CharSequence[] cs = cams.toArray(new CharSequence[cams.size()]);
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("Choose CAM");
            builder.setCancelable(false);
            builder.setItems(cs, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    // Do something with the selection
                    selectedCam = item;
                    joinRoom();
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    }

Does the following:

If theres only 1 cam present it joins the room directly. If there are more, it lets you choose the camera and sets the index to a variable (selectedCam).

2. set Parameters

I cannot remember where, but you'll need to set the Parameters like this:


    private MediaStreamParameters msp;

    msp = new MediaStreamParameters(true, true);
                        msp.setResolution(size.x, size.y);
                        msp.setCameraId(selectedCam);

localView = new VideoStreamsView(CallActivity.this.getApplicationContext(), size);

                        runOnUiThread(new Runnable() {
                            public void run() {
                                localContainer.addView(localView);
                            }
                        });

                        localStream = new Stream(msp);
                        localStream.attach(localView);

 

0 Kudos
Highlighted
42 Views

https://software.intel.com/en-us/forums/topic/543285 should help solve this issue. Let us know in case you have further issues.

0 Kudos