Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Binaries
Intermediate
54 changes: 29 additions & 25 deletions GStreamer/GStreamer.uplugin
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "0.0.1",
"FriendlyName": "GStreamer",
"Description": "",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"Category": "Media",
"CanContainContent": true,
"Modules": [
{
"Name": "GStreamer",
"Type": "Runtime",
"LoadingPhase": "PostEngineInit"
}
],
"Plugins": [
{
"Name": "GStreamerLoader",
"Enabled": true
}
]
}
{
"FileVersion": 3,
"Version": 1,
"VersionName": "0.0.1",
"FriendlyName": "GStreamer",
"Description": "",
"Category": "Simbotic",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "GStreamer",
"Type": "Runtime",
"LoadingPhase": "PostEngineInit"
}
],
"Plugins": [
{
"Name": "GStreamerLoader",
"Enabled": true
}
]
}
2 changes: 1 addition & 1 deletion GStreamer/Source/GStreamer/Private/GstAppSinkComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

DECLARE_DYNAMIC_MULTICAST_DELEGATE_FiveParams(FGstTextureCreatedSignature, UGstAppSinkComponent*, AppSink, UTexture2D*, NewTexture, EGstVideoFormat, Format, int, Width, int, Height);

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
UCLASS( ClassGroup=(Simbotic), meta=(BlueprintSpawnableComponent) )
class GSTREAMER_API UGstAppSinkComponent : public UGstElementComponent, public IGstAppSinkCallback, public IGstTextureCallback
{
GENERATED_BODY()
Expand Down
15 changes: 11 additions & 4 deletions GStreamer/Source/GStreamer/Private/GstAppSrcComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ void UGstAppSrcComponent::TickComponent(float DeltaTime, ELevelTick TickType, FA
{
USceneCaptureComponent2D *CaptureComponent = Cast<USceneCaptureComponent2D>(ComponentReference.GetComponent(Actor));
UTextureRenderTarget2D *TextureTarget = CaptureComponent->TextureTarget;
TArray<FColor> TextureData;
FTextureRenderTargetResource *TextureResource = TextureTarget->GameThread_GetRenderTargetResource();
TextureResource->ReadPixels(TextureData);
AppSrc->PushTexture((uint8_t *)TextureData.GetData(), TextureData.Num() * 4);
if (TextureTarget)
{
TArray<FColor> TextureData;
FTextureRenderTargetResource *TextureResource = TextureTarget->GameThread_GetRenderTargetResource();
TextureResource->ReadPixels(TextureData);
AppSrc->PushTexture((uint8_t *)TextureData.GetData(), TextureData.Num() * 4);
}
else
{
GST_LOG_ERR(TEXT("GstAppSrc: Missing TextureTarget"));
}
}
}
}
2 changes: 1 addition & 1 deletion GStreamer/Source/GStreamer/Private/GstAppSrcComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "GstVideoFormat.h"
#include "GstAppSrcComponent.generated.h"

UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
UCLASS(ClassGroup = (Simbotic), meta = (BlueprintSpawnableComponent))
class GSTREAMER_API UGstAppSrcComponent : public UGstElementComponent
{
GENERATED_BODY()
Expand Down
2 changes: 1 addition & 1 deletion GStreamer/Source/GStreamer/Private/GstElementComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Components/SceneComponent.h"
#include "GstElementComponent.generated.h"

UCLASS( ClassGroup=(Custom) )
UCLASS( ClassGroup=(Simbotic) )
class GSTREAMER_API UGstElementComponent : public UActorComponent
{
GENERATED_BODY()
Expand Down
2 changes: 1 addition & 1 deletion GStreamer/Source/GStreamer/Private/GstPipelineComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "GstPipelineImpl.h"
#include "GstPipelineComponent.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
UCLASS( ClassGroup=(Simbotic), meta=(BlueprintSpawnableComponent) )
class GSTREAMER_API UGstPipelineComponent : public UGstElementComponent
{
GENERATED_BODY()
Expand Down
11 changes: 4 additions & 7 deletions GStreamer/Source/GStreamer/Private/GstTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ void FGstTexture::TickGameThread()
if (m_TextureObject)
{
// render commands should be submitted only from game thread
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
UpdateTextureCmd,
FGstTexture*, Context, this,
IGstSample*, Sample, Sample,
FGstTexture* Context = this;
ENQUEUE_RENDER_COMMAND(UpdateTextureCmd)([Context, Sample](FRHICommandListImmediate& RHICmdList)
{
Context->RenderCmd_UpdateTexture(Sample);
});
Expand Down Expand Up @@ -146,9 +144,8 @@ void FGstTexture::Resize(IGstSample* Sample)
m_Height = Sample->GetHeight();
m_Pitch = m_Width * GPixelFormats[m_UeFormat].BlockBytes;

ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(
CreateTextureCmd,
FGstTexture*, Context, this,
FGstTexture* Context = this;
ENQUEUE_RENDER_COMMAND(CreateTextureCmd)([Context](FRHICommandListImmediate& RHICmdList)
{
Context->RenderCmd_CreateTexture();
});
Expand Down
2 changes: 1 addition & 1 deletion GStreamer/Source/GStreamer/Public/GStreamerModule.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "ModuleManager.h"
#include "Modules/ModuleManager.h"

class GSTREAMER_API IGStreamerModule : public IModuleInterface
{
Expand Down
43 changes: 23 additions & 20 deletions GStreamerLoader/GStreamerLoader.uplugin
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
{
"FileVersion" : 3,
"Version" : 1,
"VersionName" : "0.0.1",
"FriendlyName" : "GStreamerLoader",
"Description" : "",
"CreatedBy" : "",
"CreatedByURL" : "",
"DocsURL" : "",
"Category" : "Media",
"CanContainContent" : false,
"Modules" :
[
{
"Name" : "GStreamerLoader",
"Type": "Runtime",
"LoadingPhase" : "PostConfigInit"
}
]
}
{
"FileVersion": 3,
"Version": 1,
"VersionName": "0.0.1",
"FriendlyName": "GStreamerLoader",
"Description": "",
"Category": "Simbotic",
"CreatedBy": "",
"CreatedByURL": "",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": false,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "GStreamerLoader",
"Type": "Runtime",
"LoadingPhase": "PostConfigInit"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "ModuleManager.h"
#include "Modules/ModuleManager.h"

class GSTREAMERLOADER_API IGStreamerLoaderModule : public IModuleInterface
{
Expand Down
43 changes: 40 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,55 @@

# Setup

- Clone this repository:
- Clone this repository in the `Plugins` directory of your UE4 project:

```
git clone [email protected]:Simbotic/ue4-gst-plugin.git
```
git clone [email protected]:racsoraul/ue4-gst-plugin.git

- Update your `.uproject` adding the `Engine` as additional dependency and the `GStreamer` plugin:

```
...,
"Modules": [
{
"Name": "GST_Test",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
],
"Plugins": [
{
"Name": "GStreamer",
"Enabled": true
},
],
...

```
- Add, in the constructors of the classes of your project: `Source/PROJECT_NAME.Target.cs` and `Source/PROJECT_NAMEEditor.Target.cs` the following:
```
bUseUnityBuild = false;
bUsePCHFiles = false;
```
- Copy content in the `Plugins` directory of your UE4 project.

# Usage

Blueprints:

![gst-plugin-ue4 blueprints](docs/media/gst_pipeline.png)

GstAppSrc component:

![gst-plugin-ue4 blueprints](docs/media/GstAppSrc.png)

GstPipeline component:

![gst-plugin-ue4 blueprints](docs/media/GstPipeline.png)

Details panel:

![gst-plugin-ue4 details panel](docs/media/details_panel.png)
Binary file added docs/media/GstAppSrc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/GstPipeline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/media/details_panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.