Agora Flutter SDK

repository·main·Indexed 21 days ago

https://github.com/agoraio-extensions/agora-flutter-sdk

A Flutter plugin providing a wrapper for the Agora Video SDK to enable real-time voice and video communications across Android, iOS, macOS, Windows, and Web. It includes support for basic and advanced streaming scenes, Picture-in-Picture (PiP) mode, and the ability to bridge to the native SDK for performance-constrained raw data processing.

Tokens
18.5K
Snippets
42
Records
80
Agent score
74%

What's inside agora_rtc_engine

  1. Explore agora_rtc_engine demo scenes

    main

    The example project contains various demos categorized into Basic and Advanced scenes to demonstrate different agora_rtc_engine capabilities.

    Basic Demos

    • JoinChannelAudio: Audio live streaming.
    • JoinChannelVideo: Video live streaming.
    • StringUid: Using string-based user IDs.

    Advanced Demos

    • Media & Streaming: RTMPStreaming, ChannelMediaRelay, StartDirectCDNStreaming, StartLocalVideoTranscoder.
    • Audio Features: AudioMixing, VoiceChanger, StartRhythmPlayer.
    • Video & Visuals: EnableVirtualBackground, SetBeautyEffect, SetVideoEncoderConfiguration, TakeSnapshot, SendMultiVideoStream, SendMultiCameraStream.
    • Device & Control: DeviceManager, ScreenSharing, MediaPlayer.
    • Data & Metadata: SendMetadata, StreamMessage, SendMultiVideoStream.
    • Security & Advanced Logic: SetEncryption, SetContentInspect, JoinMultipleChannel.
  2. Overview of Picture-in-Picture (PiP) support

    main

    The Picture-in-Picture (PiP) feature enables displaying video content in a small floating window, allowing users to interact with other parts of the application while viewing video.

    Key Capabilities:

    • Display local and remote video streams in the PiP window.
    • Display custom UI content within the PiP window.
    • Automatic activation when the app moves to the background.
    • Customizable window size, aspect ratio, and layout for multiple streams.
    • Custom control styles (iOS only).

    Platform Support:

    • iOS: 15.0 and above
    • Android: 8.0 and above
  3. Interact with Agora RTC Native SDK (Android/iOS only)

    main

    For advanced features like video and audio raw data processing that are performance-constrained in Flutter, you can bridge to the native SDK.

    Starting with agora_rtc_engine >= 6.3.0, you can create an RtcEngine within Flutter by utilizing the native handle from the RtcEngine (Android) or AgoraRtcEngineKit (iOS). This allows your application to directly utilize advanced native capabilities.

  4. Configure iOS & macOS privacy permissions

    main

    To use the camera and microphone on iOS and macOS, you must add usage descriptions to your Info.plist file. Provide a meaningful string in the Value column for each key to explain to the user why the permission is needed.

    - `Privacy - Microphone Usage Description`
    - `Privacy - Camera Usage Description`
  5. Update golden screenshots for rendering tests

    main

    If you need to update the reference screenshots (golden files) used by the rendering tests, use the UPDATE_GOLDEN flag. The method for passing this flag varies by platform.

    Android/iOS and Web

    Set the UPDATE_GOLDEN environment variable to "true" before running the flutter drive command.

    macOS/Windows

    Pass UPDATE_GOLDEN=true as a --dart-define argument to the flutter test command.

    # Android/iOS & Web
    export UPDATE_GOLDEN="true"
    flutter drive --driver=test_driver/integration_test.dart \
        --target=integration_test/agora_video_view_render_test.dart \
        --dart-define=TEST_APP_ID="<APP_ID>"
    
    # macOS/Windows
    flutter test integration_test/agora_video_view_render_test.dart \
        --dart-define=TEST_APP_ID="<APP_ID>" \
        --dart-define=UPDATE_GOLDEN=true
  6. Setup Web support (Alpha)

    main

    The web implementation is in alpha and is built on top of iris_web. To use it, you must include the iris_web artifact as a <script> tag in your web/index.html file.

    Note: Only a subset of Native SDK APIs are available on web. If an API returns an AgoraRtcException with error code -4, it is not currently supported on the web platform.

    <!-- <your-project>/web/index.html -->
    <!DOCTYPE html>
    <html
    ...
    <body
      ...
      <script src="https://download.agora.io/sdk/release/iris-web-rtc_n450_w4220_0.8.6.js"></script>
    </body
    >
    </html>
  7. Customize iOS Launch Screen Assets

    main

    To change the image displayed during the app's launch on iOS, you can replace the existing image files in the example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory with your own assets.

    Alternatively, you can manage these assets using Xcode:

    1. Open the iOS project in Xcode by running open ios/Runner.xcworkspace from your terminal.
    2. In the Xcode Project Navigator, navigate to Runner/Assets.xcassets.
    3. Drag and drop your desired images into the asset catalog to replace the launch images.
    open ios/Runner.xcworkspace
  8. Configure iOS for Picture-in-Picture (PiP)

    main

    To enable PiP on iOS, you must configure background modes and, optionally, camera entitlements.

    1. Enable Background Modes

    In Xcode:

    1. Select your app's target and go to the Signing & Capabilities tab.
    2. Click the + Capability button.
    3. Add Background Modes.
    4. Select Audio, AirPlay, and Picture in Picture.

    2. Camera Access in Multitasking (Optional)

    If your PiP window needs to show the local video stream (camera), you must handle multitasking camera access:

    • iOS < 16: You must request the com.apple.developer.avfoundation.multitasking-camera-access entitlement from Apple.
    • iOS ≥ 16: Set multitaskingCameraAccessEnabled to true in the capture session (feature coming soon).