override fun onCreate()

in app/src/main/java/com/amazonaws/services/chime/sdkdemo/activity/MeetingActivity.kt [63:155]


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_meeting)
        meetingId = intent.extras?.getString(HomeActivity.MEETING_ID_KEY) as String
        name = intent.extras?.getString(HomeActivity.NAME_KEY) as String
        val audioMode = intent.extras?.getInt(HomeActivity.AUDIO_MODE_KEY)?.let { intValue ->
            AudioMode.from(intValue, defaultAudioMode = AudioMode.Stereo48K)
        } ?: AudioMode.Stereo48K
        val audioDeviceCapabilities = intent.extras?.get(HomeActivity.AUDIO_DEVICE_CAPABILITIES_KEY) as? AudioDeviceCapabilities ?: AudioDeviceCapabilities.InputAndOutput
        val enableAudioRedundancy = intent.extras?.getBoolean(HomeActivity.ENABLE_AUDIO_REDUNDANCY_KEY) as Boolean
        val reconnectTimeoutMs = intent.extras?.getInt(HomeActivity.RECONNECT_TIMEOUT_MS) as Int
        audioVideoConfig = AudioVideoConfiguration(audioMode = audioMode, audioDeviceCapabilities = audioDeviceCapabilities, enableAudioRedundancy = enableAudioRedundancy, reconnectTimeoutMs = reconnectTimeoutMs)
        meetingEndpointUrl = intent.extras?.getString(HomeActivity.MEETING_ENDPOINT_KEY) as String

        if (savedInstanceState == null) {
            val meetingResponseJson =
                intent.extras?.getString(HomeActivity.MEETING_RESPONSE_KEY) as String
            val sessionConfig =
                createSessionConfigurationAndExtractPrimaryMeetingInformation(meetingResponseJson)
            val meetingSession = sessionConfig?.let {
                logger.info(TAG, "Creating meeting session for meeting Id: $meetingId")

                DefaultMeetingSession(
                    it,
                    logger,
                    applicationContext,
                    // Note if the following isn't provided app will (as expected) crash if we use custom video source
                    // since an EglCoreFactory will be internal created and will be using a different shared EGLContext.
                    // However the internal default capture would work fine, since it is initialized using
                    // that internally created default EglCoreFactory, and can be smoke tested by removing this
                    // argument and toggling use of custom video source before starting video
                    meetingSessionModel.eglCoreFactory
                )
            }

            if (meetingSession == null) {
                Toast.makeText(
                    applicationContext,
                    getString(R.string.user_notification_meeting_start_error),
                    Toast.LENGTH_LONG
                ).show()
                finish()
            } else {
                meetingSessionModel.meetingSession = meetingSession
                meetingSessionModel.primaryExternalMeetingId = primaryExternalMeetingId
            }

            val surfaceTextureCaptureSourceFactory = DefaultSurfaceTextureCaptureSourceFactory(
                logger,
                meetingSessionModel.eglCoreFactory
            )
            meetingSessionModel.cameraCaptureSource = DefaultCameraCaptureSource(
                applicationContext,
                logger,
                surfaceTextureCaptureSourceFactory
            ).apply {
                eventAnalyticsController = meetingSession?.eventAnalyticsController
            }
            // Add a new parameter for DefaultCameraCaptureSource (videoMaxResolution)
            var resolution: VideoResolution = VideoResolution.VideoResolutionHD
            meetingSession?.let {
                resolution = it.configuration.features.videoMaxResolution
            }
            meetingSessionModel.cameraCaptureSource.setMaxResolution(resolution)

            meetingSessionModel.cpuVideoProcessor =
                CpuVideoProcessor(logger, meetingSessionModel.eglCoreFactory)
            meetingSessionModel.gpuVideoProcessor =
                GpuVideoProcessor(logger, meetingSessionModel.eglCoreFactory)
            meetingSessionModel.backgroundBlurVideoFrameProcessor =
                BackgroundBlurVideoFrameProcessor(
                    logger,
                    meetingSessionModel.eglCoreFactory,
                    applicationContext,
                    BackgroundBlurConfiguration()
                )
            meetingSessionModel.backgroundReplacementVideoFrameProcessor =
                BackgroundReplacementVideoFrameProcessor(
                    logger,
                    meetingSessionModel.eglCoreFactory,
                    applicationContext,
                    null
                )

            val deviceManagementFragment =
                DeviceManagementFragment.newInstance(meetingId, name, audioVideoConfig)
            deviceManagementFragment.setVideoMaxResolution(meetingSessionModel.meetingSession.configuration.features.videoMaxResolution)
            supportFragmentManager
                .beginTransaction()
                .add(R.id.root_layout, deviceManagementFragment, "deviceManagement")
                .commit()
        }
    }