Exemplo n.º 1
0
        private static SDP GetSDP(IPEndPoint rtpSocket, RTPPayloadTypesEnum audioPayloadType)
        {
            int samplingFrequency = RTPPayloadTypes.GetSamplingFrequency(audioPayloadType);

            var sdp = new SDP()
            {
                SessionId   = Crypto.GetRandomInt(5).ToString(),
                Address     = rtpSocket.Address.ToString(),
                SessionName = "sipsorcery",
                Timing      = "0 0",
                Connection  = new SDPConnectionInformation(rtpSocket.Address.ToString()),
            };

            var audioAnnouncement = new SDPMediaAnnouncement()
            {
                Media        = SDPMediaTypesEnum.audio,
                MediaFormats = new List <SDPMediaFormat>()
                {
                    new SDPMediaFormat((int)audioPayloadType, "PCMU", samplingFrequency)
                }
            };

            audioAnnouncement.Port = rtpSocket.Port;
            audioAnnouncement.ExtraAttributes.Add("a=sendrecv");
            audioAnnouncement.ExtraAttributes.Add($"a=rtpmap:{DTMF_EVENT_PAYLOAD_ID} telephone-event/{samplingFrequency}");
            audioAnnouncement.ExtraAttributes.Add($"a=fmtp:{DTMF_EVENT_PAYLOAD_ID} 0-15");
            sdp.Media.Add(audioAnnouncement);

            return(sdp);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new RTP session. The synchronisation source and sequence number are initialised to
 /// pseudo random values.
 /// </summary>
 /// <param name="payloadType">The payload type for the media attached to the sync source.</param>
 /// <param name="srtpProtect">Optional secure DTLS context for encrypting RTP packets.</param>
 /// <param name="srtcpProtect">Optional secure DTLS context for encrypting RTCP packets.</param>
 public RTPSession(RTPPayloadTypesEnum payloadType, ProtectRtpPacket srtpProtect, ProtectRtpPacket srtcpProtect)
 {
     PayloadType  = payloadType;
     SrtpProtect  = srtpProtect;
     SrtcpProtect = srtcpProtect;
     Ssrc         = Convert.ToUInt32(Crypto.GetRandomInt(0, Int32.MaxValue));
     SeqNum       = Convert.ToUInt16(Crypto.GetRandomInt(0, UInt16.MaxValue));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Attempts to get the sampling frequency of a payload type.
        /// </summary>
        /// <param name="payloadType">The payload type to get the frequency for.</param>
        /// <returns>An integer representing the payload type's sampling frequency or 0 if it's
        /// dynamic or can't be determined.</returns>
        public static int GetSamplingFrequency(RTPPayloadTypesEnum payloadType)
        {
            switch (payloadType)
            {
            case RTPPayloadTypesEnum.PCMU:
            case RTPPayloadTypesEnum.PCMA:
                return(8000);

            default:
                return(0);
            }
        }
Exemplo n.º 4
0
 public void SetSendCodec(RTPPayloadTypesEnum codec)
 {
     m_sendRTPHeader.PayloadType = (int)codec;
 }