diff --git a/.gitignore b/.gitignore index 5e82d29..6accd3c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ sysinfo.txt .vs **/*.h264 *.log +.vsconfig + diff --git a/Assets/uNvEncoder/Scripts/Encoder.cs b/Assets/uNvEncoder/Scripts/Encoder.cs index 73a3513..07c4a13 100644 --- a/Assets/uNvEncoder/Scripts/Encoder.cs +++ b/Assets/uNvEncoder/Scripts/Encoder.cs @@ -10,6 +10,7 @@ public class Encoder [System.Serializable] public class EncodedCallback : UnityEvent {}; public EncodedCallback onEncoded = new EncodedCallback(); + public bool outputError = false; public int id { get; private set; } = -1; @@ -99,7 +100,7 @@ public bool Encode(Texture texture, bool forceIdrFrame) if (!Encode(ptr, forceIdrFrame)) { var msg = error; - if (!string.IsNullOrEmpty(msg)) + if (outputError && !string.IsNullOrEmpty(msg)) { Debug.LogError(msg); } @@ -124,7 +125,7 @@ public bool Encode(System.IntPtr ptr, bool forceIdrFrame) } var result = Lib.Encode(id, ptr, forceIdrFrame); - if (!result) + if (outputError && !result) { Debug.LogError(error); } diff --git a/Assets/uPacketFragmentation/Plugins/x86/uPacketFragmentation.dll b/Assets/uPacketFragmentation/Plugins/x86/uPacketFragmentation.dll index 0e63aa3..df2dd2b 100644 Binary files a/Assets/uPacketFragmentation/Plugins/x86/uPacketFragmentation.dll and b/Assets/uPacketFragmentation/Plugins/x86/uPacketFragmentation.dll differ diff --git a/Assets/uPacketFragmentation/Plugins/x86_64/uPacketFragmentation.dll b/Assets/uPacketFragmentation/Plugins/x86_64/uPacketFragmentation.dll index b0d4a80..a33fac1 100644 Binary files a/Assets/uPacketFragmentation/Plugins/x86_64/uPacketFragmentation.dll and b/Assets/uPacketFragmentation/Plugins/x86_64/uPacketFragmentation.dll differ diff --git a/Assets/uRemoteDesktopDuplication/Scripts/DesktopSender.cs b/Assets/uRemoteDesktopDuplication/Scripts/DesktopSender.cs index f5825d4..00fbedc 100644 --- a/Assets/uRemoteDesktopDuplication/Scripts/DesktopSender.cs +++ b/Assets/uRemoteDesktopDuplication/Scripts/DesktopSender.cs @@ -32,6 +32,7 @@ public void OnEncoded(System.IntPtr data, int size) for (uint i = 0; i < n; ++i) { var fragmentData = fragmenter_.GetFragmentData(i); + if (fragmentData == System.IntPtr.Zero) return; var fragmentSize = (int)fragmenter_.GetFragmentSize(i); byte[] buf = new byte[fragmentSize]; Marshal.Copy(fragmentData, buf, 0, fragmentSize); diff --git a/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.cpp b/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.cpp index 0ed370f..0c7b962 100644 --- a/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.cpp +++ b/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.cpp @@ -8,7 +8,7 @@ namespace uPacketFragmentation { -void Frame::AddFragmentData(const void *pData, uint32_t size) +void Frame::AddFragmentData(const void *pData, uint32_t) { const auto &header = *reinterpret_cast(pData); diff --git a/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.h b/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.h index b2abda8..5e6d421 100644 --- a/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.h +++ b/Plugins/uPacketFragmentation/uPacketFragmentation/Assembler.h @@ -66,9 +66,9 @@ class PacketAssembler final std::map> frames_; std::deque assembledFrameIndices_; - uint64_t oldestFrameIndex_ = -1; - uint64_t latestFrameIndex_ = -1; - uint64_t latestTimestamp_ = -1; + uint64_t oldestFrameIndex_ = UINT64_MAX; + uint64_t latestFrameIndex_ = UINT64_MAX; + uint64_t latestTimestamp_ = UINT64_MAX; PacketEventType eventType_ = PacketEventType::None; PacketLossType lossType_ = PacketLossType::None; }; diff --git a/Plugins/uPacketFragmentation/uPacketFragmentation/Fragmenter.cpp b/Plugins/uPacketFragmentation/uPacketFragmentation/Fragmenter.cpp index 2b71a96..52695e4 100644 --- a/Plugins/uPacketFragmentation/uPacketFragmentation/Fragmenter.cpp +++ b/Plugins/uPacketFragmentation/uPacketFragmentation/Fragmenter.cpp @@ -21,13 +21,13 @@ void PacketFragmenter::FragmentData(const void *pData, uint32_t size) const uint32_t fragmentSize = size / fragmentCount + 1; PacketHeader header = { GetPacketHeaderVersion() }; - header.type = static_cast(PacketType::Fragment); + header.type = static_cast(PacketType::Fragment); header.totalSize = size; header.timestamp = time_point_cast(system_clock::now()).time_since_epoch().count(); header.frameIndex = frameIndex_++; - header.fragmentCount = fragmentCount; + header.fragmentCount = static_cast(fragmentCount); - for (uint32_t i = 0; i < fragmentCount; ++i) + for (uint16_t i = 0; i < fragmentCount; ++i) { const auto bufSize = static_cast(maxBufSize) + headerSize; auto buf = std::make_unique(bufSize); diff --git a/Plugins/uPacketFragmentation/uPacketFragmentation/Main.cpp b/Plugins/uPacketFragmentation/uPacketFragmentation/Main.cpp index 66bc94e..fa02aea 100644 --- a/Plugins/uPacketFragmentation/uPacketFragmentation/Main.cpp +++ b/Plugins/uPacketFragmentation/uPacketFragmentation/Main.cpp @@ -165,7 +165,7 @@ UNITY_INTERFACE_EXPORT uint64_t UNITY_INTERFACE_API UpfAssemblerGetAssembledFram { return assembler->GetAssembledFrameIndex(); } - return -1; + return UINT64_MAX; } diff --git a/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj b/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj index 0ca3e59..a25fb48 100644 --- a/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj +++ b/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj @@ -99,6 +99,7 @@ Disabled false true + stdcpp17 Console @@ -115,6 +116,7 @@ Disabled false true + stdcpp17 Console @@ -133,6 +135,8 @@ true false true + MultiThreaded + stdcpp17 Console @@ -153,6 +157,8 @@ true false true + MultiThreaded + stdcpp17 Console diff --git a/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj.filters b/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj.filters index 2ce80d0..7e2bd5f 100644 --- a/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj.filters +++ b/Plugins/uPacketFragmentation/uPacketFragmentation/uPacketFragmentation.vcxproj.filters @@ -10,5 +10,14 @@ Unity + + + + + + + + + \ No newline at end of file