Esempio n. 1
0
 public void SendPPS(RTP_SendStream sender, uint timestamp)
 {
     if (_pps != null)
     {
         RTP_Packet packet = new RTP_Packet();
         packet.Timestamp = timestamp;
         packet.Data      = _pps.NaluBytes();
         sender.Send(packet);
         _ppsStamp = Environment.TickCount;
     }
 }
Esempio n. 2
0
 private void buildFrame()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         bool isFirst = true;
         for (int i = 0; i < _nlist.Count; i++)
         {
             Nalu nal = _nlist[i];
             if (nal.Header.Type < 13)
             {
                 _ups_Unpacked(null, nal);
             }
             else
             {
                 //由于我们自己的RTP服务只使用FU_A封包方式发送数据,因此,此处示例我们只解析此封包方式。
                 if (nal.Header.Type == NaluTypes.FU_A)
                 {
                     FragUnitA fua = FragUnitA.Parse(nal.NaluBytes());
                     ////是接收序列的首包,但不是分片的首包,说明接收数据有丢失,无法正常解析。
                     //if (isFirst && !fua.Header.IsStart)
                     //    return;
                     ////是接收序列的末包,但不是分片的末包,说明接收数据有丢失,无法正常解析。
                     //if (i == _nlist.Count - 1 && !fua.Header.IsEnd)
                     //    return;
                     if (isFirst)
                     {
                         Nalu temp = new Nalu(new NaluHeader(false, fua.Indicator.NRI, fua.Header.Type), fua.Payload);
                         ms.Write(temp.NaluBytes(), 0, temp.TotalBytes);
                         isFirst = false;
                     }
                     else
                     {
                         ms.Write(fua.Payload, 0, fua.PayloadLen);
                     }
                 }
             }
         }
         if (ms.Length > 0)
         {
             _ups_Unpacked(null, Nalu.Parse(ms.ToArray()));
         }
     }
 }