Intel® Collaboration Suite for WebRTC
Community support and discussions on the Intel® Collaboration Suite for WebRTC (Intel® CS for WebRTC).

Switching between Front & Rear Cameras

Vinay_P_Intel
Employee
852 Views

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?

0 Kudos
2 Replies
Paul_S_2
Beginner
852 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
Chunbo_H_Intel1
Employee
852 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
Reply