Exemplo n.º 1
0
        public void enviarStreaming(int numberDevice, string ipReceptor, string ipEmisor, int puerto)
        {
            try
            {
                numeroDispositivo = numberDevice;
                servidorUdp = new UdpServer();
                servidorUdp.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(ipEmisor), (int)puerto) };
                servidorUdp.Start();

                puntoDestino = new IPEndPoint(IPAddress.Parse(ipReceptor), (int)puerto);

                waveIn = new WaveIn(WaveIn.Devices[numberDevice], 8000, 16, 1, 400);
                waveIn.BufferFull += new BufferFullHandler(waveIn_BufferFull);
                waveIn.Start();
            }
            catch (Exception ex)
            {
                logger.WriteToEventLog("ERROR: " + ex.Message +
                                        Environment.NewLine +
                                        "STACK TRACE: " + ex.StackTrace,
                                        "Servicio de envio de streaming [enviarStreaming]",
                                        EventLogEntryType.Error,
                                        "LogSucursalAudio");
                logger.WriteToErrorLog("ERROR: " + ex.Message,
                                        ex.StackTrace,
                                        "Streaming.cs");

                Console.WriteLine("Error [enviarStreaming]: " + ex.Message);
                Console.WriteLine("StackTrace [enviarStreaming]: " + ex.StackTrace);
            }
        }
        public void JoinConference(int MicIndex)
        {
            if (!InConference)
            {
                audioWaveOut = new WaveOut(WaveOut.Devices[0], 8000, 16, 1);
                audioServer = new UdpServer();
                audioServer.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(Main.User.MyIPAddress), audioPort) };
                audioServer.PacketReceived += new PacketReceivedHandler(AudioServer_PacketReceived);
                audioServer.Start();

                audioWaveIn = new WaveIn(WaveIn.Devices[MicIndex], 8000, 16, 1, 400);
                audioWaveIn.BufferFull += new BufferFullHandler(audioWaveIn_BufferFull);
                audioWaveIn.Start();
                InConference = true;
            }
        }
Exemplo n.º 3
0
        public void StartRecordAndSend()
        {
            if (_waveIn != null || _waveOut != null)
            {
                throw new Exception("Call is allready started");
            }

            // int waveInDevice = (Int32)Application.UserAppDataRegistry.GetValue("WaveIn", 0);
            //  int waveOutDevice = (Int32)Application.UserAppDataRegistry.GetValue("WaveOut", 0);

            int waveOutDevice = 0;

            _waveIn = new WaveIn(WaveIn.Devices[0], 8000, 16, 1, 400);

            _waveIn.BufferFull += new BufferFullHandler(_waveIn_BufferFull);
            _waveIn.Start();

            _waveOut = new WaveOut(WaveOut.Devices[waveOutDevice], 8000, 16, 1);


           

        }
Exemplo n.º 4
0
        public void micStart(int mValue)
        {
            clientID++;
            var inDevices = WaveIn.Devices;
            WavInDevice inDevice = inDevices[mValue];
            Console.WriteLine(string.Format("\n{0} , client : {1} , Mic : {2}", DateTime.Now.ToShortTimeString(), clientID, inDevice.Name));
            if (waveIn != null)
            {
                if (!isRecordVoice)
                {
                    waveIn.Start();
                    isRecordVoice = true;
                }

                return;
            }
            try
            {
                waveIn = new WaveIn(inDevice, 8000, 8, 1, waveBuffer); // 8kHz * 2Byte (16bit/sample) * 1 channel * x (s) = 8000 Byte => x=500ms
                waveIn.BufferFull += waveIn_BufferFull;
                isRecordVoice = true;
                waveIn.Start();
            }
            catch (Exception exception)
            {
                if (waveIn != null)
                    waveIn.Dispose();

                Console.WriteLine(exception.Message, exception.GetType().FullName);
                return;
            }

            //micWaveIn = waveIn;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Starts the recording.
        /// </summary>
        /// <param name="deviceNumber">The device number.</param>
        /// <param name="format">The wave-format.</param>
        /// <param name="delay">The delay to start.</param>
        /// <remarks>Documented by Dev05, 2007-08-06</remarks>
        private void startRecording(object parameters)
        {
            try
            {
                object[] Parameters = (object[])parameters;
                int deviceNumber = (int)Parameters[0];
                int delay = (int)Parameters[1];
                int bytesPerSecond = (samplingRate * 16 * channels) / 8;

                Thread.Sleep(delay);
                recorder = new WaveIn(WaveIn.Devices[deviceNumber > 0 ? deviceNumber : 0], samplingRate, 16, channels, bytesPerSecond / 10);
                recorder.BufferFull += new BufferFullHandler(WaveDataArrived);
                recorder.Start();
            }
            catch (Exception exp)
            {
                Trace.WriteLine("Recording start exception: " + exp.ToString());
            }
        }
Exemplo n.º 6
0
        private void btn_StartAudio_Click(object sender, EventArgs e)
        {
            if (audioIsRunning)
            {
                audioIsRunning = false;
                audioServer.Dispose();
                audioServer = null;
                audioWaveOut.Dispose();
                audioWaveOut = null;

                audioWaveIn.Dispose();
                audioWaveIn = null;
                btn_StartAudio.BackColor = Color.Green;
                ddl_AudioDevices.Enabled = true;
            }
            else
            {
                audioIsRunning = true;
                audioWaveOut = new WaveOut(WaveOut.Devices[0], 8000, 16, 1);
                audioServer = new UdpServer();
                audioServer.Bindings = new IPEndPoint[] { new IPEndPoint(IPAddress.Parse(GetMyIP()), audioPort) };
                audioServer.PacketReceived += new PacketReceivedHandler(AudioServer_PacketReceived);
                audioServer.Start();

                audioWaveIn = new WaveIn(WaveIn.Devices[ddl_AudioDevices.SelectedIndex], 8000, 16, 1, 400);
                audioWaveIn.BufferFull += new BufferFullHandler(audioWaveIn_BufferFull);
                audioWaveIn.Start();
                btn_StartAudio.BackColor = Color.Red;
                ddl_AudioDevices.Enabled = false;
            }
        }
Exemplo n.º 7
0
 public SoundSender(IPEndPoint targetPoint, WaveIn inputDevice)
 {
     _waveIn = inputDevice;
     _targetEndPoint = targetPoint;
 }