Exemple #1
0
        // this call block until recieved client connection request
        public AudioOutputWriter(MMDevice device, GlobalConfiguration config)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            this.config         = config;
            m_JitterBufferCount = this.config.JitterBuffer;
            m_Milliseconds      = this.config.JitterBufferTimerPeriodMsec;

            m_device     = device;
            this._WaveIn = new WasapiLoopbackCapture(m_device);
            this._WaveIn.DataAvailable    += this.WaveInOnDataAvailable;
            this._WaveIn.RecordingStopped += this.WaveInOnRecordingStopped;
            WaveFormat wfmt = this._WaveIn.WaveFormat;

            sdsock = new SoundDataSocket(NetworkTypes.Server);
            //dispatcher = Dispatcher.CurrentDispatcher;
            sdsock.ConnectedCallback         += Socket_ConnectedCallback;
            sdsock.DisconnectedCallback      += Socket_DisconnectedCallback;
            sdsock.ConnectionFailedCallback  += Socket_ConnectionFailedCallback;
            sdsock.DataRecievedCallback      += Socket_DataRecievedCallback;
            sdsock.StartDataRecievedCallback += Socket_StartDataRecievedCallback;
            sdsock.EndDataRecievedCallback   += Socket_EndDataRecievedCallback;
            //sdsock.Listen(IPAddress.Parse(GlobalConfiguration.ServerAddress), this.config.SoundServerPort);
            sdsock.Listen(IPAddress.Any, this.config.SoundServerPort);

            Start(); // start capture and send stream
        }