2017-01-21 20:27:07 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
2014-06-01 04:11:04 +00:00
|
|
|
|
using MediaBrowser.Model.Extensions;
|
2014-04-25 02:00:19 +00:00
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
2014-05-01 03:24:55 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-01-21 20:27:07 +00:00
|
|
|
|
using System.Linq;
|
2016-10-22 02:08:34 +00:00
|
|
|
|
using MediaBrowser.Model.Serialization;
|
2017-06-24 18:33:19 +00:00
|
|
|
|
using MediaBrowser.Model.Session;
|
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
|
|
|
|
{
|
2014-06-17 01:56:23 +00:00
|
|
|
|
public MediaProtocol Protocol { get; set; }
|
2014-03-22 03:35:03 +00:00
|
|
|
|
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
|
|
|
|
|
2017-01-20 17:53:48 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Differentiate internet url vs local network
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsRemote { get; set; }
|
|
|
|
|
|
2016-08-13 19:52:58 +00:00
|
|
|
|
public string ETag { get; set; }
|
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; }
|
2017-04-30 20:03:28 +00:00
|
|
|
|
public bool IgnoreDts { get; set; }
|
|
|
|
|
public bool IgnoreIndex { get; set; }
|
2017-05-14 18:56:29 +00:00
|
|
|
|
public bool GenPtsInput { 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; }
|
2015-03-26 16:58:02 +00:00
|
|
|
|
public bool SupportsDirectPlay { get; set; }
|
2016-09-30 02:21:24 +00:00
|
|
|
|
public bool IsInfiniteStream { get; set; }
|
2015-08-02 19:08:55 +00:00
|
|
|
|
public bool RequiresOpening { get; set; }
|
2015-03-29 04:56:39 +00:00
|
|
|
|
public string OpenToken { get; set; }
|
2015-08-02 19:08:55 +00:00
|
|
|
|
public bool RequiresClosing { get; set; }
|
2016-10-20 18:02:42 +00:00
|
|
|
|
public bool SupportsProbing { get; set; }
|
2015-03-29 04:56:39 +00:00
|
|
|
|
public string LiveStreamId { get; set; }
|
|
|
|
|
public int? BufferMs { get; set; }
|
|
|
|
|
|
2017-04-13 18:59:46 +00:00
|
|
|
|
public bool RequiresLooping { 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-04-06 17:53:23 +00:00
|
|
|
|
|
2017-08-19 19:43:35 +00:00
|
|
|
|
public 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; }
|
2015-03-30 16:16:34 +00:00
|
|
|
|
public Dictionary<string, string> RequiredHttpHeaders { get; set; }
|
|
|
|
|
|
2015-03-26 16:58:02 +00:00
|
|
|
|
public string TranscodingUrl { get; set; }
|
|
|
|
|
public string TranscodingSubProtocol { get; set; }
|
|
|
|
|
public string TranscodingContainer { get; set; }
|
2016-09-29 12:55:49 +00:00
|
|
|
|
|
2017-03-05 15:38:36 +00:00
|
|
|
|
public int? AnalyzeDurationMs { get; set; }
|
|
|
|
|
|
2014-04-18 05:03:01 +00:00
|
|
|
|
public MediaSourceInfo()
|
|
|
|
|
{
|
2017-08-19 19:43:35 +00:00
|
|
|
|
Formats = new string[] { };
|
2014-04-18 05:03:01 +00:00
|
|
|
|
MediaStreams = new List<MediaStream>();
|
2014-06-02 19:32:41 +00:00
|
|
|
|
RequiredHttpHeaders = new Dictionary<string, string>();
|
2015-03-02 18:48:21 +00:00
|
|
|
|
SupportsTranscoding = true;
|
2015-03-17 03:51:35 +00:00
|
|
|
|
SupportsDirectStream = true;
|
2015-03-26 16:58:02 +00:00
|
|
|
|
SupportsDirectPlay = true;
|
2016-10-20 18:02:42 +00:00
|
|
|
|
SupportsProbing = true;
|
2014-04-18 05:03:01 +00:00
|
|
|
|
}
|
2014-05-09 23:08:08 +00:00
|
|
|
|
|
2017-01-26 06:26:58 +00:00
|
|
|
|
public void InferTotalBitrate(bool force = false)
|
2017-01-21 20:27:07 +00:00
|
|
|
|
{
|
2017-01-26 06:26:58 +00:00
|
|
|
|
if (MediaStreams == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!force && Bitrate.HasValue)
|
2017-01-21 20:27:07 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var internalStreams = MediaStreams
|
|
|
|
|
.Where(i => !i.IsExternal)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
if (internalStreams.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bitrate = internalStreams
|
|
|
|
|
.Select(m => m.BitRate ?? 0)
|
|
|
|
|
.Sum();
|
|
|
|
|
|
|
|
|
|
if (bitrate > 0)
|
|
|
|
|
{
|
|
|
|
|
Bitrate = bitrate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-24 18:33:19 +00:00
|
|
|
|
[IgnoreDataMember]
|
|
|
|
|
public List<TranscodeReason> TranscodeReasons { get; set; }
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2017-08-02 07:30:17 +00:00
|
|
|
|
if (i.Type == MediaStreamType.Video)
|
2014-05-09 23:08:08 +00:00
|
|
|
|
{
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-18 19:07:28 +00: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 16:16:34 +00: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 19:33:38 +00:00
|
|
|
|
if (numStreams == 0)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return numMatches;
|
2015-03-30 16:16:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool? IsSecondaryAudio(MediaStream stream)
|
|
|
|
|
{
|
2016-04-05 01:23:42 +00:00
|
|
|
|
// Look for the first audio track marked as default
|
|
|
|
|
foreach (MediaStream currentStream in MediaStreams)
|
|
|
|
|
{
|
|
|
|
|
if (currentStream.Type == MediaStreamType.Audio && currentStream.IsDefault)
|
|
|
|
|
{
|
|
|
|
|
return currentStream.Index != stream.Index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Look for the first audio track
|
2015-03-30 16:16:34 +00:00
|
|
|
|
foreach (MediaStream currentStream in MediaStreams)
|
|
|
|
|
{
|
|
|
|
|
if (currentStream.Type == MediaStreamType.Audio)
|
|
|
|
|
{
|
|
|
|
|
return currentStream.Index != stream.Index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2014-03-19 04:59:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|