protected override async void OnNavigatedTo(NavigationEventArgs args) { var signaller = new WebsocketSignaller(); this.ConnectToServerButton.Click += async(s, a) => { this.NotConnected.Hide(); await signaller.ConnectToServer(ServerConfig.AwsAddress); this.Connected.Show(); }; this.DisconnectFromServerButton.Click += (s, a) => { this.Connected.Hide(); signaller.DisconnectFromServer(); this.NotConnected.Show(); }; var config = new ConductorConfig() { CoreDispatcher = this.Dispatcher, Signaller = signaller }; Logger.Log("Initializing WebRTC..."); await this.conductor.Initialize(config); Logger.Log("Done."); var opts = new MediaOptions( new MediaOptions.Init() { SendVideo = true }); this.conductor.SetMediaOptions(opts); this.conductor.UISignaller.ReceivedShutdown += async(s, a) => { await this.conductor.Shutdown(); }; this.conductor.UISignaller.ReceivedPlain += (s, message) => { Logger.Log(message); }; var devices = await this.conductor.GetVideoDevices(); this.MediaDeviceComboBox.ItemsSource = devices; this.MediaDeviceComboBox.SelectedIndex = 0; this.CaptureFormatComboBox.ItemsSource = await this.conductor.GetCaptureProfiles(devices.First()); this.CaptureFormatComboBox.SelectedIndex = 0; }
protected override async void OnNavigatedTo(NavigationEventArgs args) { signaller = new WebsocketSignaller(); this.SetUpCallButton.Click += async(s, a) => { this.NotConnected.Hide(); await signaller.ConnectToServer("ws://drhololens-env.esncizasfm.us-east-2.elasticbeanstalk.com/"); this.Connected.Show(); }; this.HangUpCallButton.Click += (s, a) => { this.Connected.Hide(); this.conductor.Shutdown(); this.NotConnected.Show(); }; this.DisconnectFromServerButton.Click += (s, a) => { Logger.Log("Disconnected from server"); signaller.DisconnectFromServer(); }; var config = new ConductorConfig() { CoreDispatcher = this.Dispatcher, RemoteVideo = this.RemoteVideo, Signaller = signaller }; Logger.Log("Initializing WebRTC..."); await this.conductor.Initialize(config); Logger.Log("Done."); var opts = new MediaOptions( new MediaOptions.Init() { SendAudio = true, ReceiveAudio = true }); this.conductor.SetMediaOptions(opts); this.conductor.UISignaller.ReceivedShutdown += async(s, a) => { await this.conductor.Shutdown(); }; this.conductor.UISignaller.ReceivedPlain += (s, message) => { Logger.Log(message); }; }
protected override async void OnNavigatedTo(NavigationEventArgs args) { var signaller = new WebsocketSignaller(); dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; contSpeechRecognizer = new SpeechRecognizer(); await contSpeechRecognizer.CompileConstraintsAsync(); contSpeechRecognizer.HypothesisGenerated += ContSpeechRecognizer_HypothesisGenerated; contSpeechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated; contSpeechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed; await contSpeechRecognizer.ContinuousRecognitionSession.StartAsync(); this.ServerConnectButton.Click += async(s, a) => { this.StartupSettings.Hide(); await signaller.ConnectToServer(ServerConfig.AwsAddress); this.ConnectedOptions.Show(); }; var config = new ConductorConfig() { CoreDispatcher = this.Dispatcher, RemoteVideo = this.RemoteVideo, Signaller = signaller }; await this.conductor.Initialize(config); var opts = new MediaOptions( new MediaOptions.Init() { ReceiveVideo = false }); this.conductor.SetMediaOptions(opts); this.conductor.UISignaller.ReceivedShutdown += async(s, a) => { await this.conductor.Shutdown(); }; this.conductor.UISignaller.ReceivedPlain += (s, message) => { Logger.Log(message); }; }
protected override async void OnNavigatedTo(NavigationEventArgs args) { var signaller = new WebsocketSignaller(); this.ServerConnectButton.Click += async(s, a) => { this.StartupSettings.Hide(); await signaller.ConnectToServer(ServerConfig.AwsAddress); this.ConnectedOptions.Show(); }; var config = new ConductorConfig() { CoreDispatcher = this.Dispatcher, RemoteVideo = this.RemoteVideo, Signaller = signaller }; await this.conductor.Initialize(config); var opts = new MediaOptions( new MediaOptions.Init() { ReceiveVideo = true }); this.conductor.SetMediaOptions(opts); this.conductor.UISignaller.ReceivedShutdown += async(s, a) => { await this.conductor.Shutdown(); }; this.conductor.UISignaller.ReceivedPlain += (s, message) => { Logger.Log(message); }; }
protected override async void OnNavigatedTo(NavigationEventArgs args) { signaller = new WebsocketSignaller("client"); var protocol = new MessageProtocol <WebRtcSignaller.WebRtcMessage>(); this.cursorSignaller = new ProtocolSignaller <WebRtcSignaller.WebRtcMessage> ( signaller, protocol ); // Not implemented for source, but necessary here. // EX: signaller connection void before source<=>client connection made. // This could happen if the source was disconnected before direct connection. signaller.ConnectionEnded += async(s, a) => { await this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { if (!isConnectedToSource) { this.ConnectedOptions.Hide(); this.StartupSettings.Show(); this.CursorElement.Hide(); } }); }; signaller.ConnectionFailed += (s, a) => { this.ConnectedOptions.Hide(); this.StartupSettings.Show(); this.CursorElement.Hide(); }; dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; contSpeechRecognizer = new SpeechRecognizer(); await contSpeechRecognizer.CompileConstraintsAsync(); contSpeechRecognizer.HypothesisGenerated += ContSpeechRecognizer_HypothesisGenerated; contSpeechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated; contSpeechRecognizer.ContinuousRecognitionSession.Completed += ContinuousRecognitionSession_Completed; await contSpeechRecognizer.ContinuousRecognitionSession.StartAsync(); this.ServerConnectButton.Click += async(s, a) => { this.StartupSettings.Hide(); await signaller.ConnectToServer(ServerConfig.AwsAddress); isConnectedToSource = false; if (signaller.connected) { this.ConnectedOptions.Show(); this.CursorElement.Show(); } }; this.CursorElement.ManipulationDelta += async(s, e) => { double newX = (this.t_Transform.TranslateX + e.Delta.Translation.X) / this.RemoteVideo.ActualWidth, newY = (this.t_Transform.TranslateY + e.Delta.Translation.Y) / this.RemoteVideo.ActualHeight; //Logger.Log("newX: " + newX.ToString() + " newY: " + newY.ToString()); if (newX < -threshold || newX > threshold || newY < -threshold || newY > threshold) { return; } if (this.isConnectedToSource) { await this.cursorSignaller.SendMessage( WebRtcSignaller.WebRtcMessage.CursorUpdate, "{ x: " + newX.ToString() + ", y: " + newY.ToString() + "}" ); } this.t_Transform.TranslateX += e.Delta.Translation.X; this.t_Transform.TranslateY += e.Delta.Translation.Y; }; var config = new ConductorConfig() { CoreDispatcher = this.Dispatcher, RemoteVideo = this.RemoteVideo, Signaller = signaller, Identity = "client" }; await this.conductor.Initialize(config); var opts = new MediaOptions( new MediaOptions.Init() { ReceiveVideo = (bool)this.ReceiveVideoCheck.IsChecked, ReceiveAudio = (bool)this.ReceiveAudioCheck.IsChecked, SendAudio = (bool)this.SendAudioCheck.IsChecked }); this.conductor.SetMediaOptions(opts); this.conductor.UISignaller.ReceivedShutdown += async(s, a) => { await this.conductor.Shutdown(); }; this.conductor.UISignaller.ReceivedPlain += (s, message) => { Logger.Log(message); }; this.conductor.UISignaller.ReceivedCursorUpdate += async(s, update) => { await this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { if (update.x < -threshold || update.x > threshold || update.y < -threshold || update.y > threshold) { return; } this.t_Transform.TranslateX = update.x * this.RemoteVideo.ActualWidth; this.t_Transform.TranslateY = update.y * this.RemoteVideo.ActualHeight; }); }; }