Audio/Video Broadcast

To add Audio/Video Broadcast support in your application,

Include the class <CometChatSDK/AVBroadcast.h> in the .h file of your class.

All the method calls will invoke their respective callback blocks as defined below.

1. Initialize the AVBroadcast object :

AVBroadcast *avbroadcast =  [[AVBroadcast alloc] init];

2. Send call request
Send Audio Video Broadcast call request to the userID specified. (Ensure that userID cannot be nil or empty)

- (void)sendAVBroadcastRequestToUser:(NSString *) userID
                             success:(void(^)(NSDictionary *)) response
                             failure:(void(^)(NSError *)) failure;

Return type: void
Callback Blocks:
(i). (void(^)(NSDictionary *response))response
Invocation: After audio video broadcast call request is sent successfully.
Response: NSDictionary containing id of the user to whom audio video broadcast request has been sent.
Eg:

{
  callID = 2be701b036ff9b6e3085d35049e59483;
  userID = 5;
}

(ii). (void(^)(NSError *error))failure
Invocation: If an error occurs while sending audio video broadcast request
Response: NSError containing error code and message
Usage:

[avbroadcast sendAVBroadcastRequestToUser:@”5”
                                  success:^(NSDictionary *response) {
                                } failure:^(NSError * error) {
}];

3. Start audio video broadcast
Start an audio-video broadcast within the container view. This function has to be called after sending/accepting audio-video broadcast request only. (Ensure that userID specified here should be the same while sending/accepting the request and also userID cannot be nil or empty)

- (void)startAVBroadcastWithInitiator:(BOOL)initiator
                               callID:(NSString *)callID
                      inContainerView:(UIView *)container
                              failure:(void(^)(NSError * error))failure;

Return type: void
Callback Blocks:
(i). (void(^)(NSError *error))failure
Invocation: If an error occurs while starting audio video broadcast request.
Response: NSError containing error code and message.
Usage:

Sender

[avbroadcast startAVBroadcastWithInitiator:YES
                                    callID:@”2be701b036ff9b6e3085d35049e59483”
                           inContainerView:containerView
                                   failure:^(NSError * error) {
}];

Receiver

[avbroadcast startAVBroadcastWithInitiator:NO
                                    callID:@”2be701b036ff9b6e3085d35049e59483”
                           inContainerView:containerView
                                   failure:^(NSError * error) {
}];

4. End call
End audio-video broadcast with the user corresponding to userID specified. (Ensure that userID specified should be same as given when starting the audio-video broadcast and also userID cannot be nil or empty)

- (void)endAVBroadcastWithUser:(NSString *)userID
                       success:(void(^)(NSDictionary * response)) response
                       failure:(void(^)(NSError * error)) failure;

Return type: void
Callback Blocks:
(i). (void(^)(NSDictionary *response))response
Invocation: After ending audio video broadcast successfully.
Response: NSDictionary containing id of the user with whom audio video broadcast has been ended.
Eg:

{  
 success = 1;
}

(ii). (void(^)(NSError *error))failure
Invocation: If an error occurs while ending audio video broadcast request
Response: NSError containing error code and message
Usage:


[avbroadcast endAVBroadcastWithUser:@”6”
                            success:^(NSDictionary* response) {
                           }failure:^(NSError* error) {
}];

5. Switch between front and rear camera in a Video call

- (void)switchCamera;

Return type: void
Usage:

[avbroadcast switchCamera];

Please refer ‎error codes for failure responses.

Not finding what you need?

The CometChat team is here to help!