aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Dto/MediaSourceInfo.cs
diff options
context:
space:
mode:
authorAndrew Rabert <ar@nullsum.net>2018-12-27 18:27:57 -0500
committerAndrew Rabert <ar@nullsum.net>2018-12-27 18:27:57 -0500
commita86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 (patch)
treea74f6ea4a8abfa1664a605d31d48bc38245ccf58 /MediaBrowser.Model/Dto/MediaSourceInfo.cs
parent9bac3ac616b01f67db98381feb09d34ebe821f9a (diff)
Add GPL modules
Diffstat (limited to 'MediaBrowser.Model/Dto/MediaSourceInfo.cs')
-rw-r--r--MediaBrowser.Model/Dto/MediaSourceInfo.cs236
1 files changed, 236 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs
new file mode 100644
index 000000000..d1d068fb6
--- /dev/null
+++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs
@@ -0,0 +1,236 @@
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Extensions;
+using MediaBrowser.Model.MediaInfo;
+using System.Collections.Generic;
+using MediaBrowser.Model.Serialization;
+using MediaBrowser.Model.Session;
+using System;
+
+namespace MediaBrowser.Model.Dto
+{
+ public class MediaSourceInfo
+ {
+ public MediaProtocol Protocol { get; set; }
+ public string Id { get; set; }
+
+ public string Path { get; set; }
+
+ public string EncoderPath { get; set; }
+ public MediaProtocol? EncoderProtocol { get; set; }
+
+ public MediaSourceType Type { get; set; }
+
+ public string Container { get; set; }
+ public long? Size { get; set; }
+
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Differentiate internet url vs local network
+ /// </summary>
+ public bool IsRemote { get; set; }
+
+ public string ETag { get; set; }
+ public long? RunTimeTicks { get; set; }
+ public bool ReadAtNativeFramerate { get; set; }
+ public bool IgnoreDts { get; set; }
+ public bool IgnoreIndex { get; set; }
+ public bool GenPtsInput { get; set; }
+ public bool SupportsTranscoding { get; set; }
+ public bool SupportsDirectStream { get; set; }
+ public bool SupportsDirectPlay { get; set; }
+ public bool IsInfiniteStream { get; set; }
+ public bool RequiresOpening { get; set; }
+ public string OpenToken { get; set; }
+ public bool RequiresClosing { get; set; }
+ public string LiveStreamId { get; set; }
+ public int? BufferMs { get; set; }
+
+ public bool RequiresLooping { get; set; }
+
+ public bool SupportsProbing { get; set; }
+
+ public VideoType? VideoType { get; set; }
+
+ public IsoType? IsoType { get; set; }
+
+ public Video3DFormat? Video3DFormat { get; set; }
+
+ public List<MediaStream> MediaStreams { get; set; }
+
+ public string[] Formats { get; set; }
+
+ public int? Bitrate { get; set; }
+
+ public TransportStreamTimestamp? Timestamp { get; set; }
+ public Dictionary<string, string> RequiredHttpHeaders { get; set; }
+
+ public string TranscodingUrl { get; set; }
+ public string TranscodingSubProtocol { get; set; }
+ public string TranscodingContainer { get; set; }
+
+ public int? AnalyzeDurationMs { get; set; }
+
+ public MediaSourceInfo()
+ {
+ Formats = new string[] { };
+ MediaStreams = new List<MediaStream>();
+ RequiredHttpHeaders = new Dictionary<string, string>();
+ SupportsTranscoding = true;
+ SupportsDirectStream = true;
+ SupportsDirectPlay = true;
+ SupportsProbing = true;
+ }
+
+ public void InferTotalBitrate(bool force = false)
+ {
+ if (MediaStreams == null)
+ {
+ return;
+ }
+
+ if (!force && Bitrate.HasValue)
+ {
+ return;
+ }
+
+ var bitrate = 0;
+ foreach (var stream in MediaStreams)
+ {
+ if (!stream.IsExternal)
+ {
+ bitrate += stream.BitRate ?? 0;
+ }
+ }
+
+ if (bitrate > 0)
+ {
+ Bitrate = bitrate;
+ }
+ }
+
+ [IgnoreDataMember]
+ public TranscodeReason[] TranscodeReasons { get; set; }
+
+ public int? DefaultAudioStreamIndex { get; set; }
+ public int? DefaultSubtitleStreamIndex { get; set; }
+
+ [IgnoreDataMember]
+ public MediaStream DefaultAudioStream
+ {
+ get { return GetDefaultAudioStream(DefaultAudioStreamIndex); }
+ }
+
+ public MediaStream GetDefaultAudioStream(int? defaultIndex)
+ {
+ if (defaultIndex.HasValue)
+ {
+ var val = defaultIndex.Value;
+
+ foreach (MediaStream i in MediaStreams)
+ {
+ if (i.Type == MediaStreamType.Audio && i.Index == val)
+ {
+ return i;
+ }
+ }
+ }
+
+ foreach (MediaStream i in MediaStreams)
+ {
+ if (i.Type == MediaStreamType.Audio && i.IsDefault)
+ {
+ return i;
+ }
+ }
+
+ foreach (MediaStream i in MediaStreams)
+ {
+ if (i.Type == MediaStreamType.Audio)
+ {
+ return i;
+ }
+ }
+
+ return null;
+ }
+
+ [IgnoreDataMember]
+ public MediaStream VideoStream
+ {
+ get
+ {
+ foreach (MediaStream i in MediaStreams)
+ {
+ if (i.Type == MediaStreamType.Video)
+ {
+ 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;
+ }
+
+ public int? GetStreamCount(MediaStreamType type)
+ {
+ int numMatches = 0;
+ int numStreams = 0;
+
+ foreach (MediaStream i in MediaStreams)
+ {
+ numStreams++;
+ if (i.Type == type)
+ {
+ numMatches++;
+ }
+ }
+
+ if (numStreams == 0)
+ {
+ return null;
+ }
+
+ return numMatches;
+ }
+
+ public bool? IsSecondaryAudio(MediaStream stream)
+ {
+ // Look for the first audio track marked as default
+ foreach (MediaStream currentStream in MediaStreams)
+ {
+ if (currentStream.Type == MediaStreamType.Audio && currentStream.IsDefault)
+ {
+ if (currentStream.Index != stream.Index)
+ {
+ return true;
+ }
+ }
+ }
+
+ // Look for the first audio track
+ foreach (MediaStream currentStream in MediaStreams)
+ {
+ if (currentStream.Type == MediaStreamType.Audio)
+ {
+ return currentStream.Index != stream.Index;
+ }
+ }
+
+ return null;
+ }
+ }
+}