-
Notifications
You must be signed in to change notification settings - Fork 0
Core Live Streaming Jpeg
Mr.P edited this page Aug 25, 2026
·
2 revisions
Start the device's JPEG live-stream mode and render each complete JPEG image delivered by the SDK.
- The device is connected and ready and conforms to
LiveStreamingAPI. -
supportsJPEGImageLiveStreamingistrue. - Your UI can decode and replace images without blocking the data callback.
AIBuds.xcframework
import AIBuds
import UIKit#import <AIBuds/AIBuds.h>
#import <AIBuds/AIBuds-Swift.h>
#import <UIKit/UIKit.h>/// Whether JPEG image live streaming is supported
var supportsJPEGImageLiveStreaming: Bool { get }/// Whether JPEG image live streaming is supported.
@property (nonatomic, readonly) BOOL supportsJPEGImageLiveStreaming;/// Start JPEG image live streaming
/// - Parameters:
/// - sessionStartCompletionHandler: Session start completion handler
/// - jpegDataReceivedHandler: JPEG data received handler
/// - sessionFinishHandler: Session finish handler
func startJPEGImageLiveStreaming(
withSessionStartCompletionHandler sessionStartCompletionHandler: AIBudsLiveStreamingSessionStartCompletionHandler?,
jpegDataReceivedHandler: AIBudsLiveStreamingJpegDataReceivedHandler?,
sessionFinishHandler: AIBudsLiveStreamingSessionFinishHandler?
)/// Start JPEG image live streaming
/// - Parameters:
/// - sessionStartCompletionHandler: Session start completion handler
/// - jpegDataReceivedHandler: JPEG data received handler
/// - sessionFinishHandler: Session finish handler
- (void)startJPEGImageLiveStreamingWithSessionStartCompletionHandler:(AIBudsLiveStreamingSessionStartCompletionHandler _Nullable)sessionStartCompletionHandler
jpegDataReceivedHandler:(AIBudsLiveStreamingJpegDataReceivedHandler _Nullable)jpegDataReceivedHandler
sessionFinishHandler:(AIBudsLiveStreamingSessionFinishHandler _Nullable)sessionFinishHandler;See startJPEGImageLiveStreaming.
| Handler | Values | Meaning |
|---|---|---|
sessionStartCompletionHandler |
success, error
|
Reports whether the live-stream session started. |
jpegDataReceivedHandler |
jpegData |
Delivers one complete JPEG image as Data / NSData. |
sessionFinishHandler |
isUserInitiatedStop, error
|
Reports the terminal session outcome and whether the stop was user initiated. |
The method does not return a value directly. Media and lifecycle results are delivered through the handlers.
guard let streamingDevice = device as? LiveStreamingAPI,
streamingDevice.supportsJPEGImageLiveStreaming else { return }
streamingDevice.startJPEGImageLiveStreaming(
withSessionStartCompletionHandler: { success, error in
DispatchQueue.main.async {
self.setStreamingActive(success)
if let error { self.show(error) }
}
},
jpegDataReceivedHandler: { jpegData in
// Decode away from the UI update, then assign the image on the main queue.
guard let image = UIImage(data: jpegData) else { return }
DispatchQueue.main.async {
self.imageView.image = image
}
},
sessionFinishHandler: { userStopped, error in
DispatchQueue.main.async {
self.setStreamingActive(false)
self.handleFinish(userStopped: userStopped, error: error)
}
}
)id<AIBudsLiveStreamingAPI> streamingDevice = (id<AIBudsLiveStreamingAPI>)self.device;
if (![streamingDevice conformsToProtocol:@protocol(AIBudsLiveStreamingAPI)] ||
!streamingDevice.supportsJPEGImageLiveStreaming) {
return;
}
__weak typeof(self) weakSelf = self;
[streamingDevice startJPEGImageLiveStreamingWithSessionStartCompletionHandler:^(BOOL success, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf setStreamingActive:success];
if (error) [weakSelf showError:error];
});
} jpegDataReceivedHandler:^(NSData *jpegData) {
UIImage *image = [UIImage imageWithData:jpegData];
if (!image) return;
dispatch_async(dispatch_get_main_queue(), ^{
weakSelf.imageView.image = image;
});
} sessionFinishHandler:^(BOOL userStopped, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
[weakSelf setStreamingActive:NO];
[weakSelf handleFinishUserStopped:userStopped error:error];
});
}];- Reject invalid JPEG data without replacing the last valid image.
- Treat
sessionStartCompletionHandlerfailure as a failed session start. - In
sessionFinishHandler, distinguish a user stop from an interruption and useerrorwhen present. - Do not infer frame loss, frame rate, or ordering guarantees beyond the callback sequence provided by the SDK.
- Avoid retaining every JPEG frame; replace the displayed image or use a bounded buffer.
- Keep image decoding and UI assignment lightweight to avoid callback backlog.
- Clear frame counters and presentation state when a new session begins.
- Call
stopLiveStreaming()when leaving the feature instead of only hiding the image view.
- The public SDK does not specify a fixed JPEG resolution or frame rate.
- JPEG mode does not require
AIBudsLiveStreamplayback classes. -
jpegDataReceivedHandlerprovides compressed JPEG data, not raw pixel buffers.
AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting