public void Init(string baseUri)
        {
            items = new List <Item>();

            CaptureDevice        defaultDevice = WasapiLoopbackCapture2.GetDefaultLoopbackCaptureDevice();
            List <CaptureDevice> devices       = WasapiLoopbackCapture2.GetLoopbackCaptureDevices();

            int itemId = 0;

            items.Add(new Item {
                Uri        = baseUri,
                Definition = DidlUtil.GenerateCaptureDeviceItem(++itemId, defaultDevice, baseUri)
            });

            int deviceId = 0;

            foreach (CaptureDevice captureDevice in devices)
            {
                if (captureDevice != defaultDevice)
                {
                    string uri = baseUri + "?id=" + deviceId;
                    items.Add(new Item {
                        Uri        = uri,
                        Definition = DidlUtil.GenerateCaptureDeviceItem(++itemId, captureDevice, uri)
                    });
                }
                deviceId++;
            }
        }
        public string GetDirectoryDidl()
        {
            string list = "";

            foreach (Item item in items)
            {
                list += item.Definition;
            }

            return(DidlUtil.BeginDidl() + list + DidlUtil.EndDidl());
        }
        public static String GenerateCaptureDeviceItem(int itemId, CaptureDevice captureDevice, String uri)
        {
            int sampleRate = captureDevice.MMDevice.AudioClient.MixFormat.SampleRate;

            /* The channels and bitDepth are fixed, as requested from the WasapiLoopbackCapture2
             * in LoopbackModule.Start(). */
            int channels = 2;
            int bitDepth = 16;
            int bitRate  = sampleRate * channels * (bitDepth / 2) * 8;

            return(DidlUtil.GetMusicItem(itemId + "", "0", "1",
                                         captureDevice.Name, "N/A", "N/A", "N/A", "0",
                                         bitRate + "", sampleRate + "", channels + "", bitDepth + "",
                                         StreamingFormat.DefaultFormat.GetNetworkFormatDescriptor(sampleRate, channels),
                                         uri, "object.item.audioItem.musicTrack"));
        }
        private String GenerateCaptureDeviceEntry(int itemId, CaptureDevice captureDevice, String url)
        {
            int sampleRate = captureDevice.MMDevice.AudioClient.MixFormat.SampleRate;

            /* The channels and bitDepth are fixed, as requested from the WasapiLoopbackCapture2
             * in LoopbackModule.Start(). */
            int channels = 2;
            int bitDepth = 16;
            int bitRate  = sampleRate * channels * (bitDepth / 2) * 8;

            return(DidlUtil.GetMusicItem(itemId + "", "0", "1",
                                         captureDevice.Name, "N/A", "N/A", "N/A", "0",
                                         bitRate + "", sampleRate + "", channels + "", bitDepth + "",
                                         "http-get:*:audio/L16;rate=" + sampleRate + ";channels=" + channels + ":DLNA.ORG_PN=LPCM",
                                         url, "object.item.audioItem.musicTrack"));
        }
        public void Start()
        {
            device.StartDevice();

            foreach (IPEndPoint ipep in device.LocalIPEndPoints)
            {
                if (ipep.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    Console.WriteLine("DLNA server STARTED listening @ " + ipep.ToString());
                    // create HTTP resource server endpoint
                    ipEndPoint = new IPEndPoint(ipep.Address, ipep.Port + 1);
                    break;
                }
            }

            S1 = HttpBaseURL + "capture";

            S2 = DidlUtil.BeginDidl();

            CaptureDevice        defaultDevice = WasapiLoopbackCapture2.GetDefaultLoopbackCaptureDevice();
            List <CaptureDevice> devices       = WasapiLoopbackCapture2.GetLoopbackCaptureDevices();

            S2 += GenerateCaptureDeviceEntry(1, defaultDevice, S1);

            int id = 0;

            foreach (CaptureDevice captureDevice in devices)
            {
                if (captureDevice != defaultDevice)
                {
                    S2 += GenerateCaptureDeviceEntry(id + 2, captureDevice, S1 + "?id=" + id);
                }
                id++;
            }

            S2     += DidlUtil.EndDidl();
            S2count = (uint)devices.Count;
        }
 public string GetDidl()
 {
     return(DidlUtil.BeginDidl() + Definition + DidlUtil.EndDidl());
 }