Esempio n. 1
0
        public override void SendUserData(OutgoingPackage package)
        {
            // 更新发送序号
            var seq = (ushort)this.Context.SeqNoManager.GetAndUpdateSendSeq();

            // 计算用户数据在发送队列中的排队时延。
            package.QueuingDelay = (UInt32)((DateTime.Now - package.CreationTime).TotalMilliseconds / 10);

            // 计算发送方时间戳
            var currentTime     = TripleTimestamp.CurrentTimestamp;
            var senderTimeStamp = currentTime;

            if (currentTime > (package.ExtraDelay + package.QueuingDelay))
            {
                senderTimeStamp = currentTime - package.ExtraDelay - package.QueuingDelay;
            }

            var dtFrame = new SaiTtsFrameAppData(seq,
                                                 senderTimeStamp,
                                                 this.TTS.RemoteLastSendTimestamp,
                                                 this.TTS.LocalLastRecvTimeStamp,
                                                 package.UserData);

            this.Context.NextLayer.SendUserData(dtFrame.GetBytes());
        }
Esempio n. 2
0
        public void Test1()
        {
            var frameInital = new SaiTtsFrameAppData();

            frameInital.SequenceNo                = 100;
            frameInital.SenderTimestamp           = 1000;
            frameInital.SenderLastRecvTimestamp   = 900;
            frameInital.ReceiverLastSendTimestamp = 800;
            frameInital.UserData = new byte[] { 1, 2, 3 };

            var bytes = frameInital.GetBytes();

            var actual = SaiFrame.Parse(bytes) as SaiTtsFrameAppData;

            Assert.AreEqual(frameInital.FrameType, actual.FrameType);
            Assert.AreEqual(frameInital.SequenceNo, actual.SequenceNo);
            Assert.AreEqual(frameInital.SenderTimestamp, actual.SenderTimestamp);
            Assert.AreEqual(frameInital.SenderLastRecvTimestamp, actual.SenderLastRecvTimestamp);
            Assert.AreEqual(frameInital.ReceiverLastSendTimestamp, actual.ReceiverLastSendTimestamp);
            Assert.AreEqual(frameInital.UserData[0], actual.UserData[0]);
            Assert.AreEqual(frameInital.UserData[1], actual.UserData[1]);
            Assert.AreEqual(frameInital.UserData[2], actual.UserData[2]);
        }