diff --git a/RelayClient/MainPage.xaml.cs b/RelayClient/MainPage.xaml.cs index 7cae44f..bed7a26 100644 --- a/RelayClient/MainPage.xaml.cs +++ b/RelayClient/MainPage.xaml.cs @@ -2,6 +2,10 @@ using RelayClient.Models; using WebSocketSharp; using System.Text.Json; +using System.Threading.Tasks; +using Microsoft.MixedReality.WebRTC; +using System.IO; +using System.Collections.Generic; namespace RelayClient; @@ -39,6 +43,8 @@ public partial class MainPage : ContentPage _wsc.Send($"REGISTER_KEY|{_username}|{publicKey}"); _wsc.Send("GET_SERVER_KEY"); _wsc.Send("GET_CHANNELS"); + + webRTCTest(); } private void SendButton_OnClicked(object? sender, EventArgs e) @@ -286,4 +292,69 @@ public partial class MainPage : ContentPage MessagesLayout.Children.Add(bubble); await MessagesScrollView.ScrollToAsync(MessagesLayout, ScrollToPosition.End, true); } + + private async Task webRTCTest() + { + // var path = "D:\\DDI\\Relay\\RelayChat\\RelayCore\\RelayClient\\bin\\debug.txt"; + // AudioTrackSource microphoneSource = null; + // VideoTrackSource webcamSource = null; + // Transceiver audioTransceiver = null; + // Transceiver videoTransceiver = null; + // LocalAudioTrack localAudioTrack = null; + // LocalVideoTrack localVideoTrack = null; + try + { + var deviceList = await DeviceVideoTrackSource.GetCaptureDevicesAsync(); + string devices = ""; + foreach (var device in deviceList) + { + devices += $"Found device: {device.name} (id: {device.id})\n"; + Console.WriteLine($"Found device: {device.name} (id: {device.id})"); + } + File.WriteAllText(path, devices); + } + catch (Exception e) + { + File.WriteAllText(path, e.Message); + Console.WriteLine(e); + throw; + } + + using var pc = new PeerConnection(); + var config = new PeerConnectionConfiguration + { + IceServers = new List + { + new IceServer { Urls = { "stun:stun.l.google.com:19302" } } + } + }; + await pc.InitializeAsync(config); + + // webcamSource = await DeviceVideoTrackSource.CreateAsync(); + // var videoTrackConfig = new LocalVideoTrackInitConfig + // { + // trackName = "webcam_track" + // }; + // localVideoTrack = LocalVideoTrack.CreateFromSource(webcamSource, videoTrackConfig); + // microphoneSource = await DeviceAudioTrackSource.CreateAsync(); + // var audioTrackConfig = new LocalAudioTrackInitConfig + // { + // trackName = "microphone_track" + // }; + // localAudioTrack = LocalAudioTrack.CreateFromSource(microphoneSource, audioTrackConfig); + // videoTransceiver = pc.AddTransceiver(MediaKind.Video); + // videoTransceiver.LocalVideoTrack = localVideoTrack; + // videoTransceiver.DesiredDirection = Transceiver.Direction.SendReceive; + // + // audioTransceiver = pc.AddTransceiver(MediaKind.Audio); + // audioTransceiver.LocalAudioTrack = localAudioTrack; + // audioTransceiver.DesiredDirection = Transceiver.Direction.SendReceive; + // + // + // + // localAudioTrack?.Dispose(); + // localVideoTrack?.Dispose(); + // microphoneSource?.Dispose(); + // webcamSource?.Dispose(); + } } \ No newline at end of file diff --git a/RelayClient/RelayClient.csproj b/RelayClient/RelayClient.csproj index 5d0f8bc..3fb3ed5 100644 --- a/RelayClient/RelayClient.csproj +++ b/RelayClient/RelayClient.csproj @@ -41,6 +41,7 @@ + diff --git a/mrwebrtc.dll b/mrwebrtc.dll new file mode 100644 index 0000000..9f62be7 Binary files /dev/null and b/mrwebrtc.dll differ