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; } }
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 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(); }