/// <summary>
        /// Tworzy nową instancję klienta streamingu przez udp.
        /// </summary>
        /// <param name="video_window">Picturebox, w którym będzie wyświetlany obraz z kamery/streamu.</param>
        /// <param name="remote_ip">Zdalne IP serwera lub innego klienta.</param>
        public UdpStreamClient(PictureBox video_window, string remote_ip)
        {
            videoCapture = null;
            filters = new Filters();
            microphone = null;
            speaker = null;
            streaming = false;
            recieving = false;
            inColor = true;
            timeInterval = 1000;
            framesCount = 0;
            videoWindow = video_window;
            audioCodec = new PCMU();

            #region Wstępne ustawienia kompresji
            //#################################################
            encoderParams = new EncoderParameters(2);

            // Ustawiamy format kompresji na JPEG
            jpegEncoder = GetEncoder(ImageFormat.Jpeg);

            // Ustawiamy jakość obrazu
            this.SetImageQuality(20L);

            // Ustawiamy głębię kolorów
            this.SetImageColorDepth(8L);
            //#################################################
            #endregion // Wstępne ustawienia kompresji

            // Ustalanie lokalnego ip.
            strHostName = Dns.GetHostName();
            this.ipHostEntry = Dns.GetHostByName(strHostName);
            this.localEndPoint = new IPEndPoint(ipHostEntry.AddressList[0], localUdpPort);

            // Ustawianie zdalnego ip.
            try
            {
                this.remoteEndPoint = new IPEndPoint(IPAddress.Parse(remote_ip), remoteUdpPort);
            }
            catch(FormatException ex) { MessageBox.Show(ex.Message, "Streaming"); }
        }
Exemple #2
0
        //Start Send Voice
        public void m_pToggleSend_Click2(ComboBox m_pInDevices, Button m_pToggleSend)
        {
            if(m_pWaveIn == null){
                m_pSendStream = m_pSession.CreateSendStream();

                m_pWaveIn = new AudioIn(AudioIn.Devices[m_pInDevices.SelectedIndex],8000,16,1);
                //m_pWaveIn.Start();

                m_pToggleSend.Text = "Stop";
                m_Send = true;

                Thread tr = new Thread(this.SendMic);
                tr.Start();
            }
            else{
                m_pSendStream.Close();
                m_pSendStream = null;
                m_pWaveIn.Dispose();
                m_pWaveIn = null;

                m_pToggleSend.Text = "Send";
                m_Send = false;
            }
        }
 /// <summary>
 /// Zatrzymuje przechwytywanie dźwięku.
 /// </summary>
 private void StopAudioCapture()
 {
     microphone.Dispose();
     microphone = null;
 }
        /// <summary>
        /// Uruchamia przechwytywanie dźwięku za pomocą pierwszego dostępnego urządzenia.
        /// </summary>
        private void StartAudioCapture()
        {
            if (AudioIn.Devices.Length == 0)
                throw new Exception("Brak urządzeń do przechwytywania dźwięku!");

            microphone = new AudioIn(AudioIn.Devices[0], 8000, 16, 1);
        }
Exemple #5
0
 //Dispose Send Audio
 public void wfrm_SendMic_FormClosing()
 {
     m_Send = false;
     if(m_pWaveIn != null){
         m_pWaveIn.Dispose();
         m_pWaveIn = null;
     }
     if(m_pSendStream != null){
         m_pSendStream.Close();
         m_pSendStream = null;
     }
 }
Exemple #6
0
 private void wfrm_SendMic_FormClosing(object sender, FormClosingEventArgs e)
 {
     m_Send = false;
     if(m_pWaveIn != null){
         m_pWaveIn.Dispose();
         m_pWaveIn = null;
     }
     if(m_pSendStream != null){
         m_pSendStream.Close();
         m_pSendStream = null;
     }
 }
Exemple #7
0
        private void m_pToggleSend_Click(object sender,EventArgs e)
        {
            if(m_pWaveIn == null){
                m_pSendStream = m_pSession.CreateSendStream();

                m_pWaveIn = new AudioIn(AudioIn.Devices[m_pInDevices.SelectedIndex],8000,16,1);
                //m_pWaveIn.Start();

                m_pToggleSend.Text = "Stop";
                m_Send = true;

                Thread tr = new Thread(this.SendMic);
                tr.Start();
            }
            else{
                m_pSendStream.Close();
                m_pSendStream = null;
                m_pWaveIn.Dispose();
                m_pWaveIn = null;

                m_pToggleSend.Text = "Send";
                m_Send = false;
            }
        }