Пример #1
0
            public void AddRequestFormat(MsexVersion peerMsexVersion, RequestStreamMessagePacket packet)
            {
                if (SourceIdentifier == -1)
                {
                    SourceIdentifier = packet.SourceIdentifier;
                }
                else if (SourceIdentifier != packet.SourceIdentifier)
                {
                    throw new InvalidOperationException("Cannot add request format, source id does not match");
                }


                FrameWidth  = Math.Max(FrameWidth, packet.FrameWidth);
                FrameHeight = Math.Max(FrameHeight, packet.FrameHeight);
                Fps         = Math.Max(Fps, packet.Fps);


                var format = Formats.FirstOrDefault(r => r.FrameFormat == packet.FrameFormat &&
                                                    r.IsVersion12 == (peerMsexVersion == MsexVersion.Version1_2));

                if (format != null)
                {
                    Formats.Remove(format);
                    format = new RequestFormat(format.FrameFormat, peerMsexVersion);
                    Formats.Add(format);

                    var packetExpireAt = DateTime.Now + TimeSpan.FromSeconds(packet.Timeout);

                    if (packetExpireAt > format.ExpireAt)
                    {
                        format.ExpireAt = packetExpireAt;
                    }
                }
                else
                {
                    Formats.Add(new RequestFormat(packet.FrameFormat, peerMsexVersion)
                    {
                        LastOutput = DateTime.MinValue,
                        ExpireAt   = DateTime.Now + TimeSpan.FromSeconds(packet.Timeout)
                    });
                }
            }
Пример #2
0
 public RequestFormat(MsexImageFormat frameFormat, MsexVersion version)
 {
     FrameFormat = frameFormat;
     Version     = version;
 }