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> delegateDeclared In
PWMediaSession.h
cameraPosition
The current position of your device camera.
PWCameraPosition (defined in PWMediaConfiguration)
@property (nonatomic, assign, readonly) PWCameraPosition cameraPositionDeclared In
PWMediaSession.h
myPeer
Represents client oneself.
@property (strong, nonatomic, readonly) PWRemotePeer *myPeerDeclared 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 audioCallDeclared In
PWMediaSession.h
isSelfRoomOwner
To check current room is created by you OR someone else.
@property (assign, nonatomic, readonly) BOOL isSelfRoomOwnerDeclared In
PWMediaSession.h
connectionsCount
Number of connections that are connected or in process.
@property (assign, nonatomic, readonly) NSUInteger connectionsCountDeclared In
PWMediaSession.h
onDocumentReceivingProgress
onDocumentReceivingProgress is an event responder,
called when file receiving progress changes.
@property (nonatomic, copy) void ( ^ ) ( PWDataFile *document , float progress ) onDocumentReceivingProgressDiscussion
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 ) onDocumentSendingProgressReturn 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)sharedInstanceReturn 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>)delegateParameters
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 *)configParameters
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>)delegateParameters
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)timeIntervalParameters
timeInterval |
A time interval, in |
|---|
Declared In
PWMediaSession.h
– stopCollectingStats
Disable timeInterval loop and stop collecting stats report.
- (void)stopCollectingStatsDeclared In
PWMediaSession.h
Text messaging
– sendMessage:
Send message to all participants in room.
- (void)sendMessage:(NSString *)messageParameters
message |
Your text message. |
|---|
Declared In
PWMediaSession.h
– sendMessage:toPeer:
Send private message in room.
- (void)sendMessage:(NSString *)message toPeer:(NSString *)peerIdParameters
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 *)streamIdParameters
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)lockRoomDiscussion
Warning: Only valid for room owner.
Declared In
PWMediaSession.h
– unlockRoom
Unlock room.
- (void)unlockRoomDiscussion
Warning: Only valid for room owner.
Declared In
PWMediaSession.h
Media
– switchCameraPosition:
Switch camera.
- (void)switchCameraPosition:(PWCameraPosition)positionParameters
position |
|
|---|
Declared In
PWMediaSession.h
– videoAuthorized
Check video access permission is allowed by user or not.
- (BOOL)videoAuthorizedReturn Value
Authorization status (BOOL)
Declared In
PWMediaSession.h
– audioAuthorized
Check audio access permission is allowed by user or not.
- (BOOL)audioAuthorizedReturn 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)idleTimerDisabledParameters
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)endCallDeclared In
PWMediaSession.h