iOS SDK API Reference

Instance Methods | Properties | List of all members
SKWMediaConnection Class Reference

Alternative class as MediaConnection. More...

#import <SKWMediaConnection.h>

Inheritance diagram for SKWMediaConnection:
SKWConnection

Instance Methods

(void) - answer
 When receiving a call event on a peer, you can call .answer on the media connection provided by the callback to accept the call. More...
 
(void) - answer:
 When receiving a call event on a peer, you can call .answer on the media connection provided by the callback to accept the call. More...
 
(void) - answer:options:
 When receiving a call event on a peer, you can call .answer on the media connection provided by the callback to accept the call with options. More...
 
(void) - close
 Closes the media connection. More...
 
(void) - on:callback:
 Set callbacks for media connection events. More...
 
(void) - replaceStream:
 
(void) - getStats:
 Get statistics of the connection. More...
 

Properties

NSString *__nullable connectionId
 Connection ID.
 
NSString *__nullable metadata
 Any type of metadata associated with the connection, passed in by whoever initiated the connection.
 
BOOL isOpen
 This is true if the connection is open and ready for read/write.
 
NSString *__nullable peer
 The ID of the peer on the other end of this connection.
 
NSString *__nullable type
 For type of connection.
 
NSString *__nullable label
 The optional label passed in or assigned by PeerJS when the connection was initiated.
 
BOOL reliable
 Whether the underlying data channels are reliable; defined when the connection was initiated.
 
SKWSerializationEnum serialization
 The serialization format of the data sent over the connection. More...
 
SKWPeer *__nullable provider
 Provider PeerObjC object.
 

Detailed Description

Alternative class as MediaConnection.

Method Documentation

◆ answer

- (void) answer

When receiving a call event on a peer, you can call .answer on the media connection provided by the callback to accept the call.

[peer on:SKW_PEER_EVENT_CALL callback:^(NSObject* obj) {
[media answer];
}];

◆ answer:

- (void) answer: (SKWMediaStream *__nullable)  stream

When receiving a call event on a peer, you can call .answer on the media connection provided by the callback to accept the call.

SKWMediaConstraints* constraints = [[SKWMediaConstraints alloc] init];
SKWMediaStream* stream = [SKWNavigator getUserMedia:constraints];
[peer on:SKW_PEER_EVENT_CALL callback:^(NSObject* obj) {
SKWMediaConnection* media = (SKWMediaConnection *)obj;
[media answer:stream];
}];
Parameters
streamVideo stream

◆ answer:options:

- (void) answer: (SKWMediaStream *__nullable)  stream
options: (SKWAnswerOption *__nullable)  options 

When receiving a call event on a peer, you can call .answer on the media connection provided by the callback to accept the call with options.

SKWMediaConstraints* constraints = [[SKWMediaConstraints alloc] init];
SKWMediaStream* stream = [SKWNavigator getUserMedia:constraints];
[peer on:SKW_PEER_EVENT_CALL callback:^(NSObject* obj) {
SKWMediaConnection* media = (SKWMediaConnection *)obj;
SKWAnswerOption* options = [[SKWAnswerOption alloc] init];
options.videoBandwidth = 768;
options.audioBandwidth = 64;
[media answer:stream options:options];
}];
Parameters
streamVideo stream
optionsAnswer Options

◆ close

- (void) close

Closes the media connection.

[media close];
media = nil;

◆ getStats:

- (void) getStats: (SKWConnectionGetStatsCallback __nullable)  callback

Get statistics of the connection.

Parameters
callbackCallback block literal
SKWMediaConnection *connection;
[connection getStats:^(NSArray * _Nullable stats) {
// Do something
}];

◆ on:callback:

- (void) on: (SKWMediaConnectionEventEnum event
callback: (SKWMediaConnectionEventCallback __nullable)  callback 

Set callbacks for media connection events.

(Block Literal Syntax)

[media on:SKW_MEDIACONNECTION_EVENT_STREAM callback:^(NSObject* obj) {
SKWMediaStream *stream = (SKWMediaStream *)obj;
}];
[media on:SKW_MEDIACONNECTION_EVENT_REMOVE_STREAM callback:^(NSObject* obj) {
SKWMediaStream *stream = (SKWMediaStream *)obj;
}];
[media on:SKW_MEDIACONNECTION_EVENT_CLOSE callback:^(NSObject* obj) {
// クローズ時の処理を記述
}];
[media on:SKW_MEDIACONNECTION_EVENT_ERROR callback:^(NSObject* obj) {
SKWPeerError* err = (SKWPeerError*)obj;
NSLog(@"%@", err);
}];
Parameters
eventEvent type
callbackCallback block literal

◆ replaceStream:

- (void) replaceStream: (SKWMediaStream *__nullable)  newStream
SKWMediaConnection* connection;
[connection replaceStream:stream];
Parameters
newStream

Property Documentation

◆ serialization

- (SKWSerializationEnum) serialization
readnonatomicassigninherited

The serialization format of the data sent over the connection.

Can be binary (default), binary-utf8, json, or none.

-[SKWPeer on:callback:]
void on:callback:(SKWPeerEventEnum event,[callback] SKWPeerEventCallback __nullable callback)
Set blocks for peer events.
-[SKWMediaConnection replaceStream:]
void replaceStream:(SKWMediaStream *__nullable newStream)
SKWPeerError
Error information class.
Definition: SKWPeerError.h:55
SKWPeer
A peer class.
Definition: SKWPeer.h:98
SKWMediaStream
Media stream.
Definition: SKWMediaStream.h:18
SKWMediaConnection
Alternative class as MediaConnection.
Definition: SKWMediaConnection.h:52
SKWNavigator
Alternative class as browser navigator.
Definition: SKWNavigator.h:18
SKWMediaConstraints
Media constraints class.
Definition: SKWMediaConstraints.h:49
+[SKWNavigator initialize:]
void initialize:(SKWPeer *__nonnull peer)
Initialize navigator.
SKWAnswerOption
SKWMediaConnection answer Option.
Definition: SKWAnswerOption.h:14
-[SKWMediaConnection close]
void close()
Closes the media connection.
-[SKWMediaConnection on:callback:]
void on:callback:(SKWMediaConnectionEventEnum event,[callback] SKWMediaConnectionEventCallback __nullable callback)
Set callbacks for media connection events.
SKWConnection::peer
NSString *__nullable peer
The ID of the peer on the other end of this connection.
Definition: SKWConnection.h:87
+[SKWNavigator getUserMedia:]
SKWMediaStream *__nullable getUserMedia:(SKWMediaConstraints *__nonnull constraints)
Get video stream.
-[SKWConnection getStats:]
void getStats:(SKWConnectionGetStatsCallback __nullable callback)
Get statistics of the connection.