/// <summary>
        /// Answers the /ctrl-int/dbid/getspeakers request
        /// 
        /// Query string arguments are:
        /// session-id: id of the remote session;
        /// </summary>
        /// <returns>
        /// casp --+
        ///     mstt 4 200
        ///     mdcl --+
        ///         caia 1 1
        ///         cahp 1 0
        ///         cavd 1 1
        ///         minm 8 Computer
        ///         msma 8 0
        ///         cmvo 4 100
        ///     mdcl --+
        ///         ...
        /// </returns>
        private HttpResponse GetSpeakersResponse()
        {
            var speakers = new MultiValueTag();

            using (Player.BeginRead())
            {
                speakers.Add("mstt", 200);

                speakers.Add("mdcl", new
                {
                    caia = true,                    // is active?
                    cahp = false,                   // has protection? (lock icon)
                    cavd = true,                    // can play video? (screen or speaker icon)
                    minm = "Computer",              // name
                    msma = 0L,                      // id (will be passed to set-speakers)
                    cmvo = Player.CurrentVolume     // current volume
                });

                /*speakers.Add("mdcl", new
                {
                    caia = false,
                    cahp = false,
                    cavd = false,
                    minm = "Sennheiser HD600",
                    msma = 1L,
                    cmvo = 100
                });*/

            }

            return new DmapResponse(new
            {
                casp = speakers
            });
        }
        /// <summary>
        /// Answers the /ctrl-int/dbid/getspeakers request
        ///
        /// Query string arguments are:
        /// session-id: id of the remote session;
        /// </summary>
        /// <returns>
        /// casp --+
        ///     mstt 4 200
        ///     mdcl --+
        ///         caia 1 1
        ///         cahp 1 0
        ///         cavd 1 1
        ///         minm 8 Computer
        ///         msma 8 0
        ///         cmvo 4 100
        ///     mdcl --+
        ///         ...
        /// </returns>
        private HttpResponse GetSpeakersResponse()
        {
            var speakers = new MultiValueTag();

            using (Player.BeginRead())
            {
                speakers.Add("mstt", 200);

                speakers.Add("mdcl", new
                {
                    caia = true,                    // is active?
                    cahp = false,                   // has protection? (lock icon)
                    cavd = true,                    // can play video? (screen or speaker icon)
                    minm = "Computer",              // name
                    msma = 0L,                      // id (will be passed to set-speakers)
                    cmvo = Player.CurrentVolume     // current volume
                });

                /*speakers.Add("mdcl", new
                 * {
                 *  caia = false,
                 *  cahp = false,
                 *  cavd = false,
                 *  minm = "Sennheiser HD600",
                 *  msma = 1L,
                 *  cmvo = 100
                 * });*/
            }

            return(new DmapResponse(new
            {
                casp = speakers
            }));
        }
        public override HttpResponse GetResponse()
        {
            var ifinfo = new MultiValueTag();

            try
            {
                var interfaces = NetworkInterface.GetAllNetworkInterfaces();
                foreach (var iface in interfaces.Where(
                    x => x.OperationalStatus == OperationalStatus.Up &&
                    (x.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
                     x.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||
                     x.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet)))
                {
                    var addr = iface.GetPhysicalAddress().GetAddressBytes();

                    var bytes = new byte[8];
                    Buffer.BlockCopy(addr, 0, bytes, 0, addr.Length);

                    ifinfo.Add("msma", BitConverter.ToUInt64(bytes, 0));
                }
            }
            catch (Exception ex)
            {
                Player.Logger.LogMessage("Failed to enumerate network interfaces, ignoring");
                ifinfo = null;
            }

            return new DmapResponse(new
            {
                msrv = new
                {
                    mstt = 200,
                    mpro = 0x00020009,      // DACP version
                    minm = Player.Name,     // name
                    apro = 0x0003000b,      // DAAP version
                    ppro = 0x00020000,      // unknown
                    aeSV = 0x00030009,      // HomeSharing version
                    ated = (short)7,        // unknown
                    asgr = (short)3,        // unknown, requred to request artists as groups
                    asse = 1L,              // unknown
                    aeMQ = true,            // unknown
                    aeFR = (byte)0x64,      // unknown
                    aeTr = true,            // unknown
                    aeSL = true,            // unknown
                    aeSR = true,            // unknown
                    aeFP = (byte)0,         // FairPlay version
                    //aeSX = 0x6FL,           // unknown, causes FairPlay request
                    msed = true,            // editing supported
                    ceWM = "",              // unknown
                    ceVO = false,           // unknown, probably voice-over?
                    msml = ifinfo,          // network interfaces

                    mslr = true,            // login required
                    msal = true,            // auto logout
                    mstm = 1800,            // auto logout timeout
                    msas = (byte)0x3,       // authentication schemas
                    msup = true,            // supports 'update' queries
                    mspi = true,            // supports persistent identifiers
                    msex = true,            // supports extensions (?)
                    msbr = true,            // supports 'browse' queries
                    msqy = true,            // supports query (?)
                    msix = true,            // supports index (?)
                    msrs = true,            // supports resolve (?)

                    msdc = 1,               // database count

                    mstc = DateTime.UtcNow.ToUnixTime(),    // UTC time
                    msto = (int)Math.Round(DateTimeOffset.Now.Offset.TotalSeconds)  // UTC offset
                }
            });
        }
Beispiel #4
0
        public override HttpResponse GetResponse()
        {
            var ifinfo = new MultiValueTag();

            try
            {
                var interfaces = NetworkInterface.GetAllNetworkInterfaces();
                foreach (var iface in interfaces.Where(
                             x => x.OperationalStatus == OperationalStatus.Up &&
                             (x.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
                              x.NetworkInterfaceType == NetworkInterfaceType.Ethernet ||
                              x.NetworkInterfaceType == NetworkInterfaceType.GigabitEthernet)))
                {
                    var addr = iface.GetPhysicalAddress().GetAddressBytes();

                    var bytes = new byte[8];
                    Buffer.BlockCopy(addr, 0, bytes, 0, addr.Length);

                    ifinfo.Add("msma", BitConverter.ToUInt64(bytes, 0));
                }
            }
            catch (Exception ex)
            {
                Player.Logger.LogMessage("Failed to enumerate network interfaces, ignoring");
                ifinfo = null;
            }

            return(new DmapResponse(new
            {
                msrv = new
                {
                    mstt = 200,
                    mpro = 0x00020009,                                             // DACP version
                    minm = Player.Name,                                            // name
                    apro = 0x0003000b,                                             // DAAP version
                    ppro = 0x00020000,                                             // unknown
                    aeSV = 0x00030009,                                             // HomeSharing version
                    ated = (short)7,                                               // unknown
                    asgr = (short)3,                                               // unknown, requred to request artists as groups
                    asse = 1L,                                                     // unknown
                    aeMQ = true,                                                   // unknown
                    aeFR = (byte)0x64,                                             // unknown
                    aeTr = true,                                                   // unknown
                    aeSL = true,                                                   // unknown
                    aeSR = true,                                                   // unknown
                    aeFP = (byte)0,                                                // FairPlay version
                    //aeSX = 0x6FL,           // unknown, causes FairPlay request
                    msed = true,                                                   // editing supported
                    ceWM = "",                                                     // unknown
                    ceVO = false,                                                  // unknown, probably voice-over?
                    msml = ifinfo,                                                 // network interfaces

                    mslr = true,                                                   // login required
                    msal = true,                                                   // auto logout
                    mstm = 1800,                                                   // auto logout timeout
                    msas = (byte)0x3,                                              // authentication schemas
                    msup = true,                                                   // supports 'update' queries
                    mspi = true,                                                   // supports persistent identifiers
                    msex = true,                                                   // supports extensions (?)
                    msbr = true,                                                   // supports 'browse' queries
                    msqy = true,                                                   // supports query (?)
                    msix = true,                                                   // supports index (?)
                    msrs = true,                                                   // supports resolve (?)

                    msdc = 1,                                                      // database count

                    mstc = DateTime.UtcNow.ToUnixTime(),                           // UTC time
                    msto = (int)Math.Round(DateTimeOffset.Now.Offset.TotalSeconds) // UTC offset
                }
            }));
        }