STSStreamingManager

@interface STSStreamingManager : NSObject

StraaS.io streaming manager

  • The receiver’s delegate or nil if it doesn’t have a delegate.

    Declaration

    Objective-C

    @property (nonatomic, weak, readwrite, nullable) id<STSStreamingManagerDelegate>
        delegate;

    Swift

    weak var delegate: STSStreamingManagerDelegate? { get set }
  • The position of the the source camera. Default value is AVCaptureDevicePositionBack.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        AVCaptureDevicePosition captureDevicePosition;

    Swift

    var captureDevicePosition: AVCaptureDevice.Position { get set }
  • The state of the streaming manager.

    Declaration

    Objective-C

    @property (nonatomic, readonly) STSStreamingState state;

    Swift

    var state: STSStreamingState { get }
  • JWT

    Current member JWT

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull JWT;

    Swift

    var jwt: String { get }
  • The id of the current streaming live event.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *currentStreamingLiveId;

    Swift

    var currentStreamingLiveId: String? { get }
  • The stream key of the current streaming live event.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *currentStreamingKey;

    Swift

    var currentStreamingKey: String? { get }
  • The filter group for the output video.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite, nullable)
        int *filterGroup;

    Swift

    var filterGroup: UnsafeMutablePointer<Int32>? { get set }
  • The enabled status of audio. If the audio is not enabled, it means there is no sound in the audio stream.

    This method should only be called when the enum state of STSStreamingState is greater than STSStreamingStatePreparing.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite) BOOL audioEnabled;

    Swift

    var audioEnabled: Bool { get set }
  • A boolean value indicates whether the video stream of the front camera will be flipped horizontally from the preview. Defaults to YES.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite)
        BOOL flipFrontCameraOutputHorizontally;

    Swift

    var flipFrontCameraOutputHorizontally: Bool { get set }
  • Creates and returns a STSStreamingManager object with given member JWT.

    This method can only be called after you configured application successfully (by calling STSApplication method configureApplication:), otherwise you will get a nil object.

    Declaration

    Objective-C

    + (nonnull instancetype)streamingManagerWithJWT:(NSString *_Nullable)JWT;

    Swift

    convenience init(jwt JWT: String?)

    Parameters

    JWT

    The member token got from StraaS server.

    Return Value

    A STSStreamingManager object initialized with JWT.

  • Initializes the camera, codec and microphone, you will be able to preview the live stream after prepare success. This method should only be called when the STSStreamingManager’s state is STSStreamingStateIdle or STSStreamingStatePrepared. The success and failure completion handler will always be dispatched to the main queue.

    Declaration

    Objective-C

    - (void)prepareWithPreviewView:(nonnull UIView *)previewView
                     configuration:
                         (nonnull STSStreamingPrepareConfig *)configuration
                           success:(nonnull void (^)(CGSize))success
                           failure:(nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func prepare(withPreviewView previewView: Any!, configuration: STSStreamingPrepareConfig, success: @escaping (CGSize) -> Void, failure: @escaping (Error) -> Void)

    Parameters

    previewView

    The view to preview the output video.

    configuration

    The configuration of the output video.

    success

    A block object to be executed when the task finishes successfully. This block has no return value and takes one argument: the size of the output video.

    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.

  • Initializes the camera, codec and microphone, you will be able to preview the live stream after prepare success. This method should only be called when the STSStreamingManager’s state is STSStreamingStateIdle or STSStreamingStatePrepared. The success and failure completion handler will always be dispatched to the main queue.

    Declaration

    Objective-C

    - (void)prepareWithVideoSize:(CGSize)videoSize
                     previewView:(nonnull UIView *)previewView
          outputImageOrientation:(UIInterfaceOrientation)outputImageOrientation
                         success:(nonnull void (^)(void))success
                         failure:(nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func prepare(withVideoSize videoSize: CGSize, previewView: Any!, outputImageOrientation: Any!, success: @escaping () -> Void, failure: @escaping (Error) -> Void)

    Parameters

    videoSize

    The output video size. The width and height should both be the multiple of two. If the width/height is not an even number.

    previewView

    The view to preview the output video.

    outputImageOrientation

    The orientation of the output video.

    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.

  • Starts to streaming with the provided parameters.

    This method will create a live event owned by current member JWT and start to stream. Note that you should only call this method when the length of JWT is larger than zero (which means the member is not a guest). Otherwise, you will get an error.

    Declaration

    Objective-C

    - (void)
        startStreamingWithConfguration:
            (nonnull STSStreamingLiveEventConfig *)configuration
                               success:(nonnull void (^)(NSString *_Nonnull))success
                               failure:
                                   (nonnull void (^)(NSError *_Nonnull,
                                                     NSString *_Nullable))failure;

    Swift

    func startStreaming(withConfguration configuration: STSStreamingLiveEventConfig, success: @escaping (String) -> Void, failure: @escaping (Error, String?) -> Void)

    Parameters

    configuration

    The configuration of the live event.

    success

    A block object to be executed when the task finishes successfully. This block has no return value and takes one arguments: the current streaming live event id.

    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 live event id related to this error(can be nil). e.g. When the error is STSStreamingErrorCodeLiveCountLimit, you will get the not ended live event id, so that you can remove it.

  • Starts to stream with given live event id.

    Note that you should only call this method when the length of JWT is larger than zero (which means the member is not a guest). Otherwise, you will get an error.

    Declaration

    Objective-C

    - (void)startStreamingWithliveId:(nonnull NSString *)liveId
                             success:(nonnull void (^)(void))success
                             failure:(nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func startStreamingWithliveId(_ liveId: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void)

    Parameters

    liveId

    The id of the live event.

    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.

  • Starts to stream with given stream key.

    Declaration

    Objective-C

    - (void)startStreamingWithStreamKey:(nonnull NSString *)streamKey
                                success:(nonnull void (^)(void))success
                                failure:
                                    (nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func startStreaming(withStreamKey streamKey: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void)

    Parameters

    streamKey

    The stream key got from StraaS server.

    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 the current live streaming.

    This method can only be called when state is STSStreamingStateConnecting or STSStreamingStateStreaming.

    Declaration

    Objective-C

    - (void)stopStreamingWithSuccess:(nonnull void (^)(NSString *_Nullable))success
                             failure:(nonnull void (^)(NSError *_Nonnull,
                                                       NSString *_Nullable))failure;

    Swift

    func stopStreaming(success: @escaping (String?) -> Void, failure: @escaping (Error, String?) -> 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 live event id of stopped streaming (can be nil if you start current stream by a stream key).

    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 live event id related to this error (can be nil if you start current stream by a stream key).

  • Create a live event owned by current member JWT.

    Note that you should only call this method when the length of JWT is larger than zero (which means the member is not a guest). Otherwise, you will get an error.

    Declaration

    Objective-C

    - (void)
        createLiveEventConfguration:
            (nonnull STSStreamingLiveEventConfig *)configuration
                            success:(nonnull void (^)(NSString *_Nonnull))success
                            failure:(nonnull void (^)(NSError *_Nonnull,
                                                      NSString *_Nullable))failure;

    Swift

    func createLiveEventConfguration(_ configuration: STSStreamingLiveEventConfig, success: @escaping (String) -> Void, failure: @escaping (Error, String?) -> Void)

    Parameters

    configuration

    The configuration of the live event.

    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 two arguments: the error object describing the error that occurred, and the live event id related to this error(can be nil). e.g. When the error is STSStreamingErrorCodeLiveCountLimit, you will get the not ended live event id, so that you can remove it.

  • Sets the status of a live event to ended. This method has been deprecated. Use endLiveEvent:success:failure: instead.

    Declaration

    Objective-C

    - (void)cleanLiveEvent:(nonnull NSString *)liveId
                   success:(nonnull void (^)(void))success
                   failure:(nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func cleanLiveEvent(_ liveId: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void)

    Parameters

    liveId

    The id of the live event.

    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.

  • Sets the status of a live event to ended.

    Note that you are not able to end a live event which is not owned by current member JWT through SDK.

    Declaration

    Objective-C

    - (void)endLiveEvent:(nonnull NSString *)liveId
                 success:(nonnull void (^)(void))success
                 failure:(nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func endLiveEvent(_ liveId: String, success: @escaping () -> Void, failure: @escaping (Error) -> Void)

    Parameters

    liveId

    The id of the live event.

    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.

  • Get the streaming statistics.

    Declaration

    Objective-C

    - (STSStreamingStatsReport *_Nullable)getStreamingStatsReport;

    Swift

    func getStreamingStatsReport() -> STSStreamingStatsReport?

    Return Value

    The streaming statistics, or nil if state is not STSStreamingStateStreaming.

  • Gets the streaming information of a live event.

    Note that you are not able to get the streaming information of the live event which does not belong to current member JWT through SDK.

    Declaration

    Objective-C

    - (void)getStreamingInfoWithLiveId:(nonnull NSString *)liveId
                               success:(nonnull void (^)(
                                           STSStreamingInfo *_Nonnull))success
                               failure:(nonnull void (^)(NSError *_Nonnull))failure;

    Swift

    func getStreamingInfo(withLiveId liveId: String, success: @escaping (STSStreamingInfo) -> Void, failure: @escaping (Error) -> Void)

    Parameters

    liveId

    The id of the live event.

    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.