by Pivec Labs
API Reference Voice & Video

API Reference

Namespace PivecLabs.Netcrafter.Live (assembly PivecLabs.NetCrafter.Live.Runtime, compiled only with com.unity.webrtc 3.0.0+).

01

NetCrafterLiveCall — fields#

Calls of 2–6 players in the same room. Add Component → NetCrafter → Live → Live Call.

FieldDefaultDescription
connectionOverride—ConnectionManager to use; empty = the scene's generated SmartFoxConnectionManager.
forceRelayoffSend everything through TURN (testing the relay path).
stripVideoRtxWorkaroundoffAndroid workaround if remote video stays black on some devices.
videoWebcamWebcam, RenderTexture (e.g. a game camera) or None (voice only).
customRenderTexture—Used when video is RenderTexture.
startWithCameraOffoffJoin with the camera disabled.
maxVideoBitrateKbps0 (auto)Per-peer limit. Auto: 1500 / 800 / 500 kbps by call size.
maxVideoFramerate24Per-peer frame rate limit.
sendAudioonSend the microphone.
microphoneDevice""Device name; empty = system default. The Console lists devices when a call starts.
microphoneAutoGain / microphoneGainon / 6Raises quiet microphones; silence is never boosted.
startMutedoffJoin muted.
pushToTalk / pushToTalkKeyoff / SpaceMicrophone live only while the key (or SetPushToTalkPressed(true)) is held.
voiceSpatialBlend1Used for players whose voice is attached to an avatar (see ResolveVoiceAnchor).
autoAcceptInvitesonJoin private calls automatically when invited.
02

NetCrafterLiveCall — methods and properties#

Method / propertyDescription
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, LocalUserIdCall state; Participants includes you.
IsMuted, IsCameraOn, IsPushToTalkPressed, LocalVideoLocal state.
03

NetCrafterLiveCall — events#

EventWhen
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.
04

NetCrafterLiveBroadcast#

One player streams, viewers in the same room watch. Can run next to a call (camera and microphone are shared).

MemberDescription
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), ViewersHost side viewer list.
LocalVideo, RemoteVideo, WatchState, IsHosting, IsWatching, WatchingHostIdState.
Fieldsvideo, customRenderTexture, sendAudio, microphone fields, maxVideoBitrateKbps (1200), maxVideoFramerate (30), viewerAudioSpatialBlend (0), forceRelay, allowHosting.
EventsBroadcastStarted, BroadcastStopped, ViewerJoined(int), ViewerLeft(int), ViewerStateChanged, LocalVideoAvailable, WatchStarted(int), WatchStopped(int), RemoteVideoAvailable(Texture), WatchStateChanged, ActiveBroadcastsChanged, ErrorOccurred.
06

NetCrafterLiveClient#

Created automatically (one per scene); you rarely need it directly.

MemberDescription
NetCrafterLiveClient.Ensure(MonoBehaviour connection = null)Gets/creates the client.
LocalUserId, IsReady, TurnAvailable, MaxCallSize, MaxViewersFrom the server handshake.
WhenReady(Action)Runs after the handshake (immediately if done).
Ready, RoomJoined, ConnectionLost, ErrorOccurredEvents.
BuildConfiguration(bool forceRelay)RTCConfiguration with the current ICE servers, for your own RTCPeerConnections.
07

INetCrafterSession#

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.

08

Error codes#

CodeMeaning / fix
server_outdatedThe zone extension doesn't include Live. Generate Server Code, Deploy, restart SFS3.
no_connectionNo ConnectionManager in the scene, or not logged in yet.
turn_not_configuredforceRelay is on but the server has no TURN settings.
turn_auth_failedNo relay connection: secret mismatch between coturn and NetCrafterLive.properties, wrong clock, or TURN ports blocked.
call_fullThe call (6) or broadcast (viewer cap) is full.
not_in_roomJoin an SFS3 room first (or the invited player isn't in yours).
permission_deniedPrivate call between other players, or hosting disabled.
not_foundThat broadcast is no longer running.
rate_limitedToo many signalling messages (protects your server).
mediaCamera/microphone problem (permission, device busy, unsupported texture format).
09

Server messages#

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.