Beispiel #1
0
        /// <summary>
        /// Incoming call constructor.
        /// </summary>
        /// <param name="stack">Reference to SIP stack.</param>
        /// <param name="dialog">Reference SIP dialog.</param>
        /// <param name="session">Call RTP multimedia session.</param>
        /// <param name="localSDP">Local SDP.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>stack</b>,<b>dialog</b>,<b>session</b> or <b>localSDP</b> is null reference.</exception>
        internal SIP_Call(SIP_Stack stack, SIP_Dialog dialog, RTP_MultimediaSession session, SDP_Message localSDP)
        {
            if (stack == null)
            {
                throw new ArgumentNullException("stack");
            }
            if (dialog == null)
            {
                throw new ArgumentNullException("dialog");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (localSDP == null)
            {
                throw new ArgumentNullException("localSDP");
            }

            m_pStack  = stack;
            m_pDialog = (SIP_Dialog_Invite)dialog;
            m_pRtpMultimediaSession = session;
            m_pLocalSDP             = localSDP;

            m_StartTime          = DateTime.Now;
            m_pFlow              = dialog.Flow;
            dialog.StateChanged += new EventHandler(m_pDialog_StateChanged);

            SetState(SIP_CallState.Active);

            // Start ping timer.
            m_pKeepAliveTimer          = new TimerEx(40000);
            m_pKeepAliveTimer.Elapsed += new System.Timers.ElapsedEventHandler(m_pKeepAliveTimer_Elapsed);
            m_pKeepAliveTimer.Enabled  = true;
        }
Beispiel #2
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">RTP multimedia session.</param>
        public wfrm_RTP_Debug(RTP_MultimediaSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            m_pSession = session;

            InitUI();

            m_pSession.Error          += m_pSession_Error;
            m_pSession.SessionCreated += m_pSession_SessionCreated;
            m_pSession.NewParticipant += m_pSession_NewParticipant;
            m_pSession.LocalParticipant.SourceAdded   += Participant_SourceAdded;
            m_pSession.LocalParticipant.SourceRemoved += Participant_SourceRemoved;

            m_pTimer          = new Timer();
            m_pTimer.Interval = 1000;
            m_pTimer.Tick    += m_pTimer_Tick;
            m_pTimer.Enabled  = true;

            TreeNode nodeParticipant = new TreeNode(session.LocalParticipant.CNAME);

            nodeParticipant.Tag = new RTP_ParticipantInfo(session.LocalParticipant);
            nodeParticipant.Nodes.Add("Sources");
            m_pParticipants.Nodes.Add(nodeParticipant);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="port"></param>
        /// <param name="volume">The supplied value is a percentage of the maximum volume level of the device and must be in the range 0-100.</param>
        /// <returns></returns>
        static public Status Play(Execute execute, bool multicast, IPAddress source_ip, int port, uint?volume100 = null)
        {
            if (session != null)
            {
                if (!Message.YesNo("Would you like to drop the previous stream?"))
                {
                    return(Status.BUSY);
                }
                session.Stop();
                session.Dispose();
            }

            Rtp.execute   = execute;
            Rtp.source_ip = source_ip;
            Rtp.volume100 = volume100;
            Rtp.multicast = multicast;
            session       = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME());
            if (multicast)
            {
                session.CreateMulticastSession(null, new RTP_Clock(0, 8000), new RTP_Address(source_ip, port, port + 1));
            }
            else
            {
                session.CreateSession(new RTP_Address(IPAddress.Any, port, port + 1), new RTP_Clock(0, 8000));
            }
            session.Sessions[0].NewReceiveStream += NewReceiveStream;
            session.Sessions[0].Payload           = payload;
            session.Sessions[0].Start();

            return(Status.ACCEPTED);
        }
Beispiel #4
0
        /// <summary>
        /// Calling constructor.
        /// </summary>
        /// <param name="stack">Reference to SIP stack.</param>
        /// <param name="sender">Initial INVITE sender.</param>
        /// <param name="session">Call RTP multimedia session.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>stack</b>,<b>sender</b> or <b>session</b> is null reference.</exception>
        internal SIP_Call(SIP_Stack stack, SIP_RequestSender sender, RTP_MultimediaSession session)
        {
            if (stack == null)
            {
                throw new ArgumentNullException("stack");
            }
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            m_pStack = stack;
            m_pInitialInviteSender  = sender;
            m_pRtpMultimediaSession = session;

            m_pTags = new Dictionary <string, object>();

            m_pInitialInviteSender.Completed += new EventHandler(delegate(object s, EventArgs e){
                m_pInitialInviteSender = null;

                if (this.State == SIP_CallState.Terminating)
                {
                    SetState(SIP_CallState.Terminated);
                }
            });

            m_CallState = SIP_CallState.Calling;
        }
Beispiel #5
0
        public void Start()
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException(this.GetType().Name);
            }
            if (!Started)
            {
                _hTrigger.Init();
                _multiSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME());
                RTP_Session session = _multiSession.CreateSession(new RTP_Address(IPAddress.Parse(_localIP), _localPort, _localPort + 1), new RTP_Clock(0, VideoRate));
                session.Payload = RTP_PayloadTypes.H264;
                session.Start();
                _sendStream = session.CreateSendStream();

                _vSoure = VideoSourceCreator.Instance.GetVideoSource(_videoId);
                if (_targets.Count > 0)
                {
                    foreach (string key in _targets.Keys)
                    {
                        TargetItem ti = _targets[key];
                        session.AddTarget(new RTP_Address(ti.IP, ti.Port, ti.Port + 1));
                    }
                    startPlay();
                }
                Started = true;
            }
        }
Beispiel #6
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">RTP multimedia session.</param>
        public wfrm_RTP_Debug(RTP_MultimediaSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            m_pSession = session;

            InitUI();

            // Windows must be visible, otherwise we may get "window handle not created" if RTP session rises events before window gets visible.
            this.Visible = true;

            m_pSession.Error          += new EventHandler <LumiSoft.Net.ExceptionEventArgs>(m_pSession_Error);
            m_pSession.SessionCreated += new EventHandler <LumiSoft.Net.EventArgs <RTP_Session> >(m_pSession_SessionCreated);
            m_pSession.NewParticipant += new EventHandler <RTP_ParticipantEventArgs>(m_pSession_NewParticipant);
            m_pSession.LocalParticipant.SourceAdded   += new EventHandler <RTP_SourceEventArgs>(Participant_SourceAdded);
            m_pSession.LocalParticipant.SourceRemoved += new EventHandler <RTP_SourceEventArgs>(Participant_SourceRemoved);
            //m_pSession.Disposed

            m_pTimer = new TimerEx(m_pTimer_Tick, 1000);
            m_pTimer.Start();

            foreach (RTP_Session s in m_pSession.Sessions)
            {
                ComboBoxItem item = new ComboBoxItem("Session: " + s.GetHashCode(), new RTP_SessionStatistics(s));
                m_pSessions.Items.Add(item);
            }
            if (m_pSessions.Items.Count > 0)
            {
                m_pSessions.SelectedIndex = 0;
            }
        }
Beispiel #7
0
 public void Stop()
 {
     if (Started)
     {
         stopPlay();
         _sendStream.Close();
         _multiSession.Close("User Close");
         _multiSession = null;
         Started       = false;
     }
 }
 static public void Stop()
 {
     if (session != null)
     {
         ao.Stop();
         ao.Dispose();
         ao = null;
         session.Close("Closed.");
         session.Dispose();
         session = null;
         execute = null;
     }
 }
 /// <summary>
 /// This method is called when this form is closed.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">Event data.</param>
 private void wfrm_Main_FormClosed(object sender, FormClosedEventArgs e)
 {
     m_IsRunning = false;
     if (m_pRtpSession != null)
     {
         m_pRtpSession.Close(null);
         m_pRtpSession = null;
     }
     if (m_pWaveOut != null)
     {
         m_pWaveOut.Dispose();
         m_pWaveOut = null;
     }
     if (m_pRecordStream != null)
     {
         m_pRecordStream.Dispose();
         m_pRecordStream = null;
     }
 }
Beispiel #10
0
        static void Main(string[] args)
        {
            string ip = "127.0.0.1";
            //string ip = "224.0.0.1";
            int port = 20700;



            RTP_MultimediaSession session = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME());

            session.CreateMulticastSession(null, new RTP_Clock(0, 8000), new RTP_Address(IPAddress.Parse(ip), port, port + 1));
            //session.CreateSession(new RTP_Address(IPAddress.Any, port, port + 1), new RTP_Clock(0, 8000));
            session.Sessions[0].NewReceiveStream += new EventHandler <RTP_ReceiveStreamEventArgs>(m_pRtpSession_NewReceiveStream);
            session.Sessions[0].Payload           = payload;
            session.Sessions[0].Start();


            Console.ReadKey();
        }
Beispiel #11
0
        private void StartRtpSession(IPAddress remoteIp, IPAddress localIp, int rtpPort, int rtcpPort)
        {
            Dictionary <int, AudioCodec> m_pAudioCodecs = new Dictionary <int, AudioCodec>
            {
                { 0, new PCMU() }
            };

            RTP_MultimediaSession rtpMultimediaSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME());

            sessionRtp = rtpMultimediaSession.CreateSession(new RTP_Address(localIp, rtpPort, rtcpPort), new RTP_Clock(1, 8000));
            sessionRtp.AddTarget(new RTP_Address(remoteIp, rtpPort, rtcpPort));
            sessionRtp.Payload    = 0;
            sessionRtp.StreamMode = RTP_StreamMode.SendReceive;

            sessionRtp.NewReceiveStream += delegate(object s, RTP_ReceiveStreamEventArgs e2)
            {
                if (audioOut != null)
                {
                    audioOutRtp = new AudioOut_RTP(audioOut, e2.Stream, m_pAudioCodecs);

                    if (speakerMute == false)
                    {
                        audioOutRtp.Start();
                    }
                }
            };

            if (audioIn != null)
            {
                audioInRtp = new AudioIn_RTP(audioIn, 10, m_pAudioCodecs, sessionRtp.CreateSendStream());

                if (micMute == false)
                {
                    audioInRtp.Start();
                }
            }

            sessionRtp.Start();
        }
        private void btnRestartConnection_Click_1(object sender, RoutedEventArgs e)
        {
            if (cbLocalIp.SelectedIndex < 0)
            {
                MessageBox.Show("Choose local IP");
                return;
            }

            IsConnected = true;
            InitializeClient();
            InitializeServer();

            /*InitializeSoundSender();
             * InitializeSoundReceiver();*/
            if (m_IsRunning)
            {
                m_IsRunning     = false;
                m_IsSendingTest = false;

                m_pRtpSession.Dispose();
                m_pRtpSession = null;

                m_pWaveOut.Dispose();
                m_pWaveOut = null;
            }
            else
            {
                m_IsRunning = true;

                switch (_selectedCodec)
                {
                case "PCMU":
                    m_pActiveCodec = new PCMU();
                    break;

                case "PCMA":
                default:
                    m_pActiveCodec = new PCMA();
                    break;
                }

                var selectedOutDevice = cbAudioOutDevices.SelectedItem as AudioOutDevice;
                m_pWaveOut    = new AudioOut(selectedOutDevice, _samplesPerSecond, _bitsPerSample, 1); // 1 - one channel (mono)
                m_pRtpSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME());

                string localIp   = cbLocalIp.SelectedItem.ToString();
                string partnerIp = tbxPartnerIp.Text;
                int    k         = string.Compare(localIp, partnerIp);

                m_pRtpSession.CreateSession(new RTP_Address(IPAddress.Parse(cbLocalIp.SelectedItem.ToString()), (int)10000 + k * 500 /*m_pLocalPort.Value*/, (int)/*m_pLocalPort.Value*/ 10000 + k * 500 + 1), new RTP_Clock(0, _samplesPerSecond));
                m_pRtpSession.Sessions[0].AddTarget(new RTP_Address(IPAddress.Parse(tbxPartnerIp.Text), (int)/*m_pRemotePort.Value*/ 10000 - k * 500, (int)/*m_pRemotePort.Value*/ 10000 - k * 500 + 1));
                m_pRtpSession.Sessions[0].NewSendStream    += new EventHandler <RTP_SendStreamEventArgs>(m_pRtpSession_NewSendStream);
                m_pRtpSession.Sessions[0].NewReceiveStream += new EventHandler <RTP_ReceiveStreamEventArgs>(m_pRtpSession_NewReceiveStream);
                m_pRtpSession.Sessions[0].Payload           = 0;
                m_pRtpSession.Sessions[0].Start();

                m_pAudioCodecs = new Dictionary <int, AudioCodec>();
                m_pAudioCodecs.Add(0, new PCMU());
                m_pAudioCodecs.Add(8, new PCMA());
            }
        }
        private void m_pToggleRun_Click(object sender, EventArgs e)
        {
            if (m_IsRunning)
            {
                m_IsRunning     = false;
                m_IsSendingTest = false;

                m_pRtpSession.Dispose();
                m_pRtpSession = null;

                m_pWaveOut.Dispose();
                m_pWaveOut = null;

                if (m_pRecordStream != null)
                {
                    m_pRecordStream.Dispose();
                    m_pRecordStream = null;
                }

                m_pOutDevices.Enabled       = true;
                m_pToggleRun.Text           = "Start";
                m_pRecord.Enabled           = true;
                m_pRecordFile.Enabled       = true;
                m_pRecordFileBrowse.Enabled = true;
                m_pRemoteIP.Enabled         = false;
                m_pRemotePort.Enabled       = false;
                m_pCodec.Enabled            = false;
                m_pToggleMic.Text           = "Send";
                m_pToggleMic.Enabled        = false;
                m_pSendTestSound.Enabled    = false;
                m_pSendTestSound.Text       = "Send";
                m_pPlayTestSound.Enabled    = false;
                m_pPlayTestSound.Text       = "Play";
            }
            else
            {
                if (m_pOutDevices.SelectedIndex == -1)
                {
                    MessageBox.Show(this, "Please select output device !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (m_pRecord.Checked && m_pRecordFile.Text == "")
                {
                    MessageBox.Show(this, "Please specify record file !", "Error:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (m_pRecord.Checked)
                {
                    m_pRecordStream = File.Create(m_pRecordFile.Text);
                }

                m_IsRunning = true;

                m_pWaveOut = new AudioOut(AudioOut.Devices[m_pOutDevices.SelectedIndex], 8000, 16, 1);

                m_pRtpSession = new RTP_MultimediaSession(RTP_Utils.GenerateCNAME());
                // --- Debug -----
                wfrm_RTP_Debug frmRtpDebug = new wfrm_RTP_Debug(m_pRtpSession);
                frmRtpDebug.Show();
                //-----------------
                // m_pRtpSession.CreateSession(new RTP_Address(IPAddress.Parse(m_pLocalIP.Text),(int)m_pLocalPort.Value,(int)m_pLocalPort.Value + 1),new RTP_Clock(0,8000));
                string ip          = "127.0.0.1";
                int    port        = 1100;
                int    remote_port = 20700;
                //RTP_Session session = m_pRtpSession.CreateSession(new RTP_Address(IPAddress.Parse(ip), port, port + 1), new RTP_Clock(0, 8000));
                //session.AddTarget(new RTP_Address(IPAddress.Parse("127.0.0.1"), remote_port, remote_port + 1));
                RTP_Session session = m_pRtpSession.CreateMulticastSession(new RTP_Address(IPAddress.Parse(ip), port, port + 1), new RTP_Clock(0, 8000), null);
                session.AddTarget(new RTP_Address(IPAddress.Parse("224.0.0.1"), remote_port, remote_port + 1));
                session.Payload = 0;
                session.Start();

                m_pOutDevices.Enabled       = false;
                m_pToggleRun.Text           = "Stop";
                m_pRecord.Enabled           = false;
                m_pRecordFile.Enabled       = false;
                m_pRecordFileBrowse.Enabled = false;
                m_pRemoteIP.Enabled         = true;
                m_pRemotePort.Enabled       = true;
                m_pCodec.Enabled            = true;
                m_pToggleMic.Enabled        = true;
                m_pSendTestSound.Enabled    = true;
                m_pSendTestSound.Text       = "Send";
                m_pPlayTestSound.Enabled    = true;
                m_pPlayTestSound.Text       = "Play";
            }


            wfrm_SendAudio frm = new wfrm_SendAudio(this, m_pRtpSession.Sessions[0], @"D:\_d\_PROJECTS\CisteraDesktopNotificationService\Lumisoft.Net.Rtp\Rtp Audio Demo\Rtp Audio Demo\bin\Debug\audio\futurama.raw");

            frm.Show();
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="session">RTP multimedia session.</param>
        public wfrm_RTP_Debug(RTP_MultimediaSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            m_pSession = session;

            InitUI();

            m_pSession.Error += m_pSession_Error;
            m_pSession.SessionCreated += m_pSession_SessionCreated;
            m_pSession.NewParticipant += m_pSession_NewParticipant;
            m_pSession.LocalParticipant.SourceAdded += Participant_SourceAdded;
            m_pSession.LocalParticipant.SourceRemoved += Participant_SourceRemoved;

            m_pTimer = new Timer();
            m_pTimer.Interval = 1000;
            m_pTimer.Tick += m_pTimer_Tick;
            m_pTimer.Enabled = true;

            TreeNode nodeParticipant = new TreeNode(session.LocalParticipant.CNAME);
            nodeParticipant.Tag = new RTP_ParticipantInfo(session.LocalParticipant);
            nodeParticipant.Nodes.Add("Sources");
            m_pParticipants.Nodes.Add(nodeParticipant);
        }