Inheritance: IDisposable, IAudioSink
Example #1
0
        //------------------------------------------------------------------------------------------------------------------------

        public AudioFeed CreateAudioFeed(string audioFeedName)
        {
            // when a new audio device (i.e. mic is able to stream its audio input to the mp3streaming server
            // a new feed is created
            AudioFeed af;

            lock (audiofeeds)
                if (audiofeeds.TryGetValue(audioFeedName, out af) == false)
                {
                    af = new AudioFeed(this, audioFeedName);
                    audiofeeds.Add(audioFeedName, af);
                }
            return(af);
        }
Example #2
0
        //------------------------------------------------------------------------------------------------------------------------

        public void DestroyAudioFeed(string audioFeedName)
        {
            //find feed
            AudioFeed af = null;

            lock (audiofeeds)
                if (audiofeeds.TryGetValue(audioFeedName, out af))
                {
                    audiofeeds.Remove(audioFeedName);
                }                                     //remove
            //stop
            if (af != null)
            {
                af._InternalStop();
                af.Dispose();
            }
        }
Example #3
0
        //------------------------------------------------------------------------------------------------------------------------

        private void ClientThread(object client)
        {
            var socket = (Socket)client;

            Console.WriteLine(string.Format("New client from " + socket.RemoteEndPoint.ToString()));
            //get feed name request
            string feedName = string.Empty;

            using (var netStream = new NetworkStream(socket, false))
                using (var reader = new StreamReader(netStream))
                {
                    var req = reader.ReadLine();
                    try
                    {
                        feedName = req.Split(new[] { ' ' })[1];
                        if (feedName[0] == '/')
                        {
                            feedName = feedName.Substring(1);
                        }
                    }
                    catch { }
                }

            //find feed
            AudioFeed feed = null;

            lock (audiofeeds)
                if (!string.IsNullOrEmpty(feedName))
                {
                    feed = audiofeeds.TryGetOrDefault(feedName);
                }

            //give client to feed
            if (feed != null)
            {
                DebugEx.TraceLog("add new client");
                feed.AddClient(socket);
            }
            else
            {
                DebugEx.TraceLog("Client requested feed not found");
            }
        }
Example #4
0
        //------------------------------------------------------------------------------------------------------------------------

        public AudioFeed CreateAudioFeed(string audioFeedName)
        {
            // when a new audio device (i.e. mic is able to stream its audio input to the mp3streaming server
            // a new feed is created
            AudioFeed af;
            lock (audiofeeds)
                if (audiofeeds.TryGetValue(audioFeedName, out af) == false)
                {
                    af = new AudioFeed(this, audioFeedName);
                    audiofeeds.Add(audioFeedName, af);
                }
            return af;
        }