Exemplo n.º 1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         peer?.Dispose();
         var port = int.Parse((FindName("Port") as TextBox).Text);
         peer = new Peer(port, new IPEndPoint(IPAddress.Parse("47.93.189.12"), 5000));
         peer.AddLiveAudioChatHandler();
         peer.AddHandler <ChatHandler>();
         Content = new ConnectPage(peer, this);
     }
     catch (Exception)
     {
         MessageBox.Show("请输入合法的端口值!");
     }
 }
Exemplo n.º 2
0
        public static Task StartSendLiveAudio(this Peer peer, string name)
        {
            peer.AddHandler <AudioLiveStreamHandler>();
            var channel = new MsgQueue <(byte[], int)>();
            var t       = peer.SendLiveStreamAsync(channel, name, (int)CallMethods.AudioDataSlice);
            var capture = new WaveInEvent
            {
                WaveFormat         = new WaveFormat(16000, 1),
                BufferMilliseconds = 100
            };

            capture.DataAvailable += (object sender, WaveInEventArgs e) =>
            {
                channel.Enqueue((e.Buffer, e.BytesRecorded));
            };
            capture.StartRecording();
            return(t.AsTask());
        }
Exemplo n.º 3
0
 public static void AddLiveAudioChatHandler(this Peer peer)
 {
     peer.AddHandler <AudioLiveStreamHandler>();
 }