jellyfin/MediaBrowser.Model/Dto/MediaSourceInfo.cs

128 lines
3.5 KiB
C#
Raw Normal View History

2014-05-12 18:04:25 +00:00
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.MediaInfo;
2014-05-01 03:24:55 +00:00
using System.Collections.Generic;
2014-05-12 18:04:25 +00:00
using System.Runtime.Serialization;
2014-03-19 04:59:45 +00:00
namespace MediaBrowser.Model.Dto
{
2014-03-22 16:16:43 +00:00
public class MediaSourceInfo
2014-03-19 04:59:45 +00:00
{
public MediaProtocol Protocol { get; set; }
public string Id { get; set; }
2014-03-19 04:59:45 +00:00
public string Path { get; set; }
2014-06-03 02:01:30 +00:00
public MediaSourceType Type { get; set; }
2014-04-01 22:23:07 +00:00
public string Container { get; set; }
2014-04-18 05:03:01 +00:00
public long? Size { get; set; }
2014-04-01 22:23:07 +00:00
2014-03-19 04:59:45 +00:00
public string Name { get; set; }
2014-05-09 23:08:08 +00:00
2014-03-19 04:59:45 +00:00
public long? RunTimeTicks { get; set; }
2014-10-25 18:32:58 +00:00
public bool ReadAtNativeFramerate { get; set; }
2015-03-02 18:48:21 +00:00
public bool SupportsTranscoding { get; set; }
2015-03-17 03:51:35 +00:00
public bool SupportsDirectStream { get; set; }
2014-03-19 04:59:45 +00:00
public VideoType? VideoType { get; set; }
public IsoType? IsoType { get; set; }
public Video3DFormat? Video3DFormat { get; set; }
2014-05-09 23:08:08 +00:00
2014-03-19 04:59:45 +00:00
public List<MediaStream> MediaStreams { get; set; }
2014-06-12 02:38:40 +00:00
public List<string> PlayableStreamFileNames { get; set; }
2014-04-06 17:53:23 +00:00
2014-04-18 05:03:01 +00:00
public List<string> Formats { get; set; }
2014-05-09 23:08:08 +00:00
2014-04-06 17:53:23 +00:00
public int? Bitrate { get; set; }
2014-04-18 05:03:01 +00:00
2014-04-25 02:45:06 +00:00
public TransportStreamTimestamp? Timestamp { get; set; }
2014-06-02 19:32:41 +00:00
public Dictionary<string, string> RequiredHttpHeaders { get; set; }
2014-05-09 23:08:08 +00:00
2014-04-18 05:03:01 +00:00
public MediaSourceInfo()
{
Formats = new List<string>();
MediaStreams = new List<MediaStream>();
2014-06-02 19:32:41 +00:00
RequiredHttpHeaders = new Dictionary<string, string>();
2014-06-12 02:38:40 +00:00
PlayableStreamFileNames = new List<string>();
2015-03-02 18:48:21 +00:00
SupportsTranscoding = true;
2015-03-17 03:51:35 +00:00
SupportsDirectStream = true;
2014-04-18 05:03:01 +00:00
}
2014-05-09 23:08:08 +00:00
2014-05-12 18:04:25 +00:00
public int? DefaultAudioStreamIndex { get; set; }
public int? DefaultSubtitleStreamIndex { get; set; }
2014-05-09 23:08:08 +00:00
[IgnoreDataMember]
public MediaStream DefaultAudioStream
{
2015-03-23 17:19:21 +00:00
get { return GetDefaultAudioStream(DefaultAudioStreamIndex); }
}
2014-05-12 18:04:25 +00:00
2015-03-23 17:19:21 +00:00
public MediaStream GetDefaultAudioStream(int? defaultIndex)
{
if (defaultIndex.HasValue)
{
var val = defaultIndex.Value;
2014-05-12 18:04:25 +00:00
2014-05-09 23:08:08 +00:00
foreach (MediaStream i in MediaStreams)
{
2015-03-23 17:19:21 +00:00
if (i.Type == MediaStreamType.Audio && i.Index == val)
2014-05-09 23:08:08 +00:00
{
return i;
}
}
2015-03-23 17:19:21 +00:00
}
2014-05-09 23:08:08 +00:00
2015-03-23 17:19:21 +00:00
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio && i.IsDefault)
2014-05-09 23:08:08 +00:00
{
2015-03-23 17:19:21 +00:00
return i;
2014-05-09 23:08:08 +00:00
}
2015-03-23 17:19:21 +00:00
}
2014-05-09 23:08:08 +00:00
2015-03-23 17:19:21 +00:00
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio)
{
return i;
}
2014-05-09 23:08:08 +00:00
}
2015-03-23 17:19:21 +00:00
return null;
2014-05-09 23:08:08 +00:00
}
[IgnoreDataMember]
public MediaStream VideoStream
{
get
{
foreach (MediaStream i in MediaStreams)
{
if (i.Type == MediaStreamType.Video && StringHelper.IndexOfIgnoreCase((i.Codec ?? string.Empty), "jpeg") == -1)
2014-05-09 23:08:08 +00:00
{
return i;
}
}
return null;
}
}
public MediaStream GetMediaStream(MediaStreamType type, int index)
{
foreach (MediaStream i in MediaStreams)
{
if (i.Type == type && i.Index == index)
{
return i;
}
}
return null;
}
2014-03-19 04:59:45 +00:00
}
}