• Skip to Search
  • Skip to Content
  • Skip to Side Navigation
Getting StartedSDK ReferenceGlossary
  • Home
  • Getting Started
  • SDK Reference
  • Portal
  • How-To
  • Troubleshooting
  • FAQs
  • Reference
  • Glossary
REST API
Web SDK
Android SDK
iOS SDK
Unity SDK
React Native SDK
EdgeAuth SDK
  • Overview
  • Quick Start
  • Usage

Usage

The plugin is implemented as static methods that can be called from Unity.

Initialization

Initialize Plugin

void Phenix.Init(ChannelExpressOptions options)

Initialize the plugin and create the ChannelExpress.

  • options parameter of type ChannelExpressOptions(required)

The plugin is initialized with ChannelExpressOptions wich can be created with a builder as shown in the following code snippet:

C#
1ChannelExpressOptions channelExpressOptions = new ChannelExpressOptions.ChannelExpressOptionsBuilder()
2 .WithBackendUri("https://example.yourdomain.com/phenix/")
3 .Build();
4Phenix.Init(channelExpressOptions);

Check if Already Intialized

bool Phenix.IsInitialized()

Check if the plugin has been intialized.

Channel Express APIs

Channel Express Options Builder

ChannelExpressOptions.ChannelExpressOptionsBuilder

  • WithBackendUri(string backendUri)(required) - URL to your backend. We send requests here to authenticate and get streaming tokens.
  • WithPCastUri(string pCastUri)(optional) - Allows overriding default PCast™ URI.
  • WithAuthenticationToken(string authenticationToken)(optional) - The authentication token generated using the Phenix EdgeAuth library.

Channel APIs

Join a Channel

string JoinChannel(JoinChannelOptions options)

Join a channel and automatically view the most recent content published to that channel.

  • options parameter of type JoinChannelOptions(required)
  • return the channel unique identifier
C#
1JoinChannelOptions joinChannelOptions = new JoinChannelOptions.JoinChannelOptionsBuilder()
2 .WithRoomAlias("MyAwesomeChannel")
3 .Build();
4string channelUuid = Phenix.JoinChannel(joinChannelOptions1);

Join Channel Options Builder

JoinChannelOptions.JoinChannelOptionsBuilder

  • WithRoomAlias(string roomAlias)(required)
  • WithCapabilities(string[] capabilities)(optional) - The list of all capabilities to subscribe with.
  • WithStreamToken(string streamToken)(optional) - alternative to room alias
  • WithStreamSelectionStrategy(StreamSelectionStrategy streamSelectionStrategy)(optional) - choose the stream selection strategy. Possible values are StreamSelectionStrategy.HIGH_AVAILABILITY or StreamSelectionStrategy.MOST_RECENT

Leave a Channel

void LeaveChannel(string uuid)

Leave a Channel and stop viewing of its published content.

  • uuid parameter of type string(required) - The channel unique identifier that the user wants to leave
C#
1string channelUuid = ... //obtained when joining a channel
2Phenix.LeaveChannel(channelUuid);

Check if a Specific Channel is Joined

bool IsChannelJoined(string uuid)

Check if the channel is joined.

  • uuid parameter of type string(required) - The channel unique identifier
C#
1string channelUuid = ... //obtained when joining a channel
2Phenix.IsChannelJoined(channelUuid)

Check if any Channel is Joined

bool IsJoined()

Check if any channel is joined.

C#
1Phenix.IsJoined()

Check if a Channel Exists

bool ChannelExists(string uuid)

Check if the channel exists.

  • uuid parameter of type string(required) - The channel unique identifier
C#
1string channelUuid = ... //obtained when joining a channel
2Phenix.ChannelExists(channelUuid)

Check Which Channels are Joined

string[] GetChannels()

Check which channels are currently joined.

  • return a list containing the channel unique identifiers for all the channels that are joined
C#
1string[] channels = Phenix.GetChannels();

Get the Published Content

Texture2D GetTexture(string uuid)

Get the texture that holds the published content.

  • uuid parameter of type string(required) - The channel unique identifier
  • return a texture of type Texture2D
C#
1// Script that is attached to a GameObject
2private void Awake ()
3{
4 string channelUuid = ... //obtained when joining a channel
5 rend = GetComponent<Renderer>();
6 rend.material.mainTexture = Phenix.GetTexture(uuid);
7}

Rejoin the Channel

void RejoinChannel(string uuid)

Rejoin the channel.

  • uuid parameter of type string(required) - The channel unique identifier
C#
1// Script that is attached to a GameObject
2private void Awake ()
3{
4 string channelUuid = ... //obtained when joining a channel
5 Phenix.RejoinChannel(channelUuid);
6}

Limit Channel Bandwidth

void SetBandwidthLimit(string uuid, PhenixDefinitionBandwidths bandwidth)

Limit the bandwidth of a channel.

  • uuid parameter of type string(required) - The channel unique identifier
  • bandwidth parameter of type PhenixDefinitionBandwidths(required) - The value to wich we want to limit the bandwidth
C#
1// Script that is attached to a GameObject
2private void Awake ()
3{
4 string channelUuid = ... //obtained when joining a channel
5 Phenix.SetBandwidthLimit(channelUuid, PhenixDefinitionBandwidths.PhenixStandardDefinitionBandwidth);
6}

Get the Channel Bandwidth Limit

PhenixDefinitionBandwidths GetBandwidthLimit(string uuid)

Get the channel bandwidth limit.

  • uuid parameter of type string(required) - The channel unique identifier
C#
1// Script that is attached to a GameObject
2private void Awake ()
3{
4 string channelUuid = ... //obtained when joining a channel
5 Phenix.GetBandwidthLimit(channelUuid);
6}

Flip the Channel Video Around its Axis

void SetTextureFlip(string uuid, PhenixTextureFlipAxis axisFlip)

Flip the video around its axis.

  • uuid parameter of type string(required) - The channel unique identifier
  • axisFlip parameter of type PhenixTextureFlipAxis(required) - The value that defines around which axis to flip the video.
C#
1// Script that is attached to a GameObject
2private void Awake ()
3{
4 string channelUuid = ... //obtained when joining a channel
5 SetTextureFlip(channelUuid, PhenixTextureFlipAxis.FlipUAxis);
6}

Get the Channel Flipped Axis

PhenixTextureFlipAxis GetTextureFlip(string uuid)

Get the axis around which the video is flipped.

  • uuid parameter of type string(required) - The channel unique identifier
C#
1// Script that is attached to a GameObject
2private void Awake ()
3{
4 string channelUuid = ... //obtained when joining a channel
5 Phenix.GetTextureFlip(channelUuid);
6}

Channel Callbacks

Channel Subscribe Events

OnSubscribeEvent(string uuid, PhenixRequestStatus requestStatus)

Triggered when a channel is joined or left.

C#
1Phenix.OnSubscribeEvent callback;
2
3private void Awake()
4{
5 callback = new Phenix.OnSubscribeEvent((uuid, status) =>
6 {
7 print("uuid:" + uuid);
8 print("status:" + status);
9 }
10 );
11 Phenix.OnSubscribeEvent += callback;
12}
13
14private void OnDestroy()
15{
16 // Cleanup callback to avoid leaks
17 Phenix.OnSubscribeEvent -= callback;
18}

Channel Join or Leave Detailed Event

OnJoinChannelEvent(string uuid, PhenixRequestStatus requestStatus)

Triggered when a channel is joined or left.

C#
1Phenix.OnJoinChannelEvent callback;
2
3private void Awake()
4{
5 callback = new Phenix.OnJoinChannelEvent((uuid, status) =>
6 {
7 print("uuid:" + uuid);
8 print("status:" + status);
9 }
10 );
11 Phenix.OnJoinChannelEvent += callback;
12}
13
14private void OnDestroy()
15{
16 // Cleanup callback to avoid leaks
17 Phenix.OnJoinChannelEvent -= callback;
18}

Unrecoverable Error Event

OnUnrecoverableErrorEvent(PhenixRequestStatus status, string description)

Triggered when an error occurs that the plugin can't recover from.

C#
1Phenix.OnUnrecoverableErrorEvent callback;
2
3private void Awake()
4{
5 callback = new Phenix.OnUnrecoverableErrorEvent(status =>
6 {
7 print("status:" + status);
8 }
9 );
10 Phenix.OnUnrecoverableErrorEvent += callback;
11}
12
13private void OnDestroy()
14{
15 // Cleanup callback to avoid leaks
16 Phenix.OnUnrecoverableErrorEvent -= callback;
17}

Channel Join or Leave Events

JoinEvent(bool joined)

Triggered when at least one channel is joined or the user leaves all the channels.

C#
1Phenix.JoinEvent callback;
2
3private void Awake()
4{
5 callback = new Phenix.JoinEvent(joined =>
6 {
7 print("At least one channel is joined:" + joined);
8 }
9 );
10 Phenix.OnJoinEvent += callback;
11}
12
13private void OnDestroy()
14{
15 // Cleanup callback to avoid leaks
16 Phenix.OnJoinEvent -= callback;
17}
Page Content
    Copyright 2023 © Phenix RTS
    Privacy Policy | Terms of Service
    v2023-01-31T21:25:10