private void App_Suspending(object sender, SuspendingEventArgs e)
        {
            // Save local and remote peer IDs for next launch for convenience
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            SessionModel             sessionModel  = SessionModel.Current;

            localSettings.Values["DssServerAddress"]    = sessionModel.NodeDssSignaler.HttpServerAddress;
            localSettings.Values["LocalPeerID"]         = sessionModel.NodeDssSignaler.LocalPeerId;
            localSettings.Values["RemotePeerID"]        = sessionModel.NodeDssSignaler.RemotePeerId;
            localSettings.Values["PollTimeMs"]          = sessionModel.NodeDssSignaler.PollTimeMs;
            localSettings.Values["PreferredAudioCodec"] = sessionModel.PreferredAudioCodec;
            localSettings.Values["PreferredAudioCodecExtraParamsLocal"]  = sessionModel.PreferredAudioCodecExtraParamsLocal;
            localSettings.Values["PreferredAudioCodecExtraParamsRemote"] = sessionModel.PreferredAudioCodecExtraParamsRemote;
            localSettings.Values["PreferredVideoCodec"] = sessionModel.PreferredVideoCodec;
            localSettings.Values["PreferredVideoCodecExtraParamsLocal"]  = sessionModel.PreferredVideoCodecExtraParamsLocal;
            localSettings.Values["PreferredVideoCodecExtraParamsRemote"] = sessionModel.PreferredVideoCodecExtraParamsRemote;
        }
Exemple #2
0
        private void App_Suspending(object sender, SuspendingEventArgs e)
        {
            // Save local and remote peer IDs for next launch for convenience
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            SessionModel             sessionModel  = SessionModel.Current;

            localSettings.Values["DssServerAddress"] = sessionModel.NodeDssSignaler.HttpServerAddress;
            localSettings.Values["LocalPeerID"]      = sessionModel.NodeDssSignaler.LocalPeerId;
            localSettings.Values["RemotePeerID"]     = sessionModel.NodeDssSignaler.RemotePeerId;
            localSettings.Values["PollTimeMs"]       = sessionModel.NodeDssSignaler.PollTimeMs;
            //localSettings.Values["PreferredAudioCodec"] = PreferredAudioCodec;
            //localSettings.Values["PreferredAudioCodecExtraParamsLocal"] = PreferredAudioCodecExtraParamsLocalTextBox.Text;
            //localSettings.Values["PreferredAudioCodecExtraParamsRemote"] = PreferredAudioCodecExtraParamsRemoteTextBox.Text;
            //localSettings.Values["PreferredAudioCodec_Custom"] = PreferredAudioCodec_Custom.IsChecked.GetValueOrDefault() ? CustomPreferredAudioCodec.Text : "";
            //localSettings.Values["PreferredVideoCodec"] = PreferredVideoCodec;
            //localSettings.Values["PreferredVideoCodecExtraParamsLocal"] = PreferredVideoCodecExtraParamsLocalTextBox.Text;
            //localSettings.Values["PreferredVideoCodecExtraParamsRemote"] = PreferredVideoCodecExtraParamsRemoteTextBox.Text;
            //localSettings.Values["PreferredVideoCodec_Custom"] = PreferredVideoCodec_Custom.IsChecked.GetValueOrDefault() ? CustomPreferredVideoCodec.Text : "";
        }
Exemple #3
0
 public SessionNegotiationDeferral(SessionModel session)
 {
     _session = session;
 }
Exemple #4
0
        private void RestoreSettings()
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            SessionModel             sessionModel  = SessionModel.Current;

            // Uncomment these lines if you want to connect a HoloLens (or any non-x64 device) to a
            // x64 PC.
            //var arch = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
            //if (arch == "AMD64")
            //{
            //    sessionModel.NodeDssSignaler.LocalPeerId = "Pc";
            //    sessionModel.NodeDssSignaler.RemotePeerId = "Device";
            //}
            //else
            //{
            //    sessionModel.NodeDssSignaler.LocalPeerId = "Device";
            //    sessionModel.NodeDssSignaler.RemotePeerId = "Pc";
            //}

            // Get server address and peer ID from local settings if available.
            if (localSettings.Values.TryGetValue("DssServerAddress", out object dssServerAddress))
            {
                if (dssServerAddress is string str)
                {
                    sessionModel.NodeDssSignaler.HttpServerAddress = str;
                }
            }
            if (string.IsNullOrWhiteSpace(sessionModel.NodeDssSignaler.HttpServerAddress))
            {
                sessionModel.NodeDssSignaler.HttpServerAddress = "http://localhost:3000/";
            }

            if (localSettings.Values.TryGetValue("LocalPeerID", out object localObj))
            {
                if (localObj is string str)
                {
                    sessionModel.NodeDssSignaler.LocalPeerId = str;
                }
            }
            if (string.IsNullOrWhiteSpace(sessionModel.NodeDssSignaler.LocalPeerId))
            {
                sessionModel.NodeDssSignaler.LocalPeerId = GetDeviceName();
            }
            if (localSettings.Values.TryGetValue("RemotePeerID", out object remoteObj))
            {
                if (remoteObj is string str)
                {
                    sessionModel.NodeDssSignaler.RemotePeerId = str;
                }
            }
            if (localSettings.Values.TryGetValue("PollTimeMs", out object pollTimeObject))
            {
                if (pollTimeObject is int pollTimeMs)
                {
                    sessionModel.NodeDssSignaler.PollTimeMs = pollTimeMs;
                }
            }

            if (!IsFirstInstance())
            {
                // Swap the peer IDs. This way two instances launched on the same machine connect
                // to each other by default
                var tmp = sessionModel.NodeDssSignaler.LocalPeerId;
                sessionModel.NodeDssSignaler.LocalPeerId  = sessionModel.NodeDssSignaler.RemotePeerId;
                sessionModel.NodeDssSignaler.RemotePeerId = tmp;
            }

            //if (localSettings.Values.TryGetValue("PreferredAudioCodec", out object preferredAudioObj))
            //{
            //    if (preferredAudioObj is string str)
            //    {
            //        switch (str)
            //        {
            //        case "":
            //        {
            //            PreferredAudioCodec_Default.IsChecked = true;
            //            break;
            //        }
            //        case "opus":
            //        {
            //            PreferredAudioCodec_OPUS.IsChecked = true;
            //            break;
            //        }
            //        default:
            //        {
            //            PreferredAudioCodec_Custom.IsChecked = true;
            //            CustomPreferredAudioCodec.Text = str;
            //            break;
            //        }
            //        }
            //    }
            //}
            //if (localSettings.Values.TryGetValue("PreferredAudioCodecExtraParamsLocal", out object preferredAudioParamsLocalObj))
            //{
            //    if (preferredAudioParamsLocalObj is string str)
            //    {
            //        PreferredAudioCodecExtraParamsLocalTextBox.Text = str;
            //    }
            //}
            //if (localSettings.Values.TryGetValue("PreferredAudioCodecExtraParamsRemote", out object preferredAudioParamsRemoteObj))
            //{
            //    if (preferredAudioParamsRemoteObj is string str)
            //    {
            //        PreferredAudioCodecExtraParamsRemoteTextBox.Text = str;
            //    }
            //}

            //if (localSettings.Values.TryGetValue("PreferredVideoCodec", out object preferredVideoObj))
            //{
            //    if (preferredVideoObj is string str)
            //    {
            //        switch (str)
            //        {
            //        case "":
            //        {
            //            PreferredVideoCodec_Default.IsChecked = true;
            //            break;
            //        }
            //        case "H264":
            //        {
            //            PreferredVideoCodec_H264.IsChecked = true;
            //            break;
            //        }
            //        case "VP8":
            //        {
            //            PreferredVideoCodec_VP8.IsChecked = true;
            //            break;
            //        }
            //        default:
            //        {
            //            PreferredVideoCodec_Custom.IsChecked = true;
            //            CustomPreferredVideoCodec.Text = str;
            //            break;
            //        }
            //        }
            //    }
            //}
            //if (localSettings.Values.TryGetValue("PreferredVideoCodecExtraParamsLocal", out object preferredVideoParamsLocalObj))
            //{
            //    if (preferredVideoParamsLocalObj is string str)
            //    {
            //        PreferredVideoCodecExtraParamsLocalTextBox.Text = str;
            //    }
            //}
            //if (localSettings.Values.TryGetValue("PreferredVideoCodecExtraParamsRemote", out object preferredVideoParamsRemoteObj))
            //{
            //    if (preferredVideoParamsRemoteObj is string str)
            //    {
            //        PreferredVideoCodecExtraParamsRemoteTextBox.Text = str;
            //    }
            //}
        }
Exemple #5
0
        private void RestoreSettings()
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
            SessionModel             sessionModel  = SessionModel.Current;

            // Uncomment these lines if you want to connect a HoloLens (or any non-x64 device) to a
            // x64 PC.
            //var arch = System.Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
            //if (arch == "AMD64")
            //{
            //    sessionModel.NodeDssSignaler.LocalPeerId = "Pc";
            //    sessionModel.NodeDssSignaler.RemotePeerId = "Device";
            //}
            //else
            //{
            //    sessionModel.NodeDssSignaler.LocalPeerId = "Device";
            //    sessionModel.NodeDssSignaler.RemotePeerId = "Pc";
            //}

            // Get server address and peer ID from local settings if available.
            if (localSettings.Values.TryGetValue("DssServerAddress", out object dssServerAddress))
            {
                if (dssServerAddress is string str)
                {
                    sessionModel.NodeDssSignaler.HttpServerAddress = str;
                }
            }
            if (string.IsNullOrWhiteSpace(sessionModel.NodeDssSignaler.HttpServerAddress))
            {
                sessionModel.NodeDssSignaler.HttpServerAddress = "http://localhost:3000/";
            }

            if (localSettings.Values.TryGetValue("LocalPeerID", out object localObj))
            {
                if (localObj is string str)
                {
                    sessionModel.NodeDssSignaler.LocalPeerId = str;
                }
            }
            if (localSettings.Values.TryGetValue("RemotePeerID", out object remoteObj))
            {
                if (remoteObj is string str)
                {
                    sessionModel.NodeDssSignaler.RemotePeerId = str;
                }
            }
            if (localSettings.Values.TryGetValue("PollTimeMs", out object pollTimeObject))
            {
                if (pollTimeObject is int pollTimeMs)
                {
                    sessionModel.NodeDssSignaler.PollTimeMs = pollTimeMs;
                }
            }

            if (!IsFirstInstance())
            {
                // Swap the peer IDs. This way two instances launched on the same machine connect
                // to each other by default
                var tmp = sessionModel.NodeDssSignaler.LocalPeerId;
                sessionModel.NodeDssSignaler.LocalPeerId  = sessionModel.NodeDssSignaler.RemotePeerId;
                sessionModel.NodeDssSignaler.RemotePeerId = tmp;
            }

            // Ensure the local peer is not empty, otherwise the signaler will throw an exception
            // during OnLoaded(), which will crash the application.
            if (string.IsNullOrWhiteSpace(sessionModel.NodeDssSignaler.LocalPeerId))
            {
                sessionModel.NodeDssSignaler.LocalPeerId = GetDeviceName();
            }

            if (localSettings.Values.TryGetValue("PreferredAudioCodec", out object preferredAudioObj))
            {
                sessionModel.PreferredAudioCodec = (preferredAudioObj as string);
            }
            if (localSettings.Values.TryGetValue("PreferredAudioCodecExtraParamsLocal", out object preferredAudioParamsLocalObj))
            {
                sessionModel.PreferredAudioCodecExtraParamsLocal = (preferredAudioParamsLocalObj as string);
            }
            if (localSettings.Values.TryGetValue("PreferredAudioCodecExtraParamsRemote", out object preferredAudioParamsRemoteObj))
            {
                sessionModel.PreferredAudioCodecExtraParamsRemote = (preferredAudioParamsRemoteObj as string);
            }
            if (localSettings.Values.TryGetValue("PreferredVideoCodec", out object preferredVideoObj))
            {
                sessionModel.PreferredVideoCodec = (preferredVideoObj as string);
            }
            if (localSettings.Values.TryGetValue("PreferredVideoCodecExtraParamsLocal", out object preferredVideoParamsLocalObj))
            {
                sessionModel.PreferredVideoCodecExtraParamsLocal = (preferredVideoParamsLocalObj as string);
            }
            if (localSettings.Values.TryGetValue("PreferredVideoCodecExtraParamsRemote", out object preferredVideoParamsRemoteObj))
            {
                sessionModel.PreferredVideoCodecExtraParamsRemote = (preferredVideoParamsRemoteObj as string);
            }
        }