private void video_call_btn_Click(object sender, EventArgs e) { callService = m_User.CallService; call = callService.CreateCall(); CameraVideoSource cameraVideoSource = new CameraVideoSource(); CameraDevice selectedCamera = cameraVideoSource.Cameras[0]; VideoInterface videoInterface = client.MediaServices.getVideoInterface(); call.SetVideoMode(VideoMode.SendReceive, (error) => { if (error != null) { Console.Write("Set video mode error : " + error.Message); } else { Console.Write("Set video mode success"); cameraVideoSource.Start(selectedCamera, new VideoCaptureFormat(700, 400, 0, 30), (result) => { if (result == CameraVideoSourceResult.Success) { Console.WriteLine("CameraCaptureStart Success"); } else { Console.WriteLine("Error :" + result.ToString()); } }); } }); //pictureBox2.ImageLocation = VideoRenderer2; }
private void cofigsdk() { { { //Creamos las Variables para reconocimiento de nuestra APP //Obtenemos el Sistema Operativo string os = Environment.OSVersion.Version.ToString(); //Obtenemos la ruta de Mis documentos string path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); //Definimos un Nombre de Prodcuto string prodname = "Avaya Communicator"; //Asignamos la versión string prodversion = "3.0"; string platform = "Microsoft Windows NT 6.2.9200.0"; string osv = "Microsoft Windows NT"; string builv = "3.5.0.52.37"; string uuid; string extension; string pass; string sip; string domain; int port; extension = Properties.Settings.Default.usuario; pass = Properties.Settings.Default.password; sip = Properties.Settings.Default.sipcontroller; domain = Properties.Settings.Default.sipdomain; port = Int32.Parse(Properties.Settings.Default.puerto); Console.WriteLine(os + " " + path); clientConfiguration = new ClientConfiguration(path, prodname, prodversion, platform, osv, builv, "Avaya"); //Obtenemos nuestro UUID (RFC 5626) que hemos guardado en los Settings uuid = Properties.Settings.Default.uuid; //Lo imprimimos Console.WriteLine(uuid); //Verificamos si es Nulo bool check1 = string.IsNullOrEmpty(uuid); Console.WriteLine(check1); if (check1 == false) { Console.WriteLine("Ya existe una instancia de UUID"); Console.WriteLine(uuid); } else { //Si no existe UUID Console.WriteLine("No existe UUID"); //Generamos UUID uuid = Guid.NewGuid().ToString(); Console.WriteLine("Se ha generado UUID: " + uuid); //Lo Guardamos en los Settings Properties.Settings.Default.uuid = uuid; Console.WriteLine("Se ha guardado UUID"); } //Asignamos el UUId al Configuración del cliente clientConfiguration.UserAgentInstanceId = uuid; //Declaramos una Instancia de la Clase (Listeners) ApplicationClientDelegate clientDelegate = new ApplicationClientDelegate(); SecurityPolicyConfiguration securityPolicyConfig = new SecurityPolicyConfiguration(); securityPolicyConfig.PrivateTrustStoreEnabled = true; securityPolicyConfig.TrustStoreMode = TrustStoreMode.PrivateAndSystem; securityPolicyConfig.RevocationCheckPolicy = SecurityPolicy.Disabled; securityPolicyConfig.CertificateStoreDirectory = path; clientConfiguration.SecurityPolicyConfiguration = securityPolicyConfig; // Instantiate a list of certificates. // Populate CA Certificates in the trustedAnchors as required. //Certs //Creamos el cliente pasandole las configuracion //es importante agregar al momento de crear el cliente el Dispatcher que no viene referenciado en //DevConnect de Avaya List <X509Certificate2> trustedAnchors = new List <X509Certificate2>(); client = new Client(clientConfiguration, Dispatcher.CurrentDispatcher); if (client.CertificateManager.IsCertificateStoreInUse()) { // Remove existing certificates. client.CertificateManager.DeleteCertificateStore(); // Add new certificates. client.CertificateManager.SetCertificates(trustedAnchors); } // Client certificate has been successfully provisioned. //Definimos los Handlers client.UserCreated += new EventHandler <UserEventArgs> (clientDelegate.client_UserCreated); client.UserRemoved += new EventHandler <UserEventArgs> (clientDelegate.client_UserRemoved); client.ShutdownCompleted += new EventHandler(clientDelegate.client_ShutdownCompleted); userConfiguration = new UserConfiguration(); SipUserConfiguration sipUserConfig = userConfiguration.SipUserConfiguration; sipUserConfig.Enabled = true; bool tls_status = Properties.Settings.Default.tls; if (tls_status == true) { transport = TransportType.Tls; } else { transport = TransportType.Tcp; } SignalingServer signalingServer = new SignalingServer(transport, sip, port, FailbackPolicy.Automatic); //5060 - TCP & 5061 -Tls SignalingServerGroup sipsignallingServerGroup = new SignalingServerGroup(signalingServer); sipUserConfig.ConnectionPolicy = new ConnectionPolicy(sipsignallingServerGroup); sipUserConfig.UserId = extension; sipUserConfig.Domain = domain; sipUserConfig.CredentialProvider = new UserNamePasswordCredentialProvider(extension, pass, domain); sipUserConfig.MediaEncryptionTypeArray = new MediaEncryptionType[] { MediaEncryptionType.Aes128Sha1Hmac32, MediaEncryptionType.Aes128Sha1Hmac80, MediaEncryptionType.Aes256Sha1Hmac32, MediaEncryptionType.Aes256Sha1Hmac80, MediaEncryptionType.None }; client.CreateUser(userConfiguration, (user, error) => { if (error != null) { Console.WriteLine(string.Format("User creation error {0}", error)); return; } Console.WriteLine("User created."); m_User = user; // Add event handlers to user object to handle all user related events m_User.Start(); //Cambios en UI extension_lbl.Text = userConfiguration.SipUserConfiguration.UserId; nombreext_lbl.Text = userConfiguration.SipUserConfiguration.DisplayName; dominio_lbl.Text = userConfiguration.SipUserConfiguration.Domain; call_btn.Enabled = true; hang_btn.Enabled = true; callServiceDelegate = new AppCallDelegate(); m_User.CallService.IncomingCallReceived += new EventHandler <CallEventArgs>(callServiceDelegate.user_IncomingCall); m_User.CallService.CallRemoved += new EventHandler <CallEventArgs>(callServiceDelegate.user_CallRemoved); //Agregamos a la coleccion de camaras cameraVideoSource = new CameraVideoSource(); int conteocamaras = cameraVideoSource.Cameras.Count; Console.WriteLine("Camaras Dispoibles" + conteocamaras); DataTable TablaCamaras = new DataTable("camaras"); TablaCamaras.Columns.Add("id"); TablaCamaras.Columns.Add("nombre"); int i = 0; do { Console.WriteLine("Camara: " + cameraVideoSource.Cameras[i].Name); TablaCamaras.Rows.Add(i, cameraVideoSource.Cameras[i].Name); i++; } while (i < conteocamaras); }); } } }