Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Registering VideoControllers bug #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 48 additions & 11 deletions Runtime/Components/ConferenceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down Expand Up @@ -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 =>
{
Expand All @@ -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 =>
{
Expand All @@ -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 =>
Expand All @@ -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:
Expand All @@ -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);
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions Runtime/Components/video/VideoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public void RegisterController()
if (Conference)
{
Conference.RegisterVideoController(this);
}else{
Debug.LogWarning("No conference found on VideoController");
}
}

Expand All @@ -51,6 +53,8 @@ public void CreateRenderer()
if (renderer)
{
VideoRenderer = new VideoRenderer(renderer.material);
}else{
Debug.LogWarning("No renderer found on VideoController");
}
}

Expand Down Expand Up @@ -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");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down