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

Commit

Permalink
Merge pull request #169 from DolbyIO/develop
Browse files Browse the repository at this point in the history
Merge develop into main
  • Loading branch information
Kuba Audykowicz authored May 22, 2023
2 parents ad553d5 + cdf7894 commit 6ef2d1e
Show file tree
Hide file tree
Showing 28 changed files with 149 additions and 82 deletions.
Binary file not shown.
Binary file added DolbyIO/Content/BP_DolbyIOScreensharePlane.uasset
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added DolbyIO/Content/M_DolbyIOVideo.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion DolbyIO/DolbyIO.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"DocsURL": "https://github.com/DolbyIO/comms-sdk-unreal",
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/OFFERID",
"SupportURL": "https://github.com/DolbyIO/comms-sdk-unreal",
"CanContainContent": false,
"CanContainContent": true,
"IsBetaVersion": true,
"Installed": false,
"Modules": [
Expand Down
46 changes: 46 additions & 0 deletions DolbyIO/Source/Private/DolbyIOFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ void UDolbyIOSetToken::Activate()
void UDolbyIOSetToken::OnInitializedImpl()
{
OnInitialized.Broadcast();

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnInitialized.RemoveDynamic(this, &UDolbyIOSetToken::OnInitializedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -73,6 +78,11 @@ void UDolbyIOConnect::Activate()
void UDolbyIOConnect::OnConnectedImpl(const FString& LocalParticipantID, const FString& ConferenceID)
{
OnConnected.Broadcast(LocalParticipantID, ConferenceID);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnConnected.RemoveDynamic(this, &UDolbyIOConnect::OnConnectedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -96,6 +106,11 @@ void UDolbyIODemoConference::Activate()
void UDolbyIODemoConference::OnConnectedImpl(const FString& LocalParticipantID, const FString& ConferenceID)
{
OnConnected.Broadcast(LocalParticipantID, ConferenceID);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnConnected.RemoveDynamic(this, &UDolbyIODemoConference::OnConnectedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -119,6 +134,11 @@ void UDolbyIODisconnect::Activate()
void UDolbyIODisconnect::OnDisconnectedImpl()
{
OnDisconnected.Broadcast();

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnDisconnected.RemoveDynamic(this, &UDolbyIODisconnect::OnDisconnectedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -142,6 +162,11 @@ void UDolbyIOEnableVideo::Activate()
void UDolbyIOEnableVideo::OnVideoEnabledImpl(const FString& VideoTrackID)
{
OnVideoEnabled.Broadcast(VideoTrackID);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnVideoEnabled.RemoveDynamic(this, &UDolbyIOEnableVideo::OnVideoEnabledImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -165,6 +190,11 @@ void UDolbyIODisableVideo::Activate()
void UDolbyIODisableVideo::OnVideoDisabledImpl(const FString& VideoTrackID)
{
OnVideoDisabled.Broadcast(VideoTrackID);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnVideoDisabled.RemoveDynamic(this, &UDolbyIODisableVideo::OnVideoDisabledImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -190,6 +220,12 @@ void UDolbyIOGetScreenshareSources::Activate()
void UDolbyIOGetScreenshareSources::OnScreenshareSourcesReceivedImpl(const TArray<FDolbyIOScreenshareSource>& Sources)
{
OnScreenshareSourcesReceived.Broadcast(Sources);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnScreenshareSourcesReceived.RemoveDynamic(
this, &UDolbyIOGetScreenshareSources::OnScreenshareSourcesReceivedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -217,6 +253,11 @@ void UDolbyIOStartScreenshare::Activate()
void UDolbyIOStartScreenshare::OnScreenshareStartedImpl(const FString& VideoTrackID)
{
OnScreenshareStarted.Broadcast(VideoTrackID);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnScreenshareStarted.RemoveDynamic(this, &UDolbyIOStartScreenshare::OnScreenshareStartedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand All @@ -240,6 +281,11 @@ void UDolbyIOStopScreenshare::Activate()
void UDolbyIOStopScreenshare::OnScreenshareStoppedImpl(const FString& VideoTrackID)
{
OnScreenshareStopped.Broadcast(VideoTrackID);

if (UDolbyIOSubsystem* DolbyIOSubsystem = GetDolbyIOSubsystem(WorldContextObject))
{
DolbyIOSubsystem->OnScreenshareStopped.RemoveDynamic(this, &UDolbyIOStopScreenshare::OnScreenshareStoppedImpl);
}
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions DolbyIO/Source/Private/DolbyIOObserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "DolbyIOSubsystem.h"

#include "Async/Async.h"
#include "Engine/GameInstance.h"
#include "Engine/World.h"

UDolbyIOObserver::UDolbyIOObserver()
Expand Down
6 changes: 5 additions & 1 deletion DolbyIO/Source/Private/DolbyIOSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "DolbyIOVideoSink.h"

#include "Async/Async.h"
#include "Engine/GameInstance.h"
#include "Engine/World.h"
#include "GameFramework/Pawn.h"
#include "GameFramework/PlayerController.h"
#include "TimerManager.h"

Expand Down Expand Up @@ -376,6 +378,8 @@ void UDolbyIOSubsystem::DemoConference()
return;
}

ConnectionMode = EDolbyIOConnectionMode::Active;
SpatialAudioStyle = EDolbyIOSpatialAudioStyle::Shared;
DLB_UE_LOG("Connecting to demo conference");

Sdk->session()
Expand All @@ -384,7 +388,7 @@ void UDolbyIOSubsystem::DemoConference()
[this](services::session::user_info&& User)
{
LocalParticipantID = ToFString(User.participant_id.value_or(""));
return Sdk->conference().demo(spatial_audio_style::shared);
return Sdk->conference().demo(ToSdkSpatialAudioStyle(SpatialAudioStyle));
})
.then(
[this](conference_info&& ConferenceInfo)
Expand Down
1 change: 1 addition & 0 deletions DolbyIO/Source/Private/DolbyIOVideoSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Engine/Texture2D.h"
#include "Materials/MaterialInstanceDynamic.h"
#include "Runtime/Launch/Resources/Version.h"
#include "TextureResource.h"

namespace DolbyIO
{
Expand Down
2 changes: 1 addition & 1 deletion DolbyIO/Source/Public/DolbyIOSpatialAudioStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "DolbyIOSpatialAudioStyle.generated.h"

/** The possible spatial audio styles of the conference. */
UENUM(BlueprintType, DisplayName = "Dolby.io Connection Mode")
UENUM(BlueprintType, DisplayName = "Dolby.io Spatial Audio Style")
enum class EDolbyIOSpatialAudioStyle : uint8
{
/** Spatial audio is disabled. */
Expand Down
28 changes: 20 additions & 8 deletions docs/docs/tutorial/camera-preview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_position: 5
sidebar_label: Camera preview
title: Camera preview
sidebar_position: 4
sidebar_label: Camera Preview
title: Camera Preview
---

This tutorial explains how to render a preview of your camera feed.
Expand All @@ -12,18 +12,30 @@ Before you start, [set up](common-setup) your project and follow the [video plan

## Set up camera preview

1. Open the video plane's `Event Graph` and add handlers for the [`On Video Enabled`](../blueprints/Events/on-video-enabled) and [`On Video Disabled`](../blueprints/Events/on-video-disabled) events of the `DolbyIOObserver` and wire them up as in the following example:
1. Find `BP_DolbyIOVideoPreviewPlane` in the plugin's content in `Content Browser` and drag it onto the scene.

![](../../static/img/camera-preview-eg.png)
> **_NOTE:_** If you do not see this item, go to the `Content Browser` settings and tick `Show Plugin Content`.
2. Rescale the plane to the desired aspect ratio, for example, [6.4, 3.6, 1.0], and rotate it by [90, 0, 90] to make it face the player start, as in the following example:

This automatically makes the plane render your camera feed when it is enabled and go blank when disabled.
![](../../static/img/video-plane-result.png)

2. Test the camera preview by going to the `BP_FirstPersonCharacter` Blueprint and adding the following nodes to enable video with the "V" key and disable it with the "B" key:
3. Test the camera preview by going to the `BP_FirstPersonCharacter` Blueprint and adding the following nodes to enable video with the "V" key and disable it with the "B" key:

![](../../static/img/camera-preview-toggle.png)

If you launch the game now, assuming the plugin is initialized correctly, you should see your camera feed on the plane when you press "V" and the plane should go blank when you press "B".

![](../../static/img/camera-preview-result.png)

As a useful practical exercise, you can also make the plane invisible by default, visible when video is enabled, and invisible again when it is disabled.
## How it works

`BP_DolbyIOVideoPreviewPlane` is a sample Blueprint with a simple `Event Graph`, which handles [`On Video Enabled`](../blueprints/Events/on-video-enabled) and [`On Video Disabled`](../blueprints/Events/on-video-enabled).

![](../../static/img/camera-preview-eg.png)

It also contains a generic `Construction Script` to set up the plane's material:

![](../../static/img/video-plane-cs.png)

As a useful practical exercise, you can also make the plane invisible by default, then make it visible when video is enabled and invisible again when it is disabled.
26 changes: 6 additions & 20 deletions docs/docs/tutorial/common-setup.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
sidebar_position: 3
sidebar_label: Common tutorial setup
title: Common tutorial setup
sidebar_label: Common Tutorial Setup
title: Common Tutorial Setup
---

This tutorial explains how to initialize the plugin and set up video material.
This tutorial explains how to initialize the plugin.

## Prerequisites

Make sure that you use a scene setup and the Unreal Engine 5 First Person game template.
The tutorials and samples are designed to work with the Unreal Engine 5 First Person game template.

The sample Blueprints included with the plugin are designed in Unreal Engine 5 and will not work with Unreal Engine 4. You can still use Unreal Engine 4 to follow the tutorials but you will not be able to use the sample Blueprints and will need to create them from scratch.

## Initialize the plugin

Expand All @@ -23,19 +25,3 @@ You can initialize the plugin from multiple places, such as the game instance or
In development, you may also use the [`Get Dolby.io Token`](../blueprints/Functions/get-token) helper to use your app key and secret instead.

After this step, you should connect to a conference that has a name that you specified in the [`Dolby.io Connect`](../blueprints/Functions/connect) node upon starting your game. If you cannot connect, follow the [Getting started - first conference](first-conference) tutorial first.

## Set up a video material

If you intend to work with video, set up a material for easy rendering using the [`Dolby.io Bind Material`](../blueprints/Functions/bind-material) function.

1. Create a new material anywhere within Content, name it `M_DolbyIOVideo`, and open its editor.

2. Add a `Texture Sample` node, for example, 'T' + left click, right-click the node and select `Convert to Parameter`. Name this parameter `DolbyIO Frame`.

3. To properly set up this material, you need to give this node a base texture that will be displayed when there is no video to be displayed. For example, you can select UE4_LOGO_CARD. Then, wire it up as in the following example:

![](../../static/img/common-setup-video-material.png)

All names in this tutorial are only suggestions, except the `DolbyIO Frame` parameter name, which is necessary because [`Dolby.io Bind Material`](../blueprints/Functions/bind-material) requires this specific name.

You can also modify your own material and simply add a texture parameter named `DolbyIO Frame`. Then, you can use it however you wish.
2 changes: 1 addition & 1 deletion docs/docs/tutorial/cpp.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 9
sidebar_position: 8
sidebar_label: Using the Plugin with C++
title: Using the Plugin with C++
---
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/tutorial/first-conference.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_position: 2
sidebar_label: Getting started - first conference
title: Getting started - first conference
sidebar_label: Getting Started - First Conference
title: Getting Started - First Conference
---

The following steps present how to create a sample game which uses the plugin and connects to a demo conference. It is based on the Unreal Engine 5 First Person game template.
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/tutorial/obtain-permissions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_position: 10
sidebar_label: macOS permissions
title: macOS permissions
sidebar_position: 9
sidebar_label: macOS Permissions
title: macOS Permissions
---

> **_NOTE:_** macOS only - ignore this section if you are developing on Windows.
Expand Down
26 changes: 21 additions & 5 deletions docs/docs/tutorial/remote-screenshare.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_position: 8
sidebar_label: Rendering remote screenshare
title: Rendering remote screenshare
sidebar_position: 7
sidebar_label: Rendering Remote Screen Share
title: Rendering Remote Screen Share
---

This tutorial explains how to render screen share feeds coming from remote participants.
Expand All @@ -12,8 +12,24 @@ Before you start, follow the [common setup](common-setup) tutorial and the [vide

## Set up a remote screen share preview

Open the video plane's `Event Graph` and add handlers for the [`On Video Track Added`](../blueprints/Events/on-video-track-added) and [`On Video Track Removed`](../blueprints/Events/on-video-track-removed) events of the `DolbyIOObserver` and wire them up as in the following example:
1. Find `BP_DolbyIOScreensharePlane` in the plugin's content in `Content Browser` and drag it onto the scene.

![](../../static/img/remote-screenshare-eg.png)
> **_NOTE:_** If you do not see this item, go to the `Content Browser` settings and tick `Show Plugin Content`.
2. Rescale the plane to the desired aspect ratio, for example, [6.4, 3.6, 1.0], and rotate it by [90, 0, 90] to make it face the player start, as in the following example:

![](../../static/img/video-plane-result.png)

If you launch the game now, assuming you successfully connect to a conference with screen share enabled, you should see the screen share feed on the plane.

## How it works

`BP_DolbyIOScreensharePlane` is a sample Blueprint with a simple `Event Graph`, which handles [`On Video Track Added`](../blueprints/Events/on-video-track-added) and [`On Video Track Removed`](../blueprints/Events/on-video-track-removed).

![](../../static/img/remote-screenshare-eg.png)

It also contains a generic `Construction Script` to set up the plane's material:

![](../../static/img/video-plane-cs.png)

As a useful practical exercise, you can also make the plane invisible by default, then make it visible when screenshare is started and invisible again when it is stopped.
28 changes: 22 additions & 6 deletions docs/docs/tutorial/remote-video.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
sidebar_position: 7
sidebar_label: Rendering remote video
title: Rendering remote video
sidebar_position: 6
sidebar_label: Rendering Remote Video
title: Rendering Remote Video
---

This tutorial explains how to render camera video coming from other participants.
Expand All @@ -12,10 +12,26 @@ Before you start, follow the [common setup](common-setup) tutorial and the [vide

## Set up remote video rendering

Open the video plane's `Event Graph` and add handlers for the [`On Video Track Added`](../blueprints/Events/on-video-track-added) and [`On Video Track Removed`](../blueprints/Events/on-video-track-removed) events of the `DolbyIOObserver` and wire them up as in the following example:
1. Find `BP_DolbyIOSingleVideoPlane` in the plugin's content in `Content Browser` and drag it onto the scene.

![](../../static/img/remote-video-eg.png)
> **_NOTE:_** If you do not see this item, go to the `Content Browser` settings and tick `Show Plugin Content`.
> **_NOTE:_** This particular implementation allows only one remote video feed. However, you can also create multiple planes, assign them to specific participants, and heavily modify this sample.
2. Rescale the plane to the desired aspect ratio, for example, [6.4, 3.6, 1.0], and rotate it by [90, 0, 90] to make it face the player start, as in the following example:

![](../../static/img/video-plane-result.png)

If you launch the game now, assuming you successfully connect to a conference with at least one remote participant video enabled, you should see one video feed on the plane.

> **_NOTE:_** This particular implementation allows only one remote video feed. However, you can also create multiple planes, assign them to specific participants, and heavily modify this sample.
## How it works

`BP_DolbyIOSingleVideoPlane` is a sample Blueprint with a simple `Event Graph`, which handles [`On Video Track Added`](../blueprints/Events/on-video-track-added) and [`On Video Track Removed`](../blueprints/Events/on-video-track-removed).

![](../../static/img/remote-video-eg.png)

It also contains a generic `Construction Script` to set up the plane's material:

![](../../static/img/video-plane-cs.png)

As a useful practical exercise, you can also make the plane invisible by default, then make it visible when screenshare is started and invisible again when it is stopped.
Loading

0 comments on commit 6ef2d1e

Please sign in to comment.