public TargettedSpeech(bool stop = true)
 {
     IsStop   = stop;
     PcmData  = null;
     Target   = SpeechTarget.Normal;
     TargetId = 0;
 }
 /// <summary>
 /// Add some raw PCM data to the buffer to send
 /// </summary>
 /// <param name="pcm"></param>
 /// <param name="target"></param>
 /// <param name="targetId"></param>
 public void Add(PcmArray pcm, SpeechTarget target, uint targetId)
 {
     lock (_unencodedBuffer)
     {
         _unencodedBuffer.Enqueue(new TargettedSpeech(pcm, target, targetId));
     }
 }
Ejemplo n.º 3
0
        public override void EncodedVoice(byte[] data, uint userId, long sequence, IVoiceCodec codec, SpeechTarget target)
        {
            User user = Users.FirstOrDefault(u => u.Id == userId);
            if (user != null)
                Console.WriteLine(user.Name + " is speaking. Seq" + sequence);

            base.EncodedVoice(data, userId, sequence, codec, target);
        }
Ejemplo n.º 4
0
            public TargettedSpeech(bool stop = true)
            {
                IsStop = stop;

                Pcm      = default(ArraySegment <byte>);
                Target   = SpeechTarget.Normal;
                TargetId = 0;
            }
            public TargettedSpeech(PcmArray pcm, SpeechTarget target, uint targetId)
            {
                TargetId = targetId;
                Target   = target;
                PcmData  = pcm;

                IsStop = false;
            }
Ejemplo n.º 6
0
 /// <summary>
 /// Add some raw PCM data to the buffer to send
 /// </summary>
 /// <param name="pcm"></param>
 /// <param name="target"></param>
 /// <param name="targetId"></param>
 public void Add(PcmArray pcm, SpeechTarget target, uint targetId)
 {
     lock (_bufferLock)
     {
         _unencodedBuffer.Enqueue(new TargettedSpeech(pcm, target, targetId));
         Monitor.Pulse(_bufferLock);
     }
 }
Ejemplo n.º 7
0
            public TargettedSpeech(ArraySegment <byte> pcm, SpeechTarget target, uint targetId)
            {
                TargetId = targetId;
                Target   = target;
                Pcm      = pcm;

                IsStop = false;
            }
Ejemplo n.º 8
0
 public void SendVoice(ArraySegment <byte> buffer, SpeechTarget target = SpeechTarget.Normal)
 {
     Owner.SendVoice(
         buffer,
         target: target,
         targetId: Id
         );
 }
Ejemplo n.º 9
0
        public void SendVoice(PcmArray pcm, SpeechTarget target, uint targetId)
        {
            _encodingBuffer.Add(pcm, target, targetId);

            if (!_encodingThread.IsAlive)
            {
                _encodingThread.Start();
            }
        }
Ejemplo n.º 10
0
        public void SendVoice(ArraySegment <byte> pcm, SpeechTarget target, uint targetId)
        {
            if (!Connection.VoiceSupportEnabled)
            {
                throw new InvalidOperationException("Voice Support is disabled with this connection");
            }

            _encodingBuffer.Add(pcm, target, targetId);
        }
Ejemplo n.º 11
0
        public void SendVoice(PcmArray pcm, SpeechTarget target, uint targetId)
        {
            _encodingBuffer.Add(pcm, target, targetId);

            if (_encodingThread == null)
            {
                _encodingThread = new Thread(EncodingThreadEntry)
                {
                    IsBackground = true
                };
                _encodingThread.Start();
            }
        }
Ejemplo n.º 12
0
        private bool TryAddToEncodingBuffer(TargettedSpeech t, out bool stopped)
        {
            if (t.IsStop)
            {
                stopped = true;
                return(false);
            }
            stopped = false;

            if (!(_pcmBuffer.Count == 0 || (_target == t.Target && _targetId == t.TargetId)))
            {
                return(false);
            }

            _pcmBuffer.Write(t.Pcm);

            _target   = t.Target;
            _targetId = t.TargetId;

            return(true);
        }
Ejemplo n.º 13
0
 public void SendVoice(ArraySegment<byte> pcm, SpeechTarget target, uint targetId)
 {
     _encodingBuffer.Add(pcm, target, targetId);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Received a voice packet from the server
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <param name="sequence"></param>
        /// <param name="codec"></param>
        /// <param name="target"></param>
        public virtual void EncodedVoice(byte[] data, uint userId, long sequence, IVoiceCodec codec, SpeechTarget target)
        {
            User user;
            if (!UserDictionary.TryGetValue(userId, out user))
                return;

            user.ReceiveEncodedVoice(data, sequence, codec);
        }
Ejemplo n.º 15
0
        public override void EncodedVoice(byte[] data, uint userId, long sequence, IVoiceCodec codec, SpeechTarget target)
        {
            User user = Users.FirstOrDefault(u => u.Id == userId);

            if (user != null)
            {
                Console.WriteLine(user.Name + " is speaking. Seq" + sequence);
            }

            base.EncodedVoice(data, userId, sequence, codec, target);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Received a voice packet from the server
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <param name="sequence"></param>
        /// <param name="codec"></param>
        /// <param name="target"></param>
        public virtual void EncodedVoice(byte[] data, uint userId, long sequence, IVoiceCodec codec, SpeechTarget target)
        {
            User user;

            if (!UserDictionary.TryGetValue(userId, out user))
            {
                return;
            }

            user.ReceiveEncodedVoice(data, sequence, codec);
        }
Ejemplo n.º 17
0
 public void SendVoice(ArraySegment <byte> pcm, SpeechTarget target, uint targetId)
 {
     _encodingBuffer.Add(pcm, target, targetId);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Add some raw PCM data to the buffer to send
 /// </summary>
 /// <param name="pcm"></param>
 /// <param name="target"></param>
 /// <param name="targetId"></param>
 public void Add(ArraySegment<byte> pcm, SpeechTarget target, uint targetId)
 {
     _unencodedBuffer.Add(new TargettedSpeech(pcm, target, targetId));
 }
Ejemplo n.º 19
0
            public TargettedSpeech(ArraySegment<byte> pcm, SpeechTarget target, uint targetId)
            {
                TargetId = targetId;
                Target = target;
                Pcm = pcm;

                IsStop = false;
            }
Ejemplo n.º 20
0
            public TargettedSpeech(bool stop = true)
            {
                IsStop = stop;

                Pcm = default(ArraySegment<byte>);
                Target = SpeechTarget.Normal;
                TargetId = 0;
            }
Ejemplo n.º 21
0
        private bool TryAddToEncodingBuffer(TargettedSpeech t, out bool stopped)
        {
            if (t.IsStop)
            {
                stopped = true;
                return false;
            }
            stopped = false;

            if (!(_pcmBuffer.Count == 0 || (_target == t.Target && _targetId == t.TargetId)))
                return false;

            _pcmBuffer.Write(t.Pcm);

            _target = t.Target;
            _targetId = t.TargetId;

            return true;
        }
Ejemplo n.º 22
0
 public new void SendVoice(ArraySegment <byte> pcm, SpeechTarget target, uint targetId)
 {
     base.SendVoice(pcm, target, targetId);
 }
Ejemplo n.º 23
0
 public void SendVoice(PcmArray pcm, SpeechTarget target, uint targetId)
 {
     _stopSendingRequested = false;
     _encodingBuffer.Add(pcm, target, targetId);
     _waitHandle.Set();
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Received a voice packet from the server
        /// </summary>
        /// <param name="data"></param>
        /// <param name="userId"></param>
        /// <param name="sequence"></param>
        /// <param name="codec"></param>
        /// <param name="target"></param>
        public virtual void EncodedVoice(byte[] data, uint userId, long sequence, IVoiceCodec codec, SpeechTarget target)
        {
            if (!Connection.VoiceSupportEnabled)
            {
                throw new InvalidOperationException("Voice Support is disabled with this connection");
            }

            User user;

            if (!UserDictionary.TryGetValue(userId, out user))
            {
                return;
            }

            user.ReceiveEncodedVoice(data, sequence, codec);
        }
Ejemplo n.º 25
0
 public new void SendVoice(ArraySegment<byte> pcm, SpeechTarget target, uint targetId)
 {
     base.SendVoice(pcm,target,targetId);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// Add some raw PCM data to the buffer to send
 /// </summary>
 /// <param name="pcm"></param>
 /// <param name="target"></param>
 /// <param name="targetId"></param>
 public void Add(ArraySegment <byte> pcm, SpeechTarget target, uint targetId)
 {
     _unencodedBuffer.Add(new TargettedSpeech(pcm, target, targetId));
 }
Ejemplo n.º 27
0
 public EncodedTargettedSpeech(byte[] encodedPcm, SpeechTarget target, uint targetId)
 {
     TargetId   = targetId;
     Target     = target;
     EncodedPcm = encodedPcm;
 }