From ec632c4ea6a1168cfceaafce7ec4ee7a264801b2 Mon Sep 17 00:00:00 2001 From: Lee Probert Date: Wed, 18 Oct 2023 10:40:23 +0100 Subject: [PATCH] Registering VideoControllers no longer ignores participants after the local player The ConferenceController was set to return after finding the VideoController that was local. This meant any remote participants AFTER this point did not get their VideoTrack assigned. --- Runtime/Components/ConferenceController.cs | 59 +++++++++++++++++---- Runtime/Components/video/VideoController.cs | 8 +++ package.json | 2 +- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/Runtime/Components/ConferenceController.cs b/Runtime/Components/ConferenceController.cs index 62e6936..0d4ab64 100644 --- a/Runtime/Components/ConferenceController.cs +++ b/Runtime/Components/ConferenceController.cs @@ -46,16 +46,28 @@ public string ConferenceAlias void Start() { + InitialiseConference(); + } + + public void InitialiseConference(){ if (_sdk.IsInitialized) { + if(_sdk.Conference == null){ + Debug.LogWarning("Attempting to set delegates on conference but it does not exist"); + return; + } + + // _sdk.Conference.StatusUpdated += ConferenceStatusUpdated; _sdk.Conference.VideoTrackAdded += HandleVideoTrackAdded; _sdk.Conference.VideoTrackRemoved += HandleVideoTrackRemoved; _sdk.Conference.ParticipantUpdated += HandleParticipantUpdated; - } - if (AutoJoin) - { - Join(); + if (AutoJoin) + { + Join(); + } + }else{ + Debug.LogWarning("SDK not initialized"); } } @@ -218,11 +230,17 @@ public void StopScreenShare() /// Controllers will register themself to the Conference Controller during the Awake phase. internal void RegisterVideoController(VideoController controller) { + // Debug.Log("Registering VideoController for : "+controller.Filter); _videoControllers.Add(controller); } + // private void ConferenceStatusUpdated(ConferenceStatus status, string conferenceId){ + // Debug.Log("Conference status updated: " + status); + // } + private void HandleVideoTrackAdded(VideoTrack track) { + // Debug.Log("VideoTrack Added: " + track.ParticipantId); _tracks.Add(track); UpdateVideoControllers().ContinueWith(t => { @@ -233,6 +251,7 @@ private void HandleVideoTrackAdded(VideoTrack track) private void HandleVideoTrackRemoved(VideoTrack track) { + // Debug.Log("VideoTrack Removed: " + track.ParticipantId); _tracks.Remove(track); UpdateVideoControllers().ContinueWith(t => { @@ -243,6 +262,8 @@ private void HandleVideoTrackRemoved(VideoTrack track) private void HandleParticipantUpdated(Participant p) { + // Debug.Log("Participant updated: " + p.Status); + if (ParticipantStatus.OnAir == p.Status) { UpdateVideoControllers().ContinueWith(t => @@ -257,20 +278,25 @@ private async Task UpdateVideoControllers() { if (!_sdk.Conference.IsInConference) { + Debug.LogWarning("Attempting to update video controllers but not in conference"); return; } - + Debug.Log("Updating VideoControllers"); var participants = await _sdk.Conference.GetParticipantsAsync(); + if(participants == null){ + Debug.LogWarning("Attempting to update video controllers but no participants found"); + return; + } + + if(_videoControllers.Count == 0){ + Debug.LogWarning("No video controllers found"); + return; + } foreach(var c in _videoControllers) { string participantId = ""; - if (c.IsLocal) - { - return; - } - switch (c.FilterBy) { case ParticipantFilter.ParticipantId: @@ -292,10 +318,21 @@ private async Task UpdateVideoControllers() break; } - if (!String.IsNullOrEmpty(participantId)) + if (!String.IsNullOrEmpty(participantId) && !c.IsLocal) { + // Debug.Log("Updating track for participant: " + participantId); VideoTrack track = _tracks.Find(t => t.ParticipantId.Equals(participantId)); + if(track.Equals(null)){ + Debug.LogWarning("No video track found for participant: " + participantId); + return; + } c.UpdateTrack(track); + }else{ + if(c.IsLocal){ + Debug.Log("Found local video controller for : "+c.Filter); + }else{ + Debug.LogWarning("No participant ID found for player: " + c.Filter); + } } } diff --git a/Runtime/Components/video/VideoController.cs b/Runtime/Components/video/VideoController.cs index 0d57bf5..44a0421 100644 --- a/Runtime/Components/video/VideoController.cs +++ b/Runtime/Components/video/VideoController.cs @@ -41,6 +41,8 @@ public void RegisterController() if (Conference) { Conference.RegisterVideoController(this); + }else{ + Debug.LogWarning("No conference found on VideoController"); } } @@ -51,6 +53,8 @@ public void CreateRenderer() if (renderer) { VideoRenderer = new VideoRenderer(renderer.material); + }else{ + Debug.LogWarning("No renderer found on VideoController"); } } @@ -82,7 +86,11 @@ internal void UpdateTrack(VideoTrack track) Debug.LogWarning(t.Exception.Message); }, TaskContinuationOptions.OnlyOnFaulted); + }else{ + // Debug.LogWarning("No participant id found on video track"); } + }else{ + // Debug.LogWarning("Video track already set"); } } } diff --git a/package.json b/package.json index fcc1a09..ecb5b23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dolbyio.comms.unity", - "version": "1.2.0", + "version": "1.2.2", "unity": "2021.1", "displayName": "DolbyIO Communications", "description": "The DolbyIO Virtual World Plugin for Unity",