Added ndi receiver and sdi outputs

This commit is contained in:
mchara40
2025-08-25 13:16:29 +03:00
parent 11b8be19f6
commit d046828313
125 changed files with 14757 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
/*
Copyright (C) 2024 Vizrt NDI AB. All rights reserved.
This file and its use within a Product is bound by the terms of NDI SDK license that was provided
as part of the NDI SDK. For more information, please review the license and the NDI SDK documentation.
*/
#pragma once
#include <CoreMinimal.h>
#include <Components/ActorComponent.h>
#include <Objects/Media/NDIMediaSender.h>
#include <Structures/NDIBroadcastConfiguration.h>
#include "NDIBroadcastComponent.generated.h"
/**
Provides a wrapper to allow you to modify an NDI Media Sender object from blueprints and perform broadcasting
functionality
*/
UCLASS(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI Broadcast Component", BlueprintSpawnableComponent))
class NDIIO_API UNDIBroadcastComponent : public UActorComponent
{
GENERATED_UCLASS_BODY()
private:
/** The NDI Media Sender representing the configuration of the network source to send audio, video, and metadata */
UPROPERTY(EditDefaultsOnly, Category = "Properties",
META = (DisplayName = "NDI Media Source", AllowPrivateAccess = true))
UNDIMediaSender* NDIMediaSource = nullptr;
public:
/**
Initialize this component with the media source required for sending NDI audio, video, and metadata.
Returns false, if the MediaSource is already been set. This is usually the case when this component is
initialized in Blueprints.
*/
bool Initialize(UNDIMediaSender* InMediaSource = nullptr);
/**
Attempts to start broadcasting audio, video, and metadata via the 'NDIMediaSource' associated with this object
@param ErrorMessage The error message received when the media source is unable to start broadcasting
@result Indicates whether this object successfully started broadcasting
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Start Broadcasting"))
bool StartBroadcasting(FString& ErrorMessage);
/**
Changes the name of the sender object as seen on the network for remote connections
@param InSourceName The new name of the source to be identified as on the network
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Source Name"))
void ChangeSourceName(const FString& InSourceName);
/**
Attempts to change the Broadcast information associated with this media object
@param InConfiguration The new configuration to broadcast
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Broadcast Configuration"))
void ChangeBroadcastConfiguration(const FNDIBroadcastConfiguration& InConfiguration);
/**
Attempts to change the RenderTarget used in sending video frames over NDI
@param BroadcastTexture The texture to use as video, while broadcasting over NDI
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Broadcast Texture"))
void ChangeBroadcastTexture(UTextureRenderTarget2D* BroadcastTexture = nullptr);
/**
Determines the current tally information.
@param IsOnPreview - A state indicating whether this source in on preview of a receiver
@param IsOnProgram - A state indicating whether this source is on program of a receiver
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Tally Information"))
void GetTallyInformation(bool& IsOnPreview, bool& IsOnProgram);
/**
Gets the current number of receivers connected to this source. This can be used to avoid rendering
when nothing is connected to the video source. which can significantly improve the efficiency if
you want to make a lot of sources available on the network
@param Result The total number of connected receivers attached to the broadcast of this object
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Number of Connections"))
void GetNumberOfConnections(int32& Result);
/**
Attempts to immediately stop sending frames over NDI to any connected receivers
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Stop Broadcasting"))
void StopBroadcasting();
};

View File

@@ -0,0 +1,79 @@
/*
Copyright (C) 2024 Vizrt NDI AB. All rights reserved.
This file and its use within a Product is bound by the terms of NDI SDK license that was provided
as part of the NDI SDK. For more information, please review the license and the NDI SDK documentation.
*/
#pragma once
#include <CoreMinimal.h>
#include <Components/ActorComponent.h>
#include <Structures/NDIConnectionInformation.h>
#include "NDIFinderComponent.generated.h"
/** Delegates **/
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FNDIFinderServiceCollectionChangedDelegate, UNDIFinderComponent*,
InComponent);
/** ******************* **/
/**
A component used for essential functionality when dealing with the finder service. Allowing you to
get a collection of sources found on the network.
*/
UCLASS(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI Finder Component", BlueprintSpawnableComponent))
class NDIIO_API UNDIFinderComponent : public UActorComponent
{
GENERATED_UCLASS_BODY()
public:
/** A collection of the current sources and their information, found on the network */
UPROPERTY()
TArray<FNDIConnectionInformation> NetworkSourceCollection;
/** A delegate which is broadcast when any change to the network source collection has been detected */
UPROPERTY(BlueprintAssignable, META = (DisplayName = "On Network Sources Changed", AllowPrivateAccess = true))
FNDIFinderServiceCollectionChangedDelegate OnNetworkSourcesChanged;
public:
/**
Attempts to find a network source by the supplied name.
@param ConnectionInformation An existing source information structure which contains the source name
@param InSourceName A string value representing the name of the source to find
@result A value indicating whether a source with the supplied name was found
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Find Network Source by Name"))
const bool FindNetworkSourceByName(FNDIConnectionInformation& ConnectionInformation,
FString InSourceName = FString(""));
/**
Returns the current collection of sources found on the network
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "NDI IO", META = (DisplayName = "Get Network Sources"))
const TArray<FNDIConnectionInformation> GetNetworkSources();
protected:
virtual void BeginPlay() override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
/** An override function for when the network source collection has been changed */
UFUNCTION(BlueprintImplementableEvent, META = (DisplayName = "On Network Sources Changed Event"))
void OnNetworkSourcesChangedEvent();
private:
/**
An Event handler for when the NDI Finder Service notifies listeners that changes have been
detected in the network source collection
*/
UFUNCTION()
virtual void OnNetworkSourceCollectionChangedEvent() final;
private:
FCriticalSection CollectionSyncContext;
};

View File

@@ -0,0 +1,174 @@
/*
Copyright (C) 2024 Vizrt NDI AB. All rights reserved.
This file and its use within a Product is bound by the terms of NDI SDK license that was provided
as part of the NDI SDK. For more information, please review the license and the NDI SDK documentation.
*/
#pragma once
#include <CoreMinimal.h>
#include <UObject/Interface.h>
#include <Components/ActorComponent.h>
#include <Objects/Media/NDIMediaSender.h>
#include "NDIPTZControllerComponent.generated.h"
USTRUCT(BlueprintType, Blueprintable, Category = "NDI IO", META = (DisplayName = "NDI PTZ State"))
struct NDIIO_API FPTZState
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PTZ")
float Pan;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PTZ")
float Tilt;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PTZ")
float FieldOfView;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PTZ")
float FocusDistance;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PTZ")
bool bAutoFocus;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PTZ")
FTransform CameraTransform;
FPTZState()
: Pan(0.f)
, Tilt(0.f)
, FieldOfView(90.f)
, FocusDistance(0.5f)
, bAutoFocus(false)
{}
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FNDIEventDelegate_OnPTZPanTiltSpeed, float, PanSpeed, float, TiltSpeed);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FNDIEventDelegate_OnPTZZoomSpeed, float, ZoomSpeed);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FNDIEventDelegate_OnPTZFocus, bool, AutoMode, float, Distance);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FNDIEventDelegate_OnPTZStore, int, Index);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FNDIEventDelegate_OnPTZRecall, int, Index);
UINTERFACE(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI PTZ Controllable", BlueprintSpawnableComponent))
class NDIIO_API UPTZControllableInterface : public UInterface
{
GENERATED_BODY()
};
class IPTZControllableInterface
{
GENERATED_BODY()
public:
virtual FPTZState GetPTZStateFromUE() const = 0;
virtual void SetPTZStateToUE(const FPTZState& PTZState) = 0;
};
UCLASS(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI PTZ Controller", BlueprintSpawnableComponent))
class UPTZController : public UActorComponent
{
GENERATED_BODY()
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Enable PTZ", AllowPrivateAccess = true), Category="PTZ")
bool EnablePTZ = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Pan Limit", AllowPrivateAccess = true), Category="PTZ")
bool PTZWithPanLimit = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Pan Min Limit", UIMin="-180", UIMax="180", AllowPrivateAccess = true), Category="PTZ")
float PTZPanMinLimit = -180.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Pan Max Limit", UIMin="-180", UIMax="180", AllowPrivateAccess = true), Category="PTZ")
float PTZPanMaxLimit = 180.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Invert Pan", AllowPrivateAccess = true), Category="PTZ")
bool bPTZPanInvert = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Tilt Limit", AllowPrivateAccess = true), Category="PTZ")
bool PTZWithTiltLimit = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Tilt Min Limit", UIMin="-180", UIMax="180", AllowPrivateAccess = true), Category="PTZ")
float PTZTiltMinLimit = -90.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Tilt Max Limit", UIMin="-180", UIMax="180", AllowPrivateAccess = true), Category="PTZ")
float PTZTiltMaxLimit = 90.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Invert Tilt", AllowPrivateAccess = true), Category="PTZ")
bool bPTZTiltInvert = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Field of View Limit", AllowPrivateAccess = true), Category="PTZ")
bool PTZWithFoVLimit = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Field of View Min Limit", UIMin="5", UIMax="170", AllowPrivateAccess = true), Category="PTZ")
float PTZFoVMinLimit = 5.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Field of View Max Limit", UIMin="5", UIMax="170", AllowPrivateAccess = true), Category="PTZ")
float PTZFoVMaxLimit = 170.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Preset Recall Easing", UIMin="0", UIMax="60", AllowPrivateAccess = true), Category="PTZ")
float PTZRecallEasing = 2.f;
UPROPERTY(BlueprintReadWrite, meta=(AllowPrivateAccess = true), Category="PTZ")
float PTZPanSpeed = 0.f;
UPROPERTY(BlueprintReadWrite, meta=(AllowPrivateAccess = true), Category="PTZ")
float PTZTiltSpeed = 0.f;
UPROPERTY(BlueprintReadWrite, meta=(AllowPrivateAccess = true), Category="PTZ")
float PTZZoomSpeed = 0.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="PTZ Presets", AllowPrivateAccess = true), Category="PTZ")
TArray<FPTZState> PTZStoredStates;
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "NDI IO", META = (DisplayName = "NDI Media Source", AllowPrivateAccess = true))
UNDIMediaSender* NDIMediaSource = nullptr;
UPROPERTY(BlueprintAssignable, Category="NDI Events", META = (DisplayName = "On PTZ Pan Tilt Speed", AllowPrivateAccess = true))
FNDIEventDelegate_OnPTZPanTiltSpeed OnPTZPanTiltSpeed;
UPROPERTY(BlueprintAssignable, Category="NDI Events", META = (DisplayName = "On PTZ Zoom Speed", AllowPrivateAccess = true))
FNDIEventDelegate_OnPTZZoomSpeed OnPTZZoomSpeed;
UPROPERTY(BlueprintAssignable, Category="NDI Events", META = (DisplayName = "On PTZ Focus", AllowPrivateAccess = true))
FNDIEventDelegate_OnPTZFocus OnPTZFocus;
UPROPERTY(BlueprintAssignable, Category="NDI Events", META = (DisplayName = "On PTZ Store", AllowPrivateAccess = true))
FNDIEventDelegate_OnPTZStore OnPTZStore;
UPROPERTY(BlueprintAssignable, Category="NDI Events", META = (DisplayName = "On PTZ Recall", AllowPrivateAccess = true))
FNDIEventDelegate_OnPTZRecall OnPTZRecall;
public:
/** Call with the PTZ metadata received from an NDI media sender */
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Receive Metadata From Sender"))
void ReceiveMetaDataFromSender(UNDIMediaSender* Sender, FString Data);
public:
UPTZController();
virtual ~UPTZController();
/**
Initialize this component with the required media source to receive metadata from.
Returns false, if the MediaSource is already been set. This is usually the case when this component is
initialized in Blueprints.
*/
bool Initialize(UNDIMediaSender* InMediaSource = nullptr);
void SetPTZPanTiltSpeed(float PanSpeed, float TiltSpeed);
void SetPTZZoomSpeed(float ZoomSpeed);
void SetPTZFocus(bool AutoMode, float Distance);
void StorePTZState(int Index);
void RecallPTZState(int Index);
FPTZState GetPTZStateFromUE() const;
void SetPTZStateToUE(const FPTZState& PTZState);
protected:
virtual void InitializeComponent() override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
protected:
TSharedPtr<class NDIXmlParser> NDIMetadataParser;
struct FPTZStateInterp
{
FPTZState PTZTargetState;
float EasingDuration { 0 };
float EasingRemaining { 0 };
};
FPTZStateInterp PTZStateInterp;
};

View File

@@ -0,0 +1,97 @@
/*
Copyright (C) 2024 Vizrt NDI AB. All rights reserved.
This file and its use within a Product is bound by the terms of NDI SDK license that was provided
as part of the NDI SDK. For more information, please review the license and the NDI SDK documentation.
*/
#pragma once
#include <CoreMinimal.h>
#include <Components/ActorComponent.h>
#include <Structures/NDIConnectionInformation.h>
#include <Objects/Media/NDIMediaReceiver.h>
#include "NDIReceiverComponent.generated.h"
/**
A component used to receive audio, video, and metadata over NDI
*/
UCLASS(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI Receiver Component", BlueprintSpawnableComponent))
class NDIIO_API UNDIReceiverComponent : public UActorComponent
{
GENERATED_UCLASS_BODY()
private:
/** The NDI Media Receiver representing the configuration of the network source to receive audio, video, and
* metadata from */
UPROPERTY(EditDefaultsOnly, Category = "Properties",
META = (DisplayName = "NDI Media Source", AllowPrivateAccess = true))
UNDIMediaReceiver* NDIMediaSource = nullptr;
public:
/**
Initialize this component with the media source required for receiving NDI audio, video, and metadata.
Returns false, if the MediaSource is already been set. This is usually the case when this component is
initialized in Blueprints.
*/
bool Initialize(UNDIMediaReceiver* InMediaSource = nullptr);
/**
Begin receiving NDI audio, video, and metadata frames
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Start Receiver"))
bool StartReceiver(const FNDIConnectionInformation& InConnectionInformation);
/**
Attempt to change the connection for which to get audio, video, and metadata frame from
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Connection"))
void ChangeConnection(const FNDIConnectionInformation& InConnectionInformation);
/**
This will add a metadata frame and return immediately, having scheduled the frame asynchronously
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Send Metadata Frame"))
void SendMetadataFrame(const FString& metadata);
/**
This will setup the up-stream tally notifications. If no streams are connected, it will automatically send
the tally state upon connection
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Send Tally Information"))
void SendTallyInformation(const bool& IsOnPreview, const bool& IsOnProgram);
/**
Attempts to stop receiving audio, video, and metadata frame from the connected source
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Shutdown Receiver"))
void ShutdownReceiver();
public:
/**
Returns the current framerate of the connected source
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Current Frame Rate"))
FFrameRate GetCurrentFrameRate() const;
/**
Returns the current timecode of the connected source
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Current Timecode"))
FTimecode GetCurrentTimecode() const;
/**
Returns the current connection information of the connected source
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Current Connection Information"))
FNDIConnectionInformation GetCurrentConnectionInformation() const;
/**
Returns the current performance data of the receiver while connected to the source
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Performance Data"))
FNDIReceiverPerformanceData GetPerformanceData() const;
};

View File

@@ -0,0 +1,91 @@
/*
Copyright (C) 2024 Vizrt NDI AB. All rights reserved.
This file and its use within a Product is bound by the terms of NDI SDK license that was provided
as part of the NDI SDK. For more information, please review the license and the NDI SDK documentation.
*/
#pragma once
#include <CoreMinimal.h>
#include <UObject/UnrealType.h>
#include <Objects/Media/NDIMediaSender.h>
#include <Components/ActorComponent.h>
#include "NDITriCasterExtComponent.generated.h"
USTRUCT(BlueprintType, Blueprintable, Category = "NDI IO", META = (DisplayName = "NDI TricasterExt"))
struct NDIIO_API FTriCasterExt
{
GENERATED_USTRUCT_BODY()
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="TricasterExt")
FString Value;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="TricasterExt")
TMap<FName,FString> KeyValues;
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FNDIEventDelegate_OnTriCasterExt, AActor*, Actor, UObject*, Object, FString, PropertyElementName, FString, PropertyValueStr, FTimespan, EasingDuration);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FNDIEventDelegate_OnTriCasterExtCustom, const FTriCasterExt&, TCData);
UCLASS(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI TricasterExt Component", BlueprintSpawnableComponent))
class UTriCasterExtComponent : public UActorComponent
{
GENERATED_BODY()
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta=(DisplayName="Enable TricasterExt", AllowPrivateAccess = true), Category="TricasterExt")
bool EnableTriCasterExt = true;
UPROPERTY(BlueprintReadWrite, EditInstanceOnly, Category = "NDI IO", META = (DisplayName = "NDI Media Source", AllowPrivateAccess = true))
UNDIMediaSender* NDIMediaSource = nullptr;
UPROPERTY(BlueprintAssignable, BlueprintCallable, Category="NDI Events", META = (DisplayName = "On TricasterExt", AllowPrivateAccess = true))
FNDIEventDelegate_OnTriCasterExt OnTriCasterExt;
UPROPERTY(BlueprintAssignable, BlueprintCallable, Category="NDI Events", META = (DisplayName = "On TricasterExt Custom", AllowPrivateAccess = true))
FNDIEventDelegate_OnTriCasterExtCustom OnTriCasterExtCustom;
public:
/** Call with the TriCasterExt metadata received from an NDI media sender */
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Receive Metadata From Sender"))
void ReceiveMetaDataFromSender(UNDIMediaSender* Sender, FString Data);
public:
UTriCasterExtComponent();
virtual ~UTriCasterExtComponent();
/**
Initialize this component with the required media source to receive metadata from.
Returns false, if the MediaSource is already been set. This is usually the case when this component is
initialized in Blueprints.
*/
bool Initialize(UNDIMediaSender* InMediaSource = nullptr);
void TriCasterExt(AActor* Actor, UObject* Object, FProperty* Property, FString PropertyElementName, FString PropertyValueStr, FTimespan EasingDuration);
void TriCasterExtCustom(const FTriCasterExt& TCData);
protected:
virtual void InitializeComponent() override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
protected:
TSharedPtr<class NDIXmlParser> NDIMetadataParser;
struct FTriCasterExtInterp
{
AActor* Actor;
UObject* Object;
FProperty* Property;
FString PropertyElementName;
FString PropertyValueStr;
float EasingDuration;
float EasingRemaining;
};
TArray<FTriCasterExtInterp> TriCasterExtInterp;
};

View File

@@ -0,0 +1,154 @@
/*
Copyright (C) 2024 Vizrt NDI AB. All rights reserved.
This file and its use within a Product is bound by the terms of NDI SDK license that was provided
as part of the NDI SDK. For more information, please review the license and the NDI SDK documentation.
*/
#pragma once
#include <CoreMinimal.h>
#include <CineCameraComponent.h>
#include <Engine/TextureRenderTarget2D.h>
#include <Components/SceneCaptureComponent2D.h>
#include <Objects/Media/NDIMediaSender.h>
#include <Misc/FrameRate.h>
#include <Framework/Application/SlateApplication.h>
#include <SceneManagement.h>
#include <Slate/SceneViewport.h>
#include <Widgets/SViewport.h>
#include <Widgets/SWindow.h>
#include "NDIViewportCaptureComponent.generated.h"
/**
A component used to capture an additional viewport for broadcasting over NDI
*/
UCLASS(BlueprintType, Blueprintable, Category = "NDI IO",
META = (DisplayName = "NDI Viewport Capture Component", BlueprintSpawnableComponent))
class NDIIO_API UNDIViewportCaptureComponent : public USceneCaptureComponent2D
{
GENERATED_UCLASS_BODY()
private:
/**
If true, will allow you to override the capture settings by ignoring the default Broadcast Settings
in the NDI Media Sender, Potentially Requiring a texture rescale of the capture frame when broadcasting
over NDI.
*/
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Capture Settings", META = (AllowPrivateAccess = true))
bool bOverrideBroadcastSettings = false;
/**
Describes the Height and Width of the viewport frame to capture.
*/
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Capture Settings",
META = (DisplayName = "Capture Size", AllowPrivateAccess = true,
EditCondition = "bOverrideBroadcastSettings"))
FIntPoint CaptureSize = FIntPoint(1280, 720);
/**
Represents the desired number of frames (per second) to capture the viewport
*/
UPROPERTY(BlueprintReadwrite, EditAnywhere, Category = "Capture Settings",
META = (DisplayName = "Capture Rate", AllowPrivateAccess = true,
EditCondition = "bOverrideBroadcastSettings"))
FFrameRate CaptureRate = FFrameRate(60, 1);
/**
The NDI Media Sender representing the configuration of the network source to send audio, video, and metadata
*/
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Properties",
META = (DisplayName = "NDI Media Source", AllowPrivateAccess = true))
UNDIMediaSender* NDIMediaSource = nullptr;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Capture Settings",
META = (DisplayName = "Alpha Remap Min", AllowPrivateAccess = true))
float AlphaMin = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Capture Settings",
META = (DisplayName = "Alpha Remap Max", AllowPrivateAccess = true))
float AlphaMax = 1.f;
public:
/**
Initialize this component with the media source required for sending NDI audio, video, and metadata.
Returns false, if the MediaSource is already been set. This is usually the case when this component is
initialized in Blueprints.
*/
bool Initialize(UNDIMediaSender* InMediaSource = nullptr);
/**
Changes the name of the sender object as seen on the network for remote connections
@param InSourceName The new name of the source to be identified as on the network
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Source Name"))
void ChangeSourceName(const FString& InSourceName);
/**
Attempts to change the Broadcast information associated with this media object
@param InConfiguration The new configuration to broadcast
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Broadcast Configuration"))
void ChangeBroadcastConfiguration(const FNDIBroadcastConfiguration& InConfiguration);
/**
Attempts to change the RenderTarget used in sending video frames over NDI
@param BroadcastTexture The texture to use as video, while broadcasting over NDI
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Broadcast Texture"))
void ChangeBroadcastTexture(UTextureRenderTarget2D* BroadcastTexture = nullptr);
/**
Change the capture settings of the viewport capture and overrides the NDI Media Sender settings
@param InCaptureSize The Capture size of the frame to capture of the viewport
@param InCaptureRate A framerate at which to capture frames of the viewport
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Change Capture Settings"))
void ChangeCaptureSettings(FIntPoint InCaptureSize, FFrameRate InCaptureRate);
/**
Determines the current tally information. If you specify a timeout then it will wait until it has
changed, otherwise it will simply poll it and return the current tally immediately
@param IsOnPreview - A state indicating whether this source in on preview of a receiver
@param IsOnProgram - A state indicating whether this source is on program of a receiver
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Tally Information"))
void GetTallyInformation(bool& IsOnPreview, bool& IsOnProgram);
/**
Gets the current number of receivers connected to this source. This can be used to avoid rendering
when nothing is connected to the video source. which can significantly improve the efficiency if
you want to make a lot of sources available on the network
@param Result The total number of connected receivers attached to the broadcast of this object
*/
UFUNCTION(BlueprintCallable, Category = "NDI IO", META = (DisplayName = "Get Number of Connections"))
void GetNumberOfConnections(int32& Result);
protected:
virtual ~UNDIViewportCaptureComponent();
virtual void InitializeComponent() override;
virtual void UninitializeComponent() override;
#if (ENGINE_MAJOR_VERSION > 5) || ((ENGINE_MAJOR_VERSION == 5) && (ENGINE_MINOR_VERSION >= 6)) // 5.6 or later
virtual void UpdateSceneCaptureContents(FSceneInterface* Scene, ISceneRenderBuilder& SceneRenderBuilder) override;
#else
virtual void UpdateSceneCaptureContents(FSceneInterface* Scene) override;
#endif
private:
UFUNCTION()
void OnBroadcastConfigurationChanged(UNDIMediaSender* Sender);
private:
FCriticalSection UpdateRenderContext;
};