Stop Live Streaming
Stop the current RTSP or JPEG device live-stream session and release any player, relay, image, or UI resources owned by the host app.
Prerequisites
- The target device conforms to
LiveStreamingAPI. - Keep references to presentation resources created for the current session.
- Make stop handling idempotent so view dismissal and an explicit stop action can share the same cleanup path.
API Reference
Framework
AIBuds.xcframework
Import
- Swift
- Objective-C
import AIBuds
import AIBudsLiveStream#import <AIBuds/AIBuds-Swift.h>
#import <AIBuds/AIBuds.h>
#import <AIBudsLiveStream/AIBudsLiveStream-Swift.h>Instance Method
- Swift
- Objective-C
/// Stop live streaming
func stopLiveStreaming()/// Stop live streaming
- (void)stopLiveStreaming;See stopLiveStreaming.
Parameters
This method has no parameters.
Return Value
This method does not return a value or accept a completion handler. Observe the sessionFinishHandler supplied when starting the session for terminal context.
Usage Examples
The Demo stops an optional RTMP relay before stopping RTSP playback, then clears device-session and UI state. The device command and host resources are separate lifecycles.
- Swift
- Objective-C
func stopCurrentLiveStream() {
// Stop optional host-side relay and playback resources.
liveStreamer?.stopStreaming()
liveStreamer = nil
mediaPlayer?.stop()
// Stop the RTSP or JPEG session on the connected device.
(device as? LiveStreamingAPI)?.stopLiveStreaming()
currentRTSPAddress = nil
imageView.image = nil
setStreamingActive(false)
}- (void)stopCurrentLiveStream {
// Stop optional host-side relay and playback resources.
[self.liveStreamer stopStreaming];
self.liveStreamer = nil;
[self.mediaPlayer stop];
// Stop the RTSP or JPEG session on the connected device.
id<AIBudsLiveStreamingAPI> streamingDevice = (id<AIBudsLiveStreamingAPI>)self.device;
if ([streamingDevice conformsToProtocol:@protocol(AIBudsLiveStreamingAPI)]) {
[streamingDevice stopLiveStreaming];
}
self.currentRtspAddress = nil;
self.imageView.image = nil;
[self setStreamingActive:NO];
}Error Handling
Because stopLiveStreaming() has no completion handler, make local cleanup safe to repeat and use the original session's finish callback to distinguish isUserInitiatedStop from an interruption. Log or present the callback error when a session ends unexpectedly.
Best Practices
- Stop live streaming when leaving the owning screen or ending the feature.
- Release the RTMP relay, player, and retained RTSP address together with the device session.
- Do not wait for a stop completion that the public method does not provide.
- Keep finish-callback handling idempotent because it can run after local cleanup.
Notes
- The same stop method ends either an RTSP or JPEG device session.
- Stopping
LiveStreamingPlayeralone does not stop the device session. - Stopping the device session alone does not automatically release host-owned playback or relay objects.