public bool IsPlayingSender(ModelSender aSender)
        {
            bool playingSender = false;

            if (this.Channel != null && aSender != null)
            {
                if (this.TransportState == ModelSourceReceiver.ETransportState.ePlaying ||
                    this.TransportState == ModelSourceReceiver.ETransportState.eBuffering ||
                    this.TransportState == ModelSourceReceiver.ETransportState.eWaiting)
                {
                    if (aSender.Metadata.Count > 0 && this.Channel.DidlLite.Count > 0)
                    {
                        upnpObject sender   = aSender.Metadata[0];
                        upnpObject receiver = this.Channel.DidlLite[0];

                        if (sender.Res.ToString() == receiver.Res.ToString() && DidlLiteAdapter.Title(sender) == DidlLiteAdapter.Title(receiver))
                        {
                            playingSender = true;
                        }
                    }
                }
            }

            return(playingSender);
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aObject">
 /// A <see cref="Upnp.upnpObject"/>
 /// </param>
 public void SetMetatext(Upnp.upnpObject aObject)
 {
     if (aObject != null)
     {
         iMetatext  = DidlLiteAdapter.Title(aObject);
         iMetatext2 = string.Empty;
     }
 }
Exemple #3
0
        public void SetMetatext(upnpObject aObject)
        {
            iMutex.WaitOne();

            if (aObject != null)
            {
                iAlbum  = DidlLiteAdapter.Title(aObject);
                iArtist = string.Empty;
            }

            iMutex.ReleaseMutex();
        }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aObject">
 /// A <see cref="Upnp.upnpObject"/>
 /// </param>
 public void SetItem(Upnp.upnpObject aObject)
 {
     if (aObject != null)
     {
         iTitle     = DidlLiteAdapter.Title(aObject);
         iMetatext  = DidlLiteAdapter.Album(aObject);
         iMetatext2 = DidlLiteAdapter.Artist(aObject);
     }
     else
     {
         iTitle     = string.Empty;
         iMetatext  = string.Empty;
         iMetatext2 = string.Empty;
     }
 }
        public Bookmark(Location aLocation)
            : this()
        {
            BreadcrumbTrail = aLocation.BreadcrumbTrail;

            Title = DidlLiteAdapter.Title(aLocation.Current.Metadata);
            Class = aLocation.Current.Metadata.Class;
            Uri uri = DidlLiteAdapter.ArtworkUri(aLocation.Current.Metadata);

            if (uri != null)
            {
                Image = uri.OriginalString;
            }
            else
            {
                Image = string.Empty;
            }
        }
Exemple #6
0
        public void SetItem(upnpObject aObject)
        {
            iMutex.WaitOne();

            if (aObject != null)
            {
                iTitle  = DidlLiteAdapter.Title(aObject);
                iArtist = DidlLiteAdapter.Artist(aObject);
                iAlbum  = DidlLiteAdapter.Album(aObject);

                iArtworkUri = DidlLiteAdapter.ArtworkUri(aObject);

                if (iArtworkUri == null)
                {
                    SetNoArtwork();
                }
                else
                {
                    DownloadArtwork(iArtworkUri);
                }
            }
            else
            {
                iTitle  = string.Empty;
                iArtist = string.Empty;
                iAlbum  = string.Empty;

                iCodec      = string.Empty;
                iBitDepth   = 0;
                iSampleRate = 0;
                iBitrate    = 0;
                iLossless   = false;

                iArtworkUri = null;
                SetNoArtwork();
            }

            iMutex.ReleaseMutex();
        }
        private void EventStateMetadataResponse(object sender, EventArgs e)
        {
            lock (this)
            {
                try
                {
                    iMetadata = new DidlLite(iServiceSender.Metadata);
                    string metadata = (iMetadata.Count > 0) ? DidlLiteAdapter.Title(iMetadata[0]) : "Unknown";
                    ParseName(metadata, out iRoom, out iName);
                    iFullName = string.Format("{0} ({1})", iRoom, iName);
                }
                catch (Exception ex)
                {
                    UserLog.WriteLine("Logging for ticket #1125: " + ex);
                    UserLog.WriteLine("Logging for ticket #1125: " + iServiceSender.Metadata);
                    iMetadata = null;
                }
            }

            if (EventMetadataChanged != null)
            {
                EventMetadataChanged(this, EventArgs.Empty);
            }
        }
Exemple #8
0
        private void Run()
        {
            bool errorRaised = false;
            uint total       = 0;

            try
            {
                total = iContainer.Open();
            }
            catch (Exception e)
            {
                // container has died
                UserLog.WriteLine(DateTime.Now + ": Exception caught opening container (" + e.Message + (e.InnerException != null ? (", " + e.InnerException.Message) : "") + ")");
                IContentHandler handler;
                lock (iContentHandlerLock)
                {
                    handler = iContentHandler;
                }
                if (handler != null)
                {
                    handler.ContentError(this, e.Message);
                }
                errorRaised = true;
            }

            iMutex.WaitOne();

            iContent = new upnpObject[(int)total];

            iMutex.ReleaseMutex();
            if (!errorRaised)
            {
                IContentHandler handler;
                lock (iContentHandlerLock)
                {
                    handler = iContentHandler;
                }
                if (handler != null)
                {
                    handler.Open(this, total);
                }
            }

            iMutex.WaitOne();

            while (!iExit)
            {
                iMutex.ReleaseMutex();

                iEvent.WaitOne();

                iMutex.WaitOne();

                IContentHandler handler;
                lock (iContentHandlerLock)
                {
                    handler = iContentHandler;
                }

                if (iRangeUpdated)
                {
                    Assert.Check(iExit || iStartIndex >= 0);
                    Assert.Check(iExit || iCount >= 0);

                    uint startIndex = (uint)iStartIndex;
                    uint index      = (uint)iStartIndex;
                    uint totalCount = (uint)iCount;
                    uint count      = 0;
                    iRangeUpdated = false;
                    while (!iExit && !iRangeUpdated && count < totalCount)
                    {
                        iMutex.ReleaseMutex();
                        DidlLite didl = new DidlLite();
                        try
                        {
                            uint callCount = (startIndex + totalCount) - index;
                            if (callCount > kCountPerCall)
                            {
                                callCount = kCountPerCall;
                            }

                            for (int i = (int)index; i < (int)(index + callCount) && i < iContent.Length; ++i)
                            {
                                if (iContent[i] != null)
                                {
                                    didl.Add(iContent[i]);
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (didl.Count == 0)
                            {
                                didl = iContainer.Items(index, callCount);
                            }
                        }
                        catch (Exception e)
                        {
                            iMutex.WaitOne();

                            // container has died
                            UserLog.WriteLine(DateTime.Now + ": Exception caught retrieving container content (" + e.Message + (e.InnerException != null ? (", " + e.InnerException.Message) : "") + ")");
                            UserLog.WriteLine(DateTime.Now + e.StackTrace);
                            if (!errorRaised)
                            {
                                lock (iContentHandlerLock)
                                {
                                    handler = iContentHandler;
                                }
                                if (handler != null)
                                {
                                    handler.ContentError(this, e.Message);
                                }
                                errorRaised = true;
                            }
                            break;
                        }

                        iMutex.WaitOne();

                        if (iExit || total < index + didl.Count)
                        {
                            if (total < index + didl.Count)
                            {
                                UserLog.WriteLine(DateTime.Now + ": Error: " + iContainer.Metadata.Title + " returned more items than expected");

                                lock (iContentHandlerLock)
                                {
                                    handler = iContentHandler;
                                }
                                if (handler != null)
                                {
                                    handler.ContentError(this, iContainer.Metadata.Title + " returned more items than expected");
                                }
                            }
                            break;
                        }

                        iMutex.ReleaseMutex();

                        for (uint i = 0; i < didl.Count; ++i)
                        {
                            upnpObject o = didl[(int)i];
                            iContent[index + i] = o;

                            lock (iContentHandlerLock)
                            {
                                handler = iContentHandler;
                            }
                            if (handler != null)
                            {
                                handler.Item(this, index + i, o);
                            }
                        }

                        lock (iContentHandlerLock)
                        {
                            handler = iContentHandler;
                        }
                        if (handler != null)
                        {
                            handler.Items(this, index, didl);
                        }

                        index += (uint)didl.Count;
                        count += (uint)didl.Count;

                        iMutex.WaitOne();

                        if (!iRangeUpdated)
                        {
                            iStartIndex = -1;
                            iCount      = -1;
                        }
                    }
                }
            }

            iMutex.ReleaseMutex();

            iContainer.Close();

            Trace.WriteLine(Trace.kKinsky, "ContentCollector for " + DidlLiteAdapter.Title(iContainer.Metadata) + " disposed");
        }
Exemple #9
0
        private void Parse()
        {
            lock (iLock)
            {
                if (!iParsed)
                {
                    List <KeyValuePair <string, string> > displayList = new List <KeyValuePair <string, string> >();
                    List <KeyValuePair <string, string> > fullList    = new List <KeyValuePair <string, string> >();

                    if (iItem != null)
                    {
                        string type = GetItemType(iItem);
                        fullList.Add(new KeyValuePair <string, string>("Type", type));

                        string title = DidlLiteAdapter.Title(iItem);
                        if (title != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Title", title));
                            fullList.Add(new KeyValuePair <string, string>("Title", title));
                        }

                        string album = DidlLiteAdapter.Album(iItem);
                        // if parent is a musicAlbum and album is blank, try to get album info from parent
                        if (album == string.Empty && iParent is musicAlbum)
                        {
                            album = DidlLiteAdapter.Album(iParent);
                        }
                        // don't display album field if we are a musicAlbum as it will be same as Title
                        if (album != string.Empty && !(iItem is musicAlbum))
                        {
                            // only insert album info for display if parent not a musicAlbum
                            if (!(iParent is musicAlbum))
                            {
                                displayList.Add(new KeyValuePair <string, string>("Album", album));
                            }
                            fullList.Add(new KeyValuePair <string, string>("Album", album));
                        }

                        string artist       = DidlLiteAdapter.Artist(iItem);
                        string albumArtist  = DidlLiteAdapter.AlbumArtist(iItem);
                        string parentArtist = string.Empty;
                        if (iParent != null)
                        {
                            parentArtist = DidlLiteAdapter.Artist(iParent);
                        }

                        // don't display artist field if we are a person, as it will be same as title
                        if (artist != string.Empty && !(iItem is person))
                        {
                            // only display artist field when:
                            // our parent is not a music album
                            // or we are a music album and album artist field is blank
                            // our parent is a music album but artist field is different from album artist field and different from parent's artist field

                            if (!(iParent is musicAlbum) ||
                                (iItem is musicAlbum && albumArtist == string.Empty) ||
                                (iParent is musicAlbum && albumArtist != artist && parentArtist != artist))
                            {
                                displayList.Add(new KeyValuePair <string, string>("Artist", artist));
                            }
                            fullList.Add(new KeyValuePair <string, string>("Artist", artist));
                        }

                        if (albumArtist != string.Empty)
                        {
                            // only display albumartist field when:
                            // we are a musicAlbum and album artist is different from artist
                            // or artist field is blank and album artist is not the same as parent's artist field

                            if ((iItem is musicAlbum && albumArtist != artist) ||
                                (artist == string.Empty && parentArtist != albumArtist))
                            {
                                displayList.Add(new KeyValuePair <string, string>("Album Artist", albumArtist));
                            }
                            fullList.Add(new KeyValuePair <string, string>("Album Artist", albumArtist));
                        }

                        string count = DidlLiteAdapter.Count(iItem);
                        if (count != string.Empty && count != "0")
                        {
                            displayList.Add(new KeyValuePair <string, string>("Count", count));
                            fullList.Add(new KeyValuePair <string, string>("Count", count));
                        }

                        string composer = DidlLiteAdapter.Composer(iItem);
                        if (composer != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Composer", composer));
                            fullList.Add(new KeyValuePair <string, string>("Composer", composer));
                        }

                        string genre = DidlLiteAdapter.Genre(iItem);
                        if (genre != string.Empty)
                        {
                            string parentGenre = string.Empty;
                            if (iParent != null)
                            {
                                parentGenre = DidlLiteAdapter.Genre(iParent);
                            }
                            if (parentGenre != genre)
                            {
                                displayList.Add(new KeyValuePair <string, string>("Genre", genre));
                            }
                            fullList.Add(new KeyValuePair <string, string>("Genre", genre));
                        }

                        string releaseYear = DidlLiteAdapter.ReleaseYear(iItem);
                        if (releaseYear != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Release Year", releaseYear));
                            fullList.Add(new KeyValuePair <string, string>("Release Year", releaseYear));
                        }

                        string originalTrackNumber = DidlLiteAdapter.OriginalTrackNumber(iItem);
                        if (originalTrackNumber != string.Empty)
                        {
                            fullList.Add(new KeyValuePair <string, string>("Original Track No.", originalTrackNumber));
                        }

                        string conductor = DidlLiteAdapter.Conductor(iItem);
                        if (conductor != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Conductor", conductor));
                            fullList.Add(new KeyValuePair <string, string>("Conductor", conductor));
                        }

                        string actor = DidlLiteAdapter.Actor(iItem);
                        if (actor != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Actor", actor));
                            fullList.Add(new KeyValuePair <string, string>("Actor", actor));
                        }

                        string director = DidlLiteAdapter.Director(iItem);
                        if (director != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Director", director));
                            fullList.Add(new KeyValuePair <string, string>("Director", director));
                        }

                        string publisher = DidlLiteAdapter.Publisher(iItem);
                        if (publisher != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Publisher", publisher));
                            fullList.Add(new KeyValuePair <string, string>("Publisher", publisher));
                        }

                        string contributer = DidlLiteAdapter.Contributor(iItem);
                        if (contributer != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Contributor", contributer));
                            fullList.Add(new KeyValuePair <string, string>("Contributor", contributer));
                        }

                        string duration = DidlLiteAdapter.Duration(iItem);
                        if (duration != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Duration", duration));
                            fullList.Add(new KeyValuePair <string, string>("Duration", duration));
                        }

                        string size = DidlLiteAdapter.Size(iItem);
                        if (size != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Size", size));
                            fullList.Add(new KeyValuePair <string, string>("Size", size));
                        }

                        string bitrate = DidlLiteAdapter.Bitrate(iItem);
                        if (bitrate != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Bitrate", bitrate));
                            fullList.Add(new KeyValuePair <string, string>("Bitrate", bitrate));
                        }

                        string sampleRate = DidlLiteAdapter.SampleRate(iItem);
                        if (sampleRate != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("SampleRate", sampleRate));
                            fullList.Add(new KeyValuePair <string, string>("SampleRate", sampleRate));
                        }

                        string bitDepth = DidlLiteAdapter.BitDepth(iItem);
                        if (bitDepth != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Bit Depth", bitDepth));
                            fullList.Add(new KeyValuePair <string, string>("Bit Depth", bitDepth));
                        }

                        string mimeType = DidlLiteAdapter.MimeType(iItem);
                        if (mimeType != string.Empty)
                        {
                            fullList.Add(new KeyValuePair <string, string>("Mime Type", mimeType));
                        }

                        string protocolInfo = DidlLiteAdapter.ProtocolInfo(iItem);
                        if (protocolInfo != string.Empty)
                        {
                            fullList.Add(new KeyValuePair <string, string>("Protocol Info", protocolInfo));
                        }

                        string description = DidlLiteAdapter.Description(iItem);
                        if (description != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Description", description));
                            fullList.Add(new KeyValuePair <string, string>("Description", description));
                        }

                        string info = DidlLiteAdapter.Info(iItem);
                        if (info != string.Empty)
                        {
                            displayList.Add(new KeyValuePair <string, string>("Info", description));
                            fullList.Add(new KeyValuePair <string, string>("Info", description));
                        }

                        string uri = DidlLiteAdapter.Uri(iItem);
                        if (uri != string.Empty)
                        {
                            fullList.Add(new KeyValuePair <string, string>("Uri", uri));
                        }

                        Uri artworkUri = DidlLiteAdapter.ArtworkUri(iItem);
                        if (artworkUri != null)
                        {
                            fullList.Add(new KeyValuePair <string, string>("Artwork Uri", artworkUri.OriginalString));
                        }
                    }
                    iFullInfoList    = fullList;
                    iDisplayInfoList = displayList;
                    iParsed          = true;
                }
            }
        }