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