Пример #1
0
        //------------------------------------------------------------------------------------------------------------------------
        public bool serverNegotiation(Yodiwo.YPChannel.Channel channel)
        {
            //requires authentication
            var resp = channel.SendRequest <VideoAuthenticationResponse>(new VideoAuthenticationRequest());

            if (resp == null)
            {
                return(false);
            }
            else
            {
                //handle response
                if (!videofeeds.ContainsKey(resp.videotoken))
                {
                    return(false);
                }
                else
                {
                    //create context
                    var ctx = new ChannelContext()
                    {
                        videoInfo = videofeeds[resp.videotoken],
                    };
                    channel.Tags.Add(typeof(ChannelContext), ctx);
                    ctx.Receiving = true;
                    return(true);
                }
            }
        }
Пример #2
0
 //------------------------------------------------------------------------------------------------------------------------
 public void serverChannel_OnOpenEvent(Yodiwo.YPChannel.Channel channel)
 {
     DebugEx.TraceLog("A mjpeg recorder has been connected to me");
     Task.Run(() =>
     {
         var req = new VideoDataReq()
         {
             vflow = VideoFlow.Start
         };
         channel.SendRequest(req);
     });
 }
Пример #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 VideoDataResp)
            {
                var resp = (msg.Payload as VideoDataResp);
            }
            else if (msg.Payload is VideoData)
            {
                var resp = (msg.Payload as VideoData);
                //add bitmap to videofeed
                if (ctx.Receiving && ctx.videoInfo != null && ctx.videoInfo.IsActive)
                {
                    ctx.videoInfo.AddFrame(resp.linearBytes);
                }
            }
        }
Пример #4
0
        //------------------------------------------------------------------------------------------------------------------------

        void clientOnMessageReceived(Yodiwo.YPChannel.Channel channel, Yodiwo.YPChannel.YPMessage msg)
        {
            if (msg.Payload is AudioDataReq)
            {
                var req = (msg.Payload as AudioDataReq);
                if (req.aflow == AudioFlow.Start)
                {
                    try
                    {
                        audiosource.Start();
                    }
                    catch { }
                    var resp = new AudioDataResp()
                    {
                        status = StatusCode.Success
                    };
                    yclient.SendResponse(resp, msg.MessageID);
                    IsTransmitting = true;
                }
                else if (req.aflow == AudioFlow.Stop)
                {
                    IsTransmitting = false;
                    audiosource.Stop();
                    var resp = new AudioDataResp()
                    {
                        status = StatusCode.Success
                    };
                    channel.SendResponse(resp, msg.MessageID);
                }
            }
            else if (msg.Payload is AudioAuthenticationRequest)
            {
                var resp = new AudioAuthenticationResponse()
                {
                    audiotoken = this.audiotoken
                };
                channel.SendResponse(resp, msg.MessageID);
            }
        }
Пример #5
0
        //------------------------------------------------------------------------------------------------------------------------

        void clientOnMessageReceived(Yodiwo.YPChannel.Channel channel, Yodiwo.YPChannel.YPMessage msg)
        {
            if (msg.Payload is VideoDataReq)
            {
                var req = (msg.Payload as VideoDataReq);
                if (req.vflow == VideoFlow.Start)
                {
                    videosource.Start();
                }
                else if (req.vflow == VideoFlow.Stop)
                {
                    videosource.Stop();
                }
            }
            else if (msg.Payload is VideoAuthenticationRequest)
            {
                var resp = new VideoAuthenticationResponse()
                {
                    videotoken = this.videotoken
                };
                channel.SendResponse(resp, msg.MessageID);
                DebugEx.TraceLog("Sening response for VideoAuthenticationResponse , token=" + this.videotoken);
            }
        }