/// <summary> /// 设置媒体参数请求(实时) /// </summary> /// <param name="localIp">本地ip</param> /// <param name="mediaPort">rtp/rtcp媒体端口(10000/10001)</param> /// <returns></returns> private string SetMediaAudio(string localIp, int port, string audioId) { SDPConnectionInformation sdpConn = new SDPConnectionInformation(localIp); SDP sdp = new SDP(); sdp.Version = 0; sdp.SessionId = "0"; sdp.Username = audioId; sdp.SessionName = CommandType.Play.ToString(); sdp.Connection = sdpConn; sdp.Timing = "0 0"; sdp.Address = localIp; SDPMediaFormat psFormat = new SDPMediaFormat(SDPMediaFormatsEnum.PS); psFormat.IsStandardAttribute = false; SDPMediaAnnouncement media = new SDPMediaAnnouncement(); media.Media = SDPMediaTypesEnum.audio; media.MediaFormats.Add(psFormat); media.AddExtra("a=sendonly"); media.AddExtra("y=0100000002"); //media.AddExtra("f=v/////a/1/8/1"); media.AddFormatParameterAttribute(psFormat.FormatID, psFormat.Name); media.Port = port; sdp.Media.Add(media); return(sdp.ToString()); }
/// <summary> /// 设置媒体参数请求(实时) /// </summary> /// <param name="localIp">本地ip</param> /// <param name="mediaPort">rtp/rtcp媒体端口(10000/10001)</param> /// <returns></returns> private string SetMediaReq(string localIp, int[] mediaPort) { SDPConnectionInformation sdpConn = new SDPConnectionInformation(localIp); SDP sdp = new SDP(); sdp.Version = 0; sdp.SessionId = "0"; sdp.Username = _msgCore.LocalSIPId; sdp.SessionName = CommandType.Play.ToString(); sdp.Connection = sdpConn; sdp.Timing = "0 0"; sdp.Address = localIp; SDPMediaFormat psFormat = new SDPMediaFormat(SDPMediaFormatsEnum.PS); psFormat.IsStandardAttribute = false; SDPMediaFormat h264Format = new SDPMediaFormat(SDPMediaFormatsEnum.H264); h264Format.IsStandardAttribute = false; SDPMediaAnnouncement media = new SDPMediaAnnouncement(); media.Media = SDPMediaTypesEnum.video; media.MediaFormats.Add(psFormat); media.MediaFormats.Add(h264Format); media.AddExtra("a=recvonly"); media.AddFormatParameterAttribute(psFormat.FormatID, psFormat.Name); media.AddFormatParameterAttribute(h264Format.FormatID, h264Format.Name); media.Port = mediaPort[0]; sdp.Media.Add(media); return(sdp.ToString()); }
/// <summary> /// 设置媒体参数请求(实时) /// </summary> /// <param name="localIp">本地ip</param> /// <param name="mediaPort">rtp/rtcp媒体端口(10000/10001)</param> /// <returns></returns> private string SetMediaAudio(string localIp, int port, string audioId) { var sdpConn = new SDPConnectionInformation(localIp); var sdp = new SDP { Version = 0, SessionId = "0", Username = audioId, SessionName = CommandType.Play.ToString(), Connection = sdpConn, Timing = "0 0", Address = localIp }; var psFormat = new SDPMediaFormat(SDPMediaFormatsEnum.PS) { IsStandardAttribute = false }; var media = new SDPMediaAnnouncement { Media = SDPMediaTypesEnum.audio }; media.MediaFormats.Add(psFormat); media.AddExtra("a=sendonly"); media.AddExtra("y=0100000002"); //media.AddExtra("f=v/////a/1/8/1"); media.AddFormatParameterAttribute(psFormat.FormatID, psFormat.Name); media.Port = port; sdp.Media.Add(media); return(sdp.ToString()); }