androidskype-for-businessskypedeveloper

Modify rotation of the camera instance of the "Skype for Business SDK"


I'm looking for developing a video conferencing application for Android with the Skype for Business SDK (SfbSDK).

Too see if I'm able to do some needs, I cloned the git repository of the sample application with the SfbSDK dispensed by the Office Developer Team and available here

If the sample application allow me to broadcast the front facing camera and/or the back camera, I don't find any parameters that allow me to modify the camera instance except of changing target camera (front, back ...).

What I want (at least) is to modify the rotation when you turn your phone to landscape mode (modify other parameters would be great too, like Camera.Parameters).

Because if you try it with the sample application, the preview (on the phone) and the outgoing video are both turned like below.

Outgoing and preview display turned

So I've tried to create an instance of android.hardware.Camera and set it to active camera by casting it like this :

videoService.setActiveCamera(com.microsoft.office.sfb.appsdk.Camera)

But It doesn't work ... Or I'm doing it the wrong way ...!

Is this even possible !?

Any suggestion is welcomed.


Solution

  • Back on project no long ago, I've finally found a solution

    DeviceRotationMonitor.getInstance().onRotation(Context context);
    

    Do the work !!
    Hope it help.


    EDIT : As asked by @miecio in comment below, more info to how to use this answer.

    If you're using the Skype for Business SDK, you can find in the documentation a helper class (here) which grant you some functions to interact with it and also some callback handlers to receive the different states of it.

    In this helper class, you will find the following method :

    public class ConversationHelper {
        ...
        /**
         * Setup the Video preview.
         * @param texture SurfaceTexture
         */
        private void surfaceTextureCreatedCallback(SurfaceTexture texture) {
            try {
                // Tie the video stream to the texture view control
                videoService.showPreview(texture);
    
                // Check state of video service.
                // If not started, start it.
                if (this.videoService.canStart()) {
                    this.videoService.start();
                } else {
                    // On joining the meeting the Video service is started by default.
                    // Since the view is created later the video service is paused.
                    // Resume the service.
                    if (this.videoService.canSetPaused()) {
                        this.videoService.setPaused(false);
                    }
                }
                setSkypeOrientation();
            } catch (SFBException e) {
                e.printStackTrace();
            }
        }
        ...
    }
    

    In there I've added the following instruction : setSkypeOrientation().
    This is to set the correct screen orientation once the surface is created (by default, even if you don't add this, the screen orientation should be good).

    Moreover, in the activity which implement the helper class, I've overridden the onConfigurationChanged(Configuration newConfig) as follows :

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (mConversationHelper != null) {
            mConversationHelper.setSkypeOrientation();
        }
    }
    

    That part is for handle and set the right screen orientation.

    Finally, in setSkypeOrientation(), I simply used the above-mentioned instruction in the first edition of the answer.

    public class ConversationHelper {
        ...
        public void setSkypeOrientation() {
            DeviceRotationMonitor.getInstance().onRotation(mContext);
        }
        ...
    }
    

    Note : The class DeviceRotationMonitor is imported from :
    import com.microsoft.office.lync.platform.DeviceRotationMonitor;

    At least it's how I used it, you can adapt this to your use case.
    Hope the "edit" made the use more clear.