Android SDK API Reference

Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
io.skyway.Peer.MediaConnection Class Reference

Alternative class as MediaConnection. More...

Inherits io.skyway.Peer.BaseConnection.

Classes

enum  MediaEventEnum
 Media event type. More...
 

Public Member Functions

void on (MediaEventEnum event, OnCallback callback)
 Set callbacks for media connection events. More...
 
void answer (MediaStream stream, AnswerOption option)
 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 MediaStream and options. More...
 
void answer (MediaStream 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 with MediaStream. 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 close ()
 Closes the MediaConnection. More...
 
void close (boolean forceClose)
 Closes the MediaConnection with the forceClose option. More...
 
void replaceStream (MediaStream stream)
 Change the MediaStream that is being sent. More...
 
void getStats (StatsCollectorCallback callback)
 Get statistics of the connection. More...
 
String peer ()
 Get a peer ID. More...
 
String type ()
 Get a connection type. More...
 
String label ()
 Get a connection's label. More...
 
boolean isOpen ()
 Get a connection open status. More...
 
String connectionId ()
 Connection ID. More...
 
String metadata ()
 Metadata string. More...
 
void finalize ()
 
final Object peerConnection ()
 
boolean reliable ()
 Data channel reliable. More...
 
SerializationEnum serialization ()
 Data channel serialization type. More...
 
Peer provider ()
 Parent Peer object. More...
 
final String browser ()
 
final Peer.PeerTypeEnum serverType ()
 

Static Public Member Functions

static String getSerialization (SerializationEnum type)
 Convert serialization enum type to string. More...
 
static SerializationEnum getSerializationEnum (String type)
 Convert string to serialization enum type. More...
 

Static Public Attributes

static final String TYPE_DATA = "data"
 
static final String TYPE_MEDIA = "media"
 
static final String SERIALIZATION_BINARY = "binary"
 
static final String SERIALIZATION_BINARY_UTF8 = "binary-utf8"
 
static final String SERIALIZATION_JSON = "json"
 
static final String SERIALIZATION_NONE = "none"
 

Detailed Description

Alternative class as MediaConnection.

Member Function Documentation

◆ answer() [1/3]

void io.skyway.Peer.MediaConnection.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 peer;
peer.on(Peer.PeerEventEnum.CALL, new OnCallback() {
@Override
public void onCallback(Object object) {
media = (MediaConnection)object;
media.answer();
}
});

◆ answer() [2/3]

void io.skyway.Peer.MediaConnection.answer ( MediaStream  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 with MediaStream.

Peer peer;
MediaConnection media;
Navigator.initialize(peer);
MediaConstraints constraints = new MediaConstraints();
MediaStream stream = Navigator.getUserMedia(constraints);
peer.on(Peer.PeerEventEnum.CALL, new OnCallback() {
@Override
public void onCallback(Object object) {
media = (MediaConnection)object;
media.answer(stream);
}
});
Parameters
streamMediaStream

◆ answer() [3/3]

void io.skyway.Peer.MediaConnection.answer ( MediaStream  stream,
AnswerOption  option 
)

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 MediaStream and options.

Peer peer;
MediaConnection media;
Navigator.initialize(peer);
MediaConstraints constraints = new MediaConstraints();
MediaStream stream = Navigator.getUserMedia(constraints);
peer.on(Peer.PeerEventEnum.CALL, new OnCallback() {
@Override
public void onCallback(Object object) {
media = (MediaConnection)object;
AnswerOption options = new AnswerOption();
options.videoBandwidth = 1024;
options.audioBandwidth = 128;
options.videoCodec = "H264";
options.audioCodec = "PCMU"
media.answer(stream, options);
}
});
Parameters
streamMediaStream
optionAnswer Options

◆ browser()

final String io.skyway.Peer.BaseConnection.browser ( )
inherited

◆ close() [1/2]

void io.skyway.Peer.MediaConnection.close ( )

Closes the MediaConnection.

Run the forceClose option as false. May be changed to true from a future version.

MediaConnection media;
media.close();
media = null;

◆ close() [2/2]

void io.skyway.Peer.MediaConnection.close ( boolean  forceClose)

Closes the MediaConnection with the forceClose option.

MediaConnection media;
media.close(true);
media = null;
Parameters
forceCloseSet to true and the connection on remote peer will close immediately. When set to false, the connection on remote peer will close after the end of the ICE reconnect by the browser.

◆ connectionId()

String io.skyway.Peer.MediaConnection.connectionId ( )

Connection ID.

Returns
Connection ID.

◆ getSerialization()

static String io.skyway.Peer.BaseConnection.getSerialization ( SerializationEnum  type)
staticinherited

Convert serialization enum type to string.

Parameters
typeserialization enum type
Returns
serialization type string
See also
#getSerializationEnum(String)

◆ getSerializationEnum()

static SerializationEnum io.skyway.Peer.BaseConnection.getSerializationEnum ( String  type)
staticinherited

Convert string to serialization enum type.

Parameters
typeserialization type string
Returns
serialization enum type
See also
#getSerialization(SerializationEnum)

◆ getStats()

void io.skyway.Peer.MediaConnection.getStats ( StatsCollectorCallback  callback)

Get statistics of the connection.

MediaConnection connection;
connection.getStats(new StatsCollectorCallback() {
@Override
public void onStatsDelivered(JSONArray stats) {
// Do something
}
});
Parameters
callbackCallback.

◆ isOpen()

boolean io.skyway.Peer.MediaConnection.isOpen ( )

Get a connection open status.

Returns
Connection open status.

◆ label()

String io.skyway.Peer.MediaConnection.label ( )

Get a connection's label.

Returns
Connection label.

◆ metadata()

String io.skyway.Peer.MediaConnection.metadata ( )

Metadata string.

Returns
Metadata string.

◆ on()

void io.skyway.Peer.MediaConnection.on ( MediaEventEnum  event,
OnCallback  callback 
)

Set callbacks for media connection events.

MediaConnection media;
media.on(MediaConnection.MediaEventEnum.STREAM, new OnCallback() {
@Override
public void onCallback(Object object) {
MediaStream stream = (MediaStream *)object;
}
});
media.on(MediaConnection.MediaEventEnum.REMOVE_STREAM, new OnCallback() {
@Override
public void onCallback(Object object) {
MediaStream stream = (MediaStream *)object;
}
});
media.on(MediaConnection.MediaEventEnum.CLOSE, new OnCallback() {
@Override
public void onCallback(Object object) {
// 処理を記述
}
});
media.on(MediaConnection.MediaEventEnum.ERROR, new OnCallback() {
@Override
public void onCallback(Object object) {
PeerError error = (PeerError)object;
// 処理を記述
}
});
Parameters
eventMedia connection event type to watch
callbackCallback

◆ peer()

String io.skyway.Peer.MediaConnection.peer ( )

Get a peer ID.

Returns
Peer ID.

◆ peerConnection()

final Object io.skyway.Peer.BaseConnection.peerConnection ( )
inherited

◆ provider()

Peer io.skyway.Peer.BaseConnection.provider ( )
inherited

Parent Peer object.

Returns
Parent Peer object.

◆ reliable()

boolean io.skyway.Peer.BaseConnection.reliable ( )
inherited

Data channel reliable.

Returns
Data channel reliable.

◆ replaceStream()

void io.skyway.Peer.MediaConnection.replaceStream ( MediaStream  stream)

Change the MediaStream that is being sent.

For example, you can use it to change the camera device or the image quality.

Note: It is not possible to change the state of a MediaStream from not sending to sending.You cannot change the state of MediaStream from not sending to sending and vice versa.
It is also not possible to interchange "MediaStream with either video or audio only" and "MediaStream with both video and audio".

MediaConnection media;
MediaStream stream;
media.replaceStream(stream);
Parameters
streamThe stream to replace the old stream with.

◆ serialization()

SerializationEnum io.skyway.Peer.BaseConnection.serialization ( )
inherited

Data channel serialization type.

Returns
Data channel serialization type.

◆ serverType()

final Peer.PeerTypeEnum io.skyway.Peer.BaseConnection.serverType ( )
inherited

◆ type()

String io.skyway.Peer.MediaConnection.type ( )

Get a connection type.

Returns
Connection type.
io.skyway.Peer.MediaConnection.peer
String peer()
Get a peer ID.
Definition: MediaConnection.java:366