コード例 #1
0
ファイル: Voiper.cs プロジェクト: zuohuaiyu1205/VOIP
 public bool Contains(Rtp.RtpPacket rtpPacket)     //相同序列号的消重
 {
     foreach (Rtp.RtpPacket rtp in packetsList)
     {
         if (rtp.SequenceNumber == rtpPacket.SequenceNumber)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #2
0
ファイル: Voiper.cs プロジェクト: zuohuaiyu1205/VOIP
 public void Add(Rtp.RtpPacket packet)
 {
     lock (packetsList)
     {
         if (!Contains(packet))
         {
             packetsList.Add(packet);
         }
     }
     //if(packet.Marker)
     //{
     //    int i = 0;
     //    ToPcm();
     //}
 }
コード例 #3
0
ファイル: Gfp.cs プロジェクト: zuohuaiyu1205/VOIP
 public string AsKey(IPv4Packet ipv4, UdpPacket udp, Voip.Rtp.RtpPacket rtp)
 {
     return(string.Format("{0}_{1}_{2}_{3}_{4}", ipv4.SourceAddress, ipv4.DestinationAddress, udp.SourcePort, udp.DestinationPort, rtp.SSRC));
 }
コード例 #4
0
ファイル: Gfp.cs プロジェクト: zuohuaiyu1205/VOIP
        private void Processing(Stream stream)
        {
            while (stream.CanRead && stream.Position < stream.Length)
            {
                GfpFrame frame = null;
                try
                {
                    frame = getNextFrame(stream);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("读取下一帧出现错误", ex);
                    continue;
                }
                if (frame != null && frame.IpPackets != null)
                {
                    Metadata.BaseMetadata metadata   = new Metadata.BaseMetadata(signalTime, frequency, frame);
                    IPv4Packet            ipv4Packet = new IPv4Packet(new PacketDotNet.Utils.ByteArraySegment(frame.IpPackets));
                    if (ipv4Packet == null)
                    {
                        break;
                    }
                    if (ipv4Packet.Protocol == ProtocolType.Udp)
                    {
                        if (ipv4Packet.PayloadPacket == null)
                        {
                            continue;
                        }
                        UdpPacket udpPacket = ipv4Packet.PayloadPacket as UdpPacket;
                        if (udpPacket.Bytes[8] == 0x80)
                        {
                            Voip.Rtp.RtpPacket rtpPacket = new Voip.Rtp.RtpPacket(udpPacket);
                            string             key       = AsKey(ipv4Packet, udpPacket, rtpPacket);
                            switch (rtpPacket.PayloadType)
                            {
                            case 0:         //PCMU/G711
                            case 4:         //G723
                            case 8:         //PCMA
                            case 9:         //G722
                            case 18:        //G729
                                if (Saver.Instance.Contains(key))
                                {
                                    Saver.Instance.Add(key, rtpPacket);
                                    if (Saver.Instance.Count(key) == Config.Instance.IsolatedCount)
                                    {
                                        LogHelper.Info(string.Format("发现新用户数据,五元组为{0}", key));
                                    }
                                }
                                else
                                {
                                    Saver.Instance.Create(key, rtpPacket, signalTime, frequency);
                                }
                                break;

                            default:
                                continue;
                            }
                        }
                        else
                        {
                            this.Agent?.Invoke(ipv4Packet, metadata);
                        }
                    }
                    else if (ipv4Packet.Protocol == ProtocolType.Tcp)
                    {
                        this.Agent?.Invoke(ipv4Packet, metadata);
                    }
                    else
                    {
                        this.Agent?.Invoke(ipv4Packet, metadata);
                    }
                }
            }
            stream.Close();
            stream.Dispose();
            GC.GetTotalMemory(true);
        }
コード例 #5
0
ファイル: Rtp4629.cs プロジェクト: zuohuaiyu1205/VOIP
 public Rtp4629(RtpPacket packet) : base(packet)
 {
     this.ParseData(packet.DataPointer, 0u);
 }