using System; using System.Runtime.InteropServices; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Serialization; using Agora.Rtc; using Agora.Util; using Logger = Agora.Util.Logger; namespace Agora_RTC_Plugin.API_Example.Examples.Advanced.MetadataSample { public class MetadataSample : MonoBehaviour { [FormerlySerializedAs("appIdInput")] [SerializeField] private AppIdInput _appIdInput; [Header("_____________Basic Configuration_____________")] [FormerlySerializedAs("APP_ID")] [SerializeField] public string _appID = ""; [FormerlySerializedAs("TOKEN")] [SerializeField] public string _token = ""; [FormerlySerializedAs("CHANNEL_NAME")] [SerializeField] public string _channelName = ""; public Text LogText; internal Logger Log; internal IRtcEngine RtcEngine; internal bool Sending = false; internal Queue MetadataQueue = new Queue(); private void Start() { LoadAssetData(); if (CheckAppId()) { InitEngine(); SetupUI(); JoinChannel(); } } [ContextMenu("ShowAgoraBasicProfileData")] private void LoadAssetData() { if (_appIdInput == null) return; _appID = _appIdInput.appID; _token = _appIdInput.token; _channelName = _appIdInput.channelName; } private bool CheckAppId() { Log = new Logger(LogText); return Log.DebugAssert(_appID.Length > 10, "Please fill in your appId in API-Example/profile/appIdInput.asset"); } private void InitEngine() { RtcEngine = Agora.Rtc.RtcEngine.CreateAgoraRtcEngine(); UserEventHandler handler = new UserEventHandler(this); RtcEngineContext context = new RtcEngineContext(_appID, 0, CHANNEL_PROFILE_TYPE.CHANNEL_PROFILE_LIVE_BROADCASTING, AUDIO_SCENARIO_TYPE.AUDIO_SCENARIO_GAME_STREAMING); RtcEngine.Initialize(context); RtcEngine.InitEventHandler(handler); UserMetadataObserver metadataObserver = new UserMetadataObserver(this); RtcEngine.RegisterMediaMetadataObserver(metadataObserver, METADATA_TYPE.VIDEO_METADATA); } private void SetupUI() { var ui = this.transform.Find("UI"); var btn = ui.Find("StartButton").GetComponent