CirCall IPCam Broadcasting API Change - Straas/Straas-iOS-sdk GitHub Wiki
Circall API refactor
目標
因為目前架構上, 一種 publish 方法會多出一組 prepare/publish method,對於 code 來說會較凌亂, 所以 refactor 以減少此負擔。
預計版本 0.22.0
會上此更新,一次新增新的 API 且同時 depricate 掉舊的 API。
API 更動概述
- 不需要再呼叫
CircallManager#prepare(...)
、處理PREPARING
和PREPARED
兩種狀態,CircallManager 會更單純地負責 connection 狀態。 - 呼叫
CircallManager#createStream(...)
之後即可拿到各種CircallStream
(例如:CircallRTSPURLStream
)以供publish
- publish 時帶入上一部拿到的
CircallStream
即可辨別 Stream 種類,詳見下面
API 更動細節
- CircallManager:
-
prepare:移除此 method,改以
createStreamWithConfig
來產生 stream 代表狀態完成//old API - (void)prepareForUrlWithSuccess:(void(^ _Nullable)(void))success failure:(void(^ _Nullable)(NSError * error))failure; //new API + (void)createStreamWithConfig:(STSCircallStreamConfig *)config success:(void (^ _Nullable)(STSCircallStream *stream))success failure:(void (^ _Nullable)(NSError *error))failure; //old sample [self.circallManager prepareForCameraWithStreamConfig:streamConfig success:prepareWithPreviewViewSuccessHandler failure:^(NSError * _Nonnull error) { }]; //new sample [[STSCircallManager class] createStreamWithConfig:config success:^(STSCircallStream * _Nonnull stream) { } failure:^(NSError * _Nonnull error) { }];
-
publish: 新增從
createStream
得到的CircallStream
作為傳入的參數//old API - (void)publishWithUrlConfig:(STSCircallPublishWithUrlConfig *)config success:(void(^ _Nullable)(STSCircallStream * stream))success failure:(void(^ _Nullable)(NSError * error))failure; //new API - (void)publishStream:(STSCircallStream *)stream withConfig:(STSCircallPublishConfig *)config success:(void(^ _Nullable)(STSCircallStream *stream))success failure:(void(^ _Nullable)(NSError * error))failure; //old sample [weakSelf.circallManager publishWithUrlConfig:config success:^(STSCircallStream * _Nonnull stream) { } failure:^(NSError * _Nonnull error) { }]; //new sample STSCircallPublishRTSPURLConfig *config = [[STSCircallPublishRTSPURLConfig alloc] init]; [weakSelf.circallManager publishStream:stream withConfig:(STSCircallPublishConfig *)config success:^(STSCircallStream * _Nonnull stream) { } failure:^(NSError * _Nonnull error) { }];
-
unpublish: 一樣新增 stream 作為參數
//old API - (void)unpublishWithSuccess:(void(^ _Nullable)(void))success failure:(void(^ _Nullable)(NSError * error))failure; //new API - (void)unpublishStream:(STSCircallStream *)stream withSuccess:(void(^ _Nullable)(void))success failure:(void(^ _Nullable)(NSError * error))failure; // old sample [weakSelf.circallManager unpublishWithSuccess:^{ } failure:^(NSError * _Nonnull error) { }]; // new API [weakSelf.circallManager unpublishStream:weakSelf.pictureInPictureVideoView.stream withSuccess:^{ } failure:^(NSError * _Nonnull error) { }];
-
STSCircallState
property: 移除STSCircallStatePrepared
、STSCircallStatePreparing
typedef NS_ENUM(NSUInteger, STSCircallState) { /** * The initial state. You can connect to a room in this state. */ STSCircallStateIdle = 0, /** * The STSCircallManager is connecting to the room, but is not yet connected. */ STSCircallStateConnecting = 1, /** * The STSCircallManager is connected to the room. */ STSCircallStateConnected = 2, /** * The STSCircallManager is in the process of disconnecting. */ STSCircallStateDisconnecting = 3 };
-