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

Commit bf95173

Browse files
author
Kuba Audykowicz
authored
Merge pull request #402 from DolbyIO/develop
Develop
2 parents b845cb8 + 2ba62ec commit bf95173

File tree

7 files changed

+222
-89
lines changed

7 files changed

+222
-89
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ env:
1414
CPP_SDK_URL: "https://github.com/DolbyIO/comms-sdk-cpp/releases/download"
1515
PLUGIN_SOURCE_DIR: "DolbyIO"
1616
PLUGIN_BUILD_DIR: "Build/DolbyIO"
17+
BUILD_ARGS_COMMON: "BuildPlugin -Rocket -StrictIncludes -Plugin=\"$(pwd)/DolbyIO/DolbyIO.uplugin\" -Package=\"$(pwd)/Build/DolbyIO\""
1718
GH_TOKEN: ${{ github.token }}
1819
RETENTION: 7
1920

@@ -41,10 +42,17 @@ jobs:
4142

4243
- name: Build plugin
4344
env:
44-
BUILD_ARGS: "BuildPlugin -Rocket -StrictIncludes -Plugin=\"$(pwd)\\DolbyIO\\DolbyIO.uplugin\" -Package=\"$(pwd)\\Build\\DolbyIO\" -TargetPlatforms=Win64 -VS2019"
45+
BUILD_COMMAND: "C:/Program` Files/Epic` Games/UE_${{ matrix.version }}/Engine/Build/BatchFiles/RunUAT.bat"
46+
BUILD_ARGS_PLATFORM: "-TargetPlatforms=Win64"
4547
run: |
46-
$UAT = "C:\\Program Files\\Epic Games\\UE_${{ matrix.version }}\\Engine\\Build\\BatchFiles\\RunUAT.bat"
47-
& $UAT ${{ env.BUILD_ARGS }}
48+
if (${{ matrix.version }} -eq "4.27")
49+
{
50+
${{ env.BUILD_COMMAND }} ${{ env.BUILD_ARGS_COMMON }} ${{ env.BUILD_ARGS_PLATFORM }} -VS2019
51+
}
52+
else
53+
{
54+
${{ env.BUILD_COMMAND }} ${{ env.BUILD_ARGS_COMMON }} ${{ env.BUILD_ARGS_PLATFORM }}
55+
}
4856
4957
- name: Sign plugin
5058
env:
@@ -100,9 +108,10 @@ jobs:
100108
101109
- name: Build plugin
102110
env:
103-
BUILD_ARGS: "BuildPlugin -Rocket -StrictIncludes -Plugin=\"$(pwd)/DolbyIO/DolbyIO.uplugin\" -Package=$(pwd)/Build/DolbyIO -TargetPlatforms=Mac -Architecture_Mac=x64+arm64"
111+
BUILD_COMMAND: "/Users/Shared/Epic\\ Games/UE_${{ matrix.version }}/Engine/Build/BatchFiles/RunUAT.sh"
112+
BUILD_ARGS_PLATFORM: "-TargetPlatforms=Mac -Architecture_Mac=x64+arm64"
104113
run: |
105-
/Users/Shared/Epic\ Games/UE_${{ matrix.version }}/Engine/Build/BatchFiles/RunUAT.sh ${{ env.BUILD_ARGS }}
114+
${{ env.BUILD_COMMAND }} ${{ env.BUILD_ARGS_COMMON }} ${{ env.BUILD_ARGS_PLATFORM }}
106115
107116
- name: Sign plugin
108117
env:
@@ -170,15 +179,18 @@ jobs:
170179
171180
- name: Build plugin
172181
env:
173-
BUILD_ARGS: "BuildPlugin -Rocket -StrictIncludes -Plugin=\"$(pwd)\\DolbyIO\\DolbyIO.uplugin\" -Package=\"$(pwd)\\Build\\DolbyIO\" -TargetPlatforms=Linux -NoHostPlatform"
182+
BUILD_COMMAND: "C:/Program` Files/Epic` Games/UE_${{ matrix.version }}/Engine/Build/BatchFiles/RunUAT.bat"
183+
BUILD_ARGS_PLATFORM: "-TargetPlatforms=Linux -NoHostPlatform"
174184
run: |
175-
if(${{ matrix.version }} -eq "4.27"){
185+
if (${{ matrix.version }} -eq "4.27")
186+
{
176187
$env:LINUX_MULTIARCH_ROOT="C:\\UnrealToolchains\\v19_clang-11.0.1-centos7"
177-
} else {
188+
}
189+
else
190+
{
178191
$env:LINUX_MULTIARCH_ROOT="C:\\UnrealToolchains\\v21_clang-15.0.1-centos7"
179192
}
180-
$UAT = "C:\\Program Files\\Epic Games\\UE_${{ matrix.version }}\\Engine\\Build\\BatchFiles\\RunUAT.bat"
181-
& $UAT ${{ env.BUILD_ARGS }}
193+
${{ env.BUILD_COMMAND }} ${{ env.BUILD_ARGS_COMMON }} ${{ env.BUILD_ARGS_PLATFORM }}
182194
183195
- name: Zip plugin
184196
working-directory: ${{ env.PLUGIN_BUILD_DIR }}
2.39 KB
Binary file not shown.

DolbyIO/Source/DolbyIO.Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class DolbyIO : ModuleRules
77
{
88
public DolbyIO(ReadOnlyTargetRules Target) : base(Target)
99
{
10-
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
10+
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
1111

1212
CppStandard = CppStandardVersion.Cpp17;
1313
bEnableExceptions = true;

DolbyIO/Source/Private/Subsystem/DolbyIOInitialization.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ void UDolbyIOSubsystem::Initialize(FSubsystemCollectionBase& Collection)
2727

2828
ConferenceStatus = conference_status::destroyed;
2929

30-
VideoSinks.Emplace(LocalCameraTrackID, std::make_shared<FVideoSink>(LocalCameraTrackID));
31-
VideoSinks.Emplace(LocalScreenshareTrackID, std::make_shared<FVideoSink>(LocalScreenshareTrackID));
32-
LocalCameraFrameHandler = std::make_shared<FVideoFrameHandler>(VideoSinks[LocalCameraTrackID]);
33-
LocalScreenshareFrameHandler = std::make_shared<FVideoFrameHandler>(VideoSinks[LocalScreenshareTrackID]);
30+
{
31+
FScopeLock Lock{&VideoSinksLock};
32+
VideoSinks.Emplace(LocalCameraTrackID, std::make_shared<FVideoSink>(LocalCameraTrackID));
33+
VideoSinks.Emplace(LocalScreenshareTrackID, std::make_shared<FVideoSink>(LocalScreenshareTrackID));
34+
LocalCameraFrameHandler = std::make_shared<FVideoFrameHandler>(VideoSinks[LocalCameraTrackID]);
35+
LocalScreenshareFrameHandler = std::make_shared<FVideoFrameHandler>(VideoSinks[LocalScreenshareTrackID]);
36+
}
3437

3538
FTimerManager& TimerManager = GetGameInstance()->GetTimerManager();
3639
TimerManager.SetTimer(LocationTimerHandle, this, &UDolbyIOSubsystem::SetLocationUsingFirstPlayer, 0.1, true);
@@ -42,6 +45,8 @@ void UDolbyIOSubsystem::Initialize(FSubsystemCollectionBase& Collection)
4245
void UDolbyIOSubsystem::Deinitialize()
4346
{
4447
DLB_UE_LOG("Deinitializing");
48+
49+
FScopeLock Lock{&VideoSinksLock};
4550
for (auto& Sink : VideoSinks)
4651
{
4752
Sink.Value->Disable(); // ignore new frames now on
@@ -121,7 +126,7 @@ void UDolbyIOSubsystem::SetToken(const FString& Token)
121126
{
122127
DLB_ERROR_HANDLER(OnSetTokenError).HandleError();
123128
}
124-
RefreshTokenCb.Reset(); // RefreshToken callback can be called only once
129+
RefreshTokenCb.Reset(); // RefreshToken callback can only be called once
125130
}
126131
}
127132

DolbyIO/Source/Private/Subsystem/DolbyIOVideoTracks.cpp

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using namespace DolbyIO;
1313

1414
void UDolbyIOSubsystem::BindMaterial(UMaterialInstanceDynamic* Material, const FString& VideoTrackID)
1515
{
16+
FScopeLock Lock{&VideoSinksLock};
1617
for (auto& Sink : VideoSinks)
1718
{
1819
if (Sink.Key != VideoTrackID)
@@ -29,6 +30,7 @@ void UDolbyIOSubsystem::BindMaterial(UMaterialInstanceDynamic* Material, const F
2930

3031
void UDolbyIOSubsystem::UnbindMaterial(UMaterialInstanceDynamic* Material, const FString& VideoTrackID)
3132
{
33+
FScopeLock Lock{&VideoSinksLock};
3234
if (const std::shared_ptr<DolbyIO::FVideoSink>* Sink = VideoSinks.Find(VideoTrackID))
3335
{
3436
(*Sink)->UnbindMaterial(Material);
@@ -37,6 +39,7 @@ void UDolbyIOSubsystem::UnbindMaterial(UMaterialInstanceDynamic* Material, const
3739

3840
UTexture2D* UDolbyIOSubsystem::GetTexture(const FString& VideoTrackID)
3941
{
42+
FScopeLock Lock{&VideoSinksLock};
4043
if (const std::shared_ptr<FVideoSink>* Sink = VideoSinks.Find(VideoTrackID))
4144
{
4245
return (*Sink)->GetTexture();
@@ -47,9 +50,18 @@ UTexture2D* UDolbyIOSubsystem::GetTexture(const FString& VideoTrackID)
4750
void UDolbyIOSubsystem::BroadcastVideoTrackAdded(const FDolbyIOVideoTrack& VideoTrack)
4851
{
4952
DLB_UE_LOG("Video track added: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
53+
WarnIfVideoTrackSuspicious(VideoTrack.TrackID);
5054
BroadcastEvent(OnVideoTrackAdded, VideoTrack);
5155
}
5256

57+
void UDolbyIOSubsystem::WarnIfVideoTrackSuspicious(const FString& VideoTrackID)
58+
{
59+
if (VideoTrackID == "{-}")
60+
{
61+
DLB_UE_LOG_BASE(Warning, "Suspicious video track ID added, things may not work as expected");
62+
}
63+
}
64+
5365
void UDolbyIOSubsystem::BroadcastVideoTrackEnabled(const FDolbyIOVideoTrack& VideoTrack)
5466
{
5567
DLB_UE_LOG("Video track enabled: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
@@ -60,31 +72,35 @@ void UDolbyIOSubsystem::ProcessBufferedVideoTracks(const FString& ParticipantID)
6072
{
6173
if (TArray<FDolbyIOVideoTrack>* AddedTracks = BufferedAddedVideoTracks.Find(ParticipantID))
6274
{
75+
FScopeLock Lock{&VideoSinksLock};
6376
for (const FDolbyIOVideoTrack& AddedTrack : *AddedTracks)
6477
{
65-
VideoSinks[AddedTrack.TrackID]->OnTextureCreated(
66-
[=]
67-
{
68-
BroadcastVideoTrackAdded(AddedTrack);
69-
70-
if (TArray<FDolbyIOVideoTrack>* EnabledTracks = BufferedEnabledVideoTracks.Find(ParticipantID))
78+
if (std::shared_ptr<DolbyIO::FVideoSink>* Sink = VideoSinks.Find(AddedTrack.TrackID))
79+
{
80+
(*Sink)->OnTextureCreated(
81+
[=]
7182
{
72-
TArray<FDolbyIOVideoTrack>& EnabledTracksRef = *EnabledTracks;
73-
for (int i = 0; i < EnabledTracksRef.Num(); ++i)
83+
BroadcastVideoTrackAdded(AddedTrack);
84+
85+
if (TArray<FDolbyIOVideoTrack>* EnabledTracks = BufferedEnabledVideoTracks.Find(ParticipantID))
7486
{
75-
if (EnabledTracksRef[i].TrackID == AddedTrack.TrackID)
87+
TArray<FDolbyIOVideoTrack>& EnabledTracksRef = *EnabledTracks;
88+
for (int i = 0; i < EnabledTracksRef.Num(); ++i)
7689
{
77-
BroadcastVideoTrackEnabled(EnabledTracksRef[i]);
78-
EnabledTracksRef.RemoveAt(i);
79-
if (!EnabledTracksRef.Num())
90+
if (EnabledTracksRef[i].TrackID == AddedTrack.TrackID)
8091
{
81-
BufferedEnabledVideoTracks.Remove(ParticipantID);
92+
BroadcastVideoTrackEnabled(EnabledTracksRef[i]);
93+
EnabledTracksRef.RemoveAt(i);
94+
if (!EnabledTracksRef.Num())
95+
{
96+
BufferedEnabledVideoTracks.Remove(ParticipantID);
97+
}
98+
return;
8299
}
83-
return;
84100
}
85101
}
86-
}
87-
});
102+
});
103+
}
88104
}
89105
BufferedAddedVideoTracks.Remove(ParticipantID);
90106
}
@@ -94,13 +110,14 @@ void UDolbyIOSubsystem::Handle(const remote_video_track_added& Event)
94110
{
95111
const FDolbyIOVideoTrack VideoTrack = ToFDolbyIOVideoTrack(Event.track);
96112

113+
FScopeLock Lock1{&VideoSinksLock};
97114
VideoSinks.Emplace(VideoTrack.TrackID, std::make_shared<FVideoSink>(VideoTrack.TrackID));
98115
Sdk->video()
99116
.remote()
100117
.set_video_sink(Event.track, VideoSinks[VideoTrack.TrackID])
101118
.on_error(DLB_ERROR_HANDLER_NO_DELEGATE);
102119

103-
FScopeLock Lock{&RemoteParticipantsLock};
120+
FScopeLock Lock2{&RemoteParticipantsLock};
104121
if (RemoteParticipants.Contains(VideoTrack.ParticipantID))
105122
{
106123
VideoSinks[VideoTrack.TrackID]->OnTextureCreated([this, VideoTrack] { BroadcastVideoTrackAdded(VideoTrack); });
@@ -117,9 +134,19 @@ void UDolbyIOSubsystem::Handle(const remote_video_track_removed& Event)
117134
{
118135
const FDolbyIOVideoTrack VideoTrack = ToFDolbyIOVideoTrack(Event.track);
119136
DLB_UE_LOG("Video track removed: TrackID=%s ParticipantID=%s", *VideoTrack.TrackID, *VideoTrack.ParticipantID);
137+
WarnIfVideoTrackSuspicious(VideoTrack.TrackID);
138+
139+
FScopeLock Lock{&VideoSinksLock};
140+
if (std::shared_ptr<DolbyIO::FVideoSink>* Sink = VideoSinks.Find(VideoTrack.TrackID))
141+
{
142+
(*Sink)->UnbindAllMaterials();
143+
VideoSinks.Remove(VideoTrack.TrackID);
144+
}
145+
else
146+
{
147+
DLB_UE_LOG_BASE(Warning, "Non-existent video track removed");
148+
}
120149

121-
VideoSinks[VideoTrack.TrackID]->UnbindAllMaterials();
122-
VideoSinks.Remove(VideoTrack.TrackID);
123150
BroadcastEvent(OnVideoTrackRemoved, VideoTrack);
124151
}
125152

0 commit comments

Comments
 (0)