blob: 75ccdcf276ed77ec6082c752023f0e0ce51582fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
#nullable disable
#pragma warning disable CS1591
using System.Collections.Generic;
using System.ComponentModel;
using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Session;
namespace MediaBrowser.Model.Dto
{
public class MediaSourceInfo
{
public MediaSourceInfo()
{
Formats = [];
MediaStreams = [];
MediaAttachments = [];
RequiredHttpHeaders = [];
SupportsTranscoding = true;
SupportsDirectStream = true;
SupportsDirectPlay = true;
SupportsProbing = true;
UseMostCompatibleTranscodingProfile = false;
DefaultAudioIndexSource = AudioIndexSource.None;
}
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>
/// Gets or sets a value indicating whether the media is remote.
/// 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; }
[DefaultValue(false)]
public bool UseMostCompatibleTranscodingProfile { 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 IReadOnlyList<MediaStream> MediaStreams { get; set; }
public IReadOnlyList<MediaAttachment> MediaAttachments { get; set; }
public string[] Formats { get; set; }
public int? Bitrate { get; set; }
public int? FallbackMaxStreamingBitrate { get; set; }
public TransportStreamTimestamp? Timestamp { get; set; }
public Dictionary<string, string> RequiredHttpHeaders { get; set; }
public string TranscodingUrl { get; set; }
public MediaStreamProtocol TranscodingSubProtocol { get; set; }
public string TranscodingContainer { get; set; }
public int? AnalyzeDurationMs { get; set; }
[JsonIgnore]
public TranscodeReason TranscodeReasons { get; set; }
[JsonIgnore]
public AudioIndexSource DefaultAudioIndexSource { get; set; }
public int? DefaultAudioStreamIndex { get; set; }
public int? DefaultSubtitleStreamIndex { get; set; }
public bool HasSegments { get; set; }
[JsonIgnore]
public MediaStream VideoStream
{
get
{
foreach (var i in MediaStreams)
{
if (i.Type == MediaStreamType.Video)
{
return i;
}
}
return null;
}
}
public void InferTotalBitrate(bool force = false)
{
if (MediaStreams is 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;
}
}
public MediaStream GetDefaultAudioStream(int? defaultIndex)
{
if (defaultIndex.HasValue && defaultIndex != -1)
{
var val = defaultIndex.Value;
foreach (var i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio && i.Index == val)
{
return i;
}
}
}
foreach (var i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio && i.IsDefault)
{
return i;
}
}
foreach (var i in MediaStreams)
{
if (i.Type == MediaStreamType.Audio)
{
return i;
}
}
return null;
}
public MediaStream GetMediaStream(MediaStreamType type, int index)
{
foreach (var 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 (var i in MediaStreams)
{
numStreams++;
if (i.Type == type)
{
numMatches++;
}
}
if (numStreams == 0)
{
return null;
}
return numMatches;
}
public bool? IsSecondaryAudio(MediaStream stream)
{
if (stream.IsExternal)
{
return false;
}
// Look for the first audio track
foreach (var currentStream in MediaStreams)
{
if (currentStream.Type == MediaStreamType.Audio && !currentStream.IsExternal)
{
return currentStream.Index != stream.Index;
}
}
return null;
}
}
}
|