Esempio n. 1
0
 /// <summary>
 /// Initializes the Recorder component to be able to transmit audio.
 /// </summary>
 /// <param name="voiceConnection">The VoiceConnection to be used with this Recorder.</param>
 public void Init(VoiceConnection voiceConnection)
 {
     if (this.IsInitialized)
     {
         if (this.Logger.IsWarningEnabled)
         {
             this.Logger.LogWarning("Recorder already initialized.");
         }
         return;
     }
     if (voiceConnection == null)
     {
         if (this.Logger.IsErrorEnabled)
         {
             this.Logger.LogError("voiceConnection is null.");
         }
         return;
     }
     if (voiceConnection.VoiceClient == null)
     {
         if (this.Logger.IsErrorEnabled)
         {
             this.Logger.LogError("voiceConnection.VoiceClient is null.");
         }
         return;
     }
     this.client = voiceConnection.VoiceClient;
     if (this.AutoStart)
     {
         this.StartRecording();
     }
 }
Esempio n. 2
0
        public void Init(VoiceClient voiceClient, object customObj = null)
        {
            if (this.IsInitialized)
            {
                if (this.Logger.IsWarningEnabled)
                {
                    this.Logger.LogWarning("Recorder already initialized.");
                }
                return;
            }

            if (voiceClient == null)
            {
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.LogError("voiceClient is null.");
                }
                return;
            }

            this.client   = voiceClient;
            this.userData = customObj;

            if (this.AutoStart)
            {
                this.StartRecording();
            }
        }
Esempio n. 3
0
        private void OnReceived(IAsyncResult iAsyncResult)
        {
            try
            {
                VoiceClient client    = iAsyncResult.AsyncState as VoiceClient;
                byte[]      sendBytes = client.GetData(iAsyncResult);

                if (sendBytes.Length == 0)
                {
                    client.ReadOnly.Close();
                    Clients.Remove(client);
                }
                else
                {
                    //foreach (VoiceClient clientSend in Clients)
                    //{
                    //    if (client != clientSend)
                    //    {
                    //        try
                    //        {
                    //            clientSend.ReadOnly.Send(sendBytes);
                    //        }
                    //        catch (Exception e)
                    //        {
                    //            clientSend.ReadOnly.Close();
                    //            Clients.Remove(client);
                    //            return;
                    //        }
                    //    }
                    //}
                    //client.CallBackReceive();

                    // PARALLEL ForEAch experiment:

                    Parallel.ForEach(Clients, (clientToSend, state) =>
                    {
                        if (client != clientToSend)
                        {
                            try
                            {
                                clientToSend.ReadOnly.Send(sendBytes);
                            }
                            catch (Exception e)
                            {
                                clientToSend.ReadOnly.Close();
                                Clients.Remove(client);
                                state.Break();
                                return;
                            }
                        }
                    });
                    client.CallBackReceive();
                }
            }
            catch (ObjectDisposedException e)
            {
                return;
            }
        }
Esempio n. 4
0
 private void handleIncomingCallIntent(Intent intent)
 {
     if (intent != null && intent.Action != null && intent.Action == VoiceActivity.ACTION_INCOMING_CALL)
     {
         IncomingCallMessage incomingCallMessage = intent.getParcelableExtra(INCOMING_CALL_MESSAGE);
         VoiceClient.handleIncomingCallMessage(ApplicationContext, incomingCallMessage, incomingCallMessageListener_Renamed);
     }
 }
Esempio n. 5
0
    // Token: 0x06000053 RID: 83 RVA: 0x00003290 File Offset: 0x00001490
    internal UnityVoiceFrontend(ConnectionProtocol connetProtocol) : base(connetProtocol)
    {
        VoiceClient voiceClient = this.voiceClient;

        voiceClient.OnRemoteVoiceInfoAction = (VoiceClient.RemoteVoiceInfoDelegate)Delegate.Combine(voiceClient.OnRemoteVoiceInfoAction, new VoiceClient.RemoteVoiceInfoDelegate(this.OnRemoteVoiceInfo));
        base.AutoJoinLobby              = false;
        base.OnStateChangeAction        = (Action <ExitGames.Client.Photon.LoadBalancing.ClientState>)Delegate.Combine(base.OnStateChangeAction, new Action <ExitGames.Client.Photon.LoadBalancing.ClientState>(this.OnStateChange));
        base.OnOpResponseAction        += this.OnOpResponse;
        this.loadBalancingPeer.DebugOut = DebugLevel.INFO;
    }
        private IEnumerable <RadioChannelMember> GetRadioChannelMembership(VoiceClient voiceClient)
        {
            var memberships = new List <RadioChannelMember>();

            lock (_radioChannels)
            {
                memberships.AddRange(_radioChannels.Select(radioChannel => radioChannel.Members.FirstOrDefault(m => m.VoiceClient == voiceClient)).Where(membership => membership != null));
            }

            return(memberships);
        }
Esempio n. 7
0
 public MyDataComunication CloseCommunication()
 {
     IsRecording = false;
     WaveIn.StopRecording();
     WaveOut.Stop();
     Capture.Stop();
     ImageClient.CloseConnection();
     ImageServer.CloseConnection();
     VoiceClient.CloseConnection();
     VoiceServer.CloseConnection();
     return(this);
 }
Esempio n. 8
0
 private void AcceptClient(Socket clientSocket)
 {
     try
     {
         NewVoiceClient = new VoiceClient(clientSocket, this);
         Clients.Add(NewVoiceClient);
         NewVoiceClient.CallBackReceive();
     }
     catch (ObjectDisposedException e)
     {
         return;
     }
 }
Esempio n. 9
0
		static void Main(string[] args)
		{
			int sampleRate = 21760;
			var client = new VoiceClient(new CodecInfo(VoiceCodec.Gsm610, sampleRate), null,
				() =>
				{
					return true;
					return (GetKeyState(0x41) & 0x8000) > 0;
				});
			client.AddPeer(VoiceCodec.Gsm610, sampleRate, new IPEndPoint(Dns.GetHostEntry("spoon.failurefiles.com").AddressList[0], 57222));
			client.Open();
			Console.ReadLine();
			client.InputGain = 10;
			Console.ReadLine();
		}
Esempio n. 10
0
        private async void JoinRadioChannel(VoiceClient voiceClient, string radioChannelName, bool isPrimary)
        {
            lock (_radioChannels)
            {
                if (_radioChannels.Any(c => c.Members.Any(m => m.VoiceClient == voiceClient && m.IsPrimary == isPrimary)))
                {
                    return;
                }
            }

            var radioChannel = GetRadioChannel(radioChannelName, true);

            radioChannel.AddMember(voiceClient, isPrimary);

            await Task.CompletedTask;
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            int sampleRate = 21760;
            var client     = new VoiceClient(new CodecInfo(VoiceCodec.Gsm610, sampleRate), null,
                                             () =>
            {
                return(true);

                return((GetKeyState(0x41) & 0x8000) > 0);
            });

            client.AddPeer(VoiceCodec.Gsm610, sampleRate, new IPEndPoint(Dns.GetHostEntry("spoon.failurefiles.com").AddressList[0], 57222));
            client.Open();
            Console.ReadLine();
            client.InputGain = 10;
            Console.ReadLine();
        }
Esempio n. 12
0
        private async void LeaveRadioChannel(VoiceClient voiceClient, string radioChannelName)
        {
            foreach (var membership in GetRadioChannelMembership(voiceClient).Where(m => m.RadioChannel.Name == radioChannelName))
            {
                membership.RadioChannel.RemoveMember(voiceClient);
                if (membership.RadioChannel.Members.Length != 0)
                {
                    continue;
                }
                lock (_radioChannels)
                {
                    _radioChannels.Remove(membership.RadioChannel);
                }
            }

            await Task.CompletedTask;
        }
Esempio n. 13
0
        protected override void OnEventFired(object source, EventArgs args)
        {
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    //TODO: Expose these vivox stuff as shared constants between client and server.
                    ILoginSession session = VoiceClient.GetLoginSession(new AccountId("vrguardian-vrg-dev", PlayerDetails.LocalPlayerGuid.EntityId.ToString(), "vdx5.vivox.com"));
                    ResponseModel <string, VivoxLoginResponseCode> loginResult = await VivoxAutheAuthorizationService.LoginAsync();

                    //TODO: Better error and retry handling.
                    if (!loginResult.isSuccessful)
                    {
                        if (Logger.IsErrorEnabled)
                        {
                            Logger.Error($"Failed to authenticate Vivox. Reason: {loginResult.ResultCode}");
                            return;
                        }
                    }

                    await session.LoginAsync(new Uri("https://vdx5.www.vivox.com/api2"), loginResult.Result)
                    .ConfigureAwait(true);

                    //TODO: Does this above task complete immediately or does it wait until the state is known??
                    if (session.State == LoginState.LoggedIn)
                    {
                        OnVoiceSessionAuthenticated?.Invoke(this, new VoiceSessionAuthenticatedEventArgs(session));
                    }
                    else
                    {
                        throw new InvalidOperationException($"Failed to authentication with Vivox.");
                    }
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to Initialize Vivox Voice. Reason: {e.Message}\n\nStack: {e.StackTrace}");
                    }

                    throw;
                }
            });
        }
Esempio n. 14
0
        private async void LeaveRadioChannel(VoiceClient voiceClient)
        {
            var memberships = GetRadioChannelMembership(voiceClient);

            foreach (var membership in memberships)
            {
                membership.RadioChannel.RemoveMember(voiceClient);
                if (membership.RadioChannel.Members.Length != 0)
                {
                    continue;
                }
                lock (_radioChannels)
                {
                    _radioChannels.Remove(membership.RadioChannel);
                }
            }

            await Task.CompletedTask;
        }
Esempio n. 15
0
        private void RecordSoundAndSend()
        {
            VoiceClient.OpenConnection();
            IsRecording           = true;
            WaveIn                = new WaveInEvent();
            WaveIn.DataAvailable += new EventHandler <WaveInEventArgs>((s, x) =>
            {
                VoiceClient.Send(x.Buffer);
            });

            Task.Run(() =>
            {
                WaveIn.StartRecording();
                while (IsRecording)
                {
                    ;
                }
                WaveIn.StopRecording();
            });
        }
 private void OnEnable()
 {
     VoiceConnection[] voiceConnections = this.GetComponents <VoiceConnection>();
     if (voiceConnections == null || voiceConnections.Length == 0)
     {
         Debug.LogError("No VoiceConnection component found, PhotonVoiceStatsGui disabled", this);
         this.enabled = false;
         return;
     }
     if (voiceConnections.Length > 1)
     {
         Debug.LogWarningFormat(this, "Multiple VoiceConnection components found, using first occurrence attached to GameObject {0}", voiceConnections[0].name);
     }
     this.voiceConnection = voiceConnections[0];
     this.voiceClient     = this.voiceConnection.VoiceClient;
     this.peer            = this.voiceConnection.Client.LoadBalancingPeer;
     if (this.statsRect.x <= 0)
     {
         this.statsRect.x = Screen.width - this.statsRect.width;
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Initializes the Recorder component to be able to transmit audio.
        /// </summary>
        /// <param name="voiceClient">The VoiceClient to be used with this Recorder.</param>
        /// <param name="customObj">Optional user data object to be transmitted with the voice stream info</param>
        public void Init(VoiceClient voiceClient, object customObj = null)
        {
            if (this.IsInitialized && !this.RequiresInit)
            {
                if (this.Logger.IsWarningEnabled)
                {
                    this.Logger.LogWarning("Recorder already initialized.");
                }
                return;
            }

            if (voiceClient == null)
            {
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.LogError("voiceClient is null.");
                }
                return;
            }

            if (this.IsInitialized)
            {
                this.RemoveVoice(true);
            }

            this.client   = voiceClient;
            this.userData = customObj;

            switch (this.TypeConvert)
            {
            case SampleTypeConv.Short:
                forceShort = true;
                if (this.Logger.IsInfoEnabled)
                {
                    this.Logger.LogInfo("Type Conversion set to Short. Audio samples will be converted if source samples type differs.");
                }
                break;
            }
            Setup();
        }
Esempio n. 18
0
        static void Main(string[] args)
        {
            string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890";
            string apiKey     = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";

            string phoneNumber = "phone_number";

            string message     = "You're scheduled for a dentist appointment at 2:30PM.";
            string messageType = "ARN";

            try
            {
                VoiceClient voiceClient = new VoiceClient(customerId, apiKey);
                RestClient.TelesignResponse telesignResponse = voiceClient.Call(phoneNumber, message, messageType);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Press any key to quit.");
            Console.ReadKey();
        }
Esempio n. 19
0
        public ClientRoom(PhotonClientWrapper photonClientWrapper,
                          IMessageSerializationHandler messageSerializationHandler,
                          Action <ClientRoom <TPlayer> > initializedCallback)
        {
            _photonClientWrapper = photonClientWrapper;
            _initializedCallback = initializedCallback;

            Messenger = new Messenger(messageSerializationHandler, photonClientWrapper);
            Logger.SetMessenger(Messenger);
            Logger.PlayerPhotonId = photonClientWrapper.Player.ID;
            Messenger.Subscribe((int)Channels.Players, ProcessPlayersMessage);

            //if (VoiceSettings.Instance.Enabled)
            //{
            _voiceClient = new VoiceClient();
            //}

            Players = new List <TPlayer>();

            _photonClientWrapper.EventRecievedEvent += OnRecievedEvent;

            Logger.LogDebug("Created ClientRoom");
        }
        static void Main(string[] args)
        {
            string customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890";
            string apiKey     = "EXAMPLETE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";

            string phoneNumber = "phone_number";

            string verifyCode  = "12345";
            string message     = string.Format("Hello, your code is {0}. Once again, your code is {1}. Goodbye.", verifyCode, verifyCode);
            string messageType = "OTP";

            try
            {
                VoiceClient voiceClient = new VoiceClient(customerId, apiKey);
                RestClient.TelesignResponse telesignResponse = voiceClient.Call(phoneNumber, message, messageType);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.WriteLine("Press any key to quit.");
            Console.ReadKey();
        }
        private async void OnServerEnablePlayer(IPlayer player)
        {
            var health = await AltAsync.GetHealthAsync(player);

            VoiceClient voiceClient;

            lock (_voiceClients)
            {
                voiceClient = new VoiceClient(player, GetTeamSpeakName(player), Configuration.VoiceRanges[1], health > 100);
                if (_voiceClients.ContainsKey(player))
                {
                    _voiceClients[player] = voiceClient;
                }
                else
                {
                    _voiceClients.TryAdd(player, voiceClient);
                }
            }

            player.EmitLocked("SaltyChat:Initialize", new ClientInitData(voiceClient.TeamSpeakName));

            var voiceClients = new List <VoiceClient>();

            lock (_voiceClients)
            {
                foreach (var(key, value) in _voiceClients.Where(c => c.Key.Id != player.Id))
                {
                    voiceClients.Add(new VoiceClient(key, value.TeamSpeakName, value.VoiceRange, value.IsAlive, key.Position));
                    key.EmitLocked("SaltyChat:UpdateClient", player, voiceClient.TeamSpeakName, voiceClient.VoiceRange, voiceClient.IsAlive, player.Position);
                }
            }

            player.EmitLocked("SaltyChat:SyncClients", new ClientSyncData(voiceClients));

            await Task.CompletedTask;
        }
Esempio n. 22
0
 internal RadioChannelMember(RadioChannel radioChannel, VoiceClient voiceClient, bool isPrimary)
 {
     RadioChannel = radioChannel;
     VoiceClient  = voiceClient;
     IsPrimary    = isPrimary;
 }
Esempio n. 23
0
 /*
  * Register your GCM token with Twilio to enable receiving incoming calls via GCM
  */
 private void register()
 {
     VoiceClient.register(ApplicationContext, accessToken, gcmToken, registrationListener_Renamed);
 }