API Reference
Namespace PivecLabs.Netcrafter.Live (assembly PivecLabs.NetCrafter.Live.Runtime, compiled only with com.unity.webrtc 3.0.0+).
01NetCrafterLiveCall — fields#
Calls of 2–6 players in the same room. Add Component → NetCrafter → Live → Live Call.
| Field | Default | Description |
|---|
connectionOverride | — | ConnectionManager to use; empty = the scene's generated SmartFoxConnectionManager. |
forceRelay | off | Send everything through TURN (testing the relay path). |
stripVideoRtxWorkaround | off | Android workaround if remote video stays black on some devices. |
video | Webcam | Webcam, RenderTexture (e.g. a game camera) or None (voice only). |
customRenderTexture | — | Used when video is RenderTexture. |
startWithCameraOff | off | Join with the camera disabled. |
maxVideoBitrateKbps | 0 (auto) | Per-peer limit. Auto: 1500 / 800 / 500 kbps by call size. |
maxVideoFramerate | 24 | Per-peer frame rate limit. |
sendAudio | on | Send the microphone. |
microphoneDevice | "" | Device name; empty = system default. The Console lists devices when a call starts. |
microphoneAutoGain / microphoneGain | on / 6 | Raises quiet microphones; silence is never boosted. |
startMuted | off | Join muted. |
pushToTalk / pushToTalkKey | off / Space | Microphone live only while the key (or SetPushToTalkPressed(true)) is held. |
voiceSpatialBlend | 1 | Used for players whose voice is attached to an avatar (see ResolveVoiceAnchor). |
autoAcceptInvites | on | Join private calls automatically when invited. |
02NetCrafterLiveCall — methods and properties#
| Method / property | Description |
|---|
JoinRoomCall() | Join the room's shared call (id "room"). |
JoinCall(string callId) | Join or create a named call in the room, e.g. a team channel. |
InviteToPrivateCall(int userId) | Start a private 1-to-1 call with a player in your room. |
Leave() | Hang up. |
SetMicrophoneMuted(bool) / SetCameraEnabled(bool) | Instant, no renegotiation. |
SetPushToTalkPressed(bool) | For an on-screen push-to-talk button. |
ResolveVoiceAnchor (Func<int, Transform>) | Return a player's avatar to make their voice positional; RefreshVoiceAnchors() re-applies it. |
GetRemoteVideo(int) / GetPeerState(int) / GetParticipantName(int) | Per-participant texture, connection state and login name. |
CurrentCallId, InCall, Participants, LocalUserId | Call state; Participants includes you. |
IsMuted, IsCameraOn, IsPushToTalkPressed, LocalVideo | Local state. |
03NetCrafterLiveCall — events#
| Event | When |
|---|
Joined(string callId) / Left() | You joined / left a call. |
ParticipantJoined(int) / ParticipantLeft(int) | Someone joined / left your call. |
RemoteVideoAvailable(int userId, Texture) | First frame from a participant (the texture keeps updating). |
LocalVideoAvailable(Texture) | Your own camera/RenderTexture is ready. |
PeerStateChanged(int, RTCPeerConnectionState) | Connecting / Connected / Disconnected / Failed per participant. |
InviteReceived(int fromUserId, string fromName, string callId) | Another player invited you to a private call. |
ErrorOccurred(string code, string message) | See error codes below. |
04NetCrafterLiveBroadcast#
One player streams, viewers in the same room watch. Can run next to a call (camera and microphone are shared).
| Member | Description |
|---|
StartBroadcast() / StopBroadcast() | Go live / stop. Refused when allowHosting is off (viewer-only builds). |
Watch(int hostId) / StopWatching() | Watch a broadcast in your room. |
ActiveBroadcasts (hostId → name), RefreshActiveBroadcasts() | Who is live in the room; ActiveBroadcastsChanged fires when it changes. |
SetOutgoingAudioSource(AudioSource) | Send this AudioSource (e.g. a video's sound) instead of the microphone; it keeps playing locally. |
RemoveViewer(int), Viewers | Host side viewer list. |
LocalVideo, RemoteVideo, WatchState, IsHosting, IsWatching, WatchingHostId | State. |
| Fields | video, customRenderTexture, sendAudio, microphone fields, maxVideoBitrateKbps (1200), maxVideoFramerate (30), viewerAudioSpatialBlend (0), forceRelay, allowHosting. |
| Events | BroadcastStarted, BroadcastStopped, ViewerJoined(int), ViewerLeft(int), ViewerStateChanged, LocalVideoAvailable, WatchStarted(int), WatchStopped(int), RemoteVideoAvailable(Texture), WatchStateChanged, ActiveBroadcastsChanged, ErrorOccurred. |
05NetCrafterLiveRoomLink#
| Field | Description |
|---|
call, callId | Joins this call (default "room") when the game joins its room. Found on the same GameObject if empty. |
broadcast, broadcastMode | None, StartBroadcasting or WatchFirstBroadcast on room join. |
Created automatically (one per scene); you rarely need it directly.
| Member | Description |
|---|
NetCrafterLiveClient.Ensure(MonoBehaviour connection = null) | Gets/creates the client. |
LocalUserId, IsReady, TurnAvailable, MaxCallSize, MaxViewers | From the server handshake. |
WhenReady(Action) | Runs after the handshake (immediately if done). |
Ready, RoomJoined, ConnectionLost, ErrorOccurred | Events. |
BuildConfiguration(bool forceRelay) | RTCConfiguration with the current ICE servers, for your own RTCPeerConnections. |
Implemented by the generated SmartFoxConnectionManager (namespace PivecLabs.Netcrafter): LocalUserId, LocalUserName, ConnectAndLogin(string name). Lets code in your own assemblies log in without referencing generated code. Managers generated before this version don't implement it — regenerate client code.
| Code | Meaning / fix |
|---|
server_outdated | The zone extension doesn't include Live. Generate Server Code, Deploy, restart SFS3. |
no_connection | No ConnectionManager in the scene, or not logged in yet. |
turn_not_configured | forceRelay is on but the server has no TURN settings. |
turn_auth_failed | No relay connection: secret mismatch between coturn and NetCrafterLive.properties, wrong clock, or TURN ports blocked. |
call_full | The call (6) or broadcast (viewer cap) is full. |
not_in_room | Join an SFS3 room first (or the invited player isn't in yours). |
permission_denied | Private call between other players, or hosting disabled. |
not_found | That broadcast is no longer running. |
rate_limited | Too many signalling messages (protects your server). |
media | Camera/microphone problem (permission, device busy, unsupported texture format). |
All Live traffic uses extension requests prefixed __ncl_, handled by NetCrafterLiveServer.java in your zone extension: __ncl_hello (handshake), __ncl_turn (TURN login), __ncl_join/__ncl_leave/__ncl_call (membership), __ncl_sig (offer/answer/ICE, relayed only between members of the same call, ≤16 KB, rate-limited), __ncl_invite, __ncl_bcast_* (broadcasts). Don't use the __ncl_ prefix for your own messages.