Skip to main content

Architecture

The AIBuds SDK iOS is built as a collection of modular components, each with a clearly defined responsibility. Understanding how these modules fit together will help you install only what you need and extend the SDK with your own plugins.

Architecture at a Glance

The SDK is organized in layers — top layers depend on bottom layers, and the device side (left) mirrors the AI side (right) at most levels.

System map

AIBuds SDK iOS Architecture

Your App

Your iOS app which will connect to the AIBuds device

AIBudsAllInOneOptional

Optional Convenience Wrapper

Feature Modules

Audio · VoiceAssistant · LiveStream · CrashReporter · AIBudsAIDashboard

AIBudsSDK

Device core

AIBudsAISDK

AI core

ABMateSDK(BLE)

Core Bluetooth Communication Protocol Layer

StarBurst / MagicHelper

Third-party AI Service Convenience Wrapper

  • StarBurst AI (ByteDance)
  • MltCloud AI (Meilc)
AIBudsFoundation

Device data models

AIBudsAIFoundation

AI data models

AIBudsLog

Cross-cutting logging module

AIBudsXLFacilityOptional

Optional log plugin

Understand the architecture of the AIBuds SDK iOS.

Layers from top to bottom: your app → convenience wrapper → feature modules → core SDK (device side + AI side) → protocol plugins → foundation data models → cross-cutting logging.

Device Model

Every device the SDK touches is represented by one protocol — DeviceConvertible (AIBudsDeviceConvertible in Objective-C). It is the single handle through which your app reads device identity and state, and through which it performs lifecycle operations (connect, disconnect, unpair, save). Operations are called on the device instance itself, not through a manager singleton. DeviceConvertible conforms to NSSecureCoding, so it can be archived and restored across app launches.

A separate protocol, FoundDeviceConvertible (AIBudsFoundDeviceConvertible), describes a device that has just been discovered by scanning — it wraps the Core Bluetooth trio (central + peripheral + advertisementData + RSSI) but is not yet storable. Convert it with AIBudsSDK.makeStorableDeviceFromDiscovered(_:) to get a DeviceConvertible you can persist.

Device lifecycle

Device lifecycle

From Bluetooth discovery to a command-ready device.

ScanBluetooth discovery
Nearby

Discovered

The scanner has found an advertising device.

AIBudsSDK.makeStorableDeviceFromDiscovered(_:)Create a durable model
Local

Storable

The device is normalized for local storage.

StoredDevicesMgr.addDevice
Saved

Persisted

The device remains available across launches.

device.connect(ConnectParams)
In progress

Connecting

Authentication and negotiation are underway.

deviceDidReadyDelegate callback
Online

Ready

The device can now receive commands.

AvailableReady for commands

The device flows through five states: discovered by scanning → converted to a storable device → persisted to storage → connecting → connected and ready.

StoredDevicesMgr (AIBudsStoredDevicesMgr) owns the persisted device list — addDevice, removeDevice, allDevices, findDevice(byMacAddr:), findDevice(byPeripheral:). Call loadDevicesInBackground on launch to restore previously saved devices (including auto-reconnect candidates).

Capability Protocols

Not every device supports every feature, so capabilities are modeled as individual protocols rather than one monolithic device interface. They all conform to a common marker, DeviceAPI (AIBudsDeviceAPI):

ProtocolCapability
DeviceInfoAPIBattery, capabilities, hardware configuration, language, storage, media count, sync/set time
DeviceCommonAPIFactory reset, power off
DeviceFindAPIFind device / stop find
DeviceWorkModeAPI / DeviceWorkStateAPIWork mode / work state
DeviceVolumeControlAPIVolume get / set
DeviceEqualizerAPIEqualizer settings
DeviceANCAPIANC mode, gain, transparency, fade
DeviceWearDetectionAPIWear detection capability and status
DeviceTWSAPITWS connection status
DeviceMusicControlAPIPlay / pause / next / previous / volume
DeviceAudioRecordingAPINormal & AI audio recording, max duration
DeviceCameraAPIPhoto / video capture, camera firmware
DeviceRemoteShutterAPIRemote shutter sync
DeviceFileImportAPIMedia file fetch / import / delete
DeviceOtaAPI / DeviceCameraOtaAPIFirmware update
DeviceAppsAPIDevice applications start / stop
DeviceServiceAuthAPIService auth retry & result reporting
DevicePhysicalOperationsAPIPhysical operation key mapping
LiveStreamingAPIRTSP / JPEG live streaming
OnDeviceVoiceAssistantAPIOn-device voice assistant

To call a capability, cast the device to the corresponding protocol and check for conformance — a device that lacks the hardware simply fails the cast:

Swift
if let info = device as? DeviceInfoAPI {
    info.setDeviceTime(Date()) { success, statusCode, error in
        // ...
    }
}

if let anc = device as? DeviceANCAPI {
    anc.setAncMode(.ancOn) { _ in }
}

Delegates

The SDK has two layers of delegation — choose the one that matches the scope of the events you need.

  • DeviceDelegate (AIBudsDeviceDelegate) — per-device. Assign it via device.delegate = self to receive that specific device's connection lifecycle events (didStartConnectingDevice, didConnectedToDevice, didFailToConnectDevice, device:didDisconnectWithError:, deviceDidReady) and its state-change events (battery, work mode, ANC, EQ, wear status, TWS, volumes, storage, media count, and many more). All methods are @objc optional — implement only the callbacks you need.
  • SDKDelegate (AIBudsSDKDelegate) — global. Passed to AIBudsSDK.initialize(...delegate:), it mirrors the connection events across all devices and also reports scanning status (onScanningStatusChanged:).

A common setup is to use SDKDelegate for app-level concerns (scanning, global connection UI) and DeviceDelegate for the screen that owns a specific device.

Core Singletons

SingletonScopeKey entry points
AIBudsSDKDevice sideinitialize(bleSDKs:configuration:delegate:), startScanning, stopScanning, isScanning(), makeStorableDeviceFromDiscovered(_:), AI/voice plugin setters
AIBudsAISDKAI sideinitialize(aiSDKs:), setAIServiceVendor(_:), startAIChat, startAIAudioRecording, startSimultaneousInterpretation, translateText, summary, recognizeVoice, synthesizeText

Device operations (connect, disconnect, send commands) are not on these singletons — they are called on the DeviceConvertible instance directly.

AI Service Provider

AI capabilities are supplied by a pluggable service provider. The selected provider is represented by the AIServiceVendor (AIBudsAIServiceVendor) enum:

CaseService Provider
.noneNo provider selected
.starBurstStarBurst AI (ByteDance)
.mltcloudMltCloud AI (Meilc)

The case spelling follows the public Swift API exactly: .starBurst uses an uppercase B, while .mltcloud is entirely lowercase.

Switch providers at runtime with AIBudsAISDK.setAIServiceVendor(_:). This must be called before any AI service is used.

Connection Parameters

ConnectParams (AIBudsConnectParams) packages everything device.connect(_:) needs for a connection — most notably the AI auth parameters that let the SDK authenticate with your AI providers during the connection handshake:

  • userId — identifies the end user on the AI provider side.
  • aiAuthParams (AIAuthParams / AIBudsAIAuthParams) — holds per-provider credentials:
    • starburst (StarBurstAIAuthParams): productId, optional ppeEnv
    • mltcloud (MltCloudAIAuthParams): channelId
Swift
let params = ConnectParams()
let auth = AIAuthParams()

let starBurst = StarBurstAIAuthParams()
starBurst.productId = configs["STARBURST_PRODUCTID"]
auth.starburst = starBurst

let mltCloud = MltCloudAIAuthParams()
mltCloud.channelId = configs["MLTCLOUD_CHANNELID"]
auth.mltcloud = mltCloud

params.aiAuthParams = auth
params.userId = "199"

device.connect(params)

Module Reference

Foundation Layer

AIBudsLog

The logging core module that runs through the entire AIBuds SDK. Every other module records logs through it. LogService is the protocol all log implementations conform to, so you can plug in your own LogService if the defaults don't suit you.

The default log service already supports four output destinations — console, oslogger, file, and xlfacility (the latter requires an additional plugin).

AIBudsXLFacility

An optional log plugin that routes log output through XLFacility. Compared with the plain file destination, XLFacility makes it much easier to export, query, and purge expired logs — this is the recommended log destination for production.

AIBudsFoundation

Data models, type definitions, and auxiliary data structures related to device communication. Think of it as the shared vocabulary that the device SDK and your app both rely on.

AIBudsAIFoundation

Similar to AIBudsFoundation, but scoped to AI-related business — it defines the base data models and type definitions used across all AI providers.

Core SDK Layer

AIBudsSDK

The device communication core SDK. Most device-related functionality — scanning, connecting, sending commands, receiving events — is invoked through this module.

ABMateSDK

The BLE communication protocol plugin currently used by AIBudsSDK. Because protocols are loaded as plugins, you install ABMateSDK when you need BLE communication. If additional protocols are supported in the future, you will be able to load the one that matches your device.

AIBudsAISDK

The AI functionality core SDK. It orchestrates multiple AI service providers through a plugin system — switch providers at runtime and the underlying calls route to the corresponding provider's capabilities.

AI Provider Plugins

AIBudsStarBurst

Middleware plugin for StarBurst AI (ByteDance). Wraps the provider's AI capabilities and exposes them through the AIBudsAISDK interface.

AIBudsMagicHelper

Middleware plugin for MltCloud AI (Meilc). Wraps the provider's AI capabilities and exposes them through the AIBudsAISDK interface.

Feature Modules

AIBudsAudio

Audio-related functionality: recording, playback, and Voice Activity Detection (VAD).

AIBudsVoiceAssistant

Offline voice authentication plugin. Handles on-device wake-word and voice command recognition. Requires service authorization, which is mediated through this middleware.

AIBudsLiveStream

Device live-streaming SDK. Pulls an RTSP stream from the device, provides a corresponding video player, and pushes the stream to an RTMP endpoint for broadcasting.

AIBudsCrashReporter

Crash log collection SDK. Captures app crashes, saves them to a local directory, and invokes a callback with the crash file path so your app can upload it to your server or handle it as needed.

AIBudsAIDashboard

A diagnostic dashboard for AI services. Viewable over the local network, it lets you inspect AI-related records — AI recordings, simultaneous interpretation sessions, AI conversations, and more. For each record you can see the associated device info, startup parameters, in-flight audio data, session events, and key errors, making it easier to analyze anomalies.

Convenience

AIBudsAllInOne

Because the modular architecture makes SDK initialization configuration somewhat involved, AIBudsAllInOne bundles a sane default configuration so you can initialize everything in one call — ideal when you don't need a custom installation.

Plugin Model

Four kinds of plugins drive the SDK's extensibility. Each conforms to a well-defined protocol, so you can write your own — for example, a custom BLE protocol plugin or a proprietary AI provider — and load it alongside or instead of the built-in ones:

Plugin typeProtocolLoaded byExample
BLE protocolBleConnectSDKAIBudsSDK.initialize(bleSDKs:...)ABMateSDK
AI providerAIConnectSDKAIBudsAISDK.initialize(aiSDKs:...)StarBurstSDK, MagicHelperSDK
AI / voice bridgeStarBurstBridgePlugin, MltCloudBridgePlugin, OnDeviceVoiceAssistantBridgePluginAIBudsSDK.setStarBurstAIPlugin(...) / setMltCloudAIPlugin(...) / setOnDeviceVoiceAssistantPlugin(...)Your auth plugin implementation
Log backendLogServiceAIBudsLogSDK.setXLFacilityPlugin(...)AIBudsXLFacility