Skip to content

Commit

Permalink
remove unused, fixed versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
peeld committed Nov 20, 2024
1 parent 288c97b commit c9d71bd
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 84 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.13)

project(Open3DStream VERSION 1.0.3)
project(Open3DStream VERSION)

#if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/usr )
Expand All @@ -9,6 +9,9 @@ project(Open3DStream VERSION 1.0.3)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_DEBUG_POSTFIX d)

# Version 1.0.4 Remove unused subjects, add all matrixes
set(O3DS_VERSION_TAG "1.0.4")

#add_subdirectory(apps/FbxStream)
add_subdirectory(src)
add_subdirectory(apps/Repeater)
Expand Down
2 changes: 1 addition & 1 deletion apps/Repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int main(int argc, char *argv[])
{
if (argc < 3)
{
printf("O3DS Repeater - %s\n", O3DS::getVersion().c_str());
printf("O3DS Repeater - %s\n", O3DS::getVersion());
printf("Usage: %s listen-addr broadcast-addr\n", argv[0]);
return 1;
}
Expand Down
17 changes: 9 additions & 8 deletions apps/Test1/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "o3ds/async_publisher.h"
#include "o3ds/model.h"
#include "o3ds/o3ds.h"
#include "o3ds/o3ds_version.h"
#include <chrono>
#include <iostream>
#include <thread>
Expand Down Expand Up @@ -56,16 +57,16 @@ void verify(std::vector<char> buffer, double rotate, O3DS::SubjectList &subjectL

int main(int arc, char** argv)
{

std::cout << O3DS::getVersion();
O3DS::AsyncPublisher publisher;

#if 0
FILE* fp = fopen("c:\\Users\\al\\Desktop\\data.86.dat", "rb");

char data[6192];

fread(data, 1, 6193, fp);

fclose(fp);
#endif


if (publisher.start("INVALIDTEXT")) {
Expand All @@ -79,12 +80,12 @@ int main(int arc, char** argv)
return 1;
}

O3DS::SubjectList subjectList;

subjectList.Parse(data, 6192);


O3DS::SubjectList subjectList;

#if 0
subjectList.Parse(data, 6192);
#endif
O3DS::SubjectList subjectListCopy;


Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ IF EXIST %~DP0usr GOTO USROK


cd thirdparty
build.bat
CALL build.bat
if %errorlevel% neq 0 exit /b %errorlevel%
cd %~DP0

Expand Down
104 changes: 81 additions & 23 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import re
import subprocess
import winreg
import shutil

""" creats a zip file release """

def get_version():
exp = re.compile('project\s*\(.*VERSION\s+([0-9.]+)')
exp = re.compile('O3DS_VERSION_TAG\s+"([0-9.]+)"')
with open('CMakeLists.txt') as fp:
for line in fp:
ret = exp.match(line)
ret = exp.search(line)
if ret:
return ret.group(1)
return None
Expand All @@ -22,7 +23,7 @@ def get_version():

def build_ue(plugin, ue_base, version, ue_install_path):

out = ue_base + "\\" + version + "\\PeelVCam"
out = ue_base + "\\" + version + "\\Open3dStream"

exe = rf"{ue_install_path}\Engine\Build\BatchFiles\RunUAT.bat"

Expand All @@ -48,47 +49,104 @@ def build_ue(plugin, ue_base, version, ue_install_path):
print(ex)


def remove_directory(base):
if not os.path.isdir(base):
return

for d, _, f in os.walk(base):
for each_file in f:
print("RM " + os.path.join(d, each_file))

version_input = get_version()
if version_input is None:
raise RuntimeError("Could not determine version")

print("Packacging version: " + version_input)
print("Packaging version: " + version_input)

version = "Open3DStream_" + version_input
cwd = os.path.abspath('')
out_root = "Open3DStream"
outzip = os.path.join(cwd, version + ".zip")
out_dir = os.path.abspath('usr')

fp = zipfile.ZipFile(outzip, "w", zipfile.ZIP_DEFLATED)

for d, _, f in os.walk(out_dir):
base = d[len(out_dir)+1:]
for each_file in f:
src = os.path.join(d, each_file)
out = os.path.join(base, each_file)
print(out)
fp.write(src, out)
fp.close()

# Unreal
unreal_src_plugin = os.path.abspath("plugins/unreal/Open3DStream/Open3DStream.uplugin")
unreal_dst_base = os.path.join(cwd, "plugins", "unreal")
unreal_src_plugin = os.path.abspath("D:/P4_PD/o3ds/plugins/Open3DStream/Open3DStream.uplugin")
unreal_dst_base = os.path.join(out_dir, "plugins", "unreal")
unreal_stage_base = os.path.join(cwd, "unrealstage")

ue_registry_prefix_path = r'SOFTWARE\EpicGames\Unreal Engine'
ue_registry_prefix_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, ue_registry_prefix_path, 0, winreg.KEY_READ)
ue_version_index = 0
while True:
try:
ue_version = winreg.EnumKey(ue_registry_prefix_key, ue_version_index)
ue_version_key = winreg.OpenKey(ue_registry_prefix_key, ue_version, 0, winreg.KEY_READ)
ue_path, _ = winreg.QueryValueEx(ue_version_key, "InstalledDirectory")
build_ue(unreal_src_plugin, unreal_dst_base, ue_version, ue_path)
except OSError as e:
if "[WinError 259]" in str(e):
break
raise e

print(ue_version)
if ue_version == "4.26":
ue_version_index = ue_version_index + 1
except OSError:
break
continue
ue_version_key = winreg.OpenKey(ue_registry_prefix_key, ue_version, 0, winreg.KEY_READ)
ue_path, _ = winreg.QueryValueEx(ue_version_key, "InstalledDirectory")
build_ue(unreal_src_plugin, unreal_stage_base, ue_version, ue_path)

print(f"Unreal path: {ue_path}")

dst_plugin_dir = os.path.join(unreal_dst_base, ue_version, "Open3dStream")
remove_directory(dst_plugin_dir)

ue_host_project_dir = os.path.join(unreal_stage_base, ue_version, "Open3DStream", "HostProject")
if os.path.isdir(ue_host_project_dir):
# Project was build as a "host project", copy it to the location
ue_built_plugin = os.path.join(ue_host_project_dir, "Plugins", "Open3DStream")
else:
ue_built_plugin = os.path.join(unreal_stage_base, ue_version, "Open3DStream")

if not os.path.isfile(os.path.join(ue_built_plugin, "Open3DStream.uplugin")):
raise RuntimeError("Could not find plugin: " + ue_built_plugin)

shutil.copytree(ue_built_plugin, dst_plugin_dir)

# libs
unreal_lib_dir = os.path.join(unreal_dst_base, ue_version, "Open3dStream" , "lib")
print(unreal_lib_dir)
if not os.path.isdir(unreal_lib_dir):
os.mkdir(unreal_lib_dir)

usr_lib_dir = os.path.join(out_dir, "lib")
for libfile in os.listdir(usr_lib_dir):
if libfile.endswith(".lib"):
name = libfile[:-4]
if name.endswith("d"):
release_name = name[:-1] + ".lib"
if os.path.isfile(os.path.join(out_dir, "lib", release_name)):
continue
print(libfile)
shutil.copyfile(os.path.join(out_dir, "lib", libfile), os.path.join(unreal_lib_dir, libfile))

# includes
unreal_include_dir = os.path.join(unreal_dst_base, ue_version, "Open3dStream" , "lib", "include")
usr_include_dir = os.path.join(out_dir, "include")
shutil.copytree(usr_include_dir, unreal_include_dir)

ue_version_index = ue_version_index + 1



raise RuntimeError("Here")
fp = zipfile.ZipFile(outzip, "w", zipfile.ZIP_DEFLATED)


for d, _, f in os.walk(out_dir):
base = d[len(out_dir)+1:]
for each_file in f:
src = os.path.join(d, each_file)
out = os.path.join(base, each_file)
print(out)
fp.write(src, out)
fp.close()

#installer

Expand Down
2 changes: 1 addition & 1 deletion plugins/mobu/layout.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "device.h"
#include "layout.h"

#include "o3ds/o3ds.h" // for version#
#include "o3ds/o3ds_version.h"
#include <sstream>

#define OPEN3D_DEVICE__LAYOUT Open3D_Device_Layout
Expand Down
4 changes: 2 additions & 2 deletions plugins/unreal/Open3DStream/Open3DStream.uplugin
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"Description": "Realtime Streaming",
"Category": "Other",
"CreatedBy": "Alastair Macleod",
"CreatedByURL": "",
"CreatedByURL": "https://peeldev.com/",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"SupportURL": "https://open3dstream.com/",
"CanContainContent": true,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include "Misc/MessageDialog.h"
#include "Open3DStreamSourceSettings.h"
#include "SOpen3DStreamFactory.h"

class FOpen3DStreamSource;
#include "Open3DStreamSource.h"
//class FOpen3DStreamSource;

#define LOCTEXT_NAMESPACE "Open3DStream"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Open3DStreamSource.h"
#include "LiveLinkRoleTrait.h"

#include "ILiveLinkClient.h"
#include "Roles/LiveLinkAnimationTypes.h"
#include "Roles/LiveLinkAnimationRole.h"
#include "Common/UdpSocketBuilder.h"
Expand Down Expand Up @@ -34,9 +35,8 @@ FOpen3DStreamSource::FOpen3DStreamSource(const FOpen3DStreamSettings& Settings)
, Client(nullptr)
, ArrivalTimeOffset(0.0)
, Frame(0)
, bIsValid(true)
, LogFlag(false)

, bIsValid(true)
, mAddr(ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr())
{
Url = Settings.Url;
Expand Down Expand Up @@ -79,6 +79,14 @@ void FOpen3DStreamSource::ReceiveClient(ILiveLinkClient* InClient, FGuid InSourc
SourceGuid = InSourceGuid;
bIsValid = true;

const FRegexPattern pattern(TEXT("^[0-9:.]+$"));
FRegexMatcher matcher(pattern, Url.ToString());

if (matcher.FindNext())
{
Url = FText::Format(LOCTEXT("FormattedUrl", "tcp://{0}"), Url);
}

if (!server.start(Url, Protocol))
{
bIsValid = false;
Expand All @@ -88,12 +96,18 @@ void FOpen3DStreamSource::ReceiveClient(ILiveLinkClient* InClient, FGuid InSourc

void FOpen3DStreamSource::Tick(float DeltaTime)
{
TimeSinceLastCheck += DeltaTime;
if (TimeSinceLastCheck >= CheckInterval)
{
RemoveInactiveSubjects();
TimeSinceLastCheck = 0;
}
this->server.tick();
}

bool FOpen3DStreamSource::IsTickable() const
{
return this->server.mTcp != nullptr;
return true; // this->server.mTcp != nullptr;
}

void operator >>(const O3DS::Matrixd& src, FMatrix& dst)
Expand Down Expand Up @@ -136,9 +150,6 @@ void operator >>(const O3DS::Matrixd& src, FMatrix& dst)
dst.Mirror(EAxis::X, EAxis::Y); // - NEARLY
}


// #pragma optimize( "", off )

void FOpen3DStreamSource::OnPackage(const TArray<uint8>& data)
{
if (!bIsValid)
Expand Down Expand Up @@ -251,7 +262,7 @@ void FOpen3DStreamSource::OnPackage(const TArray<uint8>& data)
continue;
}

// Cjeck if skeleton has not been initialized yet
// Check if skeleton has not been initialized yet
if (InitializedSubjects.Find(SubjectName) == INDEX_NONE)
{
// Do we have a full packet or just an update)
Expand All @@ -273,10 +284,30 @@ void FOpen3DStreamSource::OnPackage(const TArray<uint8>& data)
}

Client->PushSubjectFrameData_AnyThread(SubjectKey, MoveTemp(FrameDataStruct));

SubjectLastUpdateTime.FindOrAdd(SubjectName) = FPlatformTime::Seconds();
}
}

// #pragma optimize( "", on )
void FOpen3DStreamSource::RemoveInactiveSubjects()
{
const double CurrentTime = FPlatformTime::Seconds();

for (auto It = SubjectLastUpdateTime.CreateIterator(); It; ++It)
{
double LastUpdateTime = It.Value();
if (CurrentTime - LastUpdateTime > InactivityThreshold)
{
// Remove the subject from LiveLink
FName SubjectName = It.Key();
SubjectLastUpdateTime.Remove(SubjectName);
const FLiveLinkSubjectKey SubjectKey(SourceGuid, SubjectName);
Client->RemoveSubject_AnyThread(SubjectKey);
// It.RemoveCurrent();
InitializedSubjects.Remove(SubjectName);
}
}
}

bool FOpen3DStreamSource::RequestSourceShutdown()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "Widgets/Input/SEditableTextBox.h"
#include "Widgets/Input/SButton.h"

#include "o3ds/o3ds.h" // for version
#include "Open3DStreamSource.h"
#include "o3ds/o3ds_version.h" // for version

#define LOCTEXT_NAMESPACE "Open3DStream"

Expand All @@ -21,8 +22,6 @@ void SOpen3DStreamFactory::Construct(const FArguments& Args)
Options.Add(MakeShareable(new FString("TCP Client")));
Options.Add(MakeShareable(new FString("UDP Server")));

const char* version = O3DS::getVersion();

if (SOpen3DStreamFactory::LastUrl.IsEmpty())
{
LastUrl = LOCTEXT("Open3DStreamUrlValue", "tcp://meta.o3ds.net:9001");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "SocketSubsystem.h"
#include "Interfaces/IPv4/IPv4Address.h"
#include "Common/UdpSocketBuilder.h"
#include "HAL/PlatformTime.h"

#define LOCTEXT_NAMESPACE "Open3DStream"

Expand Down
Loading

0 comments on commit c9d71bd

Please sign in to comment.