PICO Platform Unity SDK
|
Public Member Functions | |
delegate int | ProcessAudioFrameFunction (RtcAudioFrame frame) |
Static Public Member Functions | |
static RtcEngineInitResult | InitRtcEngine () |
Initializes the RTC engine. More... | |
static Task< string > | GetToken (string roomId, string userId, int ttl, Dictionary< RtcPrivilege, int > privileges) |
Gets the token required by JoinRoom. More... | |
static int | JoinRoom (string roomId, string userId, string token, RtcRoomProfileType roomProfileType, bool isAutoSubscribeAudio) |
Joins a user to a specified room. More... | |
static int | JoinRoom2 (RtcRoomOptions joinRoomOptions, bool leaveIfInRoom=true) |
Joins a user to a room. More... | |
static int | JoinRoomWithRetry (string roomId, string userId, string token, RtcRoomProfileType roomProfileType, bool isAutoSubscribeAudio) |
Leaves a room and retries to join it when the previous request fails and returns error code -2 (the user is already in this room). More... | |
static int | LeaveRoom (string roomId) |
Leaves a specified room. More... | |
static void | SetAudioPlaybackDevice (RtcAudioPlaybackDevice device) |
Sets the audio playback device. More... | |
static void | RoomPauseAllSubscribedStream (string roomId) |
Unsubscribing from all the audio streams of a room, thereby making the local user unable to hear anything from the room. More... | |
static void | RoomResumeAllSubscribedStream (string roomId) |
Resubscribing to all the audio streams of a room, thereby making the local user hear the voice from every in-room user. More... | |
static void | RegisterLocalAudioProcessor (ProcessAudioFrameFunction processor, RtcAudioChannel channel, RtcAudioSampleRate sampleRate) |
Register local audio processor. You can use this function to modify the recorded audio. More... | |
static void | EnableAudioPropertiesReport (int interval) |
Enables audio properties report. Once enabled, you will regularly receive audio report data. More... | |
static void | PublishRoom (string roomId) |
Publishes the local audio stream to a room, thereby making the local user's voice heard by other in-room users. More... | |
static void | UnPublishRoom (string roomId) |
Stops publishing the local audio stream to a room, so other in-room users are unable to hear the local user's voice. More... | |
static void | DestroyRoom (string roomId) |
Destroys a specified room. The resources occupied by the room will be released after destruction. More... | |
static void | StartAudioCapture () |
Starts audio capture via the microphone. | |
static void | StopAudioCapture () |
Stops audio capture. | |
static void | SetCaptureVolume (int volume) |
Sets the volume of the captured audio. More... | |
static void | SetPlaybackVolume (int volume) |
Sets the playback volume. More... | |
static void | SetEarMonitorMode (RtcEarMonitorMode mode) |
Switches the in-ear monitoring mode on/off. Once the in-ear monitoring mode is enabled, one can hear their own voice. More... | |
static void | SetEarMonitorVolume (int volume) |
Sets the volume for in-ear monitoring. More... | |
static void | MuteLocalAudio (RtcMuteState rtcMuteState) |
Mutes local audio to make one's voice unable to be heard by other in-room users. More... | |
static void | UpdateToken (string roomId, string token) |
Updates the token in a room. More... | |
static void | SetAudioScenario (RtcAudioScenarioType scenarioType) |
Sets the audio scenario. More... | |
static void | RoomSetRemoteAudioPlaybackVolume (string roomId, string userId, int volume) |
Sets the volume for a remote user in a room. More... | |
static void | RoomSubscribeStream (string roomId, string userId) |
Subscribes to the audio stream of a specific user in a room. More... | |
static void | RoomUnSubscribeStream (string roomId, string userId) |
Unsubscribes from the audio stream of a specific user in a room. More... | |
static long | SendRoomBinaryMessage (string roomId, byte[] message) |
Sends a binary message to a room. All in-room users will receive this message. More... | |
static long | SendRoomMessage (string roomId, string message) |
Sends a text message to a room. All in-room users will receive this message. More... | |
static long | SendUserBinaryMessage (string roomId, string userId, byte[] message) |
Sends a binary message to a user. Only the user can receive this message. More... | |
static long | SendUserMessage (string roomId, string userId, string message) |
Sends a text message to a user. Only the user can receive this message. The message's bytes size shouldn't be greater than 64kB. More... | |
static int | SendStreamSyncInfo (byte[] data, int repeatCount) |
Sends stream sync info. The sync info data will be sent in the same packet with the audio data. Users who subscribe to this audio stream will receive the stream sync info message. More... | |
static void | SetOnTokenWillExpire (Message< string >.Handler handler) |
Sets the callback to get notified when the token is about to expire. More... | |
static void | SetOnRoomMessageReceived (Message< RtcRoomMessageReceived >.Handler handler) |
Sets the callback to get notified when a to-room message is received. More... | |
static void | SetOnRoomBinaryMessageReceived (Message< RtcBinaryMessageReceived >.Handler handler) |
Sets the callback to get notified when a to-room binary message is received. More... | |
static void | SetOnUserMessageReceived (Message< RtcUserMessageReceived >.Handler handler) |
Sets the callback to get notified when a to-user message is received. More... | |
static void | SetOnUserBinaryMessageReceived (Message< RtcBinaryMessageReceived >.Handler handler) |
Sets the callback to get notified when a to-user binary message is received. More... | |
static void | SetOnRoomMessageSendResult (Message< RtcMessageSendResult >.Handler handler) |
Sets the callback to get whether the to-room message is sent successfully. More... | |
static void | SetOnUserMessageSendResult (Message< RtcMessageSendResult >.Handler handler) |
Sets the callback to get whether the to-user message is sent successfully. More... | |
static void | SetOnUserPublishStream (Message< RtcUserPublishInfo >.Handler handler) |
Sets the callback to get notified when a remote user publishes audio stream. More... | |
static void | SetOnUserUnPublishStream (Message< RtcUserUnPublishInfo >.Handler handler) |
Sets the callback to get notified when a remote user cancels publishing audio stream. More... | |
static void | SetOnStreamSyncInfoReceived (Message< RtcStreamSyncInfo >.Handler handler) |
Sets the callback to get notified when the stream sync info is received. More... | |
static void | SetOnJoinRoomResultCallback (Message< RtcJoinRoomResult >.Handler handler) |
Sets the callback of JoinRoom to get RtcJoinRoomResult . More... | |
static void | SetOnLeaveRoomResultCallback (Message< RtcLeaveRoomResult >.Handler handler) |
Sets the callback of LeaveRoom to get RtcLeaveRoomResult . More... | |
static void | SetOnUserJoinRoomResultCallback (Message< RtcUserJoinInfo >.Handler handler) |
Sets the callback to get notified when someone has joined the room. More... | |
static void | SetOnUserLeaveRoomResultCallback (Message< RtcUserLeaveInfo >.Handler handler) |
Sets the callback to get notified when someone has left the room. More... | |
static void | SetOnRoomStatsCallback (Message< RtcRoomStats >.Handler handler) |
Sets the callback to regularly get room statistics after joining a room. More... | |
static void | SetOnWarnCallback (Message< int >.Handler handler) |
Sets the callback to get warning messages from the RTC engine. The warning codes and descriptions are given below. More... | |
static void | SetOnErrorCallback (Message< int >.Handler handler) |
Sets the callback to get error messages from the RTC engine. The error codes and descriptions are given below. More... | |
static void | SetOnRoomWarnCallback (Message< RtcRoomWarn >.Handler handler) |
Sets the callback to get warning messages from the room. More... | |
static void | SetOnRoomErrorCallback (Message< RtcRoomError >.Handler handler) |
Sets the callback to get error messages from the room. More... | |
static void | SetOnConnectionStateChangeCallback (Message< RtcConnectionState >.Handler handler) |
Sets the callback to get notified when the state of the connection to the RTC server has changed. More... | |
static void | SetOnUserMuteAudio (Message< RtcMuteInfo >.Handler handler) |
Sets the callback to get notified when the user has muted local audio. More... | |
static void | SetOnUserStartAudioCapture (Message< string >.Handler handler) |
Sets the callback to get notified when the user has started audio capture. More... | |
static void | SetOnUserStopAudioCapture (Message< string >.Handler handler) |
Sets the callback to get notified when the user has stopped audio capture. More... | |
static void | SetOnAudioPlaybackDeviceChange (Message< RtcAudioPlaybackDevice >.Handler handler) |
Sets the callback to get notified when the audio playback device has been changed. More... | |
static void | SetOnLocalAudioPropertiesReport (Message< RtcLocalAudioPropertiesReport >.Handler handler) |
Sets the callback to receive local audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport. More... | |
static void | SetOnRemoteAudioPropertiesReport (Message< RtcRemoteAudioPropertiesReport >.Handler handler) |
Sets the callback to receive remote audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport. More... | |
Real-time communications (RTC) technology enables users in the same room to communicate with each other through voice chat.
RTC service uses a centralized communication structure instead of an end-to-end one. After users have joined a room and enabled voice chat, the microphone keeps capturing audio data from users and uploading the data to the RTC server. Then, the RTC server transmits the audio data to each client in the room, and the client broadcasts the audio data received.
|
inlinestatic |
Initializes the RTC engine.
|
inlinestatic |
Gets the token required by JoinRoom.
roomId | The ID of the room that the token is for. |
userId | The ID of the user that the token is for. |
ttl | The time-to-live (ttl) of the token. The unit is seconds. The user will be kicked out from the room after ttl seconds. |
privileges | The dictionary that maps privilege to ttl. The unit is seconds. |
|
inlinestatic |
Joins a user to a specified room.
0
is returned, you should use SetOnJoinRoomResultCallback to handle the final join room result.roomId | The ID of the room to join. |
userId | The ID of user. |
token | The token required for joining the room. You can get the token by calling GetToken. |
roomProfileType | Room type:
|
isAutoSubscribeAudio | Whether to automatically subscribe to the audio in the room:
|
0
indicates success, and other codes indicate failure. Code | Description |
---|---|
0 | Success. |
-1 | Invalid roomID or userId . |
-2 | The user is already in this room. |
-3 | The RTC engine is null. You should initialize the RTC engine before joining a room. |
-4 | Creating the room failed. |
|
inlinestatic |
Joins a user to a room.
joinRoomOptions | The options to join a room. |
leaveIfInRoom | Retry to join the room if the request returns error code -2 (the user is already in the room). |
0
indicates success, and other codes indicate failure. Code | Description |
---|---|
0 | Success. |
-1 | Invalid roomID or userId . |
-2 | The user is already in this room. |
-3 | The RTC engine is null. You should initialize the RTC engine before joining a room. |
-4 | Creating the room failed. |
|
inlinestatic |
Leaves a room and retries to join it when the previous request fails and returns error code -2
(the user is already in this room).
roomId | The ID of the room to join. |
userId | The ID of user. |
token | The token required for joining the room. You can get the token by calling GetToken . |
roomProfileType | Room type:
|
isAutoSubscribeAudio | Whether to automatically subscribe to the audio in the room:
|
0
indicates success, and other codes indicate failure. Code | Description |
---|---|
0 | Success. |
-1 | Invalid roomID or userId . |
-2 | The user is already in this room. |
-3 | The RTC engine is null. You should initialize the RTC engine before joining a room. |
-4 | Creating the room failed. |
|
inlinestatic |
Leaves a specified room.
roomId | The ID of the room to leave. |
0
indicates success, and other codes indicate failure.
Code | Description |
---|---|
0 | Success. |
-1 | The RTC engine is not initialized. |
-2 | The user is not in the room. |
|
inlinestatic |
Sets the audio playback device.
device | The device ID. |
|
inlinestatic |
Unsubscribing from all the audio streams of a room, thereby making the local user unable to hear anything from the room.
roomId | The ID of the room whose audio streams are to be unsubscribed from. |
|
inlinestatic |
Resubscribing to all the audio streams of a room, thereby making the local user hear the voice from every in-room user.
roomId | The ID of the room whose audio streams are to be resubscribed to. |
|
inlinestatic |
Register local audio processor. You can use this function to modify the recorded audio.
processor | The processor function. If it returns 0,means the function didn't change the data. If its return value is negative integer, means the function encounters error. If its return value is positive integer, means the function handled successfully. |
channel | The channel of the audio you want to process. |
sampleRate | The sample rate of the audio you want to process. |
|
inlinestatic |
Enables audio properties report. Once enabled, you will regularly receive audio report data.
interval | The interval (in milliseconds) between one report and the next. You can set this parameter to 0 or any negative integer to stop receiving audio properties report. For any integer between (0, 100), the SDK will regard it as invalid and automatically set this parameter to 100 ; any integer equal to or greater than 100 is valid. |
|
inlinestatic |
Publishes the local audio stream to a room, thereby making the local user's voice heard by other in-room users.
UnPublishRoom(oldRoomId)
should be called first to stop publishing the local audio stream to the current room and then Publish(newRoomId)
should be called. roomId | The ID of the room that the local audio stream is published to. |
|
inlinestatic |
Stops publishing the local audio stream to a room, so other in-room users are unable to hear the local user's voice.
roomId | The ID of the room to stop publishing the local audio stream to. |
|
inlinestatic |
Destroys a specified room. The resources occupied by the room will be released after destruction.
roomId | The ID of the room to destroy. |
|
inlinestatic |
Sets the volume of the captured audio.
volume | The target volume. The valid value ranges from 0 to 400 . 100 indicates keeping the original volume. |
|
inlinestatic |
Sets the playback volume.
volume | The target volume. The valid value ranges from 0 to 400 . 100 indicates keeping the original volume. |
|
inlinestatic |
Switches the in-ear monitoring mode on/off. Once the in-ear monitoring mode is enabled, one can hear their own voice.
mode | Whether to switch the in-ear monitoring mode on/off:
|
|
inlinestatic |
Sets the volume for in-ear monitoring.
volume | The target volume. The valid value range from 0 to 400 . |
|
inlinestatic |
Mutes local audio to make one's voice unable to be heard by other in-room users.
rtcMuteState | The state of local audio:
|
|
inlinestatic |
Updates the token in a room.
When a token's ttl is about to expire, you will receive a notification through SetOnTokenWillExpire. If you still want to stay in the room, you should call GetToken to get a new token and call UpdateToken with the new token. If you don't update token timely,you will be kicked out from the room.
roomId | The ID of the room you are in. |
token | The token to update. |
|
inlinestatic |
Sets the audio scenario.
scenarioType | The audio scenario type:
|
|
inlinestatic |
Sets the volume for a remote user in a room.
roomId | The ID of the room. |
userId | The ID of the remote user. |
volume | The volume to set for the remote user, which ranges from 0 to 400 and 100 indicates the default volume. |
|
inlinestatic |
Subscribes to the audio stream of a specific user in a room.
roomId | The ID of the room. |
userId | The ID of the user in the room. |
|
inlinestatic |
Unsubscribes from the audio stream of a specific user in a room.
roomId | The ID of the room. |
userId | The ID of the user in the room. |
|
inlinestatic |
Sends a binary message to a room. All in-room users will receive this message.
The message's bytes size shouldn't be greater than 64kB.
roomId | The ID of the room. |
message | The binary message to be sent. |
|
inlinestatic |
Sends a text message to a room. All in-room users will receive this message.
The message's bytes size shouldn't be greater than 64kB.
roomId | The ID of the room. |
message | The message to be sent. |
|
inlinestatic |
Sends a binary message to a user. Only the user can receive this message.
The message's bytes size shouldn't be greater than 64kB.
roomId | The ID of the room the user is in. |
userId | The ID of the user the message is sent to. |
message | The message to be sent. |
|
inlinestatic |
Sends a text message to a user. Only the user can receive this message. The message's bytes size shouldn't be greater than 64kB.
roomId | The ID of the room the user is in. |
userId | The ID of the user the message is sent to. |
message | The message to be sent. |
|
inlinestatic |
Sends stream sync info. The sync info data will be sent in the same packet with the audio data. Users who subscribe to this audio stream will receive the stream sync info message.
data | The stream sync info. |
repeatCount | The stream sync info will be sent repeatedly for the times set in repeatCount . It's designed to avoid losing package and ensuring that the sync info can be sent successfully. However, if repeatCount is too large, it will cause the sync info to pile up in the queue. Setting this parameter to 0 is recommended. |
0
indicates success, and others codes indicate failure. Code | Description |
---|---|
>=0 | Send successfully.Indicates the times sent successfully. |
-1 | Send Failed. Message length exceeded 255B |
-2 | Send Failed. The data is empty. |
-3 | Send Failed. Send sync info with a un-publish screen stream. |
-4 | Send Failed. Send sync info with a un-publish audio stream. |
|
inlinestatic |
Sets the callback to get notified when the token is about to expire.
UpdateToken
.handler | The callback function, the string in the message indicates the room ID. |
|
inlinestatic |
Sets the callback to get notified when a to-room message is received.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when a to-room binary message is received.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when a to-user message is received.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when a to-user binary message is received.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get whether the to-room message is sent successfully.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get whether the to-user message is sent successfully.
handler |
|
inlinestatic |
Sets the callback to get notified when a remote user publishes audio stream.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when a remote user cancels publishing audio stream.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when the stream sync info is received.
handler | The callback handler. |
|
inlinestatic |
Sets the callback of JoinRoom
to get RtcJoinRoomResult
.
handler | The callback handler. |
|
inlinestatic |
Sets the callback of LeaveRoom
to get RtcLeaveRoomResult
.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when someone has joined the room.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when someone has left the room.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to regularly get room statistics after joining a room.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get warning messages from the RTC engine. The warning codes and descriptions are given below.
Warning Code | Description |
---|---|
-2001 | Joining the room failed. |
-2002 | Publishing audio stream failed. |
-2003 | Subscribing to the audio stream failed because the stream cannot be found. |
-2004 | Subscribing to the audio stream failed due to server error. |
-2013 | When the people count in the room exceeds 500, the client will not be informed of user join and leave info anymore. |
-5001 | The camera permission is missing. |
-5002 | The microphone permission is missing. |
-5003 | Starting the audio capture device failed. |
-5004 | Starting the audio playback device failed. |
-5005 | No available audio capture device. |
-5006 | No available audio playback device. |
-5007 | The audio capture device failed to capture valid audio data. |
-5008 | Invalid media device operation. |
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get error messages from the RTC engine. The error codes and descriptions are given below.
Error Code | Description |
---|---|
-1000 | Invalid token. |
-1001 | Unknown error. |
-1002 | No permission to publish audio stream. |
-1003 | No permission to subscribe audio stream. |
-1004 | A user with the same user Id joined this room. You are kicked out of the room. |
-1005 | Incorrect configuration on the Developer Platform. |
-1007 | Invalid room id. |
-1009 | Token expired. You should get a new token and join the room. |
-1010 | Token is invalid when you call UpdateToken |
-1011 | The room is dismissed and all user is moved out from the room. |
-1070 | Subscribing to audio stream failed. Perhaps the number of subscribed audio streams has exceeded the limit. |
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get warning messages from the room.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get error messages from the room.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when the state of the connection to the RTC server has changed.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when the user has muted local audio.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when the user has started audio capture.
When a remote user called StartAudioCapture,RTC engine will call this callback.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when the user has stopped audio capture.
When a remote user called StopAudioCapture,RTC engine will call this callback.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to get notified when the audio playback device has been changed.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to receive local audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport.
handler | The callback handler. |
|
inlinestatic |
Sets the callback to receive remote audio report. Rtc engine will call this callback periodically once you call EnableAudioPropertiesReport.
handler | The callback handler. |