Azure / azure-sdk-for-android

Android client SDKs for Microsoft Azure
https://azure.github.io/azure-sdk-for-android/
MIT License
100 stars 96 forks source link

[BUG] Camera not working on Android Automotive 12 #1751

Closed carlosmmmarques closed 1 week ago

carlosmmmarques commented 1 week ago

Subject: Bug in Azure Communication Services Calling Library regarding the video calling functionality - Issue on Android Automotive 12

Description:

I have encountered an issue in the Azure communications Service library regarding the camera while working on Android Automotive OS. The problem seems to occur under specific conditions, and I believe it might be a bug.

Steps to Reproduce:

Opening the App using Android Automotive OS environment.

Attempt to use the Azure communications service library to access the front cameras.

  1. Initializing a CommunicationIdentifier
  2. Initializing and setting StartTeamsCallOptions
  3. Starting call
    private void createTeamsIndividualCall() {
        CommunicationIdentifier calleeId = new MicrosoftTeamsUserIdentifier(teamsCallAddress);
        StartTeamsCallOptions options = new StartTeamsCallOptions();
        setCallOptions(options);
        try {
            teamsManager.call = ((TeamsCallAgent) teamsManager.callAgent).startCall(
                    getApplicationContext(),
                    calleeId,
                    options);
            finishCallSetup();
        } catch (Throwable throwable) {
            ...
        }
    }

    private void setCallOptions(CallOptions callOptions) {
        if (teamsManager.getDeviceManager() != null) {
            List<VideoDeviceInfo> cameras = teamsManager.getDeviceManager().getCameras();
            if (!cameras.isEmpty()) {
                teamsManager.camera = chooseCamera(cameras);
                teamsManager.currentVideoStream = new LocalVideoStream(teamsManager.camera, getApplicationContext());

                if (videoOn.get()) {
                    List<OutgoingVideoStream> videoStreams = new ArrayList<>();
                    videoStreams.add(teamsManager.currentVideoStream);
                    OutgoingVideoOptions outgoingVideoOptions = new OutgoingVideoOptions();
                    outgoingVideoOptions.setOutgoingVideoStreams(videoStreams);
                    callOptions.setOutgoingVideoOptions(outgoingVideoOptions);
                }
                ...
        }

        callOptions.setOutgoingAudioOptions(new OutgoingAudioOptions().setMuted(!audioOn.get()));
    }
  1. Initialize VideoStreamRenderer
  2. Create a view with ScalingMode.Fit
  3. Add the VideoStreamRenderer to a container view
        try {
            previewRenderer = new VideoStreamRenderer(stream, this);
            preview = previewRenderer.createView(new CreateViewOptions(ScalingMode.FIT));
        } catch (Exception exception) {
            ...
        }
        runOnUiThread(() -> {
            try {
                if (rendererView != null) {
                    FrameLayout container = findViewById(R.id.video_container_cv);
                    ViewGroup dataRendererViewParent = (ViewGroup) rendererView.getParent();
                    if (dataRendererViewParent != null) {
                        dataRendererViewParent.removeView(rendererView);
                 }
                container.addView(rendererView);
            }
            } catch (Exception exception) {
                ...
            }
        });

Observe that the camera does not function as expected.

Expected Behavior: The camera should work properly on Android Automotive 12, allowing access to test bench's cameras, Front/0 and Front/1.

Actual Behavior: The render view does not display the camera feed neither is any video stream sent to other participants in the call.

Environment Details:

Product Name & Version: Azure Communication Services Calling 2.11.0

OS Version: Android Automotive 12

Camera Details: The test bench used has two camera, Front/0 and Front/1.

Logs retrieved during the test

2024-11-14 11:50:46.080 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  setCallOptions start
2024-11-14 11:50:46.080 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  com.azure.android.communication.calling.DeviceManager@6a8bb71
2024-11-14 11:50:46.081 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  cameras is not empty
2024-11-14 11:50:46.081 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  chooseCamera start
2024-11-14 11:50:46.081 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  chooseCamera foreach start
2024-11-14 11:50:46.081 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  /FRONT/0 /FRONT/0 USB_CAMERA FRONT
2024-11-14 11:50:46.081 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  chooseCamera foreach end
2024-11-14 11:50:46.081 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  chooseCamera foreach start
2024-11-14 11:50:46.082 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  /FRONT/1 /FRONT/1 USB_CAMERA FRONT
2024-11-14 11:50:46.082 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  chooseCamera foreach end
2024-11-14 11:50:46.082 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  chooseCamera end
2024-11-14 11:50:46.083 16602-16602 CAMERA                  com...a.meetingsforteams.guest.aaos  I  setCallOptions endj

Additional Information:

This bug is not present in standard Android devices only in Android Automotive.

The Camera2 API implementation works correctly, suggesting the issue is isolated to the ACS library.

We'll share more information about the system's image when available.

Thank you for your assistance. Please let me know if you need any further details to investigate the problem.

lucianopa-msft commented 1 week ago

Hello @carlosmmmarques We do not officially support Android auto, refer to Android Calling SDK support

carlosmmmarques commented 1 week ago

Hello @lucianopa-msft Any suggestion about who can I address this issue?

lucianopa-msft commented 1 week ago

As it is not supported we currently have no plan for looking into it. You can try to use Raw Incoming Video APIs to try rendering video.