Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Event refactor #370

Closed
wants to merge 2 commits into from
Closed
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
Binary file modified DolbyIO/Content/VideoSamples/BP_DolbyIOGenericVideoPlane.uasset
Binary file not shown.
Binary file modified DolbyIO/Content/VideoSamples/BP_DolbyIOScreensharePlane.uasset
Binary file not shown.
Binary file not shown.
Binary file modified DolbyIO/Content/VideoSamples/BP_DolbyIOSingleVideoPlane.uasset
Binary file not shown.
Binary file modified DolbyIO/Content/VideoSamples/BP_DolbyIOVideoPlaneSpawner.uasset
Binary file not shown.
Binary file modified DolbyIO/Content/VideoSamples/BP_DolbyIOVideoPreviewPlane.uasset
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion DolbyIO/Source/Private/Subsystem/DolbyIOConference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void UDolbyIOSubsystem::UpdateStatus(conference_status Status)
}
}

bool UDolbyIOSubsystem::CanConnect(const FDolbyIOOnErrorDelegate& OnError) const
bool UDolbyIOSubsystem::CanConnect(const FDolbyIOErrorDelegate& OnError) const
{
if (!Sdk)
{
Expand Down
27 changes: 10 additions & 17 deletions DolbyIO/Source/Private/Subsystem/DolbyIODevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,11 @@ namespace DolbyIO
if (!Device)
{
DLB_UE_LOG("Got current audio input device - none");
BroadcastEvent(Subsystem.OnCurrentAudioInputDeviceReceived, bIsDeviceNone,
FDolbyIOAudioDevice{});
BroadcastEvent(Subsystem.OnCurrentAudioInputDeviceReceivedNone);
return;
}
DLB_UE_LOG("Got current audio input device - %s", *ToString(*Device));
BroadcastEvent(Subsystem.OnCurrentAudioInputDeviceReceived, !bIsDeviceNone,
ToFDolbyIOAudioDevice(*Device));
BroadcastEvent(Subsystem.OnCurrentAudioInputDeviceReceived, ToFDolbyIOAudioDevice(*Device));
})
.on_error(DLB_ERROR_HANDLER(Subsystem.OnGetCurrentAudioInputDeviceError));
}
Expand All @@ -134,13 +132,11 @@ namespace DolbyIO
if (!Device)
{
DLB_UE_LOG("Got current audio output device - none");
BroadcastEvent(Subsystem.OnCurrentAudioOutputDeviceReceived, bIsDeviceNone,
FDolbyIOAudioDevice{});
BroadcastEvent(Subsystem.OnCurrentAudioOutputDeviceReceivedNone);
return;
}
DLB_UE_LOG("Got current audio output device - %s", *ToString(*Device));
BroadcastEvent(Subsystem.OnCurrentAudioOutputDeviceReceived, !bIsDeviceNone,
ToFDolbyIOAudioDevice(*Device));
BroadcastEvent(Subsystem.OnCurrentAudioOutputDeviceReceived, ToFDolbyIOAudioDevice(*Device));
})
.on_error(DLB_ERROR_HANDLER(Subsystem.OnGetCurrentAudioOutputDeviceError));
}
Expand Down Expand Up @@ -213,12 +209,11 @@ namespace DolbyIO
if (!Device)
{
DLB_UE_LOG("Got current video device - none");
BroadcastEvent(Subsystem.OnCurrentVideoDeviceReceived, bIsDeviceNone, FDolbyIOVideoDevice{});
BroadcastEvent(Subsystem.OnCurrentVideoDeviceReceivedNone);
return;
}
DLB_UE_LOG("Got current video device - %s", *ToString(*Device));
BroadcastEvent(Subsystem.OnCurrentVideoDeviceReceived, !bIsDeviceNone,
ToFDolbyIOVideoDevice(*Device));
BroadcastEvent(Subsystem.OnCurrentVideoDeviceReceived, ToFDolbyIOVideoDevice(*Device));
})
.on_error(DLB_ERROR_HANDLER(Subsystem.OnGetCurrentVideoDeviceError));
}
Expand All @@ -232,9 +227,9 @@ void UDolbyIOSubsystem::Handle(const audio_device_changed& Event)
{
DLB_UE_LOG("Audio device changed for direction: %s to no device", *ToString(Event.utilized_direction));
if (Event.utilized_direction == audio_device::direction::input)
BroadcastEvent(OnCurrentAudioInputDeviceChanged, bIsDeviceNone, FDolbyIOAudioDevice{});
BroadcastEvent(OnCurrentAudioInputDeviceChangedToNone);
else
BroadcastEvent(OnCurrentAudioOutputDeviceChanged, bIsDeviceNone, FDolbyIOAudioDevice{});
BroadcastEvent(OnCurrentAudioOutputDeviceChangedToNone);
return;
}
Sdk->device_management()
Expand All @@ -248,11 +243,9 @@ void UDolbyIOSubsystem::Handle(const audio_device_changed& Event)
DLB_UE_LOG("Audio device changed for direction: %s to device - %s",
*ToString(Event.utilized_direction), *ToString(Device));
if (Event.utilized_direction == audio_device::direction::input)
BroadcastEvent(OnCurrentAudioInputDeviceChanged, !bIsDeviceNone,
ToFDolbyIOAudioDevice(Device));
BroadcastEvent(OnCurrentAudioInputDeviceChanged, ToFDolbyIOAudioDevice(Device));
else
BroadcastEvent(OnCurrentAudioOutputDeviceChanged, !bIsDeviceNone,
ToFDolbyIOAudioDevice(Device));
BroadcastEvent(OnCurrentAudioOutputDeviceChanged, ToFDolbyIOAudioDevice(Device));
return;
}
})
Expand Down
29 changes: 17 additions & 12 deletions DolbyIO/Source/Private/Subsystem/DolbyIOInitialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,32 +234,32 @@ void UDolbyIOObserver::InitializeComponent()

DLB_BIND(OnLocalParticipantUpdated);

DLB_BIND(OnVideoTrackAdded);

DLB_BIND(OnVideoTrackRemoved);

DLB_BIND(OnVideoTrackEnabled);

DLB_BIND(OnVideoTrackDisabled);

DLB_BIND(OnVideoEnabled);
DLB_BIND(OnRemoteCameraTrackAdded);
DLB_BIND(OnRemoteCameraTrackRemoved);
DLB_BIND(OnRemoteCameraTrackEnabled);
DLB_BIND(OnRemoteCameraTrackDisabled);
DLB_BIND(OnRemoteScreenshareTrackAdded);
DLB_BIND(OnRemoteScreenshareTrackRemoved);

DLB_BIND(OnLocalCameraTrackAdded);
DLB_BIND(OnEnableVideoError);

DLB_BIND(OnVideoDisabled);
DLB_BIND(OnLocalCameraTrackRemoved);
DLB_BIND(OnDisableVideoError);

DLB_BIND(OnScreenshareSourcesReceived);
DLB_BIND(OnGetScreenshareSourcesError);

DLB_BIND(OnScreenshareStarted);
DLB_BIND(OnLocalScreenshareTrackAdded);
DLB_BIND(OnStartScreenshareError);

DLB_BIND(OnScreenshareStopped);
DLB_BIND(OnLocalScreenshareTrackRemoved);
DLB_BIND(OnStopScreenshareError);

DLB_BIND(OnChangeScreenshareParametersError);

DLB_BIND(OnCurrentScreenshareSourceReceived);
DLB_BIND(OnCurrentScreenshareSourceReceivedNone);
DLB_BIND(OnGetCurrentScreenshareSourceError);

DLB_BIND(OnActiveSpeakersChanged);
Expand All @@ -281,21 +281,26 @@ void UDolbyIOObserver::InitializeComponent()
DLB_BIND(OnGetAudioOutputDevicesError);

DLB_BIND(OnCurrentAudioInputDeviceReceived);
DLB_BIND(OnCurrentAudioInputDeviceReceivedNone);
DLB_BIND(OnGetCurrentAudioInputDeviceError);

DLB_BIND(OnCurrentAudioOutputDeviceReceived);
DLB_BIND(OnCurrentAudioOutputDeviceReceivedNone);
DLB_BIND(OnGetCurrentAudioOutputDeviceError);

DLB_BIND(OnVideoDevicesReceived);
DLB_BIND(OnGetVideoDevicesError);

DLB_BIND(OnCurrentVideoDeviceReceived);
DLB_BIND(OnCurrentVideoDeviceReceivedNone);
DLB_BIND(OnGetCurrentVideoDeviceError);

DLB_BIND(OnCurrentAudioInputDeviceChanged);
DLB_BIND(OnCurrentAudioInputDeviceChangedToNone);
DLB_BIND(OnSetAudioInputDeviceError);

DLB_BIND(OnCurrentAudioOutputDeviceChanged);
DLB_BIND(OnCurrentAudioOutputDeviceChangedToNone);
DLB_BIND(OnSetAudioOutputDeviceError);

DLB_BIND(OnUpdateUserMetadataError);
Expand Down
9 changes: 4 additions & 5 deletions DolbyIO/Source/Private/Subsystem/DolbyIOScreenshare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void UDolbyIOSubsystem::StartScreenshare(const FDolbyIOScreenshareSource& Source
Sdk->conference()
.start_screen_share(SdkSource, LocalScreenshareFrameHandler,
ToSdkContentInfo(EncoderHint, MaxResolution, DownscaleQuality))
.then([this] { BroadcastEvent(OnScreenshareStarted, LocalScreenshareTrackID); })
.then([this] { BroadcastEvent(OnLocalScreenshareTrackAdded, LocalScreenshareTrackID); })
.on_error(DLB_ERROR_HANDLER(OnStartScreenshareError));
}

Expand All @@ -67,7 +67,7 @@ void UDolbyIOSubsystem::StopScreenshare()
DLB_UE_LOG("Stopping screenshare");
Sdk->conference()
.stop_screen_share()
.then([this] { BroadcastEvent(OnScreenshareStopped, LocalScreenshareTrackID); })
.then([this] { BroadcastEvent(OnLocalScreenshareTrackRemoved, LocalScreenshareTrackID); })
.on_error(DLB_ERROR_HANDLER(OnStopScreenshareError));
}

Expand Down Expand Up @@ -106,12 +106,11 @@ void UDolbyIOSubsystem::GetCurrentScreenshareSource()
if (!Source)
{
DLB_UE_LOG("Got current screenshare source - none");
BroadcastEvent(OnCurrentScreenshareSourceReceived, bIsSourceNone, FDolbyIOScreenshareSource{});
BroadcastEvent(OnCurrentScreenshareSourceReceivedNone);
return;
}
DLB_UE_LOG("Got current screenshare source - %s", *ToString(*Source));
BroadcastEvent(OnCurrentScreenshareSourceReceived, !bIsSourceNone,
ToFDolbyIOScreenshareSource(*Source));
BroadcastEvent(OnCurrentScreenshareSourceReceived, ToFDolbyIOScreenshareSource(*Source));
})
.on_error(DLB_ERROR_HANDLER(OnGetScreenshareSourcesError));
}
Expand Down
4 changes: 2 additions & 2 deletions DolbyIO/Source/Private/Subsystem/DolbyIOVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void UDolbyIOSubsystem::EnableVideo(const FDolbyIOVideoDevice& VideoDevice, bool
[this, VideoDevice]
{
bIsVideoEnabled = true;
BroadcastEvent(OnVideoEnabled, LocalCameraTrackID);
BroadcastEvent(OnLocalCameraTrackAdded, LocalCameraTrackID);
})
.on_error(DLB_ERROR_HANDLER(OnEnableVideoError));
}
Expand All @@ -62,7 +62,7 @@ void UDolbyIOSubsystem::DisableVideo()
[this]
{
bIsVideoEnabled = false;
BroadcastEvent(OnVideoDisabled, LocalCameraTrackID);
BroadcastEvent(OnLocalCameraTrackRemoved, LocalCameraTrackID);
})
.on_error(DLB_ERROR_HANDLER(OnDisableVideoError));
}
33 changes: 19 additions & 14 deletions DolbyIO/Source/Private/Subsystem/DolbyIOVideoTracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,17 @@ UTexture2D* UDolbyIOSubsystem::GetTexture(const FString& VideoTrackID)

void UDolbyIOSubsystem::BroadcastVideoTrackAdded(const FDolbyIOVideoTrack& VideoTrack)
{
DLB_UE_LOG("Video track added: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
BroadcastEvent(OnVideoTrackAdded, VideoTrack);
DLB_UE_LOG("Video track added: TrackID=%s ParticipantID=%s IsScreenshare=%d", *VideoTrack.TrackID,
*VideoTrack.ParticipantID, VideoTrack.bIsScreenshare);
BroadcastEvent(VideoTrack.bIsScreenshare ? OnRemoteScreenshareTrackAdded : OnRemoteCameraTrackAdded,
VideoTrack.TrackID, VideoTrack.ParticipantID);
}

void UDolbyIOSubsystem::BroadcastVideoTrackEnabled(const FDolbyIOVideoTrack& VideoTrack)
void UDolbyIOSubsystem::BroadcastRemoteCameraTrackEnabled(const FDolbyIOVideoTrack& VideoTrack)
{
DLB_UE_LOG("Video track enabled: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
BroadcastEvent(OnVideoTrackEnabled, VideoTrack);
DLB_UE_LOG("Remote camera track enabled: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID,
*VideoTrack.ParticipantID, VideoTrack.bIsScreenshare);
BroadcastEvent(OnRemoteCameraTrackEnabled, VideoTrack.TrackID, VideoTrack.ParticipantID);
}

void UDolbyIOSubsystem::ProcessBufferedVideoTracks(const FString& ParticipantID)
Expand All @@ -74,7 +77,7 @@ void UDolbyIOSubsystem::ProcessBufferedVideoTracks(const FString& ParticipantID)
{
if (EnabledTracksRef[i].TrackID == AddedTrack.TrackID)
{
BroadcastVideoTrackEnabled(EnabledTracksRef[i]);
BroadcastRemoteCameraTrackEnabled(EnabledTracksRef[i]);
EnabledTracksRef.RemoveAt(i);
if (!EnabledTracksRef.Num())
{
Expand Down Expand Up @@ -107,20 +110,22 @@ void UDolbyIOSubsystem::Handle(const remote_video_track_added& Event)
}
else
{
DLB_UE_LOG("Buffering video track added: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID,
*VideoTrack.ParticipantID);
DLB_UE_LOG("Buffering video track added: TrackID=%s ParticipantID=%s IsScreenshare=%d", *VideoTrack.TrackID,
*VideoTrack.ParticipantID, VideoTrack.bIsScreenshare);
BufferedAddedVideoTracks.FindOrAdd(VideoTrack.ParticipantID).Add(VideoTrack);
}
}

void UDolbyIOSubsystem::Handle(const remote_video_track_removed& Event)
{
const FDolbyIOVideoTrack VideoTrack = ToFDolbyIOVideoTrack(Event.track);
DLB_UE_LOG("Video track removed: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
DLB_UE_LOG("Video track removed: TrackID=%s ParticipantID=%s IsScreenshare=%d", *VideoTrack.TrackID,
*VideoTrack.ParticipantID, Event.track.is_screenshare);

VideoSinks[VideoTrack.TrackID]->UnbindAllMaterials();
VideoSinks.Remove(VideoTrack.TrackID);
BroadcastEvent(OnVideoTrackRemoved, VideoTrack);
BroadcastEvent(Event.track.is_screenshare ? OnRemoteScreenshareTrackRemoved : OnRemoteCameraTrackRemoved,
VideoTrack.TrackID, VideoTrack.ParticipantID);
}

void UDolbyIOSubsystem::Handle(const utils::vfs_event& Event)
Expand All @@ -131,19 +136,19 @@ void UDolbyIOSubsystem::Handle(const utils::vfs_event& Event)

if (GetTexture(VideoTrack.TrackID))
{
BroadcastVideoTrackEnabled(VideoTrack);
BroadcastRemoteCameraTrackEnabled(VideoTrack);
}
else
{
DLB_UE_LOG("Buffering video track enabled: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID,
*VideoTrack.ParticipantID);
DLB_UE_LOG("Buffering video track enabled: TrackID=%s ParticipantID=%s IsScreenshare=%d",
*VideoTrack.TrackID, *VideoTrack.ParticipantID, VideoTrack.bIsScreenshare);
BufferedEnabledVideoTracks.FindOrAdd(VideoTrack.ParticipantID).Add(VideoTrack);
}
}
for (const auto& TrackMapItem : Event.new_disabled)
{
const FDolbyIOVideoTrack VideoTrack = ToFDolbyIOVideoTrack(TrackMapItem);
DLB_UE_LOG("Video track ID %s for participant ID %s disabled", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
BroadcastEvent(OnVideoTrackDisabled, VideoTrack);
BroadcastEvent(OnRemoteCameraTrackDisabled, VideoTrack.TrackID, VideoTrack.ParticipantID);
}
}
4 changes: 2 additions & 2 deletions DolbyIO/Source/Private/Utils/DolbyIOErrorHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace DolbyIO
}

FErrorHandler::FErrorHandler(const FString& File, int Line, UDolbyIOSubsystem& DolbyIOSubsystem,
const FDolbyIOOnErrorDelegate& OnError)
const FDolbyIOErrorDelegate& OnError)
: File(FPaths::GetCleanFilename(File)), Line(Line), DolbyIOSubsystem(DolbyIOSubsystem), OnError(&OnError)
{
}
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace DolbyIO
}
}

void FErrorHandler::Warn(const FDolbyIOOnErrorDelegate& OnError, const FString& Msg)
void FErrorHandler::Warn(const FDolbyIOErrorDelegate& OnError, const FString& Msg)
{
DLB_UE_LOG_BASE(Warning, "%s", *Msg);
BroadcastEvent(OnError, Msg);
Expand Down
8 changes: 4 additions & 4 deletions DolbyIO/Source/Private/Utils/DolbyIOErrorHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Containers/UnrealString.h"

class UDolbyIOSubsystem;
class FDolbyIOOnErrorDelegate;
class FDolbyIOErrorDelegate;

namespace DolbyIO
{
Expand All @@ -19,12 +19,12 @@ namespace DolbyIO

FErrorHandler(const FString& File, int Line, UDolbyIOSubsystem& DolbyIOSubsystem);
FErrorHandler(const FString& File, int Line, UDolbyIOSubsystem& DolbyIOSubsystem,
const FDolbyIOOnErrorDelegate& OnError);
const FDolbyIOErrorDelegate& OnError);

void operator()(std::exception_ptr&& ExcPtr) const;
void HandleError() const;

static void Warn(const FDolbyIOOnErrorDelegate& OnError, const FString& Msg);
static void Warn(const FDolbyIOErrorDelegate& OnError, const FString& Msg);

private:
void HandleError(TFunction<void()> Callee) const;
Expand All @@ -33,6 +33,6 @@ namespace DolbyIO
FString File;
int Line;
UDolbyIOSubsystem& DolbyIOSubsystem;
const FDolbyIOOnErrorDelegate* const OnError{};
const FDolbyIOErrorDelegate* const OnError{};
};
}
Loading