Agora RTC Native SDK API Examples

repository·main·Indexed 43 days ago

https://github.com/agoraio/api-examples

A collection of sample projects demonstrating the implementation of the Agora RTC Native SDK across Android, iOS, macOS, and Windows platforms. Includes examples for Java, Kotlin (including Compose), and Objective-C, covering audio and video implementations, beauty API integration, stream encryption, and the SimpleFilter extension.

Tokens
54K
Snippets
96
Records
174
Agent score
55%

What's inside Agora

  1. Overview of APIExample-SwiftUI Case Index

    main

    The APIExample-SwiftUI project contains a wide range of sample implementations for the Agora RTC Native SDK, categorized into Basic and Advanced examples.

    Basic Examples

    • JoinChannelVideo: Basic video call using joinChannel(), setupLocalVideo(), and setupRemoteVideo().
    • JoinChannelVideo(Token): Video call using token authentication via joinChannel(byToken:).
    • JoinChannelVideo(Recorder): Local and remote stream recording using createMediaRecorder().
    • JoinChannelAudio: Basic audio call with profile and volume controls using setAudioProfile(), setAudioScenario(), and adjustRecordingSignalVolume().

    Advanced Examples (Selected)

    • LiveStreaming: Interactive streaming with setClientRole() and setVideoScenario().
    • RTMPStream: Pushing streams to a CDN using startRtmpStream().
    • VoiceChanger: Audio effects using setVoiceBeautifierPreset() and setAudioEffectPreset().
    • CustomPCMAudioSource: Pushing custom PCM audio via pushExternalAudioFrameRawData().
    • ScreenShare: Using ReplayKit via startScreenCapture().
    • VideoProcess: Beauty effects and virtual backgrounds via setBeautyEffectOptions() and enableVirtualBackground().
    • Simulcast: Publishing multiple quality layers with setSimulcastConfig().
  2. Overview of Agora RTC Native SDK Sample Projects

    main
    This repository provides sample projects for the Agora RTC Native SDK across multiple platforms. These samples are designed to demonstrate how to use the SDK for both video and audio-only implementations. Each platform-specific directory contains a complete project tailored to a specific language and SDK type.
  3. Overview of Android API Example Projects

    main

    The agoraio/api-examples repository contains three independent Android projects designed to demonstrate different Agora RTC Native SDK capabilities. Each project is a standalone Gradle project with its own APK output.

    Depending on your UI preference or use case, you can choose from:

    1. APIExample: A full-featured demo using XML layouts and mixed Java/Kotlin.
    2. APIExample-Audio: An audio-only optimized demo using a specialized voice SDK.
    3. APIExample-Compose: A modern demo built entirely with Jetpack Compose and Kotlin.
  4. Overview of iOS Example Projects

    main
    The iOS repository contains four independent example projects organized within a single Xcode workspace. Each project manages its own dependencies using CocoaPods. These examples demonstrate different ways to integrate the Agora RTC Native SDK depending on your preferred language and UI framework.
  5. Overview of APIExample-Audio capabilities

    main

    The APIExample-Audio project provides sample implementations for the Agora RTC Native SDK focused exclusively on audio functionality. It covers a range of use cases from basic audio calls to advanced audio processing.

    Key capabilities include:

    • Basic Audio: Joining channels with profiles, scenarios, and in-ear monitoring.
    • Voice Processing: Voice beautifiers, effects, conversion presets, and equalization.
    • Custom Audio Handling: Pushing custom audio via external sources (PCM or raw), and pulling audio frames for custom rendering.
    • Audio Manipulation: Mixing local audio files with microphone input, and playing metronome-style rhythm audio.
    • Testing & Spatial Audio: Pre-call echo tests, last-mile network probes, and 3D spatial audio integration.
  6. Overview of APIExample-OC Case Index

    main

    The APIExample-OC project contains various sample implementations for the Agora RTC Native SDK in Objective-C. The cases are categorized into Basic and Advanced functionality. Use this index to find specific implementation patterns for features like video calling, live streaming, RTMP streaming, custom audio/video sources, and more.

    | Case | Path | Key APIs | Description |
    |------|------|----------|-------------|
    | JoinChannelVideo | `Examples/Basic/JoinChannelVideo/JoinChannelVideo.m` | `joinChannelByToken:`, `setupLocalVideo:`, `setupRemoteVideo:` | Basic video call — join channel and render local/remote video |
    | JoinChannelVideo(Token) | `Examples/Basic/JoinChannelVideo(Token)/JoinChannelVideoToken.m` | `joinChannelByToken:`, `setupLocalVideo:`, `setupRemoteVideo:` | Video call with token authentication |
    | JoinChannelVideo(Recorder) | `Examples/Basic/JoinChannelVideo(Recorder)/JoinChannelVideoRecorder.m` | `createMediaRecorder:`, `joinChannelByToken:`, `setupLocalVideo:` | Local and remote stream recording |
    | JoinChannelAudio | `Examples/Basic/JoinChannelAudio/JoinChannelAudio.m` | `joinChannelByToken:`, `setAudioProfile:`, `enableAudioVolumeIndication:` | Basic audio call |
    | LiveStreaming | `Examples/Advanced/LiveStreaming/LiveStreaming.m` | `setClientRole:`, `setVideoScenario:`, `preloadChannelByToken:`, `enableInstantMediaRendering` | Interactive live streaming with role switching |
    | RTMPStreaming | `Examples/Advanced/RTMPStreaming/RTMPStreaming.m` | `startRtmpStreamWithoutTranscoding:`, `startRtmpStreamWithTranscoding:`, `updateRtmpTranscoding:`, `stopRtmpStream:` | Push stream to CDN with optional transcoding |
    | VideoMetadata | `Examples/Advanced/VideoMetadata/VideoMetadata.m` | `setMediaMetadataDataSource:withType:`, `setMediaMetadataDelegate:withType:` | Send and receive metadata attached to video stream |
    | VoiceChanger | `Examples/Advanced/VoiceChanger/VoiceChanger.m` | `setVoiceBeautifierPreset:`, `setAudioEffectPreset:`, `setVoiceConversionPreset:` | Voice beautifier, effects, and conversion presets |
    | CustomPcmAudioSource | `Examples/Advanced/CustomPcmAudioSource/CustomPcmAudioSource.m` | `createCustomAudioTrack:config:`, `enableCustomAudioLocalPlayback:enabled:`, `pushExternalAudioFrameRawData:` | Push custom PCM audio frames as external audio source |
    | CustomAudioRender | `Examples/Advanced/CustomAudioRender/CustomAudioRender.m` | `enableExternalAudioSink:sampleRate:channels:`, `pullPlaybackAudioFrameRawData:lengthInByte:` | Pull audio frames for custom rendering |
    | CustomVideoSourcePush | `Examples/Advanced/CustomVideoSourcePush/CustomVideoSourcePush.m` | `setExternalVideoSource:useTexture:sourceType:`, `pushExternalVideoFrame:videoTrackId:` | Push external video frames as custom video source |
    | CustomVideoRender | `Examples/Advanced/CustomVideoRender/CustomVideoRender.m` | `setVideoFrameDelegate:` | Custom rendering of remote video frames via delegate |
    | RawAudioData | `Examples/Advanced/RawAudioData/RawAudioData.m` | `setAudioFrameDelegate:` | Capture raw audio PCM data via delegate |
    | RawVideoData | `Examples/Advanced/RawVideoData/RawVideoData.m` | `setVideoFrameDelegate:` | Capture raw video frames via delegate |
    | SimpleFilter | `Examples/Advanced/SimpleFilter/SimpleFilter.m` | `enableExtensionWithVendor:extension:enabled:`, `setExtensionPropertyWithVendor:extension:key:value:` | Apply audio/video filter via Agora Extension API |
    | JoinMultiChannel | `Examples/Advanced/JoinMultiChannel/JoinMultiChannel.m` | `joinChannelExByToken:connection:delegate:mediaOptions:` | Join multiple channels simultaneously via ex connection |
    | StreamEncryption | `Examples/Advanced/StreamEncryption/StreamEncryption.m` | `enableEncryption:encryptionConfig:` | Built-in and custom stream encryption |
    | AudioMixing | `Examples/Advanced/AudioMixing/AudioMixing.m` | `startAudioMixing:loopback:cycle:`, `adjustAudioMixingVolume:`, `setEffectsVolume:` | Mix local audio file with microphone input |
    | MediaPlayer | `Examples/Advanced/MediaPlayer/MediaPlayer.m` | `createMediaPlayerWithDelegate:`, `updateChannelExWithMediaOptions:connection:` | Play media files and publish to channel via media player |
    | ScreenShare | `Examples/Advanced/ScreenShare/ScreenShare.m` | `startScreenCapture:`, `updateScreenCapture:`, `stopScreenCapture` | Screen capture and sharing via ReplayKit extension |
    | LocalCompositeGraph | `Examples/Advanced/LocalCompositeGraph/LocalCompositeGraph.m` | `startLocalVideoTranscoder:`, `startCameraCapture:config:`, `enableVirtualBackground:backData:segData:` | Composite multiple video sources locally before publishing |
    | VideoProcess | `Examples/Advanced/VideoProcess/VideoProcess.m` | `setBeautyEffectOptions:options:`, `enableVirtualBackground:backData:segData:`, `enableExtensionWithVendor:` | Built-in beauty, virtual background, and video enhancement |
    | RhythmPlayer | `Examples/Advanced/RhythmPlayer/RhythmPlayer.m` | `startRhythmPlayer:sound2:config:`, `stopRhythmPlayer` | Play metronome-style rhythm audio |
    | CreateDataStream | `Examples/Advanced/CreateDataStream/CreateDataStream.m` | `createDataStream:config:`, `sendStreamMessage:data:` | Create and send data stream messages between users |
    | MediaChannelRelay | `Examples/Advanced/MediaChannelRelay/MediaChannelRelay.m` | `startOrUpdateChannelMediaRelay:`, `stopChannelMediaRelay`, `pauseAllChannelMediaRelay`, `resumeAllChannelMediaRelay` | Relay media stream to multiple destination channels |
    | SpatialAudio | `Examples/Advanced/SpatialAudio/SpatialAudio.m` | `createMediaPlayerWithDelegate:`, `updateChannelWithMediaOptions:` | 3D spatial audio with media player integration |
    | ContentInspect | `Examples/Advanced/ContentInspect/ContentInspect.m` | `enableContentInspect:config:`, `switchCamera` | Moderate content in video stream |
    | MutliCamera | `Examples/Advanced/MutliCamera/MutliCamera.m` | `enableMultiCamera:config:`, `startCameraCapture:config:`, `stopCameraCapture:` | Capture from front and back cameras simultaneously (iOS 13+) |
    | PictureInPicture | `Examples/Advanced/PictureInPicture/PictureInPicture.m` | `setVideoFrameDelegate:`, `AVPictureInPictureController` | Picture-in-Picture using AVKit (iOS 15+) |
    | Simulcast | `Examples/Advanced/Simulcast/Simulcast.m` | `setSimulcastConfig:`, `setRemoteVideoStream:type:` | Publish multiple video quality layers simultaneously |
    | Multipath | `Examples/Advanced/Multipath/Multipath.m` | `updateChannelWithMediaOptions:` | Multi-path network transmission configuration |
  7. Index of iOS APIExample use cases

    main

    The APIExample project contains a wide range of implementation examples for the Agora RTC Native SDK on iOS. Use the following index to find specific implementation patterns based on your requirements:

    Basic Functionality

    • JoinChannelVideo: Basic video call using joinChannel(), setupLocalVideo(), and setupRemoteVideo().
    • JoinChannelVideo(Token): Video call with token authentication using joinChannel(byToken:).
    • JoinChannelVideo(Recorder): Local and remote stream recording using createMediaRecorder().
    • JoinChannelAudio: Basic audio call with volume and in-ear monitoring using setAudioProfile() and enableAudioVolumeIndication().

    Advanced Media & Streaming

    • LiveStreaming: Interactive live streaming with role switching (setClientRole()) and camera features (enableCameraCenterStage()).
    • RTMPStreaming: Push stream to CDN with optional transcoding using startRtmpStream(withTranscoding:).
    • VideoMetadata: Send/receive metadata attached to video streams via setMediaMetadataDataSource().
    • VoiceChanger: Audio beautification and AI noise suppression using setVoiceBeautifierPreset() and setAINSMode().
    • ScreenShare: Screen capture via ReplayKit using startScreenCapture().
    • Simulcast: Publish multiple video quality layers simultaneously using setSimulcastConfig().

    Custom Audio & Video Sources

    • CustomPcmAudioSource: Push custom PCM audio frames using pushExternalAudioFrameRawData().
    • CustomVideoSourcePush: Push external video frames using setExternalVideoSource() and pushExternalVideoFrame().
    • CustomVideoSourcePushMulti: Multi-track custom video source with encoded frame push using pushExternalEncodedVideoFrame().
    • ARKit: Push ARKit face tracking frames as a custom video source.

    Data & Control

    • CreateDataStream: Send data stream messages between users using createDataStream() and sendStreamMessage().
    • MediaChannelRelay: Relay media streams to multiple destination channels using startOrUpdateChannelMediaRelay().
    • StreamEncryption: Enable built-in or custom stream encryption via enableEncryption().
    • ContentInspect: Moderate content in video streams using enableContentInspect().
  8. Locate Agora RTC Native SDK sample projects by platform

    main

    This repository contains sample projects for the Agora RTC Native SDK across multiple platforms. Use the following directory mapping to find the specific implementation and SDK version you need:

    Android

    iOS

    macOS

    Windows

  9. Understand the APIExample Android project structure

    main

    The APIExample project is organized to demonstrate various Agora RTC capabilities through a modular, annotation-driven architecture.

    Key components include:

    • app/src/main/java/io/agora/api/example/examples/: The core directory where all functional use cases reside, categorized into basic and advanced groups.
    • app/src/main/java/io/agora/api/example/annotation/: Contains the @Example annotation used to register new use cases.
    • app/src/main/java/io/agora/api/example/common/: Provides shared infrastructure, including BaseFragment (the required base class for all example fragments), UI widgets (like VideoReportLayout), and models.
    • app/src/main/java/io/agora/api/example/utils/: Contains helper utilities such as ClassUtils (for auto-discovering examples), TokenUtils (for RTC token fetching), and PermissionUtils.
    • gradle.properties: Contains configuration flags for the SDK version and optional modules like agora-simple-filter or agora-stream-encrypt.
    • app/src/main/assets/: Stores sample audio/video files and beauty resources used by the examples.
  10. Understand the Directory Layout of APIExample-Audio

    main

    The APIExample-Audio project is organized to separate core application logic, common utilities, and specific Agora RTC audio use cases.

    • app/src/main/java/io/agora/api/example/examples/: Contains all functional audio test cases, categorized into basic/, advanced/, and audio/ sub-packages.
    • app/src/main/java/io/agora/api/example/common/: Contains shared logic including BaseFragment (the required base class for all cases), model/ for shared data, and widget/ for audio-specific UI components like WaveformView.
    • app/src/main/java/io/agora/api/example/utils/: Provides helper classes such as TokenUtils for token generation and ClassUtils for automatic case discovery.
    • app/src/main/res/navigation/nav_graph.xml: The central Jetpack Navigation graph defining all case destinations and transitions.
  11. Explore Agora RTC Android API Examples

    main

    The APIExample project provides a comprehensive collection of sample implementations for the Agora RTC Native SDK on Android. These examples are categorized into BASIC and ADVANCED use cases, covering everything from simple one-to-one video calls to complex scenarios like custom audio/video sources, media metadata, and video enhancement.

    Key Capabilities Covered:

    • Basic Streaming: One-to-one audio/video calling with token verification.
    • Advanced Media Control: Custom audio/video sources (YUV, external frames), raw data processing (audio/video observers), and media metadata.
    • Enhanced Audio/Video: Voice beautifiers, AI noise suppression, virtual backgrounds, and video filters.
    • Specialized Features: Screen sharing, Picture-in-Picture, RTMP streaming to CDN, and spatial audio.
    • Network & Quality: Multi-path transmission, simulcast, and pre-call network/echo testing.
  12. Understand the APIExample directory layout

    main

    The APIExample project is organized into several functional areas to separate core logic, shared utilities, and specific SDK feature demonstrations:

    • APIExample/ (Root): Contains the main project files, including Podfile for CocoaPods dependencies (like AgoraRtcEngine_iOS), and optional third-party beauty SDK resources (ByteEffectLib, FULib, SenseLib).
    • APIExample/Common/: Contains shared infrastructure used by all examples, such as KeyCenter.swift (App ID/Certificate), GlobalSettings.swift (runtime config), VideoView.swift (reusable rendering), and NetworkManager/ (token requests).
    • APIExample/Examples/: The core of the project, divided into:
      • Basic/: Simple use cases like JoinChannelVideo or JoinChannelAudio.
      • Advanced/: Complex features like LiveStreaming, RTMPStreaming, CustomVideoSourcePush, and ScreenShare.
    • libs/: Local SDK frameworks used if CocoaPods is not employed.