Skip to content

Commit 0bc4c08

Browse files
authored
Merge pull request #33 from AgoraIO-Extensions/dev/wangxidongfixbug
fix custom bug
2 parents 58dff7d + 4c3fa32 commit 0bc4c08

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/CustomCaptureVideoScene.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33

44
#include "CustomCaptureVideoScene.h"
5-
#include <mutex>
6-
75

86

97
void UCustomCaptureVideoScene::InitAgoraWidget(FString APP_ID, FString TOKEN, FString CHANNEL_NAME)
@@ -44,14 +42,26 @@ void UCustomCaptureVideoScene::NativeTick(const FGeometry& MyGeometry, float InD
4442
externalVideoFrame->buffer = (uint8*)FMemory::Malloc(tex->GetSizeX() * tex->GetSizeY()*4);
4543
}
4644
externalVideoFrame->timestamp = getTimeStamp();
47-
if (tex->PlatformData!=nullptr)
45+
#if ENGINE_MAJOR_VERSION > 4
46+
if (tex->GetPlatformData() != nullptr)
47+
{
48+
uint8* raw = (uint8*)tex->GetPlatformData()->Mips[0].BulkData.Lock(LOCK_READ_ONLY);
49+
memcpy(externalVideoFrame->buffer, raw, tex->GetSizeX() * tex->GetSizeY() * 4);
50+
tex->GetPlatformData()->Mips[0].BulkData.Unlock();
51+
52+
MediaEngineManager->pushVideoFrame(externalVideoFrame);
53+
}
54+
#else
55+
if (tex->PlatformData != nullptr)
4856
{
4957
uint8* raw = (uint8*)tex->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_ONLY);
5058
memcpy(externalVideoFrame->buffer, raw, tex->GetSizeX() * tex->GetSizeY() * 4);
5159
tex->PlatformData->Mips[0].BulkData.Unlock();
5260

5361
MediaEngineManager->pushVideoFrame(externalVideoFrame);
5462
}
63+
#endif
64+
5565
}
5666

5767

Agora-Unreal-SDK-CPP-Example/Source/AgoraExample/CustomCaptureVideoScene.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "BaseAgoraUserWidget.h"
77
#include "AgoraPluginInterface.h"
88
#include "Components/Image.h"
9-
#include "MediaTexture.h"
109
#include "Components/CanvasPanelSlot.h"
1110
#include "../Private/Misc/MediaTextureResource.h"
1211
#include <iostream>

0 commit comments

Comments
 (0)