예제 #1
0
        public uint Count(string aMediaServerId, string aId, out uint aUpdateId)
        {
            // we are in the library container
            if (aMediaServerId == string.Empty)
            {
                iMutex.WaitOne();
                aUpdateId = iUpdateId;
                uint count = (uint)iHomeContainer.ChildCount;
                iMutex.ReleaseMutex();

                return(count);
            }
            else
            {
                ModelMediaServer server = ModelMediaServer(aMediaServerId);
                if (server != null)
                {
                    DidlLite result;
                    uint     numberReturned, totalMatches;
                    server.Browse(aId, 0, 1, out result, out numberReturned, out totalMatches, out aUpdateId);

                    return(totalMatches);
                }
            }

            // we get here if the media server we are querying is not in our media server list
            throw new LibraryNotFoundException(aMediaServerId);
        }
예제 #2
0
        public DidlLite Search(string aSearchCriteria, string aMediaServerId, string aId, uint aStartIndex, uint aCount, out uint aUpdateId)
        {
            if (aMediaServerId == string.Empty)
            {
                DidlLite result = new DidlLite();

                iMutex.WaitOne();
                // we need to search across all discovered media servers
                aUpdateId = iUpdateId;
                iMutex.ReleaseMutex();

                return(result);
            }
            else
            {
                ModelMediaServer server = ModelMediaServer(aMediaServerId);
                if (server != null)
                {
                    DidlLite result;
                    uint     numberReturned, totalMatches;
                    server.Search(aSearchCriteria, aId, aStartIndex, aCount, out result, out numberReturned, out totalMatches, out aUpdateId);
                    return(result);
                }
            }
            // we get here if the media server we are querying is not in our media server list
            throw new LibraryNotFoundException(aMediaServerId);
        }
예제 #3
0
        private void MediaServerAdded(object sender, Library.EventArgsMediaServer e)
        {
            ModelMediaServer server = null;

            Trace.WriteLine(Trace.kMediaServer, ">ModelLibrary.MediaServerAdded: " + e.MediaServer);
            try
            {
                server = new ModelMediaServer(e.MediaServer, iEventServer);
            }
            catch (Linn.ControlPoint.ServiceException ex)
            {
                // Need to show media server icon with error symbol
                UserLog.WriteLine(e.MediaServer + ": (" + ex.Message + ")");

                return;
            }

            try
            {
                iMutex.WaitOne();

                UserLog.WriteLine(DateTime.Now + ": Library+                " + server);

                iMediaServerByUdn.Add(server.Udn, server);
                iMediaServerList.Add(server.Name + server.Udn, e.MediaServer);

                iHomeContainer.ChildCount = iMediaServerList.Count;

                iUpdateId++;

                iMutex.ReleaseMutex();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(Trace.kMediaServer, "ModelLibrary.MediaServerAdded: " + ex.Message);

                iMutex.ReleaseMutex();

                throw ex;
            }

            server.EventContentDirectoryInitialised += EventContentDirectoryInitialisedResponse;
            server.EventContainerUpdated            += EventContainerUpdatedResponse;

            server.Open();

            iMutex.WaitOne();
            uint updateId = iUpdateId;

            iMutex.ReleaseMutex();

            EventContainerUpdatedResponse(null, new ModelMediaServer.EventArgsContainerUpdate(iHomeContainer.Id, updateId.ToString()));

            Trace.WriteLine(Trace.kMediaServer, "<ModelLibrary.MediaServerAdded");
        }
예제 #4
0
        public DidlLite Items(string aMediaServerId, string aId, uint aStartIndex, uint aCount, out uint aUpdateId)
        {
            if (aMediaServerId == string.Empty)
            {
                DidlLite result = new DidlLite();

                iMutex.WaitOne();

                aUpdateId = iUpdateId;
                uint endIndex = aStartIndex + aCount;
                for (uint i = 0; i < endIndex && i < iMediaServerList.Values.Count; ++i)
                {
                    MediaServer      server = iMediaServerList.Values[(int)i];
                    ModelMediaServer s;
                    if (iMediaServerByUdn.TryGetValue(server.Device.Udn, out s))
                    {
                        result.Add(s.Metadata);
                    }
                }

                iMutex.ReleaseMutex();

                return(result);
            }
            else
            {
                ModelMediaServer server = ModelMediaServer(aMediaServerId);
                if (server != null)
                {
                    DidlLite result;
                    uint     numberReturned, totalMatches;
                    server.Browse(aId, aStartIndex, aCount, out result, out numberReturned, out totalMatches, out aUpdateId);
                    return(result);
                }
            }

            // we get here if the media server we are querying is not in our media server list
            throw new LibraryNotFoundException(aMediaServerId);
        }