मुख्य कंटेंट तक स्किप करें

SDK Architecture

AIBuds SDK iOS कई modular components से बना है और हर component की जिम्मेदारी स्पष्ट है। Modules के आपसी संबंध समझने से आप केवल आवश्यक SDK parts install कर सकते हैं और अपने plugins के ज़रिए SDK को extend कर सकते हैं।

Architecture का परिचय

SDK layers में व्यवस्थित है—ऊपरी layers निचली layers पर depend करती हैं और अधिकांश स्तरों पर device side (बाएँ) के सामने AI side (दाएँ) है।

सिस्टम मैप

AIBuds SDK iOS आर्किटेक्चर

आपका ऐप

AIBuds डिवाइस से जुड़ने वाला iOS ऐप

AIBudsAllInOneवैकल्पिक

वैकल्पिक एकीकृत रैपर

फ़ीचर मॉड्यूल

Audio · VoiceAssistant · LiveStream · CrashReporter · AIBudsAIDashboard

AIBudsSDK

डिवाइस कोर

AIBudsAISDK

AI कोर

ABMateSDK(BLE)

Core Bluetooth संचार प्रोटोकॉल परत

StarBurst / MagicHelper

तृतीय-पक्ष AI सेवा एकीकरण परत

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

डिवाइस डेटा मॉडल

AIBudsAIFoundation

AI डेटा मॉडल

AIBudsLog

सभी परतों के लिए लॉगिंग मॉड्यूल

AIBudsXLFacilityवैकल्पिक

वैकल्पिक लॉगिंग प्लगइन

AIBuds SDK iOS की पूरी संरचना दिखाता है।

ऊपर से नीचे तक layers: आपका app → convenience wrapper → feature modules → फिर core SDK (device side + AI side) → protocol plugins → foundation data models → cross-cutting logging।

डिवाइस मॉडल

SDK जिस भी device से काम करता है, उसे एक protocol represent करता है— DeviceConvertible (Objective-C में AIBudsDeviceConvertible)। App इसी handle से device identity और state पढ़ता है और इसी पर lifecycle operations (connect, disconnect, unpair, save) करता है। Operations किसी manager singleton के बजाय सीधे device instance पर call होते हैं। DeviceConvertible, NSSecureCoding conform करता है, इसलिए इसे app launches के बीच archive और restore किया जा सकता है।

अलग protocol FoundDeviceConvertible (AIBudsFoundDeviceConvertible) scanning में अभी-अभी discovered device को represent करता है। इसमें Core Bluetooth data (central + peripheral + advertisementData + RSSI) होता है, लेकिन यह अभी store नहीं किया जा सकता। इसे AIBudsSDK.makeStorableDeviceFromDiscovered(_:) से convert करके persist करने योग्य DeviceConvertible पाएँ।

डिवाइस lifecycle

डिवाइस जीवनचक्र

Bluetooth से खोजे जाने से लेकर कमांड प्राप्त करने के लिए तैयार होने तक।

स्कैनBluetooth डिवाइस खोज
आस-पास

खोजा गया

स्कैनर ने प्रसारण कर रहे डिवाइस को खोज लिया है।

AIBudsSDK.makeStorableDeviceFromDiscovered(_:)सहेजने योग्य मॉडल बनाएँ
स्थानीय

सहेजने योग्य

डिवाइस मॉडल को स्थानीय संग्रहण के लिए तैयार किया गया है।

StoredDevicesMgr.addDevice
सहेजा गया

सहेजा गया

ऐप दोबारा शुरू होने पर भी डिवाइस की जानकारी उपलब्ध रहती है।

device.connect(ConnectParams)
जारी है

कनेक्ट हो रहा है

प्रमाणीकरण और कनेक्शन समन्वय चल रहा है।

deviceDidReadyडेलीगेट कॉलबैक
ऑनलाइन

तैयार

डिवाइस अब कमांड प्राप्त कर सकता है।

उपलब्धकमांड प्राप्त करने के लिए तैयार

Device पाँच states से गुजरता है: scanning में discovered → storable device में converted → storage में persisted → connecting → connected और ready।

StoredDevicesMgr (AIBudsStoredDevicesMgr) persisted device list संभालता है— addDevice, removeDevice, allDevices, findDevice(byMacAddr:), findDevice(byPeripheral:)। पहले saved devices, जिनमें auto-reconnect candidates भी हैं, restore करने के लिए launch पर loadDevicesInBackground call करें।

Capability protocols का उपयोग

हर device हर feature support नहीं करता, इसलिए capabilities को एक बड़े interface के बजाय अलग-अलग protocols में model किया गया है। ये सभी common marker DeviceAPI (AIBudsDeviceAPI) conform करते हैं:

Protocolउपलब्ध क्षमता
DeviceInfoAPIBattery, device capabilities, hardware configuration, language, storage, media count, समय sync/set करना
DeviceCommonAPIFactory reset और power off
DeviceFindAPIDevice खोजें / खोज बंद करें
DeviceWorkModeAPI / DeviceWorkStateAPIकाम का mode और state
DeviceVolumeControlAPIVolume पढ़ना / set करना
DeviceEqualizerAPIEqualizer की settings
DeviceANCAPIANC का mode, gain, transparency और fade
DeviceWearDetectionAPIWear detection capability और status
DeviceTWSAPITWS connection की स्थिति
DeviceMusicControlAPIPlayback, pause, track बदलना और volume
DeviceAudioRecordingAPINormal और AI audio recording, maximum duration
DeviceCameraAPIPhoto और video capture, camera firmware
DeviceRemoteShutterAPIRemote shutter का sync
DeviceFileImportAPIMedia files पाना, import और delete करना
DeviceOtaAPI / DeviceCameraOtaAPIFirmware का update
DeviceAppsAPIDevice applications शुरू और बंद करना
DeviceServiceAuthAPIService auth retry और result reporting
DevicePhysicalOperationsAPIDevice control mapping
LiveStreamingAPIRTSP और JPEG live streaming
OnDeviceVoiceAssistantAPIOffline voice assistant

Capability call करने के लिए device को संबंधित protocol में cast करें और conformance जाँचें। Required hardware न होने पर cast fail हो जाता है:

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

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

डेलीगेट

SDK में delegation के दो levels हैं—अपनी event scope के अनुसार सही level चुनें।

  • DeviceDelegate (AIBudsDeviceDelegate) — हर device के लिए अलगdevice.delegate = self से assign करें ताकि उस device के connection से जुड़े lifecycle events (didStartConnectingDevice, didConnectedToDevice, didFailToConnectDevice, device:didDisconnectWithError:, deviceDidReady) और state-change events (battery, work mode, ANC, EQ, wear status, TWS, volumes, storage, media count आदि) मिलें। सभी methods @objc optional हैं—केवल आवश्यक callbacks implement करें।
  • SDKDelegate (AIBudsSDKDelegate) — global। इसे AIBudsSDK.initialize(...delegate:) में दें; यह सभी devices के connection events mirror करता है और scanning status (onScanningStatusChanged:) भी देता है।

आम तौर पर app-level concerns (scanning, global connection UI) के लिए SDKDelegate और किसी device की screen के लिए DeviceDelegate उपयोग करें।

मुख्य singletons

SingletonScopeमुख्य entry points
AIBudsSDKडिवाइस पक्षinitialize(bleSDKs:configuration:delegate:), startScanning, stopScanning, isScanning(), makeStorableDeviceFromDiscovered(_:) और AI/voice plugin setters
AIBudsAISDKAI पक्षinitialize(aiSDKs:), setAIServiceVendor(_:), startAIChat, startAIAudioRecording, startSimultaneousInterpretation, translateText, summary, recognizeVoice और synthesizeText

Device operations (connect, disconnect, commands भेजना) इन singletons पर नहीं होते; इन्हें सीधे DeviceConvertible instance पर call किया जाता है।

AI सेवा प्रदाता

AI capabilities pluggable service provider देता है। चुना गया provider AIServiceVendor (AIBudsAIServiceVendor) enum से represent होता है:

CaseAI सेवा प्रदाता
.noneकोई provider नहीं चुना
.starBurstStarBurst AI (ByteDance) सेवा
.mltcloudMltCloud AI (Meilc) सेवा

Case spelling public Swift API के समान है: .starBurst में uppercase B है, जबकि .mltcloud पूरी तरह lowercase है।

Runtime में provider बदलने के लिए AIBudsAISDK.setAIServiceVendor(_:) call करें। इसे किसी AI service के पहले उपयोग से पहले call करना आवश्यक है।

Connection parameters की जानकारी

ConnectParams (AIBudsConnectParams) में device.connect(_:) के लिए required सभी values होती हैं—विशेष रूप से AI auth parameters, जिनसे SDK connection handshake में AI providers authenticate करता है:

  • userId — AI provider की तरफ end user को identify करता है।
  • aiAuthParams (AIAuthParams / AIBudsAIAuthParams) — हर provider के credentials रखता है:
    • starburst (StarBurstAIAuthParams): productId और optional ppeEnv value
    • 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)

Modules की जानकारी

Foundation layer के modules

AIBudsLog

यह पूरे AIBuds SDK में उपयोग होने वाला logging core module है। बाकी सभी modules इसी के ज़रिए logs लिखते हैं। सभी log implementations LogService protocol conform करते हैं, इसलिए defaults उपयुक्त न हों तो अपना LogService plugin किया जा सकता है।

Default log service चार output destinations support करती है—console, oslogger, file और xlfacility (आखिरी के लिए अतिरिक्त plugin चाहिए)।

AIBudsXLFacility

Optional log plugin जो log output को XLFacility से route करता है। Plain file destination की तुलना में XLFacility logs export, query और expire हुए logs हटाना आसान बनाता है; production के लिए यही recommended destination है।

AIBudsFoundation

Device communication से संबंधित data models, type definitions और auxiliary data structures। इसे shared vocabulary समझें जिस पर device SDK और आपका app दोनों depend करते हैं।

AIBudsAIFoundation

AIBudsFoundation जैसा, लेकिन AI business के लिए। यह सभी AI providers में उपयोग होने वाले base data models और type definitions देता है।

Core SDK layer के modules

AIBudsSDK

Device communication का core SDK। अधिकतर device functionality— scanning, connecting, commands भेजना और events पाना— इसी module से होती है।

ABMateSDK

AIBudsSDK द्वारा अभी उपयोग किया जाने वाला BLE communication protocol plugin। Protocols plugins के रूप में load होते हैं, इसलिए BLE communication के लिए ABMateSDK install करें। भविष्य में additional protocols support हों तो अपने device से match होने वाला protocol load किया जा सकेगा।

AIBudsAISDK

AI functionality का core SDK। यह plugin system से कई AI service providers coordinate करता है। Runtime में provider बदलने पर underlying calls संबंधित provider capabilities को route होती हैं।

AI provider के plugins

AIBudsStarBurst

StarBurst AI (ByteDance) के लिए middleware plugin। Provider की AI capabilities wrap करके AIBudsAISDK interface से expose करता है।

AIBudsMagicHelper

MltCloud AI (Meilc) के लिए middleware plugin। Provider की AI capabilities wrap करके AIBudsAISDK interface से expose करता है।

Feature modules की जानकारी

AIBudsAudio

Audio functionality: recording, playback और Voice Activity Detection (VAD)।

AIBudsVoiceAssistant

Offline voice authentication plugin। On-device wake-word और voice command recognition संभालता है। इसके लिए service authorization चाहिए, जिसे यह middleware coordinate करता है।

AIBudsLiveStream

Device live-streaming SDK। Device से RTSP stream लेता है, संबंधित video player देता है और broadcast के लिए stream को RTMP endpoint पर push करता है।

AIBudsCrashReporter

App crash report collection SDK। App crash capture करता है, report local directory में save करता है और crash file path callback में देता है, ताकि app उसे server पर upload या आवश्यकतानुसार process कर सके।

AIBudsAIDashboard

AI services के लिए diagnostic dashboard। Local network से खुलने वाला dashboard AI recordings, simultaneous interpretation sessions, AI conversations और अन्य records inspect करने देता है। हर record में device info, startup parameters, in-flight audio data, session events और प्रमुख errors देखकर समस्या का कारण समझना आसान होता है।

Convenience Integration

AIBudsAllInOne

Modular architecture में SDK initialization configuration कुछ लंबी हो सकती है। AIBudsAllInOne sensible default configuration bundle करता है, जिससे सब कुछ एक call में initialize किया जा सकता है—जब custom installation की आवश्यकता न हो, तब यह उपयुक्त है।

Plugin model की जानकारी

चार तरह के plugins SDK को extend करते हैं। हर plugin well-defined protocol conform करता है, इसलिए आप अपना plugin—जैसे custom BLE protocol या proprietary AI provider—बना सकते हैं और built-in plugins के साथ या उनके बदले load कर सकते हैं:

Plugin typeProtocolकिससे load होता हैउदाहरण
BLE का protocolBleConnectSDKAIBudsSDK.initialize(bleSDKs:...)ABMateSDK
AI का providerAIConnectSDKAIBudsAISDK.initialize(aiSDKs:...)StarBurstSDK, MagicHelperSDK
AI / voice bridgeStarBurstBridgePlugin, MltCloudBridgePlugin, OnDeviceVoiceAssistantBridgePluginAIBudsSDK.setStarBurstAIPlugin(...) / setMltCloudAIPlugin(...) / setOnDeviceVoiceAssistantPlugin(...)आपका auth plugin implementation
Log का backendLogServiceAIBudsLogSDK.setXLFacilityPlugin(...)AIBudsXLFacility