Exemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------------------------

        public bool serverNegotiation(Yodiwo.YPChannel.Channel channel)
        {
            var resp = channel.SendRequest <AudioAuthenticationResponse>(new AudioAuthenticationRequest());

            if (resp == null)
            {
                return(false);
            }
            else
            {
                //handle response
                if (!audiopipes.ContainsKey(resp.audiotoken))
                {
                    return(false);
                }
                else
                {
                    //create context
                    var ctx = new ChannelContext()
                    {
                        audioInfo = audiopipes[resp.audiotoken],
                    };
                    channel.Tags.Add(typeof(ChannelContext), ctx);
                    ctx.Receiving = true;
                    return(true);
                }
            }
        }
Exemplo n.º 2
0
        //------------------------------------------------------------------------------------------------------------------------

        public void serverChannel_OnOpenEvent(Yodiwo.YPChannel.Channel channel)
        {
            DebugEx.TraceLog("A mic recorder has been connected to me");
            Task.Run(() =>
            {
                var req = new AudioDataReq()
                {
                    aflow = AudioFlow.Start
                };
                channel.SendRequest(req);
            });
        }
Exemplo n.º 3
0
        //------------------------------------------------------------------------------------------------------------------------

        public void serverOnMessageReceived(Yodiwo.YPChannel.Channel channel, Yodiwo.YPChannel.YPMessage msg)
        {
            //get context
            var ctx = channel.Tags.TryGetOrDefault(typeof(ChannelContext)) as ChannelContext;

            //handle data
            if (msg.Payload is AudioDataResp)
            {
                var resp = (msg.Payload as AudioDataResp);
            }
            else if (msg.Payload is AudioData)
            {
                var resp = (msg.Payload as AudioData);
                if (ctx.Receiving && ctx.audioInfo.audiosink != null && ctx.audioInfo.audiosink.IsActive)
                {
                    ctx.audioInfo.audiosink.AddPCMdata(resp.linearBytes);
                }
            }
        }