private void GetInviteRemoteIPPort(string strRemoteBody, ref string pRemoteSendStreamIp, ref uint uiRemoteSendStreamVideoPort)
{
NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
logEx.Trace("Enter: SipStackAdapter.GetInviteRemoteIPPort strRemoteBody = {0}.", strRemoteBody);
try
{
//获取返回值字符串的第六个字段,收流的IP
string[] strList = strRemoteBody.Split(new string[] { "\r\n" }, StringSplitOptions.None); ;
foreach (string str in strList)
{
if (str.IndexOf("c=") > -1)
{
string[] strListIP = str.Split(' ');
if (strListIP.Length > 0)
{
pRemoteSendStreamIp = strListIP[strListIP.Length - 1];
pRemoteSendStreamIp = pRemoteSendStreamIp.Trim('\r');
}
}
if (str.IndexOf("m=") > -1)
{
if (str.IndexOf("video") > -1)
{
string[] mVideo = str.Split(' ');
uint a = 0;
if (uint.TryParse(mVideo[1], out a) == true) //判断port是否可以转换为uint
{
uiRemoteSendStreamVideoPort = Convert.ToUInt32(mVideo[1]);
if (uiRemoteSendStreamVideoPort < 0)
{
logEx.Error("when m=video ,the port is wrong,it can not be smaller than 0");
}
}
else
{
logEx.Trace("the port is {0}", a);
logEx.Error("when m=video ,the port is wrong,it is not number");
}
}
}
}
logEx.Trace("SipStackAdapter.RemoteIP = {0}.", pRemoteSendStreamIp);
logEx.Trace("Leave: SipStackAdapter.GetInviteRemoteIPPort");
logEx.Trace("the RemoteIPPort is {0}", uiRemoteSendStreamVideoPort);
}
catch (System.Exception ex)
{
pRemoteSendStreamIp = "";
uiRemoteSendStreamVideoPort = 0;
logEx.Error("GetInviteRemoteIPPort failed.Exception message:{0}", ex.Message);
}
}