AVBroadcast

To add Audio/Video Broadcast support in your app,

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

Initialize the AVBroadcast object:

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

Methods Available:

Method Description
sendAVBroadcastRequestToUser The method allows user to initiate video broadcast resquest to a user from a logged-in user
acceptAVBroadcastRequestOfUser The method allows logged-in user to accept an video broadcast
startAVBroadcastWithInitiator The method allows loggedin user to start video broadcast
endAVBroadcastWithUser The method allows you end the broadcast
switchCamera The method allows you to switch camera

sendAVBroadcastRequestToUser

The method initiates video broadcast resquest to a user from a logged-in user
Method Signature:

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

Arguments:

userID

The userid of a user with whom you want to initiate a broadcast as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After video broadcast request is sent successfully
Response: NSDictionary containing id of the user to whom video broadcast request has been sent and callID

Sample Response:

{
  callID = "2be701b036ff9b6e3085d35049e59483";  
  userID = 5;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video broadcast request
Response: NSError containing error code and message

Usage:

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

acceptAVBroadcastRequestOfUser

Allows you to accept an video broadcast request when INCOMING_AVBROADCAST_REQUEST message is received in the onAVChatMessageReceived callback of subscribeWithMode method of CometChat class.
Method Signature:

 (void)acceptAVBroadcastRequestOfUser: (NSString *)userID
                               callID: (NSString *)callID
                              success: (void(^)(NSDictionary *response)) response
                              failure: (void(^)(NSError *error)) failure;

Arguments:

userID

The userid of a user who has initiated a broadcast with you as NSString datatype.

callID

The id of the broadcast session

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After sending video broadcast acknowledgement successfully
Response: NSDictionary containing id of the user to whom video broadcast acknowledgement has been sent

Sample Response:

{  
 userID = 6;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video broadcast acknowledgement
Response: NSError containing error code and message

Usage:

[avbroadcast acceptAVBroadcastRequestOfUser: @"6"
                                     callID: @"474a3e0baf0e3db251a2bc2a6a5b31a5"
                                    success: ^(NSDictionary * response){/* Code Block */}
                                    failure: ^(NSError * error){/* Code Block */}
];

startAVBroadcastWithInitiator

Starts an video broadcast within a container view. This function has to be called after sending/accepting video broadcast request only.
Method Signature:

  (void)startAVBroadcastWithInitiator: (BOOL)initiator
                               callID: (NSString *)callID
                        containerView: (UIView *)container
                        connectedUser: (void (^)(NSDictionary *response))response
                   changeInAudioRoute: (void (^)(NSDictionary *route))audioRouteInformation
                              failure: (void (^)(NSError *error))failure;

Arguments:

initiator

The value true indicates that the user is broadcasting the video and false indicated the the user is receiving a video broadcasted by another user.

callID

The id of the broadcast session as NSString datatype.

ContainerView

The reference of the UI Container in which video broadcast UI should be placed as UIView datatype.

connectedUser

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After sending video broadcast acknowledgement successfully
Response: NSDictionary containing id of the user to whom video broadcast acknowledgement has been sent

Sample Response:

{  
 "Connected user" = 1;
}

changeInAudioRoute

A callback method

Method Property Description
Method Signature: (void (^)(NSDictionary *route))audioRouteInformation
Invocation: Invoked with change in audio route
Response: NSDictionary containing audio route information

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while sending video broadcast request
Response: NSError containing error code and message

Usage:

[avbroadcast startAVBroadcastWithInitiator: YES
                                    callID: @"2be701b036ff9b6e3085d35049e59483" 
                             containerView: videoContainer connectedUser: ^(NSDictionary *response){/* Code Block */}
                        changeInAudioRoute: ^(NSDictionary *audioRoute){/* Code Block */}
                                   failure: ^(NSError *error){/* Code Block */}
];

endAVBroadcastWithUser

Ends an video broadcast corresponding to userID and callID
Method Signature:

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

Arguments:

initiator

If you are broadcaster then pass true, so the broadcast will end for all the users, if you are listener then pass false, so the broadcast will not end for all the users, you will just leave the broadcast.

userID

The userid of a user with whom you are in a broadcast session as NSString datatype.

callID

The id of a broadcast session as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After ending video broadcast successfully
Response: NSDictionary containing success message

Sample Response:

{
  success = 1;
}

failure

A callback method

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If an error occurs while ending video broadcast session
Response: NSError containing error code and message

Usage:

[avbroadcast endAVBroadcastWithUser: YES
                             userID: @"5" 
                             callID: @"2be701b036ff9b6e3085d35049e59483" 
                            success: ^(NSDictionary *response){/* Code Block */}
                            failure: ^(NSError *error){/* Code Block */}
];

switchCamera

Switch between front and rear camera for a broadcast
Method Signature:

(void)switchCamera;

Usage:

[avbroadcast switchCamera];

Please refer ‎error codes for failure responses.

  • Was this helpful?
  • Yes   No