示例#1
0
        public RTPSink(IPAddress localAddress, ArrayList inUsePorts)
        {
            m_udpListener = NetServices.CreateRandomUDPListener(localAddress, RTP_PORTRANGE_START, RTP_PORTRANGE_END, inUsePorts, out m_localEndPoint);

            m_udpListener.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.TypeOfService, RTPPacketTypeOfService);

            logger.LogInformation("RTPSink established on " + m_localEndPoint.Address.ToString() + ":" + m_localEndPoint.Port + ".");
            //receivelogger.LogInformation("Send Time,Send Timestamp,Receive Time,Receive Timestamp,Receive Offset(ms),Timestamp Diff,SeqNum,Bytes");
            //sendlogger.LogInformation("Send Time,Send Timestamp,Send Offset(ms),SeqNum,Bytes");
        }
示例#2
0
        public STUNServer(IPEndPoint primaryEndPoint, STUNSendMessageDelegate primarySend, IPEndPoint secondaryEndPoint, STUNSendMessageDelegate secondarySend)
        {
            m_primaryEndPoint   = primaryEndPoint;
            m_primarySend       = primarySend;
            m_secondaryEndPoint = secondaryEndPoint;
            m_secondarySend     = secondarySend;

            m_primaryDiffPortSocket   = NetServices.CreateRandomUDPListener(m_primaryEndPoint.Address, out m_primaryDiffPortEndPoint);
            m_secondaryDiffPortSocket = NetServices.CreateRandomUDPListener(m_secondaryEndPoint.Address, out m_secondaryDiffPortEndPoint);

            logger.LogDebug("STUN Server additional sockets, primary=" + IPSocket.GetSocketString(m_primaryDiffPortEndPoint) + ", secondary=" + IPSocket.GetSocketString(m_secondaryDiffPortEndPoint) + ".");
        }
示例#3
0
        /// <param name="rtpListenAddress">The local IP address to establish the RTP listener socket on.</param>
        /// <param name="sdpAdvertiseAddress">The public IP address to put into the SDP sent back to the caller.</param>
        /// <param name="request">The INVITE request that instigated the RTP diagnostics job.</param>
        public RTPDiagnosticsJob(IPAddress rtpListenAddress, IPAddress sdpAdvertiseAddress, SIPServerUserAgent uas, SIPRequest request)
        {
            m_request         = request;
            m_remoteSDP       = SDP.ParseSDPDescription(request.Body);
            RemoteRTPEndPoint = new IPEndPoint(IPAddress.Parse(m_remoteSDP.Connection.ConnectionAddress), m_remoteSDP.Media[0].Port);
            UAS = uas;
            //m_rawSourceStream = new RawSourceWaveStream(m_outStream, WaveFormat.CreateMuLawFormat(8000, 1));
            //m_waveFileWriter = new WaveFileWriter("out.wav", new WaveFormat(8000, 16, 1));
            m_waveFileWriter = new WaveFileWriter("out.wav", new WaveFormat(8000, 16, 1));
            //m_outPCMStream = WaveFormatConversionStream.CreatePcmStream(m_rawSourceStream);
            //m_rawRTPPayloadWriter = new StreamWriter("out.rtp");
            //m_rawRTPPayloadReader = new StreamReader("in.rtp");
            //IPEndPoint rtpListenEndPoint = null;
            IPEndPoint rtpListenEndPoint = null;

            NetServices.CreateRandomUDPListener(rtpListenAddress, RTP_PORTRANGE_START, RTP_PORTRANGE_END, m_inUsePorts, out rtpListenEndPoint);
            RTPListenEndPoint = rtpListenEndPoint;
            m_inUsePorts.Add(rtpListenEndPoint.Port);
            //RTPListenEndPoint = new IPEndPoint(rtpListenAddress, RTP_PORTRANGE_START);
            m_rtpChannel = new RTPChannel(RTPListenEndPoint);
            m_rtpChannel.SampleReceived += SampleReceived;
            ThreadPool.QueueUserWorkItem(delegate { GetAudioSamples(); });

            LocalSDP = new SDP()
            {
                SessionId   = Crypto.GetRandomString(6),
                Address     = sdpAdvertiseAddress.ToString(),
                SessionName = "sipsorcery",
                Timing      = "0 0",
                Connection  = new SDPConnectionInformation(sdpAdvertiseAddress.ToString()),
                Media       = new List <SDPMediaAnnouncement>()
                {
                    new SDPMediaAnnouncement()
                    {
                        Media        = SDPMediaTypesEnum.audio,
                        Port         = RTPListenEndPoint.Port,
                        MediaFormats = new List <SDPMediaFormat>()
                        {
                            new SDPMediaFormat((int)SDPMediaFormatsEnum.PCMU)
                        }
                    }
                }
            };
        }
示例#4
0
        public RTPSink(IPAddress localAddress, ArrayList inUsePorts)
        {
            m_udpListener = NetServices.CreateRandomUDPListener(localAddress, RTP_PORTRANGE_START, RTP_PORTRANGE_END, inUsePorts, out m_localEndPoint);

            int typeOfService = TYPEOFSERVICE_RTPSEND;

            // If a setting has been supplied in the config file use that.
            Int32.TryParse(m_typeOfService, out typeOfService);

            try
            {
                m_udpListener.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.TypeOfService, typeOfService);
                logger.Debug("Setting RTP packet ToS to " + m_typeOfService + ".");
            }
            catch (Exception excp)
            {
                logger.Warn("Exception setting IP type of service for RTP packet to " + typeOfService + ". " + excp.Message);
            }

            logger.Info("RTPSink established on " + m_localEndPoint.Address.ToString() + ":" + m_localEndPoint.Port + ".");
            //receiveLogger.Info("Send Time,Send Timestamp,Receive Time,Receive Timestamp,Receive Offset(ms),Timestamp Diff,SeqNum,Bytes");
            //sendLogger.Info("Send Time,Send Timestamp,Send Offset(ms),SeqNum,Bytes");
        }