Exemple #1
0
        static void test1()
        {
            IvrWORX x = new IvrWORX();

            x.Init("dotnet.json");


            StreamerSession streamer = new StreamerSession(x);

            streamer.Allocate(null,
                              StreamerSession.RcvDeviceType.RCV_DEVICE_NONE,
                              StreamerSession.SndDeviceType.SND_DEVICE_TYPE_FILE);

            SipCall sipCall = new SipCall(x);

            Credentials c = new Credentials();

            c.User     = "******";
            c.Realm    = "example.com";
            c.Password = "******";

            LinkedList <string> contactList =
                new LinkedList <string>();

            contactList.AddLast("sip:1234" + "@" + GetLocalIP());

//             ApiErrorCode res = sipCall.StartRegistration(
//                 contactList,
//                 "sip:[email protected]",
//                 c,
//                 DEFAULT_TIMEOUT);
//
//             if (res != ApiErrorCode.API_SUCCESS)
//                 throw new Exception("Registration failed err:" + res);


            ApiErrorCode res = sipCall.MakeCall("sip:[email protected]", streamer.LocalOffer(), c, null, DEFAULT_TIMEOUT);


            streamer.ModifyConnection(sipCall.RemoteOffer());
            streamer.PlayFile(@"c:\SOUNDS\greeting.wav", true, false);

            sipCall.HangupCall();



            Console.WriteLine("MakeCall res=" + res);
        }
Exemple #2
0
        static void test6()
        {
            IvrWORX x = new IvrWORX();

            x.Init("dotnet.json");

            RtpProxySession rtpProxy =
                new RtpProxySession(x);

            //
            // Allocate RTP endpoint for RTSP session.
            //
            RtpProxySession call1RtpSession = new RtpProxySession(x);
            AbstractOffer   dummyOffer      = new AbstractOffer();

            dummyOffer.Type = "application/sdp";
            dummyOffer.Body = @"v=0
o=alice 2890844526 2890844526 IN IP4 0.0.0.0
s=
c=IN IP4 0.0.0.0
t=0 0
m=audio 0 RTP/AVP 8 101
a=rtpmap:0 PCMA/8000
a=rtpmap:101 telephone-event/8000

";

            ApiErrorCode res = call1RtpSession.Allocate(dummyOffer);

            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("RtpProxySession(1) Allocated failed err:" + res);
            }


            SipCall caller = new SipCall(x);

            res = caller.MakeCall("sip:[email protected]",
                                  call1RtpSession.LocalOffer(),
                                  null,
                                  null,
                                  DEFAULT_TIMEOUT);

            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("MakeCall err:" + res);
            }

            bool shutdown = false;
            List <IActiveObject> actors =
                new List <IActiveObject>();

            actors.Add(caller);
            actors.Add(call1RtpSession);

            while (!shutdown)
            {
                Selector s        = new Selector();
                int      index    = 0;
                int      event_id = 0;
                res = s.Select(
                    actors,
                    DEFAULT_TIMEOUT,
                    ref index,
                    ref event_id);

                String dtmfs = call1RtpSession.DtmfBuffer();

                Console.Out.WriteLine("err=" + res +
                                      ", index=" + index +
                                      ", event=" + event_id +
                                      ", dtmfs=" + dtmfs);

                if (dtmfs.Contains("#") || index == 0)
                {
                    shutdown = true;
                }
            }


            caller.HangupCall();
        }