1- #nullable disable
2- #pragma warning disable CS1591
3-
41using System ;
52using System . Collections . Generic ;
63using System . Globalization ;
107
118namespace Jellyfin . Plugin . Dlna . Model ;
129
10+ /// <summary>
11+ /// Defines the <see cref="ContentFeatureBuilder" />.
12+ /// </summary>
1313public static class ContentFeatureBuilder
1414{
15+ /// <summary>
16+ /// Gets the image header.
17+ /// </summary>
18+ /// <param name="profile">The <see cref="DlnaDeviceProfile"/>.</param>
19+ /// <param name="container">The container.</param>
20+ /// <param name="width">The width.</param>
21+ /// <param name="height">The height.</param>
22+ /// <param name="isDirectStream">Value indicating wether the stream is direct.</param>
23+ /// <param name="orgPn">The orgPn.</param>
1524 public static string BuildImageHeader (
1625 DlnaDeviceProfile profile ,
1726 string container ,
1827 int ? width ,
1928 int ? height ,
2029 bool isDirectStream ,
21- string orgPn = null )
30+ string ? orgPn = null )
2231 {
23- string orgOp = ";DLNA.ORG_OP=" + DlnaMaps . GetImageOrgOpValue ( ) ;
32+ var orgOp = ";DLNA.ORG_OP=" + DlnaMaps . GetImageOrgOpValue ( ) ;
2433
2534 // 0 = native, 1 = transcoded
2635 var orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1" ;
@@ -29,14 +38,14 @@ public static string BuildImageHeader(
2938 DlnaFlags . InteractiveTransferMode |
3039 DlnaFlags . DlnaV15 ;
3140
32- string dlnaflags = string . Format (
41+ var dlnaflags = string . Format (
3342 CultureInfo . InvariantCulture ,
3443 ";DLNA.ORG_FLAGS={0}" ,
3544 DlnaMaps . FlagsToString ( flagValue ) ) ;
3645
3746 if ( string . IsNullOrEmpty ( orgPn ) )
3847 {
39- ResponseProfile mediaProfile = profile . GetImageMediaProfile (
48+ ResponseProfile ? mediaProfile = profile . GetImageMediaProfile (
4049 container ,
4150 width ,
4251 height ) ;
@@ -57,10 +66,23 @@ public static string BuildImageHeader(
5766 return "DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags ;
5867 }
5968
69+ /// <summary>
70+ /// Gets the audio header.
71+ /// </summary>
72+ /// <param name="profile">The <see cref="DlnaDeviceProfile"/>.</param>
73+ /// <param name="container">The container.</param>
74+ /// <param name="audioCodec">The codec.</param>
75+ /// <param name="audioBitrate">The bitrate.</param>
76+ /// <param name="audioSampleRate">The sample rate.</param>
77+ /// <param name="audioChannels">The channel count.</param>
78+ /// <param name="audioBitDepth">The bit depth.</param>
79+ /// <param name="isDirectStream">Value indicating wether the stream is direct.</param>
80+ /// <param name="runtimeTicks">The runtime ticks.</param>
81+ /// <param name="transcodeSeekInfo">The <see cref="TranscodeSeekInfo"/>.</param>
6082 public static string BuildAudioHeader (
6183 DlnaDeviceProfile profile ,
62- string container ,
63- string audioCodec ,
84+ string ? container ,
85+ string ? audioCodec ,
6486 int ? audioBitrate ,
6587 int ? audioSampleRate ,
6688 int ? audioChannels ,
@@ -70,10 +92,10 @@ public static string BuildAudioHeader(
7092 TranscodeSeekInfo transcodeSeekInfo )
7193 {
7294 // first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none
73- string orgOp = ";DLNA.ORG_OP=" + DlnaMaps . GetOrgOpValue ( runtimeTicks > 0 , isDirectStream , transcodeSeekInfo ) ;
95+ var orgOp = ";DLNA.ORG_OP=" + DlnaMaps . GetOrgOpValue ( runtimeTicks > 0 , isDirectStream , transcodeSeekInfo ) ;
7496
7597 // 0 = native, 1 = transcoded
76- string orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1" ;
98+ var orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1" ;
7799
78100 var flagValue = DlnaFlags . StreamingTransferMode |
79101 DlnaFlags . BackgroundTransferMode |
@@ -89,20 +111,20 @@ public static string BuildAudioHeader(
89111 // flagValue = flagValue | DlnaFlags.TimeBasedSeek;
90112 // }
91113
92- string dlnaflags = string . Format (
114+ var dlnaflags = string . Format (
93115 CultureInfo . InvariantCulture ,
94116 ";DLNA.ORG_FLAGS={0}" ,
95117 DlnaMaps . FlagsToString ( flagValue ) ) ;
96118
97- ResponseProfile mediaProfile = profile . GetAudioMediaProfile (
119+ ResponseProfile ? mediaProfile = profile . GetAudioMediaProfile (
98120 container ,
99121 audioCodec ,
100122 audioChannels ,
101123 audioBitrate ,
102124 audioSampleRate ,
103125 audioBitDepth ) ;
104126
105- string orgPn = mediaProfile ? . OrgPn ;
127+ var orgPn = mediaProfile ? . OrgPn ;
106128
107129 if ( string . IsNullOrEmpty ( orgPn ) )
108130 {
@@ -117,19 +139,46 @@ public static string BuildAudioHeader(
117139 return "DLNA.ORG_PN=" + orgPn + orgOp + orgCi + dlnaflags ;
118140 }
119141
142+ /// <summary>
143+ /// Gets the video header.
144+ /// </summary>
145+ /// <param name="profile">The <see cref="DlnaDeviceProfile"/>.</param>
146+ /// <param name="container">The container.</param>
147+ /// <param name="videoCodec">The video codec.</param>
148+ /// <param name="audioCodec">The audio codec.</param>
149+ /// <param name="width">The width.</param>
150+ /// <param name="height">The height.</param>
151+ /// <param name="bitDepth">The bit depth.</param>
152+ /// <param name="videoBitrate">The video bitrate.</param>
153+ /// <param name="timestamp">The <see cref="TransportStreamTimestamp"/>.</param>
154+ /// <param name="isDirectStream">Value indicating wether the stream is direct.</param>
155+ /// <param name="runtimeTicks">The runtime ticks.</param>
156+ /// <param name="videoProfile">The video profile.</param>
157+ /// <param name="videoRangeType">The <see cref="VideoRangeType"/>.</param>
158+ /// <param name="videoLevel">The video level.</param>
159+ /// <param name="videoFramerate">The video framerate.</param>
160+ /// <param name="packetLength">The packet length.</param>
161+ /// <param name="transcodeSeekInfo">The <see cref="TranscodeSeekInfo"/>.</param>
162+ /// <param name="isAnamorphic">Value indicating wether the stream is anamorphic.</param>
163+ /// <param name="isInterlaced">Value indicating wether the stream is interlaced.</param>
164+ /// <param name="refFrames">The reference frames.</param>
165+ /// <param name="numVideoStreams">The number of video streams.</param>
166+ /// <param name="numAudioStreams">The number of audio streams.</param>
167+ /// <param name="videoCodecTag">The video codec tag.</param>
168+ /// <param name="isAvc">Value indicating wether the stream is AVC.</param>
120169 public static IEnumerable < string > BuildVideoHeader (
121170 DlnaDeviceProfile profile ,
122- string container ,
123- string videoCodec ,
124- string audioCodec ,
171+ string ? container ,
172+ string ? videoCodec ,
173+ string ? audioCodec ,
125174 int ? width ,
126175 int ? height ,
127176 int ? bitDepth ,
128177 int ? videoBitrate ,
129178 TransportStreamTimestamp timestamp ,
130179 bool isDirectStream ,
131180 long ? runtimeTicks ,
132- string videoProfile ,
181+ string ? videoProfile ,
133182 VideoRangeType videoRangeType ,
134183 double ? videoLevel ,
135184 float ? videoFramerate ,
@@ -140,14 +189,14 @@ public static IEnumerable<string> BuildVideoHeader(
140189 int ? refFrames ,
141190 int ? numVideoStreams ,
142191 int ? numAudioStreams ,
143- string videoCodecTag ,
192+ string ? videoCodecTag ,
144193 bool ? isAvc )
145194 {
146195 // first bit means Time based seek supported, second byte range seek supported (not sure about the order now), so 01 = only byte seek, 10 = time based, 11 = both, 00 = none
147- string orgOp = ";DLNA.ORG_OP=" + DlnaMaps . GetOrgOpValue ( runtimeTicks > 0 , isDirectStream , transcodeSeekInfo ) ;
196+ var orgOp = ";DLNA.ORG_OP=" + DlnaMaps . GetOrgOpValue ( runtimeTicks > 0 , isDirectStream , transcodeSeekInfo ) ;
148197
149198 // 0 = native, 1 = transcoded
150- string orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1" ;
199+ var orgCi = isDirectStream ? ";DLNA.ORG_CI=0" : ";DLNA.ORG_CI=1" ;
151200
152201 var flagValue = DlnaFlags . StreamingTransferMode |
153202 DlnaFlags . BackgroundTransferMode |
@@ -165,12 +214,12 @@ public static IEnumerable<string> BuildVideoHeader(
165214 // flagValue = flagValue | DlnaFlags.TimeBasedSeek;
166215 // }
167216
168- string dlnaflags = string . Format (
217+ var dlnaflags = string . Format (
169218 CultureInfo . InvariantCulture ,
170219 ";DLNA.ORG_FLAGS={0}" ,
171220 DlnaMaps . FlagsToString ( flagValue ) ) ;
172221
173- ResponseProfile mediaProfile = profile . GetVideoMediaProfile (
222+ var mediaProfile = profile . GetVideoMediaProfile (
174223 container ,
175224 audioCodec ,
176225 videoCodec ,
@@ -234,14 +283,14 @@ public static IEnumerable<string> BuildVideoHeader(
234283 return contentFeatureList ;
235284 }
236285
237- private static string GetImageOrgPnValue ( string container , int ? width , int ? height )
286+ private static string ? GetImageOrgPnValue ( string container , int ? width , int ? height )
238287 {
239288 MediaFormatProfile ? format = MediaFormatProfileResolver . ResolveImageFormat ( container , width , height ) ;
240289
241290 return format . HasValue ? format . Value . ToString ( ) : null ;
242291 }
243292
244- private static string GetAudioOrgPnValue ( string container , int ? audioBitrate , int ? audioSampleRate , int ? audioChannels )
293+ private static string ? GetAudioOrgPnValue ( string ? container , int ? audioBitrate , int ? audioSampleRate , int ? audioChannels )
245294 {
246295 MediaFormatProfile ? format = MediaFormatProfileResolver . ResolveAudioFormat (
247296 container ,
@@ -252,8 +301,8 @@ private static string GetAudioOrgPnValue(string container, int? audioBitrate, in
252301 return format . HasValue ? format . Value . ToString ( ) : null ;
253302 }
254303
255- private static MediaFormatProfile [ ] GetVideoOrgPnValue ( string container , string videoCodec , string audioCodec , int ? width , int ? height , TransportStreamTimestamp timestamp )
304+ private static MediaFormatProfile [ ] GetVideoOrgPnValue ( string ? container , string ? videoCodec , string ? audioCodec , int ? width , int ? height , TransportStreamTimestamp timestamp )
256305 {
257306 return MediaFormatProfileResolver . ResolveVideoFormat ( container , videoCodec , audioCodec , width , height , timestamp ) ;
258307 }
259- }
308+ }
0 commit comments