示例#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);
        }
示例#2
0
        static void test2()
        {
            IvrWORX x = new IvrWORX();

            x.Init("dotnet.json");


            RtpProxySession streamerRtpSession = new RtpProxySession(x);
            AbstractOffer   dummyOffer         = new AbstractOffer();

            dummyOffer.Type = "application/sdp";
            dummyOffer.Body = @"v=0" + "\n"
                              + "o=alice 2890844526 2890844526 IN IP4 0.0.0.0" + "\n"
                              + "s=" + "\n"
                              + "c=IN IP4 0.0.0.0" + "\n"
                              + "t=0 0" + "\n"
                              + "m=audio 0 RTP/AVP 0" + "\n"
                              + "a=rtpmap:0 PCMU/8000" + "\n\n";;

            ApiErrorCode res = streamerRtpSession.Allocate(dummyOffer);

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

            StreamerSession streamer = new StreamerSession(x);

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

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

            streamerRtpSession.Modify(streamer.LocalOffer());


            RtpProxySession sipRtpSession = new RtpProxySession(x);

            sipRtpSession.Allocate(dummyOffer);


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

            SipCall sipCall = new SipCall(x);


            res =
                sipCall.MakeCall("sip:[email protected]", sipRtpSession.LocalOffer(), null, null, DEFAULT_TIMEOUT);
            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("MakeCall failed err:" + res);
            }

            sipRtpSession.Modify(sipCall.RemoteOffer());

            sipRtpSession.Bridge(streamerRtpSession, true);
            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("Bridge failed err:" + res);
            }



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

            sipCall.Dispose();

            Console.WriteLine("MakeCall res=" + res);
        }