Support for using external USB camera instead of device camera

mariuspop6891

New Member
Hi guys,

I need to implement an audio/video call over sip functionality in my app(android app), and for video I need to use an external usb camera which I already implemented and connected. Is there a way to point your library to use external usb cam instead of internal device cam?

Thanks,

Marius
 

Max

Administrator
Staff member
Good day.
Please see Media Devices example (and source code on GitHub). You can use Flashphoner.getMediaDevices() method to get all the input devices visible to the system, then use MediaDeviceList.getVideoList() to list available cameras:
Java:
        mCameraSpinner = (LabelledSpinner) findViewById(R.id.camera);
        mCameraSpinner.setItemsArray(Flashphoner.getMediaDevices().getVideoList());
Then you can select the camera from this list and can switch form one camera to another even on the fly using Stream.switchCamera() method for example by button click
Java:
        mSwitchCameraButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (publishStream != null) {
                    mSwitchCameraButton.setEnabled(false);
                    publishStream.switchCamera(new CameraSwitchHandler() {
                        @Override
                        public void onCameraSwitchDone(boolean var1) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mSwitchCameraButton.setEnabled(true);
                                }
                            });

                        }

                        @Override
                        public void onCameraSwitchError(String var1) {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    mSwitchCameraButton.setEnabled(true);
                                }
                            });
                        }
                    });
                }
            }

        });
 
Last edited:
Top