PWMediaSession Class Reference
Inherits from | NSObject |
---|---|
Declared in | PWMediaSession.h |
Overview
The PWMediaSession
class manages the execution of WebRTC operations.
Operations such as: handling offer/answer, ICE, renegotiation, data transfer and other media activities.
PWMediaSession
’s delegate methods—defined by the PWMediaSessionDelegate protocol—allow
an object to receive callbacks regarding the success or failure of an
operation and Audio/Video output.
In addition to the great communication experience, PWMediaSession
provides support for the following features:
- Get statistics of running sessions.
- File sharing and messaging.
- Lock/Unlock feature to make room private.
Properties
delegate
The PWMediaSessionDelegate object that serves as a delegate object for this PWMediaSession object, handling messages on behalf of this session.
@property (weak, nonatomic) id<PWMediaSessionDelegate> delegate
Declared In
PWMediaSession.h
cameraPosition
The current position of your device camera.
PWCameraPosition
(defined in PWMediaConfiguration)
@property (nonatomic, assign, readonly) PWCameraPosition cameraPosition
Declared In
PWMediaSession.h
myPeer
Represents client oneself.
@property (strong, nonatomic, readonly) PWRemotePeer *myPeer
Declared In
PWMediaSession.h
audioCall
Useful to identify that ongoing conference is only audio enabled (no video) or not.
@property (assign, nonatomic, readonly, getter=isAudioCall) BOOL audioCall
Declared In
PWMediaSession.h
isSelfRoomOwner
To check current room is created by you OR someone else.
@property (assign, nonatomic, readonly) BOOL isSelfRoomOwner
Declared In
PWMediaSession.h
connectionsCount
Number of connections that are connected or in process.
@property (assign, nonatomic, readonly) NSUInteger connectionsCount
Declared In
PWMediaSession.h
onDocumentReceivingProgress
onDocumentReceivingProgress
is an event responder,
called when file receiving progress changes.
@property (nonatomic, copy) void ( ^ ) ( PWDataFile *document , float progress ) onDocumentReceivingProgress
Discussion
Use it like this:
self.mediaSession.onDocumentReceivingProgress = ^(PWDataFile *document, float progress) {
};
It returns document object with its progress, you can easily identify the documents using data_id (defined in PWDataFile
.h
) and update the progress value.
Declared In
PWMediaSession.h
onDocumentSendingProgress
onDocumentSendingProgress
is an event responder,
called when file sending progress changes.
@property (nonatomic, copy) void ( ^ ) ( NSString *data_id , float progress ) onDocumentSendingProgress
Return Value
data_id
- An unique identifier of sent file.
progress
- Receiving progress value of file 0 to 1.
Discussion
Use it like this:
self.mediaSession.onDocumentSendingProgress = ^(NSString *data_id, float progress) {
};
It works same as onDocumentReceivingProgress
. The only difference is: It returns data_id instead of document object.
data_id is the unique identifier of file transfer process. When you call [PWMediaSession sendFileData:withFileName:ofType:toPeer:streamId:] you have to send an unique id in streamId
param so you can identify the operations on certain file later.
Declared In
PWMediaSession.h
Singleton
+ sharedInstance
Singleton.
+ (instancetype)sharedInstance
Return Value
Instance of PWMediaSession
.
Declared In
PWMediaSession.h
Initializing session
– startVideoCall:participant:displayName:delegate:
Start video calling
- (void)startVideoCall:(NSString *)meetingId participant:(NSString *)participantId displayName:(NSString *)displayName delegate:(id<PWMediaSessionDelegate>)delegate
Parameters
meetingId |
Your room name. |
---|---|
participantId |
Your unique id, can use |
displayName |
Your nickname, will be visible to other participants in room. |
delegate |
Declared In
PWMediaSession.h
– startVideoCall:participant:displayName:delegate:configuration:
Start video calling with custom media configuration
- (void)startVideoCall:(NSString *)meetingId participant:(NSString *)participantId displayName:(NSString *)displayName delegate:(id<PWMediaSessionDelegate>)delegate configuration:(nullable PWMediaConfiguration *)config
Parameters
meetingId |
Your room name. |
---|---|
participantId |
Your unique id, can use |
displayName |
Your nickname, will be visible to other participants in room. |
delegate |
|
config |
The configuration PWMediaConfiguration with custom media properties:
|
Discussion
Note: By default, calculates according to device capturing capabilities.
Declared In
PWMediaSession.h
– startAudioCall:participant:displayName:delegate:
Start audio calling
- (void)startAudioCall:(NSString *)meetingId participant:(NSString *)participantId displayName:(NSString *)displayName delegate:(id<PWMediaSessionDelegate>)delegate
Parameters
meetingId |
Your room name. |
---|---|
participantId |
Your unique id, can use |
displayName |
Your nickname, will be visible to other participants in room. |
delegate |
Declared In
PWMediaSession.h
Statistics
– collectStatsWithTimeInterval:
Get set of statistics of conections using WebRTC Apis
- (void)collectStatsWithTimeInterval:(NSTimeInterval)timeInterval
Parameters
timeInterval |
A time interval, in |
---|
Declared In
PWMediaSession.h
– stopCollectingStats
Disable timeInterval loop and stop collecting stats report.
- (void)stopCollectingStats
Declared In
PWMediaSession.h
Text messaging
– sendMessage:
Send message to all participants in room.
- (void)sendMessage:(NSString *)message
Parameters
message |
Your text message. |
---|
Declared In
PWMediaSession.h
– sendMessage:toPeer:
Send private message in room.
- (void)sendMessage:(NSString *)message toPeer:(NSString *)peerId
Parameters
message |
Your text message. |
---|---|
peerId |
|
Declared In
PWMediaSession.h
File sharing
– sendFileData:withFileName:ofType:toPeer:streamId:
Send data such as: txt, rtf, pdf and other documents.
- (void)sendFileData:(NSData *)data withFileName:(NSString *)filename ofType:(NSString *)extension toPeer:(NSString *)peerId streamId:(NSString *)streamId
Parameters
data |
File in form of binary data. |
---|---|
filename |
Filename. |
extension |
File extension. |
peerId |
|
streamId |
Unique identifier which represents file transfer process, can use |
Declared In
PWMediaSession.h
Privacy
– lockRoom
Lock room. When you lock the room, no one new will be able to enter.
- (void)lockRoom
Discussion
Warning: Only valid for room owner.
Declared In
PWMediaSession.h
– unlockRoom
Unlock room.
- (void)unlockRoom
Discussion
Warning: Only valid for room owner.
Declared In
PWMediaSession.h
Media
– switchCameraPosition:
Switch camera.
- (void)switchCameraPosition:(PWCameraPosition)position
Parameters
position |
|
---|
Declared In
PWMediaSession.h
– videoAuthorized
Check video access permission is allowed by user or not.
- (BOOL)videoAuthorized
Return Value
Authorization status (BOOL
)
Declared In
PWMediaSession.h
– audioAuthorized
Check audio access permission is allowed by user or not.
- (BOOL)audioAuthorized
Return Value
Authorization status (BOOL
)
Declared In
PWMediaSession.h
– setIdleTimerDisabled:
Use this to stop device to going in sleep mode during conferencing.
default is NO
- (void)setIdleTimerDisabled:(BOOL)idleTimerDisabled
Parameters
idleTimerDisabled |
|
---|
Discussion
Warning: Don’t forget to reset it in your End call
action or in AppDelegate
methods applicationDidEnterBackground
OR applicationWillTerminate
by simply using this line of code:
[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
Declared In
PWMediaSession.h
Close session
– endCall
End call: close all connections and purge current session.
- (void)endCall
Declared In
PWMediaSession.h