Пример #1
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();
        }
Пример #2
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();
        }