Issue with Screen Sharing via Raw Video Stream in Azure Communication Services for Android

Dmytro Gulko 0 Reputation points
2025-06-27T20:20:39.1833333+00:00

Hello Azure Team,

We’re building a Flutter app with video call functionality using Azure Communication Services. As ACS doesn’t have native Flutter support, we implemented a custom Flutter plugin with platform-specific code — I’m the Android developer responsible for that part.

We are currently trying to implement screen sharing on Android by following the official documentation for Raw Media Access. I created a custom screen sharing service that sets up a ScreenShareOutgoingVideoStream and tries to send raw frames from a MediaProjection source.

However, when attempting to push this stream to the call, the SDK throws the following error:

Failed to send frame: java.lang.IllegalStateException: Unknown error.
java9.util.concurrent.CompletionException: java.lang.IllegalStateException: Unknown error.
	at java9.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
	...
Caused by: java.lang.IllegalStateException: Unknown error.
	at com.azure.android.communication.calling.NativeLibraryHelpers.checkStatus(NativeLibraryHelpers.java:1282)
	...

And further:

2025-06-26 14:20:01.909 22983-23570 ScreenShareService E  Failed to start screen sharing video on call: com.azure.android.communication.calling.CallingCommunicationException

We’re unsure what the root cause is — we suspect we may be passing incorrectly formatted frames or missing some init step.

Here are the important resources for reviewing:

🔗 GitHub Plugin Repo: nerdzlab/acs_plugin 📄 Screen Sharing Service: ScreenShareService.kt (Line 204–260)

The error occurs after 260 line, the setup of stream is from 204 till 232 line.
Any guidance or clarification would be hugely appreciated! Thanks in advance

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
1,260 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Shree Hima Bindu Maganti 5,240 Reputation points Microsoft External Staff Moderator
    2025-07-02T12:50:54.1333333+00:00

    Hi @Dmytro Gulko
    It seems you are encountering an IllegalStateException while trying to implement screen sharing using the Azure Communication Services SDK for Android.

    Ensure that the frames you are sending are in the correct format as specified by the SDK. You should be using VideoStreamPixelFormat.RGBA when generating your RawVideoFrame.

    Before sending frames, confirm that the VideoStream state is VideoStreamState.STARTED. If the stream is not started, frames will not be sent successfully.

    Review the initialization steps for your ScreenShareOutgoingVideoStream. Make sure you are correctly setting up the RawOutgoingVideoStreamOptions and that the VideoFormats array is properly configured.

    Implement additional error handling to capture more specific exceptions that may provide insight into what is going wrong.

    Use logging to trace the flow of your application and identify where the failure occurs. This can help you pinpoint whether the issue is with the frame generation, stream setup, or during the transmission.

    Access raw audio and video (platform-android)
    Let me know if you have any further assistances needed.


  2. Dmytro Gulko 0 Reputation points
    2025-07-03T21:04:08.41+00:00

    Hi team,

    Thanks for your response and the suggestions!

    I’d like to clarify the following points based on your recommendations:

    1. Pixel Format: We're using VideoStreamPixelFormat.RGBA as required when generating the RawVideoFrame. You can verify this in our setup code.
    2. Video Stream State Check: We are explicitly checking that the video stream state is VideoStreamState.STARTED before sending any raw frames. You can confirm this logic at the following line in our GitHub repo: ScreenShareService.kt#L394
    3. Initialization Steps: The ScreenShareOutgoingVideoStream is created and configured properly with RawOutgoingVideoStreamOptions and a VideoFormat array using RGBA. Relevant setup is located between lines ScreenShareService.kt#L204-232
    4. Logging: We've added detailed logs throughout our stream lifecycle and error handling sections to trace execution. These logs are confirming that the state is correct but the error still occurs.
    5. Issue: Despite following the documentation and above steps, we are still encountering the following error when trying to send the raw video frame:
       java.lang.IllegalStateException: Unknown error.
    at com.azure.android.communication.calling.NativeLibraryHelpers.checkStatus(NativeLibraryHelpers.java:1282)
    ...
    

    🔗 Full repository: acs_plugin GitHub

    We would greatly appreciate any further assistance or insights you might provide to help us resolve this.

    Thanks again! — Dmytro Gulko


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.