Exemplo n.º 1
0
        public bool MakeCall(String remoteUri)
        {
            bool ret;

            base.outgoing = true;
            base.ToUri    = remoteUri;

            ActionConfig config = new ActionConfig();

            switch (this.mediaType)
            {
            case MediaType.AudioVideo:
            case MediaType.Video:
                ret = this.session.callAudioVideo(remoteUri, config);
                break;

            case MediaType.Audio:
                ret = this.session.callAudio(remoteUri, config);
                break;

            default:
                throw new Exception("This session doesn't support this media type");
            }
            config.Dispose();

            return(ret);
        }
Exemplo n.º 2
0
        public bool SendFile(string path)
        {
            bool result;

            if (string.IsNullOrEmpty(path) || !System.IO.File.Exists(path))
            {
                MyMsrpSession.LOG.Error(string.Format("File ({0}) doesn't exist", path));
                result = false;
            }
            else if (this.mMediaType != MediaType.FileTransfer)
            {
                MyMsrpSession.LOG.Error("Invalid media type");
                result = false;
            }
            else
            {
                System.IO.FileInfo finfo = new System.IO.FileInfo(path);
                this.mFilePath = (this.mFilePath = finfo.FullName);
                this.mFileType = this.GetFileType(finfo.Extension);
                string       fileSelector = string.Format("name:\"{0}\" type:{1} size:{2}", finfo.Name, this.mFileType, finfo.Length);
                ActionConfig config       = new ActionConfig();
                config.setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", this.mFilePath).setMediaString(twrap_media_type_t.twrap_media_msrp, "file-selector", fileSelector).setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", "message/CPIM application/octet-stream").setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-wrapped-types", "application/octet-stream image/jpeg image/gif image/bmp image/png").setMediaString(twrap_media_type_t.twrap_media_msrp, "file-disposition", "attachment").setMediaString(twrap_media_type_t.twrap_media_msrp, "file-icon", "cid:icon@cetc7").setMediaString(twrap_media_type_t.twrap_media_msrp, "Failure-Report", this.FailureReport ? "yes" : "no").setMediaString(twrap_media_type_t.twrap_media_msrp, "Success-Report", this.SuccessReport ? "yes" : "no").setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", 25);
                bool ret = this.mSession.callMsrp(base.RemotePartyUri, config);
                config.Dispose();
                result = ret;
            }
            return(result);
        }
Exemplo n.º 3
0
        public bool UpdateMediaAttribute(MediaType mediaType, MediaAttr attribute, ActionConfig config)
        {
            bool ret = this.mSession.update(MediaTypeUtils.ConvertToNative(mediaType), (int)attribute, config);

            config.Dispose();
            return(ret);
        }
Exemplo n.º 4
0
        public bool MakeVideoSharingCall(string remoteUri)
        {
            this.outgoing = true;
            ActionConfig config = new ActionConfig();
            bool         ret    = this.mSession.call(remoteUri, MediaTypeUtils.ConvertToNative(MediaType.Video), 0, config);

            config.Dispose();
            return(ret);
        }
Exemplo n.º 5
0
        public bool MakeCall(string remoteUri, MediaAttr mediaAttr, ActionConfig config)
        {
            this.outgoing = true;
            base.ToUri    = remoteUri;
            bool ret = this.mSession.call(remoteUri, MediaTypeUtils.ConvertToNative(this.mMediaType), (int)mediaAttr, config);

            config.Dispose();
            return(ret);
        }
Exemplo n.º 6
0
        public bool SendMessage(String message, String contentType, String wContentType)
        {
            if (String.IsNullOrEmpty(message))
            {
                LOG.Error("Null or empty message");
                return(false);
            }

            if (this.mediaType != MediaType.Chat)
            {
                LOG.Error("Invalid media type");
                return(false);
            }

            if (base.IsConnected)
            {
                ActionConfig config = new ActionConfig();
                if (!String.IsNullOrEmpty(contentType))
                {
                    config.setMediaString(twrap_media_type_t.twrap_media_msrp, "content-type", contentType);
                }
                if (!String.IsNullOrEmpty(wContentType))
                {
                    config.setMediaString(twrap_media_type_t.twrap_media_msrp, "w-content-type", wContentType);
                }
                //config.setMediaString(twrap_media_type_t.twrap_media_msrp, "content-type", contentType);
                // == OR ==
                //config.setMediaString(twrap_media_type_t.twrap_media_msrp,
                //    "content-type", "message/CPIM")
                //    .setMediaString(twrap_media_type_t.twrap_media_msrp, "w-content-type", "text/plain");
                byte[] payload = Encoding.UTF8.GetBytes(message);
                bool   ret     = this.session.sendMessage(payload, (uint)payload.Length, config);
                config.Dispose();

                return(ret);
            }
            else
            {
                if (this.pendingMessages == null)
                {
                    this.pendingMessages = new List <PendingMessage>();
                }
                this.pendingMessages.Add(new PendingMessage(message, contentType, wContentType));

                ActionConfig config = new ActionConfig();
                config.setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", MyMsrpSession.CHAT_ACCEPT_TYPES)
                .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-wrapped-types", MyMsrpSession.CHAT_ACCEPT_WRAPPED_TYPES)
                .setMediaString(twrap_media_type_t.twrap_media_msrp, "Failure-Report", this.FailureReport ? "yes" : "no")
                .setMediaString(twrap_media_type_t.twrap_media_msrp, "Success-Report", this.SuccessReport ? "yes" : "no")
                .setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", 50);

                bool ret = this.session.callMsrp(base.RemotePartyUri, config);
                config.Dispose();

                return(ret);
            }
        }
Exemplo n.º 7
0
        public bool MakeVideoSharingCall(String remoteUri)
        {
            bool ret;

            base.outgoing = true;

            ActionConfig config = new ActionConfig();

            ret = this.session.callVideo(remoteUri, config);
            config.Dispose();

            return(ret);
        }
Exemplo n.º 8
0
        public bool SendMessage(string message, string contentType, string wContentType)
        {
            bool result;

            if (string.IsNullOrEmpty(message))
            {
                MyMsrpSession.LOG.Error("Null or empty message");
                result = false;
            }
            else if (this.mMediaType != MediaType.Chat)
            {
                MyMsrpSession.LOG.Error("Invalid media type");
                result = false;
            }
            else if (base.IsConnected)
            {
                ActionConfig config = new ActionConfig();
                if (!string.IsNullOrEmpty(contentType))
                {
                    config.setMediaString(twrap_media_type_t.twrap_media_msrp, "content-type", "text/plain");
                }
                if (!string.IsNullOrEmpty(wContentType))
                {
                    config.setMediaString(twrap_media_type_t.twrap_media_msrp, "w-content-type", wContentType);
                }
                byte[]        payload = System.Text.Encoding.UTF8.GetBytes(message);
                System.IntPtr ptr     = System.Runtime.InteropServices.Marshal.AllocHGlobal(payload.Length);
                System.Runtime.InteropServices.Marshal.Copy(payload, 0, ptr, payload.Length);
                bool ret = this.mSession.sendMessage(ptr, (uint)payload.Length, config);
                System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);
                config.Dispose();
                result = ret;
            }
            else
            {
                if (this.mPendingMessages == null)
                {
                    this.mPendingMessages = new System.Collections.Generic.List <MyMsrpSession.PendingMessage>();
                }
                this.mPendingMessages.Add(new MyMsrpSession.PendingMessage(message, contentType, wContentType));
                ActionConfig config = new ActionConfig();
                config.setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", "text/plain message/CPIM").setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-wrapped-types", "text/plain image/jpeg image/gif image/bmp image/png").setMediaString(twrap_media_type_t.twrap_media_msrp, "Failure-Report", this.FailureReport ? "yes" : "no").setMediaString(twrap_media_type_t.twrap_media_msrp, "Success-Report", this.SuccessReport ? "yes" : "no").setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", 50);
                bool ret = this.mSession.callMsrp(base.RemotePartyUri, config);
                config.Dispose();
                result = ret;
            }
            return(result);
        }
Exemplo n.º 9
0
        public bool SendFile(String path)
        {
            if (String.IsNullOrEmpty(path) || !File.Exists(path))
            {
                LOG.Error(String.Format("File ({0}) doesn't exist", path));
                return(false);
            }

            if (this.mediaType != MediaType.FileTransfer)
            {
                LOG.Error("Invalid media type");
                return(false);
            }

            FileInfo finfo = new FileInfo(path);

            this.filePath = filePath = finfo.FullName;
            this.fileType = this.GetFileType(finfo.Extension);
            String fileSelector = String.Format("name:\"{0}\" type:{1} size:{2}",
                                                finfo.Name, this.fileType, finfo.Length);

            ActionConfig config = new ActionConfig();

            config
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", this.filePath)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-selector", fileSelector)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", MyMsrpSession.FILE_ACCEPT_TYPES)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-wrapped-types", MyMsrpSession.FILE_ACCEPT_WRAPPED_TYPES)
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-disposition", "attachment")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-icon", "cid:[email protected]")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "Failure-Report", this.FailureReport ? "yes" : "no")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "Success-Report", this.SuccessReport ? "yes" : "no")
            .setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", MyMsrpSession.CHUNK_DURATION)
            ;

            bool ret = this.session.callMsrp(this.RemotePartyUri, config);

            config.Dispose();
            return(ret);
        }
Exemplo n.º 10
0
        public override int OnInviteEvent(InviteEvent e)
        {
            tsip_invite_event_type_t type    = e.getType();
            InviteSession            session = e.getSession();
            SipMessage message = e.getSipMessage();

            switch (type)
            {
            case tsip_invite_event_type_t.tsip_i_newcall:
                SdpMessage sdp = message.getSdpMessage();

                if (session != null)
                {
                    Console.WriteLine("ERRRRRRRRRRRORRRR");
                    return(0);
                }
                else
                {
                    switch (e.getMediaType())
                    {
                    case twrap_media_type_t.twrap_media_audio:
                    case twrap_media_type_t.twrap_media_video:
                    case twrap_media_type_t.twrap_media_audiovideo:
                        session = e.takeCallSessionOwnership();
                        break;

                    case twrap_media_type_t.twrap_media_msrp:
                        if ((session = e.takeMsrpSessionOwnership()) != null)
                        {
                            (session as MsrpSession).setCallback(Program.msrpCallback);
                        }
                        break;
                    }
                    if (session != null)
                    {
                        ActionConfig actionConfig = new ActionConfig();
                        session.accept(actionConfig);
                        actionConfig.Dispose();
                    }
                }

                /*else if ((session = e.takeSessionOwnership()) != null)
                 * {
                 *  SdpMessage sdp = message.getSdpMessage();
                 *  if (sdp != null)
                 *  {
                 *      String fileSelector = sdp.getSdpHeaderAValue("message", "file-selector");
                 *      Console.WriteLine("file-selector={0}", fileSelector);
                 *  }
                 *
                 *  ActionConfig actionConfig = new ActionConfig();
                 *  //actionConfig.setMediaInt(twrap_media_type_t.twrap_media_audiovideo, "bandwidth-level", (int)tmedia_bandwidth_level_t.tmedia_bl_low);
                 *  actionConfig.setMediaString(twrap_media_type_t.twrap_media_file, "file-path", "C:\\tmp\\myfile");
                 *  session.accept(actionConfig);
                 *  actionConfig.Dispose();
                 * }*/
                break;

            case tsip_invite_event_type_t.tsip_i_request:
                break;

            case tsip_invite_event_type_t.tsip_ao_request:
                break;

            case tsip_invite_event_type_t.tsip_o_ect_ok:
                break;

            case tsip_invite_event_type_t.tsip_o_ect_nok:
                break;

            case tsip_invite_event_type_t.tsip_i_ect:
                break;

            case tsip_invite_event_type_t.tsip_m_local_hold_ok:
                Console.WriteLine("Local Hold OK");
                break;

            case tsip_invite_event_type_t.tsip_m_local_hold_nok:
                Console.WriteLine("Local Hold NOK");
                break;

            case tsip_invite_event_type_t.tsip_m_local_resume_ok:
                Console.WriteLine("Local Resume OK");
                break;

            case tsip_invite_event_type_t.tsip_m_local_resume_nok:
                Console.WriteLine("Local Resume NOK");
                break;

            case tsip_invite_event_type_t.tsip_m_remote_hold:
                Console.WriteLine("Remote Hold");
                break;

            case tsip_invite_event_type_t.tsip_m_remote_resume:
                Console.WriteLine("Remote Resume");
                break;
            }



            return(0);
        }
Exemplo n.º 11
0
        /*
         * const String REALM = "sip2sip.info";
         * const String USER = "******";
         * const String PASSWORD = "******";
         * const String PROXY_CSCF_IP = "192.168.0.13";
         * const uint PROXY_CSCF_PORT = 5081;
         */

        static void Main(string[] args)
        {
            Boolean success;

            /* Create callbacks */
            sipCallback  = new MySipCallback();
            msrpCallback = new MyMsrpCallback();
            //sipDebugCallback = new MySipDebugCallback();

            /* Create consumers */
            audioConsumer = new MyProxyAudioConsumer();
            videoConsumer = new MyProxyVideoConsumer(tmedia_chroma_t.tmedia_rgb565le);
            /* Create producers */
            audioProducer = new MyProxyAudioProducer();
            videoProducer = new MyProxyVideoProducer(tmedia_chroma_t.tmedia_rgb24);


            /* Create and configure the IMS/LTE stack */
            sipStack = new SipStack(sipCallback, String.Format("sip:{0}", REALM), /*String.Format("{0}@{1}", USER, REALM)*/ USER, String.Format("sip:{0}@{1}", USER, REALM));
            sipStack.setDebugCallback(sipDebugCallback);
            sipStack.addHeader("Allow", "INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER");
            sipStack.addHeader("Privacy", "header; id");
            sipStack.addHeader("P-Access-Network-Info", "ADSL;utran-cell-id-3gpp=00000000");
            sipStack.addHeader("User-Agent", "IM-client/OMA1.0 doubango/v1.0.0");

            /* Do it after stack creation */
            ProxyAudioConsumer.registerPlugin();
            ProxyAudioProducer.registerPlugin();
            ProxyVideoProducer.registerPlugin();
            ProxyVideoConsumer.registerPlugin();


            /* Sets Proxy-CSCF */
            success = sipStack.setProxyCSCF(PROXY_CSCF_IP, PROXY_CSCF_PORT, "udp", "ipv4");
            // STUN
            //sipStack.setSTUNServer("numb.viagenie.ca", 3478);
            //sipStack.setSTUNCred("login", "password");
            // DNS Discovery
            //sipStack.setDnsDiscovery(true);
            /* Starts the stack */
            success = sipStack.start();

            /* Set Password */
            sipStack.setPassword(PASSWORD);

            /* Early IMS */
            sipStack.setEarlyIMS(true);
            /* AMF and Operator Id */
            sipStack.setAMF("0x00FF");
            sipStack.setOperatorId("0xFF0000000000000000000000000000FF");

            // SigComp
            //sipStack.addSigCompCompartment("urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a876");

            //sipStack.setAoR("127.0.0.1", 1234);

            audioConsumer.setActivate(true);
            audioProducer.setActivate(true);
            videoProducer.setActivate(true);
            videoConsumer.setActivate(true);


            /* Send REGISTER */
            regSession = new RegistrationSession(sipStack);
            regSession.addCaps("+g.oma.sip-im");
            regSession.addCaps("+g.3gpp.smsip");
            regSession.addCaps("language", "\"en,fr\"");
            regSession.setExpires(350);
            //regSession.addSigCompCompartment("urn:uuid:2e5fdc76-00be-4314-8202-1116fa82a876");
            regSession.register_();

            Console.ReadLine();


            ActionConfig actionConfig = new ActionConfig();

            actionConfig
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", "C:\\Users\\root\\Desktop\\Debian.iso")
            //.setMediaString(twrap_media_type_t.twrap_media_msrp, "file-path", "C:\\avatar.png")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "accept-types", "application/octet-stream")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-disposition", "attachment")
            .setMediaString(twrap_media_type_t.twrap_media_msrp, "file-icon", "cid:[email protected]")
            .setMediaInt(twrap_media_type_t.twrap_media_msrp, "chunck-duration", 500);
            MsrpSession msrpSession = new MsrpSession(sipStack, msrpCallback);

            msrpSession.callMsrp(String.Format("sip:johndoe@{0}", REALM), actionConfig);
            actionConfig.Dispose();

            Console.ReadLine();
            msrpSession.hangup();
            Console.ReadLine();

            //RPMessage rpMessage = SMSEncoder.encodeDeliver(25, SMSC, "123456789", "salut comment tu vas?\n hdjdhfjfhfjhr, ");
            //if (rpMessage != null)
            //{
            //    uint pay_len = rpMessage.getPayloadLength();
            //    if (pay_len > 0)
            //    {
            //        byte[] pay = new byte[pay_len];
            //        rpMessage.getPayload(pay, (uint)pay.Length);

            //        MessagingSession m = new MessagingSession(sipStack);
            //        m.setToUri(String.Format("sip:{0}@{1}", SMSC, REALM));
            //        m.addHeader("Content-Type", "application/vnd.3gpp.sms");
            //        m.addHeader("Content-Transfer-Encoding", "binary");
            //        m.addHeader("P-Asserted-Identity", String.Format("sip:{0}@{1}", USER, REALM));

            //        m.send(pay, (uint)pay.Length);

            //        m.Dispose();
            //    }
            //    rpMessage.Dispose();
            //}

            //Console.ReadLine();



            //String sipUri = sipStack.dnsENUM("E2U+SIP", "+1-800-555-5555", "e164.org");
            //ushort port = 0;
            //String ipAddress = sipStack.dnsNaptrSrv("sip2sip.info", "SIP+D2U", out port);
            //String ipAddress = sipStack.dnsSrv("_sip._udp.sip2sip.info", out port);

            /*ActionConfig actionConfig = new ActionConfig();
             * actionConfig.setMediaInt(twrap_media_type_t.twrap_media_audiovideo, "bandwidth-level", (int)tmedia_bandwidth_level_t.tmedia_bl_medium);
             * callSession = new CallSession(sipStack);
             * callSession.set100rel(true);
             * callSession.setSessionTimer(90, "uas");
             * callSession.setQoS(tmedia_qos_stype_t.tmedia_qos_stype_segmented, tmedia_qos_strength_t.tmedia_qos_strength_optional);
             * callSession.callVideo(String.Format("sip:bob@{0}", REALM), actionConfig);
             * actionConfig.Dispose();*/

            //tcb = new TimerCallback(OnTimer);
            //timer = new Timer(tcb, new AutoResetEvent(false), 0, 20);

            //Console.ReadLine();
            //callSession.sendDTMF(1);
            //Console.ReadLine();
            //callSession.sendDTMF(2);
            //Console.ReadLine();
            //callSession.sendDTMF(11);
            //Console.ReadLine();

            ////Console.ReadLine();
            ////callSession.hold();
            ////Console.ReadLine();
            ////callSession.resume();
            //Console.ReadLine();
            //callSession.hangup();


            ////Thread.Sleep(2000);

            /*RPData rpdata = SMSEncoder.encodeSubmit(25, "+33160188661", "+33660188661", "salut");
             * if (rpdata != null)
             * {
             *  uint pay_len = rpdata.getPayloadLength();
             *  if (pay_len > 0)
             *  {
             *      byte[] pay = new byte[pay_len];
             *      rpdata.getPayload(pay, (uint)pay.Length);
             *
             *      MessagingSession m = new MessagingSession(sipStack);
             *      m.setToUri(String.Format("sip:+33160188661@{0}", REALM));
             *      m.addHeader("Content-Type", "application/vnd.3gpp.sms");
             *      m.addHeader("Transfer-Encoding", "binary");
             *      m.send(pay, (uint)pay.Length);
             *
             *      m.Dispose();
             *  }
             *  rpdata.Dispose();
             * }
             *
             * Console.ReadLine();*/

            ///* Send SUBSCRIBE(reg) */
            //subSession = new SubscriptionSession(sipStack);
            //subSession.addHeader("Event", "reg");
            //subSession.addHeader("Accept", "application/reginfo+xml");
            //subSession.addHeader("Allow-Events", "refer, presence, presence.winfo, xcap-diff, conference");
            //subSession.setExpires(35);
            ////subSession.Subscribe();

            ///* Send MESSAGE */
            //MessagingSession msg = new MessagingSession(sipStack);
            //byte [] content = Encoding.ASCII.GetBytes("Hello World");
            //msg.setToUri(String.Format("sip:{0}@{1}", "alice", REALM));
            //msg.addHeader("NS", "imdn <urn:ietf:params:imdn>");
            //msg.addHeader("imdn.Message-ID", "34jk324j");
            //msg.addHeader("DateTime", "2006-04-04T12:16:49-05:00");
            //msg.addHeader("imdn.Disposition-Notification", "positive-delivery, negative-delivery");
            //msg.addHeader("Content-Type", "text/plain");
            ////msg.Send(content, (uint)content.Length);

            ///* Send OPTIONS */
            //OptionsSession opt = new OptionsSession(sipStack);
            //opt.setToUri(String.Format("sip:{0}@{1}", "hacking_the_aor", REALM));
            //opt.Send();

            Console.ReadLine();

            sipStack.stop();
        }