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 ऐप
वैकल्पिक एकीकृत रैपर
Audio · VoiceAssistant · LiveStream · CrashReporter · AIBudsAIDashboard
डिवाइस कोर
AI कोर
Core Bluetooth संचार प्रोटोकॉल परत
तृतीय-पक्ष AI सेवा एकीकरण परत
- StarBurst AI (ByteDance)
- MltCloud AI (Meilc)
डिवाइस डेटा मॉडल
AI डेटा मॉडल
सभी परतों के लिए लॉगिंग मॉड्यूल
वैकल्पिक लॉगिंग प्लगइन
ऊपर से नीचे तक 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 से खोजे जाने से लेकर कमांड प्राप्त करने के लिए तैयार होने तक।
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 | उपलब्ध क्षमता |
|---|---|
DeviceInfoAPI | Battery, device capabilities, hardware configuration, language, storage, media count, समय sync/set करना |
DeviceCommonAPI | Factory reset और power off |
DeviceFindAPI | Device खोजें / खोज बंद करें |
DeviceWorkModeAPI / DeviceWorkStateAPI | काम का mode और state |
DeviceVolumeControlAPI | Volume पढ़ना / set करना |
DeviceEqualizerAPI | Equalizer की settings |
DeviceANCAPI | ANC का mode, gain, transparency और fade |
DeviceWearDetectionAPI | Wear detection capability और status |
DeviceTWSAPI | TWS connection की स्थिति |
DeviceMusicControlAPI | Playback, pause, track बदलना और volume |
DeviceAudioRecordingAPI | Normal और AI audio recording, maximum duration |
DeviceCameraAPI | Photo और video capture, camera firmware |
DeviceRemoteShutterAPI | Remote shutter का sync |
DeviceFileImportAPI | Media files पाना, import और delete करना |
DeviceOtaAPI / DeviceCameraOtaAPI | Firmware का update |
DeviceAppsAPI | Device applications शुरू और बंद करना |
DeviceServiceAuthAPI | Service auth retry और result reporting |
DevicePhysicalOperationsAPI | Device control mapping |
LiveStreamingAPI | RTSP और JPEG live streaming |
OnDeviceVoiceAssistantAPI | Offline voice assistant |
Capability call करने के लिए device को संबंधित protocol में cast करें और conformance जाँचें। Required hardware न होने पर cast fail हो जाता है:
- Swift
- Objective-C
if let info = device as? DeviceInfoAPI {
info.setDeviceTime(Date()) { success, statusCode, error in
// ...
}
}
if let anc = device as? DeviceANCAPI {
anc.setAncMode(.ancOn) { _ in }
}if ([device conformsToProtocol:@protocol(AIBudsDeviceInfoAPI)]) {
id<AIBudsDeviceInfoAPI> info = (id<AIBudsDeviceInfoAPI>)device;
[info setDeviceTime:[NSDate date]
completion:^(BOOL success, NSNumber *statusCode, NSError *error){
// ...
}];
}डेलीगेट
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
| Singleton | Scope | मुख्य entry points |
|---|---|---|
AIBudsSDK | डिवाइस पक्ष | initialize(bleSDKs:configuration:delegate:), startScanning, stopScanning, isScanning(), makeStorableDeviceFromDiscovered(_:) और AI/voice plugin setters |
AIBudsAISDK | AI पक्ष | 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 होता है:
| Case | AI सेवा प्रदाता |
|---|---|
.none | कोई provider नहीं चुना |
.starBurst | StarBurst AI (ByteDance) सेवा |
.mltcloud | MltCloud 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और optionalppeEnvvaluemltcloud(MltCloudAIAuthParams):channelId
- Swift
- Objective-C
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)AIBudsConnectParams *params = [AIBudsConnectParams new];
AIBudsAIAuthParams *auth = [AIBudsAIAuthParams new];
AIBudsStarBurstAIAuthParams *starBurst = [AIBudsStarBurstAIAuthParams new];
starBurst.productId = configs[@"STARBURST_PRODUCTID"];
auth.starburst = starBurst;
AIBudsMltCloudAIAuthParams *mltCloud = [AIBudsMltCloudAIAuthParams new];
mltCloud.channelId = configs[@"MLTCLOUD_CHANNELID"];
auth.mltcloud = mltCloud;
params.aiAuthParams = auth;
params.userId = @"199";
[device connectWithParams: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 type | Protocol | किससे load होता है | उदाहरण |
|---|---|---|---|
| BLE का protocol | BleConnectSDK | AIBudsSDK.initialize(bleSDKs:...) | ABMateSDK |
| AI का provider | AIConnectSDK | AIBudsAISDK.initialize(aiSDKs:...) | StarBurstSDK, MagicHelperSDK |
| AI / voice bridge | StarBurstBridgePlugin, MltCloudBridgePlugin, OnDeviceVoiceAssistantBridgePlugin | AIBudsSDK.setStarBurstAIPlugin(...) / setMltCloudAIPlugin(...) / setOnDeviceVoiceAssistantPlugin(...) | आपका auth plugin implementation |
| Log का backend | LogService | AIBudsLogSDK.setXLFacilityPlugin(...) | AIBudsXLFacility |