コード例 #1
0
        public void Initialise()
        {
            var rs = ServiceRegistration.Get <IResourceServer>();

            var ipaddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0];

            var baseUrl = "http://" + GetLocalIp() + ":" + rs.PortIPv4;
            var url     = baseUrl + DlnaResourceAccessUtils.GetResourceUrl(Item.MediaItemId);

            ProtocolInfo = DlnaProtocolInfoFactory.GetProfileInfo(Item).ToString();

            if (Item.Aspects.ContainsKey(VideoAspect.ASPECT_ID))
            {
                // Load Video Specific items
                var videoAspect = Item.Aspects[VideoAspect.ASPECT_ID];

                Resolution = videoAspect.GetAttributeValue(VideoAspect.ATTR_WIDTH)
                             + "x"
                             + videoAspect.GetAttributeValue(VideoAspect.ATTR_HEIGHT);

                var vidBitRate = Convert.ToInt32(videoAspect.GetAttributeValue(VideoAspect.ATTR_VIDEOBITRATE));
                var audBitRate = Convert.ToInt32(videoAspect.GetAttributeValue(VideoAspect.ATTR_AUDIOBITRATE));
                BitRate = (uint)(vidBitRate + audBitRate);
            }

            Uri = url;
        }
コード例 #2
0
        public override bool HandleRequest(IOwinContext context, DlnaMediaItem item)
        {
            bool bHandled = false;

            if (!string.IsNullOrEmpty(context.Request.Headers["getCaptionInfo.sec"]))
            {
                if (context.Request.Headers["getCaptionInfo.sec"] == "1")
                {
                    if (context.Request.Uri.ToString().ToUpperInvariant().Contains("LOCALHOST"))
                    {
                        bHandled = true;
                    }
                    string mime = "";
                    string type = "";
                    context.Response.Headers["CaptionInfo.sec"] = DlnaResourceAccessUtils.GetSubtitleBaseURL(item.MediaItemId, item.Client, out mime, out type);
                }
            }

            if (!string.IsNullOrEmpty(context.Request.Headers["getMediaInfo.sec"]))
            {
                if (context.Request.Headers["getMediaInfo.sec"] == "1")
                {
                    //TODO: How to handle multiple video streams?
                    if (item.Metadata.Duration.HasValue)
                    {
                        context.Response.Headers["MediaInfo.sec"] = $"SEC_Duration={Convert.ToInt32(item.Metadata.Duration.Value * 1000.0)};";
                    }
                }
            }
            return(bHandled);
        }
コード例 #3
0
        public void Initialise(MediaItem item)
        {
            DlnaMediaItem dlnaItem = Client.GetDlnaItem(item);
            var           url      = DlnaResourceAccessUtils.GetBaseResourceURL() + DlnaResourceAccessUtils.GetResourceUrl(item.MediaItemId.ToString() + (dlnaItem.IsSegmented ? "/playlist.m3u8" : ""), Client.ClientId);

            BitRate               = null;
            SampleFrequency       = null;
            NumberOfAudioChannels = null;
            Size          = null;
            BitsPerSample = null;
            ColorDepth    = null;
            Duration      = null;
            var dlnaProtocolInfo = DlnaProtocolInfoFactory.GetProfileInfo(dlnaItem, Client.Profile.ProtocolInfo);

            if (dlnaProtocolInfo != null)
            {
                ProtocolInfo = dlnaProtocolInfo.ToString();
            }
            if (dlnaItem.Metadata == null)
            {
                throw new DlnaAspectMissingException("No DLNA metadata found for MediaItem " + dlnaItem.MediaItemId);
            }
            if (dlnaItem.Metadata.Size > 0)
            {
                Size = Convert.ToUInt64(dlnaItem.Metadata.Size);
            }
            if (dlnaItem.IsImage == false)
            {
                if (dlnaItem.Metadata.Bitrate > 0)
                {
                    BitRate = Convert.ToUInt32((double)dlnaItem.Metadata.Bitrate / 8.0);
                }
                if (dlnaItem.Audio != null && dlnaItem.Audio.Count > 0)
                {
                    if (dlnaItem.Audio[0].Frequency > 0)
                    {
                        SampleFrequency = Convert.ToUInt32(dlnaItem.Audio[0].Frequency);
                    }
                    if (dlnaItem.Audio[0].Channels > 0)
                    {
                        NumberOfAudioChannels = Convert.ToUInt32(dlnaItem.Audio[0].Channels);
                    }
                }
                if (dlnaItem.Metadata.Duration > 0)
                {
                    Duration = TimeSpan.FromSeconds(dlnaItem.Metadata.Duration.Value).ToString(@"hh\:mm\:ss\.fff");
                }
            }
            if (dlnaItem.IsVideo == true)
            {
                Resolution = dlnaItem.Video.Width + "x" + dlnaItem.Video.Height;
            }
            else if (dlnaItem.IsImage == true)
            {
                Resolution = dlnaItem.Image.Width + "x" + dlnaItem.Image.Height;
            }

            Uri = url;
        }
コード例 #4
0
        public void Initialise(string fanartType = null)
        {
            Uri = DlnaResourceAccessUtils.GetThumbnailBaseURL(MediaItemId, Client, fanartType ?? _defaultFanArtMediaType);

            string profileId = "JPEG_TN";
            string mimeType  = "image/jpeg";

            DlnaProfiles.TryFindCompatibleProfile(Client, DlnaProfiles.ResolveImageProfile(ImageContainer.Jpeg, Client.Profile.Settings.Thumbnails.MaxWidth, Client.Profile.Settings.Thumbnails.MaxHeight),
                                                  ref profileId, ref mimeType);

            ProfileId = profileId;
            MimeType  = mimeType;
        }
コード例 #5
0
        public void Initialise(string channelName, bool isTv)
        {
            Uri = DlnaResourceAccessUtils.GetChannelLogoBaseURL(channelName, Client, isTv);

            string profileId = "JPEG_TN";
            string mimeType  = "image/jpeg";

            DlnaProfiles.TryFindCompatibleProfile(Client, DlnaProfiles.ResolveImageProfile(ImageContainer.Jpeg, Client.Profile.Settings.Thumbnails.MaxWidth, Client.Profile.Settings.Thumbnails.MaxHeight),
                                                  ref profileId, ref mimeType);

            ProfileId = profileId;
            MimeType  = mimeType;
        }
コード例 #6
0
        public void Initialise()
        {
            DlnaMediaItem dlnaItem = Client.GetDlnaItem(MediaItemId);

            if (DlnaResourceAccessUtils.IsSoftCodedSubtitleAvailable(dlnaItem, Client) == true)
            {
                string mime = null;
                string type = null;
                Uri          = DlnaResourceAccessUtils.GetSubtitleBaseURL(MediaItemId, Client, out mime, out type);
                MimeType     = mime;
                SubtitleType = type;
            }
        }
コード例 #7
0
 public MediaLibraryAlbumArt(MediaItem item, EndPointSettings client)
 {
     MediaItemId             = item.MediaItemId;
     Client                  = client;
     _defaultFanArtMediaType = DlnaResourceAccessUtils.GetFanArtMediaType(item);
 }
コード例 #8
0
 private string GetIconUrl(int size, string type)
 {
     return(string.Format("{0}{1}/{2}?aspect=ICON&size={3}&type={4}", DlnaResourceAccessUtils.GetBaseResourceURL(), DlnaResourceAccessUtils.RESOURCE_ACCESS_PATH, Guid.Empty, size, type));
 }