Example #1
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);
        }
Example #2
0
        static void test4()
        {
            IvrWORX x = new IvrWORX();

            x.Init("dotnet.json");

            //
            // Allocate RTP endpoint for RTSP session.
            //
            RtpProxySession call1RtpSession = 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 8" + "\n"
                              + "a=rtpmap:0 PCMA/8000" + "\n\n";;

            ApiErrorCode res = call1RtpSession.Allocate(dummyOffer);

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


            //
            // Allocate sip RTP session
            //
            RtpProxySession call2RtpSession = new RtpProxySession(x);

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


            //
            // Make call1
            //
            SipCall sipCall1 = new SipCall(x);

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


            call1RtpSession.Modify(sipCall1.RemoteOffer());
            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("Modify failed err:" + res);
            }

            //
            // Make call2
            //
            SipCall sipCall2 = new SipCall(x);

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


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



            Thread.Sleep(30000);
            sipCall1.Dispose();
            sipCall2.Dispose();

            Console.WriteLine("MakeCall res=" + res);
        }
Example #3
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();
        }
Example #4
0
        static void test3()
        {
            IvrWORX x = new IvrWORX();

            x.Init("dotnet.json");

            //
            // Allocate RTP endpoint for RTSP session.
            //
            RtpProxySession rtspRtpSession = 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 8" + "\n"
                              + "a=rtpmap:0 PCMA/8000" + "\n\n";;

            ApiErrorCode res = rtspRtpSession.Allocate(dummyOffer);

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


            //
            // Set up RTSP session and update its RTP endpoint.
            //
            RtspSession rtsp = new RtspSession(x);

            res = rtsp.Setup("rtsp://10.116.100.78/IvrScript.wav", rtspRtpSession.LocalOffer());
            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("RtspSession Setup failed err:" + res);
            }

            res = rtspRtpSession.Modify(rtsp.RemoteOffer());
            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("RtspSession Modify failed err:" + res);
            }


            //
            // Allocate sip RTP session
            //
            RtpProxySession sipRtpSession = new RtpProxySession(x);

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


            //
            // Make call
            //
            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());
            if (res != ApiErrorCode.API_SUCCESS)
            {
                throw new Exception("Modify failed err:" + res);
            }

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



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

            Thread.Sleep(10000);


            sipCall.Dispose();

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