jellyfin/MediaBrowser.Dlna/PlayTo/PlaylistItem.cs

112 lines
3.7 KiB
C#
Raw Normal View History

2014-02-27 02:44:00 +00:00
using MediaBrowser.Controller.Entities;
using MediaBrowser.Dlna.PlayTo.Configuration;
using System;
2014-02-26 21:31:47 +00:00
namespace MediaBrowser.Dlna.PlayTo
{
public class PlaylistItem
{
public string ItemId { get; set; }
public bool Transcode { get; set; }
public bool IsVideo { get; set; }
public bool IsAudio { get; set; }
public string FileFormat { get; set; }
2014-03-12 20:01:19 +00:00
public string MimeType { get; set; }
2014-02-26 21:31:47 +00:00
public int PlayState { get; set; }
public string StreamUrl { get; set; }
public string DlnaHeaders { get; set; }
public string Didl { get; set; }
public long StartPositionTicks { get; set; }
2014-02-27 02:44:00 +00:00
public static PlaylistItem GetBasicConfig(BaseItem item, TranscodeSettings[] profileTranscodings)
{
var playlistItem = new PlaylistItem();
playlistItem.ItemId = item.Id.ToString();
if (string.Equals(item.MediaType, Model.Entities.MediaType.Video, StringComparison.OrdinalIgnoreCase))
{
playlistItem.IsVideo = true;
}
else
{
playlistItem.IsAudio = true;
}
var path = item.Path.ToLower();
//Check the DlnaProfile associated with the renderer
if (profileTranscodings != null)
{
foreach (TranscodeSettings transcodeSetting in profileTranscodings)
{
if (string.IsNullOrWhiteSpace(transcodeSetting.Container))
continue;
2014-03-12 20:01:19 +00:00
if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.TargetContainer))
2014-02-27 02:44:00 +00:00
{
playlistItem.Transcode = true;
playlistItem.FileFormat = transcodeSetting.TargetContainer;
2014-03-12 20:01:19 +00:00
if (string.IsNullOrWhiteSpace(transcodeSetting.MimeType))
playlistItem.MimeType = transcodeSetting.MimeType;
return playlistItem;
}
if (path.EndsWith(transcodeSetting.Container) && !string.IsNullOrWhiteSpace(transcodeSetting.MimeType))
{
playlistItem.Transcode = false;
playlistItem.FileFormat = transcodeSetting.Container;
playlistItem.MimeType = transcodeSetting.MimeType;
2014-02-27 02:44:00 +00:00
return playlistItem;
}
}
}
if (playlistItem.IsVideo)
{
//Check to see if we support serving the format statically
foreach (string supported in PlayToConfiguration.SupportedStaticFormats)
{
if (path.EndsWith(supported))
{
playlistItem.Transcode = false;
playlistItem.FileFormat = supported;
return playlistItem;
}
}
playlistItem.Transcode = true;
playlistItem.FileFormat = "ts";
}
else
{
foreach (string supported in PlayToConfiguration.SupportedStaticFormats)
{
if (path.EndsWith(supported))
{
playlistItem.Transcode = false;
playlistItem.FileFormat = supported;
return playlistItem;
}
}
playlistItem.Transcode = true;
playlistItem.FileFormat = "mp3";
}
return playlistItem;
}
2014-02-26 21:31:47 +00:00
}
}