Reformat files

This commit is contained in:
Santiago Lo Coco 2024-11-11 23:20:31 +01:00
parent d8f5282892
commit 783839a0b0
12 changed files with 67 additions and 45 deletions

View File

@ -30,10 +30,14 @@ namespace WebViewStream
BoxCollider boxCollider = canvas.GetComponent<BoxCollider>();
if (boxCollider != null)
{
boxCollider.size = new Vector3(boxCollider.size.x, isVisible ? 400 : 370, boxCollider.size.z);
boxCollider.size = new Vector3(
boxCollider.size.x,
isVisible ? 400 : 370,
boxCollider.size.z
);
boxCollider.center = new Vector3(0, isVisible ? 0 : -16, 0);
}
}
}
}
}
}

View File

@ -24,4 +24,4 @@ namespace WebViewStream
}
}
}
}
}

View File

@ -76,7 +76,10 @@ namespace WebViewStream
canvas.transform.position =
cameraTransform.position + cameraTransform.TransformDirection(localOffset);
canvas.transform.rotation = Quaternion.LookRotation(cameraTransform.forward, cameraTransform.up);
canvas.transform.rotation = Quaternion.LookRotation(
cameraTransform.forward,
cameraTransform.up
);
localOffset = new Vector3(
localOffset.x + endpointLoader.GetItemWidth(canvas),
@ -86,4 +89,4 @@ namespace WebViewStream
}
}
}
}
}

View File

@ -34,4 +34,4 @@ namespace WebViewStream
PointerUtils.SetHandRayPointerBehavior(PointerBehavior.AlwaysOff);
}
}
}
}

View File

@ -36,4 +36,4 @@ namespace WebViewStream
}
}
}
}
}

View File

@ -345,4 +345,4 @@ namespace WebViewStream
}
}
}
}
}

View File

@ -46,4 +46,4 @@ namespace WebViewStream
return hash;
}
}
}
}

View File

@ -23,4 +23,4 @@ namespace WebViewStream
scrollView.MoveByTiers(amount);
}
}
}
}

View File

@ -86,7 +86,11 @@ namespace WebViewStream
}
udpClient = new UdpClient();
udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
udpClient.Client.SetSocketOption(
SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress,
true
);
udpClient.Client.Bind(new IPEndPoint(defaultIP, multicastPort));
udpClient.JoinMulticastGroup(IPAddress.Parse(multicastAddress), defaultIP);
@ -109,7 +113,11 @@ namespace WebViewStream
byte[] query = CreateMdnsQuery(serviceName);
Debug.Log($"Sending mDNS query for {serviceName}");
udpClient.Send(query, query.Length, new IPEndPoint(IPAddress.Parse(multicastAddress), multicastPort));
udpClient.Send(
query,
query.Length,
new IPEndPoint(IPAddress.Parse(multicastAddress), multicastPort)
);
}
private byte[] CreateMdnsQuery(string serviceName)
@ -262,7 +270,9 @@ namespace WebViewStream
if (recordType == 1) // A Record
{
IPAddress ipAddress = new IPAddress(new ArraySegment<byte>(data, offset, dataLength).ToArray());
IPAddress ipAddress = new IPAddress(
new ArraySegment<byte>(data, offset, dataLength).ToArray()
);
receivedIp = ipAddress.ToString();
receivedHost = name;
}
@ -372,4 +382,4 @@ namespace WebViewStream
udpClient = null;
}
}
}
}

View File

@ -103,4 +103,4 @@ namespace WebViewStream
gameObject.SetActive(isVisible);
}
}
}
}

View File

@ -18,37 +18,37 @@ namespace WebViewStream
private VideoCapture videoCapture = null;
#if WINDOWS_UWP && !UNITY_EDITOR
private const string freeSpace = "System.FreeSpace";
private const UInt64 minAvailableSpace = 5UL * 1024 * 1024 * 1024; // 5GB
private const string freeSpace = "System.FreeSpace";
private const UInt64 minAvailableSpace = 5UL * 1024 * 1024 * 1024; // 5GB
private IEnumerator CheckAvailableStorageSpace()
{
while (videoCapture != null && videoCapture.IsRecording)
private IEnumerator CheckAvailableStorageSpace()
{
yield return CheckSpaceAndHandleRecording();
yield return new WaitForSeconds(5);
}
}
private async Task CheckSpaceAndHandleRecording()
{
try
{
StorageFolder folder = ApplicationData.Current.TemporaryFolder;
var props = await folder.Properties.RetrievePropertiesAsync(new string[] { freeSpace });
UInt64 availableSpace = (UInt64)props[freeSpace];
if (availableSpace < minAvailableSpace)
while (videoCapture != null && videoCapture.IsRecording)
{
Debug.LogWarning("Not enough storage space to continue recording. Saving video.");
StopRecordingVideo();
yield return CheckSpaceAndHandleRecording();
yield return new WaitForSeconds(5);
}
}
catch (Exception ex)
private async Task CheckSpaceAndHandleRecording()
{
Debug.LogError("Error checking storage space: " + ex.Message);
try
{
StorageFolder folder = ApplicationData.Current.TemporaryFolder;
var props = await folder.Properties.RetrievePropertiesAsync(new string[] { freeSpace });
UInt64 availableSpace = (UInt64)props[freeSpace];
if (availableSpace < minAvailableSpace)
{
Debug.LogWarning("Not enough storage space to continue recording. Saving video.");
StopRecordingVideo();
}
}
catch (Exception ex)
{
Debug.LogError("Error checking storage space: " + ex.Message);
}
}
}
#endif
/// <summary>
@ -57,7 +57,7 @@ namespace WebViewStream
public void StartRecordingVideo()
{
#if WINDOWS_UWP && !UNITY_EDITOR
VideoCapture.CreateAsync(true, OnVideoCaptureCreated);
VideoCapture.CreateAsync(true, OnVideoCaptureCreated);
#else
VideoCapture.CreateAsync(false, OnVideoCaptureCreated);
#endif
@ -101,14 +101,19 @@ namespace WebViewStream
Resolution cameraResolution = new Resolution();
foreach (Resolution resolution in VideoCapture.SupportedResolutions)
{
if (resolution.width * resolution.height > cameraResolution.width * cameraResolution.height)
if (
resolution.width * resolution.height
> cameraResolution.width * cameraResolution.height
)
{
cameraResolution = resolution;
}
}
float cameraFramerate = 0.0f;
foreach (float framerate in VideoCapture.GetSupportedFrameRatesForResolution(cameraResolution))
foreach (
float framerate in VideoCapture.GetSupportedFrameRatesForResolution(cameraResolution)
)
{
if (framerate > cameraFramerate)
{
@ -154,7 +159,7 @@ namespace WebViewStream
{
Debug.Log("Started recording video");
#if WINDOWS_UWP && !UNITY_EDITOR
StartCoroutine(CheckAvailableStorageSpace());
StartCoroutine(CheckAvailableStorageSpace());
#endif
}
@ -170,4 +175,4 @@ namespace WebViewStream
videoCapture = null;
}
}
}
}

View File

@ -45,4 +45,4 @@ namespace WebViewStream
}
}
}
}
}