Skip to content

Screen Sharing Optimization

ciscoRankush edited this page Jun 5, 2023 · 1 revision

ScreenShare Optimization API's

ScreenShare Optimization API's can be used to optimise the screen sharing experience for video and text. These modification to the API's are available from v3.9.0 onwards

ScreenShare Optimization API Examples

Screen sharing APIs are available in Call object. Call object can be obtained as a result of webex.phone.dial API or it is notified in IncomingCallListener.onIncomingCall API for an incoming call.

  1. ScreenSharing on Android devices targeting API 28 or previous.

    call.startSharing(CompletionHandler { result ->
        if (result.isSuccessful) {
            // startSharing successful
        } else {
            // startSharing failed
        }
    
    }, shareConfig = ShareConfig((Call.ShareOptimizeType.AutoDetection, false)))

    The shareConfig parameter is optional. If not set, optimization will be Default and audio will not be shared. The parameter shareConfig is from v3.9.0 onwards.

  2. ScreenSharing on Android devices targeting API 29 or higher.

    call.startSharing(notification = buildScreenShareForegroundServiceNotification(), notificationId = 0xabc61. CompletionHandler { result ->
        if (result.isSuccessful) {
            // startSharing successful
        } else {
            // startSharing failed
        } 
    }, shareConfig = ShareConfig((Call.ShareOptimizeType.AutoDetection, false)))
    
    private fun buildScreenShareForegroundServiceNotification(): Notification {
    
        val channelId =
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    createNotificationChannel("screen_share_service_v3_sdk", "Background Screen Share Service v3 SDK")
                } else { "" }
        val notificationBuilder =
                NotificationCompat.Builder(requireContext(), channelId)
                        .setSmallIcon(R.drawable.app_notification_icon)
                        .setContentTitle(getString("ScreenShare"))
                        .setContentText(getString("You are starting screenshare"))
                        .setPriority(NotificationCompat.PRIORITY_MAX)
                        .setTicker(getString(contentId))
                        .setDefaults(Notification.DEFAULT_SOUND)
    
        return notificationBuilder.build()
    }

    The shareConfig parameter is optional. If not set, optimization will be Default and audio will not be shared. The parameter shareConfig is from v3.9.0 onwards.

  3. To get the active sharing type for current call below API can be used.

    var sharingConfig = call.getShareConfig()

Setting ShareConfig:

    //This doesn't set any special optimization. Maximum is 3 fps. This is the default setting if no parameters are passed to the shareConfig param.
    var shareConfig = ShareConfig(Call.ShareOptimizeType.Default, false)

    //This automatically detects the type of sharing and sets the fps. Maximum is 5 fps.
    var shareConfig = ShareConfig(Call.ShareOptimizeType.AutoDetection, false)

    //This helps in optimizing screenshare while sharing video and motion without audio. Maximum is 30 fps.
    var shareConfig = ShareConfig(Call.ShareOptimizeType.OptimizeVideo, false)

    //This helps in optimizing screenshare while sharing video and motion without audio. Maximum is 30 fps.
    var shareConfig = ShareConfig(Call.ShareOptimizeType.OptimizeVideo, true)

    //This helps in optimizing screenshare while sharing text and images. Maximum is 5 fps. Resolution of text and images gets better.
    var shareConfig = ShareConfig(Call.ShareOptimizeType.OptimizeText, false)

Note comparing ShareMaxCaptureFPS and Screenshare Optimizations:

The existing API ShareMaxCaptureFPS in AdvancedSetting.kt helps in controlling the maximum fps while screensharing. The new Screenshare Optimizations will explicitly override ShareMaxCaptureFPS setting.

ShareMaxCaptureFPS API:

webex.phone.setAdvancedSetting(AdvancedSetting.ShareMaxCaptureFPS(fps) as AdvancedSetting<*>)

The following are non-exhaustive scenarios of how ShareMaxCaptureFPS and Screenshare optimization control the FPS limit since v3.9.0 onwards.

  • ShareMaxCaptureFPS is set as 10 and then OptimizeText is set in ShareConfig. Now the fps will be set as 5.

  • ShareMaxCaptureFPS is set as 3 and then OptimizeText is set in ShareConfig. Now the fps will be set as 5.

  • ShareMaxCaptureFPS is set as 10 and then OptimizeVideo is set in ShareConfig. Now the max fps will be set as 30.

  • ShareMaxCaptureFPS is set as 7 and shareConfig is not passed. Now the max fps will be set as 7.

  • ShareMaxCaptureFPS is set as 30 and shareConfig is not passed. Now the max fps will be set as 30.

  • ShareMaxCaptureFPS is set as 0 or not set at all and shareConfig is not passed. Now the max fps will be set as 5.

Clone this wiki locally