Beispiel #1
0
 public override void BrowseMetadata(XmlWriter writer, MediaSettings settings, string host, string idParams, HashSet <string> filterSet, int parentId)
 {
     BrowseMetadata(writer, settings, host, idParams, filterSet, parentId, null);
 }
Beispiel #2
0
        public override void BrowseMetadata(XmlWriter writer, MediaSettings settings, string host, string idParams, HashSet <string> filterSet, int parentId, TimeSpan?startTime)
        {
            writer.WriteStartElement("item");

            writer.WriteAttributeString("id", this.Id.ToString());
            writer.WriteAttributeString("restricted", "true");
            writer.WriteAttributeString("parentID", parentId + "_" + VideoIndex);

            //Povinne hodnoty
            writer.WriteElementString("dc", "title", null, this.Title);
            writer.WriteElementString("upnp", "class", null, "object.item.videoItem");

            //Volitelne hodnoty
            if (filterSet == null || filterSet.Contains("dc:date"))
            {
                writer.WriteElementString("dc", "date", null, this.Date.ToString("yyyy-MM-dd"));
            }

            if ((filterSet == null || filterSet.Contains("upnp:icon")) && (this.Parent.HasThumbnail.HasValue && this.Parent.HasThumbnail.Value))
            {
                writer.WriteElementString("upnp", "icon", null, host + "/thumbnail/image.jpg?id=" + this.Id + "&codec=jpeg&width=160&height=160&keepaspect");
            }

            if ((filterSet == null || filterSet.Contains("upnp:albumArtURI")) && (this.Parent.HasThumbnail.HasValue && this.Parent.HasThumbnail.Value))
            {
                writer.WriteStartElement("upnp", "albumArtURI", null);
                writer.WriteAttributeString("dlna", "profileID", "urn:schemas-dlna-org:metadata-1-0/", "JPEG_TN");
                writer.WriteValue(host + "/thumbnail/image.jpg?id=" + this.Id + "&codec=jpeg&width=160&height=160&keepaspect");
                writer.WriteEndElement();
            }

            //Vlozi titulkovy subor, vynecha sa item s titulkami vo videu
            if ((filterSet == null || filterSet.Contains("sec:CaptionInfoEx")) && (this.SubtitlesPath == null))
            {
                ItemVideo subItem = this.Parent.Children.OfType <ItemVideo>().Where(a => a.SubtitlesPath != null).FirstOrDefault();
                if (subItem != null)
                {
                    string type = System.IO.Path.GetExtension(subItem.SubtitlesPath).TrimStart('.');

                    writer.WriteStartElement("sec", "CaptionInfoEx", null);
                    writer.WriteAttributeString("sec", "type", null, type);
                    writer.WriteValue(host + "/subtitle/subtitle." + type + "?id=" + subItem.Id);
                    writer.WriteEndElement();
                }
            }

            if (filterSet == null || filterSet.Any(a => a.StartsWith("res")))
            {
                TimeSpan?duration = this.GetDuration();
                if (duration.HasValue && startTime.HasValue)
                {
                    duration -= startTime;
                }

                if (settings.Video.NativeFile && this.SubtitlesPath == null && this.Path == null && !startTime.HasValue)
                {
                    //Povoli sa povodne video ak sa nevkladaju titulky, nemeni sa zvukova stopa alebo zaciatok videa
                    writer.WriteStartElement("res");

                    if (filterSet == null || filterSet.Contains("res@size"))
                    {
                        writer.WriteAttributeString("size", ((ItemContainerVideo)this.Parent).Length.ToString());
                    }

                    if (duration.HasValue && (filterSet == null || filterSet.Contains("res@duration")))
                    {
                        writer.WriteAttributeString("duration", duration.Value.ToString("h':'mm':'ss'.'fff"));
                    }

                    int?bitrate = ((ItemContainerVideo)this.Parent).Bitrate;
                    if (bitrate.HasValue && (filterSet == null || filterSet.Contains("res@bitrate")))
                    {
                        writer.WriteAttributeString("bitrate", bitrate.Value.ToString());
                    }

                    string resolution = ((ItemContainerVideo)this.Parent).Resolution;
                    if (resolution != null && (filterSet == null || filterSet.Contains("res@resolution")))
                    {
                        writer.WriteAttributeString("resolution", resolution);
                    }

                    writer.WriteAttributeString("protocolInfo", string.Format("http-get:*:{0}:{1}", GetMime(), GetFileFeature(settings)));
                    writer.WriteValue(string.Format("{0}/files/video{1}?id={2}", host, System.IO.Path.GetExtension(this.Parent.Path), this.Id));
                    writer.WriteEndElement();
                }

                foreach (EncoderBuilder sett in settings.Video.Encode)
                {
                    writer.WriteStartElement("res");

                    if (duration.HasValue && (filterSet == null || filterSet.Contains("res@duration")))
                    {
                        writer.WriteAttributeString("duration", duration.Value.ToString("h':'mm':'ss'.'fff"));
                    }

                    if (sett.VidBitrate != null && (filterSet == null || filterSet.Contains("res@bitrate")))
                    {
                        writer.WriteAttributeString("bitrate", sett.VidBitrate);
                    }

                    if (sett.Resolution != null && (filterSet == null || filterSet.Contains("res@resolution")))
                    {
                        writer.WriteAttributeString("resolution", sett.Resolution);
                    }

                    writer.WriteAttributeString("protocolInfo", string.Format("http-get:*:{0}:{1}{2}", sett.GetMime(), sett.GetDlnaType(), settings.Video.EncodeFeature));
                    writer.WriteValue(string.Format("{0}/encode/video?id={1}{2}{3}{4}", host, this.Id, sett.GetParamString(), this.Path,
                                                    startTime.HasValue ? "&starttime=" + startTime.Value.TotalSeconds : string.Empty));
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }
Beispiel #3
0
 public override void BrowseMetadata(XmlWriter writer, MediaSettings settings, string host, string idParams, HashSet <string> filterSet)
 {
     BrowseMetadata(writer, settings, host, idParams, filterSet, this.Parent.GetParentItem(MediaType.Video).Id);
 }
Beispiel #4
0
 public override string GetEncodeFeature(MediaSettings settings)
 {
     return(settings.Video.EncodeFeature);
 }
Beispiel #5
0
 public override string GetFileFeature(MediaSettings settings)
 {
     return(settings.Video.FileFeature);
 }
Beispiel #6
0
 public override string GetFileFeature(MediaSettings settings)
 {
     return((this.Mime == "image/jpeg" ? "DLNA.ORG_PN=JPEG_MED;" : string.Empty) + settings.Image.FileFeature);
 }
Beispiel #7
0
        public override void BrowseMetadata(XmlWriter writer, MediaSettings settings, string host, string idParams, HashSet <string> filterSet, int parentId)
        {
            writer.WriteStartElement("item");

            writer.WriteAttributeString("id", this.Id.ToString());
            writer.WriteAttributeString("restricted", "true");
            writer.WriteAttributeString("parentID", parentId + "_" + ImageIndex);

            //Povinne hodnoty
            writer.WriteElementString("dc", "title", null, this.Title);
            writer.WriteElementString("upnp", "class", null, "object.item.imageItem");

            //Volitelne hodnoty
            if (filterSet == null || filterSet.Contains("dc:date"))
            {
                writer.WriteElementString("dc", "date", null, this.Date.ToString("yyyy-MM-dd"));
            }

            if (filterSet == null || filterSet.Contains("upnp:icon"))
            {
                writer.WriteElementString("upnp", "icon", null, host + "/thumbnail/image.jpg?id=" + this.Id + "&codec=jpeg&width=160&height=160&keepaspect");
            }

            if (filterSet == null || filterSet.Contains("upnp:albumArtURI"))
            {
                writer.WriteStartElement("upnp", "albumArtURI", null);
                writer.WriteAttributeString("dlna", "profileID", "urn:schemas-dlna-org:metadata-1-0/", "JPEG_TN");
                writer.WriteValue(host + "/thumbnail/image.jpg?id=" + this.Id + "&codec=jpeg&width=160&height=160&keepaspect");
                writer.WriteEndElement();
            }

            if (filterSet == null || filterSet.Any(a => a.StartsWith("res")))
            {
                if (settings.Image.NativeFile)
                {
                    writer.WriteStartElement("res");

                    if (filterSet == null || filterSet.Contains("res@size"))
                    {
                        writer.WriteAttributeString("size", this.Length.ToString());
                    }

                    if (this.Resolution != null && (filterSet == null || filterSet.Contains("res@resolution")))
                    {
                        writer.WriteAttributeString("resolution", this.Resolution);
                    }

                    writer.WriteAttributeString("protocolInfo", string.Format("http-get:*:{0}:{1}", this.Mime, GetFileFeature(settings)));
                    writer.WriteValue(string.Format("{0}/files/image{1}?id={2}", host, System.IO.Path.GetExtension(this.Path), this.Id));
                    writer.WriteEndElement();
                }

                foreach (EncoderBuilder sett in settings.Image.Encode)
                {
                    writer.WriteStartElement("res");

                    if (sett.Resolution != null && (filterSet == null || filterSet.Contains("res@resolution")))
                    {
                        writer.WriteAttributeString("resolution", sett.Resolution);
                    }

                    writer.WriteAttributeString("protocolInfo", string.Format("http-get:*:{0}:{1}{2}", sett.GetMime(), sett.GetDlnaType(), settings.Image.EncodeFeature));
                    writer.WriteValue(host + "/encode/image?id=" + this.Id + sett.GetParamString());
                    writer.WriteEndElement();
                }
            }

            writer.WriteEndElement();
        }