STSLiveStreamer
@interface STSLiveStreamer : NSObject
StraaS.io live streamer
-
The state of the live streamer.
Declaration
Objective-C
@property (nonatomic, readonly) STSStreamingState state;
Swift
var state: STSStreamingState { get }
-
The current streaming URL.
Declaration
Objective-C
@property (nonatomic, readonly) NSURL *_Nonnull streamingURL;
Swift
var streamingURL: URL { get }
-
The receiver’s delegate or nil if it doesn’t have a delegate.
Declaration
Objective-C
@property (nonatomic, weak, readwrite, nullable) id<STSLiveStreamerDelegate> delegate;
Swift
weak var delegate: STSLiveStreamerDelegate? { get set }
-
Creates and returns a STSLiveStreamer object with specified video and audio configurations.
Declaration
Objective-C
- (nonnull instancetype) initWithVideoConfiguration:(nonnull STSVideoConfiguration *)videoConfig audioConfiguration:(nonnull STSAudioConfiguration *)audioConfig;
Swift
init(videoConfiguration videoConfig: STSVideoConfiguration, audioConfiguration audioConfig: STSAudioConfiguration)
Parameters
videoConfig
The video configuration.
audioConfig
The audio configuration.
Return Value
An initialized STSLiveStreamer object.
-
Starts streaming with a given URL.
Declaration
Objective-C
- (void)startStreamingWithURL:(nonnull NSURL *)url success:(nonnull void (^)(void))success failure:(nonnull void (^)(NSError *_Nonnull))failure;
Swift
func startStreaming(with url: URL, success: @escaping () -> Void, failure: @escaping (Error) -> Void)
Parameters
url
The streaming URL. Using multiple STSLiveStreamer instances to start stream with the same URL is unexpected.
success
A block object to be executed when the task finishes successfully.
failure
A block object to be executed when the task finishes unsuccessfully. This block has no return value and takes one argument: the error object describing the error that occurred.
-
Stops streaming.
Declaration
Objective-C
- (void)stopStreamingWithSuccess:(nonnull void (^)(NSURL *_Nonnull))success failure:(nonnull void (^)(NSError *_Nonnull, NSURL *_Nonnull))failure;
Swift
func stopStreaming(success: @escaping (URL) -> Void, failure: @escaping (Error, URL) -> Void)
Parameters
success
A block object to be executed when the task finishes successfully. This block has no return value and takes one argument: the stopped streaming URL.
failure
A block object to be executed when the task finishes unsuccessfully. This block has no return value and takes two arguments: the error object describing the error that occurred, and the streaming URL related to this error.
-
Pushes a video frame to the stream.
Declaration
Objective-C
- (void)pushVideoSampleBuffer:(nonnull CMSampleBufferRef)sampleBuffer;
Swift
func pushVideoSampleBuffer(_ sampleBuffer: CMSampleBuffer)
Parameters
sampleBuffer
The video frame.
-
Pushes an audio frame to the stream.
Declaration
Objective-C
- (void)pushAudioSampleBuffer:(nonnull CMSampleBufferRef)sampleBuffer;
Swift
func pushAudioSampleBuffer(_ sampleBuffer: CMSampleBuffer)
Parameters
sampleBuffer
The audio frame.
-
Pushes an audio frame which is sent from ReplayKit to the stream.
Declaration
Objective-C
- (void)pushAudioSampleBuffer:(nonnull CMSampleBufferRef)sampleBuffer ofAudioChannel:(nonnull NSString *)audioChannel;
Swift
func pushAudioSampleBuffer(_ sampleBuffer: CMSampleBuffer, ofAudioChannel audioChannel: String)
Parameters
sampleBuffer
The audio frame.
audioChannel
A constant NSString indicates the ReplayKit audio channel. The value could be kSTSReplayKitAudioChannelMic or kSTSReplayKitAudioChannelApp and must be registered by adding it to
replayKitAudioChannels
property of a STSAudioConfiguration object. ThesampleBuffer
will be discarded if theaudioChannel
is an unregistered channel.