Skip to content

Instantly share code, notes, and snippets.

View icywind's full-sized avatar

Rick Cheng icywind

View GitHub Profile
@icywind
icywind / AgoraDemo_JoinLeave.cs
Created August 24, 2020 22:53
Demo Join and Leave implementation
void Join()
{
mRtcEngine.EnableVideo();
mRtcEngine.EnableVideoObserver();
myView.SetEnable(true);
mRtcEngine.JoinChannel(ChannelName, "", 0);
}
void Leave()
{
void OnApplicationQuit()
{
if (mRtcEngine != null)
{
IRtcEngine.Destroy();
mRtcEngine = null;
}
}
void OnJoinChannelSuccessHandler(string channelName, uint uid, int elapsed)
{
// can add other logics here, for now just print to the log
Debug.LogFormat("Joined channel {0} successful, my uid = {1}", channelName, uid);
}
void OnLeaveChannelHandler(RtcStats stats)
{
myView.SetEnable(false);
if (remoteView != null)
void SetupAgora()
{
mRtcEngine = IRtcEngine.GetEngine(AppID);
mRtcEngine.OnUserJoined = OnUserJoined;
mRtcEngine.OnUserOffline = OnUserOffline;
mRtcEngine.OnJoinChannelSuccess = OnJoinChannelSuccessHandler;
mRtcEngine.OnLeaveChannel = OnLeaveChannelHandler;
}
void SetupUI()
{
GameObject go = GameObject.Find("MyView");
myView = go.AddComponent<VideoSurface>();
go = GameObject.Find("LeaveButton");
go?.GetComponent<Button>()?.onClick.AddListener(Leave);
go = GameObject.Find("JoinButton");
go?.GetComponent<Button>()?.onClick.AddListener(Join);
}
public string AppID;
public string ChannelName;
VideoSurface myView;
VideoSurface remoteView;
IRtcEngine mRtcEngine;
void Awake()
{
// SetupUI();
@icywind
icywind / AgoraVideoChat_PushVideo.cs
Last active April 16, 2021 00:40
Use external video source to push video frame
#region =========== Push Video =================
public const TextureFormat ConvertFormat = TextureFormat.BGRA32; // RGBA will be compatible with Web
public const VIDEO_PIXEL_FORMAT PixelFormat = VIDEO_PIXEL_FORMAT.VIDEO_PIXEL_BGRA; // note: RGBA is available from v3.0.1 and on
Texture2D BufferTexture;
bool _isRunning;
IEnumerator CoShareRenderData()
{
[SerializeField]
private GameObject avatarVideoPrefab;
// Create new image plane to display users in party.
private void CreateUserVideoSurface(uint uid, bool isLocalUser, bool isAvatar)
{
// Avoid duplicating Local player VideoSurface image plane.
for (int i = 0; i < playerVideoList.Count; i++)
{
if (playerVideoList[i].name == uid.ToString())
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
public class AvatarViewController : MonoBehaviour
{
[SerializeField]
Dropdown EffectDropdown;
[SerializeField]
GameObject EffectsParent;
.
├── Android
│   ├── AgoraRtcEngineKit.plugin
│   │   ├── AndroidManifest.xml
│   │   ├── AndroidManifest.xml.meta
│   │   ├── libs
│   │   │   ├── PLACEHOLDER
│   │   │   ├── PLACEHOLDER.meta
│   │   │   ├── agora-rtc-sdk.jar
│   │   │   ├── agora-rtc-sdk.jar.meta