Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen Share(Content Share) showing black screen on receiver's end and the app crashes #539

Closed
equilizer opened this issue Feb 15, 2023 · 2 comments

Comments

@equilizer
Copy link

equilizer commented Feb 15, 2023

i was implementing the amazon chime sdk in react native by following this https://github.com/aws-samples/amazon-chime-react-native-demo#2-add-sdk-binaries-to-the-project. and https://github.com/aws/amazon-chime-sdk-android#screen-and-content-share We were able to implement the sdk in android and was able to integrate video calling by joining the meeting session and following the steps mentioned in the shared link.

Problem: Not able to StartScreenShare from the android phone(ios not yet implemented) but able to see the Shared Screen( shared from Browser) from the attendee and was visible on the videoTile(in the android phone). The app crashes by showing a black screen on the receiver's end(in this case the browser).

val audioVideo: AudioVideoFacade = meetingSession!!.audioVideo
audioVideo.startContentShare(source)
// after reaching this line of code the black screen is seen on the recievers end and the android app crashes

Here is the code that generated the problem:

for permission// in android
val mediaProjectionManager = currentActivity?.getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
currentActivity?.startActivityForResult(
mediaProjectionManager.createScreenCaptureIntent(),
SCREEN_CAPTURE_REQUEST_CODE//1 in this case )

private val mActivityEventListener: ActivityEventListener =
object : BaseActivityEventListener() {
override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, data: Intent?) {

                if (SCREEN_CAPTURE_REQUEST_CODE == requestCode) {
                    if (resultCode != Activity.RESULT_OK) {
                        Toast.makeText(currentActivity!!.applicationContext, "Screen share cannot work without 

permissions",Toast.LENGTH_LONG).show()
} else {
Toast.makeText(currentActivity!!.applicationContext, "ALL OK", Toast.LENGTH_LONG).show()
//able to see the toast on the phone and after accepting the permission
currentActivity?.startService(Intent(currentActivity, ScreenCaptureService::class.java)
data?.let { startScreenShare(resultCode, it, currentActivity!!) }

                    }

                }
            }
        }

init {
reContext?.addActivityEventListener(mActivityEventListener)
}

ScreenCaptureService and ScreenShareManager be downloaded from amazon chime git

val eglCoreFactory: EglCoreFactory = DefaultEglCoreFactory()
private fun startScreenShare(resultCode: Int, data: Intent, context: Context) {
currentActivity!!.startService(Intent(currentActivity, ScreenCaptureService::class.java))
screenshareServiceConnection = object : ServiceConnection {
override fun onServiceConnected(className: ComponentName, service: IBinder) {

            val screenCaptureSource = DefaultScreenCaptureSource(
                    context,
                    logger,
                    DefaultSurfaceTextureCaptureSourceFactory(
                            logger,
                            eglCoreFactory
                    ),
                    resultCode,
                    data
            )

            val screenCaptureSourceObserver = object : CaptureSourceObserver {
                override fun onCaptureStarted() {
                    logger.info("#############", "Screen capture has started")
                    screenShareManager?.let { source ->
                        val audioVideo: AudioVideoFacade = meetingSession!!.audioVideo
                        audioVideo.startContentShare(source)
                    }
                }

                override fun onCaptureStopped() {

// notifyHandler("Screen capture stopped")
}

                override fun onCaptureFailed(error: CaptureSourceError) {

// notifyHandler("Screen capture failed with error $error")
meetingSession?.audioVideo?.stopContentShare()
}
}

                        screenShareManager = ScreenShareManager(screenCaptureSource, context)
                        screenShareManager?.screenCaptureConnectionService = screenshareServiceConnection
                        screenShareManager?.addObserver(screenCaptureSourceObserver)
                        screenShareManager?.start()
                        logger.info("#############", "Screen screenShareManager has started")

// currentActivity?.setScreenShareManager(screenShareManager)
}

        override fun onServiceDisconnected(arg0: ComponentName) {
            isBound = false
        }
    }

    context.startService(
            Intent(
                    context,
                    ScreenCaptureService::class.java
            ).also { intent ->
                screenshareServiceConnection?.let {
                    context?.bindService(
                            intent,
                            it,
                            Context.BIND_AUTO_CREATE
                    )
                }
            })


}

Expected behaviour :
After accepting Screen Share permission the screen should be visible to the receiver's end

Logs
If applicable, add logs from logcat to help explain your problem.

Screenshots
If applicable, add screenshots to help explain your problem.

Test environment Info (please complete the following information):

  • Device: MI

  • OS: Android pie(9)

  • Version amazon-chime-sdk:0.17.5

  • Version amazon-chime-sdk-media: 0.17.6

  • Can you reproduce this in the demo app . Demo app does not have screen share

LOGS SCREENSHOT
Screen Shot 2023-02-15 at 6 27 06 PM
Screen Shot 2023-02-15 at 6 27 21 PM
Screen Shot 2023-02-15 at 6 26 31 PM

here is a video of the same in android app.
https://user-images.githubusercontent.com/14231815/219036255-13c15866-7ba7-4346-9f0a-12bf5e1e53a1.mp4

kindly guide me through if am missing anything.thanks is advance

@equilizer
Copy link
Author

Does the video needs to be processed?

@linsang21
Copy link
Contributor

Hi @equilizer, seems you already files the same issue: aws-samples/amazon-chime-react-native-demo#178, we could use that as the main issue to track.
Will close this as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants