Пример #1
0
        public static MyAVSession TakeOutgoingTranferSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);

            if (media == MediaType.None)
            {
                return(null);
            }

            MyAVSession avSession = MyAVSession.CreateOutgoingSession(sipStack, session, media);

            if (sipMessage != null)
            {
                avSession.RemotePartyUri = sipMessage.getSipHeaderValue("refer-to");
            }
            return(avSession);
        }
Пример #2
0
        public static MyAVSession TakeIncomingSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);

            if (media == MediaType.None)
            {
                return(null);
            }

            lock (MyAVSession.sessions)
            {
                MyAVSession avSession = new MyAVSession(sipStack, session, media, InviteState.INCOMING);
                if (sipMessage != null)
                {
                    avSession.RemotePartyUri = sipMessage.getSipHeaderValue("f");
                }
                MyAVSession.sessions.Add(avSession.Id, avSession);
                return(avSession);
            }
        }
Пример #3
0
        public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message)
        {
            MyMsrpSession msrpSession = null;
            MediaType mediaType;
            SdpMessage sdp = message.getSdpMessage();
            String fromUri = message.getSipHeaderValue("f");

            if (String.IsNullOrEmpty(fromUri))
            {
                LOG.Error("Invalid fromUri");
                return null;
            }

            if (sdp == null)
            {
                LOG.Error("Invalid Sdp content");
                return null;
            }

            String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");
            mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer;

            if (mediaType == MediaType.Chat)
            {
                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
            }
            else
            {
                String name = null;
                String type = null;
                int nameIndexStart = fileSelector.IndexOf("name:\"");
                if (nameIndexStart == -1)
                {
                    LOG.Error("No name attribute");
                    return null;
                }
                int nameIndexEnd = fileSelector.IndexOf("\"", nameIndexStart + 6);
                if (nameIndexEnd == -1)
                {
                    LOG.Error("Invalid name attribute");
                    return null;
                }
                name = fileSelector.Substring(nameIndexStart + 6, (nameIndexEnd - nameIndexStart - 6)).Trim();
                fileSelector = fileSelector.Substring(0, nameIndexStart) + fileSelector.Substring(nameIndexEnd + 1, (fileSelector.Length - nameIndexEnd) - 1);

                String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String attribute in attributes)
                {
                    String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (avp.Length >= 2)
                    {
                        if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null)
                        {
                            type = avp[1];
                        }
                    }
                }

                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
                msrpSession.mFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name));
                msrpSession.mFileType = type;
            }

            return msrpSession;
        }
Пример #4
0
        public static MyMsrpSession TakeIncomingSession(MySipStack sipStack, MsrpSession session, SipMessage message)
        {
            MyMsrpSession msrpSession = null;
            MediaType     mediaType;
            SdpMessage    sdp     = message.getSdpMessage();
            String        fromUri = message.getSipHeaderValue("f");

            if (String.IsNullOrEmpty(fromUri))
            {
                LOG.Error("Invalid fromUri");
                return(null);
            }

            if (sdp == null)
            {
                LOG.Error("Invalid Sdp content");
                return(null);
            }

            String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");

            mediaType = String.IsNullOrEmpty(fileSelector) ? MediaType.Chat : MediaType.FileTransfer;

            if (mediaType == MediaType.Chat)
            {
                msrpSession = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
            }
            else
            {
                String name           = null;
                String type           = null;
                int    nameIndexStart = fileSelector.IndexOf("name:\"");
                if (nameIndexStart == -1)
                {
                    LOG.Error("No name attribute");
                    return(null);
                }
                int nameIndexEnd = fileSelector.IndexOf("\"", nameIndexStart + 6);
                if (nameIndexEnd == -1)
                {
                    LOG.Error("Invalid name attribute");
                    return(null);
                }
                name         = fileSelector.Substring(nameIndexStart + 6, (nameIndexEnd - nameIndexStart - 6)).Trim();
                fileSelector = fileSelector.Substring(0, nameIndexStart) + fileSelector.Substring(nameIndexEnd + 1, (fileSelector.Length - nameIndexEnd) - 1);

                String[] attributes = fileSelector.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (String attribute in attributes)
                {
                    String[] avp = attribute.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                    if (avp.Length >= 2)
                    {
                        if (String.Equals(avp[0], "type", StringComparison.InvariantCultureIgnoreCase) && avp[1] != null)
                        {
                            type = avp[1];
                        }
                    }
                }

                msrpSession           = MyMsrpSession.CreateIncomingSession(sipStack, session, mediaType, fromUri);
                msrpSession.mFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), String.Format("{0}/{1}", MyMsrpSession.DESTINATION_FOLDER, name));
                msrpSession.mFileType = type;
            }

            return(msrpSession);
        }
Пример #5
0
        public static MyAVSession TakeOutgoingTranferSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);
            if (media == MediaType.None)
            {
                return null;
            }

            MyAVSession avSession = MyAVSession.CreateOutgoingSession(sipStack, session, media);
            if (sipMessage != null)
            {
                avSession.RemotePartyUri = sipMessage.getSipHeaderValue("refer-to");
            }
            return avSession;
        }
Пример #6
0
        public static MyAVSession TakeIncomingSession(MySipStack sipStack, CallSession session, twrap_media_type_t mediaType, SipMessage sipMessage)
        {
            MediaType media = MediaTypeUtils.ConvertFromNative(mediaType);
            if (media == MediaType.None)
            {
                return null;
            }

            lock (MyAVSession.sessions)
            {
                MyAVSession avSession = new MyAVSession(sipStack, session, media, InviteState.INCOMING);
                if (sipMessage != null)
                {
                    avSession.RemotePartyUri = sipMessage.getSipHeaderValue("f");
                }
                MyAVSession.sessions.Add(avSession.Id, avSession);
                return avSession;
            }
        }